- reworked calls to P_SpawnPlayerMissile, P_AimLineAttack and P_LineAttack to use floating point angles.

This commit is contained in:
Christoph Oelckers 2016-03-17 11:38:56 +01:00
parent 39de225fa7
commit f332a098cd
34 changed files with 356 additions and 377 deletions

View file

@ -848,10 +848,10 @@ public:
} }
// more precise, but slower version, being used in a few places // more precise, but slower version, being used in a few places
fixed_t Distance2D(AActor *other, bool absolute = false) double Distance2D(AActor *other, bool absolute = false)
{ {
fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this); fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this);
return xs_RoundToInt(DVector2(X() - otherpos.x, Y() - otherpos.y).Length()); return (DVector2(X() - otherpos.x, Y() - otherpos.y).Length())/FRACUNIT;
} }
// a full 3D version of the above // a full 3D version of the above
@ -951,6 +951,11 @@ public:
} }
} }
double AccuracyFactor()
{
return 1. / (1 << (accuracy * 5 / 100));
}
void ClearInterpolation(); void ClearInterpolation();
void Move(fixed_t dx, fixed_t dy, fixed_t dz) void Move(fixed_t dx, fixed_t dy, fixed_t dz)

View file

@ -192,7 +192,7 @@ void DBot::Dofire (ticcmd_t *cmd)
else else
{ {
//*4 is for atmosphere, the chainsaws sounding and all.. //*4 is for atmosphere, the chainsaws sounding and all..
no_fire = (dist > (MELEERANGE*4)); no_fire = (dist > (FLOAT2FIXED(MELEERANGE)*4));
} }
} }
else if (player->ReadyWeapon->WeaponFlags & WIF_BOT_BFG) else if (player->ReadyWeapon->WeaponFlags & WIF_BOT_BFG)

View file

@ -875,7 +875,7 @@ CCMD(linetarget)
FTranslatedLineTarget t; FTranslatedLineTarget t;
if (CheckCheatmode () || players[consoleplayer].mo == NULL) return; if (CheckCheatmode () || players[consoleplayer].mo == NULL) return;
P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->_f_angle(),MISSILERANGE, &t, 0); P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->Angles.Yaw, MISSILERANGE, &t, 0.);
if (t.linetarget) if (t.linetarget)
{ {
Printf("Target=%s, Health=%d, Spawnhealth=%d\n", Printf("Target=%s, Health=%d, Spawnhealth=%d\n",
@ -892,8 +892,8 @@ CCMD(info)
FTranslatedLineTarget t; FTranslatedLineTarget t;
if (CheckCheatmode () || players[consoleplayer].mo == NULL) return; if (CheckCheatmode () || players[consoleplayer].mo == NULL) return;
P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->_f_angle(),MISSILERANGE, P_AimLineAttack(players[consoleplayer].mo,players[consoleplayer].mo->Angles.Yaw, MISSILERANGE,
&t, 0, ALF_CHECKNONSHOOTABLE|ALF_FORCENOSMART); &t, 0., ALF_CHECKNONSHOOTABLE|ALF_FORCENOSMART);
if (t.linetarget) if (t.linetarget)
{ {
Printf("Target=%s, Health=%d, Spawnhealth=%d\n", Printf("Target=%s, Health=%d, Spawnhealth=%d\n",

View file

@ -292,7 +292,7 @@ struct userinfo_t : TMap<FName,FBaseCVar *>
{ {
~userinfo_t(); ~userinfo_t();
int GetAimDist() const double GetAimDist() const
{ {
if (dmflags2 & DF2_NOAUTOAIM) if (dmflags2 & DF2_NOAUTOAIM)
{ {
@ -302,11 +302,11 @@ struct userinfo_t : TMap<FName,FBaseCVar *>
float aim = *static_cast<FFloatCVar *>(*CheckKey(NAME_Autoaim)); float aim = *static_cast<FFloatCVar *>(*CheckKey(NAME_Autoaim));
if (aim > 35 || aim < 0) if (aim > 35 || aim < 0)
{ {
return ANGLE_1*35; return 35.;
} }
else else
{ {
return xs_RoundToInt(fabs(aim * ANGLE_1)); return aim;
} }
} }
const char *GetName() const const char *GetName() const

View file

@ -3070,7 +3070,8 @@ void FParser::SF_MoveCamera(void)
fixed_t zdist, xydist, movespeed; fixed_t zdist, xydist, movespeed;
fixed_t xstep, ystep, zstep, targetheight; fixed_t xstep, ystep, zstep, targetheight;
angle_t anglespeed, anglestep, angledist, targetangle, angle_t anglespeed, anglestep, angledist, targetangle,
mobjangle, bigangle, smallangle; bigangle, smallangle;
DAngle mobjangle;
// I have to use floats for the math where angles are divided // I have to use floats for the math where angles are divided
// by fixed values. // by fixed values.
@ -3147,11 +3148,11 @@ void FParser::SF_MoveCamera(void)
} }
// set step variables based on distance and speed // set step variables based on distance and speed
mobjangle = cam->__f_AngleTo(target); mobjangle = cam->AngleTo(target);
xydist = cam->Distance2D(target); xydist = FLOAT2FIXED(cam->Distance2D(target, true));
xstep = FixedMul(finecosine[mobjangle >> ANGLETOFINESHIFT], movespeed); xstep = (fixed_t)(movespeed * mobjangle.Cos());
ystep = FixedMul(finesine[mobjangle >> ANGLETOFINESHIFT], movespeed); ystep = (fixed_t)(movespeed * mobjangle.Sin());
if(xydist && movespeed) if(xydist && movespeed)
zstep = FixedDiv(zdist, FixedDiv(xydist, movespeed)); zstep = FixedDiv(zdist, FixedDiv(xydist, movespeed));
@ -3767,14 +3768,15 @@ void FParser::SF_Resurrect()
void FParser::SF_LineAttack() void FParser::SF_LineAttack()
{ {
AActor *mo; AActor *mo;
int damage, angle, slope; int damage;
DAngle angle, slope;
if (CheckArgs(3)) if (CheckArgs(3))
{ {
mo = actorvalue(t_argv[0]); mo = actorvalue(t_argv[0]);
damage = intvalue(t_argv[2]); damage = intvalue(t_argv[2]);
angle = (intvalue(t_argv[1]) * (ANG45 / 45)); angle = floatvalue(t_argv[1]);
slope = P_AimLineAttack(mo, angle, MISSILERANGE); slope = P_AimLineAttack(mo, angle, MISSILERANGE);
P_LineAttack(mo, angle, MISSILERANGE, slope, damage, NAME_Hitscan, NAME_BulletPuff); P_LineAttack(mo, angle, MISSILERANGE, slope, damage, NAME_Hitscan, NAME_BulletPuff);

View file

@ -30,9 +30,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
angle_t angle; DAngle angle;
int damage; int damage;
int pitch; DAngle pitch;
FTranslatedLineTarget t; FTranslatedLineTarget t;
if (self->player != NULL) if (self->player != NULL)
@ -50,9 +50,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch)
if (self->FindInventory<APowerStrength>()) if (self->FindInventory<APowerStrength>())
damage *= 10; damage *= 10;
angle = self->_f_angle(); angle = self->Angles.Yaw + pr_punch.Random2() * (5.625 / 256);
angle += pr_punch.Random2() << 18;
pitch = P_AimLineAttack (self, angle, MELEERANGE); pitch = P_AimLineAttack (self, angle, MELEERANGE);
P_LineAttack (self, angle, MELEERANGE, pitch, damage, NAME_Melee, NAME_BulletPuff, LAF_ISMELEEATTACK, &t); P_LineAttack (self, angle, MELEERANGE, pitch, damage, NAME_Melee, NAME_BulletPuff, LAF_ISMELEEATTACK, &t);
@ -123,15 +121,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw)
PARAM_INT_OPT (damage) { damage = 2; } PARAM_INT_OPT (damage) { damage = 2; }
PARAM_CLASS_OPT (pufftype, AActor) { pufftype = NULL; } PARAM_CLASS_OPT (pufftype, AActor) { pufftype = NULL; }
PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (flags) { flags = 0; }
PARAM_FIXED_OPT (range) { range = 0; } PARAM_FLOAT_OPT (range) { range = 0; }
PARAM_ANGLE_OPT(spread_xy) { spread_xy = 33554432; /*angle_t(2.8125 * (ANGLE_90 / 90.0));*/ } // The floating point expression does not get optimized away. PARAM_DANGLE_OPT(spread_xy) { spread_xy = 2.8125; }
PARAM_ANGLE_OPT (spread_z) { spread_z = 0; } PARAM_DANGLE_OPT(spread_z) { spread_z = 0.; }
PARAM_FIXED_OPT (lifesteal) { lifesteal = 0; } PARAM_FIXED_OPT (lifesteal) { lifesteal = 0; }
PARAM_INT_OPT (lifestealmax) { lifestealmax = 0; } PARAM_INT_OPT (lifestealmax) { lifestealmax = 0; }
PARAM_CLASS_OPT (armorbonustype, ABasicArmorBonus) { armorbonustype = NULL; } PARAM_CLASS_OPT (armorbonustype, ABasicArmorBonus) { armorbonustype = NULL; }
angle_t angle; DAngle angle;
angle_t slope; DAngle slope;
player_t *player; player_t *player;
FTranslatedLineTarget t; FTranslatedLineTarget t;
int actualdamage; int actualdamage;
@ -154,12 +152,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw)
damage *= (pr_saw()%10+1); damage *= (pr_saw()%10+1);
} }
if (range == 0) if (range == 0)
{ // use meleerange + 1 so the puff doesn't skip the flash (i.e. plays all states) {
range = MELEERANGE+1; range = SAWRANGE;
} }
angle = self->_f_angle() + (pr_saw.Random2() * (spread_xy / 255)); angle = self->Angles.Yaw + spread_xy * (pr_saw.Random2() / 255.);
slope = P_AimLineAttack (self, angle, range, &t) + (pr_saw.Random2() * (spread_z / 255)); slope = P_AimLineAttack (self, angle, range, &t) + spread_z * (pr_saw.Random2() / 255.);
AWeapon *weapon = self->player->ReadyWeapon; AWeapon *weapon = self->player->ReadyWeapon;
if ((weapon != NULL) && !(flags & SF_NOUSEAMMO) && !(!t.linetarget && (flags & SF_NOUSEAMMOMISS)) && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_WEAPON()) if ((weapon != NULL) && !(flags & SF_NOUSEAMMO) && !(!t.linetarget && (flags & SF_NOUSEAMMOMISS)) && !(weapon->WeaponFlags & WIF_DEHAMMO) && ACTION_CALL_FROM_WEAPON())
@ -279,7 +277,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun)
} }
player->mo->PlayAttacking2 (); player->mo->PlayAttacking2 ();
angle_t pitch = P_BulletSlope (self); DAngle pitch = P_BulletSlope (self);
for (i = 0; i < 7; i++) for (i = 0; i < 7; i++)
{ {
@ -296,7 +294,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2)
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
int i; int i;
angle_t angle; DAngle angle;
int damage; int damage;
player_t *player; player_t *player;
@ -316,13 +314,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2)
player->mo->PlayAttacking2 (); player->mo->PlayAttacking2 ();
angle_t pitch = P_BulletSlope (self); DAngle pitch = P_BulletSlope (self);
for (i=0 ; i<20 ; i++) for (i=0 ; i<20 ; i++)
{ {
damage = 5*(pr_fireshotgun2()%3+1); damage = 5*(pr_fireshotgun2()%3+1);
angle = self->_f_angle(); angle = self->Angles.Yaw + pr_fireshotgun2.Random2() * (11.25 / 256);
angle += pr_fireshotgun2.Random2() << 19;
// Doom adjusts the bullet slope by shifting a random number [-255,255] // Doom adjusts the bullet slope by shifting a random number [-255,255]
// left 5 places. At 2048 units away, this means the vertical position // left 5 places. At 2048 units away, this means the vertical position
@ -333,7 +330,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireShotgun2)
P_LineAttack (self, P_LineAttack (self,
angle, angle,
PLAYERMISSILERANGE, PLAYERMISSILERANGE,
pitch + (pr_fireshotgun2.Random2() * 332063), damage, pitch + pr_fireshotgun2.Random2() * (7.097 / 256), damage,
NAME_Hitscan, NAME_BulletPuff); NAME_Hitscan, NAME_BulletPuff);
} }
return 0; return 0;
@ -620,7 +617,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireBFG)
return 0; return 0;
} }
P_SpawnPlayerMissile (self, 0, 0, 0, PClass::FindActor("BFGBall"), self->_f_angle(), NULL, NULL, !!(dmflags2 & DF2_NO_FREEAIMBFG)); P_SpawnPlayerMissile (self, 0, 0, 0, PClass::FindActor("BFGBall"), self->Angles.Yaw, NULL, NULL, !!(dmflags2 & DF2_NO_FREEAIMBFG));
return 0; return 0;
} }
@ -633,25 +630,25 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_CLASS_OPT (spraytype, AActor) { spraytype = NULL; } PARAM_CLASS_OPT (spraytype, AActor) { spraytype = NULL; }
PARAM_INT_OPT (numrays) { numrays = 40; } PARAM_INT_OPT (numrays) { numrays = 0; }
PARAM_INT_OPT (damagecnt) { damagecnt = 15; } PARAM_INT_OPT (damagecnt) { damagecnt = 0; }
PARAM_ANGLE_OPT (angle) { angle = ANGLE_90; } PARAM_DANGLE_OPT(angle) { angle = 0.; }
PARAM_FIXED_OPT (distance) { distance = 16*64*FRACUNIT; } PARAM_FLOAT_OPT (distance) { distance = 0; }
PARAM_ANGLE_OPT (vrange) { vrange = 32*ANGLE_1; } PARAM_DANGLE_OPT(vrange) { vrange = 0.; }
PARAM_INT_OPT (defdamage) { defdamage = 0; } PARAM_INT_OPT (defdamage) { defdamage = 0; }
int i; int i;
int j; int j;
int damage; int damage;
angle_t an; DAngle an;
FTranslatedLineTarget t; FTranslatedLineTarget t;
if (spraytype == NULL) spraytype = PClass::FindActor("BFGExtra"); if (spraytype == NULL) spraytype = PClass::FindActor("BFGExtra");
if (numrays <= 0) numrays = 40; if (numrays <= 0) numrays = 40;
if (damagecnt <= 0) damagecnt = 15; if (damagecnt <= 0) damagecnt = 15;
if (angle == 0) angle = ANG90; if (angle == 0) angle = 90.;
if (distance <= 0) distance = 16 * 64 * FRACUNIT; if (distance <= 0) distance = 16 * 64;
if (vrange == 0) vrange = ANGLE_1 * 32; if (vrange == 0) vrange = 32.;
// [RH] Don't crash if no target // [RH] Don't crash if no target
if (!self->target) if (!self->target)
@ -660,7 +657,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
// offset angles from its attack angle // offset angles from its attack angle
for (i = 0; i < numrays; i++) for (i = 0; i < numrays; i++)
{ {
an = self->_f_angle() - angle / 2 + angle / numrays*i; an = self->Angles.Yaw - angle / 2 + angle / numrays*i;
// self->target is the originator (player) of the missile // self->target is the originator (player) of the missile
P_AimLineAttack(self->target, an, distance, &t, vrange); P_AimLineAttack(self->target, an, distance, &t, vrange);

View file

@ -22,19 +22,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_PosAttack)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
int angle;
int damage; int damage;
int slope; DAngle angle;
DAngle slope;
if (!self->target) if (!self->target)
return 0; return 0;
A_FaceTarget (self); A_FaceTarget (self);
angle = self->_f_angle(); angle = self->Angles.Yaw;
slope = P_AimLineAttack (self, angle, MISSILERANGE); slope = P_AimLineAttack (self, angle, MISSILERANGE);
S_Sound (self, CHAN_WEAPON, "grunt/attack", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "grunt/attack", 1, ATTN_NORM);
angle += pr_posattack.Random2() << 20; angle += pr_posattack.Random2() * (22.5 / 256);
damage = ((pr_posattack()%5)+1)*3; damage = ((pr_posattack()%5)+1)*3;
P_LineAttack (self, angle, MISSILERANGE, slope, damage, NAME_Hitscan, NAME_BulletPuff); P_LineAttack (self, angle, MISSILERANGE, slope, damage, NAME_Hitscan, NAME_BulletPuff);
return 0; return 0;
@ -43,16 +43,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_PosAttack)
static void A_SPosAttack2 (AActor *self) static void A_SPosAttack2 (AActor *self)
{ {
int i; int i;
int bangle; DAngle bangle;
int slope; DAngle slope;
A_FaceTarget (self); A_FaceTarget (self);
bangle = self->_f_angle(); bangle = self->Angles.Yaw;
slope = P_AimLineAttack (self, bangle, MISSILERANGE); slope = P_AimLineAttack (self, bangle, MISSILERANGE);
for (i=0 ; i<3 ; i++) for (i=0 ; i<3 ; i++)
{ {
int angle = bangle + (pr_sposattack.Random2() << 20); DAngle angle = bangle + pr_sposattack.Random2() * (22.5 / 256);
int damage = ((pr_sposattack()%5)+1)*3; int damage = ((pr_sposattack()%5)+1)*3;
P_LineAttack(self, angle, MISSILERANGE, slope, damage, NAME_Hitscan, NAME_BulletPuff); P_LineAttack(self, angle, MISSILERANGE, slope, damage, NAME_Hitscan, NAME_BulletPuff);
} }
@ -88,10 +88,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_CPosAttack)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
int angle; DAngle angle;
int bangle; DAngle bangle;
int damage; int damage;
int slope; DAngle slope;
if (!self->target) if (!self->target)
return 0; return 0;
@ -104,10 +104,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_CPosAttack)
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
A_FaceTarget (self); A_FaceTarget (self);
bangle = self->_f_angle(); bangle = self->Angles.Yaw;
slope = P_AimLineAttack (self, bangle, MISSILERANGE); slope = P_AimLineAttack (self, bangle, MISSILERANGE);
angle = bangle + (pr_cposattack.Random2() << 20); angle = bangle + pr_cposattack.Random2() * (22.5 / 256);
damage = ((pr_cposattack()%5)+1)*3; damage = ((pr_cposattack()%5)+1)*3;
P_LineAttack (self, angle, MISSILERANGE, slope, damage, NAME_Hitscan, NAME_BulletPuff); P_LineAttack (self, angle, MISSILERANGE, slope, damage, NAME_Hitscan, NAME_BulletPuff);
return 0; return 0;

View file

@ -275,14 +275,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Saw)
A_FaceTarget (self); A_FaceTarget (self);
if (self->CheckMeleeRange ()) if (self->CheckMeleeRange ())
{ {
angle_t Angle; DAngle angle;
FTranslatedLineTarget t; FTranslatedLineTarget t;
damage *= (pr_m_saw()%10+1); damage *= (pr_m_saw()%10+1);
Angle = self->_f_angle() + (pr_m_saw.Random2() << 18); angle = self->Angles.Yaw + pr_m_saw.Random2() * (5.625 / 256);
P_LineAttack (self, Angle, MELEERANGE+1, P_LineAttack (self, angle, SAWRANGE,
P_AimLineAttack (self, Angle, MELEERANGE+1), damage, P_AimLineAttack (self, angle, SAWRANGE), damage,
NAME_Melee, pufftype, false, &t); NAME_Melee, pufftype, false, &t);
if (!t.linetarget) if (!t.linetarget)
@ -293,7 +293,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Saw)
S_Sound (self, CHAN_WEAPON, hitsound, 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, hitsound, 1, ATTN_NORM);
// turn to face target // turn to face target
DAngle angle = t.angleFromSource; angle = t.angleFromSource;
DAngle anglediff = deltaangle(self->Angles.Yaw, angle); DAngle anglediff = deltaangle(self->Angles.Yaw, angle);
if (anglediff < 0.0) if (anglediff < 0.0)
@ -327,9 +327,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Saw)
static void MarinePunch(AActor *self, int damagemul) static void MarinePunch(AActor *self, int damagemul)
{ {
angle_t angle; DAngle angle;
int damage; int damage;
int pitch; DAngle pitch;
FTranslatedLineTarget t; FTranslatedLineTarget t;
if (self->target == NULL) if (self->target == NULL)
@ -338,7 +338,7 @@ static void MarinePunch(AActor *self, int damagemul)
damage = ((pr_m_punch()%10+1) << 1) * damagemul; damage = ((pr_m_punch()%10+1) << 1) * damagemul;
A_FaceTarget (self); A_FaceTarget (self);
angle = self->_f_angle() + (pr_m_punch.Random2() << 18); angle = self->Angles.Yaw + pr_m_punch.Random2() * (5.625 / 256);
pitch = P_AimLineAttack (self, angle, MELEERANGE); pitch = P_AimLineAttack (self, angle, MELEERANGE);
P_LineAttack (self, angle, MELEERANGE, pitch, damage, NAME_Melee, NAME_BulletPuff, true, &t); P_LineAttack (self, angle, MELEERANGE, pitch, damage, NAME_Melee, NAME_BulletPuff, true, &t);
@ -365,17 +365,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Punch)
// //
//============================================================================ //============================================================================
void P_GunShot2 (AActor *mo, bool accurate, int pitch, PClassActor *pufftype) void P_GunShot2 (AActor *mo, bool accurate, DAngle pitch, PClassActor *pufftype)
{ {
angle_t angle; DAngle angle;
int damage; int damage;
damage = 5*(pr_m_gunshot()%3+1); damage = 5*(pr_m_gunshot()%3+1);
angle = mo->_f_angle(); angle = mo->Angles.Yaw;
if (!accurate) if (!accurate)
{ {
angle += pr_m_gunshot.Random2 () << 18; angle += pr_m_gunshot.Random2() * (5.625 / 256);
} }
P_LineAttack (mo, angle, MISSILERANGE, pitch, damage, NAME_Hitscan, pufftype); P_LineAttack (mo, angle, MISSILERANGE, pitch, damage, NAME_Hitscan, pufftype);
@ -397,7 +397,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_FirePistol)
S_Sound (self, CHAN_WEAPON, "weapons/pistol", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "weapons/pistol", 1, ATTN_NORM);
A_FaceTarget (self); A_FaceTarget (self);
P_GunShot2 (self, accurate, P_AimLineAttack (self, self->_f_angle(), MISSILERANGE), P_GunShot2 (self, accurate, P_AimLineAttack (self, self->Angles.Yaw, MISSILERANGE),
PClass::FindActor(NAME_BulletPuff)); PClass::FindActor(NAME_BulletPuff));
return 0; return 0;
} }
@ -412,14 +412,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_FireShotgun)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
int pitch; DAngle pitch;
if (self->target == NULL) if (self->target == NULL)
return 0; return 0;
S_Sound (self, CHAN_WEAPON, "weapons/shotgf", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "weapons/shotgf", 1, ATTN_NORM);
A_FaceTarget (self); A_FaceTarget (self);
pitch = P_AimLineAttack (self, self->_f_angle(), MISSILERANGE); pitch = P_AimLineAttack (self, self->Angles.Yaw, MISSILERANGE);
for (int i = 0; i < 7; ++i) for (int i = 0; i < 7; ++i)
{ {
P_GunShot2 (self, false, pitch, PClass::FindActor(NAME_BulletPuff)); P_GunShot2 (self, false, pitch, PClass::FindActor(NAME_BulletPuff));
@ -459,21 +459,21 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_FireShotgun2)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
int pitch; DAngle pitch;
if (self->target == NULL) if (self->target == NULL)
return 0; return 0;
S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "weapons/sshotf", 1, ATTN_NORM);
A_FaceTarget (self); A_FaceTarget (self);
pitch = P_AimLineAttack (self, self->_f_angle(), MISSILERANGE); pitch = P_AimLineAttack (self, self->Angles.Yaw, MISSILERANGE);
for (int i = 0; i < 20; ++i) for (int i = 0; i < 20; ++i)
{ {
int damage = 5*(pr_m_fireshotgun2()%3+1); int damage = 5*(pr_m_fireshotgun2()%3+1);
angle_t angle = self->_f_angle() + (pr_m_fireshotgun2.Random2() << 19); DAngle angle = self->Angles.Yaw + pr_m_fireshotgun2.Random2() * (11.25 / 256);
P_LineAttack (self, angle, MISSILERANGE, P_LineAttack (self, angle, MISSILERANGE,
pitch + (pr_m_fireshotgun2.Random2() * 332063), damage, pitch + pr_m_fireshotgun2.Random2() * (7.097 / 256), damage,
NAME_Hitscan, NAME_BulletPuff); NAME_Hitscan, NAME_BulletPuff);
} }
self->special1 = level.maptime; self->special1 = level.maptime;
@ -496,7 +496,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_FireCGun)
S_Sound (self, CHAN_WEAPON, "weapons/chngun", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "weapons/chngun", 1, ATTN_NORM);
A_FaceTarget (self); A_FaceTarget (self);
P_GunShot2 (self, accurate, P_AimLineAttack (self, self->_f_angle(), MISSILERANGE), P_GunShot2 (self, accurate, P_AimLineAttack (self, self->Angles.Yaw, MISSILERANGE),
PClass::FindActor(NAME_BulletPuff)); PClass::FindActor(NAME_BulletPuff));
return 0; return 0;
} }

View file

@ -172,9 +172,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL1)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
angle_t angle; DAngle angle;
int damage; int damage;
int slope; DAngle slope;
player_t *player; player_t *player;
FTranslatedLineTarget t; FTranslatedLineTarget t;
@ -184,7 +184,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL1)
} }
damage = 1 + (pr_beakatkpl1()&3); damage = 1 + (pr_beakatkpl1()&3);
angle = player->mo->_f_angle(); angle = player->mo->Angles.Yaw;
slope = P_AimLineAttack (player->mo, angle, MELEERANGE); slope = P_AimLineAttack (player->mo, angle, MELEERANGE);
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &t); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &t);
if (t.linetarget) if (t.linetarget)
@ -207,9 +207,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL2)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
angle_t angle; DAngle angle;
int damage; int damage;
int slope; DAngle slope;
player_t *player; player_t *player;
FTranslatedLineTarget t; FTranslatedLineTarget t;
@ -219,7 +219,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL2)
} }
damage = pr_beakatkpl2.HitDice (4); damage = pr_beakatkpl2.HitDice (4);
angle = player->mo->_f_angle(); angle = player->mo->Angles.Yaw;
slope = P_AimLineAttack (player->mo, angle, MELEERANGE); slope = P_AimLineAttack (player->mo, angle, MELEERANGE);
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &t); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &t);
if (t.linetarget) if (t.linetarget)

View file

@ -63,8 +63,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
angle_t angle; DAngle angle;
int slope; DAngle slope;
player_t *player; player_t *player;
FTranslatedLineTarget t; FTranslatedLineTarget t;
@ -86,8 +86,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack)
{ {
puff = PClass::FindActor(NAME_BulletPuff); // just to be sure puff = PClass::FindActor(NAME_BulletPuff); // just to be sure
} }
angle = self->_f_angle(); angle = self->Angles.Yaw + pr_sap.Random2() * (5.625 / 256);
angle += pr_sap.Random2() << 18;
slope = P_AimLineAttack (self, angle, MELEERANGE); slope = P_AimLineAttack (self, angle, MELEERANGE);
P_LineAttack (self, angle, MELEERANGE, slope, damage, NAME_Melee, puff, true, &t); P_LineAttack (self, angle, MELEERANGE, slope, damage, NAME_Melee, puff, true, &t);
if (t.linetarget) if (t.linetarget)
@ -110,7 +109,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireGoldWandPL1)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
angle_t angle; DAngle angle;
int damage; int damage;
player_t *player; player_t *player;
@ -125,12 +124,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireGoldWandPL1)
if (!weapon->DepleteAmmo (weapon->bAltFire)) if (!weapon->DepleteAmmo (weapon->bAltFire))
return 0; return 0;
} }
angle_t pitch = P_BulletSlope(self); DAngle pitch = P_BulletSlope(self);
damage = 7+(pr_fgw()&7); damage = 7+(pr_fgw()&7);
angle = self->_f_angle(); angle = self->Angles.Yaw;
if (player->refire) if (player->refire)
{ {
angle += pr_fgw.Random2() << 18; angle += pr_fgw.Random2() * (5.625 / 256);
} }
P_LineAttack (self, angle, PLAYERMISSILERANGE, pitch, damage, NAME_Hitscan, "GoldWandPuff1"); P_LineAttack (self, angle, PLAYERMISSILERANGE, pitch, damage, NAME_Hitscan, "GoldWandPuff1");
S_Sound (self, CHAN_WEAPON, "weapons/wandhit", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "weapons/wandhit", 1, ATTN_NORM);
@ -148,7 +147,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireGoldWandPL2)
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
int i; int i;
angle_t angle; DAngle angle;
int damage; int damage;
fixed_t vz; fixed_t vz;
player_t *player; player_t *player;
@ -164,17 +163,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireGoldWandPL2)
if (!weapon->DepleteAmmo (weapon->bAltFire)) if (!weapon->DepleteAmmo (weapon->bAltFire))
return 0; return 0;
} }
angle_t pitch = P_BulletSlope(self); DAngle pitch = P_BulletSlope(self);
vz = FixedMul (GetDefaultByName("GoldWandFX2")->Speed, //momz = GetDefault<AGoldWandFX2>()->Speed * tan(-bulletpitch);
finetangent[FINEANGLES/4-((signed)pitch>>ANGLETOFINESHIFT)]);
vz = fixed_t(GetDefaultByName("GoldWandFX2")->Speed * (-pitch).Tan());
P_SpawnMissileAngle (self, PClass::FindActor("GoldWandFX2"), self->_f_angle()-(ANG45/8), vz); P_SpawnMissileAngle (self, PClass::FindActor("GoldWandFX2"), self->_f_angle()-(ANG45/8), vz);
P_SpawnMissileAngle (self, PClass::FindActor("GoldWandFX2"), self->_f_angle()+(ANG45/8), vz); P_SpawnMissileAngle (self, PClass::FindActor("GoldWandFX2"), self->_f_angle()+(ANG45/8), vz);
angle = self->_f_angle()-(ANG45/8); angle = self->Angles.Yaw - (45. / 8);
for(i = 0; i < 5; i++) for(i = 0; i < 5; i++)
{ {
damage = 1+(pr_fgw2()&7); damage = 1+(pr_fgw2()&7);
P_LineAttack (self, angle, PLAYERMISSILERANGE, pitch, damage, NAME_Hitscan, "GoldWandPuff2"); P_LineAttack (self, angle, PLAYERMISSILERANGE, pitch, damage, NAME_Hitscan, "GoldWandPuff2");
angle += ((ANG45/8)*2)/4; angle += ((45. / 8) * 2) / 4;
} }
S_Sound (self, CHAN_WEAPON, "weapons/wandhit", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "weapons/wandhit", 1, ATTN_NORM);
return 0; return 0;
@ -204,8 +204,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCrossbowPL1)
return 0; return 0;
} }
P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX1")); P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX1"));
P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->_f_angle()-(ANG45/10)); P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->Angles.Yaw - 4.5);
P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->_f_angle()+(ANG45/10)); P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->Angles.Yaw + 4.5);
return 0; return 0;
} }
@ -233,10 +233,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCrossbowPL2)
return 0; return 0;
} }
P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX2")); P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX2"));
P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX2"), self->_f_angle()-(ANG45/10)); P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX2"), self->Angles.Yaw - 4.5);
P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX2"), self->_f_angle()+(ANG45/10)); P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX2"), self->Angles.Yaw + 4.5);
P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->_f_angle()-(ANG45/5)); P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->Angles.Yaw - 9.);
P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->_f_angle()+(ANG45/5)); P_SpawnPlayerMissile (self, PClass::FindActor("CrossbowFX3"), self->Angles.Yaw + 9.);
return 0; return 0;
} }
@ -250,11 +250,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
angle_t Angle; DAngle Angle;
int damage; int damage;
int slope; DAngle slope;
int randVal; int randVal;
fixed_t dist; double dist;
player_t *player; player_t *player;
PClassActor *pufftype; PClassActor *pufftype;
FTranslatedLineTarget t; FTranslatedLineTarget t;
@ -275,19 +275,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack)
} }
player->psprites[ps_weapon].sx = ((pr_gatk()&3)-2) * FRACUNIT; player->psprites[ps_weapon].sx = ((pr_gatk()&3)-2) * FRACUNIT;
player->psprites[ps_weapon].sy = WEAPONTOP + (pr_gatk()&3) * FRACUNIT; player->psprites[ps_weapon].sy = WEAPONTOP + (pr_gatk()&3) * FRACUNIT;
Angle = self->_f_angle(); Angle = self->Angles.Yaw;
if (power) if (power)
{ {
damage = pr_gatk.HitDice (2); damage = pr_gatk.HitDice (2);
dist = 4*MELEERANGE; dist = 4*MELEERANGE;
Angle += pr_gatk.Random2() << 17; Angle += pr_gatk.Random2() * (2.8125 / 256);
pufftype = PClass::FindActor("GauntletPuff2"); pufftype = PClass::FindActor("GauntletPuff2");
} }
else else
{ {
damage = pr_gatk.HitDice (2); damage = pr_gatk.HitDice (2);
dist = MELEERANGE+1; dist = SAWRANGE;
Angle += pr_gatk.Random2() << 18; Angle += pr_gatk.Random2() * (5.625 / 256);
pufftype = PClass::FindActor("GauntletPuff1"); pufftype = PClass::FindActor("GauntletPuff1");
} }
slope = P_AimLineAttack (self, Angle, dist); slope = P_AimLineAttack (self, Angle, dist);
@ -445,8 +445,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMacePL1)
} }
player->psprites[ps_weapon].sx = ((pr_maceatk()&3)-2)*FRACUNIT; player->psprites[ps_weapon].sx = ((pr_maceatk()&3)-2)*FRACUNIT;
player->psprites[ps_weapon].sy = WEAPONTOP+(pr_maceatk()&3)*FRACUNIT; player->psprites[ps_weapon].sy = WEAPONTOP+(pr_maceatk()&3)*FRACUNIT;
ball = P_SpawnPlayerMissile (self, PClass::FindActor("MaceFX1"), ball = P_SpawnPlayerMissile (self, PClass::FindActor("MaceFX1"), self->Angles.Yaw + (((pr_maceatk()&7)-4) * (360./256)));
self->_f_angle()+(((pr_maceatk()&7)-4)<<24));
if (ball) if (ball)
{ {
ball->special1 = 16; // tics till dropoff ball->special1 = 16; // tics till dropoff
@ -603,7 +602,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMacePL2)
if (!weapon->DepleteAmmo (weapon->bAltFire)) if (!weapon->DepleteAmmo (weapon->bAltFire))
return 0; return 0;
} }
mo = P_SpawnPlayerMissile (self, 0,0,0, RUNTIME_CLASS(AMaceFX4), self->_f_angle(), &t); mo = P_SpawnPlayerMissile (self, 0,0,0, RUNTIME_CLASS(AMaceFX4), self->Angles.Yaw, &t);
if (mo) if (mo)
{ {
mo->vel.x += self->vel.x; mo->vel.x += self->vel.x;
@ -667,7 +666,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact)
angle = 0.; angle = 0.;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
P_AimLineAttack (self, FLOAT2ANGLE(angle.Degrees), 10*64*FRACUNIT, &t, 0, ALF_NOFRIENDS|ALF_PORTALRESTRICT, NULL, self->target); P_AimLineAttack (self, angle, 640., &t, 0., ALF_NOFRIENDS|ALF_PORTALRESTRICT, NULL, self->target);
if (t.linetarget && self->target != t.linetarget) if (t.linetarget && self->target != t.linetarget)
{ {
self->tracer = t.linetarget; self->tracer = t.linetarget;
@ -772,7 +771,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireBlasterPL1)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
angle_t angle; DAngle angle;
int damage; int damage;
player_t *player; player_t *player;
@ -787,12 +786,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireBlasterPL1)
if (!weapon->DepleteAmmo (weapon->bAltFire)) if (!weapon->DepleteAmmo (weapon->bAltFire))
return 0; return 0;
} }
angle_t pitch = P_BulletSlope(self); DAngle pitch = P_BulletSlope(self);
damage = pr_fb1.HitDice (4); damage = pr_fb1.HitDice (4);
angle = self->_f_angle(); angle = self->Angles.Yaw;
if (player->refire) if (player->refire)
{ {
angle += pr_fb1.Random2() << 18; angle += pr_fb1.Random2() * (5.625 / 256);
} }
P_LineAttack (self, angle, PLAYERMISSILERANGE, pitch, damage, NAME_Hitscan, "BlasterPuff"); P_LineAttack (self, angle, PLAYERMISSILERANGE, pitch, damage, NAME_Hitscan, "BlasterPuff");
S_Sound (self, CHAN_WEAPON, "weapons/blastershoot", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "weapons/blastershoot", 1, ATTN_NORM);
@ -947,7 +946,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSkullRodPL2)
if (!weapon->DepleteAmmo (weapon->bAltFire)) if (!weapon->DepleteAmmo (weapon->bAltFire))
return 0; return 0;
} }
P_SpawnPlayerMissile (self, 0,0,0, RUNTIME_CLASS(AHornRodFX2), self->_f_angle(), &t, &MissileActor); P_SpawnPlayerMissile (self, 0,0,0, RUNTIME_CLASS(AHornRodFX2), self->Angles.Yaw, &t, &MissileActor);
// Use MissileActor instead of the return value from // Use MissileActor instead of the return value from
// P_SpawnPlayerMissile because we need to give info to the mobj // P_SpawnPlayerMissile because we need to give info to the mobj
// even if it exploded immediately. // even if it exploded immediately.

View file

@ -225,7 +225,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyAttack)
if (!weapon->DepleteAmmo (weapon->bAltFire)) if (!weapon->DepleteAmmo (weapon->bAltFire))
return 0; return 0;
} }
AActor *missile = P_SpawnPlayerMissile (self, 0,0,0, PClass::FindActor("HolyMissile"), self->_f_angle(), &t); AActor *missile = P_SpawnPlayerMissile (self, 0,0,0, PClass::FindActor("HolyMissile"), self->Angles.Yaw, &t);
if (missile != NULL && !t.unlinked) if (missile != NULL && !t.unlinked)
{ {
missile->tracer = t.linetarget; missile->tracer = t.linetarget;

View file

@ -17,9 +17,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_CMaceAttack)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
angle_t angle; DAngle angle;
int damage; int damage;
int slope; DAngle slope;
int i; int i;
player_t *player; player_t *player;
FTranslatedLineTarget t; FTranslatedLineTarget t;
@ -36,7 +36,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CMaceAttack)
{ {
for (int j = 1; j >= -1; j -= 2) for (int j = 1; j >= -1; j -= 2)
{ {
angle = player->mo->_f_angle() + j*i*(ANG45 / 16); angle = player->mo->Angles.Yaw + j*i*(45. / 16);
slope = P_AimLineAttack(player->mo, angle, 2 * MELEERANGE, &t); slope = P_AimLineAttack(player->mo, angle, 2 * MELEERANGE, &t);
if (t.linetarget) if (t.linetarget)
{ {
@ -52,7 +52,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CMaceAttack)
// didn't find any creatures, so try to strike any walls // didn't find any creatures, so try to strike any walls
player->mo->weaponspecial = 0; player->mo->weaponspecial = 0;
angle = player->mo->_f_angle(); angle = player->mo->Angles.Yaw;
slope = P_AimLineAttack (player->mo, angle, MELEERANGE); slope = P_AimLineAttack (player->mo, angle, MELEERANGE);
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, hammertime); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, hammertime);
macedone: macedone:

View file

@ -51,8 +51,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
APlayerPawn *pmo; APlayerPawn *pmo;
int damage; int damage;
int newLife, max; int newLife, max;
angle_t angle; DAngle angle;
int slope; DAngle slope;
int i; int i;
player_t *player; player_t *player;
FTranslatedLineTarget t; FTranslatedLineTarget t;
@ -72,11 +72,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
{ {
for (int j = 1; j >= -1; j -= 2) for (int j = 1; j >= -1; j -= 2)
{ {
angle = pmo->_f_angle() + j*i*(ANG45 / 16); angle = pmo->Angles.Yaw + j*i*(45. / 16);
slope = P_AimLineAttack(pmo, angle, fixed_t(1.5*MELEERANGE), &t, 0, ALF_CHECK3D); slope = P_AimLineAttack(pmo, angle, 1.5 * MELEERANGE, &t, 0., ALF_CHECK3D);
if (t.linetarget) if (t.linetarget)
{ {
P_LineAttack(pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, puff, false, &t); P_LineAttack(pmo, angle, 1.5 * MELEERANGE, slope, damage, NAME_Melee, puff, false, &t);
if (t.linetarget != NULL) if (t.linetarget != NULL)
{ {
pmo->Angles.Yaw = t.angleFromSource; pmo->Angles.Yaw = t.angleFromSource;
@ -131,12 +131,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffAttack)
if (!weapon->DepleteAmmo (weapon->bAltFire)) if (!weapon->DepleteAmmo (weapon->bAltFire))
return 0; return 0;
} }
mo = P_SpawnPlayerMissile (self, RUNTIME_CLASS(ACStaffMissile), self->_f_angle()-(ANG45/15)); mo = P_SpawnPlayerMissile (self, RUNTIME_CLASS(ACStaffMissile), self->Angles.Yaw - 3.0);
if (mo) if (mo)
{ {
mo->WeaveIndexXY = 32; mo->WeaveIndexXY = 32;
} }
mo = P_SpawnPlayerMissile (self, RUNTIME_CLASS(ACStaffMissile), self->_f_angle()+(ANG45/15)); mo = P_SpawnPlayerMissile (self, RUNTIME_CLASS(ACStaffMissile), self->Angles.Yaw + 3.0);
if (mo) if (mo)
{ {
mo->WeaveIndexXY = 0; mo->WeaveIndexXY = 0;

View file

@ -13,7 +13,7 @@
#include "thingdef/thingdef.h" #include "thingdef/thingdef.h"
*/ */
#define AXERANGE ((fixed_t)(2.25*MELEERANGE)) #define AXERANGE (2.25 * MELEERANGE)
static FRandom pr_axeatk ("FAxeAtk"); static FRandom pr_axeatk ("FAxeAtk");
@ -199,10 +199,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
angle_t angle; DAngle angle;
fixed_t power; fixed_t power;
int damage; int damage;
int slope; DAngle slope;
int i; int i;
int useMana; int useMana;
player_t *player; player_t *player;
@ -236,7 +236,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack)
{ {
for (int j = 1; j >= -1; j -= 2) for (int j = 1; j >= -1; j -= 2)
{ {
angle = pmo->_f_angle() + j*i*(ANG45 / 16); angle = pmo->Angles.Yaw + j*i*(45. / 16);
slope = P_AimLineAttack(pmo, angle, AXERANGE, &t); slope = P_AimLineAttack(pmo, angle, AXERANGE, &t);
if (t.linetarget) if (t.linetarget)
{ {
@ -257,7 +257,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack)
// didn't find any creatures, so try to strike any walls // didn't find any creatures, so try to strike any walls
pmo->weaponspecial = 0; pmo->weaponspecial = 0;
angle = pmo->_f_angle(); angle = pmo->Angles.Yaw;
slope = P_AimLineAttack (pmo, angle, MELEERANGE); slope = P_AimLineAttack (pmo, angle, MELEERANGE);
P_LineAttack (pmo, angle, MELEERANGE, slope, damage, NAME_Melee, pufftype, true); P_LineAttack (pmo, angle, MELEERANGE, slope, damage, NAME_Melee, pufftype, true);

View file

@ -13,7 +13,7 @@
#include "thingdef/thingdef.h" #include "thingdef/thingdef.h"
*/ */
const fixed_t HAMMER_RANGE = MELEERANGE+MELEERANGE/2; const double HAMMER_RANGE = 1.5 * MELEERANGE;
static FRandom pr_hammeratk ("FHammerAtk"); static FRandom pr_hammeratk ("FHammerAtk");
@ -27,10 +27,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
angle_t angle; DAngle angle;
int damage; int damage;
fixed_t power; fixed_t power;
int slope; DAngle slope;
int i; int i;
player_t *player; player_t *player;
FTranslatedLineTarget t; FTranslatedLineTarget t;
@ -47,42 +47,29 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack)
hammertime = PClass::FindActor("HammerPuff"); hammertime = PClass::FindActor("HammerPuff");
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
angle = pmo->_f_angle() + i*(ANG45/32); for (int j = 1; j >= -1; j -= 2)
slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &t, 0, ALF_CHECK3D);
if (t.linetarget != NULL)
{ {
P_LineAttack(pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, hammertime, true, &t); angle = pmo->Angles.Yaw + j*i*(45. / 32);
slope = P_AimLineAttack(pmo, angle, HAMMER_RANGE, &t, 0., ALF_CHECK3D);
if (t.linetarget != NULL) if (t.linetarget != NULL)
{ {
AdjustPlayerAngle(pmo, &t); P_LineAttack(pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, hammertime, true, &t);
if (t.linetarget->flags3 & MF3_ISMONSTER || t.linetarget->player) if (t.linetarget != NULL)
{ {
P_ThrustMobj(t.linetarget, t.angleFromSource, power); AdjustPlayerAngle(pmo, &t);
if (t.linetarget->flags3 & MF3_ISMONSTER || t.linetarget->player)
{
P_ThrustMobj(t.linetarget, t.angleFromSource, power);
}
pmo->weaponspecial = false; // Don't throw a hammer
goto hammerdone;
} }
pmo->weaponspecial = false; // Don't throw a hammer
goto hammerdone;
}
}
angle = pmo->_f_angle()-i*(ANG45/32);
slope = P_AimLineAttack(pmo, angle, HAMMER_RANGE, &t, 0, ALF_CHECK3D);
if (t.linetarget != NULL)
{
P_LineAttack(pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, hammertime, true, &t);
if (t.linetarget != NULL)
{
AdjustPlayerAngle(pmo, &t);
if (t.linetarget->flags3 & MF3_ISMONSTER || t.linetarget->player)
{
P_ThrustMobj(t.linetarget, t.angleFromSource, power);
}
pmo->weaponspecial = false; // Don't throw a hammer
goto hammerdone;
} }
} }
} }
// didn't find any targets in meleerange, so set to throw out a hammer // didn't find any targets in meleerange, so set to throw out a hammer
angle = pmo->_f_angle(); angle = pmo->Angles.Yaw;
slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, NULL, 0, ALF_CHECK3D); slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, NULL, 0., ALF_CHECK3D);
if (P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, hammertime, true) != NULL) if (P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, hammertime, true) != NULL)
{ {
pmo->weaponspecial = false; pmo->weaponspecial = false;

View file

@ -53,11 +53,11 @@ void AdjustPlayerAngle (AActor *pmo, FTranslatedLineTarget *t)
// //
//============================================================================ //============================================================================
static bool TryPunch(APlayerPawn *pmo, angle_t angle, int damage, fixed_t power) static bool TryPunch(APlayerPawn *pmo, DAngle angle, int damage, fixed_t power)
{ {
PClassActor *pufftype; PClassActor *pufftype;
FTranslatedLineTarget t; FTranslatedLineTarget t;
int slope; DAngle slope;
slope = P_AimLineAttack (pmo, angle, 2*MELEERANGE, &t); slope = P_AimLineAttack (pmo, angle, 2*MELEERANGE, &t);
if (t.linetarget != NULL) if (t.linetarget != NULL)
@ -112,8 +112,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack)
power = 2*FRACUNIT; power = 2*FRACUNIT;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
if (TryPunch(pmo, pmo->_f_angle() + i*(ANG45/16), damage, power) || if (TryPunch(pmo, pmo->Angles.Yaw + i*(45./16), damage, power) ||
TryPunch(pmo, pmo->_f_angle() - i*(ANG45/16), damage, power)) TryPunch(pmo, pmo->Angles.Yaw - i*(45./16), damage, power))
{ // hit something { // hit something
if (pmo->weaponspecial >= 3) if (pmo->weaponspecial >= 3)
{ {
@ -127,7 +127,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack)
// didn't find any creatures, so try to strike any walls // didn't find any creatures, so try to strike any walls
pmo->weaponspecial = 0; pmo->weaponspecial = 0;
int slope = P_AimLineAttack (pmo, pmo->_f_angle(), MELEERANGE); DAngle slope = P_AimLineAttack (pmo, pmo->Angles.Yaw, MELEERANGE);
P_LineAttack (pmo, pmo->_f_angle(), MELEERANGE, slope, damage, NAME_Melee, PClass::FindActor("PunchPuff"), true); P_LineAttack (pmo, pmo->Angles.Yaw, MELEERANGE, slope, damage, NAME_Melee, PClass::FindActor("PunchPuff"), true);
return 0; return 0;
} }

View file

@ -95,11 +95,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_FSwordAttack)
if (!weapon->DepleteAmmo (weapon->bAltFire)) if (!weapon->DepleteAmmo (weapon->bAltFire))
return 0; return 0;
} }
P_SpawnPlayerMissile (self, 0, 0, -10*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->_f_angle()+ANGLE_45/4); P_SpawnPlayerMissile (self, 0, 0, -10*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->Angles.Yaw + (45./4));
P_SpawnPlayerMissile (self, 0, 0, -5*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->_f_angle()+ANGLE_45/8); P_SpawnPlayerMissile (self, 0, 0, -5*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->Angles.Yaw + (45./8));
P_SpawnPlayerMissile (self, 0, 0, 0, RUNTIME_CLASS(AFSwordMissile), self->_f_angle()); P_SpawnPlayerMissile (self, 0, 0, 0, RUNTIME_CLASS(AFSwordMissile), self->Angles.Yaw);
P_SpawnPlayerMissile (self, 0, 0, 5*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->_f_angle()-ANGLE_45/8); P_SpawnPlayerMissile (self, 0, 0, 5*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->Angles.Yaw - (45./8));
P_SpawnPlayerMissile (self, 0, 0, 10*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->_f_angle()-ANGLE_45/4); P_SpawnPlayerMissile (self, 0, 0, 10*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->Angles.Yaw - (45./4));
S_Sound (self, CHAN_WEAPON, "FighterSwordFire", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "FighterSwordFire", 1, ATTN_NORM);
return 0; return 0;
} }

View file

@ -53,9 +53,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireConePL1)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
angle_t angle; DAngle angle;
int damage; int damage;
int slope; DAngle slope;
int i; int i;
AActor *mo; AActor *mo;
bool conedone=false; bool conedone=false;
@ -78,8 +78,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireConePL1)
damage = 90+(pr_cone()&15); damage = 90+(pr_cone()&15);
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
angle = self->_f_angle()+i*(ANG45/16); angle = self->Angles.Yaw + i*(45./16);
slope = P_AimLineAttack (self, angle, MELEERANGE, &t, 0, ALF_CHECK3D); slope = P_AimLineAttack (self, angle, MELEERANGE, &t, 0., ALF_CHECK3D);
if (t.linetarget) if (t.linetarget)
{ {
P_DamageMobj (t.linetarget, self, self, damage, NAME_Ice, DMG_USEANGLE, FLOAT2ANGLE(t.angleFromSource.Degrees)); P_DamageMobj (t.linetarget, self, self, damage, NAME_Ice, DMG_USEANGLE, FLOAT2ANGLE(t.angleFromSource.Degrees));

View file

@ -97,13 +97,12 @@ bool AMageStaffFX2::SpecialBlastHandling (AActor *source, fixed_t strength)
// //
//============================================================================ //============================================================================
void MStaffSpawn (AActor *pmo, angle_t angle, AActor *alttarget) void MStaffSpawn (AActor *pmo, DAngle angle, AActor *alttarget)
{ {
AActor *mo; AActor *mo;
FTranslatedLineTarget t; FTranslatedLineTarget t;
mo = P_SpawnPlayerMissile (pmo, 0, 0, 8*FRACUNIT, mo = P_SpawnPlayerMissile (pmo, 0, 0, 8*FRACUNIT, RUNTIME_CLASS(AMageStaffFX2), angle, &t);
RUNTIME_CLASS(AMageStaffFX2), angle, &t);
if (mo) if (mo)
{ {
mo->target = pmo; mo->target = pmo;
@ -124,7 +123,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MStaffAttack)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
angle_t angle; DAngle angle;
player_t *player; player_t *player;
FTranslatedLineTarget t; FTranslatedLineTarget t;
@ -139,21 +138,21 @@ DEFINE_ACTION_FUNCTION(AActor, A_MStaffAttack)
if (!weapon->DepleteAmmo (weapon->bAltFire)) if (!weapon->DepleteAmmo (weapon->bAltFire))
return 0; return 0;
} }
angle = self->_f_angle(); angle = self->Angles.Yaw;
// [RH] Let's try and actually track what the player aimed at // [RH] Let's try and actually track what the player aimed at
P_AimLineAttack (self, angle, PLAYERMISSILERANGE, &t, ANGLE_1*32); P_AimLineAttack (self, angle, PLAYERMISSILERANGE, &t, 32.);
if (t.linetarget == NULL) if (t.linetarget == NULL)
{ {
BlockCheckLine.x = self->X(); BlockCheckLine.x = self->X();
BlockCheckLine.y = self->Y(); BlockCheckLine.y = self->Y();
BlockCheckLine.dx = -finesine[angle >> ANGLETOFINESHIFT]; BlockCheckLine.dx = FLOAT2FIXED(-angle.Sin());
BlockCheckLine.dy = -finecosine[angle >> ANGLETOFINESHIFT]; BlockCheckLine.dy = FLOAT2FIXED(-angle.Cos());
t.linetarget = P_BlockmapSearch (self, 10, FrontBlockCheck); t.linetarget = P_BlockmapSearch (self, 10, FrontBlockCheck);
} }
MStaffSpawn (self, angle, t.linetarget); MStaffSpawn (self, angle, t.linetarget);
MStaffSpawn (self, angle-ANGLE_1*5, t.linetarget); MStaffSpawn (self, angle-5, t.linetarget);
MStaffSpawn (self, angle+ANGLE_1*5, t.linetarget); MStaffSpawn (self, angle+5, t.linetarget);
S_Sound (self, CHAN_WEAPON, "MageStaffFire", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "MageStaffFire", 1, ATTN_NORM);
weapon->MStaffCount = 3; weapon->MStaffCount = 3;
return 0; return 0;

View file

@ -60,9 +60,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_SnoutAttack)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
angle_t angle; DAngle angle;
int damage; int damage;
int slope; DAngle slope;
player_t *player; player_t *player;
AActor *puff; AActor *puff;
FTranslatedLineTarget t; FTranslatedLineTarget t;
@ -73,7 +73,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SnoutAttack)
} }
damage = 3+(pr_snoutattack()&3); damage = 3+(pr_snoutattack()&3);
angle = player->mo->_f_angle(); angle = player->mo->Angles.Yaw;
slope = P_AimLineAttack(player->mo, angle, MELEERANGE); slope = P_AimLineAttack(player->mo, angle, MELEERANGE);
puff = P_LineAttack(player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "SnoutPuff", true, &t); puff = P_LineAttack(player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "SnoutPuff", true, &t);
S_Sound(player->mo, CHAN_VOICE, "PigActive", 1, ATTN_NORM); S_Sound(player->mo, CHAN_VOICE, "PigActive", 1, ATTN_NORM);

View file

@ -17,17 +17,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_ReaverRanged)
if (self->target != NULL) if (self->target != NULL)
{ {
angle_t bangle; DAngle bangle;
int pitch; DAngle pitch;
A_FaceTarget (self); A_FaceTarget (self);
S_Sound (self, CHAN_WEAPON, "reaver/attack", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "reaver/attack", 1, ATTN_NORM);
bangle = self->_f_angle(); bangle = self->Angles.Yaw;
pitch = P_AimLineAttack (self, bangle, MISSILERANGE); pitch = P_AimLineAttack (self, bangle, MISSILERANGE);
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
{ {
angle_t angle = bangle + (pr_reaverattack.Random2() << 20); DAngle angle = bangle + pr_reaverattack.Random2() * (22.5 / 256);
int damage = ((pr_reaverattack() & 7) + 1) * 3; int damage = ((pr_reaverattack() & 7) + 1) * 3;
P_LineAttack (self, angle, MISSILERANGE, pitch, damage, NAME_Hitscan, NAME_StrifePuff); P_LineAttack (self, angle, MISSILERANGE, pitch, damage, NAME_Hitscan, NAME_StrifePuff);
} }

View file

@ -24,15 +24,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShootGun)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
int pitch; DAngle pitch;
if (self->target == NULL) if (self->target == NULL)
return 0; return 0;
S_Sound (self, CHAN_WEAPON, "monsters/rifle", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "monsters/rifle", 1, ATTN_NORM);
A_FaceTarget (self); A_FaceTarget (self);
pitch = P_AimLineAttack (self, self->_f_angle(), MISSILERANGE); pitch = P_AimLineAttack (self, self->Angles.Yaw, MISSILERANGE);
P_LineAttack (self, self->_f_angle() + (pr_shootgun.Random2() << 19), P_LineAttack (self, self->Angles.Yaw + pr_shootgun.Random2() * (11.25 / 256),
MISSILERANGE, pitch, MISSILERANGE, pitch,
3*(pr_shootgun() % 5 + 1), NAME_Hitscan, NAME_StrifePuff); 3*(pr_shootgun() % 5 + 1), NAME_Hitscan, NAME_StrifePuff);
return 0; return 0;

View file

@ -96,9 +96,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_JabDagger)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
angle_t angle; DAngle angle;
int damage; int damage;
int pitch; DAngle pitch;
int power; int power;
FTranslatedLineTarget t; FTranslatedLineTarget t;
@ -110,9 +110,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_JabDagger)
damage *= 10; damage *= 10;
} }
angle = self->_f_angle() + (pr_jabdagger.Random2() << 18); angle = self->Angles.Yaw + pr_jabdagger.Random2() * (5.625 / 256);
pitch = P_AimLineAttack (self, angle, 80*FRACUNIT); pitch = P_AimLineAttack (self, angle, 80.);
P_LineAttack (self, angle, 80*FRACUNIT, pitch, damage, NAME_Melee, "StrifeSpark", true, &t); P_LineAttack (self, angle, 80., pitch, damage, NAME_Melee, "StrifeSpark", true, &t);
// turn to face target // turn to face target
if (t.linetarget) if (t.linetarget)
@ -266,7 +266,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireArrow)
if (ti) if (ti)
{ {
savedangle = self->Angles.Yaw; savedangle = self->Angles.Yaw;
self->Angles.Yaw += ANGLE2DBL(pr_electric.Random2() << (18 - self->player->mo->accuracy * 5 / 100)); self->Angles.Yaw += pr_electric.Random2() * (5.625/256) * self->player->mo->AccuracyFactor();
self->player->mo->PlayAttacking2 (); self->player->mo->PlayAttacking2 ();
P_SpawnPlayerMissile (self, ti); P_SpawnPlayerMissile (self, ti);
self->Angles.Yaw = savedangle; self->Angles.Yaw = savedangle;
@ -283,17 +283,17 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireArrow)
// //
//============================================================================ //============================================================================
void P_StrifeGunShot (AActor *mo, bool accurate, angle_t pitch) void P_StrifeGunShot (AActor *mo, bool accurate, DAngle pitch)
{ {
angle_t angle; DAngle angle;
int damage; int damage;
damage = 4*(pr_sgunshot()%3+1); damage = 4*(pr_sgunshot()%3+1);
angle = mo->_f_angle(); angle = mo->Angles.Yaw;
if (mo->player != NULL && !accurate) if (mo->player != NULL && !accurate)
{ {
angle += pr_sgunshot.Random2() << (20 - mo->player->mo->accuracy * 5 / 100); angle += pr_sgunshot.Random2() * (5.625 / 256) * mo->player->mo->AccuracyFactor();
} }
P_LineAttack (mo, angle, PLAYERMISSILERANGE, pitch, damage, NAME_Hitscan, NAME_StrifePuff); P_LineAttack (mo, angle, PLAYERMISSILERANGE, pitch, damage, NAME_Hitscan, NAME_StrifePuff);
@ -359,7 +359,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMiniMissile)
} }
savedangle = self->Angles.Yaw; savedangle = self->Angles.Yaw;
self->Angles.Yaw += ANGLE2DBL(pr_minimissile.Random2() << (19 - player->mo->accuracy * 5 / 100)); self->Angles.Yaw += pr_minimissile.Random2() * (11.25 / 256) * player->mo->AccuracyFactor();
player->mo->PlayAttacking2 (); player->mo->PlayAttacking2 ();
P_SpawnPlayerMissile (self, PClass::FindActor("MiniMissile")); P_SpawnPlayerMissile (self, PClass::FindActor("MiniMissile"));
self->Angles.Yaw = savedangle; self->Angles.Yaw = savedangle;
@ -467,13 +467,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMauler1)
S_Sound (self, CHAN_WEAPON, "weapons/mauler1", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "weapons/mauler1", 1, ATTN_NORM);
int bpitch = P_BulletSlope (self); DAngle bpitch = P_BulletSlope (self);
for (int i = 0; i < 20; ++i) for (int i = 0; i < 20; ++i)
{ {
int damage = 5 * (pr_mauler1() % 3 + 1); int damage = 5 * (pr_mauler1() % 3 + 1);
angle_t angle = self->_f_angle() + (pr_mauler1.Random2() << 19); DAngle angle = self->Angles.Yaw + pr_mauler1.Random2() * (11.25 / 256);
int pitch = bpitch + (pr_mauler1.Random2() * 332063); DAngle pitch = bpitch + pr_mauler1.Random2() * (7.097 / 256);
// Strife used a range of 2112 units for the mauler to signal that // Strife used a range of 2112 units for the mauler to signal that
// it should use a different puff. ZDoom's default range is longer // it should use a different puff. ZDoom's default range is longer
@ -593,8 +593,8 @@ AActor *P_SpawnSubMissile (AActor *source, PClassActor *type, AActor *target)
if (P_CheckMissileSpawn (other, source->radius)) if (P_CheckMissileSpawn (other, source->radius))
{ {
angle_t pitch = P_AimLineAttack (source, source->_f_angle(), 1024*FRACUNIT); DAngle pitch = P_AimLineAttack (source, source->Angles.Yaw, 1024.);
other->vel.z = FixedMul (-finesine[pitch>>ANGLETOFINESHIFT], other->Speed); other->vel.z = fixed_t(-other->Speed * pitch.Cos());
return other; return other;
} }
return NULL; return NULL;
@ -1089,7 +1089,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil4)
P_BulletSlope (self, &t, ALF_PORTALRESTRICT); P_BulletSlope (self, &t, ALF_PORTALRESTRICT);
if (t.linetarget != NULL) if (t.linetarget != NULL)
{ {
spot = P_SpawnPlayerMissile (self, 0,0,0, PClass::FindActor("SpectralLightningBigV1"), self->_f_angle(), &t, NULL, false, false, ALF_PORTALRESTRICT); spot = P_SpawnPlayerMissile (self, 0,0,0, PClass::FindActor("SpectralLightningBigV1"), self->Angles.Yaw, &t, NULL, false, false, ALF_PORTALRESTRICT);
if (spot != NULL) if (spot != NULL)
{ {
spot->tracer = t.linetarget; spot->tracer = t.linetarget;

View file

@ -16,23 +16,21 @@ DEFINE_ACTION_FUNCTION(AActor, A_TemplarAttack)
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
int damage; int damage;
angle_t angle; DAngle angle;
int pitch; DAngle pitch;
int pitchdiff;
if (self->target == NULL) if (self->target == NULL)
return 0; return 0;
S_Sound (self, CHAN_WEAPON, "templar/shoot", 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, "templar/shoot", 1, ATTN_NORM);
A_FaceTarget (self); A_FaceTarget (self);
pitch = P_AimLineAttack (self, self->_f_angle(), MISSILERANGE); pitch = P_AimLineAttack (self, self->Angles.Yaw, MISSILERANGE);
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
{ {
damage = (pr_templar() & 4) * 2; damage = (pr_templar() & 4) * 2;
angle = self->_f_angle() + (pr_templar.Random2() << 19); angle = self->Angles.Yaw + pr_templar.Random2() * (11.25 / 256);
pitchdiff = pr_templar.Random2() * 332063; P_LineAttack (self, angle, MISSILERANGE+64., pitch + pr_templar.Random2() * (7.097 / 256), damage, NAME_Hitscan, NAME_MaulerPuff);
P_LineAttack (self, angle, MISSILERANGE+64*FRACUNIT, pitch+pitchdiff, damage, NAME_Hitscan, NAME_MaulerPuff);
} }
return 0; return 0;
} }

View file

@ -469,8 +469,8 @@ void cht_DoCheat (player_t *player, int cheat)
{ {
// Don't allow this in deathmatch even with cheats enabled, because it's // Don't allow this in deathmatch even with cheats enabled, because it's
// a very very cheap kill. // a very very cheap kill.
P_LineAttack (player->mo, player->mo->_f_angle(), PLAYERMISSILERANGE, P_LineAttack (player->mo, player->mo->Angles.Yaw, PLAYERMISSILERANGE,
P_AimLineAttack (player->mo, player->mo->_f_angle(), PLAYERMISSILERANGE), TELEFRAG_DAMAGE, P_AimLineAttack (player->mo, player->mo->Angles.Yaw, PLAYERMISSILERANGE), TELEFRAG_DAMAGE,
NAME_MDK, NAME_BulletPuff); NAME_MDK, NAME_BulletPuff);
} }
break; break;

View file

@ -4745,7 +4745,7 @@ static bool DoSpawnDecal(AActor *actor, const FDecalTemplate *tpl, int flags, an
static void SetActorAngle(AActor *activator, int tid, int angle, bool interpolate) static void SetActorAngle(AActor *activator, int tid, int angle, bool interpolate)
{ {
DAngle an = angle * (360. / 65536); DAngle an = angle * (360. / 65536.);
if (tid == 0) if (tid == 0)
{ {
if (activator != NULL) if (activator != NULL)
@ -5411,12 +5411,12 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args)
//[RC] A bullet firing function for ACS. Thanks to DavidPH. //[RC] A bullet firing function for ACS. Thanks to DavidPH.
case ACSF_LineAttack: case ACSF_LineAttack:
{ {
fixed_t angle = args[1] << FRACBITS; DAngle angle = args[1] * (360. / 65536.);
fixed_t pitch = args[2] << FRACBITS; DAngle pitch = args[2] * (360. / 65536.);
int damage = args[3]; int damage = args[3];
FName pufftype = argCount > 4 && args[4]? FName(FBehavior::StaticLookupString(args[4])) : NAME_BulletPuff; FName pufftype = argCount > 4 && args[4]? FName(FBehavior::StaticLookupString(args[4])) : NAME_BulletPuff;
FName damagetype = argCount > 5 && args[5]? FName(FBehavior::StaticLookupString(args[5])) : NAME_None; FName damagetype = argCount > 5 && args[5]? FName(FBehavior::StaticLookupString(args[5])) : NAME_None;
fixed_t range = argCount > 6 && args[6]? args[6] : MISSILERANGE; double range = argCount > 6 && args[6]? FIXED2DBL(args[6]) : MISSILERANGE;
int flags = argCount > 7 && args[7]? args[7] : 0; int flags = argCount > 7 && args[7]? args[7] : 0;
int pufftid = argCount > 8 && args[8]? args[8] : 0; int pufftid = argCount > 8 && args[8]? args[8] : 0;
@ -9220,7 +9220,7 @@ scriptwait:
switch (STACK(1)) switch (STACK(1))
{ {
case PLAYERINFO_TEAM: STACK(2) = userinfo->GetTeam(); break; case PLAYERINFO_TEAM: STACK(2) = userinfo->GetTeam(); break;
case PLAYERINFO_AIMDIST: STACK(2) = userinfo->GetAimDist(); break; case PLAYERINFO_AIMDIST: STACK(2) = FLOAT2ANGLE(userinfo->GetAimDist()); break; // Yes, this has been returning a BAM since its creation.
case PLAYERINFO_COLOR: STACK(2) = userinfo->GetColor(); break; case PLAYERINFO_COLOR: STACK(2) = userinfo->GetColor(); break;
case PLAYERINFO_GENDER: STACK(2) = userinfo->GetGender(); break; case PLAYERINFO_GENDER: STACK(2) = userinfo->GetGender(); break;
case PLAYERINFO_NEVERSWITCH: STACK(2) = userinfo->GetNeverSwitch(); break; case PLAYERINFO_NEVERSWITCH: STACK(2) = userinfo->GetNeverSwitch(); break;

View file

@ -308,13 +308,14 @@ bool P_CheckMeleeRange2 (AActor *actor)
AActor *mo; AActor *mo;
fixed_t dist; fixed_t dist;
if (!actor->target) if (!actor->target)
{ {
return false; return false;
} }
mo = actor->target; mo = actor->target;
dist = mo->AproxDistance (actor); dist = mo->AproxDistance (actor);
if (dist >= MELEERANGE*2 || dist < MELEERANGE-20*FRACUNIT + mo->radius) if (dist >= (128 << FRACBITS) || dist < actor->meleerange + mo->radius)
{ {
return false; return false;
} }
@ -430,9 +431,9 @@ bool P_HitFriend(AActor * self)
if (self->flags&MF_FRIENDLY && self->target != NULL) if (self->flags&MF_FRIENDLY && self->target != NULL)
{ {
angle_t angle = self->__f_AngleTo(self->target); DAngle angle = self->AngleTo(self->target);
fixed_t dist = self->AproxDistance (self->target); double dist = self->Distance2D(self->target);
P_AimLineAttack (self, angle, dist, &t, 0, true); P_AimLineAttack (self, angle, dist, &t, 0., true);
if (t.linetarget != NULL && t.linetarget != self->target) if (t.linetarget != NULL && t.linetarget != self->target)
{ {
return self->IsFriend (t.linetarget); return self->IsFriend (t.linetarget);
@ -973,7 +974,7 @@ void P_NewChaseDir(AActor * actor)
{ {
// melee range of player weapon is a parameter of the action function and cannot be checked here. // melee range of player weapon is a parameter of the action function and cannot be checked here.
// Add a new weapon property? // Add a new weapon property?
ismeleeattacker = (target->player->ReadyWeapon->WeaponFlags & WIF_MELEEWEAPON && dist < MELEERANGE*3); ismeleeattacker = (target->player->ReadyWeapon->WeaponFlags & WIF_MELEEWEAPON && dist < (192 << FRACBITS));
} }
if (ismeleeattacker) if (ismeleeattacker)
{ {
@ -1197,7 +1198,7 @@ bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams
{ {
// if real close, react anyway // if real close, react anyway
// [KS] but respect minimum distance rules // [KS] but respect minimum distance rules
if (mindist || dist > MELEERANGE) if (mindist || dist > lookee->meleerange + lookee->radius)
return false; // outside of fov return false; // outside of fov
} }
} }
@ -1732,7 +1733,7 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params)
if ((player->mo->flags & MF_SHADOW && !(i_compatflags & COMPATF_INVISIBILITY)) || if ((player->mo->flags & MF_SHADOW && !(i_compatflags & COMPATF_INVISIBILITY)) ||
player->mo->flags3 & MF3_GHOST) player->mo->flags3 & MF3_GHOST)
{ {
if ((player->mo->AproxDistance (actor) > 2*MELEERANGE) if ((player->mo->AproxDistance (actor) > (128 << FRACBITS))
&& P_AproxDistance (player->mo->vel.x, player->mo->vel.y) < 5*FRACUNIT) && P_AproxDistance (player->mo->vel.x, player->mo->vel.y) < 5*FRACUNIT)
{ // Player is sneaking - can't detect { // Player is sneaking - can't detect
continue; continue;
@ -2995,7 +2996,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail)
self->Angles.Yaw = self->AngleTo(self->target); self->Angles.Yaw = self->AngleTo(self->target);
self->Angles.Pitch = ANGLE2DBL(P_AimLineAttack (self, self->_f_angle(), MISSILERANGE, &t, ANGLE_1*60, 0, self->target)); self->Angles.Pitch = P_AimLineAttack (self, self->Angles.Yaw, MISSILERANGE, &t, 60., 0, self->target);
if (t.linetarget == NULL) if (t.linetarget == NULL)
{ {
// We probably won't hit the target, but aim at it anyway so we don't look stupid. // We probably won't hit the target, but aim at it anyway so we don't look stupid.

View file

@ -80,19 +80,16 @@ inline int GetSafeBlockY(long long blocky)
return int((blocky <= bmapnegy) ? blocky & 0x1FF: blocky); return int((blocky <= bmapnegy) ? blocky & 0x1FF: blocky);
} }
// MAXRADIUS is for precalculated sector block boxes
// the spider demon is larger,
// but we do not have any moving sectors nearby
#define MAXRADIUS 0/*32*FRACUNIT*/
//#define GRAVITY FRACUNIT //#define GRAVITY FRACUNIT
#define MAXMOVE (30*FRACUNIT) #define MAXMOVE (30*FRACUNIT)
#define TALKRANGE (128*FRACUNIT) #define TALKRANGE (128.)
#define USERANGE (64*FRACUNIT) #define USERANGE (64*FRACUNIT)
#define MELEERANGE (64*FRACUNIT)
#define MISSILERANGE (32*64*FRACUNIT) #define MELEERANGE (64.)
#define PLAYERMISSILERANGE (8192*FRACUNIT) // [RH] New MISSILERANGE for players #define SAWRANGE (64.+(1./65536.)) // use meleerange + 1 so the puff doesn't skip the flash (i.e. plays all states)
#define MISSILERANGE (32*64.)
#define PLAYERMISSILERANGE (8192.) // [RH] New MISSILERANGE for players
// follow a player exlusively for 3 seconds // follow a player exlusively for 3 seconds
// No longer used. // No longer used.
@ -178,8 +175,8 @@ AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z, PClassActor *type,
AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, PClassActor *type); AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, PClassActor *type);
AActor *P_SpawnPlayerMissile (AActor* source, PClassActor *type); AActor *P_SpawnPlayerMissile (AActor* source, PClassActor *type);
AActor *P_SpawnPlayerMissile (AActor *source, PClassActor *type, angle_t angle); AActor *P_SpawnPlayerMissile (AActor *source, PClassActor *type, DAngle angle);
AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z, PClassActor *type, angle_t angle, AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z, PClassActor *type, DAngle angle,
FTranslatedLineTarget *pLineTarget = NULL, AActor **MissileActor = NULL, bool nofreeaim = false, bool noautoaim = false, int aimflags = 0); FTranslatedLineTarget *pLineTarget = NULL, AActor **MissileActor = NULL, bool nofreeaim = false, bool noautoaim = false, int aimflags = 0);
void P_CheckFakeFloorTriggers (AActor *mo, fixed_t oldz, bool oldz_has_viewheight=false); void P_CheckFakeFloorTriggers (AActor *mo, fixed_t oldz, bool oldz_has_viewheight=false);
@ -312,7 +309,7 @@ void P_FindFloorCeiling (AActor *actor, int flags=0);
bool P_ChangeSector (sector_t* sector, int crunch, int amt, int floorOrCeil, bool isreset); bool P_ChangeSector (sector_t* sector, int crunch, int amt, int floorOrCeil, bool isreset);
fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance, FTranslatedLineTarget *pLineTarget = NULL, fixed_t vrange=0, int flags = 0, AActor *target=NULL, AActor *friender=NULL); DAngle P_AimLineAttack(AActor *t1, DAngle angle, double distance, FTranslatedLineTarget *pLineTarget = NULL, DAngle vrange = 0., int flags = 0, AActor *target = NULL, AActor *friender = NULL);
enum // P_AimLineAttack flags enum // P_AimLineAttack flags
{ {
@ -331,8 +328,9 @@ enum // P_LineAttack flags
LAF_NOIMPACTDECAL = 4 LAF_NOIMPACTDECAL = 4
}; };
AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, PClassActor *pufftype, int flags = 0, FTranslatedLineTarget *victim = NULL, int *actualdamage = NULL); AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, DAngle pitch, int damage, FName damageType, PClassActor *pufftype, int flags = 0, FTranslatedLineTarget *victim = NULL, int *actualdamage = NULL);
AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, int pitch, int damage, FName damageType, FName pufftype, int flags = 0, FTranslatedLineTarget *victim = NULL, int *actualdamage = NULL); AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, DAngle pitch, int damage, FName damageType, FName pufftype, int flags = 0, FTranslatedLineTarget *victim = NULL, int *actualdamage = NULL);
void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *target, angle_t angle, int pitch); void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *target, angle_t angle, int pitch);
inline void P_TraceBleed(int damage, const fixedvec3 &pos, AActor *target, angle_t angle, int pitch) inline void P_TraceBleed(int damage, const fixedvec3 &pos, AActor *target, angle_t angle, int pitch)
{ {

View file

@ -4045,7 +4045,7 @@ struct aim_t
// //
//============================================================================ //============================================================================
fixed_t P_AimLineAttack(AActor *t1, angle_t angle, fixed_t distance, FTranslatedLineTarget *pLineTarget, fixed_t vrange, DAngle P_AimLineAttack(AActor *t1, DAngle angle, double distance, FTranslatedLineTarget *pLineTarget, DAngle vrange,
int flags, AActor *target, AActor *friender) int flags, AActor *target, AActor *friender)
{ {
fixed_t shootz = t1->Z() + (t1->height >> 1) - t1->floorclip; fixed_t shootz = t1->Z() + (t1->height >> 1) - t1->floorclip;
@ -4063,7 +4063,7 @@ fixed_t P_AimLineAttack(AActor *t1, angle_t angle, fixed_t distance, FTranslated
{ {
if (t1->player == NULL || !level.IsFreelookAllowed()) if (t1->player == NULL || !level.IsFreelookAllowed())
{ {
vrange = ANGLE_1 * 35; vrange = 35.;
} }
else else
{ {
@ -4071,7 +4071,7 @@ fixed_t P_AimLineAttack(AActor *t1, angle_t angle, fixed_t distance, FTranslated
AWeapon *weapon = t1->player->ReadyWeapon; AWeapon *weapon = t1->player->ReadyWeapon;
if (weapon && (weapon->WeaponFlags & WIF_NOAUTOAIM)) if (weapon && (weapon->WeaponFlags & WIF_NOAUTOAIM))
{ {
vrange = ANGLE_1 / 2; vrange = 0.5;
} }
else else
{ {
@ -4079,7 +4079,7 @@ fixed_t P_AimLineAttack(AActor *t1, angle_t angle, fixed_t distance, FTranslated
// vrange of 0 degrees, because then toppitch and bottompitch will // vrange of 0 degrees, because then toppitch and bottompitch will
// be equal, and PTR_AimTraverse will never find anything to shoot at // be equal, and PTR_AimTraverse will never find anything to shoot at
// if it crosses a line. // if it crosses a line.
vrange = clamp(t1->player->userinfo.GetAimDist(), ANGLE_1 / 2, ANGLE_1 * 35); vrange = clamp(t1->player->userinfo.GetAimDist(), 0.5, 35.);
} }
} }
} }
@ -4091,11 +4091,11 @@ fixed_t P_AimLineAttack(AActor *t1, angle_t angle, fixed_t distance, FTranslated
aim.friender = (friender == NULL) ? t1 : friender; aim.friender = (friender == NULL) ? t1 : friender;
aim.aimdir = aim_t::aim_up | aim_t::aim_down; aim.aimdir = aim_t::aim_up | aim_t::aim_down;
aim.startpos = t1->Pos(); aim.startpos = t1->Pos();
aim.aimtrace = Vec2Angle(distance, angle); aim.aimtrace = Vec2Angle(FLOAT2FIXED(distance), angle);
aim.limitz = aim.shootz = shootz; aim.limitz = aim.shootz = shootz;
aim.toppitch = t1->_f_pitch() - vrange; aim.toppitch = (t1->Angles.Pitch - vrange).BAMs();
aim.bottompitch = t1->_f_pitch() + vrange; aim.bottompitch = (t1->Angles.Pitch + vrange).BAMs();
aim.attackrange = distance; aim.attackrange = FLOAT2FIXED(distance);
aim.aimpitch = t1->_f_pitch(); aim.aimpitch = t1->_f_pitch();
aim.lastsector = t1->Sector; aim.lastsector = t1->Sector;
aim.startfrac = 0; aim.startfrac = 0;
@ -4110,7 +4110,7 @@ fixed_t P_AimLineAttack(AActor *t1, angle_t angle, fixed_t distance, FTranslated
{ {
*pLineTarget = *result; *pLineTarget = *result;
} }
return result->linetarget ? result->pitch : t1->_f_pitch(); return result->linetarget ? DAngle(ANGLE2DBL(result->pitch)) : t1->Angles.Pitch;
} }
@ -4162,15 +4162,15 @@ static ETraceStatus CheckForActor(FTraceResults &res, void *userdata)
// //
//========================================================================== //==========================================================================
AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance, AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
int pitch, int damage, FName damageType, PClassActor *pufftype, int flags, FTranslatedLineTarget*victim, int *actualdamage) DAngle pitch, int damage, FName damageType, PClassActor *pufftype, int flags, FTranslatedLineTarget*victim, int *actualdamage)
{ {
fixed_t vx, vy, vz, shootz; fixed_t vx, vy, vz, shootz;
FTraceResults trace; FTraceResults trace;
Origin TData; Origin TData;
TData.Caller = t1; TData.Caller = t1;
angle_t srcangle = angle; angle_t srcangle = angle.BAMs();
int srcpitch = pitch; int srcpitch = pitch.BAMs();
bool killPuff = false; bool killPuff = false;
AActor *puff = NULL; AActor *puff = NULL;
int pflag = 0; int pflag = 0;
@ -4187,12 +4187,11 @@ AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance,
*actualdamage = 0; *actualdamage = 0;
} }
angle >>= ANGLETOFINESHIFT; double pc = pitch.Cos();
pitch = (angle_t)(pitch) >> ANGLETOFINESHIFT;
vx = FixedMul(finecosine[pitch], finecosine[angle]); vx = FLOAT2FIXED(pc * angle.Cos());
vy = FixedMul(finecosine[pitch], finesine[angle]); vy = FLOAT2FIXED(pc * angle.Sin());
vz = -finesine[pitch]; vz = FLOAT2FIXED(-pitch.Sin());
shootz = t1->Z() - t1->floorclip + (t1->height >> 1); shootz = t1->Z() - t1->floorclip + (t1->height >> 1);
if (t1->player != NULL) if (t1->player != NULL)
@ -4232,7 +4231,7 @@ AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance,
if (puffDefaults != NULL && puffDefaults->flags6 & MF6_NOTRIGGER) tflags = TRACE_NoSky; if (puffDefaults != NULL && puffDefaults->flags6 & MF6_NOTRIGGER) tflags = TRACE_NoSky;
else tflags = TRACE_NoSky | TRACE_Impact; else tflags = TRACE_NoSky | TRACE_Impact;
if (!Trace(t1->X(), t1->Y(), shootz, t1->Sector, vx, vy, vz, distance, if (!Trace(t1->X(), t1->Y(), shootz, t1->Sector, vx, vy, vz, FLOAT2FIXED(distance),
MF_SHOOTABLE, ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, t1, trace, MF_SHOOTABLE, ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, t1, trace,
tflags, CheckForActor, &TData)) tflags, CheckForActor, &TData))
{ // hit nothing { // hit nothing
@ -4419,8 +4418,8 @@ AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance,
return puff; return puff;
} }
AActor *P_LineAttack(AActor *t1, angle_t angle, fixed_t distance, AActor *P_LineAttack(AActor *t1, DAngle angle, double distance,
int pitch, int damage, FName damageType, FName pufftype, int flags, FTranslatedLineTarget *victim, int *actualdamage) DAngle pitch, int damage, FName damageType, FName pufftype, int flags, FTranslatedLineTarget *victim, int *actualdamage)
{ {
PClassActor *type = PClass::FindActor(pufftype); PClassActor *type = PClass::FindActor(pufftype);
if (type == NULL) if (type == NULL)
@ -4930,12 +4929,12 @@ void P_AimCamera(AActor *t1, fixed_t &CameraX, fixed_t &CameraY, fixed_t &Camera
bool P_TalkFacing(AActor *player) bool P_TalkFacing(AActor *player)
{ {
static const int angleofs[] = { 0, ANGLE_90 >> 4, - ANGLE_90 >> 4 }; static const double angleofs[] = { 0, 90./16, -90./16 };
FTranslatedLineTarget t; FTranslatedLineTarget t;
for (int angle : angleofs) for (double angle : angleofs)
{ {
P_AimLineAttack(player, player->_f_angle() + angle, TALKRANGE, &t, ANGLE_1 * 35, ALF_FORCENOSMART | ALF_CHECKCONVERSATION | ALF_PORTALRESTRICT); P_AimLineAttack(player, player->Angles.Yaw + angle, TALKRANGE, &t, 35., ALF_FORCENOSMART | ALF_CHECKCONVERSATION | ALF_PORTALRESTRICT);
if (t.linetarget != NULL) if (t.linetarget != NULL)
{ {
if (t.linetarget->health > 0 && // Dead things can't talk. if (t.linetarget->health > 0 && // Dead things can't talk.

View file

@ -1763,7 +1763,7 @@ bool P_SeekerMissile (AActor *actor, angle_t _thresh, angle_t _turnMax, bool pre
DAngle pitch = 0.; DAngle pitch = 0.;
if (!(actor->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER))) if (!(actor->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)))
{ // Need to seek vertically { // Need to seek vertically
fixed_t dist = MAX(1, actor->Distance2D(target)); fixed_t dist = MAX(1, FLOAT2FIXED(actor->Distance2D(target)));
// Aim at a player's eyes and at the middle of the actor for everything else. // Aim at a player's eyes and at the middle of the actor for everything else.
fixed_t aimheight = target->height/2; fixed_t aimheight = target->height/2;
if (target->IsKindOf(RUNTIME_CLASS(APlayerPawn))) if (target->IsKindOf(RUNTIME_CLASS(APlayerPawn)))
@ -6150,24 +6150,25 @@ AActor *P_SpawnPlayerMissile (AActor *source, PClassActor *type)
{ {
return NULL; return NULL;
} }
return P_SpawnPlayerMissile (source, 0, 0, 0, type, source->_f_angle()); return P_SpawnPlayerMissile (source, 0, 0, 0, type, source->Angles.Yaw);
} }
AActor *P_SpawnPlayerMissile (AActor *source, PClassActor *type, angle_t angle) AActor *P_SpawnPlayerMissile (AActor *source, PClassActor *type, DAngle angle)
{ {
return P_SpawnPlayerMissile (source, 0, 0, 0, type, angle); return P_SpawnPlayerMissile (source, 0, 0, 0, type, angle);
} }
AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z, AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z,
PClassActor *type, angle_t angle, FTranslatedLineTarget *pLineTarget, AActor **pMissileActor, PClassActor *type, DAngle angle, FTranslatedLineTarget *pLineTarget, AActor **pMissileActor,
bool nofreeaim, bool noautoaim, int aimflags) bool nofreeaim, bool noautoaim, int aimflags)
{ {
//static const double angdiff[3] = { -5.625, 5.625, 0 };
static const int angdiff[3] = { -(1<<26), 1<<26, 0 }; static const int angdiff[3] = { -(1<<26), 1<<26, 0 };
angle_t an = angle; DAngle an = angle;
angle_t pitch; DAngle pitch;
FTranslatedLineTarget scratch; FTranslatedLineTarget scratch;
AActor *defaultobject = GetDefaultByType(type); AActor *defaultobject = GetDefaultByType(type);
int vrange = nofreeaim ? ANGLE_1*35 : 0; DAngle vrange = nofreeaim ? 35. : 0.;
if (source == NULL) if (source == NULL)
{ {
@ -6178,7 +6179,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z,
{ {
// Keep exactly the same angle and pitch as the player's own aim // Keep exactly the same angle and pitch as the player's own aim
an = angle; an = angle;
pitch = source->_f_pitch(); pitch = source->Angles.Pitch;
pLineTarget->linetarget = NULL; pLineTarget->linetarget = NULL;
} }
else // see which target is to be aimed at else // see which target is to be aimed at
@ -6186,7 +6187,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z,
// [XA] If MaxTargetRange is defined in the spawned projectile, use this as the // [XA] If MaxTargetRange is defined in the spawned projectile, use this as the
// maximum range for the P_AimLineAttack call later; this allows MaxTargetRange // maximum range for the P_AimLineAttack call later; this allows MaxTargetRange
// to function as a "maximum tracer-acquisition range" for seeker missiles. // to function as a "maximum tracer-acquisition range" for seeker missiles.
fixed_t linetargetrange = defaultobject->maxtargetrange > 0 ? defaultobject->maxtargetrange*64 : 16*64*FRACUNIT; double linetargetrange = defaultobject->maxtargetrange > 0 ? FIXED2DBL(defaultobject->maxtargetrange*64) : 16*64.;
int i = 2; int i = 2;
do do
@ -6197,7 +6198,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z,
if (source->player != NULL && if (source->player != NULL &&
!nofreeaim && !nofreeaim &&
level.IsFreelookAllowed() && level.IsFreelookAllowed() &&
source->player->userinfo.GetAimDist() <= ANGLE_1/2) source->player->userinfo.GetAimDist() <= 0.5)
{ {
break; break;
} }
@ -6208,7 +6209,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z,
an = angle; an = angle;
if (nofreeaim || !level.IsFreelookAllowed()) if (nofreeaim || !level.IsFreelookAllowed())
{ {
pitch = 0; pitch = 0.;
} }
} }
} }
@ -6236,14 +6237,14 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z,
if (pMissileActor) *pMissileActor = MissileActor; if (pMissileActor) *pMissileActor = MissileActor;
P_PlaySpawnSound(MissileActor, source); P_PlaySpawnSound(MissileActor, source);
MissileActor->target = source; MissileActor->target = source;
MissileActor->Angles.Yaw = ANGLE2DBL(an); MissileActor->Angles.Yaw = an;
if (MissileActor->flags3 & (MF3_FLOORHUGGER | MF3_CEILINGHUGGER)) if (MissileActor->flags3 & (MF3_FLOORHUGGER | MF3_CEILINGHUGGER))
{ {
MissileActor->VelFromAngle(); MissileActor->VelFromAngle();
} }
else else
{ {
MissileActor->Vel3DFromAngle(ANGLE2DBL(pitch), MissileActor->Speed); MissileActor->Vel3DFromAngle(pitch, MissileActor->Speed);
} }
if (MissileActor->flags4 & MF4_SPECTRAL) if (MissileActor->flags4 & MF4_SPECTRAL)

View file

@ -919,12 +919,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_GunFlash)
// the height of the intended target // the height of the intended target
// //
angle_t P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget, int aimflags) DAngle P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget, int aimflags)
{ {
static const int angdiff[3] = { -(1<<26), 1<<26, 0 }; static const double angdiff[3] = { -5.625f, 5.625f, 0 };
int i; int i;
angle_t an; DAngle an;
angle_t pitch; DAngle pitch;
FTranslatedLineTarget scratch; FTranslatedLineTarget scratch;
if (pLineTarget == NULL) pLineTarget = &scratch; if (pLineTarget == NULL) pLineTarget = &scratch;
@ -932,12 +932,12 @@ angle_t P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget, int aimfl
i = 2; i = 2;
do do
{ {
an = mo->_f_angle() + angdiff[i]; an = mo->Angles.Yaw + angdiff[i];
pitch = P_AimLineAttack (mo, an, 16*64*FRACUNIT, pLineTarget, 0, aimflags); pitch = P_AimLineAttack (mo, an, 16.*64, pLineTarget, 0., aimflags);
if (mo->player != NULL && if (mo->player != NULL &&
level.IsFreelookAllowed() && level.IsFreelookAllowed() &&
mo->player->userinfo.GetAimDist() <= ANGLE_1/2) mo->player->userinfo.GetAimDist() <= 0.5)
{ {
break; break;
} }
@ -950,17 +950,17 @@ angle_t P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget, int aimfl
// //
// P_GunShot // P_GunShot
// //
void P_GunShot (AActor *mo, bool accurate, PClassActor *pufftype, angle_t pitch) void P_GunShot (AActor *mo, bool accurate, PClassActor *pufftype, DAngle pitch)
{ {
angle_t angle; DAngle angle;
int damage; int damage;
damage = 5*(pr_gunshot()%3+1); damage = 5*(pr_gunshot()%3+1);
angle = mo->_f_angle(); angle = mo->Angles.Yaw;
if (!accurate) if (!accurate)
{ {
angle += pr_gunshot.Random2 () << 18; angle += pr_gunshot.Random2 () * (5.625 / 256);
} }
P_LineAttack (mo, angle, PLAYERMISSILERANGE, pitch, damage, NAME_Hitscan, pufftype); P_LineAttack (mo, angle, PLAYERMISSILERANGE, pitch, damage, NAME_Hitscan, pufftype);

View file

@ -88,8 +88,9 @@ void P_BringUpWeapon (player_t *player);
void P_FireWeapon (player_t *player); void P_FireWeapon (player_t *player);
void P_DropWeapon (player_t *player); void P_DropWeapon (player_t *player);
void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y); void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y);
angle_t P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget = NULL, int aimflags = 0); DAngle P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget = NULL, int aimflags = 0);
void P_GunShot (AActor *mo, bool accurate, PClassActor *pufftype, angle_t pitch);
void P_GunShot (AActor *mo, bool accurate, PClassActor *pufftype, DAngle pitch);
void DoReadyWeapon(AActor *self); void DoReadyWeapon(AActor *self);
void DoReadyWeaponToBob(AActor *self); void DoReadyWeaponToBob(AActor *self);

View file

@ -824,20 +824,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_BulletAttack)
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
int i; int i;
int bangle;
int slope;
if (!self->target) return 0; if (!self->target) return 0;
A_FaceTarget (self); A_FaceTarget (self);
bangle = self->_f_angle();
slope = P_AimLineAttack (self, bangle, MISSILERANGE); DAngle slope = P_AimLineAttack (self, self->Angles.Yaw, MISSILERANGE);
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
for (i = self->GetMissileDamage (0, 1); i > 0; --i) for (i = self->GetMissileDamage (0, 1); i > 0; --i)
{ {
int angle = bangle + (pr_cabullet.Random2() << 20); DAngle angle = self->Angles.Yaw + pr_cabullet.Random2() * (5.625 / 256.);
int damage = ((pr_cabullet()%5)+1)*3; int damage = ((pr_cabullet()%5)+1)*3;
P_LineAttack(self, angle, MISSILERANGE, slope, damage, P_LineAttack(self, angle, MISSILERANGE, slope, damage,
NAME_Hitscan, NAME_BulletPuff); NAME_Hitscan, NAME_BulletPuff);
@ -1095,12 +1092,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Explode)
if (nails) if (nails)
{ {
angle_t ang; DAngle ang;
for (int i = 0; i < nails; i++) for (int i = 0; i < nails; i++)
{ {
ang = i*(ANGLE_MAX/nails); ang = i*360./nails;
// Comparing the results of a test wad with Eternity, it seems A_NailBomb does not aim // Comparing the results of a test wad with Eternity, it seems A_NailBomb does not aim
P_LineAttack (self, ang, MISSILERANGE, 0, P_LineAttack (self, ang, MISSILERANGE, 0.,
//P_AimLineAttack (self, ang, MISSILERANGE), //P_AimLineAttack (self, ang, MISSILERANGE),
naildamage, NAME_Hitscan, pufftype); naildamage, NAME_Hitscan, pufftype);
} }
@ -1347,12 +1344,12 @@ enum CBA_Flags
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_ANGLE (spread_xy); PARAM_DANGLE (spread_xy);
PARAM_ANGLE (spread_z); PARAM_DANGLE (spread_z);
PARAM_INT (numbullets); PARAM_INT (numbullets);
PARAM_INT (damageperbullet); PARAM_INT (damageperbullet);
PARAM_CLASS_OPT (pufftype, AActor) { pufftype = PClass::FindActor(NAME_BulletPuff); } PARAM_CLASS_OPT (pufftype, AActor) { pufftype = PClass::FindActor(NAME_BulletPuff); }
PARAM_FIXED_OPT (range) { range = MISSILERANGE; } PARAM_FLOAT_OPT (range) { range = 0; }
PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (flags) { flags = 0; }
PARAM_INT_OPT (ptr) { ptr = AAPTR_TARGET; } PARAM_INT_OPT (ptr) { ptr = AAPTR_TARGET; }
@ -1362,8 +1359,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack)
range = MISSILERANGE; range = MISSILERANGE;
int i; int i;
int bangle; DAngle bangle;
int bslope = 0; DAngle bslope = 0.;
int laflags = (flags & CBAF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0; int laflags = (flags & CBAF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0;
if (ref != NULL || (flags & CBAF_AIMFACING)) if (ref != NULL || (flags & CBAF_AIMFACING))
@ -1372,15 +1369,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack)
{ {
A_Face(self, ref); A_Face(self, ref);
} }
bangle = self->_f_angle(); bangle = self->Angles.Yaw;
if (!(flags & CBAF_NOPITCH)) bslope = P_AimLineAttack (self, bangle, MISSILERANGE); if (!(flags & CBAF_NOPITCH)) bslope = P_AimLineAttack (self, bangle, MISSILERANGE);
S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
for (i = 0; i < numbullets; i++) for (i = 0; i < numbullets; i++)
{ {
int angle = bangle; DAngle angle = bangle;
int slope = bslope; DAngle slope = bslope;
if (flags & CBAF_EXPLICITANGLE) if (flags & CBAF_EXPLICITANGLE)
{ {
@ -1389,8 +1386,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomBulletAttack)
} }
else else
{ {
angle += pr_cwbullet.Random2() * (spread_xy / 255); angle += spread_xy * (pr_cwbullet.Random2() / 255.);
slope += pr_cwbullet.Random2() * (spread_z / 255); slope += spread_z * (pr_cwbullet.Random2() / 255.);
} }
int damage = damageperbullet; int damage = damageperbullet;
@ -1531,13 +1528,13 @@ enum FB_Flags
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
{ {
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_ANGLE (spread_xy); PARAM_DANGLE (spread_xy);
PARAM_ANGLE (spread_z); PARAM_DANGLE (spread_z);
PARAM_INT (numbullets); PARAM_INT (numbullets);
PARAM_INT (damageperbullet); PARAM_INT (damageperbullet);
PARAM_CLASS_OPT (pufftype, AActor) { pufftype = NULL; } PARAM_CLASS_OPT (pufftype, AActor) { pufftype = NULL; }
PARAM_INT_OPT (flags) { flags = FBF_USEAMMO; } PARAM_INT_OPT (flags) { flags = FBF_USEAMMO; }
PARAM_FIXED_OPT (range) { range = 0; } PARAM_FLOAT_OPT (range) { range = 0; }
if (!self->player) return 0; if (!self->player) return 0;
@ -1545,8 +1542,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
AWeapon *weapon = player->ReadyWeapon; AWeapon *weapon = player->ReadyWeapon;
int i; int i;
int bangle; DAngle bangle;
int bslope = 0; DAngle bslope = 0.;
int laflags = (flags & FBF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0; int laflags = (flags & FBF_NORANDOMPUFFZ)? LAF_NORANDOMPUFFZ : 0;
if ((flags & FBF_USEAMMO) && weapon && ACTION_CALL_FROM_WEAPON()) if ((flags & FBF_USEAMMO) && weapon && ACTION_CALL_FROM_WEAPON())
@ -1561,7 +1558,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
if (!(flags & FBF_NOFLASH)) static_cast<APlayerPawn *>(self)->PlayAttacking2 (); if (!(flags & FBF_NOFLASH)) static_cast<APlayerPawn *>(self)->PlayAttacking2 ();
if (!(flags & FBF_NOPITCH)) bslope = P_BulletSlope(self); if (!(flags & FBF_NOPITCH)) bslope = P_BulletSlope(self);
bangle = self->_f_angle(); bangle = self->Angles.Yaw;
if (pufftype == NULL) if (pufftype == NULL)
pufftype = PClass::FindActor(NAME_BulletPuff); pufftype = PClass::FindActor(NAME_BulletPuff);
@ -1586,8 +1583,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
numbullets = 1; numbullets = 1;
for (i = 0; i < numbullets; i++) for (i = 0; i < numbullets; i++)
{ {
int angle = bangle; DAngle angle = bangle;
int slope = bslope; DAngle slope = bslope;
if (flags & FBF_EXPLICITANGLE) if (flags & FBF_EXPLICITANGLE)
{ {
@ -1596,8 +1593,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireBullets)
} }
else else
{ {
angle += pr_cwbullet.Random2() * (spread_xy / 255); angle += spread_xy * (pr_cwbullet.Random2() / 255.);
slope += pr_cwbullet.Random2() * (spread_z / 255); slope += spread_z * (pr_cwbullet.Random2() / 255.);
} }
int damage = damageperbullet; int damage = damageperbullet;
@ -1661,7 +1658,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile)
// Temporarily adjusts the pitch // Temporarily adjusts the pitch
DAngle saved_player_pitch = self->Angles.Pitch; DAngle saved_player_pitch = self->Angles.Pitch;
self->Angles.Pitch -= pitch; self->Angles.Pitch -= pitch;
AActor * misl=P_SpawnPlayerMissile (self, x, y, z, ti, FLOAT2ANGLE(shootangle.Degrees), &t, NULL, false, (flags & FPF_NOAUTOAIM) != 0); AActor * misl=P_SpawnPlayerMissile (self, x, y, z, ti, shootangle, &t, NULL, false, (flags & FPF_NOAUTOAIM) != 0);
self->Angles.Pitch = saved_player_pitch; self->Angles.Pitch = saved_player_pitch;
// automatic handling of seeker missiles // automatic handling of seeker missiles
@ -1711,7 +1708,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
PARAM_BOOL_OPT (norandom) { norandom = false; } PARAM_BOOL_OPT (norandom) { norandom = false; }
PARAM_INT_OPT (flags) { flags = CPF_USEAMMO; } PARAM_INT_OPT (flags) { flags = CPF_USEAMMO; }
PARAM_CLASS_OPT (pufftype, AActor) { pufftype = NULL; } PARAM_CLASS_OPT (pufftype, AActor) { pufftype = NULL; }
PARAM_FIXED_OPT (range) { range = 0; } PARAM_FLOAT_OPT (range) { range = 0; }
PARAM_FIXED_OPT (lifesteal) { lifesteal = 0; } PARAM_FIXED_OPT (lifesteal) { lifesteal = 0; }
PARAM_INT_OPT (lifestealmax) { lifestealmax = 0; } PARAM_INT_OPT (lifestealmax) { lifestealmax = 0; }
PARAM_CLASS_OPT (armorbonustype, ABasicArmorBonus) { armorbonustype = NULL; } PARAM_CLASS_OPT (armorbonustype, ABasicArmorBonus) { armorbonustype = NULL; }
@ -1725,17 +1722,16 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
AWeapon *weapon = player->ReadyWeapon; AWeapon *weapon = player->ReadyWeapon;
angle_t angle; DAngle angle;
int pitch; DAngle pitch;
FTranslatedLineTarget t; FTranslatedLineTarget t;
int actualdamage; int actualdamage;
if (!norandom) if (!norandom)
damage *= pr_cwpunch() % 8 + 1; damage *= pr_cwpunch() % 8 + 1;
angle = self->_f_angle() + (pr_cwpunch.Random2() << 18); angle = self->Angles.Yaw + pr_cwpunch.Random2() * (5.625 / 256);
if (range == 0) if (range == 0) range = MELEERANGE;
range = MELEERANGE;
pitch = P_AimLineAttack (self, angle, range, &t); pitch = P_AimLineAttack (self, angle, range, &t);
// only use ammo when actually hitting something! // only use ammo when actually hitting something!
@ -1923,7 +1919,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun)
{ {
self->Angles.Yaw = self->AngleTo(self->target); self->Angles.Yaw = self->AngleTo(self->target);
} }
self->Angles.Pitch = ANGLE2DBL(P_AimLineAttack (self, self->_f_angle(), MISSILERANGE, &t, ANGLE_1*60, 0, aim ? self->target : NULL)); self->Angles.Pitch = P_AimLineAttack (self, self->Angles.Yaw, MISSILERANGE, &t, 60., 0, aim ? self->target : NULL);
if (t.linetarget == NULL && aim) if (t.linetarget == NULL && aim)
{ {
// We probably won't hit the target, but aim at it anyway so we don't look stupid. // We probably won't hit the target, but aim at it anyway so we don't look stupid.
@ -3725,11 +3721,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF)
PARAM_ACTION_PROLOGUE; PARAM_ACTION_PROLOGUE;
PARAM_STATE (jump); PARAM_STATE (jump);
PARAM_INT_OPT (flags) { flags = 0; } PARAM_INT_OPT (flags) { flags = 0; }
PARAM_FIXED_OPT (range) { range = 0; } PARAM_FLOAT_OPT (range) { range = 0; }
PARAM_FIXED_OPT (minrange) { minrange = 0; } PARAM_FLOAT_OPT (minrange) { minrange = 0; }
{ {
PARAM_ANGLE_OPT (angle) { angle = 0; } PARAM_DANGLE_OPT(angle) { angle = 0.; }
PARAM_ANGLE_OPT (pitch) { pitch = 0; } PARAM_DANGLE_OPT(pitch) { pitch = 0.; }
PARAM_FIXED_OPT (offsetheight) { offsetheight = 0; } PARAM_FIXED_OPT (offsetheight) { offsetheight = 0; }
PARAM_FIXED_OPT (offsetwidth) { offsetwidth = 0; } PARAM_FIXED_OPT (offsetwidth) { offsetwidth = 0; }
PARAM_INT_OPT (ptr_target) { ptr_target = AAPTR_DEFAULT; } PARAM_INT_OPT (ptr_target) { ptr_target = AAPTR_DEFAULT; }
@ -3774,11 +3770,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF)
if (target) if (target)
{ {
fixed_t xydist = self->Distance2D(target); if (range > 0 && !(flags & CLOFF_CHECKPARTIAL))
fixed_t distance = P_AproxDistance(xydist, target->Z() - pos.z);
if (range && !(flags & CLOFF_CHECKPARTIAL))
{ {
double distance = self->Distance3D(target);
if (distance > range) if (distance > range)
{ {
ACTION_RETURN_STATE(NULL); ACTION_RETURN_STATE(NULL);
@ -3786,49 +3780,48 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF)
} }
{ {
angle_t ang; DAngle ang;
if (flags & CLOFF_NOAIM_HORZ) if (flags & CLOFF_NOAIM_HORZ)
{ {
ang = self->_f_angle(); ang = self->Angles.Yaw;
} }
else ang = self->__f_AngleTo (target); else ang = self->AngleTo (target);
angle += ang; angle += ang;
ang >>= ANGLETOFINESHIFT;
fixedvec2 xy = self->Vec2Offset( double s = ang.Sin();
FixedMul(offsetforward, finecosine[ang]) + FixedMul(offsetwidth, finesine[ang]), double c = ang.Cos();
FixedMul(offsetforward, finesine[ang]) - FixedMul(offsetwidth, finecosine[ang]));
fixedvec2 xy = self->Vec2Offset(fixed_t(offsetforward * c + offsetwidth * s), fixed_t(offsetforward * s - offsetwidth * c));
pos.x = xy.x; pos.x = xy.x;
pos.y = xy.y; pos.y = xy.y;
} }
double xydist = self->Distance2D(target);
if (flags & CLOFF_NOAIM_VERT) if (flags & CLOFF_NOAIM_VERT)
{ {
pitch += self->_f_pitch(); pitch += self->Angles.Pitch;
} }
else if (flags & CLOFF_AIM_VERT_NOOFFSET) else if (flags & CLOFF_AIM_VERT_NOOFFSET)
{ {
pitch -= R_PointToAngle2 (0,0, xydist, target->Z() - pos.z + offsetheight + target->height / 2); pitch -= VecToAngle(xydist, FIXED2FLOAT(target->Z() - pos.z + offsetheight + target->height / 2));
} }
else else
{ {
pitch -= R_PointToAngle2 (0,0, xydist, target->Z() - pos.z + target->height / 2); pitch -= VecToAngle(xydist, FIXED2FLOAT(target->Z() - pos.z + target->height / 2));
} }
} }
else if (flags & CLOFF_ALLOWNULL) else if (flags & CLOFF_ALLOWNULL)
{ {
angle += self->_f_angle(); angle += self->Angles.Yaw;
pitch += self->_f_pitch(); pitch += self->Angles.Pitch;
angle_t ang = self->_f_angle() >> ANGLETOFINESHIFT; double s = angle.Sin();
double c = angle.Cos();
fixedvec2 xy = self->Vec2Offset( fixedvec2 xy = self->Vec2Offset(fixed_t(offsetforward * c + offsetwidth * s), fixed_t(offsetforward * s - offsetwidth * c));
FixedMul(offsetforward, finecosine[ang]) + FixedMul(offsetwidth, finesine[ang]),
FixedMul(offsetforward, finesine[ang]) - FixedMul(offsetwidth, finecosine[ang]));
pos.x = xy.x; pos.x = xy.x;
pos.y = xy.y; pos.y = xy.y;
@ -3838,12 +3831,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF)
ACTION_RETURN_STATE(NULL); ACTION_RETURN_STATE(NULL);
} }
angle >>= ANGLETOFINESHIFT; double cp = pitch.Cos();
pitch >>= ANGLETOFINESHIFT;
vx = FixedMul (finecosine[pitch], finecosine[angle]); vx = FLOAT2FIXED(cp * angle.Cos());
vy = FixedMul (finecosine[pitch], finesine[angle]); vy = FLOAT2FIXED(cp * angle.Sin());
vz = -finesine[pitch]; vz = FLOAT2FIXED(-pitch.Sin());
} }
/* Variable set: /* Variable set:
@ -3869,13 +3861,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF)
lof_data.Flags = flags; lof_data.Flags = flags;
lof_data.BadActor = false; lof_data.BadActor = false;
Trace(pos.x, pos.y, pos.z, sec, vx, vy, vz, range, ActorFlags::FromInt(0xFFFFFFFF), ML_BLOCKEVERYTHING, self, trace, TRACE_PortalRestrict, Trace(pos.x, pos.y, pos.z, sec, vx, vy, vz, FLOAT2FIXED(range), ActorFlags::FromInt(0xFFFFFFFF), ML_BLOCKEVERYTHING, self, trace, TRACE_PortalRestrict,
CheckLOFTraceFunc, &lof_data); CheckLOFTraceFunc, &lof_data);
if (trace.HitType == TRACE_HitActor || if (trace.HitType == TRACE_HitActor ||
((flags & CLOFF_JUMP_ON_MISS) && !lof_data.BadActor && trace.HitType != TRACE_HitNone)) ((flags & CLOFF_JUMP_ON_MISS) && !lof_data.BadActor && trace.HitType != TRACE_HitNone))
{ {
if (minrange > 0 && trace.Distance < minrange) if (minrange > 0 && trace.Distance < FLOAT2FIXED(minrange))
{ {
ACTION_RETURN_STATE(NULL); ACTION_RETURN_STATE(NULL);
} }
@ -3969,7 +3961,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS)
else else
{ {
// Does the player aim at something that can be shot? // Does the player aim at something that can be shot?
P_AimLineAttack(self, self->_f_angle(), MISSILERANGE, &t, (flags & JLOSF_NOAUTOAIM) ? ANGLE_1/2 : 0, ALF_PORTALRESTRICT); P_AimLineAttack(self, self->Angles.Yaw, MISSILERANGE, &t, (flags & JLOSF_NOAUTOAIM) ? 0.5 : 0., ALF_PORTALRESTRICT);
if (!t.linetarget) if (!t.linetarget)
{ {

View file

@ -896,7 +896,7 @@ void VMDisasm(FILE *out, const VMOP *code, int codesize, const VMScriptFunction
#define PARAM_FLOAT_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); double x = param[p].f; #define PARAM_FLOAT_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); double x = param[p].f;
#define PARAM_FIXED_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); fixed_t x = FLOAT2FIXED(param[p].f); #define PARAM_FIXED_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); fixed_t x = FLOAT2FIXED(param[p].f);
#define PARAM_ANGLE_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); angle_t x = FLOAT2ANGLE(param[p].f); #define PARAM_ANGLE_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); angle_t x = FLOAT2ANGLE(param[p].f);
#define PARAM_DANGLE_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); angle_t x = param[p].f; #define PARAM_DANGLE_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_FLOAT); DAngle x = param[p].f;
#define PARAM_STRING_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_STRING); FString x = param[p].s(); #define PARAM_STRING_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_STRING); FString x = param[p].s();
#define PARAM_STATE_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_STATE || param[p].a == NULL)); FState *x = (FState *)param[p].a; #define PARAM_STATE_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_POINTER && (param[p].atag == ATAG_STATE || param[p].a == NULL)); FState *x = (FState *)param[p].a;
#define PARAM_POINTER_AT(p,x,type) assert((p) < numparam); assert(param[p].Type == REGT_POINTER); type *x = (type *)param[p].a; #define PARAM_POINTER_AT(p,x,type) assert((p) < numparam); assert(param[p].Type == REGT_POINTER); type *x = (type *)param[p].a;