- floatified player_struct::hitang

This commit is contained in:
Christoph Oelckers 2022-09-12 00:11:44 +02:00
parent a5652655db
commit 50a9ca49f3
8 changed files with 15 additions and 17 deletions

View file

@ -16,7 +16,7 @@ __forceinline constexpr int64_t DivScaleL(int64_t a, int64_t b, int shift) { ret
#include "xs_Float.h"
template<int b = 16>
inline fixed_t FloatToFixed(double f)
constexpr fixed_t FloatToFixed(double f)
{
return int(f * (1 << b));
}

View file

@ -349,7 +349,7 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
if (d < r && cansee(act2->spr.pos.plusZ(-8), act2->sector(), actor->spr.pos.plusZ(-12), actor->sector()))
{
act2->hitang = getangle(act2->spr.pos - actor->spr.pos);
act2->hitang = VecToAngle(act2->spr.pos - actor->spr.pos);
if (actor->spr.picnum == RPG && act2->spr.extra > 0)
act2->attackertype = RPG;
@ -631,13 +631,11 @@ int ifhitbyweapon_d(DDukeActor *actor)
if (attackerflag(actor, SFLAG2_DOUBLEDMGTHRUST))
{
ps[p].__vel.X += actor->hitextra * bcos(actor->hitang, 2);
ps[p].__vel.Y += actor->hitextra * bsin(actor->hitang, 2);
ps[p].vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.25 * VEL_FACTOR;
}
else
{
ps[p].__vel.X += actor->hitextra * bcos(actor->hitang, 1);
ps[p].__vel.Y += actor->hitextra * bsin(actor->hitang, 1);
ps[p].vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.125 * VEL_FACTOR;
}
}
else

View file

@ -300,7 +300,7 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
continue;
}
act2->hitang = getangle(act2->int_pos().X - actor->int_pos().X, act2->int_pos().Y - actor->int_pos().Y);
act2->hitang = VecToAngle(act2->spr.pos - actor->spr.pos);
if (actor->spr.picnum == RPG && act2->spr.extra > 0)
act2->attackertype = RPG;
@ -534,13 +534,11 @@ int ifhitbyweapon_r(DDukeActor *actor)
if (attackerflag(actor, SFLAG2_DOUBLEDMGTHRUST))
{
ps[p].__vel.X += actor->hitextra * bcos(actor->hitang, 2);
ps[p].__vel.Y += actor->hitextra * bsin(actor->hitang, 2);
ps[p].vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.25 * VEL_FACTOR;
}
else
{
ps[p].__vel.X += actor->hitextra * bcos(actor->hitang, 1);
ps[p].__vel.Y += actor->hitextra * bsin(actor->hitang, 1);
ps[p].vel.XY() += actor->hitang.ToVector() * actor->hitextra * 0.125 * VEL_FACTOR;
}
}
else

View file

@ -1270,8 +1270,8 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
else SetGameVarID(lVar2, act->attackertype, sActor, sPlayer);
break;
case ACTOR_HTANG:
if (bSet) act->hitang = lValue;
else SetGameVarID(lVar2, act->hitang, sActor, sPlayer);
if (bSet) act->hitang = mapangle(lValue);
else SetGameVarID(lVar2, act->hitang.Buildang(), sActor, sPlayer);
break;
case ACTOR_HTEXTRA:
if (bSet) act->hitextra = lValue;

View file

@ -1423,7 +1423,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
targ->attackertype = hitpic;
targ->hitextra += proj->spr.extra;
targ->hitang = proj->int_ang();
targ->hitang = proj->spr.angle;
targ->SetHitOwner(Owner);
}

View file

@ -2364,7 +2364,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj)
targ->attackertype = proj->spr.picnum;
targ->hitextra += proj->spr.extra;
if (targ->spr.picnum != COW)
targ->hitang = proj->int_ang();
targ->hitang = proj->spr.angle;
targ->SetHitOwner(proj->GetOwner());
}

View file

@ -46,10 +46,11 @@ public:
uint8_t cgg;
uint8_t spriteextra; // moved here for easier maintenance. This was originally a hacked in field in the sprite structure called 'filler'.
short attackertype, hitang, hitextra, movflag;
short attackertype, hitextra, movflag;
short tempang, dispicnum, basepicnum;
short timetosleep;
vec2_t ovel;
DAngle hitang;
double floorz, ceilingz;
union
{
@ -199,6 +200,7 @@ struct CraneDef
TObjPtr<DDukeActor*> poleactor;
};
constexpr double VEL_FACTOR = FloatToFixed<18>(1);
struct player_struct
{
union

View file

@ -28,7 +28,7 @@ class DukeActor : CoreActor native
native DukeActor ownerActor, hitOwnerActor;
native uint8 cgg;
native uint8 spriteextra; // moved here for easier maintenance. This was originally a hacked in field in the sprite structure called 'filler'.
native int16 /*attackertype,*/ hitang, hitextra, movflag;
native int16 /*attackertype, hitang,*/ hitextra, movflag;
native int16 tempang; /*, dispicnum;*/
native int16 timetosleep;
native double floorz, ceilingz;