From 9fd43ba6cca192cd7a1ca202e2f2db5b20eff981 Mon Sep 17 00:00:00 2001 From: Arnaud Boutonné Date: Mon, 20 Dec 2010 00:18:03 +0000 Subject: HUGO: Add god mode to H1 Dos and H2 Dos svn-id: r54970 --- engines/hugo/parser_v1d.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 4 deletions(-) (limited to 'engines/hugo/parser_v1d.cpp') diff --git a/engines/hugo/parser_v1d.cpp b/engines/hugo/parser_v1d.cpp index 9aab521a18..ce57222317 100644 --- a/engines/hugo/parser_v1d.cpp +++ b/engines/hugo/parser_v1d.cpp @@ -39,6 +39,7 @@ #include "hugo/file.h" #include "hugo/schedule.h" #include "hugo/util.h" +#include "hugo/sound.h" #include "hugo/object.h" namespace Hugo { @@ -302,13 +303,62 @@ bool Parser_v1d::isCatchallVerb(bool testNounFl, char *noun, char *verb, objectL void Parser_v1d::lineHandler() { debugC(1, kDebugParser, "lineHandler()"); - object_t *obj; status_t &gameStatus = _vm->getGameStatus(); - char farComment[XBYTES * 5] = ""; // hold 5 line comment if object not nearby -// Reset_prompt_line (); + // Toggle God Mode + if (!strncmp(_line, "PPG", 3)) { + _vm->_sound->playSound(!_vm->_soundTest, BOTH_CHANNELS, HIGH_PRI); + gameStatus.godModeFl = !gameStatus.godModeFl; + return; + } + Utils::strlwr(_line); // Convert to lower case + // God Mode cheat commands: + // goto Takes hero to named screen + // fetch Hero carries named object + // fetch all Hero carries all possible objects + // find Takes hero to screen containing named object + if (gameStatus.godModeFl) { + // Special code to allow me to go straight to any screen + if (strstr(_line, "goto")) { + for (int i = 0; i < _vm->_numScreens; i++) { + if (!scumm_stricmp(&_line[strlen("goto") + 1], _vm->_screenNames[i])) { + _vm->_scheduler->newScreen(i); + return; + } + } + } + + // Special code to allow me to get objects from anywhere + if (strstr(_line, "fetch all")) { + for (int i = 0; i < _vm->_object->_numObj; i++) { + if (_vm->_object->_objects[i].genericCmd & TAKE) + takeObject(&_vm->_object->_objects[i]); + } + return; + } + + if (strstr(_line, "fetch")) { + for (int i = 0; i < _vm->_object->_numObj; i++) { + if (!scumm_stricmp(&_line[strlen("fetch") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) { + takeObject(&_vm->_object->_objects[i]); + return; + } + } + } + + // Special code to allow me to goto objects + if (strstr(_line, "find")) { + for (int i = 0; i < _vm->_object->_numObj; i++) { + if (!scumm_stricmp(&_line[strlen("find") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) { + _vm->_scheduler->newScreen(_vm->_object->_objects[i].screenIndex); + return; + } + } + } + } + if (!strcmp("exit", _line) || strstr(_line, "quit")) { if (Utils::Box(BOX_YESNO, "%s", _vm->_textParser[kTBExit_1d]) != 0) _vm->endGame(); @@ -345,13 +395,14 @@ void Parser_v1d::lineHandler() { // Find the first verb in the line char *verb = findVerb(); char *noun = 0; // Noun not found yet + char farComment[XBYTES * 5] = ""; // hold 5 line comment if object not nearby if (verb) { // OK, verb found. Try to match with object do { noun = findNextNoun(noun); // Find a noun in the line // Must try at least once for objects allowing verb-context for (int i = 0; i < _vm->_object->_numObj; i++) { - obj = &_vm->_object->_objects[i]; + object_t *obj = &_vm->_object->_objects[i]; if (isNear(verb, noun, obj, farComment)) { if (isObjectVerb(verb, obj) // Foreground object || isGenericVerb(verb, obj)) // Common action type -- cgit v1.2.3