From 872833d6bef3ad744cf451069d05dc3e1e7e1c63 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 4 Sep 2022 12:53:35 +0200 Subject: [PATCH] - floatified USER::targetDist and distCheck. --- source/games/sw/src/ai.cpp | 14 +++++++------- source/games/sw/src/game.h | 4 ++-- source/games/sw/src/sprite.cpp | 4 ++-- source/games/sw/src/weapon.cpp | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index a990b0df6..aa5fe2ba9 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -817,7 +817,7 @@ int DoActorMoveCloser(DSWActor* actor) DoActorNoise(ChooseAction(actor->user.Personality->Broadcast), actor); // after moving a ways check to see if player is still in sight - if (actor->user.DistCheck > 550) + if (actor->user.DistCheck > 34.375) { actor->user.DistCheck = 0; @@ -1362,7 +1362,8 @@ int FindNewAngle(DSWActor* actor, int dir, int DistToMove) int new_ang, oang; int save_ang = -1; int set; - int save_dist = 500; + // start out with mininum distance that will be accepted as a move + double save_dist = 31.25; // if on fire, run shorter distances if (ActorFlaming(actor)) @@ -1413,11 +1414,10 @@ int FindNewAngle(DSWActor* actor, int dir, int DistToMove) #endif DVector3 stop; - // start out with mininum distance that will be accepted as a move // check to see how far we can move auto ret = move_scan(actor, new_ang, DistToMove, stop); - int dist = (actor->spr.pos.XY() - stop.XY()).Length() * worldtoint; + double dist = (actor->spr.pos.XY() - stop.XY()).Length(); if (ret.type == kHitNone) { @@ -1447,8 +1447,8 @@ int FindNewAngle(DSWActor* actor, int dir, int DistToMove) // To keep this from happening make the TargetDist is less than the // point you would hit something - if (actor->user.TargetDist > 4000) - actor->user.TargetDist -= 3500; + if (actor->user.TargetDist > 250) + actor->user.TargetDist -= 218.75; actor->set_int_ang(save_ang); return save_ang; @@ -1586,7 +1586,7 @@ int DoActorReposition(DSWActor* actor) } // if close to target distance do a Decision again - if (actor->user.TargetDist < 50) + if (actor->user.TargetDist < 3.125) { InitActorDecide(actor); } diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 9bed0cdb6..f9dfdd83e 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1027,10 +1027,10 @@ struct USER int16_t scale_tgt; // zig zagging - int16_t DistCheck; + double DistCheck; int16_t Dist; - int16_t TargetDist; + double TargetDist; int16_t WaitTics; // track diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 549597db3..cab73c101 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -4640,9 +4640,9 @@ int move_actor(DSWActor* actor, const DVector3& change) { // Keep track of how far sprite has moved dist = DistanceI(apos, actor->spr.pos); - actor->user.TargetDist -= dist; + actor->user.TargetDist -= dist * inttoworld; actor->user.Dist += dist; - actor->user.DistCheck += dist; + actor->user.DistCheck += dist * inttoworld; return true; } else diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 2ca6e706b..dc12e5fba 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -11115,7 +11115,7 @@ int DoSerpRing(DSWActor* actor) { actor->user.Dist += 8 * RINGMOVETICS; - if (actor->user.Dist > actor->user.TargetDist) + if (actor->user.Dist * inttoworld > actor->user.TargetDist) actor->user.Counter2 = true; }