[9033] Fixed percent mana regneration from spell 53228 and ranks buff.
[getmangos.git] / src / game / SpellAuras.cpp
blob337340650cca903f4bdf89969606fce3cf121161
1 /*
2 * Copyright (C) 2005-2009 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::MeleeDamageBonus and Unit::SpellBaseDamageBonusForVictim
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::MeleeDamageBonus and Unit::SpellDamageBonus
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::CalcAbsorbResist
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::CalcAbsorbResist
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::MeleeDamageBonus and Unit::SpellDamageBonus
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::CalcAbsorbResist
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::MeleeDamageBonus
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::MeleeDamageBonus
167 &Aura::HandleNoImmediateEffect, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus
168 &Aura::HandleNoImmediateEffect, //115 SPELL_AURA_MOD_HEALING implemented in Unit::SpellBaseHealingBonusForVictim
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::SpellHealingBonus
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::MeleeDamageBonus
179 &Aura::HandleNoImmediateEffect, //126 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus
180 &Aura::HandleNoImmediateEffect, //127 SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus
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::MeleeDamageBonus
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::SpellHealingBonus
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::CalcAbsorbResist
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_MELEE implememnted 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::MeleeDamageBonus
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::SpellDamageBonus, Unit::MeleeDamageBonus
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::SpellBaseDamageBonus
228 &Aura::HandleModSpellHealingPercentFromStat, //175 SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT implemented in Unit::SpellBaseHealingBonus
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::SpellDamageBonus
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_MELEE_SLOW (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::HandleNULL, //206 SPELL_AURA_MOD_SPEED_MOUNTED
260 &Aura::HandleAuraModIncreaseFlightSpeed, //207 SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
261 &Aura::HandleAuraModIncreaseFlightSpeed, //208 SPELL_AURA_MOD_SPEED_FLIGHT, used only in spell: Flight Form (Passive)
262 &Aura::HandleAuraModIncreaseFlightSpeed, //209 SPELL_AURA_MOD_FLIGHT_SPEED_ALWAYS
263 &Aura::HandleNULL, //210 "Increase flight speed by"
264 &Aura::HandleAuraModIncreaseFlightSpeed, //211 SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK
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::SpellDamageBonus
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::SpellBaseDamageBonus
291 &Aura::HandleModSpellHealingPercentFromAttackPower, //238 SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER implemented in Unit::SpellBaseHealingBonus
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::HandleNULL, //252 haste all?
306 &Aura::HandleNULL, //253 SPELL_AURA_MOD_BLOCK_CRIT_CHANCE
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::SpellDamageBonus
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::SpellDamageBonus
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::SpellHealingBonus
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
362 static AuraType const frozenAuraTypes[] = { SPELL_AURA_MOD_ROOT, SPELL_AURA_MOD_STUN, SPELL_AURA_NONE };
364 Aura::Aura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) :
365 m_spellmod(NULL), m_caster_guid(0), m_target(target), m_castItemGuid(castItem?castItem->GetGUID():0),
366 m_timeCla(1000), m_periodicTimer(0), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE),
367 m_effIndex(eff), m_auraSlot(MAX_AURAS), m_auraFlags(AFLAG_NONE), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),
368 m_positive(false), m_permanent(false), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false),
369 m_isRemovedOnShapeLost(true), m_in_use(0), m_deleted(false)
371 assert(target);
373 assert(spellproto && spellproto == sSpellStore.LookupEntry( spellproto->Id ) && "`info` must be pointer to sSpellStore element");
375 m_spellProto = spellproto;
377 m_currentBasePoints = currentBasePoints ? *currentBasePoints : m_spellProto->EffectBasePoints[eff];
379 m_isPassive = IsPassiveSpell(GetId());
380 m_positive = IsPositiveEffect(GetId(), m_effIndex);
382 m_isSingleTargetAura = IsSingleTargetSpell(m_spellProto);
384 m_applyTime = time(NULL);
386 int32 damage;
387 if(!caster)
389 m_caster_guid = target->GetGUID();
390 damage = m_currentBasePoints+1; // stored value-1
391 m_maxduration = target->CalculateSpellDuration(m_spellProto, m_effIndex, target);
393 else
395 m_caster_guid = caster->GetGUID();
397 damage = caster->CalculateSpellDamage(m_spellProto,m_effIndex,m_currentBasePoints,target);
398 m_maxduration = caster->CalculateSpellDuration(m_spellProto, m_effIndex, target);
400 if (!damage && castItem && castItem->GetItemSuffixFactor())
402 ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(castItem->GetItemRandomPropertyId()));
403 if(item_rand_suffix)
405 for (int k = 0; k < 3; ++k)
407 SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(item_rand_suffix->enchant_id[k]);
408 if(pEnchant)
410 for (int t = 0; t < 3; ++t)
411 if(pEnchant->spellid[t] == m_spellProto->Id)
413 damage = uint32((item_rand_suffix->prefix[k]*castItem->GetItemSuffixFactor()) / 10000 );
414 break;
418 if(damage)
419 break;
425 if(m_maxduration == -1 || m_isPassive && m_spellProto->DurationIndex == 0)
426 m_permanent = true;
428 Player* modOwner = caster ? caster->GetSpellModOwner() : NULL;
430 if(!m_permanent && modOwner)
432 modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, m_maxduration);
433 // Get zero duration aura after - need set m_maxduration > 0 for apply/remove aura work
434 if (m_maxduration<=0)
435 m_maxduration = 1;
438 m_duration = m_maxduration;
440 sLog.outDebug("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);
442 m_effIndex = eff;
443 SetModifier(AuraType(m_spellProto->EffectApplyAuraName[eff]), damage, m_spellProto->EffectAmplitude[eff], m_spellProto->EffectMiscValue[eff]);
445 // Apply periodic time mod
446 if(modOwner && m_modifier.periodictime)
447 modOwner->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME, m_modifier.periodictime);
449 // Start periodic on next tick or at aura apply
450 if (!(m_spellProto->AttributesEx5 & SPELL_ATTR_EX5_START_PERIODIC_AT_APPLY))
451 m_periodicTimer += m_modifier.periodictime;
453 m_isDeathPersist = IsDeathPersistentSpell(m_spellProto);
455 m_procCharges = m_spellProto->procCharges;
456 if(modOwner)
457 modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges);
459 m_isRemovedOnShapeLost = (m_caster_guid==m_target->GetGUID() &&
460 m_spellProto->Stances &&
461 !(m_spellProto->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT) &&
462 !(m_spellProto->Attributes & SPELL_ATTR_NOT_SHAPESHIFT));
464 if (caster && m_spellProto->Id == 22959) // Improved Scorch
466 // Glyph of Improved Scorch
467 if (Aura* glyph = caster->GetDummyAura(56371))
468 m_stackAmount = glyph->GetModifier()->m_amount;
472 Aura::~Aura()
476 AreaAura::AreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target,
477 Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
479 m_isAreaAura = true;
481 // caster==NULL in constructor args if target==caster in fact
482 Unit* caster_ptr = caster ? caster : target;
484 m_radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(GetSpellProto()->EffectRadiusIndex[m_effIndex]));
485 if(Player* modOwner = caster_ptr->GetSpellModOwner())
486 modOwner->ApplySpellMod(GetId(), SPELLMOD_RADIUS, m_radius);
488 switch(spellproto->Effect[eff])
490 case SPELL_EFFECT_APPLY_AREA_AURA_PARTY:
491 m_areaAuraType = AREA_AURA_PARTY;
492 if (target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isTotem())
493 m_modifier.m_auraname = SPELL_AURA_NONE;
494 break;
495 case SPELL_EFFECT_APPLY_AREA_AURA_RAID:
496 m_areaAuraType = AREA_AURA_RAID;
497 if (target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isTotem())
498 m_modifier.m_auraname = SPELL_AURA_NONE;
499 // Light's Beacon not applied to caster itself (TODO: more generic check for another simialr spell if any?)
500 else if (target == caster_ptr && m_spellProto->Id == 53651)
501 m_modifier.m_auraname = SPELL_AURA_NONE;
502 break;
503 case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND:
504 m_areaAuraType = AREA_AURA_FRIEND;
505 break;
506 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY:
507 m_areaAuraType = AREA_AURA_ENEMY;
508 if (target == caster_ptr)
509 m_modifier.m_auraname = SPELL_AURA_NONE; // Do not do any effect on self
510 break;
511 case SPELL_EFFECT_APPLY_AREA_AURA_PET:
512 m_areaAuraType = AREA_AURA_PET;
513 break;
514 case SPELL_EFFECT_APPLY_AREA_AURA_OWNER:
515 m_areaAuraType = AREA_AURA_OWNER;
516 if (target == caster_ptr)
517 m_modifier.m_auraname = SPELL_AURA_NONE;
518 break;
519 default:
520 sLog.outError("Wrong spell effect in AreaAura constructor");
521 ASSERT(false);
522 break;
526 AreaAura::~AreaAura()
530 PersistentAreaAura::PersistentAreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target,
531 Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
533 m_isPersistent = true;
536 PersistentAreaAura::~PersistentAreaAura()
540 SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target,
541 Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
543 if (caster)
544 m_casters_target_guid = caster->GetTypeId()==TYPEID_PLAYER ? ((Player*)caster)->GetSelection() : caster->GetTargetGUID();
545 else
546 m_casters_target_guid = 0;
549 SingleEnemyTargetAura::~SingleEnemyTargetAura()
553 Unit* SingleEnemyTargetAura::GetTriggerTarget() const
555 return ObjectAccessor::GetUnit(*m_target, m_casters_target_guid);
558 Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem)
560 if (IsAreaAuraEffect(spellproto->Effect[eff]))
561 return new AreaAura(spellproto, eff, currentBasePoints, target, caster, castItem);
563 uint32 triggeredSpellId = spellproto->EffectTriggerSpell[eff];
565 if(SpellEntry const* triggeredSpellInfo = sSpellStore.LookupEntry(triggeredSpellId))
566 for (int i = 0; i < 3; ++i)
567 if (triggeredSpellInfo->EffectImplicitTargetA[i] == TARGET_SINGLE_ENEMY)
568 return new SingleEnemyTargetAura(spellproto, eff, currentBasePoints, target, caster, castItem);
570 return new Aura(spellproto, eff, currentBasePoints, target, caster, castItem);
573 Unit* Aura::GetCaster() const
575 if(m_caster_guid == m_target->GetGUID())
576 return m_target;
578 //return ObjectAccessor::GetUnit(*m_target,m_caster_guid);
579 //must return caster even if it's in another grid/map
580 Unit *unit = ObjectAccessor::GetUnitInWorld(*m_target,m_caster_guid);
581 return unit && unit->IsInWorld() ? unit : NULL;
584 void Aura::SetModifier(AuraType t, int32 a, uint32 pt, int32 miscValue)
586 m_modifier.m_auraname = t;
587 m_modifier.m_amount = a;
588 m_modifier.m_miscvalue = miscValue;
589 m_modifier.periodictime = pt;
592 void Aura::Update(uint32 diff)
594 if (m_duration > 0)
596 m_duration -= diff;
597 if (m_duration < 0)
598 m_duration = 0;
599 m_timeCla -= diff;
601 // GetEffIndex()==0 prevent double/triple apply manaPerSecond/manaPerSecondPerLevel to same spell with many auras
602 // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0
603 if(GetEffIndex()==0 && m_timeCla <= 0)
605 if(Unit* caster = GetCaster())
607 Powers powertype = Powers(m_spellProto->powerType);
608 int32 manaPerSecond = m_spellProto->manaPerSecond + m_spellProto->manaPerSecondPerLevel * caster->getLevel();
609 m_timeCla = 1*IN_MILISECONDS;
610 if (manaPerSecond)
612 if(powertype==POWER_HEALTH)
613 caster->ModifyHealth(-manaPerSecond);
614 else
615 caster->ModifyPower(powertype,-manaPerSecond);
621 // Channeled aura required check distance from caster
622 if(IsChanneledSpell(m_spellProto) && m_caster_guid != m_target->GetGUID())
624 Unit* caster = GetCaster();
625 if(!caster)
627 m_target->RemoveAura(GetId(), GetEffIndex());
628 return;
631 // need check distance for channeled target only
632 if (caster->GetChannelObjectGUID() == m_target->GetGUID())
634 // Get spell range
635 float max_range = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellProto->rangeIndex));
637 if(Player* modOwner = caster->GetSpellModOwner())
638 modOwner->ApplySpellMod(GetId(), SPELLMOD_RANGE, max_range, NULL);
640 if(!caster->IsWithinDistInMap(m_target, max_range))
642 m_target->RemoveAura(GetId(), GetEffIndex());
643 return;
648 if(m_isPeriodic && (m_duration >= 0 || m_isPassive || m_permanent))
650 m_periodicTimer -= diff;
651 if(m_periodicTimer <= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N
653 // update before applying (aura can be removed in TriggerSpell or PeriodicTick calls)
654 m_periodicTimer += m_modifier.periodictime;
655 PeriodicTick();
660 void AreaAura::Update(uint32 diff)
662 // update for the caster of the aura
663 if(m_caster_guid == m_target->GetGUID())
665 Unit* caster = m_target;
667 if( !caster->hasUnitState(UNIT_STAT_ISOLATED) )
669 Unit* owner = caster->GetCharmerOrOwner();
670 if (!owner)
671 owner = caster;
672 std::list<Unit *> targets;
674 switch(m_areaAuraType)
676 case AREA_AURA_PARTY:
678 Group *pGroup = NULL;
680 if (owner->GetTypeId() == TYPEID_PLAYER)
681 pGroup = ((Player*)owner)->GetGroup();
683 if( pGroup)
685 uint8 subgroup = ((Player*)owner)->GetSubGroup();
686 for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
688 Player* Target = itr->getSource();
689 if(Target && Target->isAlive() && Target->GetSubGroup()==subgroup && caster->IsFriendlyTo(Target))
691 if(caster->IsWithinDistInMap(Target, m_radius))
692 targets.push_back(Target);
693 Pet *pet = Target->GetPet();
694 if(pet && pet->isAlive() && caster->IsWithinDistInMap(pet, m_radius))
695 targets.push_back(pet);
699 else
701 // add owner
702 if( owner != caster && caster->IsWithinDistInMap(owner, m_radius) )
703 targets.push_back(owner);
704 // add caster's pet
705 Unit* pet = caster->GetPet();
706 if( pet && caster->IsWithinDistInMap(pet, m_radius))
707 targets.push_back(pet);
709 break;
711 case AREA_AURA_RAID:
713 Group *pGroup = NULL;
715 if (owner->GetTypeId() == TYPEID_PLAYER)
716 pGroup = ((Player*)owner)->GetGroup();
718 if( pGroup)
720 for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
722 Player* Target = itr->getSource();
723 if(Target && Target->isAlive() && caster->IsFriendlyTo(Target))
725 if(caster->IsWithinDistInMap(Target, m_radius))
726 targets.push_back(Target);
727 Pet *pet = Target->GetPet();
728 if(pet && pet->isAlive() && caster->IsWithinDistInMap(pet, m_radius))
729 targets.push_back(pet);
733 else
735 // add owner
736 if( owner != caster && caster->IsWithinDistInMap(owner, m_radius) )
737 targets.push_back(owner);
738 // add caster's pet
739 Unit* pet = caster->GetPet();
740 if( pet && caster->IsWithinDistInMap(pet, m_radius))
741 targets.push_back(pet);
743 break;
745 case AREA_AURA_FRIEND:
747 CellPair p(MaNGOS::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY()));
748 Cell cell(p);
749 cell.data.Part.reserved = ALL_DISTRICT;
750 cell.SetNoCreate();
752 MaNGOS::AnyFriendlyUnitInObjectRangeCheck u_check(caster, owner, m_radius);
753 MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck> searcher(caster,targets, u_check);
754 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
755 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
756 CellLock<GridReadGuard> cell_lock(cell, p);
757 cell_lock->Visit(cell_lock, world_unit_searcher, *caster->GetMap(), *caster, m_radius);
758 cell_lock->Visit(cell_lock, grid_unit_searcher, *caster->GetMap(), *caster, m_radius);
759 break;
761 case AREA_AURA_ENEMY:
763 CellPair p(MaNGOS::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY()));
764 Cell cell(p);
765 cell.data.Part.reserved = ALL_DISTRICT;
766 cell.SetNoCreate();
768 MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(caster, owner, m_radius); // No GetCharmer in searcher
769 MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(caster, targets, u_check);
770 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
771 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
772 CellLock<GridReadGuard> cell_lock(cell, p);
773 cell_lock->Visit(cell_lock, world_unit_searcher, *caster->GetMap(), *caster, m_radius);
774 cell_lock->Visit(cell_lock, grid_unit_searcher, *caster->GetMap(), *caster, m_radius);
775 break;
777 case AREA_AURA_OWNER:
778 case AREA_AURA_PET:
780 if(owner != caster && caster->IsWithinDistInMap(owner, m_radius))
781 targets.push_back(owner);
782 break;
786 for(std::list<Unit *>::iterator tIter = targets.begin(); tIter != targets.end(); tIter++)
788 // flag for seelction is need apply aura to current iteration target
789 bool apply = true;
791 // we need ignore present caster self applied are auras sometime
792 // in cases if this only auras applied for spell effect
793 Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), m_effIndex);
794 for(Unit::AuraMap::const_iterator i = (*tIter)->GetAuras().lower_bound(spair); i != (*tIter)->GetAuras().upper_bound(spair); ++i)
796 if (i->second->IsDeleted())
797 continue;
799 switch(m_areaAuraType)
801 case AREA_AURA_ENEMY:
802 // non caster self-casted auras (non stacked)
803 if(i->second->GetModifier()->m_auraname != SPELL_AURA_NONE)
804 apply = false;
805 break;
806 case AREA_AURA_RAID:
807 // non caster self-casted auras (stacked from diff. casters)
808 if(i->second->GetModifier()->m_auraname != SPELL_AURA_NONE || i->second->GetCasterGUID() == GetCasterGUID())
809 apply = false;
810 break;
811 default:
812 // in generic case not allow stacking area auras
813 apply = false;
814 break;
817 if(!apply)
818 break;
821 if(!apply)
822 continue;
824 if(SpellEntry const *actualSpellInfo = sSpellMgr.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter)->getLevel()))
826 int32 actualBasePoints = m_currentBasePoints;
827 // recalculate basepoints for lower rank (all AreaAura spell not use custom basepoints?)
828 if(actualSpellInfo != GetSpellProto())
829 actualBasePoints = actualSpellInfo->EffectBasePoints[m_effIndex];
830 AreaAura *aur = new AreaAura(actualSpellInfo, m_effIndex, &actualBasePoints, (*tIter), caster, NULL);
831 aur->SetAuraDuration(GetAuraDuration());
832 (*tIter)->AddAura(aur);
836 Aura::Update(diff);
838 else // aura at non-caster
840 Unit* caster = GetCaster();
842 Aura::Update(diff);
844 // remove aura if out-of-range from caster (after teleport for example)
845 // or caster is isolated or caster no longer has the aura
846 // or caster is (no longer) friendly
847 bool needFriendly = (m_areaAuraType == AREA_AURA_ENEMY ? false : true);
848 if( !caster || caster->hasUnitState(UNIT_STAT_ISOLATED) ||
849 !caster->IsWithinDistInMap(m_target, m_radius) ||
850 !caster->HasAura(GetId(), GetEffIndex()) ||
851 caster->IsFriendlyTo(m_target) != needFriendly
854 m_target->RemoveAurasByCasterSpell(GetId(), GetEffIndex(),GetCasterGUID());
856 else if( m_areaAuraType == AREA_AURA_PARTY) // check if in same sub group
858 // not check group if target == owner or target == pet
859 if (caster->GetCharmerOrOwnerGUID() != m_target->GetGUID() && caster->GetGUID() != m_target->GetCharmerOrOwnerGUID())
861 Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself();
863 Group *pGroup = check ? check->GetGroup() : NULL;
864 if( pGroup )
866 Player* checkTarget = m_target->GetCharmerOrOwnerPlayerOrPlayerItself();
867 if(!checkTarget || !pGroup->SameSubGroup(check, checkTarget))
868 m_target->RemoveAura(GetId(), GetEffIndex());
870 else
871 m_target->RemoveAura(GetId(), GetEffIndex());
874 else if( m_areaAuraType == AREA_AURA_RAID) // TODO: fix me!
876 // not check group if target == owner or target == pet
877 if (caster->GetCharmerOrOwnerGUID() != m_target->GetGUID() && caster->GetGUID() != m_target->GetCharmerOrOwnerGUID())
879 Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself();
881 Group *pGroup = check ? check->GetGroup() : NULL;
882 if( pGroup )
884 Player* checkTarget = m_target->GetCharmerOrOwnerPlayerOrPlayerItself();
885 if(!checkTarget)
886 m_target->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
888 else
889 m_target->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
892 else if( m_areaAuraType == AREA_AURA_PET || m_areaAuraType == AREA_AURA_OWNER )
894 if( m_target->GetGUID() != caster->GetCharmerOrOwnerGUID() )
895 m_target->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
900 void PersistentAreaAura::Update(uint32 diff)
902 bool remove = false;
904 // remove the aura if its caster or the dynamic object causing it was removed
905 // or if the target moves too far from the dynamic object
906 if(Unit *caster = GetCaster())
908 DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex());
909 if (dynObj)
911 if (!m_target->IsWithinDistInMap(dynObj, dynObj->GetRadius()))
912 remove = true;
914 else
915 remove = true;
917 else
918 remove = true;
920 Aura::Update(diff);
922 if(remove)
923 m_target->RemoveAura(GetId(), GetEffIndex());
926 void Aura::ApplyModifier(bool apply, bool Real)
928 AuraType aura = m_modifier.m_auraname;
930 SetInUse(true);
931 if(aura < TOTAL_AURAS)
932 (*this.*AuraHandler [aura])(apply, Real);
933 SetInUse(false);
936 bool Aura::IsNeedVisibleSlot(Unit const* caster) const
938 bool totemAura = caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem();
940 // passive auras (except totem auras) do not get placed in the slots
941 if (m_isPassive && !totemAura)
942 return false;
944 // generic not caster case
945 if (m_target != caster)
946 return true;
948 // special area auras case at caster
949 switch(m_spellProto->Effect[GetEffIndex()])
951 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY:
952 return false;
953 case SPELL_EFFECT_APPLY_AREA_AURA_RAID:
954 // not sure is totemAura need, just preserve old code results
955 return totemAura || m_modifier.m_auraname != SPELL_AURA_NONE;
956 default: break;
959 return true;
962 void Aura::_AddAura()
964 if (!GetId())
965 return;
966 if(!m_target)
967 return;
969 // Second aura if some spell
970 bool secondaura = false;
971 // Try find slot for aura
972 uint8 slot = NULL_AURA_SLOT;
973 // Lookup for some spell auras (and get slot from it)
974 for(uint8 i = 0; i < m_effIndex; ++i)
976 Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), i);
977 for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr)
979 // allow use single slot only by auras from same caster
980 if(itr->second->GetCasterGUID()==GetCasterGUID())
982 slot = itr->second->GetAuraSlot();
983 secondaura = true;
984 break;
987 if (secondaura)
988 break;
990 // Lookup free slot
991 if (!secondaura && m_target->GetVisibleAurasCount() < MAX_AURAS)
993 Unit::VisibleAuraMap const *visibleAuras = m_target->GetVisibleAuras();
994 for(uint8 i = 0; i < MAX_AURAS; ++i)
996 Unit::VisibleAuraMap::const_iterator itr = visibleAuras->find(i);
997 if(itr == visibleAuras->end())
999 slot = i;
1000 // update for out of range group members (on 1 slot use)
1001 m_target->UpdateAuraForGroup(slot);
1002 break;
1007 Unit* caster = GetCaster();
1009 // set infinity cooldown state for spells
1010 if(caster && caster->GetTypeId() == TYPEID_PLAYER)
1012 if (m_spellProto->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE)
1014 Item* castItem = m_castItemGuid ? ((Player*)caster)->GetItemByGuid(m_castItemGuid) : NULL;
1015 ((Player*)caster)->AddSpellAndCategoryCooldowns(m_spellProto,castItem ? castItem->GetEntry() : 0, NULL,true);
1019 if (IsNeedVisibleSlot(caster))
1021 SetAuraSlot( slot );
1022 if(slot < MAX_AURAS) // slot found send data to client
1024 SetAura(false);
1025 SetAuraFlags((1 << GetEffIndex()) | AFLAG_NOT_CASTER | ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION : AFLAG_NONE) | (IsPositive() ? AFLAG_POSITIVE : AFLAG_NEGATIVE));
1026 SetAuraLevel(caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
1027 SendAuraUpdate(false);
1030 //*****************************************************
1031 // Update target aura state flag (at 1 aura apply)
1032 // TODO: Make it easer
1033 //*****************************************************
1034 if (!secondaura)
1036 // Sitdown on apply aura req seated
1037 if (m_spellProto->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED && !m_target->IsSitState())
1038 m_target->SetStandState(UNIT_STAND_STATE_SIT);
1040 // register aura diminishing on apply
1041 if (getDiminishGroup() != DIMINISHING_NONE )
1042 m_target->ApplyDiminishingAura(getDiminishGroup(), true);
1044 // Update Seals information
1045 if (IsSealSpell(m_spellProto))
1046 m_target->ModifyAuraState(AURA_STATE_JUDGEMENT, true);
1048 // Conflagrate aura state on Immolate and Shadowflame
1049 if (m_spellProto->SpellFamilyName == SPELLFAMILY_WARLOCK &&
1050 // Immolate
1051 ((m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000004)) ||
1052 // Shadowflame
1053 (m_spellProto->SpellFamilyFlags2 & 0x00000002)))
1054 m_target->ModifyAuraState(AURA_STATE_CONFLAGRATE, true);
1056 // Faerie Fire (druid versions)
1057 if (m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000400)))
1058 m_target->ModifyAuraState(AURA_STATE_FAERIE_FIRE, true);
1060 // Victorious
1061 if (m_spellProto->SpellFamilyName == SPELLFAMILY_WARRIOR && (m_spellProto->SpellFamilyFlags & UI64LIT(0x0004000000000000)))
1062 m_target->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH, true);
1064 // Swiftmend state on Regrowth & Rejuvenation
1065 if (m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && (m_spellProto->SpellFamilyFlags & UI64LIT(0x50)))
1066 m_target->ModifyAuraState(AURA_STATE_SWIFTMEND, true);
1068 // Deadly poison aura state
1069 if(m_spellProto->SpellFamilyName == SPELLFAMILY_ROGUE && (m_spellProto->SpellFamilyFlags & UI64LIT(0x10000)))
1070 m_target->ModifyAuraState(AURA_STATE_DEADLY_POISON, true);
1072 // Enrage aura state
1073 if(m_spellProto->Dispel == DISPEL_ENRAGE)
1074 m_target->ModifyAuraState(AURA_STATE_ENRAGE, true);
1079 bool Aura::_RemoveAura()
1081 // Remove all triggered by aura spells vs unlimited duration
1082 // except same aura replace case
1083 if(m_removeMode!=AURA_REMOVE_BY_STACK)
1084 CleanupTriggeredSpells();
1086 Unit* caster = GetCaster();
1088 if(caster && IsPersistent())
1090 DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex());
1091 if (dynObj)
1092 dynObj->RemoveAffected(m_target);
1095 //passive auras do not get put in slots
1096 // Note: but totem can be not accessible for aura target in time remove (to far for find in grid)
1097 //if(m_isPassive && !(caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem()))
1098 // return;
1100 uint8 slot = GetAuraSlot();
1102 if(slot >= MAX_AURAS) // slot not set
1103 return false;
1105 if(m_target->GetVisibleAura(slot) == 0)
1106 return false;
1108 bool lastaura = true;
1110 // find other aura in same slot (current already removed from list)
1111 for(uint8 i = 0; i < 3; ++i)
1113 Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), i);
1114 for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr)
1116 if(itr->second->GetAuraSlot() == slot)
1118 lastaura = false;
1119 break;
1122 if(!lastaura)
1123 break;
1126 // only remove icon when the last aura of the spell is removed (current aura already removed from list)
1127 if (!lastaura)
1128 return false;
1130 // unregister aura diminishing (and store last time)
1131 if (getDiminishGroup() != DIMINISHING_NONE )
1132 m_target->ApplyDiminishingAura(getDiminishGroup(), false);
1134 SetAura(true);
1135 SetAuraFlags(AFLAG_NONE);
1136 SetAuraLevel(0);
1138 if (m_removeMode != AURA_REMOVE_BY_DELETE)
1140 SendAuraUpdate(true);
1142 // update for out of range group members
1143 m_target->UpdateAuraForGroup(slot);
1145 //*****************************************************
1146 // Update target aura state flag (at last aura remove)
1147 //*****************************************************
1148 // Enrage aura state
1149 if(m_spellProto->Dispel == DISPEL_ENRAGE)
1150 m_target->ModifyAuraState(AURA_STATE_ENRAGE, false);
1152 uint32 removeState = 0;
1153 uint64 removeFamilyFlag = m_spellProto->SpellFamilyFlags;
1154 uint32 removeFamilyFlag2 = m_spellProto->SpellFamilyFlags2;
1155 switch(m_spellProto->SpellFamilyName)
1157 case SPELLFAMILY_PALADIN:
1158 if (IsSealSpell(m_spellProto))
1159 removeState = AURA_STATE_JUDGEMENT; // Update Seals information
1160 break;
1161 case SPELLFAMILY_WARLOCK:
1162 // Conflagrate aura state on Immolate and Shadowflame,
1163 if ((m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000004)) ||
1164 (m_spellProto->SpellFamilyFlags2 & 0x00000002))
1166 removeFamilyFlag = UI64LIT(0x0000000000000004);
1167 removeFamilyFlag2 = 0x00000002;
1168 removeState = AURA_STATE_CONFLAGRATE;
1170 break;
1171 case SPELLFAMILY_DRUID:
1172 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000400))
1173 removeState = AURA_STATE_FAERIE_FIRE; // Faerie Fire (druid versions)
1174 else if(m_spellProto->SpellFamilyFlags & UI64LIT(0x50))
1176 removeFamilyFlag = 0x50;
1177 removeState = AURA_STATE_SWIFTMEND; // Swiftmend aura state
1179 break;
1180 case SPELLFAMILY_WARRIOR:
1181 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x0004000000000000))
1182 removeState = AURA_STATE_WARRIOR_VICTORY_RUSH; // Victorious
1183 break;
1184 case SPELLFAMILY_ROGUE:
1185 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x10000))
1186 removeState = AURA_STATE_DEADLY_POISON; // Deadly poison aura state
1187 break;
1188 case SPELLFAMILY_HUNTER:
1189 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x1000000000000000))
1190 removeState = AURA_STATE_FAERIE_FIRE; // Sting (hunter versions)
1193 // Remove state (but need check other auras for it)
1194 if (removeState)
1196 bool found = false;
1197 Unit::AuraMap& Auras = m_target->GetAuras();
1198 for(Unit::AuraMap::iterator i = Auras.begin(); i != Auras.end(); ++i)
1200 SpellEntry const *auraSpellInfo = (*i).second->GetSpellProto();
1201 if(auraSpellInfo->SpellFamilyName == m_spellProto->SpellFamilyName &&
1202 (auraSpellInfo->SpellFamilyFlags & removeFamilyFlag || auraSpellInfo->SpellFamilyFlags2 & removeFamilyFlag2))
1204 found = true;
1205 break;
1208 // this has been last aura
1209 if(!found)
1210 m_target->ModifyAuraState(AuraState(removeState), false);
1213 // reset cooldown state for spells
1214 if(caster && caster->GetTypeId() == TYPEID_PLAYER)
1216 if ( GetSpellProto()->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE )
1217 // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
1218 ((Player*)caster)->SendCooldownEvent(GetSpellProto());
1222 return true;
1225 void Aura::SendAuraUpdate(bool remove)
1227 WorldPacket data(SMSG_AURA_UPDATE);
1228 data.append(m_target->GetPackGUID());
1229 data << uint8(GetAuraSlot());
1230 data << uint32(remove ? 0 : GetId());
1232 if(remove)
1234 m_target->SendMessageToSet(&data, true);
1235 return;
1238 uint8 auraFlags = GetAuraFlags();
1239 data << uint8(auraFlags);
1240 data << uint8(GetAuraLevel());
1241 data << uint8(m_procCharges ? m_procCharges*m_stackAmount : m_stackAmount);
1243 if(!(auraFlags & AFLAG_NOT_CASTER))
1245 data << uint8(0); // pguid
1248 if(auraFlags & AFLAG_DURATION)
1250 data << uint32(GetAuraMaxDuration());
1251 data << uint32(GetAuraDuration());
1254 m_target->SendMessageToSet(&data, true);
1257 void Aura::SetStackAmount(uint8 stackAmount)
1259 Unit *target = GetTarget();
1260 Unit *caster = GetCaster();
1261 if (!target || !caster)
1262 return;
1264 bool refresh = stackAmount >= m_stackAmount;
1265 if (stackAmount != m_stackAmount)
1267 m_stackAmount = stackAmount;
1268 int32 amount = m_stackAmount * caster->CalculateSpellDamage(m_spellProto, m_effIndex, m_currentBasePoints, target);
1269 // Reapply if amount change
1270 if (amount!=m_modifier.m_amount)
1272 ApplyModifier(false, true);
1273 m_modifier.m_amount = amount;
1274 ApplyModifier(true, true);
1278 if (refresh)
1279 // Stack increased refresh duration
1280 RefreshAura();
1281 else
1282 // Stack decreased only send update
1283 SendAuraUpdate(false);
1286 bool Aura::modStackAmount(int32 num)
1288 // Can`t mod
1289 if (!m_spellProto->StackAmount)
1290 return true;
1292 // Modify stack but limit it
1293 int32 stackAmount = m_stackAmount + num;
1294 if (stackAmount > m_spellProto->StackAmount)
1295 stackAmount = m_spellProto->StackAmount;
1296 else if (stackAmount <=0) // Last aura from stack removed
1298 m_stackAmount = 0;
1299 return true; // need remove aura
1302 // Update stack amount
1303 SetStackAmount(stackAmount);
1304 return false;
1307 void Aura::RefreshAura()
1309 m_duration = m_maxduration;
1310 SendAuraUpdate(false);
1313 bool Aura::isAffectedOnSpell(SpellEntry const *spell) const
1315 // Check family name
1316 if (spell->SpellFamilyName != m_spellProto->SpellFamilyName)
1317 return false;
1318 // Check EffectClassMask
1319 uint32 const *ptr = getAuraSpellClassMask();
1320 if (((uint64*)ptr)[0] & spell->SpellFamilyFlags)
1321 return true;
1322 if (ptr[2] & spell->SpellFamilyFlags2)
1323 return true;
1324 return false;
1327 void Aura::ReapplyAffectedPassiveAuras( Unit* target, bool owner_mode )
1329 std::set<uint32> affectedSelf;
1330 std::set<uint32> affectedAuraCaster;
1332 for(Unit::AuraMap::const_iterator itr = target->GetAuras().begin(); itr != target->GetAuras().end(); ++itr)
1334 // permanent passive or permanent area aura
1335 // passive spells can be affected only by own or owner spell mods)
1336 if (itr->second->IsPermanent() && (owner_mode && itr->second->IsPassive() || itr->second->IsAreaAura()) &&
1337 // non deleted and not same aura (any with same spell id)
1338 !itr->second->IsDeleted() && itr->second->GetId() != GetId() &&
1339 // and affected by aura
1340 isAffectedOnSpell(itr->second->GetSpellProto()))
1342 // only applied by self or aura caster
1343 if (itr->second->GetCasterGUID() == target->GetGUID())
1344 affectedSelf.insert(itr->second->GetId());
1345 else if (itr->second->GetCasterGUID() == GetCasterGUID())
1346 affectedAuraCaster.insert(itr->second->GetId());
1350 for(std::set<uint32>::const_iterator set_itr = affectedSelf.begin(); set_itr != affectedSelf.end(); ++set_itr)
1352 target->RemoveAurasDueToSpell(*set_itr);
1353 target->CastSpell(m_target, *set_itr, true);
1356 if (!affectedAuraCaster.empty())
1358 Unit* caster = GetCaster();
1359 for(std::set<uint32>::const_iterator set_itr = affectedAuraCaster.begin(); set_itr != affectedAuraCaster.end(); ++set_itr)
1361 target->RemoveAurasDueToSpell(*set_itr);
1362 if (caster)
1363 caster->CastSpell(m_target, *set_itr, true);
1368 /*********************************************************/
1369 /*** BASIC AURA FUNCTION ***/
1370 /*********************************************************/
1371 void Aura::HandleAddModifier(bool apply, bool Real)
1373 if(m_target->GetTypeId() != TYPEID_PLAYER || !Real)
1374 return;
1376 if(m_modifier.m_miscvalue >= MAX_SPELLMOD)
1377 return;
1379 if (apply)
1381 // Add custom charges for some mod aura
1382 switch (m_spellProto->Id)
1384 case 17941: // Shadow Trance
1385 case 22008: // Netherwind Focus
1386 case 31834: // Light's Grace
1387 case 34754: // Clearcasting
1388 case 34936: // Backlash
1389 case 44401: // Missile Barrage
1390 case 48108: // Hot Streak
1391 case 51124: // Killing Machine
1392 case 54741: // Firestarter
1393 case 57761: // Fireball!
1394 SetAuraCharges(1);
1395 break;
1398 SpellModifier *mod = new SpellModifier;
1399 mod->op = SpellModOp(m_modifier.m_miscvalue);
1400 mod->value = m_modifier.m_amount;
1401 mod->type = SpellModType(m_modifier.m_auraname); // SpellModType value == spell aura types
1402 mod->spellId = GetId();
1404 uint32 const *ptr;
1405 switch (m_effIndex)
1407 case 0: ptr = &m_spellProto->EffectSpellClassMaskA[0]; break;
1408 case 1: ptr = &m_spellProto->EffectSpellClassMaskB[0]; break;
1409 case 2: ptr = &m_spellProto->EffectSpellClassMaskC[0]; break;
1410 default:
1411 return;
1414 mod->mask = (uint64)ptr[0] | (uint64)ptr[1]<<32;
1415 mod->mask2= (uint64)ptr[2];
1417 // prevent expire spell mods with (charges > 0 && m_stackAmount > 1)
1418 // all this spell expected expire not at use but at spell proc event check
1419 mod->charges = m_spellProto->StackAmount > 1 ? 0 : m_procCharges;
1421 m_spellmod = mod;
1424 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
1426 // reapply talents to own passive persistent auras
1427 ReapplyAffectedPassiveAuras(m_target, true);
1429 // re-apply talents/passives/area auras applied to pet (it affected by player spellmods)
1430 if(Pet* pet = m_target->GetPet())
1431 ReapplyAffectedPassiveAuras(pet, true);
1433 // re-apply talents/passives/area auras applied to totems (it affected by player spellmods)
1434 for(int i = 0; i < MAX_TOTEM; ++i)
1435 if(m_target->m_TotemSlot[i])
1436 if(Creature* totem = m_target->GetMap()->GetCreature(m_target->m_TotemSlot[i]))
1437 ReapplyAffectedPassiveAuras(totem, true);
1439 // re-apply talents/passives/area auras applied to group members (it affected by player spellmods)
1440 if (Group* group = ((Player*)m_target)->GetGroup())
1441 for(GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
1442 if (Player* member = itr->getSource())
1443 if (member != m_target && member->IsInMap(m_target))
1444 ReapplyAffectedPassiveAuras(member, false);
1447 void Aura::HandleAddTargetTrigger(bool apply, bool /*Real*/)
1449 // Use SpellModifier structure for check
1450 // used only fields:
1451 // spellId, mask, mask2
1452 if (apply)
1454 SpellModifier *mod = new SpellModifier;
1455 mod->spellId = GetId();
1457 uint32 const *ptr;
1458 switch (m_effIndex)
1460 case 0: ptr = &m_spellProto->EffectSpellClassMaskA[0]; break;
1461 case 1: ptr = &m_spellProto->EffectSpellClassMaskB[0]; break;
1462 case 2: ptr = &m_spellProto->EffectSpellClassMaskC[0]; break;
1463 default:
1464 return;
1467 mod->mask = (uint64)ptr[0] | (uint64)ptr[1]<<32;
1468 mod->mask2= (uint64)ptr[2];
1469 m_spellmod = mod;
1471 else
1473 delete m_spellmod;
1474 m_spellmod = NULL;
1478 void Aura::TriggerSpell()
1480 const uint64& casterGUID = GetCasterGUID();
1481 Unit* target = GetTriggerTarget();
1483 if(!casterGUID || !target)
1484 return;
1486 // generic casting code with custom spells and target/caster customs
1487 uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex];
1489 SpellEntry const *triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id);
1490 SpellEntry const *auraSpellInfo = GetSpellProto();
1491 uint32 auraId = auraSpellInfo->Id;
1493 // specific code for cases with no trigger spell provided in field
1494 if (triggeredSpellInfo == NULL)
1496 switch(auraSpellInfo->SpellFamilyName)
1498 case SPELLFAMILY_GENERIC:
1500 switch(auraId)
1502 // Firestone Passive (1-5 ranks)
1503 case 758:
1504 case 17945:
1505 case 17947:
1506 case 17949:
1507 case 27252:
1509 if (target->GetTypeId() != TYPEID_PLAYER)
1510 return;
1511 Item* item = ((Player*)target)->GetWeaponForAttack(BASE_ATTACK);
1512 if (!item)
1513 return;
1514 uint32 enchant_id = 0;
1515 switch (GetId())
1517 case 758: enchant_id = 1803; break; // Rank 1
1518 case 17945: enchant_id = 1823; break; // Rank 2
1519 case 17947: enchant_id = 1824; break; // Rank 3
1520 case 17949: enchant_id = 1825; break; // Rank 4
1521 case 27252: enchant_id = 2645; break; // Rank 5
1522 default:
1523 return;
1525 // remove old enchanting before applying new
1526 ((Player*)target)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,false);
1527 item->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, m_modifier.periodictime+1000, 0);
1528 // add new enchanting
1529 ((Player*)target)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,true);
1530 return;
1532 // // Periodic Mana Burn
1533 // case 812: break;
1534 // // Polymorphic Ray
1535 // case 6965: break;
1536 // // Fire Nova (1-7 ranks)
1537 // case 8350:
1538 // case 8508:
1539 // case 8509:
1540 // case 11312:
1541 // case 11313:
1542 // case 25540:
1543 // case 25544:
1544 // break;
1545 // Thaumaturgy Channel
1546 case 9712: trigger_spell_id = 21029; break;
1547 // // Egan's Blaster
1548 // case 17368: break;
1549 // // Haunted
1550 // case 18347: break;
1551 // // Ranshalla Waiting
1552 // case 18953: break;
1553 // // Inferno
1554 // case 19695: break;
1555 // // Frostwolf Muzzle DND
1556 // case 21794: break;
1557 // // Alterac Ram Collar DND
1558 // case 21866: break;
1559 // // Celebras Waiting
1560 // case 21916: break;
1561 // Brood Affliction: Bronze
1562 case 23170:
1564 m_target->CastSpell(m_target, 23171, true, 0, this);
1565 return;
1567 // // Mark of Frost
1568 // case 23184: break;
1569 // Restoration
1570 case 23493:
1572 int32 heal = target->GetMaxHealth() / 10;
1573 target->DealHeal(target, heal, auraSpellInfo);
1575 if (int32 mana = target->GetMaxPower(POWER_MANA))
1577 mana /= 10;
1578 target->EnergizeBySpell(target, 23493, mana, POWER_MANA);
1580 return;
1582 // // Stoneclaw Totem Passive TEST
1583 // case 23792: break;
1584 // // Axe Flurry
1585 // case 24018: break;
1586 // // Mark of Arlokk
1587 // case 24210: break;
1588 // // Restoration
1589 // case 24379: break;
1590 // // Happy Pet
1591 // case 24716: break;
1592 // // Dream Fog
1593 // case 24780: break;
1594 // // Cannon Prep
1595 // case 24832: break;
1596 // // Shadow Bolt Whirl
1597 // case 24834: break;
1598 // // Stink Trap
1599 // case 24918: break;
1600 // // Mark of Nature
1601 // case 25041: break;
1602 // // Agro Drones
1603 // case 25152: break;
1604 // Consume
1605 case 25371:
1607 int32 bpDamage = target->GetMaxHealth()*10/100;
1608 target->CastCustomSpell(target, 25373, &bpDamage, NULL, NULL, true, NULL, this, casterGUID);
1609 return;
1611 // // Pain Spike
1612 // case 25572: break;
1613 // // Rotate 360
1614 // case 26009: break;
1615 // // Rotate -360
1616 // case 26136: break;
1617 // // Consume
1618 // case 26196: break;
1619 // // Berserk
1620 // case 26615: break;
1621 // // Defile
1622 // case 27177: break;
1623 // // Teleport: IF/UC
1624 // case 27601: break;
1625 // // Five Fat Finger Exploding Heart Technique
1626 // case 27673: break;
1627 // // Nitrous Boost
1628 // case 27746: break;
1629 // // Steam Tank Passive
1630 // case 27747: break;
1631 // Frost Blast
1632 case 27808:
1634 int32 bpDamage = target->GetMaxHealth()*26/100;
1635 target->CastCustomSpell(target, 29879, &bpDamage, NULL, NULL, true, NULL, this, casterGUID);
1636 return;
1638 // // Detonate Mana
1639 // case 27819: break;
1640 // // Controller Timer
1641 // case 28095: break;
1642 // // Stalagg Chain
1643 // case 28096: break;
1644 // // Stalagg Tesla Passive
1645 // case 28097: break;
1646 // // Feugen Tesla Passive
1647 // case 28109: break;
1648 // // Feugen Chain
1649 // case 28111: break;
1650 // // Mark of Didier
1651 // case 28114: break;
1652 // // Communique Timer, camp
1653 // case 28346: break;
1654 // // Icebolt
1655 // case 28522: break;
1656 // // Silithyst
1657 // case 29519: break;
1658 // Inoculate Nestlewood Owlkin
1659 case 29528:
1660 if(target->GetTypeId() != TYPEID_UNIT)// prevent error reports in case ignored player target
1661 return;
1662 break;
1663 // // Overload
1664 // case 29768: break;
1665 // // Return Fire
1666 // case 29788: break;
1667 // // Return Fire
1668 // case 29793: break;
1669 // // Return Fire
1670 // case 29794: break;
1671 // // Guardian of Icecrown Passive
1672 // case 29897: break;
1673 // Feed Captured Animal
1674 case 29917: trigger_spell_id = 29916; break;
1675 // // Flame Wreath
1676 // case 29946: break;
1677 // // Flame Wreath
1678 // case 29947: break;
1679 // // Mind Exhaustion Passive
1680 // case 30025: break;
1681 // // Nether Beam - Serenity
1682 // case 30401: break;
1683 // Extract Gas
1684 case 30427:
1686 Unit* caster = GetCaster();
1687 if (!caster)
1688 return;
1689 // move loot to player inventory and despawn target
1690 if(caster->GetTypeId() ==TYPEID_PLAYER &&
1691 target->GetTypeId() == TYPEID_UNIT &&
1692 ((Creature*)target)->GetCreatureInfo()->type == CREATURE_TYPE_GAS_CLOUD)
1694 Player* player = (Player*)caster;
1695 Creature* creature = (Creature*)target;
1696 // missing lootid has been reported on startup - just return
1697 if (!creature->GetCreatureInfo()->SkinLootId)
1698 return;
1700 player->AutoStoreLoot(creature->GetCreatureInfo()->SkinLootId,LootTemplates_Skinning,true);
1702 creature->ForcedDespawn();
1704 return;
1706 // Quake
1707 case 30576: trigger_spell_id = 30571; break;
1708 // // Burning Maul
1709 // case 30598: break;
1710 // // Regeneration
1711 // case 30799:
1712 // case 30800:
1713 // case 30801:
1714 // break;
1715 // // Despawn Self - Smoke cloud
1716 // case 31269: break;
1717 // // Time Rift Periodic
1718 // case 31320: break;
1719 // // Corrupt Medivh
1720 // case 31326: break;
1721 // Doom
1722 case 31347:
1724 m_target->CastSpell(m_target,31350,true);
1725 m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
1726 return;
1728 // Spellcloth
1729 case 31373:
1731 // Summon Elemental after create item
1732 target->SummonCreature(17870, 0, 0, 0, target->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0);
1733 return;
1735 // // Bloodmyst Tesla
1736 // case 31611: break;
1737 // Doomfire
1738 case 31944:
1740 int32 damage = m_modifier.m_amount * ((float)(GetAuraDuration() + m_modifier.periodictime) / GetAuraMaxDuration());
1741 target->CastCustomSpell(target, 31969, &damage, NULL, NULL, true, NULL, this, casterGUID);
1742 return;
1744 // // Teleport Test
1745 // case 32236: break;
1746 // // Earthquake
1747 // case 32686: break;
1748 // // Possess
1749 // case 33401: break;
1750 // // Draw Shadows
1751 // case 33563: break;
1752 // // Murmur's Touch
1753 // case 33711: break;
1754 // Flame Quills
1755 case 34229:
1757 // cast 24 spells 34269-34289, 34314-34316
1758 for(uint32 spell_id = 34269; spell_id != 34290; ++spell_id)
1759 target->CastSpell(target, spell_id, true, NULL, this, casterGUID);
1760 for(uint32 spell_id = 34314; spell_id != 34317; ++spell_id)
1761 target->CastSpell(target, spell_id, true, NULL, this, casterGUID);
1762 return;
1764 // // Gravity Lapse
1765 // case 34480: break;
1766 // // Tornado
1767 // case 34683: break;
1768 // // Frostbite Rotate
1769 // case 34748: break;
1770 // // Arcane Flurry
1771 // case 34821: break;
1772 // // Interrupt Shutdown
1773 // case 35016: break;
1774 // // Interrupt Shutdown
1775 // case 35176: break;
1776 // // Inferno
1777 // case 35268: break;
1778 // // Salaadin's Tesla
1779 // case 35515: break;
1780 // // Ethereal Channel (Red)
1781 // case 35518: break;
1782 // // Nether Vapor
1783 // case 35879: break;
1784 // // Dark Portal Storm
1785 // case 36018: break;
1786 // // Burning Maul
1787 // case 36056: break;
1788 // // Living Grove Defender Lifespan
1789 // case 36061: break;
1790 // // Professor Dabiri Talks
1791 // case 36064: break;
1792 // // Kael Gaining Power
1793 // case 36091: break;
1794 // // They Must Burn Bomb Aura
1795 // case 36344: break;
1796 // // They Must Burn Bomb Aura (self)
1797 // case 36350: break;
1798 // // Stolen Ravenous Ravager Egg
1799 // case 36401: break;
1800 // // Activated Cannon
1801 // case 36410: break;
1802 // // Stolen Ravenous Ravager Egg
1803 // case 36418: break;
1804 // // Enchanted Weapons
1805 // case 36510: break;
1806 // // Cursed Scarab Periodic
1807 // case 36556: break;
1808 // // Cursed Scarab Despawn Periodic
1809 // case 36561: break;
1810 // // Vision Guide
1811 // case 36573: break;
1812 // // Cannon Charging (platform)
1813 // case 36785: break;
1814 // // Cannon Charging (self)
1815 // case 36860: break;
1816 // Remote Toy
1817 case 37027: trigger_spell_id = 37029; break;
1818 // // Mark of Death
1819 // case 37125: break;
1820 // // Arcane Flurry
1821 // case 37268: break;
1822 // // Spout
1823 // case 37429: break;
1824 // // Spout
1825 // case 37430: break;
1826 // // Karazhan - Chess NPC AI, Snapshot timer
1827 // case 37440: break;
1828 // // Karazhan - Chess NPC AI, action timer
1829 // case 37504: break;
1830 // // Karazhan - Chess: Is Square OCCUPIED aura (DND)
1831 // case 39400: break;
1832 // // Banish
1833 // case 37546: break;
1834 // // Shriveling Gaze
1835 // case 37589: break;
1836 // // Fake Aggro Radius (2 yd)
1837 // case 37815: break;
1838 // // Corrupt Medivh
1839 // case 37853: break;
1840 // Eye of Grillok
1841 case 38495:
1843 m_target->CastSpell(m_target, 38530, true);
1844 return;
1846 // Absorb Eye of Grillok (Zezzak's Shard)
1847 case 38554:
1849 if(m_target->GetTypeId() != TYPEID_UNIT)
1850 return;
1852 if (Unit* caster = GetCaster())
1853 caster->CastSpell(caster, 38495, true, NULL, this);
1854 else
1855 return;
1857 Creature* creatureTarget = (Creature*)m_target;
1859 creatureTarget->ForcedDespawn();
1860 return;
1862 // // Magic Sucker Device timer
1863 // case 38672: break;
1864 // // Tomb Guarding Charging
1865 // case 38751: break;
1866 // // Murmur's Touch
1867 // case 38794: break;
1868 // // Activate Nether-wraith Beacon (31742 Nether-wraith Beacon item)
1869 // case 39105: break;
1870 // // Drain World Tree Visual
1871 // case 39140: break;
1872 // // Quest - Dustin's Undead Dragon Visual aura
1873 // case 39259: break;
1874 // // Hellfire - The Exorcism, Jules releases darkness, aura
1875 // case 39306: break;
1876 // // Inferno
1877 // case 39346: break;
1878 // // Enchanted Weapons
1879 // case 39489: break;
1880 // // Shadow Bolt Whirl
1881 // case 39630: break;
1882 // // Shadow Bolt Whirl
1883 // case 39634: break;
1884 // // Shadow Inferno
1885 // case 39645: break;
1886 // Tear of Azzinoth Summon Channel - it's not really supposed to do anything,and this only prevents the console spam
1887 case 39857: trigger_spell_id = 39856; break;
1888 // // Soulgrinder Ritual Visual (Smashed)
1889 // case 39974: break;
1890 // // Simon Game Pre-game timer
1891 // case 40041: break;
1892 // // Knockdown Fel Cannon: The Aggro Check Aura
1893 // case 40113: break;
1894 // // Spirit Lance
1895 // case 40157: break;
1896 // // Demon Transform 2
1897 // case 40398: break;
1898 // // Demon Transform 1
1899 // case 40511: break;
1900 // // Ancient Flames
1901 // case 40657: break;
1902 // // Ethereal Ring Cannon: Cannon Aura
1903 // case 40734: break;
1904 // // Cage Trap
1905 // case 40760: break;
1906 // // Random Periodic
1907 // case 40867: break;
1908 // // Prismatic Shield
1909 // case 40879: break;
1910 // // Aura of Desire
1911 // case 41350: break;
1912 // // Dementia
1913 // case 41404: break;
1914 // // Chaos Form
1915 // case 41629: break;
1916 // // Alert Drums
1917 // case 42177: break;
1918 // // Spout
1919 // case 42581: break;
1920 // // Spout
1921 // case 42582: break;
1922 // // Return to the Spirit Realm
1923 // case 44035: break;
1924 // // Curse of Boundless Agony
1925 // case 45050: break;
1926 // // Earthquake
1927 // case 46240: break;
1928 // Personalized Weather
1929 case 46736: trigger_spell_id = 46737; break;
1930 // // Stay Submerged
1931 // case 46981: break;
1932 // // Dragonblight Ram
1933 // case 47015: break;
1934 // // Party G.R.E.N.A.D.E.
1935 // case 51510: break;
1936 default:
1937 break;
1939 break;
1941 case SPELLFAMILY_MAGE:
1943 switch(auraId)
1945 // Invisibility
1946 case 66:
1947 // Here need periodic triger reducing threat spell (or do it manually)
1948 return;
1949 default:
1950 break;
1952 break;
1954 // case SPELLFAMILY_WARRIOR:
1955 // {
1956 // switch(auraId)
1957 // {
1958 // // Wild Magic
1959 // case 23410: break;
1960 // // Corrupted Totems
1961 // case 23425: break;
1962 // default:
1963 // break;
1964 // }
1965 // break;
1966 // }
1967 // case SPELLFAMILY_PRIEST:
1968 // {
1969 // switch(auraId)
1970 // {
1971 // // Blue Beam
1972 // case 32930: break;
1973 // // Fury of the Dreghood Elders
1974 // case 35460: break;
1975 // default:
1976 // break;
1977 // }
1978 // break;
1979 // }
1980 case SPELLFAMILY_HUNTER:
1982 switch (auraId)
1984 // Sniper training
1985 case 53302:
1986 case 53303:
1987 case 53304:
1988 if (target->GetTypeId() != TYPEID_PLAYER)
1989 return;
1991 // Reset reapply counter at move
1992 if (((Player*)target)->isMoving())
1994 m_modifier.m_amount = 6;
1995 return;
1998 // We are standing at the moment
1999 if (m_modifier.m_amount > 0)
2001 --m_modifier.m_amount;
2002 return;
2005 // select rank of buff
2006 switch(auraId)
2008 case 53302: trigger_spell_id = 64418; break;
2009 case 53303: trigger_spell_id = 64419; break;
2010 case 53304: trigger_spell_id = 64420; break;
2013 // If aura is active - no need to continue
2014 if (target->HasAura(trigger_spell_id))
2015 return;
2017 break;
2018 default:
2019 break;
2021 break;
2023 case SPELLFAMILY_DRUID:
2025 switch(auraId)
2027 // Cat Form
2028 // trigger_spell_id not set and unknown effect triggered in this case, ignoring for while
2029 case 768:
2030 return;
2031 // Frenzied Regeneration
2032 case 22842:
2033 case 22895:
2034 case 22896:
2035 case 26999:
2037 int32 LifePerRage = GetModifier()->m_amount;
2039 int32 lRage = m_target->GetPower(POWER_RAGE);
2040 if(lRage > 100) // rage stored as rage*10
2041 lRage = 100;
2042 m_target->ModifyPower(POWER_RAGE, -lRage);
2043 int32 FRTriggerBasePoints = int32(lRage*LifePerRage/10);
2044 m_target->CastCustomSpell(m_target, 22845, &FRTriggerBasePoints, NULL, NULL, true, NULL, this);
2045 return;
2047 default:
2048 break;
2050 break;
2053 // case SPELLFAMILY_HUNTER:
2054 // {
2055 // switch(auraId)
2056 // {
2057 // //Frost Trap Aura
2058 // case 13810:
2059 // return;
2060 // //Rizzle's Frost Trap
2061 // case 39900:
2062 // return;
2063 // // Tame spells
2064 // case 19597: // Tame Ice Claw Bear
2065 // case 19676: // Tame Snow Leopard
2066 // case 19677: // Tame Large Crag Boar
2067 // case 19678: // Tame Adult Plainstrider
2068 // case 19679: // Tame Prairie Stalker
2069 // case 19680: // Tame Swoop
2070 // case 19681: // Tame Dire Mottled Boar
2071 // case 19682: // Tame Surf Crawler
2072 // case 19683: // Tame Armored Scorpid
2073 // case 19684: // Tame Webwood Lurker
2074 // case 19685: // Tame Nightsaber Stalker
2075 // case 19686: // Tame Strigid Screecher
2076 // case 30100: // Tame Crazed Dragonhawk
2077 // case 30103: // Tame Elder Springpaw
2078 // case 30104: // Tame Mistbat
2079 // case 30647: // Tame Barbed Crawler
2080 // case 30648: // Tame Greater Timberstrider
2081 // case 30652: // Tame Nightstalker
2082 // return;
2083 // default:
2084 // break;
2085 // }
2086 // break;
2087 // }
2088 case SPELLFAMILY_SHAMAN:
2090 switch(auraId)
2092 // Lightning Shield (The Earthshatterer set trigger after cast Lighting Shield)
2093 case 28820:
2095 // Need remove self if Lightning Shield not active
2096 Unit::AuraMap const& auras = target->GetAuras();
2097 for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
2099 SpellEntry const* spell = itr->second->GetSpellProto();
2100 if( spell->SpellFamilyName == SPELLFAMILY_SHAMAN &&
2101 (spell->SpellFamilyFlags & UI64LIT(0x0000000000000400)))
2102 return;
2104 target->RemoveAurasDueToSpell(28820);
2105 return;
2107 // Totemic Mastery (Skyshatter Regalia (Shaman Tier 6) - bonus)
2108 case 38443:
2110 bool all = true;
2111 for(int i = 0; i < MAX_TOTEM; ++i)
2113 if(!target->m_TotemSlot[i])
2115 all = false;
2116 break;
2120 if(all)
2121 target->CastSpell(target, 38437, true, NULL, this);
2122 else
2123 target->RemoveAurasDueToSpell(38437);
2124 return;
2126 default:
2127 break;
2129 break;
2131 default:
2132 break;
2135 // Reget trigger spell proto
2136 triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id);
2138 else
2140 // Spell exist but require custom code
2141 switch(auraId)
2143 // Curse of Idiocy
2144 case 1010:
2146 // TODO: spell casted by result in correct way mostly
2147 // BUT:
2148 // 1) target show casting at each triggered cast: target don't must show casting animation for any triggered spell
2149 // but must show affect apply like item casting
2150 // 2) maybe aura must be replace by new with accumulative stat mods instead stacking
2152 // prevent cast by triggered auras
2153 if(casterGUID == target->GetGUID())
2154 return;
2156 // stop triggering after each affected stats lost > 90
2157 int32 intelectLoss = 0;
2158 int32 spiritLoss = 0;
2160 Unit::AuraList const& mModStat = target->GetAurasByType(SPELL_AURA_MOD_STAT);
2161 for(Unit::AuraList::const_iterator i = mModStat.begin(); i != mModStat.end(); ++i)
2163 if ((*i)->GetId() == 1010)
2165 switch((*i)->GetModifier()->m_miscvalue)
2167 case STAT_INTELLECT: intelectLoss += (*i)->GetModifier()->m_amount; break;
2168 case STAT_SPIRIT: spiritLoss += (*i)->GetModifier()->m_amount; break;
2169 default: break;
2174 if(intelectLoss <= -90 && spiritLoss <= -90)
2175 return;
2177 break;
2179 // Mana Tide
2180 case 16191:
2182 target->CastCustomSpell(target, trigger_spell_id, &m_modifier.m_amount, NULL, NULL, true, NULL, this);
2183 return;
2185 // Ground Slam
2186 case 33525:
2187 target->CastSpell(target, trigger_spell_id, true, NULL, this, casterGUID);
2188 return;
2189 // Beacon of Light
2190 case 53563:
2191 // original caster must be target (beacon)
2192 target->CastSpell(target, trigger_spell_id, true, NULL, this, target->GetGUID());
2193 return;
2194 // Rapid Recuperation (triggered energize have baspioints == 0)
2195 case 56654:
2196 case 58882:
2198 int32 mana = m_target->GetMaxPower(POWER_MANA) * m_modifier.m_amount / 100;
2199 target->CastCustomSpell(target, trigger_spell_id, &mana, NULL, NULL, true, NULL, this);
2200 return;
2205 // All ok cast by default case
2206 if(triggeredSpellInfo)
2207 target->CastSpell(target, triggeredSpellInfo, true, NULL, this, casterGUID);
2208 else
2210 if (Unit* caster = GetCaster())
2212 if(target->GetTypeId() != TYPEID_UNIT || !Script->EffectDummyCreature(caster, GetId(), GetEffIndex(), (Creature*)target))
2213 sLog.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex());
2218 void Aura::TriggerSpellWithValue()
2220 const uint64& casterGUID = GetCasterGUID();
2221 Unit* target = GetTriggerTarget();
2223 if(!casterGUID || !target)
2224 return;
2226 // generic casting code with custom spells and target/caster customs
2227 uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex];
2228 int32 basepoints0 = this->GetModifier()->m_amount;
2230 target->CastCustomSpell(target, trigger_spell_id, &basepoints0, NULL, NULL, true, NULL, this, casterGUID);
2233 /*********************************************************/
2234 /*** AURA EFFECTS ***/
2235 /*********************************************************/
2237 void Aura::HandleAuraDummy(bool apply, bool Real)
2239 // spells required only Real aura add/remove
2240 if(!Real)
2241 return;
2243 // AT APPLY
2244 if(apply)
2246 switch(m_spellProto->SpellFamilyName)
2248 case SPELLFAMILY_GENERIC:
2249 switch(GetId())
2251 case 1515: // Tame beast
2252 // FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness
2253 if (m_target->CanHaveThreatList())
2254 if (Unit* caster = GetCaster())
2255 m_target->AddThreat(caster, 10.0f, false, GetSpellSchoolMask(GetSpellProto()), GetSpellProto());
2256 return;
2257 case 13139: // net-o-matic
2258 // root to self part of (root_target->charge->root_self sequence
2259 if (Unit* caster = GetCaster())
2260 caster->CastSpell(caster, 13138, true, NULL, this);
2261 return;
2262 case 39850: // Rocket Blast
2263 if(roll_chance_i(20)) // backfire stun
2264 m_target->CastSpell(m_target, 51581, true, NULL, this);
2265 return;
2266 case 43873: // Headless Horseman Laugh
2267 m_target->PlayDistanceSound(11965);
2268 return;
2269 case 46354: // Blood Elf Illusion
2270 if (Unit* caster = GetCaster())
2272 switch(caster->getGender())
2274 case GENDER_FEMALE:
2275 caster->CastSpell(m_target, 46356, true, NULL, this);
2276 break;
2277 case GENDER_MALE:
2278 caster->CastSpell(m_target, 46355, true, NULL, this);
2279 break;
2280 default:
2281 break;
2284 return;
2285 case 46699: // Requires No Ammo
2286 if (m_target->GetTypeId() == TYPEID_PLAYER)
2287 // not use ammo and not allow use
2288 ((Player*)m_target)->RemoveAmmo();
2289 return;
2290 case 62061: // Festive Holiday Mount
2291 if (m_target->HasAuraType(SPELL_AURA_MOUNTED))
2292 // Reindeer Transformation
2293 m_target->CastSpell(m_target, 25860, true, NULL, this);
2294 return;
2296 break;
2297 case SPELLFAMILY_WARRIOR:
2298 // Overpower
2299 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000004))
2301 // Must be casting target
2302 if (!m_target->IsNonMeleeSpellCasted(false))
2303 return;
2305 Unit* caster = GetCaster();
2306 if (!caster)
2307 return;
2309 Unit::AuraList const& modifierAuras = caster->GetAurasByType(SPELL_AURA_ADD_FLAT_MODIFIER);
2310 for(Unit::AuraList::const_iterator itr = modifierAuras.begin(); itr != modifierAuras.end(); ++itr)
2312 // Unrelenting Assault
2313 if((*itr)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARRIOR && (*itr)->GetSpellProto()->SpellIconID == 2775)
2315 switch ((*itr)->GetSpellProto()->Id)
2317 case 46859: // Unrelenting Assault, rank 1
2318 m_target->CastSpell(m_target,64849,true,NULL,(*itr));
2319 break;
2320 case 46860: // Unrelenting Assault, rank 2
2321 m_target->CastSpell(m_target,64850,true,NULL,(*itr));
2322 break;
2323 default:
2324 break;
2326 break;
2329 return;
2331 break;
2332 case SPELLFAMILY_SHAMAN:
2333 // Tidal Force
2334 if (GetId() == 55198)
2336 // apply max stack bufs
2337 SpellEntry const* buffEntry = sSpellStore.LookupEntry(55166);
2338 if (!buffEntry)
2339 return;
2340 for(int k = 0; k < buffEntry->StackAmount; ++k)
2341 m_target->CastSpell(m_target, buffEntry, true, NULL, this);
2343 // Earth Shield
2344 else if ((GetSpellProto()->SpellFamilyFlags & UI64LIT(0x40000000000)))
2346 // prevent double apply bonuses
2347 if(m_target->GetTypeId() != TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())
2348 if (Unit* caster = GetCaster())
2349 m_modifier.m_amount = caster->SpellHealingBonus(m_target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE);
2350 return;
2352 break;
2355 // AT REMOVE
2356 else
2358 if( m_target->GetTypeId() == TYPEID_PLAYER &&
2359 ( GetSpellProto()->Effect[0]==72 || GetSpellProto()->Effect[0]==6 &&
2360 ( GetSpellProto()->EffectApplyAuraName[0]==1 || GetSpellProto()->EffectApplyAuraName[0]==128 ) ) )
2362 // spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425
2363 ((Player*)m_target)->SetFarSightGUID(0);
2364 WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0);
2365 ((Player*)m_target)->GetSession()->SendPacket(&data);
2366 return;
2369 if (IsQuestTameSpell(GetId()) && m_target->isAlive())
2371 Unit* caster = GetCaster();
2372 if (!caster || !caster->isAlive())
2373 return;
2375 uint32 finalSpelId = 0;
2376 switch(GetId())
2378 case 19548: finalSpelId = 19597; break;
2379 case 19674: finalSpelId = 19677; break;
2380 case 19687: finalSpelId = 19676; break;
2381 case 19688: finalSpelId = 19678; break;
2382 case 19689: finalSpelId = 19679; break;
2383 case 19692: finalSpelId = 19680; break;
2384 case 19693: finalSpelId = 19684; break;
2385 case 19694: finalSpelId = 19681; break;
2386 case 19696: finalSpelId = 19682; break;
2387 case 19697: finalSpelId = 19683; break;
2388 case 19699: finalSpelId = 19685; break;
2389 case 19700: finalSpelId = 19686; break;
2390 case 30646: finalSpelId = 30647; break;
2391 case 30653: finalSpelId = 30648; break;
2392 case 30654: finalSpelId = 30652; break;
2393 case 30099: finalSpelId = 30100; break;
2394 case 30102: finalSpelId = 30103; break;
2395 case 30105: finalSpelId = 30104; break;
2398 if(finalSpelId)
2399 caster->CastSpell(m_target, finalSpelId, true, NULL, this);
2400 return;
2403 switch(GetId())
2405 case 36730: // Flame Strike
2407 m_target->CastSpell(m_target, 36731, true, NULL, this);
2408 return;
2410 case 44191: // Flame Strike
2412 if (m_target->GetMap()->IsDungeon())
2414 uint32 spellId = m_target->GetMap()->IsRegularDifficulty() ? 44190 : 46163;
2416 m_target->CastSpell(m_target, spellId, true, NULL, this);
2418 return;
2420 case 45934: // Dark Fiend
2422 // Kill target if dispelled
2423 if (m_removeMode==AURA_REMOVE_BY_DISPEL)
2424 m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
2425 return;
2427 case 46308: // Burning Winds
2429 // casted only at creatures at spawn
2430 m_target->CastSpell(m_target, 47287, true, NULL, this);
2431 return;
2435 if (m_removeMode == AURA_REMOVE_BY_DEATH)
2437 // Stop caster Arcane Missle chanelling on death
2438 if (m_spellProto->SpellFamilyName == SPELLFAMILY_MAGE &&
2439 (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000800)))
2441 if (Unit* caster = GetCaster())
2442 caster->InterruptSpell(CURRENT_CHANNELED_SPELL);
2443 return;
2445 // Stop caster Penance chanelling on death
2446 if (m_spellProto->SpellFamilyName == SPELLFAMILY_PRIEST &&
2447 (m_spellProto->SpellFamilyFlags2 & UI64LIT(0x00000080)))
2449 if (Unit* caster = GetCaster())
2450 caster->InterruptSpell(CURRENT_CHANNELED_SPELL);
2451 return;
2456 // AT APPLY & REMOVE
2458 switch(m_spellProto->SpellFamilyName)
2460 case SPELLFAMILY_GENERIC:
2462 switch(GetId())
2464 // Recently Bandaged
2465 case 11196:
2466 m_target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, GetMiscValue(), apply);
2467 return;
2468 // Unstable Power
2469 case 24658:
2471 uint32 spellId = 24659;
2472 if (apply)
2474 SpellEntry const *spell = sSpellStore.LookupEntry(spellId);
2475 Unit* caster = GetCaster();
2476 if (!spell || !caster)
2477 return;
2479 for (int i=0; i < spell->StackAmount; ++i)
2480 caster->CastSpell(m_target, spellId, true, NULL, NULL, GetCasterGUID());
2481 return;
2483 m_target->RemoveAurasDueToSpell(spellId);
2484 return;
2486 // Restless Strength
2487 case 24661:
2489 uint32 spellId = 24662;
2490 if (apply)
2492 SpellEntry const* spell = sSpellStore.LookupEntry(spellId);
2493 Unit* caster = GetCaster();
2494 if (!spell || !caster)
2495 return;
2496 for (int i=0; i < spell->StackAmount; ++i)
2497 caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID());
2498 return;
2500 m_target->RemoveAurasDueToSpell(spellId);
2501 return;
2503 //Summon Fire Elemental
2504 case 40133:
2506 Unit* caster = GetCaster();
2507 if (!caster)
2508 return;
2510 Unit *owner = caster->GetOwner();
2511 if (owner && owner->GetTypeId() == TYPEID_PLAYER)
2513 if(apply)
2514 owner->CastSpell(owner, 8985, true);
2515 else
2516 ((Player*)owner)->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true);
2518 return;
2520 //Summon Earth Elemental
2521 case 40132 :
2523 Unit* caster = GetCaster();
2524 if (!caster)
2525 return;
2527 Unit *owner = caster->GetOwner();
2528 if (owner && owner->GetTypeId() == TYPEID_PLAYER)
2530 if(apply)
2531 owner->CastSpell(owner, 19704, true);
2532 else
2533 ((Player*)owner)->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true);
2535 return;
2537 //Dragonmaw Illusion
2538 case 40214 :
2540 if(apply)
2542 m_target->CastSpell(m_target, 40216, true);
2543 m_target->CastSpell(m_target, 42016, true);
2545 else
2547 m_target->RemoveAurasDueToSpell(40216);
2548 m_target->RemoveAurasDueToSpell(42016);
2550 return;
2552 // LK Intro VO (1)
2553 case 58204:
2554 if(m_target->GetTypeId() == TYPEID_PLAYER)
2556 // Play part 1
2557 if(apply)
2558 m_target->PlayDirectSound(14970, (Player *)m_target);
2559 // continue in 58205
2560 else
2561 m_target->CastSpell(m_target, 58205, true);
2563 return;
2564 // LK Intro VO (2)
2565 case 58205:
2566 if(m_target->GetTypeId() == TYPEID_PLAYER)
2568 // Play part 2
2569 if(apply)
2570 m_target->PlayDirectSound(14971, (Player *)m_target);
2571 // Play part 3
2572 else
2573 m_target->PlayDirectSound(14972, (Player *)m_target);
2575 return;
2576 case 40131:
2577 case 27978:
2578 if (apply)
2579 m_target->m_AuraFlags |= UNIT_AURAFLAG_ALIVE_INVISIBLE;
2580 else
2581 m_target->m_AuraFlags |= ~UNIT_AURAFLAG_ALIVE_INVISIBLE;
2582 return;
2584 break;
2586 case SPELLFAMILY_MAGE:
2587 break;
2588 case SPELLFAMILY_WARLOCK:
2590 // Haunt
2591 if (GetSpellProto()->SpellIconID == 3172 && (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0004000000000000)))
2593 // NOTE: for avoid use additional field damage stored in dummy value (replace unused 100%
2594 if (apply)
2595 m_modifier.m_amount = 0; // use value as damage counter instead redundent 100% percent
2596 else
2598 int32 bp0 = m_modifier.m_amount;
2600 if (Unit* caster = GetCaster())
2601 m_target->CastCustomSpell(caster,48210,&bp0,NULL,NULL,true);
2604 break;
2606 case SPELLFAMILY_PRIEST:
2608 // Pain and Suffering
2609 if( m_spellProto->SpellIconID == 2874 && m_target->GetTypeId()==TYPEID_PLAYER )
2611 if(apply)
2613 // Reduce backfire damage (dot damage) from Shadow Word: Death
2614 SpellModifier *mod = new SpellModifier;
2615 mod->op = SPELLMOD_DOT;
2616 mod->value = m_modifier.m_amount;
2617 mod->type = SPELLMOD_PCT;
2618 mod->spellId = GetId();
2619 mod->mask = UI64LIT(0x0000200000000000);
2620 mod->mask2= UI64LIT(0x0);
2621 m_spellmod = mod;
2623 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
2624 return;
2626 break;
2628 case SPELLFAMILY_DRUID:
2630 switch(GetId())
2632 case 34246: // Idol of the Emerald Queen
2633 case 60779: // Idol of Lush Moss
2635 if (m_target->GetTypeId() != TYPEID_PLAYER)
2636 return;
2638 if(apply)
2640 SpellModifier *mod = new SpellModifier;
2641 mod->op = SPELLMOD_DOT;
2642 mod->value = m_modifier.m_amount/7;
2643 mod->type = SPELLMOD_FLAT;
2644 mod->spellId = GetId();
2645 mod->mask = UI64LIT(0x001000000000);
2646 mod->mask2= UI64LIT(0x0);
2648 m_spellmod = mod;
2651 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
2652 return;
2654 case 52610: // Savage Roar
2656 if(apply)
2658 if(m_target->m_form != FORM_CAT)
2659 return;
2661 m_target->CastSpell(m_target, 62071, true);
2663 else
2664 m_target-> RemoveAurasDueToSpell(62071);
2665 return;
2667 case 61336: // Survival Instincts
2669 if(apply)
2671 if (!m_target->IsInFeralForm())
2672 return;
2674 int32 bp0 = int32(m_target->GetMaxHealth() * m_modifier.m_amount / 100);
2675 m_target->CastCustomSpell(m_target, 50322, &bp0, NULL, NULL, true);
2677 else
2678 m_target-> RemoveAurasDueToSpell(50322);
2679 return;
2683 // Lifebloom
2684 if (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x1000000000))
2686 if ( apply )
2688 if (Unit* caster = GetCaster())
2689 // prevent double apply bonuses
2690 if(m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())
2691 m_modifier.m_amount = caster->SpellHealingBonus(m_target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE);
2693 else
2695 // Final heal only on dispelled or duration end
2696 if ( !(GetAuraDuration() <= 0 || m_removeMode == AURA_REMOVE_BY_DISPEL) )
2697 return;
2699 // have a look if there is still some other Lifebloom dummy aura
2700 Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
2701 for(Unit::AuraList::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr)
2702 if((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID &&
2703 ((*itr)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x1000000000)))
2704 return;
2706 // final heal
2707 if(m_target->IsInWorld() && m_stackAmount > 0)
2709 int32 amount = m_modifier.m_amount / m_stackAmount;
2710 m_target->CastCustomSpell(m_target, 33778, &amount, NULL, NULL, true, NULL, this, GetCasterGUID());
2712 if (Unit* caster = GetCaster())
2714 int32 returnmana = (GetSpellProto()->ManaCostPercentage * caster->GetCreateMana() / 100) * m_stackAmount / 2;
2715 caster->CastCustomSpell(caster, 64372, &returnmana, NULL, NULL, true, NULL, this, GetCasterGUID());
2719 return;
2722 // Predatory Strikes
2723 if(m_target->GetTypeId()==TYPEID_PLAYER && GetSpellProto()->SpellIconID == 1563)
2725 ((Player*)m_target)->UpdateAttackPowerAndDamage();
2726 return;
2729 // Improved Moonkin Form
2730 if(GetSpellProto()->SpellIconID == 2855)
2732 uint32 spell_id;
2733 switch(GetId())
2735 case 48384: spell_id = 50170; break; //Rank 1
2736 case 48395: spell_id = 50171; break; //Rank 2
2737 case 48396: spell_id = 50172; break; //Rank 3
2738 default:
2739 sLog.outError("HandleAuraDummy: Not handled rank of IMF (Spell: %u)",GetId());
2740 return;
2743 if(apply)
2745 if(m_target->m_form != FORM_MOONKIN)
2746 return;
2748 m_target->CastSpell(m_target, spell_id, true);
2750 else
2751 m_target-> RemoveAurasDueToSpell(spell_id);
2752 return;
2754 break;
2756 case SPELLFAMILY_HUNTER:
2757 break;
2758 case SPELLFAMILY_PALADIN:
2759 switch(GetId())
2761 case 20911: // Blessing of Sanctuary
2762 case 25899: // Greater Blessing of Sanctuary
2764 if (apply)
2765 m_target->CastSpell(m_target, 67480, true, NULL, this);
2766 else
2767 m_target->RemoveAurasDueToSpell(67480);
2768 return;
2771 break;
2772 case SPELLFAMILY_SHAMAN:
2774 // Improved Weapon Totems
2775 if( GetSpellProto()->SpellIconID == 57 && m_target->GetTypeId()==TYPEID_PLAYER )
2777 if(apply)
2779 SpellModifier *mod = new SpellModifier;
2780 mod->op = SPELLMOD_EFFECT1;
2781 mod->value = m_modifier.m_amount;
2782 mod->type = SPELLMOD_PCT;
2783 mod->spellId = GetId();
2784 switch (m_effIndex)
2786 case 0:
2787 // Windfury Totem
2788 mod->mask = UI64LIT(0x00200000000);
2789 mod->mask2= UI64LIT(0x0);
2790 break;
2791 case 1:
2792 // Flametongue Totem
2793 mod->mask = UI64LIT(0x00400000000);
2794 mod->mask2= UI64LIT(0x0);
2795 break;
2798 m_spellmod = mod;
2801 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
2802 return;
2804 break;
2808 // pet auras
2809 if(PetAura const* petSpell = sSpellMgr.GetPetAura(GetId(), m_effIndex))
2811 if(apply)
2812 m_target->AddPetAura(petSpell);
2813 else
2814 m_target->RemovePetAura(petSpell);
2815 return;
2818 if(GetEffIndex()==0 && m_target->GetTypeId()==TYPEID_PLAYER)
2820 SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAuraMapBounds(GetId());
2821 if(saBounds.first != saBounds.second)
2823 uint32 zone, area;
2824 m_target->GetZoneAndAreaId(zone, area);
2826 for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
2828 // some auras remove at aura remove
2829 if(!itr->second->IsFitToRequirements((Player*)m_target, zone, area))
2830 m_target->RemoveAurasDueToSpell(itr->second->spellId);
2831 // some auras applied at aura apply
2832 else if(itr->second->autocast)
2834 if( !m_target->HasAura(itr->second->spellId, 0) )
2835 m_target->CastSpell(m_target, itr->second->spellId, true);
2842 void Aura::HandleAuraMounted(bool apply, bool Real)
2844 // only at real add/remove aura
2845 if(!Real)
2846 return;
2848 if(apply)
2850 CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(m_modifier.m_miscvalue);
2851 if(!ci)
2853 sLog.outErrorDb("AuraMounted: `creature_template`='%u' not found in database (only need it modelid)", m_modifier.m_miscvalue);
2854 return;
2857 uint32 team = 0;
2858 if (m_target->GetTypeId()==TYPEID_PLAYER)
2859 team = ((Player*)m_target)->GetTeam();
2861 uint32 display_id = sObjectMgr.ChooseDisplayId(team,ci);
2862 CreatureModelInfo const *minfo = sObjectMgr.GetCreatureModelRandomGender(display_id);
2863 if (minfo)
2864 display_id = minfo->modelid;
2866 m_target->Mount(display_id);
2868 else
2870 m_target->Unmount();
2874 void Aura::HandleAuraWaterWalk(bool apply, bool Real)
2876 // only at real add/remove aura
2877 if(!Real)
2878 return;
2880 WorldPacket data;
2881 if(apply)
2882 data.Initialize(SMSG_MOVE_WATER_WALK, 8+4);
2883 else
2884 data.Initialize(SMSG_MOVE_LAND_WALK, 8+4);
2885 data.append(m_target->GetPackGUID());
2886 data << uint32(0);
2887 m_target->SendMessageToSet(&data, true);
2890 void Aura::HandleAuraFeatherFall(bool apply, bool Real)
2892 // only at real add/remove aura
2893 if(!Real)
2894 return;
2896 WorldPacket data;
2897 if(apply)
2898 data.Initialize(SMSG_MOVE_FEATHER_FALL, 8+4);
2899 else
2900 data.Initialize(SMSG_MOVE_NORMAL_FALL, 8+4);
2901 data.append(m_target->GetPackGUID());
2902 data << uint32(0);
2903 m_target->SendMessageToSet(&data, true);
2905 // start fall from current height
2906 if(!apply && m_target->GetTypeId() == TYPEID_PLAYER)
2907 ((Player*)m_target)->SetFallInformation(0, m_target->GetPositionZ());
2910 void Aura::HandleAuraHover(bool apply, bool Real)
2912 // only at real add/remove aura
2913 if(!Real)
2914 return;
2916 WorldPacket data;
2917 if(apply)
2918 data.Initialize(SMSG_MOVE_SET_HOVER, 8+4);
2919 else
2920 data.Initialize(SMSG_MOVE_UNSET_HOVER, 8+4);
2921 data.append(m_target->GetPackGUID());
2922 data << uint32(0);
2923 m_target->SendMessageToSet(&data, true);
2926 void Aura::HandleWaterBreathing(bool /*apply*/, bool /*Real*/)
2928 // update timers in client
2929 if(m_target->GetTypeId()==TYPEID_PLAYER)
2930 ((Player*)m_target)->UpdateMirrorTimers();
2933 void Aura::HandleAuraModShapeshift(bool apply, bool Real)
2935 if(!Real)
2936 return;
2938 uint32 modelid = 0;
2939 Powers PowerType = POWER_MANA;
2940 ShapeshiftForm form = ShapeshiftForm(m_modifier.m_miscvalue);
2942 SpellShapeshiftEntry const* ssEntry = sSpellShapeshiftStore.LookupEntry(form);
2943 if (!ssEntry)
2945 sLog.outError("Unknown shapeshift form %u in spell %u", form, GetId());
2946 return;
2949 if (ssEntry->modelID_A)
2951 // i will asume that creatures will always take the defined model from the dbc
2952 // since no field in creature_templates describes wether an alliance or
2953 // horde modelid should be used at shapeshifting
2954 if (m_target->GetTypeId() != TYPEID_PLAYER)
2955 modelid = ssEntry->modelID_A;
2956 else
2958 // players are a bit difficult since the dbc has seldomly an horde modelid
2959 // so we add hacks here to set the right model
2960 if (Player::TeamForRace(m_target->getRace()) == ALLIANCE)
2961 modelid = ssEntry->modelID_A;
2962 else // 3.2.3 only the moonkin form has this information
2963 modelid = ssEntry->modelID_H;
2965 // no model found, if player is horde we look here for our hardcoded modelids
2966 if (!modelid && Player::TeamForRace(m_target->getRace()) == HORDE)
2969 switch(form)
2971 case FORM_CAT:
2972 modelid = 8571;
2973 break;
2974 case FORM_BEAR:
2975 case FORM_DIREBEAR:
2976 modelid = 2289;
2977 break;
2978 case FORM_FLIGHT:
2979 modelid = 20872;
2980 break;
2981 case FORM_FLIGHT_EPIC:
2982 modelid = 21244;
2983 break;
2984 // per default use alliance modelid
2985 // mostly horde and alliance share the same
2986 default:
2987 modelid = ssEntry->modelID_A;
2988 break;
2994 // now only powertype must be set
2995 switch(form)
2997 case FORM_CAT:
2998 PowerType = POWER_ENERGY;
2999 break;
3000 case FORM_BEAR:
3001 case FORM_DIREBEAR:
3002 case FORM_BATTLESTANCE:
3003 case FORM_BERSERKERSTANCE:
3004 case FORM_DEFENSIVESTANCE:
3005 PowerType = POWER_RAGE;
3006 break;
3007 default:
3008 break;
3011 // remove polymorph before changing display id to keep new display id
3012 switch ( form )
3014 case FORM_CAT:
3015 case FORM_TREE:
3016 case FORM_TRAVEL:
3017 case FORM_AQUA:
3018 case FORM_BEAR:
3019 case FORM_DIREBEAR:
3020 case FORM_FLIGHT_EPIC:
3021 case FORM_FLIGHT:
3022 case FORM_MOONKIN:
3024 // remove movement affects
3025 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT);
3026 Unit::AuraList const& slowingAuras = m_target->GetAurasByType(SPELL_AURA_MOD_DECREASE_SPEED);
3027 for (Unit::AuraList::const_iterator iter = slowingAuras.begin(); iter != slowingAuras.end();)
3029 SpellEntry const* aurSpellInfo = (*iter)->GetSpellProto();
3031 uint32 aurMechMask = GetAllSpellMechanicMask(aurSpellInfo);
3033 // If spell that caused this aura has Croud Control or Daze effect
3034 if((aurMechMask & MECHANIC_NOT_REMOVED_BY_SHAPESHIFT) ||
3035 // some Daze spells have these parameters instead of MECHANIC_DAZE (skip snare spells)
3036 aurSpellInfo->SpellIconID == 15 && aurSpellInfo->Dispel == 0 &&
3037 (aurMechMask & (1 << (MECHANIC_SNARE-1)))==0)
3039 ++iter;
3040 continue;
3043 // All OK, remove aura now
3044 m_target->RemoveAurasDueToSpellByCancel(aurSpellInfo->Id);
3045 iter = slowingAuras.begin();
3048 // and polymorphic affects
3049 if(m_target->IsPolymorphed())
3050 m_target->RemoveAurasDueToSpell(m_target->getTransForm());
3052 break;
3054 default:
3055 break;
3058 if(apply)
3060 // remove other shapeshift before applying a new one
3061 if(m_target->m_ShapeShiftFormSpellId)
3062 m_target->RemoveAurasDueToSpell(m_target->m_ShapeShiftFormSpellId, this);
3064 m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, form);
3066 if(modelid > 0)
3067 m_target->SetDisplayId(modelid);
3069 if(PowerType != POWER_MANA)
3071 // reset power to default values only at power change
3072 if(m_target->getPowerType() != PowerType)
3073 m_target->setPowerType(PowerType);
3075 switch(form)
3077 case FORM_CAT:
3078 case FORM_BEAR:
3079 case FORM_DIREBEAR:
3081 // get furor proc chance
3082 uint32 FurorChance = 0;
3083 Unit::AuraList const& mDummy = m_target->GetAurasByType(SPELL_AURA_DUMMY);
3084 for(Unit::AuraList::const_iterator i = mDummy.begin(); i != mDummy.end(); ++i)
3086 if ((*i)->GetSpellProto()->SpellIconID == 238)
3088 FurorChance = (*i)->GetModifier()->m_amount;
3089 break;
3093 if (m_modifier.m_miscvalue == FORM_CAT)
3095 m_target->SetPower(POWER_ENERGY, 0);
3096 if(urand(1,100) <= FurorChance)
3097 m_target->CastSpell(m_target, 17099, true, NULL, this);
3099 else
3101 m_target->SetPower(POWER_RAGE, 0);
3102 if(urand(1,100) <= FurorChance)
3103 m_target->CastSpell(m_target, 17057, true, NULL, this);
3105 break;
3107 case FORM_BATTLESTANCE:
3108 case FORM_DEFENSIVESTANCE:
3109 case FORM_BERSERKERSTANCE:
3111 uint32 Rage_val = 0;
3112 // Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch)
3113 if(m_target->GetTypeId() == TYPEID_PLAYER)
3115 PlayerSpellMap const& sp_list = ((Player *)m_target)->GetSpellMap();
3116 for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
3118 if(itr->second->state == PLAYERSPELL_REMOVED) continue;
3119 SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
3120 if (spellInfo && spellInfo->SpellFamilyName == SPELLFAMILY_WARRIOR && spellInfo->SpellIconID == 139)
3121 Rage_val += m_target->CalculateSpellDamage(spellInfo, 0, spellInfo->EffectBasePoints[0], m_target) * 10;
3125 if (m_target->GetPower(POWER_RAGE) > Rage_val)
3126 m_target->SetPower(POWER_RAGE, Rage_val);
3127 break;
3129 default:
3130 break;
3134 m_target->m_ShapeShiftFormSpellId = GetId();
3135 m_target->m_form = form;
3137 // a form can give the player a new castbar with some spells.. this is a clientside process..
3138 // serverside just needs to register the new spells so that player isn't kicked as cheater
3139 if (m_target->GetTypeId() == TYPEID_PLAYER)
3140 for (uint32 i = 0; i < 8; ++i)
3141 if (ssEntry->spellId[i])
3142 ((Player*)m_target)->addSpell(ssEntry->spellId[i], true, false, false, false);
3145 else
3147 if(modelid > 0)
3148 m_target->SetDisplayId(m_target->GetNativeDisplayId());
3149 m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, FORM_NONE);
3150 if(m_target->getClass() == CLASS_DRUID)
3151 m_target->setPowerType(POWER_MANA);
3152 m_target->m_ShapeShiftFormSpellId = 0;
3153 m_target->m_form = FORM_NONE;
3155 switch(form)
3157 // Nordrassil Harness - bonus
3158 case FORM_BEAR:
3159 case FORM_DIREBEAR:
3160 case FORM_CAT:
3161 if(Aura* dummy = m_target->GetDummyAura(37315) )
3162 m_target->CastSpell(m_target, 37316, true, NULL, dummy);
3163 break;
3164 // Nordrassil Regalia - bonus
3165 case FORM_MOONKIN:
3166 if(Aura* dummy = m_target->GetDummyAura(37324) )
3167 m_target->CastSpell(m_target, 37325, true, NULL, dummy);
3168 break;
3169 default:
3170 break;
3173 // look at the comment in apply-part
3174 if (m_target->GetTypeId() == TYPEID_PLAYER)
3175 for (uint32 i = 0; i < 8; ++i)
3176 if (ssEntry->spellId[i])
3177 ((Player*)m_target)->removeSpell(ssEntry->spellId[i], false, false, false);
3181 // adding/removing linked auras
3182 // add/remove the shapeshift aura's boosts
3183 HandleShapeshiftBoosts(apply);
3185 if(m_target->GetTypeId() == TYPEID_PLAYER)
3186 ((Player*)m_target)->InitDataForForm();
3189 void Aura::HandleAuraTransform(bool apply, bool Real)
3191 if (apply)
3193 // special case (spell specific functionality)
3194 if (m_modifier.m_miscvalue == 0)
3196 // player applied only
3197 if (m_target->GetTypeId() != TYPEID_PLAYER)
3198 return;
3200 switch (GetId())
3202 // Orb of Deception
3203 case 16739:
3205 uint32 orb_model = m_target->GetNativeDisplayId();
3206 switch(orb_model)
3208 // Troll Female
3209 case 1479: m_target->SetDisplayId(10134); break;
3210 // Troll Male
3211 case 1478: m_target->SetDisplayId(10135); break;
3212 // Tauren Male
3213 case 59: m_target->SetDisplayId(10136); break;
3214 // Human Male
3215 case 49: m_target->SetDisplayId(10137); break;
3216 // Human Female
3217 case 50: m_target->SetDisplayId(10138); break;
3218 // Orc Male
3219 case 51: m_target->SetDisplayId(10139); break;
3220 // Orc Female
3221 case 52: m_target->SetDisplayId(10140); break;
3222 // Dwarf Male
3223 case 53: m_target->SetDisplayId(10141); break;
3224 // Dwarf Female
3225 case 54: m_target->SetDisplayId(10142); break;
3226 // NightElf Male
3227 case 55: m_target->SetDisplayId(10143); break;
3228 // NightElf Female
3229 case 56: m_target->SetDisplayId(10144); break;
3230 // Undead Female
3231 case 58: m_target->SetDisplayId(10145); break;
3232 // Undead Male
3233 case 57: m_target->SetDisplayId(10146); break;
3234 // Tauren Female
3235 case 60: m_target->SetDisplayId(10147); break;
3236 // Gnome Male
3237 case 1563: m_target->SetDisplayId(10148); break;
3238 // Gnome Female
3239 case 1564: m_target->SetDisplayId(10149); break;
3240 // BloodElf Female
3241 case 15475: m_target->SetDisplayId(17830); break;
3242 // BloodElf Male
3243 case 15476: m_target->SetDisplayId(17829); break;
3244 // Dranei Female
3245 case 16126: m_target->SetDisplayId(17828); break;
3246 // Dranei Male
3247 case 16125: m_target->SetDisplayId(17827); break;
3248 default: break;
3250 break;
3252 // Murloc costume
3253 case 42365: m_target->SetDisplayId(21723); break;
3254 // Honor the Dead
3255 case 65386:
3256 case 65495:
3258 switch(m_target->getGender())
3260 case GENDER_MALE:
3261 m_target->SetDisplayId(29203); // Chapman
3262 break;
3263 case GENDER_FEMALE:
3264 case GENDER_NONE:
3265 m_target->SetDisplayId(29204); // Catrina
3266 break;
3268 break;
3270 default: break;
3273 else
3275 uint32 model_id;
3277 CreatureInfo const * ci = ObjectMgr::GetCreatureTemplate(m_modifier.m_miscvalue);
3278 if (!ci)
3280 model_id = 16358; // pig pink ^_^
3281 sLog.outError("Auras: unknown creature id = %d (only need its modelid) Form Spell Aura Transform in Spell ID = %d", m_modifier.m_miscvalue, GetId());
3283 else
3284 model_id = ci->DisplayID_A[0]; // Will use the default model here
3286 // Polymorph (sheep/penguin case)
3287 if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_MAGE && GetSpellProto()->SpellIconID == 82)
3288 if (Unit* caster = GetCaster())
3289 if (caster->HasAura(52648)) // Glyph of the Penguin
3290 model_id = 26452;
3292 m_target->SetDisplayId(model_id);
3294 // Dragonmaw Illusion (set mount model also)
3295 if(GetId()==42016 && m_target->GetMountID() && !m_target->GetAurasByType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED).empty())
3296 m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314);
3299 // update active transform spell only not set or not overwriting negative by positive case
3300 if (!m_target->getTransForm() || !IsPositiveSpell(GetId()) || IsPositiveSpell(m_target->getTransForm()))
3301 m_target->setTransForm(GetId());
3303 // polymorph case
3304 if (Real && m_target->GetTypeId() == TYPEID_PLAYER && m_target->IsPolymorphed())
3306 // for players, start regeneration after 1s (in polymorph fast regeneration case)
3307 // only if caster is Player (after patch 2.4.2)
3308 if (IS_PLAYER_GUID(GetCasterGUID()) )
3309 ((Player*)m_target)->setRegenTimer(1*IN_MILISECONDS);
3311 //dismount polymorphed target (after patch 2.4.2)
3312 if (m_target->IsMounted())
3313 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
3316 else
3318 // ApplyModifier(true) will reapply it if need
3319 m_target->setTransForm(0);
3320 m_target->SetDisplayId(m_target->GetNativeDisplayId());
3322 // re-aplly some from still active with preference negative cases
3323 Unit::AuraList const& otherTransforms = m_target->GetAurasByType(SPELL_AURA_TRANSFORM);
3324 if (!otherTransforms.empty())
3326 // look for other transform auras
3327 Aura* handledAura = *otherTransforms.begin();
3328 for(Unit::AuraList::const_iterator i = otherTransforms.begin();i != otherTransforms.end(); ++i)
3330 // negative auras are preferred
3331 if (!IsPositiveSpell((*i)->GetSpellProto()->Id))
3333 handledAura = *i;
3334 break;
3337 handledAura->ApplyModifier(true);
3340 // Dragonmaw Illusion (restore mount model)
3341 if (GetId() == 42016 && m_target->GetMountID() == 16314)
3343 if (!m_target->GetAurasByType(SPELL_AURA_MOUNTED).empty())
3345 uint32 cr_id = m_target->GetAurasByType(SPELL_AURA_MOUNTED).front()->GetModifier()->m_miscvalue;
3346 if (CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(cr_id))
3348 uint32 team = 0;
3349 if (m_target->GetTypeId() == TYPEID_PLAYER)
3350 team = ((Player*)m_target)->GetTeam();
3352 uint32 display_id = sObjectMgr.ChooseDisplayId(team, ci);
3353 CreatureModelInfo const *minfo = sObjectMgr.GetCreatureModelRandomGender(display_id);
3354 if (minfo)
3355 display_id = minfo->modelid;
3357 m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, display_id);
3364 void Aura::HandleForceReaction(bool apply, bool Real)
3366 if(m_target->GetTypeId() != TYPEID_PLAYER)
3367 return;
3369 if(!Real)
3370 return;
3372 Player* player = (Player*)m_target;
3374 uint32 faction_id = m_modifier.m_miscvalue;
3375 ReputationRank faction_rank = ReputationRank(m_modifier.m_amount);
3377 player->GetReputationMgr().ApplyForceReaction(faction_id, faction_rank, apply);
3378 player->GetReputationMgr().SendForceReactions();
3380 // stop fighting if at apply forced rank friendly or at remove real rank friendly
3381 if (apply && faction_rank >= REP_FRIENDLY || !apply && player->GetReputationRank(faction_id) >= REP_FRIENDLY)
3382 player->StopAttackFaction(faction_id);
3385 void Aura::HandleAuraModSkill(bool apply, bool /*Real*/)
3387 if(m_target->GetTypeId() != TYPEID_PLAYER)
3388 return;
3390 uint32 prot=GetSpellProto()->EffectMiscValue[m_effIndex];
3391 int32 points = GetModifier()->m_amount;
3393 ((Player*)m_target)->ModifySkillBonus(prot, (apply ? points: -points), m_modifier.m_auraname == SPELL_AURA_MOD_SKILL_TALENT);
3394 if(prot == SKILL_DEFENSE)
3395 ((Player*)m_target)->UpdateDefenseBonusesMod();
3398 void Aura::HandleChannelDeathItem(bool apply, bool Real)
3400 if(Real && !apply)
3402 if(m_removeMode != AURA_REMOVE_BY_DEATH)
3403 return;
3404 // Item amount
3405 if (m_modifier.m_amount <= 0)
3406 return;
3408 SpellEntry const *spellInfo = GetSpellProto();
3409 if(spellInfo->EffectItemType[m_effIndex] == 0)
3410 return;
3412 Unit* victim = GetTarget();
3413 Unit* caster = GetCaster();
3414 if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
3415 return;
3417 // Soul Shard only from non-grey units
3418 if( spellInfo->EffectItemType[m_effIndex] == 6265 &&
3419 (victim->getLevel() <= MaNGOS::XP::GetGrayLevel(caster->getLevel()) ||
3420 victim->GetTypeId()==TYPEID_UNIT && !((Player*)caster)->isAllowedToLoot((Creature*)victim)) )
3421 return;
3422 //Adding items
3423 uint32 noSpaceForCount = 0;
3424 uint32 count = m_modifier.m_amount;
3426 ItemPosCountVec dest;
3427 uint8 msg = ((Player*)caster)->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, spellInfo->EffectItemType[m_effIndex], count, &noSpaceForCount);
3428 if( msg != EQUIP_ERR_OK )
3430 count-=noSpaceForCount;
3431 ((Player*)caster)->SendEquipError( msg, NULL, NULL );
3432 if (count==0)
3433 return;
3436 Item* newitem = ((Player*)caster)->StoreNewItem(dest, spellInfo->EffectItemType[m_effIndex], true);
3437 ((Player*)caster)->SendNewItem(newitem, count, true, false);
3441 void Aura::HandleBindSight(bool apply, bool /*Real*/)
3443 Unit* caster = GetCaster();
3444 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3445 return;
3447 ((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);
3450 void Aura::HandleFarSight(bool apply, bool /*Real*/)
3452 Unit* caster = GetCaster();
3453 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3454 return;
3456 ((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);
3459 void Aura::HandleAuraTrackCreatures(bool apply, bool /*Real*/)
3461 if(m_target->GetTypeId()!=TYPEID_PLAYER)
3462 return;
3464 if(apply)
3465 m_target->RemoveNoStackAurasDueToAura(this);
3466 m_target->SetUInt32Value(PLAYER_TRACK_CREATURES, apply ? ((uint32)1)<<(m_modifier.m_miscvalue-1) : 0 );
3469 void Aura::HandleAuraTrackResources(bool apply, bool /*Real*/)
3471 if(m_target->GetTypeId()!=TYPEID_PLAYER)
3472 return;
3474 if(apply)
3475 m_target->RemoveNoStackAurasDueToAura(this);
3476 m_target->SetUInt32Value(PLAYER_TRACK_RESOURCES, apply ? ((uint32)1)<<(m_modifier.m_miscvalue-1): 0 );
3479 void Aura::HandleAuraTrackStealthed(bool apply, bool /*Real*/)
3481 if(m_target->GetTypeId()!=TYPEID_PLAYER)
3482 return;
3484 if(apply)
3485 m_target->RemoveNoStackAurasDueToAura(this);
3487 m_target->ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_TRACK_STEALTHED, apply);
3490 void Aura::HandleAuraModScale(bool apply, bool /*Real*/)
3492 m_target->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X, m_modifier.m_amount, apply);
3495 void Aura::HandleModPossess(bool apply, bool Real)
3497 if(!Real)
3498 return;
3500 // not possess yourself
3501 if(GetCasterGUID() == m_target->GetGUID())
3502 return;
3504 Unit* caster = GetCaster();
3505 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3506 return;
3508 Player* p_caster = (Player*)caster;
3511 if( apply )
3513 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
3515 m_target->SetCharmerGUID(p_caster->GetGUID());
3516 m_target->setFaction(p_caster->getFaction());
3518 p_caster->SetCharm(m_target);
3520 p_caster->SetFarSightGUID(m_target->GetGUID());
3521 p_caster->SetClientControl(m_target, 1);
3522 p_caster->SetMover(m_target);
3524 m_target->CombatStop();
3525 m_target->DeleteThreatList();
3527 if(m_target->GetTypeId() == TYPEID_UNIT)
3529 m_target->StopMoving();
3530 m_target->GetMotionMaster()->Clear();
3531 m_target->GetMotionMaster()->MoveIdle();
3533 else if(m_target->GetTypeId() == TYPEID_PLAYER)
3535 ((Player*)m_target)->SetClientControl(m_target, 0);
3538 if(CharmInfo *charmInfo = m_target->InitCharmInfo(m_target))
3539 charmInfo->InitPossessCreateSpells();
3541 p_caster->PossessSpellInitialize();
3543 else
3545 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
3547 m_target->SetCharmerGUID(0);
3548 p_caster->InterruptSpell(CURRENT_CHANNELED_SPELL); // the spell is not automatically canceled when interrupted, do it now
3550 if(m_target->GetTypeId() == TYPEID_PLAYER)
3552 ((Player*)m_target)->setFactionForRace(m_target->getRace());
3553 ((Player*)m_target)->SetClientControl(m_target, 1);
3555 else if(m_target->GetTypeId() == TYPEID_UNIT)
3557 CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
3558 m_target->setFaction(cinfo->faction_A);
3561 p_caster->SetCharm(NULL);
3563 p_caster->SetFarSightGUID(0);
3564 p_caster->SetClientControl(m_target, 0);
3565 p_caster->SetMover(NULL);
3567 p_caster->RemovePetActionBar();
3569 if(m_target->GetTypeId() == TYPEID_UNIT)
3571 ((Creature*)m_target)->AIM_Initialize();
3573 if (((Creature*)m_target)->AI())
3574 ((Creature*)m_target)->AI()->AttackedBy(caster);
3579 void Aura::HandleModPossessPet(bool apply, bool Real)
3581 if(!Real)
3582 return;
3584 Unit* caster = GetCaster();
3585 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3586 return;
3588 Pet *pet = caster->GetPet();
3589 if(!pet || pet != m_target)
3590 return;
3592 Player* p_caster = (Player*)caster;
3594 if(apply)
3595 pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
3596 else
3597 pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
3599 p_caster->SetFarSightGUID(apply ? pet->GetGUID() : 0);
3600 p_caster->SetCharm(apply ? pet : NULL);
3601 p_caster->SetClientControl(pet, apply ? 1 : 0);
3602 ((Player*)caster)->SetMover(apply ? pet : NULL);
3604 if(apply)
3606 pet->StopMoving();
3607 pet->GetMotionMaster()->Clear();
3608 pet->GetMotionMaster()->MoveIdle();
3610 else
3612 pet->AttackStop();
3613 pet->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
3614 pet->AddMonsterMoveFlag(MONSTER_MOVE_WALK);
3618 void Aura::HandleAuraModPetTalentsPoints(bool /*Apply*/, bool Real)
3620 if(!Real)
3621 return;
3623 // Recalculate pet talent points
3624 if (Pet *pet=m_target->GetPet())
3625 pet->InitTalentForLevel();
3628 void Aura::HandleModCharm(bool apply, bool Real)
3630 if(!Real)
3631 return;
3633 // not charm yourself
3634 if(GetCasterGUID() == m_target->GetGUID())
3635 return;
3637 Unit* caster = GetCaster();
3638 if(!caster)
3639 return;
3641 if( apply )
3643 if (m_target->GetCharmerGUID())
3645 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM);
3646 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS);
3649 m_target->SetCharmerGUID(GetCasterGUID());
3650 m_target->setFaction(caster->getFaction());
3651 m_target->CastStop(m_target == caster ? GetId() : 0);
3652 caster->SetCharm(m_target);
3654 m_target->CombatStop();
3655 m_target->DeleteThreatList();
3657 if(m_target->GetTypeId() == TYPEID_UNIT)
3659 ((Creature*)m_target)->AIM_Initialize();
3660 CharmInfo *charmInfo = m_target->InitCharmInfo(m_target);
3661 charmInfo->InitCharmCreateSpells();
3662 charmInfo->SetReactState( REACT_DEFENSIVE );
3664 if(caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK)
3666 CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
3667 if(cinfo && cinfo->type == CREATURE_TYPE_DEMON)
3669 // creature with pet number expected have class set
3670 if(m_target->GetByteValue(UNIT_FIELD_BYTES_0, 1)==0)
3672 if(cinfo->unit_class==0)
3673 sLog.outErrorDb("Creature (Entry: %u) have unit_class = 0 but used in charmed spell, that will be result client crash.",cinfo->Entry);
3674 else
3675 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);
3677 m_target->SetByteValue(UNIT_FIELD_BYTES_0, 1, CLASS_MAGE);
3680 //just to enable stat window
3681 charmInfo->SetPetNumber(sObjectMgr.GeneratePetNumber(), true);
3682 //if charmed two demons the same session, the 2nd gets the 1st one's name
3683 m_target->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL));
3688 if(caster->GetTypeId() == TYPEID_PLAYER)
3689 ((Player*)caster)->CharmSpellInitialize();
3691 else
3693 m_target->SetCharmerGUID(0);
3695 if(m_target->GetTypeId() == TYPEID_PLAYER)
3696 ((Player*)m_target)->setFactionForRace(m_target->getRace());
3697 else
3699 CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
3701 // restore faction
3702 if(((Creature*)m_target)->isPet())
3704 if(Unit* owner = m_target->GetOwner())
3705 m_target->setFaction(owner->getFaction());
3706 else if(cinfo)
3707 m_target->setFaction(cinfo->faction_A);
3709 else if(cinfo) // normal creature
3710 m_target->setFaction(cinfo->faction_A);
3712 // restore UNIT_FIELD_BYTES_0
3713 if(cinfo && caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK && cinfo->type == CREATURE_TYPE_DEMON)
3715 // DB must have proper class set in field at loading, not req. restore, including workaround case at apply
3716 // m_target->SetByteValue(UNIT_FIELD_BYTES_0, 1, cinfo->unit_class);
3718 if(m_target->GetCharmInfo())
3719 m_target->GetCharmInfo()->SetPetNumber(0, true);
3720 else
3721 sLog.outError("Aura::HandleModCharm: target (GUID: %u TypeId: %u) has a charm aura but no charm info!", m_target->GetGUIDLow(), m_target->GetTypeId());
3725 caster->SetCharm(NULL);
3727 if(caster->GetTypeId() == TYPEID_PLAYER)
3728 ((Player*)caster)->RemovePetActionBar();
3730 if(m_target->GetTypeId() == TYPEID_UNIT)
3732 ((Creature*)m_target)->AIM_Initialize();
3733 if (((Creature*)m_target)->AI())
3734 ((Creature*)m_target)->AI()->AttackedBy(caster);
3739 void Aura::HandleModConfuse(bool apply, bool Real)
3741 if(!Real)
3742 return;
3744 m_target->SetConfused(apply, GetCasterGUID(), GetId());
3747 void Aura::HandleModFear(bool apply, bool Real)
3749 if (!Real)
3750 return;
3752 m_target->SetFeared(apply, GetCasterGUID(), GetId());
3755 void Aura::HandleFeignDeath(bool apply, bool Real)
3757 if(!Real)
3758 return;
3760 m_target->SetFeignDeath(apply, GetCasterGUID(), GetId());
3763 void Aura::HandleAuraModDisarm(bool apply, bool Real)
3765 if(!Real)
3766 return;
3768 if(!apply && m_target->HasAuraType(SPELL_AURA_MOD_DISARM))
3769 return;
3771 // not sure for it's correctness
3772 if(apply)
3773 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
3774 else
3775 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
3777 // only at real add/remove aura
3778 if (m_target->GetTypeId() != TYPEID_PLAYER)
3779 return;
3781 // main-hand attack speed already set to special value for feral form already and don't must change and reset at remove.
3782 if (m_target->IsInFeralForm())
3783 return;
3785 if (apply)
3786 m_target->SetAttackTime(BASE_ATTACK,BASE_ATTACK_TIME);
3787 else
3788 ((Player *)m_target)->SetRegularAttackTime();
3790 m_target->UpdateDamagePhysical(BASE_ATTACK);
3793 void Aura::HandleAuraModStun(bool apply, bool Real)
3795 if(!Real)
3796 return;
3798 if (apply)
3800 // Frost stun aura -> freeze/unfreeze target
3801 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
3802 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
3804 m_target->addUnitState(UNIT_STAT_STUNNED);
3805 m_target->SetTargetGUID(0);
3807 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
3808 m_target->CastStop(m_target->GetGUID() == GetCasterGUID() ? GetId() : 0);
3810 // Creature specific
3811 if(m_target->GetTypeId() != TYPEID_PLAYER)
3812 m_target->StopMoving();
3813 else
3815 ((Player*)m_target)->m_movementInfo.SetMovementFlags(MOVEMENTFLAG_NONE);
3816 m_target->SetStandState(UNIT_STAND_STATE_STAND);// in 1.5 client
3819 WorldPacket data(SMSG_FORCE_MOVE_ROOT, 8);
3820 data.append(m_target->GetPackGUID());
3821 data << uint32(0);
3822 m_target->SendMessageToSet(&data, true);
3824 // Summon the Naj'entus Spine GameObject on target if spell is Impaling Spine
3825 if(GetId() == 39837)
3827 GameObject* pObj = new GameObject;
3828 if(pObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 185584, m_target->GetMap(), m_target->GetPhaseMask(),
3829 m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
3831 pObj->SetRespawnTime(GetAuraDuration()/IN_MILISECONDS);
3832 pObj->SetSpellId(GetId());
3833 m_target->AddGameObject(pObj);
3834 m_target->GetMap()->Add(pObj);
3836 else
3837 delete pObj;
3840 else
3842 // Frost stun aura -> freeze/unfreeze target
3843 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
3845 bool found_another = false;
3846 for(AuraType const* itr = &frozenAuraTypes[0]; *itr != SPELL_AURA_NONE; ++itr)
3848 Unit::AuraList const& auras = m_target->GetAurasByType(*itr);
3849 for(Unit::AuraList::const_iterator i = auras.begin(); i != auras.end(); ++i)
3851 if( GetSpellSchoolMask((*i)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST)
3853 found_another = true;
3854 break;
3857 if(found_another)
3858 break;
3861 if(!found_another)
3862 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
3865 // Real remove called after current aura remove from lists, check if other similar auras active
3866 if(m_target->HasAuraType(SPELL_AURA_MOD_STUN))
3867 return;
3869 m_target->clearUnitState(UNIT_STAT_STUNNED);
3870 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
3872 if(!m_target->hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect
3874 if(m_target->getVictim() && m_target->isAlive())
3875 m_target->SetTargetGUID(m_target->getVictim()->GetGUID());
3877 WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 8+4);
3878 data.append(m_target->GetPackGUID());
3879 data << uint32(0);
3880 m_target->SendMessageToSet(&data, true);
3883 // Wyvern Sting
3884 if (m_spellProto->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellProto->SpellFamilyFlags & UI64LIT(0x0000100000000000))
3886 Unit* caster = GetCaster();
3887 if( !caster || caster->GetTypeId()!=TYPEID_PLAYER )
3888 return;
3890 uint32 spell_id = 0;
3892 switch(GetId())
3894 case 19386: spell_id = 24131; break;
3895 case 24132: spell_id = 24134; break;
3896 case 24133: spell_id = 24135; break;
3897 case 27068: spell_id = 27069; break;
3898 case 49011: spell_id = 49009; break;
3899 case 49012: spell_id = 49010; break;
3900 default:
3901 sLog.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?",GetId());
3902 return;
3905 SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id);
3907 if(!spellInfo)
3908 return;
3910 caster->CastSpell(m_target,spellInfo,true,NULL,this);
3911 return;
3916 void Aura::HandleModStealth(bool apply, bool Real)
3918 if (apply)
3920 // drop flag at stealth in bg
3921 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
3923 // only at real aura add
3924 if (Real)
3926 m_target->SetStandFlags(UNIT_STAND_FLAGS_CREEP);
3928 if (m_target->GetTypeId()==TYPEID_PLAYER)
3929 m_target->SetFlag(PLAYER_FIELD_BYTES2, 0x2000);
3931 // apply only if not in GM invisibility (and overwrite invisibility state)
3932 if (m_target->GetVisibility()!=VISIBILITY_OFF)
3934 m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
3935 m_target->SetVisibility(VISIBILITY_GROUP_STEALTH);
3938 // apply full stealth period bonuses only at first stealth aura in stack
3939 if(m_target->GetAurasByType(SPELL_AURA_MOD_STEALTH).size()<=1)
3941 Unit::AuraList const& mDummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
3942 for(Unit::AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i)
3944 // Master of Subtlety
3945 if ((*i)->GetSpellProto()->SpellIconID == 2114)
3947 m_target->RemoveAurasDueToSpell(31666);
3948 int32 bp = (*i)->GetModifier()->m_amount;
3949 m_target->CastCustomSpell(m_target,31665,&bp,NULL,NULL,true);
3951 // Overkill
3952 else if ((*i)->GetId() == 58426 && GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000400000))
3954 m_target->RemoveAurasDueToSpell(58428);
3955 m_target->CastSpell(m_target, 58427, true);
3961 else
3963 // only at real aura remove of _last_ SPELL_AURA_MOD_STEALTH
3964 if (Real && !m_target->HasAuraType(SPELL_AURA_MOD_STEALTH))
3966 // if no GM invisibility
3967 if (m_target->GetVisibility()!=VISIBILITY_OFF)
3969 m_target->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP);
3971 if (m_target->GetTypeId()==TYPEID_PLAYER)
3972 m_target->RemoveFlag(PLAYER_FIELD_BYTES2, 0x2000);
3974 // restore invisibility if any
3975 if (m_target->HasAuraType(SPELL_AURA_MOD_INVISIBILITY))
3977 m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
3978 m_target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY);
3980 else
3981 m_target->SetVisibility(VISIBILITY_ON);
3984 // apply delayed talent bonus remover at last stealth aura remove
3985 Unit::AuraList const& mDummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
3986 for(Unit::AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i)
3988 // Master of Subtlety
3989 if ((*i)->GetSpellProto()->SpellIconID == 2114)
3990 m_target->CastSpell(m_target, 31666, true);
3991 // Overkill
3992 else if ((*i)->GetId() == 58426 && GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000400000))
3993 m_target->CastSpell(m_target, 58428, true);
3999 void Aura::HandleInvisibility(bool apply, bool Real)
4001 if(apply)
4003 m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue);
4005 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
4007 if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
4009 // apply glow vision
4010 m_target->SetFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
4014 // apply only if not in GM invisibility and not stealth
4015 if(m_target->GetVisibility() == VISIBILITY_ON)
4017 // Aura not added yet but visibility code expect temporary add aura
4018 m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
4019 m_target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY);
4022 else
4024 // recalculate value at modifier remove (current aura already removed)
4025 m_target->m_invisibilityMask = 0;
4026 Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY);
4027 for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
4028 m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue);
4030 // only at real aura remove and if not have different invisibility auras.
4031 if(Real && m_target->m_invisibilityMask == 0)
4033 // remove glow vision
4034 if(m_target->GetTypeId() == TYPEID_PLAYER)
4035 m_target->RemoveFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
4037 // apply only if not in GM invisibility & not stealthed while invisible
4038 if(m_target->GetVisibility() != VISIBILITY_OFF)
4040 // if have stealth aura then already have stealth visibility
4041 if(!m_target->HasAuraType(SPELL_AURA_MOD_STEALTH))
4042 m_target->SetVisibility(VISIBILITY_ON);
4048 void Aura::HandleInvisibilityDetect(bool apply, bool Real)
4050 if(apply)
4052 m_target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue);
4054 else
4056 // recalculate value at modifier remove (current aura already removed)
4057 m_target->m_detectInvisibilityMask = 0;
4058 Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION);
4059 for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
4060 m_target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue);
4062 if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
4063 ((Player*)m_target)->UpdateVisibilityForPlayer();
4066 void Aura::HandleAuraModRoot(bool apply, bool Real)
4068 // only at real add/remove aura
4069 if(!Real)
4070 return;
4072 if (apply)
4074 // Frost root aura -> freeze/unfreeze target
4075 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
4076 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
4078 m_target->addUnitState(UNIT_STAT_ROOT);
4079 m_target->SetTargetGUID(0);
4080 // probably wrong (this add skinnable flag)
4081 // TODO: find correct flag
4082 //m_target->SetFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
4084 //Save last orientation
4085 if( m_target->getVictim() )
4086 m_target->SetOrientation(m_target->GetAngle(m_target->getVictim()));
4088 if(m_target->GetTypeId() == TYPEID_PLAYER)
4090 WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10);
4091 data.append(m_target->GetPackGUID());
4092 data << (uint32)2;
4093 m_target->SendMessageToSet(&data, true);
4095 //Clear unit movement flags
4096 ((Player*)m_target)->m_movementInfo.SetMovementFlags(MOVEMENTFLAG_NONE);
4098 else
4099 m_target->StopMoving();
4101 else
4103 // Frost root aura -> freeze/unfreeze target
4104 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
4106 bool found_another = false;
4107 for(AuraType const* itr = &frozenAuraTypes[0]; *itr != SPELL_AURA_NONE; ++itr)
4109 Unit::AuraList const& auras = m_target->GetAurasByType(*itr);
4110 for(Unit::AuraList::const_iterator i = auras.begin(); i != auras.end(); ++i)
4112 if( GetSpellSchoolMask((*i)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST)
4114 found_another = true;
4115 break;
4118 if(found_another)
4119 break;
4122 if(!found_another)
4123 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
4126 // Real remove called after current aura remove from lists, check if other similar auras active
4127 if(m_target->HasAuraType(SPELL_AURA_MOD_ROOT))
4128 return;
4130 m_target->clearUnitState(UNIT_STAT_ROOT);
4131 // probably wrong (this add skinnable flag)
4132 // TODO: find correct flag
4133 //m_target->RemoveFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
4135 if(!m_target->hasUnitState(UNIT_STAT_STUNNED)) // prevent allow move if have also stun effect
4137 if(m_target->getVictim() && m_target->isAlive())
4138 m_target->SetTargetGUID(m_target->getVictim()->GetGUID());
4140 if(m_target->GetTypeId() == TYPEID_PLAYER)
4142 WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 10);
4143 data.append(m_target->GetPackGUID());
4144 data << (uint32)2;
4145 m_target->SendMessageToSet(&data, true);
4151 void Aura::HandleAuraModSilence(bool apply, bool Real)
4153 // only at real add/remove aura
4154 if(!Real)
4155 return;
4157 if(apply)
4159 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED);
4160 // Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE
4161 for (uint32 i = CURRENT_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
4162 if (Spell* spell = m_target->GetCurrentSpell(CurrentSpellTypes(i)))
4163 if(spell->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
4164 // Stop spells on prepare or casting state
4165 m_target->InterruptSpell(CurrentSpellTypes(i), false);
4167 else
4169 // Real remove called after current aura remove from lists, check if other similar auras active
4170 if(m_target->HasAuraType(SPELL_AURA_MOD_SILENCE))
4171 return;
4173 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED);
4177 void Aura::HandleModThreat(bool apply, bool Real)
4179 // only at real add/remove aura
4180 if (!Real)
4181 return;
4183 if (!m_target->isAlive())
4184 return;
4186 Unit* caster = GetCaster();
4188 if (!caster || !caster->isAlive())
4189 return;
4191 int level_diff = 0;
4192 int multiplier = 0;
4193 switch (GetId())
4195 // Arcane Shroud
4196 case 26400:
4197 level_diff = m_target->getLevel() - 60;
4198 multiplier = 2;
4199 break;
4200 // The Eye of Diminution
4201 case 28862:
4202 level_diff = m_target->getLevel() - 60;
4203 multiplier = 1;
4204 break;
4207 if (level_diff > 0)
4208 m_modifier.m_amount += multiplier * level_diff;
4210 if (m_target->GetTypeId() == TYPEID_PLAYER)
4211 for(int8 x=0;x < MAX_SPELL_SCHOOL;x++)
4212 if (m_modifier.m_miscvalue & int32(1<<x))
4213 ApplyPercentModFloatVar(m_target->m_threatModifier[x], m_modifier.m_amount, apply);
4216 void Aura::HandleAuraModTotalThreat(bool apply, bool Real)
4218 // only at real add/remove aura
4219 if (!Real)
4220 return;
4222 if (!m_target->isAlive() || m_target->GetTypeId() != TYPEID_PLAYER)
4223 return;
4225 Unit* caster = GetCaster();
4227 if (!caster || !caster->isAlive())
4228 return;
4230 float threatMod = apply ? float(m_modifier.m_amount) : float(-m_modifier.m_amount);
4232 m_target->getHostileRefManager().threatAssist(caster, threatMod, GetSpellProto());
4235 void Aura::HandleModTaunt(bool apply, bool Real)
4237 // only at real add/remove aura
4238 if (!Real)
4239 return;
4241 if (!m_target->isAlive() || !m_target->CanHaveThreatList())
4242 return;
4244 Unit* caster = GetCaster();
4246 if (!caster || !caster->isAlive())
4247 return;
4249 if (apply)
4250 m_target->TauntApply(caster);
4251 else
4253 // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat
4254 m_target->TauntFadeOut(caster);
4258 /*********************************************************/
4259 /*** MODIFY SPEED ***/
4260 /*********************************************************/
4261 void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real)
4263 // all applied/removed only at real aura add/remove
4264 if(!Real)
4265 return;
4267 m_target->UpdateSpeed(MOVE_RUN, true);
4270 void Aura::HandleAuraModIncreaseMountedSpeed(bool apply, bool Real)
4272 // all applied/removed only at real aura add/remove
4273 if(!Real)
4274 return;
4276 m_target->UpdateSpeed(MOVE_RUN, true);
4278 // Festive Holiday Mount
4279 if (apply && GetSpellProto()->SpellIconID != 1794 && m_target->HasAura(62061))
4280 // Reindeer Transformation
4281 m_target->CastSpell(m_target, 25860, true, NULL, this);
4284 void Aura::HandleAuraModIncreaseFlightSpeed(bool apply, bool Real)
4286 // all applied/removed only at real aura add/remove
4287 if(!Real)
4288 return;
4290 // Enable Fly mode for flying mounts
4291 if (m_modifier.m_auraname == SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED)
4293 WorldPacket data;
4294 if(apply)
4295 data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
4296 else
4297 data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
4298 data.append(m_target->GetPackGUID());
4299 data << uint32(0); // unknown
4300 m_target->SendMessageToSet(&data, true);
4302 //Players on flying mounts must be immune to polymorph
4303 if (m_target->GetTypeId()==TYPEID_PLAYER)
4304 m_target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,MECHANIC_POLYMORPH,apply);
4306 // Dragonmaw Illusion (overwrite mount model, mounted aura already applied)
4307 if( apply && m_target->HasAura(42016,0) && m_target->GetMountID())
4308 m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314);
4310 // Festive Holiday Mount
4311 if (apply && GetSpellProto()->SpellIconID != 1794 && m_target->HasAura(62061))
4312 // Reindeer Transformation
4313 m_target->CastSpell(m_target, 25860, true, NULL, this);
4316 m_target->UpdateSpeed(MOVE_FLIGHT, true);
4319 void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real)
4321 // all applied/removed only at real aura add/remove
4322 if(!Real)
4323 return;
4325 m_target->UpdateSpeed(MOVE_SWIM, true);
4328 void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real)
4330 // all applied/removed only at real aura add/remove
4331 if(!Real)
4332 return;
4334 if (apply)
4336 // Gronn Lord's Grasp, becomes stoned
4337 if (GetId() == 33572)
4339 if (GetStackAmount() >= 5 && !m_target->HasAura(33652))
4340 m_target->CastSpell(m_target, 33652, true);
4344 m_target->UpdateSpeed(MOVE_RUN, true);
4345 m_target->UpdateSpeed(MOVE_SWIM, true);
4346 m_target->UpdateSpeed(MOVE_FLIGHT, true);
4349 void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real)
4351 // all applied/removed only at real aura add/remove
4352 if(!Real)
4353 return;
4355 m_target->UpdateSpeed(MOVE_RUN, true);
4356 m_target->UpdateSpeed(MOVE_SWIM, true);
4357 m_target->UpdateSpeed(MOVE_FLIGHT, true);
4360 /*********************************************************/
4361 /*** IMMUNITY ***/
4362 /*********************************************************/
4364 void Aura::HandleModMechanicImmunity(bool apply, bool /*Real*/)
4366 uint32 misc = m_modifier.m_miscvalue;
4367 // Forbearance
4368 // in DBC wrong mechanic immune since 3.0.x
4369 if (GetId() == 25771)
4370 misc = MECHANIC_IMMUNE_SHIELD;
4373 if(apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
4375 uint32 mechanic = 1 << (misc-1);
4377 //immune movement impairment and loss of control
4378 if(GetId()==42292 || GetId()==59752)
4379 mechanic=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
4381 m_target->RemoveAurasAtMechanicImmunity(mechanic,GetId());
4384 m_target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,misc,apply);
4386 // Bestial Wrath
4387 if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellProto()->SpellIconID == 1680)
4389 // The Beast Within cast on owner if talent present
4390 if (Unit* owner = m_target->GetOwner())
4392 // Search talent
4393 Unit::AuraList const& dummyAuras = owner->GetAurasByType(SPELL_AURA_DUMMY);
4394 for(Unit::AuraList::const_iterator i = dummyAuras.begin(); i != dummyAuras.end(); ++i)
4396 if ((*i)->GetSpellProto()->SpellIconID == 2229)
4398 if (apply)
4399 owner->CastSpell(owner, 34471, true, 0, this);
4400 else
4401 owner->RemoveAurasDueToSpell(34471);
4402 break;
4409 void Aura::HandleModMechanicImmunityMask(bool apply, bool /*Real*/)
4411 uint32 mechanic = m_modifier.m_miscvalue;
4413 if(apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
4414 m_target->RemoveAurasAtMechanicImmunity(mechanic,GetId());
4416 // check implemented in Unit::IsImmunedToSpell and Unit::IsImmunedToSpellEffect
4419 //this method is called whenever we add / remove aura which gives m_target some imunity to some spell effect
4420 void Aura::HandleAuraModEffectImmunity(bool apply, bool /*Real*/)
4422 // when removing flag aura, handle flag drop
4423 if( !apply && m_target->GetTypeId() == TYPEID_PLAYER
4424 && (GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION) )
4426 if( BattleGround *bg = ((Player*)m_target)->GetBattleGround() )
4427 bg->EventPlayerDroppedFlag(((Player*)m_target));
4430 m_target->ApplySpellImmune(GetId(), IMMUNITY_EFFECT, m_modifier.m_miscvalue, apply);
4433 void Aura::HandleAuraModStateImmunity(bool apply, bool Real)
4435 if(apply && Real && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
4437 Unit::AuraList const& auraList = m_target->GetAurasByType(AuraType(m_modifier.m_miscvalue));
4438 for(Unit::AuraList::const_iterator itr = auraList.begin(); itr != auraList.end();)
4440 if (auraList.front() != this) // skip itself aura (it already added)
4442 m_target->RemoveAurasDueToSpell(auraList.front()->GetId());
4443 itr = auraList.begin();
4445 else
4446 ++itr;
4450 m_target->ApplySpellImmune(GetId(), IMMUNITY_STATE, m_modifier.m_miscvalue, apply);
4453 void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real)
4455 m_target->ApplySpellImmune(GetId(), IMMUNITY_SCHOOL, m_modifier.m_miscvalue, apply);
4457 // remove all flag auras (they are positive, but they must be removed when you are immune)
4458 if( this->GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
4459 && this->GetSpellProto()->AttributesEx2 & SPELL_ATTR_EX2_DAMAGE_REDUCED_SHIELD )
4460 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
4462 // TODO: optimalize this cycle - use RemoveAurasWithInterruptFlags call or something else
4463 if( Real && apply
4464 && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
4465 && IsPositiveSpell(GetId()) ) //Only positive immunity removes auras
4467 uint32 school_mask = m_modifier.m_miscvalue;
4468 Unit::AuraMap& Auras = m_target->GetAuras();
4469 for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next)
4471 next = iter;
4472 ++next;
4473 SpellEntry const *spell = iter->second->GetSpellProto();
4474 if((GetSpellSchoolMask(spell) & school_mask)//Check for school mask
4475 && !( spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) //Spells unaffected by invulnerability
4476 && !iter->second->IsPositive() //Don't remove positive spells
4477 && spell->Id != GetId() ) //Don't remove self
4479 m_target->RemoveAurasDueToSpell(spell->Id);
4480 if(Auras.empty())
4481 break;
4482 else
4483 next = Auras.begin();
4487 if( Real && GetSpellProto()->Mechanic == MECHANIC_BANISH )
4489 if( apply )
4490 m_target->addUnitState(UNIT_STAT_ISOLATED);
4491 else
4492 m_target->clearUnitState(UNIT_STAT_ISOLATED);
4496 void Aura::HandleAuraModDmgImmunity(bool apply, bool /*Real*/)
4498 m_target->ApplySpellImmune(GetId(), IMMUNITY_DAMAGE, m_modifier.m_miscvalue, apply);
4501 void Aura::HandleAuraModDispelImmunity(bool apply, bool Real)
4503 // all applied/removed only at real aura add/remove
4504 if(!Real)
4505 return;
4507 m_target->ApplySpellDispelImmunity(m_spellProto, DispelType(m_modifier.m_miscvalue), apply);
4510 void Aura::HandleAuraProcTriggerSpell(bool apply, bool Real)
4512 if(!Real)
4513 return;
4515 if(apply)
4517 // some spell have charges by functionality not have its in spell data
4518 switch (GetId())
4520 case 28200: // Ascendance (Talisman of Ascendance trinket)
4521 SetAuraCharges(6);
4522 break;
4523 default: break;
4528 void Aura::HandleAuraModStalked(bool apply, bool /*Real*/)
4530 // used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND
4531 if(apply)
4532 m_target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT);
4533 else
4534 m_target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT);
4537 /*********************************************************/
4538 /*** PERIODIC ***/
4539 /*********************************************************/
4541 void Aura::HandlePeriodicTriggerSpell(bool apply, bool /*Real*/)
4543 m_isPeriodic = apply;
4545 if (!apply)
4547 switch(m_spellProto->Id)
4549 case 66: // Invisibility
4550 if (m_removeMode == AURA_REMOVE_BY_DEFAULT && m_duration<=0)
4551 m_target->CastSpell(m_target, 32612, true, NULL, this);
4553 return;
4554 case 42783: //Wrath of the Astrom...
4555 if (m_removeMode == AURA_REMOVE_BY_DEFAULT && GetEffIndex() + 1 < 3)
4556 m_target->CastSpell(m_target, m_spellProto->CalculateSimpleValue(GetEffIndex()+1), true);
4557 return;
4558 default:
4559 break;
4564 void Aura::HandlePeriodicTriggerSpellWithValue(bool apply, bool /*Real*/)
4566 m_isPeriodic = apply;
4569 void Aura::HandlePeriodicEnergize(bool apply, bool Real)
4571 if (!Real)
4572 return;
4574 // For prevent double apply bonuses
4575 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
4577 if (apply && !loading)
4579 switch (GetId())
4581 case 54833: // Glyph of Innervate (value%/2 of casters base mana)
4583 if (Unit* caster = GetCaster())
4584 m_modifier.m_amount = int32(caster->GetCreateMana() * GetBasePoints() / (200 * m_maxduration / m_periodicTimer));
4585 break;
4588 case 29166: // Innervate (value% of casters base mana)
4590 if (Unit* caster = GetCaster())
4592 // Glyph of Innervate
4593 if (caster->HasAura(54832))
4594 caster->CastSpell(caster,54833,true,NULL,this);
4596 m_modifier.m_amount = int32(caster->GetCreateMana() * GetBasePoints() / (100 * m_maxduration / m_periodicTimer));
4598 break;
4600 case 48391: // Owlkin Frenzy 2% base mana
4601 m_modifier.m_amount = m_target->GetCreateMana() * 2 / 100;
4602 break;
4603 case 57669: // Replenishment (0.2% from max)
4604 case 61782: // Infinite Replenishment
4605 m_modifier.m_amount = m_target->GetMaxPower(POWER_MANA) * 2 / 1000;
4606 break;
4607 default:
4608 break;
4612 m_isPeriodic = apply;
4615 void Aura::HandleAuraPowerBurn(bool apply, bool /*Real*/)
4617 m_isPeriodic = apply;
4620 void Aura::HandleAuraPeriodicDummy(bool apply, bool Real)
4622 // spells required only Real aura add/remove
4623 if(!Real)
4624 return;
4626 // For prevent double apply bonuses
4627 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
4629 SpellEntry const*spell = GetSpellProto();
4630 switch( spell->SpellFamilyName)
4632 case SPELLFAMILY_ROGUE:
4634 if(!apply)
4636 switch(spell->Id)
4638 // Master of Subtlety
4639 case 31666: m_target->RemoveAurasDueToSpell(31665); break;
4640 // Overkill
4641 case 58428: m_target->RemoveAurasDueToSpell(58427); break;
4644 break;
4646 case SPELLFAMILY_HUNTER:
4648 Unit* caster = GetCaster();
4650 // Explosive Shot
4651 if (apply && !loading && caster)
4652 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 14 / 100);
4653 break;
4657 m_isPeriodic = apply;
4660 void Aura::HandlePeriodicHeal(bool apply, bool /*Real*/)
4662 m_isPeriodic = apply;
4665 void Aura::HandlePeriodicDamage(bool apply, bool Real)
4667 // spells required only Real aura add/remove
4668 if(!Real)
4669 return;
4671 m_isPeriodic = apply;
4673 // For prevent double apply bonuses
4674 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
4676 // Custom damage calculation after
4677 if (apply)
4679 if(loading)
4680 return;
4682 Unit *caster = GetCaster();
4683 if (!caster)
4684 return;
4686 switch (m_spellProto->SpellFamilyName)
4688 case SPELLFAMILY_GENERIC:
4690 // Pounce Bleed
4691 if ( m_spellProto->SpellIconID == 147 && m_spellProto->SpellVisual[0] == 0 )
4693 // $AP*0.18/6 bonus per tick
4694 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 3 / 100);
4695 return;
4697 break;
4699 case SPELLFAMILY_WARRIOR:
4701 // Rend
4702 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000020))
4704 // $0.2*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick
4705 float ap = caster->GetTotalAttackPowerValue(BASE_ATTACK);
4706 int32 mws = caster->GetAttackTime(BASE_ATTACK);
4707 float mwb_min = caster->GetWeaponDamageRange(BASE_ATTACK,MINDAMAGE);
4708 float mwb_max = caster->GetWeaponDamageRange(BASE_ATTACK,MAXDAMAGE);
4709 m_modifier.m_amount+=int32(((mwb_min+mwb_max)/2+ap*mws/14000)*0.2f);
4710 return;
4712 break;
4714 case SPELLFAMILY_DRUID:
4716 // Rake
4717 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000001000) && m_spellProto->Effect[2]==SPELL_EFFECT_ADD_COMBO_POINTS)
4719 // $AP*0.18/3 bonus per tick
4720 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 6 / 100);
4721 return;
4723 // Lacerate
4724 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x000000010000000000))
4726 // $AP*0.05/5 bonus per tick
4727 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100);
4728 return;
4730 // Rip
4731 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x000000000000800000))
4733 // 0.01*$AP*cp
4734 if (caster->GetTypeId() != TYPEID_PLAYER)
4735 return;
4737 uint8 cp = ((Player*)caster)->GetComboPoints();
4739 // Idol of Feral Shadows. Cant be handled as SpellMod in SpellAura:Dummy due its dependency from CPs
4740 Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY);
4741 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
4743 if((*itr)->GetId()==34241)
4745 m_modifier.m_amount += cp * (*itr)->GetModifier()->m_amount;
4746 break;
4749 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * cp / 100);
4750 return;
4752 // Lock Jaw
4753 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x1000000000000000))
4755 // 0.15*$AP
4756 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 15 / 100);
4757 return;
4759 break;
4761 case SPELLFAMILY_ROGUE:
4763 // Rupture
4764 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x000000000000100000))
4766 if (caster->GetTypeId() != TYPEID_PLAYER)
4767 return;
4768 //1 point : ${($m1+$b1*1+0.015*$AP)*4} damage over 8 secs
4769 //2 points: ${($m1+$b1*2+0.024*$AP)*5} damage over 10 secs
4770 //3 points: ${($m1+$b1*3+0.03*$AP)*6} damage over 12 secs
4771 //4 points: ${($m1+$b1*4+0.03428571*$AP)*7} damage over 14 secs
4772 //5 points: ${($m1+$b1*5+0.0375*$AP)*8} damage over 16 secs
4773 float AP_per_combo[6] = {0.0f, 0.015f, 0.024f, 0.03f, 0.03428571f, 0.0375f};
4774 uint8 cp = ((Player*)caster)->GetComboPoints();
4775 if (cp > 5) cp = 5;
4776 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * AP_per_combo[cp]);
4777 return;
4779 // Garrote
4780 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x000000000000000100))
4782 // $AP*0.07 bonus per tick
4783 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 7 / 100);
4784 return;
4786 // Deadly Poison
4787 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000010000))
4789 // 0.08*$AP / 4 * amount of stack
4790 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 2 * GetStackAmount() / 100);
4791 return;
4793 break;
4795 case SPELLFAMILY_HUNTER:
4797 // Serpent Sting
4798 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000004000))
4800 // $RAP*0.2/5 bonus per tick
4801 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.2 / 5);
4802 return;
4804 // Immolation Trap
4805 if ((m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000004)) && m_spellProto->SpellIconID == 678)
4807 // $RAP*0.1/5 bonus per tick
4808 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 10 / 500);
4809 return;
4811 break;
4813 default:
4814 break;
4817 // remove time effects
4818 else
4820 // Parasitic Shadowfiend - handle summoning of two Shadowfiends on DoT expire
4821 if(m_spellProto->Id == 41917)
4822 m_target->CastSpell(m_target, 41915, true);
4826 void Aura::HandlePeriodicDamagePCT(bool apply, bool /*Real*/)
4828 m_isPeriodic = apply;
4831 void Aura::HandlePeriodicLeech(bool apply, bool /*Real*/)
4833 m_isPeriodic = apply;
4836 void Aura::HandlePeriodicManaLeech(bool apply, bool /*Real*/)
4838 m_isPeriodic = apply;
4841 void Aura::HandlePeriodicHealthFunnel(bool apply, bool /*Real*/)
4843 m_isPeriodic = apply;
4846 /*********************************************************/
4847 /*** MODIFY STATS ***/
4848 /*********************************************************/
4850 /********************************/
4851 /*** RESISTANCE ***/
4852 /********************************/
4854 void Aura::HandleAuraModResistanceExclusive(bool apply, bool /*Real*/)
4856 for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++)
4858 if(m_modifier.m_miscvalue & int32(1<<x))
4860 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_VALUE, float(m_modifier.m_amount), apply);
4861 if(m_target->GetTypeId() == TYPEID_PLAYER)
4862 m_target->ApplyResistanceBuffModsMod(SpellSchools(x), m_positive, m_modifier.m_amount, apply);
4867 void Aura::HandleAuraModResistance(bool apply, bool /*Real*/)
4869 for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++)
4871 if(m_modifier.m_miscvalue & int32(1<<x))
4873 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), TOTAL_VALUE, float(m_modifier.m_amount), apply);
4874 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
4875 m_target->ApplyResistanceBuffModsMod(SpellSchools(x), m_positive, m_modifier.m_amount, apply);
4880 void Aura::HandleAuraModBaseResistancePCT(bool apply, bool /*Real*/)
4882 // only players have base stats
4883 if(m_target->GetTypeId() != TYPEID_PLAYER)
4885 //pets only have base armor
4886 if(((Creature*)m_target)->isPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL))
4887 m_target->HandleStatModifier(UNIT_MOD_ARMOR, BASE_PCT, float(m_modifier.m_amount), apply);
4889 else
4891 for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++)
4893 if(m_modifier.m_miscvalue & int32(1<<x))
4894 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_PCT, float(m_modifier.m_amount), apply);
4899 void Aura::HandleModResistancePercent(bool apply, bool /*Real*/)
4901 for(int8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++)
4903 if(m_modifier.m_miscvalue & int32(1<<i))
4905 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply);
4906 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
4908 m_target->ApplyResistanceBuffModsPercentMod(SpellSchools(i), true, m_modifier.m_amount, apply);
4909 m_target->ApplyResistanceBuffModsPercentMod(SpellSchools(i), false, m_modifier.m_amount, apply);
4915 void Aura::HandleModBaseResistance(bool apply, bool /*Real*/)
4917 // only players have base stats
4918 if(m_target->GetTypeId() != TYPEID_PLAYER)
4920 //only pets have base stats
4921 if(((Creature*)m_target)->isPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL))
4922 m_target->HandleStatModifier(UNIT_MOD_ARMOR, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4924 else
4926 for(int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++)
4927 if(m_modifier.m_miscvalue & (1<<i))
4928 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply);
4932 /********************************/
4933 /*** STAT ***/
4934 /********************************/
4936 void Aura::HandleAuraModStat(bool apply, bool /*Real*/)
4938 if (m_modifier.m_miscvalue < -2 || m_modifier.m_miscvalue > 4)
4940 sLog.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ",GetId(),GetEffIndex(),m_modifier.m_miscvalue);
4941 return;
4944 for(int32 i = STAT_STRENGTH; i < MAX_STATS; i++)
4946 // -1 or -2 is all stats ( misc < -2 checked in function beginning )
4947 if (m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue == i)
4949 //m_target->ApplyStatMod(Stats(i), m_modifier.m_amount,apply);
4950 m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply);
4951 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
4952 m_target->ApplyStatBuffMod(Stats(i), m_modifier.m_amount, apply);
4957 void Aura::HandleModPercentStat(bool apply, bool /*Real*/)
4959 if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4)
4961 sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
4962 return;
4965 // only players have base stats
4966 if (m_target->GetTypeId() != TYPEID_PLAYER)
4967 return;
4969 for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i)
4971 if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1)
4972 m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), BASE_PCT, float(m_modifier.m_amount), apply);
4976 void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool /*Real*/)
4978 if(m_target->GetTypeId() != TYPEID_PLAYER)
4979 return;
4981 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4982 // This information for client side use only
4983 // Recalculate bonus
4984 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4987 void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool /*Real*/)
4989 if(m_target->GetTypeId() != TYPEID_PLAYER)
4990 return;
4992 // Recalculate bonus
4993 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4996 void Aura::HandleAuraModDispelResist(bool apply, bool Real)
4998 if(!Real || !apply)
4999 return;
5001 if(GetId() == 33206)
5002 m_target->CastSpell(m_target, 44416, true, NULL, this, GetCasterGUID());
5005 void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool /*Real*/)
5007 if(m_target->GetTypeId() != TYPEID_PLAYER)
5008 return;
5010 // Magic damage modifiers implemented in Unit::SpellDamageBonus
5011 // This information for client side use only
5012 // Recalculate bonus
5013 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
5016 void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool /*Real*/)
5018 if(m_target->GetTypeId() != TYPEID_PLAYER)
5019 return;
5021 // Recalculate bonus
5022 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
5025 void Aura::HandleModHealingDone(bool /*apply*/, bool /*Real*/)
5027 if(m_target->GetTypeId() != TYPEID_PLAYER)
5028 return;
5029 // implemented in Unit::SpellHealingBonus
5030 // this information is for client side only
5031 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
5034 void Aura::HandleModTotalPercentStat(bool apply, bool /*Real*/)
5036 if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4)
5038 sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
5039 return;
5042 //save current and max HP before applying aura
5043 uint32 curHPValue = m_target->GetHealth();
5044 uint32 maxHPValue = m_target->GetMaxHealth();
5046 for (int32 i = STAT_STRENGTH; i < MAX_STATS; i++)
5048 if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1)
5050 m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply);
5051 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
5052 m_target->ApplyStatPercentBuffMod(Stats(i), m_modifier.m_amount, apply );
5056 //recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag)
5057 if ((m_modifier.m_miscvalue == STAT_STAMINA) && (maxHPValue > 0) && (m_spellProto->Attributes & 0x10))
5059 // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed
5060 uint32 newHPValue = (m_target->GetMaxHealth() * curHPValue) / maxHPValue;
5061 m_target->SetHealth(newHPValue);
5065 void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool /*Real*/)
5067 if(m_target->GetTypeId() != TYPEID_PLAYER)
5068 return;
5070 if(m_modifier.m_miscvalue != SPELL_SCHOOL_MASK_NORMAL)
5072 // support required adding replace UpdateArmor by loop by UpdateResistence at intellect update
5073 // and include in UpdateResistence same code as in UpdateArmor for aura mod apply.
5074 sLog.outError("Aura SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT(182) need adding support for non-armor resistances!");
5075 return;
5078 // Recalculate Armor
5079 m_target->UpdateArmor();
5082 /********************************/
5083 /*** HEAL & ENERGIZE ***/
5084 /********************************/
5085 void Aura::HandleAuraModTotalHealthPercentRegen(bool apply, bool /*Real*/)
5087 m_isPeriodic = apply;
5090 void Aura::HandleAuraModTotalManaPercentRegen(bool apply, bool /*Real*/)
5092 if(m_modifier.periodictime == 0)
5093 m_modifier.periodictime = 1000;
5095 m_periodicTimer = m_modifier.periodictime;
5096 m_isPeriodic = apply;
5099 void Aura::HandleModRegen(bool apply, bool /*Real*/) // eating
5101 if(m_modifier.periodictime == 0)
5102 m_modifier.periodictime = 5000;
5104 m_periodicTimer = 5000;
5105 m_isPeriodic = apply;
5108 void Aura::HandleModPowerRegen(bool apply, bool Real) // drinking
5110 if (!Real)
5111 return;
5113 Powers pt = m_target->getPowerType();
5114 if(m_modifier.periodictime == 0)
5116 // Anger Management (only spell use this aura for rage)
5117 if (pt == POWER_RAGE)
5118 m_modifier.periodictime = 3000;
5119 else
5120 m_modifier.periodictime = 2000;
5123 m_periodicTimer = 5000;
5125 if (m_target->GetTypeId() == TYPEID_PLAYER && m_modifier.m_miscvalue == POWER_MANA)
5126 ((Player*)m_target)->UpdateManaRegen();
5128 m_isPeriodic = apply;
5131 void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real)
5133 // spells required only Real aura add/remove
5134 if(!Real)
5135 return;
5137 if (m_target->GetTypeId() != TYPEID_PLAYER)
5138 return;
5140 // Update manaregen value
5141 if (m_modifier.m_miscvalue == POWER_MANA)
5142 ((Player*)m_target)->UpdateManaRegen();
5145 void Aura::HandleModManaRegen(bool /*apply*/, bool Real)
5147 // spells required only Real aura add/remove
5148 if(!Real)
5149 return;
5151 if (m_target->GetTypeId() != TYPEID_PLAYER)
5152 return;
5154 //Note: an increase in regen does NOT cause threat.
5155 ((Player*)m_target)->UpdateManaRegen();
5158 void Aura::HandleComprehendLanguage(bool apply, bool /*Real*/)
5160 if(apply)
5161 m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG);
5162 else
5163 m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG);
5166 void Aura::HandleAuraModIncreaseHealth(bool apply, bool Real)
5168 // Special case with temporary increase max/current health
5169 switch(GetId())
5171 case 12976: // Warrior Last Stand triggered spell
5172 case 28726: // Nightmare Seed ( Nightmare Seed )
5173 case 34511: // Valor (Bulwark of Kings, Bulwark of the Ancient Kings)
5174 case 44055: case 55915: case 55917: case 67596: // Tremendous Fortitude (Battlemaster's Alacrity)
5175 case 50322: // Survival Instincts
5176 case 54443: // Demonic Empowerment (Voidwalker)
5178 if(Real)
5180 if(apply)
5182 // Demonic Empowerment (Voidwalker) - special case, store percent in data
5183 // recalculate to full amount at apply for proper remove
5184 if (GetId() == 54443)
5185 m_modifier.m_amount = m_target->GetMaxHealth() * m_modifier.m_amount / 100;
5187 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5188 m_target->ModifyHealth(m_modifier.m_amount);
5190 else
5192 if (int32(m_target->GetHealth()) > m_modifier.m_amount)
5193 m_target->ModifyHealth(-m_modifier.m_amount);
5194 else
5195 m_target->SetHealth(1);
5196 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5199 return;
5203 // generic case
5204 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5207 void Aura::HandleAuraModIncreaseMaxHealth(bool apply, bool /*Real*/)
5209 uint32 oldhealth = m_target->GetHealth();
5210 double healthPercentage = (double)oldhealth / (double)m_target->GetMaxHealth();
5212 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5214 // refresh percentage
5215 if(oldhealth > 0)
5217 uint32 newhealth = uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage));
5218 if(newhealth==0)
5219 newhealth = 1;
5221 m_target->SetHealth(newhealth);
5225 void Aura::HandleAuraModIncreaseEnergy(bool apply, bool Real)
5227 Powers powerType = m_target->getPowerType();
5228 if(int32(powerType) != m_modifier.m_miscvalue)
5229 return;
5231 UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType);
5233 // Special case with temporary increase max/current power (percent)
5234 if (GetId()==64904) // Hymn of Hope
5236 if(Real)
5238 uint32 val = m_target->GetPower(powerType);
5239 m_target->HandleStatModifier(unitMod, TOTAL_PCT, float(m_modifier.m_amount), apply);
5240 m_target->SetPower(powerType, apply ? val*(100+m_modifier.m_amount)/100 : val*100/(100+m_modifier.m_amount));
5242 return;
5245 // generic flat case
5246 m_target->HandleStatModifier(unitMod, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5249 void Aura::HandleAuraModIncreaseEnergyPercent(bool apply, bool /*Real*/)
5251 Powers powerType = m_target->getPowerType();
5252 if(int32(powerType) != m_modifier.m_miscvalue)
5253 return;
5255 UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType);
5257 m_target->HandleStatModifier(unitMod, TOTAL_PCT, float(m_modifier.m_amount), apply);
5260 void Aura::HandleAuraModIncreaseHealthPercent(bool apply, bool /*Real*/)
5262 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_PCT, float(m_modifier.m_amount), apply);
5265 void Aura::HandleAuraIncreaseBaseHealthPercent(bool apply, bool /*Real*/)
5267 m_target->HandleStatModifier(UNIT_MOD_HEALTH, BASE_PCT, float(m_modifier.m_amount), apply);
5270 /********************************/
5271 /*** FIGHT ***/
5272 /********************************/
5274 void Aura::HandleAuraModParryPercent(bool /*apply*/, bool /*Real*/)
5276 if(m_target->GetTypeId() != TYPEID_PLAYER)
5277 return;
5279 ((Player*)m_target)->UpdateParryPercentage();
5282 void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool /*Real*/)
5284 if(m_target->GetTypeId() != TYPEID_PLAYER)
5285 return;
5287 ((Player*)m_target)->UpdateDodgePercentage();
5288 //sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount));
5291 void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool /*Real*/)
5293 if(m_target->GetTypeId() != TYPEID_PLAYER)
5294 return;
5296 ((Player*)m_target)->UpdateBlockPercentage();
5297 //sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount));
5300 void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real)
5302 // spells required only Real aura add/remove
5303 if(!Real)
5304 return;
5306 if(m_target->GetTypeId() != TYPEID_PLAYER)
5307 return;
5309 ((Player*)m_target)->UpdateManaRegen();
5312 void Aura::HandleAuraModCritPercent(bool apply, bool Real)
5314 if(m_target->GetTypeId() != TYPEID_PLAYER)
5315 return;
5317 // apply item specific bonuses for already equipped weapon
5318 if(Real)
5320 for(int i = 0; i < MAX_ATTACK; ++i)
5321 if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i),true,false))
5322 ((Player*)m_target)->_ApplyWeaponDependentAuraCritMod(pItem, WeaponAttackType(i), this, apply);
5325 // mods must be applied base at equipped weapon class and subclass comparison
5326 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5327 // m_modifier.m_miscvalue comparison with item generated damage types
5329 if (GetSpellProto()->EquippedItemClass == -1)
5331 ((Player*)m_target)->HandleBaseModValue(CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
5332 ((Player*)m_target)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
5333 ((Player*)m_target)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
5335 else
5337 // done in Player::_ApplyWeaponDependentAuraMods
5341 void Aura::HandleModHitChance(bool apply, bool /*Real*/)
5343 if(m_target->GetTypeId() == TYPEID_PLAYER)
5345 ((Player*)m_target)->UpdateMeleeHitChances();
5346 ((Player*)m_target)->UpdateRangedHitChances();
5348 else
5350 m_target->m_modMeleeHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount);
5351 m_target->m_modRangedHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount);
5355 void Aura::HandleModSpellHitChance(bool apply, bool /*Real*/)
5357 if(m_target->GetTypeId() == TYPEID_PLAYER)
5359 ((Player*)m_target)->UpdateSpellHitChances();
5361 else
5363 m_target->m_modSpellHitChance += apply ? m_modifier.m_amount: (-m_modifier.m_amount);
5367 void Aura::HandleModSpellCritChance(bool apply, bool Real)
5369 // spells required only Real aura add/remove
5370 if(!Real)
5371 return;
5373 if(m_target->GetTypeId() == TYPEID_PLAYER)
5375 ((Player*)m_target)->UpdateAllSpellCritChances();
5377 else
5379 m_target->m_baseSpellCritChance += apply ? m_modifier.m_amount:(-m_modifier.m_amount);
5383 void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real)
5385 // spells required only Real aura add/remove
5386 if(!Real)
5387 return;
5389 if(m_target->GetTypeId() != TYPEID_PLAYER)
5390 return;
5392 for(int school = SPELL_SCHOOL_NORMAL; school < MAX_SPELL_SCHOOL; ++school)
5393 if (m_modifier.m_miscvalue & (1<<school))
5394 ((Player*)m_target)->UpdateSpellCritChance(school);
5397 /********************************/
5398 /*** ATTACK SPEED ***/
5399 /********************************/
5401 void Aura::HandleModCastingSpeed(bool apply, bool /*Real*/)
5403 m_target->ApplyCastTimePercentMod(m_modifier.m_amount,apply);
5406 void Aura::HandleModMeleeRangedSpeedPct(bool apply, bool /*Real*/)
5408 m_target->ApplyAttackTimePercentMod(BASE_ATTACK, m_modifier.m_amount, apply);
5409 m_target->ApplyAttackTimePercentMod(OFF_ATTACK, m_modifier.m_amount, apply);
5410 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply);
5413 void Aura::HandleModCombatSpeedPct(bool apply, bool /*Real*/)
5415 m_target->ApplyCastTimePercentMod(m_modifier.m_amount, apply);
5416 m_target->ApplyAttackTimePercentMod(BASE_ATTACK, m_modifier.m_amount, apply);
5417 m_target->ApplyAttackTimePercentMod(OFF_ATTACK, m_modifier.m_amount, apply);
5418 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply);
5421 void Aura::HandleModAttackSpeed(bool apply, bool /*Real*/)
5423 if(!m_target->isAlive() )
5424 return;
5426 m_target->ApplyAttackTimePercentMod(BASE_ATTACK,m_modifier.m_amount,apply);
5429 void Aura::HandleHaste(bool apply, bool /*Real*/)
5431 m_target->ApplyAttackTimePercentMod(BASE_ATTACK, m_modifier.m_amount, apply);
5432 m_target->ApplyAttackTimePercentMod(OFF_ATTACK, m_modifier.m_amount, apply);
5433 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply);
5436 void Aura::HandleAuraModRangedHaste(bool apply, bool /*Real*/)
5438 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply);
5441 void Aura::HandleRangedAmmoHaste(bool apply, bool /*Real*/)
5443 if(m_target->GetTypeId() != TYPEID_PLAYER)
5444 return;
5445 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK,m_modifier.m_amount, apply);
5448 /********************************/
5449 /*** ATTACK POWER ***/
5450 /********************************/
5452 void Aura::HandleAuraModAttackPower(bool apply, bool /*Real*/)
5454 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5457 void Aura::HandleAuraModRangedAttackPower(bool apply, bool /*Real*/)
5459 if((m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0)
5460 return;
5462 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5465 void Aura::HandleAuraModAttackPowerPercent(bool apply, bool /*Real*/)
5467 //UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1
5468 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_PCT, float(m_modifier.m_amount), apply);
5471 void Aura::HandleAuraModRangedAttackPowerPercent(bool apply, bool /*Real*/)
5473 if((m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0)
5474 return;
5476 //UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1
5477 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply);
5480 void Aura::HandleAuraModRangedAttackPowerOfStatPercent(bool /*apply*/, bool Real)
5482 // spells required only Real aura add/remove
5483 if(!Real)
5484 return;
5486 // Recalculate bonus
5487 if(m_target->GetTypeId() == TYPEID_PLAYER && !(m_target->getClassMask() & CLASSMASK_WAND_USERS))
5488 ((Player*)m_target)->UpdateAttackPowerAndDamage(true);
5491 void Aura::HandleAuraModAttackPowerOfStatPercent(bool /*apply*/, bool Real)
5493 // spells required only Real aura add/remove
5494 if(!Real)
5495 return;
5497 // Recalculate bonus
5498 if(m_target->GetTypeId() == TYPEID_PLAYER)
5499 ((Player*)m_target)->UpdateAttackPowerAndDamage(false);
5502 void Aura::HandleAuraModAttackPowerOfArmor(bool /*apply*/, bool Real)
5504 // spells required only Real aura add/remove
5505 if(!Real)
5506 return;
5508 // Recalculate bonus
5509 if(m_target->GetTypeId() == TYPEID_PLAYER)
5510 ((Player*)m_target)->UpdateAttackPowerAndDamage(false);
5512 /********************************/
5513 /*** DAMAGE BONUS ***/
5514 /********************************/
5515 void Aura::HandleModDamageDone(bool apply, bool Real)
5517 // apply item specific bonuses for already equipped weapon
5518 if(Real && m_target->GetTypeId() == TYPEID_PLAYER)
5520 for(int i = 0; i < MAX_ATTACK; ++i)
5521 if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i),true,false))
5522 ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem, WeaponAttackType(i), this, apply);
5525 // m_modifier.m_miscvalue is bitmask of spell schools
5526 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5527 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wands
5528 // 127 - full bitmask any damages
5530 // mods must be applied base at equipped weapon class and subclass comparison
5531 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5532 // m_modifier.m_miscvalue comparison with item generated damage types
5534 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0)
5536 // apply generic physical damage bonuses including wand case
5537 if (GetSpellProto()->EquippedItemClass == -1 || m_target->GetTypeId() != TYPEID_PLAYER)
5539 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5540 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5541 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5543 else
5545 // done in Player::_ApplyWeaponDependentAuraMods
5548 if(m_target->GetTypeId() == TYPEID_PLAYER)
5550 if(m_positive)
5551 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS, m_modifier.m_amount, apply);
5552 else
5553 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG, m_modifier.m_amount, apply);
5557 // Skip non magic case for speedup
5558 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0)
5559 return;
5561 if( GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0 )
5563 // wand magic case (skip generic to all item spell bonuses)
5564 // done in Player::_ApplyWeaponDependentAuraMods
5566 // Skip item specific requirements for not wand magic damage
5567 return;
5570 // Magic damage modifiers implemented in Unit::SpellDamageBonus
5571 // This information for client side use only
5572 if(m_target->GetTypeId() == TYPEID_PLAYER)
5574 if(m_positive)
5576 for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
5578 if((m_modifier.m_miscvalue & (1<<i)) != 0)
5579 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, m_modifier.m_amount, apply);
5582 else
5584 for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
5586 if((m_modifier.m_miscvalue & (1<<i)) != 0)
5587 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i, m_modifier.m_amount, apply);
5590 Pet* pet = m_target->GetPet();
5591 if(pet)
5592 pet->UpdateAttackPowerAndDamage();
5596 void Aura::HandleModDamagePercentDone(bool apply, bool Real)
5598 sLog.outDebug("AURA MOD DAMAGE type:%u negative:%u", m_modifier.m_miscvalue, m_positive ? 0 : 1);
5600 // apply item specific bonuses for already equipped weapon
5601 if(Real && m_target->GetTypeId() == TYPEID_PLAYER)
5603 for(int i = 0; i < MAX_ATTACK; ++i)
5604 if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i),true,false))
5605 ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem, WeaponAttackType(i), this, apply);
5608 // m_modifier.m_miscvalue is bitmask of spell schools
5609 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5610 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wand
5611 // 127 - full bitmask any damages
5613 // mods must be applied base at equipped weapon class and subclass comparison
5614 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5615 // m_modifier.m_miscvalue comparison with item generated damage types
5617 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0)
5619 // apply generic physical damage bonuses including wand case
5620 if (GetSpellProto()->EquippedItemClass == -1 || m_target->GetTypeId() != TYPEID_PLAYER)
5622 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT, float(m_modifier.m_amount), apply);
5623 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply);
5624 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply);
5626 else
5628 // done in Player::_ApplyWeaponDependentAuraMods
5630 // For show in client
5631 if(m_target->GetTypeId() == TYPEID_PLAYER)
5632 m_target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT, m_modifier.m_amount/100.0f, apply);
5635 // Skip non magic case for speedup
5636 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0)
5637 return;
5639 if( GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0 )
5641 // wand magic case (skip generic to all item spell bonuses)
5642 // done in Player::_ApplyWeaponDependentAuraMods
5644 // Skip item specific requirements for not wand magic damage
5645 return;
5648 // Magic damage percent modifiers implemented in Unit::SpellDamageBonus
5649 // Send info to client
5650 if(m_target->GetTypeId() == TYPEID_PLAYER)
5651 for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
5652 m_target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i, m_modifier.m_amount/100.0f, apply);
5655 void Aura::HandleModOffhandDamagePercent(bool apply, bool Real)
5657 // spells required only Real aura add/remove
5658 if(!Real)
5659 return;
5661 sLog.outDebug("AURA MOD OFFHAND DAMAGE");
5663 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply);
5666 /********************************/
5667 /*** POWER COST ***/
5668 /********************************/
5670 void Aura::HandleModPowerCostPCT(bool apply, bool Real)
5672 // spells required only Real aura add/remove
5673 if(!Real)
5674 return;
5676 float amount = m_modifier.m_amount/100.0f;
5677 for(int i = 0; i < MAX_SPELL_SCHOOL; ++i)
5678 if(m_modifier.m_miscvalue & (1<<i))
5679 m_target->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER + i, amount, apply);
5682 void Aura::HandleModPowerCost(bool apply, bool Real)
5684 // spells required only Real aura add/remove
5685 if(!Real)
5686 return;
5688 for(int i = 0; i < MAX_SPELL_SCHOOL; ++i)
5689 if(m_modifier.m_miscvalue & (1<<i))
5690 m_target->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER + i, m_modifier.m_amount, apply);
5693 void Aura::HandleNoReagentUseAura(bool /*Apply*/, bool Real)
5695 // spells required only Real aura add/remove
5696 if(!Real)
5697 return;
5698 if(m_target->GetTypeId() != TYPEID_PLAYER)
5699 return;
5700 uint32 mask[3] = {0, 0, 0};
5701 Unit::AuraList const& noReagent = m_target->GetAurasByType(SPELL_AURA_NO_REAGENT_USE);
5702 for(Unit::AuraList::const_iterator i = noReagent.begin(); i != noReagent.end(); ++i)
5704 uint32 const *ptr = (*i)->getAuraSpellClassMask();
5705 mask[0] |= ptr[0];
5706 mask[1] |= ptr[1];
5707 mask[2] |= ptr[2];
5710 m_target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1+0, mask[0]);
5711 m_target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1+1, mask[1]);
5712 m_target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1+2, mask[2]);
5715 /*********************************************************/
5716 /*** OTHERS ***/
5717 /*********************************************************/
5719 void Aura::HandleShapeshiftBoosts(bool apply)
5721 uint32 spellId1 = 0;
5722 uint32 spellId2 = 0;
5723 uint32 HotWSpellId = 0;
5724 uint32 MasterShaperSpellId = 0;
5726 uint32 form = GetModifier()->m_miscvalue;
5728 switch(form)
5730 case FORM_CAT:
5731 spellId1 = 3025;
5732 HotWSpellId = 24900;
5733 MasterShaperSpellId = 48420;
5734 break;
5735 case FORM_TREE:
5736 spellId1 = 5420;
5737 spellId2 = 34123;
5738 MasterShaperSpellId = 48422;
5739 break;
5740 case FORM_TRAVEL:
5741 spellId1 = 5419;
5742 break;
5743 case FORM_AQUA:
5744 spellId1 = 5421;
5745 break;
5746 case FORM_BEAR:
5747 spellId1 = 1178;
5748 spellId2 = 21178;
5749 HotWSpellId = 24899;
5750 MasterShaperSpellId = 48418;
5751 break;
5752 case FORM_DIREBEAR:
5753 spellId1 = 9635;
5754 spellId2 = 21178;
5755 HotWSpellId = 24899;
5756 MasterShaperSpellId = 48418;
5757 break;
5758 case FORM_BATTLESTANCE:
5759 spellId1 = 21156;
5760 break;
5761 case FORM_DEFENSIVESTANCE:
5762 spellId1 = 7376;
5763 break;
5764 case FORM_BERSERKERSTANCE:
5765 spellId1 = 7381;
5766 break;
5767 case FORM_MOONKIN:
5768 spellId1 = 24905;
5769 MasterShaperSpellId = 48421;
5770 break;
5771 case FORM_FLIGHT:
5772 spellId1 = 33948;
5773 spellId2 = 34764;
5774 break;
5775 case FORM_FLIGHT_EPIC:
5776 spellId1 = 40122;
5777 spellId2 = 40121;
5778 break;
5779 case FORM_METAMORPHOSIS:
5780 spellId1 = 54817;
5781 spellId2 = 54879;
5782 break;
5783 case FORM_SPIRITOFREDEMPTION:
5784 spellId1 = 27792;
5785 spellId2 = 27795; // must be second, this important at aura remove to prevent to early iterator invalidation.
5786 break;
5787 case FORM_SHADOW:
5788 spellId1 = 49868;
5790 if(m_target->GetTypeId() == TYPEID_PLAYER) // Spell 49868 have same category as main form spell and share cooldown
5791 ((Player*)m_target)->RemoveSpellCooldown(49868);
5792 break;
5793 case FORM_GHOSTWOLF:
5794 spellId1 = 67116;
5795 break;
5796 case FORM_AMBIENT:
5797 case FORM_GHOUL:
5798 case FORM_STEALTH:
5799 case FORM_CREATURECAT:
5800 case FORM_CREATUREBEAR:
5801 break;
5804 if(apply)
5806 if (spellId1)
5807 m_target->CastSpell(m_target, spellId1, true, NULL, this );
5808 if (spellId2)
5809 m_target->CastSpell(m_target, spellId2, true, NULL, this);
5811 if (m_target->GetTypeId() == TYPEID_PLAYER)
5813 const PlayerSpellMap& sp_list = ((Player *)m_target)->GetSpellMap();
5814 for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
5816 if (itr->second->state == PLAYERSPELL_REMOVED) continue;
5817 if (itr->first==spellId1 || itr->first==spellId2) continue;
5818 SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
5819 if (!spellInfo || !(spellInfo->Attributes & (SPELL_ATTR_PASSIVE | (1<<7))))
5820 continue;
5821 if (spellInfo->Stances & (1<<(form-1)))
5822 m_target->CastSpell(m_target, itr->first, true, NULL, this);
5825 // Master Shapeshifter
5826 if (MasterShaperSpellId)
5828 Unit::AuraList const& ShapeShifterAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
5829 for(Unit::AuraList::const_iterator i = ShapeShifterAuras.begin(); i != ShapeShifterAuras.end(); i++)
5831 if ((*i)->GetSpellProto()->SpellIconID == 2851)
5833 int32 ShiftMod = (*i)->GetModifier()->m_amount;
5834 m_target->CastCustomSpell(m_target, MasterShaperSpellId, &ShiftMod, NULL, NULL, true);
5835 break;
5840 // Leader of the Pack
5841 if (((Player*)m_target)->HasSpell(17007))
5843 SpellEntry const *spellInfo = sSpellStore.LookupEntry(24932);
5844 if (spellInfo && spellInfo->Stances & (1<<(form-1)))
5845 m_target->CastSpell(m_target, 24932, true, NULL, this);
5848 // Savage Roar
5849 if (form == FORM_CAT && ((Player*)m_target)->HasAura(52610))
5850 m_target->CastSpell(m_target, 62071, true);
5852 // Improved Moonkin Form
5853 if (form == FORM_MOONKIN)
5855 Unit::AuraList const& dummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
5856 for(Unit::AuraList::const_iterator i = dummyAuras.begin(); i != dummyAuras.end(); i++)
5858 if ((*i)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_DRUID &&
5859 (*i)->GetSpellProto()->SpellIconID == 2855)
5861 uint32 spell_id = 0;
5862 switch((*i)->GetId())
5864 case 48384:spell_id=50170;break;//Rank 1
5865 case 48395:spell_id=50171;break;//Rank 2
5866 case 48396:spell_id=50172;break;//Rank 3
5867 default:
5868 sLog.outError("Aura::HandleShapeshiftBoosts: Not handled rank of IMF (Spell: %u)",(*i)->GetId());
5869 break;
5872 if(spell_id)
5873 m_target->CastSpell(m_target, spell_id, true, NULL, this);
5874 break;
5879 // Heart of the Wild
5880 if (HotWSpellId)
5882 Unit::AuraList const& mModTotalStatPct = m_target->GetAurasByType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE);
5883 for(Unit::AuraList::const_iterator i = mModTotalStatPct.begin(); i != mModTotalStatPct.end(); ++i)
5885 if ((*i)->GetSpellProto()->SpellIconID == 240 && (*i)->GetModifier()->m_miscvalue == 3)
5887 int32 HotWMod = (*i)->GetModifier()->m_amount;
5888 if(GetModifier()->m_miscvalue == FORM_CAT)
5889 HotWMod /= 2;
5891 m_target->CastCustomSpell(m_target, HotWSpellId, &HotWMod, NULL, NULL, true, NULL, this);
5892 break;
5898 else
5900 if(spellId1)
5901 m_target->RemoveAurasDueToSpell(spellId1);
5902 if(spellId2)
5903 m_target->RemoveAurasDueToSpell(spellId2);
5904 if(MasterShaperSpellId)
5905 m_target->RemoveAurasDueToSpell(MasterShaperSpellId);
5907 Unit::AuraMap& tAuras = m_target->GetAuras();
5908 for (Unit::AuraMap::iterator itr = tAuras.begin(); itr != tAuras.end();)
5910 if (itr->second->IsRemovedOnShapeLost())
5912 m_target->RemoveAurasDueToSpell(itr->second->GetId());
5913 itr = tAuras.begin();
5915 else
5916 ++itr;
5921 void Aura::HandleSpellSpecificBoosts(bool apply)
5923 bool cast_at_remove = false; // if spell must be casted at last aura from stack remove
5924 uint32 spellId1 = 0;
5925 uint32 spellId2 = 0;
5926 uint32 spellId3 = 0;
5927 uint32 spellId4 = 0;
5929 switch(GetSpellProto()->SpellFamilyName)
5931 case SPELLFAMILY_GENERIC:
5933 // Illusionary Barrier
5934 if(GetId() == 57350 && !apply && m_target->getPowerType() == POWER_MANA)
5936 cast_at_remove = true;
5937 spellId1 = 60242; // Darkmoon Card: Illusion
5939 else
5940 return;
5941 break;
5943 case SPELLFAMILY_MAGE:
5945 // Ice Barrier (non stacking from one caster)
5946 if (m_spellProto->SpellIconID == 32)
5948 if (!apply && (m_removeMode == AURA_REMOVE_BY_DISPEL || (m_removeMode == AURA_REMOVE_BY_DEFAULT && !GetModifier()->m_amount)))
5950 Unit::AuraList const& dummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
5951 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
5953 // Shattered Barrier
5954 if ((*itr)->GetSpellProto()->SpellIconID == 2945)
5956 cast_at_remove = true;
5957 // first rank have 50% chance
5958 if ((*itr)->GetId() != 44745 || roll_chance_i(50))
5959 spellId1 = 55080;
5960 break;
5964 else
5965 return;
5967 else
5968 return;
5970 case SPELLFAMILY_WARRIOR:
5972 if(!apply)
5974 // Remove Blood Frenzy only if target no longer has any Deep Wound or Rend (applying is handled by procs)
5975 if (GetSpellProto()->Mechanic != MECHANIC_BLEED)
5976 return;
5978 // If target still has one of Warrior's bleeds, do nothing
5979 Unit::AuraList const& PeriodicDamage = m_target->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE);
5980 for(Unit::AuraList::const_iterator i = PeriodicDamage.begin(); i != PeriodicDamage.end(); ++i)
5981 if( (*i)->GetCasterGUID() == GetCasterGUID() &&
5982 (*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARRIOR &&
5983 (*i)->GetSpellProto()->Mechanic == MECHANIC_BLEED)
5984 return;
5986 spellId1 = 30069; // Blood Frenzy (Rank 1)
5987 spellId2 = 30070; // Blood Frenzy (Rank 2)
5989 break;
5991 case SPELLFAMILY_WARLOCK:
5992 // Fear (non stacking)
5993 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000040000000000))
5995 if(!apply)
5997 Unit* caster = GetCaster();
5998 if(!caster)
5999 return;
6001 Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY);
6002 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
6004 SpellEntry const* dummyEntry = (*itr)->GetSpellProto();
6005 // Improved Fear
6006 if (dummyEntry->SpellFamilyName == SPELLFAMILY_WARLOCK && dummyEntry->SpellIconID == 98)
6008 cast_at_remove = true;
6009 switch((*itr)->GetModifier()->m_amount)
6011 // Rank 1
6012 case 0: spellId1 = 60946; break;
6013 // Rank 1
6014 case 1: spellId1 = 60947; break;
6016 break;
6020 else
6021 return;
6023 else
6024 return;
6025 break;
6026 case SPELLFAMILY_PRIEST:
6028 // Shadow Word: Pain (need visual check fro skip improvement talent) or Vampiric Touch
6029 if (m_spellProto->SpellIconID == 234 && m_spellProto->SpellVisual[0] || m_spellProto->SpellIconID == 2213)
6031 if (!apply && m_removeMode == AURA_REMOVE_BY_DISPEL)
6033 Unit* caster = GetCaster();
6034 if(!caster)
6035 return;
6037 Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY);
6038 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
6040 // Shadow Affinity
6041 if ((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_PRIEST
6042 && (*itr)->GetSpellProto()->SpellIconID == 178)
6044 // custom cast code
6045 int32 basepoints0 = (*itr)->GetModifier()->m_amount * caster->GetCreateMana() / 100;
6046 caster->CastCustomSpell(caster, 64103, &basepoints0, NULL, NULL, true, NULL, this);
6047 return;
6051 else
6052 return;
6055 switch(GetId())
6057 // Abolish Disease (remove 1 more poison effect with Body and Soul)
6058 case 552:
6060 if(apply)
6062 int chance =0;
6063 Unit::AuraList const& dummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
6064 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
6066 SpellEntry const* dummyEntry = (*itr)->GetSpellProto();
6067 // Body and Soul (talent ranks)
6068 if (dummyEntry->SpellFamilyName == SPELLFAMILY_PRIEST && dummyEntry->SpellIconID == 2218 &&
6069 dummyEntry->SpellVisual[0]==0)
6071 chance = (*itr)->GetSpellProto()->CalculateSimpleValue(1);
6072 break;
6076 if(roll_chance_i(chance))
6077 spellId1 = 64134; // Body and Soul (periodic dispel effect)
6079 else
6080 spellId1 = 64134; // Body and Soul (periodic dispel effect)
6081 break;
6083 // Dispersion mana reg and immunity
6084 case 47585:
6085 spellId1 = 60069; // Dispersion
6086 spellId2 = 63230; // Dispersion
6087 break;
6088 default:
6089 return;
6091 break;
6093 case SPELLFAMILY_ROGUE:
6094 // Sprint (skip non player casted spells by category)
6095 if (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000040) && GetSpellProto()->Category == 44)
6097 if(!apply || m_target->HasAura(58039)) // Glyph of Blurred Speed
6098 spellId1 = 61922; // Sprint (waterwalk)
6099 else
6100 return;
6102 else
6103 return;
6104 break;
6105 case SPELLFAMILY_HUNTER:
6107 // The Beast Within and Bestial Wrath - immunity
6108 if (GetId() == 19574 || GetId() == 34471)
6110 spellId1 = 24395;
6111 spellId2 = 24396;
6112 spellId3 = 24397;
6113 spellId4 = 26592;
6115 // Aspect of the Dragonhawk dodge
6116 else if (GetSpellProto()->SpellFamilyFlags2 & 0x00001000)
6118 spellId1 = 61848;
6120 // triggered spell have same category as main spell and cooldown
6121 if (apply && m_target->GetTypeId()==TYPEID_PLAYER)
6122 ((Player*)m_target)->RemoveSpellCooldown(61848);
6124 else
6125 return;
6126 break;
6128 case SPELLFAMILY_PALADIN:
6130 if (m_spellProto->Id == 31884) // Avenging Wrath
6132 if(!apply)
6133 spellId1 = 57318; // Sanctified Wrath (triggered)
6134 else
6136 int32 percent = 0;
6137 Unit::AuraList const& dummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
6138 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
6140 if ((*itr)->GetSpellProto()->SpellIconID == 3029)
6142 percent = (*itr)->GetModifier()->m_amount;
6143 break;
6147 // apply in special way
6148 if(percent)
6150 spellId1 = 57318; // Sanctified Wrath (triggered)
6151 // prevent aura deletion, specially in multi-boost case
6152 SetInUse(true);
6153 m_target->CastCustomSpell(m_target, spellId1, &percent, &percent, NULL, true, NULL, this);
6154 SetInUse(false);
6156 return;
6158 break;
6161 // Only process on player casting paladin aura
6162 // all aura bonuses applied also in aura area effect way to caster
6163 if (GetCasterGUID() != m_target->GetGUID() || !IS_PLAYER_GUID(GetCasterGUID()))
6164 return;
6166 if (GetSpellSpecific(m_spellProto->Id) != SPELL_AURA)
6167 return;
6169 // Sanctified Retribution and Swift Retribution (they share one aura), but not Retribution Aura (already gets modded)
6170 if ((GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000008))==0)
6171 spellId1 = 63531; // placeholder for talent spell mods
6172 // Improved Concentration Aura (auras bonus)
6173 spellId2 = 63510; // placeholder for talent spell mods
6174 // Improved Devotion Aura (auras bonus)
6175 spellId3 = 63514; // placeholder for talent spell mods
6176 break;
6178 case SPELLFAMILY_DEATHKNIGHT:
6180 if (GetSpellSpecific(m_spellProto->Id) != SPELL_PRESENCE)
6181 return;
6183 // Frost Presence health
6184 if (GetId() == 48263)
6185 spellId1 = 61261;
6186 // Unholy Presence move speed
6187 else if (GetId() == 48265)
6188 spellId1 = 49772;
6189 else
6190 return;
6192 break;
6194 default:
6195 return;
6198 // prevent aura deletion, specially in multi-boost case
6199 SetInUse(true);
6201 if (apply || cast_at_remove)
6203 if (spellId1)
6204 m_target->CastSpell(m_target, spellId1, true, NULL, this);
6205 if (spellId2 && !IsDeleted())
6206 m_target->CastSpell(m_target, spellId2, true, NULL, this);
6207 if (spellId3 && !IsDeleted())
6208 m_target->CastSpell(m_target, spellId3, true, NULL, this);
6209 if (spellId4 && !IsDeleted())
6210 m_target->CastSpell(m_target, spellId4, true, NULL, this);
6212 else
6214 if (spellId1)
6215 m_target->RemoveAurasByCasterSpell(spellId1, GetCasterGUID());
6216 if (spellId2)
6217 m_target->RemoveAurasByCasterSpell(spellId2, GetCasterGUID());
6218 if (spellId3)
6219 m_target->RemoveAurasByCasterSpell(spellId3, GetCasterGUID());
6220 if (spellId4)
6221 m_target->RemoveAurasByCasterSpell(spellId4, GetCasterGUID());
6224 SetInUse(false);
6227 void Aura::HandleAuraEmpathy(bool apply, bool /*Real*/)
6229 if(m_target->GetTypeId() != TYPEID_UNIT)
6230 return;
6232 CreatureInfo const * ci = ObjectMgr::GetCreatureTemplate(m_target->GetEntry());
6233 if(ci && ci->type == CREATURE_TYPE_BEAST)
6234 m_target->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO, apply);
6237 void Aura::HandleAuraUntrackable(bool apply, bool /*Real*/)
6239 if(apply)
6240 m_target->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE);
6241 else
6242 m_target->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE);
6245 void Aura::HandleAuraModPacify(bool apply, bool /*Real*/)
6247 if(m_target->GetTypeId() != TYPEID_PLAYER)
6248 return;
6250 if(apply)
6251 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
6252 else
6253 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
6256 void Aura::HandleAuraModPacifyAndSilence(bool apply, bool Real)
6258 HandleAuraModPacify(apply, Real);
6259 HandleAuraModSilence(apply, Real);
6262 void Aura::HandleAuraGhost(bool apply, bool /*Real*/)
6264 if(m_target->GetTypeId() != TYPEID_PLAYER)
6265 return;
6267 if(apply)
6269 m_target->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST);
6271 else
6273 m_target->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST);
6277 void Aura::HandleAuraAllowFlight(bool apply, bool Real)
6279 // all applied/removed only at real aura add/remove
6280 if(!Real)
6281 return;
6283 // allow fly
6284 WorldPacket data;
6285 if(apply)
6286 data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
6287 else
6288 data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
6289 data.append(m_target->GetPackGUID());
6290 data << uint32(0); // unk
6291 m_target->SendMessageToSet(&data, true);
6294 void Aura::HandleModRating(bool apply, bool Real)
6296 // spells required only Real aura add/remove
6297 if(!Real)
6298 return;
6300 if(m_target->GetTypeId() != TYPEID_PLAYER)
6301 return;
6303 for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating)
6304 if (m_modifier.m_miscvalue & (1 << rating))
6305 ((Player*)m_target)->ApplyRatingMod(CombatRating(rating), m_modifier.m_amount, apply);
6308 void Aura::HandleModRatingFromStat(bool apply, bool Real)
6310 // spells required only Real aura add/remove
6311 if(!Real)
6312 return;
6314 if(m_target->GetTypeId() != TYPEID_PLAYER)
6315 return;
6316 // Just recalculate ratings
6317 for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating)
6318 if (m_modifier.m_miscvalue & (1 << rating))
6319 ((Player*)m_target)->ApplyRatingMod(CombatRating(rating), 0, apply);
6322 void Aura::HandleForceMoveForward(bool apply, bool Real)
6324 if(!Real || m_target->GetTypeId() != TYPEID_PLAYER)
6325 return;
6326 if(apply)
6327 m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE);
6328 else
6329 m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE);
6332 void Aura::HandleAuraModExpertise(bool /*apply*/, bool /*Real*/)
6334 if(m_target->GetTypeId() != TYPEID_PLAYER)
6335 return;
6337 ((Player*)m_target)->UpdateExpertise(BASE_ATTACK);
6338 ((Player*)m_target)->UpdateExpertise(OFF_ATTACK);
6341 void Aura::HandleModTargetResistance(bool apply, bool Real)
6343 // spells required only Real aura add/remove
6344 if(!Real)
6345 return;
6346 // applied to damage as HandleNoImmediateEffect in Unit::CalcAbsorbResist and Unit::CalcArmorReducedDamage
6348 // show armor penetration
6349 if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL))
6350 m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE, m_modifier.m_amount, apply);
6352 // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy
6353 if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_SPELL)==SPELL_SCHOOL_MASK_SPELL)
6354 m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, m_modifier.m_amount, apply);
6357 void Aura::HandleShieldBlockValue(bool apply, bool /*Real*/)
6359 BaseModType modType = FLAT_MOD;
6360 if(m_modifier.m_auraname == SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT)
6361 modType = PCT_MOD;
6363 if(m_target->GetTypeId() == TYPEID_PLAYER)
6364 ((Player*)m_target)->HandleBaseModValue(SHIELD_BLOCK_VALUE, modType, float(m_modifier.m_amount), apply);
6367 void Aura::HandleAuraRetainComboPoints(bool apply, bool Real)
6369 // spells required only Real aura add/remove
6370 if(!Real)
6371 return;
6373 if(m_target->GetTypeId() != TYPEID_PLAYER)
6374 return;
6376 Player *target = (Player*)m_target;
6378 // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler
6379 // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost)
6380 if( !apply && m_duration==0 && target->GetComboTarget())
6381 if(Unit* unit = ObjectAccessor::GetUnit(*m_target,target->GetComboTarget()))
6382 target->AddComboPoints(unit, -m_modifier.m_amount);
6385 void Aura::HandleModUnattackable( bool Apply, bool Real )
6387 if(Real && Apply)
6389 m_target->CombatStop();
6390 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
6392 m_target->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE,Apply);
6395 void Aura::HandleSpiritOfRedemption( bool apply, bool Real )
6397 // spells required only Real aura add/remove
6398 if(!Real)
6399 return;
6401 // prepare spirit state
6402 if(apply)
6404 if(m_target->GetTypeId()==TYPEID_PLAYER)
6406 // disable breath/etc timers
6407 ((Player*)m_target)->StopMirrorTimers();
6409 // set stand state (expected in this form)
6410 if(!m_target->IsStandState())
6411 m_target->SetStandState(UNIT_STAND_STATE_STAND);
6414 m_target->SetHealth(1);
6416 // die at aura end
6417 else
6418 m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, GetSpellProto(), false);
6421 void Aura::CleanupTriggeredSpells()
6423 uint32 tSpellId = m_spellProto->EffectTriggerSpell[GetEffIndex()];
6424 if(!tSpellId)
6425 return;
6427 SpellEntry const* tProto = sSpellStore.LookupEntry(tSpellId);
6428 if(!tProto)
6429 return;
6431 if(GetSpellDuration(tProto) != -1)
6432 return;
6434 // needed for spell 43680, maybe others
6435 // TODO: is there a spell flag, which can solve this in a more sophisticated way?
6436 if(m_spellProto->EffectApplyAuraName[GetEffIndex()] == SPELL_AURA_PERIODIC_TRIGGER_SPELL &&
6437 GetSpellDuration(m_spellProto) == m_spellProto->EffectAmplitude[GetEffIndex()])
6438 return;
6439 m_target->RemoveAurasDueToSpell(tSpellId);
6442 void Aura::HandleSchoolAbsorb(bool apply, bool Real)
6444 if(!Real)
6445 return;
6447 Unit* caster = GetCaster();
6448 if(!caster)
6449 return;
6451 if (apply)
6453 // prevent double apply bonuses
6454 if (m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())
6456 float DoneActualBenefit = 0.0f;
6457 switch(m_spellProto->SpellFamilyName)
6459 case SPELLFAMILY_PRIEST:
6460 // Power Word: Shield
6461 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000001))
6462 //+80.68% from +spell bonus
6463 DoneActualBenefit = caster->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto)) * 0.8068f;
6464 break;
6465 case SPELLFAMILY_MAGE:
6466 // Frost Ward, Fire Ward
6467 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000108))
6468 //+10% from +spell bonus
6469 DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.1f;
6470 // Ice Barrier
6471 else if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000100000000))
6472 //+80.67% from +spell bonus
6473 DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.8067f;
6474 break;
6475 case SPELLFAMILY_WARLOCK:
6476 // Shadow Ward
6477 if (m_spellProto->SpellFamilyFlags2 & 0x00000040)
6478 //+30% from +spell bonus
6479 DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.30f;
6480 break;
6481 case SPELLFAMILY_PALADIN:
6482 // Sacred Shield
6483 // (check not strictly needed, only Sacred Shield has SPELL_AURA_SCHOOL_ABSORB in SPELLFAMILY_PALADIN at this time)
6484 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0008000000000000))
6486 // +75% from spell power
6487 DoneActualBenefit = caster->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto)) * 0.75f;
6489 break;
6490 default:
6491 break;
6494 DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto());
6496 m_modifier.m_amount += (int32)DoneActualBenefit;
6499 else
6501 if (caster &&
6502 // Power Word: Shield
6503 m_spellProto->SpellFamilyName == SPELLFAMILY_PRIEST && m_spellProto->Mechanic == MECHANIC_SHIELD &&
6504 (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000001)) &&
6505 // completely absorbed or dispelled
6506 ((m_removeMode == AURA_REMOVE_BY_DEFAULT && !m_modifier.m_amount) || m_removeMode == AURA_REMOVE_BY_DISPEL))
6508 Unit::AuraList const& vDummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY);
6509 for(Unit::AuraList::const_iterator itr = vDummyAuras.begin(); itr != vDummyAuras.end(); ++itr)
6511 SpellEntry const* vSpell = (*itr)->GetSpellProto();
6513 // Rapture (main spell)
6514 if(vSpell->SpellFamilyName == SPELLFAMILY_PRIEST && vSpell->SpellIconID == 2894 && vSpell->Effect[1])
6516 switch((*itr)->GetEffIndex())
6518 case 0:
6520 // energize caster
6521 int32 manapct1000 = 5 * ((*itr)->GetModifier()->m_amount + sSpellMgr.GetSpellRank(vSpell->Id));
6522 int32 basepoints0 = caster->GetMaxPower(POWER_MANA) * manapct1000 / 1000;
6523 caster->CastCustomSpell(caster, 47755, &basepoints0, NULL, NULL, true);
6524 break;
6526 case 1:
6528 // energize target
6529 if (!roll_chance_i((*itr)->GetModifier()->m_amount) || caster->HasAura(63853))
6530 break;
6532 switch(m_target->getPowerType())
6534 case POWER_RUNIC_POWER:
6535 m_target->CastSpell(m_target, 63652, true, NULL, NULL, m_caster_guid);
6536 break;
6537 case POWER_RAGE:
6538 m_target->CastSpell(m_target, 63653, true, NULL, NULL, m_caster_guid);
6539 break;
6540 case POWER_MANA:
6542 int32 basepoints0 = m_target->GetMaxPower(POWER_MANA) * 2 / 100;
6543 m_target->CastCustomSpell(m_target, 63654, &basepoints0, NULL, NULL, true);
6544 break;
6546 case POWER_ENERGY:
6547 m_target->CastSpell(m_target, 63655, true, NULL, NULL, m_caster_guid);
6548 break;
6549 default:
6550 break;
6553 //cooldwon aura
6554 caster->CastSpell(caster, 63853, true);
6555 break;
6557 default:
6558 sLog.outError("Changes in R-dummy spell???: effect 3");
6559 break;
6567 void Aura::PeriodicTick()
6569 switch(m_modifier.m_auraname)
6571 case SPELL_AURA_PERIODIC_DAMAGE:
6572 case SPELL_AURA_PERIODIC_DAMAGE_PERCENT:
6574 Unit *pCaster = GetCaster();
6575 if(!pCaster)
6576 return;
6578 if( GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA &&
6579 pCaster->SpellHitResult(m_target, GetSpellProto(), false) != SPELL_MISS_NONE)
6580 return;
6582 // Check for immune (not use charges)
6583 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6584 return;
6586 // some auras remove at specific health level or more
6587 if(m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE)
6589 switch(GetId())
6591 case 43093: case 31956: case 38801:
6592 case 35321: case 38363: case 39215:
6593 if(m_target->GetHealth() == m_target->GetMaxHealth() )
6595 m_target->RemoveAurasDueToSpell(GetId());
6596 return;
6598 break;
6599 case 38772:
6601 uint32 percent =
6602 GetEffIndex() < 2 && GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_DUMMY ?
6603 pCaster->CalculateSpellDamage(GetSpellProto(), GetEffIndex() + 1, GetSpellProto()->EffectBasePoints[GetEffIndex() + 1], m_target) :
6604 100;
6605 if(m_target->GetHealth() * 100 >= m_target->GetMaxHealth() * percent )
6607 m_target->RemoveAurasDueToSpell(GetId());
6608 return;
6610 break;
6612 default:
6613 break;
6617 uint32 absorb = 0;
6618 uint32 resist = 0;
6619 CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
6621 // ignore non positive values (can be result apply spellmods to aura damage
6622 uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6624 uint32 pdamage;
6626 if(m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE)
6628 pdamage = amount;
6630 // SpellDamageBonus for magic spells
6631 if(GetSpellProto()->DmgClass == SPELL_DAMAGE_CLASS_NONE || GetSpellProto()->DmgClass == SPELL_DAMAGE_CLASS_MAGIC)
6632 pdamage = pCaster->SpellDamageBonus(m_target, GetSpellProto(), pdamage, DOT, GetStackAmount());
6633 // MeleeDamagebonus for weapon based spells
6634 else
6636 WeaponAttackType attackType = GetWeaponAttackType(GetSpellProto());
6637 pdamage = pCaster->MeleeDamageBonus(m_target, pdamage, attackType, GetSpellProto(), DOT, GetStackAmount());
6640 // Calculate armor mitigation if it is a physical spell
6641 // But not for bleed mechanic spells
6642 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL &&
6643 GetEffectMechanic(GetSpellProto(), m_effIndex) != MECHANIC_BLEED)
6645 uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage);
6646 cleanDamage.damage += pdamage - pdamageReductedArmor;
6647 pdamage = pdamageReductedArmor;
6650 // Curse of Agony damage-per-tick calculation
6651 if (GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000400)) && GetSpellProto()->SpellIconID==544)
6653 // 1..4 ticks, 1/2 from normal tick damage
6654 if (m_duration >= ((m_maxduration-m_modifier.periodictime) * 2 / 3))
6655 pdamage = pdamage/2;
6656 // 9..12 ticks, 3/2 from normal tick damage
6657 else if(m_duration < ((m_maxduration-m_modifier.periodictime) / 3))
6658 pdamage += (pdamage + 1) / 2; // +1 prevent 0.5 damage possible lost at 1..4 ticks
6659 // 5..8 ticks have normal tick damage
6662 else
6663 pdamage = uint32(m_target->GetMaxHealth()*amount/100);
6665 // This method can modify pdamage
6666 bool isCrit = IsCritFromAbilityAura(pCaster, pdamage);
6668 // send critical in hit info for threat calculation
6669 if (isCrit)
6671 cleanDamage.hitOutCome = MELEE_HIT_CRIT;
6672 // Resilience - reduce crit damage
6673 pdamage -= m_target->GetSpellCritDamageReduction(pdamage);
6676 // only from players
6677 // FIXME: need use SpellDamageBonus instead?
6678 if (IS_PLAYER_GUID(m_caster_guid))
6679 pdamage -= m_target->GetSpellDamageReduction(pdamage);
6681 pCaster->CalcAbsorbResist(m_target, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist, !(GetSpellProto()->AttributesEx2 & SPELL_ATTR_EX2_CANT_REFLECTED));
6683 sLog.outDetail("PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
6684 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb);
6686 pCaster->DealDamageMods(m_target, pdamage, &absorb);
6688 SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, absorb, resist, 0.0f, isCrit);
6689 m_target->SendPeriodicAuraLog(&pInfo);
6691 // Set trigger flag
6692 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
6693 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
6694 pdamage = (pdamage <= absorb + resist) ? 0 : (pdamage - absorb - resist);
6695 if (pdamage)
6696 procVictim|=PROC_FLAG_TAKEN_ANY_DAMAGE;
6697 pCaster->ProcDamageAndSpell(m_target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, GetSpellProto());
6699 pCaster->DealDamage(m_target, pdamage, &cleanDamage, DOT, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
6700 break;
6702 case SPELL_AURA_PERIODIC_LEECH:
6703 case SPELL_AURA_PERIODIC_HEALTH_FUNNEL:
6705 Unit *pCaster = GetCaster();
6706 if(!pCaster)
6707 return;
6709 if(!pCaster->isAlive())
6710 return;
6712 if( GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA &&
6713 pCaster->SpellHitResult(m_target, GetSpellProto(), false) != SPELL_MISS_NONE)
6714 return;
6716 // Check for immune
6717 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6718 return;
6720 uint32 absorb=0;
6721 uint32 resist=0;
6722 CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
6724 uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6726 //Calculate armor mitigation if it is a physical spell
6727 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL)
6729 uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage);
6730 cleanDamage.damage += pdamage - pdamageReductedArmor;
6731 pdamage = pdamageReductedArmor;
6734 pdamage = pCaster->SpellDamageBonus(m_target, GetSpellProto(), pdamage, DOT, GetStackAmount());
6736 pCaster->CalcAbsorbResist(m_target, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist, !(GetSpellProto()->AttributesEx2 & SPELL_ATTR_EX2_CANT_REFLECTED));
6738 if(m_target->GetHealth() < pdamage)
6739 pdamage = uint32(m_target->GetHealth());
6741 sLog.outDetail("PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
6742 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb);
6744 pCaster->SendSpellNonMeleeDamageLog(m_target, GetId(), pdamage, GetSpellSchoolMask(GetSpellProto()), absorb, resist, false, 0);
6746 float multiplier = GetSpellProto()->EffectMultipleValue[GetEffIndex()] > 0 ? GetSpellProto()->EffectMultipleValue[GetEffIndex()] : 1;
6748 // Set trigger flag
6749 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
6750 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
6751 pdamage = (pdamage <= absorb + resist) ? 0 : (pdamage-absorb-resist);
6752 if (pdamage)
6753 procVictim|=PROC_FLAG_TAKEN_ANY_DAMAGE;
6754 pCaster->ProcDamageAndSpell(m_target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, GetSpellProto());
6755 int32 new_damage = pCaster->DealDamage(m_target, pdamage, &cleanDamage, DOT, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), false);
6757 if (!m_target->isAlive() && pCaster->IsNonMeleeSpellCasted(false))
6758 for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
6759 if (Spell* spell = pCaster->GetCurrentSpell(CurrentSpellTypes(i)))
6760 if (spell->m_spellInfo->Id == GetId())
6761 spell->cancel();
6764 if(Player *modOwner = pCaster->GetSpellModOwner())
6765 modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, multiplier);
6767 uint32 heal = pCaster->SpellHealingBonus(pCaster, GetSpellProto(), uint32(new_damage * multiplier), DOT, GetStackAmount());
6769 int32 gain = pCaster->DealHeal(pCaster, heal, GetSpellProto());
6770 pCaster->getHostileRefManager().threatAssist(pCaster, gain * 0.5f, GetSpellProto());
6771 break;
6773 case SPELL_AURA_PERIODIC_HEAL:
6774 case SPELL_AURA_OBS_MOD_HEALTH:
6776 Unit *pCaster = GetCaster();
6777 if(!pCaster)
6778 return;
6780 // heal for caster damage (must be alive)
6781 if(m_target != pCaster && GetSpellProto()->SpellVisual[0] == 163 && !pCaster->isAlive())
6782 return;
6784 // ignore non positive values (can be result apply spellmods to aura damage
6785 uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6787 uint32 pdamage;
6789 if(m_modifier.m_auraname==SPELL_AURA_OBS_MOD_HEALTH)
6790 pdamage = uint32(m_target->GetMaxHealth() * amount / 100);
6791 else
6793 pdamage = amount;
6795 // Wild Growth (1/7 - 6 + 2*ramainTicks) %
6796 if (m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && m_spellProto->SpellIconID == 2864)
6798 int32 ticks = m_maxduration/m_modifier.periodictime;
6799 int32 remainingTicks = int32(float(m_duration) / m_modifier.periodictime + 0.5);
6800 pdamage = int32(pdamage) + int32(amount)*ticks*(-6+2*remainingTicks)/100;
6804 pdamage = pCaster->SpellHealingBonus(m_target, GetSpellProto(), pdamage, DOT, GetStackAmount());
6806 // This method can modify pdamage
6807 bool isCrit = IsCritFromAbilityAura(pCaster, pdamage);
6809 sLog.outDetail("PeriodicTick: %u (TypeId: %u) heal of %u (TypeId: %u) for %u health inflicted by %u",
6810 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
6812 SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, 0, 0, 0.0f, isCrit);
6813 m_target->SendPeriodicAuraLog(&pInfo);
6815 int32 gain = m_target->ModifyHealth(pdamage);
6817 // add HoTs to amount healed in bgs
6818 if( pCaster->GetTypeId() == TYPEID_PLAYER )
6819 if( BattleGround *bg = ((Player*)pCaster)->GetBattleGround() )
6820 bg->UpdatePlayerScore(((Player*)pCaster), SCORE_HEALING_DONE, gain);
6822 m_target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto());
6824 SpellEntry const* spellProto = GetSpellProto();
6826 // heal for caster damage
6827 if(m_target != pCaster && spellProto->SpellVisual[0] == 163)
6829 uint32 dmg = spellProto->manaPerSecond;
6830 if(pCaster->GetHealth() <= dmg && pCaster->GetTypeId()==TYPEID_PLAYER)
6832 pCaster->RemoveAurasDueToSpell(GetId());
6834 // finish current generic/channeling spells, don't affect autorepeat
6835 pCaster->FinishSpell(CURRENT_GENERIC_SPELL);
6836 pCaster->FinishSpell(CURRENT_CHANNELED_SPELL);
6838 else
6840 uint32 damage = gain;
6841 uint32 absorb = 0;
6842 pCaster->DealDamageMods(pCaster, damage, &absorb);
6843 pCaster->SendSpellNonMeleeDamageLog(pCaster, GetId(), damage, GetSpellSchoolMask(GetSpellProto()), absorb, 0, false, 0, false);
6845 CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
6846 pCaster->DealDamage(pCaster, damage, &cleanDamage, NODAMAGE, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
6850 // uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;// | PROC_FLAG_SUCCESSFUL_HEAL;
6851 // uint32 procVictim = 0;//ROC_FLAG_ON_TAKE_PERIODIC | PROC_FLAG_TAKEN_HEAL;
6852 // ignore item heals
6853 // if(procSpell && !haveCastItem)
6854 // pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto);
6855 break;
6857 case SPELL_AURA_PERIODIC_MANA_LEECH:
6859 if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS)
6860 return;
6862 Powers power = Powers(m_modifier.m_miscvalue);
6864 // power type might have changed between aura applying and tick (druid's shapeshift)
6865 if(m_target->getPowerType() != power)
6866 return;
6868 Unit *pCaster = GetCaster();
6869 if(!pCaster)
6870 return;
6872 if(!pCaster->isAlive())
6873 return;
6875 if( GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA &&
6876 pCaster->SpellHitResult(m_target, GetSpellProto(), false) != SPELL_MISS_NONE)
6877 return;
6879 // Check for immune (not use charges)
6880 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6881 return;
6883 // ignore non positive values (can be result apply spellmods to aura damage
6884 uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6886 // Special case: draining x% of mana (up to a maximum of 2*x% of the caster's maximum mana)
6887 // It's mana percent cost spells, m_modifier.m_amount is percent drain from target
6888 if (m_spellProto->ManaCostPercentage)
6890 // max value
6891 uint32 maxmana = pCaster->GetMaxPower(power) * pdamage * 2 / 100;
6892 pdamage = m_target->GetMaxPower(power) * pdamage / 100;
6893 if(pdamage > maxmana)
6894 pdamage = maxmana;
6897 sLog.outDetail("PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u",
6898 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
6900 int32 drain_amount = m_target->GetPower(power) > pdamage ? pdamage : m_target->GetPower(power);
6902 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
6903 if (power == POWER_MANA)
6904 drain_amount -= m_target->GetSpellCritDamageReduction(drain_amount);
6906 m_target->ModifyPower(power, -drain_amount);
6908 float gain_multiplier = 0;
6910 if(pCaster->GetMaxPower(power) > 0)
6912 gain_multiplier = GetSpellProto()->EffectMultipleValue[GetEffIndex()];
6914 if(Player *modOwner = pCaster->GetSpellModOwner())
6915 modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, gain_multiplier);
6918 SpellPeriodicAuraLogInfo pInfo(this, drain_amount, 0, 0, 0, gain_multiplier);
6919 m_target->SendPeriodicAuraLog(&pInfo);
6921 int32 gain_amount = int32(drain_amount * gain_multiplier);
6923 if(gain_amount)
6925 int32 gain = pCaster->ModifyPower(power, gain_amount);
6926 m_target->AddThreat(pCaster, float(gain) * 0.5f, pInfo.critical, GetSpellSchoolMask(GetSpellProto()), GetSpellProto());
6928 break;
6930 case SPELL_AURA_PERIODIC_ENERGIZE:
6932 // ignore non positive values (can be result apply spellmods to aura damage
6933 uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6935 sLog.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u",
6936 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
6938 if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS)
6939 break;
6941 Powers power = Powers(m_modifier.m_miscvalue);
6943 if(m_target->GetMaxPower(power) == 0)
6944 break;
6946 SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, 0, 0, 0.0f);
6947 m_target->SendPeriodicAuraLog(&pInfo);
6949 int32 gain = m_target->ModifyPower(power,pdamage);
6951 if(Unit* pCaster = GetCaster())
6952 m_target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto());
6953 break;
6955 case SPELL_AURA_OBS_MOD_MANA:
6957 // ignore non positive values (can be result apply spellmods to aura damage
6958 uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6960 uint32 pdamage = uint32(m_target->GetMaxPower(POWER_MANA) * amount / 100);
6962 sLog.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u mana inflicted by %u",
6963 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
6965 if(m_target->GetMaxPower(POWER_MANA) == 0)
6966 break;
6968 SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, 0, 0, 0.0f);
6969 m_target->SendPeriodicAuraLog(&pInfo);
6971 int32 gain = m_target->ModifyPower(POWER_MANA, pdamage);
6973 if(Unit* pCaster = GetCaster())
6974 m_target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto());
6975 break;
6977 case SPELL_AURA_POWER_BURN_MANA:
6979 Unit *pCaster = GetCaster();
6980 if(!pCaster)
6981 return;
6983 // Check for immune (not use charges)
6984 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6985 return;
6987 int32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6989 Powers powerType = Powers(m_modifier.m_miscvalue);
6991 if(!m_target->isAlive() || m_target->getPowerType() != powerType)
6992 return;
6994 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
6995 if (powerType == POWER_MANA)
6996 pdamage -= m_target->GetSpellCritDamageReduction(pdamage);
6998 uint32 gain = uint32(-m_target->ModifyPower(powerType, -pdamage));
7000 gain = uint32(gain * GetSpellProto()->EffectMultipleValue[GetEffIndex()]);
7002 SpellEntry const* spellProto = GetSpellProto();
7003 // maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG
7004 SpellNonMeleeDamage damageInfo(pCaster, m_target, spellProto->Id, spellProto->SchoolMask);
7005 pCaster->CalculateSpellDamage(&damageInfo, gain, spellProto);
7007 pCaster->DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb);
7009 pCaster->SendSpellNonMeleeDamageLog(&damageInfo);
7011 // Set trigger flag
7012 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
7013 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
7014 uint32 procEx = createProcExtendMask(&damageInfo, SPELL_MISS_NONE);
7015 if (damageInfo.damage)
7016 procVictim|=PROC_FLAG_TAKEN_ANY_DAMAGE;
7018 pCaster->ProcDamageAndSpell(damageInfo.target, procAttacker, procVictim, procEx, damageInfo.damage, BASE_ATTACK, spellProto);
7020 pCaster->DealSpellDamage(&damageInfo, true);
7021 break;
7023 case SPELL_AURA_MOD_REGEN:
7025 int32 gain = m_target->ModifyHealth(m_modifier.m_amount);
7026 if (Unit *caster = GetCaster())
7027 m_target->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f, GetSpellProto());
7028 break;
7030 case SPELL_AURA_MOD_POWER_REGEN:
7032 Powers pt = m_target->getPowerType();
7033 if(int32(pt) != m_modifier.m_miscvalue)
7034 return;
7036 if ( GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED )
7038 // eating anim
7039 m_target->HandleEmoteCommand(EMOTE_ONESHOT_EAT);
7041 else if( GetId() == 20577 )
7043 // cannibalize anim
7044 m_target->HandleEmoteCommand(EMOTE_STATE_CANNIBALIZE);
7047 // Anger Management
7048 // amount = 1+ 16 = 17 = 3,4*5 = 10,2*5/3
7049 // so 17 is rounded amount for 5 sec tick grow ~ 1 range grow in 3 sec
7050 if(pt == POWER_RAGE)
7051 m_target->ModifyPower(pt, m_modifier.m_amount * 3 / 5);
7052 break;
7054 // Here tick dummy auras
7055 case SPELL_AURA_PERIODIC_DUMMY:
7057 PeriodicDummyTick();
7058 break;
7060 case SPELL_AURA_PERIODIC_TRIGGER_SPELL:
7062 TriggerSpell();
7063 break;
7065 case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE:
7067 TriggerSpellWithValue();
7068 break;
7070 default:
7071 break;
7075 void Aura::PeriodicDummyTick()
7077 SpellEntry const* spell = GetSpellProto();
7078 switch (spell->SpellFamilyName)
7080 case SPELLFAMILY_GENERIC:
7081 switch (spell->Id)
7083 // Drink
7084 case 430:
7085 case 431:
7086 case 432:
7087 case 1133:
7088 case 1135:
7089 case 1137:
7090 case 10250:
7091 case 22734:
7092 case 27089:
7093 case 34291:
7094 case 43182:
7095 case 43183:
7096 case 43706:
7097 case 46755:
7098 case 49472: // Drink Coffee
7099 case 57073:
7100 case 61830:
7102 if (m_target->GetTypeId() != TYPEID_PLAYER)
7103 return;
7104 // Search SPELL_AURA_MOD_POWER_REGEN aura for this spell and add bonus
7105 Unit::AuraList const& aura = m_target->GetAurasByType(SPELL_AURA_MOD_POWER_REGEN);
7106 for(Unit::AuraList::const_iterator i = aura.begin(); i != aura.end(); ++i)
7108 if ((*i)->GetId() == GetId())
7110 (*i)->GetModifier()->m_amount = m_modifier.m_amount;
7111 ((Player*)m_target)->UpdateManaRegen();
7112 // Disable continue
7113 m_isPeriodic = false;
7114 return;
7117 return;
7119 // Forsaken Skills
7120 case 7054:
7122 // Possibly need cast one of them (but
7123 // 7038 Forsaken Skill: Swords
7124 // 7039 Forsaken Skill: Axes
7125 // 7040 Forsaken Skill: Daggers
7126 // 7041 Forsaken Skill: Maces
7127 // 7042 Forsaken Skill: Staves
7128 // 7043 Forsaken Skill: Bows
7129 // 7044 Forsaken Skill: Guns
7130 // 7045 Forsaken Skill: 2H Axes
7131 // 7046 Forsaken Skill: 2H Maces
7132 // 7047 Forsaken Skill: 2H Swords
7133 // 7048 Forsaken Skill: Defense
7134 // 7049 Forsaken Skill: Fire
7135 // 7050 Forsaken Skill: Frost
7136 // 7051 Forsaken Skill: Holy
7137 // 7053 Forsaken Skill: Shadow
7138 return;
7140 // // Panda
7141 // case 19230: break;
7142 // // Gossip NPC Periodic - Talk
7143 // case 33208: break;
7144 // // Gossip NPC Periodic - Despawn
7145 // case 33209: break;
7146 // // Steal Weapon
7147 // case 36207: break;
7148 // // Simon Game START timer, (DND)
7149 // case 39993: break;
7150 // // Knockdown Fel Cannon: break; The Aggro Burst
7151 // case 40119: break;
7152 // // Old Mount Spell
7153 // case 40154: break;
7154 // // Magnetic Pull
7155 // case 40581: break;
7156 // // Ethereal Ring: break; The Bolt Burst
7157 // case 40801: break;
7158 // // Crystal Prison
7159 // case 40846: break;
7160 // // Copy Weapon
7161 // case 41054: break;
7162 // // Dementia
7163 // case 41404: break;
7164 // // Ethereal Ring Visual, Lightning Aura
7165 // case 41477: break;
7166 // // Ethereal Ring Visual, Lightning Aura (Fork)
7167 // case 41525: break;
7168 // // Ethereal Ring Visual, Lightning Jumper Aura
7169 // case 41567: break;
7170 // // No Man's Land
7171 // case 41955: break;
7172 // // Headless Horseman - Fire
7173 // case 42074: break;
7174 // // Headless Horseman - Visual - Large Fire
7175 // case 42075: break;
7176 // // Headless Horseman - Start Fire, Periodic Aura
7177 // case 42140: break;
7178 // // Ram Speed Boost
7179 // case 42152: break;
7180 // // Headless Horseman - Fires Out Victory Aura
7181 // case 42235: break;
7182 // // Pumpkin Life Cycle
7183 // case 42280: break;
7184 // // Brewfest Request Chick Chuck Mug Aura
7185 // case 42537: break;
7186 // // Squashling
7187 // case 42596: break;
7188 // // Headless Horseman Climax, Head: Periodic
7189 // case 42603: break;
7190 // // Fire Bomb
7191 // case 42621: break;
7192 // // Headless Horseman - Conflagrate, Periodic Aura
7193 // case 42637: break;
7194 // // Headless Horseman - Create Pumpkin Treats Aura
7195 // case 42774: break;
7196 // // Headless Horseman Climax - Summoning Rhyme Aura
7197 // case 42879: break;
7198 // // Tricky Treat
7199 // case 42919: break;
7200 // // Giddyup!
7201 // case 42924: break;
7202 // // Ram - Trot
7203 // case 42992: break;
7204 // // Ram - Canter
7205 // case 42993: break;
7206 // // Ram - Gallop
7207 // case 42994: break;
7208 // // Ram Level - Neutral
7209 // case 43310: break;
7210 // // Headless Horseman - Maniacal Laugh, Maniacal, Delayed 17
7211 // case 43884: break;
7212 // // Wretched!
7213 // case 43963: break;
7214 // // Headless Horseman - Maniacal Laugh, Maniacal, other, Delayed 17
7215 // case 44000: break;
7216 // // Energy Feedback
7217 // case 44328: break;
7218 // // Romantic Picnic
7219 // case 45102: break;
7220 // // Romantic Picnic
7221 // case 45123: break;
7222 // // Looking for Love
7223 // case 45124: break;
7224 // // Kite - Lightning Strike Kite Aura
7225 // case 45197: break;
7226 // // Rocket Chicken
7227 // case 45202: break;
7228 // // Copy Offhand Weapon
7229 // case 45205: break;
7230 // // Upper Deck - Kite - Lightning Periodic Aura
7231 // case 45207: break;
7232 // // Kite -Sky Lightning Strike Kite Aura
7233 // case 45251: break;
7234 // // Ribbon Pole Dancer Check Aura
7235 // case 45390: break;
7236 // // Holiday - Midsummer, Ribbon Pole Periodic Visual
7237 // case 45406: break;
7238 // // Parachute
7239 // case 45472: break;
7240 // // Alliance Flag, Extra Damage Debuff
7241 // case 45898: break;
7242 // // Horde Flag, Extra Damage Debuff
7243 // case 45899: break;
7244 // // Ahune - Summoning Rhyme Aura
7245 // case 45926: break;
7246 // // Ahune - Slippery Floor
7247 // case 45945: break;
7248 // // Ahune's Shield
7249 // case 45954: break;
7250 // // Nether Vapor Lightning
7251 // case 45960: break;
7252 // // Darkness
7253 // case 45996: break;
7254 // // Summon Blood Elves Periodic
7255 // case 46041: break;
7256 // // Transform Visual Missile Periodic
7257 // case 46205: break;
7258 // // Find Opening Beam End
7259 // case 46333: break;
7260 // // Ice Spear Control Aura
7261 // case 46371: break;
7262 // // Hailstone Chill
7263 // case 46458: break;
7264 // // Hailstone Chill, Internal
7265 // case 46465: break;
7266 // // Chill, Internal Shifter
7267 // case 46549: break;
7268 // // Summon Ice Spear Knockback Delayer
7269 // case 46878: break;
7270 // // Burninate Effect
7271 // case 47214: break;
7272 // // Fizzcrank Practice Parachute
7273 // case 47228: break;
7274 // // Send Mug Control Aura
7275 // case 47369: break;
7276 // // Direbrew's Disarm (precast)
7277 // case 47407: break;
7278 // // Mole Machine Port Schedule
7279 // case 47489: break;
7280 // case 47941: break; // Crystal Spike
7281 // case 48200: break; // Healer Aura
7282 // case 48630: break; // Summon Gauntlet Mobs Periodic
7283 // case 49313: break; // Proximity Mine Area Aura
7284 // // Mole Machine Portal Schedule
7285 // case 49466: break;
7286 // case 49555: break; // Corpse Explode
7287 // case 49592: break; // Temporal Rift
7288 // case 49957: break; // Cutting Laser
7289 // case 50085: break; // Slow Fall
7290 // // Listening to Music
7291 // case 50493: break;
7292 // // Love Rocket Barrage
7293 // case 50530: break;
7294 // Exist more after, need add later
7295 default:
7296 break;
7298 // Prey on the Weak
7299 if (spell->SpellIconID == 2983)
7301 Unit *target=m_target->getVictim();
7302 if (target && (m_target->GetHealth() * 100 / m_target->GetMaxHealth() > target->GetHealth() * 100 / target->GetMaxHealth()))
7304 if(!m_target->HasAura(58670))
7306 int32 basepoints = GetBasePoints();
7307 m_target->CastCustomSpell(m_target, 58670, &basepoints, 0, 0, true);
7310 else
7311 m_target->RemoveAurasDueToSpell(58670);
7313 break;
7314 case SPELLFAMILY_MAGE:
7316 // Mirror Image
7317 // if (spell->Id == 55342)
7318 // return;
7319 break;
7321 case SPELLFAMILY_DRUID:
7323 switch (spell->Id)
7325 // Frenzied Regeneration
7326 case 22842:
7328 // Converts up to 10 rage per second into health for $d. Each point of rage is converted into ${$m2/10}.1% of max health.
7329 // Should be manauser
7330 if (m_target->getPowerType() != POWER_RAGE)
7331 return;
7332 uint32 rage = m_target->GetPower(POWER_RAGE);
7333 // Nothing todo
7334 if (rage == 0)
7335 return;
7336 int32 mod = (rage < 100) ? rage : 100;
7337 int32 points = m_target->CalculateSpellDamage(spell, 1, spell->EffectBasePoints[1], m_target);
7338 int32 regen = m_target->GetMaxHealth() * (mod * points / 10) / 1000;
7339 m_target->CastCustomSpell(m_target, 22845, &regen, NULL, NULL, true, NULL, this);
7340 m_target->SetPower(POWER_RAGE, rage-mod);
7341 return;
7343 // Force of Nature
7344 case 33831:
7345 return;
7346 default:
7347 break;
7349 break;
7351 case SPELLFAMILY_ROGUE:
7353 switch (spell->Id)
7355 // Killing Spree
7356 case 51690:
7358 if (m_target->hasUnitState(UNIT_STAT_STUNNED) || m_target->HasAuraType(SPELL_AURA_MOD_FEAR))
7359 return;
7361 std::list<Unit*> targets;
7363 // eff_radius ==0
7364 float radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spell->rangeIndex));
7366 CellPair p(MaNGOS::ComputeCellPair(m_target->GetPositionX(),m_target->GetPositionY()));
7367 Cell cell(p);
7368 cell.data.Part.reserved = ALL_DISTRICT;
7370 MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck u_check(m_target, m_target, radius);
7371 MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck> checker(m_target, targets, u_check);
7373 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck>, GridTypeMapContainer > grid_object_checker(checker);
7374 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker);
7376 CellLock<GridReadGuard> cell_lock(cell, p);
7378 cell_lock->Visit(cell_lock, grid_object_checker, *m_target->GetMap(), *m_target, radius);
7379 cell_lock->Visit(cell_lock, world_object_checker, *m_target->GetMap(), *m_target, radius);
7382 if(targets.empty())
7383 return;
7385 std::list<Unit*>::const_iterator itr = targets.begin();
7386 std::advance(itr, rand()%targets.size());
7387 Unit* target = *itr;
7389 m_target->CastSpell(target, 57840, true);
7390 m_target->CastSpell(target, 57841, true);
7391 return;
7393 default:
7394 break;
7396 break;
7398 case SPELLFAMILY_HUNTER:
7400 // Explosive Shot
7401 if (spell->SpellFamilyFlags & UI64LIT(0x8000000000000000))
7403 m_target->CastCustomSpell(m_target, 53352, &m_modifier.m_amount, 0, 0, true, 0, this, GetCasterGUID());
7404 return;
7406 switch (spell->Id)
7408 // Harpooner's Mark
7409 // case 40084:
7410 // return;
7411 // Feeding Frenzy Rank 1
7412 case 53511:
7413 if ( m_target->GetHealth() * 100 < m_target->GetMaxHealth() * 35 )
7414 m_target->CastSpell(m_target, 60096, true, 0, this);
7415 return;
7416 // Feeding Frenzy Rank 2
7417 case 53512:
7418 if ( m_target->GetHealth() * 100 < m_target->GetMaxHealth() * 35 )
7419 m_target->CastSpell(m_target, 60097, true, 0, this);
7420 return;
7421 default:
7422 break;
7424 break;
7426 case SPELLFAMILY_SHAMAN:
7428 // Astral Shift
7429 if (spell->Id == 52179)
7431 // Periodic need for remove visual on stun/fear/silence lost
7432 if (!(m_target->GetUInt32Value(UNIT_FIELD_FLAGS)&(UNIT_FLAG_STUNNED|UNIT_FLAG_FLEEING|UNIT_FLAG_SILENCED)))
7433 m_target->RemoveAurasDueToSpell(52179);
7434 return;
7436 break;
7438 case SPELLFAMILY_DEATHKNIGHT:
7440 // Death and Decay
7441 if (spell->SpellFamilyFlags & UI64LIT(0x0000000000000020))
7443 if (Unit *caster = GetCaster())
7444 caster->CastCustomSpell(m_target, 52212, &m_modifier.m_amount, NULL, NULL, true, NULL, this);
7445 return;
7447 // Raise Dead
7448 // if (spell->SpellFamilyFlags & UI64LIT(0x0000000000001000))
7449 // return;
7450 // Chains of Ice
7451 if (spell->SpellFamilyFlags & UI64LIT(0x0000400000000000))
7453 // Get 0 effect aura
7454 Aura *slow = m_target->GetAura(GetId(), 0);
7455 if (slow)
7457 slow->ApplyModifier(false, true);
7458 Modifier *mod = slow->GetModifier();
7459 mod->m_amount+= m_modifier.m_amount;
7460 if (mod->m_amount > 0) mod->m_amount = 0;
7461 slow->ApplyModifier(true, true);
7463 return;
7465 // Summon Gargoyle
7466 // if (spell->SpellFamilyFlags & UI64LIT(0x0000008000000000))
7467 // return;
7468 // Death Rune Mastery
7469 // if (spell->SpellFamilyFlags & UI64LIT(0x0000000000004000))
7470 // return;
7471 // Bladed Armor
7472 if (spell->SpellIconID == 2653)
7474 // Increases your attack power by $s1 for every $s2 armor value you have.
7475 // Calculate AP bonus (from 1 efect of this spell)
7476 int32 apBonus = m_modifier.m_amount * m_target->GetArmor() / m_target->CalculateSpellDamage(spell, 1, spell->EffectBasePoints[1], m_target);
7477 m_target->CastCustomSpell(m_target, 61217, &apBonus, &apBonus, NULL, true, NULL, this);
7478 return;
7480 // Reaping
7481 // if (spell->SpellIconID == 22)
7482 // return;
7483 // Blood of the North
7484 // if (spell->SpellIconID == 30412)
7485 // return;
7486 break;
7488 default:
7489 break;
7493 void Aura::HandlePreventFleeing(bool apply, bool Real)
7495 if(!Real)
7496 return;
7498 Unit::AuraList const& fearAuras = m_target->GetAurasByType(SPELL_AURA_MOD_FEAR);
7499 if( !fearAuras.empty() )
7501 if (apply)
7502 m_target->SetFeared(false, fearAuras.front()->GetCasterGUID());
7503 else
7504 m_target->SetFeared(true);
7508 void Aura::HandleManaShield(bool apply, bool Real)
7510 if(!Real)
7511 return;
7513 // prevent double apply bonuses
7514 if(apply && (m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading()))
7516 if(Unit* caster = GetCaster())
7518 float DoneActualBenefit = 0.0f;
7519 switch(m_spellProto->SpellFamilyName)
7521 case SPELLFAMILY_MAGE:
7522 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000008000))
7524 // Mana Shield
7525 // +50% from +spd bonus
7526 DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.5f;
7527 break;
7529 break;
7530 default:
7531 break;
7534 DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto());
7536 m_modifier.m_amount += (int32)DoneActualBenefit;
7541 void Aura::HandleArenaPreparation(bool apply, bool Real)
7543 if(!Real)
7544 return;
7546 if(apply)
7547 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION);
7548 else
7549 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION);
7553 * Such auras are applied from a caster(=player) to a vehicle.
7554 * This has been verified using spell #49256
7556 void Aura::HandleAuraControlVehicle(bool apply, bool Real)
7558 if(!Real)
7559 return;
7561 Unit *player = GetCaster();
7562 Vehicle *vehicle = dynamic_cast<Vehicle*>(m_target);
7563 if(!player || player->GetTypeId() != TYPEID_PLAYER || !vehicle)
7564 return;
7566 if (apply)
7568 if(Pet *pet = player->GetPet())
7569 pet->Remove(PET_SAVE_AS_CURRENT);
7570 ((Player*)player)->EnterVehicle(vehicle);
7572 else
7574 SpellEntry const *spell = GetSpellProto();
7576 // some SPELL_AURA_CONTROL_VEHICLE auras have a dummy effect on the player - remove them
7577 player->RemoveAurasDueToSpell(spell->Id);
7579 ((Player*)player)->ExitVehicle(vehicle);
7583 void Aura::HandleAuraConvertRune(bool apply, bool Real)
7585 if(!Real)
7586 return;
7588 if(m_target->GetTypeId() != TYPEID_PLAYER)
7589 return;
7591 Player *plr = (Player*)m_target;
7593 if(plr->getClass() != CLASS_DEATH_KNIGHT)
7594 return;
7596 // how to determine what rune need to be converted?
7597 for(uint32 i = 0; i < MAX_RUNES; ++i)
7599 if(apply)
7601 if(!plr->GetRuneCooldown(i))
7603 plr->ConvertRune(i, RuneType(GetSpellProto()->EffectMiscValueB[m_effIndex]));
7604 break;
7607 else
7609 if(plr->GetCurrentRune(i) == RuneType(GetSpellProto()->EffectMiscValueB[m_effIndex]))
7611 plr->ConvertRune(i, plr->GetBaseRune(i));
7612 break;
7618 void Aura::HandlePhase(bool apply, bool Real)
7620 if(!Real)
7621 return;
7623 // always non stackable
7624 if(apply)
7626 Unit::AuraList const& phases = m_target->GetAurasByType(SPELL_AURA_PHASE);
7627 if(!phases.empty())
7628 m_target->RemoveAurasDueToSpell(phases.front()->GetId(), this);
7631 // no-phase is also phase state so same code for apply and remove
7633 // phase auras normally not expected at BG but anyway better check
7634 if(m_target->GetTypeId() == TYPEID_PLAYER)
7636 // drop flag at invisible in bg
7637 if(((Player*)m_target)->InBattleGround())
7638 if(BattleGround *bg = ((Player*)m_target)->GetBattleGround())
7639 bg->EventPlayerDroppedFlag((Player*)m_target);
7641 // GM-mode have mask 0xFFFFFFFF
7642 if(!((Player*)m_target)->isGameMaster())
7643 m_target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL, false);
7645 ((Player*)m_target)->GetSession()->SendSetPhaseShift(apply ? GetMiscValue() : PHASEMASK_NORMAL);
7647 if(GetEffIndex()==0)
7649 SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAuraMapBounds(GetId());
7650 if(saBounds.first != saBounds.second)
7652 uint32 zone, area;
7653 m_target->GetZoneAndAreaId(zone, area);
7655 for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
7657 // some auras remove at aura remove
7658 if(!itr->second->IsFitToRequirements((Player*)m_target, zone, area))
7659 m_target->RemoveAurasDueToSpell(itr->second->spellId);
7660 // some auras applied at aura apply
7661 else if(itr->second->autocast)
7663 if( !m_target->HasAura(itr->second->spellId, 0) )
7664 m_target->CastSpell(m_target, itr->second->spellId, true);
7670 else
7671 m_target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL, false);
7673 // need triggering visibility update base at phase update of not GM invisible (other GMs anyway see in any phases)
7674 if(m_target->GetVisibility() != VISIBILITY_OFF)
7675 m_target->SetVisibility(m_target->GetVisibility());
7678 void Aura::UnregisterSingleCastAura()
7680 if (IsSingleTarget())
7682 if(Unit* caster = GetCaster())
7684 caster->GetSingleCastAuras().remove(this);
7686 else
7688 sLog.outError("Couldn't find the caster of the single target aura (SpellId %u), may crash later!", GetId());
7689 assert(false);
7691 m_isSingleTargetAura = false;
7695 void Aura::HandleAuraSafeFall( bool Apply, bool Real )
7697 // implemented in WorldSession::HandleMovementOpcodes
7699 // only special case
7700 if(Apply && Real && GetId() == 32474 && m_target->GetTypeId() == TYPEID_PLAYER)
7701 ((Player*)m_target)->ActivateTaxiPathTo(506, GetId());
7704 bool Aura::IsCritFromAbilityAura(Unit* caster, uint32& damage)
7706 Unit::AuraList const& auras = caster->GetAurasByType(SPELL_AURA_ABILITY_PERIODIC_CRIT);
7707 for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
7709 if (!(*itr)->isAffectedOnSpell(m_spellProto))
7710 continue;
7711 if (!caster->isSpellCrit(m_target, m_spellProto, GetSpellSchoolMask(m_spellProto)))
7712 break;
7714 damage = caster->SpellCriticalDamageBonus(m_spellProto, damage, m_target);
7715 return true;
7717 return false;
7720 void Aura::HandleModTargetArmorPct(bool apply, bool Real)
7722 if(m_target->GetTypeId() != TYPEID_PLAYER)
7723 return;
7725 ((Player*)m_target)->UpdateArmorPenetration();
7728 void Aura::HandleAuraModAllCritChance(bool apply, bool Real)
7730 // spells required only Real aura add/remove
7731 if(!Real)
7732 return;
7734 if(m_target->GetTypeId() != TYPEID_PLAYER)
7735 return;
7737 ((Player*)m_target)->HandleBaseModValue(CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
7738 ((Player*)m_target)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
7739 ((Player*)m_target)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
7741 // included in Player::UpdateSpellCritChance calculation
7742 ((Player*)m_target)->UpdateAllSpellCritChances();
7745 void Aura::HandleAllowOnlyAbility(bool apply, bool Real)
7747 if(!Real)
7748 return;
7750 if(apply)
7752 m_target->setAttackTimer(BASE_ATTACK,m_duration);
7753 m_target->setAttackTimer(RANGED_ATTACK,m_duration);
7754 m_target->setAttackTimer(OFF_ATTACK,m_duration);
7756 else
7758 m_target->resetAttackTimer(BASE_ATTACK);
7759 m_target->resetAttackTimer(RANGED_ATTACK);
7760 m_target->resetAttackTimer(OFF_ATTACK);
7763 m_target->UpdateDamagePhysical(BASE_ATTACK);
7764 m_target->UpdateDamagePhysical(RANGED_ATTACK);
7765 m_target->UpdateDamagePhysical(OFF_ATTACK);