aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/xeen/module.mk1
-rw-r--r--engines/xeen/resources.cpp2
-rw-r--r--engines/xeen/resources.h2
-rw-r--r--engines/xeen/scripts.cpp88
-rw-r--r--engines/xeen/scripts.h11
-rw-r--r--engines/xeen/spells.cpp40
-rw-r--r--engines/xeen/spells.h46
-rw-r--r--engines/xeen/xeen.cpp3
-rw-r--r--engines/xeen/xeen.h2
9 files changed, 160 insertions, 35 deletions
diff --git a/engines/xeen/module.mk b/engines/xeen/module.mk
index ea6ea8c073..c5348442ec 100644
--- a/engines/xeen/module.mk
+++ b/engines/xeen/module.mk
@@ -26,6 +26,7 @@ MODULE_OBJS := \
screen.o \
scripts.o \
sound.o \
+ spells.o \
sprites.o \
xeen.o \
xsurface.o
diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp
index 26c33cad11..0f48073044 100644
--- a/engines/xeen/resources.cpp
+++ b/engines/xeen/resources.cpp
@@ -75,6 +75,8 @@ const char *const WHATS_THE_PASSWORD = "What's the Password?";
const char *const IN_NO_CONDITION = "\x0B""007%s is not in any condition to perform actions!";
+const char *const NOTHING_HERE = "\x03""c\x0B""010Nothing here.";
+
const char *const TERRAIN_TYPES[6] = {
"town", "cave", "towr", "cstl", "dung", "scfi"
};
diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h
index 2e77e95dbb..8537835630 100644
--- a/engines/xeen/resources.h
+++ b/engines/xeen/resources.h
@@ -40,6 +40,8 @@ extern const char *const WHATS_THE_PASSWORD;
extern const char *const IN_NO_CONDITION;
+extern const char *const NOTHING_HERE;
+
extern const char *const TERRAIN_TYPES[6];
extern const char *const SURFACE_TYPE_NAMES[15];
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index 6355c1cd2f..665fd0d632 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -96,25 +96,30 @@ Scripts::Scripts(XeenEngine *vm) : _vm(vm) {
_treasureGems = 0;
_lineNum = 0;
_charIndex = 0;
- _v2 = 0;
+ _v2 = false;
_nEdamageType = 0;
_animCounter = 0;
_eventSkipped = false;
_mirrorId = -1;
_refreshIcons = false;
+ _scriptResult = false;
+ _scriptExecuted = false;
+ _var50 = false;
}
-void Scripts::checkEvents() {
+bool Scripts::checkEvents() {
Combat &combat = *_vm->_combat;
+ EventsManager &events = *_vm->_events;
Interface &intf = *_vm->_interface;
Map &map = *_vm->_map;
Party &party = *_vm->_party;
Screen &screen = *_vm->_screen;
+ SoundManager &sound = *_vm->_sound;
_refreshIcons = false;
_itemType = 0;
- _var4F = 0;
- bool var50 = false;
+ _scriptExecuted = false;
+ _var50 = false;
_whoWill = 0;
Mode oldMode = _vm->_mode;
Common::fill(&_charFX[0], &_charFX[MAX_ACTIVE_PARTY], 0);
@@ -128,12 +133,12 @@ void Scripts::checkEvents() {
do {
_lineNum = 0;
-// int varA = 0;
+ _scriptResult = false;
_animCounter = 0;
// int var4E = 0;
_currentPos = party._mazePosition;
_charIndex = 1;
- _v2 = 1;
+ _v2 = true;
_nEdamageType = 0;
// int var40 = -1;
@@ -156,7 +161,7 @@ void Scripts::checkEvents() {
doOpcode(event);
break;
} else {
- var50 = true;
+ _var50 = true;
}
}
}
@@ -172,6 +177,35 @@ void Scripts::checkEvents() {
}
// TODO
+
+ _animCounter = 0;
+ _vm->_mode = oldMode;
+ screen.closeWindows();
+
+ if (_scriptExecuted || !intf._objNumber || _var50) {
+ if (_var50 && !_scriptExecuted && intf._objNumber && !map._currentIsEvent) {
+ sound.playFX(21);
+ }
+ } else {
+ Window &w = screen._windows[38];
+ w.open();
+ w.writeString(NOTHING_HERE);
+ w.update();
+
+ do {
+ intf.draw3d(true);
+ events.updateGameCounter();
+ events.wait(1, true);
+ } while (!events.isKeyMousePressed());
+ events.clearEvents();
+
+ w.close();
+ }
+
+ _v2 = true;
+ Common::fill(&_charFX[0], &_charFX[6], 0);
+
+ return _scriptResult;
}
void Scripts::giveTreasure() {
@@ -231,7 +265,6 @@ void Scripts::cmdDisplay1(Common::Array<byte> &params) {
screen._windows[38].writeString(msg);
screen._windows[38].update();
- _var4F = true;
cmdNoAction(params);
}
@@ -247,7 +280,6 @@ void Scripts::cmdDoorTextSml(Common::Array<byte> &params) {
intf._upDoorText = true;
intf.draw3d(true);
- _var4F = true;
cmdNoAction(params);
}
@@ -263,7 +295,6 @@ void Scripts::cmdDoorTextLrg(Common::Array<byte> &params) {
intf._upDoorText = true;
intf.draw3d(true);
- _var4F = true;
cmdNoAction(params);
}
@@ -279,7 +310,6 @@ void Scripts::cmdSignText(Common::Array<byte> &params) {
intf._upDoorText = true;
intf.draw3d(true);
- _var4F = true;
cmdNoAction(params);
}
@@ -293,7 +323,6 @@ void Scripts::cmdNPC(Common::Array<byte> &params) {
void Scripts::cmdPlayFX(Common::Array<byte> &params) {
_vm->_sound->playFX(params[0]);
- _var4F = true;
cmdNoAction(params);
}
@@ -306,7 +335,6 @@ void Scripts::cmdTeleport(Common::Array<byte> &params) {
SoundManager &sound = *_vm->_sound;
screen.closeWindows();
- _var4F = true;
int mapId;
Common::Point pt;
@@ -407,7 +435,6 @@ void Scripts::cmdIf(Common::Array<byte> &params) {
if (result)
_lineNum = newLineNum - 1;
- _var4F = true;
cmdNoAction(params);
}
@@ -463,7 +490,7 @@ void Scripts::cmdSetChar(Common::Array<byte> &params) {
_charIndex = _vm->getRandomNumber(1, _vm->_party->_partyCount);
}
- _v2 = 1;
+ _v2 = true;
cmdNoAction(params);
}
@@ -484,11 +511,15 @@ void Scripts::cmdSpawn(Common::Array<byte> &params) {
monster._isAttacking = params[1] != 0;
monster._hp = monsterData._hp;
- _var4F = 1;
cmdNoAction(params);
}
-void Scripts::cmdDoTownEvent(Common::Array<byte> &params) { error("TODO"); }
+void Scripts::cmdDoTownEvent(Common::Array<byte> &params) {
+ _scriptResult = doTownEvent(params[0]);
+ _vm->_party->_stepped = true;
+
+ cmdExit(params);
+}
/**
* Stop executing the script
@@ -510,7 +541,6 @@ void Scripts::cmdAlterMap(Common::Array<byte> &params) {
map.setWall(Common::Point(params[0], params[1]), (Direction)params[2], params[3]);
}
- _var4F = true;
cmdNoAction(params);
}
@@ -554,7 +584,6 @@ void Scripts::cmdGiveExtended(Common::Array<byte> &params) {
if (result)
_lineNum = newLineNum - 1;
- _var4F = true;
cmdNoAction(params);
}
@@ -610,7 +639,6 @@ void Scripts::cmdConfirmWord(Common::Array<byte> &params) {
}
}
- _var4F = true;
cmdNoAction(params);
}
@@ -624,7 +652,6 @@ void Scripts::cmdJumpRnd(Common::Array<byte> &params) {
if (v == params[1])
_lineNum = params[2] - 1;
- _var4F = true;
cmdNoAction(params);
}
@@ -644,7 +671,6 @@ void Scripts::cmdAlterEvent(Common::Array<byte> &params) {
}
}
- _var4F = true;
cmdNoAction(params);
}
@@ -657,7 +683,6 @@ void Scripts::cmdCallEvent(Common::Array<byte> &params) {
_currentPos = Common::Point(params[0], params[1]);
_lineNum = params[2] - 1;
- _var4F = true;
cmdNoAction(params);
}
@@ -670,7 +695,6 @@ void Scripts::cmdReturn(Common::Array<byte> &params) {
_currentPos = se;
_lineNum = se.line;
- _var4F = true;
cmdNoAction(params);
}
@@ -707,7 +731,6 @@ void Scripts::cmdSetVar(Common::Array<byte> &params) {
}
}
- _var4F = true;
cmdNoAction(params);
}
@@ -716,7 +739,6 @@ void Scripts::cmdCutsceneEndClouds(Common::Array<byte> &params) { error("TODO");
void Scripts::cmdWhoWill(Common::Array<byte> &params) {
_charIndex = WhoWill::show(_vm, params[0], params[1], true);
- _var4F = true;
if (_charIndex == 0)
cmdExit(params);
else
@@ -751,7 +773,6 @@ void Scripts::cmdMakeNothingHere(Common::Array<byte> &params) {
evt._opcode = OP_None;
}
- _var4F = true;
cmdExit(params);
}
@@ -777,7 +798,6 @@ void Scripts::cmdExchObj(Common::Array<byte> &params) {
obj1._position = obj2._position;
obj2._position = pt;
- _var4F = true;
cmdNoAction(params);
}
@@ -787,7 +807,6 @@ void Scripts::cmdFallToMap(Common::Array<byte> &params) {
party._fallPosition = Common::Point(params[1], params[2]);
party._fallDamage = params[3];
- _var4F = true;
_lineNum = -1;
}
@@ -806,7 +825,6 @@ void Scripts::cmdGoto(Common::Array<byte> &params) {
if (params[0] == map._currentSurfaceId)
_lineNum = params[1] - 1;
- _var4F = true;
cmdNoAction(params);
}
@@ -815,7 +833,6 @@ void Scripts::cmdGoto(Common::Array<byte> &params) {
*/
void Scripts::cmdGotoRandom(Common::Array<byte> &params) {
_lineNum = params[_vm->getRandomNumber(1, params[0])] - 1;
- _var4F = true;
cmdNoAction(params);
}
@@ -1254,6 +1271,15 @@ bool Scripts::ifProc(int action, uint32 mask, int mode, int charIndex) {
}
}
+bool Scripts::doTownEvent(int actionId) {
+ if (actionId == 12)
+ return false;
+
+
+
+ return false;
+}
+
bool Scripts::copyProtectionCheck() {
// Currentl not implemented
return true;
diff --git a/engines/xeen/scripts.h b/engines/xeen/scripts.h
index 72ddfbc6ec..44290eef47 100644
--- a/engines/xeen/scripts.h
+++ b/engines/xeen/scripts.h
@@ -148,9 +148,10 @@ private:
int _charIndex;
int _mirrorId;
int _refreshIcons;
-
- int _v2;
- int _var4F;
+ int _scriptResult;
+ bool _v2;
+ bool _scriptExecuted;
+ bool _var50;
MazeEvent *_event;
Common::Point _currentPos;
Common::Stack<StackEntry> _stack;
@@ -222,6 +223,8 @@ private:
bool ifProc(int action, uint32 mask, int mode, int charIndex);
+ bool doTownEvent(int actionId);
+
bool copyProtectionCheck();
public:
int _animCounter;
@@ -232,7 +235,7 @@ public:
public:
Scripts(XeenEngine *vm);
- void checkEvents();
+ bool checkEvents();
void giveTreasure();
diff --git a/engines/xeen/spells.cpp b/engines/xeen/spells.cpp
new file mode 100644
index 0000000000..8a5126c381
--- /dev/null
+++ b/engines/xeen/spells.cpp
@@ -0,0 +1,40 @@
+/* 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 "xeen/spells.h"
+#include "xeen/files.h"
+#include "xeen/xeen.h"
+
+namespace Xeen {
+
+Spells::Spells(XeenEngine *vm) : _vm(vm) {
+ load();
+}
+
+void Spells::load() {
+ File f("spells.xen");
+ while (f.pos() < f.size())
+ _spellNames.push_back(f.readString());
+ f.close();
+}
+
+} // End of namespace Xeen
diff --git a/engines/xeen/spells.h b/engines/xeen/spells.h
new file mode 100644
index 0000000000..adb957c26a
--- /dev/null
+++ b/engines/xeen/spells.h
@@ -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.
+ *
+ */
+
+#ifndef XEEN_SPELLS_H
+#define XEEN_SPELLS_H
+
+#include "common/scummsys.h"
+#include "common/str-array.h"
+
+namespace Xeen {
+
+class XeenEngine;
+
+class Spells {
+private:
+ XeenEngine *_vm;
+
+ void load();
+public:
+ Common::StringArray _spellNames;
+public:
+ Spells(XeenEngine *vm);
+};
+
+} // End of namespace Xeen
+
+#endif /* XEEN_SPELLS_H */
diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp
index 8489f86ed5..8879b15a0d 100644
--- a/engines/xeen/xeen.cpp
+++ b/engines/xeen/xeen.cpp
@@ -47,6 +47,7 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc)
_screen = nullptr;
_scripts = nullptr;
_sound = nullptr;
+ _spells = nullptr;
_eventData = nullptr;
_dangerSenseAllowed = false;
_noDirectionSense = false;
@@ -67,6 +68,7 @@ XeenEngine::~XeenEngine() {
delete _screen;
delete _scripts;
delete _sound;
+ delete _spells;
delete _eventData;
delete _files;
}
@@ -91,6 +93,7 @@ void XeenEngine::initialize() {
_scripts = new Scripts(this);
_screen->setupWindows();
_sound = new SoundManager(this);
+ _spells = new Spells(this);
File f("029.obj");
_eventData = f.readStream(f.size());
diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h
index b60908ddfe..38c7beb057 100644
--- a/engines/xeen/xeen.h
+++ b/engines/xeen/xeen.h
@@ -43,6 +43,7 @@
#include "xeen/screen.h"
#include "xeen/scripts.h"
#include "xeen/sound.h"
+#include "xeen/spells.h"
/**
* This is the namespace of the Xeen engine.
@@ -140,6 +141,7 @@ public:
Screen *_screen;
Scripts *_scripts;
SoundManager *_sound;
+ Spells *_spells;
Treasure _treasure;
Mode _mode;
GameEvent _gameEvent;