Fixed mangos.sql data for branch and partly related code.
[getmangos.git] / src / game / SpellAuras.cpp
blob376aa0d0caa0a0f63f763d95e667f76726e0576a
1 /*
2 * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "Common.h"
20 #include "Database/DatabaseEnv.h"
21 #include "WorldPacket.h"
22 #include "WorldSession.h"
23 #include "Opcodes.h"
24 #include "Log.h"
25 #include "UpdateMask.h"
26 #include "World.h"
27 #include "ObjectMgr.h"
28 #include "SpellMgr.h"
29 #include "Player.h"
30 #include "Unit.h"
31 #include "Spell.h"
32 #include "DynamicObject.h"
33 #include "Group.h"
34 #include "UpdateData.h"
35 #include "ObjectAccessor.h"
36 #include "Policies/SingletonImp.h"
37 #include "Totem.h"
38 #include "Creature.h"
39 #include "Formulas.h"
40 #include "BattleGround.h"
41 #include "CreatureAI.h"
42 #include "ScriptCalls.h"
43 #include "Util.h"
44 #include "GridNotifiers.h"
45 #include "GridNotifiersImpl.h"
46 #include "Vehicle.h"
47 #include "CellImpl.h"
49 #define NULL_AURA_SLOT 0xFF
51 pAuraHandler AuraHandler[TOTAL_AURAS]=
53 &Aura::HandleNULL, // 0 SPELL_AURA_NONE
54 &Aura::HandleBindSight, // 1 SPELL_AURA_BIND_SIGHT
55 &Aura::HandleModPossess, // 2 SPELL_AURA_MOD_POSSESS
56 &Aura::HandlePeriodicDamage, // 3 SPELL_AURA_PERIODIC_DAMAGE
57 &Aura::HandleAuraDummy, // 4 SPELL_AURA_DUMMY
58 &Aura::HandleModConfuse, // 5 SPELL_AURA_MOD_CONFUSE
59 &Aura::HandleModCharm, // 6 SPELL_AURA_MOD_CHARM
60 &Aura::HandleModFear, // 7 SPELL_AURA_MOD_FEAR
61 &Aura::HandlePeriodicHeal, // 8 SPELL_AURA_PERIODIC_HEAL
62 &Aura::HandleModAttackSpeed, // 9 SPELL_AURA_MOD_ATTACKSPEED
63 &Aura::HandleModThreat, // 10 SPELL_AURA_MOD_THREAT
64 &Aura::HandleModTaunt, // 11 SPELL_AURA_MOD_TAUNT
65 &Aura::HandleAuraModStun, // 12 SPELL_AURA_MOD_STUN
66 &Aura::HandleModDamageDone, // 13 SPELL_AURA_MOD_DAMAGE_DONE
67 &Aura::HandleNoImmediateEffect, // 14 SPELL_AURA_MOD_DAMAGE_TAKEN implemented in Unit::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 implemented in Unit::CalculateMeleeDamage and Unit::SpellCriticalDamageBonus
217 &Aura::HandleUnused, //164 unused (3.0.8a-3.2.2a), only one test spell 10654
218 &Aura::HandleNoImmediateEffect, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::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
360 &Aura::HandleNULL, //307 absorb healing?
361 &Aura::HandleNULL, //308 new aura for hunter traps
362 &Aura::HandleNULL, //309 absorb healing?
363 &Aura::HandleNULL, //310 pet avoidance passive?
364 &Aura::HandleNULL, //311 0 spells in 3.3
365 &Aura::HandleNULL, //312 0 spells in 3.3
366 &Aura::HandleNULL, //313 0 spells in 3.3
367 &Aura::HandleNULL, //314 1 test spell (reduce duration of silince/magic)
368 &Aura::HandleNULL, //315 underwater walking
369 &Aura::HandleNULL //316 makes haste affect HOT/DOT ticks
372 static AuraType const frozenAuraTypes[] = { SPELL_AURA_MOD_ROOT, SPELL_AURA_MOD_STUN, SPELL_AURA_NONE };
374 Aura::Aura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) :
375 m_spellmod(NULL), m_caster_guid(0), m_target(target), m_castItemGuid(castItem?castItem->GetGUID():0),
376 m_timeCla(1000), m_periodicTimer(0), m_periodicTick(0), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE),
377 m_effIndex(eff), m_auraSlot(MAX_AURAS), m_auraFlags(AFLAG_NONE), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),
378 m_positive(false), m_permanent(false), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false),
379 m_isRemovedOnShapeLost(true), m_in_use(0), m_deleted(false)
381 assert(target);
383 assert(spellproto && spellproto == sSpellStore.LookupEntry( spellproto->Id ) && "`info` must be pointer to sSpellStore element");
385 m_spellProto = spellproto;
387 m_currentBasePoints = currentBasePoints ? *currentBasePoints : m_spellProto->EffectBasePoints[eff];
389 m_isPassive = IsPassiveSpell(GetId());
390 m_positive = IsPositiveEffect(GetId(), m_effIndex);
392 m_isSingleTargetAura = IsSingleTargetSpell(m_spellProto);
394 m_applyTime = time(NULL);
396 int32 damage;
397 if(!caster)
399 m_caster_guid = target->GetGUID();
400 damage = m_currentBasePoints+1; // stored value-1
401 m_maxduration = target->CalculateSpellDuration(m_spellProto, m_effIndex, target);
403 else
405 m_caster_guid = caster->GetGUID();
407 damage = caster->CalculateSpellDamage(m_spellProto,m_effIndex,m_currentBasePoints,target);
408 m_maxduration = caster->CalculateSpellDuration(m_spellProto, m_effIndex, target);
410 if (!damage && castItem && castItem->GetItemSuffixFactor())
412 ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(castItem->GetItemRandomPropertyId()));
413 if(item_rand_suffix)
415 for (int k = 0; k < 3; ++k)
417 SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(item_rand_suffix->enchant_id[k]);
418 if(pEnchant)
420 for (int t = 0; t < 3; ++t)
421 if(pEnchant->spellid[t] == m_spellProto->Id)
423 damage = uint32((item_rand_suffix->prefix[k]*castItem->GetItemSuffixFactor()) / 10000 );
424 break;
428 if(damage)
429 break;
435 if(m_maxduration == -1 || m_isPassive && m_spellProto->DurationIndex == 0)
436 m_permanent = true;
438 Player* modOwner = caster ? caster->GetSpellModOwner() : NULL;
440 if(!m_permanent && modOwner)
442 modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, m_maxduration);
443 // Get zero duration aura after - need set m_maxduration > 0 for apply/remove aura work
444 if (m_maxduration<=0)
445 m_maxduration = 1;
448 m_duration = m_maxduration;
450 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);
452 m_effIndex = eff;
453 SetModifier(AuraType(m_spellProto->EffectApplyAuraName[eff]), damage, m_spellProto->EffectAmplitude[eff], m_spellProto->EffectMiscValue[eff]);
455 // Apply periodic time mod
456 if(modOwner && m_modifier.periodictime)
457 modOwner->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME, m_modifier.periodictime);
459 // Start periodic on next tick or at aura apply
460 if (!(m_spellProto->AttributesEx5 & SPELL_ATTR_EX5_START_PERIODIC_AT_APPLY))
461 m_periodicTimer += m_modifier.periodictime;
463 m_isDeathPersist = IsDeathPersistentSpell(m_spellProto);
465 m_procCharges = m_spellProto->procCharges;
466 if(modOwner)
467 modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges);
469 m_isRemovedOnShapeLost = (m_caster_guid==m_target->GetGUID() &&
470 m_spellProto->Stances &&
471 !(m_spellProto->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT) &&
472 !(m_spellProto->Attributes & SPELL_ATTR_NOT_SHAPESHIFT));
474 if (caster && m_spellProto->Id == 22959) // Improved Scorch
476 // Glyph of Improved Scorch
477 if (Aura* glyph = caster->GetDummyAura(56371))
478 m_stackAmount = glyph->GetModifier()->m_amount;
482 Aura::~Aura()
486 AreaAura::AreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target,
487 Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
489 m_isAreaAura = true;
491 // caster==NULL in constructor args if target==caster in fact
492 Unit* caster_ptr = caster ? caster : target;
494 m_radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(GetSpellProto()->EffectRadiusIndex[m_effIndex]));
495 if(Player* modOwner = caster_ptr->GetSpellModOwner())
496 modOwner->ApplySpellMod(GetId(), SPELLMOD_RADIUS, m_radius);
498 switch(spellproto->Effect[eff])
500 case SPELL_EFFECT_APPLY_AREA_AURA_PARTY:
501 m_areaAuraType = AREA_AURA_PARTY;
502 if (target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isTotem())
503 m_modifier.m_auraname = SPELL_AURA_NONE;
504 break;
505 case SPELL_EFFECT_APPLY_AREA_AURA_RAID:
506 m_areaAuraType = AREA_AURA_RAID;
507 if (target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isTotem())
508 m_modifier.m_auraname = SPELL_AURA_NONE;
509 // Light's Beacon not applied to caster itself (TODO: more generic check for another simialr spell if any?)
510 else if (target == caster_ptr && m_spellProto->Id == 53651)
511 m_modifier.m_auraname = SPELL_AURA_NONE;
512 break;
513 case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND:
514 m_areaAuraType = AREA_AURA_FRIEND;
515 break;
516 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY:
517 m_areaAuraType = AREA_AURA_ENEMY;
518 if (target == caster_ptr)
519 m_modifier.m_auraname = SPELL_AURA_NONE; // Do not do any effect on self
520 break;
521 case SPELL_EFFECT_APPLY_AREA_AURA_PET:
522 m_areaAuraType = AREA_AURA_PET;
523 break;
524 case SPELL_EFFECT_APPLY_AREA_AURA_OWNER:
525 m_areaAuraType = AREA_AURA_OWNER;
526 if (target == caster_ptr)
527 m_modifier.m_auraname = SPELL_AURA_NONE;
528 break;
529 default:
530 sLog.outError("Wrong spell effect in AreaAura constructor");
531 ASSERT(false);
532 break;
536 AreaAura::~AreaAura()
540 PersistentAreaAura::PersistentAreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target,
541 Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
543 m_isPersistent = true;
546 PersistentAreaAura::~PersistentAreaAura()
550 SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target,
551 Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
553 if (caster)
554 m_casters_target_guid = caster->GetTypeId()==TYPEID_PLAYER ? ((Player*)caster)->GetSelection() : caster->GetTargetGUID();
555 else
556 m_casters_target_guid = 0;
559 SingleEnemyTargetAura::~SingleEnemyTargetAura()
563 Unit* SingleEnemyTargetAura::GetTriggerTarget() const
565 return ObjectAccessor::GetUnit(*m_target, m_casters_target_guid);
568 Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem)
570 if (IsAreaAuraEffect(spellproto->Effect[eff]))
571 return new AreaAura(spellproto, eff, currentBasePoints, target, caster, castItem);
573 uint32 triggeredSpellId = spellproto->EffectTriggerSpell[eff];
575 if(SpellEntry const* triggeredSpellInfo = sSpellStore.LookupEntry(triggeredSpellId))
576 for (int i = 0; i < 3; ++i)
577 if (triggeredSpellInfo->EffectImplicitTargetA[i] == TARGET_SINGLE_ENEMY)
578 return new SingleEnemyTargetAura(spellproto, eff, currentBasePoints, target, caster, castItem);
580 return new Aura(spellproto, eff, currentBasePoints, target, caster, castItem);
583 Unit* Aura::GetCaster() const
585 if(m_caster_guid == m_target->GetGUID())
586 return m_target;
588 //return ObjectAccessor::GetUnit(*m_target,m_caster_guid);
589 //must return caster even if it's in another grid/map
590 Unit *unit = ObjectAccessor::GetUnitInWorld(*m_target,m_caster_guid);
591 return unit && unit->IsInWorld() ? unit : NULL;
594 void Aura::SetModifier(AuraType t, int32 a, uint32 pt, int32 miscValue)
596 m_modifier.m_auraname = t;
597 m_modifier.m_amount = a;
598 m_modifier.m_miscvalue = miscValue;
599 m_modifier.periodictime = pt;
602 void Aura::Update(uint32 diff)
604 if (m_duration > 0)
606 m_duration -= diff;
607 if (m_duration < 0)
608 m_duration = 0;
609 m_timeCla -= diff;
611 // GetEffIndex()==0 prevent double/triple apply manaPerSecond/manaPerSecondPerLevel to same spell with many auras
612 // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0
613 if(GetEffIndex()==0 && m_timeCla <= 0)
615 if(Unit* caster = GetCaster())
617 Powers powertype = Powers(m_spellProto->powerType);
618 int32 manaPerSecond = m_spellProto->manaPerSecond + m_spellProto->manaPerSecondPerLevel * caster->getLevel();
619 m_timeCla = 1*IN_MILISECONDS;
620 if (manaPerSecond)
622 if(powertype==POWER_HEALTH)
623 caster->ModifyHealth(-manaPerSecond);
624 else
625 caster->ModifyPower(powertype,-manaPerSecond);
631 // Channeled aura required check distance from caster
632 if(IsChanneledSpell(m_spellProto) && m_caster_guid != m_target->GetGUID())
634 Unit* caster = GetCaster();
635 if(!caster)
637 m_target->RemoveAura(GetId(), GetEffIndex());
638 return;
641 // need check distance for channeled target only
642 if (caster->GetChannelObjectGUID() == m_target->GetGUID())
644 // Get spell range
645 float max_range = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellProto->rangeIndex));
647 if(Player* modOwner = caster->GetSpellModOwner())
648 modOwner->ApplySpellMod(GetId(), SPELLMOD_RANGE, max_range, NULL);
650 if(!caster->IsWithinDistInMap(m_target, max_range))
652 m_target->RemoveAura(GetId(), GetEffIndex());
653 return;
658 if(m_isPeriodic && (m_duration >= 0 || m_isPassive || m_permanent))
660 m_periodicTimer -= diff;
661 if(m_periodicTimer <= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N
663 // update before applying (aura can be removed in TriggerSpell or PeriodicTick calls)
664 m_periodicTimer += m_modifier.periodictime;
665 ++m_periodicTick; // for some infinity auras in some cases can overflow and reset
666 PeriodicTick();
671 void AreaAura::Update(uint32 diff)
673 // update for the caster of the aura
674 if(m_caster_guid == m_target->GetGUID())
676 Unit* caster = m_target;
678 if( !caster->hasUnitState(UNIT_STAT_ISOLATED) )
680 Unit* owner = caster->GetCharmerOrOwner();
681 if (!owner)
682 owner = caster;
683 std::list<Unit *> targets;
685 switch(m_areaAuraType)
687 case AREA_AURA_PARTY:
689 Group *pGroup = NULL;
691 if (owner->GetTypeId() == TYPEID_PLAYER)
692 pGroup = ((Player*)owner)->GetGroup();
694 if( pGroup)
696 uint8 subgroup = ((Player*)owner)->GetSubGroup();
697 for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
699 Player* Target = itr->getSource();
700 if(Target && Target->isAlive() && Target->GetSubGroup()==subgroup && caster->IsFriendlyTo(Target))
702 if(caster->IsWithinDistInMap(Target, m_radius))
703 targets.push_back(Target);
704 Pet *pet = Target->GetPet();
705 if(pet && pet->isAlive() && caster->IsWithinDistInMap(pet, m_radius))
706 targets.push_back(pet);
710 else
712 // add owner
713 if( owner != caster && caster->IsWithinDistInMap(owner, m_radius) )
714 targets.push_back(owner);
715 // add caster's pet
716 Unit* pet = caster->GetPet();
717 if( pet && caster->IsWithinDistInMap(pet, m_radius))
718 targets.push_back(pet);
720 break;
722 case AREA_AURA_RAID:
724 Group *pGroup = NULL;
726 if (owner->GetTypeId() == TYPEID_PLAYER)
727 pGroup = ((Player*)owner)->GetGroup();
729 if( pGroup)
731 for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
733 Player* Target = itr->getSource();
734 if(Target && Target->isAlive() && caster->IsFriendlyTo(Target))
736 if(caster->IsWithinDistInMap(Target, m_radius))
737 targets.push_back(Target);
738 Pet *pet = Target->GetPet();
739 if(pet && pet->isAlive() && caster->IsWithinDistInMap(pet, m_radius))
740 targets.push_back(pet);
744 else
746 // add owner
747 if( owner != caster && caster->IsWithinDistInMap(owner, m_radius) )
748 targets.push_back(owner);
749 // add caster's pet
750 Unit* pet = caster->GetPet();
751 if( pet && caster->IsWithinDistInMap(pet, m_radius))
752 targets.push_back(pet);
754 break;
756 case AREA_AURA_FRIEND:
758 CellPair p(MaNGOS::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY()));
759 Cell cell(p);
760 cell.data.Part.reserved = ALL_DISTRICT;
761 cell.SetNoCreate();
763 MaNGOS::AnyFriendlyUnitInObjectRangeCheck u_check(caster, owner, m_radius);
764 MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck> searcher(caster,targets, u_check);
765 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
766 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
767 CellLock<GridReadGuard> cell_lock(cell, p);
768 cell_lock->Visit(cell_lock, world_unit_searcher, *caster->GetMap(), *caster, m_radius);
769 cell_lock->Visit(cell_lock, grid_unit_searcher, *caster->GetMap(), *caster, m_radius);
770 break;
772 case AREA_AURA_ENEMY:
774 CellPair p(MaNGOS::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY()));
775 Cell cell(p);
776 cell.data.Part.reserved = ALL_DISTRICT;
777 cell.SetNoCreate();
779 MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(caster, owner, m_radius); // No GetCharmer in searcher
780 MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(caster, targets, u_check);
781 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
782 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
783 CellLock<GridReadGuard> cell_lock(cell, p);
784 cell_lock->Visit(cell_lock, world_unit_searcher, *caster->GetMap(), *caster, m_radius);
785 cell_lock->Visit(cell_lock, grid_unit_searcher, *caster->GetMap(), *caster, m_radius);
786 break;
788 case AREA_AURA_OWNER:
789 case AREA_AURA_PET:
791 if(owner != caster && caster->IsWithinDistInMap(owner, m_radius))
792 targets.push_back(owner);
793 break;
797 for(std::list<Unit *>::iterator tIter = targets.begin(); tIter != targets.end(); tIter++)
799 // flag for seelction is need apply aura to current iteration target
800 bool apply = true;
802 // we need ignore present caster self applied are auras sometime
803 // in cases if this only auras applied for spell effect
804 Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), m_effIndex);
805 for(Unit::AuraMap::const_iterator i = (*tIter)->GetAuras().lower_bound(spair); i != (*tIter)->GetAuras().upper_bound(spair); ++i)
807 if (i->second->IsDeleted())
808 continue;
810 switch(m_areaAuraType)
812 case AREA_AURA_ENEMY:
813 // non caster self-casted auras (non stacked)
814 if(i->second->GetModifier()->m_auraname != SPELL_AURA_NONE)
815 apply = false;
816 break;
817 case AREA_AURA_RAID:
818 // non caster self-casted auras (stacked from diff. casters)
819 if(i->second->GetModifier()->m_auraname != SPELL_AURA_NONE || i->second->GetCasterGUID() == GetCasterGUID())
820 apply = false;
821 break;
822 default:
823 // in generic case not allow stacking area auras
824 apply = false;
825 break;
828 if(!apply)
829 break;
832 if(!apply)
833 continue;
835 if(SpellEntry const *actualSpellInfo = sSpellMgr.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter)->getLevel()))
837 int32 actualBasePoints = m_currentBasePoints;
838 // recalculate basepoints for lower rank (all AreaAura spell not use custom basepoints?)
839 if(actualSpellInfo != GetSpellProto())
840 actualBasePoints = actualSpellInfo->EffectBasePoints[m_effIndex];
841 AreaAura *aur = new AreaAura(actualSpellInfo, m_effIndex, &actualBasePoints, (*tIter), caster, NULL);
842 aur->SetAuraDuration(GetAuraDuration());
843 (*tIter)->AddAura(aur);
847 Aura::Update(diff);
849 else // aura at non-caster
851 Unit* caster = GetCaster();
853 Aura::Update(diff);
855 // remove aura if out-of-range from caster (after teleport for example)
856 // or caster is isolated or caster no longer has the aura
857 // or caster is (no longer) friendly
858 bool needFriendly = (m_areaAuraType == AREA_AURA_ENEMY ? false : true);
859 if( !caster || caster->hasUnitState(UNIT_STAT_ISOLATED) ||
860 !caster->IsWithinDistInMap(m_target, m_radius) ||
861 !caster->HasAura(GetId(), GetEffIndex()) ||
862 caster->IsFriendlyTo(m_target) != needFriendly
865 m_target->RemoveAurasByCasterSpell(GetId(), GetEffIndex(),GetCasterGUID());
867 else if( m_areaAuraType == AREA_AURA_PARTY) // check if in same sub group
869 // not check group if target == owner or target == pet
870 if (caster->GetCharmerOrOwnerGUID() != m_target->GetGUID() && caster->GetGUID() != m_target->GetCharmerOrOwnerGUID())
872 Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself();
874 Group *pGroup = check ? check->GetGroup() : NULL;
875 if( pGroup )
877 Player* checkTarget = m_target->GetCharmerOrOwnerPlayerOrPlayerItself();
878 if(!checkTarget || !pGroup->SameSubGroup(check, checkTarget))
879 m_target->RemoveAura(GetId(), GetEffIndex());
881 else
882 m_target->RemoveAura(GetId(), GetEffIndex());
885 else if( m_areaAuraType == AREA_AURA_RAID) // TODO: fix me!
887 // not check group if target == owner or target == pet
888 if (caster->GetCharmerOrOwnerGUID() != m_target->GetGUID() && caster->GetGUID() != m_target->GetCharmerOrOwnerGUID())
890 Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself();
892 Group *pGroup = check ? check->GetGroup() : NULL;
893 if( pGroup )
895 Player* checkTarget = m_target->GetCharmerOrOwnerPlayerOrPlayerItself();
896 if(!checkTarget)
897 m_target->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
899 else
900 m_target->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
903 else if( m_areaAuraType == AREA_AURA_PET || m_areaAuraType == AREA_AURA_OWNER )
905 if( m_target->GetGUID() != caster->GetCharmerOrOwnerGUID() )
906 m_target->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
911 void PersistentAreaAura::Update(uint32 diff)
913 bool remove = false;
915 // remove the aura if its caster or the dynamic object causing it was removed
916 // or if the target moves too far from the dynamic object
917 if(Unit *caster = GetCaster())
919 DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex());
920 if (dynObj)
922 if (!m_target->IsWithinDistInMap(dynObj, dynObj->GetRadius()))
923 remove = true;
925 else
926 remove = true;
928 else
929 remove = true;
931 Aura::Update(diff);
933 if(remove)
934 m_target->RemoveAura(GetId(), GetEffIndex());
937 void Aura::ApplyModifier(bool apply, bool Real)
939 AuraType aura = m_modifier.m_auraname;
941 SetInUse(true);
942 if(aura < TOTAL_AURAS)
943 (*this.*AuraHandler [aura])(apply, Real);
944 SetInUse(false);
947 bool Aura::IsNeedVisibleSlot(Unit const* caster) const
949 bool totemAura = caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem();
951 // passive auras (except totem auras) do not get placed in the slots
952 if (m_isPassive && !totemAura)
953 return false;
955 // generic not caster case
956 if (m_target != caster)
957 return true;
959 // special area auras case at caster
960 switch(m_spellProto->Effect[GetEffIndex()])
962 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY:
963 return false;
964 case SPELL_EFFECT_APPLY_AREA_AURA_RAID:
965 // not sure is totemAura need, just preserve old code results
966 return totemAura || m_modifier.m_auraname != SPELL_AURA_NONE;
967 default: break;
970 return true;
973 void Aura::_AddAura()
975 if (!GetId())
976 return;
977 if(!m_target)
978 return;
980 // Second aura if some spell
981 bool secondaura = false;
982 // Try find slot for aura
983 uint8 slot = NULL_AURA_SLOT;
984 // Lookup for some spell auras (and get slot from it)
985 for(uint8 i = 0; i < m_effIndex; ++i)
987 Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), i);
988 for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr)
990 // allow use single slot only by auras from same caster
991 if(itr->second->GetCasterGUID()==GetCasterGUID())
993 slot = itr->second->GetAuraSlot();
994 secondaura = true;
995 break;
998 if (secondaura)
999 break;
1001 // Lookup free slot
1002 if (!secondaura && m_target->GetVisibleAurasCount() < MAX_AURAS)
1004 Unit::VisibleAuraMap const *visibleAuras = m_target->GetVisibleAuras();
1005 for(uint8 i = 0; i < MAX_AURAS; ++i)
1007 Unit::VisibleAuraMap::const_iterator itr = visibleAuras->find(i);
1008 if(itr == visibleAuras->end())
1010 slot = i;
1011 // update for out of range group members (on 1 slot use)
1012 m_target->UpdateAuraForGroup(slot);
1013 break;
1018 Unit* caster = GetCaster();
1020 // set infinity cooldown state for spells
1021 if(caster && caster->GetTypeId() == TYPEID_PLAYER)
1023 if (m_spellProto->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE)
1025 Item* castItem = m_castItemGuid ? ((Player*)caster)->GetItemByGuid(m_castItemGuid) : NULL;
1026 ((Player*)caster)->AddSpellAndCategoryCooldowns(m_spellProto,castItem ? castItem->GetEntry() : 0, NULL,true);
1030 if (IsNeedVisibleSlot(caster))
1032 SetAuraSlot( slot );
1033 if(slot < MAX_AURAS) // slot found send data to client
1035 SetAura(false);
1036 SetAuraFlags((1 << GetEffIndex()) | AFLAG_NOT_CASTER | ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION : AFLAG_NONE) | (IsPositive() ? AFLAG_POSITIVE : AFLAG_NEGATIVE));
1037 SetAuraLevel(caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
1038 SendAuraUpdate(false);
1041 //*****************************************************
1042 // Update target aura state flag (at 1 aura apply)
1043 // TODO: Make it easer
1044 //*****************************************************
1045 if (!secondaura)
1047 // Sitdown on apply aura req seated
1048 if (m_spellProto->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED && !m_target->IsSitState())
1049 m_target->SetStandState(UNIT_STAND_STATE_SIT);
1051 // register aura diminishing on apply
1052 if (getDiminishGroup() != DIMINISHING_NONE )
1053 m_target->ApplyDiminishingAura(getDiminishGroup(), true);
1055 // Update Seals information
1056 if (IsSealSpell(m_spellProto))
1057 m_target->ModifyAuraState(AURA_STATE_JUDGEMENT, true);
1059 // Conflagrate aura state on Immolate and Shadowflame
1060 if (m_spellProto->SpellFamilyName == SPELLFAMILY_WARLOCK &&
1061 // Immolate
1062 ((m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000004)) ||
1063 // Shadowflame
1064 (m_spellProto->SpellFamilyFlags2 & 0x00000002)))
1065 m_target->ModifyAuraState(AURA_STATE_CONFLAGRATE, true);
1067 // Faerie Fire (druid versions)
1068 if (m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000400)))
1069 m_target->ModifyAuraState(AURA_STATE_FAERIE_FIRE, true);
1071 // Victorious
1072 if (m_spellProto->SpellFamilyName == SPELLFAMILY_WARRIOR && (m_spellProto->SpellFamilyFlags & UI64LIT(0x0004000000000000)))
1073 m_target->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH, true);
1075 // Swiftmend state on Regrowth & Rejuvenation
1076 if (m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && (m_spellProto->SpellFamilyFlags & UI64LIT(0x50)))
1077 m_target->ModifyAuraState(AURA_STATE_SWIFTMEND, true);
1079 // Deadly poison aura state
1080 if(m_spellProto->SpellFamilyName == SPELLFAMILY_ROGUE && (m_spellProto->SpellFamilyFlags & UI64LIT(0x10000)))
1081 m_target->ModifyAuraState(AURA_STATE_DEADLY_POISON, true);
1083 // Enrage aura state
1084 if(m_spellProto->Dispel == DISPEL_ENRAGE)
1085 m_target->ModifyAuraState(AURA_STATE_ENRAGE, true);
1090 bool Aura::_RemoveAura()
1092 // Remove all triggered by aura spells vs unlimited duration
1093 // except same aura replace case
1094 if(m_removeMode!=AURA_REMOVE_BY_STACK)
1095 CleanupTriggeredSpells();
1097 Unit* caster = GetCaster();
1099 if(caster && IsPersistent())
1101 DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex());
1102 if (dynObj)
1103 dynObj->RemoveAffected(m_target);
1106 //passive auras do not get put in slots
1107 // Note: but totem can be not accessible for aura target in time remove (to far for find in grid)
1108 //if(m_isPassive && !(caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem()))
1109 // return;
1111 uint8 slot = GetAuraSlot();
1113 if(slot >= MAX_AURAS) // slot not set
1114 return false;
1116 if(m_target->GetVisibleAura(slot) == 0)
1117 return false;
1119 bool lastaura = true;
1121 // find other aura in same slot (current already removed from list)
1122 for(uint8 i = 0; i < 3; ++i)
1124 Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), i);
1125 for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr)
1127 if(itr->second->GetAuraSlot() == slot)
1129 lastaura = false;
1130 break;
1133 if(!lastaura)
1134 break;
1137 // only remove icon when the last aura of the spell is removed (current aura already removed from list)
1138 if (!lastaura)
1139 return false;
1141 // unregister aura diminishing (and store last time)
1142 if (getDiminishGroup() != DIMINISHING_NONE )
1143 m_target->ApplyDiminishingAura(getDiminishGroup(), false);
1145 SetAura(true);
1146 SetAuraFlags(AFLAG_NONE);
1147 SetAuraLevel(0);
1149 if (m_removeMode != AURA_REMOVE_BY_DELETE)
1151 SendAuraUpdate(true);
1153 // update for out of range group members
1154 m_target->UpdateAuraForGroup(slot);
1156 //*****************************************************
1157 // Update target aura state flag (at last aura remove)
1158 //*****************************************************
1159 // Enrage aura state
1160 if(m_spellProto->Dispel == DISPEL_ENRAGE)
1161 m_target->ModifyAuraState(AURA_STATE_ENRAGE, false);
1163 uint32 removeState = 0;
1164 uint64 removeFamilyFlag = m_spellProto->SpellFamilyFlags;
1165 uint32 removeFamilyFlag2 = m_spellProto->SpellFamilyFlags2;
1166 switch(m_spellProto->SpellFamilyName)
1168 case SPELLFAMILY_PALADIN:
1169 if (IsSealSpell(m_spellProto))
1170 removeState = AURA_STATE_JUDGEMENT; // Update Seals information
1171 break;
1172 case SPELLFAMILY_WARLOCK:
1173 // Conflagrate aura state on Immolate and Shadowflame,
1174 if ((m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000004)) ||
1175 (m_spellProto->SpellFamilyFlags2 & 0x00000002))
1177 removeFamilyFlag = UI64LIT(0x0000000000000004);
1178 removeFamilyFlag2 = 0x00000002;
1179 removeState = AURA_STATE_CONFLAGRATE;
1181 break;
1182 case SPELLFAMILY_DRUID:
1183 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000400))
1184 removeState = AURA_STATE_FAERIE_FIRE; // Faerie Fire (druid versions)
1185 else if(m_spellProto->SpellFamilyFlags & UI64LIT(0x50))
1187 removeFamilyFlag = 0x50;
1188 removeState = AURA_STATE_SWIFTMEND; // Swiftmend aura state
1190 break;
1191 case SPELLFAMILY_WARRIOR:
1192 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x0004000000000000))
1193 removeState = AURA_STATE_WARRIOR_VICTORY_RUSH; // Victorious
1194 break;
1195 case SPELLFAMILY_ROGUE:
1196 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x10000))
1197 removeState = AURA_STATE_DEADLY_POISON; // Deadly poison aura state
1198 break;
1199 case SPELLFAMILY_HUNTER:
1200 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x1000000000000000))
1201 removeState = AURA_STATE_FAERIE_FIRE; // Sting (hunter versions)
1204 // Remove state (but need check other auras for it)
1205 if (removeState)
1207 bool found = false;
1208 Unit::AuraMap& Auras = m_target->GetAuras();
1209 for(Unit::AuraMap::iterator i = Auras.begin(); i != Auras.end(); ++i)
1211 SpellEntry const *auraSpellInfo = (*i).second->GetSpellProto();
1212 if(auraSpellInfo->SpellFamilyName == m_spellProto->SpellFamilyName &&
1213 (auraSpellInfo->SpellFamilyFlags & removeFamilyFlag || auraSpellInfo->SpellFamilyFlags2 & removeFamilyFlag2))
1215 found = true;
1216 break;
1219 // this has been last aura
1220 if(!found)
1221 m_target->ModifyAuraState(AuraState(removeState), false);
1224 // reset cooldown state for spells
1225 if(caster && caster->GetTypeId() == TYPEID_PLAYER)
1227 if ( GetSpellProto()->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE )
1228 // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
1229 ((Player*)caster)->SendCooldownEvent(GetSpellProto());
1233 return true;
1236 void Aura::SendAuraUpdate(bool remove)
1238 WorldPacket data(SMSG_AURA_UPDATE);
1239 data.append(m_target->GetPackGUID());
1240 data << uint8(GetAuraSlot());
1241 data << uint32(remove ? 0 : GetId());
1243 if(remove)
1245 m_target->SendMessageToSet(&data, true);
1246 return;
1249 uint8 auraFlags = GetAuraFlags();
1250 data << uint8(auraFlags);
1251 data << uint8(GetAuraLevel());
1252 data << uint8(m_procCharges ? m_procCharges*m_stackAmount : m_stackAmount);
1254 if(!(auraFlags & AFLAG_NOT_CASTER))
1256 data << uint8(0); // pguid
1259 if(auraFlags & AFLAG_DURATION)
1261 data << uint32(GetAuraMaxDuration());
1262 data << uint32(GetAuraDuration());
1265 m_target->SendMessageToSet(&data, true);
1268 void Aura::SetStackAmount(uint8 stackAmount)
1270 Unit *target = GetTarget();
1271 Unit *caster = GetCaster();
1272 if (!target || !caster)
1273 return;
1275 bool refresh = stackAmount >= m_stackAmount;
1276 if (stackAmount != m_stackAmount)
1278 m_stackAmount = stackAmount;
1279 int32 amount = m_stackAmount * caster->CalculateSpellDamage(m_spellProto, m_effIndex, m_currentBasePoints, target);
1280 // Reapply if amount change
1281 if (amount!=m_modifier.m_amount)
1283 ApplyModifier(false, true);
1284 m_modifier.m_amount = amount;
1285 ApplyModifier(true, true);
1289 if (refresh)
1290 // Stack increased refresh duration
1291 RefreshAura();
1292 else
1293 // Stack decreased only send update
1294 SendAuraUpdate(false);
1297 bool Aura::modStackAmount(int32 num)
1299 // Can`t mod
1300 if (!m_spellProto->StackAmount)
1301 return true;
1303 // Modify stack but limit it
1304 int32 stackAmount = m_stackAmount + num;
1305 if (stackAmount > m_spellProto->StackAmount)
1306 stackAmount = m_spellProto->StackAmount;
1307 else if (stackAmount <=0) // Last aura from stack removed
1309 m_stackAmount = 0;
1310 return true; // need remove aura
1313 // Update stack amount
1314 SetStackAmount(stackAmount);
1315 return false;
1318 void Aura::RefreshAura()
1320 m_duration = m_maxduration;
1321 SendAuraUpdate(false);
1324 bool Aura::isAffectedOnSpell(SpellEntry const *spell) const
1326 // Check family name
1327 if (spell->SpellFamilyName != m_spellProto->SpellFamilyName)
1328 return false;
1329 // Check EffectClassMask
1330 uint32 const *ptr = getAuraSpellClassMask();
1331 if (((uint64*)ptr)[0] & spell->SpellFamilyFlags)
1332 return true;
1333 if (ptr[2] & spell->SpellFamilyFlags2)
1334 return true;
1335 return false;
1338 void Aura::ReapplyAffectedPassiveAuras( Unit* target, bool owner_mode )
1340 std::set<uint32> affectedSelf;
1341 std::set<uint32> affectedAuraCaster;
1343 for(Unit::AuraMap::const_iterator itr = target->GetAuras().begin(); itr != target->GetAuras().end(); ++itr)
1345 // permanent passive or permanent area aura
1346 // passive spells can be affected only by own or owner spell mods)
1347 if (itr->second->IsPermanent() && (owner_mode && itr->second->IsPassive() || itr->second->IsAreaAura()) &&
1348 // non deleted and not same aura (any with same spell id)
1349 !itr->second->IsDeleted() && itr->second->GetId() != GetId() &&
1350 // and affected by aura
1351 isAffectedOnSpell(itr->second->GetSpellProto()))
1353 // only applied by self or aura caster
1354 if (itr->second->GetCasterGUID() == target->GetGUID())
1355 affectedSelf.insert(itr->second->GetId());
1356 else if (itr->second->GetCasterGUID() == GetCasterGUID())
1357 affectedAuraCaster.insert(itr->second->GetId());
1361 for(std::set<uint32>::const_iterator set_itr = affectedSelf.begin(); set_itr != affectedSelf.end(); ++set_itr)
1363 target->RemoveAurasDueToSpell(*set_itr);
1364 target->CastSpell(m_target, *set_itr, true);
1367 if (!affectedAuraCaster.empty())
1369 Unit* caster = GetCaster();
1370 for(std::set<uint32>::const_iterator set_itr = affectedAuraCaster.begin(); set_itr != affectedAuraCaster.end(); ++set_itr)
1372 target->RemoveAurasDueToSpell(*set_itr);
1373 if (caster)
1374 caster->CastSpell(m_target, *set_itr, true);
1379 /*********************************************************/
1380 /*** BASIC AURA FUNCTION ***/
1381 /*********************************************************/
1382 void Aura::HandleAddModifier(bool apply, bool Real)
1384 if(m_target->GetTypeId() != TYPEID_PLAYER || !Real)
1385 return;
1387 if(m_modifier.m_miscvalue >= MAX_SPELLMOD)
1388 return;
1390 if (apply)
1392 // Add custom charges for some mod aura
1393 switch (m_spellProto->Id)
1395 case 17941: // Shadow Trance
1396 case 22008: // Netherwind Focus
1397 case 31834: // Light's Grace
1398 case 34754: // Clearcasting
1399 case 34936: // Backlash
1400 case 44401: // Missile Barrage
1401 case 48108: // Hot Streak
1402 case 51124: // Killing Machine
1403 case 54741: // Firestarter
1404 case 57761: // Fireball!
1405 case 64823: // Elune's Wrath (Balance druid t8 set
1406 SetAuraCharges(1);
1407 break;
1410 m_spellmod = new SpellModifier(
1411 SpellModOp(m_modifier.m_miscvalue),
1412 SpellModType(m_modifier.m_auraname), // SpellModType value == spell aura types
1413 m_modifier.m_amount,
1414 this,
1415 // prevent expire spell mods with (charges > 0 && m_stackAmount > 1)
1416 // all this spell expected expire not at use but at spell proc event check
1417 m_spellProto->StackAmount > 1 ? 0 : m_procCharges);
1420 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
1422 // reapply talents to own passive persistent auras
1423 ReapplyAffectedPassiveAuras(m_target, true);
1425 // re-apply talents/passives/area auras applied to pet (it affected by player spellmods)
1426 if(Pet* pet = m_target->GetPet())
1427 ReapplyAffectedPassiveAuras(pet, true);
1429 // re-apply talents/passives/area auras applied to totems (it affected by player spellmods)
1430 for(int i = 0; i < MAX_TOTEM; ++i)
1431 if(m_target->m_TotemSlot[i])
1432 if(Creature* totem = m_target->GetMap()->GetCreature(m_target->m_TotemSlot[i]))
1433 ReapplyAffectedPassiveAuras(totem, true);
1435 // re-apply talents/passives/area auras applied to group members (it affected by player spellmods)
1436 if (Group* group = ((Player*)m_target)->GetGroup())
1437 for(GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
1438 if (Player* member = itr->getSource())
1439 if (member != m_target && member->IsInMap(m_target))
1440 ReapplyAffectedPassiveAuras(member, false);
1443 void Aura::HandleAddTargetTrigger(bool apply, bool /*Real*/)
1445 // Use SpellModifier structure for check
1446 // used only fields:
1447 // spellId, mask, mask2
1448 if (apply)
1450 SpellModifier *mod = new SpellModifier;
1451 mod->spellId = GetId();
1453 uint32 const *ptr = m_spellProto->GetEffectSpellClassMask(m_effIndex);
1455 mod->mask = (uint64)ptr[0] | (uint64)ptr[1]<<32;
1456 mod->mask2= ptr[2];
1457 m_spellmod = mod;
1459 else
1461 delete m_spellmod;
1462 m_spellmod = NULL;
1466 void Aura::TriggerSpell()
1468 const uint64& casterGUID = GetCasterGUID();
1469 Unit* target = GetTriggerTarget();
1471 if(!casterGUID || !target)
1472 return;
1474 // generic casting code with custom spells and target/caster customs
1475 uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex];
1477 SpellEntry const *triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id);
1478 SpellEntry const *auraSpellInfo = GetSpellProto();
1479 uint32 auraId = auraSpellInfo->Id;
1481 // specific code for cases with no trigger spell provided in field
1482 if (triggeredSpellInfo == NULL)
1484 switch(auraSpellInfo->SpellFamilyName)
1486 case SPELLFAMILY_GENERIC:
1488 switch(auraId)
1490 // Firestone Passive (1-5 ranks)
1491 case 758:
1492 case 17945:
1493 case 17947:
1494 case 17949:
1495 case 27252:
1497 if (target->GetTypeId() != TYPEID_PLAYER)
1498 return;
1499 Item* item = ((Player*)target)->GetWeaponForAttack(BASE_ATTACK);
1500 if (!item)
1501 return;
1502 uint32 enchant_id = 0;
1503 switch (GetId())
1505 case 758: enchant_id = 1803; break; // Rank 1
1506 case 17945: enchant_id = 1823; break; // Rank 2
1507 case 17947: enchant_id = 1824; break; // Rank 3
1508 case 17949: enchant_id = 1825; break; // Rank 4
1509 case 27252: enchant_id = 2645; break; // Rank 5
1510 default:
1511 return;
1513 // remove old enchanting before applying new
1514 ((Player*)target)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,false);
1515 item->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, m_modifier.periodictime+1000, 0);
1516 // add new enchanting
1517 ((Player*)target)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,true);
1518 return;
1520 // // Periodic Mana Burn
1521 // case 812: break;
1522 // // Polymorphic Ray
1523 // case 6965: break;
1524 // Thaumaturgy Channel
1525 case 9712: trigger_spell_id = 21029; break;
1526 // // Egan's Blaster
1527 // case 17368: break;
1528 // // Haunted
1529 // case 18347: break;
1530 // // Ranshalla Waiting
1531 // case 18953: break;
1532 // // Inferno
1533 // case 19695: break;
1534 // // Frostwolf Muzzle DND
1535 // case 21794: break;
1536 // // Alterac Ram Collar DND
1537 // case 21866: break;
1538 // // Celebras Waiting
1539 // case 21916: break;
1540 // Brood Affliction: Bronze
1541 case 23170:
1543 m_target->CastSpell(m_target, 23171, true, 0, this);
1544 return;
1546 // // Mark of Frost
1547 // case 23184: break;
1548 // Restoration
1549 case 23493:
1551 int32 heal = target->GetMaxHealth() / 10;
1552 target->DealHeal(target, heal, auraSpellInfo);
1554 if (int32 mana = target->GetMaxPower(POWER_MANA))
1556 mana /= 10;
1557 target->EnergizeBySpell(target, 23493, mana, POWER_MANA);
1559 return;
1561 // // Stoneclaw Totem Passive TEST
1562 // case 23792: break;
1563 // // Axe Flurry
1564 // case 24018: break;
1565 // // Mark of Arlokk
1566 // case 24210: break;
1567 // // Restoration
1568 // case 24379: break;
1569 // // Happy Pet
1570 // case 24716: break;
1571 // // Dream Fog
1572 // case 24780: break;
1573 // // Cannon Prep
1574 // case 24832: break;
1575 // // Shadow Bolt Whirl
1576 // case 24834: break;
1577 // // Stink Trap
1578 // case 24918: break;
1579 // // Mark of Nature
1580 // case 25041: break;
1581 // // Agro Drones
1582 // case 25152: break;
1583 // Consume
1584 case 25371:
1586 int32 bpDamage = target->GetMaxHealth()*10/100;
1587 target->CastCustomSpell(target, 25373, &bpDamage, NULL, NULL, true, NULL, this, casterGUID);
1588 return;
1590 // // Pain Spike
1591 // case 25572: break;
1592 // // Rotate 360
1593 // case 26009: break;
1594 // // Rotate -360
1595 // case 26136: break;
1596 // // Consume
1597 // case 26196: break;
1598 // // Berserk
1599 // case 26615: break;
1600 // // Defile
1601 // case 27177: break;
1602 // // Teleport: IF/UC
1603 // case 27601: break;
1604 // // Five Fat Finger Exploding Heart Technique
1605 // case 27673: break;
1606 // // Nitrous Boost
1607 // case 27746: break;
1608 // // Steam Tank Passive
1609 // case 27747: break;
1610 // Frost Blast
1611 case 27808:
1613 int32 bpDamage = target->GetMaxHealth()*26/100;
1614 target->CastCustomSpell(target, 29879, &bpDamage, NULL, NULL, true, NULL, this, casterGUID);
1615 return;
1617 // // Detonate Mana
1618 // case 27819: break;
1619 // // Controller Timer
1620 // case 28095: break;
1621 // // Stalagg Chain
1622 // case 28096: break;
1623 // // Stalagg Tesla Passive
1624 // case 28097: break;
1625 // // Feugen Tesla Passive
1626 // case 28109: break;
1627 // // Feugen Chain
1628 // case 28111: break;
1629 // // Mark of Didier
1630 // case 28114: break;
1631 // // Communique Timer, camp
1632 // case 28346: break;
1633 // // Icebolt
1634 // case 28522: break;
1635 // // Silithyst
1636 // case 29519: break;
1637 // Inoculate Nestlewood Owlkin
1638 case 29528:
1639 if(target->GetTypeId() != TYPEID_UNIT)// prevent error reports in case ignored player target
1640 return;
1641 break;
1642 // // Overload
1643 // case 29768: break;
1644 // // Return Fire
1645 // case 29788: break;
1646 // // Return Fire
1647 // case 29793: break;
1648 // // Return Fire
1649 // case 29794: break;
1650 // // Guardian of Icecrown Passive
1651 // case 29897: break;
1652 // Feed Captured Animal
1653 case 29917: trigger_spell_id = 29916; break;
1654 // // Flame Wreath
1655 // case 29946: break;
1656 // // Flame Wreath
1657 // case 29947: break;
1658 // // Mind Exhaustion Passive
1659 // case 30025: break;
1660 // // Nether Beam - Serenity
1661 // case 30401: break;
1662 // Extract Gas
1663 case 30427:
1665 Unit* caster = GetCaster();
1666 if (!caster)
1667 return;
1668 // move loot to player inventory and despawn target
1669 if(caster->GetTypeId() ==TYPEID_PLAYER &&
1670 target->GetTypeId() == TYPEID_UNIT &&
1671 ((Creature*)target)->GetCreatureInfo()->type == CREATURE_TYPE_GAS_CLOUD)
1673 Player* player = (Player*)caster;
1674 Creature* creature = (Creature*)target;
1675 // missing lootid has been reported on startup - just return
1676 if (!creature->GetCreatureInfo()->SkinLootId)
1677 return;
1679 player->AutoStoreLoot(creature->GetCreatureInfo()->SkinLootId,LootTemplates_Skinning,true);
1681 creature->ForcedDespawn();
1683 return;
1685 // Quake
1686 case 30576: trigger_spell_id = 30571; break;
1687 // // Burning Maul
1688 // case 30598: break;
1689 // // Regeneration
1690 // case 30799:
1691 // case 30800:
1692 // case 30801:
1693 // break;
1694 // // Despawn Self - Smoke cloud
1695 // case 31269: break;
1696 // // Time Rift Periodic
1697 // case 31320: break;
1698 // // Corrupt Medivh
1699 // case 31326: break;
1700 // Doom
1701 case 31347:
1703 m_target->CastSpell(m_target,31350,true);
1704 m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
1705 return;
1707 // Spellcloth
1708 case 31373:
1710 // Summon Elemental after create item
1711 target->SummonCreature(17870, 0, 0, 0, target->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0);
1712 return;
1714 // // Bloodmyst Tesla
1715 // case 31611: break;
1716 // Doomfire
1717 case 31944:
1719 int32 damage = m_modifier.m_amount * ((float)(GetAuraDuration() + m_modifier.periodictime) / GetAuraMaxDuration());
1720 target->CastCustomSpell(target, 31969, &damage, NULL, NULL, true, NULL, this, casterGUID);
1721 return;
1723 // // Teleport Test
1724 // case 32236: break;
1725 // // Earthquake
1726 // case 32686: break;
1727 // // Possess
1728 // case 33401: break;
1729 // // Draw Shadows
1730 // case 33563: break;
1731 // // Murmur's Touch
1732 // case 33711: break;
1733 // Flame Quills
1734 case 34229:
1736 // cast 24 spells 34269-34289, 34314-34316
1737 for(uint32 spell_id = 34269; spell_id != 34290; ++spell_id)
1738 target->CastSpell(target, spell_id, true, NULL, this, casterGUID);
1739 for(uint32 spell_id = 34314; spell_id != 34317; ++spell_id)
1740 target->CastSpell(target, spell_id, true, NULL, this, casterGUID);
1741 return;
1743 // // Gravity Lapse
1744 // case 34480: break;
1745 // // Tornado
1746 // case 34683: break;
1747 // // Frostbite Rotate
1748 // case 34748: break;
1749 // // Arcane Flurry
1750 // case 34821: break;
1751 // // Interrupt Shutdown
1752 // case 35016: break;
1753 // // Interrupt Shutdown
1754 // case 35176: break;
1755 // // Inferno
1756 // case 35268: break;
1757 // // Salaadin's Tesla
1758 // case 35515: break;
1759 // // Ethereal Channel (Red)
1760 // case 35518: break;
1761 // // Nether Vapor
1762 // case 35879: break;
1763 // // Dark Portal Storm
1764 // case 36018: break;
1765 // // Burning Maul
1766 // case 36056: break;
1767 // // Living Grove Defender Lifespan
1768 // case 36061: break;
1769 // // Professor Dabiri Talks
1770 // case 36064: break;
1771 // // Kael Gaining Power
1772 // case 36091: break;
1773 // // They Must Burn Bomb Aura
1774 // case 36344: break;
1775 // // They Must Burn Bomb Aura (self)
1776 // case 36350: break;
1777 // // Stolen Ravenous Ravager Egg
1778 // case 36401: break;
1779 // // Activated Cannon
1780 // case 36410: break;
1781 // // Stolen Ravenous Ravager Egg
1782 // case 36418: break;
1783 // // Enchanted Weapons
1784 // case 36510: break;
1785 // // Cursed Scarab Periodic
1786 // case 36556: break;
1787 // // Cursed Scarab Despawn Periodic
1788 // case 36561: break;
1789 // // Vision Guide
1790 // case 36573: break;
1791 // // Cannon Charging (platform)
1792 // case 36785: break;
1793 // // Cannon Charging (self)
1794 // case 36860: break;
1795 // Remote Toy
1796 case 37027: trigger_spell_id = 37029; break;
1797 // // Mark of Death
1798 // case 37125: break;
1799 // // Arcane Flurry
1800 // case 37268: break;
1801 // // Spout
1802 // case 37429: break;
1803 // // Spout
1804 // case 37430: break;
1805 // // Karazhan - Chess NPC AI, Snapshot timer
1806 // case 37440: break;
1807 // // Karazhan - Chess NPC AI, action timer
1808 // case 37504: break;
1809 // // Karazhan - Chess: Is Square OCCUPIED aura (DND)
1810 // case 39400: break;
1811 // // Banish
1812 // case 37546: break;
1813 // // Shriveling Gaze
1814 // case 37589: break;
1815 // // Fake Aggro Radius (2 yd)
1816 // case 37815: break;
1817 // // Corrupt Medivh
1818 // case 37853: break;
1819 // Eye of Grillok
1820 case 38495:
1822 m_target->CastSpell(m_target, 38530, true);
1823 return;
1825 // Absorb Eye of Grillok (Zezzak's Shard)
1826 case 38554:
1828 if(m_target->GetTypeId() != TYPEID_UNIT)
1829 return;
1831 if (Unit* caster = GetCaster())
1832 caster->CastSpell(caster, 38495, true, NULL, this);
1833 else
1834 return;
1836 Creature* creatureTarget = (Creature*)m_target;
1838 creatureTarget->ForcedDespawn();
1839 return;
1841 // // Magic Sucker Device timer
1842 // case 38672: break;
1843 // // Tomb Guarding Charging
1844 // case 38751: break;
1845 // // Murmur's Touch
1846 // case 38794: break;
1847 // // Activate Nether-wraith Beacon (31742 Nether-wraith Beacon item)
1848 // case 39105: break;
1849 // // Drain World Tree Visual
1850 // case 39140: break;
1851 // // Quest - Dustin's Undead Dragon Visual aura
1852 // case 39259: break;
1853 // // Hellfire - The Exorcism, Jules releases darkness, aura
1854 // case 39306: break;
1855 // // Inferno
1856 // case 39346: break;
1857 // // Enchanted Weapons
1858 // case 39489: break;
1859 // // Shadow Bolt Whirl
1860 // case 39630: break;
1861 // // Shadow Bolt Whirl
1862 // case 39634: break;
1863 // // Shadow Inferno
1864 // case 39645: break;
1865 // Tear of Azzinoth Summon Channel - it's not really supposed to do anything,and this only prevents the console spam
1866 case 39857: trigger_spell_id = 39856; break;
1867 // // Soulgrinder Ritual Visual (Smashed)
1868 // case 39974: break;
1869 // // Simon Game Pre-game timer
1870 // case 40041: break;
1871 // // Knockdown Fel Cannon: The Aggro Check Aura
1872 // case 40113: break;
1873 // // Spirit Lance
1874 // case 40157: break;
1875 // // Demon Transform 2
1876 // case 40398: break;
1877 // // Demon Transform 1
1878 // case 40511: break;
1879 // // Ancient Flames
1880 // case 40657: break;
1881 // // Ethereal Ring Cannon: Cannon Aura
1882 // case 40734: break;
1883 // // Cage Trap
1884 // case 40760: break;
1885 // // Random Periodic
1886 // case 40867: break;
1887 // // Prismatic Shield
1888 // case 40879: break;
1889 // // Aura of Desire
1890 // case 41350: break;
1891 // // Dementia
1892 // case 41404: break;
1893 // // Chaos Form
1894 // case 41629: break;
1895 // // Alert Drums
1896 // case 42177: break;
1897 // // Spout
1898 // case 42581: break;
1899 // // Spout
1900 // case 42582: break;
1901 // // Return to the Spirit Realm
1902 // case 44035: break;
1903 // // Curse of Boundless Agony
1904 // case 45050: break;
1905 // // Earthquake
1906 // case 46240: break;
1907 // Personalized Weather
1908 case 46736: trigger_spell_id = 46737; break;
1909 // // Stay Submerged
1910 // case 46981: break;
1911 // // Dragonblight Ram
1912 // case 47015: break;
1913 // // Party G.R.E.N.A.D.E.
1914 // case 51510: break;
1915 default:
1916 break;
1918 break;
1920 case SPELLFAMILY_MAGE:
1922 switch(auraId)
1924 // Invisibility
1925 case 66:
1926 // Here need periodic triger reducing threat spell (or do it manually)
1927 return;
1928 default:
1929 break;
1931 break;
1933 // case SPELLFAMILY_WARRIOR:
1934 // {
1935 // switch(auraId)
1936 // {
1937 // // Wild Magic
1938 // case 23410: break;
1939 // // Corrupted Totems
1940 // case 23425: break;
1941 // default:
1942 // break;
1943 // }
1944 // break;
1945 // }
1946 // case SPELLFAMILY_PRIEST:
1947 // {
1948 // switch(auraId)
1949 // {
1950 // // Blue Beam
1951 // case 32930: break;
1952 // // Fury of the Dreghood Elders
1953 // case 35460: break;
1954 // default:
1955 // break;
1956 // }
1957 // break;
1958 // }
1959 case SPELLFAMILY_HUNTER:
1961 switch (auraId)
1963 // Sniper training
1964 case 53302:
1965 case 53303:
1966 case 53304:
1967 if (target->GetTypeId() != TYPEID_PLAYER)
1968 return;
1970 // Reset reapply counter at move
1971 if (((Player*)target)->isMoving())
1973 m_modifier.m_amount = 6;
1974 return;
1977 // We are standing at the moment
1978 if (m_modifier.m_amount > 0)
1980 --m_modifier.m_amount;
1981 return;
1984 // select rank of buff
1985 switch(auraId)
1987 case 53302: trigger_spell_id = 64418; break;
1988 case 53303: trigger_spell_id = 64419; break;
1989 case 53304: trigger_spell_id = 64420; break;
1992 // If aura is active - no need to continue
1993 if (target->HasAura(trigger_spell_id))
1994 return;
1996 break;
1997 default:
1998 break;
2000 break;
2002 case SPELLFAMILY_DRUID:
2004 switch(auraId)
2006 // Cat Form
2007 // trigger_spell_id not set and unknown effect triggered in this case, ignoring for while
2008 case 768:
2009 return;
2010 // Frenzied Regeneration
2011 case 22842:
2012 case 22895:
2013 case 22896:
2014 case 26999:
2016 int32 LifePerRage = GetModifier()->m_amount;
2018 int32 lRage = m_target->GetPower(POWER_RAGE);
2019 if(lRage > 100) // rage stored as rage*10
2020 lRage = 100;
2021 m_target->ModifyPower(POWER_RAGE, -lRage);
2022 int32 FRTriggerBasePoints = int32(lRage*LifePerRage/10);
2023 m_target->CastCustomSpell(m_target, 22845, &FRTriggerBasePoints, NULL, NULL, true, NULL, this);
2024 return;
2026 default:
2027 break;
2029 break;
2032 // case SPELLFAMILY_HUNTER:
2033 // {
2034 // switch(auraId)
2035 // {
2036 // //Frost Trap Aura
2037 // case 13810:
2038 // return;
2039 // //Rizzle's Frost Trap
2040 // case 39900:
2041 // return;
2042 // // Tame spells
2043 // case 19597: // Tame Ice Claw Bear
2044 // case 19676: // Tame Snow Leopard
2045 // case 19677: // Tame Large Crag Boar
2046 // case 19678: // Tame Adult Plainstrider
2047 // case 19679: // Tame Prairie Stalker
2048 // case 19680: // Tame Swoop
2049 // case 19681: // Tame Dire Mottled Boar
2050 // case 19682: // Tame Surf Crawler
2051 // case 19683: // Tame Armored Scorpid
2052 // case 19684: // Tame Webwood Lurker
2053 // case 19685: // Tame Nightsaber Stalker
2054 // case 19686: // Tame Strigid Screecher
2055 // case 30100: // Tame Crazed Dragonhawk
2056 // case 30103: // Tame Elder Springpaw
2057 // case 30104: // Tame Mistbat
2058 // case 30647: // Tame Barbed Crawler
2059 // case 30648: // Tame Greater Timberstrider
2060 // case 30652: // Tame Nightstalker
2061 // return;
2062 // default:
2063 // break;
2064 // }
2065 // break;
2066 // }
2067 case SPELLFAMILY_SHAMAN:
2069 switch(auraId)
2071 // Lightning Shield (The Earthshatterer set trigger after cast Lighting Shield)
2072 case 28820:
2074 // Need remove self if Lightning Shield not active
2075 Unit::AuraMap const& auras = target->GetAuras();
2076 for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
2078 SpellEntry const* spell = itr->second->GetSpellProto();
2079 if( spell->SpellFamilyName == SPELLFAMILY_SHAMAN &&
2080 (spell->SpellFamilyFlags & UI64LIT(0x0000000000000400)))
2081 return;
2083 target->RemoveAurasDueToSpell(28820);
2084 return;
2086 // Totemic Mastery (Skyshatter Regalia (Shaman Tier 6) - bonus)
2087 case 38443:
2089 bool all = true;
2090 for(int i = 0; i < MAX_TOTEM; ++i)
2092 if(!target->m_TotemSlot[i])
2094 all = false;
2095 break;
2099 if(all)
2100 target->CastSpell(target, 38437, true, NULL, this);
2101 else
2102 target->RemoveAurasDueToSpell(38437);
2103 return;
2105 default:
2106 break;
2108 break;
2110 default:
2111 break;
2114 // Reget trigger spell proto
2115 triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id);
2117 else
2119 // Spell exist but require custom code
2120 switch(auraId)
2122 // Curse of Idiocy
2123 case 1010:
2125 // TODO: spell casted by result in correct way mostly
2126 // BUT:
2127 // 1) target show casting at each triggered cast: target don't must show casting animation for any triggered spell
2128 // but must show affect apply like item casting
2129 // 2) maybe aura must be replace by new with accumulative stat mods instead stacking
2131 // prevent cast by triggered auras
2132 if(casterGUID == target->GetGUID())
2133 return;
2135 // stop triggering after each affected stats lost > 90
2136 int32 intelectLoss = 0;
2137 int32 spiritLoss = 0;
2139 Unit::AuraList const& mModStat = target->GetAurasByType(SPELL_AURA_MOD_STAT);
2140 for(Unit::AuraList::const_iterator i = mModStat.begin(); i != mModStat.end(); ++i)
2142 if ((*i)->GetId() == 1010)
2144 switch((*i)->GetModifier()->m_miscvalue)
2146 case STAT_INTELLECT: intelectLoss += (*i)->GetModifier()->m_amount; break;
2147 case STAT_SPIRIT: spiritLoss += (*i)->GetModifier()->m_amount; break;
2148 default: break;
2153 if(intelectLoss <= -90 && spiritLoss <= -90)
2154 return;
2156 break;
2158 // Mana Tide
2159 case 16191:
2161 target->CastCustomSpell(target, trigger_spell_id, &m_modifier.m_amount, NULL, NULL, true, NULL, this);
2162 return;
2164 // Ground Slam
2165 case 33525:
2166 target->CastSpell(target, trigger_spell_id, true, NULL, this, casterGUID);
2167 return;
2168 // Beacon of Light
2169 case 53563:
2170 // original caster must be target (beacon)
2171 target->CastSpell(target, trigger_spell_id, true, NULL, this, target->GetGUID());
2172 return;
2173 // Rapid Recuperation (triggered energize have baspioints == 0)
2174 case 56654:
2175 case 58882:
2177 int32 mana = m_target->GetMaxPower(POWER_MANA) * m_modifier.m_amount / 100;
2178 target->CastCustomSpell(target, trigger_spell_id, &mana, NULL, NULL, true, NULL, this);
2179 return;
2184 // All ok cast by default case
2185 if(triggeredSpellInfo)
2186 target->CastSpell(target, triggeredSpellInfo, true, NULL, this, casterGUID);
2187 else
2189 if (Unit* caster = GetCaster())
2191 if(target->GetTypeId() != TYPEID_UNIT || !Script->EffectDummyCreature(caster, GetId(), GetEffIndex(), (Creature*)target))
2192 sLog.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex());
2197 void Aura::TriggerSpellWithValue()
2199 const uint64& casterGUID = GetCasterGUID();
2200 Unit* target = GetTriggerTarget();
2202 if(!casterGUID || !target)
2203 return;
2205 // generic casting code with custom spells and target/caster customs
2206 uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex];
2207 int32 basepoints0 = this->GetModifier()->m_amount;
2209 target->CastCustomSpell(target, trigger_spell_id, &basepoints0, NULL, NULL, true, NULL, this, casterGUID);
2212 /*********************************************************/
2213 /*** AURA EFFECTS ***/
2214 /*********************************************************/
2216 void Aura::HandleAuraDummy(bool apply, bool Real)
2218 // spells required only Real aura add/remove
2219 if(!Real)
2220 return;
2222 // AT APPLY
2223 if(apply)
2225 switch(m_spellProto->SpellFamilyName)
2227 case SPELLFAMILY_GENERIC:
2228 switch(GetId())
2230 case 1515: // Tame beast
2231 // FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness
2232 if (m_target->CanHaveThreatList())
2233 if (Unit* caster = GetCaster())
2234 m_target->AddThreat(caster, 10.0f, false, GetSpellSchoolMask(GetSpellProto()), GetSpellProto());
2235 return;
2236 case 7057: // Haunting Spirits
2237 // expected to tick with 30 sec period (tick part see in Aura::PeriodicTick)
2238 m_isPeriodic = true;
2239 m_modifier.periodictime = 30*IN_MILISECONDS;
2240 m_periodicTimer = m_modifier.periodictime;
2241 return;
2242 case 13139: // net-o-matic
2243 // root to self part of (root_target->charge->root_self sequence
2244 if (Unit* caster = GetCaster())
2245 caster->CastSpell(caster, 13138, true, NULL, this);
2246 return;
2247 case 39850: // Rocket Blast
2248 if(roll_chance_i(20)) // backfire stun
2249 m_target->CastSpell(m_target, 51581, true, NULL, this);
2250 return;
2251 case 43873: // Headless Horseman Laugh
2252 m_target->PlayDistanceSound(11965);
2253 return;
2254 case 46354: // Blood Elf Illusion
2255 if (Unit* caster = GetCaster())
2257 switch(caster->getGender())
2259 case GENDER_FEMALE:
2260 caster->CastSpell(m_target, 46356, true, NULL, this);
2261 break;
2262 case GENDER_MALE:
2263 caster->CastSpell(m_target, 46355, true, NULL, this);
2264 break;
2265 default:
2266 break;
2269 return;
2270 case 46699: // Requires No Ammo
2271 if (m_target->GetTypeId() == TYPEID_PLAYER)
2272 // not use ammo and not allow use
2273 ((Player*)m_target)->RemoveAmmo();
2274 return;
2275 case 62061: // Festive Holiday Mount
2276 if (m_target->HasAuraType(SPELL_AURA_MOUNTED))
2277 // Reindeer Transformation
2278 m_target->CastSpell(m_target, 25860, true, NULL, this);
2279 return;
2281 break;
2282 case SPELLFAMILY_WARRIOR:
2283 // Overpower
2284 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000004))
2286 // Must be casting target
2287 if (!m_target->IsNonMeleeSpellCasted(false))
2288 return;
2290 Unit* caster = GetCaster();
2291 if (!caster)
2292 return;
2294 Unit::AuraList const& modifierAuras = caster->GetAurasByType(SPELL_AURA_ADD_FLAT_MODIFIER);
2295 for(Unit::AuraList::const_iterator itr = modifierAuras.begin(); itr != modifierAuras.end(); ++itr)
2297 // Unrelenting Assault
2298 if((*itr)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARRIOR && (*itr)->GetSpellProto()->SpellIconID == 2775)
2300 switch ((*itr)->GetSpellProto()->Id)
2302 case 46859: // Unrelenting Assault, rank 1
2303 m_target->CastSpell(m_target,64849,true,NULL,(*itr));
2304 break;
2305 case 46860: // Unrelenting Assault, rank 2
2306 m_target->CastSpell(m_target,64850,true,NULL,(*itr));
2307 break;
2308 default:
2309 break;
2311 break;
2314 return;
2316 break;
2317 case SPELLFAMILY_SHAMAN:
2318 // Tidal Force
2319 if (GetId() == 55198)
2321 // apply max stack bufs
2322 SpellEntry const* buffEntry = sSpellStore.LookupEntry(55166);
2323 if (!buffEntry)
2324 return;
2325 for(int k = 0; k < buffEntry->StackAmount; ++k)
2326 m_target->CastSpell(m_target, buffEntry, true, NULL, this);
2328 // Earth Shield
2329 else if ((GetSpellProto()->SpellFamilyFlags & UI64LIT(0x40000000000)))
2331 // prevent double apply bonuses
2332 if(m_target->GetTypeId() != TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())
2333 if (Unit* caster = GetCaster())
2334 m_modifier.m_amount = caster->SpellHealingBonus(m_target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE);
2335 return;
2337 break;
2340 // AT REMOVE
2341 else
2343 if( m_target->GetTypeId() == TYPEID_PLAYER &&
2344 ( GetSpellProto()->Effect[0]==72 || GetSpellProto()->Effect[0]==6 &&
2345 ( GetSpellProto()->EffectApplyAuraName[0]==1 || GetSpellProto()->EffectApplyAuraName[0]==128 ) ) )
2347 // spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425
2348 ((Player*)m_target)->SetFarSightGUID(0);
2349 WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0);
2350 ((Player*)m_target)->GetSession()->SendPacket(&data);
2351 return;
2354 if (IsQuestTameSpell(GetId()) && m_target->isAlive())
2356 Unit* caster = GetCaster();
2357 if (!caster || !caster->isAlive())
2358 return;
2360 uint32 finalSpelId = 0;
2361 switch(GetId())
2363 case 19548: finalSpelId = 19597; break;
2364 case 19674: finalSpelId = 19677; break;
2365 case 19687: finalSpelId = 19676; break;
2366 case 19688: finalSpelId = 19678; break;
2367 case 19689: finalSpelId = 19679; break;
2368 case 19692: finalSpelId = 19680; break;
2369 case 19693: finalSpelId = 19684; break;
2370 case 19694: finalSpelId = 19681; break;
2371 case 19696: finalSpelId = 19682; break;
2372 case 19697: finalSpelId = 19683; break;
2373 case 19699: finalSpelId = 19685; break;
2374 case 19700: finalSpelId = 19686; break;
2375 case 30646: finalSpelId = 30647; break;
2376 case 30653: finalSpelId = 30648; break;
2377 case 30654: finalSpelId = 30652; break;
2378 case 30099: finalSpelId = 30100; break;
2379 case 30102: finalSpelId = 30103; break;
2380 case 30105: finalSpelId = 30104; break;
2383 if(finalSpelId)
2384 caster->CastSpell(m_target, finalSpelId, true, NULL, this);
2385 return;
2388 switch(GetId())
2390 case 28169: // Mutating Injection
2392 // Mutagen Explosion
2393 m_target->CastSpell(m_target, 28206, true, NULL, this);
2394 // Poison Cloud
2395 m_target->CastSpell(m_target, 28240, true, NULL, this);
2396 return;
2398 case 32286: // Focus Target Visual
2400 if (m_removeMode == AURA_REMOVE_BY_DEFAULT)
2401 m_target->CastSpell(m_target, 32301, true, NULL, this);
2403 return;
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 // Living Bomb
2436 if (m_spellProto->SpellFamilyName == SPELLFAMILY_MAGE && (m_spellProto->SpellFamilyFlags & UI64LIT(0x2000000000000)))
2438 // Zero duration is equal to AURA_REMOVE_BY_DEFAULT. We can't use it directly, as it is set even
2439 // when removing aura from one target due to casting Living Bomb at other.
2440 if (m_duration == 0 || m_removeMode == AURA_REMOVE_BY_DISPEL)
2441 m_target->CastSpell(m_target,m_modifier.m_amount,true,NULL,this);
2442 return;
2445 if (m_removeMode == AURA_REMOVE_BY_DEATH)
2447 // Stop caster Arcane Missle chanelling on death
2448 if (m_spellProto->SpellFamilyName == SPELLFAMILY_MAGE &&
2449 (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000800)))
2451 if (Unit* caster = GetCaster())
2452 caster->InterruptSpell(CURRENT_CHANNELED_SPELL);
2453 return;
2455 // Stop caster Penance chanelling on death
2456 if (m_spellProto->SpellFamilyName == SPELLFAMILY_PRIEST &&
2457 (m_spellProto->SpellFamilyFlags2 & UI64LIT(0x00000080)))
2459 if (Unit* caster = GetCaster())
2460 caster->InterruptSpell(CURRENT_CHANNELED_SPELL);
2461 return;
2466 // AT APPLY & REMOVE
2468 switch(m_spellProto->SpellFamilyName)
2470 case SPELLFAMILY_GENERIC:
2472 switch(GetId())
2474 // Recently Bandaged
2475 case 11196:
2476 m_target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, GetMiscValue(), apply);
2477 return;
2478 // Unstable Power
2479 case 24658:
2481 uint32 spellId = 24659;
2482 if (apply)
2484 SpellEntry const *spell = sSpellStore.LookupEntry(spellId);
2485 Unit* caster = GetCaster();
2486 if (!spell || !caster)
2487 return;
2489 for (int i=0; i < spell->StackAmount; ++i)
2490 caster->CastSpell(m_target, spellId, true, NULL, NULL, GetCasterGUID());
2491 return;
2493 m_target->RemoveAurasDueToSpell(spellId);
2494 return;
2496 // Restless Strength
2497 case 24661:
2499 uint32 spellId = 24662;
2500 if (apply)
2502 SpellEntry const* spell = sSpellStore.LookupEntry(spellId);
2503 Unit* caster = GetCaster();
2504 if (!spell || !caster)
2505 return;
2506 for (int i=0; i < spell->StackAmount; ++i)
2507 caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID());
2508 return;
2510 m_target->RemoveAurasDueToSpell(spellId);
2511 return;
2513 //Summon Fire Elemental
2514 case 40133:
2516 Unit* caster = GetCaster();
2517 if (!caster)
2518 return;
2520 Unit *owner = caster->GetOwner();
2521 if (owner && owner->GetTypeId() == TYPEID_PLAYER)
2523 if(apply)
2524 owner->CastSpell(owner, 8985, true);
2525 else
2526 ((Player*)owner)->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true);
2528 return;
2530 //Summon Earth Elemental
2531 case 40132 :
2533 Unit* caster = GetCaster();
2534 if (!caster)
2535 return;
2537 Unit *owner = caster->GetOwner();
2538 if (owner && owner->GetTypeId() == TYPEID_PLAYER)
2540 if(apply)
2541 owner->CastSpell(owner, 19704, true);
2542 else
2543 ((Player*)owner)->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true);
2545 return;
2547 //Dragonmaw Illusion
2548 case 40214 :
2550 if(apply)
2552 m_target->CastSpell(m_target, 40216, true);
2553 m_target->CastSpell(m_target, 42016, true);
2555 else
2557 m_target->RemoveAurasDueToSpell(40216);
2558 m_target->RemoveAurasDueToSpell(42016);
2560 return;
2562 // LK Intro VO (1)
2563 case 58204:
2564 if(m_target->GetTypeId() == TYPEID_PLAYER)
2566 // Play part 1
2567 if(apply)
2568 m_target->PlayDirectSound(14970, (Player *)m_target);
2569 // continue in 58205
2570 else
2571 m_target->CastSpell(m_target, 58205, true);
2573 return;
2574 // LK Intro VO (2)
2575 case 58205:
2576 if(m_target->GetTypeId() == TYPEID_PLAYER)
2578 // Play part 2
2579 if(apply)
2580 m_target->PlayDirectSound(14971, (Player *)m_target);
2581 // Play part 3
2582 else
2583 m_target->PlayDirectSound(14972, (Player *)m_target);
2585 return;
2586 case 40131:
2587 case 27978:
2588 if (apply)
2589 m_target->m_AuraFlags |= UNIT_AURAFLAG_ALIVE_INVISIBLE;
2590 else
2591 m_target->m_AuraFlags |= ~UNIT_AURAFLAG_ALIVE_INVISIBLE;
2592 return;
2594 break;
2596 case SPELLFAMILY_MAGE:
2597 break;
2598 case SPELLFAMILY_WARLOCK:
2600 // Haunt
2601 if (GetSpellProto()->SpellIconID == 3172 && (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0004000000000000)))
2603 // NOTE: for avoid use additional field damage stored in dummy value (replace unused 100%
2604 if (apply)
2605 m_modifier.m_amount = 0; // use value as damage counter instead redundent 100% percent
2606 else
2608 int32 bp0 = m_modifier.m_amount;
2610 if (Unit* caster = GetCaster())
2611 m_target->CastCustomSpell(caster,48210,&bp0,NULL,NULL,true);
2614 break;
2616 case SPELLFAMILY_PRIEST:
2618 // Pain and Suffering
2619 if( m_spellProto->SpellIconID == 2874 && m_target->GetTypeId()==TYPEID_PLAYER )
2621 if(apply)
2623 // Reduce backfire damage (dot damage) from Shadow Word: Death
2624 // aura have wrong effectclassmask, so use hardcoded value
2625 m_spellmod = new SpellModifier(SPELLMOD_DOT,SPELLMOD_PCT,m_modifier.m_amount,GetId(),UI64LIT(0x0000200000000000));
2627 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
2628 return;
2630 break;
2632 case SPELLFAMILY_DRUID:
2634 switch(GetId())
2636 case 34246: // Idol of the Emerald Queen
2637 case 60779: // Idol of Lush Moss
2639 if (m_target->GetTypeId() != TYPEID_PLAYER)
2640 return;
2642 if(apply)
2643 // dummy not have proper effectclassmask
2644 m_spellmod = new SpellModifier(SPELLMOD_DOT,SPELLMOD_FLAT,m_modifier.m_amount/7,GetId(),UI64LIT(0x001000000000));
2646 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
2647 return;
2649 case 52610: // Savage Roar
2651 if(apply)
2653 if(m_target->m_form != FORM_CAT)
2654 return;
2656 m_target->CastSpell(m_target, 62071, true);
2658 else
2659 m_target-> RemoveAurasDueToSpell(62071);
2660 return;
2662 case 61336: // Survival Instincts
2664 if(apply)
2666 if (!m_target->IsInFeralForm())
2667 return;
2669 int32 bp0 = int32(m_target->GetMaxHealth() * m_modifier.m_amount / 100);
2670 m_target->CastCustomSpell(m_target, 50322, &bp0, NULL, NULL, true);
2672 else
2673 m_target-> RemoveAurasDueToSpell(50322);
2674 return;
2678 // Lifebloom
2679 if (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x1000000000))
2681 if ( apply )
2683 if (Unit* caster = GetCaster())
2684 // prevent double apply bonuses
2685 if(m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())
2686 m_modifier.m_amount = caster->SpellHealingBonus(m_target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE);
2688 else
2690 // Final heal only on dispelled or duration end
2691 if ( !(GetAuraDuration() <= 0 || m_removeMode == AURA_REMOVE_BY_DISPEL) )
2692 return;
2694 // have a look if there is still some other Lifebloom dummy aura
2695 Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
2696 for(Unit::AuraList::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr)
2697 if((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID &&
2698 ((*itr)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x1000000000)))
2699 return;
2701 // final heal
2702 if(m_target->IsInWorld() && m_stackAmount > 0)
2704 int32 amount = m_modifier.m_amount / m_stackAmount;
2705 m_target->CastCustomSpell(m_target, 33778, &amount, NULL, NULL, true, NULL, this, GetCasterGUID());
2707 if (Unit* caster = GetCaster())
2709 int32 returnmana = (GetSpellProto()->ManaCostPercentage * caster->GetCreateMana() / 100) * m_stackAmount / 2;
2710 caster->CastCustomSpell(caster, 64372, &returnmana, NULL, NULL, true, NULL, this, GetCasterGUID());
2714 return;
2717 // Predatory Strikes
2718 if(m_target->GetTypeId()==TYPEID_PLAYER && GetSpellProto()->SpellIconID == 1563)
2720 ((Player*)m_target)->UpdateAttackPowerAndDamage();
2721 return;
2724 // Improved Moonkin Form
2725 if(GetSpellProto()->SpellIconID == 2855)
2727 uint32 spell_id;
2728 switch(GetId())
2730 case 48384: spell_id = 50170; break; //Rank 1
2731 case 48395: spell_id = 50171; break; //Rank 2
2732 case 48396: spell_id = 50172; break; //Rank 3
2733 default:
2734 sLog.outError("HandleAuraDummy: Not handled rank of IMF (Spell: %u)",GetId());
2735 return;
2738 if(apply)
2740 if(m_target->m_form != FORM_MOONKIN)
2741 return;
2743 m_target->CastSpell(m_target, spell_id, true);
2745 else
2746 m_target-> RemoveAurasDueToSpell(spell_id);
2747 return;
2749 break;
2751 case SPELLFAMILY_HUNTER:
2752 break;
2753 case SPELLFAMILY_PALADIN:
2754 switch(GetId())
2756 case 20911: // Blessing of Sanctuary
2757 case 25899: // Greater Blessing of Sanctuary
2759 if (apply)
2760 m_target->CastSpell(m_target, 67480, true, NULL, this);
2761 else
2762 m_target->RemoveAurasDueToSpell(67480);
2763 return;
2766 break;
2767 case SPELLFAMILY_SHAMAN:
2768 break;
2771 // pet auras
2772 if(PetAura const* petSpell = sSpellMgr.GetPetAura(GetId(), m_effIndex))
2774 if(apply)
2775 m_target->AddPetAura(petSpell);
2776 else
2777 m_target->RemovePetAura(petSpell);
2778 return;
2781 if(GetEffIndex()==0 && m_target->GetTypeId()==TYPEID_PLAYER)
2783 SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAuraMapBounds(GetId());
2784 if(saBounds.first != saBounds.second)
2786 uint32 zone, area;
2787 m_target->GetZoneAndAreaId(zone, area);
2789 for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
2791 // some auras remove at aura remove
2792 if(!itr->second->IsFitToRequirements((Player*)m_target, zone, area))
2793 m_target->RemoveAurasDueToSpell(itr->second->spellId);
2794 // some auras applied at aura apply
2795 else if(itr->second->autocast)
2797 if( !m_target->HasAura(itr->second->spellId, 0) )
2798 m_target->CastSpell(m_target, itr->second->spellId, true);
2805 void Aura::HandleAuraMounted(bool apply, bool Real)
2807 // only at real add/remove aura
2808 if(!Real)
2809 return;
2811 if(apply)
2813 CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(m_modifier.m_miscvalue);
2814 if(!ci)
2816 sLog.outErrorDb("AuraMounted: `creature_template`='%u' not found in database (only need it modelid)", m_modifier.m_miscvalue);
2817 return;
2820 uint32 team = 0;
2821 if (m_target->GetTypeId()==TYPEID_PLAYER)
2822 team = ((Player*)m_target)->GetTeam();
2824 uint32 display_id = sObjectMgr.ChooseDisplayId(team,ci);
2825 CreatureModelInfo const *minfo = sObjectMgr.GetCreatureModelRandomGender(display_id);
2826 if (minfo)
2827 display_id = minfo->modelid;
2829 m_target->Mount(display_id, m_spellProto->Id);
2831 else
2833 m_target->Unmount();
2837 void Aura::HandleAuraWaterWalk(bool apply, bool Real)
2839 // only at real add/remove aura
2840 if(!Real)
2841 return;
2843 WorldPacket data;
2844 if(apply)
2845 data.Initialize(SMSG_MOVE_WATER_WALK, 8+4);
2846 else
2847 data.Initialize(SMSG_MOVE_LAND_WALK, 8+4);
2848 data.append(m_target->GetPackGUID());
2849 data << uint32(0);
2850 m_target->SendMessageToSet(&data, true);
2853 void Aura::HandleAuraFeatherFall(bool apply, bool Real)
2855 // only at real add/remove aura
2856 if(!Real)
2857 return;
2859 WorldPacket data;
2860 if(apply)
2861 data.Initialize(SMSG_MOVE_FEATHER_FALL, 8+4);
2862 else
2863 data.Initialize(SMSG_MOVE_NORMAL_FALL, 8+4);
2864 data.append(m_target->GetPackGUID());
2865 data << uint32(0);
2866 m_target->SendMessageToSet(&data, true);
2868 // start fall from current height
2869 if(!apply && m_target->GetTypeId() == TYPEID_PLAYER)
2870 ((Player*)m_target)->SetFallInformation(0, m_target->GetPositionZ());
2873 void Aura::HandleAuraHover(bool apply, bool Real)
2875 // only at real add/remove aura
2876 if(!Real)
2877 return;
2879 WorldPacket data;
2880 if(apply)
2881 data.Initialize(SMSG_MOVE_SET_HOVER, 8+4);
2882 else
2883 data.Initialize(SMSG_MOVE_UNSET_HOVER, 8+4);
2884 data.append(m_target->GetPackGUID());
2885 data << uint32(0);
2886 m_target->SendMessageToSet(&data, true);
2889 void Aura::HandleWaterBreathing(bool /*apply*/, bool /*Real*/)
2891 // update timers in client
2892 if(m_target->GetTypeId()==TYPEID_PLAYER)
2893 ((Player*)m_target)->UpdateMirrorTimers();
2896 void Aura::HandleAuraModShapeshift(bool apply, bool Real)
2898 if(!Real)
2899 return;
2901 uint32 modelid = 0;
2902 Powers PowerType = POWER_MANA;
2903 ShapeshiftForm form = ShapeshiftForm(m_modifier.m_miscvalue);
2905 SpellShapeshiftEntry const* ssEntry = sSpellShapeshiftStore.LookupEntry(form);
2906 if (!ssEntry)
2908 sLog.outError("Unknown shapeshift form %u in spell %u", form, GetId());
2909 return;
2912 if (ssEntry->modelID_A)
2914 // i will asume that creatures will always take the defined model from the dbc
2915 // since no field in creature_templates describes wether an alliance or
2916 // horde modelid should be used at shapeshifting
2917 if (m_target->GetTypeId() != TYPEID_PLAYER)
2918 modelid = ssEntry->modelID_A;
2919 else
2921 // players are a bit difficult since the dbc has seldomly an horde modelid
2922 // so we add hacks here to set the right model
2923 if (Player::TeamForRace(m_target->getRace()) == ALLIANCE)
2924 modelid = ssEntry->modelID_A;
2925 else // 3.2.3 only the moonkin form has this information
2926 modelid = ssEntry->modelID_H;
2928 // no model found, if player is horde we look here for our hardcoded modelids
2929 if (!modelid && Player::TeamForRace(m_target->getRace()) == HORDE)
2932 switch(form)
2934 case FORM_CAT:
2935 modelid = 8571;
2936 break;
2937 case FORM_BEAR:
2938 case FORM_DIREBEAR:
2939 modelid = 2289;
2940 break;
2941 case FORM_FLIGHT:
2942 modelid = 20872;
2943 break;
2944 case FORM_FLIGHT_EPIC:
2945 modelid = 21244;
2946 break;
2947 // per default use alliance modelid
2948 // mostly horde and alliance share the same
2949 default:
2950 modelid = ssEntry->modelID_A;
2951 break;
2957 // now only powertype must be set
2958 switch(form)
2960 case FORM_CAT:
2961 PowerType = POWER_ENERGY;
2962 break;
2963 case FORM_BEAR:
2964 case FORM_DIREBEAR:
2965 case FORM_BATTLESTANCE:
2966 case FORM_BERSERKERSTANCE:
2967 case FORM_DEFENSIVESTANCE:
2968 PowerType = POWER_RAGE;
2969 break;
2970 default:
2971 break;
2974 // remove polymorph before changing display id to keep new display id
2975 switch ( form )
2977 case FORM_CAT:
2978 case FORM_TREE:
2979 case FORM_TRAVEL:
2980 case FORM_AQUA:
2981 case FORM_BEAR:
2982 case FORM_DIREBEAR:
2983 case FORM_FLIGHT_EPIC:
2984 case FORM_FLIGHT:
2985 case FORM_MOONKIN:
2987 // remove movement affects
2988 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT);
2989 Unit::AuraList const& slowingAuras = m_target->GetAurasByType(SPELL_AURA_MOD_DECREASE_SPEED);
2990 for (Unit::AuraList::const_iterator iter = slowingAuras.begin(); iter != slowingAuras.end();)
2992 SpellEntry const* aurSpellInfo = (*iter)->GetSpellProto();
2994 uint32 aurMechMask = GetAllSpellMechanicMask(aurSpellInfo);
2996 // If spell that caused this aura has Croud Control or Daze effect
2997 if((aurMechMask & MECHANIC_NOT_REMOVED_BY_SHAPESHIFT) ||
2998 // some Daze spells have these parameters instead of MECHANIC_DAZE (skip snare spells)
2999 aurSpellInfo->SpellIconID == 15 && aurSpellInfo->Dispel == 0 &&
3000 (aurMechMask & (1 << (MECHANIC_SNARE-1)))==0)
3002 ++iter;
3003 continue;
3006 // All OK, remove aura now
3007 m_target->RemoveAurasDueToSpellByCancel(aurSpellInfo->Id);
3008 iter = slowingAuras.begin();
3011 // and polymorphic affects
3012 if(m_target->IsPolymorphed())
3013 m_target->RemoveAurasDueToSpell(m_target->getTransForm());
3015 break;
3017 default:
3018 break;
3021 if(apply)
3023 // remove other shapeshift before applying a new one
3024 if(m_target->m_ShapeShiftFormSpellId)
3025 m_target->RemoveAurasDueToSpell(m_target->m_ShapeShiftFormSpellId, this);
3027 m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, form);
3029 if(modelid > 0)
3030 m_target->SetDisplayId(modelid);
3032 if(PowerType != POWER_MANA)
3034 // reset power to default values only at power change
3035 if(m_target->getPowerType() != PowerType)
3036 m_target->setPowerType(PowerType);
3038 switch(form)
3040 case FORM_CAT:
3041 case FORM_BEAR:
3042 case FORM_DIREBEAR:
3044 // get furor proc chance
3045 int32 furorChance = 0;
3046 Unit::AuraList const& mDummy = m_target->GetAurasByType(SPELL_AURA_DUMMY);
3047 for(Unit::AuraList::const_iterator i = mDummy.begin(); i != mDummy.end(); ++i)
3049 if ((*i)->GetSpellProto()->SpellIconID == 238)
3051 furorChance = (*i)->GetModifier()->m_amount;
3052 break;
3056 if (m_modifier.m_miscvalue == FORM_CAT)
3058 // Furor chance is now amount allowed to save energy for cat form
3059 // without talent it reset to 0
3060 if (m_target->GetPower(POWER_ENERGY) > furorChance)
3062 m_target->SetPower(POWER_ENERGY, 0);
3063 m_target->CastCustomSpell(m_target, 17099, &furorChance, NULL, NULL, this);
3066 else if(furorChance) // only if talent known
3068 m_target->SetPower(POWER_RAGE, 0);
3069 if(urand(1,100) <= furorChance)
3070 m_target->CastSpell(m_target, 17057, true, NULL, this);
3072 break;
3074 case FORM_BATTLESTANCE:
3075 case FORM_DEFENSIVESTANCE:
3076 case FORM_BERSERKERSTANCE:
3078 uint32 Rage_val = 0;
3079 // Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch)
3080 if(m_target->GetTypeId() == TYPEID_PLAYER)
3082 PlayerSpellMap const& sp_list = ((Player *)m_target)->GetSpellMap();
3083 for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
3085 if(itr->second->state == PLAYERSPELL_REMOVED) continue;
3086 SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
3087 if (spellInfo && spellInfo->SpellFamilyName == SPELLFAMILY_WARRIOR && spellInfo->SpellIconID == 139)
3088 Rage_val += m_target->CalculateSpellDamage(spellInfo, 0, spellInfo->EffectBasePoints[0], m_target) * 10;
3092 if (m_target->GetPower(POWER_RAGE) > Rage_val)
3093 m_target->SetPower(POWER_RAGE, Rage_val);
3094 break;
3096 default:
3097 break;
3101 m_target->m_ShapeShiftFormSpellId = GetId();
3102 m_target->m_form = form;
3104 // a form can give the player a new castbar with some spells.. this is a clientside process..
3105 // serverside just needs to register the new spells so that player isn't kicked as cheater
3106 if (m_target->GetTypeId() == TYPEID_PLAYER)
3107 for (uint32 i = 0; i < 8; ++i)
3108 if (ssEntry->spellId[i])
3109 ((Player*)m_target)->addSpell(ssEntry->spellId[i], true, false, false, false);
3112 else
3114 if(modelid > 0)
3115 m_target->SetDisplayId(m_target->GetNativeDisplayId());
3116 m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, FORM_NONE);
3117 if(m_target->getClass() == CLASS_DRUID)
3118 m_target->setPowerType(POWER_MANA);
3119 m_target->m_ShapeShiftFormSpellId = 0;
3120 m_target->m_form = FORM_NONE;
3122 switch(form)
3124 // Nordrassil Harness - bonus
3125 case FORM_BEAR:
3126 case FORM_DIREBEAR:
3127 case FORM_CAT:
3128 if(Aura* dummy = m_target->GetDummyAura(37315) )
3129 m_target->CastSpell(m_target, 37316, true, NULL, dummy);
3130 break;
3131 // Nordrassil Regalia - bonus
3132 case FORM_MOONKIN:
3133 if(Aura* dummy = m_target->GetDummyAura(37324) )
3134 m_target->CastSpell(m_target, 37325, true, NULL, dummy);
3135 break;
3136 default:
3137 break;
3140 // look at the comment in apply-part
3141 if (m_target->GetTypeId() == TYPEID_PLAYER)
3142 for (uint32 i = 0; i < 8; ++i)
3143 if (ssEntry->spellId[i])
3144 ((Player*)m_target)->removeSpell(ssEntry->spellId[i], false, false, false);
3148 // adding/removing linked auras
3149 // add/remove the shapeshift aura's boosts
3150 HandleShapeshiftBoosts(apply);
3152 if(m_target->GetTypeId() == TYPEID_PLAYER)
3153 ((Player*)m_target)->InitDataForForm();
3156 void Aura::HandleAuraTransform(bool apply, bool Real)
3158 if (apply)
3160 // special case (spell specific functionality)
3161 if (m_modifier.m_miscvalue == 0)
3163 // player applied only
3164 if (m_target->GetTypeId() != TYPEID_PLAYER)
3165 return;
3167 switch (GetId())
3169 // Orb of Deception
3170 case 16739:
3172 uint32 orb_model = m_target->GetNativeDisplayId();
3173 switch(orb_model)
3175 // Troll Female
3176 case 1479: m_target->SetDisplayId(10134); break;
3177 // Troll Male
3178 case 1478: m_target->SetDisplayId(10135); break;
3179 // Tauren Male
3180 case 59: m_target->SetDisplayId(10136); break;
3181 // Human Male
3182 case 49: m_target->SetDisplayId(10137); break;
3183 // Human Female
3184 case 50: m_target->SetDisplayId(10138); break;
3185 // Orc Male
3186 case 51: m_target->SetDisplayId(10139); break;
3187 // Orc Female
3188 case 52: m_target->SetDisplayId(10140); break;
3189 // Dwarf Male
3190 case 53: m_target->SetDisplayId(10141); break;
3191 // Dwarf Female
3192 case 54: m_target->SetDisplayId(10142); break;
3193 // NightElf Male
3194 case 55: m_target->SetDisplayId(10143); break;
3195 // NightElf Female
3196 case 56: m_target->SetDisplayId(10144); break;
3197 // Undead Female
3198 case 58: m_target->SetDisplayId(10145); break;
3199 // Undead Male
3200 case 57: m_target->SetDisplayId(10146); break;
3201 // Tauren Female
3202 case 60: m_target->SetDisplayId(10147); break;
3203 // Gnome Male
3204 case 1563: m_target->SetDisplayId(10148); break;
3205 // Gnome Female
3206 case 1564: m_target->SetDisplayId(10149); break;
3207 // BloodElf Female
3208 case 15475: m_target->SetDisplayId(17830); break;
3209 // BloodElf Male
3210 case 15476: m_target->SetDisplayId(17829); break;
3211 // Dranei Female
3212 case 16126: m_target->SetDisplayId(17828); break;
3213 // Dranei Male
3214 case 16125: m_target->SetDisplayId(17827); break;
3215 default: break;
3217 break;
3219 // Murloc costume
3220 case 42365: m_target->SetDisplayId(21723); break;
3221 // Honor the Dead
3222 case 65386:
3223 case 65495:
3225 switch(m_target->getGender())
3227 case GENDER_MALE:
3228 m_target->SetDisplayId(29203); // Chapman
3229 break;
3230 case GENDER_FEMALE:
3231 case GENDER_NONE:
3232 m_target->SetDisplayId(29204); // Catrina
3233 break;
3235 break;
3237 default: break;
3240 else
3242 uint32 model_id;
3244 CreatureInfo const * ci = ObjectMgr::GetCreatureTemplate(m_modifier.m_miscvalue);
3245 if (!ci)
3247 model_id = 16358; // pig pink ^_^
3248 sLog.outError("Auras: unknown creature id = %d (only need its modelid) Form Spell Aura Transform in Spell ID = %d", m_modifier.m_miscvalue, GetId());
3250 else
3251 model_id = ci->DisplayID_A[0]; // Will use the default model here
3253 // Polymorph (sheep/penguin case)
3254 if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_MAGE && GetSpellProto()->SpellIconID == 82)
3255 if (Unit* caster = GetCaster())
3256 if (caster->HasAura(52648)) // Glyph of the Penguin
3257 model_id = 26452;
3259 m_target->SetDisplayId(model_id);
3261 // Dragonmaw Illusion (set mount model also)
3262 if(GetId()==42016 && m_target->GetMountID() && !m_target->GetAurasByType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED).empty())
3263 m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314);
3266 // update active transform spell only not set or not overwriting negative by positive case
3267 if (!m_target->getTransForm() || !IsPositiveSpell(GetId()) || IsPositiveSpell(m_target->getTransForm()))
3268 m_target->setTransForm(GetId());
3270 // polymorph case
3271 if (Real && m_target->GetTypeId() == TYPEID_PLAYER && m_target->IsPolymorphed())
3273 // for players, start regeneration after 1s (in polymorph fast regeneration case)
3274 // only if caster is Player (after patch 2.4.2)
3275 if (IS_PLAYER_GUID(GetCasterGUID()) )
3276 ((Player*)m_target)->setRegenTimer(1*IN_MILISECONDS);
3278 //dismount polymorphed target (after patch 2.4.2)
3279 if (m_target->IsMounted())
3280 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
3283 else
3285 // ApplyModifier(true) will reapply it if need
3286 m_target->setTransForm(0);
3287 m_target->SetDisplayId(m_target->GetNativeDisplayId());
3289 // re-aplly some from still active with preference negative cases
3290 Unit::AuraList const& otherTransforms = m_target->GetAurasByType(SPELL_AURA_TRANSFORM);
3291 if (!otherTransforms.empty())
3293 // look for other transform auras
3294 Aura* handledAura = *otherTransforms.begin();
3295 for(Unit::AuraList::const_iterator i = otherTransforms.begin();i != otherTransforms.end(); ++i)
3297 // negative auras are preferred
3298 if (!IsPositiveSpell((*i)->GetSpellProto()->Id))
3300 handledAura = *i;
3301 break;
3304 handledAura->ApplyModifier(true);
3307 // Dragonmaw Illusion (restore mount model)
3308 if (GetId() == 42016 && m_target->GetMountID() == 16314)
3310 if (!m_target->GetAurasByType(SPELL_AURA_MOUNTED).empty())
3312 uint32 cr_id = m_target->GetAurasByType(SPELL_AURA_MOUNTED).front()->GetModifier()->m_miscvalue;
3313 if (CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(cr_id))
3315 uint32 team = 0;
3316 if (m_target->GetTypeId() == TYPEID_PLAYER)
3317 team = ((Player*)m_target)->GetTeam();
3319 uint32 display_id = sObjectMgr.ChooseDisplayId(team, ci);
3320 CreatureModelInfo const *minfo = sObjectMgr.GetCreatureModelRandomGender(display_id);
3321 if (minfo)
3322 display_id = minfo->modelid;
3324 m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, display_id);
3331 void Aura::HandleForceReaction(bool apply, bool Real)
3333 if(m_target->GetTypeId() != TYPEID_PLAYER)
3334 return;
3336 if(!Real)
3337 return;
3339 Player* player = (Player*)m_target;
3341 uint32 faction_id = m_modifier.m_miscvalue;
3342 ReputationRank faction_rank = ReputationRank(m_modifier.m_amount);
3344 player->GetReputationMgr().ApplyForceReaction(faction_id, faction_rank, apply);
3345 player->GetReputationMgr().SendForceReactions();
3347 // stop fighting if at apply forced rank friendly or at remove real rank friendly
3348 if (apply && faction_rank >= REP_FRIENDLY || !apply && player->GetReputationRank(faction_id) >= REP_FRIENDLY)
3349 player->StopAttackFaction(faction_id);
3352 void Aura::HandleAuraModSkill(bool apply, bool /*Real*/)
3354 if(m_target->GetTypeId() != TYPEID_PLAYER)
3355 return;
3357 uint32 prot=GetSpellProto()->EffectMiscValue[m_effIndex];
3358 int32 points = GetModifier()->m_amount;
3360 ((Player*)m_target)->ModifySkillBonus(prot, (apply ? points: -points), m_modifier.m_auraname == SPELL_AURA_MOD_SKILL_TALENT);
3361 if(prot == SKILL_DEFENSE)
3362 ((Player*)m_target)->UpdateDefenseBonusesMod();
3365 void Aura::HandleChannelDeathItem(bool apply, bool Real)
3367 if(Real && !apply)
3369 if(m_removeMode != AURA_REMOVE_BY_DEATH)
3370 return;
3371 // Item amount
3372 if (m_modifier.m_amount <= 0)
3373 return;
3375 SpellEntry const *spellInfo = GetSpellProto();
3376 if(spellInfo->EffectItemType[m_effIndex] == 0)
3377 return;
3379 Unit* victim = GetTarget();
3380 Unit* caster = GetCaster();
3381 if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
3382 return;
3384 // Soul Shard only from non-grey units
3385 if( spellInfo->EffectItemType[m_effIndex] == 6265 &&
3386 (victim->getLevel() <= MaNGOS::XP::GetGrayLevel(caster->getLevel()) ||
3387 victim->GetTypeId()==TYPEID_UNIT && !((Player*)caster)->isAllowedToLoot((Creature*)victim)) )
3388 return;
3389 //Adding items
3390 uint32 noSpaceForCount = 0;
3391 uint32 count = m_modifier.m_amount;
3393 ItemPosCountVec dest;
3394 uint8 msg = ((Player*)caster)->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, spellInfo->EffectItemType[m_effIndex], count, &noSpaceForCount);
3395 if( msg != EQUIP_ERR_OK )
3397 count-=noSpaceForCount;
3398 ((Player*)caster)->SendEquipError( msg, NULL, NULL );
3399 if (count==0)
3400 return;
3403 Item* newitem = ((Player*)caster)->StoreNewItem(dest, spellInfo->EffectItemType[m_effIndex], true);
3404 ((Player*)caster)->SendNewItem(newitem, count, true, false);
3408 void Aura::HandleBindSight(bool apply, bool /*Real*/)
3410 Unit* caster = GetCaster();
3411 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3412 return;
3414 ((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);
3417 void Aura::HandleFarSight(bool apply, bool /*Real*/)
3419 Unit* caster = GetCaster();
3420 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3421 return;
3423 ((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);
3426 void Aura::HandleAuraTrackCreatures(bool apply, bool /*Real*/)
3428 if(m_target->GetTypeId()!=TYPEID_PLAYER)
3429 return;
3431 if(apply)
3432 m_target->RemoveNoStackAurasDueToAura(this);
3433 m_target->SetUInt32Value(PLAYER_TRACK_CREATURES, apply ? ((uint32)1)<<(m_modifier.m_miscvalue-1) : 0 );
3436 void Aura::HandleAuraTrackResources(bool apply, bool /*Real*/)
3438 if(m_target->GetTypeId()!=TYPEID_PLAYER)
3439 return;
3441 if(apply)
3442 m_target->RemoveNoStackAurasDueToAura(this);
3443 m_target->SetUInt32Value(PLAYER_TRACK_RESOURCES, apply ? ((uint32)1)<<(m_modifier.m_miscvalue-1): 0 );
3446 void Aura::HandleAuraTrackStealthed(bool apply, bool /*Real*/)
3448 if(m_target->GetTypeId()!=TYPEID_PLAYER)
3449 return;
3451 if(apply)
3452 m_target->RemoveNoStackAurasDueToAura(this);
3454 m_target->ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_TRACK_STEALTHED, apply);
3457 void Aura::HandleAuraModScale(bool apply, bool /*Real*/)
3459 m_target->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X, m_modifier.m_amount, apply);
3462 void Aura::HandleModPossess(bool apply, bool Real)
3464 if(!Real)
3465 return;
3467 // not possess yourself
3468 if(GetCasterGUID() == m_target->GetGUID())
3469 return;
3471 Unit* caster = GetCaster();
3472 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3473 return;
3475 Player* p_caster = (Player*)caster;
3478 if( apply )
3480 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
3482 m_target->SetCharmerGUID(p_caster->GetGUID());
3483 m_target->setFaction(p_caster->getFaction());
3485 p_caster->SetCharm(m_target);
3487 p_caster->SetFarSightGUID(m_target->GetGUID());
3488 p_caster->SetClientControl(m_target, 1);
3489 p_caster->SetMover(m_target);
3491 m_target->CombatStop();
3492 m_target->DeleteThreatList();
3494 if(m_target->GetTypeId() == TYPEID_UNIT)
3496 m_target->StopMoving();
3497 m_target->GetMotionMaster()->Clear();
3498 m_target->GetMotionMaster()->MoveIdle();
3500 else if(m_target->GetTypeId() == TYPEID_PLAYER)
3502 ((Player*)m_target)->SetClientControl(m_target, 0);
3505 if(CharmInfo *charmInfo = m_target->InitCharmInfo(m_target))
3506 charmInfo->InitPossessCreateSpells();
3508 p_caster->PossessSpellInitialize();
3510 else
3512 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
3514 m_target->SetCharmerGUID(0);
3515 p_caster->InterruptSpell(CURRENT_CHANNELED_SPELL); // the spell is not automatically canceled when interrupted, do it now
3517 if(m_target->GetTypeId() == TYPEID_PLAYER)
3519 ((Player*)m_target)->setFactionForRace(m_target->getRace());
3520 ((Player*)m_target)->SetClientControl(m_target, 1);
3522 else if(m_target->GetTypeId() == TYPEID_UNIT)
3524 CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
3525 m_target->setFaction(cinfo->faction_A);
3528 p_caster->SetCharm(NULL);
3530 p_caster->SetFarSightGUID(0);
3531 p_caster->SetClientControl(m_target, 0);
3532 p_caster->SetMover(NULL);
3534 p_caster->RemovePetActionBar();
3536 if(m_target->GetTypeId() == TYPEID_UNIT)
3538 ((Creature*)m_target)->AIM_Initialize();
3540 if (((Creature*)m_target)->AI())
3541 ((Creature*)m_target)->AI()->AttackedBy(caster);
3546 void Aura::HandleModPossessPet(bool apply, bool Real)
3548 if(!Real)
3549 return;
3551 Unit* caster = GetCaster();
3552 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3553 return;
3555 Pet *pet = caster->GetPet();
3556 if(!pet || pet != m_target)
3557 return;
3559 Player* p_caster = (Player*)caster;
3561 if(apply)
3562 pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
3563 else
3564 pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
3566 p_caster->SetFarSightGUID(apply ? pet->GetGUID() : 0);
3567 p_caster->SetCharm(apply ? pet : NULL);
3568 p_caster->SetClientControl(pet, apply ? 1 : 0);
3569 ((Player*)caster)->SetMover(apply ? pet : NULL);
3571 if(apply)
3573 pet->StopMoving();
3574 pet->GetMotionMaster()->Clear();
3575 pet->GetMotionMaster()->MoveIdle();
3577 else
3579 pet->AttackStop();
3580 pet->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
3581 pet->AddMonsterMoveFlag(MONSTER_MOVE_WALK);
3585 void Aura::HandleAuraModPetTalentsPoints(bool /*Apply*/, bool Real)
3587 if(!Real)
3588 return;
3590 // Recalculate pet talent points
3591 if (Pet *pet=m_target->GetPet())
3592 pet->InitTalentForLevel();
3595 void Aura::HandleModCharm(bool apply, bool Real)
3597 if(!Real)
3598 return;
3600 // not charm yourself
3601 if(GetCasterGUID() == m_target->GetGUID())
3602 return;
3604 Unit* caster = GetCaster();
3605 if(!caster)
3606 return;
3608 if( apply )
3610 if (m_target->GetCharmerGUID())
3612 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM);
3613 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS);
3616 m_target->SetCharmerGUID(GetCasterGUID());
3617 m_target->setFaction(caster->getFaction());
3618 m_target->CastStop(m_target == caster ? GetId() : 0);
3619 caster->SetCharm(m_target);
3621 m_target->CombatStop();
3622 m_target->DeleteThreatList();
3624 if(m_target->GetTypeId() == TYPEID_UNIT)
3626 ((Creature*)m_target)->AIM_Initialize();
3627 CharmInfo *charmInfo = m_target->InitCharmInfo(m_target);
3628 charmInfo->InitCharmCreateSpells();
3629 charmInfo->SetReactState( REACT_DEFENSIVE );
3631 if(caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK)
3633 CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
3634 if(cinfo && cinfo->type == CREATURE_TYPE_DEMON)
3636 // creature with pet number expected have class set
3637 if(m_target->GetByteValue(UNIT_FIELD_BYTES_0, 1)==0)
3639 if(cinfo->unit_class==0)
3640 sLog.outErrorDb("Creature (Entry: %u) have unit_class = 0 but used in charmed spell, that will be result client crash.",cinfo->Entry);
3641 else
3642 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);
3644 m_target->SetByteValue(UNIT_FIELD_BYTES_0, 1, CLASS_MAGE);
3647 //just to enable stat window
3648 charmInfo->SetPetNumber(sObjectMgr.GeneratePetNumber(), true);
3649 //if charmed two demons the same session, the 2nd gets the 1st one's name
3650 m_target->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL));
3655 if(caster->GetTypeId() == TYPEID_PLAYER)
3656 ((Player*)caster)->CharmSpellInitialize();
3658 else
3660 m_target->SetCharmerGUID(0);
3662 if(m_target->GetTypeId() == TYPEID_PLAYER)
3663 ((Player*)m_target)->setFactionForRace(m_target->getRace());
3664 else
3666 CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
3668 // restore faction
3669 if(((Creature*)m_target)->isPet())
3671 if(Unit* owner = m_target->GetOwner())
3672 m_target->setFaction(owner->getFaction());
3673 else if(cinfo)
3674 m_target->setFaction(cinfo->faction_A);
3676 else if(cinfo) // normal creature
3677 m_target->setFaction(cinfo->faction_A);
3679 // restore UNIT_FIELD_BYTES_0
3680 if(cinfo && caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK && cinfo->type == CREATURE_TYPE_DEMON)
3682 // DB must have proper class set in field at loading, not req. restore, including workaround case at apply
3683 // m_target->SetByteValue(UNIT_FIELD_BYTES_0, 1, cinfo->unit_class);
3685 if(m_target->GetCharmInfo())
3686 m_target->GetCharmInfo()->SetPetNumber(0, true);
3687 else
3688 sLog.outError("Aura::HandleModCharm: target (GUID: %u TypeId: %u) has a charm aura but no charm info!", m_target->GetGUIDLow(), m_target->GetTypeId());
3692 caster->SetCharm(NULL);
3694 if(caster->GetTypeId() == TYPEID_PLAYER)
3695 ((Player*)caster)->RemovePetActionBar();
3697 if(m_target->GetTypeId() == TYPEID_UNIT)
3699 ((Creature*)m_target)->AIM_Initialize();
3700 if (((Creature*)m_target)->AI())
3701 ((Creature*)m_target)->AI()->AttackedBy(caster);
3706 void Aura::HandleModConfuse(bool apply, bool Real)
3708 if(!Real)
3709 return;
3711 m_target->SetConfused(apply, GetCasterGUID(), GetId());
3714 void Aura::HandleModFear(bool apply, bool Real)
3716 if (!Real)
3717 return;
3719 m_target->SetFeared(apply, GetCasterGUID(), GetId());
3722 void Aura::HandleFeignDeath(bool apply, bool Real)
3724 if(!Real)
3725 return;
3727 m_target->SetFeignDeath(apply, GetCasterGUID(), GetId());
3730 void Aura::HandleAuraModDisarm(bool apply, bool Real)
3732 if(!Real)
3733 return;
3735 if(!apply && m_target->HasAuraType(SPELL_AURA_MOD_DISARM))
3736 return;
3738 // not sure for it's correctness
3739 if(apply)
3740 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
3741 else
3742 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
3744 // only at real add/remove aura
3745 if (m_target->GetTypeId() != TYPEID_PLAYER)
3746 return;
3748 // main-hand attack speed already set to special value for feral form already and don't must change and reset at remove.
3749 if (m_target->IsInFeralForm())
3750 return;
3752 if (apply)
3753 m_target->SetAttackTime(BASE_ATTACK,BASE_ATTACK_TIME);
3754 else
3755 ((Player *)m_target)->SetRegularAttackTime();
3757 m_target->UpdateDamagePhysical(BASE_ATTACK);
3760 void Aura::HandleAuraModStun(bool apply, bool Real)
3762 if(!Real)
3763 return;
3765 if (apply)
3767 // Frost stun aura -> freeze/unfreeze target
3768 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
3769 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
3771 m_target->addUnitState(UNIT_STAT_STUNNED);
3772 m_target->SetTargetGUID(0);
3774 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
3775 m_target->CastStop(m_target->GetGUID() == GetCasterGUID() ? GetId() : 0);
3777 // Creature specific
3778 if(m_target->GetTypeId() != TYPEID_PLAYER)
3779 m_target->StopMoving();
3780 else
3782 ((Player*)m_target)->m_movementInfo.SetMovementFlags(MOVEMENTFLAG_NONE);
3783 m_target->SetStandState(UNIT_STAND_STATE_STAND);// in 1.5 client
3786 WorldPacket data(SMSG_FORCE_MOVE_ROOT, 8);
3787 data.append(m_target->GetPackGUID());
3788 data << uint32(0);
3789 m_target->SendMessageToSet(&data, true);
3791 // Summon the Naj'entus Spine GameObject on target if spell is Impaling Spine
3792 if(GetId() == 39837)
3794 GameObject* pObj = new GameObject;
3795 if(pObj->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 185584, m_target->GetMap(), m_target->GetPhaseMask(),
3796 m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
3798 pObj->SetRespawnTime(GetAuraDuration()/IN_MILISECONDS);
3799 pObj->SetSpellId(GetId());
3800 m_target->AddGameObject(pObj);
3801 m_target->GetMap()->Add(pObj);
3803 else
3804 delete pObj;
3807 else
3809 // Frost stun aura -> freeze/unfreeze target
3810 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
3812 bool found_another = false;
3813 for(AuraType const* itr = &frozenAuraTypes[0]; *itr != SPELL_AURA_NONE; ++itr)
3815 Unit::AuraList const& auras = m_target->GetAurasByType(*itr);
3816 for(Unit::AuraList::const_iterator i = auras.begin(); i != auras.end(); ++i)
3818 if( GetSpellSchoolMask((*i)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST)
3820 found_another = true;
3821 break;
3824 if(found_another)
3825 break;
3828 if(!found_another)
3829 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
3832 // Real remove called after current aura remove from lists, check if other similar auras active
3833 if(m_target->HasAuraType(SPELL_AURA_MOD_STUN))
3834 return;
3836 m_target->clearUnitState(UNIT_STAT_STUNNED);
3837 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
3839 if(!m_target->hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect
3841 if(m_target->getVictim() && m_target->isAlive())
3842 m_target->SetTargetGUID(m_target->getVictim()->GetGUID());
3844 WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 8+4);
3845 data.append(m_target->GetPackGUID());
3846 data << uint32(0);
3847 m_target->SendMessageToSet(&data, true);
3850 // Wyvern Sting
3851 if (m_spellProto->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellProto->SpellFamilyFlags & UI64LIT(0x0000100000000000))
3853 Unit* caster = GetCaster();
3854 if( !caster || caster->GetTypeId()!=TYPEID_PLAYER )
3855 return;
3857 uint32 spell_id = 0;
3859 switch(GetId())
3861 case 19386: spell_id = 24131; break;
3862 case 24132: spell_id = 24134; break;
3863 case 24133: spell_id = 24135; break;
3864 case 27068: spell_id = 27069; break;
3865 case 49011: spell_id = 49009; break;
3866 case 49012: spell_id = 49010; break;
3867 default:
3868 sLog.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?",GetId());
3869 return;
3872 SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id);
3874 if(!spellInfo)
3875 return;
3877 caster->CastSpell(m_target,spellInfo,true,NULL,this);
3878 return;
3883 void Aura::HandleModStealth(bool apply, bool Real)
3885 if (apply)
3887 // drop flag at stealth in bg
3888 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
3890 // only at real aura add
3891 if (Real)
3893 m_target->SetStandFlags(UNIT_STAND_FLAGS_CREEP);
3895 if (m_target->GetTypeId()==TYPEID_PLAYER)
3896 m_target->SetFlag(PLAYER_FIELD_BYTES2, 0x2000);
3898 // apply only if not in GM invisibility (and overwrite invisibility state)
3899 if (m_target->GetVisibility()!=VISIBILITY_OFF)
3901 m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
3902 m_target->SetVisibility(VISIBILITY_GROUP_STEALTH);
3905 // apply full stealth period bonuses only at first stealth aura in stack
3906 if(m_target->GetAurasByType(SPELL_AURA_MOD_STEALTH).size()<=1)
3908 Unit::AuraList const& mDummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
3909 for(Unit::AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i)
3911 // Master of Subtlety
3912 if ((*i)->GetSpellProto()->SpellIconID == 2114)
3914 m_target->RemoveAurasDueToSpell(31666);
3915 int32 bp = (*i)->GetModifier()->m_amount;
3916 m_target->CastCustomSpell(m_target,31665,&bp,NULL,NULL,true);
3918 // Overkill
3919 else if ((*i)->GetId() == 58426 && GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000400000))
3921 m_target->RemoveAurasDueToSpell(58428);
3922 m_target->CastSpell(m_target, 58427, true);
3928 else
3930 // only at real aura remove of _last_ SPELL_AURA_MOD_STEALTH
3931 if (Real && !m_target->HasAuraType(SPELL_AURA_MOD_STEALTH))
3933 // if no GM invisibility
3934 if (m_target->GetVisibility()!=VISIBILITY_OFF)
3936 m_target->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP);
3938 if (m_target->GetTypeId()==TYPEID_PLAYER)
3939 m_target->RemoveFlag(PLAYER_FIELD_BYTES2, 0x2000);
3941 // restore invisibility if any
3942 if (m_target->HasAuraType(SPELL_AURA_MOD_INVISIBILITY))
3944 m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
3945 m_target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY);
3947 else
3948 m_target->SetVisibility(VISIBILITY_ON);
3951 // apply delayed talent bonus remover at last stealth aura remove
3952 Unit::AuraList const& mDummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
3953 for(Unit::AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i)
3955 // Master of Subtlety
3956 if ((*i)->GetSpellProto()->SpellIconID == 2114)
3957 m_target->CastSpell(m_target, 31666, true);
3958 // Overkill
3959 else if ((*i)->GetId() == 58426 && GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000400000))
3960 m_target->CastSpell(m_target, 58428, true);
3966 void Aura::HandleInvisibility(bool apply, bool Real)
3968 if(apply)
3970 m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue);
3972 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
3974 if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
3976 // apply glow vision
3977 m_target->SetFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
3981 // apply only if not in GM invisibility and not stealth
3982 if(m_target->GetVisibility() == VISIBILITY_ON)
3984 // Aura not added yet but visibility code expect temporary add aura
3985 m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
3986 m_target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY);
3989 else
3991 // recalculate value at modifier remove (current aura already removed)
3992 m_target->m_invisibilityMask = 0;
3993 Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY);
3994 for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
3995 m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue);
3997 // only at real aura remove and if not have different invisibility auras.
3998 if(Real && m_target->m_invisibilityMask == 0)
4000 // remove glow vision
4001 if(m_target->GetTypeId() == TYPEID_PLAYER)
4002 m_target->RemoveFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
4004 // apply only if not in GM invisibility & not stealthed while invisible
4005 if(m_target->GetVisibility() != VISIBILITY_OFF)
4007 // if have stealth aura then already have stealth visibility
4008 if(!m_target->HasAuraType(SPELL_AURA_MOD_STEALTH))
4009 m_target->SetVisibility(VISIBILITY_ON);
4015 void Aura::HandleInvisibilityDetect(bool apply, bool Real)
4017 if(apply)
4019 m_target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue);
4021 else
4023 // recalculate value at modifier remove (current aura already removed)
4024 m_target->m_detectInvisibilityMask = 0;
4025 Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION);
4026 for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
4027 m_target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue);
4029 if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
4030 ((Player*)m_target)->UpdateVisibilityForPlayer();
4033 void Aura::HandleAuraModRoot(bool apply, bool Real)
4035 // only at real add/remove aura
4036 if(!Real)
4037 return;
4039 if (apply)
4041 // Frost root aura -> freeze/unfreeze target
4042 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
4043 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
4045 m_target->addUnitState(UNIT_STAT_ROOT);
4046 m_target->SetTargetGUID(0);
4047 // probably wrong (this add skinnable flag)
4048 // TODO: find correct flag
4049 //m_target->SetFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
4051 //Save last orientation
4052 if( m_target->getVictim() )
4053 m_target->SetOrientation(m_target->GetAngle(m_target->getVictim()));
4055 if(m_target->GetTypeId() == TYPEID_PLAYER)
4057 WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10);
4058 data.append(m_target->GetPackGUID());
4059 data << (uint32)2;
4060 m_target->SendMessageToSet(&data, true);
4062 //Clear unit movement flags
4063 ((Player*)m_target)->m_movementInfo.SetMovementFlags(MOVEMENTFLAG_NONE);
4065 else
4066 m_target->StopMoving();
4068 else
4070 // Frost root aura -> freeze/unfreeze target
4071 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
4073 bool found_another = false;
4074 for(AuraType const* itr = &frozenAuraTypes[0]; *itr != SPELL_AURA_NONE; ++itr)
4076 Unit::AuraList const& auras = m_target->GetAurasByType(*itr);
4077 for(Unit::AuraList::const_iterator i = auras.begin(); i != auras.end(); ++i)
4079 if( GetSpellSchoolMask((*i)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST)
4081 found_another = true;
4082 break;
4085 if(found_another)
4086 break;
4089 if(!found_another)
4090 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
4093 // Real remove called after current aura remove from lists, check if other similar auras active
4094 if(m_target->HasAuraType(SPELL_AURA_MOD_ROOT))
4095 return;
4097 m_target->clearUnitState(UNIT_STAT_ROOT);
4098 // probably wrong (this add skinnable flag)
4099 // TODO: find correct flag
4100 //m_target->RemoveFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
4102 if(!m_target->hasUnitState(UNIT_STAT_STUNNED)) // prevent allow move if have also stun effect
4104 if(m_target->getVictim() && m_target->isAlive())
4105 m_target->SetTargetGUID(m_target->getVictim()->GetGUID());
4107 if(m_target->GetTypeId() == TYPEID_PLAYER)
4109 WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 10);
4110 data.append(m_target->GetPackGUID());
4111 data << (uint32)2;
4112 m_target->SendMessageToSet(&data, true);
4118 void Aura::HandleAuraModSilence(bool apply, bool Real)
4120 // only at real add/remove aura
4121 if(!Real)
4122 return;
4124 if(apply)
4126 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED);
4127 // Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE
4128 for (uint32 i = CURRENT_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
4129 if (Spell* spell = m_target->GetCurrentSpell(CurrentSpellTypes(i)))
4130 if(spell->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
4131 // Stop spells on prepare or casting state
4132 m_target->InterruptSpell(CurrentSpellTypes(i), false);
4134 else
4136 // Real remove called after current aura remove from lists, check if other similar auras active
4137 if(m_target->HasAuraType(SPELL_AURA_MOD_SILENCE))
4138 return;
4140 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED);
4144 void Aura::HandleModThreat(bool apply, bool Real)
4146 // only at real add/remove aura
4147 if (!Real)
4148 return;
4150 if (!m_target->isAlive())
4151 return;
4153 Unit* caster = GetCaster();
4155 if (!caster || !caster->isAlive())
4156 return;
4158 int level_diff = 0;
4159 int multiplier = 0;
4160 switch (GetId())
4162 // Arcane Shroud
4163 case 26400:
4164 level_diff = m_target->getLevel() - 60;
4165 multiplier = 2;
4166 break;
4167 // The Eye of Diminution
4168 case 28862:
4169 level_diff = m_target->getLevel() - 60;
4170 multiplier = 1;
4171 break;
4174 if (level_diff > 0)
4175 m_modifier.m_amount += multiplier * level_diff;
4177 if (m_target->GetTypeId() == TYPEID_PLAYER)
4178 for(int8 x=0;x < MAX_SPELL_SCHOOL;x++)
4179 if (m_modifier.m_miscvalue & int32(1<<x))
4180 ApplyPercentModFloatVar(m_target->m_threatModifier[x], m_modifier.m_amount, apply);
4183 void Aura::HandleAuraModTotalThreat(bool apply, bool Real)
4185 // only at real add/remove aura
4186 if (!Real)
4187 return;
4189 if (!m_target->isAlive() || m_target->GetTypeId() != TYPEID_PLAYER)
4190 return;
4192 Unit* caster = GetCaster();
4194 if (!caster || !caster->isAlive())
4195 return;
4197 float threatMod = apply ? float(m_modifier.m_amount) : float(-m_modifier.m_amount);
4199 m_target->getHostileRefManager().threatAssist(caster, threatMod, GetSpellProto());
4202 void Aura::HandleModTaunt(bool apply, bool Real)
4204 // only at real add/remove aura
4205 if (!Real)
4206 return;
4208 if (!m_target->isAlive() || !m_target->CanHaveThreatList())
4209 return;
4211 Unit* caster = GetCaster();
4213 if (!caster || !caster->isAlive())
4214 return;
4216 if (apply)
4217 m_target->TauntApply(caster);
4218 else
4220 // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat
4221 m_target->TauntFadeOut(caster);
4225 /*********************************************************/
4226 /*** MODIFY SPEED ***/
4227 /*********************************************************/
4228 void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real)
4230 // all applied/removed only at real aura add/remove
4231 if(!Real)
4232 return;
4234 m_target->UpdateSpeed(MOVE_RUN, true);
4237 void Aura::HandleAuraModIncreaseMountedSpeed(bool apply, bool Real)
4239 // all applied/removed only at real aura add/remove
4240 if(!Real)
4241 return;
4243 m_target->UpdateSpeed(MOVE_RUN, true);
4245 // Festive Holiday Mount
4246 if (apply && GetSpellProto()->SpellIconID != 1794 && m_target->HasAura(62061))
4247 // Reindeer Transformation
4248 m_target->CastSpell(m_target, 25860, true, NULL, this);
4251 void Aura::HandleAuraModIncreaseFlightSpeed(bool apply, bool Real)
4253 // all applied/removed only at real aura add/remove
4254 if(!Real)
4255 return;
4257 // Enable Fly mode for flying mounts
4258 if (m_modifier.m_auraname == SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED)
4260 WorldPacket data;
4261 if(apply)
4262 data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
4263 else
4264 data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
4265 data.append(m_target->GetPackGUID());
4266 data << uint32(0); // unknown
4267 m_target->SendMessageToSet(&data, true);
4269 //Players on flying mounts must be immune to polymorph
4270 if (m_target->GetTypeId()==TYPEID_PLAYER)
4271 m_target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,MECHANIC_POLYMORPH,apply);
4273 // Dragonmaw Illusion (overwrite mount model, mounted aura already applied)
4274 if( apply && m_target->HasAura(42016,0) && m_target->GetMountID())
4275 m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314);
4277 // Festive Holiday Mount
4278 if (apply && GetSpellProto()->SpellIconID != 1794 && m_target->HasAura(62061))
4279 // Reindeer Transformation
4280 m_target->CastSpell(m_target, 25860, true, NULL, this);
4283 m_target->UpdateSpeed(MOVE_FLIGHT, true);
4286 void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real)
4288 // all applied/removed only at real aura add/remove
4289 if(!Real)
4290 return;
4292 m_target->UpdateSpeed(MOVE_SWIM, true);
4295 void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real)
4297 // all applied/removed only at real aura add/remove
4298 if(!Real)
4299 return;
4301 if (apply)
4303 // Gronn Lord's Grasp, becomes stoned
4304 if (GetId() == 33572)
4306 if (GetStackAmount() >= 5 && !m_target->HasAura(33652))
4307 m_target->CastSpell(m_target, 33652, true);
4311 m_target->UpdateSpeed(MOVE_RUN, true);
4312 m_target->UpdateSpeed(MOVE_SWIM, true);
4313 m_target->UpdateSpeed(MOVE_FLIGHT, true);
4316 void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real)
4318 // all applied/removed only at real aura add/remove
4319 if(!Real)
4320 return;
4322 m_target->UpdateSpeed(MOVE_RUN, true);
4323 m_target->UpdateSpeed(MOVE_SWIM, true);
4324 m_target->UpdateSpeed(MOVE_FLIGHT, true);
4327 /*********************************************************/
4328 /*** IMMUNITY ***/
4329 /*********************************************************/
4331 void Aura::HandleModMechanicImmunity(bool apply, bool /*Real*/)
4333 uint32 misc = m_modifier.m_miscvalue;
4334 // Forbearance
4335 // in DBC wrong mechanic immune since 3.0.x
4336 if (GetId() == 25771)
4337 misc = MECHANIC_IMMUNE_SHIELD;
4340 if(apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
4342 uint32 mechanic = 1 << (misc-1);
4344 //immune movement impairment and loss of control
4345 if(GetId()==42292 || GetId()==59752)
4346 mechanic=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
4348 m_target->RemoveAurasAtMechanicImmunity(mechanic,GetId());
4351 m_target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,misc,apply);
4353 // Bestial Wrath
4354 if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellProto()->SpellIconID == 1680)
4356 // The Beast Within cast on owner if talent present
4357 if (Unit* owner = m_target->GetOwner())
4359 // Search talent
4360 Unit::AuraList const& dummyAuras = owner->GetAurasByType(SPELL_AURA_DUMMY);
4361 for(Unit::AuraList::const_iterator i = dummyAuras.begin(); i != dummyAuras.end(); ++i)
4363 if ((*i)->GetSpellProto()->SpellIconID == 2229)
4365 if (apply)
4366 owner->CastSpell(owner, 34471, true, 0, this);
4367 else
4368 owner->RemoveAurasDueToSpell(34471);
4369 break;
4376 void Aura::HandleModMechanicImmunityMask(bool apply, bool /*Real*/)
4378 uint32 mechanic = m_modifier.m_miscvalue;
4380 if(apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
4381 m_target->RemoveAurasAtMechanicImmunity(mechanic,GetId());
4383 // check implemented in Unit::IsImmunedToSpell and Unit::IsImmunedToSpellEffect
4386 //this method is called whenever we add / remove aura which gives m_target some imunity to some spell effect
4387 void Aura::HandleAuraModEffectImmunity(bool apply, bool /*Real*/)
4389 // when removing flag aura, handle flag drop
4390 if( !apply && m_target->GetTypeId() == TYPEID_PLAYER
4391 && (GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION) )
4393 if( BattleGround *bg = ((Player*)m_target)->GetBattleGround() )
4394 bg->EventPlayerDroppedFlag(((Player*)m_target));
4397 m_target->ApplySpellImmune(GetId(), IMMUNITY_EFFECT, m_modifier.m_miscvalue, apply);
4400 void Aura::HandleAuraModStateImmunity(bool apply, bool Real)
4402 if(apply && Real && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
4404 Unit::AuraList const& auraList = m_target->GetAurasByType(AuraType(m_modifier.m_miscvalue));
4405 for(Unit::AuraList::const_iterator itr = auraList.begin(); itr != auraList.end();)
4407 if (auraList.front() != this) // skip itself aura (it already added)
4409 m_target->RemoveAurasDueToSpell(auraList.front()->GetId());
4410 itr = auraList.begin();
4412 else
4413 ++itr;
4417 m_target->ApplySpellImmune(GetId(), IMMUNITY_STATE, m_modifier.m_miscvalue, apply);
4420 void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real)
4422 m_target->ApplySpellImmune(GetId(), IMMUNITY_SCHOOL, m_modifier.m_miscvalue, apply);
4424 // remove all flag auras (they are positive, but they must be removed when you are immune)
4425 if( this->GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
4426 && this->GetSpellProto()->AttributesEx2 & SPELL_ATTR_EX2_DAMAGE_REDUCED_SHIELD )
4427 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
4429 // TODO: optimalize this cycle - use RemoveAurasWithInterruptFlags call or something else
4430 if( Real && apply
4431 && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
4432 && IsPositiveSpell(GetId()) ) //Only positive immunity removes auras
4434 uint32 school_mask = m_modifier.m_miscvalue;
4435 Unit::AuraMap& Auras = m_target->GetAuras();
4436 for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next)
4438 next = iter;
4439 ++next;
4440 SpellEntry const *spell = iter->second->GetSpellProto();
4441 if((GetSpellSchoolMask(spell) & school_mask)//Check for school mask
4442 && !( spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) //Spells unaffected by invulnerability
4443 && !iter->second->IsPositive() //Don't remove positive spells
4444 && spell->Id != GetId() ) //Don't remove self
4446 m_target->RemoveAurasDueToSpell(spell->Id);
4447 if(Auras.empty())
4448 break;
4449 else
4450 next = Auras.begin();
4454 if( Real && GetSpellProto()->Mechanic == MECHANIC_BANISH )
4456 if( apply )
4457 m_target->addUnitState(UNIT_STAT_ISOLATED);
4458 else
4459 m_target->clearUnitState(UNIT_STAT_ISOLATED);
4463 void Aura::HandleAuraModDmgImmunity(bool apply, bool /*Real*/)
4465 m_target->ApplySpellImmune(GetId(), IMMUNITY_DAMAGE, m_modifier.m_miscvalue, apply);
4468 void Aura::HandleAuraModDispelImmunity(bool apply, bool Real)
4470 // all applied/removed only at real aura add/remove
4471 if(!Real)
4472 return;
4474 m_target->ApplySpellDispelImmunity(m_spellProto, DispelType(m_modifier.m_miscvalue), apply);
4477 void Aura::HandleAuraProcTriggerSpell(bool apply, bool Real)
4479 if(!Real)
4480 return;
4482 if(apply)
4484 // some spell have charges by functionality not have its in spell data
4485 switch (GetId())
4487 case 28200: // Ascendance (Talisman of Ascendance trinket)
4488 SetAuraCharges(6);
4489 break;
4490 default: break;
4495 void Aura::HandleAuraModStalked(bool apply, bool /*Real*/)
4497 // used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND
4498 if(apply)
4499 m_target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT);
4500 else
4501 m_target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT);
4504 /*********************************************************/
4505 /*** PERIODIC ***/
4506 /*********************************************************/
4508 void Aura::HandlePeriodicTriggerSpell(bool apply, bool /*Real*/)
4510 m_isPeriodic = apply;
4512 if (!apply)
4514 switch(m_spellProto->Id)
4516 case 66: // Invisibility
4517 if (m_removeMode == AURA_REMOVE_BY_DEFAULT && m_duration<=0)
4518 m_target->CastSpell(m_target, 32612, true, NULL, this);
4520 return;
4521 case 42783: //Wrath of the Astrom...
4522 if (m_removeMode == AURA_REMOVE_BY_DEFAULT && GetEffIndex() + 1 < 3)
4523 m_target->CastSpell(m_target, m_spellProto->CalculateSimpleValue(GetEffIndex()+1), true);
4524 return;
4525 default:
4526 break;
4531 void Aura::HandlePeriodicTriggerSpellWithValue(bool apply, bool /*Real*/)
4533 m_isPeriodic = apply;
4536 void Aura::HandlePeriodicEnergize(bool apply, bool Real)
4538 if (!Real)
4539 return;
4541 // For prevent double apply bonuses
4542 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
4544 if (apply && !loading)
4546 switch (GetId())
4548 case 54833: // Glyph of Innervate (value%/2 of casters base mana)
4550 if (Unit* caster = GetCaster())
4551 m_modifier.m_amount = int32(caster->GetCreateMana() * GetBasePoints() / (200 * GetAuraMaxTicks()));
4552 break;
4555 case 29166: // Innervate (value% of casters base mana)
4557 if (Unit* caster = GetCaster())
4559 // Glyph of Innervate
4560 if (caster->HasAura(54832))
4561 caster->CastSpell(caster,54833,true,NULL,this);
4563 m_modifier.m_amount = int32(caster->GetCreateMana() * GetBasePoints() / (100 * GetAuraMaxTicks()));
4565 break;
4567 case 48391: // Owlkin Frenzy 2% base mana
4568 m_modifier.m_amount = m_target->GetCreateMana() * 2 / 100;
4569 break;
4570 case 57669: // Replenishment (0.2% from max)
4571 case 61782: // Infinite Replenishment
4572 m_modifier.m_amount = m_target->GetMaxPower(POWER_MANA) * 2 / 1000;
4573 break;
4574 default:
4575 break;
4579 m_isPeriodic = apply;
4582 void Aura::HandleAuraPowerBurn(bool apply, bool /*Real*/)
4584 m_isPeriodic = apply;
4587 void Aura::HandleAuraPeriodicDummy(bool apply, bool Real)
4589 // spells required only Real aura add/remove
4590 if(!Real)
4591 return;
4593 // For prevent double apply bonuses
4594 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
4596 SpellEntry const*spell = GetSpellProto();
4597 switch( spell->SpellFamilyName)
4599 case SPELLFAMILY_ROGUE:
4601 if(!apply)
4603 switch(spell->Id)
4605 // Master of Subtlety
4606 case 31666: m_target->RemoveAurasDueToSpell(31665); break;
4607 // Overkill
4608 case 58428: m_target->RemoveAurasDueToSpell(58427); break;
4611 break;
4613 case SPELLFAMILY_HUNTER:
4615 Unit* caster = GetCaster();
4617 // Explosive Shot
4618 if (apply && !loading && caster)
4619 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 14 / 100);
4620 break;
4624 m_isPeriodic = apply;
4627 void Aura::HandlePeriodicHeal(bool apply, bool /*Real*/)
4629 m_isPeriodic = apply;
4632 void Aura::HandlePeriodicDamage(bool apply, bool Real)
4634 // spells required only Real aura add/remove
4635 if(!Real)
4636 return;
4638 m_isPeriodic = apply;
4640 // For prevent double apply bonuses
4641 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
4643 // Custom damage calculation after
4644 if (apply)
4646 if(loading)
4647 return;
4649 Unit *caster = GetCaster();
4650 if (!caster)
4651 return;
4653 switch (m_spellProto->SpellFamilyName)
4655 case SPELLFAMILY_GENERIC:
4657 // Pounce Bleed
4658 if ( m_spellProto->SpellIconID == 147 && m_spellProto->SpellVisual[0] == 0 )
4660 // $AP*0.18/6 bonus per tick
4661 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 3 / 100);
4662 return;
4664 break;
4666 case SPELLFAMILY_WARRIOR:
4668 // Rend
4669 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000020))
4671 // $0.2*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick
4672 float ap = caster->GetTotalAttackPowerValue(BASE_ATTACK);
4673 int32 mws = caster->GetAttackTime(BASE_ATTACK);
4674 float mwb_min = caster->GetWeaponDamageRange(BASE_ATTACK,MINDAMAGE);
4675 float mwb_max = caster->GetWeaponDamageRange(BASE_ATTACK,MAXDAMAGE);
4676 m_modifier.m_amount+=int32(((mwb_min+mwb_max)/2+ap*mws/14000)*0.2f);
4677 return;
4679 break;
4681 case SPELLFAMILY_DRUID:
4683 // Rake
4684 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000001000) && m_spellProto->Effect[2]==SPELL_EFFECT_ADD_COMBO_POINTS)
4686 // $AP*0.18/3 bonus per tick
4687 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 6 / 100);
4688 return;
4690 // Lacerate
4691 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x000000010000000000))
4693 // $AP*0.05/5 bonus per tick
4694 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100);
4695 return;
4697 // Rip
4698 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x000000000000800000))
4700 // 0.01*$AP*cp
4701 if (caster->GetTypeId() != TYPEID_PLAYER)
4702 return;
4704 uint8 cp = ((Player*)caster)->GetComboPoints();
4706 // Idol of Feral Shadows. Cant be handled as SpellMod in SpellAura:Dummy due its dependency from CPs
4707 Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY);
4708 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
4710 if((*itr)->GetId()==34241)
4712 m_modifier.m_amount += cp * (*itr)->GetModifier()->m_amount;
4713 break;
4716 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * cp / 100);
4717 return;
4719 // Lock Jaw
4720 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x1000000000000000))
4722 // 0.15*$AP
4723 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 15 / 100);
4724 return;
4726 break;
4728 case SPELLFAMILY_ROGUE:
4730 // Rupture
4731 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x000000000000100000))
4733 if (caster->GetTypeId() != TYPEID_PLAYER)
4734 return;
4735 //1 point : ${($m1+$b1*1+0.015*$AP)*4} damage over 8 secs
4736 //2 points: ${($m1+$b1*2+0.024*$AP)*5} damage over 10 secs
4737 //3 points: ${($m1+$b1*3+0.03*$AP)*6} damage over 12 secs
4738 //4 points: ${($m1+$b1*4+0.03428571*$AP)*7} damage over 14 secs
4739 //5 points: ${($m1+$b1*5+0.0375*$AP)*8} damage over 16 secs
4740 float AP_per_combo[6] = {0.0f, 0.015f, 0.024f, 0.03f, 0.03428571f, 0.0375f};
4741 uint8 cp = ((Player*)caster)->GetComboPoints();
4742 if (cp > 5) cp = 5;
4743 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * AP_per_combo[cp]);
4744 return;
4746 // Garrote
4747 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x000000000000000100))
4749 // $AP*0.07 bonus per tick
4750 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 7 / 100);
4751 return;
4753 // Deadly Poison
4754 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000010000))
4756 // 0.08*$AP / 4 * amount of stack
4757 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 2 * GetStackAmount() / 100);
4758 return;
4760 break;
4762 case SPELLFAMILY_HUNTER:
4764 // Serpent Sting
4765 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000004000))
4767 // $RAP*0.2/5 bonus per tick
4768 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.2 / 5);
4769 return;
4771 // Immolation Trap
4772 if ((m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000004)) && m_spellProto->SpellIconID == 678)
4774 // $RAP*0.1/5 bonus per tick
4775 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 10 / 500);
4776 return;
4778 break;
4780 default:
4781 break;
4784 // remove time effects
4785 else
4787 // Parasitic Shadowfiend - handle summoning of two Shadowfiends on DoT expire
4788 if(m_spellProto->Id == 41917)
4789 m_target->CastSpell(m_target, 41915, true);
4793 void Aura::HandlePeriodicDamagePCT(bool apply, bool /*Real*/)
4795 m_isPeriodic = apply;
4798 void Aura::HandlePeriodicLeech(bool apply, bool /*Real*/)
4800 m_isPeriodic = apply;
4803 void Aura::HandlePeriodicManaLeech(bool apply, bool /*Real*/)
4805 m_isPeriodic = apply;
4808 void Aura::HandlePeriodicHealthFunnel(bool apply, bool /*Real*/)
4810 m_isPeriodic = apply;
4813 /*********************************************************/
4814 /*** MODIFY STATS ***/
4815 /*********************************************************/
4817 /********************************/
4818 /*** RESISTANCE ***/
4819 /********************************/
4821 void Aura::HandleAuraModResistanceExclusive(bool apply, bool /*Real*/)
4823 for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++)
4825 if(m_modifier.m_miscvalue & int32(1<<x))
4827 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_VALUE, float(m_modifier.m_amount), apply);
4828 if(m_target->GetTypeId() == TYPEID_PLAYER)
4829 m_target->ApplyResistanceBuffModsMod(SpellSchools(x), m_positive, m_modifier.m_amount, apply);
4834 void Aura::HandleAuraModResistance(bool apply, bool /*Real*/)
4836 for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++)
4838 if(m_modifier.m_miscvalue & int32(1<<x))
4840 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), TOTAL_VALUE, float(m_modifier.m_amount), apply);
4841 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
4842 m_target->ApplyResistanceBuffModsMod(SpellSchools(x), m_positive, m_modifier.m_amount, apply);
4847 void Aura::HandleAuraModBaseResistancePCT(bool apply, bool /*Real*/)
4849 // only players have base stats
4850 if(m_target->GetTypeId() != TYPEID_PLAYER)
4852 //pets only have base armor
4853 if(((Creature*)m_target)->isPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL))
4854 m_target->HandleStatModifier(UNIT_MOD_ARMOR, BASE_PCT, float(m_modifier.m_amount), apply);
4856 else
4858 for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++)
4860 if(m_modifier.m_miscvalue & int32(1<<x))
4861 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_PCT, float(m_modifier.m_amount), apply);
4866 void Aura::HandleModResistancePercent(bool apply, bool /*Real*/)
4868 for(int8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++)
4870 if(m_modifier.m_miscvalue & int32(1<<i))
4872 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply);
4873 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
4875 m_target->ApplyResistanceBuffModsPercentMod(SpellSchools(i), true, m_modifier.m_amount, apply);
4876 m_target->ApplyResistanceBuffModsPercentMod(SpellSchools(i), false, m_modifier.m_amount, apply);
4882 void Aura::HandleModBaseResistance(bool apply, bool /*Real*/)
4884 // only players have base stats
4885 if(m_target->GetTypeId() != TYPEID_PLAYER)
4887 //only pets have base stats
4888 if(((Creature*)m_target)->isPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL))
4889 m_target->HandleStatModifier(UNIT_MOD_ARMOR, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4891 else
4893 for(int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++)
4894 if(m_modifier.m_miscvalue & (1<<i))
4895 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply);
4899 /********************************/
4900 /*** STAT ***/
4901 /********************************/
4903 void Aura::HandleAuraModStat(bool apply, bool /*Real*/)
4905 if (m_modifier.m_miscvalue < -2 || m_modifier.m_miscvalue > 4)
4907 sLog.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ",GetId(),GetEffIndex(),m_modifier.m_miscvalue);
4908 return;
4911 for(int32 i = STAT_STRENGTH; i < MAX_STATS; i++)
4913 // -1 or -2 is all stats ( misc < -2 checked in function beginning )
4914 if (m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue == i)
4916 //m_target->ApplyStatMod(Stats(i), m_modifier.m_amount,apply);
4917 m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply);
4918 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
4919 m_target->ApplyStatBuffMod(Stats(i), m_modifier.m_amount, apply);
4924 void Aura::HandleModPercentStat(bool apply, bool /*Real*/)
4926 if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4)
4928 sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
4929 return;
4932 // only players have base stats
4933 if (m_target->GetTypeId() != TYPEID_PLAYER)
4934 return;
4936 for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i)
4938 if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1)
4939 m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), BASE_PCT, float(m_modifier.m_amount), apply);
4943 void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool /*Real*/)
4945 if(m_target->GetTypeId() != TYPEID_PLAYER)
4946 return;
4948 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4949 // This information for client side use only
4950 // Recalculate bonus
4951 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4954 void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool /*Real*/)
4956 if(m_target->GetTypeId() != TYPEID_PLAYER)
4957 return;
4959 // Recalculate bonus
4960 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4963 void Aura::HandleAuraModDispelResist(bool apply, bool Real)
4965 if(!Real || !apply)
4966 return;
4968 if(GetId() == 33206)
4969 m_target->CastSpell(m_target, 44416, true, NULL, this, GetCasterGUID());
4972 void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool /*Real*/)
4974 if(m_target->GetTypeId() != TYPEID_PLAYER)
4975 return;
4977 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4978 // This information for client side use only
4979 // Recalculate bonus
4980 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4983 void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool /*Real*/)
4985 if(m_target->GetTypeId() != TYPEID_PLAYER)
4986 return;
4988 // Recalculate bonus
4989 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4992 void Aura::HandleModHealingDone(bool /*apply*/, bool /*Real*/)
4994 if(m_target->GetTypeId() != TYPEID_PLAYER)
4995 return;
4996 // implemented in Unit::SpellHealingBonus
4997 // this information is for client side only
4998 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
5001 void Aura::HandleModTotalPercentStat(bool apply, bool /*Real*/)
5003 if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4)
5005 sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
5006 return;
5009 //save current and max HP before applying aura
5010 uint32 curHPValue = m_target->GetHealth();
5011 uint32 maxHPValue = m_target->GetMaxHealth();
5013 for (int32 i = STAT_STRENGTH; i < MAX_STATS; i++)
5015 if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1)
5017 m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply);
5018 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
5019 m_target->ApplyStatPercentBuffMod(Stats(i), m_modifier.m_amount, apply );
5023 //recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag)
5024 if ((m_modifier.m_miscvalue == STAT_STAMINA) && (maxHPValue > 0) && (m_spellProto->Attributes & 0x10))
5026 // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed
5027 uint32 newHPValue = (m_target->GetMaxHealth() * curHPValue) / maxHPValue;
5028 m_target->SetHealth(newHPValue);
5032 void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool /*Real*/)
5034 if(m_target->GetTypeId() != TYPEID_PLAYER)
5035 return;
5037 if(m_modifier.m_miscvalue != SPELL_SCHOOL_MASK_NORMAL)
5039 // support required adding replace UpdateArmor by loop by UpdateResistence at intellect update
5040 // and include in UpdateResistence same code as in UpdateArmor for aura mod apply.
5041 sLog.outError("Aura SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT(182) need adding support for non-armor resistances!");
5042 return;
5045 // Recalculate Armor
5046 m_target->UpdateArmor();
5049 /********************************/
5050 /*** HEAL & ENERGIZE ***/
5051 /********************************/
5052 void Aura::HandleAuraModTotalHealthPercentRegen(bool apply, bool /*Real*/)
5054 m_isPeriodic = apply;
5057 void Aura::HandleAuraModTotalManaPercentRegen(bool apply, bool /*Real*/)
5059 if(m_modifier.periodictime == 0)
5060 m_modifier.periodictime = 1000;
5062 m_periodicTimer = m_modifier.periodictime;
5063 m_isPeriodic = apply;
5066 void Aura::HandleModRegen(bool apply, bool /*Real*/) // eating
5068 if(m_modifier.periodictime == 0)
5069 m_modifier.periodictime = 5000;
5071 m_periodicTimer = 5000;
5072 m_isPeriodic = apply;
5075 void Aura::HandleModPowerRegen(bool apply, bool Real) // drinking
5077 if (!Real)
5078 return;
5080 Powers pt = m_target->getPowerType();
5081 if(m_modifier.periodictime == 0)
5083 // Anger Management (only spell use this aura for rage)
5084 if (pt == POWER_RAGE)
5085 m_modifier.periodictime = 3000;
5086 else
5087 m_modifier.periodictime = 2000;
5090 m_periodicTimer = 5000;
5092 if (m_target->GetTypeId() == TYPEID_PLAYER && m_modifier.m_miscvalue == POWER_MANA)
5093 ((Player*)m_target)->UpdateManaRegen();
5095 m_isPeriodic = apply;
5098 void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real)
5100 // spells required only Real aura add/remove
5101 if(!Real)
5102 return;
5104 if (m_target->GetTypeId() != TYPEID_PLAYER)
5105 return;
5107 // Update manaregen value
5108 if (m_modifier.m_miscvalue == POWER_MANA)
5109 ((Player*)m_target)->UpdateManaRegen();
5112 void Aura::HandleModManaRegen(bool /*apply*/, bool Real)
5114 // spells required only Real aura add/remove
5115 if(!Real)
5116 return;
5118 if (m_target->GetTypeId() != TYPEID_PLAYER)
5119 return;
5121 //Note: an increase in regen does NOT cause threat.
5122 ((Player*)m_target)->UpdateManaRegen();
5125 void Aura::HandleComprehendLanguage(bool apply, bool /*Real*/)
5127 if(apply)
5128 m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG);
5129 else
5130 m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG);
5133 void Aura::HandleAuraModIncreaseHealth(bool apply, bool Real)
5135 // Special case with temporary increase max/current health
5136 switch(GetId())
5138 case 12976: // Warrior Last Stand triggered spell
5139 case 28726: // Nightmare Seed ( Nightmare Seed )
5140 case 34511: // Valor (Bulwark of Kings, Bulwark of the Ancient Kings)
5141 case 44055: case 55915: case 55917: case 67596: // Tremendous Fortitude (Battlemaster's Alacrity)
5142 case 50322: // Survival Instincts
5143 case 54443: // Demonic Empowerment (Voidwalker)
5145 if(Real)
5147 if(apply)
5149 // Demonic Empowerment (Voidwalker) - special case, store percent in data
5150 // recalculate to full amount at apply for proper remove
5151 if (GetId() == 54443)
5152 m_modifier.m_amount = m_target->GetMaxHealth() * m_modifier.m_amount / 100;
5154 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5155 m_target->ModifyHealth(m_modifier.m_amount);
5157 else
5159 if (int32(m_target->GetHealth()) > m_modifier.m_amount)
5160 m_target->ModifyHealth(-m_modifier.m_amount);
5161 else
5162 m_target->SetHealth(1);
5163 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5166 return;
5170 // generic case
5171 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5174 void Aura::HandleAuraModIncreaseMaxHealth(bool apply, bool /*Real*/)
5176 uint32 oldhealth = m_target->GetHealth();
5177 double healthPercentage = (double)oldhealth / (double)m_target->GetMaxHealth();
5179 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5181 // refresh percentage
5182 if(oldhealth > 0)
5184 uint32 newhealth = uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage));
5185 if(newhealth==0)
5186 newhealth = 1;
5188 m_target->SetHealth(newhealth);
5192 void Aura::HandleAuraModIncreaseEnergy(bool apply, bool Real)
5194 Powers powerType = m_target->getPowerType();
5195 if(int32(powerType) != m_modifier.m_miscvalue)
5196 return;
5198 UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType);
5200 // Special case with temporary increase max/current power (percent)
5201 if (GetId()==64904) // Hymn of Hope
5203 if(Real)
5205 uint32 val = m_target->GetPower(powerType);
5206 m_target->HandleStatModifier(unitMod, TOTAL_PCT, float(m_modifier.m_amount), apply);
5207 m_target->SetPower(powerType, apply ? val*(100+m_modifier.m_amount)/100 : val*100/(100+m_modifier.m_amount));
5209 return;
5212 // generic flat case
5213 m_target->HandleStatModifier(unitMod, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5216 void Aura::HandleAuraModIncreaseEnergyPercent(bool apply, bool /*Real*/)
5218 Powers powerType = m_target->getPowerType();
5219 if(int32(powerType) != m_modifier.m_miscvalue)
5220 return;
5222 UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType);
5224 m_target->HandleStatModifier(unitMod, TOTAL_PCT, float(m_modifier.m_amount), apply);
5227 void Aura::HandleAuraModIncreaseHealthPercent(bool apply, bool /*Real*/)
5229 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_PCT, float(m_modifier.m_amount), apply);
5232 void Aura::HandleAuraIncreaseBaseHealthPercent(bool apply, bool /*Real*/)
5234 m_target->HandleStatModifier(UNIT_MOD_HEALTH, BASE_PCT, float(m_modifier.m_amount), apply);
5237 /********************************/
5238 /*** FIGHT ***/
5239 /********************************/
5241 void Aura::HandleAuraModParryPercent(bool /*apply*/, bool /*Real*/)
5243 if(m_target->GetTypeId() != TYPEID_PLAYER)
5244 return;
5246 ((Player*)m_target)->UpdateParryPercentage();
5249 void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool /*Real*/)
5251 if(m_target->GetTypeId() != TYPEID_PLAYER)
5252 return;
5254 ((Player*)m_target)->UpdateDodgePercentage();
5255 //sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount));
5258 void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool /*Real*/)
5260 if(m_target->GetTypeId() != TYPEID_PLAYER)
5261 return;
5263 ((Player*)m_target)->UpdateBlockPercentage();
5264 //sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount));
5267 void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real)
5269 // spells required only Real aura add/remove
5270 if(!Real)
5271 return;
5273 if(m_target->GetTypeId() != TYPEID_PLAYER)
5274 return;
5276 ((Player*)m_target)->UpdateManaRegen();
5279 void Aura::HandleAuraModCritPercent(bool apply, bool Real)
5281 if(m_target->GetTypeId() != TYPEID_PLAYER)
5282 return;
5284 // apply item specific bonuses for already equipped weapon
5285 if(Real)
5287 for(int i = 0; i < MAX_ATTACK; ++i)
5288 if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i),true,false))
5289 ((Player*)m_target)->_ApplyWeaponDependentAuraCritMod(pItem, WeaponAttackType(i), this, apply);
5292 // mods must be applied base at equipped weapon class and subclass comparison
5293 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5294 // m_modifier.m_miscvalue comparison with item generated damage types
5296 if (GetSpellProto()->EquippedItemClass == -1)
5298 ((Player*)m_target)->HandleBaseModValue(CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
5299 ((Player*)m_target)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
5300 ((Player*)m_target)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
5302 else
5304 // done in Player::_ApplyWeaponDependentAuraMods
5308 void Aura::HandleModHitChance(bool apply, bool /*Real*/)
5310 if(m_target->GetTypeId() == TYPEID_PLAYER)
5312 ((Player*)m_target)->UpdateMeleeHitChances();
5313 ((Player*)m_target)->UpdateRangedHitChances();
5315 else
5317 m_target->m_modMeleeHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount);
5318 m_target->m_modRangedHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount);
5322 void Aura::HandleModSpellHitChance(bool apply, bool /*Real*/)
5324 if(m_target->GetTypeId() == TYPEID_PLAYER)
5326 ((Player*)m_target)->UpdateSpellHitChances();
5328 else
5330 m_target->m_modSpellHitChance += apply ? m_modifier.m_amount: (-m_modifier.m_amount);
5334 void Aura::HandleModSpellCritChance(bool apply, bool Real)
5336 // spells required only Real aura add/remove
5337 if(!Real)
5338 return;
5340 if(m_target->GetTypeId() == TYPEID_PLAYER)
5342 ((Player*)m_target)->UpdateAllSpellCritChances();
5344 else
5346 m_target->m_baseSpellCritChance += apply ? m_modifier.m_amount:(-m_modifier.m_amount);
5350 void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real)
5352 // spells required only Real aura add/remove
5353 if(!Real)
5354 return;
5356 if(m_target->GetTypeId() != TYPEID_PLAYER)
5357 return;
5359 for(int school = SPELL_SCHOOL_NORMAL; school < MAX_SPELL_SCHOOL; ++school)
5360 if (m_modifier.m_miscvalue & (1<<school))
5361 ((Player*)m_target)->UpdateSpellCritChance(school);
5364 /********************************/
5365 /*** ATTACK SPEED ***/
5366 /********************************/
5368 void Aura::HandleModCastingSpeed(bool apply, bool /*Real*/)
5370 m_target->ApplyCastTimePercentMod(m_modifier.m_amount,apply);
5373 void Aura::HandleModMeleeRangedSpeedPct(bool apply, bool /*Real*/)
5375 m_target->ApplyAttackTimePercentMod(BASE_ATTACK, m_modifier.m_amount, apply);
5376 m_target->ApplyAttackTimePercentMod(OFF_ATTACK, m_modifier.m_amount, apply);
5377 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply);
5380 void Aura::HandleModCombatSpeedPct(bool apply, bool /*Real*/)
5382 m_target->ApplyCastTimePercentMod(m_modifier.m_amount, apply);
5383 m_target->ApplyAttackTimePercentMod(BASE_ATTACK, m_modifier.m_amount, apply);
5384 m_target->ApplyAttackTimePercentMod(OFF_ATTACK, m_modifier.m_amount, apply);
5385 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply);
5388 void Aura::HandleModAttackSpeed(bool apply, bool /*Real*/)
5390 if(!m_target->isAlive() )
5391 return;
5393 m_target->ApplyAttackTimePercentMod(BASE_ATTACK,m_modifier.m_amount,apply);
5396 void Aura::HandleHaste(bool apply, bool /*Real*/)
5398 m_target->ApplyAttackTimePercentMod(BASE_ATTACK, m_modifier.m_amount, apply);
5399 m_target->ApplyAttackTimePercentMod(OFF_ATTACK, m_modifier.m_amount, apply);
5400 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply);
5403 void Aura::HandleAuraModRangedHaste(bool apply, bool /*Real*/)
5405 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply);
5408 void Aura::HandleRangedAmmoHaste(bool apply, bool /*Real*/)
5410 if(m_target->GetTypeId() != TYPEID_PLAYER)
5411 return;
5412 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK,m_modifier.m_amount, apply);
5415 /********************************/
5416 /*** ATTACK POWER ***/
5417 /********************************/
5419 void Aura::HandleAuraModAttackPower(bool apply, bool /*Real*/)
5421 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5424 void Aura::HandleAuraModRangedAttackPower(bool apply, bool /*Real*/)
5426 if((m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0)
5427 return;
5429 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5432 void Aura::HandleAuraModAttackPowerPercent(bool apply, bool /*Real*/)
5434 //UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1
5435 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_PCT, float(m_modifier.m_amount), apply);
5438 void Aura::HandleAuraModRangedAttackPowerPercent(bool apply, bool /*Real*/)
5440 if((m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0)
5441 return;
5443 //UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1
5444 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply);
5447 void Aura::HandleAuraModRangedAttackPowerOfStatPercent(bool /*apply*/, bool Real)
5449 // spells required only Real aura add/remove
5450 if(!Real)
5451 return;
5453 // Recalculate bonus
5454 if(m_target->GetTypeId() == TYPEID_PLAYER && !(m_target->getClassMask() & CLASSMASK_WAND_USERS))
5455 ((Player*)m_target)->UpdateAttackPowerAndDamage(true);
5458 void Aura::HandleAuraModAttackPowerOfStatPercent(bool /*apply*/, bool Real)
5460 // spells required only Real aura add/remove
5461 if(!Real)
5462 return;
5464 // Recalculate bonus
5465 if(m_target->GetTypeId() == TYPEID_PLAYER)
5466 ((Player*)m_target)->UpdateAttackPowerAndDamage(false);
5469 void Aura::HandleAuraModAttackPowerOfArmor(bool /*apply*/, bool Real)
5471 // spells required only Real aura add/remove
5472 if(!Real)
5473 return;
5475 // Recalculate bonus
5476 if(m_target->GetTypeId() == TYPEID_PLAYER)
5477 ((Player*)m_target)->UpdateAttackPowerAndDamage(false);
5479 /********************************/
5480 /*** DAMAGE BONUS ***/
5481 /********************************/
5482 void Aura::HandleModDamageDone(bool apply, bool Real)
5484 // apply item specific bonuses for already equipped weapon
5485 if(Real && m_target->GetTypeId() == TYPEID_PLAYER)
5487 for(int i = 0; i < MAX_ATTACK; ++i)
5488 if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i),true,false))
5489 ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem, WeaponAttackType(i), this, apply);
5492 // m_modifier.m_miscvalue is bitmask of spell schools
5493 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5494 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wands
5495 // 127 - full bitmask any damages
5497 // mods must be applied base at equipped weapon class and subclass comparison
5498 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5499 // m_modifier.m_miscvalue comparison with item generated damage types
5501 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0)
5503 // apply generic physical damage bonuses including wand case
5504 if (GetSpellProto()->EquippedItemClass == -1 || m_target->GetTypeId() != TYPEID_PLAYER)
5506 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5507 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5508 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5510 else
5512 // done in Player::_ApplyWeaponDependentAuraMods
5515 if(m_target->GetTypeId() == TYPEID_PLAYER)
5517 if(m_positive)
5518 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS, m_modifier.m_amount, apply);
5519 else
5520 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG, m_modifier.m_amount, apply);
5524 // Skip non magic case for speedup
5525 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0)
5526 return;
5528 if( GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0 )
5530 // wand magic case (skip generic to all item spell bonuses)
5531 // done in Player::_ApplyWeaponDependentAuraMods
5533 // Skip item specific requirements for not wand magic damage
5534 return;
5537 // Magic damage modifiers implemented in Unit::SpellDamageBonus
5538 // This information for client side use only
5539 if(m_target->GetTypeId() == TYPEID_PLAYER)
5541 if(m_positive)
5543 for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
5545 if((m_modifier.m_miscvalue & (1<<i)) != 0)
5546 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, m_modifier.m_amount, apply);
5549 else
5551 for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
5553 if((m_modifier.m_miscvalue & (1<<i)) != 0)
5554 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i, m_modifier.m_amount, apply);
5557 Pet* pet = m_target->GetPet();
5558 if(pet)
5559 pet->UpdateAttackPowerAndDamage();
5563 void Aura::HandleModDamagePercentDone(bool apply, bool Real)
5565 sLog.outDebug("AURA MOD DAMAGE type:%u negative:%u", m_modifier.m_miscvalue, m_positive ? 0 : 1);
5567 // apply item specific bonuses for already equipped weapon
5568 if(Real && m_target->GetTypeId() == TYPEID_PLAYER)
5570 for(int i = 0; i < MAX_ATTACK; ++i)
5571 if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i),true,false))
5572 ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem, WeaponAttackType(i), this, apply);
5575 // m_modifier.m_miscvalue is bitmask of spell schools
5576 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5577 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wand
5578 // 127 - full bitmask any damages
5580 // mods must be applied base at equipped weapon class and subclass comparison
5581 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5582 // m_modifier.m_miscvalue comparison with item generated damage types
5584 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0)
5586 // apply generic physical damage bonuses including wand case
5587 if (GetSpellProto()->EquippedItemClass == -1 || m_target->GetTypeId() != TYPEID_PLAYER)
5589 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT, float(m_modifier.m_amount), apply);
5590 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply);
5591 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply);
5593 else
5595 // done in Player::_ApplyWeaponDependentAuraMods
5597 // For show in client
5598 if(m_target->GetTypeId() == TYPEID_PLAYER)
5599 m_target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT, m_modifier.m_amount/100.0f, apply);
5602 // Skip non magic case for speedup
5603 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0)
5604 return;
5606 if( GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0 )
5608 // wand magic case (skip generic to all item spell bonuses)
5609 // done in Player::_ApplyWeaponDependentAuraMods
5611 // Skip item specific requirements for not wand magic damage
5612 return;
5615 // Magic damage percent modifiers implemented in Unit::SpellDamageBonus
5616 // Send info to client
5617 if(m_target->GetTypeId() == TYPEID_PLAYER)
5618 for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
5619 m_target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i, m_modifier.m_amount/100.0f, apply);
5622 void Aura::HandleModOffhandDamagePercent(bool apply, bool Real)
5624 // spells required only Real aura add/remove
5625 if(!Real)
5626 return;
5628 sLog.outDebug("AURA MOD OFFHAND DAMAGE");
5630 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply);
5633 /********************************/
5634 /*** POWER COST ***/
5635 /********************************/
5637 void Aura::HandleModPowerCostPCT(bool apply, bool Real)
5639 // spells required only Real aura add/remove
5640 if(!Real)
5641 return;
5643 float amount = m_modifier.m_amount/100.0f;
5644 for(int i = 0; i < MAX_SPELL_SCHOOL; ++i)
5645 if(m_modifier.m_miscvalue & (1<<i))
5646 m_target->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER + i, amount, apply);
5649 void Aura::HandleModPowerCost(bool apply, bool Real)
5651 // spells required only Real aura add/remove
5652 if(!Real)
5653 return;
5655 for(int i = 0; i < MAX_SPELL_SCHOOL; ++i)
5656 if(m_modifier.m_miscvalue & (1<<i))
5657 m_target->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER + i, m_modifier.m_amount, apply);
5660 void Aura::HandleNoReagentUseAura(bool /*Apply*/, bool Real)
5662 // spells required only Real aura add/remove
5663 if(!Real)
5664 return;
5665 if(m_target->GetTypeId() != TYPEID_PLAYER)
5666 return;
5667 uint32 mask[3] = {0, 0, 0};
5668 Unit::AuraList const& noReagent = m_target->GetAurasByType(SPELL_AURA_NO_REAGENT_USE);
5669 for(Unit::AuraList::const_iterator i = noReagent.begin(); i != noReagent.end(); ++i)
5671 uint32 const *ptr = (*i)->getAuraSpellClassMask();
5672 mask[0] |= ptr[0];
5673 mask[1] |= ptr[1];
5674 mask[2] |= ptr[2];
5677 m_target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1+0, mask[0]);
5678 m_target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1+1, mask[1]);
5679 m_target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1+2, mask[2]);
5682 /*********************************************************/
5683 /*** OTHERS ***/
5684 /*********************************************************/
5686 void Aura::HandleShapeshiftBoosts(bool apply)
5688 uint32 spellId1 = 0;
5689 uint32 spellId2 = 0;
5690 uint32 HotWSpellId = 0;
5691 uint32 MasterShaperSpellId = 0;
5693 uint32 form = GetModifier()->m_miscvalue;
5695 switch(form)
5697 case FORM_CAT:
5698 spellId1 = 3025;
5699 HotWSpellId = 24900;
5700 MasterShaperSpellId = 48420;
5701 break;
5702 case FORM_TREE:
5703 spellId1 = 5420;
5704 spellId2 = 34123;
5705 MasterShaperSpellId = 48422;
5706 break;
5707 case FORM_TRAVEL:
5708 spellId1 = 5419;
5709 break;
5710 case FORM_AQUA:
5711 spellId1 = 5421;
5712 break;
5713 case FORM_BEAR:
5714 spellId1 = 1178;
5715 spellId2 = 21178;
5716 HotWSpellId = 24899;
5717 MasterShaperSpellId = 48418;
5718 break;
5719 case FORM_DIREBEAR:
5720 spellId1 = 9635;
5721 spellId2 = 21178;
5722 HotWSpellId = 24899;
5723 MasterShaperSpellId = 48418;
5724 break;
5725 case FORM_BATTLESTANCE:
5726 spellId1 = 21156;
5727 break;
5728 case FORM_DEFENSIVESTANCE:
5729 spellId1 = 7376;
5730 break;
5731 case FORM_BERSERKERSTANCE:
5732 spellId1 = 7381;
5733 break;
5734 case FORM_MOONKIN:
5735 spellId1 = 24905;
5736 MasterShaperSpellId = 48421;
5737 break;
5738 case FORM_FLIGHT:
5739 spellId1 = 33948;
5740 spellId2 = 34764;
5741 break;
5742 case FORM_FLIGHT_EPIC:
5743 spellId1 = 40122;
5744 spellId2 = 40121;
5745 break;
5746 case FORM_METAMORPHOSIS:
5747 spellId1 = 54817;
5748 spellId2 = 54879;
5749 break;
5750 case FORM_SPIRITOFREDEMPTION:
5751 spellId1 = 27792;
5752 spellId2 = 27795; // must be second, this important at aura remove to prevent to early iterator invalidation.
5753 break;
5754 case FORM_SHADOW:
5755 spellId1 = 49868;
5757 if(m_target->GetTypeId() == TYPEID_PLAYER) // Spell 49868 have same category as main form spell and share cooldown
5758 ((Player*)m_target)->RemoveSpellCooldown(49868);
5759 break;
5760 case FORM_GHOSTWOLF:
5761 spellId1 = 67116;
5762 break;
5763 case FORM_AMBIENT:
5764 case FORM_GHOUL:
5765 case FORM_STEALTH:
5766 case FORM_CREATURECAT:
5767 case FORM_CREATUREBEAR:
5768 break;
5771 if(apply)
5773 if (spellId1)
5774 m_target->CastSpell(m_target, spellId1, true, NULL, this );
5775 if (spellId2)
5776 m_target->CastSpell(m_target, spellId2, true, NULL, this);
5778 if (m_target->GetTypeId() == TYPEID_PLAYER)
5780 const PlayerSpellMap& sp_list = ((Player *)m_target)->GetSpellMap();
5781 for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
5783 if (itr->second->state == PLAYERSPELL_REMOVED) continue;
5784 if (itr->first==spellId1 || itr->first==spellId2) continue;
5785 SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
5786 if (!spellInfo || !(spellInfo->Attributes & (SPELL_ATTR_PASSIVE | (1<<7))))
5787 continue;
5788 if (spellInfo->Stances & (1<<(form-1)))
5789 m_target->CastSpell(m_target, itr->first, true, NULL, this);
5792 // Master Shapeshifter
5793 if (MasterShaperSpellId)
5795 Unit::AuraList const& ShapeShifterAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
5796 for(Unit::AuraList::const_iterator i = ShapeShifterAuras.begin(); i != ShapeShifterAuras.end(); i++)
5798 if ((*i)->GetSpellProto()->SpellIconID == 2851)
5800 int32 ShiftMod = (*i)->GetModifier()->m_amount;
5801 m_target->CastCustomSpell(m_target, MasterShaperSpellId, &ShiftMod, NULL, NULL, true);
5802 break;
5807 // Leader of the Pack
5808 if (((Player*)m_target)->HasSpell(17007))
5810 SpellEntry const *spellInfo = sSpellStore.LookupEntry(24932);
5811 if (spellInfo && spellInfo->Stances & (1<<(form-1)))
5812 m_target->CastSpell(m_target, 24932, true, NULL, this);
5815 // Savage Roar
5816 if (form == FORM_CAT && ((Player*)m_target)->HasAura(52610))
5817 m_target->CastSpell(m_target, 62071, true);
5819 // Improved Moonkin Form
5820 if (form == FORM_MOONKIN)
5822 Unit::AuraList const& dummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
5823 for(Unit::AuraList::const_iterator i = dummyAuras.begin(); i != dummyAuras.end(); i++)
5825 if ((*i)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_DRUID &&
5826 (*i)->GetSpellProto()->SpellIconID == 2855)
5828 uint32 spell_id = 0;
5829 switch((*i)->GetId())
5831 case 48384:spell_id=50170;break;//Rank 1
5832 case 48395:spell_id=50171;break;//Rank 2
5833 case 48396:spell_id=50172;break;//Rank 3
5834 default:
5835 sLog.outError("Aura::HandleShapeshiftBoosts: Not handled rank of IMF (Spell: %u)",(*i)->GetId());
5836 break;
5839 if(spell_id)
5840 m_target->CastSpell(m_target, spell_id, true, NULL, this);
5841 break;
5846 // Heart of the Wild
5847 if (HotWSpellId)
5849 Unit::AuraList const& mModTotalStatPct = m_target->GetAurasByType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE);
5850 for(Unit::AuraList::const_iterator i = mModTotalStatPct.begin(); i != mModTotalStatPct.end(); ++i)
5852 if ((*i)->GetSpellProto()->SpellIconID == 240 && (*i)->GetModifier()->m_miscvalue == 3)
5854 int32 HotWMod = (*i)->GetModifier()->m_amount;
5855 if(GetModifier()->m_miscvalue == FORM_CAT)
5856 HotWMod /= 2;
5858 m_target->CastCustomSpell(m_target, HotWSpellId, &HotWMod, NULL, NULL, true, NULL, this);
5859 break;
5865 else
5867 if(spellId1)
5868 m_target->RemoveAurasDueToSpell(spellId1);
5869 if(spellId2)
5870 m_target->RemoveAurasDueToSpell(spellId2);
5871 if(MasterShaperSpellId)
5872 m_target->RemoveAurasDueToSpell(MasterShaperSpellId);
5874 Unit::AuraMap& tAuras = m_target->GetAuras();
5875 for (Unit::AuraMap::iterator itr = tAuras.begin(); itr != tAuras.end();)
5877 if (itr->second->IsRemovedOnShapeLost())
5879 m_target->RemoveAurasDueToSpell(itr->second->GetId());
5880 itr = tAuras.begin();
5882 else
5883 ++itr;
5888 void Aura::HandleSpellSpecificBoosts(bool apply)
5890 bool cast_at_remove = false; // if spell must be casted at last aura from stack remove
5891 uint32 spellId1 = 0;
5892 uint32 spellId2 = 0;
5893 uint32 spellId3 = 0;
5894 uint32 spellId4 = 0;
5896 switch(GetSpellProto()->SpellFamilyName)
5898 case SPELLFAMILY_GENERIC:
5900 // Illusionary Barrier
5901 if(GetId() == 57350 && !apply && m_target->getPowerType() == POWER_MANA)
5903 cast_at_remove = true;
5904 spellId1 = 60242; // Darkmoon Card: Illusion
5906 else
5907 return;
5908 break;
5910 case SPELLFAMILY_MAGE:
5912 // Ice Barrier (non stacking from one caster)
5913 if (m_spellProto->SpellIconID == 32)
5915 if (!apply && (m_removeMode == AURA_REMOVE_BY_DISPEL || (m_removeMode == AURA_REMOVE_BY_DEFAULT && !GetModifier()->m_amount)))
5917 Unit::AuraList const& dummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
5918 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
5920 // Shattered Barrier
5921 if ((*itr)->GetSpellProto()->SpellIconID == 2945)
5923 cast_at_remove = true;
5924 // first rank have 50% chance
5925 if ((*itr)->GetId() != 44745 || roll_chance_i(50))
5926 spellId1 = 55080;
5927 break;
5931 else
5932 return;
5934 else
5935 return;
5936 break;
5938 case SPELLFAMILY_WARRIOR:
5940 if(!apply)
5942 // Remove Blood Frenzy only if target no longer has any Deep Wound or Rend (applying is handled by procs)
5943 if (GetSpellProto()->Mechanic != MECHANIC_BLEED)
5944 return;
5946 // If target still has one of Warrior's bleeds, do nothing
5947 Unit::AuraList const& PeriodicDamage = m_target->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE);
5948 for(Unit::AuraList::const_iterator i = PeriodicDamage.begin(); i != PeriodicDamage.end(); ++i)
5949 if( (*i)->GetCasterGUID() == GetCasterGUID() &&
5950 (*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARRIOR &&
5951 (*i)->GetSpellProto()->Mechanic == MECHANIC_BLEED)
5952 return;
5954 spellId1 = 30069; // Blood Frenzy (Rank 1)
5955 spellId2 = 30070; // Blood Frenzy (Rank 2)
5957 break;
5959 case SPELLFAMILY_WARLOCK:
5961 // Fear (non stacking)
5962 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000040000000000))
5964 if(!apply)
5966 Unit* caster = GetCaster();
5967 if(!caster)
5968 return;
5970 Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY);
5971 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
5973 SpellEntry const* dummyEntry = (*itr)->GetSpellProto();
5974 // Improved Fear
5975 if (dummyEntry->SpellFamilyName == SPELLFAMILY_WARLOCK && dummyEntry->SpellIconID == 98)
5977 cast_at_remove = true;
5978 switch((*itr)->GetModifier()->m_amount)
5980 // Rank 1
5981 case 0: spellId1 = 60946; break;
5982 // Rank 1
5983 case 1: spellId1 = 60947; break;
5985 break;
5989 else
5990 return;
5992 else
5993 return;
5994 break;
5996 case SPELLFAMILY_PRIEST:
5998 // Shadow Word: Pain (need visual check fro skip improvement talent) or Vampiric Touch
5999 if (m_spellProto->SpellIconID == 234 && m_spellProto->SpellVisual[0] || m_spellProto->SpellIconID == 2213)
6001 if (!apply && m_removeMode == AURA_REMOVE_BY_DISPEL)
6003 Unit* caster = GetCaster();
6004 if(!caster)
6005 return;
6007 Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY);
6008 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
6010 // Shadow Affinity
6011 if ((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_PRIEST
6012 && (*itr)->GetSpellProto()->SpellIconID == 178)
6014 // custom cast code
6015 int32 basepoints0 = (*itr)->GetModifier()->m_amount * caster->GetCreateMana() / 100;
6016 caster->CastCustomSpell(caster, 64103, &basepoints0, NULL, NULL, true, NULL, this);
6017 return;
6021 else
6022 return;
6025 switch(GetId())
6027 // Abolish Disease (remove 1 more poison effect with Body and Soul)
6028 case 552:
6030 if(apply)
6032 int chance =0;
6033 Unit::AuraList const& dummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
6034 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
6036 SpellEntry const* dummyEntry = (*itr)->GetSpellProto();
6037 // Body and Soul (talent ranks)
6038 if (dummyEntry->SpellFamilyName == SPELLFAMILY_PRIEST && dummyEntry->SpellIconID == 2218 &&
6039 dummyEntry->SpellVisual[0]==0)
6041 chance = (*itr)->GetSpellProto()->CalculateSimpleValue(1);
6042 break;
6046 if(roll_chance_i(chance))
6047 spellId1 = 64134; // Body and Soul (periodic dispel effect)
6049 else
6050 spellId1 = 64134; // Body and Soul (periodic dispel effect)
6051 break;
6053 // Dispersion mana reg and immunity
6054 case 47585:
6055 spellId1 = 60069; // Dispersion
6056 spellId2 = 63230; // Dispersion
6057 break;
6058 default:
6059 return;
6061 break;
6063 case SPELLFAMILY_ROGUE:
6064 // Sprint (skip non player casted spells by category)
6065 if (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000040) && GetSpellProto()->Category == 44)
6067 if(!apply || m_target->HasAura(58039)) // Glyph of Blurred Speed
6068 spellId1 = 61922; // Sprint (waterwalk)
6069 else
6070 return;
6072 else
6073 return;
6074 break;
6075 case SPELLFAMILY_HUNTER:
6077 // The Beast Within and Bestial Wrath - immunity
6078 if (GetId() == 19574 || GetId() == 34471)
6080 spellId1 = 24395;
6081 spellId2 = 24396;
6082 spellId3 = 24397;
6083 spellId4 = 26592;
6085 // Aspect of the Dragonhawk dodge
6086 else if (GetSpellProto()->SpellFamilyFlags2 & 0x00001000)
6088 spellId1 = 61848;
6090 // triggered spell have same category as main spell and cooldown
6091 if (apply && m_target->GetTypeId()==TYPEID_PLAYER)
6092 ((Player*)m_target)->RemoveSpellCooldown(61848);
6094 else
6095 return;
6096 break;
6098 case SPELLFAMILY_PALADIN:
6100 if (m_spellProto->Id == 31884) // Avenging Wrath
6102 if(!apply)
6103 spellId1 = 57318; // Sanctified Wrath (triggered)
6104 else
6106 int32 percent = 0;
6107 Unit::AuraList const& dummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
6108 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
6110 if ((*itr)->GetSpellProto()->SpellIconID == 3029)
6112 percent = (*itr)->GetModifier()->m_amount;
6113 break;
6117 // apply in special way
6118 if(percent)
6120 spellId1 = 57318; // Sanctified Wrath (triggered)
6121 // prevent aura deletion, specially in multi-boost case
6122 SetInUse(true);
6123 m_target->CastCustomSpell(m_target, spellId1, &percent, &percent, NULL, true, NULL, this);
6124 SetInUse(false);
6126 return;
6128 break;
6131 // Only process on player casting paladin aura
6132 // all aura bonuses applied also in aura area effect way to caster
6133 if (GetCasterGUID() != m_target->GetGUID() || !IS_PLAYER_GUID(GetCasterGUID()))
6134 return;
6136 if (GetSpellSpecific(m_spellProto->Id) != SPELL_AURA)
6137 return;
6139 // Sanctified Retribution and Swift Retribution (they share one aura), but not Retribution Aura (already gets modded)
6140 if ((GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000008))==0)
6141 spellId1 = 63531; // placeholder for talent spell mods
6142 // Improved Concentration Aura (auras bonus)
6143 spellId2 = 63510; // placeholder for talent spell mods
6144 // Improved Devotion Aura (auras bonus)
6145 spellId3 = 63514; // placeholder for talent spell mods
6146 break;
6148 case SPELLFAMILY_DEATHKNIGHT:
6150 if (GetSpellSpecific(m_spellProto->Id) != SPELL_PRESENCE)
6151 return;
6153 // Frost Presence health
6154 if (GetId() == 48263)
6155 spellId1 = 61261;
6156 // Unholy Presence move speed
6157 else if (GetId() == 48265)
6158 spellId1 = 49772;
6159 else
6160 return;
6162 break;
6164 default:
6165 return;
6168 // prevent aura deletion, specially in multi-boost case
6169 SetInUse(true);
6171 if (apply || cast_at_remove)
6173 if (spellId1)
6174 m_target->CastSpell(m_target, spellId1, true, NULL, this);
6175 if (spellId2 && !IsDeleted())
6176 m_target->CastSpell(m_target, spellId2, true, NULL, this);
6177 if (spellId3 && !IsDeleted())
6178 m_target->CastSpell(m_target, spellId3, true, NULL, this);
6179 if (spellId4 && !IsDeleted())
6180 m_target->CastSpell(m_target, spellId4, true, NULL, this);
6182 else
6184 if (spellId1)
6185 m_target->RemoveAurasByCasterSpell(spellId1, GetCasterGUID());
6186 if (spellId2)
6187 m_target->RemoveAurasByCasterSpell(spellId2, GetCasterGUID());
6188 if (spellId3)
6189 m_target->RemoveAurasByCasterSpell(spellId3, GetCasterGUID());
6190 if (spellId4)
6191 m_target->RemoveAurasByCasterSpell(spellId4, GetCasterGUID());
6194 SetInUse(false);
6197 void Aura::HandleAuraEmpathy(bool apply, bool /*Real*/)
6199 if(m_target->GetTypeId() != TYPEID_UNIT)
6200 return;
6202 CreatureInfo const * ci = ObjectMgr::GetCreatureTemplate(m_target->GetEntry());
6203 if(ci && ci->type == CREATURE_TYPE_BEAST)
6204 m_target->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO, apply);
6207 void Aura::HandleAuraUntrackable(bool apply, bool /*Real*/)
6209 if(apply)
6210 m_target->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE);
6211 else
6212 m_target->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE);
6215 void Aura::HandleAuraModPacify(bool apply, bool /*Real*/)
6217 if(m_target->GetTypeId() != TYPEID_PLAYER)
6218 return;
6220 if(apply)
6221 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
6222 else
6223 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
6226 void Aura::HandleAuraModPacifyAndSilence(bool apply, bool Real)
6228 HandleAuraModPacify(apply, Real);
6229 HandleAuraModSilence(apply, Real);
6232 void Aura::HandleAuraGhost(bool apply, bool /*Real*/)
6234 if(m_target->GetTypeId() != TYPEID_PLAYER)
6235 return;
6237 if(apply)
6239 m_target->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST);
6241 else
6243 m_target->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST);
6247 void Aura::HandleAuraAllowFlight(bool apply, bool Real)
6249 // all applied/removed only at real aura add/remove
6250 if(!Real)
6251 return;
6253 // allow fly
6254 WorldPacket data;
6255 if(apply)
6256 data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
6257 else
6258 data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
6259 data.append(m_target->GetPackGUID());
6260 data << uint32(0); // unk
6261 m_target->SendMessageToSet(&data, true);
6264 void Aura::HandleModRating(bool apply, bool Real)
6266 // spells required only Real aura add/remove
6267 if(!Real)
6268 return;
6270 if(m_target->GetTypeId() != TYPEID_PLAYER)
6271 return;
6273 for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating)
6274 if (m_modifier.m_miscvalue & (1 << rating))
6275 ((Player*)m_target)->ApplyRatingMod(CombatRating(rating), m_modifier.m_amount, apply);
6278 void Aura::HandleModRatingFromStat(bool apply, bool Real)
6280 // spells required only Real aura add/remove
6281 if(!Real)
6282 return;
6284 if(m_target->GetTypeId() != TYPEID_PLAYER)
6285 return;
6286 // Just recalculate ratings
6287 for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating)
6288 if (m_modifier.m_miscvalue & (1 << rating))
6289 ((Player*)m_target)->ApplyRatingMod(CombatRating(rating), 0, apply);
6292 void Aura::HandleForceMoveForward(bool apply, bool Real)
6294 if(!Real || m_target->GetTypeId() != TYPEID_PLAYER)
6295 return;
6296 if(apply)
6297 m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE);
6298 else
6299 m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE);
6302 void Aura::HandleAuraModExpertise(bool /*apply*/, bool /*Real*/)
6304 if(m_target->GetTypeId() != TYPEID_PLAYER)
6305 return;
6307 ((Player*)m_target)->UpdateExpertise(BASE_ATTACK);
6308 ((Player*)m_target)->UpdateExpertise(OFF_ATTACK);
6311 void Aura::HandleModTargetResistance(bool apply, bool Real)
6313 // spells required only Real aura add/remove
6314 if(!Real)
6315 return;
6316 // applied to damage as HandleNoImmediateEffect in Unit::CalcAbsorbResist and Unit::CalcArmorReducedDamage
6318 // show armor penetration
6319 if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL))
6320 m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE, m_modifier.m_amount, apply);
6322 // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy
6323 if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_SPELL)==SPELL_SCHOOL_MASK_SPELL)
6324 m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, m_modifier.m_amount, apply);
6327 void Aura::HandleShieldBlockValue(bool apply, bool /*Real*/)
6329 BaseModType modType = FLAT_MOD;
6330 if(m_modifier.m_auraname == SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT)
6331 modType = PCT_MOD;
6333 if(m_target->GetTypeId() == TYPEID_PLAYER)
6334 ((Player*)m_target)->HandleBaseModValue(SHIELD_BLOCK_VALUE, modType, float(m_modifier.m_amount), apply);
6337 void Aura::HandleAuraRetainComboPoints(bool apply, bool Real)
6339 // spells required only Real aura add/remove
6340 if(!Real)
6341 return;
6343 if(m_target->GetTypeId() != TYPEID_PLAYER)
6344 return;
6346 Player *target = (Player*)m_target;
6348 // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler
6349 // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost)
6350 if( !apply && m_duration==0 && target->GetComboTarget())
6351 if(Unit* unit = ObjectAccessor::GetUnit(*m_target,target->GetComboTarget()))
6352 target->AddComboPoints(unit, -m_modifier.m_amount);
6355 void Aura::HandleModUnattackable( bool Apply, bool Real )
6357 if(Real && Apply)
6359 m_target->CombatStop();
6360 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
6362 m_target->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE,Apply);
6365 void Aura::HandleSpiritOfRedemption( bool apply, bool Real )
6367 // spells required only Real aura add/remove
6368 if(!Real)
6369 return;
6371 // prepare spirit state
6372 if(apply)
6374 if(m_target->GetTypeId()==TYPEID_PLAYER)
6376 // disable breath/etc timers
6377 ((Player*)m_target)->StopMirrorTimers();
6379 // set stand state (expected in this form)
6380 if(!m_target->IsStandState())
6381 m_target->SetStandState(UNIT_STAND_STATE_STAND);
6384 m_target->SetHealth(1);
6386 // die at aura end
6387 else
6388 m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, GetSpellProto(), false);
6391 void Aura::CleanupTriggeredSpells()
6393 uint32 tSpellId = m_spellProto->EffectTriggerSpell[GetEffIndex()];
6394 if(!tSpellId)
6395 return;
6397 SpellEntry const* tProto = sSpellStore.LookupEntry(tSpellId);
6398 if(!tProto)
6399 return;
6401 if(GetSpellDuration(tProto) != -1)
6402 return;
6404 // needed for spell 43680, maybe others
6405 // TODO: is there a spell flag, which can solve this in a more sophisticated way?
6406 if(m_spellProto->EffectApplyAuraName[GetEffIndex()] == SPELL_AURA_PERIODIC_TRIGGER_SPELL &&
6407 GetSpellDuration(m_spellProto) == m_spellProto->EffectAmplitude[GetEffIndex()])
6408 return;
6409 m_target->RemoveAurasDueToSpell(tSpellId);
6412 void Aura::HandleSchoolAbsorb(bool apply, bool Real)
6414 if(!Real)
6415 return;
6417 Unit* caster = GetCaster();
6418 if(!caster)
6419 return;
6421 if (apply)
6423 // prevent double apply bonuses
6424 if (m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())
6426 float DoneActualBenefit = 0.0f;
6427 switch(m_spellProto->SpellFamilyName)
6429 case SPELLFAMILY_PRIEST:
6430 // Power Word: Shield
6431 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000001))
6432 //+80.68% from +spell bonus
6433 DoneActualBenefit = caster->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto)) * 0.8068f;
6434 break;
6435 case SPELLFAMILY_MAGE:
6436 // Frost Ward, Fire Ward
6437 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000108))
6438 //+10% from +spell bonus
6439 DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.1f;
6440 // Ice Barrier
6441 else if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000100000000))
6442 //+80.67% from +spell bonus
6443 DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.8067f;
6444 break;
6445 case SPELLFAMILY_WARLOCK:
6446 // Shadow Ward
6447 if (m_spellProto->SpellFamilyFlags2 & 0x00000040)
6448 //+30% from +spell bonus
6449 DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.30f;
6450 break;
6451 case SPELLFAMILY_PALADIN:
6452 // Sacred Shield
6453 // (check not strictly needed, only Sacred Shield has SPELL_AURA_SCHOOL_ABSORB in SPELLFAMILY_PALADIN at this time)
6454 if (m_spellProto->SpellFamilyFlags & UI64LIT(0x0008000000000000))
6456 // +75% from spell power
6457 DoneActualBenefit = caster->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto)) * 0.75f;
6459 break;
6460 default:
6461 break;
6464 DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto());
6466 m_modifier.m_amount += (int32)DoneActualBenefit;
6469 else
6471 if (caster &&
6472 // Power Word: Shield
6473 m_spellProto->SpellFamilyName == SPELLFAMILY_PRIEST && m_spellProto->Mechanic == MECHANIC_SHIELD &&
6474 (m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000001)) &&
6475 // completely absorbed or dispelled
6476 ((m_removeMode == AURA_REMOVE_BY_DEFAULT && !m_modifier.m_amount) || m_removeMode == AURA_REMOVE_BY_DISPEL))
6478 Unit::AuraList const& vDummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY);
6479 for(Unit::AuraList::const_iterator itr = vDummyAuras.begin(); itr != vDummyAuras.end(); ++itr)
6481 SpellEntry const* vSpell = (*itr)->GetSpellProto();
6483 // Rapture (main spell)
6484 if(vSpell->SpellFamilyName == SPELLFAMILY_PRIEST && vSpell->SpellIconID == 2894 && vSpell->Effect[1])
6486 switch((*itr)->GetEffIndex())
6488 case 0:
6490 // energize caster
6491 int32 manapct1000 = 5 * ((*itr)->GetModifier()->m_amount + sSpellMgr.GetSpellRank(vSpell->Id));
6492 int32 basepoints0 = caster->GetMaxPower(POWER_MANA) * manapct1000 / 1000;
6493 caster->CastCustomSpell(caster, 47755, &basepoints0, NULL, NULL, true);
6494 break;
6496 case 1:
6498 // energize target
6499 if (!roll_chance_i((*itr)->GetModifier()->m_amount) || caster->HasAura(63853))
6500 break;
6502 switch(m_target->getPowerType())
6504 case POWER_RUNIC_POWER:
6505 m_target->CastSpell(m_target, 63652, true, NULL, NULL, m_caster_guid);
6506 break;
6507 case POWER_RAGE:
6508 m_target->CastSpell(m_target, 63653, true, NULL, NULL, m_caster_guid);
6509 break;
6510 case POWER_MANA:
6512 int32 basepoints0 = m_target->GetMaxPower(POWER_MANA) * 2 / 100;
6513 m_target->CastCustomSpell(m_target, 63654, &basepoints0, NULL, NULL, true);
6514 break;
6516 case POWER_ENERGY:
6517 m_target->CastSpell(m_target, 63655, true, NULL, NULL, m_caster_guid);
6518 break;
6519 default:
6520 break;
6523 //cooldwon aura
6524 caster->CastSpell(caster, 63853, true);
6525 break;
6527 default:
6528 sLog.outError("Changes in R-dummy spell???: effect 3");
6529 break;
6537 void Aura::PeriodicTick()
6539 switch(m_modifier.m_auraname)
6541 case SPELL_AURA_PERIODIC_DAMAGE:
6542 case SPELL_AURA_PERIODIC_DAMAGE_PERCENT:
6544 Unit *pCaster = GetCaster();
6545 if(!pCaster)
6546 return;
6548 if( GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA &&
6549 pCaster->SpellHitResult(m_target, GetSpellProto(), false) != SPELL_MISS_NONE)
6550 return;
6552 // Check for immune (not use charges)
6553 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6554 return;
6556 // some auras remove at specific health level or more
6557 if(m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE)
6559 switch(GetId())
6561 case 43093: case 31956: case 38801:
6562 case 35321: case 38363: case 39215:
6563 if(m_target->GetHealth() == m_target->GetMaxHealth() )
6565 m_target->RemoveAurasDueToSpell(GetId());
6566 return;
6568 break;
6569 case 38772:
6571 uint32 percent =
6572 GetEffIndex() < 2 && GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_DUMMY ?
6573 pCaster->CalculateSpellDamage(GetSpellProto(), GetEffIndex() + 1, GetSpellProto()->EffectBasePoints[GetEffIndex() + 1], m_target) :
6574 100;
6575 if(m_target->GetHealth() * 100 >= m_target->GetMaxHealth() * percent )
6577 m_target->RemoveAurasDueToSpell(GetId());
6578 return;
6580 break;
6582 default:
6583 break;
6587 uint32 absorb = 0;
6588 uint32 resist = 0;
6589 CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
6591 // ignore non positive values (can be result apply spellmods to aura damage
6592 uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6594 uint32 pdamage;
6596 if(m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE)
6598 pdamage = amount;
6600 // SpellDamageBonus for magic spells
6601 if(GetSpellProto()->DmgClass == SPELL_DAMAGE_CLASS_NONE || GetSpellProto()->DmgClass == SPELL_DAMAGE_CLASS_MAGIC)
6602 pdamage = pCaster->SpellDamageBonus(m_target, GetSpellProto(), pdamage, DOT, GetStackAmount());
6603 // MeleeDamagebonus for weapon based spells
6604 else
6606 WeaponAttackType attackType = GetWeaponAttackType(GetSpellProto());
6607 pdamage = pCaster->MeleeDamageBonus(m_target, pdamage, attackType, GetSpellProto(), DOT, GetStackAmount());
6610 // Calculate armor mitigation if it is a physical spell
6611 // But not for bleed mechanic spells
6612 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL &&
6613 GetEffectMechanic(GetSpellProto(), m_effIndex) != MECHANIC_BLEED)
6615 uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage);
6616 cleanDamage.damage += pdamage - pdamageReductedArmor;
6617 pdamage = pdamageReductedArmor;
6620 // Curse of Agony damage-per-tick calculation
6621 if (GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000400)) && GetSpellProto()->SpellIconID==544)
6623 // 1..4 ticks, 1/2 from normal tick damage
6624 if (GetAuraTicks() <= 4)
6625 pdamage = pdamage/2;
6626 // 9..12 ticks, 3/2 from normal tick damage
6627 else if(GetAuraTicks() >= 9)
6628 pdamage += (pdamage + 1) / 2; // +1 prevent 0.5 damage possible lost at 1..4 ticks
6629 // 5..8 ticks have normal tick damage
6632 else
6633 pdamage = uint32(m_target->GetMaxHealth()*amount/100);
6635 // This method can modify pdamage
6636 bool isCrit = IsCritFromAbilityAura(pCaster, pdamage);
6638 // send critical in hit info for threat calculation
6639 if (isCrit)
6641 cleanDamage.hitOutCome = MELEE_HIT_CRIT;
6642 // Resilience - reduce crit damage
6643 pdamage -= m_target->GetSpellCritDamageReduction(pdamage);
6646 // only from players
6647 // FIXME: need use SpellDamageBonus instead?
6648 if (IS_PLAYER_GUID(m_caster_guid))
6649 pdamage -= m_target->GetSpellDamageReduction(pdamage);
6651 pCaster->CalcAbsorbResist(m_target, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist, !(GetSpellProto()->AttributesEx2 & SPELL_ATTR_EX2_CANT_REFLECTED));
6653 sLog.outDetail("PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
6654 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb);
6656 pCaster->DealDamageMods(m_target, pdamage, &absorb);
6658 SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, absorb, resist, 0.0f, isCrit);
6659 m_target->SendPeriodicAuraLog(&pInfo);
6661 // Set trigger flag
6662 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
6663 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
6664 pdamage = (pdamage <= absorb + resist) ? 0 : (pdamage - absorb - resist);
6665 if (pdamage)
6666 procVictim|=PROC_FLAG_TAKEN_ANY_DAMAGE;
6667 pCaster->ProcDamageAndSpell(m_target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, GetSpellProto());
6669 pCaster->DealDamage(m_target, pdamage, &cleanDamage, DOT, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
6670 break;
6672 case SPELL_AURA_PERIODIC_LEECH:
6673 case SPELL_AURA_PERIODIC_HEALTH_FUNNEL:
6675 Unit *pCaster = GetCaster();
6676 if(!pCaster)
6677 return;
6679 if(!pCaster->isAlive())
6680 return;
6682 if( GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA &&
6683 pCaster->SpellHitResult(m_target, GetSpellProto(), false) != SPELL_MISS_NONE)
6684 return;
6686 // Check for immune
6687 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6688 return;
6690 uint32 absorb=0;
6691 uint32 resist=0;
6692 CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
6694 uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6696 //Calculate armor mitigation if it is a physical spell
6697 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL)
6699 uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage);
6700 cleanDamage.damage += pdamage - pdamageReductedArmor;
6701 pdamage = pdamageReductedArmor;
6704 pdamage = pCaster->SpellDamageBonus(m_target, GetSpellProto(), pdamage, DOT, GetStackAmount());
6706 pCaster->CalcAbsorbResist(m_target, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist, !(GetSpellProto()->AttributesEx2 & SPELL_ATTR_EX2_CANT_REFLECTED));
6708 if(m_target->GetHealth() < pdamage)
6709 pdamage = uint32(m_target->GetHealth());
6711 sLog.outDetail("PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
6712 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb);
6714 pCaster->SendSpellNonMeleeDamageLog(m_target, GetId(), pdamage, GetSpellSchoolMask(GetSpellProto()), absorb, resist, false, 0);
6716 float multiplier = GetSpellProto()->EffectMultipleValue[GetEffIndex()] > 0 ? GetSpellProto()->EffectMultipleValue[GetEffIndex()] : 1;
6718 // Set trigger flag
6719 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
6720 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
6721 pdamage = (pdamage <= absorb + resist) ? 0 : (pdamage-absorb-resist);
6722 if (pdamage)
6723 procVictim|=PROC_FLAG_TAKEN_ANY_DAMAGE;
6724 pCaster->ProcDamageAndSpell(m_target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, GetSpellProto());
6725 int32 new_damage = pCaster->DealDamage(m_target, pdamage, &cleanDamage, DOT, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), false);
6727 if (!m_target->isAlive() && pCaster->IsNonMeleeSpellCasted(false))
6728 for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
6729 if (Spell* spell = pCaster->GetCurrentSpell(CurrentSpellTypes(i)))
6730 if (spell->m_spellInfo->Id == GetId())
6731 spell->cancel();
6734 if(Player *modOwner = pCaster->GetSpellModOwner())
6735 modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, multiplier);
6737 uint32 heal = pCaster->SpellHealingBonus(pCaster, GetSpellProto(), uint32(new_damage * multiplier), DOT, GetStackAmount());
6739 int32 gain = pCaster->DealHeal(pCaster, heal, GetSpellProto());
6740 pCaster->getHostileRefManager().threatAssist(pCaster, gain * 0.5f, GetSpellProto());
6741 break;
6743 case SPELL_AURA_PERIODIC_HEAL:
6744 case SPELL_AURA_OBS_MOD_HEALTH:
6746 Unit *pCaster = GetCaster();
6747 if(!pCaster)
6748 return;
6750 // heal for caster damage (must be alive)
6751 if(m_target != pCaster && GetSpellProto()->SpellVisual[0] == 163 && !pCaster->isAlive())
6752 return;
6754 // ignore non positive values (can be result apply spellmods to aura damage
6755 uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6757 uint32 pdamage;
6759 if(m_modifier.m_auraname==SPELL_AURA_OBS_MOD_HEALTH)
6760 pdamage = uint32(m_target->GetMaxHealth() * amount / 100);
6761 else
6763 pdamage = amount;
6765 // Wild Growth (1/7 - 6 + 2*ramainTicks) %
6766 if (m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && m_spellProto->SpellIconID == 2864)
6768 int32 ticks = GetAuraMaxTicks();
6769 int32 remainingTicks = ticks - GetAuraTicks();
6770 pdamage = int32(pdamage) + int32(amount)*ticks*(-6+2*remainingTicks)/100;
6774 pdamage = pCaster->SpellHealingBonus(m_target, GetSpellProto(), pdamage, DOT, GetStackAmount());
6776 // This method can modify pdamage
6777 bool isCrit = IsCritFromAbilityAura(pCaster, pdamage);
6779 sLog.outDetail("PeriodicTick: %u (TypeId: %u) heal of %u (TypeId: %u) for %u health inflicted by %u",
6780 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
6782 SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, 0, 0, 0.0f, isCrit);
6783 m_target->SendPeriodicAuraLog(&pInfo);
6785 int32 gain = m_target->ModifyHealth(pdamage);
6787 // Set trigger flag
6788 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;
6789 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;
6790 pCaster->ProcDamageAndSpell(m_target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, gain, BASE_ATTACK, m_spellProto);
6792 // add HoTs to amount healed in bgs
6793 if( pCaster->GetTypeId() == TYPEID_PLAYER )
6794 if( BattleGround *bg = ((Player*)pCaster)->GetBattleGround() )
6795 bg->UpdatePlayerScore(((Player*)pCaster), SCORE_HEALING_DONE, gain);
6797 m_target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto());
6799 SpellEntry const* spellProto = GetSpellProto();
6801 // heal for caster damage
6802 if(m_target != pCaster && spellProto->SpellVisual[0] == 163)
6804 uint32 dmg = spellProto->manaPerSecond;
6805 if(pCaster->GetHealth() <= dmg && pCaster->GetTypeId()==TYPEID_PLAYER)
6807 pCaster->RemoveAurasDueToSpell(GetId());
6809 // finish current generic/channeling spells, don't affect autorepeat
6810 pCaster->FinishSpell(CURRENT_GENERIC_SPELL);
6811 pCaster->FinishSpell(CURRENT_CHANNELED_SPELL);
6813 else
6815 uint32 damage = gain;
6816 uint32 absorb = 0;
6817 pCaster->DealDamageMods(pCaster, damage, &absorb);
6818 pCaster->SendSpellNonMeleeDamageLog(pCaster, GetId(), damage, GetSpellSchoolMask(GetSpellProto()), absorb, 0, false, 0, false);
6820 CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
6821 pCaster->DealDamage(pCaster, damage, &cleanDamage, NODAMAGE, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
6825 // uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;// | PROC_FLAG_SUCCESSFUL_HEAL;
6826 // uint32 procVictim = 0;//ROC_FLAG_ON_TAKE_PERIODIC | PROC_FLAG_TAKEN_HEAL;
6827 // ignore item heals
6828 // if(procSpell && !haveCastItem)
6829 // pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto);
6830 break;
6832 case SPELL_AURA_PERIODIC_MANA_LEECH:
6834 if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS)
6835 return;
6837 Powers power = Powers(m_modifier.m_miscvalue);
6839 // power type might have changed between aura applying and tick (druid's shapeshift)
6840 if(m_target->getPowerType() != power)
6841 return;
6843 Unit *pCaster = GetCaster();
6844 if(!pCaster)
6845 return;
6847 if(!pCaster->isAlive())
6848 return;
6850 if( GetSpellProto()->Effect[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA &&
6851 pCaster->SpellHitResult(m_target, GetSpellProto(), false) != SPELL_MISS_NONE)
6852 return;
6854 // Check for immune (not use charges)
6855 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6856 return;
6858 // ignore non positive values (can be result apply spellmods to aura damage
6859 uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6861 // Special case: draining x% of mana (up to a maximum of 2*x% of the caster's maximum mana)
6862 // It's mana percent cost spells, m_modifier.m_amount is percent drain from target
6863 if (m_spellProto->ManaCostPercentage)
6865 // max value
6866 uint32 maxmana = pCaster->GetMaxPower(power) * pdamage * 2 / 100;
6867 pdamage = m_target->GetMaxPower(power) * pdamage / 100;
6868 if(pdamage > maxmana)
6869 pdamage = maxmana;
6872 sLog.outDetail("PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u",
6873 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
6875 int32 drain_amount = m_target->GetPower(power) > pdamage ? pdamage : m_target->GetPower(power);
6877 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
6878 if (power == POWER_MANA)
6879 drain_amount -= m_target->GetSpellCritDamageReduction(drain_amount);
6881 m_target->ModifyPower(power, -drain_amount);
6883 float gain_multiplier = 0;
6885 if(pCaster->GetMaxPower(power) > 0)
6887 gain_multiplier = GetSpellProto()->EffectMultipleValue[GetEffIndex()];
6889 if(Player *modOwner = pCaster->GetSpellModOwner())
6890 modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, gain_multiplier);
6893 SpellPeriodicAuraLogInfo pInfo(this, drain_amount, 0, 0, 0, gain_multiplier);
6894 m_target->SendPeriodicAuraLog(&pInfo);
6896 int32 gain_amount = int32(drain_amount * gain_multiplier);
6898 if(gain_amount)
6900 int32 gain = pCaster->ModifyPower(power, gain_amount);
6901 m_target->AddThreat(pCaster, float(gain) * 0.5f, pInfo.critical, GetSpellSchoolMask(GetSpellProto()), GetSpellProto());
6903 break;
6905 case SPELL_AURA_PERIODIC_ENERGIZE:
6907 // ignore non positive values (can be result apply spellmods to aura damage
6908 uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6910 sLog.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u",
6911 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
6913 if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS)
6914 break;
6916 Powers power = Powers(m_modifier.m_miscvalue);
6918 if(m_target->GetMaxPower(power) == 0)
6919 break;
6921 SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, 0, 0, 0.0f);
6922 m_target->SendPeriodicAuraLog(&pInfo);
6924 int32 gain = m_target->ModifyPower(power,pdamage);
6926 if(Unit* pCaster = GetCaster())
6927 m_target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto());
6928 break;
6930 case SPELL_AURA_OBS_MOD_MANA:
6932 // ignore non positive values (can be result apply spellmods to aura damage
6933 uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6935 uint32 pdamage = uint32(m_target->GetMaxPower(POWER_MANA) * amount / 100);
6937 sLog.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u mana inflicted by %u",
6938 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
6940 if(m_target->GetMaxPower(POWER_MANA) == 0)
6941 break;
6943 SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, 0, 0, 0.0f);
6944 m_target->SendPeriodicAuraLog(&pInfo);
6946 int32 gain = m_target->ModifyPower(POWER_MANA, pdamage);
6948 if(Unit* pCaster = GetCaster())
6949 m_target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto());
6950 break;
6952 case SPELL_AURA_POWER_BURN_MANA:
6954 Unit *pCaster = GetCaster();
6955 if(!pCaster)
6956 return;
6958 // Check for immune (not use charges)
6959 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6960 return;
6962 int32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6964 Powers powerType = Powers(m_modifier.m_miscvalue);
6966 if(!m_target->isAlive() || m_target->getPowerType() != powerType)
6967 return;
6969 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
6970 if (powerType == POWER_MANA)
6971 pdamage -= m_target->GetSpellCritDamageReduction(pdamage);
6973 uint32 gain = uint32(-m_target->ModifyPower(powerType, -pdamage));
6975 gain = uint32(gain * GetSpellProto()->EffectMultipleValue[GetEffIndex()]);
6977 SpellEntry const* spellProto = GetSpellProto();
6978 // maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG
6979 SpellNonMeleeDamage damageInfo(pCaster, m_target, spellProto->Id, spellProto->SchoolMask);
6980 pCaster->CalculateSpellDamage(&damageInfo, gain, spellProto);
6982 pCaster->DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb);
6984 pCaster->SendSpellNonMeleeDamageLog(&damageInfo);
6986 // Set trigger flag
6987 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
6988 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
6989 uint32 procEx = createProcExtendMask(&damageInfo, SPELL_MISS_NONE);
6990 if (damageInfo.damage)
6991 procVictim|=PROC_FLAG_TAKEN_ANY_DAMAGE;
6993 pCaster->ProcDamageAndSpell(damageInfo.target, procAttacker, procVictim, procEx, damageInfo.damage, BASE_ATTACK, spellProto);
6995 pCaster->DealSpellDamage(&damageInfo, true);
6996 break;
6998 case SPELL_AURA_MOD_REGEN:
7000 int32 gain = m_target->ModifyHealth(m_modifier.m_amount);
7001 if (Unit *caster = GetCaster())
7002 m_target->getHostileRefManager().threatAssist(caster, float(gain) * 0.5f, GetSpellProto());
7003 break;
7005 case SPELL_AURA_MOD_POWER_REGEN:
7007 Powers pt = m_target->getPowerType();
7008 if(int32(pt) != m_modifier.m_miscvalue)
7009 return;
7011 if ( GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED )
7013 // eating anim
7014 m_target->HandleEmoteCommand(EMOTE_ONESHOT_EAT);
7016 else if( GetId() == 20577 )
7018 // cannibalize anim
7019 m_target->HandleEmoteCommand(EMOTE_STATE_CANNIBALIZE);
7022 // Anger Management
7023 // amount = 1+ 16 = 17 = 3,4*5 = 10,2*5/3
7024 // so 17 is rounded amount for 5 sec tick grow ~ 1 range grow in 3 sec
7025 if(pt == POWER_RAGE)
7026 m_target->ModifyPower(pt, m_modifier.m_amount * 3 / 5);
7027 break;
7029 // Here tick dummy auras
7030 case SPELL_AURA_DUMMY: // some spells have dummy aura
7031 case SPELL_AURA_PERIODIC_DUMMY:
7033 PeriodicDummyTick();
7034 break;
7036 case SPELL_AURA_PERIODIC_TRIGGER_SPELL:
7038 TriggerSpell();
7039 break;
7041 case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE:
7043 TriggerSpellWithValue();
7044 break;
7046 default:
7047 break;
7051 void Aura::PeriodicDummyTick()
7053 SpellEntry const* spell = GetSpellProto();
7054 switch (spell->SpellFamilyName)
7056 case SPELLFAMILY_GENERIC:
7057 switch (spell->Id)
7059 // Drink
7060 case 430:
7061 case 431:
7062 case 432:
7063 case 1133:
7064 case 1135:
7065 case 1137:
7066 case 10250:
7067 case 22734:
7068 case 27089:
7069 case 34291:
7070 case 43182:
7071 case 43183:
7072 case 43706:
7073 case 46755:
7074 case 49472: // Drink Coffee
7075 case 57073:
7076 case 61830:
7078 if (m_target->GetTypeId() != TYPEID_PLAYER)
7079 return;
7080 // Search SPELL_AURA_MOD_POWER_REGEN aura for this spell and add bonus
7081 Unit::AuraList const& aura = m_target->GetAurasByType(SPELL_AURA_MOD_POWER_REGEN);
7082 for(Unit::AuraList::const_iterator i = aura.begin(); i != aura.end(); ++i)
7084 if ((*i)->GetId() == GetId())
7086 (*i)->GetModifier()->m_amount = m_modifier.m_amount;
7087 ((Player*)m_target)->UpdateManaRegen();
7088 // Disable continue
7089 m_isPeriodic = false;
7090 return;
7093 return;
7095 // Forsaken Skills
7096 case 7054:
7098 // Possibly need cast one of them (but
7099 // 7038 Forsaken Skill: Swords
7100 // 7039 Forsaken Skill: Axes
7101 // 7040 Forsaken Skill: Daggers
7102 // 7041 Forsaken Skill: Maces
7103 // 7042 Forsaken Skill: Staves
7104 // 7043 Forsaken Skill: Bows
7105 // 7044 Forsaken Skill: Guns
7106 // 7045 Forsaken Skill: 2H Axes
7107 // 7046 Forsaken Skill: 2H Maces
7108 // 7047 Forsaken Skill: 2H Swords
7109 // 7048 Forsaken Skill: Defense
7110 // 7049 Forsaken Skill: Fire
7111 // 7050 Forsaken Skill: Frost
7112 // 7051 Forsaken Skill: Holy
7113 // 7053 Forsaken Skill: Shadow
7114 return;
7116 case 7057: // Haunting Spirits
7117 if (roll_chance_i(33))
7118 m_target->CastSpell(m_target,m_modifier.m_amount,true,NULL,this);
7119 return;
7120 // // Panda
7121 // case 19230: break;
7122 // // Gossip NPC Periodic - Talk
7123 // case 33208: break;
7124 // // Gossip NPC Periodic - Despawn
7125 // case 33209: break;
7126 // // Steal Weapon
7127 // case 36207: break;
7128 // // Simon Game START timer, (DND)
7129 // case 39993: break;
7130 // // Knockdown Fel Cannon: break; The Aggro Burst
7131 // case 40119: break;
7132 // // Old Mount Spell
7133 // case 40154: break;
7134 // // Magnetic Pull
7135 // case 40581: break;
7136 // // Ethereal Ring: break; The Bolt Burst
7137 // case 40801: break;
7138 // // Crystal Prison
7139 // case 40846: break;
7140 // // Copy Weapon
7141 // case 41054: break;
7142 // // Dementia
7143 // case 41404: break;
7144 // // Ethereal Ring Visual, Lightning Aura
7145 // case 41477: break;
7146 // // Ethereal Ring Visual, Lightning Aura (Fork)
7147 // case 41525: break;
7148 // // Ethereal Ring Visual, Lightning Jumper Aura
7149 // case 41567: break;
7150 // // No Man's Land
7151 // case 41955: break;
7152 // // Headless Horseman - Fire
7153 // case 42074: break;
7154 // // Headless Horseman - Visual - Large Fire
7155 // case 42075: break;
7156 // // Headless Horseman - Start Fire, Periodic Aura
7157 // case 42140: break;
7158 // // Ram Speed Boost
7159 // case 42152: break;
7160 // // Headless Horseman - Fires Out Victory Aura
7161 // case 42235: break;
7162 // // Pumpkin Life Cycle
7163 // case 42280: break;
7164 // // Brewfest Request Chick Chuck Mug Aura
7165 // case 42537: break;
7166 // // Squashling
7167 // case 42596: break;
7168 // // Headless Horseman Climax, Head: Periodic
7169 // case 42603: break;
7170 // // Fire Bomb
7171 // case 42621: break;
7172 // // Headless Horseman - Conflagrate, Periodic Aura
7173 // case 42637: break;
7174 // // Headless Horseman - Create Pumpkin Treats Aura
7175 // case 42774: break;
7176 // // Headless Horseman Climax - Summoning Rhyme Aura
7177 // case 42879: break;
7178 // // Tricky Treat
7179 // case 42919: break;
7180 // // Giddyup!
7181 // case 42924: break;
7182 // // Ram - Trot
7183 // case 42992: break;
7184 // // Ram - Canter
7185 // case 42993: break;
7186 // // Ram - Gallop
7187 // case 42994: break;
7188 // // Ram Level - Neutral
7189 // case 43310: break;
7190 // // Headless Horseman - Maniacal Laugh, Maniacal, Delayed 17
7191 // case 43884: break;
7192 // // Wretched!
7193 // case 43963: break;
7194 // // Headless Horseman - Maniacal Laugh, Maniacal, other, Delayed 17
7195 // case 44000: break;
7196 // // Energy Feedback
7197 // case 44328: break;
7198 // // Romantic Picnic
7199 // case 45102: break;
7200 // // Romantic Picnic
7201 // case 45123: break;
7202 // // Looking for Love
7203 // case 45124: break;
7204 // // Kite - Lightning Strike Kite Aura
7205 // case 45197: break;
7206 // // Rocket Chicken
7207 // case 45202: break;
7208 // // Copy Offhand Weapon
7209 // case 45205: break;
7210 // // Upper Deck - Kite - Lightning Periodic Aura
7211 // case 45207: break;
7212 // // Kite -Sky Lightning Strike Kite Aura
7213 // case 45251: break;
7214 // // Ribbon Pole Dancer Check Aura
7215 // case 45390: break;
7216 // // Holiday - Midsummer, Ribbon Pole Periodic Visual
7217 // case 45406: break;
7218 // // Parachute
7219 // case 45472: break;
7220 // // Alliance Flag, Extra Damage Debuff
7221 // case 45898: break;
7222 // // Horde Flag, Extra Damage Debuff
7223 // case 45899: break;
7224 // // Ahune - Summoning Rhyme Aura
7225 // case 45926: break;
7226 // // Ahune - Slippery Floor
7227 // case 45945: break;
7228 // // Ahune's Shield
7229 // case 45954: break;
7230 // // Nether Vapor Lightning
7231 // case 45960: break;
7232 // // Darkness
7233 // case 45996: break;
7234 case 46041: // Summon Blood Elves Periodic
7235 m_target->CastSpell(m_target, 46037, true, NULL, this);
7236 m_target->CastSpell(m_target, roll_chance_i(50) ? 46038 : 46039, true, NULL, this);
7237 m_target->CastSpell(m_target, 46040, true, NULL, this);
7238 return;
7239 // // Transform Visual Missile Periodic
7240 // case 46205: break;
7241 // // Find Opening Beam End
7242 // case 46333: break;
7243 // // Ice Spear Control Aura
7244 // case 46371: break;
7245 // // Hailstone Chill
7246 // case 46458: break;
7247 // // Hailstone Chill, Internal
7248 // case 46465: break;
7249 // // Chill, Internal Shifter
7250 // case 46549: break;
7251 // // Summon Ice Spear Knockback Delayer
7252 // case 46878: break;
7253 // // Burninate Effect
7254 // case 47214: break;
7255 // // Fizzcrank Practice Parachute
7256 // case 47228: break;
7257 // // Send Mug Control Aura
7258 // case 47369: break;
7259 // // Direbrew's Disarm (precast)
7260 // case 47407: break;
7261 // // Mole Machine Port Schedule
7262 // case 47489: break;
7263 // case 47941: break; // Crystal Spike
7264 // case 48200: break; // Healer Aura
7265 case 48630: // Summon Gauntlet Mobs Periodic
7266 case 59275: // Below may need some adjustment, pattern for amount of summon and where is not verified 100% (except for odd/even tick)
7268 bool chance = roll_chance_i(50);
7270 m_target->CastSpell(m_target, chance ? 48631 : 48632, true, NULL, this);
7272 if (GetAuraTicks() % 2) // which doctor at odd tick
7273 m_target->CastSpell(m_target, chance ? 48636 : 48635, true, NULL, this);
7274 else // or harponeer, at even tick
7275 m_target->CastSpell(m_target, chance ? 48634 : 48633, true, NULL, this);
7277 return;
7279 // case 49313: break; // Proximity Mine Area Aura
7280 // // Mole Machine Portal Schedule
7281 // case 49466: break;
7282 // case 49555: break; // Corpse Explode
7283 // case 49592: break; // Temporal Rift
7284 // case 49957: break; // Cutting Laser
7285 // case 50085: break; // Slow Fall
7286 // // Listening to Music
7287 // case 50493: break;
7288 // // Love Rocket Barrage
7289 // case 50530: break;
7290 case 50789: // Summon iron dwarf (left or right)
7291 case 59860:
7292 m_target->CastSpell(m_target, roll_chance_i(50) ? 50790 : 50791, true, NULL, this);
7293 return;
7294 case 50792: // Summon iron trogg (left or right)
7295 case 59859:
7296 m_target->CastSpell(m_target, roll_chance_i(50) ? 50793 : 50794, true, NULL, this);
7297 return;
7298 case 50801: // Summon malformed ooze (left or right)
7299 case 59858:
7300 m_target->CastSpell(m_target, roll_chance_i(50) ? 50802 : 50803, true, NULL, this);
7301 return;
7302 case 50824: // Summon earthen dwarf
7303 m_target->CastSpell(m_target, roll_chance_i(50) ? 50825 : 50826, true, NULL, this);
7304 return;
7305 case 52441: // Cool Down
7306 m_target->CastSpell(m_target, 52443, true);
7307 return;
7308 case 53520: // Carrion Beetles
7309 m_target->CastSpell(m_target, 53521, true, NULL, this);
7310 m_target->CastSpell(m_target, 53521, true, NULL, this);
7311 return;
7312 case 55592: // Clean
7313 switch(urand(0,2))
7315 case 0: m_target->CastSpell(m_target, 55731, true); break;
7316 case 1: m_target->CastSpell(m_target, 55738, true); break;
7317 case 2: m_target->CastSpell(m_target, 55739, true); break;
7319 return;
7320 // Exist more after, need add later
7321 default:
7322 break;
7324 // Prey on the Weak
7325 if (spell->SpellIconID == 2983)
7327 Unit *target=m_target->getVictim();
7328 if (target && (m_target->GetHealth() * 100 / m_target->GetMaxHealth() > target->GetHealth() * 100 / target->GetMaxHealth()))
7330 if(!m_target->HasAura(58670))
7332 int32 basepoints = GetBasePoints();
7333 m_target->CastCustomSpell(m_target, 58670, &basepoints, 0, 0, true);
7336 else
7337 m_target->RemoveAurasDueToSpell(58670);
7339 break;
7340 case SPELLFAMILY_MAGE:
7342 // Mirror Image
7343 // if (spell->Id == 55342)
7344 // return;
7345 break;
7347 case SPELLFAMILY_DRUID:
7349 switch (spell->Id)
7351 // Frenzied Regeneration
7352 case 22842:
7354 // Converts up to 10 rage per second into health for $d. Each point of rage is converted into ${$m2/10}.1% of max health.
7355 // Should be manauser
7356 if (m_target->getPowerType() != POWER_RAGE)
7357 return;
7358 uint32 rage = m_target->GetPower(POWER_RAGE);
7359 // Nothing todo
7360 if (rage == 0)
7361 return;
7362 int32 mod = (rage < 100) ? rage : 100;
7363 int32 points = m_target->CalculateSpellDamage(spell, 1, spell->EffectBasePoints[1], m_target);
7364 int32 regen = m_target->GetMaxHealth() * (mod * points / 10) / 1000;
7365 m_target->CastCustomSpell(m_target, 22845, &regen, NULL, NULL, true, NULL, this);
7366 m_target->SetPower(POWER_RAGE, rage-mod);
7367 return;
7369 // Force of Nature
7370 case 33831:
7371 return;
7372 default:
7373 break;
7375 break;
7377 case SPELLFAMILY_ROGUE:
7379 switch (spell->Id)
7381 // Killing Spree
7382 case 51690:
7384 if (m_target->hasUnitState(UNIT_STAT_STUNNED) || m_target->HasAuraType(SPELL_AURA_MOD_FEAR))
7385 return;
7387 std::list<Unit*> targets;
7389 // eff_radius ==0
7390 float radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(spell->rangeIndex));
7392 CellPair p(MaNGOS::ComputeCellPair(m_target->GetPositionX(),m_target->GetPositionY()));
7393 Cell cell(p);
7394 cell.data.Part.reserved = ALL_DISTRICT;
7396 MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck u_check(m_target, m_target, radius);
7397 MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck> checker(m_target, targets, u_check);
7399 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck>, GridTypeMapContainer > grid_object_checker(checker);
7400 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker);
7402 CellLock<GridReadGuard> cell_lock(cell, p);
7404 cell_lock->Visit(cell_lock, grid_object_checker, *m_target->GetMap(), *m_target, radius);
7405 cell_lock->Visit(cell_lock, world_object_checker, *m_target->GetMap(), *m_target, radius);
7408 if(targets.empty())
7409 return;
7411 std::list<Unit*>::const_iterator itr = targets.begin();
7412 std::advance(itr, rand()%targets.size());
7413 Unit* target = *itr;
7415 m_target->CastSpell(target, 57840, true);
7416 m_target->CastSpell(target, 57841, true);
7417 return;
7419 default:
7420 break;
7422 break;
7424 case SPELLFAMILY_HUNTER:
7426 // Explosive Shot
7427 if (spell->SpellFamilyFlags & UI64LIT(0x8000000000000000))
7429 m_target->CastCustomSpell(m_target, 53352, &m_modifier.m_amount, 0, 0, true, 0, this, GetCasterGUID());
7430 return;
7432 switch (spell->Id)
7434 // Harpooner's Mark
7435 // case 40084:
7436 // return;
7437 // Feeding Frenzy Rank 1
7438 case 53511:
7439 if ( m_target->GetHealth() * 100 < m_target->GetMaxHealth() * 35 )
7440 m_target->CastSpell(m_target, 60096, true, 0, this);
7441 return;
7442 // Feeding Frenzy Rank 2
7443 case 53512:
7444 if ( m_target->GetHealth() * 100 < m_target->GetMaxHealth() * 35 )
7445 m_target->CastSpell(m_target, 60097, true, 0, this);
7446 return;
7447 default:
7448 break;
7450 break;
7452 case SPELLFAMILY_SHAMAN:
7454 // Astral Shift
7455 if (spell->Id == 52179)
7457 // Periodic need for remove visual on stun/fear/silence lost
7458 if (!(m_target->GetUInt32Value(UNIT_FIELD_FLAGS)&(UNIT_FLAG_STUNNED|UNIT_FLAG_FLEEING|UNIT_FLAG_SILENCED)))
7459 m_target->RemoveAurasDueToSpell(52179);
7460 return;
7462 break;
7464 case SPELLFAMILY_DEATHKNIGHT:
7466 // Death and Decay
7467 if (spell->SpellFamilyFlags & UI64LIT(0x0000000000000020))
7469 if (Unit *caster = GetCaster())
7470 caster->CastCustomSpell(m_target, 52212, &m_modifier.m_amount, NULL, NULL, true, NULL, this);
7471 return;
7473 // Raise Dead
7474 // if (spell->SpellFamilyFlags & UI64LIT(0x0000000000001000))
7475 // return;
7476 // Chains of Ice
7477 if (spell->SpellFamilyFlags & UI64LIT(0x0000400000000000))
7479 // Get 0 effect aura
7480 Aura *slow = m_target->GetAura(GetId(), 0);
7481 if (slow)
7483 slow->ApplyModifier(false, true);
7484 Modifier *mod = slow->GetModifier();
7485 mod->m_amount+= m_modifier.m_amount;
7486 if (mod->m_amount > 0) mod->m_amount = 0;
7487 slow->ApplyModifier(true, true);
7489 return;
7491 // Summon Gargoyle
7492 // if (spell->SpellFamilyFlags & UI64LIT(0x0000008000000000))
7493 // return;
7494 // Death Rune Mastery
7495 // if (spell->SpellFamilyFlags & UI64LIT(0x0000000000004000))
7496 // return;
7497 // Bladed Armor
7498 if (spell->SpellIconID == 2653)
7500 // Increases your attack power by $s1 for every $s2 armor value you have.
7501 // Calculate AP bonus (from 1 efect of this spell)
7502 int32 apBonus = m_modifier.m_amount * m_target->GetArmor() / m_target->CalculateSpellDamage(spell, 1, spell->EffectBasePoints[1], m_target);
7503 m_target->CastCustomSpell(m_target, 61217, &apBonus, &apBonus, NULL, true, NULL, this);
7504 return;
7506 // Reaping
7507 // if (spell->SpellIconID == 22)
7508 // return;
7509 // Blood of the North
7510 // if (spell->SpellIconID == 30412)
7511 // return;
7512 break;
7514 default:
7515 break;
7519 void Aura::HandlePreventFleeing(bool apply, bool Real)
7521 if(!Real)
7522 return;
7524 Unit::AuraList const& fearAuras = m_target->GetAurasByType(SPELL_AURA_MOD_FEAR);
7525 if( !fearAuras.empty() )
7527 if (apply)
7528 m_target->SetFeared(false, fearAuras.front()->GetCasterGUID());
7529 else
7530 m_target->SetFeared(true);
7534 void Aura::HandleManaShield(bool apply, bool Real)
7536 if(!Real)
7537 return;
7539 // prevent double apply bonuses
7540 if(apply && (m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading()))
7542 if(Unit* caster = GetCaster())
7544 float DoneActualBenefit = 0.0f;
7545 switch(m_spellProto->SpellFamilyName)
7547 case SPELLFAMILY_MAGE:
7548 if(m_spellProto->SpellFamilyFlags & UI64LIT(0x0000000000008000))
7550 // Mana Shield
7551 // +50% from +spd bonus
7552 DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.5f;
7553 break;
7555 break;
7556 default:
7557 break;
7560 DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto());
7562 m_modifier.m_amount += (int32)DoneActualBenefit;
7567 void Aura::HandleArenaPreparation(bool apply, bool Real)
7569 if(!Real)
7570 return;
7572 if(apply)
7573 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION);
7574 else
7575 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION);
7579 * Such auras are applied from a caster(=player) to a vehicle.
7580 * This has been verified using spell #49256
7582 void Aura::HandleAuraControlVehicle(bool apply, bool Real)
7584 if(!Real)
7585 return;
7587 Unit *player = GetCaster();
7588 Vehicle *vehicle = dynamic_cast<Vehicle*>(m_target);
7589 if(!player || player->GetTypeId() != TYPEID_PLAYER || !vehicle)
7590 return;
7592 if (apply)
7594 if(Pet *pet = player->GetPet())
7595 pet->Remove(PET_SAVE_AS_CURRENT);
7596 ((Player*)player)->EnterVehicle(vehicle);
7598 else
7600 SpellEntry const *spell = GetSpellProto();
7602 // some SPELL_AURA_CONTROL_VEHICLE auras have a dummy effect on the player - remove them
7603 player->RemoveAurasDueToSpell(spell->Id);
7605 ((Player*)player)->ExitVehicle(vehicle);
7609 void Aura::HandleAuraConvertRune(bool apply, bool Real)
7611 if(!Real)
7612 return;
7614 if(m_target->GetTypeId() != TYPEID_PLAYER)
7615 return;
7617 Player *plr = (Player*)m_target;
7619 if(plr->getClass() != CLASS_DEATH_KNIGHT)
7620 return;
7622 // how to determine what rune need to be converted?
7623 for(uint32 i = 0; i < MAX_RUNES; ++i)
7625 if(apply)
7627 if(!plr->GetRuneCooldown(i))
7629 plr->ConvertRune(i, RuneType(GetSpellProto()->EffectMiscValueB[m_effIndex]));
7630 break;
7633 else
7635 if(plr->GetCurrentRune(i) == RuneType(GetSpellProto()->EffectMiscValueB[m_effIndex]))
7637 plr->ConvertRune(i, plr->GetBaseRune(i));
7638 break;
7644 void Aura::HandlePhase(bool apply, bool Real)
7646 if(!Real)
7647 return;
7649 // always non stackable
7650 if(apply)
7652 Unit::AuraList const& phases = m_target->GetAurasByType(SPELL_AURA_PHASE);
7653 if(!phases.empty())
7654 m_target->RemoveAurasDueToSpell(phases.front()->GetId(), this);
7657 // no-phase is also phase state so same code for apply and remove
7659 // phase auras normally not expected at BG but anyway better check
7660 if(m_target->GetTypeId() == TYPEID_PLAYER)
7662 // drop flag at invisible in bg
7663 if(((Player*)m_target)->InBattleGround())
7664 if(BattleGround *bg = ((Player*)m_target)->GetBattleGround())
7665 bg->EventPlayerDroppedFlag((Player*)m_target);
7667 // GM-mode have mask 0xFFFFFFFF
7668 if(!((Player*)m_target)->isGameMaster())
7669 m_target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL, false);
7671 ((Player*)m_target)->GetSession()->SendSetPhaseShift(apply ? GetMiscValue() : PHASEMASK_NORMAL);
7673 if(GetEffIndex()==0)
7675 SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAuraMapBounds(GetId());
7676 if(saBounds.first != saBounds.second)
7678 uint32 zone, area;
7679 m_target->GetZoneAndAreaId(zone, area);
7681 for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
7683 // some auras remove at aura remove
7684 if(!itr->second->IsFitToRequirements((Player*)m_target, zone, area))
7685 m_target->RemoveAurasDueToSpell(itr->second->spellId);
7686 // some auras applied at aura apply
7687 else if(itr->second->autocast)
7689 if( !m_target->HasAura(itr->second->spellId, 0) )
7690 m_target->CastSpell(m_target, itr->second->spellId, true);
7696 else
7697 m_target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL, false);
7699 // need triggering visibility update base at phase update of not GM invisible (other GMs anyway see in any phases)
7700 if(m_target->GetVisibility() != VISIBILITY_OFF)
7701 m_target->SetVisibility(m_target->GetVisibility());
7704 void Aura::UnregisterSingleCastAura()
7706 if (IsSingleTarget())
7708 if(Unit* caster = GetCaster())
7710 caster->GetSingleCastAuras().remove(this);
7712 else
7714 sLog.outError("Couldn't find the caster of the single target aura (SpellId %u), may crash later!", GetId());
7715 assert(false);
7717 m_isSingleTargetAura = false;
7721 void Aura::HandleAuraSafeFall( bool Apply, bool Real )
7723 // implemented in WorldSession::HandleMovementOpcodes
7725 // only special case
7726 if(Apply && Real && GetId() == 32474 && m_target->GetTypeId() == TYPEID_PLAYER)
7727 ((Player*)m_target)->ActivateTaxiPathTo(506, GetId());
7730 bool Aura::IsCritFromAbilityAura(Unit* caster, uint32& damage)
7732 Unit::AuraList const& auras = caster->GetAurasByType(SPELL_AURA_ABILITY_PERIODIC_CRIT);
7733 for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
7735 if (!(*itr)->isAffectedOnSpell(m_spellProto))
7736 continue;
7737 if (!caster->isSpellCrit(m_target, m_spellProto, GetSpellSchoolMask(m_spellProto)))
7738 break;
7740 damage = caster->SpellCriticalDamageBonus(m_spellProto, damage, m_target);
7741 return true;
7743 return false;
7746 void Aura::HandleModTargetArmorPct(bool apply, bool Real)
7748 if(m_target->GetTypeId() != TYPEID_PLAYER)
7749 return;
7751 ((Player*)m_target)->UpdateArmorPenetration();
7754 void Aura::HandleAuraModAllCritChance(bool apply, bool Real)
7756 // spells required only Real aura add/remove
7757 if(!Real)
7758 return;
7760 if(m_target->GetTypeId() != TYPEID_PLAYER)
7761 return;
7763 ((Player*)m_target)->HandleBaseModValue(CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
7764 ((Player*)m_target)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
7765 ((Player*)m_target)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
7767 // included in Player::UpdateSpellCritChance calculation
7768 ((Player*)m_target)->UpdateAllSpellCritChances();
7771 void Aura::HandleAllowOnlyAbility(bool apply, bool Real)
7773 if(!Real)
7774 return;
7776 if(apply)
7778 m_target->setAttackTimer(BASE_ATTACK,m_duration);
7779 m_target->setAttackTimer(RANGED_ATTACK,m_duration);
7780 m_target->setAttackTimer(OFF_ATTACK,m_duration);
7782 else
7784 m_target->resetAttackTimer(BASE_ATTACK);
7785 m_target->resetAttackTimer(RANGED_ATTACK);
7786 m_target->resetAttackTimer(OFF_ATTACK);
7789 m_target->UpdateDamagePhysical(BASE_ATTACK);
7790 m_target->UpdateDamagePhysical(RANGED_ATTACK);
7791 m_target->UpdateDamagePhysical(OFF_ATTACK);