ScummVM API documentation
spelshow.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_SPELSHOW_H
27#define SAGA2_SPELSHOW_H
28
29#include "saga2/dispnode.h"
30#include "saga2/speldefs.h"
31
32namespace Saga2 {
33
34//-----------------------------------------------------------------------
35// Effectron List
36
37typedef DisplayNodeList EffectronList;
38
39//-----------------------------------------------------------------------
40// Spell control functions
41// Various instances of these can be used in different combinations to
42// yield different shaped spells. Each spell will need one each of
43// these types of functions:
44//
45// Effectron Status
46// This returns the state of a given effectron as a function of time
47//
48// Spell Spritation
49// Returns a sprite facing as a function of time.
50//
51// Spell Location
52// Returns the position of the effectron as a function of time
53//
54// Spell Height
55// This is NOT the effectron's Z coordinate. It is the height used
56// for collision detection purposes
57//
58// Spell Breadth
59// This is the effectron's cross section for collision detection
60// purposes.
61//
62
63//-----------------------------------------------------------------------
64// Spell Status
65
66typedef EffectronFlags SpellStatusFunction(Effectron *);
67
68#define SPELLSTATUSFUNCTION(fname) EffectronFlags fname( Effectron * effectron )
69
70//-----------------------------------------------------------------------
71// Spell Spritation
72
73typedef SpellPoseID SpellSpritationFunction(const Effectron *const);
74
75#define SPELLSPRITATIONFUNCTION(fname) SpellPoseID fname( const Effectron * const effectron )
76
77//-----------------------------------------------------------------------
78// Spell Location Calls
79
80typedef TilePoint SpellLocationFunction(const Effectron *const);
81
82#define SPELLLOCATIONFUNCTION(fname) TilePoint fname( const Effectron * const effectron )
83
84//-----------------------------------------------------------------------
85// Spell Height
86
87typedef spellHeight SpellHeightFunction(const Effectron *const);
88
89#define SPELLHEIGHTFUNCTION(fname) spellHeight fname( const Effectron * const effectron )
90
91//-----------------------------------------------------------------------
92// Spell width
93
94typedef spellBreadth SpellBreadthFunction(const Effectron *const);
95
96#define SPELLBREADTHFUNCTION(fname) spellBreadth fname( const Effectron * const effectron )
97
98//-----------------------------------------------------------------------
99// Spell init
100
101typedef void SpellInitFunction(Effectron *);
102
103#define SPELLINITFUNCTION(fname) void fname( Effectron * effectron )
104
105
106//-----------------------------------------------------------------------
107// EffectronDisplayPrototype
108// This tracks the functions needed to display a particular type of
109// spell on the screen. (Ball spells, bolt spells, etc)
110//
111
113 static SPELLLOCATIONFUNCTION(nullLocation) {
114 return TilePoint(0, 0, 0);
115 }
116 static SPELLSPRITATIONFUNCTION(nullSpritation) {
117 return 0;
118 }
119 static SPELLSTATUSFUNCTION(nullStatus) {
120 return kEffectronDead;
121 }
122 static SPELLHEIGHTFUNCTION(nullHeight) {
123 return 0;
124 }
125 static SPELLBREADTHFUNCTION(nullBreadth) {
126 return 0;
127 }
128 static SPELLINITFUNCTION(nullInit) {
129 }
130
131 EffectID _ID;
132public:
133 int16 _nodeCount;
135
136 SpellLocationFunction *_location;
137 SpellSpritationFunction *_spriteno;
138 SpellStatusFunction *_status;
139 SpellHeightFunction *_height;
140 SpellBreadthFunction *_breadth;
141 SpellInitFunction *_init;
142
144 _nodeCount = 0;
145 _next = NULL;
146 _location = &nullLocation;
147 _spriteno = &nullSpritation;
148 _status = &nullStatus;
149 _height = &nullHeight;
150 _breadth = &nullBreadth;
151 _init = &nullInit;
152 }
153
155 int16 nodes,
156 SpellLocationFunction *newLocation,
157 SpellSpritationFunction *newSpriteno,
158 SpellStatusFunction *newStatus,
159 SpellHeightFunction *newHeight,
160 SpellBreadthFunction *newBreadth,
161 SpellInitFunction *newInit);
163 if (_next) delete _next;
164 _next = NULL;
165 }
166 void setID(EffectID i) {
167 _ID = i;
168 }
169 EffectID thisID() {
170 return _ID;
171 }
172};
173
175
176//-----------------------------------------------------------------------
177// Effect Display Prototype List
178//
179// This class embodies a global list of EDPs
180//
181
182
184 pEffectDisplayPrototype *_effects;
185 uint16 _count;
186 uint16 _maxCount;
187
188public:
191
192 int32 add(EffectDisplayPrototype *edp) ;
193 void cleanup();
194 void append(EffectDisplayPrototype *edp, int32 acount);
195 EffectDisplayPrototype *operator[](EffectID e);
196};
197
198//-----------------------------------------------------------------------
199// Effectron collision flags
200//
201// need to track whether things
202// bounce/die/stop/ignore
203// when hitting
204// actors/objects/terrain
205//
206
207enum effectCollisionCont {
208 kEcFlagNone = 0,
209 kEcFlagBounce,
210 kEcFlagDie,
211 kEcFlagStop
212};
213
214enum effectDirectionInit {
215 kDiFlagZero = 0,
216 kDiFlagInc = 1,
217 kDiFlagInc2 = 2,
218 kDiFlagInc3 = 3,
219 kDiFlagInc4 = 4,
220 kDiFlagRand = 5
221};
222
223
224//-----------------------------------------------------------------------
225// SpellDisplayPrototype
226// All the information needed to display a spell
227// Combines a SpellEffectPrototype with the appropriate sprites
228
230 SpellID _ID;
231public:
232 EffectID _effect; // Effect ID
233 int32 _effParm1; // effect setting 1
234 int32 _effParm2; // effect setting 1
235 int32 _effParm3; // effect setting 1
236 int32 _effParm4; // effect setting 1
237
238 effectDirectionInit _scatter; // direction init mode
239 effectCollisionCont _elasticity; // collision flags
240
241 SpellAge _maxAge; // auto self-destruct age
242 SpellAge _implementAge; // auto self-destruct age
243 uint32 _primarySpriteID; // RES_ID(x, y, z, 0) to get sprites
244 uint8 _primarySpriteNo; // sprites available
245 uint32 _secondarySpriteID; // RES_ID(x, y, z, 0) to get sprites
246 uint8 _secondarySpriteNo; // sprites available
247 //uint8 _effCount; // effectrons to allocate
248
249 uint8 _colorMap[4]; // indirect color map
250 // full init
252 EffectID, int32, int32, int32, int32, effectDirectionInit,
253 effectCollisionCont, SpellAge, uint32, uint8, uint8);
254
256
257 void getColorTranslation(ColorTable mainColors, Effectron *); // colors for effectrons
258 void setID(SpellID i) {
259 _ID = i;
260 }
261 SpellID thisID() {
262 return _ID;
263 }
264};
265
266//-----------------------------------------------------------------------
267// SpellDisplayPrototypeList
268// A global list of sdp's
269
271
273 pSpellDisplayPrototype *_spells;
274 uint16 _count;
275 uint16 _maxCount;
276
277public:
280
281 void init();
282 void cleanup();
283 int32 add(SpellDisplayPrototype *sdp);
284 SpellDisplayPrototype *operator[](SpellID s);
285};
286
287//-----------------------------------------------------------------------
288// SpellInstance
289// When a SpellDisplayPrototype is instantiated, one of these is created
290// and the main display loop updates it till it dies
291
293 friend struct StorageSpellInstance;
294
295 SpellAge _implementAge; // age at which to implement the spell effects
296public:
297 EffectDisplayPrototype *_effect; // effect prototype of the current effect
298 SpellDisplayPrototype *_dProto; // effect prototype of the current effect
299 SpellCaster *_caster;
300 SpellTarget *_target;
301 GameWorld *_world;
302 SpellAge _age;
303 EffectronList _eList;
304 SpellID _spell;
305 SpellAge _maxAge;
306 int16 _effSeq; // which effect in a sequence is being played
307
308 SpellInstance(SpellCaster *newCaster, SpellTarget *newTarget, SpellID);
309 SpellInstance(SpellCaster *newCaster, GameObject &newTarget, SpellID);
310 SpellInstance(SpellCaster *newCaster, GameObject *newTarget, SpellID);
311 SpellInstance(SpellCaster *newCaster, TilePoint &newTarget, SpellID);
314
315 void init();
316 void initEffect(TilePoint);
317 void readEffect(Common::InSaveFile *in, uint16 eListSize);
318 void writeEffect(Common::MemoryWriteStreamDynamic *out);
319 void termEffect();
320 size_t saveSize();
321
322 bool buildList();
323 bool updateStates(int32 deltaTime);
324};
325
326//-----------------------------------------------------------------------
327// SpellDisplayList
328// This class is used to keep track of all the spells currently
329// displaying effectrons
330
332
334 uint16 _count;
335 uint16 _maxCount;
336public :
337 pSpellInstance *_spells;
338
339 void init();
340 void cleanup();
341 SpellDisplayList(uint16 s);
343
344 void add(SpellInstance *newSpell);
345
346 void tidyKill(uint16 spellNo);
347
348 void buildList();
349 void updateStates(int32 deltaTime);
350
351 void write(Common::OutSaveFile *outD);
352 void read(Common::InSaveFile *in);
353 void wipe();
354 size_t saveSize();
355};
356
357
358/* ===================================================================== *
359 Inlines
360 * ===================================================================== */
361
362//-----------------------------------------------------------------------
363// Some functions that require the above definitions to work
364
365inline GameWorld *Effectron::world() const {
366 return _parent->_world;
367}
368inline int16 Effectron::getMapNum() const {
369 return _parent->_world->_mapNum;
370}
371
372inline EffectID Effectron::spellID() {
373 return _parent->_spell;
374}
375inline SpellDisplayPrototype *Effectron::spell() {
376 return (*g_vm->_sdpList)[(SpellID)spellID()];
377}
378inline EffectID Effectron::effectID() {
379 return spell()->_effect;
380}
381inline EffectDisplayPrototype *Effectron::effect() {
382 return _parent->_effect;
383}
384inline EffectronFlags Effectron::staCall() {
385 return _parent->_effect->_status(this);
386}
387inline TilePoint Effectron::posCall() {
388 return _parent->_effect->_location(this);
389}
390inline SpellSpritationSeed Effectron::sprCall() {
391 return _parent->_effect->_spriteno(this);
392}
393inline spellHeight Effectron::hgtCall() {
394 return _parent->_effect->_height(this);
395}
396inline spellBreadth Effectron::brdCall() {
397 return _parent->_effect->_breadth(this);
398}
399inline void Effectron::initCall(int16 eno) {
400 _partno = eno;
401 _parent->_effect->_init(this);
402}
403
404/* ===================================================================== *
405 prototypes
406 * ===================================================================== */
407
408int16 whichColorMap(EffectID eid, const Effectron *const effectron);
409
410//-----------------------------------------------------------------------
411// Spell building block functions
412// These are the functions available to update various aspects
413// of Effectrons
414
415SPELLSTATUSFUNCTION(invisibleSpellSta);
416SPELLSTATUSFUNCTION(auraSpellSta);
417SPELLSTATUSFUNCTION(projectileSpellSta);
418SPELLSTATUSFUNCTION(exchangeSpellSta);
419SPELLSTATUSFUNCTION(boltSpellSta);
420SPELLSTATUSFUNCTION(coneSpellSta);
421SPELLSTATUSFUNCTION(ballSpellSta);
422SPELLSTATUSFUNCTION(squareSpellSta);
423SPELLSTATUSFUNCTION(waveSpellSta);
424SPELLSTATUSFUNCTION(stormSpellSta);
425SPELLSTATUSFUNCTION(beamSpellSta);
426SPELLSTATUSFUNCTION(wallSpellSta);
427
428SPELLLOCATIONFUNCTION(invisibleSpellPos);
429SPELLLOCATIONFUNCTION(auraSpellPos);
430SPELLLOCATIONFUNCTION(projectileSpellPos);
431SPELLLOCATIONFUNCTION(exchangeSpellPos);
432SPELLLOCATIONFUNCTION(boltSpellPos);
433SPELLLOCATIONFUNCTION(coneSpellPos);
434SPELLLOCATIONFUNCTION(ballSpellPos);
435SPELLLOCATIONFUNCTION(squareSpellPos);
436SPELLLOCATIONFUNCTION(waveSpellPos);
437SPELLLOCATIONFUNCTION(stormSpellPos);
438SPELLLOCATIONFUNCTION(beamSpellPos);
439SPELLLOCATIONFUNCTION(wallSpellPos);
440SPELLLOCATIONFUNCTION(glowSpellPos);
441
442SPELLSPRITATIONFUNCTION(invisibleSprites);
443SPELLSPRITATIONFUNCTION(auraSprites);
444SPELLSPRITATIONFUNCTION(projectileSprites);
445SPELLSPRITATIONFUNCTION(exchangeSprites);
446SPELLSPRITATIONFUNCTION(boltSprites);
447SPELLSPRITATIONFUNCTION(coneSprites);
448SPELLSPRITATIONFUNCTION(ballSprites);
449SPELLSPRITATIONFUNCTION(squareSprites);
450SPELLSPRITATIONFUNCTION(waveSprites);
451SPELLSPRITATIONFUNCTION(stormSprites);
452SPELLSPRITATIONFUNCTION(beamSprites);
453SPELLSPRITATIONFUNCTION(wallSprites);
454
455SPELLHEIGHTFUNCTION(ShortTillThere);
456SPELLHEIGHTFUNCTION(GrowLinear);
457SPELLBREADTHFUNCTION(StaticHeight);
458
459SPELLBREADTHFUNCTION(ThinTillThere);
460SPELLBREADTHFUNCTION(BulkLinear);
461SPELLBREADTHFUNCTION(StaticBreadth);
462
463SPELLINITFUNCTION(invisibleSpellInit);
464SPELLINITFUNCTION(auraSpellInit);
465SPELLINITFUNCTION(projectileSpellInit);
466SPELLINITFUNCTION(exchangeSpellInit);
467SPELLINITFUNCTION(boltSpellInit);
468SPELLINITFUNCTION(coneSpellInit);
469SPELLINITFUNCTION(ballSpellInit);
470SPELLINITFUNCTION(squareSpellInit);
471SPELLINITFUNCTION(waveSpellInit);
472SPELLINITFUNCTION(stormSpellInit);
473SPELLINITFUNCTION(glowSpellInit);
474SPELLINITFUNCTION(beamSpellInit);
475SPELLINITFUNCTION(wallSpellInit);
476
477} // end of namespace Saga2
478
479#endif //SPELLBUK_H
Definition: memstream.h:194
Definition: savefile.h:54
Definition: stream.h:745
Definition: dispnode.h:86
Definition: spelshow.h:112
Definition: spelshow.h:183
Definition: speldefs.h:277
Definition: objects.h:118
Definition: objects.h:768
Definition: spelshow.h:333
Definition: spelshow.h:229
Definition: spelshow.h:272
Definition: spelshow.h:292
Definition: speldefs.h:139
Definition: spellio.h:57
Definition: spellio.h:132
Definition: tcoords.h:127