From 4c6a5bab5670dce3af5b190af87a7e7aba9fc53b Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 19 Aug 2021 06:58:05 +0200 Subject: [PATCH] Clean up god mode --- Source/debug.cpp | 5 +-- Source/debug.h | 1 + Source/diablo.cpp | 6 +--- Source/diablo.h | 1 - Source/missiles.cpp | 76 +++++++++++++++++++++++---------------------- Source/monster.cpp | 2 +- Source/player.cpp | 24 +++++++------- 7 files changed, 56 insertions(+), 59 deletions(-) diff --git a/Source/debug.cpp b/Source/debug.cpp index 36c4e7631..8e821b7c9 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -18,6 +18,7 @@ namespace devilution { std::optional pSquareCel; +bool DebugGodMode = false; namespace { @@ -137,8 +138,8 @@ std::string DebugCmdResetLevel(const std::string_view parameter) std::string DebugCmdGodMode(const std::string_view parameter) { - debug_mode_key_inverted_v = !debug_mode_key_inverted_v; - if (debug_mode_key_inverted_v) + DebugGodMode = !DebugGodMode; + if (DebugGodMode) return "A god descended."; return "You are mortal, beware of the darkness."; } diff --git a/Source/debug.h b/Source/debug.h index 52a8977b8..0ce9c2aa3 100644 --- a/Source/debug.h +++ b/Source/debug.h @@ -14,6 +14,7 @@ namespace devilution { extern std::optional pSquareCel; +extern bool DebugGodMode; void FreeDebugGFX(); void LoadDebugGFX(); diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 78f7a0bb2..629420871 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -106,7 +106,6 @@ bool visiondebug = false; int questdebug = -1; bool debug_mode_key_w = false; bool debug_mode_key_inverted_v = false; -bool debug_mode_dollar_sign = false; bool debug_mode_key_i = false; int debug_mode_key_j = 0; #endif @@ -881,8 +880,7 @@ void RunGameLoop(interface_mode uMsg) #ifdef _DEBUG printInConsole("\nDebug options:\n"); printInConsole(" %-20s %-30s\n", "-w", "Enable cheats"); - printInConsole(" %-20s %-30s\n", "-$", "Enable god mode"); - printInConsole(" %-20s %-30s\n", "-^", "Enable god mode and debug tools"); + printInConsole(" %-20s %-30s\n", "-^", "Enable debug tools"); printInConsole(" %-20s %-30s\n", "-v", "Highlight visibility"); printInConsole(" %-20s %-30s\n", "-i", "Ignore network timeout"); printInConsole(" %-20s %-30s\n", "-j <##>", "Mausoleum warps to given level"); @@ -945,8 +943,6 @@ void DiabloParseFlags(int argc, char **argv) #ifdef _DEBUG } else if (strcasecmp("-^", argv[i]) == 0) { debug_mode_key_inverted_v = true; - } else if (strcasecmp("-$", argv[i]) == 0) { - debug_mode_dollar_sign = true; } else if (strcasecmp("-i", argv[i]) == 0) { debug_mode_key_i = true; } else if (strcasecmp("-j", argv[i]) == 0) { diff --git a/Source/diablo.h b/Source/diablo.h index e7a8698cf..f5d11ef17 100644 --- a/Source/diablo.h +++ b/Source/diablo.h @@ -110,7 +110,6 @@ extern bool visiondebug; extern int questdebug; extern bool debug_mode_key_w; extern bool debug_mode_key_inverted_v; -extern bool debug_mode_dollar_sign; extern bool debug_mode_key_i; extern int debug_mode_key_j; #endif diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 6bba249d6..5bf648f73 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -10,6 +10,9 @@ #include "control.h" #include "cursor.h" #include "dead.h" +#ifdef _DEBUG +#include "debug.h" +#endif #include "engine/cel_header.hpp" #include "engine/load_file.hpp" #include "engine/random.hpp" @@ -265,13 +268,12 @@ bool MonsterMHit(int pnum, int m, int mindam, int maxdam, int dist, int t, bool if (CheckMonsterHit(monster, &ret)) return ret; + if (hit >= hper) { #ifdef _DEBUG - if (hit >= hper && !debug_mode_key_inverted_v && !debug_mode_dollar_sign) - return false; -#else - if (hit >= hper) - return false; + if (!DebugGodMode) #endif + return false; + } int dam; if (t == MIS_BONESPIRIT) { @@ -994,44 +996,44 @@ bool MonsterTrapHit(int m, int mindam, int maxdam, int dist, int t, bool shift) if (CheckMonsterHit(monster, &ret)) { return ret; } + if (hit >= hper && monster._mmode != MM_STONE) { #ifdef _DEBUG - if (hit < hper || debug_mode_dollar_sign || debug_mode_key_inverted_v || monster._mmode == MM_STONE) { -#else - if (hit < hper || monster._mmode == MM_STONE) { + if (!DebugGodMode) #endif - int dam = mindam + GenerateRnd(maxdam - mindam + 1); - if (!shift) - dam <<= 6; - if (resist) - monster._mhitpoints -= dam / 4; - else - monster._mhitpoints -= dam; + return false; + } + + int dam = mindam + GenerateRnd(maxdam - mindam + 1); + if (!shift) + dam <<= 6; + if (resist) + monster._mhitpoints -= dam / 4; + else + monster._mhitpoints -= dam; #ifdef _DEBUG - if (debug_mode_dollar_sign || debug_mode_key_inverted_v) - monster._mhitpoints = 0; + if (DebugGodMode) + monster._mhitpoints = 0; #endif - if (monster._mhitpoints >> 6 <= 0) { - if (monster._mmode == MM_STONE) { - M_StartKill(m, -1); - monster.Petrify(); - } else { - M_StartKill(m, -1); - } + if (monster._mhitpoints >> 6 <= 0) { + if (monster._mmode == MM_STONE) { + M_StartKill(m, -1); + monster.Petrify(); } else { - if (resist) { - PlayEffect(monster, 1); - } else if (monster._mmode == MM_STONE) { - if (m > MAX_PLRS - 1) - M_StartHit(m, -1, dam); - monster.Petrify(); - } else { - if (m > MAX_PLRS - 1) - M_StartHit(m, -1, dam); - } + M_StartKill(m, -1); + } + } else { + if (resist) { + PlayEffect(monster, 1); + } else if (monster._mmode == MM_STONE) { + if (m > MAX_PLRS - 1) + M_StartHit(m, -1, dam); + monster.Petrify(); + } else { + if (m > MAX_PLRS - 1) + M_StartHit(m, -1, dam); } - return true; } - return false; + return true; } bool PlayerMHit(int pnum, MonsterStruct *monster, int dist, int mind, int maxd, int mtype, bool shift, int earflag, bool *blocked) @@ -1054,7 +1056,7 @@ bool PlayerMHit(int pnum, MonsterStruct *monster, int dist, int mind, int maxd, int hit = GenerateRnd(100); #ifdef _DEBUG - if (debug_mode_dollar_sign || debug_mode_key_inverted_v) + if (DebugGodMode) hit = 1000; #endif int hper = 40; diff --git a/Source/monster.cpp b/Source/monster.cpp index 8b3399850..37013fe2d 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -1442,7 +1442,7 @@ void MonsterAttackPlayer(int i, int pnum, int hit, int minDam, int maxDam) int hper = GenerateRnd(100); #ifdef _DEBUG - if (debug_mode_dollar_sign || debug_mode_key_inverted_v) + if (DebugGodMode) hper = 1000; #endif int ac = player.GetArmor(); diff --git a/Source/player.cpp b/Source/player.cpp index 866814a62..9613f5a00 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -9,6 +9,9 @@ #include "control.h" #include "cursor.h" #include "dead.h" +#ifdef _DEBUG +#include "debug.h" +#endif #include "engine/cel_header.hpp" #include "engine/load_file.hpp" #include "engine/random.hpp" @@ -919,13 +922,14 @@ bool PlrHitMonst(int pnum, int m) if (CheckMonsterHit(monster, &ret)) { return ret; } + + if (hit >= hper) { #ifdef _DEBUG - if (hit >= hper && !debug_mode_key_inverted_v && !debug_mode_dollar_sign) - return false; -#else - if (hit >= hper) - return false; + if (!DebugGodMode) #endif + return false; + } + if ((player._pIFlags & ISPL_FIREDAM) != 0 && (player._pIFlags & ISPL_LIGHTDAM) != 0) { int midam = player._pIFMinDam + GenerateRnd(player._pIFMaxDam - player._pIFMinDam); AddMissile(player.position.tile, player.position.temp, player._pdir, MIS_SPECARROW, TARGET_MONSTERS, pnum, midam, 0); @@ -1054,7 +1058,7 @@ bool PlrHitMonst(int pnum, int m) monster._mFlags |= MFLAG_NOHEAL; } #ifdef _DEBUG - if (debug_mode_dollar_sign || debug_mode_key_inverted_v) { + if (DebugGodMode) { monster._mhitpoints = 0; /* double check */ } #endif @@ -2719,7 +2723,7 @@ void InitPlayer(int pnum, bool firstTime) player.pManaShield = false; } - if (player.plrlevel == currlevel || leveldebug) { + if (player.plrlevel == currlevel) { SetPlrAnims(player); @@ -2781,12 +2785,6 @@ void InitPlayer(int pnum, bool firstTime) } #ifdef _DEBUG - if (debug_mode_dollar_sign && firstTime) { - player._pMemSpells |= 1 << (SPL_TELEPORT - 1); - if (myPlayer._pSplLvl[SPL_TELEPORT] == 0) { - myPlayer._pSplLvl[SPL_TELEPORT] = 1; - } - } if (debug_mode_key_inverted_v && firstTime) { player._pMemSpells = SPL_INVALID; }