Skip to content
Permalink
Browse files

BLADERUNNER: Debugger health command

Needed mostly to heal McCoy, or un-retire some actors
  • Loading branch information...
antoniou79 committed May 22, 2019
1 parent d4e5211 commit e4b8c0f4e3911062bbbb4829d85b11be80a0e8ae
Showing with 37 additions and 0 deletions.
  1. +36 −0 engines/bladerunner/debugger.cpp
  2. +1 −0 engines/bladerunner/debugger.h
@@ -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;

@@ -90,6 +90,7 @@ class Debugger : public GUI::Debugger{
~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);

0 comments on commit e4b8c0f

Please sign in to comment.
You can’t perform that action at this time.