2015-01-11 10:43:02 -05:00
|
|
|
/* 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/scripts.h"
|
2015-01-20 08:46:27 -05:00
|
|
|
#include "xeen/party.h"
|
2015-01-21 20:42:44 -05:00
|
|
|
#include "xeen/xeen.h"
|
2015-01-11 10:43:02 -05:00
|
|
|
|
|
|
|
namespace Xeen {
|
|
|
|
|
|
|
|
MazeEvent::MazeEvent() : _direction(DIR_ALL), _line(-1), _opcode(OP_None) {
|
|
|
|
}
|
|
|
|
|
2015-01-11 14:21:57 -05:00
|
|
|
void MazeEvent::synchronize(Common::Serializer &s) {
|
|
|
|
int len = 5 + _parameters.size();
|
|
|
|
s.syncAsByte(len);
|
|
|
|
|
|
|
|
s.syncAsByte(_position.x);
|
|
|
|
s.syncAsByte(_position.y);
|
|
|
|
s.syncAsByte(_direction);
|
|
|
|
s.syncAsByte(_line);
|
|
|
|
s.syncAsByte(_opcode);
|
|
|
|
|
|
|
|
len -= 5;
|
|
|
|
if (s.isLoading())
|
|
|
|
_parameters.resize(len);
|
|
|
|
for (int i = 0; i < len; ++i)
|
|
|
|
s.syncAsByte(_parameters[i]);
|
2015-01-11 10:43:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
2015-01-11 14:21:57 -05:00
|
|
|
void MazeEvents::synchronize(XeenSerializer &s) {
|
2015-01-11 10:43:02 -05:00
|
|
|
MazeEvent e;
|
|
|
|
|
2015-01-11 14:21:57 -05:00
|
|
|
if (s.isLoading()) {
|
|
|
|
clear();
|
|
|
|
while (!s.finished()) {
|
|
|
|
e.synchronize(s);
|
|
|
|
push_back(e);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (uint i = 0; i < size(); ++i)
|
|
|
|
(*this).operator[](i).synchronize(s);
|
2015-01-11 10:43:02 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-19 11:32:57 -05:00
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
Scripts::Scripts(XeenEngine *vm) : _vm(vm) {
|
2015-01-21 20:42:44 -05:00
|
|
|
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;
|
2015-01-19 11:32:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void Scripts::checkEvents() {
|
2015-01-21 20:42:44 -05:00
|
|
|
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);
|
|
|
|
|
2015-01-19 11:32:57 -05:00
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scripts::giveTreasure() {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scripts::openGrate(int v1, int v2) {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2015-01-21 20:42:44 -05:00
|
|
|
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) {}
|
|
|
|
|
2015-01-11 10:43:02 -05:00
|
|
|
} // End of namespace Xeen
|