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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
|
/* 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.
*
* MIT License:
*
* Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef WAGE_ENTITIES_H
#define WAGE_ENTITIES_H
namespace Wage {
class Design;
class Obj;
class Scene;
class Script;
class Weapon;
typedef Common::Array<Weapon *> WeaponArray;
class Context {
public:
enum StatVariables {
/** The base physical accuracy of the player. */
PHYS_ACC_BAS = 0,
/** The current physical accuracy of the player. */
PHYS_ACC_CUR = 1,
/** The base physical armor of the player. */
PHYS_ARM_BAS = 2,
/** The current physical armor of the player. */
PHYS_ARM_CUR = 3,
/** The base physical hit points of the player. */
PHYS_HIT_BAS = 4,
/** The current physical hit points of the player. */
PHYS_HIT_CUR = 5,
/** The base physical speed of the player. */
PHYS_SPE_BAS = 6,
/** The current physical speed of the player. */
PHYS_SPE_CUR = 7,
/** The base physical strength of the player. */
PHYS_STR_BAS = 8,
/** The current physical strength of the player. */
PHYS_STR_CUR = 9,
/** The base spiritual accuracy of the player. */
SPIR_ACC_BAS = 10,
/** The current spiritual accuracy of the player. */
SPIR_ACC_CUR = 11,
/** The base spiritual armor of the player. */
SPIR_ARM_BAS = 12,
/** The current spiritual armor of the player. */
SPIR_ARM_CUR = 13,
/** The base spiritual hit points of the player. */
SPIR_HIT_BAS = 14,
/** The current spiritual hit points of the player. */
SPIR_HIT_CUR = 15,
/** The base spiritual strength of the player. */
SPIR_STR_BAS = 16,
/** The current spiritual strength of the player. */
SPIR_STR_CUR = 17
};
int16 _visits; // Number of scenes visited, including repeated visits
int16 _kills; // Number of characters killed
int16 _experience;
int16 _userVariables[26 * 9];
int16 _statVariables[18];
};
class Designed {
public:
Designed() : _design(NULL), _designBounds(NULL), _classType(UNKNOWN) {}
String _name;
Design *_design;
Common::Rect *_designBounds;
OperandType _classType;
Common::Rect *getDesignBounds() {
return _designBounds == NULL ? NULL : new Common::Rect(*_designBounds);
}
void setDesignBounds(Common::Rect *bounds);
String toString() { return _name; }
};
class Chr : public Designed {
public:
enum ChrDestination {
RETURN_TO_STORAGE = 0,
RETURN_TO_RANDOM_SCENE = 1,
RETURN_TO_INITIAL_SCENE = 2
};
enum ChrPart {
HEAD = 0,
CHEST = 1,
SIDE = 2
};
enum ChrArmorType {
HEAD_ARMOR = 0,
BODY_ARMOR = 1,
SHIELD_ARMOR = 2
};
Chr(String name, Common::SeekableReadStream *data);
int _index;
String _initialScene;
int _gender;
bool _nameProperNoun;
bool _playerCharacter;
int _maximumCarriedObjects;
int _returnTo;
int _physicalStrength;
int _physicalHp;
int _naturalArmor;
int _physicalAccuracy;
int _spiritualStength;
int _spiritialHp;
int _resistanceToMagic;
int _spiritualAccuracy;
int _runningSpeed;
int _rejectsOffers;
int _followsOpponent;
String _initialSound;
String _scoresHitSound;
String _receivesHitSound;
String _dyingSound;
String _nativeWeapon1;
String _operativeVerb1;
int _weaponDamage1;
String _weaponSound1;
String _nativeWeapon2;
String _operativeVerb2;
int _weaponDamage2;
String _weaponSound2;
int _winningWeapons;
int _winningMagic;
int _winningRun;
int _winningOffer;
int _losingWeapons;
int _losingMagic;
int _losingRun;
int _losingOffer;
String _initialComment;
String _scoresHitComment;
String _receivesHitComment;
String _makesOfferComment;
String _rejectsOfferComment;
String _acceptsOfferComment;
String _dyingWords;
Scene *_currentScene;
Common::List<Obj> _inventory;
Obj *_armor[3];
Context _context;
WeaponArray *getWeapons();
public:
#if 0
Weapon[] getWeapons() {
ArrayList<Weapon> weapons = new ArrayList<Weapon>();
if (hasNativeWeapon1()) {
weapons.add(new Weapon() {
String getName() {
return _getNativeWeapon1();
}
String getOperativeVerb() {
return _getOperativeVerb1();
}
int getType() {
return _Obj.REGULAR_WEAPON;
}
int getAccuracy() {
return _0;
}
int getDamage() {
return _getWeaponDamage1();
}
String getSound() {
return _getWeaponSound1();
}
void decrementNumberOfUses() {}
});
}
if (hasNativeWeapon2()) {
weapons.add(new Weapon() {
String getName() {
return _getNativeWeapon2();
}
String getOperativeVerb() {
return _getOperativeVerb2();
}
int getType() {
return _Obj.REGULAR_WEAPON;
}
int getAccuracy() {
return _0;
}
int getDamage() {
return _getWeaponDamage2();
}
String getSound() {
return _getWeaponSound2();
}
void decrementNumberOfUses() {}
});
}
for (Obj o : getInventory()) {
switch (o.getType()) {
case Obj.REGULAR_WEAPON:
case Obj.THROW_WEAPON:
case Obj.MAGICAL_OBJECT:
weapons.add(o);
}
}
return _(Weapon[]) weapons.toArray(new Weapon[0]);
}
#endif
bool hasNativeWeapon1() {
return (_nativeWeapon1.size() > 0 && _operativeVerb1.size() > 0);
}
bool hasNativeWeapon2() {
return (_nativeWeapon2.size() > 0 && _operativeVerb2.size() > 0);
}
};
class Weapon {
public:
uint _accuracy;
String _operativeVerb;
int _type;
int _damage;
String _sound;
int _numberOfUses;
Weapon() : _numberOfUses(0) {}
void decrementNumberOfUses() {
if (_numberOfUses != -1) {
_numberOfUses--;
}
}
};
class Obj : public Weapon, public Designed {
public:
Obj() : _currentOwner(NULL), _currentScene(NULL) {}
Obj(String name, Common::SeekableReadStream *data);
enum ObjectTypes {
REGULAR_WEAPON = 1,
THROW_WEAPON = 2,
MAGICAL_OBJECT = 3,
HELMET = 4,
SHIELD = 5,
CHEST_ARMOR = 6,
SPIRITUAL_ARMOR = 7,
MOBILE_OBJECT = 8,
IMMOBILE_OBJECT = 9
};
enum AttackTypes {
CAUSES_PHYSICAL_DAMAGE = 0,
CAUSES_SPIRITUAL_DAMAGE = 1,
CAUSES_PHYSICAL_AND_SPIRITUAL_DAMAGE = 2,
HEALS_PHYSICAL_DAMAGE = 3,
HEALS_SPIRITUAL_DAMAGE = 4,
HEALS_PHYSICAL_AND_SPIRITUAL_DAMAGE = 5,
FREEZES_OPPONENT = 6
};
public:
int _index;
bool _namePlural;
uint _value;
int _attackType;
int _numberOfUses;
bool _returnToRandomScene;
String _sceneOrOwner;
String _clickMessage;
String _failureMessage;
String _useMessage;
Scene *_currentScene;
Chr *_currentOwner;
public:
void setCurrentOwner(Chr *currentOwner) {
_currentOwner = currentOwner;
if (currentOwner != NULL)
_currentScene = NULL;
}
void setCurrentScene(Scene *currentScene) {
_currentScene = currentScene;
if (currentScene != NULL)
_currentOwner = NULL;
}
};
class Scene : public Designed {
public:
enum Directions {
NORTH = 0,
SOUTH = 1,
EAST = 2,
WEST = 3
};
enum SceneTypes {
PERIODIC = 0,
RANDOM = 1
};
Script *_script;
String _text;
Common::Rect *_textBounds;
int _fontSize;
int _fontType; // 3 => Geneva, 22 => Courier, param to TextFont() function
bool _blocked[4];
String _messages[4];
int _soundFrequency; // times a minute, max 3600
int _soundType;
String _soundName;
int _worldX;
int _worldY;
Common::List<Obj> _objs;
Common::List<Chr> _chrs;
Scene() {}
Scene(String name, Common::SeekableReadStream *data);
Common::Rect *getTextBounds() {
return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
}
#if 0
String getFontName() {
String[] fonts = {
"Chicago", // system font
"Geneva", // application font
"New York",
"Geneva",
"Monaco",
"Venice",
"London",
"Athens",
"San Francisco",
"Toronto",
"Cairo",
"Los Angeles", // 12
null, null, null, null, null, null, null, // not in Inside Macintosh
"Times", // 20
"Helvetica",
"Courier",
"Symbol",
"Taliesin" // mobile?
};
/*
mappings found on some forums:
systemFont(0):System(Swiss)
times(20):Times New Roman(Roman)
helvetica(21):Arial(Modern)
courier(22):Courier New(Modern)
symbol(23):Symbol(Decorative)
applFont(1):Arial(Swiss)
newYork(2):Times New Roman(Roman)
geneva(3):Arial(Swiss)
monaco(4):Courier New(Modern)
venice(5):Times New Roman(Roman)
london(6):Times New Roman(Roman)
athens(7):Times New Roman(Roman)
sanFran(8):Times New Roman(Roman)
toronto(9):Times New Roman(Roman)
cairo(11):Wingdings(Decorative)
losAngeles(12):Times New Roman(Roman)
taliesin(24):Wingdings(Decorative)
*/
if (fontType >= 0 && fontType < fonts.length && fonts[fontType] != null) {
return _fonts[fontType];
}
return _"Unknown";
}
#endif
};
class Sound {
public:
Sound(String name, Common::SeekableReadStream *data) : _name(name), _data(data) {}
~Sound() { }
String _name;
Common::SeekableReadStream *_data;
};
} // End of namespace Wage
#endif
|