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