From 1589afb46e3ae50a00886ad20f8a8d85802f63fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Sat, 13 May 2023 20:30:42 -0300 Subject: [PATCH] Add Voodoo Zombie Compatflag --- src/d_main.cpp | 2 +- src/doomdef.h | 1 + src/gamedata/g_mapinfo.cpp | 1 + src/maploader/compatibility.cpp | 1 + src/playsim/p_interaction.cpp | 17 +++++++-- wadsrc/static/zscript/actors/player/player.zs | 35 +++++++++++++++++-- wadsrc/static/zscript/constants.zs | 1 + 7 files changed, 51 insertions(+), 7 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 31e1568ba8..6e88286c85 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -625,7 +625,7 @@ CUSTOM_CVAR(Int, compatmode, 0, CVAR_ARCHIVE|CVAR_NOINITCALL) COMPATF_TRACE | COMPATF_MISSILECLIP | COMPATF_SOUNDTARGET | COMPATF_NO_PASSMOBJ | COMPATF_LIMITPAIN | COMPATF_DEHHEALTH | COMPATF_INVISIBILITY | COMPATF_CROSSDROPOFF | COMPATF_VILEGHOSTS | COMPATF_HITSCAN | COMPATF_WALLRUN | COMPATF_NOTOSSDROPS | COMPATF_LIGHT | COMPATF_MASKEDMIDTEX; - w = COMPATF2_BADANGLES | COMPATF2_FLOORMOVE | COMPATF2_POINTONLINE | COMPATF2_EXPLODE2 | COMPATF2_NOMBF21; + w = COMPATF2_BADANGLES | COMPATF2_FLOORMOVE | COMPATF2_POINTONLINE | COMPATF2_EXPLODE2 | COMPATF2_NOMBF21 | COMPATF2_VOODOO_ZOMBIES; break; case 3: // Boom compat mode diff --git a/src/doomdef.h b/src/doomdef.h index 8dd96ea704..bdeb81611f 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -233,6 +233,7 @@ enum : unsigned int COMPATF2_AVOID_HAZARDS = 1 << 12, // another MBF thing. COMPATF2_STAYONLIFT = 1 << 13, // yet another MBF thing. COMPATF2_NOMBF21 = 1 << 14, // disable MBF21 features that may clash with certain maps + COMPATF2_VOODOO_ZOMBIES = 1 << 15, // [RL0] allow playerinfo, playerpawn, and voodoo health to all be different, and skip killing the player's mobj if a voodoo doll dies to allow voodoo zombies }; diff --git a/src/gamedata/g_mapinfo.cpp b/src/gamedata/g_mapinfo.cpp index b87036be78..a5b0bfb1c7 100644 --- a/src/gamedata/g_mapinfo.cpp +++ b/src/gamedata/g_mapinfo.cpp @@ -1842,6 +1842,7 @@ MapFlagHandlers[] = { "compat_avoidhazards", MITYPE_COMPATFLAG, 0, COMPATF2_AVOID_HAZARDS }, { "compat_stayonlift", MITYPE_COMPATFLAG, 0, COMPATF2_STAYONLIFT }, { "compat_nombf21", MITYPE_COMPATFLAG, 0, COMPATF2_NOMBF21 }, + { "compat_voodoozombies", MITYPE_COMPATFLAG, 0, COMPATF2_VOODOO_ZOMBIES }, { "cd_start_track", MITYPE_EATNEXT, 0, 0 }, { "cd_end1_track", MITYPE_EATNEXT, 0, 0 }, { "cd_end2_track", MITYPE_EATNEXT, 0, 0 }, diff --git a/src/maploader/compatibility.cpp b/src/maploader/compatibility.cpp index a9d9ca0e5a..2a0fa07491 100644 --- a/src/maploader/compatibility.cpp +++ b/src/maploader/compatibility.cpp @@ -171,6 +171,7 @@ static FCompatOption Options[] = { "railing", COMPATF2_RAILING, SLOT_COMPAT2 }, { "scriptwait", COMPATF2_SCRIPTWAIT, SLOT_COMPAT2 }, { "nombf21", COMPATF2_NOMBF21, SLOT_COMPAT2 }, + { "voodoozombies", COMPATF2_VOODOO_ZOMBIES, SLOT_COMPAT2 }, { NULL, 0, 0 } }; diff --git a/src/playsim/p_interaction.cpp b/src/playsim/p_interaction.cpp index 2c89e3cc1b..4baac07a45 100644 --- a/src/playsim/p_interaction.cpp +++ b/src/playsim/p_interaction.cpp @@ -1335,13 +1335,24 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da } } + bool compat_voodoo_zombie = target->Level->i_compatflags2 & COMPATF2_VOODOO_ZOMBIES; + player->health -= damage; // mirror mobj health here for Dave - // [RH] Make voodoo dolls and real players record the same health - target->health = player->mo->health -= damage; + if(compat_voodoo_zombie) + { // [RL0] To allow voodoo zombies, don't set the voodoo doll to the player mobj's health and don't change the player mobj's health on damage + target->health -= damage; + } + else + { // [RH] Make voodoo dolls and real players record the same health + target->health = player->mo->health -= damage; + } if (player->health < 50 && !deathmatch && !(flags & DMG_FORCED)) { P_AutoUseStrifeHealth (player); - player->mo->health = player->health; + if(!compat_voodoo_zombie) + { // [RL0] To match vanilla behavior, don't set the player mo's health to 0 if voodoo zombies compat is enabled + player->mo->health = player->health; + } } if (player->health <= 0) { diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index 7039f94363..5f6d0f616a 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -85,6 +85,11 @@ class PlayerPawn : Actor flagdef CanSuperMorph: PlayerFlags, 1; flagdef CrouchableMorph: PlayerFlags, 2; flagdef WeaponLevel2Ended: PlayerFlags, 3; + + enum EPrivatePlayerFlags + { + PF_VOODOO_ZOMBIE = 1<<4, + } Default { @@ -777,14 +782,16 @@ class PlayerPawn : Actor Super.Die (source, inflictor, dmgflags, MeansOfDeath); if (player != NULL && player.mo == self) player.bonuscount = 0; - - if (player != NULL && player.mo != self) + + // [RL0] To allow voodoo zombies, don't kill the player together with voodoo dolls if the compat flag is enabled + if (player != NULL && player.mo != self && !(Level.compatflags2 & COMPATF2_VOODOO_ZOMBIES)) { // Make the real player die, too player.mo.Die (source, inflictor, dmgflags, MeansOfDeath); } else { - if (player != NULL && sv_weapondrop) + // [RL0] player.mo == self will always be true if COMPATF2_VOODOO_ZOMBIES is false, so there's no need to check the compatflag here too, just self + if (player != NULL && sv_weapondrop && player.mo == self) { // Voodoo dolls don't drop weapons let weap = player.ReadyWeapon; if (weap != NULL) @@ -1609,6 +1616,12 @@ class PlayerPawn : Actor { let player = self.player; UserCmd cmd = player.cmd; + + // [RL0] Mark players that became zombies (this stays even if they 'revive' by healing, until a level change) + if((Level.compatflags2 & COMPATF2_VOODOO_ZOMBIES) && player.health <= 0 && player.mo.health > 0) + { + PlayerFlags |= PF_VOODOO_ZOMBIE; + } CheckFOV(); @@ -1692,6 +1705,9 @@ class PlayerPawn : Actor void BringUpWeapon () { + // [RL0] Don't bring up weapon when in a voodoo zombie state + if(PlayerFlags & PF_VOODOO_ZOMBIE) return; + let player = self.player; if (player.PendingWeapon == WP_NOCHANGE) { @@ -2007,6 +2023,19 @@ class PlayerPawn : Actor void PlayerFinishLevel (int mode, int flags) { + // [RL0] Handle player exit behavior for voodoo zombies + if(PlayerFlags & PF_VOODOO_ZOMBIE) + { + if(player.health > 0) + { + PlayerFlags &= ~PF_VOODOO_ZOMBIE; + } + else + { + bShootable = false; + bKilled = true; + } + } Inventory item, next; let p = player; diff --git a/wadsrc/static/zscript/constants.zs b/wadsrc/static/zscript/constants.zs index 66426a1256..8e31a68eae 100644 --- a/wadsrc/static/zscript/constants.zs +++ b/wadsrc/static/zscript/constants.zs @@ -1429,6 +1429,7 @@ enum ECompatFlags COMPATF2_EXPLODE1 = 1 << 8, // No vertical explosion thrust COMPATF2_EXPLODE2 = 1 << 9, // Use original explosion code throughout. COMPATF2_RAILING = 1 << 10, // Bugged Strife railings. + COMPATF2_VOODOO_ZOMBIES = 1 << 15, // allow playerinfo, playerpawn, and voodoo health to all be different, and allow monster targetting of 'dead' players that have positive health }; const M_E = 2.7182818284590452354; // e