ScummVM API documentation
scripts.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef XEEN_SCRIPTS_H
23#define XEEN_SCRIPTS_H
24
25#include "common/scummsys.h"
26#include "common/system.h"
27#include "common/serializer.h"
28#include "common/stack.h"
29#include "common/str-array.h"
30#include "mm/xeen/files.h"
31#include "mm/xeen/party.h"
32
33namespace MM {
34namespace Xeen {
35
36enum Opcode {
37 OP_None = 0x00,
38 OP_Display0x01 = 0x01,
39 OP_DoorTextSml = 0x02,
40 OP_DoorTextLrg = 0x03,
41 OP_SignText = 0x04,
42 OP_NPC = 0x05,
43 OP_PlayFX = 0x06,
44 OP_TeleportAndExit = 0x07,
45 OP_If1 = 0x08,
46 OP_If2 = 0x09,
47 OP_If3 = 0x0A,
48 OP_MoveObj = 0x0B,
49 OP_TakeOrGive = 0x0C,
50 OP_NoAction = 0x0D,
51 OP_Remove = 0x0E,
52 OP_SetChar = 0x0F,
53 OP_Spawn = 0x10,
54 OP_DoTownEvent = 0x11,
55 OP_Exit = 0x12,
56 OP_AfterMap = 0x13,
57 OP_GiveMulti = 0x14,
58 OP_ConfirmWord = 0x15,
59 OP_Damage = 0x16,
60 OP_JumpRnd = 0x17,
61 OP_AfterEvent = 0x18,
62 OP_CallEvent = 0x19,
63 OP_Return = 0x1A,
64 OP_SetVar = 0x1B,
65 OP_TakeOrGive_2 = 0x1C,
66 OP_TakeOrGive_3 = 0x1D,
67 OP_CutsceneEndClouds = 0x1E,
68 OP_TeleportAndContinue = 0x1F,
69 OP_WhoWill = 0x20,
70 OP_RndDamage = 0x21,
71 OP_MoveWallObj = 0x22,
72 OP_AlterCellFlag = 0x23,
73 OP_AlterHed = 0x24,
74 OP_DisplayStat = 0x25,
75 OP_TakeOrGive_4 = 0x26,
76 OP_SeatTextSml = 0x27,
77 OP_PlayEventVoc = 0x28,
78 OP_DisplayBottom = 0x29,
79 OP_IfMapFlag = 0x2A,
80 OP_SelectRandomChar = 0x2B,
81 OP_GiveEnchanted = 0x2C,
82 OP_ItemType = 0x2D,
83 OP_MakeNothingHere = 0x2E,
84 OP_NoAction_2 = 0x2F,
85 OP_ChooseNumeric = 0x30,
86 OP_DisplayBottomTwoLines = 0x31,
87 OP_DisplayLarge = 0x32,
88 OP_ExchObj = 0x33,
89 OP_FallToMap = 0x34,
90 OP_DisplayMain = 0x35,
91 OP_Goto = 0x36,
92 OP_ConfirmWord_2 = 0x37,
93 OP_GotoRandom = 0x38,
94 OP_CutsceneEndDarkside = 0x39,
95 OP_CutsceneEdWorld = 0x3A,
96 OP_FlipWorld = 0x3B,
97 OP_PlayCD = 0x3C
98};
99
100enum {
101 SCRIPT_ABORT = -1,
102 SCRIPT_RESET = -2
103};
104
105class XeenEngine;
106
110class EventParameters : public Common::Array<byte> {
111public:
112 class Iterator {
113 private:
114 uint _index;
115 const EventParameters &_data;
116 public:
117 Iterator(const EventParameters &owner) : _data(owner), _index(0) {
118 }
119 Iterator(const Iterator &it) : _data(it._data), _index(0) {
120 }
121
125 byte readByte();
126
130 int8 readShort() {
131 return (int8)readByte();
132 }
133
137 uint16 readUint16LE();
138
142 uint32 readUint32LE();
143 };
144public:
149 return Iterator(*this);
150 }
151};
152
157public:
158 Common::Point _position;
159 int _direction;
160 int _line;
161 Opcode _opcode;
162 EventParameters _parameters;
163public:
164 MazeEvent();
165
170};
171
175class MazeEvents : public Common::Array<MazeEvent> {
176public:
178public:
183};
184
188struct StackEntry : public Common::Point {
189 int line;
190
191 StackEntry(const Common::Point &pt, int l) : Common::Point(pt), line(l) {
192 }
193};
194
199 Common::String _name;
200 int _mapId;
201 Common::Point _position;
202 int _direction;
203
204 MirrorEntry() : _mapId(0), _direction(DIR_ALL) {
205 }
206
207 bool synchronize(Common::SeekableReadStream &s);
208};
209
213class Scripts {
214private:
215 XeenEngine *_vm;
216 int _treasureItems;
217 int _lineNum;
218 int _charIndex;
219 int _mirrorId;
220 int _refreshIcons;
221 int _scriptResult;
222 bool _scriptExecuted;
223 bool _dirFlag;
224 int _windowIndex;
225 bool _redrawDone;
226 MazeEvent *_event;
227 Common::Point _currentPos;
229 Common::String _displayMessage;
230
232
236 bool doOpcode(MazeEvent &event);
237
241 bool cmdDoNothing(ParamsIterator &params);
242
246 bool cmdDisplay1(ParamsIterator &params);
247
251 bool cmdDoorTextSml(ParamsIterator &params);
252
256 bool cmdDoorTextLrg(ParamsIterator &params);
257
261 bool cmdSignText(ParamsIterator &params);
262
266 bool cmdNPC(ParamsIterator &params);
267
271 bool cmdPlayFX(ParamsIterator &params);
272
276 bool cmdTeleport(ParamsIterator &params);
277
281 bool cmdIf(ParamsIterator &params);
282
286 bool cmdMoveObj(ParamsIterator &params);
287
291 bool cmdTakeOrGive(ParamsIterator &params);
292
296 bool cmdRemove(ParamsIterator &params);
297
301 bool cmdSetChar(ParamsIterator &params);
302
306 bool cmdSpawn(ParamsIterator &params);
307
312 bool cmdDoTownEvent(ParamsIterator &params);
313
317 bool cmdExit(ParamsIterator &params);
318
322 bool cmdAlterMap(ParamsIterator &params);
323
327 bool cmdGiveMulti(ParamsIterator &params);
328
333 bool cmdConfirmWord(ParamsIterator &params);
334
338 bool cmdDamage(ParamsIterator &params);
339
343 bool cmdJumpRnd(ParamsIterator &params);
344
348 bool cmdAlterEvent(ParamsIterator &params);
349
354 bool cmdCallEvent(ParamsIterator &params);
355
360 bool cmdReturn(ParamsIterator &params);
361
365 bool cmdSetVar(ParamsIterator &params);
366
370 bool cmdCutsceneEndClouds(ParamsIterator &params);
371
375 bool cmdWhoWill(ParamsIterator &params);
376
380 bool cmdRndDamage(ParamsIterator &params);
381
387 bool cmdMoveWallObj(ParamsIterator &params);
388
392 bool cmdAlterCellFlag(ParamsIterator &params);
393
398 bool cmdAlterHed(ParamsIterator &params);
399
403 bool cmdDisplayStat(ParamsIterator &params);
404
409 bool cmdSignTextSml(ParamsIterator &params);
410
415 bool cmdPlayEventVoc(ParamsIterator &params);
416
420 bool cmdDisplayBottom(ParamsIterator &params);
421
426 bool cmdIfMapFlag(ParamsIterator &params);
427
431 bool cmdSelectRandomChar(ParamsIterator &params);
432
436 bool cmdGiveEnchanted(ParamsIterator &params);
437
441 bool cmdItemType(ParamsIterator &params);
442
446 bool cmdMakeNothingHere(ParamsIterator &params);
447
451 bool cmdCheckProtection(ParamsIterator &params);
452
457 bool cmdChooseNumeric(ParamsIterator &params);
458
462 bool cmdDisplayBottomTwoLines(ParamsIterator &params);
463
467 bool cmdDisplayLarge(ParamsIterator &params);
468
472 bool cmdExchObj(ParamsIterator &params);
473
477 bool cmdFallToMap(ParamsIterator &params);
478
482 bool cmdDisplayMain(ParamsIterator &params);
483
489 bool cmdGoto(ParamsIterator &params);
490
494 bool cmdGotoRandom(ParamsIterator &params);
495
499 bool cmdCutsceneEndDarkside(ParamsIterator &params);
500
504 bool cmdCutsceneEndWorld(ParamsIterator &params);
505
509 bool cmdFlipWorld(ParamsIterator &params);
510
514 bool cmdPlayCD(ParamsIterator &params);
515
516 int whoWill(int v1, int v2, int v3);
517
521 void doCloudsEnding();
522
526 void doDarkSideEnding();
527
532 void doWorldEnding();
533
537 void doEnding(const Common::String &endStr);
538
542 bool ifProc(int action, uint32 val, int mode, int charIndex);
543
547 bool copyProtectionCheck();
548
552 void display(bool justifyFlag, int var46);
553
557 uint convertCDTime(uint srcTime);
558public:
559 int _animCounter;
560 bool _eventSkipped;
561 int _whoWill;
562 DamageType _nEdamageType;
564 Common::String _message;
565public:
566 Scripts(XeenEngine *vm);
567
573
578 bool openGrate(int wallVal, int action);
579};
580
581} // End of namespace Xeen
582} // End of namespace MM
583
584#endif
Definition: array.h:52
Definition: stream.h:745
Definition: serializer.h:80
Definition: str.h:59
Definition: scripts.h:112
int8 readShort()
Definition: scripts.h:130
Definition: scripts.h:110
Iterator getIterator() const
Definition: scripts.h:148
Definition: scripts.h:156
void synchronize(Common::Serializer &s)
Definition: scripts.h:175
void synchronize(XeenSerializer &s)
Definition: scripts.h:213
bool openGrate(int wallVal, int action)
Definition: xeen.h:107
Definition: files.h:133
Definition: detection.h:27
Definition: rect.h:144
Definition: scripts.h:198
Definition: scripts.h:188