- some refactoring of P_AproxDistance calls into newly defined AActor method AproxDistance.

The main reason here is to reduce the number of instances where AActor::x and AActor::y are being referenced.
This commit is contained in:
Christoph Oelckers 2016-01-10 17:52:41 +01:00
parent 1f34372abc
commit 1e2ce9a622
25 changed files with 1293 additions and 1286 deletions

File diff suppressed because it is too large Load diff

View file

@ -37,7 +37,7 @@ bool DBot::Reachable (AActor *rtarget)
sector_t *last_s = player->mo->Sector;
fixed_t last_z = last_s->floorplane.ZatPoint (player->mo->x, player->mo->y);
fixed_t estimated_dist = P_AproxDistance (player->mo->x - rtarget->x, player->mo->y - rtarget->y);
fixed_t estimated_dist = player->mo->AproxDistance(rtarget);
bool reachable = true;
FPathTraverse it(player->mo->x+player->mo->velx, player->mo->y+player->mo->vely, rtarget->x, rtarget->y, PT_ADDLINES|PT_ADDTHINGS);
@ -165,10 +165,8 @@ void DBot::Dofire (ticcmd_t *cmd)
//MAKEME: Decrease the rocket suicides even more.
no_fire = true;
//angle = R_PointToAngle2(player->mo->x, player->mo->y, player->enemy->x, player->enemy->y);
//Distance to enemy.
dist = P_AproxDistance ((player->mo->x + player->mo->velx) - (enemy->x + enemy->velx),
(player->mo->y + player->mo->vely) - (enemy->y + enemy->vely));
dist = player->mo->AproxDistance(enemy, player->mo->velx - enemy->velx, player->mo->vely - enemy->vely);
//FIRE EACH TYPE OF WEAPON DIFFERENT: Here should all the different weapons go.
if (player->ReadyWeapon->WeaponFlags & WIF_MELEEWEAPON)
@ -219,7 +217,7 @@ void DBot::Dofire (ticcmd_t *cmd)
}
// prediction aiming
shootmissile:
dist = P_AproxDistance (player->mo->x - enemy->x, player->mo->y - enemy->y);
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);
@ -331,8 +329,7 @@ AActor *DBot::Choose_Mate ()
{
if (P_CheckSight (player->mo, client->mo, SF_IGNOREVISIBILITY))
{
test = P_AproxDistance (client->mo->x - player->mo->x,
client->mo->y - player->mo->y);
test = client->mo->AproxDistance(player->mo);
if (test < closest_dist)
{
@ -402,8 +399,7 @@ AActor *DBot::Find_enemy ()
if (Check_LOS (client->mo, vangle)) //Here's a strange one, when bot is standing still, the P_CheckSight within Check_LOS almost always returns false. tought it should be the same checksight as below but.. (below works) something must be fuckin wierd screded up.
//if(P_CheckSight(player->mo, players[count].mo))
{
temp = P_AproxDistance (client->mo->x - player->mo->x,
client->mo->y - player->mo->y);
temp = client->mo->AproxDistance(player->mo);
//Too dark?
if (temp > DARK_DIST &&
@ -505,7 +501,7 @@ angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd)
actor = bglobal.body2;
dist = P_AproxDistance (actor->x-enemy->x, actor->y-enemy->y);
dist = actor->AproxDistance (enemy);
if (dist < SAFE_SELF_MISDIST)
return 0;
//Predict.

View file

@ -347,7 +347,7 @@ void DBot::Pitch (AActor *target)
double diff;
diff = target->z - player->mo->z;
aim = atan (diff / (double)P_AproxDistance (player->mo->x - target->x, player->mo->y - target->y));
aim = atan(diff / (double)player->mo->AproxDistance(target));
player->mo->pitch = -(int)(aim * ANGLE_180/M_PI);
}

View file

@ -81,7 +81,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
int r;
stuck = false;
dist = dest ? P_AproxDistance(player->mo->x-dest->x, player->mo->y-dest->y) : 0;
dist = dest ? player->mo->AproxDistance(dest) : 0;
if (missile &&
((!missile->velx || !missile->vely) || !Check_LOS(missile, SHOOTFOV*3/2)))
@ -96,14 +96,14 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
player->mo->pitch += 80;
//HOW TO MOVE:
if (missile && (P_AproxDistance(player->mo->x-missile->x, player->mo->y-missile->y)<AVOID_DIST)) //try avoid missile got from P_Mobj.c thinking part.
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);
cmd->ucmd.sidemove = sleft ? -SIDERUN : SIDERUN;
cmd->ucmd.forwardmove = -FORWARDRUN; //Back IS best.
if ((P_AproxDistance(player->mo->x-oldx, player->mo->y-oldy)<50000)
if ((player->mo->AproxDistance(oldx, oldy)<50000)
&& t_strafe<=0)
{
t_strafe = 5;
@ -156,7 +156,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
t_fight = AFTERTICS;
if (t_strafe <= 0 &&
(P_AproxDistance(player->mo->x-oldx, player->mo->y-oldy)<50000
(player->mo->AproxDistance(oldx, oldy)<50000
|| ((pr_botmove()%30)==10))
)
{
@ -168,7 +168,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
angle = R_PointToAngle2(player->mo->x, player->mo->y, enemy->x, enemy->y);
if (player->ReadyWeapon == NULL ||
P_AproxDistance(player->mo->x-enemy->x, player->mo->y-enemy->y) >
player->mo->AproxDistance(enemy) >
player->ReadyWeapon->MoveCombatDist)
{
// If a monster, use lower speed (just for cooler apperance while strafing down doomed monster)
@ -208,7 +208,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
angle = R_PointToAngle2(player->mo->x, player->mo->y, mate->x, mate->y);
matedist = P_AproxDistance(player->mo->x - mate->x, player->mo->y - mate->y);
matedist = player->mo->AproxDistance(mate);
if (matedist > (FRIEND_DIST*2))
cmd->ucmd.forwardmove = FORWARDRUN;
else if (matedist > FRIEND_DIST)

View file

@ -36,7 +36,7 @@ void A_SkullAttack(AActor *self, fixed_t speed)
an = self->angle >> ANGLETOFINESHIFT;
self->velx = FixedMul (speed, finecosine[an]);
self->vely = FixedMul (speed, finesine[an]);
dist = P_AproxDistance (dest->x - self->x, dest->y - self->y);
dist = self->AproxDistance (dest);
dist = dist / speed;
if (dist < 1)

View file

@ -102,10 +102,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer)
if (!(self->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)))
{
// change slope
dist = P_AproxDistance (dest->x - self->x,
dest->y - self->y);
dist = dist / self->Speed;
dist = self->AproxDistance (dest) / self->Speed;
if (dist < 1)
dist = 1;

View file

@ -1479,8 +1479,7 @@ static fixed_t PlayersRangeFromSpot (FPlayerStart *spot)
if (!playeringame[i] || !players[i].mo || players[i].health <= 0)
continue;
distance = P_AproxDistance (players[i].mo->x - spot->x,
players[i].mo->y - spot->y);
distance = players[i].mo->AproxDistance (spot->x, spot->y);
if (distance < closest)
closest = distance;

View file

@ -91,8 +91,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichAttack)
P_TraceBleed (newdam > 0 ? newdam : damage, target, self);
return;
}
dist = P_AproxDistance (self->x-target->x, self->y-target->y)
> 8*64*FRACUNIT;
dist = self->AproxDistance (target) > 8*64*FRACUNIT;
randAttack = pr_atk ();
if (randAttack < atkResolve1[dist])
{ // Ice ball

View file

@ -141,7 +141,7 @@ DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_Blast)
{ // Must be monster, player, missile, touchy or vulnerable
continue;
}
dist = P_AproxDistance (self->x - mo->x, self->y - mo->y);
dist = self->AproxDistance (mo);
if (dist > radius)
{ // Out of range
continue;

View file

@ -264,12 +264,11 @@ static void CHolyTailFollow (AActor *actor, fixed_t dist)
{
an = R_PointToAngle2(actor->x, actor->y, child->x,
child->y)>>ANGLETOFINESHIFT;
oldDistance = P_AproxDistance (child->x-actor->x, child->y-actor->y);
oldDistance = child->AproxDistance (actor);
if (P_TryMove (child, actor->x+FixedMul(dist, finecosine[an]),
actor->y+FixedMul(dist, finesine[an]), true))
{
newDistance = P_AproxDistance (child->x-actor->x,
child->y-actor->y)-FRACUNIT;
newDistance = child->AproxDistance (actor)-FRACUNIT;
if (oldDistance < FRACUNIT)
{
if (child->z < actor->z)
@ -425,7 +424,7 @@ static void CHolySeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax)
deltaZ = -15*FRACUNIT;
}
}
dist = P_AproxDistance (target->x-actor->x, target->y-actor->y);
dist = actor->AproxDistance (target);
dist = dist / actor->Speed;
if (dist < 1)
{

View file

@ -59,22 +59,16 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax)
angle = actor->angle>>ANGLETOFINESHIFT;
actor->velx = FixedMul (actor->Speed, finecosine[angle]);
actor->vely = FixedMul (actor->Speed, finesine[angle]);
dist = actor->AproxDistance (target) / actor->Speed;
if (actor->z+actor->height < target->z ||
target->z+target->height < actor->z)
{
dist = P_AproxDistance(target->x-actor->x, target->y-actor->y);
dist = dist/actor->Speed;
if (dist < 1)
{
dist = 1;
}
actor->velz = (target->z - actor->z)/dist;
}
else
{
dist = P_AproxDistance (target->x-actor->x, target->y-actor->y);
dist = dist/actor->Speed;
}
if (target->flags&MF_SHOOTABLE && pr_dragonseek() < 64)
{ // attack the destination mobj if it's attackable
AActor *oldTarget;

View file

@ -158,7 +158,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredChase)
{
self->special2 = 0;
self->velx = self->vely = 0;
dist = P_AproxDistance (self->x - target->x, self->y - target->y);
dist = self->AproxDistance (target);
if (dist < FIREDEMON_ATTACK_RANGE)
{
if (pr_firedemonchase() < 30)

View file

@ -37,7 +37,7 @@ bool AArtiHealingRadius::Use (bool pickup)
if (playeringame[i] &&
players[i].mo != NULL &&
players[i].mo->health > 0 &&
P_AproxDistance (players[i].mo->x - Owner->x, players[i].mo->y - Owner->y) <= HEAL_RADIUS_DIST)
players[i].mo->AproxDistance (Owner) <= HEAL_RADIUS_DIST)
{
// Q: Is it worth it to make this selectable as a player property?
// A: Probably not - but it sure doesn't hurt.

View file

@ -665,8 +665,7 @@ void A_SorcOffense2(AActor *actor)
if (mo)
{
mo->special2 = 35*5/2; // 5 seconds
dist = P_AproxDistance(dest->x - mo->x, dest->y - mo->y);
dist = dist/mo->Speed;
dist = mo->AproxDistance(dest) / mo->Speed;
if(dist < 1) dist = 1;
mo->velz = (dest->z - mo->z) / dist;
}

View file

@ -388,8 +388,7 @@ void A_KSpiritSeeker (AActor *actor, angle_t thresh, angle_t turnMax)
deltaZ = -15*FRACUNIT;
}
}
dist = P_AproxDistance (target->x-actor->x, target->y-actor->y);
dist = dist/actor->Speed;
dist = actor->AproxDistance (target) / actor->Speed;
if (dist < 1)
{
dist = 1;
@ -495,8 +494,7 @@ AActor *P_SpawnKoraxMissile (fixed_t x, fixed_t y, fixed_t z,
an >>= ANGLETOFINESHIFT;
th->velx = FixedMul (th->Speed, finecosine[an]);
th->vely = FixedMul (th->Speed, finesine[an]);
dist = P_AproxDistance (dest->x - x, dest->y - y);
dist = dist/th->Speed;
dist = dest->AproxDistance (x, y, source) / th->Speed;
if (dist < 1)
{
dist = 1;

View file

@ -185,7 +185,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurDecide)
{
S_Sound (self, CHAN_WEAPON, "minotaur/sight", 1, ATTN_NORM);
}
dist = P_AproxDistance (self->x-target->x, self->y-target->y);
dist = self->AproxDistance (target);
if (target->z+target->height > self->z
&& target->z+target->height < self->z+self->height
&& dist < (friendly ? 16*64*FRACUNIT : 8*64*FRACUNIT)
@ -489,7 +489,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurLook)
mo = player->mo;
if (mo == master) continue;
if (mo->health <= 0) continue;
dist = P_AproxDistance(self->x - mo->x, self->y - mo->y);
dist = self->AproxDistance(mo);
if (dist > MINOTAUR_LOOK_DIST) continue;
self->target = mo;
break;
@ -514,7 +514,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurLook)
if (!(mo->flags3 & MF3_ISMONSTER)) continue;
if (mo->health <= 0) continue;
if (!(mo->flags & MF_SHOOTABLE)) continue;
dist = P_AproxDistance (self->x - mo->x, self->y - mo->y);
dist = self->AproxDistance(mo);
if (dist > MINOTAUR_LOOK_DIST) continue;
if ((mo == master) || (mo == self)) continue;
if ((mo->flags5 & MF5_SUMMONEDMONSTER) && (mo->tracer == master)) continue;

View file

@ -129,7 +129,7 @@ void DEarthquake::Tick ()
AActor *victim = players[i].mo;
fixed_t dist;
dist = P_AproxDistance (victim->x - m_Spot->x, victim->y - m_Spot->y);
dist = m_Spot->AproxDistance (victim, true);
// Check if in damage radius
if (dist < m_DamageRadius && victim->z <= victim->floorz)
{
@ -242,8 +242,7 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger
{
if (quake->m_Spot != NULL)
{
fixed_t dist = P_AproxDistance (victim->x - quake->m_Spot->x,
victim->y - quake->m_Spot->y);
fixed_t dist = quake->m_Spot->AproxDistance (victim, true);
if (dist < quake->m_TremorRadius)
{
++count;

View file

@ -158,7 +158,7 @@ struct FSpotList
while (true)
{
distance = P_AproxDistance(Spots[i]->x - x, Spots[i]->y - y);
distance = Spots[i]->AproxDistance(x, y);
if ((distance >= mindist) && ((maxdist == 0) || (distance <= maxdist))) break;

View file

@ -11,9 +11,9 @@
static bool CrusaderCheckRange (AActor *self)
{
if (P_CheckSight (self, self->target) && self->reactiontime == 0)
if (self->reactiontime == 0 && P_CheckSight (self, self->target))
{
return P_AproxDistance (self->x - self->target->x, self->y - self->target->y) < 264*FRACUNIT;
return self->AproxDistance (self->target) < 264*FRACUNIT;
}
return false;
}

View file

@ -20,7 +20,7 @@ bool InquisitorCheckDistance (AActor *self)
{
if (self->reactiontime == 0 && P_CheckSight (self, self->target))
{
return P_AproxDistance (self->x - self->target->x, self->y - self->target->y) < 264*FRACUNIT;
return self->AproxDistance (self->target) < 264*FRACUNIT;
}
return false;
}
@ -85,7 +85,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump)
speed = self->Speed * 2/3;
self->velx += FixedMul (speed, finecosine[an]);
self->vely += FixedMul (speed, finesine[an]);
dist = P_AproxDistance (self->target->x - self->x, self->target->y - self->y);
dist = self->AproxDistance (self->target);
dist /= speed;
if (dist < 1)
{

View file

@ -138,7 +138,7 @@ void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soun
for (actor = sec->thinglist; actor != NULL; actor = actor->snext)
{
if (actor != soundtarget && (!splash || !(actor->flags4 & MF4_NOSPLASHALERT)) &&
(!maxdist || (P_AproxDistance(actor->x - emitter->x, actor->y - emitter->y) <= maxdist)))
(!maxdist || (actor->AproxDistance(emitter) <= maxdist)))
{
actor->LastHeard = soundtarget;
}
@ -231,7 +231,7 @@ bool AActor::CheckMeleeRange ()
if (!pl)
return false;
dist = P_AproxDistance (pl->x - x, pl->y - y);
dist = AproxDistance (pl);
if (dist >= meleerange + pl->radius)
return false;
@ -275,7 +275,7 @@ bool P_CheckMeleeRange2 (AActor *actor)
return false;
}
mo = actor->target;
dist = P_AproxDistance (mo->x-actor->x, mo->y-actor->y);
dist = mo->AproxDistance (actor);
if (dist >= MELEERANGE*2 || dist < MELEERANGE-20*FRACUNIT + mo->radius)
{
return false;
@ -348,8 +348,7 @@ bool P_CheckMissileRange (AActor *actor)
// OPTIMIZE: get this from a global checksight
// [RH] What?
dist = P_AproxDistance (actor->x-actor->target->x,
actor->y-actor->target->y) - 64*FRACUNIT;
dist = actor->AproxDistance (actor->target) - 64*FRACUNIT;
if (actor->MeleeState == NULL)
dist -= 128*FRACUNIT; // no melee attack, so fire more
@ -394,7 +393,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);
fixed_t dist = P_AproxDistance (self->x - self->target->x, self->y - self->target->y);
fixed_t dist = self->AproxDistance (self->target);
P_AimLineAttack (self, angle, dist, &linetarget, 0, true);
if (linetarget != NULL && linetarget != self->target)
{
@ -450,7 +449,7 @@ bool P_Move (AActor *actor)
if ((actor->flags6 & MF6_JUMPDOWN) && target &&
!(target->IsFriend(actor)) &&
P_AproxDistance(actor->x - target->x, actor->y - target->y) < FRACUNIT*144 &&
actor->AproxDistance(target) < FRACUNIT*144 &&
pr_dropoff() < 235)
{
dropoff = 2;
@ -933,7 +932,7 @@ void P_NewChaseDir(AActor * actor)
if (actor->flags3 & MF3_AVOIDMELEE)
{
bool ismeleeattacker = false;
fixed_t dist = P_AproxDistance(actor->x-target->x, actor->y-target->y);
fixed_t dist = actor->AproxDistance(target);
if (target->player == NULL)
{
ismeleeattacker = (target->MissileState == NULL && dist < (target->meleerange + target->radius)*2);
@ -1151,7 +1150,7 @@ bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams
fov = allaround ? 0 : ANGLE_180;
}
fixed_t dist = P_AproxDistance (other->x - lookee->x, other->y - lookee->y);
fixed_t dist = lookee->AproxDistance (other);
if (maxdist && dist > maxdist)
return false; // [KS] too far
@ -1202,8 +1201,7 @@ bool P_LookForMonsters (AActor *actor)
{ // Not a valid monster
continue;
}
if (P_AproxDistance (actor->x-mo->x, actor->y-mo->y)
> MONS_LOOK_RANGE)
if (mo->AproxDistance (actor) > MONS_LOOK_RANGE)
{ // Out of range
continue;
}
@ -1703,10 +1701,8 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params)
if ((player->mo->flags & MF_SHADOW && !(i_compatflags & COMPATF_INVISIBILITY)) ||
player->mo->flags3 & MF3_GHOST)
{
if ((P_AproxDistance (player->mo->x - actor->x,
player->mo->y - actor->y) > 2*MELEERANGE)
&& P_AproxDistance (player->mo->velx, player->mo->vely)
< 5*FRACUNIT)
if ((player->mo->AproxDistance (actor) > 2*MELEERANGE)
&& P_AproxDistance (player->mo->velx, player->mo->vely) < 5*FRACUNIT)
{ // Player is sneaking - can't detect
continue;
}
@ -1903,8 +1899,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
}
else
{
dist = P_AproxDistance (targ->x - self->x,
targ->y - self->y);
dist = self->AproxDistance (targ);
// [KS] If the target is too far away, don't respond to the sound.
if (maxheardist && dist > maxheardist)
@ -1975,8 +1970,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
{
if (self->flags & MF_AMBUSH)
{
dist = P_AproxDistance (self->target->x - self->x,
self->target->y - self->y);
dist = self->AproxDistance (self->target);
if (P_CheckSight (self, self->target, SF_SEEPASTBLOCKEVERYTHING) &&
(!minseedist || dist > minseedist) &&
(!maxseedist || dist < maxseedist))
@ -2390,7 +2384,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
actor->FastChaseStrafeCount = 0;
actor->velx = 0;
actor->vely = 0;
fixed_t dist = P_AproxDistance (actor->x - actor->target->x, actor->y - actor->target->y);
fixed_t dist = actor->AproxDistance (actor->target);
if (dist < CLASS_BOSS_STRAFE_RANGE)
{
if (pr_chase() < 100)

View file

@ -1075,8 +1075,8 @@ bool PIT_CheckThing(AActor *thing, FCheckPosition &tm)
abs(thing->y - tm.thing->y) < (thing->radius+tm.thing->radius))
{
fixed_t newdist = P_AproxDistance(thing->x - tm.x, thing->y - tm.y);
fixed_t olddist = P_AproxDistance(thing->x - tm.thing->x, thing->y - tm.thing->y);
fixed_t newdist = thing->AproxDistance(tm.x, tm.y, tm.thing);
fixed_t olddist = thing->AproxDistance(tm.thing);
if (newdist > olddist)
{
@ -1754,7 +1754,7 @@ void P_FakeZMovement(AActor *mo)
{ // float down towards target if too close
if (!(mo->flags & MF_SKULLFLY) && !(mo->flags & MF_INFLOAT))
{
fixed_t dist = P_AproxDistance(mo->x - mo->target->x, mo->y - mo->target->y);
fixed_t dist = mo->AproxDistance(mo->target);
fixed_t delta = (mo->target->z + (mo->height >> 1)) - mo->z;
if (delta < 0 && dist < -(delta * 3))
mo->z -= mo->FloatSpeed;

View file

@ -1669,8 +1669,7 @@ bool P_SeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax, bool preci
if (actor->z + actor->height < target->z ||
target->z + target->height < actor->z)
{ // Need to seek vertically
dist = P_AproxDistance (target->x - actor->x, target->y - actor->y);
dist = dist / speed;
dist = actor->AproxDistance (target) / speed;
if (dist < 1)
{
dist = 1;
@ -2380,7 +2379,7 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz)
{ // float down towards target if too close
if (!(mo->flags & (MF_SKULLFLY | MF_INFLOAT)))
{
dist = P_AproxDistance (mo->x - mo->target->x, mo->y - mo->target->y);
dist = mo->AproxDistance (mo->target);
delta = (mo->target->z + (mo->height>>1)) - mo->z;
if (delta < 0 && dist < -(delta*3))
mo->z -= mo->FloatSpeed;
@ -3392,7 +3391,7 @@ void AActor::Tick ()
if (health > 0
&& !players[i].Bot->enemy
&& player ? !IsTeammate (players[i].mo) : true
&& P_AproxDistance (players[i].mo->x-x, players[i].mo->y-y) < MAX_MONSTER_TARGET_DIST
&& AproxDistance (players[i].mo) < MAX_MONSTER_TARGET_DIST
&& P_CheckSight (players[i].mo, this, SF_SEEPASTBLOCKEVERYTHING))
{ //Probably a monster, so go kill it.
players[i].Bot->enemy = this;
@ -5788,7 +5787,7 @@ AActor * P_OldSpawnMissile(AActor * source, AActor * owner, AActor * dest, const
th->velx = FixedMul (th->Speed, finecosine[an]);
th->vely = FixedMul (th->Speed, finesine[an]);
dist = P_AproxDistance (dest->x - source->x, dest->y - source->y);
dist = source->AproxDistance (dest);
if (th->Speed) dist = dist / th->Speed;
if (dist < 1)
@ -5849,7 +5848,7 @@ AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, const PCl
{
an += pr_spawnmissile.Random2() << 20;
}
dist = P_AproxDistance (dest->x - source->x, dest->y - source->y);
dist = source->AproxDistance (dest);
speed = GetDefaultSpeed (type);
dist /= speed;
velz = dist != 0 ? (dest->z - source->z)/dist : speed;

View file

@ -2225,7 +2225,7 @@ void DPusher::Tick ()
{
int sx = m_X;
int sy = m_Y;
int dist = P_AproxDistance (thing->x - sx,thing->y - sy);
int dist = thing->AproxDistance (sx, sy);
int speed = (m_Magnitude - ((dist>>FRACBITS)>>1))<<(FRACBITS-PUSH_FACTOR-1);
// If speed <= 0, you're outside the effective radius. You also have

View file

@ -670,7 +670,7 @@ void DoJumpIfCloser(AActor *target, DECLARE_PARAMINFO)
// No target - no jump
if (!target)
return;
if (P_AproxDistance(self->x-target->x, self->y-target->y) < dist &&
if (self->AproxDistance(target) < dist &&
(noz ||
((self->z > target->z && self->z - (target->z + target->height) < dist) ||
(self->z <= target->z && target->z - (self->z + self->height) < dist))))
@ -3342,8 +3342,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF)
if (target)
{
FVector2 xyvec(target->x - x1, target->y - y1);
fixed_t distance = P_AproxDistance((fixed_t)xyvec.Length(), target->z - z1);
fixed_t xydist = self->Distance2D(target);
fixed_t distance = P_AproxDistance(xydist, target->z - z1);
if (range && !(flags & CLOFF_CHECKPARTIAL))
{
@ -3372,11 +3372,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF)
}
else if (flags & CLOFF_AIM_VERT_NOOFFSET)
{
pitch += R_PointToAngle2 (0,0, (fixed_t)xyvec.Length(), target->z - z1 + offsetheight + target->height / 2);
pitch += R_PointToAngle2 (0,0, xydist, target->z - z1 + offsetheight + target->height / 2);
}
else
{
pitch += R_PointToAngle2 (0,0, (fixed_t)xyvec.Length(), target->z - z1 + target->height / 2);
pitch += R_PointToAngle2 (0,0, xydist, target->z - z1 + target->height / 2);
}
}
else if (flags & CLOFF_ALLOWNULL)
@ -3546,8 +3546,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfTargetInLOS)
// [FDARI] If actors share team, don't jump
if ((flags & JLOSF_ALLYNOJUMP) && self->IsFriend(target)) return;
fixed_t distance = P_AproxDistance(target->x - self->x, target->y - self->y);
distance = P_AproxDistance(distance, target->z - self->z);
fixed_t distance = self->AproxDistance3D(target);
if (dist_max && (distance > dist_max)) return;
@ -3635,8 +3634,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_JumpIfInTargetLOS)
if ((flags & JLOSF_DEADNOJUMP) && (target->health <= 0)) return;
fixed_t distance = P_AproxDistance(target->x - self->x, target->y - self->y);
distance = P_AproxDistance(distance, target->z - self->z);
fixed_t distance = self->AproxDistance3D(target);
if (dist_max && (distance > dist_max)) return;
@ -5950,7 +5948,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckProximity)
continue;
//Make sure it's in range and respect the desire for Z or not.
if (P_AproxDistance(ref->x - mo->x, ref->y - mo->y) < distance &&
if (ref->AproxDistance(mo) < distance &&
((flags & CPXF_NOZ) ||
((ref->z > mo->z && ref->z - (mo->z + mo->height) < distance) ||
(ref->z <= mo->z && mo->z - (ref->z + ref->height) < distance))))