diff options
-rw-r--r-- | engines/bladerunner/debugger.cpp | 36 | ||||
-rw-r--r-- | engines/bladerunner/debugger.h | 1 |
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); |