Metal SA2 Crate crushes players if it falls onto them

This commit is contained in:
James R 2024-01-02 03:48:07 -08:00
parent 4277c6d930
commit 77e69228f7

View file

@ -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>