From 3f05f38a600307e443e9396ece8bcadd0d420cf1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 20 Dec 2023 00:11:09 +0100 Subject: [PATCH] fix max health for Doom's health bonus with Dehacked modifications present. --- src/gamedata/d_dehacked.cpp | 2 +- .../static/zscript/actors/doom/doomhealth.zs | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/gamedata/d_dehacked.cpp b/src/gamedata/d_dehacked.cpp index b7d970e00..029878176 100644 --- a/src/gamedata/d_dehacked.cpp +++ b/src/gamedata/d_dehacked.cpp @@ -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"); diff --git a/wadsrc/static/zscript/actors/doom/doomhealth.zs b/wadsrc/static/zscript/actors/doom/doomhealth.zs index c0ecf2dc0..04909b248 100644 --- a/wadsrc/static/zscript/actors/doom/doomhealth.zs +++ b/wadsrc/static/zscript/actors/doom/doomhealth.zs @@ -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 -----------------------------------------------------------------