aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanasis Antoniou2019-05-23 02:16:50 +0300
committerThanasis Antoniou2019-05-23 02:16:50 +0300
commite4b8c0f4e3911062bbbb4829d85b11be80a0e8ae (patch)
tree97843b953eb4ee9c9dc66b76d82427adc7916ab1
parentd4e5211ebbb6690356d6cf9bc56e866b5094fd83 (diff)
downloadscummvm-rg350-e4b8c0f4e3911062bbbb4829d85b11be80a0e8ae.tar.gz
scummvm-rg350-e4b8c0f4e3911062bbbb4829d85b11be80a0e8ae.tar.bz2
scummvm-rg350-e4b8c0f4e3911062bbbb4829d85b11be80a0e8ae.zip
BLADERUNNER: Debugger health command
Needed mostly to heal McCoy, or un-retire some actors
-rw-r--r--engines/bladerunner/debugger.cpp36
-rw-r--r--engines/bladerunner/debugger.h1
2 files changed, 37 insertions, 0 deletions
diff --git a/engines/bladerunner/debugger.cpp b/engines/bladerunner/debugger.cpp
index de7c22fd2e..b19dd54d99 100644
--- a/engines/bladerunner/debugger.cpp
+++ b/engines/bladerunner/debugger.cpp
@@ -108,6 +108,7 @@ Debugger::Debugger(BladeRunnerEngine *vm) : GUI::Debugger() {
_showMazeScore = false;
registerCmd("anim", WRAP_METHOD(Debugger, cmdAnimation));
+ registerCmd("health", WRAP_METHOD(Debugger, cmdHealth));
registerCmd("draw", WRAP_METHOD(Debugger, cmdDraw));
registerCmd("list", WRAP_METHOD(Debugger, cmdList));
registerCmd("flag", WRAP_METHOD(Debugger, cmdFlag));
@@ -173,6 +174,41 @@ bool Debugger::cmdAnimation(int argc, const char **argv) {
return true;
}
+bool Debugger::cmdHealth(int argc, const char **argv) {
+ if (argc != 2 && argc != 4) {
+ debugPrintf("Get or set health for the actor.\n");
+ debugPrintf("Usage: %s <actorId> [<health> <max health>]\n", argv[0]);
+ return true;
+ }
+
+ int actorId = atoi(argv[1]);
+
+ Actor *actor = nullptr;
+ if (actorId >= 0 && actorId < (int)_vm->_gameInfo->getActorCount()) {
+ actor = _vm->_actors[actorId];
+ }
+
+ if (actor == nullptr) {
+ debugPrintf("Unknown actor %i\n", actorId);
+ return true;
+ }
+
+ if (argc == 4) {
+ int currHealth = atoi(argv[2]);
+ int maxHealth = atoi(argv[3]);
+ currHealth = CLIP(currHealth, 0, 100);
+ maxHealth = CLIP(maxHealth, 0, 100);
+ if (currHealth > maxHealth) {
+ debugPrintf("Actor's current health cannot be greater than their max health\n");
+ return true;
+ }
+ actor->setHealth(currHealth, maxHealth);
+ }
+
+ debugPrintf("actor health(%i) = %i, max: %i\n", actorId, actor->getCurrentHP(), actor->getMaxHP());
+ return true;
+}
+
bool Debugger::cmdDraw(int argc, const char **argv) {
bool invalidSyntax = false;
diff --git a/engines/bladerunner/debugger.h b/engines/bladerunner/debugger.h
index 5368286bfc..a1737de007 100644
--- a/engines/bladerunner/debugger.h
+++ b/engines/bladerunner/debugger.h
@@ -90,6 +90,7 @@ public:
~Debugger();
bool cmdAnimation(int argc, const char **argv);
+ bool cmdHealth(int argc, const char **argv);
bool cmdChapter(int argc, const char **argv);
bool cmdDraw(int argc, const char **argv);
bool cmdFlag(int argc, const char **argv);