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