Fix falling rocks (and possibly other objects) having no collision

This commit is contained in:
GenericHeroGuy 2025-11-23 00:34:35 +01:00
parent fd2e480ee4
commit f11e9a7d13
3 changed files with 47 additions and 41 deletions

View file

@ -57,6 +57,12 @@ static void K_ItemDamage(mobj_t *t1, mobj_t *t2, boolean clash)
P_SpawnMobj(t1->x/2 + t2->x/2, t1->y/2 + t2->y/2, t1->z/2 + t2->z/2, MT_ITEMCLASH);
}
// makes sure that hitthing isn't set to tmthing, otherwise the bounce doesn't work
static void K_SetHitThing(mobj_t *t1, mobj_t *t2)
{
P_SetTarget(&g_tm.hitthing, t1 == g_tm.thing ? t2 : t1);
}
boolean K_OrbinautJawzCollide(mobj_t *t1, mobj_t *t2)
{
boolean damageitem = false;
@ -97,7 +103,7 @@ boolean K_OrbinautJawzCollide(mobj_t *t1, mobj_t *t2)
{
// Player Damage
P_DamageMobj(t2, t1, t1->target, 1, DMG_WIPEOUT);
P_SetTarget(&g_tm.hitthing, t1);
K_SetHitThing(t2, t1);
S_StartSound(t2, sfx_s3k7b);
}
@ -754,7 +760,7 @@ boolean K_KitchenSinkCollide(mobj_t *t1, mobj_t *t2)
boolean K_FallingRockCollide(mobj_t *t1, mobj_t *t2)
{
if ((t2->player && (G_CompatLevel(0x0008) || !t2->player->hyudorotimer)) || t2->type == MT_FALLINGROCK)
P_SetTarget(&g_tm.hitthing, t1);
K_SetHitThing(t1, t2);
return true;
}
@ -782,7 +788,7 @@ boolean K_SMKIceBlockCollide(mobj_t *t1, mobj_t *t2)
return true;
*/
P_SetTarget(&g_tm.hitthing, t1);
K_SetHitThing(t1, t2);
return false;
}

View file

@ -3528,43 +3528,6 @@ static void P_BouncePlayerMove(mobj_t *mo, TryMoveResult_t *result)
return;
}
if (!P_MobjWasRemoved(result->mo)) // object bounce
{
mobj_t *mo1 = mo, *mo2 = result->mo;
boolean bounce = false;
if (result->mo->player != NULL)
{
if (P_IsObjectOnGround(mo2) && mo1->momz < 0)
{
bounce = true;
}
else if (P_IsObjectOnGround(mo1) && mo2->momz < 0)
{
bounce = true;
mo1 = result->mo;
mo2 = mo;
}
}
else switch (mo2->type)
{
case MT_BLUEROBRA:
case MT_BLUEROBRA_HEAD:
case MT_SMK_PIPE:
case MT_SMK_THWOMP:
case MT_SMK_ICEBLOCK:
break;
default:
case MT_KART_LEFTOVER:
bounce = P_IsObjectOnGround(mo2) && mo1->momz < 0;
break;
}
// no more special logic! if you want a solid bounce, return BMIT_ABORT
K_KartBouncing(mo1, mo2, bounce, result->blockingmo);
}
if (result->line == NULL)
return;
@ -3666,6 +3629,43 @@ void P_BounceMove(mobj_t *mo, TryMoveResult_t *result)
if (P_MobjWasRemoved(mo))
return;
if (result != NULL && !P_MobjWasRemoved(result->mo)) // object bounce
{
mobj_t *mo1 = mo, *mo2 = result->mo;
boolean bounce = false;
if (mo2->player != NULL)
{
if (P_IsObjectOnGround(mo2) && mo1->momz < 0)
{
bounce = true;
}
else if (P_IsObjectOnGround(mo1) && mo2->momz < 0)
{
bounce = true;
mo1 = result->mo;
mo2 = mo;
}
}
else switch (mo2->type)
{
case MT_BLUEROBRA:
case MT_BLUEROBRA_HEAD:
case MT_SMK_PIPE:
case MT_SMK_THWOMP:
case MT_SMK_ICEBLOCK:
break;
default:
case MT_KART_LEFTOVER:
bounce = P_IsObjectOnGround(mo2) && mo1->momz < 0;
break;
}
// no more special logic! if you want a solid bounce, return BMIT_ABORT
K_KartBouncing(mo1, mo2, bounce, result->blockingmo);
}
if (mo->player)
{
P_BouncePlayerMove(mo, result);

View file

@ -1843,7 +1843,7 @@ void P_XYMovement(mobj_t *mo)
K_HandleFootstepParticles(mo);
// we still need to bounce off objects even if the move succeeded!
if (player != NULL && !P_MobjWasRemoved(result.mo))
if (!P_MobjWasRemoved(result.mo))
P_BounceMove(mo, &result);
}