From fe14b5378b95b563b5c9272e897d870e6af7967a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 4 Sep 2022 20:50:43 +0200 Subject: [PATCH] - floatified DoActorPickClosePlayer --- source/games/sw/src/ai.cpp | 11 ++++++----- source/games/sw/src/game.h | 2 +- source/games/sw/src/sprite.cpp | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index 2e4ddf7fc..89a28289b 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -267,13 +267,15 @@ int CanHitPlayer(DSWActor* actor) int DoActorPickClosePlayer(DSWActor* actor) { - int dist, near_dist = MAX_ACTIVE_RANGE, a,b,c; int pnum; PLAYER* pp; // if actor can still see the player bool found = false; int i; + double near_dist = MAX_ACTIVE_RANGE; + double dist; + if (actor->user.ID == ZOMBIE_RUN_R0 && gNet.MultiGameType == MULTI_GAME_COOPERATIVE) goto TARGETACTOR; @@ -296,7 +298,6 @@ int DoActorPickClosePlayer(DSWActor* actor) // Set initial target to the closest player - near_dist = MAX_ACTIVE_RANGE; TRAVERSE_CONNECT(pnum) { pp = &Player[pnum]; @@ -315,7 +316,7 @@ int DoActorPickClosePlayer(DSWActor* actor) // continue; } - DISTANCE(actor->spr.pos, pp->pos, dist, a, b, c); + dist = (actor->spr.pos - pp->pos).Length(); if (dist < near_dist) { @@ -341,7 +342,7 @@ int DoActorPickClosePlayer(DSWActor* actor) continue; } - DISTANCE(actor->spr.pos, pp->pos, dist, a, b, c); + dist = (actor->spr.pos - pp->pos).Length(); DSWActor* plActor = pp->actor; @@ -369,7 +370,7 @@ TARGETACTOR: if ((itActor->user.Flags & (SPR_SUICIDE | SPR_DEAD))) continue; - DISTANCE(actor->spr.pos, itActor->spr.pos, dist, a, b, c); + dist = (actor->spr.pos - itActor->spr.pos).Length(); if (dist < near_dist && FAFcansee(ActorVectOfTop(actor), actor->sector(), ActorUpperVect(itActor), itActor->sector())) { diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index b49053a6a..5b2d67f36 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -163,7 +163,7 @@ enum { CIRCLE_CAMERA_DIST_MIN = 12000, // dist at which actors will not move (unless shot?? to do) - MAX_ACTIVE_RANGE = 42000, + MAX_ACTIVE_RANGE = 42000 / 16, // dist at which actors roam about on their own MIN_ACTIVE_RANGE = 20000, }; diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 2cfef3df5..b4b47be50 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -5845,7 +5845,7 @@ void AdjustActiveRange(PLAYER* pp, DSWActor* actor, int dist) actor->user.wait_active_check = 0; // check aboslute max - if (dist > MAX_ACTIVE_RANGE) + if (dist > MAX_ACTIVE_RANGE * worldtoint) return; // do not do a FAFcansee if your already active