1 /* GemRB - Infinity Engine Emulator 2 * Copyright (C) 2003 The GemRB Project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 * 19 */ 20 21 /** 22 * @file Spell.h 23 * Declares Spell, class for magic incantations, cleric prayers, 24 * bardic songs and innate abilities 25 * @author The GemRB Project 26 */ 27 28 #ifndef SPELL_H 29 #define SPELL_H 30 31 #include "exports.h" 32 #include "ie_types.h" 33 34 #include "EffectQueue.h" 35 36 namespace GemRB { 37 38 class Projectile; 39 40 //values for Spell usability Flags 41 42 #define SF_BREAK_SANCTUARY 0x200 // TODO: EE bit to force the removal of any fx_set_sanctuary_state effects 43 #define SF_HOSTILE 0x400 // bit 18 44 #define SF_NO_LOS 0x800 45 // unknown Allow spotting 0x1000 46 #define SF_NOT_INDOORS 0x2000 47 #define SF_HLA 0x4000 // this means a nonmagical ability (also ignores dead-magic and wild surge effect) 48 #define SF_TRIGGER 0x8000 49 #define SF_NOT_IN_COMBAT 0x10000 // bit 24 unused 50 // 7 unknowns, likely unused 51 #define SF_TARGETS_INVISIBLE 0x1000000 // tobex/ee: can target invisible creatures 52 #define SF_IGNORES_SILENCE 0x2000000 // tobex/ee: can be cast while silenced 53 //this is a relocated bit (used in iwd2 as 0x4000) 54 #define SF_SIMPLIFIED_DURATION 0x40 55 56 //spelltypes in spells 57 #define IE_SPL_ITEM 0 58 #define IE_SPL_WIZARD 1 59 #define IE_SPL_PRIEST 2 60 #define IE_SPL_PSION 3 61 #define IE_SPL_INNATE 4 62 #define IE_SPL_SONG 5 63 64 //this is not the same as the book types which is 3 or 11) 65 #define NUM_SPELL_TYPES 6 66 67 #define SPEC_IDENTIFY 1 //spells that don't appear in the casting bar 68 #define SPEC_SILENCE 2 //spells that can be cast when silenced 69 #define SPEC_DEAD 4 //spells that can target dead actors despite their target type is 1 (pst hack) 70 71 extern void ReleaseMemorySpell(); 72 73 /** 74 * @class SPLExtHeader 75 * Header for Spell special effects 76 */ 77 78 class GEM_EXPORT SPLExtHeader { 79 public: 80 SPLExtHeader(); 81 ~SPLExtHeader(); 82 83 ieByte SpellForm; 84 ieByte Hostile; 85 ieByte Location; 86 ieByte unknown2; 87 ieResRef MemorisedIcon; 88 ieByte Target; 89 ieByte TargetNumber; 90 ieWord Range; 91 ieWord RequiredLevel; 92 ieDword CastingTime; 93 ieWord DiceSides; 94 ieWord DiceThrown; 95 ieWord DamageBonus; 96 ieWord DamageType; 97 ieWord FeatureCount; 98 ieWord FeatureOffset; 99 ieWord Charges; 100 ieWord ChargeDepletion; 101 ieWord ProjectileAnimation; 102 Effect* features; 103 }; 104 105 /** 106 * @class Spell 107 * Class for magic incantations, cleric prayers, 108 * bardic songs and innate abilities. 109 */ 110 111 class GEM_EXPORT Spell { 112 public: 113 Spell(); 114 ~Spell(); 115 116 SPLExtHeader *ext_headers; 117 Effect* casting_features; 118 119 /** Resref of the spell itself */ 120 ieResRef Name; 121 ieStrRef SpellName; 122 ieStrRef SpellNameIdentified; 123 ieResRef CompletionSound; 124 ieDword Flags; 125 ieWord SpellType; 126 ieWord ExclusionSchool; 127 ieWord PriestType; 128 ieWord CastingGraphics; 129 ieByte unknown1; 130 ieWord PrimaryType; 131 ieByte SecondaryType; 132 ieDword unknown2; 133 ieDword unknown3; 134 ieDword unknown4; 135 ieDword SpellLevel; 136 ieWord unknown5; 137 ieResRef SpellbookIcon; 138 ieWord unknown6; 139 ieDword unknown7; 140 ieDword unknown8; 141 ieDword unknown9; 142 ieStrRef SpellDesc; 143 ieStrRef SpellDescIdentified; 144 ieDword unknown10; 145 ieDword unknown11; 146 ieDword unknown12; 147 ieDword ExtHeaderOffset; 148 ieWord ExtHeaderCount; 149 ieDword FeatureBlockOffset; 150 ieWord CastingFeatureOffset; 151 ieWord CastingFeatureCount; 152 153 // IWD2 only 154 ieByte TimePerLevel; 155 ieByte TimeConstant; 156 char unknown13[14]; 157 //derived values 158 int CastingSound; 159 160 public: 161 //returns the requested extended header GetExtHeader(unsigned int which)162 inline SPLExtHeader *GetExtHeader(unsigned int which) const 163 { 164 if (Flags & SF_SIMPLIFIED_DURATION) { 165 which = 0; 166 } 167 168 if(ExtHeaderCount<=which) { 169 return NULL; 170 } 171 return ext_headers+which; 172 } 173 //converts a wanted level to block index count 174 int GetHeaderIndexFromLevel(int level) const; 175 //-1 will return the cfb 176 EffectQueue *GetEffectBlock(Scriptable *self, const Point &pos, int block_index, int level, ieDword pro=0) const; 177 // add appropriate casting glow effect 178 void AddCastingGlow(EffectQueue *fxqueue, ieDword duration, int gender) const; 179 //returns a projectile created from an extended header 180 Projectile *GetProjectile(Scriptable *self, int headerindex, int level, const Point &pos) const; 181 unsigned int GetCastingDistance(Scriptable *Sender) const; 182 bool ContainsDamageOpcode() const; 183 }; 184 185 } 186 187 #endif // ! SPELL_H 188