From 767933dff9f4ccc28edf46b017a6f927239fe5d0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Aug 2022 22:21:31 +0200 Subject: [PATCH] - track stuff in ai.cpp --- source/games/sw/src/ai.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index 5a7c1b38c..a473fc53f 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -788,7 +788,8 @@ int DoActorCantMoveCloser(DSWActor* actor) if (actor->user.track >= 0) { - actor->set_int_ang(getangle((Track[actor->user.track].TrackPoint + actor->user.point)->int_tx() - actor->int_pos().X, (Track[actor->user.track].TrackPoint + actor->user.point)->int_ty() - actor->int_pos().Y)); + auto tp = Track[actor->user.track].TrackPoint + actor->user.point; + actor->spr.angle = VecToAngle(tp->pos - actor->spr.pos); DoActorSetSpeed(actor, MID_SPEED); actor->user.Flags |= (SPR_FIND_PLAYER); @@ -1020,7 +1021,8 @@ int InitActorRunAway(DSWActor* actor) if (actor->user.track >= 0) { - actor->set_int_ang(NORM_ANGLE(getangle((Track[actor->user.track].TrackPoint + actor->user.point)->int_tx() - actor->int_pos().X, (Track[actor->user.track].TrackPoint + actor->user.point)->int_ty() - actor->int_pos().Y))); + auto tp = Track[actor->user.track].TrackPoint + actor->user.point; + actor->spr.angle = VecToAngle(tp->pos - actor->spr.pos); DoActorSetSpeed(actor, FAST_SPEED); actor->user.Flags |= (SPR_RUN_AWAY); } @@ -1180,7 +1182,8 @@ int InitActorEvade(DSWActor* actor) if (actor->user.track >= 0) { - actor->set_int_ang(NORM_ANGLE(getangle((Track[actor->user.track].TrackPoint + actor->user.point)->int_tx() - actor->int_pos().X, (Track[actor->user.track].TrackPoint + actor->user.point)->int_ty() - actor->int_pos().Y))); + auto tp = Track[actor->user.track].TrackPoint + actor->user.point; + actor->spr.angle = VecToAngle(tp->pos - actor->spr.pos); DoActorSetSpeed(actor, FAST_SPEED); // NOT doing a RUN_AWAY actor->user.Flags &= ~(SPR_RUN_AWAY); @@ -1200,7 +1203,8 @@ int InitActorWanderAround(DSWActor* actor) if (actor->user.track >= 0) { - actor->set_int_ang(getangle((Track[actor->user.track].TrackPoint + actor->user.point)->int_tx() - actor->int_pos().X, (Track[actor->user.track].TrackPoint + actor->user.point)->int_ty() - actor->int_pos().Y)); + auto tp = Track[actor->user.track].TrackPoint + actor->user.point; + actor->spr.angle = VecToAngle(tp->pos - actor->spr.pos); DoActorSetSpeed(actor, NORM_SPEED); } @@ -1216,7 +1220,8 @@ int InitActorFindPlayer(DSWActor* actor) if (actor->user.track >= 0) { - actor->set_int_ang(getangle((Track[actor->user.track].TrackPoint + actor->user.point)->int_tx() - actor->int_pos().X, (Track[actor->user.track].TrackPoint + actor->user.point)->int_ty() - actor->int_pos().Y)); + auto tp = Track[actor->user.track].TrackPoint + actor->user.point; + actor->spr.angle = VecToAngle(tp->pos - actor->spr.pos); DoActorSetSpeed(actor, MID_SPEED); actor->user.Flags |= (SPR_FIND_PLAYER);