Browse Source

Clean up god mode

pull/2643/head
Anders Jenbo 5 years ago
parent
commit
4c6a5bab56
  1. 5
      Source/debug.cpp
  2. 1
      Source/debug.h
  3. 6
      Source/diablo.cpp
  4. 1
      Source/diablo.h
  5. 76
      Source/missiles.cpp
  6. 2
      Source/monster.cpp
  7. 24
      Source/player.cpp

5
Source/debug.cpp

@ -18,6 +18,7 @@
namespace devilution {
std::optional<CelSprite> 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.";
}

1
Source/debug.h

@ -14,6 +14,7 @@
namespace devilution {
extern std::optional<CelSprite> pSquareCel;
extern bool DebugGodMode;
void FreeDebugGFX();
void LoadDebugGFX();

6
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) {

1
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

76
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;

2
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();

24
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;
}

Loading…
Cancel
Save