diff --git a/src/playsim/p_things.cpp b/src/playsim/p_things.cpp index 12d685952b..c818fb6182 100644 --- a/src/playsim/p_things.cpp +++ b/src/playsim/p_things.cpp @@ -171,7 +171,7 @@ void InterceptDefaultAim(AActor *mobj, AActor *targ, DVector3 aim, double speed) // [MC] Was part of P_Thing_Projectile, now its own function for use in ZScript. // Aims mobj at targ based on speed and targ's velocity. -static void VelIntercept(AActor *targ, AActor *mobj, double speed, bool aimpitch = false, bool oldvel = false, bool leadtarget = true) +static void VelIntercept(AActor *targ, AActor *mobj, double speed, bool aimpitch = false, bool oldvel = false, bool resetvel = false, bool leadtarget = true) { if (targ == nullptr || mobj == nullptr) return; @@ -199,7 +199,7 @@ static void VelIntercept(AActor *targ, AActor *mobj, double speed, bool aimpitch if (targ->Vel.X == 0 && targ->Vel.Y == 0) { InterceptDefaultAim(mobj, targ, aim, speed); - if (oldvel) + if (resetvel) { mobj->Vel = prevel; } @@ -225,6 +225,10 @@ static void VelIntercept(AActor *targ, AActor *mobj, double speed, bool aimpitch // And make the projectile follow that vector at the desired speed. mobj->Vel = aimvec * (speed / dist); mobj->AngleFromVel(); + if (oldvel) + { + mobj->Vel = prevel; + } if (aimpitch) // [MC] Ripped right out of A_FaceMovementDirection { const DVector2 velocity = mobj->Vel.XY(); @@ -235,7 +239,7 @@ static void VelIntercept(AActor *targ, AActor *mobj, double speed, bool aimpitch { InterceptDefaultAim(mobj, targ, aim, speed); } - if (oldvel) + if (resetvel) { mobj->Vel = prevel; } @@ -248,8 +252,9 @@ DEFINE_ACTION_FUNCTION(AActor, VelIntercept) PARAM_FLOAT(speed); PARAM_BOOL(aimpitch); PARAM_BOOL(oldvel); + PARAM_BOOL(resetvel); if (speed < 0) speed = self->Speed; - VelIntercept(targ, self, speed, aimpitch, oldvel); + VelIntercept(targ, self, speed, aimpitch, oldvel, resetvel); return 0; } @@ -335,7 +340,7 @@ bool FLevelLocals::EV_Thing_Projectile (int tid, AActor *source, int type, const if (targ != nullptr) { - VelIntercept(targ, mobj, speed, false, false, leadTarget); + VelIntercept(targ, mobj, speed, false, false, false, leadTarget); if (mobj->flags2 & MF2_SEEKERMISSILE) { diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 3abfbaabe2..e336b70ceb 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -751,7 +751,7 @@ class Actor : Thinker native native clearscope vector2 Vec2Angle(double length, double angle, bool absolute = false) const; native clearscope vector2 Vec2Offset(double x, double y, bool absolute = false) const; native clearscope vector3 Vec2OffsetZ(double x, double y, double atz, bool absolute = false) const; - native void VelIntercept(Actor targ, double speed = -1, bool aimpitch = true, bool oldvel = false); + native void VelIntercept(Actor targ, double speed = -1, bool aimpitch = true, bool oldvel = false, bool resetvel = false); native void VelFromAngle(double speed = 1e37, double angle = 1e37); native void Vel3DFromAngle(double speed, double angle, double pitch); native void Thrust(double speed = 1e37, double angle = 1e37);