factored out the EFFv2 saving into EFFImporter
[gemrb.git] / gemrb / core / Spell.h
blob785f1ac0caafd6c3d49d308384dd12225ef3e05a
1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
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.
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.
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.
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
28 #ifndef SPELL_H
29 #define SPELL_H
31 #include "exports.h"
32 #include "ie_types.h"
34 #include "EffectQueue.h"
36 class Projectile;
38 //values for Spell usability Flags
40 #define SF_HOSTILE 0x400
41 #define SF_NO_LOS 0x800
42 #define SF_NOT_INDOORS 0x2000
43 #define SF_HLA 0x4000 // probably this means a nonmagical ability
44 #define SF_TRIGGER 0x8000
45 #define SF_NOT_IN_COMBAT 0x10000
46 //this is a relocated bit (used in iwd2 as 0x4000)
47 #define SF_SIMPLIFIED_DURATION 0x40
49 //spelltypes in spells
50 #define IE_SPL_ITEM 0
51 #define IE_SPL_WIZARD 1
52 #define IE_SPL_PRIEST 2
53 #define IE_SPL_PSION 3
54 #define IE_SPL_INNATE 4
55 #define IE_SPL_SONG 5
57 //this is not the same as the book types which is 3 or 11)
58 #define NUM_SPELL_TYPES 6
60 /**
61 * @class SPLExtHeader
62 * Header for Spell special effects
65 class GEM_EXPORT SPLExtHeader {
66 public:
67 SPLExtHeader();
68 ~SPLExtHeader();
70 ieByte SpellForm;
71 ieByte unknown1;
72 ieByte Location;
73 ieByte unknown2;
74 ieResRef MemorisedIcon;
75 ieByte Target;
76 ieByte TargetNumber;
77 ieWord Range;
78 ieWord RequiredLevel;
79 ieDword CastingTime;
80 ieWord DiceSides;
81 ieWord DiceThrown;
82 ieWord DamageBonus;
83 ieWord DamageType;
84 ieWord FeatureCount;
85 ieWord FeatureOffset;
86 ieWord Charges;
87 ieWord ChargeDepletion;
88 ieWord ProjectileAnimation;
89 Effect* features;
92 /**
93 * @class Spell
94 * Class for magic incantations, cleric prayers,
95 * bardic songs and innate abilities.
98 class GEM_EXPORT Spell {
99 public:
100 Spell();
101 ~Spell();
103 SPLExtHeader *ext_headers;
104 Effect* casting_features;
106 /** Resref of the spell itself */
107 ieResRef Name;
108 ieStrRef SpellName;
109 ieStrRef SpellNameIdentified;
110 ieResRef CompletionSound;
111 ieDword Flags;
112 ieWord SpellType;
113 ieWord ExclusionSchool;
114 ieWord PriestType;
115 ieWord CastingGraphics;
116 ieByte unknown1;
117 ieWord PrimaryType;
118 ieByte SecondaryType;
119 ieDword unknown2;
120 ieDword unknown3;
121 ieDword unknown4;
122 ieDword SpellLevel;
123 ieWord unknown5;
124 ieResRef SpellbookIcon;
125 ieWord unknown6;
126 ieDword unknown7;
127 ieDword unknown8;
128 ieDword unknown9;
129 ieStrRef SpellDesc;
130 ieStrRef SpellDescIdentified;
131 ieDword unknown10;
132 ieDword unknown11;
133 ieDword unknown12;
134 ieDword ExtHeaderOffset;
135 ieWord ExtHeaderCount;
136 ieDword FeatureBlockOffset;
137 ieWord CastingFeatureOffset;
138 ieWord CastingFeatureCount;
140 // IWD2 only
141 ieDword TimePerLevel;
142 ieDword TimeConstant;
143 char unknown13[8];
144 //derived values
145 int CastingSound;
147 public:
148 //returns the requested extended header
149 inline SPLExtHeader *GetExtHeader(unsigned int which) const
151 if (Flags & SF_SIMPLIFIED_DURATION) {
152 which = 0;
155 if(ExtHeaderCount<=which) {
156 return NULL;
158 return ext_headers+which;
160 //converts a wanted level to block index count
161 int GetHeaderIndexFromLevel(int level) const;
162 //-1 will return the cfb
163 EffectQueue *GetEffectBlock(Scriptable *self, const Point &pos, int block_index, ieDword pro=0) const;
164 // add appropriate casting glow effect
165 void AddCastingGlow(EffectQueue *fxqueue, ieDword duration, int gender);
166 //returns a projectile created from an extended header
167 Projectile *GetProjectile(Scriptable *self, int headerindex, const Point &pos) const;
168 unsigned int GetCastingDistance(Scriptable *Sender) const;
171 #endif // ! SPELL_H