fix max health for Doom's health bonus with Dehacked modifications present.

This commit is contained in:
Christoph Oelckers 2023-12-20 00:11:09 +01:00
parent a31cfa97e4
commit 3f05f38a60
2 changed files with 28 additions and 1 deletions

View file

@ -2545,7 +2545,7 @@ static int PatchMisc (int dummy)
auto health = GetDefaultByName ("HealthBonus");
if (health!=NULL)
{
health->IntVar(NAME_MaxAmount) = 2 * deh.MaxHealth;
health->IntVar(NAME_MaxAmount) = -1; // needs to be evaluated at run time due to the compat flag.
}
health = GetDefaultByName ("Soulsphere");

View file

@ -16,6 +16,33 @@ class HealthBonus : Health
BON1 ABCDCB 6;
Loop;
}
//===========================================================================
//
// TryPickup
//
//===========================================================================
override bool TryPickup (in out Actor other)
{
PrevHealth = other.player != NULL ? other.player.health : other.health;
// Dehacked max health is compatibility dependent because Boom interpreted this value wrong.
let maxamt = MaxAmount;
if (maxamt < 0)
{
maxamt = deh.MaxHealth;
if (!(Level.compatflags & COMPATF_DEHHEALTH)) maxamt *= 2;
}
if (other.GiveBody(Amount, maxamt))
{
GoAwayAndDie();
return true;
}
return false;
}
}
// Stimpack -----------------------------------------------------------------