[9956] Spell 45524 expected apply debuf 55095 to target at cast.
[getmangos.git] / src / game / SpellAuras.cpp
blob843ef5c7ccbdc8d1051678f96005f758353dfd91
1 /*
2 * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
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
19 #include "Common.h"
20 #include "Database/DatabaseEnv.h"
21 #include "WorldPacket.h"
22 #include "WorldSession.h"
23 #include "Opcodes.h"
24 #include "Log.h"
25 #include "UpdateMask.h"
26 #include "World.h"
27 #include "ObjectMgr.h"
28 #include "SpellMgr.h"
29 #include "Player.h"
30 #include "Unit.h"
31 #include "Spell.h"
32 #include "DynamicObject.h"
33 #include "Group.h"
34 #include "UpdateData.h"
35 #include "ObjectAccessor.h"
36 #include "Policies/SingletonImp.h"
37 #include "Totem.h"
38 #include "Creature.h"
39 #include "Formulas.h"
40 #include "BattleGround.h"
41 #include "CreatureAI.h"
42 #include "ScriptCalls.h"
43 #include "Util.h"
44 #include "GridNotifiers.h"
45 #include "GridNotifiersImpl.h"
46 #include "Vehicle.h"
47 #include "CellImpl.h"
49 #define NULL_AURA_SLOT 0xFF
51 pAuraHandler AuraHandler[TOTAL_AURAS]=
53 &Aura::HandleNULL, // 0 SPELL_AURA_NONE
54 &Aura::HandleBindSight, // 1 SPELL_AURA_BIND_SIGHT
55 &Aura::HandleModPossess, // 2 SPELL_AURA_MOD_POSSESS
56 &Aura::HandlePeriodicDamage, // 3 SPELL_AURA_PERIODIC_DAMAGE
57 &Aura::HandleAuraDummy, // 4 SPELL_AURA_DUMMY
58 &Aura::HandleModConfuse, // 5 SPELL_AURA_MOD_CONFUSE
59 &Aura::HandleModCharm, // 6 SPELL_AURA_MOD_CHARM
60 &Aura::HandleModFear, // 7 SPELL_AURA_MOD_FEAR
61 &Aura::HandlePeriodicHeal, // 8 SPELL_AURA_PERIODIC_HEAL
62 &Aura::HandleModAttackSpeed, // 9 SPELL_AURA_MOD_ATTACKSPEED
63 &Aura::HandleModThreat, // 10 SPELL_AURA_MOD_THREAT
64 &Aura::HandleModTaunt, // 11 SPELL_AURA_MOD_TAUNT
65 &Aura::HandleAuraModStun, // 12 SPELL_AURA_MOD_STUN
66 &Aura::HandleModDamageDone, // 13 SPELL_AURA_MOD_DAMAGE_DONE
67 &Aura::HandleNoImmediateEffect, // 14 SPELL_AURA_MOD_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonusTaken and Unit::SpellBaseDamageBonusTaken
68 &Aura::HandleNoImmediateEffect, // 15 SPELL_AURA_DAMAGE_SHIELD implemented in Unit::DealMeleeDamage
69 &Aura::HandleModStealth, // 16 SPELL_AURA_MOD_STEALTH
70 &Aura::HandleNoImmediateEffect, // 17 SPELL_AURA_MOD_STEALTH_DETECT implemented in Unit::isVisibleForOrDetect
71 &Aura::HandleInvisibility, // 18 SPELL_AURA_MOD_INVISIBILITY
72 &Aura::HandleInvisibilityDetect, // 19 SPELL_AURA_MOD_INVISIBILITY_DETECTION
73 &Aura::HandleAuraModTotalHealthPercentRegen, // 20 SPELL_AURA_OBS_MOD_HEALTH
74 &Aura::HandleAuraModTotalManaPercentRegen, // 21 SPELL_AURA_OBS_MOD_MANA
75 &Aura::HandleAuraModResistance, // 22 SPELL_AURA_MOD_RESISTANCE
76 &Aura::HandlePeriodicTriggerSpell, // 23 SPELL_AURA_PERIODIC_TRIGGER_SPELL
77 &Aura::HandlePeriodicEnergize, // 24 SPELL_AURA_PERIODIC_ENERGIZE
78 &Aura::HandleAuraModPacify, // 25 SPELL_AURA_MOD_PACIFY
79 &Aura::HandleAuraModRoot, // 26 SPELL_AURA_MOD_ROOT
80 &Aura::HandleAuraModSilence, // 27 SPELL_AURA_MOD_SILENCE
81 &Aura::HandleNoImmediateEffect, // 28 SPELL_AURA_REFLECT_SPELLS implement in Unit::SpellHitResult
82 &Aura::HandleAuraModStat, // 29 SPELL_AURA_MOD_STAT
83 &Aura::HandleAuraModSkill, // 30 SPELL_AURA_MOD_SKILL
84 &Aura::HandleAuraModIncreaseSpeed, // 31 SPELL_AURA_MOD_INCREASE_SPEED
85 &Aura::HandleAuraModIncreaseMountedSpeed, // 32 SPELL_AURA_MOD_INCREASE_MOUNTED_SPEED
86 &Aura::HandleAuraModDecreaseSpeed, // 33 SPELL_AURA_MOD_DECREASE_SPEED
87 &Aura::HandleAuraModIncreaseHealth, // 34 SPELL_AURA_MOD_INCREASE_HEALTH
88 &Aura::HandleAuraModIncreaseEnergy, // 35 SPELL_AURA_MOD_INCREASE_ENERGY
89 &Aura::HandleAuraModShapeshift, // 36 SPELL_AURA_MOD_SHAPESHIFT
90 &Aura::HandleAuraModEffectImmunity, // 37 SPELL_AURA_EFFECT_IMMUNITY
91 &Aura::HandleAuraModStateImmunity, // 38 SPELL_AURA_STATE_IMMUNITY
92 &Aura::HandleAuraModSchoolImmunity, // 39 SPELL_AURA_SCHOOL_IMMUNITY
93 &Aura::HandleAuraModDmgImmunity, // 40 SPELL_AURA_DAMAGE_IMMUNITY
94 &Aura::HandleAuraModDispelImmunity, // 41 SPELL_AURA_DISPEL_IMMUNITY
95 &Aura::HandleAuraProcTriggerSpell, // 42 SPELL_AURA_PROC_TRIGGER_SPELL implemented in Unit::ProcDamageAndSpellFor and Unit::HandleProcTriggerSpell
96 &Aura::HandleNoImmediateEffect, // 43 SPELL_AURA_PROC_TRIGGER_DAMAGE implemented in Unit::ProcDamageAndSpellFor
97 &Aura::HandleAuraTrackCreatures, // 44 SPELL_AURA_TRACK_CREATURES
98 &Aura::HandleAuraTrackResources, // 45 SPELL_AURA_TRACK_RESOURCES
99 &Aura::HandleUnused, // 46 SPELL_AURA_46 (used in test spells 54054 and 54058, and spell 48050) (3.0.8a-3.2.2a)
100 &Aura::HandleAuraModParryPercent, // 47 SPELL_AURA_MOD_PARRY_PERCENT
101 &Aura::HandleNULL, // 48 SPELL_AURA_48 spell Napalm (area damage spell with additional delayed damage effect)
102 &Aura::HandleAuraModDodgePercent, // 49 SPELL_AURA_MOD_DODGE_PERCENT
103 &Aura::HandleNoImmediateEffect, // 50 SPELL_AURA_MOD_CRITICAL_HEALING_AMOUNT implemented in Unit::SpellCriticalHealingBonus
104 &Aura::HandleAuraModBlockPercent, // 51 SPELL_AURA_MOD_BLOCK_PERCENT
105 &Aura::HandleAuraModCritPercent, // 52 SPELL_AURA_MOD_CRIT_PERCENT
106 &Aura::HandlePeriodicLeech, // 53 SPELL_AURA_PERIODIC_LEECH
107 &Aura::HandleModHitChance, // 54 SPELL_AURA_MOD_HIT_CHANCE
108 &Aura::HandleModSpellHitChance, // 55 SPELL_AURA_MOD_SPELL_HIT_CHANCE
109 &Aura::HandleAuraTransform, // 56 SPELL_AURA_TRANSFORM
110 &Aura::HandleModSpellCritChance, // 57 SPELL_AURA_MOD_SPELL_CRIT_CHANCE
111 &Aura::HandleAuraModIncreaseSwimSpeed, // 58 SPELL_AURA_MOD_INCREASE_SWIM_SPEED
112 &Aura::HandleNoImmediateEffect, // 59 SPELL_AURA_MOD_DAMAGE_DONE_CREATURE implemented in Unit::MeleeDamageBonusDone and Unit::SpellDamageBonusDone
113 &Aura::HandleAuraModPacifyAndSilence, // 60 SPELL_AURA_MOD_PACIFY_SILENCE
114 &Aura::HandleAuraModScale, // 61 SPELL_AURA_MOD_SCALE
115 &Aura::HandlePeriodicHealthFunnel, // 62 SPELL_AURA_PERIODIC_HEALTH_FUNNEL
116 &Aura::HandleUnused, // 63 unused (3.0.8a-3.2.2a) old SPELL_AURA_PERIODIC_MANA_FUNNEL
117 &Aura::HandlePeriodicManaLeech, // 64 SPELL_AURA_PERIODIC_MANA_LEECH
118 &Aura::HandleModCastingSpeed, // 65 SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK
119 &Aura::HandleFeignDeath, // 66 SPELL_AURA_FEIGN_DEATH
120 &Aura::HandleAuraModDisarm, // 67 SPELL_AURA_MOD_DISARM
121 &Aura::HandleAuraModStalked, // 68 SPELL_AURA_MOD_STALKED
122 &Aura::HandleSchoolAbsorb, // 69 SPELL_AURA_SCHOOL_ABSORB implemented in Unit::CalculateAbsorbAndResist
123 &Aura::HandleUnused, // 70 SPELL_AURA_EXTRA_ATTACKS Useless, used by only one spell 41560 that has only visual effect (3.2.2a)
124 &Aura::HandleModSpellCritChanceShool, // 71 SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL
125 &Aura::HandleModPowerCostPCT, // 72 SPELL_AURA_MOD_POWER_COST_SCHOOL_PCT
126 &Aura::HandleModPowerCost, // 73 SPELL_AURA_MOD_POWER_COST_SCHOOL
127 &Aura::HandleNoImmediateEffect, // 74 SPELL_AURA_REFLECT_SPELLS_SCHOOL implemented in Unit::SpellHitResult
128 &Aura::HandleNoImmediateEffect, // 75 SPELL_AURA_MOD_LANGUAGE implemented in WorldSession::HandleMessagechatOpcode
129 &Aura::HandleFarSight, // 76 SPELL_AURA_FAR_SIGHT
130 &Aura::HandleModMechanicImmunity, // 77 SPELL_AURA_MECHANIC_IMMUNITY
131 &Aura::HandleAuraMounted, // 78 SPELL_AURA_MOUNTED
132 &Aura::HandleModDamagePercentDone, // 79 SPELL_AURA_MOD_DAMAGE_PERCENT_DONE
133 &Aura::HandleModPercentStat, // 80 SPELL_AURA_MOD_PERCENT_STAT
134 &Aura::HandleNoImmediateEffect, // 81 SPELL_AURA_SPLIT_DAMAGE_PCT implemented in Unit::CalculateAbsorbAndResist
135 &Aura::HandleWaterBreathing, // 82 SPELL_AURA_WATER_BREATHING
136 &Aura::HandleModBaseResistance, // 83 SPELL_AURA_MOD_BASE_RESISTANCE
137 &Aura::HandleModRegen, // 84 SPELL_AURA_MOD_REGEN
138 &Aura::HandleModPowerRegen, // 85 SPELL_AURA_MOD_POWER_REGEN
139 &Aura::HandleChannelDeathItem, // 86 SPELL_AURA_CHANNEL_DEATH_ITEM
140 &Aura::HandleNoImmediateEffect, // 87 SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN implemented in Unit::MeleeDamageBonusTaken and Unit::SpellDamageBonusTaken
141 &Aura::HandleNoImmediateEffect, // 88 SPELL_AURA_MOD_HEALTH_REGEN_PERCENT implemented in Player::RegenerateHealth
142 &Aura::HandlePeriodicDamagePCT, // 89 SPELL_AURA_PERIODIC_DAMAGE_PERCENT
143 &Aura::HandleUnused, // 90 unused (3.0.8a-3.2.2a) old SPELL_AURA_MOD_RESIST_CHANCE
144 &Aura::HandleNoImmediateEffect, // 91 SPELL_AURA_MOD_DETECT_RANGE implemented in Creature::GetAttackDistance
145 &Aura::HandlePreventFleeing, // 92 SPELL_AURA_PREVENTS_FLEEING
146 &Aura::HandleModUnattackable, // 93 SPELL_AURA_MOD_UNATTACKABLE
147 &Aura::HandleNoImmediateEffect, // 94 SPELL_AURA_INTERRUPT_REGEN implemented in Player::RegenerateAll
148 &Aura::HandleAuraGhost, // 95 SPELL_AURA_GHOST
149 &Aura::HandleNoImmediateEffect, // 96 SPELL_AURA_SPELL_MAGNET implemented in Unit::SelectMagnetTarget
150 &Aura::HandleManaShield, // 97 SPELL_AURA_MANA_SHIELD implemented in Unit::CalculateAbsorbAndResist
151 &Aura::HandleAuraModSkill, // 98 SPELL_AURA_MOD_SKILL_TALENT
152 &Aura::HandleAuraModAttackPower, // 99 SPELL_AURA_MOD_ATTACK_POWER
153 &Aura::HandleUnused, //100 SPELL_AURA_AURAS_VISIBLE obsolete 3.x? all player can see all auras now, but still have 2 spells including GM-spell (1852,2855)
154 &Aura::HandleModResistancePercent, //101 SPELL_AURA_MOD_RESISTANCE_PCT
155 &Aura::HandleNoImmediateEffect, //102 SPELL_AURA_MOD_MELEE_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonusDone
156 &Aura::HandleAuraModTotalThreat, //103 SPELL_AURA_MOD_TOTAL_THREAT
157 &Aura::HandleAuraWaterWalk, //104 SPELL_AURA_WATER_WALK
158 &Aura::HandleAuraFeatherFall, //105 SPELL_AURA_FEATHER_FALL
159 &Aura::HandleAuraHover, //106 SPELL_AURA_HOVER
160 &Aura::HandleAddModifier, //107 SPELL_AURA_ADD_FLAT_MODIFIER
161 &Aura::HandleAddModifier, //108 SPELL_AURA_ADD_PCT_MODIFIER
162 &Aura::HandleAddTargetTrigger, //109 SPELL_AURA_ADD_TARGET_TRIGGER
163 &Aura::HandleModPowerRegenPCT, //110 SPELL_AURA_MOD_POWER_REGEN_PERCENT
164 &Aura::HandleNoImmediateEffect, //111 SPELL_AURA_ADD_CASTER_HIT_TRIGGER implemented in Unit::SelectMagnetTarget
165 &Aura::HandleNoImmediateEffect, //112 SPELL_AURA_OVERRIDE_CLASS_SCRIPTS implemented in diff functions.
166 &Aura::HandleNoImmediateEffect, //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonusTaken
167 &Aura::HandleNoImmediateEffect, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonusTaken
168 &Aura::HandleNoImmediateEffect, //115 SPELL_AURA_MOD_HEALING implemented in Unit::SpellBaseHealingBonusTaken
169 &Aura::HandleNoImmediateEffect, //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT imppemented in Player::RegenerateAll and Player::RegenerateHealth
170 &Aura::HandleNoImmediateEffect, //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE implemented in Unit::MagicSpellHitResult
171 &Aura::HandleNoImmediateEffect, //118 SPELL_AURA_MOD_HEALING_PCT implemented in Unit::SpellHealingBonusTaken
172 &Aura::HandleUnused, //119 unused (3.0.8a-3.2.2a) old SPELL_AURA_SHARE_PET_TRACKING
173 &Aura::HandleAuraUntrackable, //120 SPELL_AURA_UNTRACKABLE
174 &Aura::HandleAuraEmpathy, //121 SPELL_AURA_EMPATHY
175 &Aura::HandleModOffhandDamagePercent, //122 SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT
176 &Aura::HandleModTargetResistance, //123 SPELL_AURA_MOD_TARGET_RESISTANCE
177 &Aura::HandleAuraModRangedAttackPower, //124 SPELL_AURA_MOD_RANGED_ATTACK_POWER
178 &Aura::HandleNoImmediateEffect, //125 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonusTaken
179 &Aura::HandleNoImmediateEffect, //126 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonusTaken
180 &Aura::HandleNoImmediateEffect, //127 SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonusDone
181 &Aura::HandleModPossessPet, //128 SPELL_AURA_MOD_POSSESS_PET
182 &Aura::HandleAuraModIncreaseSpeed, //129 SPELL_AURA_MOD_SPEED_ALWAYS
183 &Aura::HandleAuraModIncreaseMountedSpeed, //130 SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS
184 &Aura::HandleNoImmediateEffect, //131 SPELL_AURA_MOD_RANGED_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonusDone
185 &Aura::HandleAuraModIncreaseEnergyPercent, //132 SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT
186 &Aura::HandleAuraModIncreaseHealthPercent, //133 SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT
187 &Aura::HandleAuraModRegenInterrupt, //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT
188 &Aura::HandleModHealingDone, //135 SPELL_AURA_MOD_HEALING_DONE
189 &Aura::HandleNoImmediateEffect, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonusDone
190 &Aura::HandleModTotalPercentStat, //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
191 &Aura::HandleHaste, //138 SPELL_AURA_MOD_HASTE
192 &Aura::HandleForceReaction, //139 SPELL_AURA_FORCE_REACTION
193 &Aura::HandleAuraModRangedHaste, //140 SPELL_AURA_MOD_RANGED_HASTE
194 &Aura::HandleRangedAmmoHaste, //141 SPELL_AURA_MOD_RANGED_AMMO_HASTE
195 &Aura::HandleAuraModBaseResistancePCT, //142 SPELL_AURA_MOD_BASE_RESISTANCE_PCT
196 &Aura::HandleAuraModResistanceExclusive, //143 SPELL_AURA_MOD_RESISTANCE_EXCLUSIVE
197 &Aura::HandleAuraSafeFall, //144 SPELL_AURA_SAFE_FALL implemented in WorldSession::HandleMovementOpcodes
198 &Aura::HandleAuraModPetTalentsPoints, //145 SPELL_AURA_MOD_PET_TALENT_POINTS
199 &Aura::HandleNoImmediateEffect, //146 SPELL_AURA_ALLOW_TAME_PET_TYPE implemented in Player::CanTameExoticPets
200 &Aura::HandleModMechanicImmunityMask, //147 SPELL_AURA_MECHANIC_IMMUNITY_MASK implemented in Unit::IsImmunedToSpell and Unit::IsImmunedToSpellEffect (check part)
201 &Aura::HandleAuraRetainComboPoints, //148 SPELL_AURA_RETAIN_COMBO_POINTS
202 &Aura::HandleNoImmediateEffect, //149 SPELL_AURA_REDUCE_PUSHBACK implemented in Spell::Delayed and Spell::DelayedChannel
203 &Aura::HandleShieldBlockValue, //150 SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT
204 &Aura::HandleAuraTrackStealthed, //151 SPELL_AURA_TRACK_STEALTHED
205 &Aura::HandleNoImmediateEffect, //152 SPELL_AURA_MOD_DETECTED_RANGE implemented in Creature::GetAttackDistance
206 &Aura::HandleNoImmediateEffect, //153 SPELL_AURA_SPLIT_DAMAGE_FLAT implemented in Unit::CalculateAbsorbAndResist
207 &Aura::HandleNoImmediateEffect, //154 SPELL_AURA_MOD_STEALTH_LEVEL implemented in Unit::isVisibleForOrDetect
208 &Aura::HandleNoImmediateEffect, //155 SPELL_AURA_MOD_WATER_BREATHING implemented in Player::getMaxTimer
209 &Aura::HandleNoImmediateEffect, //156 SPELL_AURA_MOD_REPUTATION_GAIN implemented in Player::CalculateReputationGain
210 &Aura::HandleUnused, //157 SPELL_AURA_PET_DAMAGE_MULTI (single test like spell 20782, also single for 214 aura)
211 &Aura::HandleShieldBlockValue, //158 SPELL_AURA_MOD_SHIELD_BLOCKVALUE
212 &Aura::HandleNoImmediateEffect, //159 SPELL_AURA_NO_PVP_CREDIT implemented in Player::RewardHonor
213 &Aura::HandleNoImmediateEffect, //160 SPELL_AURA_MOD_AOE_AVOIDANCE implemented in Unit::MagicSpellHitResult
214 &Aura::HandleNoImmediateEffect, //161 SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT implemented in Player::RegenerateAll and Player::RegenerateHealth
215 &Aura::HandleAuraPowerBurn, //162 SPELL_AURA_POWER_BURN_MANA
216 &Aura::HandleNoImmediateEffect, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS implemented in Unit::CalculateMeleeDamage and Unit::SpellCriticalDamageBonus
217 &Aura::HandleUnused, //164 unused (3.0.8a-3.2.2a), only one test spell 10654
218 &Aura::HandleNoImmediateEffect, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonusDone
219 &Aura::HandleAuraModAttackPowerPercent, //166 SPELL_AURA_MOD_ATTACK_POWER_PCT
220 &Aura::HandleAuraModRangedAttackPowerPercent, //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT
221 &Aura::HandleNoImmediateEffect, //168 SPELL_AURA_MOD_DAMAGE_DONE_VERSUS implemented in Unit::SpellDamageBonusDone, Unit::MeleeDamageBonusDone
222 &Aura::HandleNoImmediateEffect, //169 SPELL_AURA_MOD_CRIT_PERCENT_VERSUS implemented in Unit::DealDamageBySchool, Unit::DoAttackDamage, Unit::SpellCriticalBonus
223 &Aura::HandleNULL, //170 SPELL_AURA_DETECT_AMORE different spells that ignore transformation effects
224 &Aura::HandleAuraModIncreaseSpeed, //171 SPELL_AURA_MOD_SPEED_NOT_STACK
225 &Aura::HandleAuraModIncreaseMountedSpeed, //172 SPELL_AURA_MOD_MOUNTED_SPEED_NOT_STACK
226 &Aura::HandleUnused, //173 unused (3.0.8a-3.2.2a) no spells, old SPELL_AURA_ALLOW_CHAMPION_SPELLS only for Proclaim Champion spell
227 &Aura::HandleModSpellDamagePercentFromStat, //174 SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT implemented in Unit::SpellBaseDamageBonusDone
228 &Aura::HandleModSpellHealingPercentFromStat, //175 SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT implemented in Unit::SpellBaseHealingBonusDone
229 &Aura::HandleSpiritOfRedemption, //176 SPELL_AURA_SPIRIT_OF_REDEMPTION only for Spirit of Redemption spell, die at aura end
230 &Aura::HandleNULL, //177 SPELL_AURA_AOE_CHARM (22 spells)
231 &Aura::HandleNoImmediateEffect, //178 SPELL_AURA_MOD_DEBUFF_RESISTANCE implemented in Unit::MagicSpellHitResult
232 &Aura::HandleNoImmediateEffect, //179 SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE implemented in Unit::SpellCriticalBonus
233 &Aura::HandleNoImmediateEffect, //180 SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS implemented in Unit::SpellDamageBonusDone
234 &Aura::HandleUnused, //181 unused (3.0.8a-3.2.2a) old SPELL_AURA_MOD_FLAT_SPELL_CRIT_DAMAGE_VERSUS
235 &Aura::HandleAuraModResistenceOfStatPercent, //182 SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT
236 &Aura::HandleNoImmediateEffect, //183 SPELL_AURA_MOD_CRITICAL_THREAT only used in 28746, implemented in ThreatCalcHelper::calcThreat
237 &Aura::HandleNoImmediateEffect, //184 SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
238 &Aura::HandleNoImmediateEffect, //185 SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
239 &Aura::HandleNoImmediateEffect, //186 SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE implemented in Unit::MagicSpellHitResult
240 &Aura::HandleNoImmediateEffect, //187 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance
241 &Aura::HandleNoImmediateEffect, //188 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance
242 &Aura::HandleModRating, //189 SPELL_AURA_MOD_RATING
243 &Aura::HandleNoImmediateEffect, //190 SPELL_AURA_MOD_FACTION_REPUTATION_GAIN implemented in Player::CalculateReputationGain
244 &Aura::HandleAuraModUseNormalSpeed, //191 SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED
245 &Aura::HandleModMeleeRangedSpeedPct, //192 SPELL_AURA_HASTE_MELEE
246 &Aura::HandleModCombatSpeedPct, //193 SPELL_AURA_HASTE_ALL (in fact combat (any type attack) speed pct)
247 &Aura::HandleNoImmediateEffect, //194 SPELL_AURA_MOD_IGNORE_ABSORB_SCHOOL implement in Unit::CalcNotIgnoreAbsorbDamage
248 &Aura::HandleNoImmediateEffect, //195 SPELL_AURA_MOD_IGNORE_ABSORB_FOR_SPELL implement in Unit::CalcNotIgnoreAbsorbDamage
249 &Aura::HandleNULL, //196 SPELL_AURA_MOD_COOLDOWN (single spell 24818 in 3.2.2a)
250 &Aura::HandleNoImmediateEffect, //197 SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE implemented in Unit::SpellCriticalBonus Unit::GetUnitCriticalChance
251 &Aura::HandleUnused, //198 unused (3.0.8a-3.2.2a) old SPELL_AURA_MOD_ALL_WEAPON_SKILLS
252 &Aura::HandleNoImmediateEffect, //199 SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT implemented in Unit::MagicSpellHitResult
253 &Aura::HandleNoImmediateEffect, //200 SPELL_AURA_MOD_KILL_XP_PCT implemented in Player::GiveXP
254 &Aura::HandleAuraAllowFlight, //201 SPELL_AURA_FLY this aura enable flight mode...
255 &Aura::HandleNoImmediateEffect, //202 SPELL_AURA_CANNOT_BE_DODGED implemented in Unit::RollPhysicalOutcomeAgainst
256 &Aura::HandleNoImmediateEffect, //203 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE implemented in Unit::CalculateMeleeDamage and Unit::SpellCriticalDamageBonus
257 &Aura::HandleNoImmediateEffect, //204 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE implemented in Unit::CalculateMeleeDamage and Unit::SpellCriticalDamageBonus
258 &Aura::HandleNoImmediateEffect, //205 SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_DAMAGE implemented in Unit::SpellCriticalDamageBonus
259 &Aura::HandleAuraModIncreaseFlightSpeed, //206 SPELL_AURA_MOD_FLIGHT_SPEED
260 &Aura::HandleAuraModIncreaseFlightSpeed, //207 SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED
261 &Aura::HandleAuraModIncreaseFlightSpeed, //208 SPELL_AURA_MOD_FLIGHT_SPEED_STACKING
262 &Aura::HandleAuraModIncreaseFlightSpeed, //209 SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED_STACKING
263 &Aura::HandleAuraModIncreaseFlightSpeed, //210 SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACKING
264 &Aura::HandleAuraModIncreaseFlightSpeed, //211 SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED_NOT_STACKING
265 &Aura::HandleAuraModRangedAttackPowerOfStatPercent, //212 SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT
266 &Aura::HandleNoImmediateEffect, //213 SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT implemented in Player::RewardRage
267 &Aura::HandleUnused, //214 Tamed Pet Passive (single test like spell 20782, also single for 157 aura)
268 &Aura::HandleArenaPreparation, //215 SPELL_AURA_ARENA_PREPARATION
269 &Aura::HandleModCastingSpeed, //216 SPELL_AURA_HASTE_SPELLS
270 &Aura::HandleUnused, //217 unused (3.0.8a-3.2.2a)
271 &Aura::HandleAuraModRangedHaste, //218 SPELL_AURA_HASTE_RANGED
272 &Aura::HandleModManaRegen, //219 SPELL_AURA_MOD_MANA_REGEN_FROM_STAT
273 &Aura::HandleModRatingFromStat, //220 SPELL_AURA_MOD_RATING_FROM_STAT
274 &Aura::HandleNULL, //221 ignored
275 &Aura::HandleUnused, //222 unused (3.0.8a-3.2.2a) only for spell 44586 that not used in real spell cast
276 &Aura::HandleNULL, //223 dummy code (cast damage spell to attacker) and another dymmy (jump to another nearby raid member)
277 &Aura::HandleUnused, //224 unused (3.0.8a-3.2.2a)
278 &Aura::HandleNoImmediateEffect, //225 SPELL_AURA_PRAYER_OF_MENDING
279 &Aura::HandleAuraPeriodicDummy, //226 SPELL_AURA_PERIODIC_DUMMY
280 &Aura::HandlePeriodicTriggerSpellWithValue, //227 SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
281 &Aura::HandleNoImmediateEffect, //228 SPELL_AURA_DETECT_STEALTH
282 &Aura::HandleNoImmediateEffect, //229 SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE implemented in Unit::SpellDamageBonusTaken
283 &Aura::HandleAuraModIncreaseMaxHealth, //230 Commanding Shout
284 &Aura::HandleNoImmediateEffect, //231 SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE
285 &Aura::HandleNoImmediateEffect, //232 SPELL_AURA_MECHANIC_DURATION_MOD implement in Unit::CalculateSpellDuration
286 &Aura::HandleNULL, //233 set model id to the one of the creature with id m_modifier.m_miscvalue
287 &Aura::HandleNoImmediateEffect, //234 SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK implement in Unit::CalculateSpellDuration
288 &Aura::HandleAuraModDispelResist, //235 SPELL_AURA_MOD_DISPEL_RESIST implement in Unit::MagicSpellHitResult
289 &Aura::HandleAuraControlVehicle, //236 SPELL_AURA_CONTROL_VEHICLE
290 &Aura::HandleModSpellDamagePercentFromAttackPower, //237 SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER implemented in Unit::SpellBaseDamageBonusDone
291 &Aura::HandleModSpellHealingPercentFromAttackPower, //238 SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER implemented in Unit::SpellBaseHealingBonusDone
292 &Aura::HandleAuraModScale, //239 SPELL_AURA_MOD_SCALE_2 only in Noggenfogger Elixir (16595) before 2.3.0 aura 61
293 &Aura::HandleAuraModExpertise, //240 SPELL_AURA_MOD_EXPERTISE
294 &Aura::HandleForceMoveForward, //241 Forces the player to move forward
295 &Aura::HandleUnused, //242 SPELL_AURA_MOD_SPELL_DAMAGE_FROM_HEALING (only 2 test spels in 3.2.2a)
296 &Aura::HandleNULL, //243 faction reaction override spells
297 &Aura::HandleComprehendLanguage, //244 SPELL_AURA_COMPREHEND_LANGUAGE
298 &Aura::HandleNoImmediateEffect, //245 SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS implemented in Unit::CalculateSpellDuration
299 &Aura::HandleNoImmediateEffect, //246 SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL implemented in Unit::CalculateSpellDuration
300 &Aura::HandleNULL, //247 target to become a clone of the caster
301 &Aura::HandleNoImmediateEffect, //248 SPELL_AURA_MOD_COMBAT_RESULT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
302 &Aura::HandleAuraConvertRune, //249 SPELL_AURA_CONVERT_RUNE
303 &Aura::HandleAuraModIncreaseHealth, //250 SPELL_AURA_MOD_INCREASE_HEALTH_2
304 &Aura::HandleNULL, //251 SPELL_AURA_MOD_ENEMY_DODGE
305 &Aura::HandleModCombatSpeedPct, //252 SPELL_AURA_SLOW_ALL
306 &Aura::HandleNoImmediateEffect, //253 SPELL_AURA_MOD_BLOCK_CRIT_CHANCE implemented in Unit::CalculateMeleeDamage
307 &Aura::HandleNULL, //254 SPELL_AURA_MOD_DISARM_SHIELD disarm Shield
308 &Aura::HandleNoImmediateEffect, //255 SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT implemented in Unit::SpellDamageBonusTaken
309 &Aura::HandleNoReagentUseAura, //256 SPELL_AURA_NO_REAGENT_USE Use SpellClassMask for spell select
310 &Aura::HandleNULL, //257 SPELL_AURA_MOD_TARGET_RESIST_BY_SPELL_CLASS Use SpellClassMask for spell select
311 &Aura::HandleNULL, //258 SPELL_AURA_MOD_SPELL_VISUAL
312 &Aura::HandleNULL, //259 corrupt healing over time spell
313 &Aura::HandleNoImmediateEffect, //260 SPELL_AURA_SCREEN_EFFECT (miscvalue = id in ScreenEffect.dbc) not required any code
314 &Aura::HandlePhase, //261 SPELL_AURA_PHASE undetectable invisibility? implemented in Unit::isVisibleForOrDetect
315 &Aura::HandleNULL, //262 ignore combat/aura state?
316 &Aura::HandleAllowOnlyAbility, //263 SPELL_AURA_ALLOW_ONLY_ABILITY player can use only abilities set in SpellClassMask
317 &Aura::HandleUnused, //264 unused (3.0.8a-3.2.2a)
318 &Aura::HandleUnused, //265 unused (3.0.8a-3.2.2a)
319 &Aura::HandleUnused, //266 unused (3.0.8a-3.2.2a)
320 &Aura::HandleNoImmediateEffect, //267 SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL implemented in Unit::IsImmunedToSpellEffect
321 &Aura::HandleAuraModAttackPowerOfStatPercent, //268 SPELL_AURA_MOD_ATTACK_POWER_OF_STAT_PERCENT
322 &Aura::HandleNoImmediateEffect, //269 SPELL_AURA_MOD_IGNORE_DAMAGE_REDUCTION_SCHOOL implemented in Unit::CalcNotIgnoreDamageRedunction
323 &Aura::HandleUnused, //270 SPELL_AURA_MOD_IGNORE_TARGET_RESIST (unused in 3.2.2a)
324 &Aura::HandleNoImmediateEffect, //271 SPELL_AURA_MOD_DAMAGE_FROM_CASTER implemented in Unit::SpellDamageBonusTaken
325 &Aura::HandleNoImmediateEffect, //272 SPELL_AURA_MAELSTROM_WEAPON (unclear use for aura, it used in (3.2.2a...3.3.0) in single spell 53817 that spellmode stacked and charged spell expected to be drop as stack
326 &Aura::HandleNoImmediateEffect, //273 SPELL_AURA_X_RAY (client side implementation)
327 &Aura::HandleNULL, //274 proc free shot?
328 &Aura::HandleNoImmediateEffect, //275 SPELL_AURA_MOD_IGNORE_SHAPESHIFT Use SpellClassMask for spell select
329 &Aura::HandleNULL, //276 mod damage % mechanic?
330 &Aura::HandleNoImmediateEffect, //277 SPELL_AURA_MOD_MAX_AFFECTED_TARGETS Use SpellClassMask for spell select
331 &Aura::HandleNULL, //278 SPELL_AURA_MOD_DISARM_RANGED disarm ranged weapon
332 &Aura::HandleNULL, //279 visual effects? 58836 and 57507
333 &Aura::HandleModTargetArmorPct, //280 SPELL_AURA_MOD_TARGET_ARMOR_PCT
334 &Aura::HandleNoImmediateEffect, //281 SPELL_AURA_MOD_HONOR_GAIN implemented in Player::RewardHonor
335 &Aura::HandleAuraIncreaseBaseHealthPercent, //282 SPELL_AURA_INCREASE_BASE_HEALTH_PERCENT
336 &Aura::HandleNoImmediateEffect, //283 SPELL_AURA_MOD_HEALING_RECEIVED implemented in Unit::SpellHealingBonusTaken
337 &Aura::HandleNULL, //284 51 spells
338 &Aura::HandleAuraModAttackPowerOfArmor, //285 SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR implemented in Player::UpdateAttackPowerAndDamage
339 &Aura::HandleNoImmediateEffect, //286 SPELL_AURA_ABILITY_PERIODIC_CRIT implemented in Aura::IsCritFromAbilityAura called from Aura::PeriodicTick
340 &Aura::HandleNoImmediateEffect, //287 SPELL_AURA_DEFLECT_SPELLS implemented in Unit::MagicSpellHitResult and Unit::MeleeSpellHitResult
341 &Aura::HandleNULL, //288 increase parry/deflect, prevent attack (single spell used 67801)
342 &Aura::HandleUnused, //289 unused (3.2.2a)
343 &Aura::HandleAuraModAllCritChance, //290 SPELL_AURA_MOD_ALL_CRIT_CHANCE
344 &Aura::HandleNoImmediateEffect, //291 SPELL_AURA_MOD_QUEST_XP_PCT implemented in Player::GiveXP
345 &Aura::HandleNULL, //292 call stabled pet
346 &Aura::HandleNULL, //293 3 spells
347 &Aura::HandleNULL, //294 2 spells, possible prevent mana regen
348 &Aura::HandleUnused, //295 unused (3.2.2a)
349 &Aura::HandleNULL, //296 2 spells
350 &Aura::HandleNULL, //297 1 spell (counter spell school?)
351 &Aura::HandleUnused, //298 unused (3.2.2a)
352 &Aura::HandleUnused, //299 unused (3.2.2a)
353 &Aura::HandleNULL, //300 3 spells (share damage?)
354 &Aura::HandleNULL, //301 5 spells
355 &Aura::HandleUnused, //302 unused (3.2.2a)
356 &Aura::HandleNULL, //303 17 spells
357 &Aura::HandleNULL, //304 2 spells (alcohol effect?)
358 &Aura::HandleAuraModIncreaseSpeed, //305 SPELL_AURA_MOD_MINIMUM_SPEED
359 &Aura::HandleNULL, //306 1 spell
360 &Aura::HandleNULL, //307 absorb healing?
361 &Aura::HandleNULL, //308 new aura for hunter traps
362 &Aura::HandleNULL, //309 absorb healing?
363 &Aura::HandleNULL, //310 pet avoidance passive?
364 &Aura::HandleNULL, //311 0 spells in 3.3
365 &Aura::HandleNULL, //312 0 spells in 3.3
366 &Aura::HandleNULL, //313 0 spells in 3.3
367 &Aura::HandleNULL, //314 1 test spell (reduce duration of silince/magic)
368 &Aura::HandleNULL, //315 underwater walking
369 &Aura::HandleNULL //316 makes haste affect HOT/DOT ticks
372 static AuraType const frozenAuraTypes[] = { SPELL_AURA_MOD_ROOT, SPELL_AURA_MOD_STUN, SPELL_AURA_NONE };
374 Aura::Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) :
375 m_spellmod(NULL), m_caster_guid(0), m_target(target), m_castItemGuid(castItem?castItem->GetGUID():0),
376 m_timeCla(1000), m_periodicTimer(0), m_periodicTick(0), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE),
377 m_effIndex(eff), m_auraSlot(MAX_AURAS), m_auraFlags(AFLAG_NONE), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),
378 m_positive(false), m_permanent(false), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false),
379 m_isRemovedOnShapeLost(true), m_in_use(0), m_deleted(false)
381 ASSERT(target);
383 ASSERT(spellproto && spellproto == sSpellStore.LookupEntry( spellproto->Id ) && "`info` must be pointer to sSpellStore element");
385 m_spellProto = spellproto;
387 m_currentBasePoints = currentBasePoints ? *currentBasePoints : m_spellProto->CalculateSimpleValue(eff);
389 m_isPassive = IsPassiveSpell(GetId());
390 m_positive = IsPositiveEffect(GetId(), m_effIndex);
392 m_isSingleTargetAura = IsSingleTargetSpell(m_spellProto);
394 m_applyTime = time(NULL);
396 int32 damage;
397 if(!caster)
399 m_caster_guid = target->GetGUID();
400 damage = m_currentBasePoints;
401 m_maxduration = target->CalculateSpellDuration(m_spellProto, m_effIndex, target);
403 else
405 m_caster_guid = caster->GetGUID();
407 damage = caster->CalculateSpellDamage(target, m_spellProto, m_effIndex, &m_currentBasePoints);
408 m_maxduration = caster->CalculateSpellDuration(m_spellProto, m_effIndex, target);
410 if (!damage && castItem && castItem->GetItemSuffixFactor())
412 ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(castItem->GetItemRandomPropertyId()));
413 if(item_rand_suffix)
415 for (int k = 0; k < 3; ++k)
417 SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(item_rand_suffix->enchant_id[k]);
418 if(pEnchant)
420 for (int t = 0; t < 3; ++t)
421 if(pEnchant->spellid[t] == m_spellProto->Id)
423 damage = uint32((item_rand_suffix->prefix[k]*castItem->GetItemSuffixFactor()) / 10000 );
424 break;
428 if(damage)
429 break;
435 if(m_maxduration == -1 || m_isPassive && m_spellProto->DurationIndex == 0)
436 m_permanent = true;
438 Player* modOwner = caster ? caster->GetSpellModOwner() : NULL;
440 if(!m_permanent && modOwner)
442 modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, m_maxduration);
443 // Get zero duration aura after - need set m_maxduration > 0 for apply/remove aura work
444 if (m_maxduration<=0)
445 m_maxduration = 1;
448 m_duration = m_maxduration;
450 DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Aura: construct Spellid : %u, Aura : %u Duration : %d Target : %d Damage : %d", m_spellProto->Id, m_spellProto->EffectApplyAuraName[eff], m_maxduration, m_spellProto->EffectImplicitTargetA[eff],damage);
452 SetModifier(AuraType(m_spellProto->EffectApplyAuraName[eff]), damage, m_spellProto->EffectAmplitude[eff], m_spellProto->EffectMiscValue[eff]);
454 // Apply periodic time mod
455 if(modOwner && m_modifier.periodictime)
456 modOwner->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME, m_modifier.periodictime);
458 // Start periodic on next tick or at aura apply
459 if (!(m_spellProto->AttributesEx5 & SPELL_ATTR_EX5_START_PERIODIC_AT_APPLY))
460 m_periodicTimer += m_modifier.periodictime;
462 m_isDeathPersist = IsDeathPersistentSpell(m_spellProto);
464 m_procCharges = m_spellProto->procCharges;
465 if(modOwner)
466 modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges);
468 m_isRemovedOnShapeLost = (m_caster_guid==m_target->GetGUID() &&
469 m_spellProto->Stances &&
470 !(m_spellProto->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT) &&
471 !(m_spellProto->Attributes & SPELL_ATTR_NOT_SHAPESHIFT));
473 if (caster && m_spellProto->Id == 22959) // Improved Scorch
475 // Glyph of Improved Scorch
476 if (Aura* glyph = caster->GetDummyAura(56371))
477 m_stackAmount = glyph->GetModifier()->m_amount;
481 Aura::~Aura()
485 AreaAura::AreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target,
486 Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
488 m_isAreaAura = true;
490 // caster==NULL in constructor args if target==caster in fact
491 Unit* caster_ptr = caster ? caster : target;
493 m_radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(GetSpellProto()->EffectRadiusIndex[m_effIndex]));
494 if(Player* modOwner = caster_ptr->GetSpellModOwner())
495 modOwner->ApplySpellMod(GetId(), SPELLMOD_RADIUS, m_radius);
497 switch(spellproto->Effect[eff])
499 case SPELL_EFFECT_APPLY_AREA_AURA_PARTY:
500 m_areaAuraType = AREA_AURA_PARTY;
501 if (target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isTotem())
502 m_modifier.m_auraname = SPELL_AURA_NONE;
503 break;
504 case SPELL_EFFECT_APPLY_AREA_AURA_RAID:
505 m_areaAuraType = AREA_AURA_RAID;
506 if (target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isTotem())
507 m_modifier.m_auraname = SPELL_AURA_NONE;
508 // Light's Beacon not applied to caster itself (TODO: more generic check for another simialr spell if any?)
509 else if (target == caster_ptr && m_spellProto->Id == 53651)
510 m_modifier.m_auraname = SPELL_AURA_NONE;
511 break;
512 case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND:
513 m_areaAuraType = AREA_AURA_FRIEND;
514 break;
515 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY:
516 m_areaAuraType = AREA_AURA_ENEMY;
517 if (target == caster_ptr)
518 m_modifier.m_auraname = SPELL_AURA_NONE; // Do not do any effect on self
519 break;
520 case SPELL_EFFECT_APPLY_AREA_AURA_PET:
521 m_areaAuraType = AREA_AURA_PET;
522 break;
523 case SPELL_EFFECT_APPLY_AREA_AURA_OWNER:
524 m_areaAuraType = AREA_AURA_OWNER;
525 if (target == caster_ptr)
526 m_modifier.m_auraname = SPELL_AURA_NONE;
527 break;
528 default:
529 sLog.outError("Wrong spell effect in AreaAura constructor");
530 ASSERT(false);
531 break;
535 AreaAura::~AreaAura()
539 PersistentAreaAura::PersistentAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target,
540 Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
542 m_isPersistent = true;
545 PersistentAreaAura::~PersistentAreaAura()
549 SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target,
550 Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
552 if (caster)
553 m_casters_target_guid = caster->GetTypeId()==TYPEID_PLAYER ? ((Player*)caster)->GetSelection() : caster->GetTargetGUID();
554 else
555 m_casters_target_guid = 0;
558 SingleEnemyTargetAura::~SingleEnemyTargetAura()
562 Unit* SingleEnemyTargetAura::GetTriggerTarget() const
564 return ObjectAccessor::GetUnit(*m_target, m_casters_target_guid);
567 Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem)
569 if (IsAreaAuraEffect(spellproto->Effect[eff]))
570 return new AreaAura(spellproto, eff, currentBasePoints, target, caster, castItem);
572 uint32 triggeredSpellId = spellproto->EffectTriggerSpell[eff];
574 if(SpellEntry const* triggeredSpellInfo = sSpellStore.LookupEntry(triggeredSpellId))
575 for (int i = 0; i < MAX_EFFECT_INDEX; ++i)
576 if (triggeredSpellInfo->EffectImplicitTargetA[i] == TARGET_SINGLE_ENEMY)
577 return new SingleEnemyTargetAura(spellproto, eff, currentBasePoints, target, caster, castItem);
579 return new Aura(spellproto, eff, currentBasePoints, target, caster, castItem);
582 Unit* Aura::GetCaster() const
584 if(m_caster_guid == m_target->GetGUID())
585 return m_target;
587 //return ObjectAccessor::GetUnit(*m_target,m_caster_guid);
588 //must return caster even if it's in another grid/map
589 Unit *unit = ObjectAccessor::GetUnitInWorld(*m_target,m_caster_guid);
590 return unit && unit->IsInWorld() ? unit : NULL;
593 void Aura::SetModifier(AuraType t, int32 a, uint32 pt, int32 miscValue)
595 m_modifier.m_auraname = t;
596 m_modifier.m_amount = a;
597 m_modifier.m_miscvalue = miscValue;
598 m_modifier.periodictime = pt;
601 void Aura::Update(uint32 diff)
603 if (m_duration > 0)
605 m_duration -= diff;
606 if (m_duration < 0)
607 m_duration = 0;
608 m_timeCla -= diff;
610 // GetEffIndex()==0 prevent double/triple apply manaPerSecond/manaPerSecondPerLevel to same spell with many auras
611 // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0
612 if (GetEffIndex() == EFFECT_INDEX_0 && m_timeCla <= 0)
614 if(Unit* caster = GetCaster())
616 Powers powertype = Powers(m_spellProto->powerType);
617 int32 manaPerSecond = m_spellProto->manaPerSecond + m_spellProto->manaPerSecondPerLevel * caster->getLevel();
618 m_timeCla = 1*IN_MILLISECONDS;
619 if (manaPerSecond)
621 if(powertype==POWER_HEALTH)
622 caster->ModifyHealth(-manaPerSecond);
623 else
624 caster->ModifyPower(powertype,-manaPerSecond);
630 // Channeled aura required check distance from caster
631 if(IsChanneledSpell(m_spellProto) && m_caster_guid != m_target->GetGUID())
633 Unit* caster = GetCaster();
634 if(!caster)
636 m_target->RemoveAura(GetId(), GetEffIndex());
637 return;
640 // need check distance for channeled target only
641 if (caster->GetChannelObjectGUID() == m_target->GetGUID())
643 // Get spell range
644 float max_range = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellProto->rangeIndex));
646 if(Player* modOwner = caster->GetSpellModOwner())
647 modOwner->ApplySpellMod(GetId(), SPELLMOD_RANGE, max_range, NULL);
649 if(!caster->IsWithinDistInMap(m_target, max_range))
651 m_target->RemoveAura(GetId(), GetEffIndex());
652 return;
657 if(m_isPeriodic && (m_duration >= 0 || m_isPassive || m_permanent))
659 m_periodicTimer -= diff;
660 if(m_periodicTimer <= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N
662 // update before applying (aura can be removed in TriggerSpell or PeriodicTick calls)
663 m_periodicTimer += m_modifier.periodictime;
664 ++m_periodicTick; // for some infinity auras in some cases can overflow and reset
665 PeriodicTick();
670 void AreaAura::Update(uint32 diff)
672 // update for the caster of the aura
673 if(m_caster_guid == m_target->GetGUID())
675 Unit* caster = m_target;
677 if( !caster->hasUnitState(UNIT_STAT_ISOLATED) )
679 Unit* owner = caster->GetCharmerOrOwner();
680 if (!owner)
681 owner = caster;
682 std::list<Unit *> targets;
684 switch(m_areaAuraType)
686 case AREA_AURA_PARTY:
688 Group *pGroup = NULL;
690 if (owner->GetTypeId() == TYPEID_PLAYER)
691 pGroup = ((Player*)owner)->GetGroup();
693 if( pGroup)
695 uint8 subgroup = ((Player*)owner)->GetSubGroup();
696 for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
698 Player* Target = itr->getSource();
699 if(Target && Target->isAlive() && Target->GetSubGroup()==subgroup && caster->IsFriendlyTo(Target))
701 if(caster->IsWithinDistInMap(Target, m_radius))
702 targets.push_back(Target);
703 Pet *pet = Target->GetPet();
704 if(pet && pet->isAlive() && caster->IsWithinDistInMap(pet, m_radius))
705 targets.push_back(pet);
709 else
711 // add owner
712 if( owner != caster && caster->IsWithinDistInMap(owner, m_radius) )
713 targets.push_back(owner);
714 // add caster's pet
715 Unit* pet = caster->GetPet();
716 if( pet && caster->IsWithinDistInMap(pet, m_radius))
717 targets.push_back(pet);
719 break;
721 case AREA_AURA_RAID:
723 Group *pGroup = NULL;
725 if (owner->GetTypeId() == TYPEID_PLAYER)
726 pGroup = ((Player*)owner)->GetGroup();
728 if( pGroup)
730 for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
732 Player* Target = itr->getSource();
733 if(Target && Target->isAlive() && caster->IsFriendlyTo(Target))
735 if(caster->IsWithinDistInMap(Target, m_radius))
736 targets.push_back(Target);
737 Pet *pet = Target->GetPet();
738 if(pet && pet->isAlive() && caster->IsWithinDistInMap(pet, m_radius))
739 targets.push_back(pet);
743 else
745 // add owner
746 if( owner != caster && caster->IsWithinDistInMap(owner, m_radius) )
747 targets.push_back(owner);
748 // add caster's pet
749 Unit* pet = caster->GetPet();
750 if( pet && caster->IsWithinDistInMap(pet, m_radius))
751 targets.push_back(pet);
753 break;
755 case AREA_AURA_FRIEND:
757 MaNGOS::AnyFriendlyUnitInObjectRangeCheck u_check(caster, m_radius);
758 MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck> searcher(caster,targets, u_check);
759 Cell::VisitAllObjects(caster, searcher, m_radius);
760 break;
762 case AREA_AURA_ENEMY:
764 MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(caster, m_radius); // No GetCharmer in searcher
765 MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(caster, targets, u_check);
766 Cell::VisitAllObjects(caster, searcher, m_radius);
767 break;
769 case AREA_AURA_OWNER:
770 case AREA_AURA_PET:
772 if(owner != caster && caster->IsWithinDistInMap(owner, m_radius))
773 targets.push_back(owner);
774 break;
778 for(std::list<Unit *>::iterator tIter = targets.begin(); tIter != targets.end(); tIter++)
780 // flag for seelction is need apply aura to current iteration target
781 bool apply = true;
783 // we need ignore present caster self applied are auras sometime
784 // in cases if this only auras applied for spell effect
785 Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), m_effIndex);
786 for(Unit::AuraMap::const_iterator i = (*tIter)->GetAuras().lower_bound(spair); i != (*tIter)->GetAuras().upper_bound(spair); ++i)
788 if (i->second->IsDeleted())
789 continue;
791 switch(m_areaAuraType)
793 case AREA_AURA_ENEMY:
794 // non caster self-casted auras (non stacked)
795 if(i->second->GetModifier()->m_auraname != SPELL_AURA_NONE)
796 apply = false;
797 break;
798 case AREA_AURA_RAID:
799 // non caster self-casted auras (stacked from diff. casters)
800 if(i->second->GetModifier()->m_auraname != SPELL_AURA_NONE || i->second->GetCasterGUID() == GetCasterGUID())
801 apply = false;
802 break;
803 default:
804 // in generic case not allow stacking area auras
805 apply = false;
806 break;
809 if(!apply)
810 break;
813 if(!apply)
814 continue;
816 if(SpellEntry const *actualSpellInfo = sSpellMgr.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter)->getLevel()))
818 int32 actualBasePoints = m_currentBasePoints;
819 // recalculate basepoints for lower rank (all AreaAura spell not use custom basepoints?)
820 if(actualSpellInfo != GetSpellProto())
821 actualBasePoints = actualSpellInfo->CalculateSimpleValue(m_effIndex);
822 AreaAura *aur = new AreaAura(actualSpellInfo, m_effIndex, &actualBasePoints, (*tIter), caster, NULL);
823 aur->SetAuraDuration(GetAuraDuration());
824 (*tIter)->AddAura(aur);
828 Aura::Update(diff);
830 else // aura at non-caster
832 Unit* caster = GetCaster();
834 Aura::Update(diff);
836 // remove aura if out-of-range from caster (after teleport for example)
837 // or caster is isolated or caster no longer has the aura
838 // or caster is (no longer) friendly
839 bool needFriendly = (m_areaAuraType == AREA_AURA_ENEMY ? false : true);
840 if( !caster || caster->hasUnitState(UNIT_STAT_ISOLATED) ||
841 !caster->IsWithinDistInMap(m_target, m_radius) ||
842 !caster->HasAura(GetId(), GetEffIndex()) ||
843 caster->IsFriendlyTo(m_target) != needFriendly
846 m_target->RemoveAurasByCasterSpell(GetId(), GetEffIndex(),GetCasterGUID());
848 else if( m_areaAuraType == AREA_AURA_PARTY) // check if in same sub group
850 // not check group if target == owner or target == pet
851 if (caster->GetCharmerOrOwnerGUID() != m_target->GetGUID() && caster->GetGUID() != m_target->GetCharmerOrOwnerGUID())
853 Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself();
855 Group *pGroup = check ? check->GetGroup() : NULL;
856 if( pGroup )
858 Player* checkTarget = m_target->GetCharmerOrOwnerPlayerOrPlayerItself();
859 if(!checkTarget || !pGroup->SameSubGroup(check, checkTarget))
860 m_target->RemoveAura(GetId(), GetEffIndex());
862 else
863 m_target->RemoveAura(GetId(), GetEffIndex());
866 else if( m_areaAuraType == AREA_AURA_RAID) // TODO: fix me!
868 // not check group if target == owner or target == pet
869 if (caster->GetCharmerOrOwnerGUID() != m_target->GetGUID() && caster->GetGUID() != m_target->GetCharmerOrOwnerGUID())
871 Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself();
873 Group *pGroup = check ? check->GetGroup() : NULL;
874 if( pGroup )
876 Player* checkTarget = m_target->GetCharmerOrOwnerPlayerOrPlayerItself();
877 if(!checkTarget)
878 m_target->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
880 else
881 m_target->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
884 else if( m_areaAuraType == AREA_AURA_PET || m_areaAuraType == AREA_AURA_OWNER )
886 if( m_target->GetGUID() != caster->GetCharmerOrOwnerGUID() )
887 m_target->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
892 void PersistentAreaAura::Update(uint32 diff)
894 bool remove = false;
896 // remove the aura if its caster or the dynamic object causing it was removed
897 // or if the target moves too far from the dynamic object
898 if(Unit *caster = GetCaster())
900 DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex());
901 if (dynObj)
903 if (!m_target->IsWithinDistInMap(dynObj, dynObj->GetRadius()))
904 remove = true;
906 else
907 remove = true;
909 else
910 remove = true;
912 Aura::Update(diff);
914 if(remove)
915 m_target->RemoveAura(GetId(), GetEffIndex());
918 void Aura::ApplyModifier(bool apply, bool Real)
920 AuraType aura = m_modifier.m_auraname;
922 SetInUse(true);
923 if(aura < TOTAL_AURAS)
924 (*this.*AuraHandler [aura])(apply, Real);
925 SetInUse(false);
928 bool Aura::IsNeedVisibleSlot(Unit const* caster) const
930 bool totemAura = caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem();
932 // special area auras cases
933 switch(m_spellProto->Effect[GetEffIndex()])
935 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY:
936 return m_target != caster;
937 case SPELL_EFFECT_APPLY_AREA_AURA_PET:
938 case SPELL_EFFECT_APPLY_AREA_AURA_OWNER:
939 case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND:
940 case SPELL_EFFECT_APPLY_AREA_AURA_PARTY:
941 case SPELL_EFFECT_APPLY_AREA_AURA_RAID:
942 // passive auras (except totem auras) do not get placed in caster slot
943 return (m_target != caster || totemAura || !m_isPassive) && m_modifier.m_auraname != SPELL_AURA_NONE;
944 default:
945 break;
948 // passive auras (except totem auras) do not get placed in the slots
949 return !m_isPassive || totemAura;
952 void Aura::_AddAura()
954 if (!GetId())
955 return;
956 if(!m_target)
957 return;
959 // Second aura if some spell
960 bool secondaura = false;
961 // Try find slot for aura
962 uint8 slot = NULL_AURA_SLOT;
963 // Lookup for some spell auras (and get slot from it)
964 for(uint8 i = 0; i < MAX_EFFECT_INDEX; ++i)
966 Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), SpellEffectIndex(i));
967 for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr)
969 // allow use single slot only by auras from same caster
970 if(itr->second->GetCasterGUID()==GetCasterGUID() &&
971 !isWeaponBuffCoexistableWith(itr->second))
973 slot = itr->second->GetAuraSlot();
974 secondaura = true;
975 break;
978 if (secondaura)
979 break;
981 // Lookup free slot
982 if (!secondaura && m_target->GetVisibleAurasCount() < MAX_AURAS)
984 Unit::VisibleAuraMap const *visibleAuras = m_target->GetVisibleAuras();
985 for(uint8 i = 0; i < MAX_AURAS; ++i)
987 Unit::VisibleAuraMap::const_iterator itr = visibleAuras->find(i);
988 if(itr == visibleAuras->end())
990 slot = i;
991 // update for out of range group members (on 1 slot use)
992 m_target->UpdateAuraForGroup(slot);
993 break;
998 Unit* caster = GetCaster();
1000 // set infinity cooldown state for spells
1001 if(caster && caster->GetTypeId() == TYPEID_PLAYER)
1003 if (m_spellProto->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE)
1005 Item* castItem = m_castItemGuid ? ((Player*)caster)->GetItemByGuid(m_castItemGuid) : NULL;
1006 ((Player*)caster)->AddSpellAndCategoryCooldowns(m_spellProto,castItem ? castItem->GetEntry() : 0, NULL,true);
1010 if (IsNeedVisibleSlot(caster))
1012 SetAuraSlot( slot );
1013 if(slot < MAX_AURAS) // slot found send data to client
1015 SetAura(false);
1016 SetAuraFlags((1 << GetEffIndex()) | ((GetCasterGUID() == GetTarget()->GetGUID()) ? AFLAG_NOT_CASTER : AFLAG_NONE) | ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION : AFLAG_NONE) | (IsPositive() ? AFLAG_POSITIVE : AFLAG_NEGATIVE));
1017 SetAuraLevel(caster ? caster->getLevel() : sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL));
1018 SendAuraUpdate(false);
1021 //*****************************************************
1022 // Update target aura state flag (at 1 aura apply)
1023 // TODO: Make it easer
1024 //*****************************************************
1025 if (!secondaura)
1027 // Sitdown on apply aura req seated
1028 if (m_spellProto->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED && !m_target->IsSitState())
1029 m_target->SetStandState(UNIT_STAND_STATE_SIT);
1031 // register aura diminishing on apply
1032 if (getDiminishGroup() != DIMINISHING_NONE )
1033 m_target->ApplyDiminishingAura(getDiminishGroup(), true);
1035 // Update Seals information
1036 if (IsSealSpell(m_spellProto))
1037 m_target->ModifyAuraState(AURA_STATE_JUDGEMENT, true);
1039 // Conflagrate aura state on Immolate and Shadowflame
1040 if (m_spellProto->SpellFamilyName == SPELLFAMILY_WARLOCK &&
1041 // Immolate
1042 ((m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000004)) ||
1043 // Shadowflame
1044 (m_spellProto->SpellFamilyFlags2 & 0x00000002)))
1045 m_target->ModifyAuraState(AURA_STATE_CONFLAGRATE, true);
1047 // Faerie Fire (druid versions)
1048 if (m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000400)))
1049 m_target->ModifyAuraState(AURA_STATE_FAERIE_FIRE, true);
1051 // Victorious
1052 if (m_spellProto->SpellFamilyName == SPELLFAMILY_WARRIOR && (m_spellProto->SpellFamilyFlags & UI64LIT(0x0004000000000000)))
1053 m_target->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH, true);
1055 // Swiftmend state on Regrowth & Rejuvenation
1056 if (m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && (m_spellProto->SpellFamilyFlags & UI64LIT(0x50)))
1057 m_target->ModifyAuraState(AURA_STATE_SWIFTMEND, true);
1059 // Deadly poison aura state
1060 if(m_spellProto->SpellFamilyName == SPELLFAMILY_ROGUE && (m_spellProto->SpellFamilyFlags & UI64LIT(0x10000)))
1061 m_target->ModifyAuraState(AURA_STATE_DEADLY_POISON, true);
1063 // Enrage aura state
1064 if(m_spellProto->Dispel == DISPEL_ENRAGE)
1065 m_target->ModifyAuraState(AURA_STATE_ENRAGE, true);
1070 bool Aura::_RemoveAura()
1072 // Remove all triggered by aura spells vs unlimited duration
1073 // except same aura replace case
1074 if(m_removeMode!=AURA_REMOVE_BY_STACK)
1075 CleanupTriggeredSpells();
1077 Unit* caster = GetCaster();
1079 if(caster && IsPersistent())
1081 DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex());
1082 if (dynObj)
1083 dynObj->RemoveAffected(m_target);
1086 //passive auras do not get put in slots
1087 // Note: but totem can be not accessible for aura target in time remove (to far for find in grid)
1088 //if(m_isPassive && !(caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem()))
1089 // return;
1091 uint8 slot = GetAuraSlot();
1093 if(slot >= MAX_AURAS) // slot not set
1094 return false;
1096 if(m_target->GetVisibleAura(slot) == 0)
1097 return false;
1099 bool lastaura = true;
1101 // find other aura in same slot (current already removed from list)
1102 for(int i = 0; i < MAX_EFFECT_INDEX; ++i)
1104 Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), SpellEffectIndex(i));
1105 for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr)
1107 if(itr->second->GetAuraSlot() == slot)
1109 lastaura = false;
1110 break;
1113 if(!lastaura)
1114 break;
1117 // only remove icon when the last aura of the spell is removed (current aura already removed from list)
1118 if (!lastaura)
1119 return false;
1121 // unregister aura diminishing (and store last time)
1122 if (getDiminishGroup() != DIMINISHING_NONE )
1123 m_target->ApplyDiminishingAura(getDiminishGroup(), false);
1125 SetAura(true);
1126 SetAuraFlags(AFLAG_NONE);
1127 SetAuraLevel(0);
1129 if (m_removeMode != AURA_REMOVE_BY_DELETE)
1131 SendAuraUpdate(true);
1133 // update for out of range group members
1134 m_target->UpdateAuraForGroup(slot);
1136 //*****************************************************
1137 // Update target aura state flag (at last aura remove)
1138 //*****************************************************
1139 // Enrage aura state
1140 if(m_spellProto->Dispel == DISPEL_ENRAGE)
1141 m_target->ModifyAuraState(AURA_STATE_ENRAGE, false);
1143 uint32 removeState = 0;
1144 uint64 removeFamilyFlag = m_spellProto->SpellFamilyFlags;
1145 uint32 removeFamilyFlag2 = m_spellProto->SpellFamilyFlags2;
1146 switch(m_spellProto->SpellFamilyName)
1148 case SPELLFAMILY_PALADIN:
1149 if (IsSealSpell(m_spellProto))
1150 removeState = AURA_STATE_JUDGEMENT; // Update Seals information
1151 break;
1152 case SPELLFAMILY_WARLOCK:
1153 // Conflagrate aura state on Immolate and Shadowflame,
1154 if ((m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000004)) ||
1155 (m_spellProto->SpellFamilyFlags2 & 0x00000002))
1157 removeFamilyFlag = UI64LIT(0x0000000000000004);
1158 removeFamilyFlag2 = 0x00000002;
1159 removeState = AURA_STATE_CONFLAGRATE;
1161 break;
1162 case SPELLFAMILY_DRUID:
1163 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000400))
1164 removeState = AURA_STATE_FAERIE_FIRE; // Faerie Fire (druid versions)
1165 else if(m_spellProto->SpellFamilyFlags & UI64LIT(0x50))
1167 removeFamilyFlag = 0x50;
1168 removeState = AURA_STATE_SWIFTMEND; // Swiftmend aura state
1170 break;
1171 case SPELLFAMILY_WARRIOR:
1172 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x0004000000000000))
1173 removeState = AURA_STATE_WARRIOR_VICTORY_RUSH; // Victorious
1174 break;
1175 case SPELLFAMILY_ROGUE:
1176 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x10000))
1177 removeState = AURA_STATE_DEADLY_POISON; // Deadly poison aura state
1178 break;
1179 case SPELLFAMILY_HUNTER:
1180 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x1000000000000000))
1181 removeState = AURA_STATE_FAERIE_FIRE; // Sting (hunter versions)
1184 // Remove state (but need check other auras for it)
1185 if (removeState)
1187 bool found = false;
1188 Unit::AuraMap& Auras = m_target->GetAuras();
1189 for(Unit::AuraMap::iterator i = Auras.begin(); i != Auras.end(); ++i)
1191 SpellEntry const *auraSpellInfo = (*i).second->GetSpellProto();
1192 if(auraSpellInfo->SpellFamilyName == m_spellProto->SpellFamilyName &&
1193 (auraSpellInfo->SpellFamilyFlags & removeFamilyFlag || auraSpellInfo->SpellFamilyFlags2 & removeFamilyFlag2))
1195 found = true;
1196 break;
1199 // this has been last aura
1200 if(!found)
1201 m_target->ModifyAuraState(AuraState(removeState), false);
1204 // reset cooldown state for spells
1205 if(caster && caster->GetTypeId() == TYPEID_PLAYER)
1207 if ( GetSpellProto()->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE )
1208 // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
1209 ((Player*)caster)->SendCooldownEvent(GetSpellProto());
1213 return true;
1216 void Aura::SendAuraUpdate(bool remove)
1218 WorldPacket data(SMSG_AURA_UPDATE);
1219 data << m_target->GetPackGUID();
1220 data << uint8(GetAuraSlot());
1221 data << uint32(remove ? 0 : GetId());
1223 if(remove)
1225 m_target->SendMessageToSet(&data, true);
1226 return;
1229 uint8 auraFlags = GetAuraFlags();
1230 data << uint8(auraFlags);
1231 data << uint8(GetAuraLevel());
1232 data << uint8(m_procCharges ? m_procCharges*m_stackAmount : m_stackAmount);
1234 if(!(auraFlags & AFLAG_NOT_CASTER))
1236 data.appendPackGUID(GetCasterGUID());
1239 if(auraFlags & AFLAG_DURATION)
1241 data << uint32(GetAuraMaxDuration());
1242 data << uint32(GetAuraDuration());
1245 m_target->SendMessageToSet(&data, true);
1248 void Aura::SetStackAmount(uint8 stackAmount)
1250 Unit *target = GetTarget();
1251 Unit *caster = GetCaster();
1252 if (!target || !caster)
1253 return;
1255 bool refresh = stackAmount >= m_stackAmount;
1256 if (stackAmount != m_stackAmount)
1258 m_stackAmount = stackAmount;
1259 int32 amount = m_stackAmount * caster->CalculateSpellDamage(target, m_spellProto, m_effIndex, &m_currentBasePoints);
1260 // Reapply if amount change
1261 if (amount!=m_modifier.m_amount)
1263 ApplyModifier(false, true);
1264 m_modifier.m_amount = amount;
1265 ApplyModifier(true, true);
1269 if (refresh)
1270 // Stack increased refresh duration
1271 RefreshAura();
1272 else
1273 // Stack decreased only send update
1274 SendAuraUpdate(false);
1277 bool Aura::modStackAmount(int32 num)
1279 // Can`t mod
1280 if (!m_spellProto->StackAmount)
1281 return true;
1283 // Modify stack but limit it
1284 int32 stackAmount = m_stackAmount + num;
1285 if (stackAmount > (int32)m_spellProto->StackAmount)
1286 stackAmount = m_spellProto->StackAmount;
1287 else if (stackAmount <=0) // Last aura from stack removed
1289 m_stackAmount = 0;
1290 return true; // need remove aura
1293 // Update stack amount
1294 SetStackAmount(stackAmount);
1295 return false;
1298 void Aura::RefreshAura()
1300 m_duration = m_maxduration;
1301 SendAuraUpdate(false);
1304 bool Aura::isAffectedOnSpell(SpellEntry const *spell) const
1306 // Check family name
1307 if (spell->SpellFamilyName != m_spellProto->SpellFamilyName)
1308 return false;
1309 // Check EffectClassMask
1310 uint32 const *ptr = getAuraSpellClassMask();
1311 if (((uint64*)ptr)[0] & spell->SpellFamilyFlags)
1312 return true;
1313 if (ptr[2] & spell->SpellFamilyFlags2)
1314 return true;
1315 return false;
1318 void Aura::ReapplyAffectedPassiveAuras( Unit* target, bool owner_mode )
1320 std::set<uint32> affectedSelf;
1321 std::set<uint32> affectedAuraCaster;
1323 for(Unit::AuraMap::const_iterator itr = target->GetAuras().begin(); itr != target->GetAuras().end(); ++itr)
1325 // permanent passive or permanent area aura
1326 // passive spells can be affected only by own or owner spell mods)
1327 if (itr->second->IsPermanent() && (owner_mode && itr->second->IsPassive() || itr->second->IsAreaAura()) &&
1328 // non deleted and not same aura (any with same spell id)
1329 !itr->second->IsDeleted() && itr->second->GetId() != GetId() &&
1330 // and affected by aura
1331 isAffectedOnSpell(itr->second->GetSpellProto()))
1333 // only applied by self or aura caster
1334 if (itr->second->GetCasterGUID() == target->GetGUID())
1335 affectedSelf.insert(itr->second->GetId());
1336 else if (itr->second->GetCasterGUID() == GetCasterGUID())
1337 affectedAuraCaster.insert(itr->second->GetId());
1341 for(std::set<uint32>::const_iterator set_itr = affectedSelf.begin(); set_itr != affectedSelf.end(); ++set_itr)
1343 target->RemoveAurasDueToSpell(*set_itr);
1344 target->CastSpell(m_target, *set_itr, true);
1347 if (!affectedAuraCaster.empty())
1349 Unit* caster = GetCaster();
1350 for(std::set<uint32>::const_iterator set_itr = affectedAuraCaster.begin(); set_itr != affectedAuraCaster.end(); ++set_itr)
1352 target->RemoveAurasDueToSpell(*set_itr);
1353 if (caster)
1354 caster->CastSpell(m_target, *set_itr, true);
1359 struct ReapplyAffectedPassiveAurasHelper
1361 explicit ReapplyAffectedPassiveAurasHelper(Aura* _aura) : aura(_aura) {}
1362 void operator()(Unit* unit) const { aura->ReapplyAffectedPassiveAuras(unit, true); }
1363 Aura* aura;
1366 void Aura::ReapplyAffectedPassiveAuras()
1368 // not reapply spell mods with charges (use original value because processed and at remove)
1369 if (m_spellProto->procCharges)
1370 return;
1372 // not reapply some spell mods ops (mostly speedup case)
1373 switch (m_modifier.m_miscvalue)
1375 case SPELLMOD_DURATION:
1376 case SPELLMOD_CHARGES:
1377 case SPELLMOD_NOT_LOSE_CASTING_TIME:
1378 case SPELLMOD_CASTING_TIME:
1379 case SPELLMOD_COOLDOWN:
1380 case SPELLMOD_COST:
1381 case SPELLMOD_ACTIVATION_TIME:
1382 case SPELLMOD_CASTING_TIME_OLD:
1383 return;
1386 // reapply talents to own passive persistent auras
1387 ReapplyAffectedPassiveAuras(m_target, true);
1389 // re-apply talents/passives/area auras applied to pet/totems (it affected by player spellmods)
1390 m_target->CallForAllControlledUnits(ReapplyAffectedPassiveAurasHelper(this),true,false,false);
1392 // re-apply talents/passives/area auras applied to group members (it affected by player spellmods)
1393 if (Group* group = ((Player*)m_target)->GetGroup())
1394 for(GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
1395 if (Player* member = itr->getSource())
1396 if (member != m_target && member->IsInMap(m_target))
1397 ReapplyAffectedPassiveAuras(member, false);
1400 bool Aura::isWeaponBuffCoexistableWith(Aura* ref)
1402 // Exclude Debuffs
1403 if (!IsPositive())
1404 return false;
1406 // Exclude Non-generic Buffs [ie: Runeforging] and Executioner-Enchant
1407 if (GetSpellProto()->SpellFamilyName != SPELLFAMILY_GENERIC || GetId() == 42976)
1408 return false;
1410 // Exclude Stackable Buffs [ie: Blood Reserve]
1411 if (GetSpellProto()->StackAmount)
1412 return false;
1414 // only self applied player buffs
1415 if (m_target->GetTypeId() != TYPEID_PLAYER || m_target->GetGUID() != GetCasterGUID())
1416 return false;
1418 Item* castItem = ((Player*)m_target)->GetItemByGuid(GetCastItemGUID());
1419 if (!castItem)
1420 return false;
1422 // Limit to Weapon-Slots
1423 if (!castItem->IsEquipped() ||
1424 (castItem->GetSlot() != EQUIPMENT_SLOT_MAINHAND && castItem->GetSlot() != EQUIPMENT_SLOT_OFFHAND))
1425 return false;
1427 // form different weapons
1428 return ref->GetCastItemGUID() != GetCastItemGUID();
1431 /*********************************************************/
1432 /*** BASIC AURA FUNCTION ***/
1433 /*********************************************************/
1434 void Aura::HandleAddModifier(bool apply, bool Real)
1436 if(m_target->GetTypeId() != TYPEID_PLAYER || !Real)
1437 return;
1439 if(m_modifier.m_miscvalue >= MAX_SPELLMOD)
1440 return;
1442 if (apply)
1444 // Add custom charges for some mod aura
1445 switch (m_spellProto->Id)
1447 case 17941: // Shadow Trance
1448 case 22008: // Netherwind Focus
1449 case 31834: // Light's Grace
1450 case 34754: // Clearcasting
1451 case 34936: // Backlash
1452 case 44401: // Missile Barrage
1453 case 48108: // Hot Streak
1454 case 51124: // Killing Machine
1455 case 54741: // Firestarter
1456 case 57761: // Fireball!
1457 case 64823: // Elune's Wrath (Balance druid t8 set
1458 SetAuraCharges(1);
1459 break;
1462 m_spellmod = new SpellModifier(
1463 SpellModOp(m_modifier.m_miscvalue),
1464 SpellModType(m_modifier.m_auraname), // SpellModType value == spell aura types
1465 m_modifier.m_amount,
1466 this,
1467 // prevent expire spell mods with (charges > 0 && m_stackAmount > 1)
1468 // all this spell expected expire not at use but at spell proc event check
1469 m_spellProto->StackAmount > 1 ? 0 : m_procCharges);
1472 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
1474 ReapplyAffectedPassiveAuras();
1477 void Aura::HandleAddTargetTrigger(bool apply, bool /*Real*/)
1479 // Use SpellModifier structure for check
1480 // used only fields:
1481 // spellId, mask, mask2
1482 if (apply)
1484 SpellModifier *mod = new SpellModifier;
1485 mod->spellId = GetId();
1487 uint32 const *ptr = m_spellProto->GetEffectSpellClassMask(m_effIndex);
1489 mod->mask = (uint64)ptr[0] | (uint64)ptr[1]<<32;
1490 mod->mask2= ptr[2];
1491 m_spellmod = mod;
1493 else
1495 delete m_spellmod;
1496 m_spellmod = NULL;
1500 void Aura::TriggerSpell()
1502 const uint64& casterGUID = GetCasterGUID();
1503 Unit* target = GetTriggerTarget();
1505 if(!casterGUID || !target)
1506 return;
1508 // generic casting code with custom spells and target/caster customs
1509 uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex];
1511 SpellEntry const *triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id);
1512 SpellEntry const *auraSpellInfo = GetSpellProto();
1513 uint32 auraId = auraSpellInfo->Id;
1515 // specific code for cases with no trigger spell provided in field
1516 if (triggeredSpellInfo == NULL)
1518 switch(auraSpellInfo->SpellFamilyName)
1520 case SPELLFAMILY_GENERIC:
1522 switch(auraId)
1524 // // Periodic Mana Burn
1525 // case 812: break;
1526 // // Polymorphic Ray
1527 // case 6965: break;
1528 // Thaumaturgy Channel
1529 case 9712: trigger_spell_id = 21029; break;
1530 // // Egan's Blaster
1531 // case 17368: break;
1532 // // Haunted
1533 // case 18347: break;
1534 // // Ranshalla Waiting
1535 // case 18953: break;
1536 // // Inferno
1537 // case 19695: break;
1538 // // Frostwolf Muzzle DND
1539 // case 21794: break;
1540 // // Alterac Ram Collar DND
1541 // case 21866: break;
1542 // // Celebras Waiting
1543 // case 21916: break;
1544 // Brood Affliction: Bronze
1545 case 23170:
1547 m_target->CastSpell(m_target, 23171, true, NULL, this);
1548 return;
1550 // // Mark of Frost
1551 // case 23184: break;
1552 // Restoration
1553 case 23493:
1555 int32 heal = target->GetMaxHealth() / 10;
1556 target->DealHeal(target, heal, auraSpellInfo);
1558 if (int32 mana = target->GetMaxPower(POWER_MANA))
1560 mana /= 10;
1561 target->EnergizeBySpell(target, 23493, mana, POWER_MANA);
1563 return;
1565 // // Stoneclaw Totem Passive TEST
1566 // case 23792: break;
1567 // // Axe Flurry
1568 // case 24018: break;
1569 // // Mark of Arlokk
1570 // case 24210: break;
1571 // // Restoration
1572 // case 24379: break;
1573 // // Happy Pet
1574 // case 24716: break;
1575 // // Dream Fog
1576 // case 24780: break;
1577 // // Cannon Prep
1578 // case 24832: break;
1579 // Shadow Bolt Whirl
1580 case 24834:
1582 uint32 spellForTick[8] = { 24820, 24821, 24822, 24823, 24835, 24836, 24837, 24838 };
1583 uint32 tick = GetAuraTicks();
1584 if(tick < 8)
1586 trigger_spell_id = spellForTick[tick];
1588 // casted in left/right (but triggered spell have wide forward cone)
1589 float forward = m_target->GetOrientation();
1590 float angle = m_target->GetOrientation() + ( tick % 2 == 0 ? M_PI_F / 2 : - M_PI_F / 2);
1591 m_target->SetOrientation(angle);
1592 target->CastSpell(target, trigger_spell_id, true, NULL, this, casterGUID);
1593 m_target->SetOrientation(forward);
1595 return;
1597 // // Stink Trap
1598 // case 24918: break;
1599 // // Mark of Nature
1600 // case 25041: break;
1601 // // Agro Drones
1602 // case 25152: break;
1603 // Consume
1604 case 25371:
1606 int32 bpDamage = target->GetMaxHealth()*10/100;
1607 target->CastCustomSpell(target, 25373, &bpDamage, NULL, NULL, true, NULL, this, casterGUID);
1608 return;
1610 // // Pain Spike
1611 // case 25572: break;
1612 // // Rotate 360
1613 // case 26009: break;
1614 // // Rotate -360
1615 // case 26136: break;
1616 // // Consume
1617 // case 26196: break;
1618 // // Berserk
1619 // case 26615: break;
1620 // // Defile
1621 // case 27177: break;
1622 // // Teleport: IF/UC
1623 // case 27601: break;
1624 // // Five Fat Finger Exploding Heart Technique
1625 // case 27673: break;
1626 // // Nitrous Boost
1627 // case 27746: break;
1628 // // Steam Tank Passive
1629 // case 27747: break;
1630 // Frost Blast
1631 case 27808:
1633 int32 bpDamage = target->GetMaxHealth()*26/100;
1634 target->CastCustomSpell(target, 29879, &bpDamage, NULL, NULL, true, NULL, this, casterGUID);
1635 return;
1637 // // Detonate Mana
1638 // case 27819: break;
1639 // // Controller Timer
1640 // case 28095: break;
1641 // // Stalagg Chain
1642 // case 28096: break;
1643 // // Stalagg Tesla Passive
1644 // case 28097: break;
1645 // // Feugen Tesla Passive
1646 // case 28109: break;
1647 // // Feugen Chain
1648 // case 28111: break;
1649 // // Mark of Didier
1650 // case 28114: break;
1651 // // Communique Timer, camp
1652 // case 28346: break;
1653 // // Icebolt
1654 // case 28522: break;
1655 // // Silithyst
1656 // case 29519: break;
1657 // Inoculate Nestlewood Owlkin
1658 case 29528:
1659 if(target->GetTypeId() != TYPEID_UNIT)// prevent error reports in case ignored player target
1660 return;
1661 break;
1662 // // Overload
1663 // case 29768: break;
1664 // // Return Fire
1665 // case 29788: break;
1666 // // Return Fire
1667 // case 29793: break;
1668 // // Return Fire
1669 // case 29794: break;
1670 // // Guardian of Icecrown Passive
1671 // case 29897: break;
1672 // Feed Captured Animal
1673 case 29917: trigger_spell_id = 29916; break;
1674 // // Flame Wreath
1675 // case 29946: break;
1676 // // Flame Wreath
1677 // case 29947: break;
1678 // // Mind Exhaustion Passive
1679 // case 30025: break;
1680 // // Nether Beam - Serenity
1681 // case 30401: break;
1682 // Extract Gas
1683 case 30427:
1685 Unit* caster = GetCaster();
1686 if (!caster)
1687 return;
1688 // move loot to player inventory and despawn target
1689 if(caster->GetTypeId() ==TYPEID_PLAYER &&
1690 target->GetTypeId() == TYPEID_UNIT &&
1691 ((Creature*)target)->GetCreatureInfo()->type == CREATURE_TYPE_GAS_CLOUD)
1693 Player* player = (Player*)caster;
1694 Creature* creature = (Creature*)target;
1695 // missing lootid has been reported on startup - just return
1696 if (!creature->GetCreatureInfo()->SkinLootId)
1697 return;
1699 player->AutoStoreLoot(creature->GetCreatureInfo()->SkinLootId,LootTemplates_Skinning,true);
1701 creature->ForcedDespawn();
1703 return;
1705 // Quake
1706 case 30576: trigger_spell_id = 30571; break;
1707 // // Burning Maul
1708 // case 30598: break;
1709 // // Regeneration
1710 // case 30799:
1711 // case 30800:
1712 // case 30801:
1713 // break;
1714 // // Despawn Self - Smoke cloud
1715 // case 31269: break;
1716 // // Time Rift Periodic
1717 // case 31320: break;
1718 // // Corrupt Medivh
1719 // case 31326: break;
1720 // Doom
1721 case 31347:
1723 m_target->CastSpell(m_target,31350,true);
1724 m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
1725 return;
1727 // Spellcloth
1728 case 31373:
1730 // Summon Elemental after create item
1731 target->SummonCreature(17870, 0, 0, 0, target->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0);
1732 return;
1734 // // Bloodmyst Tesla
1735 // case 31611: break;
1736 // Doomfire
1737 case 31944:
1739 int32 damage = m_modifier.m_amount * ((GetAuraDuration() + m_modifier.periodictime) / GetAuraMaxDuration());
1740 target->CastCustomSpell(target, 31969, &damage, NULL, NULL, true, NULL, this, casterGUID);
1741 return;
1743 // // Teleport Test
1744 // case 32236: break;
1745 // // Earthquake
1746 // case 32686: break;
1747 // // Possess
1748 // case 33401: break;
1749 // // Draw Shadows
1750 // case 33563: break;
1751 // // Murmur's Touch
1752 // case 33711: break;
1753 // Flame Quills
1754 case 34229:
1756 // cast 24 spells 34269-34289, 34314-34316
1757 for(uint32 spell_id = 34269; spell_id != 34290; ++spell_id)
1758 target->CastSpell(target, spell_id, true, NULL, this, casterGUID);
1759 for(uint32 spell_id = 34314; spell_id != 34317; ++spell_id)
1760 target->CastSpell(target, spell_id, true, NULL, this, casterGUID);
1761 return;
1763 // // Gravity Lapse
1764 // case 34480: break;
1765 // // Tornado
1766 // case 34683: break;
1767 // // Frostbite Rotate
1768 // case 34748: break;
1769 // // Arcane Flurry
1770 // case 34821: break;
1771 // // Interrupt Shutdown
1772 // case 35016: break;
1773 // // Interrupt Shutdown
1774 // case 35176: break;
1775 // // Inferno
1776 // case 35268: break;
1777 // // Salaadin's Tesla
1778 // case 35515: break;
1779 // // Ethereal Channel (Red)
1780 // case 35518: break;
1781 // // Nether Vapor
1782 // case 35879: break;
1783 // // Dark Portal Storm
1784 // case 36018: break;
1785 // // Burning Maul
1786 // case 36056: break;
1787 // // Living Grove Defender Lifespan
1788 // case 36061: break;
1789 // // Professor Dabiri Talks
1790 // case 36064: break;
1791 // // Kael Gaining Power
1792 // case 36091: break;
1793 // // They Must Burn Bomb Aura
1794 // case 36344: break;
1795 // // They Must Burn Bomb Aura (self)
1796 // case 36350: break;
1797 // // Stolen Ravenous Ravager Egg
1798 // case 36401: break;
1799 // // Activated Cannon
1800 // case 36410: break;
1801 // // Stolen Ravenous Ravager Egg
1802 // case 36418: break;
1803 // // Enchanted Weapons
1804 // case 36510: break;
1805 // // Cursed Scarab Periodic
1806 // case 36556: break;
1807 // // Cursed Scarab Despawn Periodic
1808 // case 36561: break;
1809 // // Vision Guide
1810 // case 36573: break;
1811 // // Cannon Charging (platform)
1812 // case 36785: break;
1813 // // Cannon Charging (self)
1814 // case 36860: break;
1815 // Remote Toy
1816 case 37027: trigger_spell_id = 37029; break;
1817 // // Mark of Death
1818 // case 37125: break;
1819 // // Arcane Flurry
1820 // case 37268: break;
1821 // // Spout
1822 // case 37429: break;
1823 // // Spout
1824 // case 37430: break;
1825 // // Karazhan - Chess NPC AI, Snapshot timer
1826 // case 37440: break;
1827 // // Karazhan - Chess NPC AI, action timer
1828 // case 37504: break;
1829 // // Karazhan - Chess: Is Square OCCUPIED aura (DND)
1830 // case 39400: break;
1831 // // Banish
1832 // case 37546: break;
1833 // // Shriveling Gaze
1834 // case 37589: break;
1835 // // Fake Aggro Radius (2 yd)
1836 // case 37815: break;
1837 // // Corrupt Medivh
1838 // case 37853: break;
1839 // Eye of Grillok
1840 case 38495:
1842 m_target->CastSpell(m_target, 38530, true);
1843 return;
1845 // Absorb Eye of Grillok (Zezzak's Shard)
1846 case 38554:
1848 if(m_target->GetTypeId() != TYPEID_UNIT)
1849 return;
1851 if (Unit* caster = GetCaster())
1852 caster->CastSpell(caster, 38495, true, NULL, this);
1853 else
1854 return;
1856 Creature* creatureTarget = (Creature*)m_target;
1858 creatureTarget->ForcedDespawn();
1859 return;
1861 // // Magic Sucker Device timer
1862 // case 38672: break;
1863 // // Tomb Guarding Charging
1864 // case 38751: break;
1865 // // Murmur's Touch
1866 // case 38794: break;
1867 // // Activate Nether-wraith Beacon (31742 Nether-wraith Beacon item)
1868 // case 39105: break;
1869 // // Drain World Tree Visual
1870 // case 39140: break;
1871 // // Quest - Dustin's Undead Dragon Visual aura
1872 // case 39259: break;
1873 // // Hellfire - The Exorcism, Jules releases darkness, aura
1874 // case 39306: break;
1875 // // Inferno
1876 // case 39346: break;
1877 // // Enchanted Weapons
1878 // case 39489: break;
1879 // // Shadow Bolt Whirl
1880 // case 39630: break;
1881 // // Shadow Bolt Whirl
1882 // case 39634: break;
1883 // // Shadow Inferno
1884 // case 39645: break;
1885 // Tear of Azzinoth Summon Channel - it's not really supposed to do anything,and this only prevents the console spam
1886 case 39857: trigger_spell_id = 39856; break;
1887 // // Soulgrinder Ritual Visual (Smashed)
1888 // case 39974: break;
1889 // // Simon Game Pre-game timer
1890 // case 40041: break;
1891 // // Knockdown Fel Cannon: The Aggro Check Aura
1892 // case 40113: break;
1893 // // Spirit Lance
1894 // case 40157: break;
1895 // // Demon Transform 2
1896 // case 40398: break;
1897 // // Demon Transform 1
1898 // case 40511: break;
1899 // // Ancient Flames
1900 // case 40657: break;
1901 // // Ethereal Ring Cannon: Cannon Aura
1902 // case 40734: break;
1903 // // Cage Trap
1904 // case 40760: break;
1905 // // Random Periodic
1906 // case 40867: break;
1907 // // Prismatic Shield
1908 // case 40879: break;
1909 // // Aura of Desire
1910 // case 41350: break;
1911 // // Dementia
1912 // case 41404: break;
1913 // // Chaos Form
1914 // case 41629: break;
1915 // // Alert Drums
1916 // case 42177: break;
1917 // // Spout
1918 // case 42581: break;
1919 // // Spout
1920 // case 42582: break;
1921 // // Return to the Spirit Realm
1922 // case 44035: break;
1923 // // Curse of Boundless Agony
1924 // case 45050: break;
1925 // // Earthquake
1926 // case 46240: break;
1927 // Personalized Weather
1928 case 46736: trigger_spell_id = 46737; break;
1929 // // Stay Submerged
1930 // case 46981: break;
1931 // // Dragonblight Ram
1932 // case 47015: break;
1933 // // Party G.R.E.N.A.D.E.
1934 // case 51510: break;
1935 default:
1936 break;
1938 break;
1940 case SPELLFAMILY_MAGE:
1942 switch(auraId)
1944 // Invisibility
1945 case 66:
1946 // Here need periodic triger reducing threat spell (or do it manually)
1947 return;
1948 default:
1949 break;
1951 break;
1953 // case SPELLFAMILY_WARRIOR:
1954 // {
1955 // switch(auraId)
1956 // {
1957 // // Wild Magic
1958 // case 23410: break;
1959 // // Corrupted Totems
1960 // case 23425: break;
1961 // default:
1962 // break;
1963 // }
1964 // break;
1965 // }
1966 // case SPELLFAMILY_PRIEST:
1967 // {
1968 // switch(auraId)
1969 // {
1970 // // Blue Beam
1971 // case 32930: break;
1972 // // Fury of the Dreghood Elders
1973 // case 35460: break;
1974 // default:
1975 // break;
1976 // }
1977 // break;
1978 // }
1979 case SPELLFAMILY_HUNTER:
1981 switch (auraId)
1983 // Sniper training
1984 case 53302:
1985 case 53303:
1986 case 53304:
1987 if (target->GetTypeId() != TYPEID_PLAYER)
1988 return;
1990 // Reset reapply counter at move
1991 if (((Player*)target)->isMoving())
1993 m_modifier.m_amount = 6;
1994 return;
1997 // We are standing at the moment
1998 if (m_modifier.m_amount > 0)
2000 --m_modifier.m_amount;
2001 return;
2004 // select rank of buff
2005 switch(auraId)
2007 case 53302: trigger_spell_id = 64418; break;
2008 case 53303: trigger_spell_id = 64419; break;
2009 case 53304: trigger_spell_id = 64420; break;
2012 // If aura is active - no need to continue
2013 if (target->HasAura(trigger_spell_id))
2014 return;
2016 break;
2017 default:
2018 break;
2020 break;
2022 case SPELLFAMILY_DRUID:
2024 switch(auraId)
2026 // Cat Form
2027 // trigger_spell_id not set and unknown effect triggered in this case, ignoring for while
2028 case 768:
2029 return;
2030 // Frenzied Regeneration
2031 case 22842:
2032 case 22895:
2033 case 22896:
2034 case 26999:
2036 int32 LifePerRage = GetModifier()->m_amount;
2038 int32 lRage = m_target->GetPower(POWER_RAGE);
2039 if(lRage > 100) // rage stored as rage*10
2040 lRage = 100;
2041 m_target->ModifyPower(POWER_RAGE, -lRage);
2042 int32 FRTriggerBasePoints = int32(lRage*LifePerRage/10);
2043 m_target->CastCustomSpell(m_target, 22845, &FRTriggerBasePoints, NULL, NULL, true, NULL, this);
2044 return;
2046 default:
2047 break;
2049 break;
2052 // case SPELLFAMILY_HUNTER:
2053 // {
2054 // switch(auraId)
2055 // {
2056 // //Frost Trap Aura
2057 // case 13810:
2058 // return;
2059 // //Rizzle's Frost Trap
2060 // case 39900:
2061 // return;
2062 // // Tame spells
2063 // case 19597: // Tame Ice Claw Bear
2064 // case 19676: // Tame Snow Leopard
2065 // case 19677: // Tame Large Crag Boar
2066 // case 19678: // Tame Adult Plainstrider
2067 // case 19679: // Tame Prairie Stalker
2068 // case 19680: // Tame Swoop
2069 // case 19681: // Tame Dire Mottled Boar
2070 // case 19682: // Tame Surf Crawler
2071 // case 19683: // Tame Armored Scorpid
2072 // case 19684: // Tame Webwood Lurker
2073 // case 19685: // Tame Nightsaber Stalker
2074 // case 19686: // Tame Strigid Screecher
2075 // case 30100: // Tame Crazed Dragonhawk
2076 // case 30103: // Tame Elder Springpaw
2077 // case 30104: // Tame Mistbat
2078 // case 30647: // Tame Barbed Crawler
2079 // case 30648: // Tame Greater Timberstrider
2080 // case 30652: // Tame Nightstalker
2081 // return;
2082 // default:
2083 // break;
2084 // }
2085 // break;
2086 // }
2087 case SPELLFAMILY_SHAMAN:
2089 switch(auraId)
2091 // Lightning Shield (The Earthshatterer set trigger after cast Lighting Shield)
2092 case 28820:
2094 // Need remove self if Lightning Shield not active
2095 Unit::AuraMap const& auras = target->GetAuras();
2096 for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
2098 SpellEntry const* spell = itr->second->GetSpellProto();
2099 if( spell->SpellFamilyName == SPELLFAMILY_SHAMAN &&
2100 (spell->SpellFamilyFlags & UI64LIT(0x0000000000000400)))
2101 return;
2103 target->RemoveAurasDueToSpell(28820);
2104 return;
2106 // Totemic Mastery (Skyshatter Regalia (Shaman Tier 6) - bonus)
2107 case 38443:
2109 if(target->IsAllTotemSlotsUsed())
2110 target->CastSpell(target, 38437, true, NULL, this);
2111 else
2112 target->RemoveAurasDueToSpell(38437);
2113 return;
2115 default:
2116 break;
2118 break;
2120 default:
2121 break;
2124 // Reget trigger spell proto
2125 triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id);
2127 else
2129 // Spell exist but require custom code
2130 switch(auraId)
2132 // Curse of Idiocy
2133 case 1010:
2135 // TODO: spell casted by result in correct way mostly
2136 // BUT:
2137 // 1) target show casting at each triggered cast: target don't must show casting animation for any triggered spell
2138 // but must show affect apply like item casting
2139 // 2) maybe aura must be replace by new with accumulative stat mods instead stacking
2141 // prevent cast by triggered auras
2142 if(casterGUID == target->GetGUID())
2143 return;
2145 // stop triggering after each affected stats lost > 90
2146 int32 intelectLoss = 0;
2147 int32 spiritLoss = 0;
2149 Unit::AuraList const& mModStat = target->GetAurasByType(SPELL_AURA_MOD_STAT);
2150 for(Unit::AuraList::const_iterator i = mModStat.begin(); i != mModStat.end(); ++i)
2152 if ((*i)->GetId() == 1010)
2154 switch((*i)->GetModifier()->m_miscvalue)
2156 case STAT_INTELLECT: intelectLoss += (*i)->GetModifier()->m_amount; break;
2157 case STAT_SPIRIT: spiritLoss += (*i)->GetModifier()->m_amount; break;
2158 default: break;
2163 if(intelectLoss <= -90 && spiritLoss <= -90)
2164 return;
2166 break;
2168 // Mana Tide
2169 case 16191:
2171 target->CastCustomSpell(target, trigger_spell_id, &m_modifier.m_amount, NULL, NULL, true, NULL, this);
2172 return;
2174 // Ground Slam
2175 case 33525:
2176 target->CastSpell(target, trigger_spell_id, true, NULL, this, casterGUID);
2177 return;
2178 // Rod of Purification - for quest 10839 (Veil Skith: Darkstone of Terokk)
2179 case 38736:
2181 if(Unit* caster = GetCaster())
2182 caster->CastSpell(target, trigger_spell_id, true, NULL, this);
2183 return;
2185 // Beacon of Light
2186 case 53563:
2187 // original caster must be target (beacon)
2188 target->CastSpell(target, trigger_spell_id, true, NULL, this, target->GetGUID());
2189 return;
2190 // Rapid Recuperation (triggered energize have baspioints == 0)
2191 case 56654:
2192 case 58882:
2194 int32 mana = m_target->GetMaxPower(POWER_MANA) * m_modifier.m_amount / 100;
2195 target->CastCustomSpell(target, trigger_spell_id, &mana, NULL, NULL, true, NULL, this);
2196 return;
2201 // All ok cast by default case
2202 if(triggeredSpellInfo)
2203 target->CastSpell(target, triggeredSpellInfo, true, NULL, this, casterGUID);
2204 else
2206 if (Unit* caster = GetCaster())
2208 if(target->GetTypeId() != TYPEID_UNIT || !Script->EffectDummyCreature(caster, GetId(), GetEffIndex(), (Creature*)target))
2209 sLog.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex());
2214 void Aura::TriggerSpellWithValue()
2216 const uint64& casterGUID = GetCasterGUID();
2217 Unit* target = GetTriggerTarget();
2219 if(!casterGUID || !target)
2220 return;
2222 // generic casting code with custom spells and target/caster customs
2223 uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex];
2224 int32 basepoints0 = this->GetModifier()->m_amount;
2226 target->CastCustomSpell(target, trigger_spell_id, &basepoints0, NULL, NULL, true, NULL, this, casterGUID);
2229 /*********************************************************/
2230 /*** AURA EFFECTS ***/
2231 /*********************************************************/
2233 void Aura::HandleAuraDummy(bool apply, bool Real)
2235 // spells required only Real aura add/remove
2236 if (!Real)
2237 return;
2239 // AT APPLY
2240 if (apply)
2242 switch(m_spellProto->SpellFamilyName)
2244 case SPELLFAMILY_GENERIC:
2246 switch(GetId())
2248 case 1515: // Tame beast
2249 // FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness
2250 if (m_target->CanHaveThreatList())
2251 if (Unit* caster = GetCaster())
2252 m_target->AddThreat(caster, 10.0f, false, GetSpellSchoolMask(GetSpellProto()), GetSpellProto());
2253 return;
2254 case 7057: // Haunting Spirits
2255 // expected to tick with 30 sec period (tick part see in Aura::PeriodicTick)
2256 m_isPeriodic = true;
2257 m_modifier.periodictime = 30*IN_MILLISECONDS;
2258 m_periodicTimer = m_modifier.periodictime;
2259 return;
2260 case 13139: // net-o-matic
2261 // root to self part of (root_target->charge->root_self sequence
2262 if (Unit* caster = GetCaster())
2263 caster->CastSpell(caster, 13138, true, NULL, this);
2264 return;
2265 case 39850: // Rocket Blast
2266 if (roll_chance_i(20)) // backfire stun
2267 m_target->CastSpell(m_target, 51581, true, NULL, this);
2268 return;
2269 case 43873: // Headless Horseman Laugh
2270 m_target->PlayDistanceSound(11965);
2271 return;
2272 case 46354: // Blood Elf Illusion
2273 if (Unit* caster = GetCaster())
2275 switch(caster->getGender())
2277 case GENDER_FEMALE:
2278 caster->CastSpell(m_target, 46356, true, NULL, this);
2279 break;
2280 case GENDER_MALE:
2281 caster->CastSpell(m_target, 46355, true, NULL, this);
2282 break;
2283 default:
2284 break;
2287 return;
2288 case 46699: // Requires No Ammo
2289 if (m_target->GetTypeId() == TYPEID_PLAYER)
2290 // not use ammo and not allow use
2291 ((Player*)m_target)->RemoveAmmo();
2292 return;
2293 case 48025: // Headless Horseman's Mount
2294 Spell::SelectMountByAreaAndSkill(m_target, 51621, 48024, 51617, 48023, 0);
2295 return;
2296 case 62061: // Festive Holiday Mount
2297 if (m_target->HasAuraType(SPELL_AURA_MOUNTED))
2298 // Reindeer Transformation
2299 m_target->CastSpell(m_target, 25860, true, NULL, this);
2300 return;
2301 case 63624: // Learn a Second Talent Specialization
2302 // Teach Learn Talent Specialization Switches, required for client triggered casts, allow after 30 sec delay
2303 if (m_target->GetTypeId() == TYPEID_PLAYER)
2304 ((Player*)m_target)->learnSpell(63680, false);
2305 return;
2306 case 63651: // Revert to One Talent Specialization
2307 // Teach Learn Talent Specialization Switches, remove
2308 if (m_target->GetTypeId() == TYPEID_PLAYER)
2309 ((Player*)m_target)->removeSpell(63680);
2310 return;
2311 case 71342: // Big Love Rocket
2312 Spell::SelectMountByAreaAndSkill(m_target, 71344, 71345, 71346, 71347, 0);
2313 return;
2314 case 72286: // Invincible
2315 Spell::SelectMountByAreaAndSkill(m_target, 72281, 72282, 72283, 72284, 0);
2316 return;
2317 case 74856: // Blazing Hippogryph
2318 Spell::SelectMountByAreaAndSkill(m_target, 0, 0, 74854, 74855, 0);
2319 return;
2320 case 75614: // Celestial Steed
2321 Spell::SelectMountByAreaAndSkill(m_target, 75619, 75620, 75617, 75618, 76153);
2322 return;
2324 break;
2326 case SPELLFAMILY_WARRIOR:
2328 // Overpower
2329 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000004))
2331 // Must be casting target
2332 if (!m_target->IsNonMeleeSpellCasted(false))
2333 return;
2335 Unit* caster = GetCaster();
2336 if (!caster)
2337 return;
2339 Unit::AuraList const& modifierAuras = caster->GetAurasByType(SPELL_AURA_ADD_FLAT_MODIFIER);
2340 for(Unit::AuraList::const_iterator itr = modifierAuras.begin(); itr != modifierAuras.end(); ++itr)
2342 // Unrelenting Assault
2343 if ((*itr)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARRIOR && (*itr)->GetSpellProto()->SpellIconID == 2775)
2345 switch ((*itr)->GetSpellProto()->Id)
2347 case 46859: // Unrelenting Assault, rank 1
2348 m_target->CastSpell(m_target,64849,true,NULL,(*itr));
2349 break;
2350 case 46860: // Unrelenting Assault, rank 2
2351 m_target->CastSpell(m_target,64850,true,NULL,(*itr));
2352 break;
2353 default:
2354 break;
2356 break;
2359 return;
2361 break;
2363 case SPELLFAMILY_SHAMAN:
2365 // Tidal Force
2366 if (GetId() == 55198)
2368 // apply max stack bufs
2369 SpellEntry const* buffEntry = sSpellStore.LookupEntry(55166);
2370 if (!buffEntry)
2371 return;
2373 for(uint32 k = 0; k < buffEntry->StackAmount; ++k)
2374 m_target->CastSpell(m_target, buffEntry, true, NULL, this);
2376 // Earth Shield
2377 else if ((GetSpellProto()->SpellFamilyFlags & UI64LIT(0x40000000000)))
2379 // prevent double apply bonuses
2380 if (m_target->GetTypeId() != TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())
2382 if (Unit* caster = GetCaster())
2384 m_modifier.m_amount = caster->SpellHealingBonusDone(m_target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE);
2385 m_modifier.m_amount = m_target->SpellHealingBonusTaken(caster, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE);
2388 return;
2390 break;
2394 // AT REMOVE
2395 else
2397 if (m_target->GetTypeId() == TYPEID_PLAYER &&
2398 (GetSpellProto()->Effect[EFFECT_INDEX_0] == 72 || GetSpellProto()->Effect[EFFECT_INDEX_0] == 6 &&
2399 (GetSpellProto()->EffectApplyAuraName[EFFECT_INDEX_0] == 1 || GetSpellProto()->EffectApplyAuraName[EFFECT_INDEX_0] == 128)))
2401 // spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425
2402 ((Player*)m_target)->SetFarSightGUID(0);
2403 WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0);
2404 ((Player*)m_target)->GetSession()->SendPacket(&data);
2405 return;
2408 if (IsQuestTameSpell(GetId()) && m_target->isAlive())
2410 Unit* caster = GetCaster();
2411 if (!caster || !caster->isAlive())
2412 return;
2414 uint32 finalSpelId = 0;
2415 switch(GetId())
2417 case 19548: finalSpelId = 19597; break;
2418 case 19674: finalSpelId = 19677; break;
2419 case 19687: finalSpelId = 19676; break;
2420 case 19688: finalSpelId = 19678; break;
2421 case 19689: finalSpelId = 19679; break;
2422 case 19692: finalSpelId = 19680; break;
2423 case 19693: finalSpelId = 19684; break;
2424 case 19694: finalSpelId = 19681; break;
2425 case 19696: finalSpelId = 19682; break;
2426 case 19697: finalSpelId = 19683; break;
2427 case 19699: finalSpelId = 19685; break;
2428 case 19700: finalSpelId = 19686; break;
2429 case 30646: finalSpelId = 30647; break;
2430 case 30653: finalSpelId = 30648; break;
2431 case 30654: finalSpelId = 30652; break;
2432 case 30099: finalSpelId = 30100; break;
2433 case 30102: finalSpelId = 30103; break;
2434 case 30105: finalSpelId = 30104; break;
2437 if (finalSpelId)
2438 caster->CastSpell(m_target, finalSpelId, true, NULL, this);
2440 return;
2443 switch(GetId())
2445 case 12479: // Hex of Jammal'an
2446 m_target->CastSpell(m_target, 12480, true, NULL, this);
2447 return;
2448 case 28169: // Mutating Injection
2450 // Mutagen Explosion
2451 m_target->CastSpell(m_target, 28206, true, NULL, this);
2452 // Poison Cloud
2453 m_target->CastSpell(m_target, 28240, true, NULL, this);
2454 return;
2456 case 32286: // Focus Target Visual
2458 if (m_removeMode == AURA_REMOVE_BY_DEFAULT)
2459 m_target->CastSpell(m_target, 32301, true, NULL, this);
2461 return;
2463 case 36730: // Flame Strike
2465 m_target->CastSpell(m_target, 36731, true, NULL, this);
2466 return;
2468 case 44191: // Flame Strike
2470 if (m_target->GetMap()->IsDungeon())
2472 uint32 spellId = m_target->GetMap()->IsRegularDifficulty() ? 44190 : 46163;
2474 m_target->CastSpell(m_target, spellId, true, NULL, this);
2476 return;
2478 case 45934: // Dark Fiend
2480 // Kill target if dispelled
2481 if (m_removeMode==AURA_REMOVE_BY_DISPEL)
2482 m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
2483 return;
2485 case 46308: // Burning Winds
2487 // casted only at creatures at spawn
2488 m_target->CastSpell(m_target, 47287, true, NULL, this);
2489 return;
2491 case 51870: // Collect Hair Sample
2493 if (Unit* pCaster = GetCaster())
2495 if (m_removeMode == AURA_REMOVE_BY_DEFAULT)
2496 pCaster->CastSpell(m_target, 51872, true, NULL, this);
2499 return;
2501 case 58600: // Restricted Flight Area
2503 // Remove Flight Auras
2504 m_target->CastSpell(m_target, 58601, true);
2505 // Parachute
2506 m_target->CastSpell(m_target, 45472, true);
2507 return;
2511 // Living Bomb
2512 if (m_spellProto->SpellFamilyName == SPELLFAMILY_MAGE && (m_spellProto->SpellFamilyFlags & UI64LIT(0x2000000000000)))
2514 // Zero duration is equal to AURA_REMOVE_BY_DEFAULT. We can't use it directly, as it is set even
2515 // when removing aura from one target due to casting Living Bomb at other.
2516 if (m_duration == 0 || m_removeMode == AURA_REMOVE_BY_DISPEL)
2517 m_target->CastSpell(m_target,m_modifier.m_amount,true,NULL,this);
2519 return;
2522 if (m_removeMode == AURA_REMOVE_BY_DEATH)
2524 // Stop caster Arcane Missle chanelling on death
2525 if (m_spellProto->SpellFamilyName == SPELLFAMILY_MAGE && (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000800)))
2527 if (Unit* caster = GetCaster())
2528 caster->InterruptSpell(CURRENT_CHANNELED_SPELL);
2530 return;
2535 // AT APPLY & REMOVE
2537 switch(m_spellProto->SpellFamilyName)
2539 case SPELLFAMILY_GENERIC:
2541 switch(GetId())
2543 case 11196: // Recently Bandaged
2544 m_target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, GetMiscValue(), apply);
2545 return;
2546 case 24658: // Unstable Power
2548 uint32 spellId = 24659;
2549 if (apply)
2551 SpellEntry const *spell = sSpellStore.LookupEntry(spellId);
2552 Unit* caster = GetCaster();
2553 if (!spell || !caster)
2554 return;
2556 for (uint32 i = 0; i < spell->StackAmount; ++i)
2557 caster->CastSpell(m_target, spellId, true, NULL, NULL, GetCasterGUID());
2559 return;
2561 m_target->RemoveAurasDueToSpell(spellId);
2562 return;
2564 case 24661: // Restless Strength
2566 uint32 spellId = 24662;
2567 if (apply)
2569 SpellEntry const* spell = sSpellStore.LookupEntry(spellId);
2570 Unit* caster = GetCaster();
2571 if (!spell || !caster)
2572 return;
2574 for (uint32 i=0; i < spell->StackAmount; ++i)
2575 caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID());
2577 return;
2579 m_target->RemoveAurasDueToSpell(spellId);
2580 return;
2582 case 29266: // Permanent Feign Death
2583 case 31261: // Permanent Feign Death (Root)
2584 case 37493: // Feign Death
2585 case 51329: // Feign Death
2586 case 52593: // Bloated Abomination Feign Death
2587 case 55795: // Falling Dragon Feign Death
2588 case 57626: // Feign Death
2589 case 57685: // Permanent Feign Death
2590 case 58768: // Permanent Feign Death (Freeze Jumpend)
2591 case 58806: // Permanent Feign Death (Drowned Anim)
2592 case 58951: // Permanent Feign Death
2593 case 64461: // Permanent Feign Death (No Anim) (Root)
2594 case 65985: // Permanent Feign Death (Root Silence Pacify)
2595 case 70592: // Permanent Feign Death
2596 case 70628: // Permanent Feign Death
2597 case 70630: // Frozen Aftermath - Feign Death
2598 case 71598: // Feign Death
2600 // Unclear what the difference really is between them.
2601 // Some has effect1 that makes the difference, however not all.
2602 // Some appear to be used depending on creature location, in water, at solid ground, in air/suspended, etc
2603 // For now, just handle all the same way
2604 if (m_target->GetTypeId() == TYPEID_UNIT)
2605 m_target->SetFeignDeath(apply);
2607 return;
2609 case 35356: // Spawn Feign Death
2610 case 35357: // Spawn Feign Death
2611 case 42557: // Feign Death
2613 if (m_target->GetTypeId() == TYPEID_UNIT)
2615 // Flags not set like it's done in SetFeignDeath() and apparently always applied at spawn of creature
2616 // All three does however have SPELL_EFFECT_SPAWN(46) as effect1
2617 // It is possible this effect will remove some flags, and then the three here can be handled "normally"
2618 if (apply)
2620 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29);
2621 m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
2623 m_target->addUnitState(UNIT_STAT_DIED);
2625 else
2627 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29);
2628 m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
2630 m_target->clearUnitState(UNIT_STAT_DIED);
2633 return;
2635 case 40133: //Summon Fire Elemental
2637 Unit* caster = GetCaster();
2638 if (!caster)
2639 return;
2641 Unit *owner = caster->GetOwner();
2642 if (owner && owner->GetTypeId() == TYPEID_PLAYER)
2644 if (apply)
2645 owner->CastSpell(owner, 8985, true);
2646 else
2647 ((Player*)owner)->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true);
2649 return;
2651 case 40132: //Summon Earth Elemental
2653 Unit* caster = GetCaster();
2654 if (!caster)
2655 return;
2657 Unit *owner = caster->GetOwner();
2658 if (owner && owner->GetTypeId() == TYPEID_PLAYER)
2660 if (apply)
2661 owner->CastSpell(owner, 19704, true);
2662 else
2663 ((Player*)owner)->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true);
2665 return;
2667 case 40214: //Dragonmaw Illusion
2669 if (apply)
2671 m_target->CastSpell(m_target, 40216, true);
2672 m_target->CastSpell(m_target, 42016, true);
2674 else
2676 m_target->RemoveAurasDueToSpell(40216);
2677 m_target->RemoveAurasDueToSpell(42016);
2679 return;
2681 case 58204: // LK Intro VO (1)
2682 if (m_target->GetTypeId() == TYPEID_PLAYER)
2684 // Play part 1
2685 if (apply)
2686 m_target->PlayDirectSound(14970, (Player *)m_target);
2687 // continue in 58205
2688 else
2689 m_target->CastSpell(m_target, 58205, true);
2691 return;
2692 case 58205: // LK Intro VO (2)
2693 if (m_target->GetTypeId() == TYPEID_PLAYER)
2695 // Play part 2
2696 if (apply)
2697 m_target->PlayDirectSound(14971, (Player *)m_target);
2698 // Play part 3
2699 else
2700 m_target->PlayDirectSound(14972, (Player *)m_target);
2702 return;
2703 case 40131:
2704 case 27978:
2705 if (apply)
2706 m_target->m_AuraFlags |= UNIT_AURAFLAG_ALIVE_INVISIBLE;
2707 else
2708 m_target->m_AuraFlags |= ~UNIT_AURAFLAG_ALIVE_INVISIBLE;
2709 return;
2711 break;
2713 case SPELLFAMILY_MAGE:
2714 break;
2715 case SPELLFAMILY_WARLOCK:
2717 // Haunt
2718 if (GetSpellProto()->SpellIconID == 3172 && (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0004000000000000)))
2720 // NOTE: for avoid use additional field damage stored in dummy value (replace unused 100%
2721 if (apply)
2722 m_modifier.m_amount = 0; // use value as damage counter instead redundent 100% percent
2723 else
2725 int32 bp0 = m_modifier.m_amount;
2727 if (Unit* caster = GetCaster())
2728 m_target->CastCustomSpell(caster,48210,&bp0,NULL,NULL,true);
2731 break;
2733 case SPELLFAMILY_PRIEST:
2735 // Pain and Suffering
2736 if (m_spellProto->SpellIconID == 2874 && m_target->GetTypeId()==TYPEID_PLAYER)
2738 if (apply)
2740 // Reduce backfire damage (dot damage) from Shadow Word: Death
2741 // aura have wrong effectclassmask, so use hardcoded value
2742 m_spellmod = new SpellModifier(SPELLMOD_DOT,SPELLMOD_PCT,m_modifier.m_amount,GetId(),UI64LIT(0x0000200000000000));
2744 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
2745 return;
2747 break;
2749 case SPELLFAMILY_DRUID:
2751 switch(GetId())
2753 case 34246: // Idol of the Emerald Queen
2754 case 60779: // Idol of Lush Moss
2756 if (m_target->GetTypeId() != TYPEID_PLAYER)
2757 return;
2759 if (apply)
2760 // dummy not have proper effectclassmask
2761 m_spellmod = new SpellModifier(SPELLMOD_DOT,SPELLMOD_FLAT,m_modifier.m_amount/7,GetId(),UI64LIT(0x001000000000));
2763 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
2764 return;
2766 case 52610: // Savage Roar
2768 if (apply)
2770 if (m_target->m_form != FORM_CAT)
2771 return;
2773 m_target->CastSpell(m_target, 62071, true);
2775 else
2776 m_target-> RemoveAurasDueToSpell(62071);
2777 return;
2779 case 61336: // Survival Instincts
2781 if(apply)
2783 if (!m_target->IsInFeralForm())
2784 return;
2786 int32 bp0 = int32(m_target->GetMaxHealth() * m_modifier.m_amount / 100);
2787 m_target->CastCustomSpell(m_target, 50322, &bp0, NULL, NULL, true);
2789 else
2790 m_target-> RemoveAurasDueToSpell(50322);
2791 return;
2795 // Lifebloom
2796 if (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x1000000000))
2798 if (apply)
2800 if (Unit* caster = GetCaster())
2802 // prevent double apply bonuses
2803 if (m_target->GetTypeId() != TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())
2805 m_modifier.m_amount = caster->SpellHealingBonusDone(m_target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE);
2806 m_modifier.m_amount = m_target->SpellHealingBonusTaken(caster, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE);
2810 else
2812 // Final heal only on dispelled or duration end
2813 if (!(GetAuraDuration() <= 0 || m_removeMode == AURA_REMOVE_BY_DISPEL))
2814 return;
2816 // have a look if there is still some other Lifebloom dummy aura
2817 Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
2818 for(Unit::AuraList::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr)
2819 if ((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID &&
2820 ((*itr)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x1000000000)))
2821 return;
2823 // final heal
2824 if (m_target->IsInWorld() && m_stackAmount > 0)
2826 int32 amount = m_modifier.m_amount / m_stackAmount;
2827 m_target->CastCustomSpell(m_target, 33778, &amount, NULL, NULL, true, NULL, this, GetCasterGUID());
2829 if (Unit* caster = GetCaster())
2831 int32 returnmana = (GetSpellProto()->ManaCostPercentage * caster->GetCreateMana() / 100) * m_stackAmount / 2;
2832 caster->CastCustomSpell(caster, 64372, &returnmana, NULL, NULL, true, NULL, this, GetCasterGUID());
2836 return;
2839 // Predatory Strikes
2840 if (m_target->GetTypeId()==TYPEID_PLAYER && GetSpellProto()->SpellIconID == 1563)
2842 ((Player*)m_target)->UpdateAttackPowerAndDamage();
2843 return;
2846 // Improved Moonkin Form
2847 if (GetSpellProto()->SpellIconID == 2855)
2849 uint32 spell_id;
2850 switch(GetId())
2852 case 48384: spell_id = 50170; break; //Rank 1
2853 case 48395: spell_id = 50171; break; //Rank 2
2854 case 48396: spell_id = 50172; break; //Rank 3
2855 default:
2856 sLog.outError("HandleAuraDummy: Not handled rank of IMF (Spell: %u)",GetId());
2857 return;
2860 if (apply)
2862 if (m_target->m_form != FORM_MOONKIN)
2863 return;
2865 m_target->CastSpell(m_target, spell_id, true);
2867 else
2868 m_target-> RemoveAurasDueToSpell(spell_id);
2869 return;
2871 break;
2873 case SPELLFAMILY_HUNTER:
2874 break;
2875 case SPELLFAMILY_PALADIN:
2876 switch(GetId())
2878 case 20911: // Blessing of Sanctuary
2879 case 25899: // Greater Blessing of Sanctuary
2881 if (apply)
2882 m_target->CastSpell(m_target, 67480, true, NULL, this);
2883 else
2884 m_target->RemoveAurasDueToSpell(67480);
2885 return;
2888 break;
2889 case SPELLFAMILY_SHAMAN:
2890 break;
2893 // pet auras
2894 if (PetAura const* petSpell = sSpellMgr.GetPetAura(GetId(), m_effIndex))
2896 if (apply)
2897 m_target->AddPetAura(petSpell);
2898 else
2899 m_target->RemovePetAura(petSpell);
2900 return;
2903 if (GetEffIndex() == EFFECT_INDEX_0 && m_target->GetTypeId() == TYPEID_PLAYER)
2905 SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAuraMapBounds(GetId());
2906 if (saBounds.first != saBounds.second)
2908 uint32 zone, area;
2909 m_target->GetZoneAndAreaId(zone, area);
2911 for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
2913 // some auras remove at aura remove
2914 if (!itr->second->IsFitToRequirements((Player*)m_target, zone, area))
2915 m_target->RemoveAurasDueToSpell(itr->second->spellId);
2916 // some auras applied at aura apply
2917 else if (itr->second->autocast)
2919 if (!m_target->HasAura(itr->second->spellId, EFFECT_INDEX_0))
2920 m_target->CastSpell(m_target, itr->second->spellId, true);
2926 // script has to "handle with care", only use where data are not ok to use in the above code.
2927 if (m_target->GetTypeId() == TYPEID_UNIT)
2928 Script->EffectAuraDummy(this, apply);
2931 void Aura::HandleAuraMounted(bool apply, bool Real)
2933 // only at real add/remove aura
2934 if(!Real)
2935 return;
2937 if(apply)
2939 CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(m_modifier.m_miscvalue);
2940 if(!ci)
2942 sLog.outErrorDb("AuraMounted: `creature_template`='%u' not found in database (only need it modelid)", m_modifier.m_miscvalue);
2943 return;
2946 uint32 team = 0;
2947 if (m_target->GetTypeId()==TYPEID_PLAYER)
2948 team = ((Player*)m_target)->GetTeam();
2950 uint32 display_id = sObjectMgr.ChooseDisplayId(team,ci);
2951 CreatureModelInfo const *minfo = sObjectMgr.GetCreatureModelRandomGender(display_id);
2952 if (minfo)
2953 display_id = minfo->modelid;
2955 m_target->Mount(display_id, m_spellProto->Id);
2957 else
2959 m_target->Unmount();
2963 void Aura::HandleAuraWaterWalk(bool apply, bool Real)
2965 // only at real add/remove aura
2966 if(!Real)
2967 return;
2969 WorldPacket data;
2970 if(apply)
2971 data.Initialize(SMSG_MOVE_WATER_WALK, 8+4);
2972 else
2973 data.Initialize(SMSG_MOVE_LAND_WALK, 8+4);
2974 data << m_target->GetPackGUID();
2975 data << uint32(0);
2976 m_target->SendMessageToSet(&data, true);
2979 void Aura::HandleAuraFeatherFall(bool apply, bool Real)
2981 // only at real add/remove aura
2982 if(!Real)
2983 return;
2985 WorldPacket data;
2986 if(apply)
2987 data.Initialize(SMSG_MOVE_FEATHER_FALL, 8+4);
2988 else
2989 data.Initialize(SMSG_MOVE_NORMAL_FALL, 8+4);
2990 data << m_target->GetPackGUID();
2991 data << uint32(0);
2992 m_target->SendMessageToSet(&data, true);
2994 // start fall from current height
2995 if(!apply && m_target->GetTypeId() == TYPEID_PLAYER)
2996 ((Player*)m_target)->SetFallInformation(0, m_target->GetPositionZ());
2999 void Aura::HandleAuraHover(bool apply, bool Real)
3001 // only at real add/remove aura
3002 if(!Real)
3003 return;
3005 WorldPacket data;
3006 if(apply)
3007 data.Initialize(SMSG_MOVE_SET_HOVER, 8+4);
3008 else
3009 data.Initialize(SMSG_MOVE_UNSET_HOVER, 8+4);
3010 data << m_target->GetPackGUID();
3011 data << uint32(0);
3012 m_target->SendMessageToSet(&data, true);
3015 void Aura::HandleWaterBreathing(bool /*apply*/, bool /*Real*/)
3017 // update timers in client
3018 if(m_target->GetTypeId()==TYPEID_PLAYER)
3019 ((Player*)m_target)->UpdateMirrorTimers();
3022 void Aura::HandleAuraModShapeshift(bool apply, bool Real)
3024 if(!Real)
3025 return;
3027 uint32 modelid = 0;
3028 Powers PowerType = POWER_MANA;
3029 ShapeshiftForm form = ShapeshiftForm(m_modifier.m_miscvalue);
3031 SpellShapeshiftEntry const* ssEntry = sSpellShapeshiftStore.LookupEntry(form);
3032 if (!ssEntry)
3034 sLog.outError("Unknown shapeshift form %u in spell %u", form, GetId());
3035 return;
3038 if (ssEntry->modelID_A)
3040 // i will asume that creatures will always take the defined model from the dbc
3041 // since no field in creature_templates describes wether an alliance or
3042 // horde modelid should be used at shapeshifting
3043 if (m_target->GetTypeId() != TYPEID_PLAYER)
3044 modelid = ssEntry->modelID_A;
3045 else
3047 // players are a bit difficult since the dbc has seldomly an horde modelid
3048 // so we add hacks here to set the right model
3049 if (Player::TeamForRace(m_target->getRace()) == ALLIANCE)
3050 modelid = ssEntry->modelID_A;
3051 else // 3.2.3 only the moonkin form has this information
3052 modelid = ssEntry->modelID_H;
3054 // no model found, if player is horde we look here for our hardcoded modelids
3055 if (!modelid && Player::TeamForRace(m_target->getRace()) == HORDE)
3058 switch(form)
3060 case FORM_CAT:
3061 modelid = 8571;
3062 break;
3063 case FORM_BEAR:
3064 case FORM_DIREBEAR:
3065 modelid = 2289;
3066 break;
3067 case FORM_FLIGHT:
3068 modelid = 20872;
3069 break;
3070 case FORM_FLIGHT_EPIC:
3071 modelid = 21244;
3072 break;
3073 // per default use alliance modelid
3074 // mostly horde and alliance share the same
3075 default:
3076 modelid = ssEntry->modelID_A;
3077 break;
3083 // now only powertype must be set
3084 switch(form)
3086 case FORM_CAT:
3087 PowerType = POWER_ENERGY;
3088 break;
3089 case FORM_BEAR:
3090 case FORM_DIREBEAR:
3091 case FORM_BATTLESTANCE:
3092 case FORM_BERSERKERSTANCE:
3093 case FORM_DEFENSIVESTANCE:
3094 PowerType = POWER_RAGE;
3095 break;
3096 default:
3097 break;
3100 // remove polymorph before changing display id to keep new display id
3101 switch ( form )
3103 case FORM_CAT:
3104 case FORM_TREE:
3105 case FORM_TRAVEL:
3106 case FORM_AQUA:
3107 case FORM_BEAR:
3108 case FORM_DIREBEAR:
3109 case FORM_FLIGHT_EPIC:
3110 case FORM_FLIGHT:
3111 case FORM_MOONKIN:
3113 // remove movement affects
3114 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT);
3115 Unit::AuraList const& slowingAuras = m_target->GetAurasByType(SPELL_AURA_MOD_DECREASE_SPEED);
3116 for (Unit::AuraList::const_iterator iter = slowingAuras.begin(); iter != slowingAuras.end();)
3118 SpellEntry const* aurSpellInfo = (*iter)->GetSpellProto();
3120 uint32 aurMechMask = GetAllSpellMechanicMask(aurSpellInfo);
3122 // If spell that caused this aura has Croud Control or Daze effect
3123 if((aurMechMask & MECHANIC_NOT_REMOVED_BY_SHAPESHIFT) ||
3124 // some Daze spells have these parameters instead of MECHANIC_DAZE (skip snare spells)
3125 aurSpellInfo->SpellIconID == 15 && aurSpellInfo->Dispel == 0 &&
3126 (aurMechMask & (1 << (MECHANIC_SNARE-1)))==0)
3128 ++iter;
3129 continue;
3132 // All OK, remove aura now
3133 m_target->RemoveAurasDueToSpellByCancel(aurSpellInfo->Id);
3134 iter = slowingAuras.begin();
3137 // and polymorphic affects
3138 if(m_target->IsPolymorphed())
3139 m_target->RemoveAurasDueToSpell(m_target->getTransForm());
3141 break;
3143 default:
3144 break;
3147 if(apply)
3149 // remove other shapeshift before applying a new one
3150 if(m_target->m_ShapeShiftFormSpellId)
3151 m_target->RemoveAurasDueToSpell(m_target->m_ShapeShiftFormSpellId, this);
3153 m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, form);
3155 if(modelid > 0)
3156 m_target->SetDisplayId(modelid);
3158 if(PowerType != POWER_MANA)
3160 // reset power to default values only at power change
3161 if(m_target->getPowerType() != PowerType)
3162 m_target->setPowerType(PowerType);
3164 switch(form)
3166 case FORM_CAT:
3167 case FORM_BEAR:
3168 case FORM_DIREBEAR:
3170 // get furor proc chance
3171 int32 furorChance = 0;
3172 Unit::AuraList const& mDummy = m_target->GetAurasByType(SPELL_AURA_DUMMY);
3173 for(Unit::AuraList::const_iterator i = mDummy.begin(); i != mDummy.end(); ++i)
3175 if ((*i)->GetSpellProto()->SpellIconID == 238)
3177 furorChance = (*i)->GetModifier()->m_amount;
3178 break;
3182 if (m_modifier.m_miscvalue == FORM_CAT)
3184 // Furor chance is now amount allowed to save energy for cat form
3185 // without talent it reset to 0
3186 if ((int32)m_target->GetPower(POWER_ENERGY) > furorChance)
3188 m_target->SetPower(POWER_ENERGY, 0);
3189 m_target->CastCustomSpell(m_target, 17099, &furorChance, NULL, NULL, this);
3192 else if(furorChance) // only if talent known
3194 m_target->SetPower(POWER_RAGE, 0);
3195 if(irand(1,100) <= furorChance)
3196 m_target->CastSpell(m_target, 17057, true, NULL, this);
3198 break;
3200 case FORM_BATTLESTANCE:
3201 case FORM_DEFENSIVESTANCE:
3202 case FORM_BERSERKERSTANCE:
3204 uint32 Rage_val = 0;
3205 // Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch)
3206 if(m_target->GetTypeId() == TYPEID_PLAYER)
3208 PlayerSpellMap const& sp_list = ((Player *)m_target)->GetSpellMap();
3209 for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
3211 if(itr->second.state == PLAYERSPELL_REMOVED) continue;
3212 SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
3213 if (spellInfo && spellInfo->SpellFamilyName == SPELLFAMILY_WARRIOR && spellInfo->SpellIconID == 139)
3214 Rage_val += m_target->CalculateSpellDamage(m_target, spellInfo, EFFECT_INDEX_0) * 10;
3218 if (m_target->GetPower(POWER_RAGE) > Rage_val)
3219 m_target->SetPower(POWER_RAGE, Rage_val);
3220 break;
3222 default:
3223 break;
3227 m_target->m_ShapeShiftFormSpellId = GetId();
3228 m_target->m_form = form;
3230 // a form can give the player a new castbar with some spells.. this is a clientside process..
3231 // serverside just needs to register the new spells so that player isn't kicked as cheater
3232 if (m_target->GetTypeId() == TYPEID_PLAYER)
3233 for (uint32 i = 0; i < 8; ++i)
3234 if (ssEntry->spellId[i])
3235 ((Player*)m_target)->addSpell(ssEntry->spellId[i], true, false, false, false);
3238 else
3240 if(modelid > 0)
3241 m_target->SetDisplayId(m_target->GetNativeDisplayId());
3242 m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, FORM_NONE);
3243 if(m_target->getClass() == CLASS_DRUID)
3244 m_target->setPowerType(POWER_MANA);
3245 m_target->m_ShapeShiftFormSpellId = 0;
3246 m_target->m_form = FORM_NONE;
3248 switch(form)
3250 // Nordrassil Harness - bonus
3251 case FORM_BEAR:
3252 case FORM_DIREBEAR:
3253 case FORM_CAT:
3254 if(Aura* dummy = m_target->GetDummyAura(37315) )
3255 m_target->CastSpell(m_target, 37316, true, NULL, dummy);
3256 break;
3257 // Nordrassil Regalia - bonus
3258 case FORM_MOONKIN:
3259 if(Aura* dummy = m_target->GetDummyAura(37324) )
3260 m_target->CastSpell(m_target, 37325, true, NULL, dummy);
3261 break;
3262 default:
3263 break;
3266 // look at the comment in apply-part
3267 if (m_target->GetTypeId() == TYPEID_PLAYER)
3268 for (uint32 i = 0; i < 8; ++i)
3269 if (ssEntry->spellId[i])
3270 ((Player*)m_target)->removeSpell(ssEntry->spellId[i], false, false, false);
3274 // adding/removing linked auras
3275 // add/remove the shapeshift aura's boosts
3276 HandleShapeshiftBoosts(apply);
3278 if(m_target->GetTypeId() == TYPEID_PLAYER)
3279 ((Player*)m_target)->InitDataForForm();
3282 void Aura::HandleAuraTransform(bool apply, bool Real)
3284 if (apply)
3286 // special case (spell specific functionality)
3287 if (m_modifier.m_miscvalue == 0)
3289 // player applied only
3290 if (m_target->GetTypeId() != TYPEID_PLAYER)
3291 return;
3293 switch (GetId())
3295 // Orb of Deception
3296 case 16739:
3298 uint32 orb_model = m_target->GetNativeDisplayId();
3299 switch(orb_model)
3301 // Troll Female
3302 case 1479: m_target->SetDisplayId(10134); break;
3303 // Troll Male
3304 case 1478: m_target->SetDisplayId(10135); break;
3305 // Tauren Male
3306 case 59: m_target->SetDisplayId(10136); break;
3307 // Human Male
3308 case 49: m_target->SetDisplayId(10137); break;
3309 // Human Female
3310 case 50: m_target->SetDisplayId(10138); break;
3311 // Orc Male
3312 case 51: m_target->SetDisplayId(10139); break;
3313 // Orc Female
3314 case 52: m_target->SetDisplayId(10140); break;
3315 // Dwarf Male
3316 case 53: m_target->SetDisplayId(10141); break;
3317 // Dwarf Female
3318 case 54: m_target->SetDisplayId(10142); break;
3319 // NightElf Male
3320 case 55: m_target->SetDisplayId(10143); break;
3321 // NightElf Female
3322 case 56: m_target->SetDisplayId(10144); break;
3323 // Undead Female
3324 case 58: m_target->SetDisplayId(10145); break;
3325 // Undead Male
3326 case 57: m_target->SetDisplayId(10146); break;
3327 // Tauren Female
3328 case 60: m_target->SetDisplayId(10147); break;
3329 // Gnome Male
3330 case 1563: m_target->SetDisplayId(10148); break;
3331 // Gnome Female
3332 case 1564: m_target->SetDisplayId(10149); break;
3333 // BloodElf Female
3334 case 15475: m_target->SetDisplayId(17830); break;
3335 // BloodElf Male
3336 case 15476: m_target->SetDisplayId(17829); break;
3337 // Dranei Female
3338 case 16126: m_target->SetDisplayId(17828); break;
3339 // Dranei Male
3340 case 16125: m_target->SetDisplayId(17827); break;
3341 default: break;
3343 break;
3345 // Murloc costume
3346 case 42365: m_target->SetDisplayId(21723); break;
3347 // Honor the Dead
3348 case 65386:
3349 case 65495:
3351 switch(m_target->getGender())
3353 case GENDER_MALE:
3354 m_target->SetDisplayId(29203); // Chapman
3355 break;
3356 case GENDER_FEMALE:
3357 case GENDER_NONE:
3358 m_target->SetDisplayId(29204); // Catrina
3359 break;
3361 break;
3363 default: break;
3366 else
3368 uint32 model_id;
3370 CreatureInfo const * ci = ObjectMgr::GetCreatureTemplate(m_modifier.m_miscvalue);
3371 if (!ci)
3373 model_id = 16358; // pig pink ^_^
3374 sLog.outError("Auras: unknown creature id = %d (only need its modelid) Form Spell Aura Transform in Spell ID = %d", m_modifier.m_miscvalue, GetId());
3376 else
3377 model_id = ci->DisplayID_A[0]; // Will use the default model here
3379 // Polymorph (sheep/penguin case)
3380 if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_MAGE && GetSpellProto()->SpellIconID == 82)
3381 if (Unit* caster = GetCaster())
3382 if (caster->HasAura(52648)) // Glyph of the Penguin
3383 model_id = 26452;
3385 m_target->SetDisplayId(model_id);
3387 // creature case, need to update equipment
3388 if (ci && m_target->GetTypeId() == TYPEID_UNIT)
3389 ((Creature*)m_target)->LoadEquipment(ci->equipmentId, true);
3391 // Dragonmaw Illusion (set mount model also)
3392 if(GetId()==42016 && m_target->GetMountID() && !m_target->GetAurasByType(SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED).empty())
3393 m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314);
3396 // update active transform spell only not set or not overwriting negative by positive case
3397 if (!m_target->getTransForm() || !IsPositiveSpell(GetId()) || IsPositiveSpell(m_target->getTransForm()))
3398 m_target->setTransForm(GetId());
3400 // polymorph case
3401 if (Real && m_target->GetTypeId() == TYPEID_PLAYER && m_target->IsPolymorphed())
3403 // for players, start regeneration after 1s (in polymorph fast regeneration case)
3404 // only if caster is Player (after patch 2.4.2)
3405 if (IS_PLAYER_GUID(GetCasterGUID()) )
3406 ((Player*)m_target)->setRegenTimer(1*IN_MILLISECONDS);
3408 //dismount polymorphed target (after patch 2.4.2)
3409 if (m_target->IsMounted())
3410 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
3413 else
3415 // ApplyModifier(true) will reapply it if need
3416 m_target->setTransForm(0);
3417 m_target->SetDisplayId(m_target->GetNativeDisplayId());
3419 // apply default equipment for creature case
3420 if (m_target->GetTypeId() == TYPEID_UNIT)
3421 ((Creature*)m_target)->LoadEquipment(((Creature*)m_target)->GetCreatureInfo()->equipmentId, true);
3423 // re-apply some from still active with preference negative cases
3424 Unit::AuraList const& otherTransforms = m_target->GetAurasByType(SPELL_AURA_TRANSFORM);
3425 if (!otherTransforms.empty())
3427 // look for other transform auras
3428 Aura* handledAura = *otherTransforms.begin();
3429 for(Unit::AuraList::const_iterator i = otherTransforms.begin();i != otherTransforms.end(); ++i)
3431 // negative auras are preferred
3432 if (!IsPositiveSpell((*i)->GetSpellProto()->Id))
3434 handledAura = *i;
3435 break;
3438 handledAura->ApplyModifier(true);
3441 // Dragonmaw Illusion (restore mount model)
3442 if (GetId() == 42016 && m_target->GetMountID() == 16314)
3444 if (!m_target->GetAurasByType(SPELL_AURA_MOUNTED).empty())
3446 uint32 cr_id = m_target->GetAurasByType(SPELL_AURA_MOUNTED).front()->GetModifier()->m_miscvalue;
3447 if (CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(cr_id))
3449 uint32 team = 0;
3450 if (m_target->GetTypeId() == TYPEID_PLAYER)
3451 team = ((Player*)m_target)->GetTeam();
3453 uint32 display_id = sObjectMgr.ChooseDisplayId(team, ci);
3454 CreatureModelInfo const *minfo = sObjectMgr.GetCreatureModelRandomGender(display_id);
3455 if (minfo)
3456 display_id = minfo->modelid;
3458 m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, display_id);
3465 void Aura::HandleForceReaction(bool apply, bool Real)
3467 if(m_target->GetTypeId() != TYPEID_PLAYER)
3468 return;
3470 if(!Real)
3471 return;
3473 Player* player = (Player*)m_target;
3475 uint32 faction_id = m_modifier.m_miscvalue;
3476 ReputationRank faction_rank = ReputationRank(m_modifier.m_amount);
3478 player->GetReputationMgr().ApplyForceReaction(faction_id, faction_rank, apply);
3479 player->GetReputationMgr().SendForceReactions();
3481 // stop fighting if at apply forced rank friendly or at remove real rank friendly
3482 if (apply && faction_rank >= REP_FRIENDLY || !apply && player->GetReputationRank(faction_id) >= REP_FRIENDLY)
3483 player->StopAttackFaction(faction_id);
3486 void Aura::HandleAuraModSkill(bool apply, bool /*Real*/)
3488 if(m_target->GetTypeId() != TYPEID_PLAYER)
3489 return;
3491 uint32 prot=GetSpellProto()->EffectMiscValue[m_effIndex];
3492 int32 points = GetModifier()->m_amount;
3494 ((Player*)m_target)->ModifySkillBonus(prot, (apply ? points: -points), m_modifier.m_auraname == SPELL_AURA_MOD_SKILL_TALENT);
3495 if(prot == SKILL_DEFENSE)
3496 ((Player*)m_target)->UpdateDefenseBonusesMod();
3499 void Aura::HandleChannelDeathItem(bool apply, bool Real)
3501 if(Real && !apply)
3503 if(m_removeMode != AURA_REMOVE_BY_DEATH)
3504 return;
3505 // Item amount
3506 if (m_modifier.m_amount <= 0)
3507 return;
3509 SpellEntry const *spellInfo = GetSpellProto();
3510 if(spellInfo->EffectItemType[m_effIndex] == 0)
3511 return;
3513 Unit* victim = GetTarget();
3514 Unit* caster = GetCaster();
3515 if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
3516 return;
3518 // Soul Shard only from non-grey units
3519 if( spellInfo->EffectItemType[m_effIndex] == 6265 &&
3520 (victim->getLevel() <= MaNGOS::XP::GetGrayLevel(caster->getLevel()) ||
3521 victim->GetTypeId()==TYPEID_UNIT && !((Player*)caster)->isAllowedToLoot((Creature*)victim)) )
3522 return;
3523 //Adding items
3524 uint32 noSpaceForCount = 0;
3525 uint32 count = m_modifier.m_amount;
3527 ItemPosCountVec dest;
3528 uint8 msg = ((Player*)caster)->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, spellInfo->EffectItemType[m_effIndex], count, &noSpaceForCount);
3529 if( msg != EQUIP_ERR_OK )
3531 count-=noSpaceForCount;
3532 ((Player*)caster)->SendEquipError( msg, NULL, NULL, spellInfo->EffectItemType[m_effIndex] );
3533 if (count==0)
3534 return;
3537 Item* newitem = ((Player*)caster)->StoreNewItem(dest, spellInfo->EffectItemType[m_effIndex], true);
3538 ((Player*)caster)->SendNewItem(newitem, count, true, false);
3542 void Aura::HandleBindSight(bool apply, bool /*Real*/)
3544 Unit* caster = GetCaster();
3545 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3546 return;
3548 ((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);
3551 void Aura::HandleFarSight(bool apply, bool /*Real*/)
3553 Unit* caster = GetCaster();
3554 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3555 return;
3557 ((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);
3560 void Aura::HandleAuraTrackCreatures(bool apply, bool /*Real*/)
3562 if(m_target->GetTypeId()!=TYPEID_PLAYER)
3563 return;
3565 if(apply)
3566 m_target->RemoveNoStackAurasDueToAura(this);
3567 m_target->SetUInt32Value(PLAYER_TRACK_CREATURES, apply ? ((uint32)1)<<(m_modifier.m_miscvalue-1) : 0 );
3570 void Aura::HandleAuraTrackResources(bool apply, bool /*Real*/)
3572 if(m_target->GetTypeId()!=TYPEID_PLAYER)
3573 return;
3575 if(apply)
3576 m_target->RemoveNoStackAurasDueToAura(this);
3577 m_target->SetUInt32Value(PLAYER_TRACK_RESOURCES, apply ? ((uint32)1)<<(m_modifier.m_miscvalue-1): 0 );
3580 void Aura::HandleAuraTrackStealthed(bool apply, bool /*Real*/)
3582 if(m_target->GetTypeId()!=TYPEID_PLAYER)
3583 return;
3585 if(apply)
3586 m_target->RemoveNoStackAurasDueToAura(this);
3588 m_target->ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_TRACK_STEALTHED, apply);
3591 void Aura::HandleAuraModScale(bool apply, bool /*Real*/)
3593 m_target->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X, float(m_modifier.m_amount), apply);
3596 void Aura::HandleModPossess(bool apply, bool Real)
3598 if(!Real)
3599 return;
3601 // not possess yourself
3602 if(GetCasterGUID() == m_target->GetGUID())
3603 return;
3605 Unit* caster = GetCaster();
3606 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3607 return;
3609 Player* p_caster = (Player*)caster;
3612 if( apply )
3614 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
3616 m_target->SetCharmerGUID(p_caster->GetGUID());
3617 m_target->setFaction(p_caster->getFaction());
3619 p_caster->SetCharm(m_target);
3621 p_caster->SetFarSightGUID(m_target->GetGUID());
3622 p_caster->SetClientControl(m_target, 1);
3623 p_caster->SetMover(m_target);
3625 m_target->CombatStop();
3626 m_target->DeleteThreatList();
3628 if(m_target->GetTypeId() == TYPEID_UNIT)
3630 m_target->StopMoving();
3631 m_target->GetMotionMaster()->Clear();
3632 m_target->GetMotionMaster()->MoveIdle();
3634 else if(m_target->GetTypeId() == TYPEID_PLAYER)
3636 ((Player*)m_target)->SetClientControl(m_target, 0);
3639 if(CharmInfo *charmInfo = m_target->InitCharmInfo(m_target))
3640 charmInfo->InitPossessCreateSpells();
3642 p_caster->PossessSpellInitialize();
3644 else
3646 p_caster->InterruptSpell(CURRENT_CHANNELED_SPELL); // the spell is not automatically canceled when interrupted, do it now
3647 p_caster->SetCharm(NULL);
3649 p_caster->SetFarSightGUID(0);
3650 p_caster->SetClientControl(m_target, 0);
3651 p_caster->SetMover(NULL);
3653 p_caster->RemovePetActionBar();
3655 // on delete only do caster related effects
3656 if(m_removeMode == AURA_REMOVE_BY_DELETE)
3657 return;
3659 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
3661 m_target->SetCharmerGUID(0);
3663 if(m_target->GetTypeId() == TYPEID_PLAYER)
3665 ((Player*)m_target)->setFactionForRace(m_target->getRace());
3666 ((Player*)m_target)->SetClientControl(m_target, 1);
3668 else if(m_target->GetTypeId() == TYPEID_UNIT)
3670 CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
3671 m_target->setFaction(cinfo->faction_A);
3674 if(m_target->GetTypeId() == TYPEID_UNIT)
3676 ((Creature*)m_target)->AIM_Initialize();
3678 if (((Creature*)m_target)->AI())
3679 ((Creature*)m_target)->AI()->AttackedBy(caster);
3684 void Aura::HandleModPossessPet(bool apply, bool Real)
3686 if(!Real)
3687 return;
3689 Unit* caster = GetCaster();
3690 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3691 return;
3693 Pet *pet = caster->GetPet();
3694 if(!pet || pet != m_target)
3695 return;
3697 Player* p_caster = (Player*)caster;
3699 if(apply)
3700 pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
3701 else
3702 pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
3704 p_caster->SetFarSightGUID(apply ? pet->GetGUID() : 0);
3705 p_caster->SetCharm(apply ? pet : NULL);
3706 p_caster->SetClientControl(pet, apply ? 1 : 0);
3707 ((Player*)caster)->SetMover(apply ? pet : NULL);
3709 if(apply)
3711 pet->StopMoving();
3712 pet->GetMotionMaster()->Clear();
3713 pet->GetMotionMaster()->MoveIdle();
3715 else
3717 pet->AttackStop();
3718 pet->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
3719 pet->AddSplineFlag(SPLINEFLAG_WALKMODE);
3723 void Aura::HandleAuraModPetTalentsPoints(bool /*Apply*/, bool Real)
3725 if(!Real)
3726 return;
3728 // Recalculate pet talent points
3729 if (Pet *pet=m_target->GetPet())
3730 pet->InitTalentForLevel();
3733 void Aura::HandleModCharm(bool apply, bool Real)
3735 if(!Real)
3736 return;
3738 // not charm yourself
3739 if(GetCasterGUID() == m_target->GetGUID())
3740 return;
3742 Unit* caster = GetCaster();
3743 if(!caster)
3744 return;
3746 if( apply )
3748 if (m_target->GetCharmerGUID())
3750 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM);
3751 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS);
3754 m_target->SetCharmerGUID(GetCasterGUID());
3755 m_target->setFaction(caster->getFaction());
3756 m_target->CastStop(m_target == caster ? GetId() : 0);
3757 caster->SetCharm(m_target);
3759 m_target->CombatStop();
3760 m_target->DeleteThreatList();
3762 if(m_target->GetTypeId() == TYPEID_UNIT)
3764 ((Creature*)m_target)->AIM_Initialize();
3765 CharmInfo *charmInfo = m_target->InitCharmInfo(m_target);
3766 charmInfo->InitCharmCreateSpells();
3767 charmInfo->SetReactState( REACT_DEFENSIVE );
3769 if(caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK)
3771 CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
3772 if(cinfo && cinfo->type == CREATURE_TYPE_DEMON)
3774 // creature with pet number expected have class set
3775 if(m_target->GetByteValue(UNIT_FIELD_BYTES_0, 1)==0)
3777 if(cinfo->unit_class==0)
3778 sLog.outErrorDb("Creature (Entry: %u) have unit_class = 0 but used in charmed spell, that will be result client crash.",cinfo->Entry);
3779 else
3780 sLog.outError("Creature (Entry: %u) have unit_class = %u but at charming have class 0!!! that will be result client crash.",cinfo->Entry,cinfo->unit_class);
3782 m_target->SetByteValue(UNIT_FIELD_BYTES_0, 1, CLASS_MAGE);
3785 //just to enable stat window
3786 charmInfo->SetPetNumber(sObjectMgr.GeneratePetNumber(), true);
3787 //if charmed two demons the same session, the 2nd gets the 1st one's name
3788 m_target->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL)));
3793 if(caster->GetTypeId() == TYPEID_PLAYER)
3794 ((Player*)caster)->CharmSpellInitialize();
3796 else
3798 m_target->SetCharmerGUID(0);
3800 if(m_target->GetTypeId() == TYPEID_PLAYER)
3801 ((Player*)m_target)->setFactionForRace(m_target->getRace());
3802 else
3804 CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
3806 // restore faction
3807 if(((Creature*)m_target)->isPet())
3809 if(Unit* owner = m_target->GetOwner())
3810 m_target->setFaction(owner->getFaction());
3811 else if(cinfo)
3812 m_target->setFaction(cinfo->faction_A);
3814 else if(cinfo) // normal creature
3815 m_target->setFaction(cinfo->faction_A);
3817 // restore UNIT_FIELD_BYTES_0
3818 if(cinfo && caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK && cinfo->type == CREATURE_TYPE_DEMON)
3820 // DB must have proper class set in field at loading, not req. restore, including workaround case at apply
3821 // m_target->SetByteValue(UNIT_FIELD_BYTES_0, 1, cinfo->unit_class);
3823 if(m_target->GetCharmInfo())
3824 m_target->GetCharmInfo()->SetPetNumber(0, true);
3825 else
3826 sLog.outError("Aura::HandleModCharm: target (GUID: %u TypeId: %u) has a charm aura but no charm info!", m_target->GetGUIDLow(), m_target->GetTypeId());
3830 caster->SetCharm(NULL);
3832 if(caster->GetTypeId() == TYPEID_PLAYER)
3833 ((Player*)caster)->RemovePetActionBar();
3835 if(m_target->GetTypeId() == TYPEID_UNIT)
3837 ((Creature*)m_target)->AIM_Initialize();
3838 if (((Creature*)m_target)->AI())
3839 ((Creature*)m_target)->AI()->AttackedBy(caster);
3844 void Aura::HandleModConfuse(bool apply, bool Real)
3846 if(!Real)
3847 return;
3849 m_target->SetConfused(apply, GetCasterGUID(), GetId());
3852 void Aura::HandleModFear(bool apply, bool Real)
3854 if (!Real)
3855 return;
3857 m_target->SetFeared(apply, GetCasterGUID(), GetId());
3860 void Aura::HandleFeignDeath(bool apply, bool Real)
3862 if(!Real)
3863 return;
3865 m_target->SetFeignDeath(apply, GetCasterGUID(), GetId());
3868 void Aura::HandleAuraModDisarm(bool apply, bool Real)
3870 if(!Real)
3871 return;
3873 if(!apply && m_target->HasAuraType(SPELL_AURA_MOD_DISARM))
3874 return;
3876 // not sure for it's correctness
3877 if(apply)
3878 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
3879 else
3880 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
3882 // only at real add/remove aura
3883 if (m_target->GetTypeId() != TYPEID_PLAYER)
3884 return;
3886 // main-hand attack speed already set to special value for feral form already and don't must change and reset at remove.
3887 if (m_target->IsInFeralForm())
3888 return;
3890 if (apply)
3891 m_target->SetAttackTime(BASE_ATTACK,BASE_ATTACK_TIME);
3892 else
3893 ((Player *)m_target)->SetRegularAttackTime();
3895 m_target->UpdateDamagePhysical(BASE_ATTACK);
3898 void Aura::HandleAuraModStun(bool apply, bool Real)
3900 if(!Real)
3901 return;
3903 if (apply)
3905 // Frost stun aura -> freeze/unfreeze target
3906 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
3907 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
3909 m_target->addUnitState(UNIT_STAT_STUNNED);
3910 m_target->SetTargetGUID(0);
3912 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
3913 m_target->CastStop(m_target->GetGUID() == GetCasterGUID() ? GetId() : 0);
3915 // Creature specific
3916 if(m_target->GetTypeId() != TYPEID_PLAYER)
3917 m_target->StopMoving();
3918 else
3920 ((Player*)m_target)->m_movementInfo.SetMovementFlags(MOVEFLAG_NONE);
3921 m_target->SetStandState(UNIT_STAND_STATE_STAND);// in 1.5 client
3924 WorldPacket data(SMSG_FORCE_MOVE_ROOT, 8);
3925 data << m_target->GetPackGUID();
3926 data << uint32(0);
3927 m_target->SendMessageToSet(&data, true);
3929 // Summon the Naj'entus Spine GameObject on target if spell is Impaling Spine
3930 if(GetId() == 39837)
3932 GameObject* pObj = new GameObject;
3933 if(pObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 185584, m_target->GetMap(), m_target->GetPhaseMask(),
3934 m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
3936 pObj->SetRespawnTime(GetAuraDuration()/IN_MILLISECONDS);
3937 pObj->SetSpellId(GetId());
3938 m_target->AddGameObject(pObj);
3939 m_target->GetMap()->Add(pObj);
3941 else
3942 delete pObj;
3945 else
3947 // Frost stun aura -> freeze/unfreeze target
3948 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
3950 bool found_another = false;
3951 for(AuraType const* itr = &frozenAuraTypes[0]; *itr != SPELL_AURA_NONE; ++itr)
3953 Unit::AuraList const& auras = m_target->GetAurasByType(*itr);
3954 for(Unit::AuraList::const_iterator i = auras.begin(); i != auras.end(); ++i)
3956 if( GetSpellSchoolMask((*i)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST)
3958 found_another = true;
3959 break;
3962 if(found_another)
3963 break;
3966 if(!found_another)
3967 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
3970 // Real remove called after current aura remove from lists, check if other similar auras active
3971 if(m_target->HasAuraType(SPELL_AURA_MOD_STUN))
3972 return;
3974 m_target->clearUnitState(UNIT_STAT_STUNNED);
3975 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
3977 if(!m_target->hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect
3979 if(m_target->getVictim() && m_target->isAlive())
3980 m_target->SetTargetGUID(m_target->getVictim()->GetGUID());
3982 WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 8+4);
3983 data << m_target->GetPackGUID();
3984 data << uint32(0);
3985 m_target->SendMessageToSet(&data, true);
3988 // Wyvern Sting
3989 if (m_spellProto->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellProto->SpellFamilyFlags & UI64LIT(0x0000100000000000))
3991 Unit* caster = GetCaster();
3992 if( !caster || caster->GetTypeId()!=TYPEID_PLAYER )
3993 return;
3995 uint32 spell_id = 0;
3997 switch(GetId())
3999 case 19386: spell_id = 24131; break;
4000 case 24132: spell_id = 24134; break;
4001 case 24133: spell_id = 24135; break;
4002 case 27068: spell_id = 27069; break;
4003 case 49011: spell_id = 49009; break;
4004 case 49012: spell_id = 49010; break;
4005 default:
4006 sLog.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?",GetId());
4007 return;
4010 SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id);
4012 if(!spellInfo)
4013 return;
4015 caster->CastSpell(m_target,spellInfo,true,NULL,this);
4016 return;
4021 void Aura::HandleModStealth(bool apply, bool Real)
4023 if (apply)
4025 // drop flag at stealth in bg
4026 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
4028 // only at real aura add
4029 if (Real)
4031 m_target->SetStandFlags(UNIT_STAND_FLAGS_CREEP);
4033 if (m_target->GetTypeId()==TYPEID_PLAYER)
4034 m_target->SetFlag(PLAYER_FIELD_BYTES2, 0x2000);
4036 // apply only if not in GM invisibility (and overwrite invisibility state)
4037 if (m_target->GetVisibility()!=VISIBILITY_OFF)
4039 m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
4040 m_target->SetVisibility(VISIBILITY_GROUP_STEALTH);
4043 // apply full stealth period bonuses only at first stealth aura in stack
4044 if(m_target->GetAurasByType(SPELL_AURA_MOD_STEALTH).size()<=1)
4046 Unit::AuraList const& mDummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
4047 for(Unit::AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i)
4049 // Master of Subtlety
4050 if ((*i)->GetSpellProto()->SpellIconID == 2114)
4052 m_target->RemoveAurasDueToSpell(31666);
4053 int32 bp = (*i)->GetModifier()->m_amount;
4054 m_target->CastCustomSpell(m_target,31665,&bp,NULL,NULL,true);
4056 // Overkill
4057 else if ((*i)->GetId() == 58426 && GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000400000))
4059 m_target->RemoveAurasDueToSpell(58428);
4060 m_target->CastSpell(m_target, 58427, true);
4066 else
4068 // only at real aura remove of _last_ SPELL_AURA_MOD_STEALTH
4069 if (Real && !m_target->HasAuraType(SPELL_AURA_MOD_STEALTH))
4071 // if no GM invisibility
4072 if (m_target->GetVisibility()!=VISIBILITY_OFF)
4074 m_target->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP);
4076 if (m_target->GetTypeId()==TYPEID_PLAYER)
4077 m_target->RemoveFlag(PLAYER_FIELD_BYTES2, 0x2000);
4079 // restore invisibility if any
4080 if (m_target->HasAuraType(SPELL_AURA_MOD_INVISIBILITY))
4082 m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
4083 m_target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY);
4085 else
4086 m_target->SetVisibility(VISIBILITY_ON);
4089 // apply delayed talent bonus remover at last stealth aura remove
4090 Unit::AuraList const& mDummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
4091 for(Unit::AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i)
4093 // Master of Subtlety
4094 if ((*i)->GetSpellProto()->SpellIconID == 2114)
4095 m_target->CastSpell(m_target, 31666, true);
4096 // Overkill
4097 else if ((*i)->GetId() == 58426 && GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000400000))
4098 m_target->CastSpell(m_target, 58428, true);
4104 void Aura::HandleInvisibility(bool apply, bool Real)
4106 if(apply)
4108 m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue);
4110 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
4112 if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
4114 // apply glow vision
4115 m_target->SetFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
4119 // apply only if not in GM invisibility and not stealth
4120 if(m_target->GetVisibility() == VISIBILITY_ON)
4122 // Aura not added yet but visibility code expect temporary add aura
4123 m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
4124 m_target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY);
4127 else
4129 // recalculate value at modifier remove (current aura already removed)
4130 m_target->m_invisibilityMask = 0;
4131 Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY);
4132 for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
4133 m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue);
4135 // only at real aura remove and if not have different invisibility auras.
4136 if(Real && m_target->m_invisibilityMask == 0)
4138 // remove glow vision
4139 if(m_target->GetTypeId() == TYPEID_PLAYER)
4140 m_target->RemoveFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
4142 // apply only if not in GM invisibility & not stealthed while invisible
4143 if(m_target->GetVisibility() != VISIBILITY_OFF)
4145 // if have stealth aura then already have stealth visibility
4146 if(!m_target->HasAuraType(SPELL_AURA_MOD_STEALTH))
4147 m_target->SetVisibility(VISIBILITY_ON);
4153 void Aura::HandleInvisibilityDetect(bool apply, bool Real)
4155 if(apply)
4157 m_target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue);
4159 else
4161 // recalculate value at modifier remove (current aura already removed)
4162 m_target->m_detectInvisibilityMask = 0;
4163 Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION);
4164 for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
4165 m_target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue);
4167 if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
4168 ((Player*)m_target)->UpdateVisibilityForPlayer();
4171 void Aura::HandleAuraModRoot(bool apply, bool Real)
4173 // only at real add/remove aura
4174 if(!Real)
4175 return;
4177 if (apply)
4179 // Frost root aura -> freeze/unfreeze target
4180 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
4181 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
4183 m_target->addUnitState(UNIT_STAT_ROOT);
4184 m_target->SetTargetGUID(0);
4186 //Save last orientation
4187 if( m_target->getVictim() )
4188 m_target->SetOrientation(m_target->GetAngle(m_target->getVictim()));
4190 if(m_target->GetTypeId() == TYPEID_PLAYER)
4192 WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10);
4193 data << m_target->GetPackGUID();
4194 data << (uint32)2;
4195 m_target->SendMessageToSet(&data, true);
4197 //Clear unit movement flags
4198 ((Player*)m_target)->m_movementInfo.SetMovementFlags(MOVEFLAG_NONE);
4200 else
4201 m_target->StopMoving();
4203 else
4205 // Frost root aura -> freeze/unfreeze target
4206 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
4208 bool found_another = false;
4209 for(AuraType const* itr = &frozenAuraTypes[0]; *itr != SPELL_AURA_NONE; ++itr)
4211 Unit::AuraList const& auras = m_target->GetAurasByType(*itr);
4212 for(Unit::AuraList::const_iterator i = auras.begin(); i != auras.end(); ++i)
4214 if( GetSpellSchoolMask((*i)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST)
4216 found_another = true;
4217 break;
4220 if(found_another)
4221 break;
4224 if(!found_another)
4225 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
4228 // Real remove called after current aura remove from lists, check if other similar auras active
4229 if(m_target->HasAuraType(SPELL_AURA_MOD_ROOT))
4230 return;
4232 m_target->clearUnitState(UNIT_STAT_ROOT);
4234 if(!m_target->hasUnitState(UNIT_STAT_STUNNED)) // prevent allow move if have also stun effect
4236 if(m_target->getVictim() && m_target->isAlive())
4237 m_target->SetTargetGUID(m_target->getVictim()->GetGUID());
4239 if(m_target->GetTypeId() == TYPEID_PLAYER)
4241 WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 10);
4242 data << m_target->GetPackGUID();
4243 data << (uint32)2;
4244 m_target->SendMessageToSet(&data, true);
4250 void Aura::HandleAuraModSilence(bool apply, bool Real)
4252 // only at real add/remove aura
4253 if(!Real)
4254 return;
4256 if(apply)
4258 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED);
4259 // Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE
4260 for (uint32 i = CURRENT_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
4261 if (Spell* spell = m_target->GetCurrentSpell(CurrentSpellTypes(i)))
4262 if(spell->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
4263 // Stop spells on prepare or casting state
4264 m_target->InterruptSpell(CurrentSpellTypes(i), false);
4266 else
4268 // Real remove called after current aura remove from lists, check if other similar auras active
4269 if(m_target->HasAuraType(SPELL_AURA_MOD_SILENCE))
4270 return;
4272 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED);
4276 void Aura::HandleModThreat(bool apply, bool Real)
4278 // only at real add/remove aura
4279 if (!Real)
4280 return;
4282 if (!m_target->isAlive())
4283 return;
4285 Unit* caster = GetCaster();
4287 if (!caster || !caster->isAlive())
4288 return;
4290 int level_diff = 0;
4291 int multiplier = 0;
4292 switch (GetId())
4294 // Arcane Shroud
4295 case 26400:
4296 level_diff = m_target->getLevel() - 60;
4297 multiplier = 2;
4298 break;
4299 // The Eye of Diminution
4300 case 28862:
4301 level_diff = m_target->getLevel() - 60;
4302 multiplier = 1;
4303 break;
4306 if (level_diff > 0)
4307 m_modifier.m_amount += multiplier * level_diff;
4309 if (m_target->GetTypeId() == TYPEID_PLAYER)
4310 for(int8 x=0;x < MAX_SPELL_SCHOOL;x++)
4311 if (m_modifier.m_miscvalue & int32(1<<x))
4312 ApplyPercentModFloatVar(m_target->m_threatModifier[x], float(m_modifier.m_amount), apply);
4315 void Aura::HandleAuraModTotalThreat(bool apply, bool Real)
4317 // only at real add/remove aura
4318 if (!Real)
4319 return;
4321 if (!m_target->isAlive() || m_target->GetTypeId() != TYPEID_PLAYER)
4322 return;
4324 Unit* caster = GetCaster();
4326 if (!caster || !caster->isAlive())
4327 return;
4329 float threatMod = apply ? float(m_modifier.m_amount) : float(-m_modifier.m_amount);
4331 m_target->getHostileRefManager().threatAssist(caster, threatMod, GetSpellProto());
4334 void Aura::HandleModTaunt(bool apply, bool Real)
4336 // only at real add/remove aura
4337 if (!Real)
4338 return;
4340 if (!m_target->isAlive() || !m_target->CanHaveThreatList())
4341 return;
4343 Unit* caster = GetCaster();
4345 if (!caster || !caster->isAlive())
4346 return;
4348 if (apply)
4349 m_target->TauntApply(caster);
4350 else
4352 // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat
4353 m_target->TauntFadeOut(caster);
4357 /*********************************************************/
4358 /*** MODIFY SPEED ***/
4359 /*********************************************************/
4360 void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real)
4362 // all applied/removed only at real aura add/remove
4363 if(!Real)
4364 return;
4366 m_target->UpdateSpeed(MOVE_RUN, true);
4369 void Aura::HandleAuraModIncreaseMountedSpeed(bool apply, bool Real)
4371 // all applied/removed only at real aura add/remove
4372 if(!Real)
4373 return;
4375 m_target->UpdateSpeed(MOVE_RUN, true);
4377 // Festive Holiday Mount
4378 if (apply && GetSpellProto()->SpellIconID != 1794 && m_target->HasAura(62061))
4379 // Reindeer Transformation
4380 m_target->CastSpell(m_target, 25860, true, NULL, this);
4383 void Aura::HandleAuraModIncreaseFlightSpeed(bool apply, bool Real)
4385 // all applied/removed only at real aura add/remove
4386 if(!Real)
4387 return;
4389 // Enable Fly mode for flying mounts
4390 if (m_modifier.m_auraname == SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED)
4392 WorldPacket data;
4393 if(apply)
4394 data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
4395 else
4396 data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
4397 data << m_target->GetPackGUID();
4398 data << uint32(0); // unknown
4399 m_target->SendMessageToSet(&data, true);
4401 //Players on flying mounts must be immune to polymorph
4402 if (m_target->GetTypeId()==TYPEID_PLAYER)
4403 m_target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,MECHANIC_POLYMORPH,apply);
4405 // Dragonmaw Illusion (overwrite mount model, mounted aura already applied)
4406 if (apply && m_target->HasAura(42016, EFFECT_INDEX_0) && m_target->GetMountID())
4407 m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314);
4409 // Festive Holiday Mount
4410 if (apply && GetSpellProto()->SpellIconID != 1794 && m_target->HasAura(62061))
4411 // Reindeer Transformation
4412 m_target->CastSpell(m_target, 25860, true, NULL, this);
4415 // Swift Flight Form check for higher speed flying mounts
4416 if (apply && m_target->GetTypeId() == TYPEID_PLAYER && GetSpellProto()->Id == 40121)
4418 for (PlayerSpellMap::const_iterator iter = ((Player*)m_target)->GetSpellMap().begin(); iter != ((Player*)m_target)->GetSpellMap().end(); ++iter)
4420 if (iter->second.state != PLAYERSPELL_REMOVED)
4422 bool changedSpeed = false;
4423 SpellEntry const *spellInfo = sSpellStore.LookupEntry(iter->first);
4424 for(int i = 0; i < MAX_EFFECT_INDEX; ++i)
4426 if(spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED)
4428 int32 mountSpeed = spellInfo->CalculateSimpleValue(SpellEffectIndex(i));
4429 if (mountSpeed > m_modifier.m_amount)
4431 m_modifier.m_amount = mountSpeed;
4432 changedSpeed = true;
4433 break;
4437 if (changedSpeed)
4438 break;
4443 m_target->UpdateSpeed(MOVE_FLIGHT, true);
4446 void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real)
4448 // all applied/removed only at real aura add/remove
4449 if(!Real)
4450 return;
4452 m_target->UpdateSpeed(MOVE_SWIM, true);
4455 void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real)
4457 // all applied/removed only at real aura add/remove
4458 if(!Real)
4459 return;
4461 if (apply)
4463 // Gronn Lord's Grasp, becomes stoned
4464 if (GetId() == 33572)
4466 if (GetStackAmount() >= 5 && !m_target->HasAura(33652))
4467 m_target->CastSpell(m_target, 33652, true);
4471 m_target->UpdateSpeed(MOVE_RUN, true);
4472 m_target->UpdateSpeed(MOVE_SWIM, true);
4473 m_target->UpdateSpeed(MOVE_FLIGHT, true);
4476 void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real)
4478 // all applied/removed only at real aura add/remove
4479 if(!Real)
4480 return;
4482 m_target->UpdateSpeed(MOVE_RUN, true);
4483 m_target->UpdateSpeed(MOVE_SWIM, true);
4484 m_target->UpdateSpeed(MOVE_FLIGHT, true);
4487 /*********************************************************/
4488 /*** IMMUNITY ***/
4489 /*********************************************************/
4491 void Aura::HandleModMechanicImmunity(bool apply, bool /*Real*/)
4493 uint32 misc = m_modifier.m_miscvalue;
4494 // Forbearance
4495 // in DBC wrong mechanic immune since 3.0.x
4496 if (GetId() == 25771)
4497 misc = MECHANIC_IMMUNE_SHIELD;
4500 if(apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
4502 uint32 mechanic = 1 << (misc-1);
4504 //immune movement impairment and loss of control
4505 if(GetId()==42292 || GetId()==59752)
4506 mechanic=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
4508 m_target->RemoveAurasAtMechanicImmunity(mechanic,GetId());
4511 m_target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,misc,apply);
4513 // Bestial Wrath
4514 if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellProto()->SpellIconID == 1680)
4516 // The Beast Within cast on owner if talent present
4517 if (Unit* owner = m_target->GetOwner())
4519 // Search talent The Beast Within
4520 Unit::AuraList const& dummyAuras = owner->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
4521 for(Unit::AuraList::const_iterator i = dummyAuras.begin(); i != dummyAuras.end(); ++i)
4523 if ((*i)->GetSpellProto()->SpellIconID == 2229)
4525 if (apply)
4526 owner->CastSpell(owner, 34471, true, NULL, this);
4527 else
4528 owner->RemoveAurasDueToSpell(34471);
4529 break;
4534 // Heroic Fury (Intercept cooldown remove)
4535 else if (apply && GetSpellProto()->Id == 60970 && m_target->GetTypeId() == TYPEID_PLAYER)
4536 ((Player*)m_target)->RemoveSpellCooldown(20252, true);
4539 void Aura::HandleModMechanicImmunityMask(bool apply, bool /*Real*/)
4541 uint32 mechanic = m_modifier.m_miscvalue;
4543 if(apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
4544 m_target->RemoveAurasAtMechanicImmunity(mechanic,GetId());
4546 // check implemented in Unit::IsImmunedToSpell and Unit::IsImmunedToSpellEffect
4549 //this method is called whenever we add / remove aura which gives m_target some imunity to some spell effect
4550 void Aura::HandleAuraModEffectImmunity(bool apply, bool /*Real*/)
4552 // when removing flag aura, handle flag drop
4553 if( !apply && m_target->GetTypeId() == TYPEID_PLAYER
4554 && (GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION) )
4556 if( BattleGround *bg = ((Player*)m_target)->GetBattleGround() )
4557 bg->EventPlayerDroppedFlag(((Player*)m_target));
4560 m_target->ApplySpellImmune(GetId(), IMMUNITY_EFFECT, m_modifier.m_miscvalue, apply);
4563 void Aura::HandleAuraModStateImmunity(bool apply, bool Real)
4565 if(apply && Real && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
4567 Unit::AuraList const& auraList = m_target->GetAurasByType(AuraType(m_modifier.m_miscvalue));
4568 for(Unit::AuraList::const_iterator itr = auraList.begin(); itr != auraList.end();)
4570 if (auraList.front() != this) // skip itself aura (it already added)
4572 m_target->RemoveAurasDueToSpell(auraList.front()->GetId());
4573 itr = auraList.begin();
4575 else
4576 ++itr;
4580 m_target->ApplySpellImmune(GetId(), IMMUNITY_STATE, m_modifier.m_miscvalue, apply);
4583 void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real)
4585 m_target->ApplySpellImmune(GetId(), IMMUNITY_SCHOOL, m_modifier.m_miscvalue, apply);
4587 // remove all flag auras (they are positive, but they must be removed when you are immune)
4588 if( this->GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
4589 && this->GetSpellProto()->AttributesEx2 & SPELL_ATTR_EX2_DAMAGE_REDUCED_SHIELD )
4590 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
4592 // TODO: optimalize this cycle - use RemoveAurasWithInterruptFlags call or something else
4593 if( Real && apply
4594 && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
4595 && IsPositiveSpell(GetId()) ) //Only positive immunity removes auras
4597 uint32 school_mask = m_modifier.m_miscvalue;
4598 Unit::AuraMap& Auras = m_target->GetAuras();
4599 for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next)
4601 next = iter;
4602 ++next;
4603 SpellEntry const *spell = iter->second->GetSpellProto();
4604 if((GetSpellSchoolMask(spell) & school_mask)//Check for school mask
4605 && !( spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) //Spells unaffected by invulnerability
4606 && !iter->second->IsPositive() //Don't remove positive spells
4607 && spell->Id != GetId() ) //Don't remove self
4609 m_target->RemoveAurasDueToSpell(spell->Id);
4610 if(Auras.empty())
4611 break;
4612 else
4613 next = Auras.begin();
4617 if( Real && GetSpellProto()->Mechanic == MECHANIC_BANISH )
4619 if( apply )
4620 m_target->addUnitState(UNIT_STAT_ISOLATED);
4621 else
4622 m_target->clearUnitState(UNIT_STAT_ISOLATED);
4626 void Aura::HandleAuraModDmgImmunity(bool apply, bool /*Real*/)
4628 m_target->ApplySpellImmune(GetId(), IMMUNITY_DAMAGE, m_modifier.m_miscvalue, apply);
4631 void Aura::HandleAuraModDispelImmunity(bool apply, bool Real)
4633 // all applied/removed only at real aura add/remove
4634 if(!Real)
4635 return;
4637 m_target->ApplySpellDispelImmunity(m_spellProto, DispelType(m_modifier.m_miscvalue), apply);
4640 void Aura::HandleAuraProcTriggerSpell(bool apply, bool Real)
4642 if(!Real)
4643 return;
4645 if(apply)
4647 // some spell have charges by functionality not have its in spell data
4648 switch (GetId())
4650 case 28200: // Ascendance (Talisman of Ascendance trinket)
4651 SetAuraCharges(6);
4652 break;
4653 default: break;
4658 void Aura::HandleAuraModStalked(bool apply, bool /*Real*/)
4660 // used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND
4661 if(apply)
4662 m_target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT);
4663 else
4664 m_target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT);
4667 /*********************************************************/
4668 /*** PERIODIC ***/
4669 /*********************************************************/
4671 void Aura::HandlePeriodicTriggerSpell(bool apply, bool /*Real*/)
4673 m_isPeriodic = apply;
4675 if (!apply)
4677 switch(m_spellProto->Id)
4679 case 66: // Invisibility
4680 if (m_removeMode == AURA_REMOVE_BY_DEFAULT && m_duration<=0)
4681 m_target->CastSpell(m_target, 32612, true, NULL, this);
4683 return;
4684 case 42783: //Wrath of the Astrom...
4685 if (m_removeMode == AURA_REMOVE_BY_DEFAULT && GetEffIndex() + 1 < MAX_EFFECT_INDEX)
4686 m_target->CastSpell(m_target, m_spellProto->CalculateSimpleValue(SpellEffectIndex(GetEffIndex()+1)), true);
4687 return;
4688 case 51912: // Ultra-Advanced Proto-Typical Shortening Blaster
4689 if (m_removeMode == AURA_REMOVE_BY_DEFAULT && m_duration <= 0)
4691 if (Unit* pCaster = GetCaster())
4692 pCaster->CastSpell(m_target, m_spellProto->EffectTriggerSpell[GetEffIndex()], true, NULL, this);
4695 return;
4696 default:
4697 break;
4702 void Aura::HandlePeriodicTriggerSpellWithValue(bool apply, bool /*Real*/)
4704 m_isPeriodic = apply;
4707 void Aura::HandlePeriodicEnergize(bool apply, bool Real)
4709 if (!Real)
4710 return;
4712 // For prevent double apply bonuses
4713 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
4715 if (apply && !loading)
4717 switch (GetId())
4719 case 54833: // Glyph of Innervate (value%/2 of casters base mana)
4721 if (Unit* caster = GetCaster())
4722 m_modifier.m_amount = int32(caster->GetCreateMana() * GetBasePoints() / (200 * GetAuraMaxTicks()));
4723 break;
4726 case 29166: // Innervate (value% of casters base mana)
4728 if (Unit* caster = GetCaster())
4730 // Glyph of Innervate
4731 if (caster->HasAura(54832))
4732 caster->CastSpell(caster,54833,true,NULL,this);
4734 m_modifier.m_amount = int32(caster->GetCreateMana() * GetBasePoints() / (100 * GetAuraMaxTicks()));
4736 break;
4738 case 48391: // Owlkin Frenzy 2% base mana
4739 m_modifier.m_amount = m_target->GetCreateMana() * 2 / 100;
4740 break;
4741 case 57669: // Replenishment (0.2% from max)
4742 case 61782: // Infinite Replenishment
4743 m_modifier.m_amount = m_target->GetMaxPower(POWER_MANA) * 2 / 1000;
4744 break;
4745 default:
4746 break;
4750 m_isPeriodic = apply;
4753 void Aura::HandleAuraPowerBurn(bool apply, bool /*Real*/)
4755 m_isPeriodic = apply;
4758 void Aura::HandleAuraPeriodicDummy(bool apply, bool Real)
4760 // spells required only Real aura add/remove
4761 if(!Real)
4762 return;
4764 // For prevent double apply bonuses
4765 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
4767 SpellEntry const*spell = GetSpellProto();
4768 switch( spell->SpellFamilyName)
4770 case SPELLFAMILY_ROGUE:
4772 if(!apply)
4774 switch(spell->Id)
4776 // Master of Subtlety
4777 case 31666: m_target->RemoveAurasDueToSpell(31665); break;
4778 // Overkill
4779 case 58428: m_target->RemoveAurasDueToSpell(58427); break;
4782 break;
4784 case SPELLFAMILY_HUNTER:
4786 Unit* caster = GetCaster();
4788 // Explosive Shot
4789 if (apply && !loading && caster)
4790 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 14 / 100);
4791 break;
4795 m_isPeriodic = apply;
4798 void Aura::HandlePeriodicHeal(bool apply, bool /*Real*/)
4800 m_isPeriodic = apply;
4802 // For prevent double apply bonuses
4803 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
4805 // Custom damage calculation after
4806 if (apply)
4808 if(loading)
4809 return;
4811 Unit *caster = GetCaster();
4812 if (!caster)
4813 return;
4815 // Gift of the Naaru (have diff spellfamilies)
4816 if (m_spellProto->SpellIconID == 329 && m_spellProto->SpellVisual[0] == 7625)
4818 int32 ap = int32 (0.22f * caster->GetTotalAttackPowerValue(BASE_ATTACK));
4819 int32 holy = caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellProto));
4820 if (holy < 0)
4821 holy = 0;
4822 holy = int32(holy * 377 / 1000);
4823 m_modifier.m_amount += ap > holy ? ap : holy;
4826 m_modifier.m_amount = caster->SpellHealingBonusDone(m_target, GetSpellProto(), m_modifier.m_amount, DOT, GetStackAmount());
4830 void Aura::HandlePeriodicDamage(bool apply, bool Real)
4832 // spells required only Real aura add/remove
4833 if(!Real)
4834 return;
4836 m_isPeriodic = apply;
4838 // For prevent double apply bonuses
4839 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
4841 // Custom damage calculation after
4842 if (apply)
4844 if(loading)
4845 return;
4847 Unit *caster = GetCaster();
4848 if (!caster)
4849 return;
4851 switch (m_spellProto->SpellFamilyName)
4853 case SPELLFAMILY_GENERIC:
4855 // Pounce Bleed
4856 if ( m_spellProto->SpellIconID == 147 && m_spellProto->SpellVisual[0] == 0 )
4857 // $AP*0.18/6 bonus per tick
4858 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 3 / 100);
4859 break;
4861 case SPELLFAMILY_WARRIOR:
4863 // Rend
4864 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000020))
4866 // $0.2*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick
4867 float ap = caster->GetTotalAttackPowerValue(BASE_ATTACK);
4868 int32 mws = caster->GetAttackTime(BASE_ATTACK);
4869 float mwb_min = caster->GetWeaponDamageRange(BASE_ATTACK,MINDAMAGE);
4870 float mwb_max = caster->GetWeaponDamageRange(BASE_ATTACK,MAXDAMAGE);
4871 m_modifier.m_amount+=int32(((mwb_min+mwb_max)/2+ap*mws/14000)*0.2f);
4872 // If used while target is above 75% health, Rend does 35% more damage
4873 if (m_spellProto->CalculateSimpleValue(EFFECT_INDEX_1) !=0 &&
4874 m_target->GetHealth() > m_target->GetMaxHealth() * m_spellProto->CalculateSimpleValue(EFFECT_INDEX_1) / 100)
4875 m_modifier.m_amount += m_modifier.m_amount * m_spellProto->CalculateSimpleValue(EFFECT_INDEX_2) / 100;
4877 break;
4879 case SPELLFAMILY_DRUID:
4881 // Rake
4882 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000001000) && m_spellProto->Effect[EFFECT_INDEX_2] == SPELL_EFFECT_ADD_COMBO_POINTS)
4883 // $AP*0.18/3 bonus per tick
4884 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 6 / 100);
4885 // Lacerate
4886 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x000000010000000000))
4887 // $AP*0.05/5 bonus per tick
4888 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100);
4889 // Rip
4890 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x000000000000800000))
4892 // 0.01*$AP*cp
4893 if (caster->GetTypeId() != TYPEID_PLAYER)
4894 break;
4896 uint8 cp = ((Player*)caster)->GetComboPoints();
4898 // Idol of Feral Shadows. Cant be handled as SpellMod in SpellAura:Dummy due its dependency from CPs
4899 Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY);
4900 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
4902 if((*itr)->GetId()==34241)
4904 m_modifier.m_amount += cp * (*itr)->GetModifier()->m_amount;
4905 break;
4908 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * cp / 100);
4910 // Lock Jaw
4911 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x1000000000000000))
4912 // 0.15*$AP
4913 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 15 / 100);
4914 break;
4916 case SPELLFAMILY_ROGUE:
4918 // Rupture
4919 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x000000000000100000))
4921 if (caster->GetTypeId() != TYPEID_PLAYER)
4922 break;
4923 //1 point : ${($m1+$b1*1+0.015*$AP)*4} damage over 8 secs
4924 //2 points: ${($m1+$b1*2+0.024*$AP)*5} damage over 10 secs
4925 //3 points: ${($m1+$b1*3+0.03*$AP)*6} damage over 12 secs
4926 //4 points: ${($m1+$b1*4+0.03428571*$AP)*7} damage over 14 secs
4927 //5 points: ${($m1+$b1*5+0.0375*$AP)*8} damage over 16 secs
4928 float AP_per_combo[6] = {0.0f, 0.015f, 0.024f, 0.03f, 0.03428571f, 0.0375f};
4929 uint8 cp = ((Player*)caster)->GetComboPoints();
4930 if (cp > 5) cp = 5;
4931 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * AP_per_combo[cp]);
4933 // Garrote
4934 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x000000000000000100))
4935 // $AP*0.07 bonus per tick
4936 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 7 / 100);
4937 // Deadly Poison
4938 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000010000))
4939 // 0.12*$AP / 4 * amount of stack
4940 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 3 * GetStackAmount() / 100);
4941 break;
4943 case SPELLFAMILY_HUNTER:
4945 // Serpent Sting
4946 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000004000))
4947 // $RAP*0.2/5 bonus per tick
4948 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.2 / 5);
4949 // Immolation Trap
4950 if ((m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000004)) && m_spellProto->SpellIconID == 678)
4951 // $RAP*0.1/5 bonus per tick
4952 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 10 / 500);
4953 break;
4955 case SPELLFAMILY_PALADIN:
4957 // Holy Vengeance / Blood Corruption
4958 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000080000000000) && m_spellProto->SpellVisual[0] == 7902)
4960 // AP * 0.025 + SPH * 0.013 bonus per tick
4961 float ap = caster->GetTotalAttackPowerValue(BASE_ATTACK);
4962 int32 holy = caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellProto));
4963 if (holy < 0)
4964 holy = 0;
4965 m_modifier.m_amount += int32(GetStackAmount()) * (int32(ap * 0.025f) + int32(holy * 13 / 1000));
4967 break;
4969 default:
4970 break;
4973 if(m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE)
4975 // SpellDamageBonusDone for magic spells
4976 if(GetSpellProto()->DmgClass == SPELL_DAMAGE_CLASS_NONE || GetSpellProto()->DmgClass == SPELL_DAMAGE_CLASS_MAGIC)
4977 m_modifier.m_amount = caster->SpellDamageBonusDone(m_target, GetSpellProto(), m_modifier.m_amount, DOT, GetStackAmount());
4978 // MeleeDamagebonusDone for weapon based spells
4979 else
4981 WeaponAttackType attackType = GetWeaponAttackType(GetSpellProto());
4982 m_modifier.m_amount = caster->MeleeDamageBonusDone(m_target, m_modifier.m_amount, attackType, GetSpellProto(), DOT, GetStackAmount());
4986 // remove time effects
4987 else
4989 // Parasitic Shadowfiend - handle summoning of two Shadowfiends on DoT expire
4990 if(m_spellProto->Id == 41917)
4991 m_target->CastSpell(m_target, 41915, true);
4995 void Aura::HandlePeriodicDamagePCT(bool apply, bool /*Real*/)
4997 m_isPeriodic = apply;
5000 void Aura::HandlePeriodicLeech(bool apply, bool /*Real*/)
5002 m_isPeriodic = apply;
5004 // For prevent double apply bonuses
5005 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
5007 // Custom damage calculation after
5008 if (apply)
5010 if(loading)
5011 return;
5013 Unit *caster = GetCaster();
5014 if (!caster)
5015 return;
5017 m_modifier.m_amount = caster->SpellDamageBonusDone(m_target, GetSpellProto(), m_modifier.m_amount, DOT, GetStackAmount());
5021 void Aura::HandlePeriodicManaLeech(bool apply, bool /*Real*/)
5023 m_isPeriodic = apply;
5026 void Aura::HandlePeriodicHealthFunnel(bool apply, bool /*Real*/)
5028 m_isPeriodic = apply;
5030 // For prevent double apply bonuses
5031 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
5033 // Custom damage calculation after
5034 if (apply)
5036 if(loading)
5037 return;
5039 Unit *caster = GetCaster();
5040 if (!caster)
5041 return;
5043 m_modifier.m_amount = caster->SpellDamageBonusDone(m_target, GetSpellProto(), m_modifier.m_amount, DOT, GetStackAmount());
5047 /*********************************************************/
5048 /*** MODIFY STATS ***/
5049 /*********************************************************/
5051 /********************************/
5052 /*** RESISTANCE ***/
5053 /********************************/
5055 void Aura::HandleAuraModResistanceExclusive(bool apply, bool /*Real*/)
5057 for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++)
5059 if(m_modifier.m_miscvalue & int32(1<<x))
5061 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_VALUE, float(m_modifier.m_amount), apply);
5062 if(m_target->GetTypeId() == TYPEID_PLAYER)
5063 m_target->ApplyResistanceBuffModsMod(SpellSchools(x), m_positive, float(m_modifier.m_amount), apply);
5068 void Aura::HandleAuraModResistance(bool apply, bool /*Real*/)
5070 for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++)
5072 if(m_modifier.m_miscvalue & int32(1<<x))
5074 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), TOTAL_VALUE, float(m_modifier.m_amount), apply);
5075 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
5076 m_target->ApplyResistanceBuffModsMod(SpellSchools(x), m_positive, float(m_modifier.m_amount), apply);
5081 void Aura::HandleAuraModBaseResistancePCT(bool apply, bool /*Real*/)
5083 // only players have base stats
5084 if(m_target->GetTypeId() != TYPEID_PLAYER)
5086 //pets only have base armor
5087 if(((Creature*)m_target)->isPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL))
5088 m_target->HandleStatModifier(UNIT_MOD_ARMOR, BASE_PCT, float(m_modifier.m_amount), apply);
5090 else
5092 for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++)
5094 if(m_modifier.m_miscvalue & int32(1<<x))
5095 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_PCT, float(m_modifier.m_amount), apply);
5100 void Aura::HandleModResistancePercent(bool apply, bool /*Real*/)
5102 for(int8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++)
5104 if(m_modifier.m_miscvalue & int32(1<<i))
5106 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply);
5107 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
5109 m_target->ApplyResistanceBuffModsPercentMod(SpellSchools(i), true, float(m_modifier.m_amount), apply);
5110 m_target->ApplyResistanceBuffModsPercentMod(SpellSchools(i), false, float(m_modifier.m_amount), apply);
5116 void Aura::HandleModBaseResistance(bool apply, bool /*Real*/)
5118 // only players have base stats
5119 if(m_target->GetTypeId() != TYPEID_PLAYER)
5121 //only pets have base stats
5122 if(((Creature*)m_target)->isPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL))
5123 m_target->HandleStatModifier(UNIT_MOD_ARMOR, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5125 else
5127 for(int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++)
5128 if(m_modifier.m_miscvalue & (1<<i))
5129 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply);
5133 /********************************/
5134 /*** STAT ***/
5135 /********************************/
5137 void Aura::HandleAuraModStat(bool apply, bool /*Real*/)
5139 if (m_modifier.m_miscvalue < -2 || m_modifier.m_miscvalue > 4)
5141 sLog.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ",GetId(),GetEffIndex(),m_modifier.m_miscvalue);
5142 return;
5145 for(int32 i = STAT_STRENGTH; i < MAX_STATS; i++)
5147 // -1 or -2 is all stats ( misc < -2 checked in function beginning )
5148 if (m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue == i)
5150 //m_target->ApplyStatMod(Stats(i), m_modifier.m_amount,apply);
5151 m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply);
5152 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
5153 m_target->ApplyStatBuffMod(Stats(i), float(m_modifier.m_amount), apply);
5158 void Aura::HandleModPercentStat(bool apply, bool /*Real*/)
5160 if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4)
5162 sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
5163 return;
5166 // only players have base stats
5167 if (m_target->GetTypeId() != TYPEID_PLAYER)
5168 return;
5170 for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i)
5172 if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1)
5173 m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), BASE_PCT, float(m_modifier.m_amount), apply);
5177 void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool /*Real*/)
5179 if(m_target->GetTypeId() != TYPEID_PLAYER)
5180 return;
5182 // Magic damage modifiers implemented in Unit::SpellDamageBonusDone
5183 // This information for client side use only
5184 // Recalculate bonus
5185 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
5188 void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool /*Real*/)
5190 if(m_target->GetTypeId() != TYPEID_PLAYER)
5191 return;
5193 // Recalculate bonus
5194 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
5197 void Aura::HandleAuraModDispelResist(bool apply, bool Real)
5199 if(!Real || !apply)
5200 return;
5202 if(GetId() == 33206)
5203 m_target->CastSpell(m_target, 44416, true, NULL, this, GetCasterGUID());
5206 void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool /*Real*/)
5208 if(m_target->GetTypeId() != TYPEID_PLAYER)
5209 return;
5211 // Magic damage modifiers implemented in Unit::SpellDamageBonusDone
5212 // This information for client side use only
5213 // Recalculate bonus
5214 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
5217 void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool /*Real*/)
5219 if(m_target->GetTypeId() != TYPEID_PLAYER)
5220 return;
5222 // Recalculate bonus
5223 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
5226 void Aura::HandleModHealingDone(bool /*apply*/, bool /*Real*/)
5228 if(m_target->GetTypeId() != TYPEID_PLAYER)
5229 return;
5230 // implemented in Unit::SpellHealingBonusDone
5231 // this information is for client side only
5232 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
5235 void Aura::HandleModTotalPercentStat(bool apply, bool /*Real*/)
5237 if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4)
5239 sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
5240 return;
5243 //save current and max HP before applying aura
5244 uint32 curHPValue = m_target->GetHealth();
5245 uint32 maxHPValue = m_target->GetMaxHealth();
5247 for (int32 i = STAT_STRENGTH; i < MAX_STATS; i++)
5249 if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1)
5251 m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply);
5252 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
5253 m_target->ApplyStatPercentBuffMod(Stats(i), float(m_modifier.m_amount), apply );
5257 //recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag)
5258 if ((m_modifier.m_miscvalue == STAT_STAMINA) && (maxHPValue > 0) && (m_spellProto->Attributes & 0x10))
5260 // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed
5261 uint32 newHPValue = (m_target->GetMaxHealth() * curHPValue) / maxHPValue;
5262 m_target->SetHealth(newHPValue);
5266 void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool /*Real*/)
5268 if(m_target->GetTypeId() != TYPEID_PLAYER)
5269 return;
5271 if(m_modifier.m_miscvalue != SPELL_SCHOOL_MASK_NORMAL)
5273 // support required adding replace UpdateArmor by loop by UpdateResistence at intellect update
5274 // and include in UpdateResistence same code as in UpdateArmor for aura mod apply.
5275 sLog.outError("Aura SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT(182) need adding support for non-armor resistances!");
5276 return;
5279 // Recalculate Armor
5280 m_target->UpdateArmor();
5283 /********************************/
5284 /*** HEAL & ENERGIZE ***/
5285 /********************************/
5286 void Aura::HandleAuraModTotalHealthPercentRegen(bool apply, bool /*Real*/)
5288 m_isPeriodic = apply;
5291 void Aura::HandleAuraModTotalManaPercentRegen(bool apply, bool /*Real*/)
5293 if(m_modifier.periodictime == 0)
5294 m_modifier.periodictime = 1000;
5296 m_periodicTimer = m_modifier.periodictime;
5297 m_isPeriodic = apply;
5300 void Aura::HandleModRegen(bool apply, bool /*Real*/) // eating
5302 if(m_modifier.periodictime == 0)
5303 m_modifier.periodictime = 5000;
5305 m_periodicTimer = 5000;
5306 m_isPeriodic = apply;
5309 void Aura::HandleModPowerRegen(bool apply, bool Real) // drinking
5311 if (!Real)
5312 return;
5314 Powers pt = m_target->getPowerType();
5315 if(m_modifier.periodictime == 0)
5317 // Anger Management (only spell use this aura for rage)
5318 if (pt == POWER_RAGE)
5319 m_modifier.periodictime = 3000;
5320 else
5321 m_modifier.periodictime = 2000;
5324 m_periodicTimer = 5000;
5326 if (m_target->GetTypeId() == TYPEID_PLAYER && m_modifier.m_miscvalue == POWER_MANA)
5327 ((Player*)m_target)->UpdateManaRegen();
5329 m_isPeriodic = apply;
5332 void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real)
5334 // spells required only Real aura add/remove
5335 if(!Real)
5336 return;
5338 if (m_target->GetTypeId() != TYPEID_PLAYER)
5339 return;
5341 // Update manaregen value
5342 if (m_modifier.m_miscvalue == POWER_MANA)
5343 ((Player*)m_target)->UpdateManaRegen();
5346 void Aura::HandleModManaRegen(bool /*apply*/, bool Real)
5348 // spells required only Real aura add/remove
5349 if(!Real)
5350 return;
5352 if (m_target->GetTypeId() != TYPEID_PLAYER)
5353 return;
5355 //Note: an increase in regen does NOT cause threat.
5356 ((Player*)m_target)->UpdateManaRegen();
5359 void Aura::HandleComprehendLanguage(bool apply, bool /*Real*/)
5361 if(apply)
5362 m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG);
5363 else
5364 m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG);
5367 void Aura::HandleAuraModIncreaseHealth(bool apply, bool Real)
5369 // Special case with temporary increase max/current health
5370 switch(GetId())
5372 case 12976: // Warrior Last Stand triggered spell
5373 case 28726: // Nightmare Seed ( Nightmare Seed )
5374 case 34511: // Valor (Bulwark of Kings, Bulwark of the Ancient Kings)
5375 case 44055: case 55915: case 55917: case 67596: // Tremendous Fortitude (Battlemaster's Alacrity)
5376 case 50322: // Survival Instincts
5377 case 54443: // Demonic Empowerment (Voidwalker)
5378 case 55233: // Vampiric Blood
5379 case 59465: // Brood Rage (Ahn'Kahet)
5381 if(Real)
5383 if(apply)
5385 // Demonic Empowerment (Voidwalker) & Vampiric Blood - special cases, store percent in data
5386 // recalculate to full amount at apply for proper remove
5387 if (GetId() == 54443 || GetId() == 55233)
5388 m_modifier.m_amount = m_target->GetMaxHealth() * m_modifier.m_amount / 100;
5390 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5391 m_target->ModifyHealth(m_modifier.m_amount);
5393 else
5395 if (int32(m_target->GetHealth()) > m_modifier.m_amount)
5396 m_target->ModifyHealth(-m_modifier.m_amount);
5397 else
5398 m_target->SetHealth(1);
5399 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5402 return;
5406 // generic case
5407 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5410 void Aura::HandleAuraModIncreaseMaxHealth(bool apply, bool /*Real*/)
5412 uint32 oldhealth = m_target->GetHealth();
5413 double healthPercentage = (double)oldhealth / (double)m_target->GetMaxHealth();
5415 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5417 // refresh percentage
5418 if(oldhealth > 0)
5420 uint32 newhealth = uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage));
5421 if(newhealth==0)
5422 newhealth = 1;
5424 m_target->SetHealth(newhealth);
5428 void Aura::HandleAuraModIncreaseEnergy(bool apply, bool Real)
5430 Powers powerType = m_target->getPowerType();
5431 if(int32(powerType) != m_modifier.m_miscvalue)
5432 return;
5434 UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType);
5436 // Special case with temporary increase max/current power (percent)
5437 if (GetId()==64904) // Hymn of Hope
5439 if(Real)
5441 uint32 val = m_target->GetPower(powerType);
5442 m_target->HandleStatModifier(unitMod, TOTAL_PCT, float(m_modifier.m_amount), apply);
5443 m_target->SetPower(powerType, apply ? val*(100+m_modifier.m_amount)/100 : val*100/(100+m_modifier.m_amount));
5445 return;
5448 // generic flat case
5449 m_target->HandleStatModifier(unitMod, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5452 void Aura::HandleAuraModIncreaseEnergyPercent(bool apply, bool /*Real*/)
5454 Powers powerType = m_target->getPowerType();
5455 if(int32(powerType) != m_modifier.m_miscvalue)
5456 return;
5458 UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType);
5460 m_target->HandleStatModifier(unitMod, TOTAL_PCT, float(m_modifier.m_amount), apply);
5463 void Aura::HandleAuraModIncreaseHealthPercent(bool apply, bool /*Real*/)
5465 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_PCT, float(m_modifier.m_amount), apply);
5468 void Aura::HandleAuraIncreaseBaseHealthPercent(bool apply, bool /*Real*/)
5470 m_target->HandleStatModifier(UNIT_MOD_HEALTH, BASE_PCT, float(m_modifier.m_amount), apply);
5473 /********************************/
5474 /*** FIGHT ***/
5475 /********************************/
5477 void Aura::HandleAuraModParryPercent(bool /*apply*/, bool /*Real*/)
5479 if(m_target->GetTypeId() != TYPEID_PLAYER)
5480 return;
5482 ((Player*)m_target)->UpdateParryPercentage();
5485 void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool /*Real*/)
5487 if(m_target->GetTypeId() != TYPEID_PLAYER)
5488 return;
5490 ((Player*)m_target)->UpdateDodgePercentage();
5491 //sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount));
5494 void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool /*Real*/)
5496 if(m_target->GetTypeId() != TYPEID_PLAYER)
5497 return;
5499 ((Player*)m_target)->UpdateBlockPercentage();
5500 //sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount));
5503 void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real)
5505 // spells required only Real aura add/remove
5506 if(!Real)
5507 return;
5509 if(m_target->GetTypeId() != TYPEID_PLAYER)
5510 return;
5512 ((Player*)m_target)->UpdateManaRegen();
5515 void Aura::HandleAuraModCritPercent(bool apply, bool Real)
5517 if(m_target->GetTypeId() != TYPEID_PLAYER)
5518 return;
5520 // apply item specific bonuses for already equipped weapon
5521 if(Real)
5523 for(int i = 0; i < MAX_ATTACK; ++i)
5524 if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i),true,false))
5525 ((Player*)m_target)->_ApplyWeaponDependentAuraCritMod(pItem, WeaponAttackType(i), this, apply);
5528 // mods must be applied base at equipped weapon class and subclass comparison
5529 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5530 // m_modifier.m_miscvalue comparison with item generated damage types
5532 if (GetSpellProto()->EquippedItemClass == -1)
5534 ((Player*)m_target)->HandleBaseModValue(CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
5535 ((Player*)m_target)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
5536 ((Player*)m_target)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
5538 else
5540 // done in Player::_ApplyWeaponDependentAuraMods
5544 void Aura::HandleModHitChance(bool apply, bool /*Real*/)
5546 if(m_target->GetTypeId() == TYPEID_PLAYER)
5548 ((Player*)m_target)->UpdateMeleeHitChances();
5549 ((Player*)m_target)->UpdateRangedHitChances();
5551 else
5553 m_target->m_modMeleeHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount);
5554 m_target->m_modRangedHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount);
5558 void Aura::HandleModSpellHitChance(bool apply, bool /*Real*/)
5560 if(m_target->GetTypeId() == TYPEID_PLAYER)
5562 ((Player*)m_target)->UpdateSpellHitChances();
5564 else
5566 m_target->m_modSpellHitChance += apply ? m_modifier.m_amount: (-m_modifier.m_amount);
5570 void Aura::HandleModSpellCritChance(bool apply, bool Real)
5572 // spells required only Real aura add/remove
5573 if(!Real)
5574 return;
5576 if(m_target->GetTypeId() == TYPEID_PLAYER)
5578 ((Player*)m_target)->UpdateAllSpellCritChances();
5580 else
5582 m_target->m_baseSpellCritChance += apply ? m_modifier.m_amount:(-m_modifier.m_amount);
5586 void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real)
5588 // spells required only Real aura add/remove
5589 if(!Real)
5590 return;
5592 if(m_target->GetTypeId() != TYPEID_PLAYER)
5593 return;
5595 for(int school = SPELL_SCHOOL_NORMAL; school < MAX_SPELL_SCHOOL; ++school)
5596 if (m_modifier.m_miscvalue & (1<<school))
5597 ((Player*)m_target)->UpdateSpellCritChance(school);
5600 /********************************/
5601 /*** ATTACK SPEED ***/
5602 /********************************/
5604 void Aura::HandleModCastingSpeed(bool apply, bool /*Real*/)
5606 m_target->ApplyCastTimePercentMod(float(m_modifier.m_amount),apply);
5609 void Aura::HandleModMeleeRangedSpeedPct(bool apply, bool /*Real*/)
5611 m_target->ApplyAttackTimePercentMod(BASE_ATTACK, float(m_modifier.m_amount), apply);
5612 m_target->ApplyAttackTimePercentMod(OFF_ATTACK, float(m_modifier.m_amount), apply);
5613 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, float(m_modifier.m_amount), apply);
5616 void Aura::HandleModCombatSpeedPct(bool apply, bool /*Real*/)
5618 m_target->ApplyCastTimePercentMod(float(m_modifier.m_amount), apply);
5619 m_target->ApplyAttackTimePercentMod(BASE_ATTACK, float(m_modifier.m_amount), apply);
5620 m_target->ApplyAttackTimePercentMod(OFF_ATTACK, float(m_modifier.m_amount), apply);
5621 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, float(m_modifier.m_amount), apply);
5624 void Aura::HandleModAttackSpeed(bool apply, bool /*Real*/)
5626 m_target->ApplyAttackTimePercentMod(BASE_ATTACK,float(m_modifier.m_amount),apply);
5629 void Aura::HandleHaste(bool apply, bool /*Real*/)
5631 m_target->ApplyAttackTimePercentMod(BASE_ATTACK, float(m_modifier.m_amount), apply);
5632 m_target->ApplyAttackTimePercentMod(OFF_ATTACK, float(m_modifier.m_amount), apply);
5633 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, float(m_modifier.m_amount), apply);
5636 void Aura::HandleAuraModRangedHaste(bool apply, bool /*Real*/)
5638 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, float(m_modifier.m_amount), apply);
5641 void Aura::HandleRangedAmmoHaste(bool apply, bool /*Real*/)
5643 if(m_target->GetTypeId() != TYPEID_PLAYER)
5644 return;
5645 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, float(m_modifier.m_amount), apply);
5648 /********************************/
5649 /*** ATTACK POWER ***/
5650 /********************************/
5652 void Aura::HandleAuraModAttackPower(bool apply, bool /*Real*/)
5654 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5657 void Aura::HandleAuraModRangedAttackPower(bool apply, bool /*Real*/)
5659 if((m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0)
5660 return;
5662 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5665 void Aura::HandleAuraModAttackPowerPercent(bool apply, bool /*Real*/)
5667 //UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1
5668 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_PCT, float(m_modifier.m_amount), apply);
5671 void Aura::HandleAuraModRangedAttackPowerPercent(bool apply, bool /*Real*/)
5673 if((m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0)
5674 return;
5676 //UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1
5677 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply);
5680 void Aura::HandleAuraModRangedAttackPowerOfStatPercent(bool /*apply*/, bool Real)
5682 // spells required only Real aura add/remove
5683 if(!Real)
5684 return;
5686 // Recalculate bonus
5687 if(m_target->GetTypeId() == TYPEID_PLAYER && !(m_target->getClassMask() & CLASSMASK_WAND_USERS))
5688 ((Player*)m_target)->UpdateAttackPowerAndDamage(true);
5691 void Aura::HandleAuraModAttackPowerOfStatPercent(bool /*apply*/, bool Real)
5693 // spells required only Real aura add/remove
5694 if(!Real)
5695 return;
5697 // Recalculate bonus
5698 if(m_target->GetTypeId() == TYPEID_PLAYER)
5699 ((Player*)m_target)->UpdateAttackPowerAndDamage(false);
5702 void Aura::HandleAuraModAttackPowerOfArmor(bool /*apply*/, bool Real)
5704 // spells required only Real aura add/remove
5705 if(!Real)
5706 return;
5708 // Recalculate bonus
5709 if(m_target->GetTypeId() == TYPEID_PLAYER)
5710 ((Player*)m_target)->UpdateAttackPowerAndDamage(false);
5712 /********************************/
5713 /*** DAMAGE BONUS ***/
5714 /********************************/
5715 void Aura::HandleModDamageDone(bool apply, bool Real)
5717 // apply item specific bonuses for already equipped weapon
5718 if(Real && m_target->GetTypeId() == TYPEID_PLAYER)
5720 for(int i = 0; i < MAX_ATTACK; ++i)
5721 if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i),true,false))
5722 ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem, WeaponAttackType(i), this, apply);
5725 // m_modifier.m_miscvalue is bitmask of spell schools
5726 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5727 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wands
5728 // 127 - full bitmask any damages
5730 // mods must be applied base at equipped weapon class and subclass comparison
5731 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5732 // m_modifier.m_miscvalue comparison with item generated damage types
5734 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0)
5736 // apply generic physical damage bonuses including wand case
5737 if (GetSpellProto()->EquippedItemClass == -1 || m_target->GetTypeId() != TYPEID_PLAYER)
5739 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5740 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5741 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5743 else
5745 // done in Player::_ApplyWeaponDependentAuraMods
5748 if(m_target->GetTypeId() == TYPEID_PLAYER)
5750 if(m_positive)
5751 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS, m_modifier.m_amount, apply);
5752 else
5753 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG, m_modifier.m_amount, apply);
5757 // Skip non magic case for speedup
5758 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0)
5759 return;
5761 if( GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0 )
5763 // wand magic case (skip generic to all item spell bonuses)
5764 // done in Player::_ApplyWeaponDependentAuraMods
5766 // Skip item specific requirements for not wand magic damage
5767 return;
5770 // Magic damage modifiers implemented in Unit::SpellDamageBonusDone
5771 // This information for client side use only
5772 if(m_target->GetTypeId() == TYPEID_PLAYER)
5774 if(m_positive)
5776 for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
5778 if((m_modifier.m_miscvalue & (1<<i)) != 0)
5779 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, m_modifier.m_amount, apply);
5782 else
5784 for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
5786 if((m_modifier.m_miscvalue & (1<<i)) != 0)
5787 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i, m_modifier.m_amount, apply);
5790 Pet* pet = m_target->GetPet();
5791 if(pet)
5792 pet->UpdateAttackPowerAndDamage();
5796 void Aura::HandleModDamagePercentDone(bool apply, bool Real)
5798 DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "AURA MOD DAMAGE type:%u negative:%u", m_modifier.m_miscvalue, m_positive ? 0 : 1);
5800 // apply item specific bonuses for already equipped weapon
5801 if(Real && m_target->GetTypeId() == TYPEID_PLAYER)
5803 for(int i = 0; i < MAX_ATTACK; ++i)
5804 if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i),true,false))
5805 ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem, WeaponAttackType(i), this, apply);
5808 // m_modifier.m_miscvalue is bitmask of spell schools
5809 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5810 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wand
5811 // 127 - full bitmask any damages
5813 // mods must be applied base at equipped weapon class and subclass comparison
5814 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5815 // m_modifier.m_miscvalue comparison with item generated damage types
5817 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0)
5819 // apply generic physical damage bonuses including wand case
5820 if (GetSpellProto()->EquippedItemClass == -1 || m_target->GetTypeId() != TYPEID_PLAYER)
5822 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT, float(m_modifier.m_amount), apply);
5823 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply);
5824 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply);
5826 else
5828 // done in Player::_ApplyWeaponDependentAuraMods
5830 // For show in client
5831 if(m_target->GetTypeId() == TYPEID_PLAYER)
5832 m_target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT, m_modifier.m_amount/100.0f, apply);
5835 // Skip non magic case for speedup
5836 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0)
5837 return;
5839 if( GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0 )
5841 // wand magic case (skip generic to all item spell bonuses)
5842 // done in Player::_ApplyWeaponDependentAuraMods
5844 // Skip item specific requirements for not wand magic damage
5845 return;
5848 // Magic damage percent modifiers implemented in Unit::SpellDamageBonusDone
5849 // Send info to client
5850 if(m_target->GetTypeId() == TYPEID_PLAYER)
5851 for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
5852 m_target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i, m_modifier.m_amount/100.0f, apply);
5855 void Aura::HandleModOffhandDamagePercent(bool apply, bool Real)
5857 // spells required only Real aura add/remove
5858 if(!Real)
5859 return;
5861 DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "AURA MOD OFFHAND DAMAGE");
5863 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply);
5866 /********************************/
5867 /*** POWER COST ***/
5868 /********************************/
5870 void Aura::HandleModPowerCostPCT(bool apply, bool Real)
5872 // spells required only Real aura add/remove
5873 if(!Real)
5874 return;
5876 float amount = m_modifier.m_amount/100.0f;
5877 for(int i = 0; i < MAX_SPELL_SCHOOL; ++i)
5878 if(m_modifier.m_miscvalue & (1<<i))
5879 m_target->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER + i, amount, apply);
5882 void Aura::HandleModPowerCost(bool apply, bool Real)
5884 // spells required only Real aura add/remove
5885 if(!Real)
5886 return;
5888 for(int i = 0; i < MAX_SPELL_SCHOOL; ++i)
5889 if(m_modifier.m_miscvalue & (1<<i))
5890 m_target->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER + i, m_modifier.m_amount, apply);
5893 void Aura::HandleNoReagentUseAura(bool /*Apply*/, bool Real)
5895 // spells required only Real aura add/remove
5896 if(!Real)
5897 return;
5898 if(m_target->GetTypeId() != TYPEID_PLAYER)
5899 return;
5900 uint32 mask[3] = {0, 0, 0};
5901 Unit::AuraList const& noReagent = m_target->GetAurasByType(SPELL_AURA_NO_REAGENT_USE);
5902 for(Unit::AuraList::const_iterator i = noReagent.begin(); i != noReagent.end(); ++i)
5904 uint32 const *ptr = (*i)->getAuraSpellClassMask();
5905 mask[0] |= ptr[0];
5906 mask[1] |= ptr[1];
5907 mask[2] |= ptr[2];
5910 m_target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1+0, mask[0]);
5911 m_target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1+1, mask[1]);
5912 m_target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1+2, mask[2]);
5915 /*********************************************************/
5916 /*** OTHERS ***/
5917 /*********************************************************/
5919 void Aura::HandleShapeshiftBoosts(bool apply)
5921 uint32 spellId1 = 0;
5922 uint32 spellId2 = 0;
5923 uint32 HotWSpellId = 0;
5924 uint32 MasterShaperSpellId = 0;
5926 uint32 form = GetModifier()->m_miscvalue;
5928 switch(form)
5930 case FORM_CAT:
5931 spellId1 = 3025;
5932 HotWSpellId = 24900;
5933 MasterShaperSpellId = 48420;
5934 break;
5935 case FORM_TREE:
5936 spellId1 = 5420;
5937 spellId2 = 34123;
5938 MasterShaperSpellId = 48422;
5939 break;
5940 case FORM_TRAVEL:
5941 spellId1 = 5419;
5942 break;
5943 case FORM_AQUA:
5944 spellId1 = 5421;
5945 break;
5946 case FORM_BEAR:
5947 spellId1 = 1178;
5948 spellId2 = 21178;
5949 HotWSpellId = 24899;
5950 MasterShaperSpellId = 48418;
5951 break;
5952 case FORM_DIREBEAR:
5953 spellId1 = 9635;
5954 spellId2 = 21178;
5955 HotWSpellId = 24899;
5956 MasterShaperSpellId = 48418;
5957 break;
5958 case FORM_BATTLESTANCE:
5959 spellId1 = 21156;
5960 break;
5961 case FORM_DEFENSIVESTANCE:
5962 spellId1 = 7376;
5963 break;
5964 case FORM_BERSERKERSTANCE:
5965 spellId1 = 7381;
5966 break;
5967 case FORM_MOONKIN:
5968 spellId1 = 24905;
5969 MasterShaperSpellId = 48421;
5970 break;
5971 case FORM_FLIGHT:
5972 spellId1 = 33948;
5973 spellId2 = 34764;
5974 break;
5975 case FORM_FLIGHT_EPIC:
5976 spellId1 = 40122;
5977 spellId2 = 40121;
5978 break;
5979 case FORM_METAMORPHOSIS:
5980 spellId1 = 54817;
5981 spellId2 = 54879;
5982 break;
5983 case FORM_SPIRITOFREDEMPTION:
5984 spellId1 = 27792;
5985 spellId2 = 27795; // must be second, this important at aura remove to prevent to early iterator invalidation.
5986 break;
5987 case FORM_SHADOW:
5988 spellId1 = 49868;
5990 if(m_target->GetTypeId() == TYPEID_PLAYER) // Spell 49868 have same category as main form spell and share cooldown
5991 ((Player*)m_target)->RemoveSpellCooldown(49868);
5992 break;
5993 case FORM_GHOSTWOLF:
5994 spellId1 = 67116;
5995 break;
5996 case FORM_AMBIENT:
5997 case FORM_GHOUL:
5998 case FORM_STEALTH:
5999 case FORM_CREATURECAT:
6000 case FORM_CREATUREBEAR:
6001 break;
6004 if(apply)
6006 if (spellId1)
6007 m_target->CastSpell(m_target, spellId1, true, NULL, this );
6008 if (spellId2)
6009 m_target->CastSpell(m_target, spellId2, true, NULL, this);
6011 if (m_target->GetTypeId() == TYPEID_PLAYER)
6013 const PlayerSpellMap& sp_list = ((Player *)m_target)->GetSpellMap();
6014 for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
6016 if (itr->second.state == PLAYERSPELL_REMOVED) continue;
6017 if (itr->first==spellId1 || itr->first==spellId2) continue;
6018 SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
6019 if (!spellInfo || !(spellInfo->Attributes & (SPELL_ATTR_PASSIVE | (1<<7))))
6020 continue;
6021 if (spellInfo->Stances & (1<<(form-1)))
6022 m_target->CastSpell(m_target, itr->first, true, NULL, this);
6025 // Master Shapeshifter
6026 if (MasterShaperSpellId)
6028 Unit::AuraList const& ShapeShifterAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
6029 for(Unit::AuraList::const_iterator i = ShapeShifterAuras.begin(); i != ShapeShifterAuras.end(); i++)
6031 if ((*i)->GetSpellProto()->SpellIconID == 2851)
6033 int32 ShiftMod = (*i)->GetModifier()->m_amount;
6034 m_target->CastCustomSpell(m_target, MasterShaperSpellId, &ShiftMod, NULL, NULL, true);
6035 break;
6040 // Leader of the Pack
6041 if (((Player*)m_target)->HasSpell(17007))
6043 SpellEntry const *spellInfo = sSpellStore.LookupEntry(24932);
6044 if (spellInfo && spellInfo->Stances & (1<<(form-1)))
6045 m_target->CastSpell(m_target, 24932, true, NULL, this);
6048 // Savage Roar
6049 if (form == FORM_CAT && ((Player*)m_target)->HasAura(52610))
6050 m_target->CastSpell(m_target, 62071, true);
6052 // Improved Moonkin Form
6053 if (form == FORM_MOONKIN)
6055 Unit::AuraList const& dummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
6056 for(Unit::AuraList::const_iterator i = dummyAuras.begin(); i != dummyAuras.end(); i++)
6058 if ((*i)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_DRUID &&
6059 (*i)->GetSpellProto()->SpellIconID == 2855)
6061 uint32 spell_id = 0;
6062 switch((*i)->GetId())
6064 case 48384:spell_id=50170;break;//Rank 1
6065 case 48395:spell_id=50171;break;//Rank 2
6066 case 48396:spell_id=50172;break;//Rank 3
6067 default:
6068 sLog.outError("Aura::HandleShapeshiftBoosts: Not handled rank of IMF (Spell: %u)",(*i)->GetId());
6069 break;
6072 if(spell_id)
6073 m_target->CastSpell(m_target, spell_id, true, NULL, this);
6074 break;
6079 // Heart of the Wild
6080 if (HotWSpellId)
6082 Unit::AuraList const& mModTotalStatPct = m_target->GetAurasByType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE);
6083 for(Unit::AuraList::const_iterator i = mModTotalStatPct.begin(); i != mModTotalStatPct.end(); ++i)
6085 if ((*i)->GetSpellProto()->SpellIconID == 240 && (*i)->GetModifier()->m_miscvalue == 3)
6087 int32 HotWMod = (*i)->GetModifier()->m_amount;
6088 if(GetModifier()->m_miscvalue == FORM_CAT)
6089 HotWMod /= 2;
6091 m_target->CastCustomSpell(m_target, HotWSpellId, &HotWMod, NULL, NULL, true, NULL, this);
6092 break;
6098 else
6100 if(spellId1)
6101 m_target->RemoveAurasDueToSpell(spellId1);
6102 if(spellId2)
6103 m_target->RemoveAurasDueToSpell(spellId2);
6104 if(MasterShaperSpellId)
6105 m_target->RemoveAurasDueToSpell(MasterShaperSpellId);
6107 Unit::AuraMap& tAuras = m_target->GetAuras();
6108 for (Unit::AuraMap::iterator itr = tAuras.begin(); itr != tAuras.end();)
6110 if (itr->second->IsRemovedOnShapeLost())
6112 m_target->RemoveAurasDueToSpell(itr->second->GetId());
6113 itr = tAuras.begin();
6115 else
6116 ++itr;
6121 void Aura::HandleSpellSpecificBoosts(bool apply)
6123 bool cast_at_remove = false; // if spell must be casted at last aura from stack remove
6124 uint32 spellId1 = 0;
6125 uint32 spellId2 = 0;
6126 uint32 spellId3 = 0;
6127 uint32 spellId4 = 0;
6129 switch(GetSpellProto()->SpellFamilyName)
6131 case SPELLFAMILY_GENERIC:
6133 // Illusionary Barrier
6134 if(GetId() == 57350 && !apply && m_target->getPowerType() == POWER_MANA)
6136 cast_at_remove = true;
6137 spellId1 = 60242; // Darkmoon Card: Illusion
6139 else
6140 return;
6141 break;
6143 case SPELLFAMILY_MAGE:
6145 // Ice Barrier (non stacking from one caster)
6146 if (m_spellProto->SpellIconID == 32)
6148 if (!apply && (m_removeMode == AURA_REMOVE_BY_DISPEL || (m_removeMode == AURA_REMOVE_BY_DEFAULT && !GetModifier()->m_amount)))
6150 Unit::AuraList const& dummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
6151 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
6153 // Shattered Barrier
6154 if ((*itr)->GetSpellProto()->SpellIconID == 2945)
6156 cast_at_remove = true;
6157 // first rank have 50% chance
6158 if ((*itr)->GetId() != 44745 || roll_chance_i(50))
6159 spellId1 = 55080;
6160 break;
6164 else
6165 return;
6166 break;
6169 switch(GetId())
6171 case 11129: // Combustion (remove triggered aura stack)
6173 if(!apply)
6174 spellId1 = 28682;
6175 else
6176 return;
6177 break;
6179 case 28682: // Combustion (remove main aura)
6181 if(!apply)
6182 spellId1 = 11129;
6183 else
6184 return;
6185 break;
6187 case 44401: // Missile Barrage (triggered)
6188 case 48108: // Hot Streak (triggered)
6189 case 57761: // Fireball! (Brain Freeze triggered)
6191 // consumed aura
6192 if (!apply && m_removeMode == AURA_REMOVE_BY_DEFAULT && m_duration != 0)
6194 Unit* caster = GetCaster();
6195 // Item - Mage T10 2P Bonus
6196 if (!caster || !caster->HasAura(70752))
6197 return;
6199 cast_at_remove = true;
6200 spellId1 = 70753; // Pushing the Limit
6202 else
6203 return;
6204 break;
6206 default:
6207 return;
6209 break;
6211 case SPELLFAMILY_WARRIOR:
6213 if(!apply)
6215 // Remove Blood Frenzy only if target no longer has any Deep Wound or Rend (applying is handled by procs)
6216 if (GetSpellProto()->Mechanic != MECHANIC_BLEED)
6217 return;
6219 // If target still has one of Warrior's bleeds, do nothing
6220 Unit::AuraList const& PeriodicDamage = m_target->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE);
6221 for(Unit::AuraList::const_iterator i = PeriodicDamage.begin(); i != PeriodicDamage.end(); ++i)
6222 if( (*i)->GetCasterGUID() == GetCasterGUID() &&
6223 (*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARRIOR &&
6224 (*i)->GetSpellProto()->Mechanic == MECHANIC_BLEED)
6225 return;
6227 spellId1 = 30069; // Blood Frenzy (Rank 1)
6228 spellId2 = 30070; // Blood Frenzy (Rank 2)
6230 break;
6232 case SPELLFAMILY_WARLOCK:
6234 // Fear (non stacking)
6235 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000040000000000))
6237 if(!apply)
6239 Unit* caster = GetCaster();
6240 if(!caster)
6241 return;
6243 Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY);
6244 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
6246 SpellEntry const* dummyEntry = (*itr)->GetSpellProto();
6247 // Improved Fear
6248 if (dummyEntry->SpellFamilyName == SPELLFAMILY_WARLOCK && dummyEntry->SpellIconID == 98)
6250 cast_at_remove = true;
6251 switch((*itr)->GetModifier()->m_amount)
6253 // Rank 1
6254 case 0: spellId1 = 60946; break;
6255 // Rank 1
6256 case 1: spellId1 = 60947; break;
6258 break;
6262 else
6263 return;
6265 // Shadowflame (DoT)
6266 else if (m_spellProto->SpellFamilyFlags2 & 0x00000002)
6268 // Glyph of Shadowflame
6269 Unit* caster;
6270 if(!apply)
6271 spellId1 = 63311;
6272 else if(((caster = GetCaster())) && caster->HasAura(63310))
6273 spellId1 = 63311;
6274 else
6275 return;
6277 else
6278 return;
6279 break;
6281 case SPELLFAMILY_PRIEST:
6283 // Shadow Word: Pain (need visual check fro skip improvement talent) or Vampiric Touch
6284 if (m_spellProto->SpellIconID == 234 && m_spellProto->SpellVisual[0] || m_spellProto->SpellIconID == 2213)
6286 if (!apply && m_removeMode == AURA_REMOVE_BY_DISPEL)
6288 Unit* caster = GetCaster();
6289 if(!caster)
6290 return;
6292 Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY);
6293 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
6295 // Shadow Affinity
6296 if ((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_PRIEST
6297 && (*itr)->GetSpellProto()->SpellIconID == 178)
6299 // custom cast code
6300 int32 basepoints0 = (*itr)->GetModifier()->m_amount * caster->GetCreateMana() / 100;
6301 caster->CastCustomSpell(caster, 64103, &basepoints0, NULL, NULL, true, NULL, this);
6302 return;
6306 else
6307 return;
6309 // Power Word: Shield
6310 else if (apply && m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000001) && m_spellProto->Mechanic == MECHANIC_SHIELD)
6312 Unit* caster = GetCaster();
6313 if(!caster)
6314 return;
6316 // Glyph of Power Word: Shield
6317 if (Aura* glyph = caster->GetAura(55672, EFFECT_INDEX_0))
6319 int32 heal = (glyph->GetModifier()->m_amount * m_modifier.m_amount)/100;
6320 caster->CastCustomSpell(m_target, 56160, &heal, NULL, NULL, true, 0, this);
6322 return;
6325 switch(GetId())
6327 // Abolish Disease (remove 1 more poison effect with Body and Soul)
6328 case 552:
6330 if(apply)
6332 int chance =0;
6333 Unit::AuraList const& dummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
6334 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
6336 SpellEntry const* dummyEntry = (*itr)->GetSpellProto();
6337 // Body and Soul (talent ranks)
6338 if (dummyEntry->SpellFamilyName == SPELLFAMILY_PRIEST && dummyEntry->SpellIconID == 2218 &&
6339 dummyEntry->SpellVisual[0]==0)
6341 chance = (*itr)->GetSpellProto()->CalculateSimpleValue(EFFECT_INDEX_1);
6342 break;
6346 if(roll_chance_i(chance))
6347 spellId1 = 64134; // Body and Soul (periodic dispel effect)
6349 else
6350 spellId1 = 64134; // Body and Soul (periodic dispel effect)
6351 break;
6353 // Dispersion mana reg and immunity
6354 case 47585:
6355 spellId1 = 60069; // Dispersion
6356 spellId2 = 63230; // Dispersion
6357 break;
6358 default:
6359 return;
6361 break;
6363 case SPELLFAMILY_ROGUE:
6364 // Sprint (skip non player casted spells by category)
6365 if (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000040) && GetSpellProto()->Category == 44)
6367 if(!apply || m_target->HasAura(58039)) // Glyph of Blurred Speed
6368 spellId1 = 61922; // Sprint (waterwalk)
6369 else
6370 return;
6372 else
6373 return;
6374 break;
6375 case SPELLFAMILY_HUNTER:
6377 // Freezing Trap Effect
6378 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000008))
6380 if(!apply)
6382 Unit *caster = GetCaster();
6383 // Glyph of Freezing Trap
6384 if (caster && caster->HasAura(56845))
6386 cast_at_remove = true;
6387 spellId1 = 61394;
6389 else
6390 return;
6392 else
6393 return;
6395 // Aspect of the Dragonhawk dodge
6396 else if (GetSpellProto()->SpellFamilyFlags2 & 0x00001000)
6398 spellId1 = 61848;
6400 // triggered spell have same category as main spell and cooldown
6401 if (apply && m_target->GetTypeId()==TYPEID_PLAYER)
6402 ((Player*)m_target)->RemoveSpellCooldown(61848);
6404 else
6405 return;
6406 break;
6408 case SPELLFAMILY_PALADIN:
6410 if (m_spellProto->Id == 31884) // Avenging Wrath
6412 if(!apply)
6413 spellId1 = 57318; // Sanctified Wrath (triggered)
6414 else
6416 int32 percent = 0;
6417 Unit::AuraList const& dummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
6418 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
6420 if ((*itr)->GetSpellProto()->SpellIconID == 3029)
6422 percent = (*itr)->GetModifier()->m_amount;
6423 break;
6427 // apply in special way
6428 if(percent)
6430 spellId1 = 57318; // Sanctified Wrath (triggered)
6431 // prevent aura deletion, specially in multi-boost case
6432 SetInUse(true);
6433 m_target->CastCustomSpell(m_target, spellId1, &percent, &percent, NULL, true, NULL, this);
6434 SetInUse(false);
6436 return;
6438 break;
6441 // Only process on player casting paladin aura
6442 // all aura bonuses applied also in aura area effect way to caster
6443 if (GetCasterGUID() != m_target->GetGUID() || !IS_PLAYER_GUID(GetCasterGUID()))
6444 return;
6446 if (GetSpellSpecific(m_spellProto->Id) != SPELL_AURA)
6447 return;
6449 // Sanctified Retribution and Swift Retribution (they share one aura), but not Retribution Aura (already gets modded)
6450 if ((GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000008))==0)
6451 spellId1 = 63531; // placeholder for talent spell mods
6452 // Improved Concentration Aura (auras bonus)
6453 spellId2 = 63510; // placeholder for talent spell mods
6454 // Improved Devotion Aura (auras bonus)
6455 spellId3 = 63514; // placeholder for talent spell mods
6456 break;
6458 case SPELLFAMILY_DEATHKNIGHT:
6460 // second part of spell apply
6461 switch (GetId())
6463 case 45524: // Chains of Ice
6465 if (apply)
6466 spellId1 = 55095; // Frost Fever
6467 else
6468 return;
6469 break;
6471 case 49039: spellId1 = 50397; break; // Lichborne
6473 case 48263: // Frost Presence
6474 case 48265: // Unholy Presence
6475 case 48266: // Blood Presence
6477 // else part one per 3 pair
6478 if (GetId()==48263 || GetId()==48265) // Frost Presence or Unholy Presence
6480 // Improved Blood Presence
6481 int32 heal_pct = 0;
6482 if (apply)
6484 Unit::AuraList const& bloodAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
6485 for(Unit::AuraList::const_iterator itr = bloodAuras.begin(); itr != bloodAuras.end(); ++itr)
6487 // skip same icon
6488 if ((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT &&
6489 (*itr)->GetSpellProto()->SpellIconID == 2636)
6491 heal_pct = (*itr)->GetModifier()->m_amount;
6492 break;
6497 if (heal_pct)
6498 m_target->CastCustomSpell(m_target, 63611, &heal_pct, NULL, NULL, true, NULL, this);
6499 else
6500 m_target->RemoveAurasDueToSpell(63611);
6502 else
6503 spellId1 = 63611; // Improved Blood Presence, trigger for heal
6505 if (GetId()==48263 || GetId()==48266) // Frost Presence or Blood Presence
6507 // Improved Unholy Presence
6508 int32 power_pct = 0;
6509 if (apply)
6511 Unit::AuraList const& unholyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
6512 for(Unit::AuraList::const_iterator itr = unholyAuras.begin(); itr != unholyAuras.end(); ++itr)
6514 // skip same icon
6515 if ((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT &&
6516 (*itr)->GetSpellProto()->SpellIconID == 2633)
6518 power_pct = (*itr)->GetModifier()->m_amount;
6519 break;
6524 if (power_pct || !apply)
6525 spellId2 = 49772; // Unholy Presence, speed part, spell1 used for Improvement presence fit to own presence
6527 else
6528 spellId1 = 49772; // Unholy Presence move speed
6530 if (GetId()==48265 || GetId()==48266) // Unholy Presence or Blood Presence
6532 // Improved Frost Presence
6533 int32 stamina_pct = 0;
6534 if (apply)
6536 Unit::AuraList const& frostAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
6537 for(Unit::AuraList::const_iterator itr = frostAuras.begin(); itr != frostAuras.end(); ++itr)
6539 // skip same icon
6540 if ((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT &&
6541 (*itr)->GetSpellProto()->SpellIconID == 2632)
6543 stamina_pct = (*itr)->GetModifier()->m_amount;
6544 break;
6549 if (stamina_pct)
6550 m_target->CastCustomSpell(m_target, 61261, &stamina_pct, NULL, NULL, true, NULL, this);
6551 else
6552 m_target->RemoveAurasDueToSpell(61261);
6554 else
6555 spellId1 = 61261; // Frost Presence, stamina
6557 if (GetId()==48265) // Unholy Presence
6559 // Improved Unholy Presence, special case for own presence
6560 int32 power_pct = 0;
6561 if (apply)
6563 Unit::AuraList const& unholyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
6564 for(Unit::AuraList::const_iterator itr = unholyAuras.begin(); itr != unholyAuras.end(); ++itr)
6566 // skip same icon
6567 if ((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT &&
6568 (*itr)->GetSpellProto()->SpellIconID == 2633)
6570 power_pct = (*itr)->GetModifier()->m_amount;
6571 break;
6576 if (power_pct)
6578 int32 bp = 5;
6579 m_target->CastCustomSpell(m_target, 63622, &bp, &bp, &bp, true, NULL, this);
6580 m_target->CastCustomSpell(m_target, 65095, &bp, NULL, NULL, true, NULL, this);
6582 else
6584 m_target->RemoveAurasDueToSpell(63622);
6585 m_target->RemoveAurasDueToSpell(65095);
6588 break;
6592 // Improved Blood Presence
6593 if (GetSpellProto()->SpellIconID == 2632 && GetModifier()->m_auraname==SPELL_AURA_DUMMY)
6595 // if presence active: Frost Presence or Unholy Presence
6596 if (apply && (m_target->HasAura(48263) || m_target->HasAura(48265)))
6598 int32 bp = GetModifier()->m_amount;
6599 m_target->CastCustomSpell(m_target, 63611, &bp, NULL, NULL, true, NULL, this);
6601 else
6602 m_target->RemoveAurasDueToSpell(63611);
6603 return;
6606 // Improved Frost Presence
6607 if (GetSpellProto()->SpellIconID == 2636 && GetModifier()->m_auraname==SPELL_AURA_DUMMY)
6609 // if presence active: Unholy Presence or Blood Presence
6610 if (apply && (m_target->HasAura(48265) || m_target->HasAura(48266)))
6612 int32 bp = GetModifier()->m_amount;
6613 m_target->CastCustomSpell(m_target, 61261, &bp, NULL, NULL, true, NULL, this);
6615 else
6616 m_target->RemoveAurasDueToSpell(61261);
6617 return;
6620 // Improved Unholy Presence
6621 if (GetSpellProto()->SpellIconID == 2633 && GetModifier()->m_auraname==SPELL_AURA_DUMMY)
6623 // if presence active: Unholy Presence
6624 if (apply && m_target->HasAura(48265))
6626 int32 bp = 5;
6627 m_target->CastCustomSpell(m_target, 63622, &bp, &bp, &bp, true, NULL, this);
6628 m_target->CastCustomSpell(m_target, 65095, &bp, NULL, NULL, true, NULL, this);
6630 else
6632 m_target->RemoveAurasDueToSpell(63622);
6633 m_target->RemoveAurasDueToSpell(65095);
6636 // if presence active: Frost Presence or Blood Presence
6637 if (!apply || m_target->HasAura(48263) || m_target->HasAura(48266))
6638 spellId1 = 49772;
6639 else
6640 return;
6641 break;
6643 break;
6645 default:
6646 return;
6649 // prevent aura deletion, specially in multi-boost case
6650 SetInUse(true);
6652 if (apply || cast_at_remove)
6654 if (spellId1)
6655 m_target->CastSpell(m_target, spellId1, true, NULL, this);
6656 if (spellId2 && !IsDeleted())
6657 m_target->CastSpell(m_target, spellId2, true, NULL, this);
6658 if (spellId3 && !IsDeleted())
6659 m_target->CastSpell(m_target, spellId3, true, NULL, this);
6660 if (spellId4 && !IsDeleted())
6661 m_target->CastSpell(m_target, spellId4, true, NULL, this);
6663 else
6665 if (spellId1)
6666 m_target->RemoveAurasByCasterSpell(spellId1, GetCasterGUID());
6667 if (spellId2)
6668 m_target->RemoveAurasByCasterSpell(spellId2, GetCasterGUID());
6669 if (spellId3)
6670 m_target->RemoveAurasByCasterSpell(spellId3, GetCasterGUID());
6671 if (spellId4)
6672 m_target->RemoveAurasByCasterSpell(spellId4, GetCasterGUID());
6675 SetInUse(false);
6678 void Aura::HandleAuraEmpathy(bool apply, bool /*Real*/)
6680 if(m_target->GetTypeId() != TYPEID_UNIT)
6681 return;
6683 CreatureInfo const * ci = ObjectMgr::GetCreatureTemplate(m_target->GetEntry());
6684 if(ci && ci->type == CREATURE_TYPE_BEAST)
6685 m_target->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO, apply);
6688 void Aura::HandleAuraUntrackable(bool apply, bool /*Real*/)
6690 if(apply)
6691 m_target->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE);
6692 else
6693 m_target->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE);
6696 void Aura::HandleAuraModPacify(bool apply, bool /*Real*/)
6698 if(m_target->GetTypeId() != TYPEID_PLAYER)
6699 return;
6701 if(apply)
6702 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
6703 else
6704 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
6707 void Aura::HandleAuraModPacifyAndSilence(bool apply, bool Real)
6709 HandleAuraModPacify(apply, Real);
6710 HandleAuraModSilence(apply, Real);
6713 void Aura::HandleAuraGhost(bool apply, bool /*Real*/)
6715 if(m_target->GetTypeId() != TYPEID_PLAYER)
6716 return;
6718 if(apply)
6720 m_target->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST);
6722 else
6724 m_target->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST);
6728 void Aura::HandleAuraAllowFlight(bool apply, bool Real)
6730 // all applied/removed only at real aura add/remove
6731 if(!Real)
6732 return;
6734 // allow fly
6735 WorldPacket data;
6736 if(apply)
6737 data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
6738 else
6739 data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
6740 data << m_target->GetPackGUID();
6741 data << uint32(0); // unk
6742 m_target->SendMessageToSet(&data, true);
6745 void Aura::HandleModRating(bool apply, bool Real)
6747 // spells required only Real aura add/remove
6748 if(!Real)
6749 return;
6751 if(m_target->GetTypeId() != TYPEID_PLAYER)
6752 return;
6754 for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating)
6755 if (m_modifier.m_miscvalue & (1 << rating))
6756 ((Player*)m_target)->ApplyRatingMod(CombatRating(rating), m_modifier.m_amount, apply);
6759 void Aura::HandleModRatingFromStat(bool apply, bool Real)
6761 // spells required only Real aura add/remove
6762 if(!Real)
6763 return;
6765 if(m_target->GetTypeId() != TYPEID_PLAYER)
6766 return;
6767 // Just recalculate ratings
6768 for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating)
6769 if (m_modifier.m_miscvalue & (1 << rating))
6770 ((Player*)m_target)->ApplyRatingMod(CombatRating(rating), 0, apply);
6773 void Aura::HandleForceMoveForward(bool apply, bool Real)
6775 if(!Real || m_target->GetTypeId() != TYPEID_PLAYER)
6776 return;
6777 if(apply)
6778 m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE);
6779 else
6780 m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE);
6783 void Aura::HandleAuraModExpertise(bool /*apply*/, bool /*Real*/)
6785 if(m_target->GetTypeId() != TYPEID_PLAYER)
6786 return;
6788 ((Player*)m_target)->UpdateExpertise(BASE_ATTACK);
6789 ((Player*)m_target)->UpdateExpertise(OFF_ATTACK);
6792 void Aura::HandleModTargetResistance(bool apply, bool Real)
6794 // spells required only Real aura add/remove
6795 if(!Real)
6796 return;
6797 // applied to damage as HandleNoImmediateEffect in Unit::CalculateAbsorbAndResist and Unit::CalcArmorReducedDamage
6799 // show armor penetration
6800 if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL))
6801 m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE, m_modifier.m_amount, apply);
6803 // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy
6804 if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_SPELL)==SPELL_SCHOOL_MASK_SPELL)
6805 m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, m_modifier.m_amount, apply);
6808 void Aura::HandleShieldBlockValue(bool apply, bool /*Real*/)
6810 BaseModType modType = FLAT_MOD;
6811 if(m_modifier.m_auraname == SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT)
6812 modType = PCT_MOD;
6814 if(m_target->GetTypeId() == TYPEID_PLAYER)
6815 ((Player*)m_target)->HandleBaseModValue(SHIELD_BLOCK_VALUE, modType, float(m_modifier.m_amount), apply);
6818 void Aura::HandleAuraRetainComboPoints(bool apply, bool Real)
6820 // spells required only Real aura add/remove
6821 if(!Real)
6822 return;
6824 if(m_target->GetTypeId() != TYPEID_PLAYER)
6825 return;
6827 Player *target = (Player*)m_target;
6829 // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler
6830 // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost)
6831 if( !apply && m_duration==0 && target->GetComboTarget())
6832 if(Unit* unit = ObjectAccessor::GetUnit(*m_target,target->GetComboTarget()))
6833 target->AddComboPoints(unit, -m_modifier.m_amount);
6836 void Aura::HandleModUnattackable( bool Apply, bool Real )
6838 if(Real && Apply)
6840 m_target->CombatStop();
6841 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
6843 m_target->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE,Apply);
6846 void Aura::HandleSpiritOfRedemption( bool apply, bool Real )
6848 // spells required only Real aura add/remove
6849 if(!Real)
6850 return;
6852 // prepare spirit state
6853 if(apply)
6855 if(m_target->GetTypeId()==TYPEID_PLAYER)
6857 // disable breath/etc timers
6858 ((Player*)m_target)->StopMirrorTimers();
6860 // set stand state (expected in this form)
6861 if(!m_target->IsStandState())
6862 m_target->SetStandState(UNIT_STAND_STATE_STAND);
6865 m_target->SetHealth(1);
6867 // die at aura end
6868 else
6869 m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, GetSpellProto(), false);
6872 void Aura::CleanupTriggeredSpells()
6874 uint32 tSpellId = m_spellProto->EffectTriggerSpell[GetEffIndex()];
6875 if(!tSpellId)
6876 return;
6878 SpellEntry const* tProto = sSpellStore.LookupEntry(tSpellId);
6879 if(!tProto)
6880 return;
6882 if(GetSpellDuration(tProto) != -1)
6883 return;
6885 // needed for spell 43680, maybe others
6886 // TODO: is there a spell flag, which can solve this in a more sophisticated way?
6887 if(m_spellProto->EffectApplyAuraName[GetEffIndex()] == SPELL_AURA_PERIODIC_TRIGGER_SPELL &&
6888 GetSpellDuration(m_spellProto) == m_spellProto->EffectAmplitude[GetEffIndex()])
6889 return;
6890 m_target->RemoveAurasDueToSpell(tSpellId);
6893 void Aura::HandleSchoolAbsorb(bool apply, bool Real)
6895 if(!Real)
6896 return;
6898 Unit* caster = GetCaster();
6899 if(!caster)
6900 return;
6902 if (apply)
6904 // prevent double apply bonuses
6905 if (m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())
6907 float DoneActualBenefit = 0.0f;
6908 switch(m_spellProto->SpellFamilyName)
6910 case SPELLFAMILY_PRIEST:
6911 // Power Word: Shield
6912 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000001))
6914 //+80.68% from +spell bonus
6915 DoneActualBenefit = caster->SpellBaseHealingBonusDone(GetSpellSchoolMask(m_spellProto)) * 0.8068f;
6916 //Borrowed Time
6917 Unit::AuraList const& borrowedTime = caster->GetAurasByType(SPELL_AURA_DUMMY);
6918 for(Unit::AuraList::const_iterator itr = borrowedTime.begin(); itr != borrowedTime.end(); ++itr)
6920 SpellEntry const* i_spell = (*itr)->GetSpellProto();
6921 if(i_spell->SpellFamilyName==SPELLFAMILY_PRIEST && i_spell->SpellIconID == 2899 && i_spell->EffectMiscValue[(*itr)->GetEffIndex()] == 24)
6923 DoneActualBenefit += DoneActualBenefit * (*itr)->GetModifier()->m_amount / 100;
6924 break;
6929 break;
6930 case SPELLFAMILY_MAGE:
6931 // Frost Ward, Fire Ward
6932 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000108))
6933 //+10% from +spell bonus
6934 DoneActualBenefit = caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellProto)) * 0.1f;
6935 // Ice Barrier
6936 else if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000100000000))
6937 //+80.67% from +spell bonus
6938 DoneActualBenefit = caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellProto)) * 0.8067f;
6939 break;
6940 case SPELLFAMILY_WARLOCK:
6941 // Shadow Ward
6942 if (m_spellProto->SpellFamilyFlags2 & 0x00000040)
6943 //+30% from +spell bonus
6944 DoneActualBenefit = caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellProto)) * 0.30f;
6945 break;
6946 case SPELLFAMILY_PALADIN:
6947 // Sacred Shield
6948 // (check not strictly needed, only Sacred Shield has SPELL_AURA_SCHOOL_ABSORB in SPELLFAMILY_PALADIN at this time)
6949 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0008000000000000))
6951 // +75% from spell power
6952 DoneActualBenefit = caster->SpellBaseHealingBonusDone(GetSpellSchoolMask(m_spellProto)) * 0.75f;
6954 break;
6955 default:
6956 break;
6959 DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto());
6961 m_modifier.m_amount += (int32)DoneActualBenefit;
6964 else
6966 if (caster &&
6967 // Power Word: Shield
6968 m_spellProto->SpellFamilyName == SPELLFAMILY_PRIEST && m_spellProto->Mechanic == MECHANIC_SHIELD &&
6969 (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000001)) &&
6970 // completely absorbed or dispelled
6971 ((m_removeMode == AURA_REMOVE_BY_DEFAULT && !m_modifier.m_amount) || m_removeMode == AURA_REMOVE_BY_DISPEL))
6973 Unit::AuraList const& vDummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY);
6974 for(Unit::AuraList::const_iterator itr = vDummyAuras.begin(); itr != vDummyAuras.end(); ++itr)
6976 SpellEntry const* vSpell = (*itr)->GetSpellProto();
6978 // Rapture (main spell)
6979 if(vSpell->SpellFamilyName == SPELLFAMILY_PRIEST && vSpell->SpellIconID == 2894 && vSpell->Effect[EFFECT_INDEX_1])
6981 switch((*itr)->GetEffIndex())
6983 case EFFECT_INDEX_0:
6985 // energize caster
6986 int32 manapct1000 = 5 * ((*itr)->GetModifier()->m_amount + sSpellMgr.GetSpellRank(vSpell->Id));
6987 int32 basepoints0 = caster->GetMaxPower(POWER_MANA) * manapct1000 / 1000;
6988 caster->CastCustomSpell(caster, 47755, &basepoints0, NULL, NULL, true);
6989 break;
6991 case EFFECT_INDEX_1:
6993 // energize target
6994 if (!roll_chance_i((*itr)->GetModifier()->m_amount) || caster->HasAura(63853))
6995 break;
6997 switch(m_target->getPowerType())
6999 case POWER_RUNIC_POWER:
7000 m_target->CastSpell(m_target, 63652, true, NULL, NULL, m_caster_guid);
7001 break;
7002 case POWER_RAGE:
7003 m_target->CastSpell(m_target, 63653, true, NULL, NULL, m_caster_guid);
7004 break;
7005 case POWER_MANA:
7007 int32 basepoints0 = m_target->GetMaxPower(POWER_MANA) * 2 / 100;
7008 m_target->CastCustomSpell(m_target, 63654, &basepoints0, NULL, NULL, true);
7009 break;
7011 case POWER_ENERGY:
7012 m_target->CastSpell(m_target, 63655, true, NULL, NULL, m_caster_guid);
7013 break;
7014 default:
7015 break;
7018 //cooldwon aura
7019 caster->CastSpell(caster, 63853, true);
7020 break;
7022 default:
7023 sLog.outError("Changes in R-dummy spell???: effect 3");
7024 break;
7032 void Aura::PeriodicTick()
7034 switch(m_modifier.m_auraname)
7036 case SPELL_AURA_PERIODIC_DAMAGE:
7037 case SPELL_AURA_PERIODIC_DAMAGE_PERCENT:
7039 // don't damage target if not alive, possible death persistent effects
7040 if (!m_target->isAlive())
7041 return;
7043 Unit *pCaster = GetCaster();
7044 if(!pCaster)
7045 return;
7047 if( GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA &&
7048 pCaster->SpellHitResult(m_target, GetSpellProto(), false) != SPELL_MISS_NONE)
7049 return;
7051 // Check for immune (not use charges)
7052 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
7053 return;
7055 // some auras remove at specific health level or more
7056 if(m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE)
7058 switch(GetId())
7060 case 43093: case 31956: case 38801:
7061 case 35321: case 38363: case 39215:
7062 case 48920:
7064 if(m_target->GetHealth() == m_target->GetMaxHealth() )
7066 m_target->RemoveAurasDueToSpell(GetId());
7067 return;
7069 break;
7071 case 38772:
7073 uint32 percent =
7074 GetEffIndex() < EFFECT_INDEX_2 && GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_DUMMY ?
7075 pCaster->CalculateSpellDamage(m_target, GetSpellProto(), SpellEffectIndex(GetEffIndex() + 1)) :
7076 100;
7077 if(m_target->GetHealth() * 100 >= m_target->GetMaxHealth() * percent )
7079 m_target->RemoveAurasDueToSpell(GetId());
7080 return;
7082 break;
7084 default:
7085 break;
7089 uint32 absorb = 0;
7090 uint32 resist = 0;
7091 CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
7093 // ignore non positive values (can be result apply spellmods to aura damage
7094 uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
7096 uint32 pdamage;
7098 if(m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE)
7099 pdamage = amount;
7100 else
7101 pdamage = uint32(m_target->GetMaxHealth()*amount/100);
7104 // SpellDamageBonus for magic spells
7105 if(GetSpellProto()->DmgClass == SPELL_DAMAGE_CLASS_NONE || GetSpellProto()->DmgClass == SPELL_DAMAGE_CLASS_MAGIC)
7106 pdamage = m_target->SpellDamageBonusTaken(pCaster, GetSpellProto(), pdamage, DOT, GetStackAmount());
7107 // MeleeDamagebonus for weapon based spells
7108 else
7110 WeaponAttackType attackType = GetWeaponAttackType(GetSpellProto());
7111 pdamage = m_target->MeleeDamageBonusTaken(pCaster, pdamage, attackType, GetSpellProto(), DOT, GetStackAmount());
7114 // Calculate armor mitigation if it is a physical spell
7115 // But not for bleed mechanic spells
7116 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL &&
7117 GetEffectMechanic(GetSpellProto(), m_effIndex) != MECHANIC_BLEED)
7119 uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage);
7120 cleanDamage.damage += pdamage - pdamageReductedArmor;
7121 pdamage = pdamageReductedArmor;
7124 // Curse of Agony damage-per-tick calculation
7125 if (GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000400)) && GetSpellProto()->SpellIconID==544)
7127 // 1..4 ticks, 1/2 from normal tick damage
7128 if (GetAuraTicks() <= 4)
7129 pdamage = pdamage/2;
7130 // 9..12 ticks, 3/2 from normal tick damage
7131 else if(GetAuraTicks() >= 9)
7132 pdamage += (pdamage + 1) / 2; // +1 prevent 0.5 damage possible lost at 1..4 ticks
7133 // 5..8 ticks have normal tick damage
7136 // This method can modify pdamage
7137 bool isCrit = IsCritFromAbilityAura(pCaster, pdamage);
7139 // send critical in hit info for threat calculation
7140 if (isCrit)
7142 cleanDamage.hitOutCome = MELEE_HIT_CRIT;
7143 // Resilience - reduce crit damage
7144 pdamage -= m_target->GetSpellCritDamageReduction(pdamage);
7147 // only from players
7148 // FIXME: need use SpellDamageBonus instead?
7149 if (IS_PLAYER_GUID(m_caster_guid))
7150 pdamage -= m_target->GetSpellDamageReduction(pdamage);
7152 m_target->CalculateAbsorbAndResist(pCaster, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist, !(GetSpellProto()->AttributesEx2 & SPELL_ATTR_EX2_CANT_REFLECTED));
7154 DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS, "PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
7155 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb);
7157 pCaster->DealDamageMods(m_target, pdamage, &absorb);
7159 // Set trigger flag
7160 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
7161 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
7162 pdamage = (pdamage <= absorb + resist) ? 0 : (pdamage - absorb - resist);
7164 SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, absorb, resist, 0.0f, isCrit);
7165 m_target->SendPeriodicAuraLog(&pInfo);
7167 if (pdamage)
7168 procVictim|=PROC_FLAG_TAKEN_ANY_DAMAGE;
7170 pCaster->ProcDamageAndSpell(m_target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, GetSpellProto());
7172 pCaster->DealDamage(m_target, pdamage, &cleanDamage, DOT, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
7173 break;
7175 case SPELL_AURA_PERIODIC_LEECH:
7176 case SPELL_AURA_PERIODIC_HEALTH_FUNNEL:
7178 // don't damage target if not alive, possible death persistent effects
7179 if (!m_target->isAlive())
7180 return;
7182 Unit *pCaster = GetCaster();
7183 if(!pCaster)
7184 return;
7186 if(!pCaster->isAlive())
7187 return;
7189 if( GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA &&
7190 pCaster->SpellHitResult(m_target, GetSpellProto(), false) != SPELL_MISS_NONE)
7191 return;
7193 // Check for immune
7194 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
7195 return;
7197 uint32 absorb=0;
7198 uint32 resist=0;
7199 CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
7201 uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
7203 //Calculate armor mitigation if it is a physical spell
7204 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL)
7206 uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage);
7207 cleanDamage.damage += pdamage - pdamageReductedArmor;
7208 pdamage = pdamageReductedArmor;
7211 pdamage = m_target->SpellDamageBonusTaken(pCaster, GetSpellProto(), pdamage, DOT, GetStackAmount());
7213 bool isCrit = IsCritFromAbilityAura(pCaster, pdamage);
7215 // send critical in hit info for threat calculation
7216 if (isCrit)
7218 cleanDamage.hitOutCome = MELEE_HIT_CRIT;
7219 // Resilience - reduce crit damage
7220 pdamage -= m_target->GetSpellCritDamageReduction(pdamage);
7223 // only from players
7224 // FIXME: need use SpellDamageBonus instead?
7225 if (IS_PLAYER_GUID(m_caster_guid))
7226 pdamage -= m_target->GetSpellDamageReduction(pdamage);
7228 m_target->CalculateAbsorbAndResist(pCaster, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist, !(GetSpellProto()->AttributesEx2 & SPELL_ATTR_EX2_CANT_REFLECTED));
7230 if(m_target->GetHealth() < pdamage)
7231 pdamage = uint32(m_target->GetHealth());
7233 DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS, "PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
7234 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb);
7236 pCaster->DealDamageMods(m_target, pdamage, &absorb);
7238 pCaster->SendSpellNonMeleeDamageLog(m_target, GetId(), pdamage, GetSpellSchoolMask(GetSpellProto()), absorb, resist, false, 0, isCrit);
7240 float multiplier = GetSpellProto()->EffectMultipleValue[GetEffIndex()] > 0 ? GetSpellProto()->EffectMultipleValue[GetEffIndex()] : 1;
7242 // Set trigger flag
7243 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
7244 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
7245 pdamage = (pdamage <= absorb + resist) ? 0 : (pdamage-absorb-resist);
7246 if (pdamage)
7247 procVictim|=PROC_FLAG_TAKEN_ANY_DAMAGE;
7248 pCaster->ProcDamageAndSpell(m_target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, GetSpellProto());
7249 int32 new_damage = pCaster->DealDamage(m_target, pdamage, &cleanDamage, DOT, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), false);
7251 if (!m_target->isAlive() && pCaster->IsNonMeleeSpellCasted(false))
7252 for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
7253 if (Spell* spell = pCaster->GetCurrentSpell(CurrentSpellTypes(i)))
7254 if (spell->m_spellInfo->Id == GetId())
7255 spell->cancel();
7258 if(Player *modOwner = pCaster->GetSpellModOwner())
7259 modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, multiplier);
7261 int32 heal = pCaster->SpellHealingBonusTaken(pCaster, GetSpellProto(), int32(new_damage * multiplier), DOT, GetStackAmount());
7263 int32 gain = pCaster->DealHeal(pCaster, heal, GetSpellProto());
7264 pCaster->getHostileRefManager().threatAssist(pCaster, gain * 0.5f, GetSpellProto());
7265 break;
7267 case SPELL_AURA_PERIODIC_HEAL:
7268 case SPELL_AURA_OBS_MOD_HEALTH:
7270 // don't heal target if not alive, mostly death persistent effects from items
7271 if (!m_target->isAlive())
7272 return;
7274 Unit *pCaster = GetCaster();
7275 if(!pCaster)
7276 return;
7278 // heal for caster damage (must be alive)
7279 if(m_target != pCaster && GetSpellProto()->SpellVisual[0] == 163 && !pCaster->isAlive())
7280 return;
7282 // ignore non positive values (can be result apply spellmods to aura damage
7283 uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
7285 uint32 pdamage;
7287 if(m_modifier.m_auraname==SPELL_AURA_OBS_MOD_HEALTH)
7288 pdamage = uint32(m_target->GetMaxHealth() * amount / 100);
7289 else
7291 pdamage = amount;
7293 // Wild Growth (1/7 - 6 + 2*ramainTicks) %
7294 if (m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && m_spellProto->SpellIconID == 2864)
7296 int32 ticks = GetAuraMaxTicks();
7297 int32 remainingTicks = ticks - GetAuraTicks();
7298 int32 addition = int32(amount)*ticks*(-6+2*remainingTicks)/100;
7300 if (GetAuraTicks() != 1)
7301 // Item - Druid T10 Restoration 2P Bonus
7302 if (Aura *aura = pCaster->GetAura(70658, EFFECT_INDEX_0))
7303 addition += abs(int32((addition * aura->GetModifier()->m_amount) / ((ticks-1)* 100)));
7305 pdamage = int32(pdamage) + addition;
7309 pdamage = m_target->SpellHealingBonusTaken(pCaster, GetSpellProto(), pdamage, DOT, GetStackAmount());
7311 // This method can modify pdamage
7312 bool isCrit = IsCritFromAbilityAura(pCaster, pdamage);
7314 DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS, "PeriodicTick: %u (TypeId: %u) heal of %u (TypeId: %u) for %u health inflicted by %u",
7315 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
7317 int32 gain = m_target->ModifyHealth(pdamage);
7318 SpellPeriodicAuraLogInfo pInfo(this, pdamage, (pdamage - uint32(gain)), 0, 0, 0.0f, isCrit);
7319 m_target->SendPeriodicAuraLog(&pInfo);
7321 // Set trigger flag
7322 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;
7323 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;
7324 pCaster->ProcDamageAndSpell(m_target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, gain, BASE_ATTACK, m_spellProto);
7326 // add HoTs to amount healed in bgs
7327 if( pCaster->GetTypeId() == TYPEID_PLAYER )
7328 if( BattleGround *bg = ((Player*)pCaster)->GetBattleGround() )
7329 bg->UpdatePlayerScore(((Player*)pCaster), SCORE_HEALING_DONE, gain);
7331 m_target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto());
7333 SpellEntry const* spellProto = GetSpellProto();
7335 // heal for caster damage
7336 if(m_target != pCaster && spellProto->SpellVisual[0] == 163)
7338 uint32 dmg = spellProto->manaPerSecond;
7339 if(pCaster->GetHealth() <= dmg && pCaster->GetTypeId()==TYPEID_PLAYER)
7341 pCaster->RemoveAurasDueToSpell(GetId());
7343 // finish current generic/channeling spells, don't affect autorepeat
7344 pCaster->FinishSpell(CURRENT_GENERIC_SPELL);
7345 pCaster->FinishSpell(CURRENT_CHANNELED_SPELL);
7347 else
7349 uint32 damage = gain;
7350 uint32 absorb = 0;
7351 pCaster->DealDamageMods(pCaster, damage, &absorb);
7352 pCaster->SendSpellNonMeleeDamageLog(pCaster, GetId(), damage, GetSpellSchoolMask(GetSpellProto()), absorb, 0, false, 0, false);
7354 CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
7355 pCaster->DealDamage(pCaster, damage, &cleanDamage, NODAMAGE, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
7359 // uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;// | PROC_FLAG_SUCCESSFUL_HEAL;
7360 // uint32 procVictim = 0;//ROC_FLAG_ON_TAKE_PERIODIC | PROC_FLAG_TAKEN_HEAL;
7361 // ignore item heals
7362 // if(procSpell && !haveCastItem)
7363 // pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto);
7364 break;
7366 case SPELL_AURA_PERIODIC_MANA_LEECH:
7368 // don't damage target if not alive, possible death persistent effects
7369 if (!m_target->isAlive())
7370 return;
7372 if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS)
7373 return;
7375 Powers power = Powers(m_modifier.m_miscvalue);
7377 // power type might have changed between aura applying and tick (druid's shapeshift)
7378 if(m_target->getPowerType() != power)
7379 return;
7381 Unit *pCaster = GetCaster();
7382 if(!pCaster)
7383 return;
7385 if(!pCaster->isAlive())
7386 return;
7388 if( GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA &&
7389 pCaster->SpellHitResult(m_target, GetSpellProto(), false) != SPELL_MISS_NONE)
7390 return;
7392 // Check for immune (not use charges)
7393 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
7394 return;
7396 // ignore non positive values (can be result apply spellmods to aura damage
7397 uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
7399 // Special case: draining x% of mana (up to a maximum of 2*x% of the caster's maximum mana)
7400 // It's mana percent cost spells, m_modifier.m_amount is percent drain from target
7401 if (m_spellProto->ManaCostPercentage)
7403 // max value
7404 uint32 maxmana = pCaster->GetMaxPower(power) * pdamage * 2 / 100;
7405 pdamage = m_target->GetMaxPower(power) * pdamage / 100;
7406 if(pdamage > maxmana)
7407 pdamage = maxmana;
7410 DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS, "PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u",
7411 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
7413 int32 drain_amount = m_target->GetPower(power) > pdamage ? pdamage : m_target->GetPower(power);
7415 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
7416 if (power == POWER_MANA)
7417 drain_amount -= m_target->GetSpellCritDamageReduction(drain_amount);
7419 m_target->ModifyPower(power, -drain_amount);
7421 float gain_multiplier = 0;
7423 if(pCaster->GetMaxPower(power) > 0)
7425 gain_multiplier = GetSpellProto()->EffectMultipleValue[GetEffIndex()];
7427 if(Player *modOwner = pCaster->GetSpellModOwner())
7428 modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, gain_multiplier);
7431 SpellPeriodicAuraLogInfo pInfo(this, drain_amount, 0, 0, 0, gain_multiplier);
7432 m_target->SendPeriodicAuraLog(&pInfo);
7434 int32 gain_amount = int32(drain_amount * gain_multiplier);
7436 if(gain_amount)
7438 int32 gain = pCaster->ModifyPower(power, gain_amount);
7439 m_target->AddThreat(pCaster, float(gain) * 0.5f, pInfo.critical, GetSpellSchoolMask(GetSpellProto()), GetSpellProto());
7441 break;
7443 case SPELL_AURA_PERIODIC_ENERGIZE:
7445 // don't energize target if not alive, possible death persistent effects
7446 if (!m_target->isAlive())
7447 return;
7449 // ignore non positive values (can be result apply spellmods to aura damage
7450 uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
7452 DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS, "PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u",
7453 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
7455 if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS)
7456 break;
7458 Powers power = Powers(m_modifier.m_miscvalue);
7460 if(m_target->GetMaxPower(power) == 0)
7461 break;
7463 SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, 0, 0, 0.0f);
7464 m_target->SendPeriodicAuraLog(&pInfo);
7466 int32 gain = m_target->ModifyPower(power,pdamage);
7468 if(Unit* pCaster = GetCaster())
7469 m_target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto());
7470 break;
7472 case SPELL_AURA_OBS_MOD_MANA:
7474 // don't energize target if not alive, possible death persistent effects
7475 if (!m_target->isAlive())
7476 return;
7478 // ignore non positive values (can be result apply spellmods to aura damage
7479 uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
7481 uint32 pdamage = uint32(m_target->GetMaxPower(POWER_MANA) * amount / 100);
7483 DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS, "PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u mana inflicted by %u",
7484 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
7486 if(m_target->GetMaxPower(POWER_MANA) == 0)
7487 break;
7489 SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, 0, 0, 0.0f);
7490 m_target->SendPeriodicAuraLog(&pInfo);
7492 int32 gain = m_target->ModifyPower(POWER_MANA, pdamage);
7494 if(Unit* pCaster = GetCaster())
7495 m_target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto());
7496 break;
7498 case SPELL_AURA_POWER_BURN_MANA:
7500 // don't mana burn target if not alive, possible death persistent effects
7501 if (!m_target->isAlive())
7502 return;
7504 Unit *pCaster = GetCaster();
7505 if(!pCaster)
7506 return;
7508 // Check for immune (not use charges)
7509 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
7510 return;
7512 int32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
7514 Powers powerType = Powers(m_modifier.m_miscvalue);
7516 if(!m_target->isAlive() || m_target->getPowerType() != powerType)
7517 return;
7519 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
7520 if (powerType == POWER_MANA)
7521 pdamage -= m_target->GetSpellCritDamageReduction(pdamage);
7523 uint32 gain = uint32(-m_target->ModifyPower(powerType, -pdamage));
7525 gain = uint32(gain * GetSpellProto()->EffectMultipleValue[GetEffIndex()]);
7527 SpellEntry const* spellProto = GetSpellProto();
7528 // maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG
7529 SpellNonMeleeDamage damageInfo(pCaster, m_target, spellProto->Id, spellProto->SchoolMask);
7530 pCaster->CalculateSpellDamage(&damageInfo, gain, spellProto);
7532 damageInfo.target->CalculateAbsorbResistBlock(pCaster, &damageInfo, spellProto);
7534 pCaster->DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb);
7536 pCaster->SendSpellNonMeleeDamageLog(&damageInfo);
7538 // Set trigger flag
7539 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
7540 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
7541 uint32 procEx = createProcExtendMask(&damageInfo, SPELL_MISS_NONE);
7542 if (damageInfo.damage)
7543 procVictim|=PROC_FLAG_TAKEN_ANY_DAMAGE;
7545 pCaster->ProcDamageAndSpell(damageInfo.target, procAttacker, procVictim, procEx, damageInfo.damage, BASE_ATTACK, spellProto);
7547 pCaster->DealSpellDamage(&damageInfo, true);
7548 break;
7550 case SPELL_AURA_MOD_REGEN:
7552 // don't heal target if not alive, possible death persistent effects
7553 if (!m_target->isAlive())
7554 return;
7556 int32 gain = m_target->ModifyHealth(m_modifier.m_amount);
7557 if (Unit *caster = GetCaster())
7558 m_target->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f, GetSpellProto());
7559 break;
7561 case SPELL_AURA_MOD_POWER_REGEN:
7563 // don't energize target if not alive, possible death persistent effects
7564 if (!m_target->isAlive())
7565 return;
7567 Powers pt = m_target->getPowerType();
7568 if(int32(pt) != m_modifier.m_miscvalue)
7569 return;
7571 if ( GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED )
7573 // eating anim
7574 m_target->HandleEmoteCommand(EMOTE_ONESHOT_EAT);
7576 else if( GetId() == 20577 )
7578 // cannibalize anim
7579 m_target->HandleEmoteCommand(EMOTE_STATE_CANNIBALIZE);
7582 // Anger Management
7583 // amount = 1+ 16 = 17 = 3,4*5 = 10,2*5/3
7584 // so 17 is rounded amount for 5 sec tick grow ~ 1 range grow in 3 sec
7585 if(pt == POWER_RAGE)
7586 m_target->ModifyPower(pt, m_modifier.m_amount * 3 / 5);
7587 break;
7589 // Here tick dummy auras
7590 case SPELL_AURA_DUMMY: // some spells have dummy aura
7591 case SPELL_AURA_PERIODIC_DUMMY:
7593 PeriodicDummyTick();
7594 break;
7596 case SPELL_AURA_PERIODIC_TRIGGER_SPELL:
7598 TriggerSpell();
7599 break;
7601 case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE:
7603 TriggerSpellWithValue();
7604 break;
7606 default:
7607 break;
7611 void Aura::PeriodicDummyTick()
7613 SpellEntry const* spell = GetSpellProto();
7614 switch (spell->SpellFamilyName)
7616 case SPELLFAMILY_GENERIC:
7617 switch (spell->Id)
7619 // Drink
7620 case 430:
7621 case 431:
7622 case 432:
7623 case 1133:
7624 case 1135:
7625 case 1137:
7626 case 10250:
7627 case 22734:
7628 case 27089:
7629 case 34291:
7630 case 43182:
7631 case 43183:
7632 case 43706:
7633 case 46755:
7634 case 49472: // Drink Coffee
7635 case 57073:
7636 case 61830:
7638 if (m_target->GetTypeId() != TYPEID_PLAYER)
7639 return;
7640 // Search SPELL_AURA_MOD_POWER_REGEN aura for this spell and add bonus
7641 Unit::AuraList const& aura = m_target->GetAurasByType(SPELL_AURA_MOD_POWER_REGEN);
7642 for(Unit::AuraList::const_iterator i = aura.begin(); i != aura.end(); ++i)
7644 if ((*i)->GetId() == GetId())
7646 (*i)->GetModifier()->m_amount = m_modifier.m_amount;
7647 ((Player*)m_target)->UpdateManaRegen();
7648 // Disable continue
7649 m_isPeriodic = false;
7650 return;
7653 return;
7655 // Forsaken Skills
7656 case 7054:
7658 // Possibly need cast one of them (but
7659 // 7038 Forsaken Skill: Swords
7660 // 7039 Forsaken Skill: Axes
7661 // 7040 Forsaken Skill: Daggers
7662 // 7041 Forsaken Skill: Maces
7663 // 7042 Forsaken Skill: Staves
7664 // 7043 Forsaken Skill: Bows
7665 // 7044 Forsaken Skill: Guns
7666 // 7045 Forsaken Skill: 2H Axes
7667 // 7046 Forsaken Skill: 2H Maces
7668 // 7047 Forsaken Skill: 2H Swords
7669 // 7048 Forsaken Skill: Defense
7670 // 7049 Forsaken Skill: Fire
7671 // 7050 Forsaken Skill: Frost
7672 // 7051 Forsaken Skill: Holy
7673 // 7053 Forsaken Skill: Shadow
7674 return;
7676 case 7057: // Haunting Spirits
7677 if (roll_chance_i(33))
7678 m_target->CastSpell(m_target,m_modifier.m_amount,true,NULL,this);
7679 return;
7680 // // Panda
7681 // case 19230: break;
7682 // // Gossip NPC Periodic - Talk
7683 // case 33208: break;
7684 // // Gossip NPC Periodic - Despawn
7685 // case 33209: break;
7686 // // Steal Weapon
7687 // case 36207: break;
7688 // // Simon Game START timer, (DND)
7689 // case 39993: break;
7690 // // Knockdown Fel Cannon: break; The Aggro Burst
7691 // case 40119: break;
7692 // // Old Mount Spell
7693 // case 40154: break;
7694 // // Magnetic Pull
7695 // case 40581: break;
7696 // // Ethereal Ring: break; The Bolt Burst
7697 // case 40801: break;
7698 // // Crystal Prison
7699 // case 40846: break;
7700 // // Copy Weapon
7701 // case 41054: break;
7702 // // Dementia
7703 // case 41404: break;
7704 // // Ethereal Ring Visual, Lightning Aura
7705 // case 41477: break;
7706 // // Ethereal Ring Visual, Lightning Aura (Fork)
7707 // case 41525: break;
7708 // // Ethereal Ring Visual, Lightning Jumper Aura
7709 // case 41567: break;
7710 // // No Man's Land
7711 // case 41955: break;
7712 // // Headless Horseman - Fire
7713 // case 42074: break;
7714 // // Headless Horseman - Visual - Large Fire
7715 // case 42075: break;
7716 // // Headless Horseman - Start Fire, Periodic Aura
7717 // case 42140: break;
7718 // // Ram Speed Boost
7719 // case 42152: break;
7720 // // Headless Horseman - Fires Out Victory Aura
7721 // case 42235: break;
7722 // // Pumpkin Life Cycle
7723 // case 42280: break;
7724 // // Brewfest Request Chick Chuck Mug Aura
7725 // case 42537: break;
7726 // // Squashling
7727 // case 42596: break;
7728 // // Headless Horseman Climax, Head: Periodic
7729 // case 42603: break;
7730 // // Fire Bomb
7731 // case 42621: break;
7732 // // Headless Horseman - Conflagrate, Periodic Aura
7733 // case 42637: break;
7734 // // Headless Horseman - Create Pumpkin Treats Aura
7735 // case 42774: break;
7736 // // Headless Horseman Climax - Summoning Rhyme Aura
7737 // case 42879: break;
7738 // // Tricky Treat
7739 // case 42919: break;
7740 // // Giddyup!
7741 // case 42924: break;
7742 // // Ram - Trot
7743 // case 42992: break;
7744 // // Ram - Canter
7745 // case 42993: break;
7746 // // Ram - Gallop
7747 // case 42994: break;
7748 // // Ram Level - Neutral
7749 // case 43310: break;
7750 // // Headless Horseman - Maniacal Laugh, Maniacal, Delayed 17
7751 // case 43884: break;
7752 // // Wretched!
7753 // case 43963: break;
7754 // // Headless Horseman - Maniacal Laugh, Maniacal, other, Delayed 17
7755 // case 44000: break;
7756 // // Energy Feedback
7757 // case 44328: break;
7758 // // Romantic Picnic
7759 // case 45102: break;
7760 // // Romantic Picnic
7761 // case 45123: break;
7762 // // Looking for Love
7763 // case 45124: break;
7764 // // Kite - Lightning Strike Kite Aura
7765 // case 45197: break;
7766 // // Rocket Chicken
7767 // case 45202: break;
7768 // // Copy Offhand Weapon
7769 // case 45205: break;
7770 // // Upper Deck - Kite - Lightning Periodic Aura
7771 // case 45207: break;
7772 // // Kite -Sky Lightning Strike Kite Aura
7773 // case 45251: break;
7774 // // Ribbon Pole Dancer Check Aura
7775 // case 45390: break;
7776 // // Holiday - Midsummer, Ribbon Pole Periodic Visual
7777 // case 45406: break;
7778 // // Parachute
7779 // case 45472: break;
7780 // // Alliance Flag, Extra Damage Debuff
7781 // case 45898: break;
7782 // // Horde Flag, Extra Damage Debuff
7783 // case 45899: break;
7784 // // Ahune - Summoning Rhyme Aura
7785 // case 45926: break;
7786 // // Ahune - Slippery Floor
7787 // case 45945: break;
7788 // // Ahune's Shield
7789 // case 45954: break;
7790 // // Nether Vapor Lightning
7791 // case 45960: break;
7792 // // Darkness
7793 // case 45996: break;
7794 case 46041: // Summon Blood Elves Periodic
7795 m_target->CastSpell(m_target, 46037, true, NULL, this);
7796 m_target->CastSpell(m_target, roll_chance_i(50) ? 46038 : 46039, true, NULL, this);
7797 m_target->CastSpell(m_target, 46040, true, NULL, this);
7798 return;
7799 // // Transform Visual Missile Periodic
7800 // case 46205: break;
7801 // // Find Opening Beam End
7802 // case 46333: break;
7803 // // Ice Spear Control Aura
7804 // case 46371: break;
7805 // // Hailstone Chill
7806 // case 46458: break;
7807 // // Hailstone Chill, Internal
7808 // case 46465: break;
7809 // // Chill, Internal Shifter
7810 // case 46549: break;
7811 // // Summon Ice Spear Knockback Delayer
7812 // case 46878: break;
7813 // // Burninate Effect
7814 // case 47214: break;
7815 // // Fizzcrank Practice Parachute
7816 // case 47228: break;
7817 // // Send Mug Control Aura
7818 // case 47369: break;
7819 // // Direbrew's Disarm (precast)
7820 // case 47407: break;
7821 // // Mole Machine Port Schedule
7822 // case 47489: break;
7823 // case 47941: break; // Crystal Spike
7824 // case 48200: break; // Healer Aura
7825 case 48630: // Summon Gauntlet Mobs Periodic
7826 case 59275: // Below may need some adjustment, pattern for amount of summon and where is not verified 100% (except for odd/even tick)
7828 bool chance = roll_chance_i(50);
7830 m_target->CastSpell(m_target, chance ? 48631 : 48632, true, NULL, this);
7832 if (GetAuraTicks() % 2) // which doctor at odd tick
7833 m_target->CastSpell(m_target, chance ? 48636 : 48635, true, NULL, this);
7834 else // or harponeer, at even tick
7835 m_target->CastSpell(m_target, chance ? 48634 : 48633, true, NULL, this);
7837 return;
7839 // case 49313: break; // Proximity Mine Area Aura
7840 // // Mole Machine Portal Schedule
7841 // case 49466: break;
7842 // case 49555: break; // Corpse Explode
7843 // case 49592: break; // Temporal Rift
7844 // case 49957: break; // Cutting Laser
7845 // case 50085: break; // Slow Fall
7846 // // Listening to Music
7847 // case 50493: break;
7848 // // Love Rocket Barrage
7849 // case 50530: break;
7850 case 50789: // Summon iron dwarf (left or right)
7851 case 59860:
7852 m_target->CastSpell(m_target, roll_chance_i(50) ? 50790 : 50791, true, NULL, this);
7853 return;
7854 case 50792: // Summon iron trogg (left or right)
7855 case 59859:
7856 m_target->CastSpell(m_target, roll_chance_i(50) ? 50793 : 50794, true, NULL, this);
7857 return;
7858 case 50801: // Summon malformed ooze (left or right)
7859 case 59858:
7860 m_target->CastSpell(m_target, roll_chance_i(50) ? 50802 : 50803, true, NULL, this);
7861 return;
7862 case 50824: // Summon earthen dwarf
7863 m_target->CastSpell(m_target, roll_chance_i(50) ? 50825 : 50826, true, NULL, this);
7864 return;
7865 case 52441: // Cool Down
7866 m_target->CastSpell(m_target, 52443, true);
7867 return;
7868 case 53520: // Carrion Beetles
7869 m_target->CastSpell(m_target, 53521, true, NULL, this);
7870 m_target->CastSpell(m_target, 53521, true, NULL, this);
7871 return;
7872 case 55592: // Clean
7873 switch(urand(0,2))
7875 case 0: m_target->CastSpell(m_target, 55731, true); break;
7876 case 1: m_target->CastSpell(m_target, 55738, true); break;
7877 case 2: m_target->CastSpell(m_target, 55739, true); break;
7879 return;
7880 // Exist more after, need add later
7881 default:
7882 break;
7884 // Prey on the Weak
7885 if (spell->SpellIconID == 2983)
7887 Unit *target=m_target->getVictim();
7888 if (target && (m_target->GetHealth() * 100 / m_target->GetMaxHealth() > target->GetHealth() * 100 / target->GetMaxHealth()))
7890 if(!m_target->HasAura(58670))
7892 int32 basepoints = GetBasePoints();
7893 m_target->CastCustomSpell(m_target, 58670, &basepoints, 0, 0, true);
7896 else
7897 m_target->RemoveAurasDueToSpell(58670);
7899 break;
7900 case SPELLFAMILY_MAGE:
7902 // Mirror Image
7903 // if (spell->Id == 55342)
7904 // return;
7905 break;
7907 case SPELLFAMILY_DRUID:
7909 switch (spell->Id)
7911 // Frenzied Regeneration
7912 case 22842:
7914 // Converts up to 10 rage per second into health for $d. Each point of rage is converted into ${$m2/10}.1% of max health.
7915 // Should be manauser
7916 if (m_target->getPowerType() != POWER_RAGE)
7917 return;
7918 uint32 rage = m_target->GetPower(POWER_RAGE);
7919 // Nothing todo
7920 if (rage == 0)
7921 return;
7922 int32 mod = (rage < 100) ? rage : 100;
7923 int32 points = m_target->CalculateSpellDamage(m_target, spell, EFFECT_INDEX_1);
7924 int32 regen = m_target->GetMaxHealth() * (mod * points / 10) / 1000;
7925 m_target->CastCustomSpell(m_target, 22845, &regen, NULL, NULL, true, NULL, this);
7926 m_target->SetPower(POWER_RAGE, rage-mod);
7927 return;
7929 // Force of Nature
7930 case 33831:
7931 return;
7932 default:
7933 break;
7935 break;
7937 case SPELLFAMILY_ROGUE:
7939 switch (spell->Id)
7941 // Killing Spree
7942 case 51690:
7944 if (m_target->hasUnitState(UNIT_STAT_STUNNED) || m_target->isFeared())
7945 return;
7947 std::list<Unit*> targets;
7949 // eff_radius ==0
7950 float radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spell->rangeIndex));
7952 MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck u_check(m_target, m_target, radius);
7953 MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck> checker(m_target, targets, u_check);
7954 Cell::VisitAllObjects(m_target, checker, radius);
7957 if(targets.empty())
7958 return;
7960 std::list<Unit*>::const_iterator itr = targets.begin();
7961 std::advance(itr, rand()%targets.size());
7962 Unit* target = *itr;
7964 m_target->CastSpell(target, 57840, true);
7965 m_target->CastSpell(target, 57841, true);
7966 return;
7968 default:
7969 break;
7971 break;
7973 case SPELLFAMILY_HUNTER:
7975 // Explosive Shot
7976 if (spell->SpellFamilyFlags & UI64LIT(0x8000000000000000))
7978 m_target->CastCustomSpell(m_target, 53352, &m_modifier.m_amount, 0, 0, true, 0, this, GetCasterGUID());
7979 return;
7981 switch (spell->Id)
7983 // Harpooner's Mark
7984 // case 40084:
7985 // return;
7986 // Feeding Frenzy Rank 1 & 2
7987 case 53511:
7988 case 53512:
7990 Unit* victim = m_target->getVictim();
7991 if( victim && victim->GetHealth() * 100 < victim->GetMaxHealth() * 35 )
7992 m_target->CastSpell(m_target, spell->Id == 53511 ? 60096 : 60097, true, NULL, this);
7993 return;
7995 default:
7996 break;
7998 break;
8000 case SPELLFAMILY_SHAMAN:
8002 // Astral Shift
8003 if (spell->Id == 52179)
8005 // Periodic need for remove visual on stun/fear/silence lost
8006 if (!(m_target->GetUInt32Value(UNIT_FIELD_FLAGS)&(UNIT_FLAG_STUNNED|UNIT_FLAG_FLEEING|UNIT_FLAG_SILENCED)))
8007 m_target->RemoveAurasDueToSpell(52179);
8008 return;
8010 break;
8012 case SPELLFAMILY_DEATHKNIGHT:
8014 // Death and Decay
8015 if (spell->SpellFamilyFlags & UI64LIT(0x0000000000000020))
8017 if (Unit *caster = GetCaster())
8018 caster->CastCustomSpell(m_target, 52212, &m_modifier.m_amount, NULL, NULL, true, NULL, this);
8019 return;
8021 // Raise Dead
8022 // if (spell->SpellFamilyFlags & UI64LIT(0x0000000000001000))
8023 // return;
8024 // Chains of Ice
8025 if (spell->SpellFamilyFlags & UI64LIT(0x0000400000000000))
8027 // Get 0 effect aura
8028 Aura *slow = m_target->GetAura(GetId(), EFFECT_INDEX_0);
8029 if (slow)
8031 slow->ApplyModifier(false, true);
8032 Modifier *mod = slow->GetModifier();
8033 mod->m_amount+= m_modifier.m_amount;
8034 if (mod->m_amount > 0) mod->m_amount = 0;
8035 slow->ApplyModifier(true, true);
8037 return;
8039 // Summon Gargoyle
8040 // if (spell->SpellFamilyFlags & UI64LIT(0x0000008000000000))
8041 // return;
8042 // Death Rune Mastery
8043 // if (spell->SpellFamilyFlags & UI64LIT(0x0000000000004000))
8044 // return;
8045 // Bladed Armor
8046 if (spell->SpellIconID == 2653)
8048 // Increases your attack power by $s1 for every $s2 armor value you have.
8049 // Calculate AP bonus (from 1 efect of this spell)
8050 int32 apBonus = m_modifier.m_amount * m_target->GetArmor() / m_target->CalculateSpellDamage(m_target, spell, EFFECT_INDEX_1);
8051 m_target->CastCustomSpell(m_target, 61217, &apBonus, &apBonus, NULL, true, NULL, this);
8052 return;
8054 // Reaping
8055 // if (spell->SpellIconID == 22)
8056 // return;
8057 // Blood of the North
8058 // if (spell->SpellIconID == 30412)
8059 // return;
8060 break;
8062 default:
8063 break;
8067 void Aura::HandlePreventFleeing(bool apply, bool Real)
8069 if(!Real)
8070 return;
8072 Unit::AuraList const& fearAuras = m_target->GetAurasByType(SPELL_AURA_MOD_FEAR);
8073 if( !fearAuras.empty() )
8075 if (apply)
8076 m_target->SetFeared(false, fearAuras.front()->GetCasterGUID());
8077 else
8078 m_target->SetFeared(true);
8082 void Aura::HandleManaShield(bool apply, bool Real)
8084 if(!Real)
8085 return;
8087 // prevent double apply bonuses
8088 if(apply && (m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading()))
8090 if(Unit* caster = GetCaster())
8092 float DoneActualBenefit = 0.0f;
8093 switch(m_spellProto->SpellFamilyName)
8095 case SPELLFAMILY_MAGE:
8096 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000008000))
8098 // Mana Shield
8099 // +50% from +spd bonus
8100 DoneActualBenefit = caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellProto)) * 0.5f;
8101 break;
8103 break;
8104 default:
8105 break;
8108 DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto());
8110 m_modifier.m_amount += (int32)DoneActualBenefit;
8115 void Aura::HandleArenaPreparation(bool apply, bool Real)
8117 if(!Real)
8118 return;
8120 if(apply)
8121 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION);
8122 else
8123 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION);
8127 * Such auras are applied from a caster(=player) to a vehicle.
8128 * This has been verified using spell #49256
8130 void Aura::HandleAuraControlVehicle(bool apply, bool Real)
8132 if(!Real)
8133 return;
8135 Unit *player = GetCaster();
8136 Vehicle *vehicle = dynamic_cast<Vehicle*>(m_target);
8137 if(!player || player->GetTypeId() != TYPEID_PLAYER || !vehicle)
8138 return;
8140 if (apply)
8142 if(Pet *pet = player->GetPet())
8143 pet->Remove(PET_SAVE_AS_CURRENT);
8144 ((Player*)player)->EnterVehicle(vehicle);
8146 else
8148 SpellEntry const *spell = GetSpellProto();
8150 // some SPELL_AURA_CONTROL_VEHICLE auras have a dummy effect on the player - remove them
8151 player->RemoveAurasDueToSpell(spell->Id);
8153 ((Player*)player)->ExitVehicle(vehicle);
8157 void Aura::HandleAuraConvertRune(bool apply, bool Real)
8159 if(!Real)
8160 return;
8162 if(m_target->GetTypeId() != TYPEID_PLAYER)
8163 return;
8165 Player *plr = (Player*)m_target;
8167 if(plr->getClass() != CLASS_DEATH_KNIGHT)
8168 return;
8170 RuneType runeFrom = RuneType(GetSpellProto()->EffectMiscValue[m_effIndex]);
8171 RuneType runeTo = RuneType(GetSpellProto()->EffectMiscValueB[m_effIndex]);
8173 if (apply)
8175 for(uint32 i = 0; i < MAX_RUNES; ++i)
8177 if (plr->GetCurrentRune(i) == runeFrom && !plr->GetRuneCooldown(i))
8179 plr->ConvertRune(i, runeTo);
8180 break;
8184 else
8186 for(uint32 i = 0; i < MAX_RUNES; ++i)
8188 if(plr->GetCurrentRune(i) == runeTo && plr->GetBaseRune(i) == runeFrom)
8190 plr->ConvertRune(i, runeFrom);
8191 break;
8197 void Aura::HandlePhase(bool apply, bool Real)
8199 if(!Real)
8200 return;
8202 // always non stackable
8203 if(apply)
8205 Unit::AuraList const& phases = m_target->GetAurasByType(SPELL_AURA_PHASE);
8206 if(!phases.empty())
8207 m_target->RemoveAurasDueToSpell(phases.front()->GetId(), this);
8210 // no-phase is also phase state so same code for apply and remove
8212 // phase auras normally not expected at BG but anyway better check
8213 if(m_target->GetTypeId() == TYPEID_PLAYER)
8215 // drop flag at invisible in bg
8216 if(((Player*)m_target)->InBattleGround())
8217 if(BattleGround *bg = ((Player*)m_target)->GetBattleGround())
8218 bg->EventPlayerDroppedFlag((Player*)m_target);
8220 // GM-mode have mask 0xFFFFFFFF
8221 if(!((Player*)m_target)->isGameMaster())
8222 m_target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL, false);
8224 ((Player*)m_target)->GetSession()->SendSetPhaseShift(apply ? GetMiscValue() : PHASEMASK_NORMAL);
8226 if (GetEffIndex() == EFFECT_INDEX_0)
8228 SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAuraMapBounds(GetId());
8229 if(saBounds.first != saBounds.second)
8231 uint32 zone, area;
8232 m_target->GetZoneAndAreaId(zone, area);
8234 for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
8236 // some auras remove at aura remove
8237 if(!itr->second->IsFitToRequirements((Player*)m_target, zone, area))
8238 m_target->RemoveAurasDueToSpell(itr->second->spellId);
8239 // some auras applied at aura apply
8240 else if(itr->second->autocast)
8242 if (!m_target->HasAura(itr->second->spellId, EFFECT_INDEX_0))
8243 m_target->CastSpell(m_target, itr->second->spellId, true);
8249 else
8250 m_target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL, false);
8252 // need triggering visibility update base at phase update of not GM invisible (other GMs anyway see in any phases)
8253 if(m_target->GetVisibility() != VISIBILITY_OFF)
8254 m_target->SetVisibility(m_target->GetVisibility());
8257 void Aura::UnregisterSingleCastAura()
8259 if (IsSingleTarget())
8261 if(Unit* caster = GetCaster())
8263 caster->GetSingleCastAuras().remove(this);
8265 else
8267 sLog.outError("Couldn't find the caster of the single target aura (SpellId %u), may crash later!", GetId());
8268 ASSERT(false);
8270 m_isSingleTargetAura = false;
8274 void Aura::HandleAuraSafeFall( bool Apply, bool Real )
8276 // implemented in WorldSession::HandleMovementOpcodes
8278 // only special case
8279 if(Apply && Real && GetId() == 32474 && m_target->GetTypeId() == TYPEID_PLAYER)
8280 ((Player*)m_target)->ActivateTaxiPathTo(506, GetId());
8283 bool Aura::IsCritFromAbilityAura(Unit* caster, uint32& damage)
8285 Unit::AuraList const& auras = caster->GetAurasByType(SPELL_AURA_ABILITY_PERIODIC_CRIT);
8286 for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
8288 if (!(*itr)->isAffectedOnSpell(m_spellProto))
8289 continue;
8290 if (!caster->IsSpellCrit(m_target, m_spellProto, GetSpellSchoolMask(m_spellProto)))
8291 break;
8293 damage = caster->SpellCriticalDamageBonus(m_spellProto, damage, m_target);
8294 return true;
8296 return false;
8299 void Aura::HandleModTargetArmorPct(bool /*apply*/, bool /*Real*/)
8301 if(m_target->GetTypeId() != TYPEID_PLAYER)
8302 return;
8304 ((Player*)m_target)->UpdateArmorPenetration();
8307 void Aura::HandleAuraModAllCritChance(bool apply, bool Real)
8309 // spells required only Real aura add/remove
8310 if(!Real)
8311 return;
8313 if(m_target->GetTypeId() != TYPEID_PLAYER)
8314 return;
8316 ((Player*)m_target)->HandleBaseModValue(CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
8317 ((Player*)m_target)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
8318 ((Player*)m_target)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
8320 // included in Player::UpdateSpellCritChance calculation
8321 ((Player*)m_target)->UpdateAllSpellCritChances();
8324 void Aura::HandleAllowOnlyAbility(bool apply, bool Real)
8326 if(!Real)
8327 return;
8329 if(apply)
8331 m_target->setAttackTimer(BASE_ATTACK,m_duration);
8332 m_target->setAttackTimer(RANGED_ATTACK,m_duration);
8333 m_target->setAttackTimer(OFF_ATTACK,m_duration);
8335 else
8337 m_target->resetAttackTimer(BASE_ATTACK);
8338 m_target->resetAttackTimer(RANGED_ATTACK);
8339 m_target->resetAttackTimer(OFF_ATTACK);
8342 m_target->UpdateDamagePhysical(BASE_ATTACK);
8343 m_target->UpdateDamagePhysical(RANGED_ATTACK);
8344 m_target->UpdateDamagePhysical(OFF_ATTACK);