1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
|
/* 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_SCRIPTS_H
#define XEEN_SCRIPTS_H
#include "common/scummsys.h"
#include "common/system.h"
#include "common/serializer.h"
#include "common/stack.h"
#include "common/str-array.h"
#include "xeen/files.h"
#include "xeen/party.h"
namespace Xeen {
enum Opcode {
OP_None = 0x00,
OP_Display0x01 = 0x01,
OP_DoorTextSml = 0x02,
OP_DoorTextLrg = 0x03,
OP_SignText = 0x04,
OP_NPC = 0x05,
OP_PlayFX = 0x06,
OP_TeleportAndExit = 0x07,
OP_If1 = 0x08,
OP_If2 = 0x09,
OP_If3 = 0x0A,
OP_MoveObj = 0x0B,
OP_TakeOrGive = 0x0C,
OP_NoAction = 0x0D,
OP_Remove = 0x0E,
OP_SetChar = 0x0F,
OP_Spawn = 0x10,
OP_DoTownEvent = 0x11,
OP_Exit = 0x12,
OP_AfterMap = 0x13,
OP_GiveExtended = 0x14,
OP_ConfirmWord = 0x15,
OP_Damage = 0x16,
OP_JumpRnd = 0x17,
OP_AfterEvent = 0x18,
OP_CallEvent = 0x19,
OP_Return = 0x1A,
OP_SetVar = 0x1B,
OP_TakeOrGive_2 = 0x1C,
OP_TakeOrGive_3 = 0x1D,
OP_CutsceneEndClouds = 0x1E,
OP_TeleportAndContinue = 0x1F,
OP_WhoWill = 0x20,
OP_RndDamage = 0x21,
OP_MoveWallObj = 0x22,
OP_AlterCellFlag= 0x23,
OP_AlterHed = 0x24,
OP_DisplayStat = 0x25,
OP_TakeOrGive_4 = 0x26,
OP_SeatTextSml = 0x27,
OP_PlayEventVoc = 0x28,
OP_DisplayBottom = 0x29,
OP_IfMapFlag = 0x2A,
OP_SelRndChar = 0x2B,
OP_GiveEnchanted= 0x2C,
OP_ItemType = 0x2D,
OP_MakeNothingHere = 0x2E,
OP_NoAction_2 = 0x2F,
OP_ChooseNumeric= 0x30,
OP_DisplayBottomTwoLines = 0x31,
OP_DisplayLarge = 0x32,
OP_ExchObj = 0x33,
OP_FallToMap = 0x34,
OP_DisplayMain = 0x35,
OP_Goto = 0x36,
OP_ConfirmWord_2= 0x37,
OP_GotoRandom = 0x38,
OP_CutsceneEndDarkside = 0x39,
OP_CutsceneEdWorld = 0x3A,
OP_FlipWorld = 0x3B,
OP_PlayCD = 0x3C
};
class XeenEngine;
class MazeEvent {
public:
Common::Point _position;
int _direction;
int _line;
Opcode _opcode;
Common::Array<byte> _parameters;
public:
MazeEvent();
void synchronize(Common::Serializer &s);
};
class MazeEvents : public Common::Array<MazeEvent> {
public:
Common::StringArray _text;
public:
void synchronize(XeenSerializer &s);
};
struct StackEntry : public Common::Point {
int line;
StackEntry(const Common::Point &pt, int l) : Common::Point(pt), line(l) {}
};
struct MirrorEntry {
Common::String _name;
int _mapId;
Common::Point _position;
int _direction;
MirrorEntry() : _mapId(0), _direction(DIR_ALL) {}
bool synchronize(Common::SeekableReadStream &s);
};
class Scripts {
private:
XeenEngine *_vm;
int _treasureItems;
int _lineNum;
int _charIndex;
int _mirrorId;
int _refreshIcons;
int _scriptResult;
bool _scriptExecuted;
bool _var50;
int _windowIndex;
bool _redrawDone;
MazeEvent *_event;
Common::Point _currentPos;
Common::Stack<StackEntry> _stack;
Common::String _message;
Common::String _displayMessage;
/**
* Handles executing a given script command
*/
bool doOpcode(MazeEvent &event);
/**
* Do nothing
*/
bool cmdDoNothing(Common::Array<byte> ¶ms);
/**
* Display a msesage on-screen
*/
bool cmdDisplay1(Common::Array<byte> ¶ms);
/**
* Displays a door text message using the small font
*/
bool cmdDoorTextSml(Common::Array<byte> ¶ms);
/**
* Displays a door text message using the large font
*/
bool cmdDoorTextLrg(Common::Array<byte> ¶ms);
/**
* Show a sign text on-screen
*/
bool cmdSignText(Common::Array<byte> ¶ms);
/**
* Show an NPC interaction message
*/
bool cmdNPC(Common::Array<byte> ¶ms);
/**
* Play a sound FX
*/
bool cmdPlayFX(Common::Array<byte> ¶ms);
/**
* Handles teleportation
*/
bool cmdTeleport(Common::Array<byte> ¶ms);
/**
* Do a conditional check
*/
bool cmdIf(Common::Array<byte> ¶ms);
/**
* Moves the position of an object
*/
bool cmdMoveObj(Common::Array<byte> ¶ms);
/**
* Take or give amounts from various character or party figures
*/
bool cmdTakeOrGive(Common::Array<byte> ¶ms);
/**
* Removes an object from the playfield
*/
bool cmdRemove(Common::Array<byte> ¶ms);
/**
* Set the currently active character for other script operations
*/
bool cmdSetChar(Common::Array<byte> ¶ms);
/**
* Spawn a monster
*/
bool cmdSpawn(Common::Array<byte> ¶ms);
/**
* Does various things that can be done within towns, like visiting
* banks, guilds, etc.
*/
bool cmdDoTownEvent(Common::Array<byte> ¶ms);
/**
* Stop executing the script
*/
bool cmdExit(Common::Array<byte> ¶ms);
/**
* Changes the value for the wall on a given cell
*/
bool cmdAlterMap(Common::Array<byte> ¶ms);
/**
*
*/
bool cmdGiveExtended(Common::Array<byte> ¶ms);
/**
* Confirms with the player for initiating the endgame
*/
bool cmdConfirmEnding(Common::Array<byte> ¶ms);
/**
* Deals damage to a character
*/
bool cmdDamage(Common::Array<byte> ¶ms);
/**
* Jump if a random number matches a given value
*/
bool cmdJumpRnd(Common::Array<byte> ¶ms);
/**
* Alter an existing event
*/
bool cmdAlterEvent(Common::Array<byte> ¶ms);
/**
* Stores the current location and line for later resuming, and set up to execute
* a script at a given location
*/
bool cmdCallEvent(Common::Array<byte> ¶ms);
/**
* Return from executing a script to the script location that previously
* called the script
*/
bool cmdReturn(Common::Array<byte> ¶ms);
bool cmdSetVar(Common::Array<byte> ¶ms);
bool cmdCutsceneEndClouds(Common::Array<byte> ¶ms);
bool cmdWhoWill(Common::Array<byte> ¶ms);
bool cmdRndDamage(Common::Array<byte> ¶ms);
bool cmdMoveWallObj(Common::Array<byte> ¶ms);
bool cmdAlterCellFlag(Common::Array<byte> ¶ms);
bool cmdAlterHed(Common::Array<byte> ¶ms);
bool cmdDisplayStat(Common::Array<byte> ¶ms);
bool cmdSeatTextSml(Common::Array<byte> ¶ms);
bool cmdPlayEventVoc(Common::Array<byte> ¶ms);
bool cmdDisplayBottom(Common::Array<byte> ¶ms);
bool cmdIfMapFlag(Common::Array<byte> ¶ms);
bool cmdSelRndChar(Common::Array<byte> ¶ms);
bool cmdGiveEnchanted(Common::Array<byte> ¶ms);
bool cmdItemType(Common::Array<byte> ¶ms);
/**
* Disable all the scripts at the party's current position
*/
bool cmdMakeNothingHere(Common::Array<byte> ¶ms);
bool cmdCheckProtection(Common::Array<byte> ¶ms);
/**
* Given a number of options, and a list of line numbers associated with
* those options, jumps to whichever line for the option the user selects
*/
bool cmdChooseNumeric(Common::Array<byte> ¶ms);
bool cmdDisplayBottomTwoLines(Common::Array<byte> ¶ms);
bool cmdDisplayLarge(Common::Array<byte> ¶ms);
/**
* Exchange the positions of two objects in the maze
*/
bool cmdExchObj(Common::Array<byte> ¶ms);
bool cmdFallToMap(Common::Array<byte> ¶ms);
bool cmdDisplayMain(Common::Array<byte> ¶ms);
/**
* Jumps to a given line number if the surface at relative cell position 1 matches
* a specified surface.
* @remarks This opcode is apparently never actually used
*/
bool cmdGoto(Common::Array<byte> ¶ms);
/**
* Pick a random value from the parameter list and jump to that line number
*/
bool cmdGotoRandom(Common::Array<byte> ¶ms);
bool cmdCutsceneEndDarkside(Common::Array<byte> ¶ms);
bool cmdCutsceneEdWorld(Common::Array<byte> ¶ms);
bool cmdFlipWorld(Common::Array<byte> ¶ms);
bool cmdPlayCD(Common::Array<byte> ¶ms);
int whoWill(int v1, int v2, int v3);
void doEndGame();
void doEndGame2();
void doWorldEnd();
void doEnding(const Common::String &endStr, int v2);
/**
* This monstrosity handles doing the various types of If checks on various data
*/
bool ifProc(int action, uint32 mask, int mode, int charIndex);
bool copyProtectionCheck();
void display(bool justifyFlag, int var46);
public:
int _animCounter;
bool _eventSkipped;
int _whoWill;
DamageType _nEdamageType;
int _itemType;
int _v2;
Common::Array<MirrorEntry> _mirror;
public:
Scripts(XeenEngine *vm);
int checkEvents();
void openGrate(int wallVal, int action);
};
} // End of namespace Xeen
#endif /* XEEN_SCRIPTS_H */
|