Revert "Replace all instances of P_AproxDistance with FixedHypot"

This reverts commit 75633bde50.
This commit is contained in:
LJ Sonic 2021-02-13 17:45:20 +01:00
parent 481ddb6532
commit 09d911a5b6
17 changed files with 219 additions and 218 deletions

View file

@ -54,11 +54,11 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
boolean _2d = (tails->flags2 & MF2_TWOD) || twodlevel;
fixed_t scale = tails->scale;
fixed_t dist = FixedHypot(sonic->x - tails->x, sonic->y - tails->y);
fixed_t dist = P_AproxDistance(sonic->x - tails->x, sonic->y - tails->y);
fixed_t zdist = flip * (sonic->z - tails->z);
angle_t ang = sonic->angle;
fixed_t pmom = FixedHypot(sonic->momx, sonic->momy);
fixed_t bmom = FixedHypot(tails->momx, tails->momy);
fixed_t pmom = P_AproxDistance(sonic->momx, sonic->momy);
fixed_t bmom = P_AproxDistance(tails->momx, tails->momy);
fixed_t followmax = 128 * 8 * scale; // Max follow distance before AI begins to enter "panic" state
fixed_t followthres = 92 * scale; // Distance that AI will try to reach
fixed_t followmin = 32 * scale;
@ -81,7 +81,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
if (tails->player->powers[pw_carry] == CR_MACESPIN || tails->player->powers[pw_carry] == CR_GENERIC)
{
boolean isrelevant = (sonic->player->powers[pw_carry] == CR_MACESPIN || sonic->player->powers[pw_carry] == CR_GENERIC);
dist = FixedHypot(tails->x-sonic->x, tails->y-sonic->y);
dist = P_AproxDistance(tails->x-sonic->x, tails->y-sonic->y);
if (sonic->player->cmd.buttons & BT_JUMP && (sonic->player->pflags & PF_JUMPED) && isrelevant)
cmd->buttons |= BT_JUMP;
if (isrelevant)
@ -496,7 +496,7 @@ boolean B_CheckRespawn(player_t *player)
}
// If you can't see Sonic, I guess we should?
if (!P_CheckSight(sonic, tails) && FixedHypot(FixedHypot(tails->x-sonic->x, tails->y-sonic->y), tails->z-sonic->z) > FixedMul(1024*FRACUNIT, tails->scale))
if (!P_CheckSight(sonic, tails) && P_AproxDistance(P_AproxDistance(tails->x-sonic->x, tails->y-sonic->y), tails->z-sonic->z) > FixedMul(1024*FRACUNIT, tails->scale))
return true;
return false;
}

View file

@ -1423,7 +1423,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
newtarget = P_SpawnMobj(ticcmd_ztargetfocus[forplayer]->x, ticcmd_ztargetfocus[forplayer]->y, ticcmd_ztargetfocus[forplayer]->z, MT_LOCKON); // positioning, flip handled in P_SceneryThinker
P_SetTarget(&newtarget->target, ticcmd_ztargetfocus[forplayer]);
if (FixedHypot(
if (P_AproxDistance(
player->mo->x - ticcmd_ztargetfocus[forplayer]->x,
player->mo->y - ticcmd_ztargetfocus[forplayer]->y
) > 50*player->mo->scale)

View file

@ -468,7 +468,7 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type)
// Linedef executor excellence
case moveCeilingByFrontSector:
ceiling->speed = FixedHypot(line->dx, line->dy);
ceiling->speed = P_AproxDistance(line->dx, line->dy);
ceiling->speed = FixedDiv(ceiling->speed,8*FRACUNIT);
if (line->frontsector->ceilingheight >= sec->ceilingheight) // Move up
{
@ -547,7 +547,7 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type)
*/
case bounceCeiling:
ceiling->speed = FixedHypot(line->dx, line->dy); // same speed as elevateContinuous
ceiling->speed = P_AproxDistance(line->dx, line->dy); // same speed as elevateContinuous
ceiling->speed = FixedDiv(ceiling->speed,4*FRACUNIT);
ceiling->origspeed = ceiling->speed;
if (line->frontsector->ceilingheight >= sec->ceilingheight) // Move up

View file

@ -334,7 +334,7 @@ boolean P_CheckMeleeRange(mobj_t *actor)
return false;
pl = actor->target;
dist = FixedHypot(pl->x-actor->x, pl->y-actor->y);
dist = P_AproxDistance(pl->x-actor->x, pl->y-actor->y);
if (dist >= FixedMul(MELEERANGE - 20*FRACUNIT, actor->scale) + pl->radius)
return false;
@ -360,7 +360,7 @@ boolean P_JetbCheckMeleeRange(mobj_t *actor)
return false;
pl = actor->target;
dist = FixedHypot(pl->x-actor->x, pl->y-actor->y);
dist = P_AproxDistance(pl->x-actor->x, pl->y-actor->y);
if (dist >= (actor->radius + pl->radius)*2)
return false;
@ -389,7 +389,7 @@ boolean P_FaceStabCheckMeleeRange(mobj_t *actor)
return false;
pl = actor->target;
dist = FixedHypot(pl->x-actor->x, pl->y-actor->y);
dist = P_AproxDistance(pl->x-actor->x, pl->y-actor->y);
if (dist >= (actor->radius + pl->radius)*4)
return false;
@ -413,7 +413,7 @@ boolean P_SkimCheckMeleeRange(mobj_t *actor)
return false;
pl = actor->target;
dist = FixedHypot(pl->x-actor->x, pl->y-actor->y);
dist = P_AproxDistance(pl->x-actor->x, pl->y-actor->y);
if (dist >= FixedMul(MELEERANGE - 20*FRACUNIT, actor->scale) + pl->radius)
return false;
@ -449,7 +449,7 @@ boolean P_CheckMissileRange(mobj_t *actor)
return false;
// OPTIMIZE: get this from a global checksight
dist = FixedHypot(actor->x-actor->target->x, actor->y-actor->target->y) - FixedMul(64*FRACUNIT, actor->scale);
dist = P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) - FixedMul(64*FRACUNIT, actor->scale);
if (!actor->info->meleestate)
dist -= FixedMul(128*FRACUNIT, actor->scale); // no melee attack, so fire more
@ -750,7 +750,7 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed
continue; // Ignore uncontrolled bodies
if (dist > 0
&& FixedHypot(FixedHypot(player->mo->x - actor->x, player->mo->y - actor->y), player->mo->z - actor->z) > dist)
&& P_AproxDistance(P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y), player->mo->z - actor->z) > dist)
continue; // Too far away
if (!allaround)
@ -758,7 +758,7 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed
an = R_PointToAngle2(actor->x, actor->y, player->mo->x, player->mo->y) - actor->angle;
if (an > ANGLE_90 && an < ANGLE_270)
{
dist = FixedHypot(player->mo->x - actor->x, player->mo->y - actor->y);
dist = P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y);
// if real close, react anyway
if (dist > FixedMul(MELEERANGE, actor->scale))
continue; // behind back
@ -821,7 +821,7 @@ static boolean P_LookForShield(mobj_t *actor)
continue;
if ((player->powers[pw_shield] & SH_PROTECTELECTRIC)
&& (FixedHypot(FixedHypot(actor->x-player->mo->x, actor->y-player->mo->y), actor->z-player->mo->z) < FixedMul(RING_DIST, player->mo->scale)))
&& (P_AproxDistance(P_AproxDistance(actor->x-player->mo->x, actor->y-player->mo->y), actor->z-player->mo->z) < FixedMul(RING_DIST, player->mo->scale)))
{
P_SetTarget(&actor->tracer, player->mo);
@ -1548,8 +1548,8 @@ void A_PointyThink(mobj_t *actor)
}
else
{
if (FixedHypot(players[i].mo->x - actor->x, players[i].mo->y - actor->y) <
FixedHypot(player->mo->x - actor->x, player->mo->y - actor->y))
if (P_AproxDistance(players[i].mo->x - actor->x, players[i].mo->y - actor->y) <
P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y))
player = &players[i];
}
}
@ -1561,7 +1561,7 @@ void A_PointyThink(mobj_t *actor)
P_SetTarget(&actor->target, player->mo);
A_FaceTarget(actor);
if (FixedHypot(player->mo->x - actor->x, player->mo->y - actor->y) < FixedHypot(player->mo->x + player->mo->momx - actor->x, player->mo->y + player->mo->momy - actor->y))
if (P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y) < P_AproxDistance(player->mo->x + player->mo->momx - actor->x, player->mo->y + player->mo->momy - actor->y))
sign = -1; // Player is moving away
else
sign = 1; // Player is moving closer
@ -1638,7 +1638,7 @@ static void P_ParabolicMove(mobj_t *actor, fixed_t x, fixed_t y, fixed_t z, fixe
y -= actor->y;
z -= actor->z;
dh = FixedHypot(x, y);
dh = P_AproxDistance(x, y);
actor->momx = FixedMul(FixedDiv(x, dh), speed);
actor->momy = FixedMul(FixedDiv(y, dh), speed);
@ -1706,7 +1706,7 @@ void A_HoodThink(mobj_t *actor)
}
dx = (actor->target->x - actor->x), dy = (actor->target->y - actor->y), dz = (actor->target->z - actor->z);
dm = FixedHypot(dx, dy);
dm = P_AproxDistance(dx, dy);
// Target dangerously close to robohood, retreat then.
if ((dm < 256<<FRACBITS) && (abs(dz) < 128<<FRACBITS))
{
@ -2094,7 +2094,7 @@ void A_CrushclawAim(mobj_t *actor)
if (!crab->target || !crab->info->missilestate || (statenum_t)(crab->state-states) == crab->info->missilestate)
return;
if (((ang + ANG1) < ANG2) || FixedHypot(crab->x - crab->target->x, crab->y - crab->target->y) < 333*crab->scale)
if (((ang + ANG1) < ANG2) || P_AproxDistance(crab->x - crab->target->x, crab->y - crab->target->y) < 333*crab->scale)
P_SetMobjState(crab, crab->info->missilestate);
}
@ -2703,7 +2703,7 @@ void A_LobShot(mobj_t *actor)
shot->angle = an = actor->angle;
an >>= ANGLETOFINESHIFT;
dist = FixedHypot(actor->target->x - shot->x, actor->target->y - shot->y);
dist = P_AproxDistance(actor->target->x - shot->x, actor->target->y - shot->y);
horizontal = dist / airtime;
vertical = FixedMul((gravity*airtime)/2, shot->scale);
@ -2721,7 +2721,7 @@ void A_LobShot(mobj_t *actor)
diff = actor->z - actor->target->z;
{
launchhyp = FixedHypot(horizontal, vertical);
launchhyp = P_AproxDistance(horizontal, vertical);
orig = FixedMul(FixedDiv(vertical, horizontal), diff);
@ -3325,7 +3325,7 @@ void A_SkullAttack(mobj_t *actor)
S_StartSound(actor, actor->info->activesound);
A_FaceTarget(actor);
dist = FixedHypot(dest->x - actor->x, dest->y - actor->y);
dist = P_AproxDistance(dest->x - actor->x, dest->y - actor->y);
if (locvar1 == 1)
actor->angle += ANGLE_180;
@ -3443,7 +3443,7 @@ void A_BossZoom(mobj_t *actor)
an = actor->angle >> ANGLETOFINESHIFT;
actor->momx = FixedMul(FixedMul(actor->info->speed*5*FRACUNIT, actor->scale), FINECOSINE(an));
actor->momy = FixedMul(FixedMul(actor->info->speed*5*FRACUNIT, actor->scale), FINESINE(an));
dist = FixedHypot(dest->x - actor->x, dest->y - actor->y);
dist = P_AproxDistance(dest->x - actor->x, dest->y - actor->y);
dist = dist / FixedMul(actor->info->speed*5*FRACUNIT, actor->scale);
if (dist < 1)
@ -3599,7 +3599,7 @@ void A_1upThinker(mobj_t *actor)
if ((netgame || multiplayer) && players[i].playerstate != PST_LIVE)
continue;
temp = FixedHypot(players[i].mo->x-actor->x, players[i].mo->y-actor->y);
temp = P_AproxDistance(players[i].mo->x-actor->x, players[i].mo->y-actor->y);
if (temp < dist)
{
@ -4144,8 +4144,8 @@ bossjustdie:
// If this one's further then the last one, don't go for it.
if (mo->target &&
FixedHypot(FixedHypot(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z) >
FixedHypot(FixedHypot(mo->x - mo->target->x, mo->y - mo->target->y), mo->z - mo->target->z))
P_AproxDistance(P_AproxDistance(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z) >
P_AproxDistance(P_AproxDistance(mo->x - mo->target->x, mo->y - mo->target->y), mo->z - mo->target->z))
continue;
// Otherwise... Do!
@ -4536,7 +4536,7 @@ void A_BubbleSpawn(mobj_t *actor)
// Don't spawn bubbles unless a player is relatively close by (var1).
for (i = 0; i < MAXPLAYERS; ++i)
if (playeringame[i] && players[i].mo
&& FixedHypot(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (locvar1<<FRACBITS))
&& P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (locvar1<<FRACBITS))
break; // Stop looking.
if (i == MAXPLAYERS)
return; // don't make bubble!
@ -4584,7 +4584,7 @@ void A_FanBubbleSpawn(mobj_t *actor)
// Don't spawn bubbles unless a player is relatively close by (var2).
for (i = 0; i < MAXPLAYERS; ++i)
if (playeringame[i] && players[i].mo
&& FixedHypot(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (locvar1<<FRACBITS))
&& P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (locvar1<<FRACBITS))
break; // Stop looking.
if (i == MAXPLAYERS)
return; // don't make bubble!
@ -4759,7 +4759,7 @@ void A_DropMine(mobj_t *actor)
if (!target)
return;
dist = FixedHypot(actor->x-target->x, actor->y-target->y)>>FRACBITS;
dist = P_AproxDistance(actor->x-target->x, actor->y-target->y)>>FRACBITS;
if (dist > FixedMul((locvar2 & 65535), actor->scale))
return;
@ -4800,7 +4800,7 @@ void A_FishJump(mobj_t *actor)
// Don't spawn trail unless a player is nearby.
for (i = 0; i < MAXPLAYERS; ++i)
if (playeringame[i] && players[i].mo
&& FixedHypot(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed))
&& P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed))
break; // Stop looking.
if (i < MAXPLAYERS)
{
@ -4905,7 +4905,7 @@ void A_ThrownRing(mobj_t *actor)
// magnetic player. If he gets too far away, make
// sure to stop the attraction!
if ((!actor->tracer->health) || (actor->tracer->player && (actor->tracer->player->powers[pw_shield] & SH_PROTECTELECTRIC)
&& FixedHypot(FixedHypot(actor->tracer->x-actor->x,
&& P_AproxDistance(P_AproxDistance(actor->tracer->x-actor->x,
actor->tracer->y-actor->y), actor->tracer->z-actor->z) > FixedMul(RING_DIST/4, actor->tracer->scale)))
{
P_SetTarget(&actor->tracer, NULL);
@ -4964,7 +4964,7 @@ void A_ThrownRing(mobj_t *actor)
continue;
}
dist = FixedHypot(FixedHypot(player->mo->x-actor->x,
dist = P_AproxDistance(P_AproxDistance(player->mo->x-actor->x,
player->mo->y-actor->y), player->mo->z-actor->z);
// check distance
@ -5345,7 +5345,7 @@ void A_JetChase(mobj_t *actor)
return; // got a new target
// If the player is over 3072 fracunits away, then look for another player
if (FixedHypot(FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y),
if (P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y),
actor->target->z - actor->z) > FixedMul(3072*FRACUNIT, actor->scale) && P_LookForPlayers(actor, true, false, FixedMul(3072*FRACUNIT, actor->scale)))
{
return; // got a new target
@ -5460,7 +5460,7 @@ void A_JetgShoot(mobj_t *actor)
if (actor->reactiontime)
return;
dist = FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y);
dist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y);
if (dist > FixedMul(actor->info->painchance*FRACUNIT, actor->scale))
return;
@ -5497,7 +5497,7 @@ void A_ShootBullet(mobj_t *actor)
if (!actor->target)
return;
dist = FixedHypot(FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z);
dist = P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z);
if (dist > FixedMul(actor->info->painchance*FRACUNIT, actor->scale))
return;
@ -5522,7 +5522,7 @@ static boolean PIT_MinusCarry(mobj_t *thing)
if (!(thing->flags & (MF_PUSHABLE|MF_ENEMY)))
return true;
if (FixedHypot(minus->x - thing->x, minus->y - thing->y) >= minus->radius*3)
if (P_AproxDistance(minus->x - thing->x, minus->y - thing->y) >= minus->radius*3)
return true;
if (abs(thing->z - minus->z) > minus->height)
@ -5566,7 +5566,7 @@ void A_MinusDigging(mobj_t *actor)
P_TryMove(par, x, y, false);
// If close enough, prepare to attack
if (FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y) < actor->radius*2)
if (P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) < actor->radius*2)
{
P_SetMobjState(actor, actor->info->meleestate);
P_TryMove(actor, actor->target->x, actor->target->y, false);
@ -5858,7 +5858,7 @@ void A_DetonChase(mobj_t *actor)
}
}*/
// movedir is up/down angle: how much it has to go up as it goes over to the player
xydist = FixedHypot(actor->tracer->x - actor->x, actor->tracer->y - actor->y);
xydist = P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y);
exact = R_PointToAngle2(0, 0, xydist, actor->tracer->z - actor->z);
actor->movedir = exact;
/*if (exact != actor->movedir)
@ -5880,7 +5880,7 @@ void A_DetonChase(mobj_t *actor)
// check for melee attack
if (actor->tracer)
{
if (FixedHypot(actor->tracer->x-actor->x, actor->tracer->y-actor->y) < actor->radius+actor->tracer->radius)
if (P_AproxDistance(actor->tracer->x-actor->x, actor->tracer->y-actor->y) < actor->radius+actor->tracer->radius)
{
if (!((actor->tracer->z > actor->z + actor->height) || (actor->z > actor->tracer->z + actor->tracer->height)))
{
@ -5891,7 +5891,7 @@ void A_DetonChase(mobj_t *actor)
}
// chase towards player
if ((dist = FixedHypot(xydist, actor->tracer->z-actor->z))
if ((dist = P_AproxDistance(xydist, actor->tracer->z-actor->z))
> FixedMul((actor->info->painchance << FRACBITS), actor->scale))
{
P_SetTarget(&actor->tracer, NULL); // Too far away
@ -5938,7 +5938,7 @@ void A_DetonChase(mobj_t *actor)
actor->momy = FixedMul(xyspeed, FINESINE(exact));
// Variable re-use
xyspeed = (FixedHypot(actor->tracer->x - actor->x, FixedHypot(actor->tracer->y - actor->y, actor->tracer->z - actor->z))>>(FRACBITS+6));
xyspeed = (P_AproxDistance(actor->tracer->x - actor->x, P_AproxDistance(actor->tracer->y - actor->y, actor->tracer->z - actor->z))>>(FRACBITS+6));
if (xyspeed < 1)
xyspeed = 1;
@ -6086,7 +6086,7 @@ void A_UnidusBall(mobj_t *actor)
if (actor->movecount)
{
if (FixedHypot(actor->momx, actor->momy) < FixedMul(actor->info->damage/2, actor->scale))
if (P_AproxDistance(actor->momx, actor->momy) < FixedMul(actor->info->damage/2, actor->scale))
P_ExplodeMissile(actor);
return;
}
@ -6118,7 +6118,7 @@ void A_UnidusBall(mobj_t *actor)
if (locvar1 == 1 && canthrow)
{
if (FixedHypot(actor->target->target->x - actor->target->x, actor->target->target->y - actor->target->y) > FixedMul(MISSILERANGE>>1, actor->scale)
if (P_AproxDistance(actor->target->target->x - actor->target->x, actor->target->target->y - actor->target->y) > FixedMul(MISSILERANGE>>1, actor->scale)
|| !P_CheckSight(actor, actor->target->target))
return;
@ -6193,7 +6193,7 @@ void A_RockSpawn(mobj_t *actor)
return;
}
dist = FixedHypot(line->dx, line->dy)/16;
dist = P_AproxDistance(line->dx, line->dy)/16;
if (dist < 1)
dist = 1;
@ -6359,7 +6359,7 @@ void A_CrawlaCommanderThink(mobj_t *actor)
return;
}
dist = FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y);
dist = P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y);
if (actor->target->player && (!hovermode || actor->reactiontime <= 2*TICRATE))
{
@ -6396,7 +6396,7 @@ void A_CrawlaCommanderThink(mobj_t *actor)
{
fixed_t mom;
P_Thrust(actor, actor->angle, 2*actor->scale);
mom = FixedHypot(actor->momx, actor->momy);
mom = P_AproxDistance(actor->momx, actor->momy);
if (mom > 20*actor->scale)
{
mom += 20*actor->scale;
@ -6484,7 +6484,7 @@ void A_RingExplode(mobj_t *actor)
if (mo2 == actor) // Don't explode yourself! Endless loop!
continue;
if (FixedHypot(FixedHypot(mo2->x - actor->x, mo2->y - actor->y), mo2->z - actor->z) > FixedMul(actor->info->painchance, actor->scale))
if (P_AproxDistance(P_AproxDistance(mo2->x - actor->x, mo2->y - actor->y), mo2->z - actor->z) > FixedMul(actor->info->painchance, actor->scale))
continue;
if (mo2->flags & MF_SHOOTABLE)
@ -7083,7 +7083,7 @@ nomissile:
}
// chase towards player
if (FixedHypot(actor->target->x-actor->x, actor->target->y-actor->y) > actor->radius+actor->target->radius)
if (P_AproxDistance(actor->target->x-actor->x, actor->target->y-actor->y) > actor->radius+actor->target->radius)
{
if (--actor->movecount < 0 || !P_Move(actor, actor->info->speed))
P_NewChaseDir(actor);
@ -7322,7 +7322,7 @@ void A_Boss7Chase(mobj_t *actor)
// Self-adjust if stuck on the edge
if (actor->tracer)
{
if (FixedHypot(actor->x - actor->tracer->x, actor->y - actor->tracer->y) > 128*FRACUNIT - actor->radius)
if (P_AproxDistance(actor->x - actor->tracer->x, actor->y - actor->tracer->y) > 128*FRACUNIT - actor->radius)
P_InstaThrust(actor, R_PointToAngle2(actor->x, actor->y, actor->tracer->x, actor->tracer->y), FRACUNIT);
}
@ -7358,7 +7358,7 @@ void A_Boss7Chase(mobj_t *actor)
if (players[i].mo->health <= 0)
continue;
if (FixedHypot(players[i].mo->x - actor->x, players[i].mo->y - actor->y) > actor->radius)
if (P_AproxDistance(players[i].mo->x - actor->x, players[i].mo->y - actor->y) > actor->radius)
continue;
if (players[i].mo->z > actor->z + actor->height - 2*FRACUNIT
@ -7481,7 +7481,7 @@ void A_Boss2PogoSFX(mobj_t *actor)
}
// Boing!
if (FixedHypot(actor->x-actor->target->x, actor->y-actor->target->y) < FixedMul(256*FRACUNIT, actor->scale))
if (P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) < FixedMul(256*FRACUNIT, actor->scale))
{
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y);
P_InstaThrust(actor, actor->angle, FixedMul(actor->info->speed, actor->scale));
@ -7514,7 +7514,7 @@ void A_Boss2PogoTarget(mobj_t *actor)
return;
if (!actor->target || !(actor->target->flags & MF_SHOOTABLE) || (actor->target->player && actor->target->player->powers[pw_flashing])
|| FixedHypot(actor->x-actor->target->x, actor->y-actor->target->y) >= FixedMul(512*FRACUNIT, actor->scale))
|| P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) >= FixedMul(512*FRACUNIT, actor->scale))
{
// look for a new target
if (P_LookForPlayers(actor, true, false, 512*FRACUNIT))
@ -7535,7 +7535,7 @@ void A_Boss2PogoTarget(mobj_t *actor)
P_InstaThrust(actor, actor->angle+ANGLE_180, FixedMul(FixedMul(actor->info->speed,(locvar2)), actor->scale)); // Move at wandering speed
}
// Try to land on top of the player.
else if (FixedHypot(actor->x-actor->target->x, actor->y-actor->target->y) < FixedMul(512*FRACUNIT, actor->scale))
else if (P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) < FixedMul(512*FRACUNIT, actor->scale))
{
fixed_t airtime, gravityadd, zoffs, height;
@ -7569,7 +7569,7 @@ void A_Boss2PogoTarget(mobj_t *actor)
airtime = FixedDiv((-actor->momz - FixedSqrt(FixedMul(actor->momz,actor->momz)+zoffs)), gravityadd)<<1; // to try and land on their head rather than on their feet
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y);
P_InstaThrust(actor, actor->angle, FixedDiv(FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y), airtime));
P_InstaThrust(actor, actor->angle, FixedDiv(P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y), airtime));
}
// Wander semi-randomly towards the player to get closer.
else
@ -7640,7 +7640,7 @@ void A_TurretFire(mobj_t *actor)
while (P_SupermanLook4Players(actor) && count < MAXPLAYERS)
{
if (FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y) < dist)
if (P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) < dist)
{
actor->flags2 |= MF2_FIRING;
actor->extravalue1 = locvar1;
@ -7678,7 +7678,7 @@ void A_SuperTurretFire(mobj_t *actor)
while (P_SupermanLook4Players(actor) && count < MAXPLAYERS)
{
if (FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y) < dist)
if (P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) < dist)
{
actor->flags2 |= MF2_FIRING;
actor->flags2 |= MF2_SUPERFIRE;
@ -7799,7 +7799,7 @@ void A_BuzzFly(mobj_t *actor)
}
// If the player is over 3072 fracunits away, then look for another player
if (FixedHypot(FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y),
if (P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y),
actor->target->z - actor->z) > FixedMul(3072*FRACUNIT, actor->scale))
{
if (multiplayer || netgame)
@ -7818,7 +7818,7 @@ void A_BuzzFly(mobj_t *actor)
else
realspeed = FixedMul(actor->info->speed, actor->scale);
dist = FixedHypot(FixedHypot(actor->target->x - actor->x,
dist = P_AproxDistance(P_AproxDistance(actor->target->x - actor->x,
actor->target->y - actor->y), actor->target->z - actor->z);
if (dist < 1)
@ -8176,7 +8176,7 @@ void A_Boss3Path(mobj_t *actor)
if (actor->target->x == actor->x && actor->target->y == actor->y)
{
dist = FixedHypot(FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z + actor->movefactor - actor->z);
dist = P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z + actor->movefactor - actor->z);
if (dist < 1)
dist = 1;
@ -9586,7 +9586,7 @@ void A_SetObjectTypeState(mobj_t *actor)
if (mo2->type == (mobjtype_t)loc2lw)
{
dist = FixedHypot(mo2->x - actor->x, mo2->y - actor->y);
dist = P_AproxDistance(mo2->x - actor->x, mo2->y - actor->y);
if (mo2->health > 0)
{
@ -10092,9 +10092,9 @@ void A_CheckRange(mobj_t *actor)
return;
if (!(locvar1 >> 16)) //target
dist = FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y);
dist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y);
else //tracer
dist = FixedHypot(actor->tracer->x - actor->x, actor->tracer->y - actor->y);
dist = P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y);
if (dist <= FixedMul((locvar1 & 65535)*FRACUNIT, actor->scale))
P_SetMobjState(actor, locvar2);
@ -10156,16 +10156,16 @@ void A_CheckTrueRange(mobj_t *actor)
if (!(locvar1 >> 16)) // target
{
height = actor->target->z - actor->z;
dist = FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y);
dist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y);
}
else // tracer
{
height = actor->tracer->z - actor->z;
dist = FixedHypot(actor->tracer->x - actor->x, actor->tracer->y - actor->y);
dist = P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y);
}
l = FixedHypot(dist, height);
l = P_AproxDistance(dist, height);
if (l <= FixedMul((locvar1 & 65535)*FRACUNIT, actor->scale))
P_SetMobjState(actor, locvar2);
@ -10210,7 +10210,7 @@ void A_CheckThingCount(mobj_t *actor)
if (mo2->type == (mobjtype_t)loc1up)
{
dist = FixedHypot(mo2->x - actor->x, mo2->y - actor->y);
dist = P_AproxDistance(mo2->x - actor->x, mo2->y - actor->y);
if (loc2up == 0)
count++;
@ -10819,7 +10819,7 @@ void A_HomingChase(mobj_t *actor)
actor->angle = R_PointToAngle2(actor->x, actor->y, dest->x, dest->y);
dist = FixedHypot(FixedHypot(dest->x - actor->x, dest->y - actor->y), dest->z - actor->z);
dist = P_AproxDistance(P_AproxDistance(dest->x - actor->x, dest->y - actor->y), dest->z - actor->z);
if (dist < 1)
dist = 1;
@ -11405,14 +11405,14 @@ void A_BrakLobShot(mobj_t *actor)
g = gravity;
// Look up distance between actor and its target
x = FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y);
x = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y);
if (!aimDirect)
{
// Distance should actually be a third of the way over
x = FixedDiv(x, 3<<FRACBITS);
newTargetX = actor->x + P_ReturnThrustX(actor, actor->angle, x);
newTargetY = actor->y + P_ReturnThrustY(actor, actor->angle, x);
x = FixedHypot(newTargetX - actor->x, newTargetY - actor->y);
x = P_AproxDistance(newTargetX - actor->x, newTargetY - actor->y);
// Look up height difference between actor and the ground 1/3 of the way to its target
y = P_FloorzAtPos(newTargetX, newTargetY, actor->target->z, actor->target->height) - (actor->z + FixedMul(locvar2*FRACUNIT, actor->scale));
}
@ -11764,7 +11764,7 @@ void A_FlickyCenter(mobj_t *actor)
P_LookForPlayers(actor, true, false, actor->extravalue1);
if (actor->target && FixedHypot(actor->target->x - originx, actor->target->y - originy) < actor->extravalue1)
if (actor->target && P_AproxDistance(actor->target->x - originx, actor->target->y - originy) < actor->extravalue1)
{
actor->extravalue2 = 1;
P_TeleportMove(actor, actor->target->x, actor->target->y, actor->target->z);
@ -11820,7 +11820,7 @@ void A_FlickyAim(mobj_t *actor)
if ((actor->momx == actor->momy && actor->momy == 0)
|| (actor->target && P_IsFlickyCenter(actor->target->type)
&& actor->target->extravalue1 && (actor->target->flags & MF_SLIDEME)
&& FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y) >= actor->target->extravalue1))
&& P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) >= actor->target->extravalue1))
flickyhitwall = true;
P_InternalFlickyBubble(actor);
@ -11842,12 +11842,12 @@ void A_FlickyAim(mobj_t *actor)
actor->movedir *= -1;
posvar = ((R_PointToAngle2(actor->target->x, actor->target->y, actor->x, actor->y) + actor->movedir*locvar1) >> ANGLETOFINESHIFT) & FINEMASK;
chasevar = FixedSqrt(max(FRACUNIT, FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y) - locvar2)) + locvar2;
chasevar = FixedSqrt(max(FRACUNIT, P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y) - locvar2)) + locvar2;
chasex = actor->target->x + FixedMul(FINECOSINE(posvar), chasevar);
chasey = actor->target->y + FixedMul(FINESINE(posvar), chasevar);
if (FixedHypot(chasex - actor->x, chasey - actor->y))
if (P_AproxDistance(chasex - actor->x, chasey - actor->y))
actor->angle = R_PointToAngle2(actor->x, actor->y, chasex, chasey);
}
else if (flickyhitwall)
@ -11889,7 +11889,7 @@ void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fi
targetdist = 16*FRACUNIT; //Default!
if (actor->target && abs(chasez - actor->z) > targetdist)
targetdist = FixedHypot(actor->target->x - actor->x, actor->target->y - actor->y);
targetdist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y);
if (actor->target
&& P_IsFlickyCenter(actor->target->type)
@ -11967,7 +11967,7 @@ void A_FlickyCoast(mobj_t *actor)
actor->momy = (11*actor->momy)/12;
actor->momz = (11*actor->momz)/12;
if (FixedHypot(FixedHypot(actor->momx, actor->momy), actor->momz) < locvar1)
if (P_AproxDistance(P_AproxDistance(actor->momx, actor->momy), actor->momz) < locvar1)
P_SetMobjState(actor, locvar2);
return;
@ -12231,7 +12231,7 @@ void A_Boss5Jump(mobj_t *actor)
g = gravity;
// Look up distance between actor and its tracer
x = FixedHypot(actor->tracer->x - actor->x, actor->tracer->y - actor->y);
x = P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y);
// Look up height difference between actor and its tracer
y = actor->tracer->z - actor->z;
@ -12352,7 +12352,7 @@ void A_MineExplode(mobj_t *actor)
actor->z+P_RandomRange(((actor->eflags & MFE_UNDERWATER) ? -dist : 0), dist)*FRACUNIT,
type);
fixed_t dx = b->x - actor->x, dy = b->y - actor->y, dz = b->z - actor->z;
fixed_t dm = FixedHypot(dz, FixedHypot(dy, dx));
fixed_t dm = P_AproxDistance(dz, P_AproxDistance(dy, dx));
b->momx = FixedDiv(dx, dm)*3;
b->momy = FixedDiv(dy, dm)*3;
b->momz = FixedDiv(dz, dm)*3;
@ -12384,7 +12384,7 @@ void A_MineRange(mobj_t *actor)
if (!actor->target)
return;
dm = FixedHypot(actor->z - actor->target->z, FixedHypot(actor->y - actor->target->y, actor->x - actor->target->x));
dm = P_AproxDistance(actor->z - actor->target->z, P_AproxDistance(actor->y - actor->target->y, actor->x - actor->target->x));
if ((dm>>FRACBITS) < locvar1)
P_SetMobjState(actor, actor->info->meleestate);
}
@ -12510,7 +12510,7 @@ void A_MultiShotDist(mobj_t *actor)
// Don't spawn dust unless a player is relatively close by (var1).
for (i = 0; i < MAXPLAYERS; ++i)
if (playeringame[i] && players[i].mo
&& FixedHypot(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (1600<<FRACBITS))
&& P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (1600<<FRACBITS))
break; // Stop looking.
if (i == MAXPLAYERS)
return; // don't make bubble!
@ -12680,8 +12680,8 @@ void A_Boss5FindWaypoint(mobj_t *actor)
// If this one's further then the last one, don't go for it.
if (actor->tracer &&
FixedHypot(FixedHypot(actor->x - mo2->x, actor->y - mo2->y), actor->z - mo2->z) >
FixedHypot(FixedHypot(actor->x - actor->tracer->x, actor->y - actor->tracer->y), actor->z - actor->tracer->z))
P_AproxDistance(P_AproxDistance(actor->x - mo2->x, actor->y - mo2->y), actor->z - mo2->z) >
P_AproxDistance(P_AproxDistance(actor->x - actor->tracer->x, actor->y - actor->tracer->y), actor->z - actor->tracer->z))
continue;
// Otherwise... Do!
@ -13058,7 +13058,7 @@ void A_Boss5CheckOnGround(mobj_t *actor)
P_SetMobjState(actor, locvar1);
}
if (actor->tracer && FixedHypot(actor->tracer->x - actor->x, actor->tracer->y - actor->y) < 2*actor->radius)
if (actor->tracer && P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y) < 2*actor->radius)
{
actor->momx = (4*actor->momx)/5;
actor->momy = (4*actor->momy)/5;
@ -13518,7 +13518,7 @@ static boolean PIT_TNTExplode(mobj_t *nearby)
dx = nearby->x - barrel->x;
dy = nearby->y - barrel->y;
dz = nearby->z - barrel->z + (nearby->height - barrel->height/2)/2;
dm = FixedHypot(FixedHypot(dx, dy), dz);
dm = P_AproxDistance(P_AproxDistance(dx, dy), dz);
if (dm >= exploderadius || !P_CheckSight(barrel, nearby)) // out of range or not visible
return true;
@ -13921,7 +13921,7 @@ void A_SnapperThinker(mobj_t *actor)
// Look for nearby, valid players to chase angrily at.
if ((actor->target || P_LookForPlayers(actor, true, false, 1024*FRACUNIT))
&& FixedHypot(actor->target->x - xs, actor->target->y - ys) < 2048*FRACUNIT
&& P_AproxDistance(actor->target->x - xs, actor->target->y - ys) < 2048*FRACUNIT
&& abs(actor->target->z - actor->z) < 80*FRACUNIT
&& P_CheckSight(actor, actor->target))
{
@ -13936,7 +13936,7 @@ void A_SnapperThinker(mobj_t *actor)
y1 = ys;
}
dist = FixedHypot(x1 - x0, y1 - y0);
dist = P_AproxDistance(x1 - x0, y1 - y0);
// The snapper either chases what it considers to be a nearby player, or instead decides to go back to its spawnpoint.
if (chasing || dist > 32*FRACUNIT)
@ -14121,7 +14121,7 @@ void A_LavafallRocks(mobj_t *actor)
// Don't spawn rocks unless a player is relatively close by.
for (i = 0; i < MAXPLAYERS; ++i)
if (playeringame[i] && players[i].mo
&& FixedHypot(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed >> 1))
&& P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed >> 1))
break; // Stop looking.
if (i < MAXPLAYERS)
@ -14155,7 +14155,7 @@ void A_LavafallLava(mobj_t *actor)
// Don't spawn lava unless a player is nearby.
for (i = 0; i < MAXPLAYERS; ++i)
if (playeringame[i] && players[i].mo
&& FixedHypot(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed))
&& P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed))
break; // Stop looking.
if (i >= MAXPLAYERS)
@ -14285,7 +14285,7 @@ void A_RolloutSpawn(mobj_t *actor)
if (!(actor->target)
|| P_MobjWasRemoved(actor->target)
|| FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y) > locvar1)
|| P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) > locvar1)
{
actor->target = P_SpawnMobj(actor->x, actor->y, actor->z, locvar2);
actor->target->flags2 |= (actor->flags2 & (MF2_AMBUSH | MF2_OBJECTFLIP)) | MF2_SLIDEPUSH;
@ -14313,7 +14313,7 @@ void A_RolloutRock(mobj_t *actor)
UINT8 maxframes = actor->info->reactiontime; // number of frames the mobj cycles through
fixed_t pi = (22*FRACUNIT/7);
fixed_t circumference = FixedMul(2 * pi, actor->radius); // used to calculate when to change frame
fixed_t speed = FixedHypot(actor->momx, actor->momy), topspeed = FixedMul(actor->info->speed, actor->scale);
fixed_t speed = P_AproxDistance(actor->momx, actor->momy), topspeed = FixedMul(actor->info->speed, actor->scale);
boolean inwater = actor->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER);
if (LUA_CallAction(A_ROLLOUTROCK, actor))
@ -14355,7 +14355,7 @@ void A_RolloutRock(mobj_t *actor)
actor->momy = FixedMul(actor->momy, locvar1);
}
speed = FixedHypot(actor->momx, actor->momy); // recalculate speed for visual rolling
speed = P_AproxDistance(actor->momx, actor->momy); // recalculate speed for visual rolling
if (speed < actor->scale >> 1) // stop moving if speed is insignificant
{
@ -14477,7 +14477,7 @@ void A_DragonSegment(mobj_t *actor)
return;
}
dist = FixedHypot(FixedHypot(actor->x - target->x, actor->y - target->y), actor->z - target->z);
dist = P_AproxDistance(P_AproxDistance(actor->x - target->x, actor->y - target->y), actor->z - target->z);
radius = actor->radius + target->radius;
hangle = R_PointToAngle2(target->x, target->y, actor->x, actor->y);
zangle = R_PointToAngle2(0, target->z, dist, actor->z);

View file

@ -1164,7 +1164,7 @@ void T_ThwompSector(thwomp_t *thwomp)
if (players[i].mo->z > thwomp->sector->ceilingheight)
continue;
if (FixedHypot(thwompx - players[i].mo->x, thwompy - players[i].mo->y) > 96*FRACUNIT)
if (P_AproxDistance(thwompx - players[i].mo->x, thwompy - players[i].mo->y) > 96*FRACUNIT)
continue;
thwomp->direction = -1;
@ -1892,7 +1892,7 @@ void EV_DoFloor(line_t *line, floor_e floortype)
// Linedef executor command, linetype 106.
// Line length = speed, front sector floor = destination height.
case moveFloorByFrontSector:
dofloor->speed = FixedHypot(line->dx, line->dy);
dofloor->speed = P_AproxDistance(line->dx, line->dy);
dofloor->speed = FixedDiv(dofloor->speed,8*FRACUNIT);
dofloor->floordestheight = line->frontsector->floorheight;
@ -1958,7 +1958,7 @@ void EV_DoFloor(line_t *line, floor_e floortype)
// Linetypes 2/3.
// Move floor up and down indefinitely like the old elevators.
case bounceFloor:
dofloor->speed = FixedHypot(line->dx, line->dy); // same speed as elevateContinuous
dofloor->speed = P_AproxDistance(line->dx, line->dy); // same speed as elevateContinuous
dofloor->speed = FixedDiv(dofloor->speed,4*FRACUNIT);
dofloor->origspeed = dofloor->speed; // it gets slowed down at the top and bottom
dofloor->floordestheight = line->frontsector->floorheight;
@ -2104,7 +2104,7 @@ void EV_DoElevator(line_t *line, elevator_e elevtype, boolean customspeed)
case elevateContinuous:
if (customspeed)
{
elevator->origspeed = FixedHypot(line->dx, line->dy);
elevator->origspeed = P_AproxDistance(line->dx, line->dy);
elevator->origspeed = FixedDiv(elevator->origspeed,4*FRACUNIT);
elevator->speed = elevator->origspeed;
}
@ -2266,7 +2266,7 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover)
if (flags & ML_EFFECT1)
{
P_InstaThrust(spawned, R_PointToAngle2(sec->soundorg.x, sec->soundorg.y, a, b), FixedDiv(FixedHypot(a - sec->soundorg.x, b - sec->soundorg.y), widthfactor));
P_InstaThrust(spawned, R_PointToAngle2(sec->soundorg.x, sec->soundorg.y, a, b), FixedDiv(P_AproxDistance(a - sec->soundorg.x, b - sec->soundorg.y), widthfactor));
P_SetObjectMomZ(spawned, FixedDiv((c - bottomz), heightfactor), false);
}

View file

@ -1002,7 +1002,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
x = (x/count)<<FRACBITS;
y = (y/count)<<FRACBITS;
z = (z/count)<<FRACBITS;
gatherradius = FixedHypot(FixedHypot(special->x - x, special->y - y), special->z - z);
gatherradius = P_AproxDistance(P_AproxDistance(special->x - x, special->y - y), special->z - z);
P_RemoveMobj(special);
if (player->powers[pw_nights_superloop])
@ -1028,7 +1028,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
mo2 = (mobj_t *)th;
if (FixedHypot(FixedHypot(mo2->x - x, mo2->y - y), mo2->z - z) > gatherradius)
if (P_AproxDistance(P_AproxDistance(mo2->x - x, mo2->y - y), mo2->z - z) > gatherradius)
continue;
if (mo2->flags & MF_SHOOTABLE)
@ -1450,8 +1450,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
fixed_t touchx, touchy, touchspeed;
angle_t angle;
if (FixedHypot(toucher->x-special->x, toucher->y-special->y) >
FixedHypot((toucher->x-toucher->momx)-special->x, (toucher->y-toucher->momy)-special->y))
if (P_AproxDistance(toucher->x-special->x, toucher->y-special->y) >
P_AproxDistance((toucher->x-toucher->momx)-special->x, (toucher->y-toucher->momy)-special->y))
{
touchx = toucher->x + toucher->momx;
touchy = toucher->y + toucher->momy;
@ -1463,7 +1463,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
}
angle = R_PointToAngle2(special->x, special->y, touchx, touchy);
touchspeed = FixedHypot(toucher->momx, toucher->momy);
touchspeed = P_AproxDistance(toucher->momx, toucher->momy);
toucher->momx = P_ReturnThrustX(special, angle, touchspeed);
toucher->momy = P_ReturnThrustY(special, angle, touchspeed);
@ -1509,7 +1509,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
case MT_EGGSHIELD:
{
angle_t angle = R_PointToAngle2(special->x, special->y, toucher->x, toucher->y) - special->angle;
fixed_t touchspeed = FixedHypot(toucher->momx, toucher->momy);
fixed_t touchspeed = P_AproxDistance(toucher->momx, toucher->momy);
if (touchspeed < special->scale)
touchspeed = special->scale;
@ -1590,7 +1590,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
{
special->momx = toucher->momx;
special->momy = toucher->momy;
special->momz = FixedHypot(toucher->momx, toucher->momy)/4;
special->momz = P_AproxDistance(toucher->momx, toucher->momy)/4;
if (toucher->momz > 0)
special->momz += toucher->momz/8;
@ -1762,7 +1762,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
toucher->momx = toucher->tracer->momx/2;
toucher->momy = toucher->tracer->momy/2;
toucher->momz = toucher->tracer->momz + FixedHypot(toucher->tracer->momx, toucher->tracer->momy)/2;
toucher->momz = toucher->tracer->momz + P_AproxDistance(toucher->tracer->momx, toucher->tracer->momy)/2;
P_ResetPlayer(player);
player->pflags &= ~PF_APPLYAUTOBRAKE;
P_SetPlayerMobjState(toucher, S_PLAY_FALL);
@ -2666,7 +2666,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
case MT_BUGGLE:
if (inflictor && inflictor->player // did a player kill you? Spawn relative to the player so they're bound to get it
&& FixedHypot(inflictor->x - target->x, inflictor->y - target->y) <= inflictor->radius + target->radius + FixedMul(8*FRACUNIT, inflictor->scale) // close enough?
&& P_AproxDistance(inflictor->x - target->x, inflictor->y - target->y) <= inflictor->radius + target->radius + FixedMul(8*FRACUNIT, inflictor->scale) // close enough?
&& inflictor->z <= target->z + target->height + FixedMul(8*FRACUNIT, inflictor->scale)
&& inflictor->z + inflictor->height >= target->z - FixedMul(8*FRACUNIT, inflictor->scale))
mo = P_SpawnMobj(inflictor->x + inflictor->momx, inflictor->y + inflictor->momy, inflictor->z + (inflictor->height / 2) + inflictor->momz, MT_EXTRALARGEBUBBLE);
@ -3305,7 +3305,7 @@ static void P_SuperDamage(player_t *player, mobj_t *inflictor, mobj_t *source, I
// to recover
if (inflictor->flags2 & MF2_SCATTER && source)
{
fixed_t dist = FixedHypot(FixedHypot(source->x-player->mo->x, source->y-player->mo->y), source->z-player->mo->z);
fixed_t dist = P_AproxDistance(P_AproxDistance(source->x-player->mo->x, source->y-player->mo->y), source->z-player->mo->z);
dist = FixedMul(128*FRACUNIT, inflictor->scale) - dist/4;

View file

@ -776,7 +776,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
if (thing->flags & MF_SOLID)
S_StartSound(tmthing, thing->info->deathsound);
for (iter = thing->subsector->sector->thinglist; iter; iter = iter->snext)
if (iter->type == thing->type && iter->health > 0 && iter->flags & MF_SOLID && (iter == thing || FixedHypot(FixedHypot(thing->x - iter->x, thing->y - iter->y), thing->z - iter->z) < 56*thing->scale))//FixedMul(56*FRACUNIT, thing->scale))
if (iter->type == thing->type && iter->health > 0 && iter->flags & MF_SOLID && (iter == thing || P_AproxDistance(P_AproxDistance(thing->x - iter->x, thing->y - iter->y), thing->z - iter->z) < 56*thing->scale))//FixedMul(56*FRACUNIT, thing->scale))
P_KillMobj(iter, tmthing, tmthing, 0);
}
else
@ -815,7 +815,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
if (thing->flags & MF_SOLID)
S_StartSound(tmthing, thing->info->deathsound);
for (iter = thing->subsector->sector->thinglist; iter; iter = iter->snext)
if (iter->type == thing->type && iter->health > 0 && iter->flags & MF_SOLID && (iter == thing || FixedHypot(FixedHypot(thing->x - iter->x, thing->y - iter->y), thing->z - iter->z) < 56*thing->scale))//FixedMul(56*FRACUNIT, thing->scale))
if (iter->type == thing->type && iter->health > 0 && iter->flags & MF_SOLID && (iter == thing || P_AproxDistance(P_AproxDistance(thing->x - iter->x, thing->y - iter->y), thing->z - iter->z) < 56*thing->scale))//FixedMul(56*FRACUNIT, thing->scale))
P_KillMobj(iter, tmthing, tmthing, 0);
return true;
}
@ -3063,7 +3063,7 @@ static void P_HitCameraSlideLine(line_t *ld, camera_t *thiscam)
lineangle >>= ANGLETOFINESHIFT;
deltaangle >>= ANGLETOFINESHIFT;
movelen = FixedHypot(tmxmove, tmymove);
movelen = P_AproxDistance(tmxmove, tmymove);
newlen = FixedMul(movelen, FINECOSINE(deltaangle));
tmxmove = FixedMul(newlen, FINECOSINE(lineangle));
@ -3149,7 +3149,7 @@ static void P_HitBounceLine(line_t *ld)
lineangle >>= ANGLETOFINESHIFT;
deltaangle >>= ANGLETOFINESHIFT;
movelen = FixedHypot(tmxmove, tmymove);
movelen = P_AproxDistance(tmxmove, tmymove);
tmxmove = FixedMul(movelen, FINECOSINE(deltaangle));
tmymove = FixedMul(movelen, FINESINE(deltaangle));
@ -4076,7 +4076,7 @@ static boolean PIT_RadiusAttack(mobj_t *thing)
dy = abs(thing->y - bombspot->y);
dz = abs(thing->z + (thing->height>>1) - bombspot->z);
dist = FixedHypot(FixedHypot(dx, dy), dz);
dist = P_AproxDistance(P_AproxDistance(dx, dy), dz);
dist -= thing->radius;
if (dist < 0)

View file

@ -41,6 +41,7 @@ typedef boolean (*traverser_t)(intercept_t *in);
boolean P_PathTraverse(fixed_t px1, fixed_t py1, fixed_t px2, fixed_t py2,
INT32 pflags, traverser_t ptrav);
#define P_AproxDistance(dx, dy) FixedHypot(dx, dy)
void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result);
void P_ClosestPointOnLine3D(const vector3_t *p, const vector3_t *line, vector3_t *result);
INT32 P_PointOnLineSide(fixed_t x, fixed_t y, line_t *line);

View file

@ -1736,7 +1736,7 @@ static void P_PushableCheckBustables(mobj_t *mo)
// Run a linedef executor??
if (rover->master->flags & ML_EFFECT5)
P_LinedefExecute((INT16)(FixedHypot(rover->master->dx, rover->master->dy)>>FRACBITS), mo, node->m_sector);
P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), mo, node->m_sector);
goto bustupdone;
}
@ -2512,7 +2512,7 @@ boolean P_ZMovement(mobj_t *mo)
// float down towards target if too close
if (!(mo->flags2 & MF2_SKULLFLY) && !(mo->flags2 & MF2_INFLOAT))
{
dist = FixedHypot(mo->x - mo->target->x, mo->y - mo->target->y);
dist = P_AproxDistance(mo->x - mo->target->x, mo->y - mo->target->y);
delta = (mo->target->z + (mo->height>>1)) - mo->z;
@ -3665,11 +3665,11 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
P_ResetCamera(player, thiscam);
else
{
fixed_t camspeed = FixedHypot(thiscam->momx, thiscam->momy);
fixed_t camspeed = P_AproxDistance(thiscam->momx, thiscam->momy);
P_SlideCameraMove(thiscam);
if (!resetcalled && FixedHypot(thiscam->momx, thiscam->momy) == camspeed)
if (!resetcalled && P_AproxDistance(thiscam->momx, thiscam->momy) == camspeed)
{
P_ResetCamera(player, thiscam);
resetcalled = true;
@ -4152,7 +4152,7 @@ boolean P_BossTargetPlayer(mobj_t *actor, boolean closest)
if (closest)
{
dist = FixedHypot(actor->x - player->mo->x, actor->y - player->mo->y);
dist = P_AproxDistance(actor->x - player->mo->x, actor->y - player->mo->y);
if (!lastdist || dist < lastdist)
{
lastdist = dist+1;
@ -4521,7 +4521,7 @@ static void P_Boss3Thinker(mobj_t *mobj)
if (mobj->tracer->x == mobj->x && mobj->tracer->y == mobj->y)
{
// apply ambush for old routing, otherwise whack a mole only
dist = FixedHypot(FixedHypot(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z + mobj->movefactor - mobj->z);
dist = P_AproxDistance(P_AproxDistance(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z + mobj->movefactor - mobj->z);
if (dist < 1)
dist = 1;
@ -5045,7 +5045,7 @@ static void P_Boss5Thinker(mobj_t *mobj)
}
if (mobj->state == &states[mobj->info->xdeathstate])
mobj->momz -= (2*FRACUNIT)/3;
else if (mobj->tracer && FixedHypot(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y) < 2*mobj->radius)
else if (mobj->tracer && P_AproxDistance(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y) < 2*mobj->radius)
mobj->flags &= ~MF_NOCLIP;
}
else
@ -5171,7 +5171,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
if (players[i].mo->health <= 0)
continue;
if (FixedHypot(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y) > (mobj->radius + players[i].mo->radius))
if (P_AproxDistance(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y) > (mobj->radius + players[i].mo->radius))
continue;
if (players[i].mo->z > mobj->z + mobj->height - FRACUNIT
@ -5275,7 +5275,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
if (mobj->health <= mobj->info->damage && !(mo2->spawnpoint->options & 7))
continue; // don't jump to center
dist = FixedHypot(players[i].mo->x - mo2->x, players[i].mo->y - mo2->y);
dist = P_AproxDistance(players[i].mo->x - mo2->x, players[i].mo->y - mo2->y);
if (!(closestNum == -1 || dist < closestdist))
continue;
@ -5348,7 +5348,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
an = mobj->angle;
an >>= ANGLETOFINESHIFT;
dist = FixedHypot(hitspot->x - mobj->x, hitspot->y - mobj->y);
dist = P_AproxDistance(hitspot->x - mobj->x, hitspot->y - mobj->y);
horizontal = dist / airtime;
vertical = (gravity*airtime)/2;
@ -5399,7 +5399,7 @@ static void P_Boss7Thinker(mobj_t *mobj)
if (players[i].mo->health <= 0)
continue;
if (FixedHypot(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y) > mobj->radius*4)
if (P_AproxDistance(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y) > mobj->radius*4)
continue;
if (players[i].mo->z > mobj->z + 128*FRACUNIT)
@ -5653,14 +5653,14 @@ static void P_Boss9Thinker(mobj_t *mobj)
// Spawn energy particles
for (spawner = mobj->hnext; spawner; spawner = spawner->hnext)
{
dist = FixedHypot(spawner->x - mobj->x, spawner->y - mobj->y);
dist = P_AproxDistance(spawner->x - mobj->x, spawner->y - mobj->y);
if (P_RandomRange(1,(dist>>FRACBITS)/16) == 1)
break;
}
if (spawner && dist)
{
mobj_t *missile = P_SpawnMissile(spawner, mobj, MT_MSGATHER);
missile->fuse = (dist/FixedHypot(missile->momx, missile->momy));
missile->fuse = (dist/P_AproxDistance(missile->momx, missile->momy));
if (missile->fuse > mobj->fuse)
P_RemoveMobj(missile);
@ -6092,7 +6092,7 @@ nodanger:
mobj->flags2 |= MF2_INVERTAIMABLE;
// Move normally: Approach the player using normal thrust and simulated friction.
dist = FixedHypot(mobj->x-mobj->target->x, mobj->y-mobj->target->y);
dist = P_AproxDistance(mobj->x-mobj->target->x, mobj->y-mobj->target->y);
P_Thrust(mobj, R_PointToAngle2(0, 0, mobj->momx, mobj->momy), -3*FRACUNIT/8);
if (dist < 64*FRACUNIT && !(mobj->target->player && mobj->target->player->homing))
P_Thrust(mobj, mobj->angle, -4*FRACUNIT);
@ -6100,7 +6100,7 @@ nodanger:
P_Thrust(mobj, mobj->angle, FRACUNIT);
else
P_Thrust(mobj, mobj->angle + ANGLE_90, FINECOSINE((((angle_t)(leveltime*ANG1))>>ANGLETOFINESHIFT) & FINEMASK)>>1);
mobj->momz += FixedHypot(mobj->momx, mobj->momy)/12; // Move up higher the faster you're going.
mobj->momz += P_AproxDistance(mobj->momx, mobj->momy)/12; // Move up higher the faster you're going.
}
}
}
@ -6306,7 +6306,7 @@ void P_SpawnParaloop(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 numb
mobj->angle = R_PointToAngle2(mobj->x, mobj->y, x, y);
// change slope
dist = FixedHypot(FixedHypot(x - mobj->x, y - mobj->y), z - mobj->z);
dist = P_AproxDistance(P_AproxDistance(x - mobj->x, y - mobj->y), z - mobj->z);
if (dist < 1)
dist = 1;
@ -6380,7 +6380,7 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y
fixed_t tx = dest->x;
fixed_t ty = dest->y;
fixed_t tz = dest->z + (dest->height/2); // Aim for center
fixed_t xydist = FixedHypot(tx - source->x, ty - source->y);
fixed_t xydist = P_AproxDistance(tx - source->x, ty - source->y);
if (!dest || dest->health <= 0 || !dest->player || !source->tracer)
return;
@ -6389,7 +6389,7 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y
source->angle = R_PointToAngle2(source->x, source->y, tx, ty);
// change slope
dist = FixedHypot(xydist, tz - source->z);
dist = P_AproxDistance(xydist, tz - source->z);
if (dist < 1)
dist = 1;
@ -6415,9 +6415,9 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y
else
{
if (nightsgrab)
speedmul = FixedHypot(dest->momx, dest->momy) + FixedMul(8*FRACUNIT, source->scale);
speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(8*FRACUNIT, source->scale);
else
speedmul = FixedHypot(dest->momx, dest->momy) + FixedMul(source->info->speed, source->scale);
speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(source->info->speed, source->scale);
source->momx = FixedMul(FixedDiv(tx - source->x, dist), speedmul);
source->momy = FixedMul(FixedDiv(ty - source->y, dist), speedmul);
@ -6425,7 +6425,7 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y
}
// Instead of just unsetting NOCLIP like an idiot, let's check the distance to our target.
ndist = FixedHypot(FixedHypot(tx - (source->x+source->momx),
ndist = P_AproxDistance(P_AproxDistance(tx - (source->x+source->momx),
ty - (source->y+source->momy)),
tz - (source->z+source->momz));
@ -7076,7 +7076,7 @@ static void P_MaceSceneryThink(mobj_t *mobj)
// The below is selected based on CEZ2's first room. I promise you it is a coincidence that it looks like the weed number.
for (i = 0; i < MAXPLAYERS; ++i)
if (playeringame[i] && players[i].mo
&& FixedHypot(FixedHypot(mobj->x - players[i].mo->x, mobj->y - players[i].mo->y), mobj->z - players[i].mo->z) < (4200 << FRACBITS))
&& P_AproxDistance(P_AproxDistance(mobj->x - players[i].mo->x, mobj->y - players[i].mo->y), mobj->z - players[i].mo->z) < (4200 << FRACBITS))
break; // Stop looking.
if (i == MAXPLAYERS)
{
@ -8052,7 +8052,7 @@ static boolean P_MobjBossThink(mobj_t *mobj)
{
if (mobj->target)
{
mobj->momz = FixedMul(FixedDiv(mobj->target->z - mobj->z, FixedHypot(mobj->x - mobj->target->x, mobj->y - mobj->target->y)), mobj->scale << 1);
mobj->momz = FixedMul(FixedDiv(mobj->target->z - mobj->z, P_AproxDistance(mobj->x - mobj->target->x, mobj->y - mobj->target->y)), mobj->scale << 1);
mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y);
}
else
@ -8296,7 +8296,7 @@ static void P_ArrowThink(mobj_t *mobj)
0------dist(momx,momy)
*/
fixed_t dist = FixedHypot(mobj->momx, mobj->momy);
fixed_t dist = P_AproxDistance(mobj->momx, mobj->momy);
angle_t angle = R_PointToAngle2(0, 0, dist, mobj->momz);
if (angle > ANG20 && angle <= ANGLE_180)
@ -8578,7 +8578,7 @@ static boolean P_EggRobo1Think(mobj_t *mobj)
continue;
if (players[i].mo->z + players[i].mo->height < mobj->z - 8*mobj->scale)
continue;
compdist = FixedHypot(
compdist = P_AproxDistance(
players[i].mo->x + players[i].mo->momx - basex,
players[i].mo->y + players[i].mo->momy - basey);
if (compdist >= dist)
@ -8593,7 +8593,7 @@ static boolean P_EggRobo1Think(mobj_t *mobj)
mobj->frame = 3 + ((leveltime & 2) >> 1);
mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y);
if (FixedHypot(
if (P_AproxDistance(
mobj->x - basex,
mobj->y - basey)
< mobj->scale)
@ -8624,7 +8624,7 @@ static boolean P_EggRobo1Think(mobj_t *mobj)
if (!didmove)
{
if (FixedHypot(mobj->x - basex, mobj->y - basey) < mobj->scale)
if (P_AproxDistance(mobj->x - basex, mobj->y - basey) < mobj->scale)
P_TeleportMove(mobj, basex, basey, mobj->z);
else
P_TeleportMove(mobj,
@ -9014,7 +9014,7 @@ static void P_PyreFlyThink(mobj_t *mobj)
{
//Aim for player z position. If too close to floor/ceiling, aim just above/below them.
fixed_t destz = min(max(mobj->target->z, mobj->target->floorz + 70*FRACUNIT), mobj->target->ceilingz - 80*FRACUNIT - mobj->height);
fixed_t dist = FixedHypot(hdist, destz - mobj->z);
fixed_t dist = P_AproxDistance(hdist, destz - mobj->z);
P_InstaThrust(mobj, R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y), 2*FRACUNIT);
mobj->momz = FixedMul(FixedDiv(destz - mobj->z, dist), 2*FRACUNIT);
}
@ -9116,7 +9116,7 @@ static void P_PterabyteThink(mobj_t *mobj)
var1 = 2*mobj->info->speed;
var2 = 1;
A_HomingChase(mobj);
if (FixedHypot(mobj->x - mobj->tracer->x, mobj->y - mobj->tracer->y) <= mobj->info->speed)
if (P_AproxDistance(mobj->x - mobj->tracer->x, mobj->y - mobj->tracer->y) <= mobj->info->speed)
{
mobj->extravalue1 -= 2;
mobj->momx = mobj->momy = mobj->momz = 0;
@ -9141,7 +9141,7 @@ static void P_DragonbomberThink(mobj_t *mobj)
{
mobj_t *mine = P_SpawnMobjFromMobj(segment, 0, 0, 0, segment->info->painchance);
mine->angle = segment->angle;
P_InstaThrust(mine, mobj->angle, FixedHypot(mobj->momx, mobj->momy) >> 1);
P_InstaThrust(mine, mobj->angle, P_AproxDistance(mobj->momx, mobj->momy) >> 1);
P_SetObjectMomZ(mine, -2*FRACUNIT, true);
S_StartSound(mine, mine->info->seesound);
P_SetMobjState(segment, segment->info->raisestate);
@ -9151,7 +9151,7 @@ static void P_DragonbomberThink(mobj_t *mobj)
}
if (mobj->target) // Are we chasing a player?
{
fixed_t dist = FixedHypot(mobj->x - mobj->target->x, mobj->y - mobj->target->y);
fixed_t dist = P_AproxDistance(mobj->x - mobj->target->x, mobj->y - mobj->target->y);
if (dist > 2000*mobj->scale) // Not anymore!
P_SetTarget(&mobj->target, NULL);
else
@ -9259,7 +9259,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
mobj->eflags |= MFE_UNDERWATER; //P_MobjCheckWater(mobj); // solely for MFE_UNDERWATER for A_FlickySpawn
{
if (mobj->tracer && mobj->tracer->player && mobj->tracer->health > 0
&& FixedHypot(FixedHypot(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z - mobj->z) <= mobj->radius*16)
&& P_AproxDistance(P_AproxDistance(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z - mobj->z) <= mobj->radius*16)
{
var1 = mobj->info->speed;
var2 = 1;
@ -9394,7 +9394,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
if (playeringame[i] && players[i].mo
&& players[i].mare == mobj->threshold && players[i].spheres > 0)
{
fixed_t dist = FixedHypot(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y);
fixed_t dist = P_AproxDistance(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y);
if (dist < shortest)
{
P_SetTarget(&mobj->target, players[i].mo);
@ -9425,7 +9425,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
P_KoopaThinker(mobj);
break;
case MT_FIREBALL:
if (FixedHypot(mobj->momx, mobj->momy) <= 16*FRACUNIT) // Once fireballs lose enough speed, kill them
if (P_AproxDistance(mobj->momx, mobj->momy) <= 16*FRACUNIT) // Once fireballs lose enough speed, kill them
{
P_KillMobj(mobj, NULL, NULL, 0);
return false;
@ -13530,7 +13530,7 @@ mobj_t *P_SpawnXYZMissile(mobj_t *source, mobj_t *dest, mobjtype_t type,
th->momx = FixedMul(speed, FINECOSINE(an));
th->momy = FixedMul(speed, FINESINE(an));
dist = FixedHypot(dest->x - x, dest->y - y);
dist = P_AproxDistance(dest->x - x, dest->y - y);
dist = dist / speed;
if (dist < 1)
@ -13592,7 +13592,7 @@ mobj_t *P_SpawnAlteredDirectionMissile(mobj_t *source, mobjtype_t type, fixed_t
th->momx = FixedMul(speed, FINECOSINE(an));
th->momy = FixedMul(speed, FINESINE(an));
dist = FixedHypot(source->momx*800, source->momy*800);
dist = P_AproxDistance(source->momx*800, source->momy*800);
dist = dist / speed;
if (dist < 1)
@ -13657,7 +13657,7 @@ mobj_t *P_SpawnPointMissile(mobj_t *source, fixed_t xa, fixed_t ya, fixed_t za,
th->momx = FixedMul(speed, FINECOSINE(an));
th->momy = FixedMul(speed, FINESINE(an));
dist = FixedHypot(xa - x, ya - y);
dist = P_AproxDistance(xa - x, ya - y);
dist = dist / speed;
if (dist < 1)
@ -13737,9 +13737,9 @@ mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type)
th->momy = FixedMul(speed, FINESINE(an));
if (type == MT_TURRETLASER || type == MT_ENERGYBALL) // More accurate!
dist = FixedHypot(dest->x+(dest->momx*gsf) - source->x, dest->y+(dest->momy*gsf) - source->y);
dist = P_AproxDistance(dest->x+(dest->momx*gsf) - source->x, dest->y+(dest->momy*gsf) - source->y);
else
dist = FixedHypot(dest->x - source->x, dest->y - source->y);
dist = P_AproxDistance(dest->x - source->x, dest->y - source->y);
dist = dist / speed;

View file

@ -1636,7 +1636,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
distx = target->x - pox;
disty = target->y - poy;
distz = target->z - poz;
dist = FixedHypot(FixedHypot(distx, disty), distz);
dist = P_AproxDistance(P_AproxDistance(distx, disty), distz);
if (dist < 1)
dist = 1;

View file

@ -232,7 +232,7 @@ mobj_t *P_GetClosestWaypoint(UINT8 sequence, mobj_t *mo)
if (!mo2)
continue;
curdist = FixedHypot(FixedHypot(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z);
curdist = P_AproxDistance(P_AproxDistance(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z);
if (result && curdist > bestdist)
continue;

View file

@ -885,7 +885,7 @@ void P_ButteredSlope(mobj_t *mo)
}
if (mo->momx || mo->momy) // Slightly increase thrust based on the object's speed
thrust = FixedMul(thrust, FRACUNIT+FixedHypot(mo->momx, mo->momy)/16);
thrust = FixedMul(thrust, FRACUNIT+P_AproxDistance(mo->momx, mo->momy)/16);
// This makes it harder to zigzag up steep slopes, as well as allows greater top speed when rolling down
// Let's get the gravity strength for the object...

View file

@ -1240,7 +1240,7 @@ static boolean PolyFlag(line_t *line)
polyflagdata_t pfd;
pfd.polyObjNum = Tag_FGet(&line->tags);
pfd.speed = FixedHypot(line->dx, line->dy) >> FRACBITS;
pfd.speed = P_AproxDistance(line->dx, line->dy) >> FRACBITS;
pfd.angle = R_PointToAngle2(line->v1->x, line->v1->y, line->v2->x, line->v2->y) >> ANGLETOFINESHIFT;
pfd.momx = sides[line->sidenum[0]].textureoffset >> FRACBITS;
@ -1567,7 +1567,7 @@ static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor)
boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller)
{
sector_t *ctlsector;
fixed_t dist = FixedHypot(triggerline->dx, triggerline->dy)>>FRACBITS;
fixed_t dist = P_AproxDistance(triggerline->dx, triggerline->dy)>>FRACBITS;
size_t i, linecnt, sectori;
INT16 specialtype = triggerline->special;
@ -2629,7 +2629,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
sectors[secnum].lightlevel = line->backsector->lightlevel;
flick = P_SpawnAdjustableFireFlicker(line->frontsector, &sectors[secnum],
FixedHypot(line->dx, line->dy)>>FRACBITS);
P_AproxDistance(line->dx, line->dy)>>FRACBITS);
// Make sure the starting light level is in range.
if (reallightlevel < flick->minlight)
@ -2644,7 +2644,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
// Use front sector for min, target sector for max,
// the same way linetype 61 does it.
P_SpawnAdjustableFireFlicker(line->frontsector, &sectors[secnum],
FixedHypot(line->dx, line->dy)>>FRACBITS);
P_AproxDistance(line->dx, line->dy)>>FRACBITS);
}
}
break;
@ -2663,7 +2663,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
sectors[secnum].lightlevel = line->backsector->lightlevel;
glow = P_SpawnAdjustableGlowingLight(line->frontsector, &sectors[secnum],
FixedHypot(line->dx, line->dy)>>FRACBITS);
P_AproxDistance(line->dx, line->dy)>>FRACBITS);
// Make sure the starting light level is in range.
if (reallightlevel < glow->minlight)
@ -2678,7 +2678,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
// Use front sector for min, target sector for max,
// the same way linetype 602 does it.
P_SpawnAdjustableGlowingLight(line->frontsector, &sectors[secnum],
FixedHypot(line->dx, line->dy)>>FRACBITS);
P_AproxDistance(line->dx, line->dy)>>FRACBITS);
}
}
break;
@ -2760,7 +2760,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
((line->sidenum[1] != 0xFFFF && !(sides[line->sidenum[0]].rowoffset>>FRACBITS)) ?
max(min(sides[line->sidenum[1]].rowoffset>>FRACBITS, 255), 0)
: max(min(sides[line->sidenum[0]].rowoffset>>FRACBITS, 255), 0))
: abs(FixedHypot(line->dx, line->dy))>>FRACBITS,
: abs(P_AproxDistance(line->dx, line->dy))>>FRACBITS,
(line->flags & ML_EFFECT4),
(line->flags & ML_EFFECT5));
break;
@ -2795,7 +2795,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
else
{
P_SetTarget(&mo->player->awayviewmobj, altview);
mo->player->awayviewtics = FixedHypot(line->dx, line->dy)>>FRACBITS;
mo->player->awayviewtics = P_AproxDistance(line->dx, line->dy)>>FRACBITS;
}
@ -2840,7 +2840,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
case 425: // Calls P_SetMobjState on calling mobj
if (mo && !mo->player)
P_SetMobjState(mo, sides[line->sidenum[0]].toptexture); //FixedHypot(line->dx, line->dy)>>FRACBITS);
P_SetMobjState(mo, sides[line->sidenum[0]].toptexture); //P_AproxDistance(line->dx, line->dy)>>FRACBITS);
break;
case 426: // Moves the mobj to its sector's soundorg and on the floor, and stops it
@ -3026,7 +3026,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
case 438: // Set player scale
if (mo)
{
mo->destscale = FixedDiv(FixedHypot(line->dx, line->dy), 100<<FRACBITS);
mo->destscale = FixedDiv(P_AproxDistance(line->dx, line->dy), 100<<FRACBITS);
if (mo->destscale < FRACUNIT/100)
mo->destscale = FRACUNIT/100;
if (mo->player && bot)
@ -3144,7 +3144,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
{
quake.intensity = sides[line->sidenum[0]].textureoffset;
quake.radius = sides[line->sidenum[0]].rowoffset;
quake.time = FixedHypot(line->dx, line->dy)>>FRACBITS;
quake.time = P_AproxDistance(line->dx, line->dy)>>FRACBITS;
quake.epicenter = NULL; /// \todo
@ -3407,7 +3407,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
case 452: // Set FOF alpha
{
INT16 destvalue = line->sidenum[1] != 0xffff ?
(INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : (INT16)(FixedHypot(line->dx, line->dy)>>FRACBITS);
(INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : (INT16)(P_AproxDistance(line->dx, line->dy)>>FRACBITS);
INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS);
INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS);
sector_t *sec; // Sector that the FOF is visible in
@ -4997,8 +4997,8 @@ DoneSection2:
}
else
{
if (FixedHypot(FixedHypot(player->mo->x-resultlow.x, player->mo->y-resultlow.y),
player->mo->z-resultlow.z) < FixedHypot(FixedHypot(player->mo->x-resulthigh.x,
if (P_AproxDistance(P_AproxDistance(player->mo->x-resultlow.x, player->mo->y-resultlow.y),
player->mo->z-resultlow.z) < P_AproxDistance(P_AproxDistance(player->mo->x-resulthigh.x,
player->mo->y-resulthigh.y), player->mo->z-resulthigh.z))
{
// Line between Mid and Low is closer
@ -6316,7 +6316,7 @@ void P_SpawnSpecials(boolean fromnetsave)
break;
case 52: // Continuously Falling sector
EV_DoContinuousFall(lines[i].frontsector, lines[i].backsector, FixedHypot(lines[i].dx, lines[i].dy), (lines[i].flags & ML_NOCLIMB));
EV_DoContinuousFall(lines[i].frontsector, lines[i].backsector, P_AproxDistance(lines[i].dx, lines[i].dy), (lines[i].flags & ML_NOCLIMB));
break;
case 53: // New super cool and awesome moving floor and ceiling type
@ -6388,15 +6388,15 @@ void P_SpawnSpecials(boolean fromnetsave)
case 66: // Displace floor by front sector
TAG_ITER_SECTORS(0, tag, s)
P_AddPlaneDisplaceThinker(pd_floor, FixedHypot(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB));
P_AddPlaneDisplaceThinker(pd_floor, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB));
break;
case 67: // Displace ceiling by front sector
TAG_ITER_SECTORS(0, tag, s)
P_AddPlaneDisplaceThinker(pd_ceiling, FixedHypot(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB));
P_AddPlaneDisplaceThinker(pd_ceiling, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB));
break;
case 68: // Displace both floor AND ceiling by front sector
TAG_ITER_SECTORS(0, tag, s)
P_AddPlaneDisplaceThinker(pd_both, FixedHypot(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB));
P_AddPlaneDisplaceThinker(pd_both, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB));
break;
case 100: // FOF (solid, opaque, shadows)
@ -6590,18 +6590,18 @@ void P_SpawnSpecials(boolean fromnetsave)
case 150: // Air bobbing platform
case 151: // Adjustable air bobbing platform
{
fixed_t dist = (lines[i].special == 150) ? 16*FRACUNIT : FixedHypot(lines[i].dx, lines[i].dy);
fixed_t dist = (lines[i].special == 150) ? 16*FRACUNIT : P_AproxDistance(lines[i].dx, lines[i].dy);
P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers);
P_AddAirbob(lines[i].frontsector, tag, dist, false, !!(lines[i].flags & ML_NOCLIMB), false);
break;
}
case 152: // Adjustable air bobbing platform in reverse
P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers);
P_AddAirbob(lines[i].frontsector, tag, FixedHypot(lines[i].dx, lines[i].dy), true, !!(lines[i].flags & ML_NOCLIMB), false);
P_AddAirbob(lines[i].frontsector, tag, P_AproxDistance(lines[i].dx, lines[i].dy), true, !!(lines[i].flags & ML_NOCLIMB), false);
break;
case 153: // Dynamic Sinking Platform
P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers);
P_AddAirbob(lines[i].frontsector, tag, FixedHypot(lines[i].dx, lines[i].dy), false, !!(lines[i].flags & ML_NOCLIMB), true);
P_AddAirbob(lines[i].frontsector, tag, P_AproxDistance(lines[i].dx, lines[i].dy), false, !!(lines[i].flags & ML_NOCLIMB), true);
break;
case 160: // Float/bob platform
@ -6680,7 +6680,7 @@ void P_SpawnSpecials(boolean fromnetsave)
case 194: // Rising Platform 'Platform' - You can jump up through it
case 195: // Rising Platform Translucent "platform"
{
fixed_t speed = FixedDiv(FixedHypot(lines[i].dx, lines[i].dy), 4*FRACUNIT);
fixed_t speed = FixedDiv(P_AproxDistance(lines[i].dx, lines[i].dy), 4*FRACUNIT);
fixed_t ceilingtop = P_FindHighestCeilingSurrounding(lines[i].frontsector);
fixed_t ceilingbottom = P_FindLowestCeilingSurrounding(lines[i].frontsector);
@ -7005,14 +7005,14 @@ void P_SpawnSpecials(boolean fromnetsave)
sec = sides[*lines[i].sidenum].sector - sectors;
TAG_ITER_SECTORS(0, tag, s)
P_SpawnAdjustableGlowingLight(&sectors[sec], &sectors[s],
FixedHypot(lines[i].dx, lines[i].dy)>>FRACBITS);
P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS);
break;
case 603: // Adjustable flickering light
sec = sides[*lines[i].sidenum].sector - sectors;
TAG_ITER_SECTORS(0, tag, s)
P_SpawnAdjustableFireFlicker(&sectors[sec], &sectors[s],
FixedHypot(lines[i].dx, lines[i].dy)>>FRACBITS);
P_AproxDistance(lines[i].dx, lines[i].dy)>>FRACBITS);
break;
case 604: // Adjustable Blinking Light (unsynchronized)
@ -8418,9 +8418,9 @@ static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t *
// "The right triangle of the square of the length of the hypotenuse is equal to the sum of the squares of the lengths of the other two sides."
// "Bah! Stupid brains! Don't you know anything besides the Pythagorean Theorem?" - Earthworm Jim
if (type == p_downcurrent || type == p_upcurrent || type == p_upwind || type == p_downwind)
p->magnitude = FixedHypot(p->x_mag,p->y_mag)<<(FRACBITS-PUSH_FACTOR);
p->magnitude = P_AproxDistance(p->x_mag,p->y_mag)<<(FRACBITS-PUSH_FACTOR);
else
p->magnitude = FixedHypot(p->x_mag,p->y_mag);
p->magnitude = P_AproxDistance(p->x_mag,p->y_mag);
if (source) // point source exist?
{
// where force goes to zero
@ -8471,14 +8471,14 @@ static inline boolean PIT_PushThing(mobj_t *thing)
// don't fade wrt Z if health & 2 (mapthing has multi flag)
if (tmpusher->source->health & 2)
dist = FixedHypot(thing->x - sx,thing->y - sy);
dist = P_AproxDistance(thing->x - sx,thing->y - sy);
else
{
// Make sure the Z is in range
if (thing->z < sz - tmpusher->radius || thing->z > sz + tmpusher->radius)
return false;
dist = FixedHypot(FixedHypot(thing->x - sx, thing->y - sy),
dist = P_AproxDistance(P_AproxDistance(thing->x - sx, thing->y - sy),
thing->z - sz);
}
@ -8813,7 +8813,7 @@ void T_Pusher(pusher_t *p)
// Tumbleweeds bounce a bit...
if (thing->type == MT_LITTLETUMBLEWEED || thing->type == MT_BIGTUMBLEWEED)
thing->momz += FixedHypot(xspeed<<(FRACBITS-PUSH_FACTOR), yspeed<<(FRACBITS-PUSH_FACTOR)) >> 2;
thing->momz += P_AproxDistance(xspeed<<(FRACBITS-PUSH_FACTOR), yspeed<<(FRACBITS-PUSH_FACTOR)) >> 2;
}
if (moved)

View file

@ -1018,7 +1018,7 @@ void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor)
// to recover
if ((inflictor->flags2 & MF2_SCATTER) && source)
{
fixed_t dist = FixedHypot(FixedHypot(source->x-player->mo->x, source->y-player->mo->y), source->z-player->mo->z);
fixed_t dist = P_AproxDistance(P_AproxDistance(source->x-player->mo->x, source->y-player->mo->y), source->z-player->mo->z);
dist = FixedMul(128*FRACUNIT, inflictor->scale) - dist/4;
@ -2701,7 +2701,7 @@ static void P_CheckBustableBlocks(player_t *player)
// Run a linedef executor??
if (rover->master->flags & ML_EFFECT5)
P_LinedefExecute((INT16)(FixedHypot(rover->master->dx, rover->master->dy)>>FRACBITS), player->mo, node->m_sector);
P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), player->mo, node->m_sector);
goto bustupdone;
}
@ -2764,7 +2764,7 @@ static void P_CheckBouncySectors(player_t *player)
if (player->mo->z + player->mo->height < bottomheight)
continue;
bouncestrength = FixedHypot(rover->master->dx, rover->master->dy)/100;
bouncestrength = P_AproxDistance(rover->master->dx, rover->master->dy)/100;
if (oldz < P_GetFOFTopZ(player->mo, node->m_sector, rover, oldx, oldy, NULL)
&& oldz + player->mo->height > P_GetFOFBottomZ(player->mo, node->m_sector, rover, oldx, oldy, NULL))
@ -4981,7 +4981,7 @@ void P_Telekinesis(player_t *player, fixed_t thrust, fixed_t range)
if (!((mo2->flags & MF_SHOOTABLE && mo2->flags & MF_ENEMY) || mo2->type == MT_EGGGUARD || mo2->player))
continue;
dist = FixedHypot(FixedHypot(player->mo->x-mo2->x, player->mo->y-mo2->y), player->mo->z-mo2->z);
dist = P_AproxDistance(P_AproxDistance(player->mo->x-mo2->x, player->mo->y-mo2->y), player->mo->z-mo2->z);
if (range < dist)
continue;
@ -6464,12 +6464,12 @@ static void P_NightsTransferPoints(player_t *player, fixed_t xspeed, fixed_t rad
//CONS_Debug(DBG_NIGHTS, "T1 is at %d, %d\n", transfer1->x>>FRACBITS, transfer1->y>>FRACBITS);
//CONS_Debug(DBG_NIGHTS, "T2 is at %d, %d\n", transfer2->x>>FRACBITS, transfer2->y>>FRACBITS);
//CONS_Debug(DBG_NIGHTS, "Distance from T1: %d\n", FixedHypot(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS);
//CONS_Debug(DBG_NIGHTS, "Distance from T2: %d\n", FixedHypot(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS);
//CONS_Debug(DBG_NIGHTS, "Distance from T1: %d\n", P_AproxDistance(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS);
//CONS_Debug(DBG_NIGHTS, "Distance from T2: %d\n", P_AproxDistance(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS);
// Transfer1 is closer to the player than transfer2
if (FixedHypot(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS
< FixedHypot(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS)
if (P_AproxDistance(transfer1->x - player->mo->x, transfer1->y - player->mo->y)>>FRACBITS
< P_AproxDistance(transfer2->x - player->mo->x, transfer2->y - player->mo->y)>>FRACBITS)
{
//CONS_Debug(DBG_NIGHTS, " must be < 0 to transfer\n");
@ -7709,7 +7709,7 @@ void P_BlackOw(player_t *player)
S_StartSound (player->mo, sfx_bkpoof); // Sound the BANG!
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && FixedHypot(player->mo->x - players[i].mo->x,
if (playeringame[i] && P_AproxDistance(player->mo->x - players[i].mo->x,
player->mo->y - players[i].mo->y) < 1536*FRACUNIT)
P_FlashPal(&players[i], PAL_NUKE, 10);
@ -7893,7 +7893,7 @@ static void P_SkidStuff(player_t *player)
P_SpawnSkidDust(player, 0, false);
}
}
else if (FixedHypot(pmx, pmy) >= FixedMul(player->runspeed/2, player->mo->scale) // if you were moving faster than half your run speed last frame
else if (P_AproxDistance(pmx, pmy) >= FixedMul(player->runspeed/2, player->mo->scale) // if you were moving faster than half your run speed last frame
&& (player->mo->momx != pmx || player->mo->momy != pmy) // and you are moving differently this frame
&& P_GetPlayerControlDirection(player) == 2) // and your controls are pointing in the opposite direction to your movement
{ // check for skidding
@ -8524,7 +8524,7 @@ void P_MovePlayer(player_t *player)
P_ResetScore(player);
// Show the "THOK!" graphic when spinning quickly across the ground. (even applies to non-spinners, in the case of zoom tubes)
if (player->pflags & PF_SPINNING && FixedHypot(player->speed, player->mo->momz) > FixedMul(15<<FRACBITS, player->mo->scale) && !(player->pflags & PF_JUMPED))
if (player->pflags & PF_SPINNING && P_AproxDistance(player->speed, player->mo->momz) > FixedMul(15<<FRACBITS, player->mo->scale) && !(player->pflags & PF_JUMPED))
{
P_SpawnSpinMobj(player, player->spinitem);
G_GhostAddSpin();
@ -8745,7 +8745,7 @@ static void P_DoZoomTube(player_t *player)
speed = abs(player->speed);
// change slope
dist = FixedHypot(FixedHypot(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z);
dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z);
if (dist < 1)
dist = 1;
@ -8786,7 +8786,7 @@ static void P_DoZoomTube(player_t *player)
// calculate MOMX/MOMY/MOMZ for next waypoint
// change slope
dist = FixedHypot(FixedHypot(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z);
dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z);
if (dist < 1)
dist = 1;
@ -8839,7 +8839,7 @@ static void P_DoRopeHang(player_t *player)
sequence = player->mo->tracer->threshold;
// change slope
dist = FixedHypot(FixedHypot(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz);
dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz);
if (dist < 1)
dist = 1;
@ -8902,7 +8902,7 @@ static void P_DoRopeHang(player_t *player)
// calculate MOMX/MOMY/MOMZ for next waypoint
// change slope
dist = FixedHypot(FixedHypot(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz);
dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - playerz);
if (dist < 1)
dist = 1;
@ -9003,7 +9003,7 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius)
if (abs(inflictor->x - mo->x) > radius || abs(inflictor->y - mo->y) > radius || abs(inflictor->z - mo->z) > radius)
continue; // Workaround for possible integer overflow in the below -Red
if (FixedHypot(FixedHypot(inflictor->x - mo->x, inflictor->y - mo->y), inflictor->z - mo->z) > radius)
if (P_AproxDistance(P_AproxDistance(inflictor->x - mo->x, inflictor->y - mo->y), inflictor->z - mo->z) > radius)
continue;
if (mo->type == MT_MINUS && !(mo->flags & (MF_SPECIAL|MF_SHOOTABLE)))
@ -9139,12 +9139,12 @@ mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction,
{
fixed_t zdist = (player->mo->z + player->mo->height/2) - (mo->z + mo->height/2);
dist = FixedHypot(player->mo->x-mo->x, player->mo->y-mo->y);
dist = P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y);
if (abs(zdist) > dist)
continue; // Don't home outside of desired angle!
dist = FixedHypot(dist, zdist);
dist = P_AproxDistance(dist, zdist);
if (dist > maxdist)
continue; // out of range
}
@ -9236,7 +9236,7 @@ mobj_t *P_LookForEnemies(player_t *player, boolean nonenemies, boolean bullet)
{
fixed_t zdist = (player->mo->z + player->mo->height/2) - (mo->z + mo->height/2);
dist = FixedHypot(player->mo->x-mo->x, player->mo->y-mo->y);
dist = P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y);
if (bullet)
{
if ((R_PointToAngle2(0, 0, dist, zdist) + span) > span*2)
@ -9253,7 +9253,7 @@ mobj_t *P_LookForEnemies(player_t *player, boolean nonenemies, boolean bullet)
continue;
}
dist = FixedHypot(dist, zdist);
dist = P_AproxDistance(dist, zdist);
if (dist > maxdist)
continue; // out of range
}
@ -9313,7 +9313,7 @@ boolean P_HomingAttack(mobj_t *source, mobj_t *enemy) // Home in on your target
// change slope
zdist = ((P_MobjFlip(source) == -1) ? (enemy->z + enemy->height) - (source->z + source->height) : (enemy->z - source->z));
dist = FixedHypot(FixedHypot(enemy->x - source->x, enemy->y - source->y), zdist);
dist = P_AproxDistance(P_AproxDistance(enemy->x - source->x, enemy->y - source->y), zdist);
if (dist < 1)
dist = 1;
@ -10362,7 +10362,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
// follow the player
/*if (player->playerstate != PST_DEAD && (camspeed) != 0)
{
if (FixedHypot(mo->x - thiscam->x, mo->y - thiscam->y) > (checkdist + FixedHypot(mo->momx, mo->momy)) * 4
if (P_AproxDistance(mo->x - thiscam->x, mo->y - thiscam->y) > (checkdist + P_AproxDistance(mo->momx, mo->momy)) * 4
|| abs(mo->z - thiscam->z) > checkdist * 3)
{
if (!resetcalled)
@ -10427,7 +10427,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
}
/* check z distance too for orbital camera */
if (FixedHypot(FixedHypot(vx - mo->x, vy - mo->y),
if (P_AproxDistance(P_AproxDistance(vx - mo->x, vy - mo->y),
vz - ( mo->z + mo->height / 2 )) < FixedMul(48*FRACUNIT, mo->scale))
mo->flags2 |= MF2_SHADOW;
else
@ -10912,7 +10912,7 @@ static void P_ParabolicMove(mobj_t *mo, fixed_t x, fixed_t y, fixed_t z, fixed_t
fixed_t dx = x - mo->x;
fixed_t dy = y - mo->y;
fixed_t dz = z - mo->z;
fixed_t dh = FixedHypot(dx, dy);
fixed_t dh = P_AproxDistance(dx, dy);
fixed_t c = FixedDiv(dx, dh);
fixed_t s = FixedDiv(dy, dh);
fixed_t fixConst = FixedDiv(speed, g);
@ -11784,7 +11784,7 @@ void P_PlayerThink(player_t *player)
if (mo2->flags2 & MF2_NIGHTSPULL)
continue;
if (FixedHypot(FixedHypot(mo2->x - x, mo2->y - y), mo2->z - z) > FixedMul(128*FRACUNIT, player->mo->scale))
if (P_AproxDistance(P_AproxDistance(mo2->x - x, mo2->y - y), mo2->z - z) > FixedMul(128*FRACUNIT, player->mo->scale))
continue;
// Yay! The thing's in reach! Pull it in!
@ -12020,7 +12020,7 @@ void P_PlayerThink(player_t *player)
if (!currentlyonground)
acceleration /= 2;
// fake skidding! see P_SkidStuff for reference on conditionals
else if (!player->skidtime && !(player->mo->eflags & MFE_GOOWATER) && !(player->pflags & (PF_JUMPED|PF_SPINNING|PF_SLIDING)) && !(player->charflags & SF_NOSKID) && FixedHypot(player->mo->momx, player->mo->momy) >= FixedMul(player->runspeed, player->mo->scale)) // modified from player->runspeed/2 'cuz the skid was just TOO frequent ngl
else if (!player->skidtime && !(player->mo->eflags & MFE_GOOWATER) && !(player->pflags & (PF_JUMPED|PF_SPINNING|PF_SLIDING)) && !(player->charflags & SF_NOSKID) && P_AproxDistance(player->mo->momx, player->mo->momy) >= FixedMul(player->runspeed, player->mo->scale)) // modified from player->runspeed/2 'cuz the skid was just TOO frequent ngl
{
if (player->mo->state-states != S_PLAY_SKID)
P_SetPlayerMobjState(player->mo, S_PLAY_SKID);
@ -12605,7 +12605,7 @@ void P_PlayerAfterThink(player_t *player)
P_SetPlayerAngle(player, player->mo->angle);
}
if (FixedHypot(player->mo->x - tails->x, player->mo->y - tails->y) > player->mo->radius)
if (P_AproxDistance(player->mo->x - tails->x, player->mo->y - tails->y) > player->mo->radius)
player->powers[pw_carry] = CR_NONE;
if (player->powers[pw_carry] != CR_NONE)
@ -12794,7 +12794,7 @@ void P_PlayerAfterThink(player_t *player)
player->mo->momy = ptera->momy;
player->mo->momz = ptera->momz;
if (FixedHypot(player->mo->x - ptera->x - ptera->watertop, player->mo->y - ptera->y - ptera->waterbottom) > player->mo->radius)
if (P_AproxDistance(player->mo->x - ptera->x - ptera->watertop, player->mo->y - ptera->y - ptera->waterbottom) > player->mo->radius)
goto dropoff;
ptera->watertop >>= 1;

View file

@ -3019,7 +3019,7 @@ boolean R_ThingVisibleWithinDist (mobj_t *thing,
if (! R_ThingVisible(thing))
return false;
approx_dist = FixedHypot(viewx-thing->x, viewy-thing->y);
approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y);
if (thing->sprite == SPR_HOOP)
{
@ -3044,7 +3044,7 @@ boolean R_PrecipThingVisible (precipmobj_t *precipthing,
if (( precipthing->precipflags & PCF_INVISIBLE ))
return false;
approx_dist = FixedHypot(viewx-precipthing->x, viewy-precipthing->y);
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
return ( approx_dist <= limit_dist );
}

View file

@ -943,8 +943,8 @@ void S_UpdateSounds(void)
const mobj_t *soundmobj = c->origin;
fixed_t dist1, dist2;
dist1 = FixedHypot(listener.x-soundmobj->x, listener.y-soundmobj->y);
dist2 = FixedHypot(listener2.x-soundmobj->x, listener2.y-soundmobj->y);
dist1 = P_AproxDistance(listener.x-soundmobj->x, listener.y-soundmobj->y);
dist2 = P_AproxDistance(listener2.x-soundmobj->x, listener2.y-soundmobj->y);
if (dist1 <= dist2)
{

View file

@ -2458,7 +2458,7 @@ num:
static INT32 ST_drawEmeraldHuntIcon(mobj_t *hunt, patch_t **patches, INT32 offset)
{
INT32 interval, i;
UINT32 dist = ((UINT32)FixedHypot(FixedHypot(stplyr->mo->x - hunt->x, stplyr->mo->y - hunt->y), stplyr->mo->z - hunt->z))>>FRACBITS;
UINT32 dist = ((UINT32)P_AproxDistance(P_AproxDistance(stplyr->mo->x - hunt->x, stplyr->mo->y - hunt->y), stplyr->mo->z - hunt->z))>>FRACBITS;
if (dist < 128)
{