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 
50 namespace Graphics {
51  class ManagedSurface;
52  class MacFont;
53 }
54 
55 namespace Wage {
56 
57 class Design;
58 class Script;
59 
60 enum 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 
99 class Context {
100 public:
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 _userVariables[26 * 9];
108  int16 _statVariables[18];
109 };
110 
111 class Designed {
112 public:
113  Designed() : _design(NULL), _designBounds(NULL), _classType(UNKNOWN) {}
114  ~Designed();
115 
116  Common::String _name;
117  Design *_design;
118  Common::Rect *_designBounds;
119  OperandType _classType;
120 
121  Common::Rect *getDesignBounds() {
122  return _designBounds == NULL ? NULL : new Common::Rect(*_designBounds);
123  }
124 
125  void setDesignBounds(Common::Rect *bounds);
126 
127  Common::String toString() const { return _name; }
128 };
129 
130 class Chr : public Designed {
131 public:
132  enum ChrDestination {
133  RETURN_TO_STORAGE = 0,
134  RETURN_TO_RANDOM_SCENE = 1,
135  RETURN_TO_INITIAL_SCENE = 2
136  };
137 
138  enum ChrPart {
139  HEAD = 0,
140  CHEST = 1,
141  SIDE = 2
142  };
143 
144  enum ChrArmorType {
145  HEAD_ARMOR = 0,
146  BODY_ARMOR = 1,
147  SHIELD_ARMOR = 2,
148  MAGIC_ARMOR = 3,
149  NUMBER_OF_ARMOR_TYPES = 4
150  };
151 
153  ~Chr();
154 
155  int _index;
156  int _resourceId;
157  Common::String _initialScene;
158  int _gender;
159  bool _nameProperNoun;
160  bool _playerCharacter;
161  uint _maximumCarriedObjects;
162  int _returnTo;
163 
164  int _physicalStrength;
165  int _physicalHp;
166  int _naturalArmor;
167  int _physicalAccuracy;
168  int _spiritualStength;
169  int _spiritialHp;
170  int _resistanceToMagic;
171  int _spiritualAccuracy;
172  int _runningSpeed;
173  uint _rejectsOffers;
174  int _followsOpponent;
175 
176  Common::String _initialSound;
177  Common::String _scoresHitSound;
178  Common::String _receivesHitSound;
179  Common::String _dyingSound;
180 
181  Common::String _nativeWeapon1;
182  Common::String _operativeVerb1;
183  int _weaponDamage1;
184  Common::String _weaponSound1;
185 
186  Common::String _nativeWeapon2;
187  Common::String _operativeVerb2;
188  int _weaponDamage2;
189  Common::String _weaponSound2;
190 
191  int _winningWeapons;
192  int _winningMagic;
193  int _winningRun;
194  int _winningOffer;
195  int _losingWeapons;
196  int _losingMagic;
197  int _losingRun;
198  int _losingOffer;
199 
200  Common::String _initialComment;
201  Common::String _scoresHitComment;
202  Common::String _receivesHitComment;
203  Common::String _makesOfferComment;
204  Common::String _rejectsOfferComment;
205  Common::String _acceptsOfferComment;
206  Common::String _dyingWords;
207 
208  Scene *_currentScene;
209  ObjArray _inventory;
210 
211  Obj *_armor[NUMBER_OF_ARMOR_TYPES];
212 
213  Context _context;
214 
215  ObjArray *getWeapons(bool includeMagic);
216  ObjArray *getMagicalObjects();
217  const char *getDefiniteArticle(bool capitalize);
218 
219  Obj *_weapon1;
220  Obj *_weapon2;
221 
222 public:
223  int wearObjIfPossible(Obj *obj);
224  void wearObjs();
225 
226  void resetState();
227 
228  bool isWearing(Obj *obj);
229 };
230 
231 class Obj : public Designed {
232 public:
233  Obj();
234  Obj(Common::String name, Common::SeekableReadStream *data, int resourceId);
235  ~Obj();
236 
237  enum ObjectType {
238  REGULAR_WEAPON = 1,
239  THROW_WEAPON = 2,
240  MAGICAL_OBJECT = 3,
241  HELMET = 4,
242  SHIELD = 5,
243  CHEST_ARMOR = 6,
244  SPIRITUAL_ARMOR = 7,
245  MOBILE_OBJECT = 8,
246  IMMOBILE_OBJECT = 9
247  };
248 
249  enum AttackType {
250  CAUSES_PHYSICAL_DAMAGE = 0,
251  CAUSES_SPIRITUAL_DAMAGE = 1,
252  CAUSES_PHYSICAL_AND_SPIRITUAL_DAMAGE = 2,
253  HEALS_PHYSICAL_DAMAGE = 3,
254  HEALS_SPIRITUAL_DAMAGE = 4,
255  HEALS_PHYSICAL_AND_SPIRITUAL_DAMAGE = 5,
256  FREEZES_OPPONENT = 6
257  };
258 
259 public:
260  int _index;
261  int _resourceId;
262  bool _namePlural;
263  uint _value;
264  int _attackType;
265  int _numberOfUses;
266  bool _returnToRandomScene;
267  Common::String _sceneOrOwner;
268  Common::String _clickMessage;
269  Common::String _failureMessage;
270  Common::String _useMessage;
271 
272  Scene *_currentScene;
273  Chr *_currentOwner;
274 
275  int _type;
276  uint _accuracy;
277  Common::String _operativeVerb;
278  int _damage;
279  Common::String _sound;
280 
281 public:
282  void setCurrentOwner(Chr *currentOwner) {
283  _currentOwner = currentOwner;
284  if (currentOwner != NULL)
285  _currentScene = NULL;
286  }
287 
288  void setCurrentScene(Scene *currentScene) {
289  _currentScene = currentScene;
290  if (currentScene != NULL)
291  _currentOwner = NULL;
292  }
293 
294  Chr *removeFromChr();
295  Designed *removeFromCharOrScene();
296 
297  void resetState(Chr *owner, Scene *scene);
298 };
299 
300 class Scene : public Designed {
301 public:
302  enum SceneTypes {
303  PERIODIC = 0,
304  RANDOM = 1
305  };
306 
307  int _resourceId;
308 
309  Script *_script;
310  Common::String _text;
311  Common::Rect *_textBounds;
312  Graphics::MacFont *_font;
313  bool _blocked[4];
314  Common::String _messages[4];
315  int _soundFrequency; // times a minute, max 3600
316  int _soundType;
317  Common::String _soundName;
318  int _worldX;
319  int _worldY;
320  bool _visited;
321 
322  ObjList _objs;
323  ChrList _chrs;
324 
325  Scene();
327  ~Scene();
328 
329  Designed *lookUpEntity(int x, int y);
330 
331  Common::Rect *getTextBounds() {
332  return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
333  }
334 
335  void paint(Graphics::ManagedSurface *screen, int x, int y);
336 
337  const Graphics::MacFont *getFont() { return _font; }
338 };
339 
340 } // End of namespace Wage
341 
342 #endif
Definition: managed_surface.h:51
Definition: script.h:52
Definition: str.h:59
Definition: array.h:52
Definition: list.h:44
Definition: rect.h:144
Definition: stream.h:745
Definition: entities.h:231
Definition: formatinfo.h:28
Definition: macfontmanager.h:106
Definition: design.h:60
Definition: entities.h:300
Definition: debugger.h:28
Definition: entities.h:130
Definition: entities.h:111
Definition: entities.h:99