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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
/* 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_MAP_H
#define XEEN_MAP_H
#include "common/stream.h"
#include "common/array.h"
#include "common/rect.h"
#include "xeen/party.h"
#include "xeen/scripts.h"
#include "xeen/sprites.h"
namespace Xeen {
#define MAP_WIDTH 16
#define MAP_HEIGHT 16
#define TOTAL_SURFACES 16
class XeenEngine;
enum DamageType {
DT_PHYSICAL = 0, DT_1 = 1, DT_FIRE = 2, DT_ELECTRICAL = 3,
DT_COLD = 4, DT_POISON = 5, DT_ENERGY = 6, DT_SLEEP = 7,
DT_FINGEROFDEATH = 8, DT_HOLYWORD = 9, DT_MASS_DISTORTION = 10,
DT_UNDED = 11, DT_BEASTMASTER = 12, DT_DRAGONSLEEP = 13,
DT_GOLEMSTOPPER = 14, DT_HYPNOTIZE = 15, DT_INSECT_SPRAY = 16,
DT_POISON_VALLEY = 17, DT_MAGIC_ARROW = 18
};
enum SpecialAttack {
SA_NONE = 0, SA_MAGIC = 1, SA_FIRE = 2, SA_ELEC = 3, SA_COLD = 4,
SA_POISON = 5, SA_ENERGY = 6, SA_DISEASE = 7, SA_INSANE = 8,
SA_SLEEP = 9, SA_CURSEITEM = 10, SA_INLOVE = 11, SA_DRAINSP = 12,
SA_CURSE = 13, SA_PARALYZE = 14, SA_UNCONSCIOUS = 15,
SA_CONFUSE = 16, SA_BREAKWEAPON = 17, SA_WEAKEN = 18,
SA_ERADICATE = 19, SA_AGING = 20, SA_DEATH = 21, SA_STONE = 22
};
enum MonsterType {
MONSTER_0 = 0, MONSTER_ANIMAL = 1, MONSTER_INSECT = 2,
MONSTER_HUMANOID = 3, MONSTER_UNDEAD = 4, MONSTER_GOLEM = 5,
MONSTER_DRAGON = 6
};
class MonsterStruct {
public:
Common::String _name;
int _experience;
int _hp;
int _accuracy;
int _speed;
int _numberOfAttacks;
CharacterClass _hatesClass;
int _strikes;
int _dmgPerStrike;
DamageType _attackType;
SpecialAttack _specialAttack;
int _hitChance;
int _rangeAttack;
MonsterType _monsterType;
int _fireResistence;
int _electricityResistence;
int _coldResistence;
int _poisonResistence;
int _energyResistence;
int _magicResistence;
int _phsyicalResistence;
int _field29;
int _gold;
int _gems;
int _itemDrop;
bool _flying;
int _imageNumber;
int _loopAnimation;
int _animationEffect;
int _field32;
Common::String _attackVoc;
public:
MonsterStruct();
MonsterStruct(Common::String name, int experience, int hp, int accuracy,
int speed, int numberOfAttacks, CharacterClass hatesClass, int strikes,
int dmgPerStrike, DamageType attackType, SpecialAttack specialAttack,
int hitChance, int rangeAttack, MonsterType monsterType,
int fireResistence, int electricityResistence, int coldResistence,
int poisonResistence, int energyResistence, int magicResistence,
int phsyicalResistence, int field29, int gold, int gems, int itemDrop,
bool flying, int imageNumber, int loopAnimation, int animationEffect,
int field32, Common::String attackVoc);
void synchronize(Common::SeekableReadStream &s);
};
class MonsterData : public Common::Array<MonsterStruct> {
private:
void synchronize(Common::SeekableReadStream &s);
public:
MonsterData();
void load(const Common::String &name);
};
class SurroundingMazes {
public:
int _north;
int _east;
int _south;
int _west;
public:
SurroundingMazes();
void synchronize(Common::SeekableReadStream &s);
int &operator[](int idx);
};
class MazeDifficulties {
public:
int _wallNoPass;
int _surfaceNoPass;
int _unlockDoor;
int _unlockBox;
int _bashDoor;
int _bashGrate;
int _bashWall;
int _chance2Run;
public:
MazeDifficulties();
void synchronize(Common::SeekableReadStream &s);
};
enum MazeFlags {
OUTFLAG_GRATE = 0x80, OUTFLAG_DRAIN = 0x20, OUTFLAG_OBJECT_EXISTS = 0x08,
INFLAG_INSIDE = 0x08,
FLAG_WATER = 0x40, FLAG_AUTOEXECUTE_EVENT = 0x10,
FLAG_GROUND_BITS = 7
};
enum MazeFlags2 { FLAG_IS_OUTDOORS = 0x8000, FLAG_IS_DARK = 0x4000 };
enum SurfaceType {
SURFTYPE_DEFAULT = 0,
SURFTYPE_WATER = 0, SURFTYPE_DIRT = 1, SURFTYPE_GRASS = 2,
SURFTYPE_SNOW = 3, SURFTYPE_SWAMP = 4, SURFTYPE_LAVA = 5,
SURFTYPE_DESERT = 6, SURFTYPE_ROAD = 7, SURFTYPE_DWATER = 8,
SURFTYPE_TFLR = 9, SURFTYPE_SKY = 10, SURFTYPE_CROAD = 11,
SURFTYPE_SEWER = 12, SURFTYPE_CLOUD = 13, SURFTYPE_SCORCH = 14,
SURFTYPE_SPACE = 15
};
union MazeWallLayers {
struct MazeWallIndoors {
int _wallNorth : 4;
int _wallEast : 4;
int _wallSouth : 4;
int _wallWest : 4;
} _indoors;
struct MazeWallOutdoors {
SurfaceType _surfaceId : 4;
int _iMiddle : 4;
int _iTop : 4;
int _iOverlay : 4;
} _outdoors;
uint16 _data;
};
struct MazeCell {
int _flags;
int _surfaceId;
MazeCell() : _flags(0), _surfaceId(0) {}
};
class MazeData {
public:
// Resource fields
MazeWallLayers _wallData[MAP_HEIGHT][MAP_WIDTH];
MazeCell _cells[MAP_HEIGHT][MAP_WIDTH];
int _mazeNumber;
SurroundingMazes _surroundingMazes;
int _mazeFlags;
int _mazeFlags2;
int _wallTypes[16];
int _surfaceTypes[16];
int _floorType;
Common::Point _runPosition;
MazeDifficulties _difficulties;
int _trapDamage;
int _wallKind;
int _tavernTips;
bool _seenTiles[MAP_HEIGHT][MAP_WIDTH];
bool _steppedOnTiles[MAP_HEIGHT][MAP_WIDTH];
// Misc fields
int _mazeId;
public:
MazeData();
void synchronize(Common::SeekableReadStream &s);
void setAllTilesStepped();
void clearCellSurfaces();
};
class MobStruct {
public:
Common::Point _pos;
int _id;
Direction _direction;
public:
MobStruct();
bool synchronize(XeenSerializer &s);
};
struct MazeObject {
public:
Common::Point _position;
int _id;
int _frame;
int _spriteId;
Direction _direction;
bool _flipped;
SpriteResource *_sprites;
MazeObject();
};
struct MazeMonster {
Common::Point _position;
int _frame;
int _id;
int _spriteId;
bool _isAttacking;
int _hp;
int _effect1, _effect2;
int _effect3;
SpriteResource *_sprites;
SpriteResource *_attackSprites;
MazeMonster();
};
class MazeWallItem {
public:
Common::Point _position;
int _id;
int _frame;
int _spriteId;
Direction _direction;
SpriteResource *_sprites;
public:
MazeWallItem();
};
struct WallSprites {
SpriteResource _surfaces[TOTAL_SURFACES];
SpriteResource _fwl1;
SpriteResource _fwl2;
SpriteResource _fwl3;
SpriteResource _fwl4;
SpriteResource _swl;
};
class Map;
class MonsterObjectData {
friend class Map;
public:
struct SpriteResourceEntry {
int _spriteId;
SpriteResource _sprites;
SpriteResource _attackSprites;
SpriteResourceEntry() { _spriteId = -1; }
SpriteResourceEntry(int spriteId): _spriteId(spriteId) { }
};
private:
XeenEngine *_vm;
Common::Array<SpriteResourceEntry> _objectSprites;
Common::Array<SpriteResourceEntry> _monsterSprites;
Common::Array<SpriteResourceEntry> _monsterAttackSprites;
Common::Array<SpriteResourceEntry> _wallItemSprites;
public:
Common::Array<MazeObject> _objects;
Common::Array<MazeMonster> _monsters;
Common::Array<MazeWallItem> _wallItems;
public:
MonsterObjectData(XeenEngine *vm);
void synchronize(XeenSerializer &s, MonsterData monsterData);
};
class HeadData {
public:
struct HeadEntry {
int _left;
int _right;
};
HeadEntry _data[MAP_HEIGHT][MAP_WIDTH];
public:
HeadData();
void synchronize(Common::SeekableReadStream &s);
};
struct AnimationFrame { int _front, _left, _back, _right; };
struct AnimationFlipped { bool _front, _left, _back, _right; };
struct AnimationEntry {
union {
AnimationFrame _positions;
int _frames[4];
} _frame1;
union {
AnimationFlipped _positions;
bool _flags[4];
} _flipped;
union {
AnimationFrame _positions;
int _frames[4];
} _frame2;
void synchronize(Common::SeekableReadStream &s);
};
class AnimationInfo : public Common::Array<AnimationEntry> {
public:
void synchronize(Common::SeekableReadStream &s);
void load(const Common::String &name);
};
class Map {
private:
XeenEngine *_vm;
MazeData _mazeData[9];
Common::String _mazeName;
SpriteResource _wallPicSprites;
int _townPortalSide;
int _sidePictures;
int _sideObjects;
int _sideMonsters;
bool _stepped;
int _mazeDataIndex;
bool _currentSteppedOn;
void loadEvents(int mapId);
public:
bool _isOutdoors;
MonsterObjectData _mobData;
MonsterData _monsterData;
MazeEvents _events;
HeadData _headData;
AnimationInfo _animationInfo;
SpriteResource _skySprites;
SpriteResource _mazeSkySprites;
SpriteResource _groundSprites;
SpriteResource _tileSprites;
SpriteResource _surfaceSprites[TOTAL_SURFACES];
WallSprites _wallSprites;
bool _currentIsGrate;
bool _currentCantRest;
bool _currentIsDrain;
bool _currentIsEvent;
bool _currentSky;
int _currentMonsterFlags;
MazeWallLayers _currentWall;
int _currentTile;
int _currentSurfaceId;
public:
Map(XeenEngine *vm);
void load(int mapId);
int mazeLookup(const Common::Point &pt, int layerShift);
void cellFlagLookup(const Common::Point &pt);
void setCellSurfaceFlags(const Common::Point &pt, int bits);
void saveMaze();
int getCell(int idx);
MazeData mazeData() { return _mazeData[0]; }
void loadSky();
};
} // End of namespace Xeen
#endif /* XEEN_MAP_H */
|