ScummVM API documentation
spellbuk.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 * Based on the original sources
22 * Faery Tale II -- The Halls of the Dead
23 * (c) 1993-1996 The Wyrmkeep Entertainment Co.
24 */
25
26#ifndef SAGA2_SPELLBUK_H
27#define SAGA2_SPELLBUK_H
28
29namespace Saga2 {
30
31struct ResourceSpellEffect;
32struct ResourceSpellItem;
33
34class SpellTarget;
35class ProtoEffect;
36
37// Mana IDs as spells see them
38
39enum SpellManaID {
40 ksManaIDRed = 0,
41 ksManaIDOrange = 1,
42 ksManaIDYellow = 2,
43 ksManaIDGreen = 3,
44 ksManaIDBlue = 4,
45 ksManaIDViolet = 5,
46 ksManaIDSkill = 6 // skills are here for convenience
47};
48
49//-------------------------------------------------------------------
50// targeting bits
51// These two types are used to determine :
52// The types of screen object a spell can be used on
53// The type of target the spell will eventually be applied to
54// respectively.
55
56//-------------------------------------------------------------------
57// legal target selections
58enum SpellTargetingTypes {
59 kSpellTargNone = 0,
60 kSpellTargWorld = 1 << 0, // instant spell
61 kSpellTargLocation = 1 << 1, // cast at any location on map
62 kSpellTargTAG = 1 << 2, // cast at tileactivity inst.
63 kSpellTargObject = 1 << 3, // cast at objects
64 kSpellTargActor = 1 << 4,
65 kSpellTargCaster = 1 << 5
66};
67
68//-------------------------------------------------------------------
69// target type the spell uses when implemented
70enum SpellApplicationTypes {
71 kSpellApplyNone = kSpellTargNone,
72 kSpellApplyWorld = kSpellTargWorld,
73 kSpellApplyLocation = kSpellTargLocation,
74 kSpellApplyTAG = kSpellTargTAG,
75 kSpellApplyObject = kSpellTargObject,
76 kSpellApplyActor = kSpellTargObject,
77 kSpellApplyTracking = 1 << 6 // track object targets
78};
79
80
81//-------------------------------------------------------------------
82// effect templates
83// These are the shapes of the visible effects of spells
84
85enum effectAreas {
86 keAreaInvisible = 0,
87 keAreaAura,
88 keAreaProjectile,
89 keAreaExchange,
90 keAreaBolt,
91 keAreaCone,
92 keAreaBall,
93 keAreaSquare,
94 keAreaWave,
95 keAreaStorm,
96 keAreaMissle,
97 keAreaGlow,
98 keAreaBeam,
99 keAreaWall
100};
101
102
103
104//-------------------------------------------------------------------
105// SpellStuff
106// The master spell list is an array of these records.
107// Unfortunately this class and the SpellDisplayProto could have been
108// implemented as one larger structure, but the evolved from separate
109// parts of the code
110
112 SpellID _master; // index in array
113 SkillProto *_prototype; // ponts back to object prototype
114 SpellID _display; // currently same as master
115 SpellTargetingTypes _targetableTypes; // valid targeting types
116 SpellApplicationTypes _targetTypes; // the targeting type to implement
117 ProtoEffect *_effects; // the effects of this spell
118 SpellTarget *_targets; // transient target list
119 SpellManaID _manaType; // color mana used
120 int8 _manaUse; // mana points used
121 effectAreas _shape;
122 int32 _size;
123 int32 _range;
124 int16 _sound;
125
126 bool _debug;
127
128public:
129
130 SpellStuff();
131
132 void setProto(SkillProto *p) {
133 _prototype = p;
134 }
135 SkillProto *getProto() {
136 return _prototype;
137 }
138
139 void setupFromResource(ResourceSpellItem *rsi);
140
141 void addEffect(ProtoEffect *pe);
142 void addEffect(ResourceSpellEffect *rse);
143 void killEffects();
144
145 bool canTarget(SpellTargetingTypes t) {
146 return _targetableTypes & t;
147 }
148 bool shouldTarget(SpellApplicationTypes t) {
149 return _targetTypes & t;
150 }
151
152 bool untargetable() {
153 return (_targetableTypes == kSpellTargNone);
154 }
155 bool untargeted() {
156 return false; //(targetableTypes == kSpellTargWorld ) ||
157 }
158 //(targetableTypes == kSpellTargCaster ) ||
159 //(targetableTypes == targetableTypes &
160 // (kSpellTargWorld | kSpellTargCaster)); }
161
162 void implement(GameObject *enactor, SpellTarget *target);
163 void implement(GameObject *enactor, GameObject *target);
164 void implement(GameObject *enactor, ActiveItem *target);
165 void implement(GameObject *enactor, Location target);
166
167 SpellID getDisplayID() {
168 return _display;
169 }
170 SpellManaID getManaType() {
171 return _manaType;
172 }
173 void setManaType(SpellManaID smid) {
174 _manaType = smid;
175 }
176 int8 getManaAmt() {
177 return _manaUse;
178 }
179 int32 getRange() {
180 return _range;
181 }
182
183 void buildTargetList(GameObject *, SpellTarget &);
184 void addTarget(SpellTarget *trg);
185 void removeTargetList();
186
187 void apply(ProtoEffect *pe, GameObject *target);
188 void apply(ProtoEffect *pe, ActiveItem *target);
189
190 void playSound(GameObject *go);
191 void show(GameObject *, SpellTarget &);
192 bool safe();
193 bool isOffensive();
194};
195
196/* ===================================================================== *
197 Prototypes
198 * ===================================================================== */
199
200//-------------------------------------------------------------------
201// At this point these are the effects requiring special handling
202
203SPECIALSPELL(DeathSpell);
204SPECIALSPELL(DispellProtections);
205SPECIALSPELL(DispellCurses);
206SPECIALSPELL(Resurrect);
207SPECIALSPELL(CreateWallOfFire);
208SPECIALSPELL(CreateFireWisp);
209SPECIALSPELL(CreateWindWisp);
210SPECIALSPELL(Timequake);
211SPECIALSPELL(TeleportToShrine);
212SPECIALSPELL(TeleportToLocation);
213SPECIALSPELL(Rejoin);
214SPECIALSPELL(CreateRingOfForce);
215SPECIALSPELL(DispellPoison);
216SPECIALSPELL(CreateWraith);
217SPECIALSPELL(SagaSpellCall);
218SPECIALSPELL(CreateWWisp);
219SPECIALSPELL(CreateFWisp);
220SPECIALSPELL(CreateFood);
221
222} // End of namespace Saga2
223
224#endif //SPELLBUK_H
Definition: tile.h:388
Definition: objects.h:118
Definition: objproto.h:105
Definition: effects.h:348
Definition: objproto.h:1493
Definition: spellbuk.h:111
Definition: speldefs.h:139
Definition: spellio.h:81
Definition: spellio.h:57