ScummVM API documentation
spells_monsters.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_SPELLS_MONSTERS
23 #define MM1_GAME_SPELLS_MONSTERS
24 
25 #include "mm/mm1/game/game_logic.h"
26 #include "mm/mm1/data/character.h"
27 #include "mm/mm1/data/monsters.h"
28 #include "mm/mm1/messages.h"
29 #include "common/str.h"
30 
31 namespace MM {
32 namespace MM1 {
33 namespace Game {
34 
35 #define MAX_COMBAT_MONSTERS 15
36 #define MONSTER_SPELLS_COUNT 32
37 
38 class SpellsMonsters;
39 typedef void (SpellsMonsters::*SpellMonstersSpell)();
40 
41 class SpellsMonsters : public GameLogic {
42 private:
43  static const SpellMonstersSpell SPELLS[MONSTER_SPELLS_COUNT];
44 
45  void spell01_curse();
46  void spell02_energyBlast();
47  void spell03_fire();
48  void spell04_blindness();
49  void spell05_sprayPoison();
50  void spell06_sprayAcid();
51  void spell07_sleep();
52  void spell08_paralyze();
53  void spell09_dispel();
54  void spell10_lightningBolt();
55  void spell11_strangeGas();
56  void spell12_explode();
57  void spell13_fireball();
58  void spell14_fireBreath();
59  void spell15_gazes();
60  void spell16_acidArrow();
61  void spell17_elements();
62  void spell18_coldBeam();
63  void spell19_dancingSword();
64  void spell20_magicDrain();
65  void spell21_fingerOfDeath();
66  void spell22_sunRay();
67  void spell23_disintegration();
68  void spell24_commandsEnergy();
69  void spell25_poison();
70  void spell26_lightning();
71  void spell27_frost();
72  void spell28_spikes();
73  void spell29_acid();
74  void spell30_fire();
75  void spell31_energy();
76  void spell32_swarm();
77 
81  bool casts();
82 
86  void damageRandomChar();
87 
91  void chooseCharacter();
92 
98  void handleDamage();
99 
104  bool charAffected();
105 
109  bool randomThreshold(int threshold) const {
110  int v = getRandomNumber(120);
111  return v < 3 || v >= threshold;
112  }
113 
114  bool isEffective();
115 
119  void writeDamage();
120 
121  bool testElementalResistance();
122 
126  void writeConditionEffect();
127 
131  void handlePartyEffects();
132 
133 protected:
134  Common::Array<Monster *> _remainingMonsters;
135  LineArray _lines;
136  int _damage = 0, _displayedDamage = 0;
137 
138  virtual bool canMonsterCast() const = 0;
139  virtual int getMonsterIndex() const = 0;
140  virtual void dispelParty() = 0;
141  virtual void removeMonster() = 0;
142 
148 
152  void handlePartyDamage();
153 
157  void setCondition(byte newCondition);
158 
162  bool isCharAffected() const;
163 
167  bool damageType1();
168  bool damageType2();
169  bool damageType3();
170  bool damageType4();
171  bool damageType5();
172  bool damageType6();
173  bool damageType7();
174 
175  void proc9();
176 
180  void add(const Common::String &msg) {
181  _lines.back()._text += msg;
182  }
183  void add(char c) {
184  _lines.back()._text += c;
185  }
186 
190  void addCharName();
191 
192 public:
193  SpellsMonsters();
194  virtual ~SpellsMonsters() {}
195 
199  void castMonsterSpell(const Common::String &monsterName, int spellNum);
200 
205  return _lines;
206  }
207 };
208 
209 } // namespace Game
210 } // namespace MM1
211 } // namespace MM
212 
213 #endif
void castMonsterSpell(const Common::String &monsterName, int spellNum)
Definition: str.h:59
void setCondition(byte newCondition)
Definition: spells_monsters.h:41
Definition: array.h:52
const LineArray & getMonsterSpellMessage() const
Definition: spells_monsters.h:204
virtual Common::String subtractDamageFromChar()=0
Definition: detection.h:27
Definition: game_logic.h:29
static int getRandomNumber(int minNumber, int maxNumber)
T & back()
Definition: array.h:229
void add(const Common::String &msg)
Definition: spells_monsters.h:180