- the last remaining approxDist calls in nnexts.

This commit is contained in:
Christoph Oelckers 2022-09-28 14:31:38 +02:00
parent cf2d29e921
commit 5dc2d467ee
3 changed files with 11 additions and 11 deletions

View file

@ -7951,13 +7951,13 @@ void aiPatrolSetMarker(DBloodActor* actor)
auto targetactor = actor->GetTarget();
DBloodActor* selected = nullptr;
int closest = 200000;
double closest = DBL_MAX;
// select closest marker that dude can see
if (targetactor == nullptr)
{
double zt1, zb1, zt2, zb2;
int dist;
double dist;
GetActorExtents(actor, &zt2, &zb2);
BloodStatIterator it(kStatPathMarker);
@ -7965,7 +7965,7 @@ void aiPatrolSetMarker(DBloodActor* actor)
{
if (!nextactor->hasX()) continue;
if (nextactor->xspr.locked || nextactor->xspr.isTriggered || nextactor->xspr.DudeLockout || (dist = approxDist(nextactor->spr.pos.XY() - actor->spr.pos.XY())) > closest)
if (nextactor->xspr.locked || nextactor->xspr.isTriggered || nextactor->xspr.DudeLockout || (dist = (nextactor->spr.pos.XY() - actor->spr.pos.XY()).LengthSquared()) > closest)
continue;
GetActorExtents(nextactor, &zt1, &zb1);
@ -8247,11 +8247,11 @@ void aiPatrolAlarmLite(DBloodActor* actor, DBloodActor* targetactor)
continue;
double eaz2 = (getDudeInfo(targetactor->spr.type)->eyeHeight * targetactor->spr.yrepeat) * REPEAT_SCALE;
int nDist = approxDist(dudeactor->spr.pos.XY() - actor->spr.pos.XY());
if (nDist >= kPatrolAlarmSeeDist || !cansee(DVector3(actor->spr.pos, zt1), actor->sector(), dudeactor->spr.pos.plusZ(-eaz2), dudeactor->sector()))
double nDist = (dudeactor->spr.pos.XY() - actor->spr.pos.XY()).LengthSquared();
if (nDist >= kPatrolAlarmSeeDistSq || !cansee(DVector3(actor->spr.pos, zt1), actor->sector(), dudeactor->spr.pos.plusZ(-eaz2), dudeactor->sector()))
{
nDist = approxDist(dudeactor->spr.pos.XY() - targetactor->spr.pos.XY());
if (nDist >= kPatrolAlarmSeeDist || !cansee(DVector3(targetactor->spr.pos, zt2), targetactor->sector(), dudeactor->spr.pos.plusZ(-eaz2), dudeactor->sector()))
nDist = (dudeactor->spr.pos.XY() - targetactor->spr.pos.XY()).LengthSquared();
if (nDist >= kPatrolAlarmSeeDistSq || !cansee(DVector3(targetactor->spr.pos, zt2), targetactor->sector(), dudeactor->spr.pos.plusZ(-eaz2), dudeactor->sector()))
continue;
}

View file

@ -74,7 +74,7 @@ enum
enum
{
kPatrolStateSize = 42,
kPatrolAlarmSeeDist = 10000,
kPatrolAlarmSeeDistSq = 625*625,
kPatrolAlarmHearDist = 10000,
kMaxPatrolSpotValue = 500,
kMinPatrolTurnDelay = 8,
@ -310,7 +310,7 @@ void aiSetGenIdleState(DBloodActor*);
// triggers related
// ------------------------------------------------------------------------- //
int aiFightGetTargetDist(DBloodActor* pSprite, DUDEINFO* pDudeInfo, DBloodActor* pTarget);
int aiFightGetFineTargetDist(DBloodActor* actor, DBloodActor* target);
double aiFightGetFineTargetDist(DBloodActor* actor, DBloodActor* target);
bool aiFightDudeCanSeeTarget(DBloodActor* pXDude, DUDEINFO* pDudeInfo, DBloodActor* pTarget);
bool aiFightDudeIsAffected(DBloodActor* pXDude);
bool aiFightMatesHaveSameTarget(DBloodActor* leaderactor, DBloodActor* targetactor, int allow);

View file

@ -279,7 +279,7 @@ void fakePlayerProcess(PLAYER* pPlayer, InputPacket* pInput)
}
fakeProcessInput(pPlayer, pInput);
int nSpeed = approxDist(predict.xvel, predict.yvel);
int nSpeed = a pproxDist(predict.xvel, predict.yvel);
predict.zViewVel = interpolatedvalue(predict.zViewVel, predict.zvel, FixedToFloat(0x7000));
int dz = predict.z - pPosture->eyeAboveZ - predict.viewz;
@ -556,7 +556,7 @@ static void fakeMoveDude(DBloodActor* actor)
nDrag -= scale(gDudeDrag, predict.floordist, 0x100);
predict.xvel -= mulscale16r(predict.xvel, nDrag);
predict.yvel -= mulscale16r(predict.yvel, nDrag);
if (approxDist(predict.xvel, predict.yvel) < 0x1000)
if (a pproxDist(predict.xvel, predict.yvel) < 0x1000)
predict.xvel = predict.yvel = 0;
}
#endif