From 2b51d324f3cc2a58f2a703c23030ee19ba85836b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 22 Jan 2015 22:05:36 -0500 Subject: XEEN: Implemented dialogs for Who Will and YesNo --- engines/xeen/dialogs_error.h | 3 - engines/xeen/dialogs_whowill.cpp | 104 ++++++++++++++++++++++++++ engines/xeen/dialogs_whowill.h | 43 +++++++++++ engines/xeen/dialogs_yesno.cpp | 94 ++++++++++++++++++++++++ engines/xeen/dialogs_yesno.h | 43 +++++++++++ engines/xeen/interface.h | 1 + engines/xeen/interface_map.cpp | 13 +++- engines/xeen/interface_map.h | 6 +- engines/xeen/map.h | 2 + engines/xeen/module.mk | 2 + engines/xeen/party.cpp | 6 ++ engines/xeen/party.h | 2 + engines/xeen/resources.cpp | 14 ++++ engines/xeen/resources.h | 6 ++ engines/xeen/scripts.cpp | 154 ++++++++++++++++++++++++++------------- engines/xeen/scripts.h | 5 +- engines/xeen/xeen.cpp | 6 +- engines/xeen/xeen.h | 4 +- 18 files changed, 444 insertions(+), 64 deletions(-) create mode 100644 engines/xeen/dialogs_whowill.cpp create mode 100644 engines/xeen/dialogs_whowill.h create mode 100644 engines/xeen/dialogs_yesno.cpp create mode 100644 engines/xeen/dialogs_yesno.h diff --git a/engines/xeen/dialogs_error.h b/engines/xeen/dialogs_error.h index 03a6f16cf2..ba36f285cf 100644 --- a/engines/xeen/dialogs_error.h +++ b/engines/xeen/dialogs_error.h @@ -23,9 +23,6 @@ #ifndef XEEN_DIALOGS_ERROR_H #define XEEN_DIALOGS_ERROR_H -#include "common/array.h" -#include "common/stack.h" -#include "common/rect.h" #include "xeen/dialogs.h" namespace Xeen { diff --git a/engines/xeen/dialogs_whowill.cpp b/engines/xeen/dialogs_whowill.cpp new file mode 100644 index 0000000000..402f5c6107 --- /dev/null +++ b/engines/xeen/dialogs_whowill.cpp @@ -0,0 +1,104 @@ +/* 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/dialogs_whowill.h" +#include "xeen/resources.h" +#include "xeen/xeen.h" + +namespace Xeen { + +int WhoWill::show(XeenEngine *vm, int message, int action, bool type) { + WhoWill *dlg = new WhoWill(vm); + int result = dlg->execute(message, action, type); + delete dlg; + + return result; +} + +int WhoWill::execute(int message, int action, bool type) { + EventsManager &events = *_vm->_events; + Interface &intf = *_vm->_interface; + Map &map = *_vm->_map; + Party &party = *_vm->_party; + Screen &screen = *_vm->_screen; + Scripts &scripts = *_vm->_scripts; + int numFrames; + + if (party._partyCount <= 1) + // Unless there's at least two characters, just return the first one + return 1; + + screen._windows[38].close(); + screen._windows[12].close(); + + Common::String actionStr = type ? map._events._text[action] : WHO_WILL_ACTIONS[action]; + Common::String msg = Common::String::format(WHO_WILL, actionStr.c_str(), + WHO_ACTIONS[message], party._partyCount); + + screen._windows[36].open(); + screen._windows[36].writeString(msg); + screen._windows[36].update(); + + intf._face1State = map._headData[party._mazePosition.y][party._mazePosition.x]._left; + intf._face2State = map._headData[party._mazePosition.y][party._mazePosition.x]._right; + + while (!_vm->shouldQuit()) { + events.updateGameCounter(); + + if (screen._windows[11]._enabled) { + intf.drawTownAnim(0); + screen._windows[36].frame(); + numFrames = 3; + } else { + intf.draw3d(false); + screen._windows[36].frame(); + screen._windows[3].update(); + numFrames = 1; + } + + events.wait(numFrames, true); + if (!_buttonValue) + continue; + + if (_buttonValue == 27) { + _buttonValue = 0; + break; + } else if (_buttonValue >= 201 && _buttonValue <= 206) { + _buttonValue -= 201; + if (_buttonValue > party._partyCount) + continue; + + if (party._activeParty[_buttonValue - 1].noActions()) + continue; + + scripts._whoWill = _buttonValue; + break; + } + } + + + intf._face1State = intf._face2State = 2; + screen._windows[36].close(); + return _buttonValue; +} + +} // End of namespace Xeen diff --git a/engines/xeen/dialogs_whowill.h b/engines/xeen/dialogs_whowill.h new file mode 100644 index 0000000000..8080c36ddb --- /dev/null +++ b/engines/xeen/dialogs_whowill.h @@ -0,0 +1,43 @@ +/* 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_DIALOGS_WHOWHILL_H +#define XEEN_DIALOGS_WHOWHILL_H + +#include "xeen/dialogs.h" + +namespace Xeen { + +class WhoWill : public ButtonContainer { +private: + XeenEngine *_vm; + + WhoWill(XeenEngine *vm) : ButtonContainer(), _vm(vm) {} + + int execute(int message, int action, bool type); +public: + static int show(XeenEngine *vm, int message, int action, bool type); +}; + +} // End of namespace Xeen + +#endif /* XEEN_DIALOGS_WHOWHILL_H */ diff --git a/engines/xeen/dialogs_yesno.cpp b/engines/xeen/dialogs_yesno.cpp new file mode 100644 index 0000000000..cefafa0feb --- /dev/null +++ b/engines/xeen/dialogs_yesno.cpp @@ -0,0 +1,94 @@ +/* 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/dialogs_yesno.h" +#include "xeen/xeen.h" + +namespace Xeen { + +bool YesNo::show(XeenEngine *vm, bool type, int v2) { + YesNo *dlg = new YesNo(vm); + bool result = dlg->execute(type, v2); + delete dlg; + + return result; +} + +bool YesNo::execute(bool type, int v2) { + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + Interface &intf = *_vm->_interface; + Map &map = *_vm->_map; + Party &party = *_vm->_party; + SpriteResource confirmSprites; + int numFrames; + bool result = false; + + Mode oldMode = _vm->_mode; + _vm->_mode = oldMode == MODE_7 ? MODE_8 : MODE_7; + + if (!type) { + confirmSprites.load("confirm.icn"); + intf._globalSprites.draw(screen, 7, Common::Point(232, 74)); + confirmSprites.draw(screen, 0, Common::Point(235, 75)); + confirmSprites.draw(screen, 2, Common::Point(260, 75)); + screen._windows[34].update(); + + addButton(Common::Rect(235, 75, 259, 95), 'Y', &confirmSprites); + addButton(Common::Rect(260, 75, 284, 95), 'N', &confirmSprites); + + intf._face1State = map._headData[party._mazePosition.y][party._mazePosition.x]._left; + intf._face2State = map._headData[party._mazePosition.y][party._mazePosition.x]._right; + } + + while (!_vm->shouldQuit()) { + events.updateGameCounter(); + + if (intf._townSprites[0].empty()) { + intf.draw3d(true); + numFrames = 1; + } else { + intf.drawTownAnim(v2); + numFrames = 3; + } + + events.wait(3, true); + if (!_buttonValue) + continue; + + if (type || _buttonValue == 'Y') { + result = true; + break; + } else if (_buttonValue == 'N' || _buttonValue == Common::KEYCODE_ESCAPE) + break; + } + + intf._face1State = intf._face2State = 2; + _vm->_mode = oldMode; + + if (!type) + intf.mainIconsPrint(); + + return result; +} + +} // End of namespace Xeen diff --git a/engines/xeen/dialogs_yesno.h b/engines/xeen/dialogs_yesno.h new file mode 100644 index 0000000000..82ac402c85 --- /dev/null +++ b/engines/xeen/dialogs_yesno.h @@ -0,0 +1,43 @@ +/* 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_DIALOGS_YESNO_H +#define XEEN_DIALOGS_YESNO_H + +#include "xeen/dialogs.h" + +namespace Xeen { + +class YesNo : public ButtonContainer { +private: + XeenEngine *_vm; + + YesNo(XeenEngine *vm) : ButtonContainer(), _vm(vm) {} + + bool execute(bool type, int v2); +public: + static bool show(XeenEngine *vm, bool type, int v2); +}; + +} // End of namespace Xeen + +#endif /* XEEN_DIALOGS_YESNO_H */ diff --git a/engines/xeen/interface.h b/engines/xeen/interface.h index 28f2bbee75..7879da59ed 100644 --- a/engines/xeen/interface.h +++ b/engines/xeen/interface.h @@ -76,6 +76,7 @@ private: bool checkMoveDirection(int key); public: + SpriteResource _townSprites[8]; int _intrIndex1; public: Interface(XeenEngine *vm); diff --git a/engines/xeen/interface_map.cpp b/engines/xeen/interface_map.cpp index 70297be5af..2d2fddf4e0 100644 --- a/engines/xeen/interface_map.cpp +++ b/engines/xeen/interface_map.cpp @@ -393,6 +393,7 @@ InterfaceMap::InterfaceMap(XeenEngine *vm): _vm(vm) { _tillMove = 0; _flag1 = false; _overallFrame = 0; + _face1State = _face2State = 0; } void InterfaceMap::setup() { @@ -3852,15 +3853,15 @@ void InterfaceMap::assembleBorder() { // Handle the face UI elements for indicating clairvoyance status _face1UIFrame = (_face1UIFrame + 1) % 4; - if (_vm->_face1State == 0) + if (_face1State == 0) _face1UIFrame += 4; - else if (_vm->_face1State == 2) + else if (_face1State == 2) _face1UIFrame = 0; _face2UIFrame = (_face2UIFrame + 1) % 4 + 12; - if (_vm->_face2State == 0) + if (_face2State == 0) _face2UIFrame += 252; - else if (_vm->_face2State == 2) + else if (_face2State == 2) _face2UIFrame = 0; if (!_vm->_party->_clairvoyanceActive) { @@ -4310,4 +4311,8 @@ void InterfaceMap::drawMiniMap() { party._wizardEyeActive = eyeActive; } +void InterfaceMap::drawTownAnim(int v) { + warning("TODO"); +} + } // End of namespace Xeen diff --git a/engines/xeen/interface_map.h b/engines/xeen/interface_map.h index 0867907516..51b82a9445 100644 --- a/engines/xeen/interface_map.h +++ b/engines/xeen/interface_map.h @@ -103,7 +103,6 @@ private: void setMonsterSprite(DrawStruct &drawStruct, MazeMonster &monster, SpriteResource *sprites, int frame, int defaultY); protected: - SpriteResource _globalSprites; int8 _wp[20]; byte _wo[308]; bool _flipWater; @@ -143,8 +142,11 @@ protected: public: OutdoorDrawList _outdoorList; IndoorDrawList _indoorList; + SpriteResource _globalSprites; bool _upDoorText; Common::String _screenText; + int _face1State; + int _face2State; public: InterfaceMap(XeenEngine *vm); @@ -163,6 +165,8 @@ public: void setOutdoorsMonsters(); void setOutdoorsObjects(); + + void drawTownAnim(int v); }; } // End of namespace Xeen diff --git a/engines/xeen/map.h b/engines/xeen/map.h index 7815d143d5..58e3aaa39c 100644 --- a/engines/xeen/map.h +++ b/engines/xeen/map.h @@ -309,6 +309,8 @@ public: HeadData(); void synchronize(Common::SeekableReadStream &s); + + HeadEntry *operator[](int y) { return &_data[y][0]; } }; struct AnimationFrame { int _front, _left, _back, _right; }; diff --git a/engines/xeen/module.mk b/engines/xeen/module.mk index 6362ffe1bf..05a9b23797 100644 --- a/engines/xeen/module.mk +++ b/engines/xeen/module.mk @@ -10,6 +10,8 @@ MODULE_OBJS := \ dialogs.o \ dialogs_error.o \ dialogs_options.o \ + dialogs_whowill.o \ + dialogs_yesno.o \ events.o \ files.o \ font.o \ diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp index d465cc9975..c1c4062172 100644 --- a/engines/xeen/party.cpp +++ b/engines/xeen/party.cpp @@ -167,6 +167,12 @@ bool PlayerStruct::charSavingThrow() { return false; } +bool PlayerStruct::noActions() { + // TODO + return false; +} + + /*------------------------------------------------------------------------*/ void Roster::synchronize(Common::Serializer &s) { diff --git a/engines/xeen/party.h b/engines/xeen/party.h index c598e8c3f9..19376839af 100644 --- a/engines/xeen/party.h +++ b/engines/xeen/party.h @@ -139,6 +139,8 @@ public: int getStat(int statNum, int v2); bool charSavingThrow(); + + bool noActions(); }; class Roster: public Common::Array { diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index 085f84aa73..994762bf5b 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -68,6 +68,9 @@ const char *const OPTIONS_TITLE = const char *const THE_PARTY_NEEDS_REST = "\x0B""012The Party needs rest!"; +const char *const WHO_WILL = "\X03""c\X0B""000\x09""000%s\x0A\x0A" + "Who will\x0A%s?\x0A\x0B""055F1 - F%d"; + const char *const TERRAIN_TYPES[6] = { "town", "cave", "towr", "cstl", "dung", "scfi" }; @@ -85,6 +88,17 @@ const char *const SURFACE_NAMES[16] = { "space.srf" }; +const char *const WHO_ACTIONS[32] = { + "aSearch", "aOpen", "aDrink", "aMine", "aTouch", "aRead", "aLearn", "aTake", + "aBang", "aSteal", "aBribe", "aPay", "aSit", "aTry", "aTurn", "aBathe", + "aDestroy", "aPull", "aDescend", "aTossACoin", "aPray", "aJoin", "aAct", + "aPlay", "aPush", "aRub", "aPick", "aEat", "aSign", "aClose", "aLook", "aTry" +}; + +const char *const WHO_WILL_ACTIONS[4] = { + "Open Grate", "Open Door", "Open Scroll", "Select Char" +}; + const byte SYMBOLS[20][64] = { { // 0 0x00, 0x00, 0xA8, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0x00, 0xA8, 0x9E, 0x9C, 0x9C, 0x9E, 0x9E, 0x9E, diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h index f6bcffaf4e..28a35543b6 100644 --- a/engines/xeen/resources.h +++ b/engines/xeen/resources.h @@ -34,12 +34,18 @@ extern const char *const OPTIONS_TITLE; extern const char *const THE_PARTY_NEEDS_REST; +extern const char *const WHO_WILL; + extern const char *const TERRAIN_TYPES[6]; extern const char *const SURFACE_TYPE_NAMES[15]; extern const char *const SURFACE_NAMES[16]; +extern const char *const WHO_ACTIONS[32]; + +extern const char *const WHO_WILL_ACTIONS[4]; + extern const byte SYMBOLS[20][64]; extern const byte TEXT_COLORS[40][4]; diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index 73c0445011..4ccac8b1af 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -21,6 +21,7 @@ */ #include "xeen/scripts.h" +#include "xeen/dialogs_whowill.h" #include "xeen/party.h" #include "xeen/xeen.h" @@ -72,7 +73,8 @@ Scripts::Scripts(XeenEngine *vm) : _vm(vm) { _treasureItems = 0; _treasureGold = 0; _treasureGems = 0; - + _lineNum = 0; + _charIndex = 0; _v2 = 0; _nEdamageType = 0; _animCounter = 0; @@ -85,7 +87,7 @@ void Scripts::checkEvents() { Map &map = *_vm->_map; Party &party = *_vm->_party; - int var18 = 0; +// int var18 = 0; _itemType = 0; _var4F = 0; bool var50 = false; @@ -102,14 +104,14 @@ void Scripts::checkEvents() { do { _lineNum = 0; - int varA = 0; +// int varA = 0; _animCounter = 0; - int var4E = 0; +// int var4E = 0; const Common::Point pt = party._mazePosition; - int varC = 1; + _charIndex = 1; _v2 = 1; _nEdamageType = 0; - int var40 = -1; +// int var40 = -1; while (_lineNum >= 0) { // Break out of the events if there's an attacking monster @@ -232,6 +234,9 @@ void Scripts::cmdDoorTextLrg(Common::Array ¶ms) { cmdNoAction(params); } +/** + * Show a sign text on-screen + */ void Scripts::cmdSignText(Common::Array ¶ms) { Interface &intf = *_vm->_interface; intf._screenText = Common::String::format("\f08\x03""c\t120\v088%s\x03""l\fd", @@ -247,6 +252,9 @@ void Scripts::cmdNPC(Common::Array ¶ms) { warning("TODO: cmdNPC"); } +/** + * Play a sound FX + */ void Scripts::cmdPlayFX(Common::Array ¶ms) { _vm->_sound->playFX(params[0]); @@ -255,74 +263,118 @@ void Scripts::cmdPlayFX(Common::Array ¶ms) { } void Scripts::cmdTeleport(Common::Array ¶ms) { + error("TODO"); } +/** + * Do a conditional check + */ void Scripts::cmdIf(Common::Array ¶ms) { switch (params[0]) { case 16: case 34: case 100: + // TODO break; case 25: case 35: case 101: case 106: + // TODO break; default: break; } } -void Scripts::cmdMoveObj(Common::Array ¶ms) {} -void Scripts::cmdTakeOrGive(Common::Array ¶ms) {} +void Scripts::cmdMoveObj(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdTakeOrGive(Common::Array ¶ms) { error("TODO"); } +/** + * Move to the next line of the script + */ void Scripts::cmdNoAction(Common::Array ¶ms) { // Move to next line _lineNum = _vm->_party->_partyDead ? -1 : _lineNum + 1; } -void Scripts::cmdRemove(Common::Array ¶ms) {} -void Scripts::cmdSetChar(Common::Array ¶ms) {} -void Scripts::cmdSpawn(Common::Array ¶ms) {} -void Scripts::cmdDoTownEvent(Common::Array ¶ms) {} -void Scripts::cmdExit(Common::Array ¶ms) {} -void Scripts::cmdAfterMap(Common::Array ¶ms) {} -void Scripts::cmdGiveExtended(Common::Array ¶ms) {} -void Scripts::cmdConfirmWord(Common::Array ¶ms) {} -void Scripts::cmdDamage(Common::Array ¶ms) {} -void Scripts::cmdJumpRnd(Common::Array ¶ms) {} -void Scripts::cmdAfterEvent(Common::Array ¶ms) {} -void Scripts::cmdCallEvent(Common::Array ¶ms) {} -void Scripts::cmdReturn(Common::Array ¶ms) {} -void Scripts::cmdSetVar(Common::Array ¶ms) {} -void Scripts::cmdCutsceneEndClouds(Common::Array ¶ms) {} -void Scripts::cmdWhoWill(Common::Array ¶ms) {} -void Scripts::cmdRndDamage(Common::Array ¶ms) {} -void Scripts::cmdMoveWallObj(Common::Array ¶ms) {} -void Scripts::cmdAlterCellFlag(Common::Array ¶ms) {} -void Scripts::cmdAlterHed(Common::Array ¶ms) {} -void Scripts::cmdDisplayStat(Common::Array ¶ms) {} -void Scripts::cmdSeatTextSml(Common::Array ¶ms) {} -void Scripts::cmdPlayEventVoc(Common::Array ¶ms) {} -void Scripts::cmdDisplayBottom(Common::Array ¶ms) {} -void Scripts::cmdIfMapFlag(Common::Array ¶ms) {} -void Scripts::cmdSelRndChar(Common::Array ¶ms) {} -void Scripts::cmdGiveEnchanted(Common::Array ¶ms) {} -void Scripts::cmdItemType(Common::Array ¶ms) {} -void Scripts::cmdMakeNothingHere(Common::Array ¶ms) {} -void Scripts::cmdNoAction2(Common::Array ¶ms) {} -void Scripts::cmdChooseNumeric(Common::Array ¶ms) {} -void Scripts::cmdDisplayBottomTwoLines(Common::Array ¶ms) {} -void Scripts::cmdDisplayLarge(Common::Array ¶ms) {} -void Scripts::cmdExchObj(Common::Array ¶ms) {} -void Scripts::cmdFallToMap(Common::Array ¶ms) {} -void Scripts::cmdDisplayMain(Common::Array ¶ms) {} -void Scripts::cmdGoto(Common::Array ¶ms) {} -void Scripts::cmdConfirmWord2(Common::Array ¶ms) {} -void Scripts::cmdGotoRandom(Common::Array ¶ms) {} -void Scripts::cmdCutsceneEndDarkside(Common::Array ¶ms) {} -void Scripts::cmdCutsceneEdWorld(Common::Array ¶ms) {} -void Scripts::cmdFlipWorld(Common::Array ¶ms) {} -void Scripts::cmdPlayCD(Common::Array ¶ms) {} +void Scripts::cmdRemove(Common::Array ¶ms) { error("TODO"); } + +/** + * Set the currently active character for other script operations + */ +void Scripts::cmdSetChar(Common::Array ¶ms) { + if (params[0] != 7) { + _charIndex = WhoWill::show(_vm, 22, 3, false); + if (_charIndex == 0) { + cmdExit(params); + return; + } + } else { + _charIndex = _vm->getRandomNumber(1, _vm->_party->_partyCount); + } + + _v2 = 1; + cmdNoAction(params); +} + +void Scripts::cmdSpawn(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdDoTownEvent(Common::Array ¶ms) { error("TODO"); } + +/** + * Stop executing the script + */ +void Scripts::cmdExit(Common::Array ¶ms) { + _lineNum = -1; +} + +void Scripts::cmdAfterMap(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdGiveExtended(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdConfirmWord(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdDamage(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdJumpRnd(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdAfterEvent(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdCallEvent(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdReturn(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdSetVar(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdCutsceneEndClouds(Common::Array ¶ms) { error("TODO"); } + +void Scripts::cmdWhoWill(Common::Array ¶ms) { + _charIndex = WhoWill::show(_vm, params[0], params[1], true); + + _var4F = true; + if (_charIndex == 0) + cmdExit(params); + else + cmdNoAction(params); +} + +void Scripts::cmdRndDamage(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdMoveWallObj(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdAlterCellFlag(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdAlterHed(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdDisplayStat(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdSeatTextSml(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdPlayEventVoc(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdDisplayBottom(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdIfMapFlag(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdSelRndChar(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdGiveEnchanted(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdItemType(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdMakeNothingHere(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdNoAction2(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdChooseNumeric(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdDisplayBottomTwoLines(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdDisplayLarge(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdExchObj(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdFallToMap(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdDisplayMain(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdGoto(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdConfirmWord2(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdGotoRandom(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdCutsceneEndDarkside(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdCutsceneEdWorld(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdFlipWorld(Common::Array ¶ms) { error("TODO"); } +void Scripts::cmdPlayCD(Common::Array ¶ms) { error("TODO"); } } // End of namespace Xeen diff --git a/engines/xeen/scripts.h b/engines/xeen/scripts.h index 808566af39..2e4996e6be 100644 --- a/engines/xeen/scripts.h +++ b/engines/xeen/scripts.h @@ -121,12 +121,12 @@ class Scripts { private: XeenEngine *_vm; int _charFX[6]; - int _whoWill; int _itemType; int _treasureItems; int _treasureGold; int _treasureGems; int _lineNum; + int _charIndex; int _v2; int _var4F; @@ -134,6 +134,8 @@ private: Common::String _paramText; MazeEvent *_event; + int whoWill(int v1, int v2, int v3); + void doOpcode(MazeEvent &event); void cmdDisplay1(Common::Array ¶ms); void cmdDoorTextSml(Common::Array ¶ms); @@ -192,6 +194,7 @@ private: public: int _animCounter; bool _eventSkipped; + int _whoWill; public: Scripts(XeenEngine *vm); diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index 38026d0117..2d824e53bc 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -50,8 +50,6 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc) _eventData = nullptr; _loadDarkSide = 1; _dangerSenseAllowed = false; - _face1State = 0; - _face2State = 0; _noDirectionSense = false; _moveMonsters = false; _mode = MODE_0; @@ -128,6 +126,10 @@ int XeenEngine::getRandomNumber(int maxNumber) { return _randomSource.getRandomNumber(maxNumber); } +int XeenEngine::getRandomNumber(int minNumber, int maxNumber) { + return getRandomNumber(maxNumber - minNumber) + minNumber; +} + Common::Error XeenEngine::saveGameState(int slot, const Common::String &desc) { Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving( generateSaveName(slot)); diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h index 3e8637476a..cf872b3ede 100644 --- a/engines/xeen/xeen.h +++ b/engines/xeen/xeen.h @@ -145,8 +145,6 @@ public: Roster _roster; int _loadDarkSide; bool _dangerSenseAllowed; - int _face1State; - int _face2State; bool _noDirectionSense; bool _moveMonsters; int _openDoor; @@ -163,6 +161,8 @@ public: int getRandomNumber(int maxNumber); + int getRandomNumber(int minNumber, int maxNumber); + /** * Load a savegame */ -- cgit v1.2.3