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 MM1_GAME_COMBAT_H
23 #define MM1_GAME_COMBAT_H
24 
25 #include "common/array.h"
26 #include "mm/mm1/data/character.h"
27 #include "mm/mm1/data/party.h"
28 #include "mm/mm1/game/game_logic.h"
29 #include "mm/mm1/game/encounter.h"
30 #include "mm/mm1/game/monster_touch.h"
31 
32 namespace MM {
33 namespace MM1 {
34 namespace Game {
35 
36 class Combat : public MonsterTouch {
37 protected:
38  Common::Array<Line> _message;
39  int _monstersCount = 0;
40  Monster *_monsterP;
41  bool _treasureFlags[MAX_PARTY_SIZE];
42  int _val1;
43  int _roundNum;
44  int _monsterIndex, _currentChar;
45  bool _allowFight, _allowShoot, _allowCast, _allowAttack;
46  byte _val6, _val7;
47  int _partyIndex, _val9, _monsterShootingCtr;
48  int _activeMonsterNum;
49  int _destCharCtr;
50  int _destAC;
51  int _numberOfTimes;
52  int _attackerLevel;
53  int _advanceIndex;
54  int _handicapThreshold, _handicapParty;
55  int _handicapMonsters, _handicapDelta;
56  int _attackersCount;
57  int _totalExperience;
58  Common::String _monsterName;
59  bool _monstersResistSpells;
60  bool _monstersRegenerate;
61  AttributePair _attackAttr1, _attackAttr2;
62  int _timesHit;
63  bool _isShooting;
64  Common::String _attackMessage;
65  enum Handicap {
66  HANDICAP_EVEN = 0, HANDICAP_PARTY = 1,
67  HANDICAP_MONSTER = 2
68  };
69  Handicap _handicap = HANDICAP_EVEN;
70  enum Mode {
71  SELECT_OPTION, FIGHT_WHICH, DEFEATED_MONSTERS,
72  NEXT_ROUND, MONSTER_ADVANCES, MONSTERS_AFFECTED,
73  MONSTER_FLEES, MONSTER_WANDERS, MONSTER_SPELL,
74  CHAR_ATTACKS, MONSTER_ATTACK, INFILTRATION,
75  WAITS_FOR_OPENING, SPELL_RESULT, NO_EFFECT
76  };
77  Mode _mode = SELECT_OPTION;
78 
79  int _destMonsterNum = 0;
80  int _monstersDestroyedCtr = 0;
81  bool _turnUndeadUsed = false;
82  bool _divineInterventionUsed = false;
83  size_t _spellMonsterCount = 0;
84 
85  int _monsterAttackStyle = -1;
86 
90  Combat();
91 
95  virtual ~Combat();
96 
100  virtual void setMode(Mode newMode) = 0;
101 
105  virtual void combatDone();
106 
112 
116  void clear();
117 
118  void loadMonsters();
119 
124  void monsterIndexOf();
125 
129  void monsterSetPtr(int monsterNum);
130 
135  void setupCanAttacks();
136 
140  void setupAttackersCount();
141 
146  void checkLeftWall();
147 
152  void checkRightWall();
153 
157  void setupHandicap();
158 
159  /*------- Inherited virtual methods ------*/
160 
164  int getMonsterIndex() const override {
165  return _monsterIndex;
166  }
167 
171  bool canMonsterCast() const override;
172 
176  void dispelParty() override;
177 
178  void removeMonster() override;
179 
180  /*------- combat execution ------*/
181 
186  void combatLoop(bool checkMonstersFirst = false);
187 
191  void selectTreasure();
192  void selectTreasure2(int index);
193 
197  void nextRound();
198  void nextRound2();
199  void nextRound3();
200 
205  void updateHighestLevel();
206 
210  void monsterAction();
211 
215  bool checkMonsterSpells();
216 
220  void checkMonsterActions();
221 
222  void defeatedMonsters();
223  void setTreasure();
224  void clearArrays();
225  bool moveMonsters();
226  void monsterAdvances();
227  bool monsterChanges();
228  void proc2();
229  void checkParty();
230 
234  void fightMonster(int monsterNum);
235  void shootMonster(int monsterNum);
236  void attackMonsterPhysical();
237  void attackMonsterShooting();
238  void attackMonster(int monsterNum);
239 
243  void addAttackDamage();
244 
248  void updateMonsterStatus();
249 
253  bool monsterTouch(Common::String &line);
254 
258  void monsterAttackRandom();
259  void monsterAttackInner();
260 
264  void monsterAttackShooting();
265 
269  void selectMonsterTarget();
270 
271 
275  void attack();
276 
280  void block();
281 
285  void cast();
286 
290  void exchangeWith(int charNum);
291 
295  void use();
296 
300  void retreat();
301 
305  void removeDeadMonsters();
306 
307 private:
308  void spellFailed();
309  void destroyMonster();
310  bool monsterLevelThreshold() const;
311  void iterateMonsters1Inner();
312  void iterateMonsters2Inner();
313  void characterDone();
314  void summonLightning2();
315  void fireball2();
316  void levelAdjust();
317 
318 public:
322  virtual void displaySpellResult(const InfoMessage &msg) = 0;
323 
324  void iterateMonsters1();
325  void iterateMonsters2();
326  void resetDestMonster();
327 
328  // Cleric spells that need access to internal fields
329  void turnUndead();
330  void summonLightning();
331  void paralyze();
332  bool divineIntervention();
333  void holyWord();
334 
335  // Wizard spells that need access to internal fields
336  void identifyMonster();
337  void fireball();
338  void lightningBolt();
339  void makeRoom();
340  void slow();
341  void weaken();
342  bool web();
343  bool acidRain();
344  void fingerOfDeath();
345  void disintegration();
346 };
347 
348 } // namespace Game
349 } // namespace MM1
350 } // namespace MM
351 
352 #endif
Definition: str.h:59
void exchangeWith(int charNum)
Definition: monster_touch.h:34
void monsterSetPtr(int monsterNum)
virtual void setMode(Mode newMode)=0
void fightMonster(int monsterNum)
virtual void combatDone()
void combatLoop(bool checkMonstersFirst=false)
Common::String subtractDamageFromChar() override
Definition: detection.h:27
Definition: messages.h:129
Definition: combat.h:36
int getMonsterIndex() const override
Definition: combat.h:164
bool canMonsterCast() const override
Definition: monsters.h:80
void dispelParty() override
virtual void displaySpellResult(const InfoMessage &msg)=0
bool monsterTouch(Common::String &line)
Definition: character.h:332