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
|
/* 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
* aint32 with this program; if not, write to the Free Software
*
*
* Based on the original sources
* Faery Tale II -- The Halls of the Dead
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
#include "saga2/saga2.h"
#include "saga2/spelshow.h"
#include "saga2/spelvals.h"
#include "saga2/tilevect.h"
namespace Saga2 {
// ------------------------------------------------------------------
// Spell Display Initialization handlers
//
// What is primarily done in these routines is to set up
// the positions, velocities & accelerations of the individual
// effectrons
// In most cases, once the effectrons are given their initial
// push they can be updated by just adding the velocity to the
// position.
// Sprite directionality is also set up here
//
/* ===================================================================== *
Inlines
* ===================================================================== */
#define randOff (randomVector(TilePoint(-1,-1,0),TilePoint(1,1,0)))
/* ===================================================================== *
Effect specific code
* ===================================================================== */
// ------------------------------------------------------------------
// null effect
SPELLINITFUNCTION(invisibleSpellInit) {
effectron->_velocity = TilePoint(0, 0, 0);
effectron->_acceleration = TilePoint(0, 0, 0);
}
// ------------------------------------------------------------------
// aura that tracks target
SPELLINITFUNCTION(auraSpellInit) {
if (effectron->_parent->_maxAge)
effectron->_totalSteps = effectron->_parent->_maxAge;
else
effectron->_totalSteps = 20;
effectron->_current = effectron->_parent->_target->getPoint();
effectron->_velocity = TilePoint(0, 0, 0);
effectron->_acceleration = TilePoint(0, 0, 0);
}
// ------------------------------------------------------------------
// aura that tracks target (in front)
SPELLINITFUNCTION(glowSpellInit) {
if (effectron->_parent->_maxAge)
effectron->_totalSteps = effectron->_parent->_maxAge;
else
effectron->_totalSteps = 20;
effectron->_current = effectron->_parent->_target->getPoint() - TilePoint(1, 1, 0);
effectron->_finish = effectron->_current;
effectron->_velocity = TilePoint(0, 0, 0);
effectron->_acceleration = TilePoint(0, 0, 0);
}
// ------------------------------------------------------------------
// sprites that surround target
SPELLINITFUNCTION(wallSpellInit) {
if (effectron->_parent->_maxAge)
effectron->_totalSteps = effectron->_parent->_maxAge;
else
effectron->_totalSteps = 20;
effectron->_current = effectron->_parent->_target->getPoint();
effectron->_velocity = WallVectors[effectron->_partno] * kWallSpellRadius / 3;
effectron->_current = effectron->_parent->_target->getPoint() + effectron->_velocity;
effectron->_acceleration = TilePoint(0, 0, 0);
}
// ------------------------------------------------------------------
// projectile from caster to target
SPELLINITFUNCTION(projectileSpellInit) {
effectron->_start = effectron->_current;
effectron->_finish = effectron->_parent->_target->getPoint();
TilePoint tp = (effectron->_finish - effectron->_start);
effectron->_totalSteps = 1 + (tp.magnitude() / (2 * kSpellJumpiness));
effectron->_velocity = tp / effectron->_totalSteps;
effectron->_acceleration = TilePoint(0, 0, 0);
}
// ------------------------------------------------------------------
// bi-directional beams of energy
SPELLINITFUNCTION(exchangeSpellInit) {
if (effectron->_partno % 2) {
effectron->_finish = effectron->_current;
effectron->_start = effectron->_parent->_target->getPoint();
} else {
effectron->_start = effectron->_current;
effectron->_finish = effectron->_parent->_target->getPoint();
}
TilePoint tp = (effectron->_finish - effectron->_start);
effectron->_totalSteps = 1 + (tp.magnitude() / (kSpellJumpiness));
effectron->_velocity = tp / effectron->_totalSteps;
effectron->_totalSteps += (effectron->_partno / 2);
effectron->_acceleration = TilePoint(0, 0, 0);
effectron->_current = effectron->_start;
}
// ------------------------------------------------------------------
// lightning bolt shaped spell
SPELLINITFUNCTION(boltSpellInit) {
effectron->_stepNo = 0;
if (effectron->_parent->_maxAge)
effectron->_totalSteps = effectron->_parent->_maxAge;
else
effectron->_totalSteps = 1 + (kBoltSpellLength / (kSpellJumpiness * 3));
effectron->_start = effectron->_current;
effectron->_finish = effectron->_parent->_target->getPoint();
TilePoint tVect = effectron->_finish - effectron->_start ;
setMagnitude(tVect, kBoltSpellLength);
TilePoint orth = rightVector(tVect, 0);
setMagnitude(orth, kBoltSpellWidth * (effectron->_partno % 3 - 1) / 6);
TilePoint offVect = tVect * ((effectron->_partno / 3) % 3) / (kSpellJumpiness * 3);
effectron->_start += orth;
effectron->_finish += orth + offVect;
effectron->_velocity = tVect / effectron->_totalSteps + randOff;
effectron->_acceleration = TilePoint(0, 0, 0);
effectron->_current = effectron->_start;
}
// ------------------------------------------------------------------
// narrow bolt
SPELLINITFUNCTION(beamSpellInit) {
effectron->_stepNo = 0;
if (effectron->_parent->_maxAge)
effectron->_totalSteps = effectron->_parent->_maxAge;
else
effectron->_totalSteps = 1 + (kBeamSpellLength / (kSpellJumpiness));
effectron->_start = effectron->_current;
effectron->_finish = effectron->_parent->_target->getPoint();
TilePoint tVect = effectron->_finish - effectron->_start ;
setMagnitude(tVect, kBeamSpellLength);
TilePoint orth = rightVector(tVect, 0);
setMagnitude(orth, kBeamSpellWidth / 2);
effectron->_start += (tVect * effectron->_partno) / effectron->_totalSteps;
effectron->_finish = effectron->_start;
effectron->_velocity = orth;
effectron->_acceleration = TilePoint(0, 0, 0);
effectron->_current = effectron->_start;
}
// ------------------------------------------------------------------
// narrow cone shaped spell
SPELLINITFUNCTION(coneSpellInit) {
effectron->_stepNo = 0;
effectron->_totalSteps = 1 + (kConeSpellLength / (kSpellJumpiness * 3));
effectron->_start = effectron->_current;
effectron->_finish = effectron->_parent->_target->getPoint();
TilePoint tVect = effectron->_finish - effectron->_start ;
setMagnitude(tVect, kConeSpellLength);
TilePoint orth = rightVector(tVect, 0);
setMagnitude(orth, kConeSpellWidth * (effectron->_partno % 9 - 4) / 8);
effectron->_finish = effectron->_start + tVect + orth;
effectron->_velocity = (effectron->_finish - effectron->_start) / effectron->_totalSteps + randOff;
effectron->_acceleration = TilePoint(0, 0, 0);
}
// ------------------------------------------------------------------
// wide cone shaped spell
SPELLINITFUNCTION(waveSpellInit) {
effectron->_stepNo = 0;
effectron->_totalSteps = 1 + (kConeSpellLength / (kSpellJumpiness * 2));
effectron->_start = effectron->_current;
effectron->_finish = effectron->_parent->_target->getPoint();
TilePoint tVect = effectron->_finish - effectron->_start ;
setMagnitude(tVect, kWaveSpellLength);
TilePoint orth = rightVector(tVect, 0);
setMagnitude(orth, kWaveSpellWidth * (effectron->_partno % 17 - 8) / 8);
effectron->_finish = effectron->_start + tVect + orth;
effectron->_velocity = (effectron->_finish - effectron->_start) / effectron->_totalSteps + randOff;
effectron->_acceleration = TilePoint(0, 0, 0);
}
// ------------------------------------------------------------------
// small exploding ball
SPELLINITFUNCTION(ballSpellInit) {
effectron->_stepNo = 0;
effectron->_start = effectron->_current;
effectron->_finish = FireballVectors[effectron->_partno];
setMagnitude(effectron->_finish, kBallSpellRadius);
effectron->_finish = effectron->_finish + effectron->_start;
effectron->_totalSteps = 1 + (kBallSpellRadius / kSpellJumpiness);
effectron->_acceleration = TilePoint(0, 0, 0);
TilePoint tp = (effectron->_finish - effectron->_start);
effectron->_totalSteps = 1 + (tp.magnitude() / kSpellJumpiness);
effectron->_velocity = tp / effectron->_totalSteps;
effectron->_velocity.z = 0;
effectron->_acceleration = TilePoint(0, 0, 0);
}
// ------------------------------------------------------------------
// square exploding ball
SPELLINITFUNCTION(squareSpellInit) {
effectron->_stepNo = 0;
effectron->_start = effectron->_current;
effectron->_finish = SquareSpellVectors[effectron->_partno];
setMagnitude(effectron->_finish, effectron->_finish.magnitude()*kSquareSpellSize / 4);
effectron->_finish = effectron->_finish + effectron->_start;
effectron->_totalSteps = 1 + (kSquareSpellSize / kSpellJumpiness);
effectron->_acceleration = TilePoint(0, 0, 0);
TilePoint tp = (effectron->_finish - effectron->_start);
effectron->_totalSteps = 1 + (tp.magnitude() / kSpellJumpiness);
effectron->_velocity = tp / effectron->_totalSteps;
effectron->_velocity.z = 0;
effectron->_acceleration = TilePoint(0, 0, 0);
}
// ------------------------------------------------------------------
// large exploding ball
SPELLINITFUNCTION(stormSpellInit) {
effectron->_stepNo = 0;
effectron->_start = effectron->_current;
effectron->_finish = FireballVectors[effectron->_partno];
setMagnitude(effectron->_finish, kBallSpellRadius);
effectron->_finish = effectron->_finish + effectron->_start;
effectron->_totalSteps = 1 + (kBallSpellRadius / kSpellJumpiness);
effectron->_acceleration = TilePoint(0, 0, 0);
TilePoint tp = (effectron->_finish - effectron->_start);
effectron->_totalSteps = 1 + (2 * tp.magnitude() / kSpellJumpiness);
effectron->_velocity = tp / effectron->_totalSteps;
effectron->_velocity.z = 0;
effectron->_acceleration = TilePoint(0, 0, 0);
}
} // end of namespace Saga2
|