ScummVM API documentation
spell.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 ULTIMA4_GAME_SPELL_H
23 #define ULTIMA4_GAME_SPELL_H
24 
25 #include "ultima/ultima4/game/context.h"
26 #include "ultima/ultima4/map/location.h"
27 #include "ultima/ultima4/map/map.h"
28 #include "ultima/ultima4/filesys/savegame.h"
29 #include "ultima/ultima4/sound/sound.h"
30 
31 namespace Ultima {
32 namespace Ultima4 {
33 
34 enum SpellCastError {
35  CASTERR_NOERROR, /* success */
36  CASTERR_NOMIX, /* no mixture available */
37  CASTERR_MPTOOLOW, /* caster doesn't have enough mp */
38  CASTERR_FAILED, /* the spell failed */
39  CASTERR_WRONGCONTEXT, /* generic 'wrong-context' error (generrally finds the correct
40  context error message on its own) */
41  CASTERR_COMBATONLY, /* e.g. spell must be cast in combat */
42  CASTERR_DUNGEONONLY, /* e.g. spell must be cast in dungeons */
43  CASTERR_WORLDMAPONLY /* e.g. spell must be cast on the world map */
44 };
45 
49 enum EnergyFieldType {
50  ENERGYFIELD_NONE,
51  ENERGYFIELD_FIRE,
52  ENERGYFIELD_LIGHTNING,
53  ENERGYFIELD_POISON,
54  ENERGYFIELD_SLEEP
55 };
56 
60 class Ingredients {
61 public:
62  Ingredients();
63  bool addReagent(Reagent reagent);
64  bool removeReagent(Reagent reagent);
65  int getReagent(Reagent reagent) const;
66  void revert();
67  bool checkMultiple(int mixes) const;
68  void multiply(int mixes);
69 
70 private:
71  unsigned short _reagents[REAG_MAX];
72 };
73 
74 class Spells;
75 typedef int (Spells::*SpellProc)(int);
76 
77 struct Spell {
78  enum Param {
84  PARAM_FROMDIR
85  };
86 
90  SFX_TREMOR
91  };
92 
93  const char *_name;
94  int _components;
95  LocationContext _context;
96  TransportContext _transportContext;
97  SpellProc _spellFunc;
98  Param _paramType;
99  int _mp;
100 };
101 
102 typedef void (*SpellEffectCallback)(int spell, int player, Sound sound);
103 #define N_SPELLS 26
104 
105 class Spells {
106 private:
107  static const Spell SPELL_LIST[N_SPELLS];
108  SpellEffectCallback spellEffectCallback;
109 private:
110  int spellAwaken(int player);
111  int spellBlink(int dir);
112  int spellCure(int player);
113  int spellDispel(int dir);
114  int spellEField(int param);
115  int spellFireball(int dir);
116  int spellGate(int phase);
117  int spellHeal(int player);
118  int spellIceball(int dir);
119  int spellJinx(int unused);
120  int spellKill(int dir);
121  int spellLight(int unused);
122  int spellMMissle(int dir);
123  int spellNegate(int unused);
124  int spellOpen(int unused);
125  int spellProtect(int unused);
126  int spellRez(int player);
127  int spellQuick(int unused);
128  int spellSleep(int unused);
129  int spellTremor(int unused);
130  int spellUndead(int unused);
131  int spellView(int unsued);
132  int spellWinds(int fromdir);
133  int spellXit(int unused);
134  int spellYup(int unused);
135  int spellZdown(int unused);
136 private:
137  CombatController *spellCombatController();
138 
142  void spellMagicAttack(const Common::String &tilename, Direction dir, int minDamage, int maxDamage);
143  bool spellMagicAttackAt(const Coords &coords, MapTile attackTile, int attackDamage);
144 
145  LocationContext spellGetContext(uint spell) const;
146  TransportContext spellGetTransportContext(uint spell) const;
147 
151  bool isDebuggerActive() const;
152 public:
156  Spells();
157 
161  ~Spells();
162 
163  void spellSetEffectCallback(SpellEffectCallback callback);
164 
165  void spellEffect(int spell, int player, Sound sound) {
166  (spellEffectCallback)(spell, player, sound);
167  }
168 
173  int spellMix(uint spell, const Ingredients *ingredients);
174 
179  bool spellCast(uint spell, int character, int param, SpellCastError *error, bool spellEffect);
180 
181  Common::String spellGetErrorMessage(uint spell, SpellCastError error);
182 
183  const char *spellGetName(uint spell) const;
184 
190  SpellCastError spellCheckPrerequisites(uint spell, int character);
191  Spell::Param spellGetParamType(uint spell) const;
192  int spellGetRequiredMP(uint spell) const;
193  const Spell *getSpell(int i) const;
194 };
195 
196 extern Spells *g_spells;
197 
198 } // End of namespace Ultima4
199 } // End of namespace Ultima
200 
201 #endif
Definition: spell.h:77
Definition: str.h:59
Definition: coords.h:31
invert the screen (moongates, most normal spells)
Definition: spell.h:89
None.
Definition: spell.h:79
Definition: detection.h:27
Definition: combat_controller.h:59
Definition: map_tile.h:34
Param
Definition: spell.h:78
number of a player required
Definition: spell.h:80
Definition: spell.h:105
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
type of field and direction required (energy field)
Definition: spell.h:82
Definition: spell.h:60
none
Definition: spell.h:88
SpecialEffects
Definition: spell.h:87
phase required (gate)
Definition: spell.h:83
direction required
Definition: spell.h:81