ScummVM API documentation
entities.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 * MIT License:
21 *
22 * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko
23 *
24 * Permission is hereby granted, free of charge, to any person
25 * obtaining a copy of this software and associated documentation
26 * files (the "Software"), to deal in the Software without
27 * restriction, including without limitation the rights to use,
28 * copy, modify, merge, publish, distribute, sublicense, and/or sell
29 * copies of the Software, and to permit persons to whom the
30 * Software is furnished to do so, subject to the following
31 * conditions:
32 *
33 * The above copyright notice and this permission notice shall be
34 * included in all copies or substantial portions of the Software.
35 *
36 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
37 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
38 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
39 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
40 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
41 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
42 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
43 * OTHER DEALINGS IN THE SOFTWARE.
44 *
45 */
46
47#ifndef WAGE_ENTITIES_H
48#define WAGE_ENTITIES_H
49
50namespace Graphics {
51 class ManagedSurface;
52 class MacFont;
53}
54
55namespace Wage {
56
57class Design;
58class Script;
59
60enum StatVariable {
62 PHYS_ACC_BAS = 0,
64 PHYS_ACC_CUR = 1,
66 PHYS_ARM_BAS = 2,
68 PHYS_ARM_CUR = 3,
70 PHYS_HIT_BAS = 4,
72 PHYS_HIT_CUR = 5,
74 PHYS_SPE_BAS = 6,
76 PHYS_SPE_CUR = 7,
78 PHYS_STR_BAS = 8,
80 PHYS_STR_CUR = 9,
82 SPIR_ACC_BAS = 10,
84 SPIR_ACC_CUR = 11,
86 SPIR_ARM_BAS = 12,
88 SPIR_ARM_CUR = 13,
90 SPIR_HIT_BAS = 14,
92 SPIR_HIT_CUR = 15,
94 SPIR_STR_BAS = 16,
96 SPIR_STR_CUR = 17
97};
98
99class Context {
100public:
101 Context();
102
103 int16 _visits; // Number of scenes visited, including repeated visits
104 int16 _kills; // Number of characters killed
105 int16 _experience;
106 bool _frozen;
107 int16 _freezeTimer;
108 int16 _userVariables[26 * 9];
109 int16 _statVariables[18];
110};
111
112class Designed {
113public:
114 Designed() : _design(NULL), _designBounds(NULL), _classType(UNKNOWN) {}
115 ~Designed();
116
117 Common::String _name;
118 Design *_design;
119 Common::Rect *_designBounds;
120 OperandType _classType;
121
122 Common::Rect *getDesignBounds() {
123 return _designBounds == NULL ? NULL : new Common::Rect(*_designBounds);
124 }
125
126 void setDesignBounds(Common::Rect *bounds);
127
128 Common::String toString() const { return _name; }
129};
130
131class Chr : public Designed {
132public:
133 enum ChrDestination {
134 RETURN_TO_STORAGE = 0,
135 RETURN_TO_RANDOM_SCENE = 1,
136 RETURN_TO_INITIAL_SCENE = 2
137 };
138
139 enum ChrPart {
140 HEAD = 0,
141 CHEST = 1,
142 SIDE = 2
143 };
144
145 enum ChrArmorType {
146 HEAD_ARMOR = 0,
147 BODY_ARMOR = 1,
148 SHIELD_ARMOR = 2,
149 MAGIC_ARMOR = 3,
150 NUMBER_OF_ARMOR_TYPES = 4
151 };
152
154 ~Chr();
155
156 int _index;
157 int _resourceId;
158 Common::String _initialScene;
159 int _gender;
160 bool _nameProperNoun;
161 bool _playerCharacter;
162 uint _maximumCarriedObjects;
163 int _returnTo;
164
165 int _physicalStrength;
166 int _physicalHp;
167 int _naturalArmor;
168 int _physicalAccuracy;
169 int _spiritualStength;
170 int _spiritialHp;
171 int _resistanceToMagic;
172 int _spiritualAccuracy;
173 int _runningSpeed;
174 uint _rejectsOffers;
175 int _followsOpponent;
176
177 Common::String _initialSound;
178 Common::String _scoresHitSound;
179 Common::String _receivesHitSound;
180 Common::String _dyingSound;
181
182 Common::String _nativeWeapon1;
183 Common::String _operativeVerb1;
184 int _weaponDamage1;
185 Common::String _weaponSound1;
186
187 Common::String _nativeWeapon2;
188 Common::String _operativeVerb2;
189 int _weaponDamage2;
190 Common::String _weaponSound2;
191
192 int _winningWeapons;
193 int _winningMagic;
194 int _winningRun;
195 int _winningOffer;
196 int _losingWeapons;
197 int _losingMagic;
198 int _losingRun;
199 int _losingOffer;
200
201 Common::String _initialComment;
202 Common::String _scoresHitComment;
203 Common::String _receivesHitComment;
204 Common::String _makesOfferComment;
205 Common::String _rejectsOfferComment;
206 Common::String _acceptsOfferComment;
207 Common::String _dyingWords;
208
209 Scene *_currentScene;
210 ObjArray _inventory;
211
212 Obj *_armor[NUMBER_OF_ARMOR_TYPES];
213
214 Context _context;
215
216 ObjArray *getWeapons(bool includeMagic);
217 ObjArray *getMagicalObjects();
218 const char *getDefiniteArticle(bool capitalize);
219
220 Obj *_weapon1;
221 Obj *_weapon2;
222
223public:
224 int wearObjIfPossible(Obj *obj);
225 void wearObjs();
226
227 void resetState();
228
229 bool isWearing(Obj *obj);
230};
231
232class Obj : public Designed {
233public:
234 Obj();
235 Obj(Common::String name, Common::SeekableReadStream *data, int resourceId);
236 ~Obj();
237
238 enum ObjectType {
239 REGULAR_WEAPON = 1,
240 THROW_WEAPON = 2,
241 MAGICAL_OBJECT = 3,
242 HELMET = 4,
243 SHIELD = 5,
244 CHEST_ARMOR = 6,
245 SPIRITUAL_ARMOR = 7,
246 MOBILE_OBJECT = 8,
247 IMMOBILE_OBJECT = 9
248 };
249
250 enum AttackType {
251 CAUSES_PHYSICAL_DAMAGE = 0,
252 CAUSES_SPIRITUAL_DAMAGE = 1,
253 CAUSES_PHYSICAL_AND_SPIRITUAL_DAMAGE = 2,
254 HEALS_PHYSICAL_DAMAGE = 3,
255 HEALS_SPIRITUAL_DAMAGE = 4,
256 HEALS_PHYSICAL_AND_SPIRITUAL_DAMAGE = 5,
257 FREEZES_OPPONENT = 6
258 };
259
260public:
261 int _index;
262 int _resourceId;
263 bool _namePlural;
264 uint _value;
265 int _attackType;
266 int _numberOfUses;
267 bool _returnToRandomScene;
268 Common::String _sceneOrOwner;
269 Common::String _clickMessage;
270 Common::String _failureMessage;
271 Common::String _useMessage;
272
273 Scene *_currentScene;
274 Chr *_currentOwner;
275
276 int _type;
277 uint _accuracy;
278 Common::String _operativeVerb;
279 int _damage;
280 Common::String _sound;
281
282public:
283 void setCurrentOwner(Chr *currentOwner) {
284 _currentOwner = currentOwner;
285 if (currentOwner != NULL)
286 _currentScene = NULL;
287 }
288
289 void setCurrentScene(Scene *currentScene) {
290 _currentScene = currentScene;
291 if (currentScene != NULL)
292 _currentOwner = NULL;
293 }
294
295 Chr *removeFromChr();
296 Designed *removeFromCharOrScene();
297
298 void resetState(Chr *owner, Scene *scene);
299};
300
301class Scene : public Designed {
302public:
303 enum SceneTypes {
304 PERIODIC = 0,
305 RANDOM = 1
306 };
307
308 int _resourceId;
309
310 Script *_script;
311 Common::String _text;
312 Common::Rect *_textBounds;
313 Graphics::MacFont *_font;
314 bool _blocked[4];
315 Common::String _messages[4];
316 int _soundFrequency; // times a minute, max 3600
317 int _soundType;
318 Common::String _soundName;
319 int _worldX;
320 int _worldY;
321 bool _visited;
322
323 ObjList _objs;
324 ChrList _chrs;
325
326 Scene();
328 ~Scene();
329
330 Designed *lookUpEntity(int x, int y);
331
332 Common::Rect *getTextBounds() {
333 return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
334 }
335
336 void paint(Graphics::ManagedSurface *screen, int x, int y);
337
338 const Graphics::MacFont *getFont() { return _font; }
339};
340
341} // End of namespace Wage
342
343#endif
Definition: stream.h:745
Definition: str.h:59
Definition: macfontmanager.h:110
Definition: managed_surface.h:51
Definition: entities.h:131
Definition: entities.h:99
Definition: design.h:69
Definition: entities.h:112
Definition: entities.h:232
Definition: entities.h:301
Definition: script.h:52
Definition: formatinfo.h:28
Definition: rect.h:536