aboutsummaryrefslogtreecommitdiff
path: root/engines/griffon
diff options
context:
space:
mode:
authorEugene Sandulenko2019-01-08 00:05:11 +0100
committerEugene Sandulenko2019-11-13 22:07:08 +0100
commit5c4016b4820cced49c3d56e4ef2c626acc511ec2 (patch)
tree15e160e0a73911fdc781abf4b83776ca0de8b56f /engines/griffon
parent62066b530fca62ab7a8c3f646e6b5e1a7399e90c (diff)
downloadscummvm-rg350-5c4016b4820cced49c3d56e4ef2c626acc511ec2.tar.gz
scummvm-rg350-5c4016b4820cced49c3d56e4ef2c626acc511ec2.tar.bz2
scummvm-rg350-5c4016b4820cced49c3d56e4ef2c626acc511ec2.zip
GRIFFON: Implemented cheat mode via debug console
Diffstat (limited to 'engines/griffon')
-rw-r--r--engines/griffon/console.cpp46
-rw-r--r--engines/griffon/console.h41
-rw-r--r--engines/griffon/engine.cpp16
-rw-r--r--engines/griffon/griffon.cpp5
-rw-r--r--engines/griffon/griffon.h4
-rw-r--r--engines/griffon/module.mk1
6 files changed, 112 insertions, 1 deletions
diff --git a/engines/griffon/console.cpp b/engines/griffon/console.cpp
new file mode 100644
index 0000000000..e055bc2416
--- /dev/null
+++ b/engines/griffon/console.cpp
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "gui/debugger.h"
+
+#include "griffon/console.h"
+
+namespace Griffon {
+
+Console::Console() {
+ _godMode = false;
+ registerCmd("godmode", WRAP_METHOD(Console, Cmd_godMode));
+}
+
+bool Console::Cmd_godMode(int argc, const char** argv) {
+ if (argc != 1) {
+ debugPrintf("Usage: %s\n", argv[0]);
+ debugPrintf("Enables/Disables invincibility and megadamage\n");
+ return true;
+ }
+
+ _godMode ^= true;
+ debugPrintf("God mode is now %s\n", _godMode ? "Enabled" : "Disabled");
+ return true;
+}
+
+} // End of namespace Plumbers
diff --git a/engines/griffon/console.h b/engines/griffon/console.h
new file mode 100644
index 0000000000..4709b7e7f9
--- /dev/null
+++ b/engines/griffon/console.h
@@ -0,0 +1,41 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+#ifndef GRIFFON_CONSOLE_H
+#define GRIFFON_CONSOLE_H
+
+#include "gui/debugger.h"
+
+namespace Griffon {
+
+class Console : public GUI::Debugger {
+public:
+ bool _godMode;
+
+ explicit Console();
+ virtual ~Console(void) {}
+
+ bool Cmd_godMode(int argc, const char** argv);
+};
+}
+
+#endif
diff --git a/engines/griffon/engine.cpp b/engines/griffon/engine.cpp
index cc1fe2b628..3f32486dc8 100644
--- a/engines/griffon/engine.cpp
+++ b/engines/griffon/engine.cpp
@@ -36,6 +36,7 @@
#include "griffon/griffon.h"
#include "griffon/config.h"
+#include "griffon/console.h"
#include "common/events.h"
#include "common/file.h"
@@ -936,6 +937,10 @@ void GriffonEngine::game_checkhit() {
if (ps > 1)
ps = ps * 0.75;
damage = (float)player.sworddamage * (1.0 + RND() * 1.0) * player.attackstrength / 100.0 * ps;
+
+ if (_console->_godMode)
+ damage = 1000;
+
if (player.attackstrength == 100)
damage = damage * 1.5;
@@ -1004,6 +1009,9 @@ void GriffonEngine::game_checkinputs() {
if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
if (itemticks < ticks)
game_title(1);
+ } else if (event.kbd.keycode == Common::KEYCODE_d && event.kbd.hasFlags(Common::KBD_CTRL)) {
+ _console->attach();
+ event.type = Common::EVENT_INVALID;
} else if (event.kbd.hasFlags(Common::KBD_CTRL)) {
if (itemselon == 0 && itemticks < ticks)
game_attack();
@@ -2118,7 +2126,9 @@ void GriffonEngine::game_damagenpc(int npcnum, int damage, int spell) {
void GriffonEngine::game_damageplayer(int damage) {
char line[256];
- player.hp -= damage;
+ if (!_console->_godMode)
+ player.hp -= damage;
+
if (player.hp < 0)
player.hp = 0;
@@ -3822,6 +3832,8 @@ void GriffonEngine::game_loadmap(int mapnum) {
char name[256];
int tempmap[320][200];
+ debug(2, "Loaded map %d", mapnum);
+
ccc = clipbg->format.RGBToColor(255, 255, 255);
curmap = mapnum;
@@ -4838,6 +4850,8 @@ void GriffonEngine::game_playgame() {
game_updmusic();
+ _console->onFrame();
+
sys_update();
} while (!_shouldQuit);
}
diff --git a/engines/griffon/griffon.cpp b/engines/griffon/griffon.cpp
index 17cb048ac2..f1ba852659 100644
--- a/engines/griffon/griffon.cpp
+++ b/engines/griffon/griffon.cpp
@@ -31,6 +31,7 @@
#include "engines/util.h"
#include "griffon/griffon.h"
+#include "griffon/console.h"
namespace Griffon {
@@ -40,6 +41,8 @@ GriffonEngine::GriffonEngine(OSystem *syst) : Engine(syst) {
_rnd = new Common::RandomSource("griffon");
+ _console = nullptr;
+
_shouldQuit = false;
}
@@ -50,6 +53,8 @@ GriffonEngine::~GriffonEngine() {
Common::Error GriffonEngine::run() {
initGraphics(320, 240, new Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
+ _console = new Console();
+
griffon_main();
return Common::kNoError;
diff --git a/engines/griffon/griffon.h b/engines/griffon/griffon.h
index 9e4b4995bc..d8e323b057 100644
--- a/engines/griffon/griffon.h
+++ b/engines/griffon/griffon.h
@@ -44,6 +44,8 @@
namespace Griffon {
+class Console;
+
#define kMaxNPC 32
#define kMaxFloat 32
#define kMaxSpell 32
@@ -241,6 +243,8 @@ private:
Common::RandomSource *_rnd;
bool _shouldQuit;
+ Console *_console;
+
private:
void griffon_main();
diff --git a/engines/griffon/module.mk b/engines/griffon/module.mk
index 7df4e2e102..de09712b88 100644
--- a/engines/griffon/module.mk
+++ b/engines/griffon/module.mk
@@ -2,6 +2,7 @@ MODULE := engines/griffon
MODULE_OBJS := \
config.o \
+ console.o \
engine.o \
griffon.o \
detection.o \