[4434] * Fixed: restore build mangos at Windows. Some lost in prev. commit changes :(
[mangos-git.git] / src / game / SpellAuras.h
blobe047b4a28a4002f636b000a15b6ded970b7a1034
1 /*
2 * Copyright (C) 2005,2006,2007 MaNGOS <http://www.mangosproject.org/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #ifndef MANGOS_SPELLAURAS_H
19 #define MANGOS_SPELLAURAS_H
21 #include "SpellAuraDefines.h"
23 struct DamageManaShield
25 uint32 m_spellId;
26 uint32 m_modType;
27 int32 m_schoolType;
28 uint32 m_totalAbsorb;
29 uint32 m_currAbsorb;
32 struct Modifier
34 uint8 m_auraname;
35 int32 m_amount;
36 int32 m_miscvalue;
37 uint32 m_miscvalue2;
38 uint32 periodictime;
41 class Unit;
42 struct SpellEntry;
43 struct ProcTriggerSpell;
45 typedef void(Aura::*pAuraHandler)(bool Apply, bool Real);
46 // Real == true at aura add/remove
47 // Real == false at aura mod unapply/reapply, when this need to add/remove dependent aura/item/stat mods
49 // Code in aura handler can be guarded by if(Real) check in case if need it execution only at real add/remove of aura
51 // MAIN RULE: Code DON'T MUST be guarded by if(Real) check if this aura mod required to unapply before add/remove dependent aura/item/stat mods
52 // (percent auras, stats mods, etc)
53 // Second rule: Code must be guarded by if(Real) check if it modify object state (start/stop attack, send packets to client, etc)
55 // Other case choice: each code line moved under if(Real) check is mangos speedup,
56 // each setting object update field code line moved under if(Real) check is significant mangos speedup, and less server->client data sends
57 // each packet sending code moved under if(Real) check is _large_ mangos speedup, and lot less server->client data sends
59 class Aura
61 public:
62 //aura handlers
63 void HandleNULL(bool, bool)
65 // NOT IMPLEMENTED
67 void HandleNoImmediateEffect(bool, bool)
69 // aura not have immediate effect at add/remove and handled by ID in other code place
71 void HandleBindSight(bool Apply, bool Real);
72 void HandleModPossess(bool Apply, bool Real);
73 void HandlePeriodicDamage(bool Apply, bool Real);
74 void HandleAuraDummy(bool Apply, bool Real);
75 void HandleModConfuse(bool Apply, bool Real);
76 void HandleModCharm(bool Apply, bool Real);
77 void HandleModFear(bool Apply, bool Real);
78 void HandlePeriodicHeal(bool Apply, bool Real);
79 void HandleModAttackSpeed(bool Apply, bool Real);
80 void HandleModCombatSpeedPct(bool apply, bool Real);
81 void HandleModThreat(bool Apply, bool Real);
82 void HandleModTaunt(bool Apply, bool Real);
83 void HandleFeignDeath(bool Apply, bool Real);
84 void HandleAuraModDisarm(bool Apply, bool Real);
85 void HandleAuraModStalked(bool Apply, bool Real);
86 void HandleAuraWaterWalk(bool Apply, bool Real);
87 void HandleAuraFeatherFall(bool Apply, bool Real);
88 void HandleAuraHover(bool Apply, bool Real);
89 void HandleAddModifier(bool Apply, bool Real);
90 void HandleAuraModStun(bool Apply, bool Real);
91 void HandleModDamageDone(bool Apply, bool Real);
92 void HandleAuraUntrackable(bool Apply, bool Real);
93 void HandleAuraEmpathy(bool Apply, bool Real);
94 void HandleModOffhandDamagePercent(bool apply, bool Real);
95 void HandleAuraModRangedAttackPower(bool Apply, bool Real);
96 void HandleAuraModIncreaseSpeedAlways(bool Apply, bool Real);
97 void HandleAuraModIncreaseEnergyPercent(bool Apply, bool Real);
98 void HandleAuraModIncreaseHealthPercent(bool Apply, bool Real);
99 void HandleHaste(bool Apply, bool Real);
100 void HandlePeriodicTriggerSpell(bool Apply, bool Real);
101 void HandlePeriodicEnergize(bool Apply, bool Real);
102 void HandleAuraModResistanceExclusive(bool Apply, bool Real);
103 void HandleAuraSafeFall(bool Apply, bool Real);
104 void HandleAuraDamageShield(bool Apply, bool Real);
105 void HandleModStealth(bool Apply, bool Real);
106 void HandleModStealthDetect(bool Apply, bool Real);
107 void HandleInvisibility(bool Apply, bool Real);
108 void HandleInvisibilityDetect(bool Apply, bool Real);
109 void HandleAuraModTotalHealthPercentRegen(bool Apply, bool Real);
110 void HandleAuraModTotalManaPercentRegen(bool Apply, bool Real);
111 void HandleAuraModResistance(bool Apply, bool Real);
112 void HandleAuraModRoot(bool Apply, bool Real);
113 void HandleAuraModSilence(bool Apply, bool Real);
114 void HandleAuraModStat(bool Apply, bool Real);
115 void HandleAuraModIncreaseSpeed(bool Apply, bool Real);
116 void HandleAuraModIncreaseMountedSpeed(bool Apply, bool Real);
117 void HandleAuraModDecreaseSpeed(bool Apply, bool Real);
118 void HandleAuraModIncreaseHealth(bool Apply, bool Real);
119 void HandleAuraModIncreaseEnergy(bool Apply, bool Real);
120 void HandleAuraModShapeshift(bool Apply, bool Real);
121 void HandleAuraModEffectImmunity(bool Apply, bool Real);
122 void HandleAuraModStateImmunity(bool Apply, bool Real);
123 void HandleAuraModSchoolImmunity(bool Apply, bool Real);
124 void HandleAuraModDmgImmunity(bool Apply, bool Real);
125 void HandleAuraModDispelImmunity(bool Apply, bool Real);
126 void HandleAuraProcTriggerSpell(bool Apply, bool Real);
127 void HandleAuraProcTriggerDamage(bool Apply, bool Real);
128 void HandleAuraTrackCreatures(bool Apply, bool Real);
129 void HandleAuraTrackResources(bool Apply, bool Real);
130 void HandleAuraModParryPercent(bool Apply, bool Real);
131 void HandleAuraModDodgePercent(bool Apply, bool Real);
132 void HandleAuraModBlockPercent(bool Apply, bool Real);
133 void HandleAuraModCritPercent(bool Apply, bool Real);
134 void HandlePeriodicLeech(bool Apply, bool Real);
135 void HandleModHitChance(bool Apply, bool Real);
136 void HandleModSpellHitChance(bool Apply, bool Real);
137 void HandleAuraModScale(bool Apply, bool Real);
138 void HandlePeriodicManaLeech(bool Apply, bool Real);
139 void HandleModCastingSpeed(bool Apply, bool Real);
140 void HandleAuraMounted(bool Apply, bool Real);
141 void HandleWaterBreathing(bool Apply, bool Real);
142 void HandleModBaseResistance(bool Apply, bool Real);
143 void HandleModRegen(bool Apply, bool Real);
144 void HandleModPowerRegen(bool Apply, bool Real);
145 void HandleChannelDeathItem(bool Apply, bool Real);
146 void HandlePeriodicDamagePCT(bool Apply, bool Real);
147 void HandleAuraModAttackPower(bool Apply, bool Real);
148 void HandleAuraTransform(bool Apply, bool Real);
149 void HandleModSpellCritChance(bool Apply, bool Real);
150 void HandleAuraModIncreaseSwimSpeed(bool Apply, bool Real);
151 void HandleModPowerCost(bool Apply, bool Real);
152 void HandleFarSight(bool Apply, bool Real);
153 void HandleModPossessPet(bool Apply, bool Real);
154 void HandleModMechanicImmunity(bool Apply, bool Real);
155 void HandleAuraModSkill(bool Apply, bool Real);
156 void HandleModDamagePercentDone(bool Apply, bool Real);
157 void HandleModPercentStat(bool Apply, bool Real);
158 void HandleModResistancePercent(bool Apply, bool Real);
159 void HandleAuraModBaseResistancePCT(bool Apply, bool Real);
160 void HandleModShieldBlockPCT(bool Apply, bool Real);
161 void HandleAuraTrackStealthed(bool Apply, bool Real);
162 void HandleModShieldBlock(bool Apply, bool Real);
163 void HandleForceReaction(bool Apply, bool Real);
164 void HandleAuraModRangedHaste(bool Apply, bool Real);
165 void HandleRangedAmmoHaste(bool Apply, bool Real);
166 void HandleModHealingDone(bool Apply, bool Real);
167 void HandleModTotalPercentStat(bool Apply, bool Real);
168 void HandleAuraModTotalThreat(bool Apply, bool Real);
169 void HandleModUnattackable(bool Apply, bool Real);
170 void HandleInterruptRegen(bool Apply, bool Real);
171 void HandleAuraModPacify(bool Apply, bool Real);
172 void HandleAuraGhost(bool Apply, bool Real);
173 void HandleAuraAllowFlight(bool Apply, bool Real);
174 void HandleAuraModSpeedMountedFlight(bool Apply, bool Real);
175 void HandleAuraModSpeedFlight(bool Apply, bool Real);
176 void HandleModRating(bool apply, bool Real);
177 void HandleModTargetResistance(bool apply, bool Real);
178 void HandleAuraModAttackPowerPercent(bool apply, bool Real);
179 void HandleAuraModRangedAttackPowerPercent(bool apply, bool Real);
180 void HandleSpiritOfRedumption(bool apply, bool Real);
181 void HandleAuraHealingPct(bool apply, bool Real);
182 void HandleModManaRegen(bool apply, bool Real);
183 void HandleAuraHealing(bool apply, bool Real);
184 void HandleShieldBlockValue(bool apply, bool Real);
185 void HandleModSpellCritChanceShool(bool apply, bool Real);
186 void HandleAuraRetainComboPoints(bool apply, bool Real);
188 Aura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL);
189 virtual ~Aura();
191 void SetModifier(uint8 t, int32 a, uint32 pt, int32 miscValue, uint32 miscValue2);
192 Modifier* GetModifier() {return &m_modifier;}
194 SpellEntry const* GetSpellProto() const { return m_spellProto; }
195 uint32 GetId() const{ return m_spellId; }
196 uint64 GetCastItemGUID() const { return m_castItemGuid; }
197 uint32 GetEffIndex() const{ return m_effIndex; }
198 void SetEffIndex(uint32 eff) { m_effIndex = eff; }
199 int32 GetBasePoints() const { return m_currentBasePoints; }
200 int32 GetAuraDuration() const { return m_duration; }
201 void SetAuraDuration(int32 duration) { m_duration = duration; }
202 time_t GetAuraApplyTime() { return m_applyTime; }
203 void UpdateAuraDuration();
205 uint64 const& GetCasterGUID() const { return m_caster_guid; }
206 Unit* GetCaster() const;
207 Unit* GetTarget() const { return m_target; }
208 void SetTarget(Unit* target) { m_target = target; }
209 void SetLoadedState(uint64 caster_guid,int32 damage,int32 duration)
211 m_caster_guid = caster_guid;
212 m_modifier.m_amount = damage;
213 m_duration = duration;
216 uint8 GetAuraSlot() const { return m_auraSlot; }
217 void SetAuraSlot(uint8 slot) { m_auraSlot = slot; }
219 bool IsPositive() { return m_positive; }
220 void SetNegative() { m_positive = false; }
221 void SetPositive() { m_positive = true; }
223 bool IsPermanent() const { return m_permanent; }
224 bool IsAreaAura() const { return m_isAreaAura; }
225 bool IsPeriodic() const { return m_isPeriodic; }
226 bool IsTrigger() const { return m_isTrigger; }
227 bool IsPassive() const { return m_isPassive; }
228 bool IsPersistent() const { return m_isPersistent; }
229 bool IsDeathPersistent() const { return m_isDeathPersist; }
231 virtual void Update(uint32 diff);
232 void ApplyModifier(bool apply, bool Real = false);
234 void _AddAura();
235 void _RemoveAura();
237 void TriggerSpell();
238 void SendCoolDownEvent();
239 bool IsUpdated() { return m_updated; }
240 void SetUpdated(bool val) { m_updated = val; }
241 void SetRemoveOnDeath(bool rod) { m_removeOnDeath = rod; }
243 int32 m_procCharges;
245 // add/remove SPELL_AURA_MOD_SHAPESHIFT (36) linked auras
246 void HandleShapeshiftBoosts(bool apply);
247 protected:
248 Modifier m_modifier;
249 SpellModifier *m_spellmod;
250 uint32 m_spellId;
251 uint32 m_effIndex;
252 SpellEntry const *m_spellProto;
253 int32 m_currentBasePoints; // cache SpellEntry::EffectBasePoints and use for set custom base points
254 uint64 m_caster_guid;
255 Unit* m_target;
256 int32 m_duration;
257 int32 m_timeCla;
258 // it is NOT safe to keep a pointer to the item because it may get deleted
259 uint64 m_castItemGuid;
260 time_t m_applyTime;
262 uint8 m_auraSlot;
264 bool m_positive;
265 bool m_permanent;
266 bool m_isPeriodic;
267 bool m_isTrigger;
268 bool m_isAreaAura;
269 bool m_isPassive;
270 bool m_isPersistent;
271 bool m_isDeathPersist;
273 int32 m_periodicTimer;
274 uint32 m_PeriodicEventId;
275 bool m_updated;
276 bool m_removeOnDeath;
277 private:
278 void UpdateSlotCounterAndDuration(bool add);
279 float m_fearMoveAngle;
282 class AreaAura : public Aura
284 public:
285 AreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL);
286 ~AreaAura();
287 void Update(uint32 diff);
290 class PersistentAreaAura : public Aura
292 public:
293 PersistentAreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL);
294 ~PersistentAreaAura();
295 void Update(uint32 diff);
297 #endif