From b6b7d7a93ea3b1c7beaf132e3048d8ddb8e15ec2 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 23 Sep 2022 20:10:05 -0700 Subject: [PATCH] Don't thrust orbinauts while airborne Fixes bonking against a wall transfer. --- src/p_mobj.c | 59 ++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 10978db11..b9dfed581 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6739,40 +6739,45 @@ static boolean P_MobjRegularThink(mobj_t *mobj) } else { - fixed_t finalspeed = mobj->movefactor; - const fixed_t currentspeed = R_PointToDist2(0, 0, mobj->momx, mobj->momy); - fixed_t thrustamount = 0; - fixed_t frictionsafety = (mobj->friction == 0) ? 1 : mobj->friction; mobj_t *ghost = P_SpawnGhostMobj(mobj); ghost->colorized = true; // already has color! - if (!grounded) - { - // No friction in the air - frictionsafety = FRACUNIT; - } - mobj->angle = K_MomentumAngle(mobj); - if (mobj->health <= 5) - { - INT32 i; - for (i = 5; i >= mobj->health; i--) - finalspeed = FixedMul(finalspeed, FRACUNIT-FRACUNIT/4); - } - if (currentspeed >= finalspeed) + if (P_IsObjectOnGround(mobj)) { - // Thrust as if you were at top speed, slow down naturally - thrustamount = FixedDiv(finalspeed, frictionsafety) - finalspeed; - } - else - { - const fixed_t beatfriction = FixedDiv(currentspeed, frictionsafety) - currentspeed; - // Thrust to immediately get to top speed - thrustamount = beatfriction + FixedDiv(finalspeed - currentspeed, frictionsafety); - } + fixed_t finalspeed = mobj->movefactor; + const fixed_t currentspeed = R_PointToDist2(0, 0, mobj->momx, mobj->momy); + fixed_t thrustamount = 0; + fixed_t frictionsafety = (mobj->friction == 0) ? 1 : mobj->friction; - P_Thrust(mobj, mobj->angle, thrustamount); + if (!grounded) + { + // No friction in the air + frictionsafety = FRACUNIT; + } + + if (mobj->health <= 5) + { + INT32 i; + for (i = 5; i >= mobj->health; i--) + finalspeed = FixedMul(finalspeed, FRACUNIT-FRACUNIT/4); + } + + if (currentspeed >= finalspeed) + { + // Thrust as if you were at top speed, slow down naturally + thrustamount = FixedDiv(finalspeed, frictionsafety) - finalspeed; + } + else + { + const fixed_t beatfriction = FixedDiv(currentspeed, frictionsafety) - currentspeed; + // Thrust to immediately get to top speed + thrustamount = beatfriction + FixedDiv(finalspeed - currentspeed, frictionsafety); + } + + P_Thrust(mobj, mobj->angle, thrustamount); + } if (P_MobjTouchingSectorSpecial(mobj, 3, 1, true)) K_DoPogoSpring(mobj, 0, 1);