mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Metal SA2 Crate crushes players if it falls onto them
This commit is contained in:
parent
4277c6d930
commit
77e69228f7
1 changed files with 35 additions and 0 deletions
|
|
@ -332,11 +332,46 @@ struct Crate : Box<SA2CrateConfig>
|
|||
|
||||
if (metal() && !inflictor->boosting())
|
||||
{
|
||||
crush(inflictor);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return Box::damage(inflictor);
|
||||
}
|
||||
|
||||
private:
|
||||
bool clip2d(const Toucher* inflictor) const
|
||||
{
|
||||
LineSegment a = aabb();
|
||||
LineSegment b = inflictor->aabb();
|
||||
|
||||
return a.a.x < b.b.x && b.a.x < a.b.x && a.a.y < b.b.y && b.a.y < a.b.y;
|
||||
}
|
||||
|
||||
void crush(Toucher* inflictor)
|
||||
{
|
||||
if (!momz)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((momz < 0 ? mobj_t::z - inflictor->floorz : inflictor->ceilingz - top()) > inflictor->height)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!clip2d(inflictor))
|
||||
{
|
||||
// Bumping the side of a falling crate should not
|
||||
// kill you.
|
||||
// Note: this check is imperfect. That's why
|
||||
// everything is guarded by momz anyway.
|
||||
return;
|
||||
}
|
||||
|
||||
P_DamageMobj(inflictor, this, nullptr, 1, DMG_CRUSHED);
|
||||
}
|
||||
};
|
||||
|
||||
struct Ice : Box<IceCapBlockConfig>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue