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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * 22 * Based on the original sources 23 * Faery Tale II -- The Halls of the Dead 24 * (c) 1993-1996 The Wyrmkeep Entertainment Co. 25 */ 26 27 #ifndef SAGA2_SPELLBUK_H 28 #define SAGA2_SPELLBUK_H 29 30 namespace Saga2 { 31 32 struct ResourceSpellEffect; 33 struct ResourceSpellItem; 34 35 class SpellTarget; 36 class ProtoEffect; 37 38 // Mana IDs as spells see them 39 40 enum SpellManaID { 41 sManaIDRed = 0, 42 sManaIDOrange = 1, 43 sManaIDYellow = 2, 44 sManaIDGreen = 3, 45 sManaIDBlue = 4, 46 sManaIDViolet = 5, 47 sManaIDSkill = 6 // skills are here for convenience 48 }; 49 50 //------------------------------------------------------------------- 51 // targeting bits 52 // These two types are used to determine : 53 // The types of screen object a spell can be used on 54 // The type of target the spell will eventually be applied to 55 // respectively. 56 57 //------------------------------------------------------------------- 58 // legal target selections 59 enum SpellTargetingTypes { 60 spellTargNone = 0, 61 spellTargWorld = 1 << 0, // instant spell 62 spellTargLocation = 1 << 1, // cast at any location on map 63 spellTargTAG = 1 << 2, // cast at tileactivity inst. 64 spellTargObject = 1 << 3, // cast at objects 65 spellTargActor = 1 << 4, 66 spellTargCaster = 1 << 5 67 }; 68 69 //------------------------------------------------------------------- 70 // target type the spell uses when implemented 71 enum SpellApplicationTypes { 72 spellApplyNone = spellTargNone, 73 spellApplyWorld = spellTargWorld, 74 spellApplyLocation = spellTargLocation, 75 spellApplyTAG = spellTargTAG, 76 spellApplyObject = spellTargObject, 77 spellApplyActor = spellTargObject, 78 spellApplyTracking = 1 << 6 // track object targets 79 }; 80 81 82 //------------------------------------------------------------------- 83 // effect templates 84 // These are the shapes of the visible effects of spells 85 86 enum effectAreas { 87 eAreaInvisible = 0, 88 eAreaAura, 89 eAreaProjectile, 90 eAreaExchange, 91 eAreaBolt, 92 eAreaCone, 93 eAreaBall, 94 eAreaSquare, 95 eAreaWave, 96 eAreaStorm, 97 eAreaMissle, 98 eAreaGlow, 99 eAreaBeam, 100 eAreaWall 101 }; 102 103 104 105 //------------------------------------------------------------------- 106 // SpellStuff 107 // The master spell list is an array of these records. 108 // Unfortunately this class and the SpellDisplayProto could have been 109 // implemented as one larger structure, but the evolved from separate 110 // parts of the code 111 112 class SpellStuff { 113 SpellID master; // index in array 114 SkillProto *prototype; // ponts back to object prototype 115 SpellID display; // currently same as master 116 SpellTargetingTypes targetableTypes; // valid targeting types 117 SpellApplicationTypes targetTypes; // the targeting type to implement 118 ProtoEffect *effects; // the effects of this spell 119 SpellTarget *targets; // transient target list 120 SpellManaID manaType; // color mana used 121 int8 manaUse; // mana points used 122 effectAreas shape; 123 int32 size; 124 int32 range; 125 int16 sound; 126 127 public: 128 129 SpellStuff(); 130 setProto(SkillProto * p)131 void setProto(SkillProto *p) { 132 prototype = p; 133 } getProto(void)134 SkillProto *getProto(void) { 135 return prototype; 136 } 137 138 void setupFromResource(ResourceSpellItem *rsi); 139 140 void addEffect(ProtoEffect *pe); 141 void addEffect(ResourceSpellEffect *rse); 142 void killEffects(void); 143 canTarget(SpellTargetingTypes t)144 bool canTarget(SpellTargetingTypes t) { 145 return targetableTypes & t; 146 } shouldTarget(SpellApplicationTypes t)147 bool shouldTarget(SpellApplicationTypes t) { 148 return targetTypes & t; 149 } 150 untargetable(void)151 bool untargetable(void) { 152 return (targetableTypes == spellTargNone); 153 } untargeted(void)154 bool untargeted(void) { 155 return false; //(targetableTypes == spellTargWorld ) || 156 } 157 //(targetableTypes == spellTargCaster ) || 158 //(targetableTypes == targetableTypes & 159 // (spellTargWorld | spellTargCaster)); } 160 161 void implement(GameObject *enactor, SpellTarget *target); 162 void implement(GameObject *enactor, GameObject *target); 163 void implement(GameObject *enactor, ActiveItem *target); 164 void implement(GameObject *enactor, Location target); 165 getDisplayID(void)166 SpellID getDisplayID(void) { 167 return display; 168 } getManaType(void)169 SpellManaID getManaType(void) { 170 return manaType; 171 } setManaType(SpellManaID smid)172 void setManaType(SpellManaID smid) { 173 manaType = smid; 174 } getManaAmt(void)175 int8 getManaAmt(void) { 176 return manaUse; 177 } getRange(void)178 int32 getRange(void) { 179 return range; 180 } 181 182 void buildTargetList(GameObject *, SpellTarget &); 183 void addTarget(SpellTarget *trg); 184 void removeTargetList(); 185 186 void apply(ProtoEffect *pe, GameObject *target); 187 void apply(ProtoEffect *pe, ActiveItem *target); 188 189 void playSound(GameObject *go); 190 void show(GameObject *, SpellTarget &); 191 bool safe(void); 192 bool isOffensive(void); 193 }; 194 195 /* ===================================================================== * 196 Prototypes 197 * ===================================================================== */ 198 199 //------------------------------------------------------------------- 200 // At this point these are the effects requiring special handling 201 202 SPECIALSPELL(DeathSpell); 203 SPECIALSPELL(DispellProtections); 204 SPECIALSPELL(DispellCurses); 205 SPECIALSPELL(Resurrect); 206 SPECIALSPELL(CreateWallOfFire); 207 SPECIALSPELL(CreateFireWisp); 208 SPECIALSPELL(CreateWindWisp); 209 SPECIALSPELL(Timequake); 210 SPECIALSPELL(TeleportToShrine); 211 SPECIALSPELL(TeleportToLocation); 212 SPECIALSPELL(Rejoin); 213 SPECIALSPELL(CreateRingOfForce); 214 SPECIALSPELL(DispellPoison); 215 SPECIALSPELL(CreateWraith); 216 SPECIALSPELL(SagaSpellCall); 217 SPECIALSPELL(CreateWWisp); 218 SPECIALSPELL(CreateFWisp); 219 SPECIALSPELL(CreateWraith); 220 SPECIALSPELL(CreateFood); 221 222 } // End of namespace Saga2 223 224 #endif //SPELLBUK_H 225