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 "xeen/combat.h"
30 #include "xeen/item.h"
31 #include "xeen/sprites.h"
32 
33 namespace Xeen {
34 
35 #define INV_ITEMS_TOTAL 9
36 #define SPELLS_PER_CLASS 39
37 #define AWARDS_TOTAL 88
38 #define WARZONE_AWARD 9
39 
40 enum Award {
41  SHANGRILA_GUILD_MEMBER = 5, GOOBER = 76, SUPER_GOOBER = 77,
42  CASTLEVIEW_GUILD_MEMBER = 83, SANDCASTER_GUILD_MEMBER = 84,
43  LAKESIDE_GUILD_MEMBER = 85, NECROPOLIS_GUILD_MEMBER = 86, OLYMPUS_GUILD_MEMBER = 87
44 };
45 
46 enum Sex { MALE = 0, FEMALE = 1, YES_PLEASE = 2 };
47 
48 enum Race { HUMAN = 0, ELF = 1, DWARF = 2, GNOME = 3, HALF_ORC = 4 };
49 
50 enum CharacterClass {
51  CLASS_KNIGHT = 0, CLASS_PALADIN = 1, CLASS_ARCHER = 2, CLASS_CLERIC = 3,
52  CLASS_SORCERER = 4, CLASS_ROBBER = 5, CLASS_NINJA = 6, CLASS_BARBARIAN = 7,
53  CLASS_DRUID = 8, CLASS_RANGER = 9, TOTAL_CLASSES = 10
54 };
55 
56 enum HatesClass {
57  HATES_DWARF = 12, HATES_PARTY = 15, HATES_NOBODY = 16
58 };
59 
60 enum Attribute {
61  MIGHT = 0, INTELLECT = 1, PERSONALITY = 2, ENDURANCE = 3, SPEED = 4,
62  ACCURACY = 5, LUCK = 6, TOTAL_ATTRIBUTES = 7
63 };
64 
65 enum Skill {
66  THIEVERY = 0, ARMS_MASTER = 1, ASTROLOGER = 2, BODYBUILDER = 3,
67  CARTOGRAPHER = 4, CRUSADER = 5, DIRECTION_SENSE = 6, LINGUIST = 7,
68  MERCHANT = 8, MOUNTAINEER = 9, NAVIGATOR = 10, PATHFINDER = 11,
69  PRAYER_MASTER = 12, PRESTIDIGITATION = 13, SWIMMING = 14, TRACKING = 15,
70  SPOT_DOORS = 16, DANGER_SENSE = 17
71 };
72 
73 enum Condition {
74  CURSED = 0, HEART_BROKEN = 1, WEAK = 2, POISONED = 3,
75  DISEASED = 4, INSANE = 5, IN_LOVE = 6, DRUNK = 7, ASLEEP = 8,
76  DEPRESSED = 9, CONFUSED = 10, PARALYZED = 11, UNCONSCIOUS = 12,
77  DEAD = 13, STONED = 14, ERADICATED = 15,
78  NO_CONDITION = 16
79 };
80 
81 enum QuickAction {
82  QUICK_ATTACK = 0, QUICK_SPELL = 1, QUICK_BLOCK = 2, QUICK_RUN = 3
83 };
84 
85 enum SpellsCategory {
86  SPELLCAT_INVALID = -1, SPELLCAT_CLERICAL = 0, SPELLCAT_WIZARDRY = 1, SPELLCAT_DRUIDIC = 2
87 };
88 
89 
90 class XeenEngine;
91 
93 public:
94  int _permanent;
95  int _temporary;
96 public:
97  AttributePair();
98  void synchronize(Common::Serializer &s);
99 };
100 
101 class Character {
102 private:
106  int conditionMod(Attribute attrib) const;
107 public:
108  Common::String _name;
109  Sex _sex;
110  Race _race;
111  int _xeenSide;
112  CharacterClass _class;
113  AttributePair _might;
114  AttributePair _intellect;
115  AttributePair _personality;
116  AttributePair _endurance;
117  AttributePair _speed;
118  AttributePair _accuracy;
119  AttributePair _luck;
120  int _ACTemp;
121  AttributePair _level;
122  uint _birthDay;
123  int _tempAge;
124  int _skills[18];
125  int _awards[128];
126  bool _spells[SPELLS_PER_CLASS];
127  int _lloydMap;
128  Common::Point _lloydPosition;
129  bool _hasSpells;
130  int8 _currentSpell;
131  QuickAction _quickOption;
132  WeaponItems _weapons;
133  ArmorItems _armor;
134  AccessoryItems _accessories;
135  MiscItems _misc;
136  InventoryItemsGroup _items;
137  int _lloydSide;
138  AttributePair _fireResistence;
139  AttributePair _coldResistence;
140  AttributePair _electricityResistence;
141  AttributePair _poisonResistence;
142  AttributePair _energyResistence;
143  AttributePair _magicResistence;
144  int _conditions[16];
145  int _townUnknown;
146  int _savedMazeId;
147  int _currentHp;
148  int _currentSp;
149  uint _birthYear;
150  uint32 _experience;
151  int _currentAdventuringSpell;
152  int _currentCombatSpell;
153 
154  SpriteResource *_faceSprites;
155  int _rosterId;
156 public:
157  static int _itemType;
158 public:
162  Character();
163 
167  Character(const Character &src);
168 
172  bool operator==(const Character &src) const { return src._rosterId == _rosterId; }
173 
177  bool operator!=(const Character &src) const { return src._rosterId != _rosterId; }
178 
182  void clear();
183 
187  Character &operator=(const Character &src);
188 
192  void synchronize(Common::Serializer &s);
193 
197  Condition worstCondition() const;
198 
202  bool isDisabled() const;
203 
207  bool isDisabledOrDead() const;
208 
212  bool isDead() const;
213 
217  int getAge(bool ignoreTemp = false) const;
218 
222  int getMaxHP() const;
223 
227  int getMaxSP() const;
228 
232  uint getStat(Attribute attrib, bool baseOnly = false) const;
233 
238  static int statColor(int amount, int threshold);
239 
243  int statBonus(uint statValue) const;
244 
248  bool charSavingThrow(DamageType attackType) const;
249 
253  bool noActions();
254 
258  void setAward(int awardId, bool value);
259 
263  bool hasAward(int awardId) const;
264 
268  int getAwardCount(int awardId) const;
269 
273  int getArmorClass(bool baseOnly = false) const;
274 
278  int getThievery() const;
279 
280  uint getCurrentLevel() const;
281 
285  int itemScan(int itemId) const;
286 
290  void setValue(int id, uint value);
291 
295  bool guildMember() const;
296 
300  uint experienceToNextLevel() const;
301 
305  uint nextExperienceLevel() const;
306 
310  uint getCurrentExperience() const;
311 
315  int getNumSkills() const;
316 
320  int getNumAwards() const;
321 
325  ItemCategory makeItem(int p1, int itemIndex, int p3);
326 
330  void addHitPoints(int amount);
331 
335  void subtractHitPoints(int amount);
336 
340  bool hasSlayerSword() const;
341 
345  bool hasMissileWeapon() const;
346 
350  SpellsCategory getSpellsCategory() const;
351 
356  return (_class == CLASS_PALADIN || _class == CLASS_ARCHER || _class == CLASS_RANGER) ? 1 : 0;
357  }
358 
362  void clearConditions();
363 };
364 
365 class CharacterArray : public Common::Array<Character> {
366 public:
370  int indexOf(const Character &c);
371 };
372 
373 } // End of namespace Xeen
374 
375 #endif /* XEEN_CHARACTER_H */
Definition: str.h:59
bool operator==(const Character &src) const
Definition: character.h:172
Definition: array.h:52
Definition: sprites.h:48
Definition: character.h:92
Definition: character.h:365
Definition: item.h:324
Definition: serializer.h:79
int getSpellsExpenseFactor() const
Definition: character.h:355
bool operator!=(const Character &src) const
Definition: character.h:177
Definition: item.h:244
Definition: item.h:341
Definition: rect.h:45
Definition: xeen.h:100
Definition: character.h:101
Definition: item.h:303
Definition: character.h:33
Definition: item.h:276