ScummVM API documentation
character.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  */
21 
22 #ifndef XEEN_CHARACTER_H
23 #define XEEN_CHARACTER_H
24 
25 #include "common/scummsys.h"
26 #include "common/array.h"
27 #include "common/rect.h"
28 #include "common/serializer.h"
29 #include "mm/xeen/combat.h"
30 #include "mm/xeen/item.h"
31 #include "mm/xeen/sprites.h"
32 
33 namespace MM {
34 namespace Xeen {
35 
36 #define INV_ITEMS_TOTAL 9
37 #define SPELLS_PER_CLASS 39
38 #define AWARDS_TOTAL 88
39 #define WARZONE_AWARD 9
40 
41 enum Award {
42  SHANGRILA_GUILD_MEMBER = 5, GOOBER = 76, SUPER_GOOBER = 77,
43  CASTLEVIEW_GUILD_MEMBER = 83, SANDCASTER_GUILD_MEMBER = 84,
44  LAKESIDE_GUILD_MEMBER = 85, NECROPOLIS_GUILD_MEMBER = 86, OLYMPUS_GUILD_MEMBER = 87
45 };
46 
47 enum Sex {
48  MALE = 0, FEMALE = 1, YES_PLEASE = 2
49 };
50 
51 enum Race {
52  HUMAN = 0, ELF = 1, DWARF = 2, GNOME = 3, HALF_ORC = 4
53 };
54 
55 enum CharacterClass {
56  CLASS_KNIGHT = 0, CLASS_PALADIN = 1, CLASS_ARCHER = 2, CLASS_CLERIC = 3,
57  CLASS_SORCERER = 4, CLASS_ROBBER = 5, CLASS_NINJA = 6, CLASS_BARBARIAN = 7,
58  CLASS_DRUID = 8, CLASS_RANGER = 9, TOTAL_CLASSES = 10
59 };
60 
61 enum HatesClass {
62  HATES_DWARF = 12, HATES_PARTY = 15, HATES_NOBODY = 16
63 };
64 
65 enum Attribute {
66  MIGHT = 0, INTELLECT = 1, PERSONALITY = 2, ENDURANCE = 3, SPEED = 4,
67  ACCURACY = 5, LUCK = 6, TOTAL_ATTRIBUTES = 7
68 };
69 
70 enum Skill {
71  THIEVERY = 0, ARMS_MASTER = 1, ASTROLOGER = 2, BODYBUILDER = 3,
72  CARTOGRAPHER = 4, CRUSADER = 5, DIRECTION_SENSE = 6, LINGUIST = 7,
73  MERCHANT = 8, MOUNTAINEER = 9, NAVIGATOR = 10, PATHFINDER = 11,
74  PRAYER_MASTER = 12, PRESTIDIGITATION = 13, SWIMMING = 14, TRACKING = 15,
75  SPOT_DOORS = 16, DANGER_SENSE = 17
76 };
77 
78 enum Condition {
79  CURSED = 0, HEART_BROKEN = 1, WEAK = 2, POISONED = 3,
80  DISEASED = 4, INSANE = 5, IN_LOVE = 6, DRUNK = 7, ASLEEP = 8,
81  DEPRESSED = 9, CONFUSED = 10, PARALYZED = 11, UNCONSCIOUS = 12,
82  DEAD = 13, STONED = 14, ERADICATED = 15,
83  NO_CONDITION = 16
84 };
85 
86 enum QuickAction {
87  QUICK_ATTACK = 0, QUICK_SPELL = 1, QUICK_BLOCK = 2, QUICK_RUN = 3
88 };
89 
90 enum SpellsCategory {
91  SPELLCAT_INVALID = -1, SPELLCAT_CLERICAL = 0, SPELLCAT_WIZARDRY = 1, SPELLCAT_DRUIDIC = 2
92 };
93 
94 
95 class XeenEngine;
96 
98 public:
99  int _permanent;
100  int _temporary;
101 public:
102  AttributePair();
103  void synchronize(Common::Serializer &s);
104 };
105 
106 class Character {
107 private:
111  int conditionMod(Attribute attrib) const;
112 public:
113  Common::String _name;
114  Sex _sex;
115  Race _race;
116  int _xeenSide;
117  CharacterClass _class;
118  AttributePair _might;
119  AttributePair _intellect;
120  AttributePair _personality;
121  AttributePair _endurance;
122  AttributePair _speed;
123  AttributePair _accuracy;
124  AttributePair _luck;
125  int _ACTemp;
126  AttributePair _level;
127  uint _birthDay;
128  int _tempAge;
129  int _skills[18];
130  int _awards[128];
131  bool _spells[SPELLS_PER_CLASS];
132  int _lloydMap;
133  Common::Point _lloydPosition;
134  bool _hasSpells;
135  int8 _currentSpell;
136  QuickAction _quickOption;
137  WeaponItems _weapons;
138  ArmorItems _armor;
139  AccessoryItems _accessories;
140  MiscItems _misc;
141  InventoryItemsGroup _items;
142  int _lloydSide;
143  AttributePair _fireResistance;
144  AttributePair _coldResistance;
145  AttributePair _electricityResistance;
146  AttributePair _poisonResistance;
147  AttributePair _energyResistance;
148  AttributePair _magicResistance;
149  int _conditions[16];
150  int _townUnknown;
151  int _savedMazeId;
152  int _currentHp;
153  int _currentSp;
154  uint _birthYear;
155  uint32 _experience;
156  int _currentAdventuringSpell;
157  int _currentCombatSpell;
158 
159  SpriteResource *_faceSprites;
160  int _rosterId;
161 public:
162  static int _itemType;
163 public:
167  Character();
168 
172  Character(const Character &src);
173 
177  bool operator==(const Character &src) const {
178  return src._rosterId == _rosterId;
179  }
180 
184  bool operator!=(const Character &src) const {
185  return src._rosterId != _rosterId;
186  }
187 
191  void clear();
192 
196  Character &operator=(const Character &src);
197 
201  void synchronize(Common::Serializer &s);
202 
206  Condition worstCondition() const;
207 
211  bool isDisabled() const;
212 
216  bool isDisabledOrDead() const;
217 
221  bool isDead() const;
222 
226  int getAge(bool ignoreTemp = false) const;
227 
231  int getMaxHP() const;
232 
236  int getMaxSP() const;
237 
241  uint getStat(Attribute attrib, bool baseOnly = false) const;
242 
247  static int statColor(int amount, int threshold);
248 
252  int statBonus(uint statValue) const;
253 
257  bool charSavingThrow(DamageType attackType) const;
258 
262  bool noActions();
263 
267  void setAward(int awardId, bool value);
268 
272  bool hasAward(int awardId) const;
273 
277  int getAwardCount(int awardId) const;
278 
282  int getArmorClass(bool baseOnly = false) const;
283 
287  int getThievery() const;
288 
289  uint getCurrentLevel() const;
290 
294  int itemScan(int itemId) const;
295 
299  void setValue(int id, uint value);
300 
304  bool guildMember() const;
305 
309  uint experienceToNextLevel() const;
310 
314  uint nextExperienceLevel() const;
315 
319  uint getCurrentExperience() const;
320 
324  int getNumSkills() const;
325 
329  int getNumAwards() const;
330 
334  ItemCategory makeItem(int p1, int itemIndex, int p3);
335 
339  void addHitPoints(int amount);
340 
344  void subtractHitPoints(int amount);
345 
349  bool hasSlayerSword() const;
350 
354  bool hasMissileWeapon() const;
355 
359  SpellsCategory getSpellsCategory() const;
360 
365  return (_class == CLASS_PALADIN || _class == CLASS_ARCHER || _class == CLASS_RANGER) ? 1 : 0;
366  }
367 
371  void clearConditions();
372 };
373 
374 class CharacterArray : public Common::Array<Character> {
375 public:
379  int indexOf(const Character &c);
380 };
381 
382 } // End of namespace Xeen
383 } // End of namespace MM
384 
385 #endif
bool operator!=(const Character &src) const
Definition: character.h:184
Definition: str.h:59
Definition: array.h:52
Definition: item.h:329
Definition: sprites.h:52
Definition: item.h:351
Definition: serializer.h:79
Definition: character.h:374
Definition: character.h:106
Definition: detection.h:27
Definition: rect.h:45
Definition: item.h:266
Definition: item.h:300
Definition: character.h:97
bool operator==(const Character &src) const
Definition: character.h:177
Definition: item.h:370
int getSpellsExpenseFactor() const
Definition: character.h:364