mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- refactoring of R_PointToAngle2 when used to calculate direction between two actors.
This commit is contained in:
parent
1e2ce9a622
commit
2c0f64cf9f
31 changed files with 92 additions and 115 deletions
22
src/actor.h
22
src/actor.h
|
@ -612,7 +612,7 @@ extern FDropItemPtrArray DropItemList;
|
|||
void FreeDropItemChain(FDropItem *chain);
|
||||
int StoreDropItemChain(FDropItem *chain);
|
||||
fixed_t P_AproxDistance (fixed_t dx, fixed_t dy); // since we cannot include p_local here...
|
||||
|
||||
angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2); // same reason here with r_defs.h
|
||||
|
||||
|
||||
// Map Object definition.
|
||||
|
@ -889,6 +889,26 @@ public:
|
|||
return xs_RoundToInt(FVector3(x - other->x, y - other->y, z - other->z).Length());
|
||||
}
|
||||
|
||||
angle_t AngleTo(AActor *other, bool absolute = false) const
|
||||
{
|
||||
return R_PointToAngle2(x, y, other->x, other->y);
|
||||
}
|
||||
|
||||
angle_t AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const
|
||||
{
|
||||
return R_PointToAngle2(x, y, other->x + oxofs, other->y + oyofs);
|
||||
}
|
||||
|
||||
fixed_t AngleTo(fixed_t otherx, fixed_t othery, AActor *ref = NULL)
|
||||
{
|
||||
return R_PointToAngle2(x, y, otherx, othery);
|
||||
}
|
||||
|
||||
fixed_t AngleXYTo(fixed_t myx, fixed_t myy, AActor *other, bool absolute = false)
|
||||
{
|
||||
return R_PointToAngle2(myx, myy, other->x, other->y);
|
||||
}
|
||||
|
||||
inline void SetFriendPlayer(player_t *player);
|
||||
|
||||
bool IsVisibleToPlayer() const;
|
||||
|
|
|
@ -123,7 +123,7 @@ bool DBot::Check_LOS (AActor *to, angle_t vangle)
|
|||
if (vangle == 0)
|
||||
return false; //Looker seems to be blind.
|
||||
|
||||
return absangle(R_PointToAngle2 (player->mo->x, player->mo->y, to->x, to->y) - player->mo->angle) <= vangle/2;
|
||||
return absangle(player->mo->AngleTo(to) - player->mo->angle) <= vangle/2;
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
|
@ -220,14 +220,14 @@ shootmissile:
|
|||
dist = player->mo->AproxDistance (enemy);
|
||||
m = dist / GetDefaultByType (player->ReadyWeapon->ProjectileType)->Speed;
|
||||
bglobal.SetBodyAt (enemy->x + enemy->velx*m*2, enemy->y + enemy->vely*m*2, enemy->z, 1);
|
||||
angle = R_PointToAngle2 (player->mo->x, player->mo->y, bglobal.body1->x, bglobal.body1->y);
|
||||
angle = player->mo->AngleTo(bglobal.body1);
|
||||
if (Check_LOS (enemy, SHOOTFOV))
|
||||
no_fire = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Other weapons, mostly instant hit stuff.
|
||||
angle = R_PointToAngle2 (player->mo->x, player->mo->y, enemy->x, enemy->y);
|
||||
angle = player->mo->AngleTo(enemy);
|
||||
aiming_penalty = 0;
|
||||
if (enemy->flags & MF_SHADOW)
|
||||
aiming_penalty += (pr_botdofire()%25)+10;
|
||||
|
@ -263,7 +263,6 @@ shootmissile:
|
|||
cmd->ucmd.buttons |= BT_ATTACK;
|
||||
}
|
||||
//Prevents bot from jerking, when firing automatic things with low skill.
|
||||
//player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, player->enemy->x, player->enemy->y);
|
||||
}
|
||||
|
||||
bool FCajunMaster::IsLeader (player_t *player)
|
||||
|
@ -518,7 +517,7 @@ angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd)
|
|||
{
|
||||
if (bglobal.FakeFire (actor, bglobal.body1, cmd) >= SAFE_SELF_MISDIST)
|
||||
{
|
||||
ang = R_PointToAngle2 (actor->x, actor->y, bglobal.body1->x, bglobal.body1->y);
|
||||
ang = actor->AngleTo(bglobal.body1);
|
||||
return ang;
|
||||
}
|
||||
}
|
||||
|
@ -528,7 +527,7 @@ angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd)
|
|||
{
|
||||
if (bglobal.FakeFire (player->mo, enemy, cmd) >= SAFE_SELF_MISDIST)
|
||||
{
|
||||
ang = R_PointToAngle2(player->mo->x, player->mo->y, enemy->x, enemy->y);
|
||||
ang = player->mo->AngleTo(enemy);
|
||||
return ang;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ void DBot::Roam (ticcmd_t *cmd)
|
|||
|
||||
if (Reachable(dest))
|
||||
{ // Straight towards it.
|
||||
angle = R_PointToAngle2(player->mo->x, player->mo->y, dest->x, dest->y);
|
||||
angle = player->mo->AngleTo(dest);
|
||||
}
|
||||
else if (player->mo->movedir < 8) // turn towards movement direction if not there yet
|
||||
{
|
||||
|
|
|
@ -99,7 +99,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
|
|||
if (missile && (player->mo->AproxDistance(missile)<AVOID_DIST)) //try avoid missile got from P_Mobj.c thinking part.
|
||||
{
|
||||
Pitch (missile);
|
||||
angle = R_PointToAngle2(player->mo->x, player->mo->y, missile->x, missile->y);
|
||||
angle = player->mo->AngleTo(missile);
|
||||
cmd->ucmd.sidemove = sleft ? -SIDERUN : SIDERUN;
|
||||
cmd->ucmd.forwardmove = -FORWARDRUN; //Back IS best.
|
||||
|
||||
|
@ -165,7 +165,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
|
|||
sleft = !sleft;
|
||||
}
|
||||
|
||||
angle = R_PointToAngle2(player->mo->x, player->mo->y, enemy->x, enemy->y);
|
||||
angle = player->mo->AngleTo(enemy);
|
||||
|
||||
if (player->ReadyWeapon == NULL ||
|
||||
player->mo->AproxDistance(enemy) >
|
||||
|
@ -206,7 +206,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
|
|||
goto roam;
|
||||
}
|
||||
|
||||
angle = R_PointToAngle2(player->mo->x, player->mo->y, mate->x, mate->y);
|
||||
angle = player->mo->AngleTo(mate);
|
||||
|
||||
matedist = player->mo->AproxDistance(mate);
|
||||
if (matedist > (FRIEND_DIST*2))
|
||||
|
@ -241,7 +241,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
|
|||
(pr_botmove()%100)>skill.isp) && player->ReadyWeapon != NULL && !(player->ReadyWeapon->WeaponFlags & WIF_WIMPY_WEAPON))
|
||||
dest = enemy;//Dont let enemy kill the bot by supressive fire. So charge enemy.
|
||||
else //hide while t_fight, but keep view at enemy.
|
||||
angle = R_PointToAngle2(player->mo->x, player->mo->y, enemy->x, enemy->y);
|
||||
angle = player->mo->AngleTo(enemy);
|
||||
} //Just a monster, so kill it.
|
||||
else
|
||||
dest = enemy;
|
||||
|
|
|
@ -3145,8 +3145,8 @@ void FParser::SF_MoveCamera(void)
|
|||
}
|
||||
|
||||
// set step variables based on distance and speed
|
||||
mobjangle = R_PointToAngle2(cam->x, cam->y, target->x, target->y);
|
||||
xydist = R_PointToDist2(target->x - cam->x, target->y - cam->y);
|
||||
mobjangle = cam->AngleTo(target);
|
||||
xydist = cam->Distance2D(target);
|
||||
|
||||
xstep = FixedMul(finecosine[mobjangle >> ANGLETOFINESHIFT], movespeed);
|
||||
ystep = FixedMul(finesine[mobjangle >> ANGLETOFINESHIFT], movespeed);
|
||||
|
|
|
@ -59,10 +59,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch)
|
|||
if (linetarget)
|
||||
{
|
||||
S_Sound (self, CHAN_WEAPON, "*fist", 1, ATTN_NORM);
|
||||
self->angle = R_PointToAngle2 (self->x,
|
||||
self->y,
|
||||
linetarget->x,
|
||||
linetarget->y);
|
||||
self->angle = self->AngleTo(linetarget);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,8 +215,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw)
|
|||
// turn to face target
|
||||
if (!(Flags & SF_NOTURN))
|
||||
{
|
||||
angle = R_PointToAngle2(self->x, self->y,
|
||||
linetarget->x, linetarget->y);
|
||||
angle = self->AngleTo(linetarget);
|
||||
if (angle - self->angle > ANG180)
|
||||
{
|
||||
if (angle - self->angle < (angle_t)(-ANG90 / 20))
|
||||
|
|
|
@ -77,7 +77,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer)
|
|||
return;
|
||||
|
||||
// change angle
|
||||
exact = R_PointToAngle2 (self->x, self->y, dest->x, dest->y);
|
||||
exact = self->AngleTo(dest);
|
||||
|
||||
if (exact != self->angle)
|
||||
{
|
||||
|
|
|
@ -276,7 +276,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Saw)
|
|||
S_Sound (self, CHAN_WEAPON, hitsound, 1, ATTN_NORM);
|
||||
|
||||
// turn to face target
|
||||
angle = R_PointToAngle2 (self->x, self->y, linetarget->x, linetarget->y);
|
||||
angle = self->AngleTo(linetarget);
|
||||
if (angle - self->angle > ANG180)
|
||||
{
|
||||
if (angle - self->angle < (angle_t)(-ANG90/20))
|
||||
|
@ -326,7 +326,8 @@ static void MarinePunch(AActor *self, int damagemul)
|
|||
if (linetarget)
|
||||
{
|
||||
S_Sound (self, CHAN_WEAPON, "*fist", 1, ATTN_NORM);
|
||||
self->angle = R_PointToAngle2 (self->x, self->y, linetarget->x, linetarget->y);
|
||||
self->angle = self->AngleTo(linetarget);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -178,8 +178,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL1)
|
|||
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &linetarget);
|
||||
if (linetarget)
|
||||
{
|
||||
player->mo->angle = R_PointToAngle2 (player->mo->x,
|
||||
player->mo->y, linetarget->x, linetarget->y);
|
||||
player->mo->angle = player->mo->AngleTo(linetarget);
|
||||
}
|
||||
P_PlayPeck (player->mo);
|
||||
player->chickenPeck = 12;
|
||||
|
@ -211,8 +210,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL2)
|
|||
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &linetarget);
|
||||
if (linetarget)
|
||||
{
|
||||
player->mo->angle = R_PointToAngle2 (player->mo->x,
|
||||
player->mo->y, linetarget->x, linetarget->y);
|
||||
player->mo->angle = player->mo->AngleTo(linetarget);
|
||||
}
|
||||
P_PlayPeck (player->mo);
|
||||
player->chickenPeck = 12;
|
||||
|
|
|
@ -90,8 +90,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack)
|
|||
{
|
||||
//S_StartSound(player->mo, sfx_stfhit);
|
||||
// turn to face target
|
||||
self->angle = R_PointToAngle2 (self->x,
|
||||
self->y, linetarget->x, linetarget->y);
|
||||
self->angle = self->AngleTo(linetarget);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,8 +306,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack)
|
|||
S_Sound (self, CHAN_AUTO, "weapons/gauntletshit", 1, ATTN_NORM);
|
||||
}
|
||||
// turn to face target
|
||||
angle = R_PointToAngle2 (self->x, self->y,
|
||||
linetarget->x, linetarget->y);
|
||||
angle = self->AngleTo(linetarget);
|
||||
if (angle-self->angle > ANG180)
|
||||
{
|
||||
if ((int)(angle-self->angle) < -ANG90/20)
|
||||
|
@ -648,8 +646,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact)
|
|||
}
|
||||
else
|
||||
{ // Seek
|
||||
angle = R_PointToAngle2(self->x, self->y,
|
||||
target->x, target->y);
|
||||
self->angle = self->AngleTo(target);
|
||||
newAngle = true;
|
||||
}
|
||||
}
|
||||
|
@ -662,8 +659,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact)
|
|||
if (linetarget && self->target != linetarget)
|
||||
{
|
||||
self->tracer = linetarget;
|
||||
angle = R_PointToAngle2 (self->x, self->y,
|
||||
linetarget->x, linetarget->y);
|
||||
angle = self->AngleTo(linetarget);
|
||||
newAngle = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -33,13 +33,13 @@ void BlastActor (AActor *victim, fixed_t strength, fixed_t speed, AActor * Owner
|
|||
return;
|
||||
}
|
||||
|
||||
angle = R_PointToAngle2 (Owner->x, Owner->y, victim->x, victim->y);
|
||||
angle = Owner->AngleTo(victim);
|
||||
angle >>= ANGLETOFINESHIFT;
|
||||
victim->velx = FixedMul (speed, finecosine[angle]);
|
||||
victim->vely = FixedMul (speed, finesine[angle]);
|
||||
|
||||
// Spawn blast puff
|
||||
ang = R_PointToAngle2 (victim->x, victim->y, Owner->x, Owner->y);
|
||||
ang = victim->AngleTo(Owner);
|
||||
ang >>= ANGLETOFINESHIFT;
|
||||
x = victim->x + FixedMul (victim->radius+FRACUNIT, finecosine[ang]);
|
||||
y = victim->y + FixedMul (victim->radius+FRACUNIT, finesine[ang]);
|
||||
|
|
|
@ -262,8 +262,7 @@ static void CHolyTailFollow (AActor *actor, fixed_t dist)
|
|||
child = actor->tracer;
|
||||
if (child)
|
||||
{
|
||||
an = R_PointToAngle2(actor->x, actor->y, child->x,
|
||||
child->y)>>ANGLETOFINESHIFT;
|
||||
an = actor->AngleTo(child) >> ANGLETOFINESHIFT;
|
||||
oldDistance = child->AproxDistance (actor);
|
||||
if (P_TryMove (child, actor->x+FixedMul(dist, finecosine[an]),
|
||||
actor->y+FixedMul(dist, finesine[an]), true))
|
||||
|
|
|
@ -73,7 +73,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
|
|||
P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff"), false, &linetarget);
|
||||
if (linetarget != NULL)
|
||||
{
|
||||
pmo->angle = R_PointToAngle2 (pmo->x, pmo->y, linetarget->x, linetarget->y);
|
||||
pmo->angle = pmo->AngleTo(linetarget);
|
||||
if (((linetarget->player && (!linetarget->IsTeammate (pmo) || level.teamdamage != 0))|| linetarget->flags3&MF3_ISMONSTER)
|
||||
&& (!(linetarget->flags2&(MF2_DORMANT|MF2_INVULNERABLE))))
|
||||
{
|
||||
|
@ -103,7 +103,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
|
|||
P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff"), false, &linetarget);
|
||||
if (linetarget != NULL)
|
||||
{
|
||||
pmo->angle = R_PointToAngle2 (pmo->x, pmo->y, linetarget->x, linetarget->y);
|
||||
pmo->angle = pmo->AngleTo(linetarget);
|
||||
if ((linetarget->player && (!linetarget->IsTeammate (pmo) || level.teamdamage != 0)) || linetarget->flags3&MF3_ISMONSTER)
|
||||
{
|
||||
newLife = player->health+(damage>>4);
|
||||
|
|
|
@ -73,8 +73,7 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax)
|
|||
{ // attack the destination mobj if it's attackable
|
||||
AActor *oldTarget;
|
||||
|
||||
if (absangle(actor->angle-R_PointToAngle2(actor->x, actor->y,
|
||||
target->x, target->y)) < ANGLE_45/2)
|
||||
if (absangle(actor->angle - actor->AngleTo(target)) < ANGLE_45/2)
|
||||
{
|
||||
oldTarget = actor->target;
|
||||
actor->target = target;
|
||||
|
@ -99,8 +98,7 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax)
|
|||
{
|
||||
AActor *bestActor = NULL;
|
||||
bestAngle = ANGLE_MAX;
|
||||
angleToTarget = R_PointToAngle2(actor->x, actor->y,
|
||||
actor->target->x, actor->target->y);
|
||||
angleToTarget = actor->AngleTo(actor->target);
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
if (!target->args[i])
|
||||
|
@ -113,8 +111,7 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax)
|
|||
{
|
||||
continue;
|
||||
}
|
||||
angleToSpot = R_PointToAngle2(actor->x, actor->y,
|
||||
mo->x, mo->y);
|
||||
angleToSpot = actor->AngleTo(mo);
|
||||
if (absangle(angleToSpot-angleToTarget) < bestAngle)
|
||||
{
|
||||
bestAngle = absangle(angleToSpot-angleToTarget);
|
||||
|
@ -190,8 +187,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFlight)
|
|||
self->target = NULL;
|
||||
return;
|
||||
}
|
||||
angle = R_PointToAngle2(self->x, self->y, self->target->x,
|
||||
self->target->y);
|
||||
angle = self->AngleTo(self->target);
|
||||
if (absangle(self->angle-angle) < ANGLE_45/2 && self->CheckMeleeRange())
|
||||
{
|
||||
int damage = pr_dragonflight.HitDice (8);
|
||||
|
|
|
@ -30,7 +30,7 @@ void AdjustPlayerAngle (AActor *pmo, AActor *linetarget)
|
|||
angle_t angle;
|
||||
int difference;
|
||||
|
||||
angle = R_PointToAngle2 (pmo->x, pmo->y, linetarget->x, linetarget->y);
|
||||
angle = pmo->AngleTo(linetarget);
|
||||
difference = (int)angle - (int)pmo->angle;
|
||||
if (abs(difference) > MAX_ANGLE_ADJUST)
|
||||
{
|
||||
|
|
|
@ -163,7 +163,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredChase)
|
|||
{
|
||||
if (pr_firedemonchase() < 30)
|
||||
{
|
||||
ang = R_PointToAngle2 (self->x, self->y, target->x, target->y);
|
||||
ang = self->AngleTo(target);
|
||||
if (pr_firedemonchase() < 128)
|
||||
ang += ANGLE_90;
|
||||
else
|
||||
|
|
|
@ -79,7 +79,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FlyBuzz)
|
|||
return;
|
||||
}
|
||||
|
||||
angle_t ang = R_PointToAngle2(self->x, self->y, targ->x, targ->y);
|
||||
angle_t ang = self->AngleTo(targ);
|
||||
self->angle = ang;
|
||||
self->args[0]++;
|
||||
ang >>= ANGLETOFINESHIFT;
|
||||
|
|
|
@ -109,8 +109,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PotteryCheck)
|
|||
if (playeringame[i])
|
||||
{
|
||||
AActor *pmo = players[i].mo;
|
||||
if (P_CheckSight (self, pmo) && (absangle(R_PointToAngle2 (pmo->x,
|
||||
pmo->y, self->x, self->y) - pmo->angle) <= ANGLE_45))
|
||||
if (P_CheckSight (self, pmo) && (absangle(pmo->AngleTo(self) - pmo->angle) <= ANGLE_45))
|
||||
{ // Previous state (pottery bit waiting state)
|
||||
self->SetState (self->state - 1);
|
||||
return;
|
||||
|
|
|
@ -485,7 +485,7 @@ AActor *P_SpawnKoraxMissile (fixed_t x, fixed_t y, fixed_t z,
|
|||
z -= source->floorclip;
|
||||
th = Spawn (type, x, y, z, ALLOW_REPLACE);
|
||||
th->target = source; // Originator
|
||||
an = R_PointToAngle2(x, y, dest->x, dest->y);
|
||||
an = source->AngleXYTo(x, y, dest);
|
||||
if (dest->flags & MF_SHADOW)
|
||||
{ // Invisible target
|
||||
an += pr_kmissile.Random2()<<21;
|
||||
|
|
|
@ -190,7 +190,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningClip)
|
|||
}
|
||||
else
|
||||
{
|
||||
self->angle = R_PointToAngle2(self->x, self->y, target->x, target->y);
|
||||
self->angle = self->AngleTo(target);
|
||||
self->velx = 0;
|
||||
self->vely = 0;
|
||||
P_ThrustMobj (self, self->angle, self->Speed>>1);
|
||||
|
|
|
@ -390,7 +390,7 @@ void P_MinotaurSlam (AActor *source, AActor *target)
|
|||
fixed_t thrust;
|
||||
int damage;
|
||||
|
||||
angle = R_PointToAngle2 (source->x, source->y, target->x, target->y);
|
||||
angle = source->AngleTo(target);
|
||||
angle >>= ANGLETOFINESHIFT;
|
||||
thrust = 16*FRACUNIT+(pr_minotaurslam()<<10);
|
||||
target->velx += FixedMul (thrust, finecosine[angle]);
|
||||
|
|
|
@ -366,7 +366,7 @@ int FMugShot::UpdateState(player_t *player, StateFlags stateflags)
|
|||
if (player->mo != NULL)
|
||||
{
|
||||
// The next 12 lines are from the Doom statusbar code.
|
||||
badguyangle = R_PointToAngle2(player->mo->x, player->mo->y, player->attacker->x, player->attacker->y);
|
||||
badguyangle = player->mo->AngleTo(player->attacker);
|
||||
if (badguyangle > player->mo->angle)
|
||||
{
|
||||
// whether right or left
|
||||
|
|
|
@ -118,10 +118,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_JabDagger)
|
|||
S_Sound (self, CHAN_WEAPON,
|
||||
linetarget->flags & MF_NOBLOOD ? "misc/metalhit" : "misc/meathit",
|
||||
1, ATTN_NORM);
|
||||
self->angle = R_PointToAngle2 (self->x,
|
||||
self->y,
|
||||
linetarget->x,
|
||||
linetarget->y);
|
||||
self->angle = self->AngleTo(linetarget);
|
||||
self->flags |= MF_JUSTATTACKED;
|
||||
P_DaggerAlert (self, linetarget);
|
||||
}
|
||||
|
|
|
@ -1117,7 +1117,7 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang
|
|||
if (facetalker)
|
||||
{
|
||||
A_FaceTarget (npc);
|
||||
pc->angle = R_PointToAngle2 (pc->x, pc->y, npc->x, npc->y);
|
||||
pc->angle = pc->AngleTo(npc);
|
||||
}
|
||||
if ((npc->flags & MF_FRIENDLY) || (npc->flags4 & MF4_NOHATEPLAYERS))
|
||||
{
|
||||
|
|
|
@ -392,7 +392,7 @@ bool P_HitFriend(AActor * self)
|
|||
|
||||
if (self->flags&MF_FRIENDLY && self->target != NULL)
|
||||
{
|
||||
angle_t angle = R_PointToAngle2 (self->x, self->y, self->target->x, self->target->y);
|
||||
angle_t angle = self->AngleTo(self->target);
|
||||
fixed_t dist = self->AproxDistance (self->target);
|
||||
P_AimLineAttack (self, angle, dist, &linetarget, 0, true);
|
||||
if (linetarget != NULL && linetarget != self->target)
|
||||
|
@ -1160,7 +1160,7 @@ bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams
|
|||
|
||||
if (fov && fov < ANGLE_MAX)
|
||||
{
|
||||
angle_t an = R_PointToAngle2 (lookee->x, lookee->y, other->x, other->y) - lookee->angle;
|
||||
angle_t an = lookee->AngleTo(other) - lookee->angle;
|
||||
|
||||
if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2)))
|
||||
{
|
||||
|
@ -2389,7 +2389,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
|
|||
{
|
||||
if (pr_chase() < 100)
|
||||
{
|
||||
angle_t ang = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y);
|
||||
angle_t ang = actor->AngleTo(actor->target);
|
||||
if (pr_chase() < 128) ang += ANGLE_90;
|
||||
else ang -= ANGLE_90;
|
||||
actor->velx = 13 * finecosine[ang>>ANGLETOFINESHIFT];
|
||||
|
@ -2743,7 +2743,7 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, a
|
|||
|
||||
self->flags &= ~MF_AMBUSH;
|
||||
|
||||
angle_t other_angle = R_PointToAngle2 (self->x, self->y, other->x, other->y);
|
||||
angle_t other_angle = self->AngleTo(other);
|
||||
|
||||
// 0 means no limit. Also, if we turn in a single step anyways, no need to go through the algorithms.
|
||||
// It also means that there is no need to check for going past the other.
|
||||
|
@ -2916,10 +2916,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail)
|
|||
|
||||
self->flags &= ~MF_AMBUSH;
|
||||
|
||||
self->angle = R_PointToAngle2 (self->x,
|
||||
self->y,
|
||||
self->target->x,
|
||||
self->target->y);
|
||||
self->angle = self->AngleTo(self->target);
|
||||
|
||||
self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE, &linetarget, ANGLE_1*60, 0, self->target);
|
||||
if (linetarget == NULL)
|
||||
|
@ -2932,10 +2929,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail)
|
|||
}
|
||||
|
||||
// Let the aim trail behind the player
|
||||
self->angle = R_PointToAngle2 (self->x,
|
||||
self->y,
|
||||
self->target->x - self->target->velx * 3,
|
||||
self->target->y - self->target->vely * 3);
|
||||
self->angle = self->AngleTo(self->target, -self->target->velx * 3, -self->target->vely * 3);
|
||||
|
||||
if (self->target->flags & MF_SHADOW && !(self->flags6 & MF6_SEEINVISIBLE))
|
||||
{
|
||||
|
|
|
@ -1164,7 +1164,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage,
|
|||
}
|
||||
else
|
||||
{
|
||||
ang = R_PointToAngle2 (origin->x, origin->y, target->x, target->y);
|
||||
ang = origin->AngleTo(target);
|
||||
}
|
||||
|
||||
// Calculate this as float to avoid overflows so that the
|
||||
|
|
|
@ -3066,7 +3066,7 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop)
|
|||
if (!ontop)
|
||||
{
|
||||
fixed_t speed;
|
||||
angle_t angle = R_PointToAngle2(BlockingMobj->x,BlockingMobj->y, mo->x, mo->y) + ANGLE_1*((pr_bounce() % 16) - 8);
|
||||
angle_t angle = BlockingMobj->AngleTo(mo) + ANGLE_1*((pr_bounce() % 16) - 8);
|
||||
speed = P_AproxDistance(mo->velx, mo->vely);
|
||||
speed = FixedMul(speed, mo->wallbouncefactor); // [GZ] was 0.75, using wallbouncefactor seems more consistent
|
||||
mo->angle = angle;
|
||||
|
@ -4084,7 +4084,7 @@ void P_TraceBleed(int damage, AActor *target, AActor *missile)
|
|||
pitch = 0;
|
||||
}
|
||||
P_TraceBleed(damage, target->x, target->y, target->z + target->height / 2,
|
||||
target, R_PointToAngle2(missile->x, missile->y, target->x, target->y),
|
||||
target, missile->AngleTo(target),
|
||||
pitch);
|
||||
}
|
||||
|
||||
|
@ -4853,7 +4853,7 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo
|
|||
{
|
||||
velz *= 0.8f;
|
||||
}
|
||||
angle_t ang = R_PointToAngle2(bombspot->x, bombspot->y, thing->x, thing->y) >> ANGLETOFINESHIFT;
|
||||
angle_t ang = bombspot->AngleTo(thing) >> ANGLETOFINESHIFT;
|
||||
thing->velx += fixed_t(finecosine[ang] * thrust);
|
||||
thing->vely += fixed_t(finesine[ang] * thrust);
|
||||
if (!(flags & RADF_NODAMAGE))
|
||||
|
|
|
@ -1556,7 +1556,7 @@ int P_FaceMobj (AActor *source, AActor *target, angle_t *delta)
|
|||
angle_t angle2;
|
||||
|
||||
angle1 = source->angle;
|
||||
angle2 = R_PointToAngle2 (source->x, source->y, target->x, target->y);
|
||||
angle2 = source->AngleTo(target);
|
||||
if (angle2 > angle1)
|
||||
{
|
||||
diff = angle2 - angle1;
|
||||
|
@ -2019,7 +2019,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly)
|
|||
// Don't change the angle if there's THRUREFLECT on the monster.
|
||||
if (!(BlockingMobj->flags7 & MF7_THRUREFLECT))
|
||||
{
|
||||
angle = R_PointToAngle2(BlockingMobj->x, BlockingMobj->y, mo->x, mo->y);
|
||||
angle = BlockingMobj->AngleTo(mo);
|
||||
bool dontReflect = (mo->AdjustReflectionAngle(BlockingMobj, angle));
|
||||
// Change angle for deflection/reflection
|
||||
|
||||
|
@ -3088,8 +3088,7 @@ bool AActor::IsOkayToAttack (AActor *link)
|
|||
// to only allow the check to succeed if the enemy was in a ~84<38> FOV of the player
|
||||
if (flags3 & MF3_SCREENSEEKER)
|
||||
{
|
||||
angle_t angle = R_PointToAngle2(Friend->x,
|
||||
Friend->y, link->x, link->y) - Friend->angle;
|
||||
angle_t angle = Friend->AngleTo(link) - Friend->angle;
|
||||
angle >>= 24;
|
||||
if (angle>226 || angle<30)
|
||||
{
|
||||
|
@ -5035,7 +5034,7 @@ AActor *P_SpawnPuff (AActor *source, const PClass *pufftype, fixed_t x, fixed_t
|
|||
puff->target = source;
|
||||
|
||||
|
||||
if (source != NULL) puff->angle = R_PointToAngle2(x, y, source->x, source->y);
|
||||
if (source != NULL) puff->angle = puff->AngleTo(source);
|
||||
|
||||
// If a puff has a crash state and an actor was not hit,
|
||||
// it will enter the crash state. This is used by the StrifeSpark
|
||||
|
@ -5782,7 +5781,7 @@ AActor * P_OldSpawnMissile(AActor * source, AActor * owner, AActor * dest, const
|
|||
P_PlaySpawnSound(th, source);
|
||||
th->target = owner; // record missile's originator
|
||||
|
||||
th->angle = an = R_PointToAngle2 (source->x, source->y, dest->x, dest->y);
|
||||
th->angle = an = source->AngleTo(dest);
|
||||
an >>= ANGLETOFINESHIFT;
|
||||
th->velx = FixedMul (th->Speed, finecosine[an]);
|
||||
th->vely = FixedMul (th->Speed, finesine[an]);
|
||||
|
|
|
@ -2233,7 +2233,7 @@ void DPusher::Tick ()
|
|||
|
||||
if ((speed > 0) && (P_CheckSight (thing, m_Source, SF_IGNOREVISIBILITY)))
|
||||
{
|
||||
angle_t pushangle = R_PointToAngle2 (thing->x, thing->y, sx, sy);
|
||||
angle_t pushangle = thing->AngleTo(sx, sy);
|
||||
if (m_Source->GetClass()->TypeName == NAME_PointPusher)
|
||||
pushangle += ANG180; // away
|
||||
pushangle >>= ANGLETOFINESHIFT;
|
||||
|
|
|
@ -304,7 +304,8 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam
|
|||
}
|
||||
else
|
||||
{
|
||||
nolead: mobj->angle = R_PointToAngle2 (mobj->x, mobj->y, targ->x, targ->y);
|
||||
nolead:
|
||||
mobj->angle = mobj->AngleTo(targ);
|
||||
aim.Resize (fspeed);
|
||||
mobj->velx = fixed_t(aim[0]);
|
||||
mobj->vely = fixed_t(aim[1]);
|
||||
|
|
|
@ -1487,10 +1487,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
|
|||
if (!(flags & CPF_NOTURN))
|
||||
{
|
||||
// turn to face target
|
||||
self->angle = R_PointToAngle2 (self->x,
|
||||
self->y,
|
||||
linetarget->x,
|
||||
linetarget->y);
|
||||
self->angle = self->AngleTo(linetarget);
|
||||
}
|
||||
|
||||
if (flags & CPF_PULLIN) self->flags |= MF_JUSTATTACKED;
|
||||
|
@ -1614,10 +1611,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun)
|
|||
|
||||
if (aim)
|
||||
{
|
||||
self->angle = R_PointToAngle2 (self->x,
|
||||
self->y,
|
||||
self->target->x,
|
||||
self->target->y);
|
||||
self->angle = self->AngleTo(self->target);
|
||||
}
|
||||
self->pitch = P_AimLineAttack (self, self->angle, MISSILERANGE, &linetarget, ANGLE_1*60, 0, aim ? self->target : NULL);
|
||||
if (linetarget == NULL && aim)
|
||||
|
@ -1631,9 +1625,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun)
|
|||
// Let the aim trail behind the player
|
||||
if (aim)
|
||||
{
|
||||
saved_angle = self->angle = R_PointToAngle2 (self->x, self->y,
|
||||
self->target->x - self->target->velx * 3,
|
||||
self->target->y - self->target->vely * 3);
|
||||
saved_angle = self->angle = self->AngleTo(self->target, -self->target->velx * 3, -self->target->vely * 3);
|
||||
|
||||
if (aim == CRF_AIMDIRECT)
|
||||
{
|
||||
|
@ -1642,9 +1634,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomRailgun)
|
|||
self->x += Spawnofs_XY * finecosine[self->angle];
|
||||
self->y += Spawnofs_XY * finesine[self->angle];
|
||||
Spawnofs_XY = 0;
|
||||
self->angle = R_PointToAngle2 (self->x, self->y,
|
||||
self->target->x - self->target->velx * 3,
|
||||
self->target->y - self->target->vely * 3);
|
||||
self->angle = self->AngleTo(self->target,- self->target->velx * 3, -self->target->vely * 3);
|
||||
}
|
||||
|
||||
if (self->target->flags & MF_SHADOW)
|
||||
|
@ -3357,7 +3347,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF)
|
|||
{
|
||||
ang = self->angle;
|
||||
}
|
||||
else ang = R_PointToAngle2 (x1, y1, target->x, target->y);
|
||||
else ang = self->AngleTo (target);
|
||||
|
||||
angle += ang;
|
||||
|
||||
|
@ -3576,11 +3566,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS)
|
|||
|
||||
if (fov && (fov < ANGLE_MAX))
|
||||
{
|
||||
an = R_PointToAngle2 (viewport->x,
|
||||
viewport->y,
|
||||
target->x,
|
||||
target->y)
|
||||
- viewport->angle;
|
||||
an = viewport->AngleTo(target) - viewport->angle;
|
||||
|
||||
if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2)))
|
||||
{
|
||||
|
@ -3654,11 +3640,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS)
|
|||
|
||||
if (fov && (fov < ANGLE_MAX))
|
||||
{
|
||||
an = R_PointToAngle2 (target->x,
|
||||
target->y,
|
||||
self->x,
|
||||
self->y)
|
||||
- target->angle;
|
||||
an = target->AngleTo(self) - target->angle;
|
||||
|
||||
if (an > (fov / 2) && an < (ANGLE_MAX - (fov / 2)))
|
||||
{
|
||||
|
@ -4588,7 +4570,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack)
|
|||
|
||||
|
||||
// Target can dodge if it can see enemy
|
||||
angle_t angle = R_PointToAngle2(self->target->x, self->target->y, self->x, self->y) - self->target->angle;
|
||||
angle_t angle = self->target->AngleTo(self) - self->target->angle;
|
||||
angle >>= 24;
|
||||
bool dodge = (P_CheckSight(self->target, self) && (angle>226 || angle<30));
|
||||
|
||||
|
@ -4627,7 +4609,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack)
|
|||
dx = self->target->x;
|
||||
dy = self->target->y;
|
||||
dz = self->target->z + (self->target->height>>1);
|
||||
angle = R_PointToAngle2(dx, dy, self->x, self->y);
|
||||
angle = self->target->AngleTo(self);
|
||||
|
||||
dx += FixedMul(self->target->radius, finecosine[angle>>ANGLETOFINESHIFT]);
|
||||
dy += FixedMul(self->target->radius, finesine[angle>>ANGLETOFINESHIFT]);
|
||||
|
@ -4662,7 +4644,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack)
|
|||
if (spawnblood)
|
||||
{
|
||||
P_SpawnBlood(dx, dy, dz, angle, newdam > 0 ? newdam : damage, self->target);
|
||||
P_TraceBleed(newdam > 0 ? newdam : damage, self->target, R_PointToAngle2(self->x, self->y, dx, dy), 0);
|
||||
P_TraceBleed(newdam > 0 ? newdam : damage, self->target, self->AngleTo(dx, dy, self->target), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue