ScummVM API documentation
champion.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 /*
23  * Based on the Reverse Engineering work of Christophe Fontanel,
24  * maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
25  */
26 
27 #ifndef DM_CHAMPION_H
28 #define DM_CHAMPION_H
29 
30 #include "common/str.h"
31 
32 #include "dm/dm.h"
33 #include "dm/gfx.h"
34 
35 namespace DM {
36 
37 #define kDMIgnoreObjectModifiers 0x4000 // @ MASK0x4000_IGNORE_OBJECT_MODIFIERS
38 #define kDMIgnoreTemporaryExperience 0x8000 // @ MASK0x8000_IGNORE_TEMPORARY_EXPERIENCE
39 
40 class Scent {
41  uint16 _scent;
42 public:
43  explicit Scent(uint16 scent = 0): _scent(scent) {}
44 
45  uint16 getMapX() { return _scent & 0x1F; }
46  uint16 getMapY() { return (_scent >> 5) & 0x1F; }
47  uint16 getMapIndex() { return (_scent >> 10) & 0x3F; }
48 
49  void setMapX(uint16 val) { _scent = (_scent & ~0x1F) | (val & 0x1F); }
50  void setMapY(uint16 val) { _scent = (_scent & ~(0x1F << 5)) | (val & 0x1F); }
51  void setMapIndex(uint16 val) { _scent = (_scent & ~(0x1F << 10)) | (val & 0x3F); }
52  void setVal(uint16 val) { _scent = val; }
53 
54  uint16 toUint16() { return _scent; }
55 }; // @ SCENT
56 
57 class Party {
58 public:
59  Party() {
60  resetToZero();
61  }
62  int16 _magicalLightAmount;
63  byte _event73Count_ThievesEye;
64  byte _event79Count_Footprints;
65  int16 _shieldDefense;
66 
67  int16 _fireShieldDefense;
68  int16 _spellShieldDefense;
69  byte _scentCount;
70  byte _freezeLifeTicks;
71  byte _firstScentIndex;
72 
73  byte _lastScentIndex;
74  Scent _scents[24]; // if I remember correctly, user defined default constructors are always called
75  byte _scentStrengths[24];
76  byte _event71Count_Invisibility;
77  void resetToZero() {
78  _magicalLightAmount = 0;
79  _event73Count_ThievesEye = 0;
80  _event79Count_Footprints = 0;
81  _shieldDefense = 0;
82 
83  _fireShieldDefense = 0;
84  _spellShieldDefense = 0;
85  _scentCount = 0;
86  _freezeLifeTicks = 0;
87  _firstScentIndex = 0;
88 
89  _lastScentIndex = 0;
90  for (int16 i = 0; i < 24; ++i) {
91  _scents[i].setVal(0);
92  _scentStrengths[i] = 0;
93  }
94  _event71Count_Invisibility = 0;
95  }
96 }; // @ PARTY
97 
98 enum IconIndice {
99  kDMIconIndiceNone = -1, // @ CM1_ICON_NONE
100  kDMIconIndiceJunkCompassNorth = 0, // @ C000_ICON_JUNK_COMPASS_NORTH
101  kDMIconIndiceJunkCompassWest = 3, // @ C003_ICON_JUNK_COMPASS_WEST
102  kDMIconIndiceWeaponTorchUnlit = 4, // @ C004_ICON_WEAPON_TORCH_UNLIT
103  kDMIconIndiceWeaponTorchLit = 7, // @ C007_ICON_WEAPON_TORCH_LIT
104  kDMIconIndiceJunkWater = 8, // @ C008_ICON_JUNK_WATER
105  kDMIconIndiceJunkWaterSkin = 9, // @ C009_ICON_JUNK_WATERSKIN
106  kDMIconIndiceJunkJewelSymalUnequipped = 10, // @ C010_ICON_JUNK_JEWEL_SYMAL_UNEQUIPPED
107  kDMIconIndiceJunkJewelSymalEquipped = 11, // @ C011_ICON_JUNK_JEWEL_SYMAL_EQUIPPED
108  kDMIconIndiceJunkIllumuletUnequipped = 12, // @ C012_ICON_JUNK_ILLUMULET_UNEQUIPPED
109  kDMIconIndiceJunkIllumuletEquipped = 13, // @ C013_ICON_JUNK_ILLUMULET_EQUIPPED
110  kDMIconIndiceWeaponFlamittEmpty = 14, // @ C014_ICON_WEAPON_FLAMITT_EMPTY
111  kDMIconIndiceWeaponEyeOfTimeEmpty = 16, // @ C016_ICON_WEAPON_EYE_OF_TIME_EMPTY
112  kDMIconIndiceWeaponStormringEmpty = 18, // @ C018_ICON_WEAPON_STORMRING_EMPTY
113  kDMIconIndiceWeaponStaffOfClawsEmpty = 20, // @ C020_ICON_WEAPON_STAFF_OF_CLAWS_EMPTY
114  kDMIconIndiceWeaponStaffOfClawsFull = 22, // @ C022_ICON_WEAPON_STAFF_OF_CLAWS_FULL
115  kDMIconIndiceWeaponBoltBladeStormEmpty = 23, // @ C023_ICON_WEAPON_BOLT_BLADE_STORM_EMPTY
116  kDMIconIndiceWeaponFuryRaBladeEmpty = 25, // @ C025_ICON_WEAPON_FURY_RA_BLADE_EMPTY
117  kDMIconIndiceWeaponTheFirestaff = 27, // @ C027_ICON_WEAPON_THE_FIRESTAFF
118  kDMIconIndiceWeaponTheFirestaffComplete = 28, // @ C028_ICON_WEAPON_THE_FIRESTAFF_COMPLETE
119  kDMIconIndiceScrollOpen = 30, // @ C030_ICON_SCROLL_SCROLL_OPEN
120  kDMIconIndiceScrollClosed = 31, // @ C031_ICON_SCROLL_SCROLL_CLOSED
121  kDMIconIndiceWeaponDagger = 32, // @ C032_ICON_WEAPON_DAGGER
122  kDMIconIndiceWeaponDeltaSideSplitter = 38, // @ C038_ICON_WEAPON_DELTA_SIDE_SPLITTER
123  kDMIconIndiceWeaponDiamondEdge = 39, // @ C039_ICON_WEAPON_DIAMOND_EDGE
124  kDMIconIndiceWeaponVorpalBlade = 40, // @ C040_ICON_WEAPON_VORPAL_BLADE
125  kDMIconIndiceWeaponTheInquisitorDragonFang = 41, // @ C041_ICON_WEAPON_THE_INQUISITOR_DRAGON_FANG
126  kDMIconIndiceWeaponHardcleaveExecutioner = 43, // @ C043_ICON_WEAPON_HARDCLEAVE_EXECUTIONER
127  kDMIconIndiceWeaponMaceOfOrder = 45, // @ C045_ICON_WEAPON_MACE_OF_ORDER
128  kDMIconIndiceWeaponArrow = 51, // @ C051_ICON_WEAPON_ARROW
129  kDMIconIndiceWeaponSlayer = 52, // @ C052_ICON_WEAPON_SLAYER
130  kDMIconIndiceWeaponRock = 54, // @ C054_ICON_WEAPON_ROCK
131  kDMIconIndiceWeaponPoisonDart = 55, // @ C055_ICON_WEAPON_POISON_DART
132  kDMIconIndiceWeaponThrowingStar = 56, // @ C056_ICON_WEAPON_THROWING_STAR
133  kDMIconIndiceWeaponStaff = 58, // @ C058_ICON_WEAPON_STAFF
134  kDMIconIndiceWeaponWand = 59, // @ C059_ICON_WEAPON_WAND
135  kDMIconIndiceWeaponTeowand = 60, // @ C060_ICON_WEAPON_TEOWAND
136  kDMIconIndiceWeaponYewStaff = 61, // @ C061_ICON_WEAPON_YEW_STAFF
137  kDMIconIndiceWeaponStaffOfManarStaffOfIrra = 62, // @ C062_ICON_WEAPON_STAFF_OF_MANAR_STAFF_OF_IRRA
138  kDMIconIndiceWeaponSnakeStaffCrossOfNeta = 63, // @ C063_ICON_WEAPON_SNAKE_STAFF_CROSS_OF_NETA
139  kDMIconIndiceWeaponTheConduitSerpentStaff = 64, // @ C064_ICON_WEAPON_THE_CONDUIT_SERPENT_STAFF
140  kDMIconIndiceWeaponDragonSpit = 65, // @ C065_ICON_WEAPON_DRAGON_SPIT
141  kDMIconIndiceWeaponSceptreOfLyf = 66, // @ C066_ICON_WEAPON_SCEPTRE_OF_LYF
142  kDMIconIndiceArmourCloakOfNight = 81, // @ C081_ICON_ARMOUR_CLOAK_OF_NIGHT
143  kDMIconIndiceArmourCrownOfNerra = 104, // @ C104_ICON_ARMOUR_CROWN_OF_NERRA
144  kDMIconIndiceArmourElvenBoots = 119, // @ C119_ICON_ARMOUR_ELVEN_BOOTS
145  kDMIconIndiceJunkGemOfAges = 120, // @ C120_ICON_JUNK_GEM_OF_AGES
146  kDMIconIndiceJunkEkkhardCross = 121, // @ C121_ICON_JUNK_EKKHARD_CROSS
147  kDMIconIndiceJunkMoonstone = 122, // @ C122_ICON_JUNK_MOONSTONE
148  kDMIconIndiceJunkPendantFeral = 124, // @ C124_ICON_JUNK_PENDANT_FERAL
149  kDMIconIndiceJunkBoulder = 128, // @ C128_ICON_JUNK_BOULDER
150  kDMIconIndiceJunkRabbitsFoot = 137, // @ C137_ICON_JUNK_RABBITS_FOOT
151  kDMIconIndiceArmourDexhelm = 140, // @ C140_ICON_ARMOUR_DEXHELM
152  kDMIconIndiceArmourFlamebain = 141, // @ C141_ICON_ARMOUR_FLAMEBAIN
153  kDMIconIndiceArmourPowertowers = 142, // @ C142_ICON_ARMOUR_POWERTOWERS
154  kDMIconIndiceContainerChestClosed = 144, // @ C144_ICON_CONTAINER_CHEST_CLOSED
155  kDMIconIndiceContainerChestOpen = 145, // @ C145_ICON_CONTAINER_CHEST_OPEN
156  kDMIconIndiceJunkChampionBones = 147, // @ C147_ICON_JUNK_CHAMPION_BONES
157  kDMIconIndicePotionMaPotionMonPotion = 148, // @ C148_ICON_POTION_MA_POTION_MON_POTION
158  kDMIconIndicePotionWaterFlask = 163, // @ C163_ICON_POTION_WATER_FLASK
159  kDMIconIndiceJunkApple = 168, // @ C168_ICON_JUNK_APPLE
160  kDMIconIndiceJunkIronKey = 176, // @ C176_ICON_JUNK_IRON_KEY
161  kDMIconIndiceJunkMasterKey = 191, // @ C191_ICON_JUNK_MASTER_KEY
162  kDMIconIndiceArmourBootOfSpeed = 194, // @ C194_ICON_ARMOUR_BOOT_OF_SPEED
163  kDMIconIndicePotionEmptyFlask = 195, // @ C195_ICON_POTION_EMPTY_FLASK
164  kDMIconIndiceJunkZokathra = 197, // @ C197_ICON_JUNK_ZOKATHRA
165  kDMIconIndiceActionEmptyHand = 201, // @ C201_ICON_ACTION_ICON_EMPTY_HAND
166  kDMIconIndiceEyeNotLooking = 202, // @ C202_ICON_EYE_NOT_LOOKING /* One pixel is different in this bitmap from the eye in C017_GRAPHIC_INVENTORY. This is visible by selecting another champion after clicking the eye */
167  kDMIconIndiceEyeLooking = 203, // @ C203_ICON_EYE_LOOKING
168  kDMIconIndiceEmptyBox = 204, // @ C204_ICON_EMPTY_BOX
169  kDMIconIndiceMouthOpen = 205, // @ C205_ICON_MOUTH_OPEN
170  kDMIconIndiceNeck = 208, // @ C208_ICON_NECK
171  kDMIconIndiceReadyHand = 212 // @ C212_ICON_READY_HAND
172 };
173 
174 enum ChampionIndex {
175  kDMChampionNone = -1, // @ CM1_CHAMPION_NONE
176  kDMChampionFirst = 0, // @ C00_CHAMPION_FIRST
177  kDMChampionSecond = 1,
178  kDMChampionThird = 2,
179  kDMChampionFourth = 3,
180  kDMChampionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY
181  kDMChampionSpecialInventory = 5 // @ C05_CHAMPION_SPECIAL_INVENTORY
182 };
183 
184 enum ChampionAttribute {
185  kDMAttributNone = 0x0000, // @ MASK0x0000_NONE
186  kDMAttributeDisableAction = 0x0008, // @ MASK0x0008_DISABLE_ACTION
187  kDMAttributeMale = 0x0010, // @ MASK0x0010_MALE
188  kDMAttributeNameTitle = 0x0080, // @ MASK0x0080_NAME_TITLE
189  kDMAttributeStatistics = 0x0100, // @ MASK0x0100_STATISTICS
190  kDMAttributeLoad = 0x0200, // @ MASK0x0200_LOAD
191  kDMAttributeIcon = 0x0400, // @ MASK0x0400_ICON
192  kDMAttributePanel = 0x0800, // @ MASK0x0800_PANEL
193  kDMAttributeStatusBox = 0x1000, // @ MASK0x1000_STATUS_BOX
194  kDMAttributeWounds = 0x2000, // @ MASK0x2000_WOUNDS
195  kDMAttributeViewport = 0x4000, // @ MASK0x4000_VIEWPORT
196  kDMAttributeActionHand = 0x8000 // @ MASK0x8000_ACTION_HAND
197 };
198 
199 enum ChampionWound {
200  kDMWoundNone = 0x0000, // @ MASK0x0000_NO_WOUND
201  kDMWoundReadHand = 0x0001, // @ MASK0x0001_READY_HAND
202  kDMWoundActionHand = 0x0002, // @ MASK0x0002_ACTION_HAND
203  kDMWoundHead = 0x0004, // @ MASK0x0004_HEAD
204  kDMWoundTorso = 0x0008, // @ MASK0x0008_TORSO
205  kDMWoundLegs = 0x0010, // @ MASK0x0010_LEGS
206  kDMWoundFeet = 0x0020 // @ MASK0x0020_FEET
207 };
208 
209 enum ChampionStatType {
210  kDMStatLuck = 0, // @ C0_STATISTIC_LUCK
211  kDMStatStrength = 1, // @ C1_STATISTIC_STRENGTH
212  kDMStatDexterity = 2, // @ C2_STATISTIC_DEXTERITY
213  kDMStatWisdom = 3, // @ C3_STATISTIC_WISDOM
214  kDMStatVitality = 4, // @ C4_STATISTIC_VITALITY
215  kDMStatAntimagic = 5, // @ C5_STATISTIC_ANTIMAGIC
216  kDMStatAntifire = 6, // @ C6_STATISTIC_ANTIFIRE
217  kDMStatMana = 8 // @ C8_STATISTIC_MANA /* Used as a fake statistic index for objects granting a Mana bonus */
218 };
219 
220 enum ChampionStatValue {
221  kDMStatMaximum = 0, // @ C0_MAXIMUM
222  kDMStatCurrent = 1, // @ C1_CURRENT
223  kDMStatMinimum = 2 // @ C2_MINIMUM
224 };
225 
226 enum ChampionSkill {
227  kDMSkillFighter = 0, // @ C00_SKILL_FIGHTER
228  kDMSkillNinja = 1, // @ C01_SKILL_NINJA
229  kDMSkillPriest = 2, // @ C02_SKILL_PRIEST
230  kDMSkillWizard = 3, // @ C03_SKILL_WIZARD
231  kDMSkillSwing = 4, // @ C04_SKILL_SWING
232  kDMSkillThrust = 5, // @ C05_SKILL_THRUST
233  kDMSkillClub = 6, // @ C06_SKILL_CLUB
234  kDMSkillParry = 7, // @ C07_SKILL_PARRY
235  kDMSkillSteal = 8, // @ C08_SKILL_STEAL
236  kDMSkillFight = 9, // @ C09_SKILL_FIGHT
237  kDMSkillThrow = 10, // @ C10_SKILL_THROW
238  kDMSkillShoot = 11, // @ C11_SKILL_SHOOT
239  kDMSkillIdentify = 12, // @ C12_SKILL_IDENTIFY
240  kDMSkillHeal = 13, // @ C13_SKILL_HEAL
241  kDMSkillInfluence = 14, // @ C14_SKILL_INFLUENCE
242  kDMSkillDefend = 15, // @ C15_SKILL_DEFEND
243  kDMSkillFire = 16, // @ C16_SKILL_FIRE
244  kDMSkillAir = 17, // @ C17_SKILL_AIR
245  kDMSkillEarth = 18, // @ C18_SKILL_EARTH
246  kDMSkillWater = 19 // @ C19_SKILL_WATER
247 };
248 
249 enum ChampionSlot {
250  kDMSlotLeaderHand = -1, // @ CM1_SLOT_LEADER_HAND
251  kDMSlotReadyHand = 0, // @ C00_SLOT_READY_HAND
252  kDMSlotActionHand = 1, // @ C01_SLOT_ACTION_HAND
253  kDMSlotHead = 2, // @ C02_SLOT_HEAD
254  kDMSlotTorso = 3, // @ C03_SLOT_TORSO
255  kDMSlotLegs = 4, // @ C04_SLOT_LEGS
256  kDMSlotFeet = 5, // @ C05_SLOT_FEET
257  kDMSlotPouch_2 = 6, // @ C06_SLOT_POUCH_2
258  kDMSlotQuiverLine2_1 = 7, // @ C07_SLOT_QUIVER_LINE2_1
259  kDMSlotQuiverLine1_2 = 8, // @ C08_SLOT_QUIVER_LINE1_2
260  kDMSlotQuiverLine2_2 = 9, // @ C09_SLOT_QUIVER_LINE2_2
261  kDMSlotNeck = 10, // @ C10_SLOT_NECK
262  kDMSlotPouch1 = 11, // @ C11_SLOT_POUCH_1
263  kDMSlotQuiverLine1_1 = 12, // @ C12_SLOT_QUIVER_LINE1_1
264  kDMSlotBackpackLine1_1 = 13, // @ C13_SLOT_BACKPACK_LINE1_1
265  kDMSlotBackpackLine2_2 = 14, // @ C14_SLOT_BACKPACK_LINE2_2
266  kDMSlotBackpackLine2_3 = 15, // @ C15_SLOT_BACKPACK_LINE2_3
267  kDMSlotBackpackLine2_4 = 16, // @ C16_SLOT_BACKPACK_LINE2_4
268  kDMSlotBackpackLine2_5 = 17, // @ C17_SLOT_BACKPACK_LINE2_5
269  kDMSlotBackpackLine2_6 = 18, // @ C18_SLOT_BACKPACK_LINE2_6
270  kDMSlotBackpackLine2_7 = 19, // @ C19_SLOT_BACKPACK_LINE2_7
271  kDMSlotBackpackLine2_8 = 20, // @ C20_SLOT_BACKPACK_LINE2_8
272  kDMSlotBackpackLine2_9 = 21, // @ C21_SLOT_BACKPACK_LINE2_9
273  kDMSlotBackpackLine1_2 = 22, // @ C22_SLOT_BACKPACK_LINE1_2
274  kDMSlotBackpackLine1_3 = 23, // @ C23_SLOT_BACKPACK_LINE1_3
275  kDMSlotBackpackLine1_4 = 24, // @ C24_SLOT_BACKPACK_LINE1_4
276  kDMSlotBackpackLine1_5 = 25, // @ C25_SLOT_BACKPACK_LINE1_5
277  kDMSlotBackpackLine1_6 = 26, // @ C26_SLOT_BACKPACK_LINE1_6
278  kDMSlotBackpackLine1_7 = 27, // @ C27_SLOT_BACKPACK_LINE1_7
279  kDMSlotBackpackLine1_8 = 28, // @ C28_SLOT_BACKPACK_LINE1_8
280  kDMSlotBackpackLine1_9 = 29, // @ C29_SLOT_BACKPACK_LINE1_9
281  kDMSlotChest1 = 30, // @ C30_SLOT_CHEST_1
282  kDMSlotChest2 = 31, // @ C31_SLOT_CHEST_2
283  kDMSlotChest3 = 32, // @ C32_SLOT_CHEST_3
284  kDMSlotChest4 = 33, // @ C33_SLOT_CHEST_4
285  kDMSlotChest5 = 34, // @ C34_SLOT_CHEST_5
286  kDMSlotChest6 = 35, // @ C35_SLOT_CHEST_6
287  kDMSlotChest7 = 36, // @ C36_SLOT_CHEST_7
288  kDMSlotChest8 = 37 // @ C37_SLOT_CHEST_8
289 };
290 
291 enum ChampionAction {
292  kDMActionN = 0, // @ C000_ACTION_N
293  kDMActionBlock = 1, // @ C001_ACTION_BLOCK
294  kDMActionChop = 2, // @ C002_ACTION_CHOP
295  kDMActionX = 3, // @ C003_ACTION_X
296  kDMActionBlowHorn = 4, // @ C004_ACTION_BLOW_HORN
297  kDMActionFlip = 5, // @ C005_ACTION_FLIP
298  kDMActionPunch = 6, // @ C006_ACTION_PUNCH
299  kDMActionKick = 7, // @ C007_ACTION_KICK
300  kDMActionWarCry = 8, // @ C008_ACTION_WAR_CRY
301  kDMActionStab9 = 9, // @ C009_ACTION_STAB
302  kDMActionClimbDown = 10, // @ C010_ACTION_CLIMB_DOWN
303  kDMActionFreezeLife = 11, // @ C011_ACTION_FREEZE_LIFE
304  kDMActionHit = 12, // @ C012_ACTION_HIT
305  kDMActionSwing = 13, // @ C013_ACTION_SWING
306  kDMActionStab14 = 14, // @ C014_ACTION_STAB
307  kDMActionThrust = 15, // @ C015_ACTION_THRUST
308  kDMActionJab = 16, // @ C016_ACTION_JAB
309  kDMActionParry = 17, // @ C017_ACTION_PARRY
310  kDMActionHack = 18, // @ C018_ACTION_HACK
311  kDMActionBerzerk = 19, // @ C019_ACTION_BERZERK
312  kDMActionFireball = 20, // @ C020_ACTION_FIREBALL
313  kDMActionDispel = 21, // @ C021_ACTION_DISPELL
314  kDMActionConfuse = 22, // @ C022_ACTION_CONFUSE
315  kDMActionLightning = 23, // @ C023_ACTION_LIGHTNING
316  kDMActionDisrupt = 24, // @ C024_ACTION_DISRUPT
317  kDMActionMelee = 25, // @ C025_ACTION_MELEE
318  kDMActionX_C026 = 26, // @ C026_ACTION_X
319  kDMActionInvoke = 27, // @ C027_ACTION_INVOKE
320  kDMActionSlash = 28, // @ C028_ACTION_SLASH
321  kDMActionCleave = 29, // @ C029_ACTION_CLEAVE
322  kDMActionBash = 30, // @ C030_ACTION_BASH
323  kDMActionStun = 31, // @ C031_ACTION_STUN
324  kDMActionShoot = 32, // @ C032_ACTION_SHOOT
325  kDMActionSpellshield = 33, // @ C033_ACTION_SPELLSHIELD
326  kDMActionFireshield = 34, // @ C034_ACTION_FIRESHIELD
327  kDMActionFluxcage = 35, // @ C035_ACTION_FLUXCAGE
328  kDMActionHeal = 36, // @ C036_ACTION_HEAL
329  kDMActionCalm = 37, // @ C037_ACTION_CALM
330  kDMActionLight = 38, // @ C038_ACTION_LIGHT
331  kDMActionWindow = 39, // @ C039_ACTION_WINDOW
332  kDMActionSpit = 40, // @ C040_ACTION_SPIT
333  kDMActionBrandish = 41, // @ C041_ACTION_BRANDISH
334  kDMActionThrow = 42, // @ C042_ACTION_THROW
335  kDMActionFuse = 43, // @ C043_ACTION_FUSE
336  kDMActionNone = 255 // @ C255_ACTION_NONE
337 };
338 
339 enum AttackType {
340  kDMAttackTypeNormal = 0, // @ C0_ATTACK_NORMAL
341  kDMAttackTypeFire = 1, // @ C1_ATTACK_FIRE
342  kDMAttackTypeSelf = 2, // @ C2_ATTACK_SELF
343  kDMAttackTypeBlunt = 3, // @ C3_ATTACK_BLUNT
344  kDMAttackTypeSharp = 4, // @ C4_ATTACK_SHARP
345  kDMAttackTypeMagic = 5, // @ C5_ATTACK_MAGIC
346  kDMAttackTypePsychic = 6, // @ C6_ATTACK_PSYCHIC
347  kDMAttackTypeLightning = 7 // @ C7_ATTACK_LIGHTNING
348 };
349 
350 enum SpellCastResult {
351  kDMSpellCastFailure = 0, // @ C0_SPELL_CAST_FAILURE
352  kDMSpellCastSuccess = 1, // @ C1_SPELL_CAST_SUCCESS
353  kDMSpellCastFailureNeedsFlask = 3 // @ C3_SPELL_CAST_FAILURE_NEEDS_FLASK
354 };
355 
356 enum SpellFailure {
357  kDMFailureNeedsMorePractice = 0, // @ C00_FAILURE_NEEDS_MORE_PRACTICE
358  kDMFailureMeaninglessSpell = 1, // @ C01_FAILURE_MEANINGLESS_SPELL
359  kDMFailureNeedsFlaskInHand = 10, // @ C10_FAILURE_NEEDS_FLASK_IN_HAND
360  kDMFailureNeedsMagicMapInHand = 11 // @ C11_FAILURE_NEEDS_MAGIC_MAP_IN_HAND
361 };
362 
363 enum SpellKind {
364  kDMSpellKindPotion = 1, // @ C1_SPELL_KIND_POTION
365  kDMSpellKindProjectile = 2, // @ C2_SPELL_KIND_PROJECTILE
366  kDMSpellKindOther = 3, // @ C3_SPELL_KIND_OTHER
367  kDMSpellKindMagicMap = 4 // @ C4_SPELL_KIND_MAGIC_MAP
368 };
369 
370 enum SpellType {
371  kDMSpellTypeProjectileOpenDoor = 4, // @ C4_SPELL_TYPE_PROJECTILE_OPEN_DOOR
372  kDMSpellTypeOtherLight = 0, // @ C0_SPELL_TYPE_OTHER_LIGHT
373  kDMSpellTypeOtherDarkness = 1, // @ C1_SPELL_TYPE_OTHER_DARKNESS
374  kDMSpellTypeOtherThievesEye = 2, // @ C2_SPELL_TYPE_OTHER_THIEVES_EYE
375  kDMSpellTypeOtherInvisibility = 3, // @ C3_SPELL_TYPE_OTHER_INVISIBILITY
376  kDMSpellTypeOtherPartyShield = 4, // @ C4_SPELL_TYPE_OTHER_PARTY_SHIELD
377  kDMSpellTypeOtherMagicTorch = 5, // @ C5_SPELL_TYPE_OTHER_MAGIC_TORCH
378  kDMSpellTypeOtherFootprints = 6, // @ C6_SPELL_TYPE_OTHER_FOOTPRINTS
379  kDMSpellTypeOtherZokathra = 7, // @ C7_SPELL_TYPE_OTHER_ZOKATHRA
380  kDMSpellTypeOtherFireshield = 8, // @ C8_SPELL_TYPE_OTHER_FIRESHIELD
381  kDMSpellTypeMagicMap0 = 0, // @ C0_SPELL_TYPE_MAGIC_MAP
382  kDMSpellTypeMagicMap1 = 1, // @ C1_SPELL_TYPE_MAGIC_MAP
383  kDMSpellTypeMagicMap2 = 2, // @ C2_SPELL_TYPE_MAGIC_MAP
384  kDMSpellTypeMagicMap3 = 3 // @ C3_SPELL_TYPE_MAGIC_MAP
385 };
386 
387 #define kDMMaskNoSharpDefense 0x0000 // @ MASK0x0000_DO_NOT_USE_SHARP_DEFENSE
388 #define kDMMaskSharpDefense 0x8000 // @ MASK0x8000_USE_SHARP_DEFENSE
389 
390 class Skill {
391 public:
392  int16 _temporaryExperience;
393  int32 _experience;
394 
395  void resetToZero() { _temporaryExperience = _experience = 0; }
396 }; // @ SKILL
397 
398 class Champion {
399 private:
400  DMEngine *_vm;
401 
402 public:
403  uint16 _attributes;
404  uint16 _wounds;
405  byte _statistics[7][3];
406  Thing _slots[30];
407  Skill _skills[20];
408  char _name[8];
409  char _title[20];
410  Direction _dir;
411  ViewCell _cell;
412  ChampionAction _actionIndex;
413  uint16 _symbolStep;
414  char _symbols[5];
415  uint16 _directionMaximumDamageReceived;
416  uint16 _maximumDamageReceived;
417  uint16 _poisonEventCount;
418  int16 _enableActionEventIndex;
419  int16 _hideDamageReceivedIndex;
420  int16 _currHealth;
421  int16 _maxHealth;
422  int16 _currStamina;
423  int16 _maxStamina;
424  int16 _currMana;
425  int16 _maxMana;
426  int16 _actionDefense;
427  int16 _food;
428  int16 _water;
429  uint16 _load;
430  int16 _shieldDefense;
431  byte _portrait[928]; // 32 x 29 pixel portrait
432 
433  Champion() {}
434  void setVm(DMEngine *vm) { _vm = vm; }
435 
436  Thing &getSlot(ChampionSlot slot) { return _slots[slot]; }
437  void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; }
438 
439  Skill &getSkill(ChampionSkill skill) { return _skills[skill]; }
440  void setSkillExp(ChampionSkill skill, int32 val) { _skills[skill]._experience = val; }
441  void setSkillTempExp(ChampionSkill skill, int16 val) { _skills[skill]._temporaryExperience= val; }
442 
443  byte& getStatistic(ChampionStatType type, ChampionStatValue valType) { return _statistics[type][valType]; }
444  void setStatistic(ChampionStatType type, ChampionStatValue valType, byte newVal) { _statistics[type][valType] = newVal; }
445 
446  uint16 getAttributes() { return _attributes; }
447  uint16 getAttributes(ChampionAttribute flag) { return _attributes & flag; }
448  void setAttributeFlag(ChampionAttribute flag, bool value);
449  void clearAttributes(ChampionAttribute attribute = kDMAttributNone) { _attributes = attribute; }
450 
451  uint16 getWounds() { return _wounds; }
452  void setWoundsFlag(ChampionWound flag, bool value);
453  uint16 getWoundsFlag(ChampionWound wound) { return _wounds & wound; }
454  void clearWounds() { _wounds = kDMWoundNone; }
455  void resetSkillsToZero() {
456  for (int16 i = 0; i < 20; ++i)
457  _skills[i].resetToZero();
458  }
459  void resetToZero();
460 
461 }; // @ CHAMPION_INCLUDING_PORTRAIT
462 
463 class Spell {
464 public:
465  Spell() {}
466  Spell(int32 symbols, byte baseSkillReq, byte skillIndex, uint16 attributes)
467  : _symbols(symbols), _baseRequiredSkillLevel(baseSkillReq), _skillIndex(skillIndex), _attributes(attributes) {}
468 
469  int32 _symbols; /* Most significant byte: 0 (spell definition does not include power symbol) / not 0 (spell definition includes power symbol) */
470  byte _baseRequiredSkillLevel;
471  byte _skillIndex;
472  uint16 _attributes; /* Bits 15-10: Duration, Bits 9-4: Type, Bits 3-0: Kind */
473 
474  uint16 getKind() { return _attributes & 0xF; } // @ M67_SPELL_KIND
475  uint16 getType() { return (_attributes >> 4) & 0x3F; } // @ M68_SPELL_TYPE
476  uint16 getDuration() { return (_attributes >> 10) & 0x3F; } // @ M69_SPELL_DURATION
477 }; // @ SPELL
478 
479 class ChampionMan {
480  DMEngine *_vm;
481 
482  uint16 getChampionPortraitX(uint16 index); // @ M27_PORTRAIT_X
483  uint16 getChampionPortraitY(uint16 index); // @ M28_PORTRAIT_Y
484 
485  int16 getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue
486  void drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue
487  uint16 getHandSlotIndex(uint16 slotBoxIndex);// @ M70_HAND_SLOT_INDEX
488  int16 _championPendingWounds[4]; // @ G0410_ai_ChampionPendingWounds
489  int16 _championPendingDamage[4]; // @ G0409_ai_ChampionPendingDamage
490 
491  void initConstants();
492 
493 public:
494 
495  Champion *_champions; // @ K0071_as_Champions
496  uint16 _partyChampionCount; // @ G0305_ui_PartyChampionCount
497  bool _partyDead; // @ G0303_B_PartyDead
498  Thing _leaderHandObject; // @ G0414_T_LeaderHandObject
499  ChampionIndex _leaderIndex; // @ G0411_i_LeaderIndex
500  uint16 _candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal
501  bool _partyIsSleeping; // @ G0300_B_PartyIsSleeping
502  uint16 _actingChampionOrdinal; // @ G0506_ui_ActingChampionOrdinal
503  IconIndice _leaderHandObjectIconIndex; // @ G0413_i_LeaderHandObjectIconIndex
504  bool _leaderEmptyHanded; // @ G0415_B_LeaderEmptyHanded
505  Party _party; // @ G0407_s_Party
506  ChampionIndex _magicCasterChampionIndex; // @ G0514_i_MagicCasterChampionIndex
507  bool _mousePointerHiddenToDrawChangedObjIconOnScreen; // @ G0420_B_MousePointerHiddenToDrawChangedObjectIconOnScreen
508 
509  explicit ChampionMan(DMEngine *vm);
510  ~ChampionMan();
511 
512  ChampionIndex getIndexInCell(int16 cell); // @ F0285_CHAMPION_GetIndexInCell
513  bool isLeaderHandObjectThrown(int16 side); // @ F0329_CHAMPION_IsLeaderHandObjectThrown
514  bool isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side); // @ F0328_CHAMPION_IsObjectThrown
515  void resetDataToStartGame(); // @ F0278_CHAMPION_ResetDataToStartGame
516  void addCandidateChampionToParty(uint16 championPortraitIndex); // @ F0280_CHAMPION_AddCandidateChampionToParty
517  void drawChampionBarGraphs(ChampionIndex champIndex); // @ F0287_CHAMPION_DrawBarGraphs
518  uint16 getStaminaAdjustedValue(Champion *champ, int16 val); // @ F0306_CHAMPION_GetStaminaAdjustedValue
519  uint16 getMaximumLoad(Champion *champ); // @ F0309_CHAMPION_GetMaximumLoad
520  void drawChampionState(ChampionIndex champIndex); // @ F0292_CHAMPION_DrawState
521  uint16 getChampionIconIndex(int16 val, Direction dir); // @ M26_CHAMPION_ICON_INDEX
522  void drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues
523  void drawSlot(uint16 champIndex, int16 slotIndex); // @ F0291_CHAMPION_DrawSlot
524  void renameChampion(Champion *champ); // @ F0281_CHAMPION_Rename
525  uint16 getSkillLevel(int16 champIndex, uint16 skillIndex);// @ F0303_CHAMPION_GetSkillLevel
526  Common::String getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger
527  void applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex,
528  int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics
529  bool hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged
530  void drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons
531  void addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex); // @ F0301_CHAMPION_AddObjectInSlot
532  int16 getScentOrdinal(int16 mapX, int16 mapY); // @ F0315_CHAMPION_GetScentOrdinal
533  Thing getObjectRemovedFromLeaderHand(); // @ F0298_CHAMPION_GetObjectRemovedFromLeaderHand
534  uint16 getStrength(int16 champIndex, int16 slotIndex); // @ F0312_CHAMPION_GetStrength
535  Thing getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex); // @ F0300_CHAMPION_GetObjectRemovedFromSlot
536  void decrementStamina(int16 championIndex, int16 decrement); // @ F0325_CHAMPION_DecrementStamina
537  int16 addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds,
538  uint16 attackType); // @ F0321_CHAMPION_AddPendingDamageAndWounds_GetDamage
539  int16 getWoundDefense(int16 champIndex, uint16 woundIndex); // @ F0313_CHAMPION_GetWoundDefense
540  uint16 getStatisticAdjustedAttack(Champion *champ, uint16 statIndex, uint16 attack); // @ F0307_CHAMPION_GetStatisticAdjustedAttack
541  void wakeUp(); // @ F0314_CHAMPION_WakeUp
542  int16 getThrowingStaminaCost(Thing thing);// @ F0305_CHAMPION_GetThrowingStaminaCost
543  void disableAction(uint16 champIndex, uint16 ticks); // @ F0330_CHAMPION_DisableAction
544  void addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp);// @ F0304_CHAMPION_AddSkillExperience
545  int16 getDamagedChampionCount(uint16 attack, int16 wounds,
546  int16 attackType); // @ F0324_CHAMPION_DamageAll_GetDamagedChampionCount
547  int16 getTargetChampionIndex(int16 mapX, int16 mapY, uint16 cell); // @ F0286_CHAMPION_GetTargetChampionIndex
548  int16 getDexterity(Champion *champ); // @ F0311_CHAMPION_GetDexterity
549  bool isLucky(Champion *champ, uint16 percentage); // @ F0308_CHAMPION_IsLucky
550  void championPoison(int16 championIndex, uint16 attack); // @ F0322_CHAMPION_Poison
551  void setPartyDirection(int16 dir); // @ F0284_CHAMPION_SetPartyDirection
552  void deleteScent(uint16 scentIndex); // @ F0316_CHAMPION_DeleteScent
553  void addScentStrength(int16 mapX, int16 mapY, int32 cycleCount); // @ F0317_CHAMPION_AddScentStrength
554  void putObjectInLeaderHand(Thing thing, bool setMousePointer); // @ F0297_CHAMPION_PutObjectInLeaderHand
555  int16 getMovementTicks(Champion *champ); // @ F0310_CHAMPION_GetMovementTicks
556  bool isAmmunitionCompatibleWithWeapon(uint16 champIndex, uint16 weaponSlotIndex,
557  uint16 ammunitionSlotIndex); // @ F0294_CHAMPION_IsAmmunitionCompatibleWithWeapon
558  void drawAllChampionStates(); // @ F0293_CHAMPION_DrawAllChampionStates
559  void viAltarRebirth(uint16 champIndex); // @ F0283_CHAMPION_ViAltarRebirth
560  void clickOnSlotBox(uint16 slotBoxIndex); // @ F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox
561  bool isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount); // @ F0327_CHAMPION_IsProjectileSpellCast
562  void championShootProjectile(Champion *champ, Thing thing, int16 kineticEnergy,
563  int16 attack, int16 stepEnergy); // @ F0326_CHAMPION_ShootProjectile
564  void applyAndDrawPendingDamageAndWounds(); // @ F0320_CHAMPION_ApplyAndDrawPendingDamageAndWounds
565  void championKill(uint16 champIndex); // @ F0319_CHAMPION_Kill
566  void dropAllObjects(uint16 champIndex); // @ F0318_CHAMPION_DropAllObjects
567  void unpoison(int16 champIndex); // @ F0323_CHAMPION_Unpoison
568  void applyTimeEffects(); // @ F0331_CHAMPION_ApplyTimeEffects_CPSF
569  void savePartyPart2(Common::OutSaveFile *file);
570  void loadPartyPart2(Common::InSaveFile *file);
571 
572  Box _boxChampionIcons[4];
573  Color _championColor[4];
574  int16 _lightPowerToLightAmount[16]; // g039_LightPowerToLightAmount
575  Box _boxChampionPortrait;
576  uint16 _slotMasks[38];
577  const char *_baseSkillName[4];
578 };
579 
580 }
581 
582 #endif
Definition: str.h:59
Definition: savefile.h:54
Definition: dm.h:117
Definition: stream.h:745
Definition: champion.h:40
Definition: champion.h:463
Definition: gfx.h:372
Definition: champion.h:390
Definition: champion.h:57
Definition: champion.h:35
Definition: dm.h:155
Definition: champion.h:479
Definition: champion.h:398