Merge branch 'metal-crate-just-bumped' into 'master'

Add justbumped exception to metal SA2 crates

See merge request KartKrew/Kart!1701
This commit is contained in:
Oni 2023-12-22 21:14:51 +00:00
commit 1c3000ad34
3 changed files with 23 additions and 3 deletions

View file

@ -822,6 +822,20 @@ static void K_PlayerJustBumped(player_t *player)
}
}
static boolean K_JustBumpedException(mobj_t *mobj)
{
switch (mobj->type)
{
case MT_SA2_CRATE:
return Obj_SA2CrateIsMetal(mobj);
default:
break;
}
return false;
}
static fixed_t K_GetBounceForce(mobj_t *mobj1, mobj_t *mobj2, fixed_t distx, fixed_t disty)
{
const fixed_t forceMul = (4 * FRACUNIT) / 10; // Multiply by this value to make it feel like old bumps.
@ -918,13 +932,13 @@ boolean K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2)
}
// Don't bump if you've recently bumped
if (mobj1->player && mobj1->player->justbumped)
if (mobj1->player && mobj1->player->justbumped && !K_JustBumpedException(mobj2))
{
mobj1->player->justbumped = bumptime;
return false;
}
if (mobj2->player && mobj2->player->justbumped)
if (mobj2->player && mobj2->player->justbumped && !K_JustBumpedException(mobj1))
{
mobj2->player->justbumped = bumptime;
return false;
@ -1032,7 +1046,7 @@ boolean K_KartSolidBounce(mobj_t *bounceMobj, mobj_t *solidMobj)
return false;
// Don't bump if you've recently bumped
if (bounceMobj->player && bounceMobj->player->justbumped)
if (bounceMobj->player && bounceMobj->player->justbumped && !K_JustBumpedException(solidMobj))
{
bounceMobj->player->justbumped = bumptime;
return false;

View file

@ -327,6 +327,7 @@ void Obj_TryCrateInit(mobj_t *mo);
boolean Obj_TryCrateThink(mobj_t *mo);
void Obj_TryCrateTouch(mobj_t *special, mobj_t *toucher);
void Obj_TryCrateDamage(mobj_t *target, mobj_t *inflictor);
boolean Obj_SA2CrateIsMetal(mobj_t *mo);
/* Lavender Shrine Spears */
void Obj_SpearInit(mobj_t *mo);

View file

@ -389,3 +389,8 @@ void Obj_TryCrateDamage(mobj_t* target, mobj_t* inflictor)
{
static_cast<AnyBox*>(target)->visit([&](auto box) { box->damage(static_cast<Toucher*>(inflictor)); });
}
boolean Obj_SA2CrateIsMetal(mobj_t* mobj)
{
return static_cast<Crate*>(mobj)->metal();
}