From d48d02971f1dccdd2670daefe2d330fcfde92554 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Wed, 6 Dec 2023 13:00:07 +0100 Subject: [PATCH] fix Max Health setting in Dehacked using complevel 2 Fixes #1305 --- src/d_deh.c | 8 +++++++- src/d_main.c | 18 ++++++++++++++++++ src/d_main.h | 1 + src/g_game.c | 2 ++ src/p_inter.c | 5 +++-- src/p_inter.h | 1 + 6 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/d_deh.c b/src/d_deh.c index 541ee164..c31dabe4 100644 --- a/src/d_deh.c +++ b/src/d_deh.c @@ -129,6 +129,9 @@ boolean deh_pars = false; // in wi_stuff to allow pars in modified games boolean deh_set_blood_color = false; +int deh_maxhealth; +boolean deh_set_maxhealth = false; + char **dehfiles = NULL; // filenames of .deh files for demo footer // #include "d_deh.h" -- we don't do that here but we declare the @@ -2777,7 +2780,10 @@ void deh_procMisc(DEHFILE *fpin, FILE* fpout, char *line) // done initial_bullets = value; else if (!strcasecmp(key,deh_misc[2])) // Max Health - maxhealth = value; + { + deh_maxhealth = value; + deh_set_maxhealth = true; + } else if (!strcasecmp(key,deh_misc[3])) // Max Armor max_armor = value; diff --git a/src/d_main.c b/src/d_main.c index f0822fa6..c3d8e63d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -68,6 +68,7 @@ #include "i_endoom.h" #include "d_quit.h" #include "r_bmaps.h" +#include "p_inter.h" // maxhealthbonus #include "dsdhacked.h" @@ -1838,6 +1839,23 @@ static void D_InitTables(void) states[i].flags |= STATEF_SKILL5FAST; } +void D_SetMaxHealth(void) +{ + extern boolean deh_set_maxhealth; + extern int deh_maxhealth; + + if (demo_compatibility) + { + maxhealth = 100; + maxhealthbonus = deh_set_maxhealth ? deh_maxhealth : 200; + } + else + { + maxhealth = deh_set_maxhealth ? deh_maxhealth : 100; + maxhealthbonus = maxhealth * 2; + } +} + void D_SetBloodColor(void) { extern boolean deh_set_blood_color; diff --git a/src/d_main.h b/src/d_main.h index 40a4a38a..1158428c 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -39,6 +39,7 @@ extern boolean clrespawnparm; // checkparm of -respawn extern boolean clfastparm; // checkparm of -fast //jff end of external declaration of command line playmode +void D_SetMaxHealth(void); void D_SetBloodColor(void); void D_SetPredefinedTranslucency(void); void D_DehChangePredefinedTranslucency(int index); diff --git a/src/g_game.c b/src/g_game.c index 9f12ea84..69832245 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3113,6 +3113,8 @@ void G_ReloadDefaults(boolean keep_demover) G_MBF21Defaults(); } + D_SetMaxHealth(); + D_SetBloodColor(); D_SetPredefinedTranslucency(); diff --git a/src/p_inter.c b/src/p_inter.c index a4545543..c4b61a7b 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -39,6 +39,7 @@ int initial_health = 100; int initial_bullets = 50; int maxhealth = 100; // was MAXHEALTH as a #define, used only in this module +int maxhealthbonus = 200; int max_armor = 200; int green_armor_class = 1; // these are involved with armortype below int blue_armor_class = 2; @@ -334,8 +335,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher) } player->health++; // can go over 100% - if (player->health > (maxhealth * 2)) - player->health = (maxhealth * 2); + if (player->health > maxhealthbonus) + player->health = maxhealthbonus; player->mo->health = player->health; pickupmsg(player, "%s", s_GOTHTHBONUS); // Ty 03/22/98 - externalized break; diff --git a/src/p_inter.h b/src/p_inter.h index e1d4c598..06544348 100644 --- a/src/p_inter.h +++ b/src/p_inter.h @@ -46,6 +46,7 @@ extern int idkfa_armor_class; // Ty - end extern int initial_health; extern int initial_bullets; extern int maxhealth; +extern int maxhealthbonus; extern int max_armor; extern int green_armor_class; extern int blue_armor_class;