Improvements to death and cheat handling

Extra safety to ensure dummy Actor deaths properly emulate a real death and aren't duplicate called. Fixed a crash when using the kill command while set to unmorph on death. Super morphing is now possible while using the morphme cheat if passing the morph class directly. Added a flag to ignore player invulnerability completely when morphing.
This commit is contained in:
Boondorl 2024-02-07 17:56:38 -05:00 committed by Rachael Alexanderson
commit 3033fafaa7
8 changed files with 44 additions and 23 deletions

View file

@ -324,14 +324,23 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf
{
// Return values are no longer used to ensure things stay properly managed.
AActor* const realMo = alternative;
const int morphStyle = player != nullptr ? player->MorphStyle : IntVar(NAME_MorphFlags);
int morphStyle = 0;
VMValue params[] = { this };
{
IFVM(Actor, GetMorphStyle)
{
VMReturn ret[] = { &morphStyle };
VMCall(func, params, 1, ret, 1);
}
}
VMCall(func, params, 1, nullptr, 0);
// Kill the dummy Actor if it didn't unmorph, otherwise checking the morph flags. Player pawns need
// to stay, otherwise they won't respawn correctly.
if (realMo != nullptr
if (realMo != nullptr && !(realMo->flags6 & MF6_KILLED)
&& ((alternative != nullptr && player == nullptr) || (alternative == nullptr && !(morphStyle & MORPH_UNDOBYDEATHSAVES))))
{
if (wasgibbed)
@ -345,6 +354,11 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags, FName MeansOf
realMo->health = 0;
}
// Pass appropriate damage information along when it's confirmed to die.
realMo->DamageTypeReceived = DamageTypeReceived;
realMo->DamageType = DamageType;
realMo->special1 = special1;
realMo->CallDie(source, inflictor, dmgflags, MeansOfDeath);
}
}