diff options
author | Paul Gilbert | 2015-01-21 20:42:44 -0500 |
---|---|---|
committer | Paul Gilbert | 2015-01-21 20:42:44 -0500 |
commit | 932222de7dd32ff0a0b643a2e9d756160bff27bf (patch) | |
tree | 3be023b947f38976ce24640676d51b98710f48e9 | |
parent | 69ca508e8fd16e79bfa5a0f66ced3ccf9fb2dbf8 (diff) | |
download | scummvm-rg350-932222de7dd32ff0a0b643a2e9d756160bff27bf.tar.gz scummvm-rg350-932222de7dd32ff0a0b643a2e9d756160bff27bf.tar.bz2 scummvm-rg350-932222de7dd32ff0a0b643a2e9d756160bff27bf.zip |
XEEN: Skeleton beginnings of script handling
-rw-r--r-- | engines/xeen/files.cpp | 11 | ||||
-rw-r--r-- | engines/xeen/files.h | 2 | ||||
-rw-r--r-- | engines/xeen/interface.cpp | 4 | ||||
-rw-r--r-- | engines/xeen/interface.h | 3 | ||||
-rw-r--r-- | engines/xeen/map.cpp | 5 | ||||
-rw-r--r-- | engines/xeen/scripts.cpp | 161 | ||||
-rw-r--r-- | engines/xeen/scripts.h | 78 |
7 files changed, 257 insertions, 7 deletions
diff --git a/engines/xeen/files.cpp b/engines/xeen/files.cpp index f8e7a3fc0c..0c3402f00d 100644 --- a/engines/xeen/files.cpp +++ b/engines/xeen/files.cpp @@ -232,4 +232,15 @@ void File::openFile(const Common::String &filename, Common::Archive &archive) { error("Could not open file - %s", filename.c_str()); } +Common::String File::readString() { + Common::String result; + char c; + + while (pos() < size() && (c = (char)readByte()) != '\0') + result += c; + + return result; +} + + } // End of namespace Xeen diff --git a/engines/xeen/files.h b/engines/xeen/files.h index f350e34166..f0c92d1050 100644 --- a/engines/xeen/files.h +++ b/engines/xeen/files.h @@ -75,6 +75,8 @@ public: void openFile(const Common::String &filename); void openFile(const Common::String &filename, Common::Archive &archive); + + Common::String readString(); }; class XeenSerializer : public Common::Serializer { diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp index d2fea36872..e31b9e240a 100644 --- a/engines/xeen/interface.cpp +++ b/engines/xeen/interface.cpp @@ -43,7 +43,6 @@ Interface::Interface(XeenEngine *vm) : ButtonContainer(), InterfaceMap(vm), _vm( _hiliteChar = -1; _intrIndex1 = 0; _flag1 = false; - _animCounter = 0; _isAnimReset = false; _tillMove = 0; _overallFrame = 0; @@ -542,6 +541,7 @@ void Interface::draw3d(bool updateFlag) { Map &map = *_vm->_map; Party &party = *_vm->_party; Screen &screen = *_vm->_screen; + Scripts &scripts = *_vm->_scripts; if (screen._windows[11]._enabled) return; @@ -570,7 +570,7 @@ void Interface::draw3d(bool updateFlag) { mazeObject._frame = animEntry._frame1._frames[directionIndex]; } else { ++mazeObject._frame; - if ((int)idx == objNum && _animCounter > 0 && ( + if ((int)idx == objNum && scripts._animCounter > 0 && ( objObject._spriteId == (_vm->_files->_isDarkCc ? 15 : 16) || objObject._spriteId == 58 || objObject._spriteId == 73)) { if (mazeObject._frame > 4 || mazeObject._spriteId == 58) diff --git a/engines/xeen/interface.h b/engines/xeen/interface.h index 93c861e0cd..37ac7be5be 100644 --- a/engines/xeen/interface.h +++ b/engines/xeen/interface.h @@ -66,10 +66,8 @@ private: int _heroismUIFrame; int _flipUIFrame; bool _buttonsLoaded; - Common::String _interfaceText; int _hiliteChar; bool _flag1; - int _animCounter; bool _isAnimReset; byte _tillMove; int _overallFrame; @@ -107,6 +105,7 @@ private: bool checkMoveDirection(int key); public: int _intrIndex1; + Common::String _interfaceText; public: Interface(XeenEngine *vm); diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp index e541d374d6..d2f4c5e18d 100644 --- a/engines/xeen/map.cpp +++ b/engines/xeen/map.cpp @@ -1284,8 +1284,9 @@ void Map::loadEvents(int mapId) { filename = Common::String::format("aaze%c%03d.txt", (mapId >= 100) ? 'x' : '0', mapId); File fText(filename); - _events._text.resize(fText.size()); - fText.read(&_events._text[0], fText.size()); + _events._text.clear(); + while (fText.pos() < fText.size()) + _events._text.push_back(fText.readString()); fText.close(); } diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index 55388ec343..50584a2551 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -22,6 +22,7 @@ #include "xeen/scripts.h" #include "xeen/party.h" +#include "xeen/xeen.h" namespace Xeen { @@ -65,9 +66,76 @@ void MazeEvents::synchronize(XeenSerializer &s) { /*------------------------------------------------------------------------*/ Scripts::Scripts(XeenEngine *vm) : _vm(vm) { + Common::fill(&_charFX[0], &_charFX[MAX_ACTIVE_PARTY], 0); + _whoWill = 0; + _itemType = 0; + _treasureItems = 0; + _treasureGold = 0; + _treasureGems = 0; + + _v2 = 0; + _nEdamageType = 0; + _animCounter = 0; + _eventSkipped = false; } void Scripts::checkEvents() { + Combat &combat = *_vm->_combat; + Interface &intf = *_vm->_interface; + Map &map = *_vm->_map; + Party &party = *_vm->_party; + + int var18 = 0; + _itemType = 0; + int var4F = 0; + bool var50 = false; + _whoWill = 0; + Mode oldMode = _vm->_mode; + Common::fill(&_charFX[0], &_charFX[MAX_ACTIVE_PARTY], 0); + int items = _treasureItems; + + if (_treasureGold & _treasureItems) { + // TODO + } else { + // TODO + } + + do { + int var4 = 0; + int varA = 0; + _animCounter = 0; + int var4E = 0; + const Common::Point pt = party._mazePosition; + int varC = 1; + _v2 = 1; + _nEdamageType = 0; + int var40 = -1; + + // Break out of the events if there's an attacking monster + if (combat._attackMonsters[0] != -1) { + _eventSkipped = true; + break; + } + + _eventSkipped = false; + + for (uint eventIndex = 0; eventIndex < map._events.size(); ++eventIndex) { + MazeEvent &event = map._events[eventIndex]; + + if (event._position == pt && party._mazeDirection != (pt.x | pt.y)) { + if (event._direction == party._mazeDirection || event._direction == DIR_ALL) { + _vm->_mode = MODE_9; + intf._interfaceText = event._parameters.size() == 0 ? "" : + map._events._text[event._parameters[0]]; + doOpcode(event._opcode, event._parameters); + + } else { + var50 = true; + } + } + } + } while (0); + // TODO } @@ -79,4 +147,97 @@ void Scripts::openGrate(int v1, int v2) { // TODO } +typedef void(Scripts::*ScriptMethodPtr)(Common::Array<byte> &); + +void Scripts::doOpcode(Opcode opcode, Common::Array<byte> ¶ms) { + static const ScriptMethodPtr COMMAND_LIST[] = { + &Scripts::cmdNone, &Scripts::cmdDisplay0x01, &Scripts::cmdDoorTextSml, + &Scripts::cmdDoorTextLrg, &Scripts::cmdSignText, + &Scripts::cmdNPC, &Scripts::cmdPlayFX, &Scripts::cmdTeleportAndExit, + &Scripts::cmdIf1, &Scripts::cmdIf2, &Scripts::cmdIf3, + &Scripts::cmdMoveObj, &Scripts::cmdTakeOrGive, &Scripts::cmdNoAction, + &Scripts::cmdRemove, &Scripts::cmdSetChar, &Scripts::cmdSpawn, + &Scripts::cmdDoTownEvent, &Scripts::cmdExit, &Scripts::cmdAfterMap, + &Scripts::cmdGiveExtended, &Scripts::cmdConfirmWord, &Scripts::cmdDamage, + &Scripts::cmdJumpRnd, &Scripts::cmdAfterEvent, &Scripts::cmdCallEvent, + &Scripts::cmdReturn, &Scripts::cmdSetVar, &Scripts::cmdTakeOrGive2, + &Scripts::cmdTakeOrGive3, &Scripts::cmdCutsceneEndClouds, + &Scripts::cmdTeleportAndContinue, &Scripts::cmdWhoWill, + &Scripts::cmdRndDamage, &Scripts::cmdMoveWallObj, &Scripts::cmdAlterCellFlag, + &Scripts::cmdAlterHed, &Scripts::cmdDisplayStat, &Scripts::cmdTakeOrGive4, + &Scripts::cmdSeatTextSml, &Scripts::cmdPlayEventVoc, &Scripts::cmdDisplayBottom, + &Scripts::cmdIfMapFlag, &Scripts::cmdSelRndChar, &Scripts::cmdGiveEnchanted, + &Scripts::cmdItemType, &Scripts::cmdMakeNothingHere, &Scripts::cmdNoAction2, + &Scripts::cmdChooseNumeric, &Scripts::cmdDisplayBottomTwoLines, + &Scripts::cmdDisplayLarge, &Scripts::cmdExchObj, &Scripts::cmdFallToMap, + &Scripts::cmdDisplayMain, &Scripts::cmdGoto, &Scripts::cmdConfirmWord2, + &Scripts::cmdGotoRandom, &Scripts::cmdCutsceneEndDarkside, + &Scripts::cmdCutsceneEdWorld, &Scripts::cmdFlipWorld, &Scripts::cmdPlayCD + }; + + (this->*COMMAND_LIST[opcode])(params); +} + +void Scripts::cmdNone(Common::Array<byte> ¶ms) {} +void Scripts::cmdDisplay0x01(Common::Array<byte> ¶ms) {} +void Scripts::cmdDoorTextSml(Common::Array<byte> ¶ms) {} +void Scripts::cmdDoorTextLrg(Common::Array<byte> ¶ms) {} +void Scripts::cmdSignText(Common::Array<byte> ¶ms) {} +void Scripts::cmdNPC(Common::Array<byte> ¶ms) {} +void Scripts::cmdPlayFX(Common::Array<byte> ¶ms) {} +void Scripts::cmdTeleportAndExit(Common::Array<byte> ¶ms) {} +void Scripts::cmdIf1(Common::Array<byte> ¶ms) {} +void Scripts::cmdIf2(Common::Array<byte> ¶ms) {} +void Scripts::cmdIf3(Common::Array<byte> ¶ms) {} +void Scripts::cmdMoveObj(Common::Array<byte> ¶ms) {} +void Scripts::cmdTakeOrGive(Common::Array<byte> ¶ms) {} +void Scripts::cmdNoAction(Common::Array<byte> ¶ms) {} +void Scripts::cmdRemove(Common::Array<byte> ¶ms) {} +void Scripts::cmdSetChar(Common::Array<byte> ¶ms) {} +void Scripts::cmdSpawn(Common::Array<byte> ¶ms) {} +void Scripts::cmdDoTownEvent(Common::Array<byte> ¶ms) {} +void Scripts::cmdExit(Common::Array<byte> ¶ms) {} +void Scripts::cmdAfterMap(Common::Array<byte> ¶ms) {} +void Scripts::cmdGiveExtended(Common::Array<byte> ¶ms) {} +void Scripts::cmdConfirmWord(Common::Array<byte> ¶ms) {} +void Scripts::cmdDamage(Common::Array<byte> ¶ms) {} +void Scripts::cmdJumpRnd(Common::Array<byte> ¶ms) {} +void Scripts::cmdAfterEvent(Common::Array<byte> ¶ms) {} +void Scripts::cmdCallEvent(Common::Array<byte> ¶ms) {} +void Scripts::cmdReturn(Common::Array<byte> ¶ms) {} +void Scripts::cmdSetVar(Common::Array<byte> ¶ms) {} +void Scripts::cmdTakeOrGive2(Common::Array<byte> ¶ms) {} +void Scripts::cmdTakeOrGive3(Common::Array<byte> ¶ms) {} +void Scripts::cmdCutsceneEndClouds(Common::Array<byte> ¶ms) {} +void Scripts::cmdTeleportAndContinue(Common::Array<byte> ¶ms) {} +void Scripts::cmdWhoWill(Common::Array<byte> ¶ms) {} +void Scripts::cmdRndDamage(Common::Array<byte> ¶ms) {} +void Scripts::cmdMoveWallObj(Common::Array<byte> ¶ms) {} +void Scripts::cmdAlterCellFlag(Common::Array<byte> ¶ms) {} +void Scripts::cmdAlterHed(Common::Array<byte> ¶ms) {} +void Scripts::cmdDisplayStat(Common::Array<byte> ¶ms) {} +void Scripts::cmdTakeOrGive4(Common::Array<byte> ¶ms) {} +void Scripts::cmdSeatTextSml(Common::Array<byte> ¶ms) {} +void Scripts::cmdPlayEventVoc(Common::Array<byte> ¶ms) {} +void Scripts::cmdDisplayBottom(Common::Array<byte> ¶ms) {} +void Scripts::cmdIfMapFlag(Common::Array<byte> ¶ms) {} +void Scripts::cmdSelRndChar(Common::Array<byte> ¶ms) {} +void Scripts::cmdGiveEnchanted(Common::Array<byte> ¶ms) {} +void Scripts::cmdItemType(Common::Array<byte> ¶ms) {} +void Scripts::cmdMakeNothingHere(Common::Array<byte> ¶ms) {} +void Scripts::cmdNoAction2(Common::Array<byte> ¶ms) {} +void Scripts::cmdChooseNumeric(Common::Array<byte> ¶ms) {} +void Scripts::cmdDisplayBottomTwoLines(Common::Array<byte> ¶ms) {} +void Scripts::cmdDisplayLarge(Common::Array<byte> ¶ms) {} +void Scripts::cmdExchObj(Common::Array<byte> ¶ms) {} +void Scripts::cmdFallToMap(Common::Array<byte> ¶ms) {} +void Scripts::cmdDisplayMain(Common::Array<byte> ¶ms) {} +void Scripts::cmdGoto(Common::Array<byte> ¶ms) {} +void Scripts::cmdConfirmWord2(Common::Array<byte> ¶ms) {} +void Scripts::cmdGotoRandom(Common::Array<byte> ¶ms) {} +void Scripts::cmdCutsceneEndDarkside(Common::Array<byte> ¶ms) {} +void Scripts::cmdCutsceneEdWorld(Common::Array<byte> ¶ms) {} +void Scripts::cmdFlipWorld(Common::Array<byte> ¶ms) {} +void Scripts::cmdPlayCD(Common::Array<byte> ¶ms) {} + } // End of namespace Xeen diff --git a/engines/xeen/scripts.h b/engines/xeen/scripts.h index 9974892221..2fbcf78b38 100644 --- a/engines/xeen/scripts.h +++ b/engines/xeen/scripts.h @@ -26,6 +26,7 @@ #include "common/scummsys.h" #include "common/system.h" #include "common/serializer.h" +#include "common/str-array.h" #include "xeen/files.h" namespace Xeen { @@ -111,7 +112,7 @@ public: class MazeEvents : public Common::Array<MazeEvent> { public: - Common::Array<byte> _text; + Common::StringArray _text; public: void synchronize(XeenSerializer &s); }; @@ -119,6 +120,81 @@ public: class Scripts { private: XeenEngine *_vm; + int _charFX[6]; + int _whoWill; + int _itemType; + int _treasureItems; + int _treasureGold; + int _treasureGems; + + int _v2; + int _nEdamageType; + + void doOpcode(Opcode opcode, Common::Array<byte> ¶ms); + void cmdNone(Common::Array<byte> ¶ms); + void cmdDisplay0x01(Common::Array<byte> ¶ms); + void cmdDoorTextSml(Common::Array<byte> ¶ms); + void cmdDoorTextLrg(Common::Array<byte> ¶ms); + void cmdSignText(Common::Array<byte> ¶ms); + void cmdNPC(Common::Array<byte> ¶ms); + void cmdPlayFX(Common::Array<byte> ¶ms); + void cmdTeleportAndExit(Common::Array<byte> ¶ms); + void cmdIf1(Common::Array<byte> ¶ms); + void cmdIf2(Common::Array<byte> ¶ms); + void cmdIf3(Common::Array<byte> ¶ms); + void cmdMoveObj(Common::Array<byte> ¶ms); + void cmdTakeOrGive(Common::Array<byte> ¶ms); + void cmdNoAction(Common::Array<byte> ¶ms); + void cmdRemove(Common::Array<byte> ¶ms); + void cmdSetChar(Common::Array<byte> ¶ms); + void cmdSpawn(Common::Array<byte> ¶ms); + void cmdDoTownEvent(Common::Array<byte> ¶ms); + void cmdExit(Common::Array<byte> ¶ms); + void cmdAfterMap(Common::Array<byte> ¶ms); + void cmdGiveExtended(Common::Array<byte> ¶ms); + void cmdConfirmWord(Common::Array<byte> ¶ms); + void cmdDamage(Common::Array<byte> ¶ms); + void cmdJumpRnd(Common::Array<byte> ¶ms); + void cmdAfterEvent(Common::Array<byte> ¶ms); + void cmdCallEvent(Common::Array<byte> ¶ms); + void cmdReturn(Common::Array<byte> ¶ms); + void cmdSetVar(Common::Array<byte> ¶ms); + void cmdTakeOrGive2(Common::Array<byte> ¶ms); + void cmdTakeOrGive3(Common::Array<byte> ¶ms); + void cmdCutsceneEndClouds(Common::Array<byte> ¶ms); + void cmdTeleportAndContinue(Common::Array<byte> ¶ms); + void cmdWhoWill(Common::Array<byte> ¶ms); + void cmdRndDamage(Common::Array<byte> ¶ms); + void cmdMoveWallObj(Common::Array<byte> ¶ms); + void cmdAlterCellFlag(Common::Array<byte> ¶ms); + void cmdAlterHed(Common::Array<byte> ¶ms); + void cmdDisplayStat(Common::Array<byte> ¶ms); + void cmdTakeOrGive4(Common::Array<byte> ¶ms); + void cmdSeatTextSml(Common::Array<byte> ¶ms); + void cmdPlayEventVoc(Common::Array<byte> ¶ms); + void cmdDisplayBottom(Common::Array<byte> ¶ms); + void cmdIfMapFlag(Common::Array<byte> ¶ms); + void cmdSelRndChar(Common::Array<byte> ¶ms); + void cmdGiveEnchanted(Common::Array<byte> ¶ms); + void cmdItemType(Common::Array<byte> ¶ms); + void cmdMakeNothingHere(Common::Array<byte> ¶ms); + void cmdNoAction2(Common::Array<byte> ¶ms); + void cmdChooseNumeric(Common::Array<byte> ¶ms); + void cmdDisplayBottomTwoLines(Common::Array<byte> ¶ms); + void cmdDisplayLarge(Common::Array<byte> ¶ms); + void cmdExchObj(Common::Array<byte> ¶ms); + void cmdFallToMap(Common::Array<byte> ¶ms); + void cmdDisplayMain(Common::Array<byte> ¶ms); + void cmdGoto(Common::Array<byte> ¶ms); + void cmdConfirmWord2(Common::Array<byte> ¶ms); + void cmdGotoRandom(Common::Array<byte> ¶ms); + void cmdCutsceneEndDarkside(Common::Array<byte> ¶ms); + void cmdCutsceneEdWorld(Common::Array<byte> ¶ms); + void cmdFlipWorld(Common::Array<byte> ¶ms); + void cmdPlayCD(Common::Array<byte> ¶ms); +public: + int _animCounter; + bool _eventSkipped; public: Scripts(XeenEngine *vm); |