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
32namespace MM {
33namespace MM1 {
34namespace Game {
35
36class Combat : public MonsterTouch {
37protected:
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 _handicapThreshold, _handicapParty;
54 int _handicapMonsters, _handicapDelta;
55 int _attackersCount;
56 int _totalExperience;
57 Common::String _monsterName;
58 bool _monstersResistSpells;
59 bool _monstersRegenerate;
60 AttributePair _attackAttr1, _attackAttr2;
61 int _timesHit;
62 bool _isShooting;
63 Common::String _attackMessage;
64 enum Handicap {
65 HANDICAP_EVEN = 0, HANDICAP_PARTY = 1,
66 HANDICAP_MONSTER = 2
67 };
68 Handicap _handicap = HANDICAP_EVEN;
69 enum Mode {
70 SELECT_OPTION, FIGHT_WHICH, DEFEATED_MONSTERS,
71 NEXT_ROUND, MONSTER_ADVANCES, MONSTERS_AFFECTED,
72 MONSTER_FLEES, MONSTER_WANDERS, MONSTER_SPELL,
73 CHAR_ATTACKS, MONSTER_ATTACK, INFILTRATION,
74 WAITS_FOR_OPENING, SPELL_RESULT, NO_EFFECT
75 };
76 Mode _mode = SELECT_OPTION;
77
78 int _destMonsterNum = 0;
79 int _selectedSpellMonster = -1;
80 int _monstersDestroyedCtr = 0;
81 bool _turnUndeadUsed = false;
82 bool _divineInterventionUsed = false;
83 size_t _spellMonsterCount = 0;
84 // Transient combat-only display state; never serialized.
85 int _slowCasts = 0;
86 int _weakenCasts = 0;
87 int _heroismBonus[MAX_PARTY_SIZE] = {};
88 bool _heroismIsSuper[MAX_PARTY_SIZE] = {};
89 // -1 means the spell has not been cast; a real roll may be zero.
90 int _powerBonus[MAX_PARTY_SIZE] = {};
91 int _quicknessBonus[MAX_PARTY_SIZE] = {};
92
93 int _monsterAttackStyle = -1;
94
99
103 virtual ~Combat();
104
108 virtual void setMode(Mode newMode) = 0;
109
113 virtual void combatDone();
114
120
124 void clear();
125
126 void loadMonsters();
127
133
137 void monsterSetPtr(int monsterNum);
138
144
149
155
161
166
167 /*------- Inherited virtual methods ------*/
168
172 int getMonsterIndex() const override {
173 return _monsterIndex;
174 }
175
179 bool canMonsterCast() const override;
180
184 void dispelParty() override;
185
186 void removeMonster() override;
187
188 /*------- combat execution ------*/
189
194 void combatLoop(bool checkMonstersFirst = false);
195
200 void selectTreasure2(int index);
201
205 void nextRound();
206 void nextRound2();
207 void nextRound3();
208
214
219
224
229
230 void defeatedMonsters();
231 void setTreasure();
232 void clearArrays();
233 bool moveMonsters();
234 void monsterAdvances(uint index);
235 bool monsterChanges();
236 void proc2();
237 void checkParty();
238
242 void fightMonster(int monsterNum);
243 void shootMonster(int monsterNum);
244 void attackMonsterPhysical();
245 void attackMonsterShooting();
246 void attackMonster(int monsterNum);
247
252
257
262
267 void monsterAttackInner();
268
273
278
279
283 void attack();
284
288 void block();
289
293 void cast();
294
298 void exchangeWith(int charNum);
299
303 void use();
304
308 void retreat();
309
314
315private:
316 void spellFailed();
317 void destroyMonster();
318 bool monsterLevelThreshold() const;
319 void iterateMonsters1Inner();
320 void iterateMonsters2Inner();
321 void characterDone();
322 void summonLightning2();
323 void fireball2();
324 void levelAdjust();
325
326public:
330 virtual void displaySpellResult(const InfoMessage &msg) = 0;
331
332 void iterateMonsters1();
333 void iterateMonsters2();
334 void iterateSelectedMonster1();
335 void iterateSelectedMonster2();
336 bool setSpellTarget(int monsterNum);
337 void resetDestMonster();
338
339 // Cleric spells that need access to internal fields
340 void turnUndead();
341 void summonLightning();
342 void paralyze();
343 bool divineIntervention();
344 void holyWord();
345
346 int getSlowCasts() const { return _slowCasts; }
347 int getWeakenCasts() const { return _weakenCasts; }
348 int getHeroismBonus(uint index) const;
349 bool isSuperHeroism(uint index) const;
350 int getPowerBonus(uint index) const;
351 int getQuicknessBonus(uint index) const;
352 void recordHeroism(Character *character, int bonus, bool isSuper);
353 void recordPower(Character *character, int bonus);
354 void recordQuickness(Character *character, int bonus);
355
356 // Wizard spells that need access to internal fields
357 void identifyMonster();
358 bool fireball();
359 void lightningBolt();
360 void makeRoom();
361 void slow();
362 void weaken();
363 bool web();
364 bool acidRain();
365 void fingerOfDeath();
366 void disintegration();
367
369 void endCombat();
370};
371
372} // namespace Game
373} // namespace MM1
374} // namespace MM
375
376#endif
Definition: str.h:59
Definition: combat.h:36
bool monsterTouch(Common::String &line)
bool canMonsterCast() const override
void combatLoop(bool checkMonstersFirst=false)
void fightMonster(int monsterNum)
virtual void displaySpellResult(const InfoMessage &msg)=0
virtual void combatDone()
void dispelParty() override
int getMonsterIndex() const override
Definition: combat.h:172
virtual void setMode(Mode newMode)=0
void exchangeWith(int charNum)
void monsterSetPtr(int monsterNum)
Common::String subtractDamageFromChar() override
Definition: monster_touch.h:34
Definition: detection.h:27
Definition: character.h:332
Definition: character.h:432
Definition: messages.h:134
Definition: monsters.h:80