1 | /* |
---|
2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
3 | * |
---|
4 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or modify |
---|
7 | * it under the terms of the GNU General Public License as published by |
---|
8 | * the Free Software Foundation; either version 2 of the License, or |
---|
9 | * (at your option) any later version. |
---|
10 | * |
---|
11 | * This program is distributed in the hope that it will be useful, |
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | * GNU General Public License for more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License |
---|
17 | * along with this program; if not, write to the Free Software |
---|
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
19 | */ |
---|
20 | #ifndef TRINITY_SPELLAURAS_H |
---|
21 | #define TRINITY_SPELLAURAS_H |
---|
22 | |
---|
23 | #include "SpellAuraDefines.h" |
---|
24 | |
---|
25 | struct DamageManaShield |
---|
26 | { |
---|
27 | uint32 m_spellId; |
---|
28 | uint32 m_modType; |
---|
29 | int32 m_schoolType; |
---|
30 | uint32 m_totalAbsorb; |
---|
31 | uint32 m_currAbsorb; |
---|
32 | }; |
---|
33 | |
---|
34 | struct Modifier |
---|
35 | { |
---|
36 | AuraType m_auraname; |
---|
37 | int32 m_amount; |
---|
38 | int32 m_miscvalue; |
---|
39 | uint32 periodictime; |
---|
40 | }; |
---|
41 | |
---|
42 | class Unit; |
---|
43 | struct SpellEntry; |
---|
44 | struct SpellModifier; |
---|
45 | struct ProcTriggerSpell; |
---|
46 | |
---|
47 | // forward decl |
---|
48 | class Aura; |
---|
49 | |
---|
50 | typedef void(Aura::*pAuraHandler)(bool Apply, bool Real); |
---|
51 | // Real == true at aura add/remove |
---|
52 | // Real == false at aura mod unapply/reapply; when adding/removing dependent aura/item/stat mods |
---|
53 | // |
---|
54 | // Code in aura handler can be guarded by if(Real) check if it should execution only at real add/remove of aura |
---|
55 | // |
---|
56 | // MAIN RULE: Code MUST NOT be guarded by if(Real) check if it modifies any stats |
---|
57 | // (percent auras, stats mods, etc) |
---|
58 | // Second rule: Code must be guarded by if(Real) check if it modifies object state (start/stop attack, send packets to client, etc) |
---|
59 | // |
---|
60 | // Other case choice: each code line moved under if(Real) check is Trinity speedup, |
---|
61 | // each setting object update field code line moved under if(Real) check is significant Trinity speedup, and less server->client data sends |
---|
62 | // each packet sending code moved under if(Real) check is _large_ Trinity speedup, and lot less server->client data sends |
---|
63 | |
---|
64 | class TRINITY_DLL_SPEC Aura |
---|
65 | { |
---|
66 | friend Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem); |
---|
67 | |
---|
68 | public: |
---|
69 | //aura handlers |
---|
70 | void HandleNULL(bool, bool) |
---|
71 | { |
---|
72 | // NOT IMPLEMENTED |
---|
73 | } |
---|
74 | void HandleUnused(bool, bool) |
---|
75 | { |
---|
76 | // NOT USED BY ANY SPELL OR USELESS |
---|
77 | } |
---|
78 | void HandleNoImmediateEffect(bool, bool) |
---|
79 | { |
---|
80 | // aura not have immediate effect at add/remove and handled by ID in other code place |
---|
81 | } |
---|
82 | void HandleBindSight(bool Apply, bool Real); |
---|
83 | void HandleModPossess(bool Apply, bool Real); |
---|
84 | void HandlePeriodicDamage(bool Apply, bool Real); |
---|
85 | void HandleAuraDummy(bool Apply, bool Real); |
---|
86 | void HandleAuraPeriodicDummy(bool apply, bool Real); |
---|
87 | void HandleModConfuse(bool Apply, bool Real); |
---|
88 | void HandleModCharm(bool Apply, bool Real); |
---|
89 | void HandleModFear(bool Apply, bool Real); |
---|
90 | void HandlePeriodicHeal(bool Apply, bool Real); |
---|
91 | void HandleModAttackSpeed(bool Apply, bool Real); |
---|
92 | void HandleModMeleeRangedSpeedPct(bool apply, bool Real); |
---|
93 | void HandleModCombatSpeedPct(bool apply, bool Real); |
---|
94 | void HandleModThreat(bool Apply, bool Real); |
---|
95 | void HandleModTaunt(bool Apply, bool Real); |
---|
96 | void HandleFeignDeath(bool Apply, bool Real); |
---|
97 | void HandleAuraModDisarm(bool Apply, bool Real); |
---|
98 | void HandleAuraModStalked(bool Apply, bool Real); |
---|
99 | void HandleAuraWaterWalk(bool Apply, bool Real); |
---|
100 | void HandleAuraFeatherFall(bool Apply, bool Real); |
---|
101 | void HandleAuraHover(bool Apply, bool Real); |
---|
102 | void HandleAddModifier(bool Apply, bool Real); |
---|
103 | void HandleAuraModStun(bool Apply, bool Real); |
---|
104 | void HandleModDamageDone(bool Apply, bool Real); |
---|
105 | void HandleAuraUntrackable(bool Apply, bool Real); |
---|
106 | void HandleAuraEmpathy(bool Apply, bool Real); |
---|
107 | void HandleModOffhandDamagePercent(bool apply, bool Real); |
---|
108 | void HandleAuraModRangedAttackPower(bool Apply, bool Real); |
---|
109 | void HandleAuraModIncreaseEnergyPercent(bool Apply, bool Real); |
---|
110 | void HandleAuraModIncreaseHealthPercent(bool Apply, bool Real); |
---|
111 | void HandleAuraModRegenInterrupt(bool Apply, bool Real); |
---|
112 | void HandleHaste(bool Apply, bool Real); |
---|
113 | void HandlePeriodicTriggerSpell(bool Apply, bool Real); |
---|
114 | void HandlePeriodicEnergize(bool Apply, bool Real); |
---|
115 | void HandleAuraModResistanceExclusive(bool Apply, bool Real); |
---|
116 | void HandleModStealth(bool Apply, bool Real); |
---|
117 | void HandleInvisibility(bool Apply, bool Real); |
---|
118 | void HandleInvisibilityDetect(bool Apply, bool Real); |
---|
119 | void HandleAuraModTotalHealthPercentRegen(bool Apply, bool Real); |
---|
120 | void HandleAuraModTotalManaPercentRegen(bool Apply, bool Real); |
---|
121 | void HandleAuraModResistance(bool Apply, bool Real); |
---|
122 | void HandleAuraModRoot(bool Apply, bool Real); |
---|
123 | void HandleAuraModSilence(bool Apply, bool Real); |
---|
124 | void HandleAuraModStat(bool Apply, bool Real); |
---|
125 | void HandleAuraModIncreaseSpeed(bool Apply, bool Real); |
---|
126 | void HandleAuraModIncreaseMountedSpeed(bool Apply, bool Real); |
---|
127 | void HandleAuraModIncreaseFlightSpeed(bool Apply, bool Real); |
---|
128 | void HandleAuraModDecreaseSpeed(bool Apply, bool Real); |
---|
129 | void HandleAuraModUseNormalSpeed(bool Apply, bool Real); |
---|
130 | void HandleAuraModIncreaseHealth(bool Apply, bool Real); |
---|
131 | void HandleAuraModIncreaseEnergy(bool Apply, bool Real); |
---|
132 | void HandleAuraModShapeshift(bool Apply, bool Real); |
---|
133 | void HandleAuraModEffectImmunity(bool Apply, bool Real); |
---|
134 | void HandleAuraModStateImmunity(bool Apply, bool Real); |
---|
135 | void HandleAuraModSchoolImmunity(bool Apply, bool Real); |
---|
136 | void HandleAuraModDmgImmunity(bool Apply, bool Real); |
---|
137 | void HandleAuraModDispelImmunity(bool Apply, bool Real); |
---|
138 | void HandleAuraProcTriggerSpell(bool Apply, bool Real); |
---|
139 | void HandleAuraTrackCreatures(bool Apply, bool Real); |
---|
140 | void HandleAuraTrackResources(bool Apply, bool Real); |
---|
141 | void HandleAuraModParryPercent(bool Apply, bool Real); |
---|
142 | void HandleAuraModDodgePercent(bool Apply, bool Real); |
---|
143 | void HandleAuraModBlockPercent(bool Apply, bool Real); |
---|
144 | void HandleAuraModCritPercent(bool Apply, bool Real); |
---|
145 | void HandlePeriodicLeech(bool Apply, bool Real); |
---|
146 | void HandleModHitChance(bool Apply, bool Real); |
---|
147 | void HandleModSpellHitChance(bool Apply, bool Real); |
---|
148 | void HandleAuraModScale(bool Apply, bool Real); |
---|
149 | void HandlePeriodicManaLeech(bool Apply, bool Real); |
---|
150 | void HandleModCastingSpeed(bool Apply, bool Real); |
---|
151 | void HandleAuraMounted(bool Apply, bool Real); |
---|
152 | void HandleWaterBreathing(bool Apply, bool Real); |
---|
153 | void HandleModBaseResistance(bool Apply, bool Real); |
---|
154 | void HandleModRegen(bool Apply, bool Real); |
---|
155 | void HandleModPowerRegen(bool Apply, bool Real); |
---|
156 | void HandleModPowerRegenPCT(bool Apply, bool Real); |
---|
157 | void HandleChannelDeathItem(bool Apply, bool Real); |
---|
158 | void HandlePeriodicDamagePCT(bool Apply, bool Real); |
---|
159 | void HandleAuraModAttackPower(bool Apply, bool Real); |
---|
160 | void HandleAuraTransform(bool Apply, bool Real); |
---|
161 | void HandleModSpellCritChance(bool Apply, bool Real); |
---|
162 | void HandleAuraModIncreaseSwimSpeed(bool Apply, bool Real); |
---|
163 | void HandleModPowerCostPCT(bool Apply, bool Real); |
---|
164 | void HandleModPowerCost(bool Apply, bool Real); |
---|
165 | void HandleFarSight(bool Apply, bool Real); |
---|
166 | void HandleModPossessPet(bool Apply, bool Real); |
---|
167 | void HandleModMechanicImmunity(bool Apply, bool Real); |
---|
168 | void HandleAuraModSkill(bool Apply, bool Real); |
---|
169 | void HandleModDamagePercentDone(bool Apply, bool Real); |
---|
170 | void HandleModPercentStat(bool Apply, bool Real); |
---|
171 | void HandleModResistancePercent(bool Apply, bool Real); |
---|
172 | void HandleAuraModBaseResistancePCT(bool Apply, bool Real); |
---|
173 | void HandleModShieldBlockPCT(bool Apply, bool Real); |
---|
174 | void HandleAuraTrackStealthed(bool Apply, bool Real); |
---|
175 | void HandleModShieldBlock(bool Apply, bool Real); |
---|
176 | void HandleForceReaction(bool Apply, bool Real); |
---|
177 | void HandleAuraModRangedHaste(bool Apply, bool Real); |
---|
178 | void HandleRangedAmmoHaste(bool Apply, bool Real); |
---|
179 | void HandleModHealingDone(bool Apply, bool Real); |
---|
180 | void HandleModTotalPercentStat(bool Apply, bool Real); |
---|
181 | void HandleAuraModTotalThreat(bool Apply, bool Real); |
---|
182 | void HandleModUnattackable(bool Apply, bool Real); |
---|
183 | void HandleAuraModPacify(bool Apply, bool Real); |
---|
184 | void HandleAuraGhost(bool Apply, bool Real); |
---|
185 | void HandleAuraAllowFlight(bool Apply, bool Real); |
---|
186 | void HandleModRating(bool apply, bool Real); |
---|
187 | void HandleModTargetResistance(bool apply, bool Real); |
---|
188 | void HandleAuraAttackPowerAttacker(bool apply, bool Real); |
---|
189 | void HandleAuraModAttackPowerPercent(bool apply, bool Real); |
---|
190 | void HandleAuraModRangedAttackPowerPercent(bool apply, bool Real); |
---|
191 | void HandleAuraModRangedAttackPowerOfStatPercent(bool apply, bool Real); |
---|
192 | void HandleSpiritOfRedemption(bool apply, bool Real); |
---|
193 | void HandleAuraHealingPct(bool apply, bool Real); |
---|
194 | void HandleModManaRegen(bool apply, bool Real); |
---|
195 | void HandleComprehendLanguage(bool apply, bool Real); |
---|
196 | void HandleAuraHealing(bool apply, bool Real); |
---|
197 | void HandleShieldBlockValue(bool apply, bool Real); |
---|
198 | void HandleModSpellCritChanceShool(bool apply, bool Real); |
---|
199 | void HandleAuraRetainComboPoints(bool apply, bool Real); |
---|
200 | void HandleModSpellDamagePercentFromStat(bool apply, bool Real); |
---|
201 | void HandleModSpellHealingPercentFromStat(bool apply, bool Real); |
---|
202 | void HandleAuraModDispelResist(bool apply, bool Real); |
---|
203 | void HandleModSpellDamagePercentFromAttackPower(bool apply, bool Real); |
---|
204 | void HandleModSpellHealingPercentFromAttackPower(bool apply, bool Real); |
---|
205 | void HandleAuraModPacifyAndSilence(bool Apply, bool Real); |
---|
206 | void HandleAuraModIncreaseMaxHealth(bool apply, bool Real); |
---|
207 | void HandleAuraModExpertise(bool apply, bool Real); |
---|
208 | void HandleForceMoveForward(bool apply, bool Real); |
---|
209 | void HandleAuraModResistenceOfStatPercent(bool apply, bool Real); |
---|
210 | void HandleAuraPowerBurn(bool apply, bool Real); |
---|
211 | void HandleSchoolAbsorb(bool apply, bool Real); |
---|
212 | void HandlePreventFleeing(bool apply, bool Real); |
---|
213 | void HandleManaShield(bool apply, bool Real); |
---|
214 | void HandleArenaPreparation(bool apply, bool Real); |
---|
215 | |
---|
216 | virtual ~Aura(); |
---|
217 | |
---|
218 | void SetModifier(AuraType t, int32 a, uint32 pt, int32 miscValue); |
---|
219 | Modifier* GetModifier() {return &m_modifier;} |
---|
220 | int32 GetMiscValue() {return m_spellProto->EffectMiscValue[m_effIndex];} |
---|
221 | int32 GetMiscBValue() {return m_spellProto->EffectMiscValueB[m_effIndex];} |
---|
222 | |
---|
223 | SpellEntry const* GetSpellProto() const { return m_spellProto; } |
---|
224 | uint32 GetId() const{ return m_spellProto->Id; } |
---|
225 | uint64 GetCastItemGUID() const { return m_castItemGuid; } |
---|
226 | uint32 GetEffIndex() const{ return m_effIndex; } |
---|
227 | int32 GetBasePoints() const { return m_currentBasePoints; } |
---|
228 | |
---|
229 | int32 GetAuraMaxDuration() const { return m_maxduration; } |
---|
230 | void SetAuraMaxDuration(int32 duration) { m_maxduration = duration; } |
---|
231 | int32 GetAuraDuration() const { return m_duration; } |
---|
232 | void SetAuraDuration(int32 duration) { m_duration = duration; } |
---|
233 | time_t GetAuraApplyTime() { return m_applyTime; } |
---|
234 | void UpdateAuraDuration(); |
---|
235 | void SendAuraDurationForCaster(Player* caster); |
---|
236 | |
---|
237 | uint64 const& GetCasterGUID() const { return m_caster_guid; } |
---|
238 | Unit* GetCaster() const; |
---|
239 | Unit* GetTarget() const { return m_target; } |
---|
240 | void SetTarget(Unit* target) { m_target = target; } |
---|
241 | void SetLoadedState(uint64 caster_guid,int32 damage,int32 maxduration,int32 duration,int32 charges) |
---|
242 | { |
---|
243 | m_caster_guid = caster_guid; |
---|
244 | m_modifier.m_amount = damage; |
---|
245 | m_maxduration = maxduration; |
---|
246 | m_duration = duration; |
---|
247 | m_procCharges = charges; |
---|
248 | } |
---|
249 | |
---|
250 | uint8 GetAuraSlot() const { return m_auraSlot; } |
---|
251 | void SetAuraSlot(uint8 slot) { m_auraSlot = slot; } |
---|
252 | void UpdateAuraCharges() |
---|
253 | { |
---|
254 | uint8 slot = GetAuraSlot(); |
---|
255 | |
---|
256 | // only aura inslot with charges and without stack limitation |
---|
257 | if (slot < MAX_AURAS && m_procCharges >= 1 && GetSpellProto()->StackAmount==0) |
---|
258 | SetAuraApplication(slot, m_procCharges - 1); |
---|
259 | } |
---|
260 | |
---|
261 | bool IsPositive() { return m_positive; } |
---|
262 | void SetNegative() { m_positive = false; } |
---|
263 | void SetPositive() { m_positive = true; } |
---|
264 | |
---|
265 | bool IsPermanent() const { return m_permanent; } |
---|
266 | bool IsAreaAura() const { return m_isAreaAura; } |
---|
267 | bool IsPeriodic() const { return m_isPeriodic; } |
---|
268 | bool IsTrigger() const { return m_isTrigger; } |
---|
269 | bool IsPassive() const { return m_isPassive; } |
---|
270 | bool IsPersistent() const { return m_isPersistent; } |
---|
271 | bool IsDeathPersistent() const { return m_isDeathPersist; } |
---|
272 | bool IsRemovedOnShapeLost() const { return m_isRemovedOnShapeLost; } |
---|
273 | bool IsInUse() const { return m_in_use;} |
---|
274 | |
---|
275 | virtual void Update(uint32 diff); |
---|
276 | void ApplyModifier(bool apply, bool Real = false); |
---|
277 | |
---|
278 | void _AddAura(); |
---|
279 | void _RemoveAura(); |
---|
280 | |
---|
281 | void TriggerSpell(); |
---|
282 | |
---|
283 | bool IsUpdated() { return m_updated; } |
---|
284 | void SetUpdated(bool val) { m_updated = val; } |
---|
285 | void SetRemoveMode(AuraRemoveMode mode) { m_removeMode = mode; } |
---|
286 | |
---|
287 | int32 m_procCharges; |
---|
288 | void SetAuraProcCharges(int32 charges) { m_procCharges = charges; } |
---|
289 | |
---|
290 | Unit* GetTriggerTarget() const; |
---|
291 | |
---|
292 | // add/remove SPELL_AURA_MOD_SHAPESHIFT (36) linked auras |
---|
293 | void HandleShapeshiftBoosts(bool apply); |
---|
294 | |
---|
295 | // Allow Apply Aura Handler to modify and access m_AuraDRGroup |
---|
296 | void setDiminishGroup(DiminishingGroup group) { m_AuraDRGroup = group; } |
---|
297 | DiminishingGroup getDiminishGroup() const { return m_AuraDRGroup; } |
---|
298 | |
---|
299 | void PeriodicTick(); |
---|
300 | void PeriodicDummyTick(); |
---|
301 | protected: |
---|
302 | Aura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); |
---|
303 | |
---|
304 | Modifier m_modifier; |
---|
305 | SpellModifier *m_spellmod; |
---|
306 | uint32 m_effIndex; |
---|
307 | SpellEntry const *m_spellProto; |
---|
308 | int32 m_currentBasePoints; // cache SpellEntry::EffectBasePoints and use for set custom base points |
---|
309 | uint64 m_caster_guid; |
---|
310 | Unit* m_target; |
---|
311 | int32 m_maxduration; |
---|
312 | int32 m_duration; |
---|
313 | int32 m_timeCla; |
---|
314 | uint64 m_castItemGuid; // it is NOT safe to keep a pointer to the item because it may get deleted |
---|
315 | time_t m_applyTime; |
---|
316 | |
---|
317 | AuraRemoveMode m_removeMode; |
---|
318 | |
---|
319 | uint8 m_auraSlot; |
---|
320 | |
---|
321 | bool m_positive:1; |
---|
322 | bool m_permanent:1; |
---|
323 | bool m_isPeriodic:1; |
---|
324 | bool m_isTrigger:1; |
---|
325 | bool m_isAreaAura:1; |
---|
326 | bool m_isPassive:1; |
---|
327 | bool m_isPersistent:1; |
---|
328 | bool m_isDeathPersist:1; |
---|
329 | bool m_isRemovedOnShapeLost:1; |
---|
330 | bool m_updated:1; |
---|
331 | bool m_in_use:1; // true while in Aura::ApplyModifier call |
---|
332 | |
---|
333 | int32 m_periodicTimer; |
---|
334 | uint32 m_PeriodicEventId; |
---|
335 | DiminishingGroup m_AuraDRGroup; |
---|
336 | private: |
---|
337 | void UpdateSlotCounterAndDuration(bool add); |
---|
338 | void CleanupTriggeredSpells(); |
---|
339 | void SetAura(uint32 slot, bool remove) { m_target->SetUInt32Value(UNIT_FIELD_AURA + slot, remove ? 0 : GetId()); } |
---|
340 | void SetAuraFlag(uint32 slot, bool add); |
---|
341 | void SetAuraLevel(uint32 slot, uint32 level); |
---|
342 | void SetAuraApplication(uint32 slot, int8 count); |
---|
343 | }; |
---|
344 | |
---|
345 | class TRINITY_DLL_SPEC AreaAura : public Aura |
---|
346 | { |
---|
347 | public: |
---|
348 | AreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); |
---|
349 | ~AreaAura(); |
---|
350 | void Update(uint32 diff); |
---|
351 | private: |
---|
352 | float m_radius; |
---|
353 | AreaAuraType m_areaAuraType; |
---|
354 | }; |
---|
355 | |
---|
356 | class TRINITY_DLL_SPEC PersistentAreaAura : public Aura |
---|
357 | { |
---|
358 | public: |
---|
359 | PersistentAreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); |
---|
360 | ~PersistentAreaAura(); |
---|
361 | void Update(uint32 diff); |
---|
362 | }; |
---|
363 | |
---|
364 | Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); |
---|
365 | #endif |
---|