From 8a23a5d16b907ccb65c2f5880df71c16c83fdb05 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 1 Sep 2022 22:52:08 +0200 Subject: [PATCH] - floatified VectorWormSeek --- source/games/sw/src/weapon.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 02eca7493..a1a3cc2dc 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -7795,9 +7795,6 @@ int VectorMissileSeek(DSWActor* actor, int16_t delay_tics, int16_t turn_speed, i // completely vector manipulation int VectorWormSeek(DSWActor* actor, int16_t delay_tics, int16_t aware_range1, int16_t aware_range2) { - int dist; - int zh; - if (actor->user.WaitTics <= delay_tics) actor->user.WaitTics += MISSILEMOVETICS; @@ -7824,21 +7821,16 @@ int VectorWormSeek(DSWActor* actor, int16_t delay_tics, int16_t aware_range1, in DSWActor* goal = actor->user.WpnGoalActor; if (goal != nullptr) { - int ox,oy,oz; + auto delta = (goal->spr.pos.XY() - actor->spr.pos.XY()); + double zdiff = ActorZOfTop(goal) + (ActorSizeZ(goal) * 0.25) - actor->spr.pos.Z; + double dist = g_sqrt(delta.LengthSquared() + zdiff * zdiff); - zh = int_ActorZOfTop(actor) + (int_ActorSizeZ(actor) >> 2); + auto oc = actor->user.change; - dist = ksqrt(SQ(actor->int_pos().X - goal->int_pos().X) + SQ(actor->int_pos().Y - goal->int_pos().Y) + (SQ(actor->int_pos().Z - zh)>>8)); + auto vel = (actor->spr.xvel * zinttoworld) / dist; + actor->user.change = DVector3(delta, zdiff) * vel + oc * (7. / 8); - auto oc = actor->user.change; - - actor->user.set_int_change_x(Scale(actor->spr.xvel, goal->int_pos().X - actor->int_pos().X, dist)); - actor->user.set_int_change_y(Scale(actor->spr.xvel, goal->int_pos().Y - actor->int_pos().Y, dist)); - actor->user.set_int_change_z(Scale(actor->spr.xvel, zh - actor->int_pos().Z, dist)); - - actor->user.change += oc * (7./8); - - SetAngleFromChange(actor); + SetAngleFromChange(actor); } return 0;