Merge branch 'underwater-gravity-fix' into 'master'

Fix underwater gravity for Gachabom and Battle UFO tractor beam

Closes #444 and #874

See merge request KartKrew/Kart!1809
This commit is contained in:
James R. 2024-01-11 20:42:39 +00:00
commit 52bf348d0b
2 changed files with 34 additions and 8 deletions

View file

@ -789,7 +789,14 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
{ {
fixed_t tractorHeight = 211*mapobjectscale; fixed_t tractorHeight = 211*mapobjectscale;
fixed_t zRange = FixedDiv(thing->z - tm.thing->z, tractorHeight); fixed_t zRange = FixedDiv(thing->z - tm.thing->z, tractorHeight);
P_SetObjectMomZ(tm.thing, max(zRange, FRACUNIT/16), true); fixed_t momZ = max(zRange, FRACUNIT/16);
if (tm.thing->eflags & MFE_UNDERWATER)
{
momZ = (117 * momZ) / 200;
}
P_SetObjectMomZ(tm.thing, momZ, true);
} }
fixed_t friction = 33*FRACUNIT/35; fixed_t friction = 33*FRACUNIT/35;

View file

@ -1048,6 +1048,27 @@ static void P_PlayerFlip(mobj_t *mo)
// Flip aiming to match! // Flip aiming to match!
} }
static boolean P_UseUnderwaterGravity(mobj_t *mo)
{
switch (mo->type)
{
case MT_BANANA:
return false;
case MT_GACHABOM:
if (Obj_GachaBomWasTossed(mo))
{
return false;
}
break;
default:
break;
}
return true;
}
// //
// P_GetMobjGravity // P_GetMobjGravity
// //
@ -1106,7 +1127,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
} }
// Less gravity underwater. // Less gravity underwater.
if ((mo->eflags & MFE_UNDERWATER) && !goopgravity) if ((mo->eflags & MFE_UNDERWATER) && !goopgravity && P_UseUnderwaterGravity(mo))
{ {
if (mo->momz * P_MobjFlip(mo) <= 0) if (mo->momz * P_MobjFlip(mo) <= 0)
{ {
@ -1234,12 +1255,8 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
gravityadd /= 2; gravityadd /= 2;
break; break;
case MT_GACHABOM: case MT_GACHABOM:
// Use normal gravity, unless if it was tossed. gravityadd = (5*gravityadd)/2;
if (!Obj_GachaBomWasTossed(mo)) break;
{
break;
}
/*FALLTHRU*/
case MT_BANANA: case MT_BANANA:
case MT_EGGMANITEM: case MT_EGGMANITEM:
case MT_SSMINE: case MT_SSMINE:
@ -7601,6 +7618,8 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
mobj->rollangle -= spin; mobj->rollangle -= spin;
} }
P_MobjCheckWater(mobj);
if (mobj->threshold > 0) if (mobj->threshold > 0)
mobj->threshold--; mobj->threshold--;
break; break;