ScummVM API documentation
combat.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_COMBAT_H
23 #define XEEN_COMBAT_H
24 
25 #include "common/scummsys.h"
26 #include "common/rect.h"
27 #include "mm/xeen/files.h"
28 #include "mm/xeen/sprites.h"
29 
30 namespace MM {
31 namespace Xeen {
32 
33 #define MAX_NUM_MONSTERS 107
34 #define PARTY_AND_MONSTERS 12
35 #define POW_COUNT 12
36 #define ATTACK_MONSTERS_COUNT 26
37 
38 enum DamageType {
39  DT_PHYSICAL = 0, DT_MAGICAL = 1, DT_FIRE = 2, DT_ELECTRICAL = 3,
40  DT_COLD = 4, DT_POISON = 5, DT_ENERGY = 6, DT_SLEEP = 7,
41  DT_FINGEROFDEATH = 8, DT_HOLYWORD = 9, DT_MASS_DISTORTION = 10,
42  DT_UNDEAD = 11, DT_BEASTMASTER = 12, DT_DRAGONSLEEP = 13,
43  DT_GOLEMSTOPPER = 14, DT_HYPNOTIZE = 15, DT_INSECT_SPRAY = 16,
44  DT_POISON_VOLLEY = 17, DT_MAGIC_ARROW = 18
45 };
46 
47 enum SpecialAttack {
48  SA_NONE = 0, SA_MAGIC = 1, SA_FIRE = 2, SA_ELEC = 3, SA_COLD = 4,
49  SA_POISON = 5, SA_ENERGY = 6, SA_DISEASE = 7, SA_INSANE = 8,
50  SA_SLEEP = 9, SA_CURSEITEM = 10, SA_INLOVE = 11, SA_DRAINSP = 12,
51  SA_CURSE = 13, SA_PARALYZE = 14, SA_UNCONSCIOUS = 15,
52  SA_CONFUSE = 16, SA_BREAKWEAPON = 17, SA_WEAKEN = 18,
53  SA_ERADICATE = 19, SA_AGING = 20, SA_DEATH = 21, SA_STONE = 22
54 };
55 
56 enum ShootType {
57  ST_0 = 0, ST_1 = 1
58 };
59 
60 enum CombatMode {
61  COMBATMODE_STARTUP = 0, COMBATMODE_INTERACTIVE = 1, COMBATMODE_2 = 2
62 };
63 
64 enum PowType {
65  POW_INVALID = -1, POW_FIREBALL = 0, POW_INCINERATE = 1,
66  POW_FIERY_FLAIL = 2, POW_LIGHTNING = 3, POW_MEGAVOLTS = 4,
67  POW_SPARKS = 5, POW_STOPPER = 6, POW_MAGIC_ORB = 7,
68  POW_COLD_RAY = 8, POW_FROST_WAVE = 9, POW_SPRAY = 10,
69  POW_ARROW = 11, POW_MAGIC_ARROW = 12, POW_ENERGY_BLAST = 13,
70  POW_SPARKLES = 14, POW_DEADLY_SWARM = 15
71 };
72 
73 enum RangeType {
74  RT_SINGLE = 0, RT_GROUP = 1, RT_ALL = 2, RT_HIT = 3
75 };
76 
77 class XeenEngine;
78 class Character;
79 class XeenItem;
80 class MonsterStruct;
81 
82 struct PowSlot {
83  bool _active;
84  int _duration;
85  int _scale;
86  int _elemFrame;
87  int _elemScale;
88 
89  PowSlot() : _active(false), _duration(0), _scale(0),
90  _elemFrame(0), _elemScale(0) {}
91 };
92 
93 class PowSlots {
94 private:
95  PowSlot _data[POW_COUNT];
96 public:
100  PowSlot &operator[](uint idx) {
101  assert(idx < POW_COUNT);
102  return _data[idx];
103  }
104 
109  for (int idx = 0; idx < POW_COUNT; ++idx)
110  _data[idx]._elemFrame = 0;
111  }
112 };
113 
114 class Combat {
115 private:
116  XeenEngine *_vm;
117 
121  void attack2(int damage, RangeType rangeType);
122 
126  bool hitMonster(Character &c, RangeType rangeType);
127 
131  void getWeaponDamage(Character &c, RangeType rangeType);
132 
136  int getMonsterDamage(Character &c);
137 
141  int getDamageScale(int v);
142 
146  int getMonsterResistence(RangeType rangeType);
147 
151  void giveExperience(int experience);
152 public:
153  Common::Array<Character *> _combatParty;
154  bool _charsBlocked[PARTY_AND_MONSTERS];
155  int _charsGone[PARTY_AND_MONSTERS];
156  SpriteResource _powSprites;
157  int _attackMonsters[ATTACK_MONSTERS_COUNT];
158  int _monster2Attack;
159  PowSlots _pow;
160  int _missedShot[8];
161  Common::Array<int> _speedTable;
162  int _shootingRow[8];
163  int _globalCombat;
164  int _whosTurn;
165  bool _itemFlag;
166  int _monsterMap[32][32];
167  bool _monsterMoved[MAX_NUM_MONSTERS];
168  bool _rangeAttacking[MAX_NUM_MONSTERS];
169  int _gmonHit[36];
170  bool _monstersAttacking;
171  CombatMode _combatMode;
172  int _attackDurationCtr;
173  bool _partyRan;
174  int _whosSpeed;
175  DamageType _damageType;
176  Character *_oldCharacter;
177  int _monsterDamage;
178  int _weaponDamage;
179  int _weaponDie, _weaponDice;
180  int _weaponElemMaterial;
181  XeenItem *_attackWeapon;
182  int _attackWeaponId;
183  File _missVoc;
184  int _hitChanceBonus;
185  bool _dangerPresent;
186  bool _moveMonsters;
187  RangeType _rangeType;
188  ShootType _shootType;
189  int _combatTarget;
190 public:
191  Combat(XeenEngine *vm);
192 
196  void clearAttackers();
197 
201  void clearBlocked();
202 
206  void clearShooting();
207 
211  void reset();
212 
216  void giveCharDamage(int damage, DamageType attackType, int charIndex);
217 
221  void doCharDamage(Character &c, int charNum, int monsterDataIndex);
222 
226  void moveMonsters();
227 
231  void setupCombatParty();
232 
236  void setSpeedTable();
237 
241  bool allHaveGone() const;
242 
246  bool charsCantAct() const;
247 
251  Common::String getMonsterDescriptions();
252 
256  void attack(Character &c, RangeType rangeType);
257 
261  void block();
262 
266  void quickFight();
267 
271  void run();
272 
276  void monstersAttack();
277 
278  void setupMonsterAttack(int monsterDataIndex, const Common::Point &pt);
279 
288  bool canMonsterMove(const Common::Point &pt, int wallShift, int xDiff, int yDiff, int monsterId);
289 
293  void moveMonster(int monsterId, const Common::Point &moveDelta);
294 
298  void doMonsterTurn(int monsterId);
299 
303  void doMonsterTurn(int monsterId, int charNum);
304 
308  void endAttack();
309 
310  void monsterOvercome();
311 
315  int stopAttack(const Common::Point &diffPt);
316 
320  void rangedAttack(PowType powNum);
321 
325  void shootRangedWeapon();
326 
330  bool areMonstersPresent() const;
331 };
332 
333 } // End of namespace Xeen
334 } // End of namespace MM
335 
336 #endif
Definition: str.h:59
Definition: combat.h:82
Definition: combat.h:93
Definition: array.h:52
Definition: combat.h:114
Definition: sprites.h:52
Definition: xeen.h:93
Definition: character.h:106
Definition: detection.h:27
Definition: rect.h:45
Definition: file.h:36
PowSlot & operator[](uint idx)
Definition: combat.h:100
void resetElementals()
Definition: combat.h:108
Definition: item.h:111