aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen
diff options
context:
space:
mode:
authorPaul Gilbert2018-01-20 18:32:46 -0500
committerPaul Gilbert2018-01-20 18:32:46 -0500
commita8377334b7ad10704920bbb2481e1f41dcdbc242 (patch)
treeea516b59f51cd3b91e9e694db00dc4d3189ff815 /engines/xeen
parent1bff4cf444ddc19c6ea9718a7c3d6f50046851ed (diff)
downloadscummvm-rg350-a8377334b7ad10704920bbb2481e1f41dcdbc242.tar.gz
scummvm-rg350-a8377334b7ad10704920bbb2481e1f41dcdbc242.tar.bz2
scummvm-rg350-a8377334b7ad10704920bbb2481e1f41dcdbc242.zip
XEEN: Add invincible debugger command
Diffstat (limited to 'engines/xeen')
-rw-r--r--engines/xeen/character.cpp15
-rw-r--r--engines/xeen/character.h5
-rw-r--r--engines/xeen/combat.cpp8
-rw-r--r--engines/xeen/debugger.cpp10
-rw-r--r--engines/xeen/debugger.h7
5 files changed, 41 insertions, 4 deletions
diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp
index e95bf6d4c8..b2cf11d0cb 100644
--- a/engines/xeen/character.cpp
+++ b/engines/xeen/character.cpp
@@ -1287,7 +1287,7 @@ void Character::setValue(int id, uint value) {
// Set condition
if (value == 16) {
// Clear all the conditions
- Common::fill(&_conditions[CURSED], &_conditions[NO_CONDITION], false);
+ clearConditions();
} else if (value == 6) {
_conditions[value] = 1;
} else {
@@ -1785,7 +1785,14 @@ void Character::addHitPoints(int amount) {
}
void Character::subtractHitPoints(int amount) {
- Sound &sound = *Party::_vm->_sound;
+ Debugger &debugger = *g_vm->_debugger;
+ Sound &sound = *g_vm->_sound;
+
+ // If invincibility is turned on in the debugger, ignore all damage
+ if (debugger._invincible)
+ return;
+
+ // Subtract the given HP amount
_currentHp -= amount;
bool flag = _currentHp <= 10;
@@ -1847,4 +1854,8 @@ int Character::getClassCategory() const {
}
}
+void Character::clearConditions() {
+ Common::fill(&_conditions[CURSED], &_conditions[NO_CONDITION], false);
+}
+
} // End of namespace Xeen
diff --git a/engines/xeen/character.h b/engines/xeen/character.h
index 2db5734909..1e13c36260 100644
--- a/engines/xeen/character.h
+++ b/engines/xeen/character.h
@@ -529,6 +529,11 @@ public:
* Returns a category index for a character, used such for indexing into spell data
*/
int getClassCategory() const;
+
+ /**
+ * Clears the character of any currently set conditions
+ */
+ void clearConditions();
};
} // End of namespace Xeen
diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp
index 7b50ae8bf5..219652c976 100644
--- a/engines/xeen/combat.cpp
+++ b/engines/xeen/combat.cpp
@@ -267,6 +267,7 @@ loop:
}
void Combat::doCharDamage(Character &c, int charNum, int monsterDataIndex) {
+ Debugger &debugger = *g_vm->_debugger;
EventsManager &events = *_vm->_events;
Interface &intf = *_vm->_interface;
Map &map = *_vm->_map;
@@ -434,7 +435,12 @@ void Combat::doCharDamage(Character &c, int charNum, int monsterDataIndex) {
break;
}
- c.subtractHitPoints(damage);
+ if (debugger._invincible)
+ // Invincibility mode is on, so reset conditions that were set
+ c.clearConditions();
+ else
+ // Standard gameplay, deal out the damage
+ c.subtractHitPoints(damage);
}
events.ipause(2);
diff --git a/engines/xeen/debugger.cpp b/engines/xeen/debugger.cpp
index 24cb947ef4..4efd18137a 100644
--- a/engines/xeen/debugger.cpp
+++ b/engines/xeen/debugger.cpp
@@ -44,7 +44,8 @@ static int strToInt(const char *s) {
/*------------------------------------------------------------------------*/
-Debugger::Debugger(XeenEngine *vm) : GUI::Debugger(), _vm(vm) {
+Debugger::Debugger(XeenEngine *vm) : GUI::Debugger(), _vm(vm),
+ _invincible(false) {
registerCmd("continue", WRAP_METHOD(Debugger, cmdExit));
registerCmd("spell", WRAP_METHOD(Debugger, cmdSpell));
registerCmd("spells", WRAP_METHOD(Debugger, cmdSpells));
@@ -53,6 +54,7 @@ Debugger::Debugger(XeenEngine *vm) : GUI::Debugger(), _vm(vm) {
registerCmd("gems", WRAP_METHOD(Debugger, cmdGems));
registerCmd("map", WRAP_METHOD(Debugger, cmdMap));
registerCmd("pos", WRAP_METHOD(Debugger, cmdPos));
+ registerCmd("invincible", WRAP_METHOD(Debugger, cmdInvincible));
_spellId = -1;
}
@@ -192,4 +194,10 @@ bool Debugger::cmdPos(int argc, const char **argv) {
}
}
+bool Debugger::cmdInvincible(int argc, const char **argv) {
+ _invincible = (argc < 2) || strcmp(argv[1], "off");
+ debugPrintf("Invincibility is %s\n", _invincible ? "on" : "off");
+ return true;
+}
+
} // End of namespace Xeen
diff --git a/engines/xeen/debugger.h b/engines/xeen/debugger.h
index 6841d606e1..b7e1f1c325 100644
--- a/engines/xeen/debugger.h
+++ b/engines/xeen/debugger.h
@@ -69,6 +69,13 @@ private:
* Changes the party's position in the current map
*/
bool cmdPos(int argc, const char **argv);
+
+ /**
+ * Flags whether to make the party invincible
+ */
+ bool cmdInvincible(int argc, const char **argv);
+public:
+ bool _invincible;
public:
Debugger(XeenEngine *vm);