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
20 #include "Database/DatabaseEnv.h"
21 #include "WorldPacket.h"
22 #include "WorldSession.h"
25 #include "UpdateMask.h"
27 #include "ObjectMgr.h"
32 #include "DynamicObject.h"
34 #include "UpdateData.h"
35 #include "ObjectAccessor.h"
36 #include "Policies/SingletonImp.h"
40 #include "BattleGround.h"
41 #include "CreatureAI.h"
42 #include "ScriptCalls.h"
44 #include "GridNotifiers.h"
45 #include "GridNotifiersImpl.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
362 static AuraType
const frozenAuraTypes
[] = { SPELL_AURA_MOD_ROOT
, SPELL_AURA_MOD_STUN
, SPELL_AURA_NONE
};
364 Aura::Aura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
, Unit
*caster
, Item
* castItem
) :
365 m_spellmod(NULL
), m_caster_guid(0), m_target(target
), m_castItemGuid(castItem
?castItem
->GetGUID():0),
366 m_timeCla(1000), m_periodicTimer(0), m_periodicTick(0), m_removeMode(AURA_REMOVE_BY_DEFAULT
), m_AuraDRGroup(DIMINISHING_NONE
),
367 m_effIndex(eff
), m_auraSlot(MAX_AURAS
), m_auraFlags(AFLAG_NONE
), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),
368 m_positive(false), m_permanent(false), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false),
369 m_isRemovedOnShapeLost(true), m_in_use(0), m_deleted(false)
373 assert(spellproto
&& spellproto
== sSpellStore
.LookupEntry( spellproto
->Id
) && "`info` must be pointer to sSpellStore element");
375 m_spellProto
= spellproto
;
377 m_currentBasePoints
= currentBasePoints
? *currentBasePoints
: m_spellProto
->EffectBasePoints
[eff
];
379 m_isPassive
= IsPassiveSpell(GetId());
380 m_positive
= IsPositiveEffect(GetId(), m_effIndex
);
382 m_isSingleTargetAura
= IsSingleTargetSpell(m_spellProto
);
384 m_applyTime
= time(NULL
);
389 m_caster_guid
= target
->GetGUID();
390 damage
= m_currentBasePoints
+1; // stored value-1
391 m_maxduration
= target
->CalculateSpellDuration(m_spellProto
, m_effIndex
, target
);
395 m_caster_guid
= caster
->GetGUID();
397 damage
= caster
->CalculateSpellDamage(m_spellProto
,m_effIndex
,m_currentBasePoints
,target
);
398 m_maxduration
= caster
->CalculateSpellDuration(m_spellProto
, m_effIndex
, target
);
400 if (!damage
&& castItem
&& castItem
->GetItemSuffixFactor())
402 ItemRandomSuffixEntry
const *item_rand_suffix
= sItemRandomSuffixStore
.LookupEntry(abs(castItem
->GetItemRandomPropertyId()));
405 for (int k
= 0; k
< 3; ++k
)
407 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(item_rand_suffix
->enchant_id
[k
]);
410 for (int t
= 0; t
< 3; ++t
)
411 if(pEnchant
->spellid
[t
] == m_spellProto
->Id
)
413 damage
= uint32((item_rand_suffix
->prefix
[k
]*castItem
->GetItemSuffixFactor()) / 10000 );
425 if(m_maxduration
== -1 || m_isPassive
&& m_spellProto
->DurationIndex
== 0)
428 Player
* modOwner
= caster
? caster
->GetSpellModOwner() : NULL
;
430 if(!m_permanent
&& modOwner
)
432 modOwner
->ApplySpellMod(GetId(), SPELLMOD_DURATION
, m_maxduration
);
433 // Get zero duration aura after - need set m_maxduration > 0 for apply/remove aura work
434 if (m_maxduration
<=0)
438 m_duration
= m_maxduration
;
440 sLog
.outDebug("Aura: construct Spellid : %u, Aura : %u Duration : %d Target : %d Damage : %d", m_spellProto
->Id
, m_spellProto
->EffectApplyAuraName
[eff
], m_maxduration
, m_spellProto
->EffectImplicitTargetA
[eff
],damage
);
443 SetModifier(AuraType(m_spellProto
->EffectApplyAuraName
[eff
]), damage
, m_spellProto
->EffectAmplitude
[eff
], m_spellProto
->EffectMiscValue
[eff
]);
445 // Apply periodic time mod
446 if(modOwner
&& m_modifier
.periodictime
)
447 modOwner
->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME
, m_modifier
.periodictime
);
449 // Start periodic on next tick or at aura apply
450 if (!(m_spellProto
->AttributesEx5
& SPELL_ATTR_EX5_START_PERIODIC_AT_APPLY
))
451 m_periodicTimer
+= m_modifier
.periodictime
;
453 m_isDeathPersist
= IsDeathPersistentSpell(m_spellProto
);
455 m_procCharges
= m_spellProto
->procCharges
;
457 modOwner
->ApplySpellMod(GetId(), SPELLMOD_CHARGES
, m_procCharges
);
459 m_isRemovedOnShapeLost
= (m_caster_guid
==m_target
->GetGUID() &&
460 m_spellProto
->Stances
&&
461 !(m_spellProto
->AttributesEx2
& SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT
) &&
462 !(m_spellProto
->Attributes
& SPELL_ATTR_NOT_SHAPESHIFT
));
464 if (caster
&& m_spellProto
->Id
== 22959) // Improved Scorch
466 // Glyph of Improved Scorch
467 if (Aura
* glyph
= caster
->GetDummyAura(56371))
468 m_stackAmount
= glyph
->GetModifier()->m_amount
;
476 AreaAura::AreaAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
,
477 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
481 // caster==NULL in constructor args if target==caster in fact
482 Unit
* caster_ptr
= caster
? caster
: target
;
484 m_radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(GetSpellProto()->EffectRadiusIndex
[m_effIndex
]));
485 if(Player
* modOwner
= caster_ptr
->GetSpellModOwner())
486 modOwner
->ApplySpellMod(GetId(), SPELLMOD_RADIUS
, m_radius
);
488 switch(spellproto
->Effect
[eff
])
490 case SPELL_EFFECT_APPLY_AREA_AURA_PARTY
:
491 m_areaAuraType
= AREA_AURA_PARTY
;
492 if (target
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)target
)->isTotem())
493 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
495 case SPELL_EFFECT_APPLY_AREA_AURA_RAID
:
496 m_areaAuraType
= AREA_AURA_RAID
;
497 if (target
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)target
)->isTotem())
498 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
499 // Light's Beacon not applied to caster itself (TODO: more generic check for another simialr spell if any?)
500 else if (target
== caster_ptr
&& m_spellProto
->Id
== 53651)
501 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
503 case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
:
504 m_areaAuraType
= AREA_AURA_FRIEND
;
506 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
:
507 m_areaAuraType
= AREA_AURA_ENEMY
;
508 if (target
== caster_ptr
)
509 m_modifier
.m_auraname
= SPELL_AURA_NONE
; // Do not do any effect on self
511 case SPELL_EFFECT_APPLY_AREA_AURA_PET
:
512 m_areaAuraType
= AREA_AURA_PET
;
514 case SPELL_EFFECT_APPLY_AREA_AURA_OWNER
:
515 m_areaAuraType
= AREA_AURA_OWNER
;
516 if (target
== caster_ptr
)
517 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
520 sLog
.outError("Wrong spell effect in AreaAura constructor");
526 AreaAura::~AreaAura()
530 PersistentAreaAura::PersistentAreaAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
,
531 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
533 m_isPersistent
= true;
536 PersistentAreaAura::~PersistentAreaAura()
540 SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
,
541 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
544 m_casters_target_guid
= caster
->GetTypeId()==TYPEID_PLAYER
? ((Player
*)caster
)->GetSelection() : caster
->GetTargetGUID();
546 m_casters_target_guid
= 0;
549 SingleEnemyTargetAura::~SingleEnemyTargetAura()
553 Unit
* SingleEnemyTargetAura::GetTriggerTarget() const
555 return ObjectAccessor::GetUnit(*m_target
, m_casters_target_guid
);
558 Aura
* CreateAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
, Unit
*caster
, Item
* castItem
)
560 if (IsAreaAuraEffect(spellproto
->Effect
[eff
]))
561 return new AreaAura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
563 uint32 triggeredSpellId
= spellproto
->EffectTriggerSpell
[eff
];
565 if(SpellEntry
const* triggeredSpellInfo
= sSpellStore
.LookupEntry(triggeredSpellId
))
566 for (int i
= 0; i
< 3; ++i
)
567 if (triggeredSpellInfo
->EffectImplicitTargetA
[i
] == TARGET_SINGLE_ENEMY
)
568 return new SingleEnemyTargetAura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
570 return new Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
573 Unit
* Aura::GetCaster() const
575 if(m_caster_guid
== m_target
->GetGUID())
578 //return ObjectAccessor::GetUnit(*m_target,m_caster_guid);
579 //must return caster even if it's in another grid/map
580 Unit
*unit
= ObjectAccessor::GetUnitInWorld(*m_target
,m_caster_guid
);
581 return unit
&& unit
->IsInWorld() ? unit
: NULL
;
584 void Aura::SetModifier(AuraType t
, int32 a
, uint32 pt
, int32 miscValue
)
586 m_modifier
.m_auraname
= t
;
587 m_modifier
.m_amount
= a
;
588 m_modifier
.m_miscvalue
= miscValue
;
589 m_modifier
.periodictime
= pt
;
592 void Aura::Update(uint32 diff
)
601 // GetEffIndex()==0 prevent double/triple apply manaPerSecond/manaPerSecondPerLevel to same spell with many auras
602 // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0
603 if(GetEffIndex()==0 && m_timeCla
<= 0)
605 if(Unit
* caster
= GetCaster())
607 Powers powertype
= Powers(m_spellProto
->powerType
);
608 int32 manaPerSecond
= m_spellProto
->manaPerSecond
+ m_spellProto
->manaPerSecondPerLevel
* caster
->getLevel();
609 m_timeCla
= 1*IN_MILISECONDS
;
612 if(powertype
==POWER_HEALTH
)
613 caster
->ModifyHealth(-manaPerSecond
);
615 caster
->ModifyPower(powertype
,-manaPerSecond
);
621 // Channeled aura required check distance from caster
622 if(IsChanneledSpell(m_spellProto
) && m_caster_guid
!= m_target
->GetGUID())
624 Unit
* caster
= GetCaster();
627 m_target
->RemoveAura(GetId(), GetEffIndex());
631 // need check distance for channeled target only
632 if (caster
->GetChannelObjectGUID() == m_target
->GetGUID())
635 float max_range
= GetSpellMaxRange(sSpellRangeStore
.LookupEntry(m_spellProto
->rangeIndex
));
637 if(Player
* modOwner
= caster
->GetSpellModOwner())
638 modOwner
->ApplySpellMod(GetId(), SPELLMOD_RANGE
, max_range
, NULL
);
640 if(!caster
->IsWithinDistInMap(m_target
, max_range
))
642 m_target
->RemoveAura(GetId(), GetEffIndex());
648 if(m_isPeriodic
&& (m_duration
>= 0 || m_isPassive
|| m_permanent
))
650 m_periodicTimer
-= diff
;
651 if(m_periodicTimer
<= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N
653 // update before applying (aura can be removed in TriggerSpell or PeriodicTick calls)
654 m_periodicTimer
+= m_modifier
.periodictime
;
655 ++m_periodicTick
; // for some infinity auras in some cases can overflow and reset
661 void AreaAura::Update(uint32 diff
)
663 // update for the caster of the aura
664 if(m_caster_guid
== m_target
->GetGUID())
666 Unit
* caster
= m_target
;
668 if( !caster
->hasUnitState(UNIT_STAT_ISOLATED
) )
670 Unit
* owner
= caster
->GetCharmerOrOwner();
673 std::list
<Unit
*> targets
;
675 switch(m_areaAuraType
)
677 case AREA_AURA_PARTY
:
679 Group
*pGroup
= NULL
;
681 if (owner
->GetTypeId() == TYPEID_PLAYER
)
682 pGroup
= ((Player
*)owner
)->GetGroup();
686 uint8 subgroup
= ((Player
*)owner
)->GetSubGroup();
687 for(GroupReference
*itr
= pGroup
->GetFirstMember(); itr
!= NULL
; itr
= itr
->next())
689 Player
* Target
= itr
->getSource();
690 if(Target
&& Target
->isAlive() && Target
->GetSubGroup()==subgroup
&& caster
->IsFriendlyTo(Target
))
692 if(caster
->IsWithinDistInMap(Target
, m_radius
))
693 targets
.push_back(Target
);
694 Pet
*pet
= Target
->GetPet();
695 if(pet
&& pet
->isAlive() && caster
->IsWithinDistInMap(pet
, m_radius
))
696 targets
.push_back(pet
);
703 if( owner
!= caster
&& caster
->IsWithinDistInMap(owner
, m_radius
) )
704 targets
.push_back(owner
);
706 Unit
* pet
= caster
->GetPet();
707 if( pet
&& caster
->IsWithinDistInMap(pet
, m_radius
))
708 targets
.push_back(pet
);
714 Group
*pGroup
= NULL
;
716 if (owner
->GetTypeId() == TYPEID_PLAYER
)
717 pGroup
= ((Player
*)owner
)->GetGroup();
721 for(GroupReference
*itr
= pGroup
->GetFirstMember(); itr
!= NULL
; itr
= itr
->next())
723 Player
* Target
= itr
->getSource();
724 if(Target
&& Target
->isAlive() && caster
->IsFriendlyTo(Target
))
726 if(caster
->IsWithinDistInMap(Target
, m_radius
))
727 targets
.push_back(Target
);
728 Pet
*pet
= Target
->GetPet();
729 if(pet
&& pet
->isAlive() && caster
->IsWithinDistInMap(pet
, m_radius
))
730 targets
.push_back(pet
);
737 if( owner
!= caster
&& caster
->IsWithinDistInMap(owner
, m_radius
) )
738 targets
.push_back(owner
);
740 Unit
* pet
= caster
->GetPet();
741 if( pet
&& caster
->IsWithinDistInMap(pet
, m_radius
))
742 targets
.push_back(pet
);
746 case AREA_AURA_FRIEND
:
748 CellPair
p(MaNGOS::ComputeCellPair(caster
->GetPositionX(), caster
->GetPositionY()));
750 cell
.data
.Part
.reserved
= ALL_DISTRICT
;
753 MaNGOS::AnyFriendlyUnitInObjectRangeCheck
u_check(caster
, owner
, m_radius
);
754 MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
> searcher(caster
,targets
, u_check
);
755 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
>, WorldTypeMapContainer
> world_unit_searcher(searcher
);
756 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
>, GridTypeMapContainer
> grid_unit_searcher(searcher
);
757 CellLock
<GridReadGuard
> cell_lock(cell
, p
);
758 cell_lock
->Visit(cell_lock
, world_unit_searcher
, *caster
->GetMap(), *caster
, m_radius
);
759 cell_lock
->Visit(cell_lock
, grid_unit_searcher
, *caster
->GetMap(), *caster
, m_radius
);
762 case AREA_AURA_ENEMY
:
764 CellPair
p(MaNGOS::ComputeCellPair(caster
->GetPositionX(), caster
->GetPositionY()));
766 cell
.data
.Part
.reserved
= ALL_DISTRICT
;
769 MaNGOS::AnyAoETargetUnitInObjectRangeCheck
u_check(caster
, owner
, m_radius
); // No GetCharmer in searcher
770 MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
> searcher(caster
, targets
, u_check
);
771 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
>, WorldTypeMapContainer
> world_unit_searcher(searcher
);
772 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
>, GridTypeMapContainer
> grid_unit_searcher(searcher
);
773 CellLock
<GridReadGuard
> cell_lock(cell
, p
);
774 cell_lock
->Visit(cell_lock
, world_unit_searcher
, *caster
->GetMap(), *caster
, m_radius
);
775 cell_lock
->Visit(cell_lock
, grid_unit_searcher
, *caster
->GetMap(), *caster
, m_radius
);
778 case AREA_AURA_OWNER
:
781 if(owner
!= caster
&& caster
->IsWithinDistInMap(owner
, m_radius
))
782 targets
.push_back(owner
);
787 for(std::list
<Unit
*>::iterator tIter
= targets
.begin(); tIter
!= targets
.end(); tIter
++)
789 // flag for seelction is need apply aura to current iteration target
792 // we need ignore present caster self applied are auras sometime
793 // in cases if this only auras applied for spell effect
794 Unit::spellEffectPair spair
= Unit::spellEffectPair(GetId(), m_effIndex
);
795 for(Unit::AuraMap::const_iterator i
= (*tIter
)->GetAuras().lower_bound(spair
); i
!= (*tIter
)->GetAuras().upper_bound(spair
); ++i
)
797 if (i
->second
->IsDeleted())
800 switch(m_areaAuraType
)
802 case AREA_AURA_ENEMY
:
803 // non caster self-casted auras (non stacked)
804 if(i
->second
->GetModifier()->m_auraname
!= SPELL_AURA_NONE
)
808 // non caster self-casted auras (stacked from diff. casters)
809 if(i
->second
->GetModifier()->m_auraname
!= SPELL_AURA_NONE
|| i
->second
->GetCasterGUID() == GetCasterGUID())
813 // in generic case not allow stacking area auras
825 if(SpellEntry
const *actualSpellInfo
= sSpellMgr
.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter
)->getLevel()))
827 int32 actualBasePoints
= m_currentBasePoints
;
828 // recalculate basepoints for lower rank (all AreaAura spell not use custom basepoints?)
829 if(actualSpellInfo
!= GetSpellProto())
830 actualBasePoints
= actualSpellInfo
->EffectBasePoints
[m_effIndex
];
831 AreaAura
*aur
= new AreaAura(actualSpellInfo
, m_effIndex
, &actualBasePoints
, (*tIter
), caster
, NULL
);
832 aur
->SetAuraDuration(GetAuraDuration());
833 (*tIter
)->AddAura(aur
);
839 else // aura at non-caster
841 Unit
* caster
= GetCaster();
845 // remove aura if out-of-range from caster (after teleport for example)
846 // or caster is isolated or caster no longer has the aura
847 // or caster is (no longer) friendly
848 bool needFriendly
= (m_areaAuraType
== AREA_AURA_ENEMY
? false : true);
849 if( !caster
|| caster
->hasUnitState(UNIT_STAT_ISOLATED
) ||
850 !caster
->IsWithinDistInMap(m_target
, m_radius
) ||
851 !caster
->HasAura(GetId(), GetEffIndex()) ||
852 caster
->IsFriendlyTo(m_target
) != needFriendly
855 m_target
->RemoveAurasByCasterSpell(GetId(), GetEffIndex(),GetCasterGUID());
857 else if( m_areaAuraType
== AREA_AURA_PARTY
) // check if in same sub group
859 // not check group if target == owner or target == pet
860 if (caster
->GetCharmerOrOwnerGUID() != m_target
->GetGUID() && caster
->GetGUID() != m_target
->GetCharmerOrOwnerGUID())
862 Player
* check
= caster
->GetCharmerOrOwnerPlayerOrPlayerItself();
864 Group
*pGroup
= check
? check
->GetGroup() : NULL
;
867 Player
* checkTarget
= m_target
->GetCharmerOrOwnerPlayerOrPlayerItself();
868 if(!checkTarget
|| !pGroup
->SameSubGroup(check
, checkTarget
))
869 m_target
->RemoveAura(GetId(), GetEffIndex());
872 m_target
->RemoveAura(GetId(), GetEffIndex());
875 else if( m_areaAuraType
== AREA_AURA_RAID
) // TODO: fix me!
877 // not check group if target == owner or target == pet
878 if (caster
->GetCharmerOrOwnerGUID() != m_target
->GetGUID() && caster
->GetGUID() != m_target
->GetCharmerOrOwnerGUID())
880 Player
* check
= caster
->GetCharmerOrOwnerPlayerOrPlayerItself();
882 Group
*pGroup
= check
? check
->GetGroup() : NULL
;
885 Player
* checkTarget
= m_target
->GetCharmerOrOwnerPlayerOrPlayerItself();
887 m_target
->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
890 m_target
->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
893 else if( m_areaAuraType
== AREA_AURA_PET
|| m_areaAuraType
== AREA_AURA_OWNER
)
895 if( m_target
->GetGUID() != caster
->GetCharmerOrOwnerGUID() )
896 m_target
->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
901 void PersistentAreaAura::Update(uint32 diff
)
905 // remove the aura if its caster or the dynamic object causing it was removed
906 // or if the target moves too far from the dynamic object
907 if(Unit
*caster
= GetCaster())
909 DynamicObject
*dynObj
= caster
->GetDynObject(GetId(), GetEffIndex());
912 if (!m_target
->IsWithinDistInMap(dynObj
, dynObj
->GetRadius()))
924 m_target
->RemoveAura(GetId(), GetEffIndex());
927 void Aura::ApplyModifier(bool apply
, bool Real
)
929 AuraType aura
= m_modifier
.m_auraname
;
932 if(aura
< TOTAL_AURAS
)
933 (*this.*AuraHandler
[aura
])(apply
, Real
);
937 bool Aura::IsNeedVisibleSlot(Unit
const* caster
) const
939 bool totemAura
= caster
&& caster
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)caster
)->isTotem();
941 // passive auras (except totem auras) do not get placed in the slots
942 if (m_isPassive
&& !totemAura
)
945 // generic not caster case
946 if (m_target
!= caster
)
949 // special area auras case at caster
950 switch(m_spellProto
->Effect
[GetEffIndex()])
952 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
:
954 case SPELL_EFFECT_APPLY_AREA_AURA_RAID
:
955 // not sure is totemAura need, just preserve old code results
956 return totemAura
|| m_modifier
.m_auraname
!= SPELL_AURA_NONE
;
963 void Aura::_AddAura()
970 // Second aura if some spell
971 bool secondaura
= false;
972 // Try find slot for aura
973 uint8 slot
= NULL_AURA_SLOT
;
974 // Lookup for some spell auras (and get slot from it)
975 for(uint8 i
= 0; i
< m_effIndex
; ++i
)
977 Unit::spellEffectPair spair
= Unit::spellEffectPair(GetId(), i
);
978 for(Unit::AuraMap::const_iterator itr
= m_target
->GetAuras().lower_bound(spair
); itr
!= m_target
->GetAuras().upper_bound(spair
); ++itr
)
980 // allow use single slot only by auras from same caster
981 if(itr
->second
->GetCasterGUID()==GetCasterGUID())
983 slot
= itr
->second
->GetAuraSlot();
992 if (!secondaura
&& m_target
->GetVisibleAurasCount() < MAX_AURAS
)
994 Unit::VisibleAuraMap
const *visibleAuras
= m_target
->GetVisibleAuras();
995 for(uint8 i
= 0; i
< MAX_AURAS
; ++i
)
997 Unit::VisibleAuraMap::const_iterator itr
= visibleAuras
->find(i
);
998 if(itr
== visibleAuras
->end())
1001 // update for out of range group members (on 1 slot use)
1002 m_target
->UpdateAuraForGroup(slot
);
1008 Unit
* caster
= GetCaster();
1010 // set infinity cooldown state for spells
1011 if(caster
&& caster
->GetTypeId() == TYPEID_PLAYER
)
1013 if (m_spellProto
->Attributes
& SPELL_ATTR_DISABLED_WHILE_ACTIVE
)
1015 Item
* castItem
= m_castItemGuid
? ((Player
*)caster
)->GetItemByGuid(m_castItemGuid
) : NULL
;
1016 ((Player
*)caster
)->AddSpellAndCategoryCooldowns(m_spellProto
,castItem
? castItem
->GetEntry() : 0, NULL
,true);
1020 if (IsNeedVisibleSlot(caster
))
1022 SetAuraSlot( slot
);
1023 if(slot
< MAX_AURAS
) // slot found send data to client
1026 SetAuraFlags((1 << GetEffIndex()) | AFLAG_NOT_CASTER
| ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION
: AFLAG_NONE
) | (IsPositive() ? AFLAG_POSITIVE
: AFLAG_NEGATIVE
));
1027 SetAuraLevel(caster
? caster
->getLevel() : sWorld
.getConfig(CONFIG_MAX_PLAYER_LEVEL
));
1028 SendAuraUpdate(false);
1031 //*****************************************************
1032 // Update target aura state flag (at 1 aura apply)
1033 // TODO: Make it easer
1034 //*****************************************************
1037 // Sitdown on apply aura req seated
1038 if (m_spellProto
->AuraInterruptFlags
& AURA_INTERRUPT_FLAG_NOT_SEATED
&& !m_target
->IsSitState())
1039 m_target
->SetStandState(UNIT_STAND_STATE_SIT
);
1041 // register aura diminishing on apply
1042 if (getDiminishGroup() != DIMINISHING_NONE
)
1043 m_target
->ApplyDiminishingAura(getDiminishGroup(), true);
1045 // Update Seals information
1046 if (IsSealSpell(m_spellProto
))
1047 m_target
->ModifyAuraState(AURA_STATE_JUDGEMENT
, true);
1049 // Conflagrate aura state on Immolate and Shadowflame
1050 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARLOCK
&&
1052 ((m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000004)) ||
1054 (m_spellProto
->SpellFamilyFlags2
& 0x00000002)))
1055 m_target
->ModifyAuraState(AURA_STATE_CONFLAGRATE
, true);
1057 // Faerie Fire (druid versions)
1058 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_DRUID
&& (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000400)))
1059 m_target
->ModifyAuraState(AURA_STATE_FAERIE_FIRE
, true);
1062 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0004000000000000)))
1063 m_target
->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH
, true);
1065 // Swiftmend state on Regrowth & Rejuvenation
1066 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_DRUID
&& (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x50)))
1067 m_target
->ModifyAuraState(AURA_STATE_SWIFTMEND
, true);
1069 // Deadly poison aura state
1070 if(m_spellProto
->SpellFamilyName
== SPELLFAMILY_ROGUE
&& (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x10000)))
1071 m_target
->ModifyAuraState(AURA_STATE_DEADLY_POISON
, true);
1073 // Enrage aura state
1074 if(m_spellProto
->Dispel
== DISPEL_ENRAGE
)
1075 m_target
->ModifyAuraState(AURA_STATE_ENRAGE
, true);
1080 bool Aura::_RemoveAura()
1082 // Remove all triggered by aura spells vs unlimited duration
1083 // except same aura replace case
1084 if(m_removeMode
!=AURA_REMOVE_BY_STACK
)
1085 CleanupTriggeredSpells();
1087 Unit
* caster
= GetCaster();
1089 if(caster
&& IsPersistent())
1091 DynamicObject
*dynObj
= caster
->GetDynObject(GetId(), GetEffIndex());
1093 dynObj
->RemoveAffected(m_target
);
1096 //passive auras do not get put in slots
1097 // Note: but totem can be not accessible for aura target in time remove (to far for find in grid)
1098 //if(m_isPassive && !(caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem()))
1101 uint8 slot
= GetAuraSlot();
1103 if(slot
>= MAX_AURAS
) // slot not set
1106 if(m_target
->GetVisibleAura(slot
) == 0)
1109 bool lastaura
= true;
1111 // find other aura in same slot (current already removed from list)
1112 for(uint8 i
= 0; i
< 3; ++i
)
1114 Unit::spellEffectPair spair
= Unit::spellEffectPair(GetId(), i
);
1115 for(Unit::AuraMap::const_iterator itr
= m_target
->GetAuras().lower_bound(spair
); itr
!= m_target
->GetAuras().upper_bound(spair
); ++itr
)
1117 if(itr
->second
->GetAuraSlot() == slot
)
1127 // only remove icon when the last aura of the spell is removed (current aura already removed from list)
1131 // unregister aura diminishing (and store last time)
1132 if (getDiminishGroup() != DIMINISHING_NONE
)
1133 m_target
->ApplyDiminishingAura(getDiminishGroup(), false);
1136 SetAuraFlags(AFLAG_NONE
);
1139 if (m_removeMode
!= AURA_REMOVE_BY_DELETE
)
1141 SendAuraUpdate(true);
1143 // update for out of range group members
1144 m_target
->UpdateAuraForGroup(slot
);
1146 //*****************************************************
1147 // Update target aura state flag (at last aura remove)
1148 //*****************************************************
1149 // Enrage aura state
1150 if(m_spellProto
->Dispel
== DISPEL_ENRAGE
)
1151 m_target
->ModifyAuraState(AURA_STATE_ENRAGE
, false);
1153 uint32 removeState
= 0;
1154 uint64 removeFamilyFlag
= m_spellProto
->SpellFamilyFlags
;
1155 uint32 removeFamilyFlag2
= m_spellProto
->SpellFamilyFlags2
;
1156 switch(m_spellProto
->SpellFamilyName
)
1158 case SPELLFAMILY_PALADIN
:
1159 if (IsSealSpell(m_spellProto
))
1160 removeState
= AURA_STATE_JUDGEMENT
; // Update Seals information
1162 case SPELLFAMILY_WARLOCK
:
1163 // Conflagrate aura state on Immolate and Shadowflame,
1164 if ((m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000004)) ||
1165 (m_spellProto
->SpellFamilyFlags2
& 0x00000002))
1167 removeFamilyFlag
= UI64LIT(0x0000000000000004);
1168 removeFamilyFlag2
= 0x00000002;
1169 removeState
= AURA_STATE_CONFLAGRATE
;
1172 case SPELLFAMILY_DRUID
:
1173 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000400))
1174 removeState
= AURA_STATE_FAERIE_FIRE
; // Faerie Fire (druid versions)
1175 else if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x50))
1177 removeFamilyFlag
= 0x50;
1178 removeState
= AURA_STATE_SWIFTMEND
; // Swiftmend aura state
1181 case SPELLFAMILY_WARRIOR
:
1182 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0004000000000000))
1183 removeState
= AURA_STATE_WARRIOR_VICTORY_RUSH
; // Victorious
1185 case SPELLFAMILY_ROGUE
:
1186 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x10000))
1187 removeState
= AURA_STATE_DEADLY_POISON
; // Deadly poison aura state
1189 case SPELLFAMILY_HUNTER
:
1190 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x1000000000000000))
1191 removeState
= AURA_STATE_FAERIE_FIRE
; // Sting (hunter versions)
1194 // Remove state (but need check other auras for it)
1198 Unit::AuraMap
& Auras
= m_target
->GetAuras();
1199 for(Unit::AuraMap::iterator i
= Auras
.begin(); i
!= Auras
.end(); ++i
)
1201 SpellEntry
const *auraSpellInfo
= (*i
).second
->GetSpellProto();
1202 if(auraSpellInfo
->SpellFamilyName
== m_spellProto
->SpellFamilyName
&&
1203 (auraSpellInfo
->SpellFamilyFlags
& removeFamilyFlag
|| auraSpellInfo
->SpellFamilyFlags2
& removeFamilyFlag2
))
1209 // this has been last aura
1211 m_target
->ModifyAuraState(AuraState(removeState
), false);
1214 // reset cooldown state for spells
1215 if(caster
&& caster
->GetTypeId() == TYPEID_PLAYER
)
1217 if ( GetSpellProto()->Attributes
& SPELL_ATTR_DISABLED_WHILE_ACTIVE
)
1218 // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
1219 ((Player
*)caster
)->SendCooldownEvent(GetSpellProto());
1226 void Aura::SendAuraUpdate(bool remove
)
1228 WorldPacket
data(SMSG_AURA_UPDATE
);
1229 data
.append(m_target
->GetPackGUID());
1230 data
<< uint8(GetAuraSlot());
1231 data
<< uint32(remove
? 0 : GetId());
1235 m_target
->SendMessageToSet(&data
, true);
1239 uint8 auraFlags
= GetAuraFlags();
1240 data
<< uint8(auraFlags
);
1241 data
<< uint8(GetAuraLevel());
1242 data
<< uint8(m_procCharges
? m_procCharges
*m_stackAmount
: m_stackAmount
);
1244 if(!(auraFlags
& AFLAG_NOT_CASTER
))
1246 data
<< uint8(0); // pguid
1249 if(auraFlags
& AFLAG_DURATION
)
1251 data
<< uint32(GetAuraMaxDuration());
1252 data
<< uint32(GetAuraDuration());
1255 m_target
->SendMessageToSet(&data
, true);
1258 void Aura::SetStackAmount(uint8 stackAmount
)
1260 Unit
*target
= GetTarget();
1261 Unit
*caster
= GetCaster();
1262 if (!target
|| !caster
)
1265 bool refresh
= stackAmount
>= m_stackAmount
;
1266 if (stackAmount
!= m_stackAmount
)
1268 m_stackAmount
= stackAmount
;
1269 int32 amount
= m_stackAmount
* caster
->CalculateSpellDamage(m_spellProto
, m_effIndex
, m_currentBasePoints
, target
);
1270 // Reapply if amount change
1271 if (amount
!=m_modifier
.m_amount
)
1273 ApplyModifier(false, true);
1274 m_modifier
.m_amount
= amount
;
1275 ApplyModifier(true, true);
1280 // Stack increased refresh duration
1283 // Stack decreased only send update
1284 SendAuraUpdate(false);
1287 bool Aura::modStackAmount(int32 num
)
1290 if (!m_spellProto
->StackAmount
)
1293 // Modify stack but limit it
1294 int32 stackAmount
= m_stackAmount
+ num
;
1295 if (stackAmount
> m_spellProto
->StackAmount
)
1296 stackAmount
= m_spellProto
->StackAmount
;
1297 else if (stackAmount
<=0) // Last aura from stack removed
1300 return true; // need remove aura
1303 // Update stack amount
1304 SetStackAmount(stackAmount
);
1308 void Aura::RefreshAura()
1310 m_duration
= m_maxduration
;
1311 SendAuraUpdate(false);
1314 bool Aura::isAffectedOnSpell(SpellEntry
const *spell
) const
1316 // Check family name
1317 if (spell
->SpellFamilyName
!= m_spellProto
->SpellFamilyName
)
1319 // Check EffectClassMask
1320 uint32
const *ptr
= getAuraSpellClassMask();
1321 if (((uint64
*)ptr
)[0] & spell
->SpellFamilyFlags
)
1323 if (ptr
[2] & spell
->SpellFamilyFlags2
)
1328 void Aura::ReapplyAffectedPassiveAuras( Unit
* target
, bool owner_mode
)
1330 std::set
<uint32
> affectedSelf
;
1331 std::set
<uint32
> affectedAuraCaster
;
1333 for(Unit::AuraMap::const_iterator itr
= target
->GetAuras().begin(); itr
!= target
->GetAuras().end(); ++itr
)
1335 // permanent passive or permanent area aura
1336 // passive spells can be affected only by own or owner spell mods)
1337 if (itr
->second
->IsPermanent() && (owner_mode
&& itr
->second
->IsPassive() || itr
->second
->IsAreaAura()) &&
1338 // non deleted and not same aura (any with same spell id)
1339 !itr
->second
->IsDeleted() && itr
->second
->GetId() != GetId() &&
1340 // and affected by aura
1341 isAffectedOnSpell(itr
->second
->GetSpellProto()))
1343 // only applied by self or aura caster
1344 if (itr
->second
->GetCasterGUID() == target
->GetGUID())
1345 affectedSelf
.insert(itr
->second
->GetId());
1346 else if (itr
->second
->GetCasterGUID() == GetCasterGUID())
1347 affectedAuraCaster
.insert(itr
->second
->GetId());
1351 for(std::set
<uint32
>::const_iterator set_itr
= affectedSelf
.begin(); set_itr
!= affectedSelf
.end(); ++set_itr
)
1353 target
->RemoveAurasDueToSpell(*set_itr
);
1354 target
->CastSpell(m_target
, *set_itr
, true);
1357 if (!affectedAuraCaster
.empty())
1359 Unit
* caster
= GetCaster();
1360 for(std::set
<uint32
>::const_iterator set_itr
= affectedAuraCaster
.begin(); set_itr
!= affectedAuraCaster
.end(); ++set_itr
)
1362 target
->RemoveAurasDueToSpell(*set_itr
);
1364 caster
->CastSpell(m_target
, *set_itr
, true);
1369 /*********************************************************/
1370 /*** BASIC AURA FUNCTION ***/
1371 /*********************************************************/
1372 void Aura::HandleAddModifier(bool apply
, bool Real
)
1374 if(m_target
->GetTypeId() != TYPEID_PLAYER
|| !Real
)
1377 if(m_modifier
.m_miscvalue
>= MAX_SPELLMOD
)
1382 // Add custom charges for some mod aura
1383 switch (m_spellProto
->Id
)
1385 case 17941: // Shadow Trance
1386 case 22008: // Netherwind Focus
1387 case 31834: // Light's Grace
1388 case 34754: // Clearcasting
1389 case 34936: // Backlash
1390 case 44401: // Missile Barrage
1391 case 48108: // Hot Streak
1392 case 51124: // Killing Machine
1393 case 54741: // Firestarter
1394 case 57761: // Fireball!
1395 case 64823: // Elune's Wrath (Balance druid t8 set
1400 m_spellmod
= new SpellModifier(
1401 SpellModOp(m_modifier
.m_miscvalue
),
1402 SpellModType(m_modifier
.m_auraname
), // SpellModType value == spell aura types
1403 m_modifier
.m_amount
,
1405 // prevent expire spell mods with (charges > 0 && m_stackAmount > 1)
1406 // all this spell expected expire not at use but at spell proc event check
1407 m_spellProto
->StackAmount
> 1 ? 0 : m_procCharges
);
1410 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
1412 // reapply talents to own passive persistent auras
1413 ReapplyAffectedPassiveAuras(m_target
, true);
1415 // re-apply talents/passives/area auras applied to pet (it affected by player spellmods)
1416 if(Pet
* pet
= m_target
->GetPet())
1417 ReapplyAffectedPassiveAuras(pet
, true);
1419 // re-apply talents/passives/area auras applied to totems (it affected by player spellmods)
1420 for(int i
= 0; i
< MAX_TOTEM
; ++i
)
1421 if(m_target
->m_TotemSlot
[i
])
1422 if(Creature
* totem
= m_target
->GetMap()->GetCreature(m_target
->m_TotemSlot
[i
]))
1423 ReapplyAffectedPassiveAuras(totem
, true);
1425 // re-apply talents/passives/area auras applied to group members (it affected by player spellmods)
1426 if (Group
* group
= ((Player
*)m_target
)->GetGroup())
1427 for(GroupReference
*itr
= group
->GetFirstMember(); itr
!= NULL
; itr
= itr
->next())
1428 if (Player
* member
= itr
->getSource())
1429 if (member
!= m_target
&& member
->IsInMap(m_target
))
1430 ReapplyAffectedPassiveAuras(member
, false);
1433 void Aura::HandleAddTargetTrigger(bool apply
, bool /*Real*/)
1435 // Use SpellModifier structure for check
1436 // used only fields:
1437 // spellId, mask, mask2
1440 SpellModifier
*mod
= new SpellModifier
;
1441 mod
->spellId
= GetId();
1443 uint32
const *ptr
= m_spellProto
->GetEffectSpellClassMask(m_effIndex
);
1445 mod
->mask
= (uint64
)ptr
[0] | (uint64
)ptr
[1]<<32;
1456 void Aura::TriggerSpell()
1458 const uint64
& casterGUID
= GetCasterGUID();
1459 Unit
* target
= GetTriggerTarget();
1461 if(!casterGUID
|| !target
)
1464 // generic casting code with custom spells and target/caster customs
1465 uint32 trigger_spell_id
= GetSpellProto()->EffectTriggerSpell
[m_effIndex
];
1467 SpellEntry
const *triggeredSpellInfo
= sSpellStore
.LookupEntry(trigger_spell_id
);
1468 SpellEntry
const *auraSpellInfo
= GetSpellProto();
1469 uint32 auraId
= auraSpellInfo
->Id
;
1471 // specific code for cases with no trigger spell provided in field
1472 if (triggeredSpellInfo
== NULL
)
1474 switch(auraSpellInfo
->SpellFamilyName
)
1476 case SPELLFAMILY_GENERIC
:
1480 // Firestone Passive (1-5 ranks)
1487 if (target
->GetTypeId() != TYPEID_PLAYER
)
1489 Item
* item
= ((Player
*)target
)->GetWeaponForAttack(BASE_ATTACK
);
1492 uint32 enchant_id
= 0;
1495 case 758: enchant_id
= 1803; break; // Rank 1
1496 case 17945: enchant_id
= 1823; break; // Rank 2
1497 case 17947: enchant_id
= 1824; break; // Rank 3
1498 case 17949: enchant_id
= 1825; break; // Rank 4
1499 case 27252: enchant_id
= 2645; break; // Rank 5
1503 // remove old enchanting before applying new
1504 ((Player
*)target
)->ApplyEnchantment(item
,TEMP_ENCHANTMENT_SLOT
,false);
1505 item
->SetEnchantment(TEMP_ENCHANTMENT_SLOT
, enchant_id
, m_modifier
.periodictime
+1000, 0);
1506 // add new enchanting
1507 ((Player
*)target
)->ApplyEnchantment(item
,TEMP_ENCHANTMENT_SLOT
,true);
1510 // // Periodic Mana Burn
1512 // // Polymorphic Ray
1513 // case 6965: break;
1514 // // Fire Nova (1-7 ranks)
1523 // Thaumaturgy Channel
1524 case 9712: trigger_spell_id
= 21029; break;
1525 // // Egan's Blaster
1526 // case 17368: break;
1528 // case 18347: break;
1529 // // Ranshalla Waiting
1530 // case 18953: break;
1532 // case 19695: break;
1533 // // Frostwolf Muzzle DND
1534 // case 21794: break;
1535 // // Alterac Ram Collar DND
1536 // case 21866: break;
1537 // // Celebras Waiting
1538 // case 21916: break;
1539 // Brood Affliction: Bronze
1542 m_target
->CastSpell(m_target
, 23171, true, 0, this);
1546 // case 23184: break;
1550 int32 heal
= target
->GetMaxHealth() / 10;
1551 target
->DealHeal(target
, heal
, auraSpellInfo
);
1553 if (int32 mana
= target
->GetMaxPower(POWER_MANA
))
1556 target
->EnergizeBySpell(target
, 23493, mana
, POWER_MANA
);
1560 // // Stoneclaw Totem Passive TEST
1561 // case 23792: break;
1563 // case 24018: break;
1564 // // Mark of Arlokk
1565 // case 24210: break;
1567 // case 24379: break;
1569 // case 24716: break;
1571 // case 24780: break;
1573 // case 24832: break;
1574 // // Shadow Bolt Whirl
1575 // case 24834: break;
1577 // case 24918: break;
1578 // // Mark of Nature
1579 // case 25041: break;
1581 // case 25152: break;
1585 int32 bpDamage
= target
->GetMaxHealth()*10/100;
1586 target
->CastCustomSpell(target
, 25373, &bpDamage
, NULL
, NULL
, true, NULL
, this, casterGUID
);
1590 // case 25572: break;
1592 // case 26009: break;
1594 // case 26136: break;
1596 // case 26196: break;
1598 // case 26615: break;
1600 // case 27177: break;
1601 // // Teleport: IF/UC
1602 // case 27601: break;
1603 // // Five Fat Finger Exploding Heart Technique
1604 // case 27673: break;
1606 // case 27746: break;
1607 // // Steam Tank Passive
1608 // case 27747: break;
1612 int32 bpDamage
= target
->GetMaxHealth()*26/100;
1613 target
->CastCustomSpell(target
, 29879, &bpDamage
, NULL
, NULL
, true, NULL
, this, casterGUID
);
1617 // case 27819: break;
1618 // // Controller Timer
1619 // case 28095: break;
1621 // case 28096: break;
1622 // // Stalagg Tesla Passive
1623 // case 28097: break;
1624 // // Feugen Tesla Passive
1625 // case 28109: break;
1627 // case 28111: break;
1628 // // Mark of Didier
1629 // case 28114: break;
1630 // // Communique Timer, camp
1631 // case 28346: break;
1633 // case 28522: break;
1635 // case 29519: break;
1636 // Inoculate Nestlewood Owlkin
1638 if(target
->GetTypeId() != TYPEID_UNIT
)// prevent error reports in case ignored player target
1642 // case 29768: break;
1644 // case 29788: break;
1646 // case 29793: break;
1648 // case 29794: break;
1649 // // Guardian of Icecrown Passive
1650 // case 29897: break;
1651 // Feed Captured Animal
1652 case 29917: trigger_spell_id
= 29916; break;
1654 // case 29946: break;
1656 // case 29947: break;
1657 // // Mind Exhaustion Passive
1658 // case 30025: break;
1659 // // Nether Beam - Serenity
1660 // case 30401: break;
1664 Unit
* caster
= GetCaster();
1667 // move loot to player inventory and despawn target
1668 if(caster
->GetTypeId() ==TYPEID_PLAYER
&&
1669 target
->GetTypeId() == TYPEID_UNIT
&&
1670 ((Creature
*)target
)->GetCreatureInfo()->type
== CREATURE_TYPE_GAS_CLOUD
)
1672 Player
* player
= (Player
*)caster
;
1673 Creature
* creature
= (Creature
*)target
;
1674 // missing lootid has been reported on startup - just return
1675 if (!creature
->GetCreatureInfo()->SkinLootId
)
1678 player
->AutoStoreLoot(creature
->GetCreatureInfo()->SkinLootId
,LootTemplates_Skinning
,true);
1680 creature
->ForcedDespawn();
1685 case 30576: trigger_spell_id
= 30571; break;
1687 // case 30598: break;
1693 // // Despawn Self - Smoke cloud
1694 // case 31269: break;
1695 // // Time Rift Periodic
1696 // case 31320: break;
1697 // // Corrupt Medivh
1698 // case 31326: break;
1702 m_target
->CastSpell(m_target
,31350,true);
1703 m_target
->DealDamage(m_target
, m_target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
1709 // Summon Elemental after create item
1710 target
->SummonCreature(17870, 0, 0, 0, target
->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN
, 0);
1713 // // Bloodmyst Tesla
1714 // case 31611: break;
1718 int32 damage
= m_modifier
.m_amount
* ((float)(GetAuraDuration() + m_modifier
.periodictime
) / GetAuraMaxDuration());
1719 target
->CastCustomSpell(target
, 31969, &damage
, NULL
, NULL
, true, NULL
, this, casterGUID
);
1723 // case 32236: break;
1725 // case 32686: break;
1727 // case 33401: break;
1729 // case 33563: break;
1730 // // Murmur's Touch
1731 // case 33711: break;
1735 // cast 24 spells 34269-34289, 34314-34316
1736 for(uint32 spell_id
= 34269; spell_id
!= 34290; ++spell_id
)
1737 target
->CastSpell(target
, spell_id
, true, NULL
, this, casterGUID
);
1738 for(uint32 spell_id
= 34314; spell_id
!= 34317; ++spell_id
)
1739 target
->CastSpell(target
, spell_id
, true, NULL
, this, casterGUID
);
1743 // case 34480: break;
1745 // case 34683: break;
1746 // // Frostbite Rotate
1747 // case 34748: break;
1749 // case 34821: break;
1750 // // Interrupt Shutdown
1751 // case 35016: break;
1752 // // Interrupt Shutdown
1753 // case 35176: break;
1755 // case 35268: break;
1756 // // Salaadin's Tesla
1757 // case 35515: break;
1758 // // Ethereal Channel (Red)
1759 // case 35518: break;
1761 // case 35879: break;
1762 // // Dark Portal Storm
1763 // case 36018: break;
1765 // case 36056: break;
1766 // // Living Grove Defender Lifespan
1767 // case 36061: break;
1768 // // Professor Dabiri Talks
1769 // case 36064: break;
1770 // // Kael Gaining Power
1771 // case 36091: break;
1772 // // They Must Burn Bomb Aura
1773 // case 36344: break;
1774 // // They Must Burn Bomb Aura (self)
1775 // case 36350: break;
1776 // // Stolen Ravenous Ravager Egg
1777 // case 36401: break;
1778 // // Activated Cannon
1779 // case 36410: break;
1780 // // Stolen Ravenous Ravager Egg
1781 // case 36418: break;
1782 // // Enchanted Weapons
1783 // case 36510: break;
1784 // // Cursed Scarab Periodic
1785 // case 36556: break;
1786 // // Cursed Scarab Despawn Periodic
1787 // case 36561: break;
1789 // case 36573: break;
1790 // // Cannon Charging (platform)
1791 // case 36785: break;
1792 // // Cannon Charging (self)
1793 // case 36860: break;
1795 case 37027: trigger_spell_id
= 37029; break;
1797 // case 37125: break;
1799 // case 37268: break;
1801 // case 37429: break;
1803 // case 37430: break;
1804 // // Karazhan - Chess NPC AI, Snapshot timer
1805 // case 37440: break;
1806 // // Karazhan - Chess NPC AI, action timer
1807 // case 37504: break;
1808 // // Karazhan - Chess: Is Square OCCUPIED aura (DND)
1809 // case 39400: break;
1811 // case 37546: break;
1812 // // Shriveling Gaze
1813 // case 37589: break;
1814 // // Fake Aggro Radius (2 yd)
1815 // case 37815: break;
1816 // // Corrupt Medivh
1817 // case 37853: break;
1821 m_target
->CastSpell(m_target
, 38530, true);
1824 // Absorb Eye of Grillok (Zezzak's Shard)
1827 if(m_target
->GetTypeId() != TYPEID_UNIT
)
1830 if (Unit
* caster
= GetCaster())
1831 caster
->CastSpell(caster
, 38495, true, NULL
, this);
1835 Creature
* creatureTarget
= (Creature
*)m_target
;
1837 creatureTarget
->ForcedDespawn();
1840 // // Magic Sucker Device timer
1841 // case 38672: break;
1842 // // Tomb Guarding Charging
1843 // case 38751: break;
1844 // // Murmur's Touch
1845 // case 38794: break;
1846 // // Activate Nether-wraith Beacon (31742 Nether-wraith Beacon item)
1847 // case 39105: break;
1848 // // Drain World Tree Visual
1849 // case 39140: break;
1850 // // Quest - Dustin's Undead Dragon Visual aura
1851 // case 39259: break;
1852 // // Hellfire - The Exorcism, Jules releases darkness, aura
1853 // case 39306: break;
1855 // case 39346: break;
1856 // // Enchanted Weapons
1857 // case 39489: break;
1858 // // Shadow Bolt Whirl
1859 // case 39630: break;
1860 // // Shadow Bolt Whirl
1861 // case 39634: break;
1862 // // Shadow Inferno
1863 // case 39645: break;
1864 // Tear of Azzinoth Summon Channel - it's not really supposed to do anything,and this only prevents the console spam
1865 case 39857: trigger_spell_id
= 39856; break;
1866 // // Soulgrinder Ritual Visual (Smashed)
1867 // case 39974: break;
1868 // // Simon Game Pre-game timer
1869 // case 40041: break;
1870 // // Knockdown Fel Cannon: The Aggro Check Aura
1871 // case 40113: break;
1873 // case 40157: break;
1874 // // Demon Transform 2
1875 // case 40398: break;
1876 // // Demon Transform 1
1877 // case 40511: break;
1878 // // Ancient Flames
1879 // case 40657: break;
1880 // // Ethereal Ring Cannon: Cannon Aura
1881 // case 40734: break;
1883 // case 40760: break;
1884 // // Random Periodic
1885 // case 40867: break;
1886 // // Prismatic Shield
1887 // case 40879: break;
1888 // // Aura of Desire
1889 // case 41350: break;
1891 // case 41404: break;
1893 // case 41629: break;
1895 // case 42177: break;
1897 // case 42581: break;
1899 // case 42582: break;
1900 // // Return to the Spirit Realm
1901 // case 44035: break;
1902 // // Curse of Boundless Agony
1903 // case 45050: break;
1905 // case 46240: break;
1906 // Personalized Weather
1907 case 46736: trigger_spell_id
= 46737; break;
1908 // // Stay Submerged
1909 // case 46981: break;
1910 // // Dragonblight Ram
1911 // case 47015: break;
1912 // // Party G.R.E.N.A.D.E.
1913 // case 51510: break;
1919 case SPELLFAMILY_MAGE
:
1925 // Here need periodic triger reducing threat spell (or do it manually)
1932 // case SPELLFAMILY_WARRIOR:
1937 // case 23410: break;
1938 // // Corrupted Totems
1939 // case 23425: break;
1945 // case SPELLFAMILY_PRIEST:
1950 // case 32930: break;
1951 // // Fury of the Dreghood Elders
1952 // case 35460: break;
1958 case SPELLFAMILY_HUNTER
:
1966 if (target
->GetTypeId() != TYPEID_PLAYER
)
1969 // Reset reapply counter at move
1970 if (((Player
*)target
)->isMoving())
1972 m_modifier
.m_amount
= 6;
1976 // We are standing at the moment
1977 if (m_modifier
.m_amount
> 0)
1979 --m_modifier
.m_amount
;
1983 // select rank of buff
1986 case 53302: trigger_spell_id
= 64418; break;
1987 case 53303: trigger_spell_id
= 64419; break;
1988 case 53304: trigger_spell_id
= 64420; break;
1991 // If aura is active - no need to continue
1992 if (target
->HasAura(trigger_spell_id
))
2001 case SPELLFAMILY_DRUID
:
2006 // trigger_spell_id not set and unknown effect triggered in this case, ignoring for while
2009 // Frenzied Regeneration
2015 int32 LifePerRage
= GetModifier()->m_amount
;
2017 int32 lRage
= m_target
->GetPower(POWER_RAGE
);
2018 if(lRage
> 100) // rage stored as rage*10
2020 m_target
->ModifyPower(POWER_RAGE
, -lRage
);
2021 int32 FRTriggerBasePoints
= int32(lRage
*LifePerRage
/10);
2022 m_target
->CastCustomSpell(m_target
, 22845, &FRTriggerBasePoints
, NULL
, NULL
, true, NULL
, this);
2031 // case SPELLFAMILY_HUNTER:
2035 // //Frost Trap Aura
2038 // //Rizzle's Frost Trap
2042 // case 19597: // Tame Ice Claw Bear
2043 // case 19676: // Tame Snow Leopard
2044 // case 19677: // Tame Large Crag Boar
2045 // case 19678: // Tame Adult Plainstrider
2046 // case 19679: // Tame Prairie Stalker
2047 // case 19680: // Tame Swoop
2048 // case 19681: // Tame Dire Mottled Boar
2049 // case 19682: // Tame Surf Crawler
2050 // case 19683: // Tame Armored Scorpid
2051 // case 19684: // Tame Webwood Lurker
2052 // case 19685: // Tame Nightsaber Stalker
2053 // case 19686: // Tame Strigid Screecher
2054 // case 30100: // Tame Crazed Dragonhawk
2055 // case 30103: // Tame Elder Springpaw
2056 // case 30104: // Tame Mistbat
2057 // case 30647: // Tame Barbed Crawler
2058 // case 30648: // Tame Greater Timberstrider
2059 // case 30652: // Tame Nightstalker
2066 case SPELLFAMILY_SHAMAN
:
2070 // Lightning Shield (The Earthshatterer set trigger after cast Lighting Shield)
2073 // Need remove self if Lightning Shield not active
2074 Unit::AuraMap
const& auras
= target
->GetAuras();
2075 for(Unit::AuraMap::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
2077 SpellEntry
const* spell
= itr
->second
->GetSpellProto();
2078 if( spell
->SpellFamilyName
== SPELLFAMILY_SHAMAN
&&
2079 (spell
->SpellFamilyFlags
& UI64LIT(0x0000000000000400)))
2082 target
->RemoveAurasDueToSpell(28820);
2085 // Totemic Mastery (Skyshatter Regalia (Shaman Tier 6) - bonus)
2089 for(int i
= 0; i
< MAX_TOTEM
; ++i
)
2091 if(!target
->m_TotemSlot
[i
])
2099 target
->CastSpell(target
, 38437, true, NULL
, this);
2101 target
->RemoveAurasDueToSpell(38437);
2113 // Reget trigger spell proto
2114 triggeredSpellInfo
= sSpellStore
.LookupEntry(trigger_spell_id
);
2118 // Spell exist but require custom code
2124 // TODO: spell casted by result in correct way mostly
2126 // 1) target show casting at each triggered cast: target don't must show casting animation for any triggered spell
2127 // but must show affect apply like item casting
2128 // 2) maybe aura must be replace by new with accumulative stat mods instead stacking
2130 // prevent cast by triggered auras
2131 if(casterGUID
== target
->GetGUID())
2134 // stop triggering after each affected stats lost > 90
2135 int32 intelectLoss
= 0;
2136 int32 spiritLoss
= 0;
2138 Unit::AuraList
const& mModStat
= target
->GetAurasByType(SPELL_AURA_MOD_STAT
);
2139 for(Unit::AuraList::const_iterator i
= mModStat
.begin(); i
!= mModStat
.end(); ++i
)
2141 if ((*i
)->GetId() == 1010)
2143 switch((*i
)->GetModifier()->m_miscvalue
)
2145 case STAT_INTELLECT
: intelectLoss
+= (*i
)->GetModifier()->m_amount
; break;
2146 case STAT_SPIRIT
: spiritLoss
+= (*i
)->GetModifier()->m_amount
; break;
2152 if(intelectLoss
<= -90 && spiritLoss
<= -90)
2160 target
->CastCustomSpell(target
, trigger_spell_id
, &m_modifier
.m_amount
, NULL
, NULL
, true, NULL
, this);
2165 target
->CastSpell(target
, trigger_spell_id
, true, NULL
, this, casterGUID
);
2169 // original caster must be target (beacon)
2170 target
->CastSpell(target
, trigger_spell_id
, true, NULL
, this, target
->GetGUID());
2172 // Rapid Recuperation (triggered energize have baspioints == 0)
2176 int32 mana
= m_target
->GetMaxPower(POWER_MANA
) * m_modifier
.m_amount
/ 100;
2177 target
->CastCustomSpell(target
, trigger_spell_id
, &mana
, NULL
, NULL
, true, NULL
, this);
2183 // All ok cast by default case
2184 if(triggeredSpellInfo
)
2185 target
->CastSpell(target
, triggeredSpellInfo
, true, NULL
, this, casterGUID
);
2188 if (Unit
* caster
= GetCaster())
2190 if(target
->GetTypeId() != TYPEID_UNIT
|| !Script
->EffectDummyCreature(caster
, GetId(), GetEffIndex(), (Creature
*)target
))
2191 sLog
.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex());
2196 void Aura::TriggerSpellWithValue()
2198 const uint64
& casterGUID
= GetCasterGUID();
2199 Unit
* target
= GetTriggerTarget();
2201 if(!casterGUID
|| !target
)
2204 // generic casting code with custom spells and target/caster customs
2205 uint32 trigger_spell_id
= GetSpellProto()->EffectTriggerSpell
[m_effIndex
];
2206 int32 basepoints0
= this->GetModifier()->m_amount
;
2208 target
->CastCustomSpell(target
, trigger_spell_id
, &basepoints0
, NULL
, NULL
, true, NULL
, this, casterGUID
);
2211 /*********************************************************/
2212 /*** AURA EFFECTS ***/
2213 /*********************************************************/
2215 void Aura::HandleAuraDummy(bool apply
, bool Real
)
2217 // spells required only Real aura add/remove
2224 switch(m_spellProto
->SpellFamilyName
)
2226 case SPELLFAMILY_GENERIC
:
2229 case 1515: // Tame beast
2230 // FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness
2231 if (m_target
->CanHaveThreatList())
2232 if (Unit
* caster
= GetCaster())
2233 m_target
->AddThreat(caster
, 10.0f
, false, GetSpellSchoolMask(GetSpellProto()), GetSpellProto());
2235 case 7057: // Haunting Spirits
2236 // expected to tick with 30 sec period (tick part see in Aura::PeriodicTick)
2237 m_isPeriodic
= true;
2238 m_modifier
.periodictime
= 30*IN_MILISECONDS
;
2239 m_periodicTimer
= m_modifier
.periodictime
;
2241 case 13139: // net-o-matic
2242 // root to self part of (root_target->charge->root_self sequence
2243 if (Unit
* caster
= GetCaster())
2244 caster
->CastSpell(caster
, 13138, true, NULL
, this);
2246 case 39850: // Rocket Blast
2247 if(roll_chance_i(20)) // backfire stun
2248 m_target
->CastSpell(m_target
, 51581, true, NULL
, this);
2250 case 43873: // Headless Horseman Laugh
2251 m_target
->PlayDistanceSound(11965);
2253 case 46354: // Blood Elf Illusion
2254 if (Unit
* caster
= GetCaster())
2256 switch(caster
->getGender())
2259 caster
->CastSpell(m_target
, 46356, true, NULL
, this);
2262 caster
->CastSpell(m_target
, 46355, true, NULL
, this);
2269 case 46699: // Requires No Ammo
2270 if (m_target
->GetTypeId() == TYPEID_PLAYER
)
2271 // not use ammo and not allow use
2272 ((Player
*)m_target
)->RemoveAmmo();
2274 case 62061: // Festive Holiday Mount
2275 if (m_target
->HasAuraType(SPELL_AURA_MOUNTED
))
2276 // Reindeer Transformation
2277 m_target
->CastSpell(m_target
, 25860, true, NULL
, this);
2281 case SPELLFAMILY_WARRIOR
:
2283 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000004))
2285 // Must be casting target
2286 if (!m_target
->IsNonMeleeSpellCasted(false))
2289 Unit
* caster
= GetCaster();
2293 Unit::AuraList
const& modifierAuras
= caster
->GetAurasByType(SPELL_AURA_ADD_FLAT_MODIFIER
);
2294 for(Unit::AuraList::const_iterator itr
= modifierAuras
.begin(); itr
!= modifierAuras
.end(); ++itr
)
2296 // Unrelenting Assault
2297 if((*itr
)->GetSpellProto()->SpellFamilyName
==SPELLFAMILY_WARRIOR
&& (*itr
)->GetSpellProto()->SpellIconID
== 2775)
2299 switch ((*itr
)->GetSpellProto()->Id
)
2301 case 46859: // Unrelenting Assault, rank 1
2302 m_target
->CastSpell(m_target
,64849,true,NULL
,(*itr
));
2304 case 46860: // Unrelenting Assault, rank 2
2305 m_target
->CastSpell(m_target
,64850,true,NULL
,(*itr
));
2316 case SPELLFAMILY_SHAMAN
:
2318 if (GetId() == 55198)
2320 // apply max stack bufs
2321 SpellEntry
const* buffEntry
= sSpellStore
.LookupEntry(55166);
2324 for(int k
= 0; k
< buffEntry
->StackAmount
; ++k
)
2325 m_target
->CastSpell(m_target
, buffEntry
, true, NULL
, this);
2328 else if ((GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x40000000000)))
2330 // prevent double apply bonuses
2331 if(m_target
->GetTypeId() != TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading())
2332 if (Unit
* caster
= GetCaster())
2333 m_modifier
.m_amount
= caster
->SpellHealingBonus(m_target
, GetSpellProto(), m_modifier
.m_amount
, SPELL_DIRECT_DAMAGE
);
2342 if( m_target
->GetTypeId() == TYPEID_PLAYER
&&
2343 ( GetSpellProto()->Effect
[0]==72 || GetSpellProto()->Effect
[0]==6 &&
2344 ( GetSpellProto()->EffectApplyAuraName
[0]==1 || GetSpellProto()->EffectApplyAuraName
[0]==128 ) ) )
2346 // spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425
2347 ((Player
*)m_target
)->SetFarSightGUID(0);
2348 WorldPacket
data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE
, 0);
2349 ((Player
*)m_target
)->GetSession()->SendPacket(&data
);
2353 if (IsQuestTameSpell(GetId()) && m_target
->isAlive())
2355 Unit
* caster
= GetCaster();
2356 if (!caster
|| !caster
->isAlive())
2359 uint32 finalSpelId
= 0;
2362 case 19548: finalSpelId
= 19597; break;
2363 case 19674: finalSpelId
= 19677; break;
2364 case 19687: finalSpelId
= 19676; break;
2365 case 19688: finalSpelId
= 19678; break;
2366 case 19689: finalSpelId
= 19679; break;
2367 case 19692: finalSpelId
= 19680; break;
2368 case 19693: finalSpelId
= 19684; break;
2369 case 19694: finalSpelId
= 19681; break;
2370 case 19696: finalSpelId
= 19682; break;
2371 case 19697: finalSpelId
= 19683; break;
2372 case 19699: finalSpelId
= 19685; break;
2373 case 19700: finalSpelId
= 19686; break;
2374 case 30646: finalSpelId
= 30647; break;
2375 case 30653: finalSpelId
= 30648; break;
2376 case 30654: finalSpelId
= 30652; break;
2377 case 30099: finalSpelId
= 30100; break;
2378 case 30102: finalSpelId
= 30103; break;
2379 case 30105: finalSpelId
= 30104; break;
2383 caster
->CastSpell(m_target
, finalSpelId
, true, NULL
, this);
2389 case 28169: // Mutating Injection
2391 // Mutagen Explosion
2392 m_target
->CastSpell(m_target
, 28206, true, NULL
, this);
2394 m_target
->CastSpell(m_target
, 28240, true, NULL
, this);
2397 case 32286: // Focus Target Visual
2399 if (m_removeMode
== AURA_REMOVE_BY_DEFAULT
)
2400 m_target
->CastSpell(m_target
, 32301, true, NULL
, this);
2404 case 36730: // Flame Strike
2406 m_target
->CastSpell(m_target
, 36731, true, NULL
, this);
2409 case 44191: // Flame Strike
2411 if (m_target
->GetMap()->IsDungeon())
2413 uint32 spellId
= m_target
->GetMap()->IsRegularDifficulty() ? 44190 : 46163;
2415 m_target
->CastSpell(m_target
, spellId
, true, NULL
, this);
2419 case 45934: // Dark Fiend
2421 // Kill target if dispelled
2422 if (m_removeMode
==AURA_REMOVE_BY_DISPEL
)
2423 m_target
->DealDamage(m_target
, m_target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
2426 case 46308: // Burning Winds
2428 // casted only at creatures at spawn
2429 m_target
->CastSpell(m_target
, 47287, true, NULL
, this);
2435 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_MAGE
&& (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x2000000000000)))
2437 // Zero duration is equal to AURA_REMOVE_BY_DEFAULT. We can't use it directly, as it is set even
2438 // when removing aura from one target due to casting Living Bomb at other.
2439 if (m_duration
== 0 || m_removeMode
== AURA_REMOVE_BY_DISPEL
)
2440 m_target
->CastSpell(m_target
,m_modifier
.m_amount
,true,NULL
,this);
2444 if (m_removeMode
== AURA_REMOVE_BY_DEATH
)
2446 // Stop caster Arcane Missle chanelling on death
2447 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_MAGE
&&
2448 (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000800)))
2450 if (Unit
* caster
= GetCaster())
2451 caster
->InterruptSpell(CURRENT_CHANNELED_SPELL
);
2454 // Stop caster Penance chanelling on death
2455 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_PRIEST
&&
2456 (m_spellProto
->SpellFamilyFlags2
& UI64LIT(0x00000080)))
2458 if (Unit
* caster
= GetCaster())
2459 caster
->InterruptSpell(CURRENT_CHANNELED_SPELL
);
2465 // AT APPLY & REMOVE
2467 switch(m_spellProto
->SpellFamilyName
)
2469 case SPELLFAMILY_GENERIC
:
2473 // Recently Bandaged
2475 m_target
->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC
, GetMiscValue(), apply
);
2480 uint32 spellId
= 24659;
2483 SpellEntry
const *spell
= sSpellStore
.LookupEntry(spellId
);
2484 Unit
* caster
= GetCaster();
2485 if (!spell
|| !caster
)
2488 for (int i
=0; i
< spell
->StackAmount
; ++i
)
2489 caster
->CastSpell(m_target
, spellId
, true, NULL
, NULL
, GetCasterGUID());
2492 m_target
->RemoveAurasDueToSpell(spellId
);
2495 // Restless Strength
2498 uint32 spellId
= 24662;
2501 SpellEntry
const* spell
= sSpellStore
.LookupEntry(spellId
);
2502 Unit
* caster
= GetCaster();
2503 if (!spell
|| !caster
)
2505 for (int i
=0; i
< spell
->StackAmount
; ++i
)
2506 caster
->CastSpell(m_target
, spell
->Id
, true, NULL
, NULL
, GetCasterGUID());
2509 m_target
->RemoveAurasDueToSpell(spellId
);
2512 //Summon Fire Elemental
2515 Unit
* caster
= GetCaster();
2519 Unit
*owner
= caster
->GetOwner();
2520 if (owner
&& owner
->GetTypeId() == TYPEID_PLAYER
)
2523 owner
->CastSpell(owner
, 8985, true);
2525 ((Player
*)owner
)->RemovePet(NULL
, PET_SAVE_NOT_IN_SLOT
, true);
2529 //Summon Earth Elemental
2532 Unit
* caster
= GetCaster();
2536 Unit
*owner
= caster
->GetOwner();
2537 if (owner
&& owner
->GetTypeId() == TYPEID_PLAYER
)
2540 owner
->CastSpell(owner
, 19704, true);
2542 ((Player
*)owner
)->RemovePet(NULL
, PET_SAVE_NOT_IN_SLOT
, true);
2546 //Dragonmaw Illusion
2551 m_target
->CastSpell(m_target
, 40216, true);
2552 m_target
->CastSpell(m_target
, 42016, true);
2556 m_target
->RemoveAurasDueToSpell(40216);
2557 m_target
->RemoveAurasDueToSpell(42016);
2563 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2567 m_target
->PlayDirectSound(14970, (Player
*)m_target
);
2568 // continue in 58205
2570 m_target
->CastSpell(m_target
, 58205, true);
2575 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2579 m_target
->PlayDirectSound(14971, (Player
*)m_target
);
2582 m_target
->PlayDirectSound(14972, (Player
*)m_target
);
2588 m_target
->m_AuraFlags
|= UNIT_AURAFLAG_ALIVE_INVISIBLE
;
2590 m_target
->m_AuraFlags
|= ~UNIT_AURAFLAG_ALIVE_INVISIBLE
;
2595 case SPELLFAMILY_MAGE
:
2597 case SPELLFAMILY_WARLOCK
:
2600 if (GetSpellProto()->SpellIconID
== 3172 && (GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0004000000000000)))
2602 // NOTE: for avoid use additional field damage stored in dummy value (replace unused 100%
2604 m_modifier
.m_amount
= 0; // use value as damage counter instead redundent 100% percent
2607 int32 bp0
= m_modifier
.m_amount
;
2609 if (Unit
* caster
= GetCaster())
2610 m_target
->CastCustomSpell(caster
,48210,&bp0
,NULL
,NULL
,true);
2615 case SPELLFAMILY_PRIEST
:
2617 // Pain and Suffering
2618 if( m_spellProto
->SpellIconID
== 2874 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2622 // Reduce backfire damage (dot damage) from Shadow Word: Death
2623 // aura have wrong effectclassmask, so use hardcoded value
2624 m_spellmod
= new SpellModifier(SPELLMOD_DOT
,SPELLMOD_PCT
,m_modifier
.m_amount
,GetId(),UI64LIT(0x0000200000000000));
2626 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2631 case SPELLFAMILY_DRUID
:
2635 case 34246: // Idol of the Emerald Queen
2636 case 60779: // Idol of Lush Moss
2638 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
2642 // dummy not have proper effectclassmask
2643 m_spellmod
= new SpellModifier(SPELLMOD_DOT
,SPELLMOD_FLAT
,m_modifier
.m_amount
/7,GetId(),UI64LIT(0x001000000000));
2645 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2648 case 52610: // Savage Roar
2652 if(m_target
->m_form
!= FORM_CAT
)
2655 m_target
->CastSpell(m_target
, 62071, true);
2658 m_target
-> RemoveAurasDueToSpell(62071);
2661 case 61336: // Survival Instincts
2665 if (!m_target
->IsInFeralForm())
2668 int32 bp0
= int32(m_target
->GetMaxHealth() * m_modifier
.m_amount
/ 100);
2669 m_target
->CastCustomSpell(m_target
, 50322, &bp0
, NULL
, NULL
, true);
2672 m_target
-> RemoveAurasDueToSpell(50322);
2678 if (GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x1000000000))
2682 if (Unit
* caster
= GetCaster())
2683 // prevent double apply bonuses
2684 if(m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading())
2685 m_modifier
.m_amount
= caster
->SpellHealingBonus(m_target
, GetSpellProto(), m_modifier
.m_amount
, SPELL_DIRECT_DAMAGE
);
2689 // Final heal only on dispelled or duration end
2690 if ( !(GetAuraDuration() <= 0 || m_removeMode
== AURA_REMOVE_BY_DISPEL
) )
2693 // have a look if there is still some other Lifebloom dummy aura
2694 Unit::AuraList
const& auras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
2695 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!=auras
.end(); ++itr
)
2696 if((*itr
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_DRUID
&&
2697 ((*itr
)->GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x1000000000)))
2701 if(m_target
->IsInWorld() && m_stackAmount
> 0)
2703 int32 amount
= m_modifier
.m_amount
/ m_stackAmount
;
2704 m_target
->CastCustomSpell(m_target
, 33778, &amount
, NULL
, NULL
, true, NULL
, this, GetCasterGUID());
2706 if (Unit
* caster
= GetCaster())
2708 int32 returnmana
= (GetSpellProto()->ManaCostPercentage
* caster
->GetCreateMana() / 100) * m_stackAmount
/ 2;
2709 caster
->CastCustomSpell(caster
, 64372, &returnmana
, NULL
, NULL
, true, NULL
, this, GetCasterGUID());
2716 // Predatory Strikes
2717 if(m_target
->GetTypeId()==TYPEID_PLAYER
&& GetSpellProto()->SpellIconID
== 1563)
2719 ((Player
*)m_target
)->UpdateAttackPowerAndDamage();
2723 // Improved Moonkin Form
2724 if(GetSpellProto()->SpellIconID
== 2855)
2729 case 48384: spell_id
= 50170; break; //Rank 1
2730 case 48395: spell_id
= 50171; break; //Rank 2
2731 case 48396: spell_id
= 50172; break; //Rank 3
2733 sLog
.outError("HandleAuraDummy: Not handled rank of IMF (Spell: %u)",GetId());
2739 if(m_target
->m_form
!= FORM_MOONKIN
)
2742 m_target
->CastSpell(m_target
, spell_id
, true);
2745 m_target
-> RemoveAurasDueToSpell(spell_id
);
2750 case SPELLFAMILY_HUNTER
:
2752 case SPELLFAMILY_PALADIN
:
2755 case 20911: // Blessing of Sanctuary
2756 case 25899: // Greater Blessing of Sanctuary
2759 m_target
->CastSpell(m_target
, 67480, true, NULL
, this);
2761 m_target
->RemoveAurasDueToSpell(67480);
2766 case SPELLFAMILY_SHAMAN
:
2771 if(PetAura
const* petSpell
= sSpellMgr
.GetPetAura(GetId(), m_effIndex
))
2774 m_target
->AddPetAura(petSpell
);
2776 m_target
->RemovePetAura(petSpell
);
2780 if(GetEffIndex()==0 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2782 SpellAreaForAreaMapBounds saBounds
= sSpellMgr
.GetSpellAreaForAuraMapBounds(GetId());
2783 if(saBounds
.first
!= saBounds
.second
)
2786 m_target
->GetZoneAndAreaId(zone
, area
);
2788 for(SpellAreaForAreaMap::const_iterator itr
= saBounds
.first
; itr
!= saBounds
.second
; ++itr
)
2790 // some auras remove at aura remove
2791 if(!itr
->second
->IsFitToRequirements((Player
*)m_target
, zone
, area
))
2792 m_target
->RemoveAurasDueToSpell(itr
->second
->spellId
);
2793 // some auras applied at aura apply
2794 else if(itr
->second
->autocast
)
2796 if( !m_target
->HasAura(itr
->second
->spellId
, 0) )
2797 m_target
->CastSpell(m_target
, itr
->second
->spellId
, true);
2804 void Aura::HandleAuraMounted(bool apply
, bool Real
)
2806 // only at real add/remove aura
2812 CreatureInfo
const* ci
= ObjectMgr::GetCreatureTemplate(m_modifier
.m_miscvalue
);
2815 sLog
.outErrorDb("AuraMounted: `creature_template`='%u' not found in database (only need it modelid)", m_modifier
.m_miscvalue
);
2820 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
2821 team
= ((Player
*)m_target
)->GetTeam();
2823 uint32 display_id
= sObjectMgr
.ChooseDisplayId(team
,ci
);
2824 CreatureModelInfo
const *minfo
= sObjectMgr
.GetCreatureModelRandomGender(display_id
);
2826 display_id
= minfo
->modelid
;
2828 m_target
->Mount(display_id
, m_spellProto
->Id
);
2832 m_target
->Unmount();
2836 void Aura::HandleAuraWaterWalk(bool apply
, bool Real
)
2838 // only at real add/remove aura
2844 data
.Initialize(SMSG_MOVE_WATER_WALK
, 8+4);
2846 data
.Initialize(SMSG_MOVE_LAND_WALK
, 8+4);
2847 data
.append(m_target
->GetPackGUID());
2849 m_target
->SendMessageToSet(&data
, true);
2852 void Aura::HandleAuraFeatherFall(bool apply
, bool Real
)
2854 // only at real add/remove aura
2860 data
.Initialize(SMSG_MOVE_FEATHER_FALL
, 8+4);
2862 data
.Initialize(SMSG_MOVE_NORMAL_FALL
, 8+4);
2863 data
.append(m_target
->GetPackGUID());
2865 m_target
->SendMessageToSet(&data
, true);
2867 // start fall from current height
2868 if(!apply
&& m_target
->GetTypeId() == TYPEID_PLAYER
)
2869 ((Player
*)m_target
)->SetFallInformation(0, m_target
->GetPositionZ());
2872 void Aura::HandleAuraHover(bool apply
, bool Real
)
2874 // only at real add/remove aura
2880 data
.Initialize(SMSG_MOVE_SET_HOVER
, 8+4);
2882 data
.Initialize(SMSG_MOVE_UNSET_HOVER
, 8+4);
2883 data
.append(m_target
->GetPackGUID());
2885 m_target
->SendMessageToSet(&data
, true);
2888 void Aura::HandleWaterBreathing(bool /*apply*/, bool /*Real*/)
2890 // update timers in client
2891 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
2892 ((Player
*)m_target
)->UpdateMirrorTimers();
2895 void Aura::HandleAuraModShapeshift(bool apply
, bool Real
)
2901 Powers PowerType
= POWER_MANA
;
2902 ShapeshiftForm form
= ShapeshiftForm(m_modifier
.m_miscvalue
);
2904 SpellShapeshiftEntry
const* ssEntry
= sSpellShapeshiftStore
.LookupEntry(form
);
2907 sLog
.outError("Unknown shapeshift form %u in spell %u", form
, GetId());
2911 if (ssEntry
->modelID_A
)
2913 // i will asume that creatures will always take the defined model from the dbc
2914 // since no field in creature_templates describes wether an alliance or
2915 // horde modelid should be used at shapeshifting
2916 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
2917 modelid
= ssEntry
->modelID_A
;
2920 // players are a bit difficult since the dbc has seldomly an horde modelid
2921 // so we add hacks here to set the right model
2922 if (Player::TeamForRace(m_target
->getRace()) == ALLIANCE
)
2923 modelid
= ssEntry
->modelID_A
;
2924 else // 3.2.3 only the moonkin form has this information
2925 modelid
= ssEntry
->modelID_H
;
2927 // no model found, if player is horde we look here for our hardcoded modelids
2928 if (!modelid
&& Player::TeamForRace(m_target
->getRace()) == HORDE
)
2943 case FORM_FLIGHT_EPIC
:
2946 // per default use alliance modelid
2947 // mostly horde and alliance share the same
2949 modelid
= ssEntry
->modelID_A
;
2956 // now only powertype must be set
2960 PowerType
= POWER_ENERGY
;
2964 case FORM_BATTLESTANCE
:
2965 case FORM_BERSERKERSTANCE
:
2966 case FORM_DEFENSIVESTANCE
:
2967 PowerType
= POWER_RAGE
;
2973 // remove polymorph before changing display id to keep new display id
2982 case FORM_FLIGHT_EPIC
:
2986 // remove movement affects
2987 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT
);
2988 Unit::AuraList
const& slowingAuras
= m_target
->GetAurasByType(SPELL_AURA_MOD_DECREASE_SPEED
);
2989 for (Unit::AuraList::const_iterator iter
= slowingAuras
.begin(); iter
!= slowingAuras
.end();)
2991 SpellEntry
const* aurSpellInfo
= (*iter
)->GetSpellProto();
2993 uint32 aurMechMask
= GetAllSpellMechanicMask(aurSpellInfo
);
2995 // If spell that caused this aura has Croud Control or Daze effect
2996 if((aurMechMask
& MECHANIC_NOT_REMOVED_BY_SHAPESHIFT
) ||
2997 // some Daze spells have these parameters instead of MECHANIC_DAZE (skip snare spells)
2998 aurSpellInfo
->SpellIconID
== 15 && aurSpellInfo
->Dispel
== 0 &&
2999 (aurMechMask
& (1 << (MECHANIC_SNARE
-1)))==0)
3005 // All OK, remove aura now
3006 m_target
->RemoveAurasDueToSpellByCancel(aurSpellInfo
->Id
);
3007 iter
= slowingAuras
.begin();
3010 // and polymorphic affects
3011 if(m_target
->IsPolymorphed())
3012 m_target
->RemoveAurasDueToSpell(m_target
->getTransForm());
3022 // remove other shapeshift before applying a new one
3023 if(m_target
->m_ShapeShiftFormSpellId
)
3024 m_target
->RemoveAurasDueToSpell(m_target
->m_ShapeShiftFormSpellId
, this);
3026 m_target
->SetByteValue(UNIT_FIELD_BYTES_2
, 3, form
);
3029 m_target
->SetDisplayId(modelid
);
3031 if(PowerType
!= POWER_MANA
)
3033 // reset power to default values only at power change
3034 if(m_target
->getPowerType() != PowerType
)
3035 m_target
->setPowerType(PowerType
);
3043 // get furor proc chance
3044 int32 furorChance
= 0;
3045 Unit::AuraList
const& mDummy
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
3046 for(Unit::AuraList::const_iterator i
= mDummy
.begin(); i
!= mDummy
.end(); ++i
)
3048 if ((*i
)->GetSpellProto()->SpellIconID
== 238)
3050 furorChance
= (*i
)->GetModifier()->m_amount
;
3055 if (m_modifier
.m_miscvalue
== FORM_CAT
)
3057 // Furor chance is now amount allowed to save energy for cat form
3058 // without talent it reset to 0
3059 if (m_target
->GetPower(POWER_ENERGY
) > furorChance
)
3061 m_target
->SetPower(POWER_ENERGY
, 0);
3062 m_target
->CastCustomSpell(m_target
, 17099, &furorChance
, NULL
, NULL
, this);
3065 else if(furorChance
) // only if talent known
3067 m_target
->SetPower(POWER_RAGE
, 0);
3068 if(urand(1,100) <= furorChance
)
3069 m_target
->CastSpell(m_target
, 17057, true, NULL
, this);
3073 case FORM_BATTLESTANCE
:
3074 case FORM_DEFENSIVESTANCE
:
3075 case FORM_BERSERKERSTANCE
:
3077 uint32 Rage_val
= 0;
3078 // Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch)
3079 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3081 PlayerSpellMap
const& sp_list
= ((Player
*)m_target
)->GetSpellMap();
3082 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
3084 if(itr
->second
->state
== PLAYERSPELL_REMOVED
) continue;
3085 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
3086 if (spellInfo
&& spellInfo
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& spellInfo
->SpellIconID
== 139)
3087 Rage_val
+= m_target
->CalculateSpellDamage(spellInfo
, 0, spellInfo
->EffectBasePoints
[0], m_target
) * 10;
3091 if (m_target
->GetPower(POWER_RAGE
) > Rage_val
)
3092 m_target
->SetPower(POWER_RAGE
, Rage_val
);
3100 m_target
->m_ShapeShiftFormSpellId
= GetId();
3101 m_target
->m_form
= form
;
3103 // a form can give the player a new castbar with some spells.. this is a clientside process..
3104 // serverside just needs to register the new spells so that player isn't kicked as cheater
3105 if (m_target
->GetTypeId() == TYPEID_PLAYER
)
3106 for (uint32 i
= 0; i
< 8; ++i
)
3107 if (ssEntry
->spellId
[i
])
3108 ((Player
*)m_target
)->addSpell(ssEntry
->spellId
[i
], true, false, false, false);
3114 m_target
->SetDisplayId(m_target
->GetNativeDisplayId());
3115 m_target
->SetByteValue(UNIT_FIELD_BYTES_2
, 3, FORM_NONE
);
3116 if(m_target
->getClass() == CLASS_DRUID
)
3117 m_target
->setPowerType(POWER_MANA
);
3118 m_target
->m_ShapeShiftFormSpellId
= 0;
3119 m_target
->m_form
= FORM_NONE
;
3123 // Nordrassil Harness - bonus
3127 if(Aura
* dummy
= m_target
->GetDummyAura(37315) )
3128 m_target
->CastSpell(m_target
, 37316, true, NULL
, dummy
);
3130 // Nordrassil Regalia - bonus
3132 if(Aura
* dummy
= m_target
->GetDummyAura(37324) )
3133 m_target
->CastSpell(m_target
, 37325, true, NULL
, dummy
);
3139 // look at the comment in apply-part
3140 if (m_target
->GetTypeId() == TYPEID_PLAYER
)
3141 for (uint32 i
= 0; i
< 8; ++i
)
3142 if (ssEntry
->spellId
[i
])
3143 ((Player
*)m_target
)->removeSpell(ssEntry
->spellId
[i
], false, false, false);
3147 // adding/removing linked auras
3148 // add/remove the shapeshift aura's boosts
3149 HandleShapeshiftBoosts(apply
);
3151 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3152 ((Player
*)m_target
)->InitDataForForm();
3155 void Aura::HandleAuraTransform(bool apply
, bool Real
)
3159 // special case (spell specific functionality)
3160 if (m_modifier
.m_miscvalue
== 0)
3162 // player applied only
3163 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
3171 uint32 orb_model
= m_target
->GetNativeDisplayId();
3175 case 1479: m_target
->SetDisplayId(10134); break;
3177 case 1478: m_target
->SetDisplayId(10135); break;
3179 case 59: m_target
->SetDisplayId(10136); break;
3181 case 49: m_target
->SetDisplayId(10137); break;
3183 case 50: m_target
->SetDisplayId(10138); break;
3185 case 51: m_target
->SetDisplayId(10139); break;
3187 case 52: m_target
->SetDisplayId(10140); break;
3189 case 53: m_target
->SetDisplayId(10141); break;
3191 case 54: m_target
->SetDisplayId(10142); break;
3193 case 55: m_target
->SetDisplayId(10143); break;
3195 case 56: m_target
->SetDisplayId(10144); break;
3197 case 58: m_target
->SetDisplayId(10145); break;
3199 case 57: m_target
->SetDisplayId(10146); break;
3201 case 60: m_target
->SetDisplayId(10147); break;
3203 case 1563: m_target
->SetDisplayId(10148); break;
3205 case 1564: m_target
->SetDisplayId(10149); break;
3207 case 15475: m_target
->SetDisplayId(17830); break;
3209 case 15476: m_target
->SetDisplayId(17829); break;
3211 case 16126: m_target
->SetDisplayId(17828); break;
3213 case 16125: m_target
->SetDisplayId(17827); break;
3219 case 42365: m_target
->SetDisplayId(21723); break;
3224 switch(m_target
->getGender())
3227 m_target
->SetDisplayId(29203); // Chapman
3231 m_target
->SetDisplayId(29204); // Catrina
3243 CreatureInfo
const * ci
= ObjectMgr::GetCreatureTemplate(m_modifier
.m_miscvalue
);
3246 model_id
= 16358; // pig pink ^_^
3247 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 model_id
= ci
->DisplayID_A
[0]; // Will use the default model here
3252 // Polymorph (sheep/penguin case)
3253 if (GetSpellProto()->SpellFamilyName
== SPELLFAMILY_MAGE
&& GetSpellProto()->SpellIconID
== 82)
3254 if (Unit
* caster
= GetCaster())
3255 if (caster
->HasAura(52648)) // Glyph of the Penguin
3258 m_target
->SetDisplayId(model_id
);
3260 // Dragonmaw Illusion (set mount model also)
3261 if(GetId()==42016 && m_target
->GetMountID() && !m_target
->GetAurasByType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
).empty())
3262 m_target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
,16314);
3265 // update active transform spell only not set or not overwriting negative by positive case
3266 if (!m_target
->getTransForm() || !IsPositiveSpell(GetId()) || IsPositiveSpell(m_target
->getTransForm()))
3267 m_target
->setTransForm(GetId());
3270 if (Real
&& m_target
->GetTypeId() == TYPEID_PLAYER
&& m_target
->IsPolymorphed())
3272 // for players, start regeneration after 1s (in polymorph fast regeneration case)
3273 // only if caster is Player (after patch 2.4.2)
3274 if (IS_PLAYER_GUID(GetCasterGUID()) )
3275 ((Player
*)m_target
)->setRegenTimer(1*IN_MILISECONDS
);
3277 //dismount polymorphed target (after patch 2.4.2)
3278 if (m_target
->IsMounted())
3279 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
3284 // ApplyModifier(true) will reapply it if need
3285 m_target
->setTransForm(0);
3286 m_target
->SetDisplayId(m_target
->GetNativeDisplayId());
3288 // re-aplly some from still active with preference negative cases
3289 Unit::AuraList
const& otherTransforms
= m_target
->GetAurasByType(SPELL_AURA_TRANSFORM
);
3290 if (!otherTransforms
.empty())
3292 // look for other transform auras
3293 Aura
* handledAura
= *otherTransforms
.begin();
3294 for(Unit::AuraList::const_iterator i
= otherTransforms
.begin();i
!= otherTransforms
.end(); ++i
)
3296 // negative auras are preferred
3297 if (!IsPositiveSpell((*i
)->GetSpellProto()->Id
))
3303 handledAura
->ApplyModifier(true);
3306 // Dragonmaw Illusion (restore mount model)
3307 if (GetId() == 42016 && m_target
->GetMountID() == 16314)
3309 if (!m_target
->GetAurasByType(SPELL_AURA_MOUNTED
).empty())
3311 uint32 cr_id
= m_target
->GetAurasByType(SPELL_AURA_MOUNTED
).front()->GetModifier()->m_miscvalue
;
3312 if (CreatureInfo
const* ci
= ObjectMgr::GetCreatureTemplate(cr_id
))
3315 if (m_target
->GetTypeId() == TYPEID_PLAYER
)
3316 team
= ((Player
*)m_target
)->GetTeam();
3318 uint32 display_id
= sObjectMgr
.ChooseDisplayId(team
, ci
);
3319 CreatureModelInfo
const *minfo
= sObjectMgr
.GetCreatureModelRandomGender(display_id
);
3321 display_id
= minfo
->modelid
;
3323 m_target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
, display_id
);
3330 void Aura::HandleForceReaction(bool apply
, bool Real
)
3332 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
3338 Player
* player
= (Player
*)m_target
;
3340 uint32 faction_id
= m_modifier
.m_miscvalue
;
3341 ReputationRank faction_rank
= ReputationRank(m_modifier
.m_amount
);
3343 player
->GetReputationMgr().ApplyForceReaction(faction_id
, faction_rank
, apply
);
3344 player
->GetReputationMgr().SendForceReactions();
3346 // stop fighting if at apply forced rank friendly or at remove real rank friendly
3347 if (apply
&& faction_rank
>= REP_FRIENDLY
|| !apply
&& player
->GetReputationRank(faction_id
) >= REP_FRIENDLY
)
3348 player
->StopAttackFaction(faction_id
);
3351 void Aura::HandleAuraModSkill(bool apply
, bool /*Real*/)
3353 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
3356 uint32 prot
=GetSpellProto()->EffectMiscValue
[m_effIndex
];
3357 int32 points
= GetModifier()->m_amount
;
3359 ((Player
*)m_target
)->ModifySkillBonus(prot
, (apply
? points
: -points
), m_modifier
.m_auraname
== SPELL_AURA_MOD_SKILL_TALENT
);
3360 if(prot
== SKILL_DEFENSE
)
3361 ((Player
*)m_target
)->UpdateDefenseBonusesMod();
3364 void Aura::HandleChannelDeathItem(bool apply
, bool Real
)
3368 if(m_removeMode
!= AURA_REMOVE_BY_DEATH
)
3371 if (m_modifier
.m_amount
<= 0)
3374 SpellEntry
const *spellInfo
= GetSpellProto();
3375 if(spellInfo
->EffectItemType
[m_effIndex
] == 0)
3378 Unit
* victim
= GetTarget();
3379 Unit
* caster
= GetCaster();
3380 if (!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3383 // Soul Shard only from non-grey units
3384 if( spellInfo
->EffectItemType
[m_effIndex
] == 6265 &&
3385 (victim
->getLevel() <= MaNGOS::XP::GetGrayLevel(caster
->getLevel()) ||
3386 victim
->GetTypeId()==TYPEID_UNIT
&& !((Player
*)caster
)->isAllowedToLoot((Creature
*)victim
)) )
3389 uint32 noSpaceForCount
= 0;
3390 uint32 count
= m_modifier
.m_amount
;
3392 ItemPosCountVec dest
;
3393 uint8 msg
= ((Player
*)caster
)->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, spellInfo
->EffectItemType
[m_effIndex
], count
, &noSpaceForCount
);
3394 if( msg
!= EQUIP_ERR_OK
)
3396 count
-=noSpaceForCount
;
3397 ((Player
*)caster
)->SendEquipError( msg
, NULL
, NULL
);
3402 Item
* newitem
= ((Player
*)caster
)->StoreNewItem(dest
, spellInfo
->EffectItemType
[m_effIndex
], true);
3403 ((Player
*)caster
)->SendNewItem(newitem
, count
, true, false);
3407 void Aura::HandleBindSight(bool apply
, bool /*Real*/)
3409 Unit
* caster
= GetCaster();
3410 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3413 ((Player
*)caster
)->SetFarSightGUID(apply
? m_target
->GetGUID() : 0);
3416 void Aura::HandleFarSight(bool apply
, bool /*Real*/)
3418 Unit
* caster
= GetCaster();
3419 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3422 ((Player
*)caster
)->SetFarSightGUID(apply
? m_target
->GetGUID() : 0);
3425 void Aura::HandleAuraTrackCreatures(bool apply
, bool /*Real*/)
3427 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
3431 m_target
->RemoveNoStackAurasDueToAura(this);
3432 m_target
->SetUInt32Value(PLAYER_TRACK_CREATURES
, apply
? ((uint32
)1)<<(m_modifier
.m_miscvalue
-1) : 0 );
3435 void Aura::HandleAuraTrackResources(bool apply
, bool /*Real*/)
3437 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
3441 m_target
->RemoveNoStackAurasDueToAura(this);
3442 m_target
->SetUInt32Value(PLAYER_TRACK_RESOURCES
, apply
? ((uint32
)1)<<(m_modifier
.m_miscvalue
-1): 0 );
3445 void Aura::HandleAuraTrackStealthed(bool apply
, bool /*Real*/)
3447 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
3451 m_target
->RemoveNoStackAurasDueToAura(this);
3453 m_target
->ApplyModFlag(PLAYER_FIELD_BYTES
, PLAYER_FIELD_BYTE_TRACK_STEALTHED
, apply
);
3456 void Aura::HandleAuraModScale(bool apply
, bool /*Real*/)
3458 m_target
->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X
, m_modifier
.m_amount
, apply
);
3461 void Aura::HandleModPossess(bool apply
, bool Real
)
3466 // not possess yourself
3467 if(GetCasterGUID() == m_target
->GetGUID())
3470 Unit
* caster
= GetCaster();
3471 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3474 Player
* p_caster
= (Player
*)caster
;
3479 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PLAYER_CONTROLLED
);
3481 m_target
->SetCharmerGUID(p_caster
->GetGUID());
3482 m_target
->setFaction(p_caster
->getFaction());
3484 p_caster
->SetCharm(m_target
);
3486 p_caster
->SetFarSightGUID(m_target
->GetGUID());
3487 p_caster
->SetClientControl(m_target
, 1);
3488 p_caster
->SetMover(m_target
);
3490 m_target
->CombatStop();
3491 m_target
->DeleteThreatList();
3493 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3495 m_target
->StopMoving();
3496 m_target
->GetMotionMaster()->Clear();
3497 m_target
->GetMotionMaster()->MoveIdle();
3499 else if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3501 ((Player
*)m_target
)->SetClientControl(m_target
, 0);
3504 if(CharmInfo
*charmInfo
= m_target
->InitCharmInfo(m_target
))
3505 charmInfo
->InitPossessCreateSpells();
3507 p_caster
->PossessSpellInitialize();
3511 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PLAYER_CONTROLLED
);
3513 m_target
->SetCharmerGUID(0);
3514 p_caster
->InterruptSpell(CURRENT_CHANNELED_SPELL
); // the spell is not automatically canceled when interrupted, do it now
3516 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3518 ((Player
*)m_target
)->setFactionForRace(m_target
->getRace());
3519 ((Player
*)m_target
)->SetClientControl(m_target
, 1);
3521 else if(m_target
->GetTypeId() == TYPEID_UNIT
)
3523 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
3524 m_target
->setFaction(cinfo
->faction_A
);
3527 p_caster
->SetCharm(NULL
);
3529 p_caster
->SetFarSightGUID(0);
3530 p_caster
->SetClientControl(m_target
, 0);
3531 p_caster
->SetMover(NULL
);
3533 p_caster
->RemovePetActionBar();
3535 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3537 ((Creature
*)m_target
)->AIM_Initialize();
3539 if (((Creature
*)m_target
)->AI())
3540 ((Creature
*)m_target
)->AI()->AttackedBy(caster
);
3545 void Aura::HandleModPossessPet(bool apply
, bool Real
)
3550 Unit
* caster
= GetCaster();
3551 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3554 Pet
*pet
= caster
->GetPet();
3555 if(!pet
|| pet
!= m_target
)
3558 Player
* p_caster
= (Player
*)caster
;
3561 pet
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PLAYER_CONTROLLED
);
3563 pet
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PLAYER_CONTROLLED
);
3565 p_caster
->SetFarSightGUID(apply
? pet
->GetGUID() : 0);
3566 p_caster
->SetCharm(apply
? pet
: NULL
);
3567 p_caster
->SetClientControl(pet
, apply
? 1 : 0);
3568 ((Player
*)caster
)->SetMover(apply
? pet
: NULL
);
3573 pet
->GetMotionMaster()->Clear();
3574 pet
->GetMotionMaster()->MoveIdle();
3579 pet
->GetMotionMaster()->MoveFollow(caster
, PET_FOLLOW_DIST
, PET_FOLLOW_ANGLE
);
3580 pet
->AddMonsterMoveFlag(MONSTER_MOVE_WALK
);
3584 void Aura::HandleAuraModPetTalentsPoints(bool /*Apply*/, bool Real
)
3589 // Recalculate pet talent points
3590 if (Pet
*pet
=m_target
->GetPet())
3591 pet
->InitTalentForLevel();
3594 void Aura::HandleModCharm(bool apply
, bool Real
)
3599 // not charm yourself
3600 if(GetCasterGUID() == m_target
->GetGUID())
3603 Unit
* caster
= GetCaster();
3609 if (m_target
->GetCharmerGUID())
3611 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM
);
3612 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS
);
3615 m_target
->SetCharmerGUID(GetCasterGUID());
3616 m_target
->setFaction(caster
->getFaction());
3617 m_target
->CastStop(m_target
== caster
? GetId() : 0);
3618 caster
->SetCharm(m_target
);
3620 m_target
->CombatStop();
3621 m_target
->DeleteThreatList();
3623 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3625 ((Creature
*)m_target
)->AIM_Initialize();
3626 CharmInfo
*charmInfo
= m_target
->InitCharmInfo(m_target
);
3627 charmInfo
->InitCharmCreateSpells();
3628 charmInfo
->SetReactState( REACT_DEFENSIVE
);
3630 if(caster
->GetTypeId() == TYPEID_PLAYER
&& caster
->getClass() == CLASS_WARLOCK
)
3632 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
3633 if(cinfo
&& cinfo
->type
== CREATURE_TYPE_DEMON
)
3635 // creature with pet number expected have class set
3636 if(m_target
->GetByteValue(UNIT_FIELD_BYTES_0
, 1)==0)
3638 if(cinfo
->unit_class
==0)
3639 sLog
.outErrorDb("Creature (Entry: %u) have unit_class = 0 but used in charmed spell, that will be result client crash.",cinfo
->Entry
);
3641 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
);
3643 m_target
->SetByteValue(UNIT_FIELD_BYTES_0
, 1, CLASS_MAGE
);
3646 //just to enable stat window
3647 charmInfo
->SetPetNumber(sObjectMgr
.GeneratePetNumber(), true);
3648 //if charmed two demons the same session, the 2nd gets the 1st one's name
3649 m_target
->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP
, time(NULL
));
3654 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3655 ((Player
*)caster
)->CharmSpellInitialize();
3659 m_target
->SetCharmerGUID(0);
3661 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3662 ((Player
*)m_target
)->setFactionForRace(m_target
->getRace());
3665 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
3668 if(((Creature
*)m_target
)->isPet())
3670 if(Unit
* owner
= m_target
->GetOwner())
3671 m_target
->setFaction(owner
->getFaction());
3673 m_target
->setFaction(cinfo
->faction_A
);
3675 else if(cinfo
) // normal creature
3676 m_target
->setFaction(cinfo
->faction_A
);
3678 // restore UNIT_FIELD_BYTES_0
3679 if(cinfo
&& caster
->GetTypeId() == TYPEID_PLAYER
&& caster
->getClass() == CLASS_WARLOCK
&& cinfo
->type
== CREATURE_TYPE_DEMON
)
3681 // DB must have proper class set in field at loading, not req. restore, including workaround case at apply
3682 // m_target->SetByteValue(UNIT_FIELD_BYTES_0, 1, cinfo->unit_class);
3684 if(m_target
->GetCharmInfo())
3685 m_target
->GetCharmInfo()->SetPetNumber(0, true);
3687 sLog
.outError("Aura::HandleModCharm: target (GUID: %u TypeId: %u) has a charm aura but no charm info!", m_target
->GetGUIDLow(), m_target
->GetTypeId());
3691 caster
->SetCharm(NULL
);
3693 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3694 ((Player
*)caster
)->RemovePetActionBar();
3696 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3698 ((Creature
*)m_target
)->AIM_Initialize();
3699 if (((Creature
*)m_target
)->AI())
3700 ((Creature
*)m_target
)->AI()->AttackedBy(caster
);
3705 void Aura::HandleModConfuse(bool apply
, bool Real
)
3710 m_target
->SetConfused(apply
, GetCasterGUID(), GetId());
3713 void Aura::HandleModFear(bool apply
, bool Real
)
3718 m_target
->SetFeared(apply
, GetCasterGUID(), GetId());
3721 void Aura::HandleFeignDeath(bool apply
, bool Real
)
3726 m_target
->SetFeignDeath(apply
, GetCasterGUID(), GetId());
3729 void Aura::HandleAuraModDisarm(bool apply
, bool Real
)
3734 if(!apply
&& m_target
->HasAuraType(SPELL_AURA_MOD_DISARM
))
3737 // not sure for it's correctness
3739 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_DISARMED
);
3741 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_DISARMED
);
3743 // only at real add/remove aura
3744 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
3747 // main-hand attack speed already set to special value for feral form already and don't must change and reset at remove.
3748 if (m_target
->IsInFeralForm())
3752 m_target
->SetAttackTime(BASE_ATTACK
,BASE_ATTACK_TIME
);
3754 ((Player
*)m_target
)->SetRegularAttackTime();
3756 m_target
->UpdateDamagePhysical(BASE_ATTACK
);
3759 void Aura::HandleAuraModStun(bool apply
, bool Real
)
3766 // Frost stun aura -> freeze/unfreeze target
3767 if (GetSpellSchoolMask(m_spellProto
) & SPELL_SCHOOL_MASK_FROST
)
3768 m_target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
3770 m_target
->addUnitState(UNIT_STAT_STUNNED
);
3771 m_target
->SetTargetGUID(0);
3773 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
3774 m_target
->CastStop(m_target
->GetGUID() == GetCasterGUID() ? GetId() : 0);
3776 // Creature specific
3777 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
3778 m_target
->StopMoving();
3781 ((Player
*)m_target
)->m_movementInfo
.SetMovementFlags(MOVEMENTFLAG_NONE
);
3782 m_target
->SetStandState(UNIT_STAND_STATE_STAND
);// in 1.5 client
3785 WorldPacket
data(SMSG_FORCE_MOVE_ROOT
, 8);
3786 data
.append(m_target
->GetPackGUID());
3788 m_target
->SendMessageToSet(&data
, true);
3790 // Summon the Naj'entus Spine GameObject on target if spell is Impaling Spine
3791 if(GetId() == 39837)
3793 GameObject
* pObj
= new GameObject
;
3794 if(pObj
->Create(sObjectMgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), 185584, m_target
->GetMap(), m_target
->GetPhaseMask(),
3795 m_target
->GetPositionX(), m_target
->GetPositionY(), m_target
->GetPositionZ(), m_target
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 100, GO_STATE_READY
))
3797 pObj
->SetRespawnTime(GetAuraDuration()/IN_MILISECONDS
);
3798 pObj
->SetSpellId(GetId());
3799 m_target
->AddGameObject(pObj
);
3800 m_target
->GetMap()->Add(pObj
);
3808 // Frost stun aura -> freeze/unfreeze target
3809 if (GetSpellSchoolMask(m_spellProto
) & SPELL_SCHOOL_MASK_FROST
)
3811 bool found_another
= false;
3812 for(AuraType
const* itr
= &frozenAuraTypes
[0]; *itr
!= SPELL_AURA_NONE
; ++itr
)
3814 Unit::AuraList
const& auras
= m_target
->GetAurasByType(*itr
);
3815 for(Unit::AuraList::const_iterator i
= auras
.begin(); i
!= auras
.end(); ++i
)
3817 if( GetSpellSchoolMask((*i
)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST
)
3819 found_another
= true;
3828 m_target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
3831 // Real remove called after current aura remove from lists, check if other similar auras active
3832 if(m_target
->HasAuraType(SPELL_AURA_MOD_STUN
))
3835 m_target
->clearUnitState(UNIT_STAT_STUNNED
);
3836 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
3838 if(!m_target
->hasUnitState(UNIT_STAT_ROOT
)) // prevent allow move if have also root effect
3840 if(m_target
->getVictim() && m_target
->isAlive())
3841 m_target
->SetTargetGUID(m_target
->getVictim()->GetGUID());
3843 WorldPacket
data(SMSG_FORCE_MOVE_UNROOT
, 8+4);
3844 data
.append(m_target
->GetPackGUID());
3846 m_target
->SendMessageToSet(&data
, true);
3850 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_HUNTER
&& m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000100000000000))
3852 Unit
* caster
= GetCaster();
3853 if( !caster
|| caster
->GetTypeId()!=TYPEID_PLAYER
)
3856 uint32 spell_id
= 0;
3860 case 19386: spell_id
= 24131; break;
3861 case 24132: spell_id
= 24134; break;
3862 case 24133: spell_id
= 24135; break;
3863 case 27068: spell_id
= 27069; break;
3864 case 49011: spell_id
= 49009; break;
3865 case 49012: spell_id
= 49010; break;
3867 sLog
.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?",GetId());
3871 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell_id
);
3876 caster
->CastSpell(m_target
,spellInfo
,true,NULL
,this);
3882 void Aura::HandleModStealth(bool apply
, bool Real
)
3886 // drop flag at stealth in bg
3887 m_target
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
);
3889 // only at real aura add
3892 m_target
->SetStandFlags(UNIT_STAND_FLAGS_CREEP
);
3894 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
3895 m_target
->SetFlag(PLAYER_FIELD_BYTES2
, 0x2000);
3897 // apply only if not in GM invisibility (and overwrite invisibility state)
3898 if (m_target
->GetVisibility()!=VISIBILITY_OFF
)
3900 m_target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
3901 m_target
->SetVisibility(VISIBILITY_GROUP_STEALTH
);
3904 // apply full stealth period bonuses only at first stealth aura in stack
3905 if(m_target
->GetAurasByType(SPELL_AURA_MOD_STEALTH
).size()<=1)
3907 Unit::AuraList
const& mDummyAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
3908 for(Unit::AuraList::const_iterator i
= mDummyAuras
.begin();i
!= mDummyAuras
.end(); ++i
)
3910 // Master of Subtlety
3911 if ((*i
)->GetSpellProto()->SpellIconID
== 2114)
3913 m_target
->RemoveAurasDueToSpell(31666);
3914 int32 bp
= (*i
)->GetModifier()->m_amount
;
3915 m_target
->CastCustomSpell(m_target
,31665,&bp
,NULL
,NULL
,true);
3918 else if ((*i
)->GetId() == 58426 && GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000400000))
3920 m_target
->RemoveAurasDueToSpell(58428);
3921 m_target
->CastSpell(m_target
, 58427, true);
3929 // only at real aura remove of _last_ SPELL_AURA_MOD_STEALTH
3930 if (Real
&& !m_target
->HasAuraType(SPELL_AURA_MOD_STEALTH
))
3932 // if no GM invisibility
3933 if (m_target
->GetVisibility()!=VISIBILITY_OFF
)
3935 m_target
->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP
);
3937 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
3938 m_target
->RemoveFlag(PLAYER_FIELD_BYTES2
, 0x2000);
3940 // restore invisibility if any
3941 if (m_target
->HasAuraType(SPELL_AURA_MOD_INVISIBILITY
))
3943 m_target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
3944 m_target
->SetVisibility(VISIBILITY_GROUP_INVISIBILITY
);
3947 m_target
->SetVisibility(VISIBILITY_ON
);
3950 // apply delayed talent bonus remover at last stealth aura remove
3951 Unit::AuraList
const& mDummyAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
3952 for(Unit::AuraList::const_iterator i
= mDummyAuras
.begin();i
!= mDummyAuras
.end(); ++i
)
3954 // Master of Subtlety
3955 if ((*i
)->GetSpellProto()->SpellIconID
== 2114)
3956 m_target
->CastSpell(m_target
, 31666, true);
3958 else if ((*i
)->GetId() == 58426 && GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000400000))
3959 m_target
->CastSpell(m_target
, 58428, true);
3965 void Aura::HandleInvisibility(bool apply
, bool Real
)
3969 m_target
->m_invisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3971 m_target
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
);
3973 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
3975 // apply glow vision
3976 m_target
->SetFlag(PLAYER_FIELD_BYTES2
,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
);
3980 // apply only if not in GM invisibility and not stealth
3981 if(m_target
->GetVisibility() == VISIBILITY_ON
)
3983 // Aura not added yet but visibility code expect temporary add aura
3984 m_target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
3985 m_target
->SetVisibility(VISIBILITY_GROUP_INVISIBILITY
);
3990 // recalculate value at modifier remove (current aura already removed)
3991 m_target
->m_invisibilityMask
= 0;
3992 Unit::AuraList
const& auras
= m_target
->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY
);
3993 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
3994 m_target
->m_invisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3996 // only at real aura remove and if not have different invisibility auras.
3997 if(Real
&& m_target
->m_invisibilityMask
== 0)
3999 // remove glow vision
4000 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4001 m_target
->RemoveFlag(PLAYER_FIELD_BYTES2
,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
);
4003 // apply only if not in GM invisibility & not stealthed while invisible
4004 if(m_target
->GetVisibility() != VISIBILITY_OFF
)
4006 // if have stealth aura then already have stealth visibility
4007 if(!m_target
->HasAuraType(SPELL_AURA_MOD_STEALTH
))
4008 m_target
->SetVisibility(VISIBILITY_ON
);
4014 void Aura::HandleInvisibilityDetect(bool apply
, bool Real
)
4018 m_target
->m_detectInvisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
4022 // recalculate value at modifier remove (current aura already removed)
4023 m_target
->m_detectInvisibilityMask
= 0;
4024 Unit::AuraList
const& auras
= m_target
->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION
);
4025 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
4026 m_target
->m_detectInvisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
4028 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
4029 ((Player
*)m_target
)->UpdateVisibilityForPlayer();
4032 void Aura::HandleAuraModRoot(bool apply
, bool Real
)
4034 // only at real add/remove aura
4040 // Frost root aura -> freeze/unfreeze target
4041 if (GetSpellSchoolMask(m_spellProto
) & SPELL_SCHOOL_MASK_FROST
)
4042 m_target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
4044 m_target
->addUnitState(UNIT_STAT_ROOT
);
4045 m_target
->SetTargetGUID(0);
4046 // probably wrong (this add skinnable flag)
4047 // TODO: find correct flag
4048 //m_target->SetFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
4050 //Save last orientation
4051 if( m_target
->getVictim() )
4052 m_target
->SetOrientation(m_target
->GetAngle(m_target
->getVictim()));
4054 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4056 WorldPacket
data(SMSG_FORCE_MOVE_ROOT
, 10);
4057 data
.append(m_target
->GetPackGUID());
4059 m_target
->SendMessageToSet(&data
, true);
4061 //Clear unit movement flags
4062 ((Player
*)m_target
)->m_movementInfo
.SetMovementFlags(MOVEMENTFLAG_NONE
);
4065 m_target
->StopMoving();
4069 // Frost root aura -> freeze/unfreeze target
4070 if (GetSpellSchoolMask(m_spellProto
) & SPELL_SCHOOL_MASK_FROST
)
4072 bool found_another
= false;
4073 for(AuraType
const* itr
= &frozenAuraTypes
[0]; *itr
!= SPELL_AURA_NONE
; ++itr
)
4075 Unit::AuraList
const& auras
= m_target
->GetAurasByType(*itr
);
4076 for(Unit::AuraList::const_iterator i
= auras
.begin(); i
!= auras
.end(); ++i
)
4078 if( GetSpellSchoolMask((*i
)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST
)
4080 found_another
= true;
4089 m_target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
4092 // Real remove called after current aura remove from lists, check if other similar auras active
4093 if(m_target
->HasAuraType(SPELL_AURA_MOD_ROOT
))
4096 m_target
->clearUnitState(UNIT_STAT_ROOT
);
4097 // probably wrong (this add skinnable flag)
4098 // TODO: find correct flag
4099 //m_target->RemoveFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
4101 if(!m_target
->hasUnitState(UNIT_STAT_STUNNED
)) // prevent allow move if have also stun effect
4103 if(m_target
->getVictim() && m_target
->isAlive())
4104 m_target
->SetTargetGUID(m_target
->getVictim()->GetGUID());
4106 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4108 WorldPacket
data(SMSG_FORCE_MOVE_UNROOT
, 10);
4109 data
.append(m_target
->GetPackGUID());
4111 m_target
->SendMessageToSet(&data
, true);
4117 void Aura::HandleAuraModSilence(bool apply
, bool Real
)
4119 // only at real add/remove aura
4125 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_SILENCED
);
4126 // Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE
4127 for (uint32 i
= CURRENT_MELEE_SPELL
; i
< CURRENT_MAX_SPELL
; ++i
)
4128 if (Spell
* spell
= m_target
->GetCurrentSpell(CurrentSpellTypes(i
)))
4129 if(spell
->m_spellInfo
->PreventionType
== SPELL_PREVENTION_TYPE_SILENCE
)
4130 // Stop spells on prepare or casting state
4131 m_target
->InterruptSpell(CurrentSpellTypes(i
), false);
4135 // Real remove called after current aura remove from lists, check if other similar auras active
4136 if(m_target
->HasAuraType(SPELL_AURA_MOD_SILENCE
))
4139 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_SILENCED
);
4143 void Aura::HandleModThreat(bool apply
, bool Real
)
4145 // only at real add/remove aura
4149 if (!m_target
->isAlive())
4152 Unit
* caster
= GetCaster();
4154 if (!caster
|| !caster
->isAlive())
4163 level_diff
= m_target
->getLevel() - 60;
4166 // The Eye of Diminution
4168 level_diff
= m_target
->getLevel() - 60;
4174 m_modifier
.m_amount
+= multiplier
* level_diff
;
4176 if (m_target
->GetTypeId() == TYPEID_PLAYER
)
4177 for(int8 x
=0;x
< MAX_SPELL_SCHOOL
;x
++)
4178 if (m_modifier
.m_miscvalue
& int32(1<<x
))
4179 ApplyPercentModFloatVar(m_target
->m_threatModifier
[x
], m_modifier
.m_amount
, apply
);
4182 void Aura::HandleAuraModTotalThreat(bool apply
, bool Real
)
4184 // only at real add/remove aura
4188 if (!m_target
->isAlive() || m_target
->GetTypeId() != TYPEID_PLAYER
)
4191 Unit
* caster
= GetCaster();
4193 if (!caster
|| !caster
->isAlive())
4196 float threatMod
= apply
? float(m_modifier
.m_amount
) : float(-m_modifier
.m_amount
);
4198 m_target
->getHostileRefManager().threatAssist(caster
, threatMod
, GetSpellProto());
4201 void Aura::HandleModTaunt(bool apply
, bool Real
)
4203 // only at real add/remove aura
4207 if (!m_target
->isAlive() || !m_target
->CanHaveThreatList())
4210 Unit
* caster
= GetCaster();
4212 if (!caster
|| !caster
->isAlive())
4216 m_target
->TauntApply(caster
);
4219 // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat
4220 m_target
->TauntFadeOut(caster
);
4224 /*********************************************************/
4225 /*** MODIFY SPEED ***/
4226 /*********************************************************/
4227 void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real
)
4229 // all applied/removed only at real aura add/remove
4233 m_target
->UpdateSpeed(MOVE_RUN
, true);
4236 void Aura::HandleAuraModIncreaseMountedSpeed(bool apply
, bool Real
)
4238 // all applied/removed only at real aura add/remove
4242 m_target
->UpdateSpeed(MOVE_RUN
, true);
4244 // Festive Holiday Mount
4245 if (apply
&& GetSpellProto()->SpellIconID
!= 1794 && m_target
->HasAura(62061))
4246 // Reindeer Transformation
4247 m_target
->CastSpell(m_target
, 25860, true, NULL
, this);
4250 void Aura::HandleAuraModIncreaseFlightSpeed(bool apply
, bool Real
)
4252 // all applied/removed only at real aura add/remove
4256 // Enable Fly mode for flying mounts
4257 if (m_modifier
.m_auraname
== SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
)
4261 data
.Initialize(SMSG_MOVE_SET_CAN_FLY
, 12);
4263 data
.Initialize(SMSG_MOVE_UNSET_CAN_FLY
, 12);
4264 data
.append(m_target
->GetPackGUID());
4265 data
<< uint32(0); // unknown
4266 m_target
->SendMessageToSet(&data
, true);
4268 //Players on flying mounts must be immune to polymorph
4269 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
4270 m_target
->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC
,MECHANIC_POLYMORPH
,apply
);
4272 // Dragonmaw Illusion (overwrite mount model, mounted aura already applied)
4273 if( apply
&& m_target
->HasAura(42016,0) && m_target
->GetMountID())
4274 m_target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
,16314);
4276 // Festive Holiday Mount
4277 if (apply
&& GetSpellProto()->SpellIconID
!= 1794 && m_target
->HasAura(62061))
4278 // Reindeer Transformation
4279 m_target
->CastSpell(m_target
, 25860, true, NULL
, this);
4282 m_target
->UpdateSpeed(MOVE_FLIGHT
, true);
4285 void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real
)
4287 // all applied/removed only at real aura add/remove
4291 m_target
->UpdateSpeed(MOVE_SWIM
, true);
4294 void Aura::HandleAuraModDecreaseSpeed(bool apply
, bool Real
)
4296 // all applied/removed only at real aura add/remove
4302 // Gronn Lord's Grasp, becomes stoned
4303 if (GetId() == 33572)
4305 if (GetStackAmount() >= 5 && !m_target
->HasAura(33652))
4306 m_target
->CastSpell(m_target
, 33652, true);
4310 m_target
->UpdateSpeed(MOVE_RUN
, true);
4311 m_target
->UpdateSpeed(MOVE_SWIM
, true);
4312 m_target
->UpdateSpeed(MOVE_FLIGHT
, true);
4315 void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real
)
4317 // all applied/removed only at real aura add/remove
4321 m_target
->UpdateSpeed(MOVE_RUN
, true);
4322 m_target
->UpdateSpeed(MOVE_SWIM
, true);
4323 m_target
->UpdateSpeed(MOVE_FLIGHT
, true);
4326 /*********************************************************/
4328 /*********************************************************/
4330 void Aura::HandleModMechanicImmunity(bool apply
, bool /*Real*/)
4332 uint32 misc
= m_modifier
.m_miscvalue
;
4334 // in DBC wrong mechanic immune since 3.0.x
4335 if (GetId() == 25771)
4336 misc
= MECHANIC_IMMUNE_SHIELD
;
4339 if(apply
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
4341 uint32 mechanic
= 1 << (misc
-1);
4343 //immune movement impairment and loss of control
4344 if(GetId()==42292 || GetId()==59752)
4345 mechanic
=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK
;
4347 m_target
->RemoveAurasAtMechanicImmunity(mechanic
,GetId());
4350 m_target
->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC
,misc
,apply
);
4353 if (GetSpellProto()->SpellFamilyName
== SPELLFAMILY_HUNTER
&& GetSpellProto()->SpellIconID
== 1680)
4355 // The Beast Within cast on owner if talent present
4356 if (Unit
* owner
= m_target
->GetOwner())
4359 Unit::AuraList
const& dummyAuras
= owner
->GetAurasByType(SPELL_AURA_DUMMY
);
4360 for(Unit::AuraList::const_iterator i
= dummyAuras
.begin(); i
!= dummyAuras
.end(); ++i
)
4362 if ((*i
)->GetSpellProto()->SpellIconID
== 2229)
4365 owner
->CastSpell(owner
, 34471, true, 0, this);
4367 owner
->RemoveAurasDueToSpell(34471);
4375 void Aura::HandleModMechanicImmunityMask(bool apply
, bool /*Real*/)
4377 uint32 mechanic
= m_modifier
.m_miscvalue
;
4379 if(apply
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
4380 m_target
->RemoveAurasAtMechanicImmunity(mechanic
,GetId());
4382 // check implemented in Unit::IsImmunedToSpell and Unit::IsImmunedToSpellEffect
4385 //this method is called whenever we add / remove aura which gives m_target some imunity to some spell effect
4386 void Aura::HandleAuraModEffectImmunity(bool apply
, bool /*Real*/)
4388 // when removing flag aura, handle flag drop
4389 if( !apply
&& m_target
->GetTypeId() == TYPEID_PLAYER
4390 && (GetSpellProto()->AuraInterruptFlags
& AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
) )
4392 if( BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround() )
4393 bg
->EventPlayerDroppedFlag(((Player
*)m_target
));
4396 m_target
->ApplySpellImmune(GetId(), IMMUNITY_EFFECT
, m_modifier
.m_miscvalue
, apply
);
4399 void Aura::HandleAuraModStateImmunity(bool apply
, bool Real
)
4401 if(apply
&& Real
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
4403 Unit::AuraList
const& auraList
= m_target
->GetAurasByType(AuraType(m_modifier
.m_miscvalue
));
4404 for(Unit::AuraList::const_iterator itr
= auraList
.begin(); itr
!= auraList
.end();)
4406 if (auraList
.front() != this) // skip itself aura (it already added)
4408 m_target
->RemoveAurasDueToSpell(auraList
.front()->GetId());
4409 itr
= auraList
.begin();
4416 m_target
->ApplySpellImmune(GetId(), IMMUNITY_STATE
, m_modifier
.m_miscvalue
, apply
);
4419 void Aura::HandleAuraModSchoolImmunity(bool apply
, bool Real
)
4421 m_target
->ApplySpellImmune(GetId(), IMMUNITY_SCHOOL
, m_modifier
.m_miscvalue
, apply
);
4423 // remove all flag auras (they are positive, but they must be removed when you are immune)
4424 if( this->GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
4425 && this->GetSpellProto()->AttributesEx2
& SPELL_ATTR_EX2_DAMAGE_REDUCED_SHIELD
)
4426 m_target
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
);
4428 // TODO: optimalize this cycle - use RemoveAurasWithInterruptFlags call or something else
4430 && GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
4431 && IsPositiveSpell(GetId()) ) //Only positive immunity removes auras
4433 uint32 school_mask
= m_modifier
.m_miscvalue
;
4434 Unit::AuraMap
& Auras
= m_target
->GetAuras();
4435 for(Unit::AuraMap::iterator iter
= Auras
.begin(), next
; iter
!= Auras
.end(); iter
= next
)
4439 SpellEntry
const *spell
= iter
->second
->GetSpellProto();
4440 if((GetSpellSchoolMask(spell
) & school_mask
)//Check for school mask
4441 && !( spell
->Attributes
& SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY
) //Spells unaffected by invulnerability
4442 && !iter
->second
->IsPositive() //Don't remove positive spells
4443 && spell
->Id
!= GetId() ) //Don't remove self
4445 m_target
->RemoveAurasDueToSpell(spell
->Id
);
4449 next
= Auras
.begin();
4453 if( Real
&& GetSpellProto()->Mechanic
== MECHANIC_BANISH
)
4456 m_target
->addUnitState(UNIT_STAT_ISOLATED
);
4458 m_target
->clearUnitState(UNIT_STAT_ISOLATED
);
4462 void Aura::HandleAuraModDmgImmunity(bool apply
, bool /*Real*/)
4464 m_target
->ApplySpellImmune(GetId(), IMMUNITY_DAMAGE
, m_modifier
.m_miscvalue
, apply
);
4467 void Aura::HandleAuraModDispelImmunity(bool apply
, bool Real
)
4469 // all applied/removed only at real aura add/remove
4473 m_target
->ApplySpellDispelImmunity(m_spellProto
, DispelType(m_modifier
.m_miscvalue
), apply
);
4476 void Aura::HandleAuraProcTriggerSpell(bool apply
, bool Real
)
4483 // some spell have charges by functionality not have its in spell data
4486 case 28200: // Ascendance (Talisman of Ascendance trinket)
4494 void Aura::HandleAuraModStalked(bool apply
, bool /*Real*/)
4496 // used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND
4498 m_target
->SetFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_TRACK_UNIT
);
4500 m_target
->RemoveFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_TRACK_UNIT
);
4503 /*********************************************************/
4505 /*********************************************************/
4507 void Aura::HandlePeriodicTriggerSpell(bool apply
, bool /*Real*/)
4509 m_isPeriodic
= apply
;
4513 switch(m_spellProto
->Id
)
4515 case 66: // Invisibility
4516 if (m_removeMode
== AURA_REMOVE_BY_DEFAULT
&& m_duration
<=0)
4517 m_target
->CastSpell(m_target
, 32612, true, NULL
, this);
4520 case 42783: //Wrath of the Astrom...
4521 if (m_removeMode
== AURA_REMOVE_BY_DEFAULT
&& GetEffIndex() + 1 < 3)
4522 m_target
->CastSpell(m_target
, m_spellProto
->CalculateSimpleValue(GetEffIndex()+1), true);
4530 void Aura::HandlePeriodicTriggerSpellWithValue(bool apply
, bool /*Real*/)
4532 m_isPeriodic
= apply
;
4535 void Aura::HandlePeriodicEnergize(bool apply
, bool Real
)
4540 // For prevent double apply bonuses
4541 bool loading
= (m_target
->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)m_target
)->GetSession()->PlayerLoading());
4543 if (apply
&& !loading
)
4547 case 54833: // Glyph of Innervate (value%/2 of casters base mana)
4549 if (Unit
* caster
= GetCaster())
4550 m_modifier
.m_amount
= int32(caster
->GetCreateMana() * GetBasePoints() / (200 * GetAuraMaxTicks()));
4554 case 29166: // Innervate (value% of casters base mana)
4556 if (Unit
* caster
= GetCaster())
4558 // Glyph of Innervate
4559 if (caster
->HasAura(54832))
4560 caster
->CastSpell(caster
,54833,true,NULL
,this);
4562 m_modifier
.m_amount
= int32(caster
->GetCreateMana() * GetBasePoints() / (100 * GetAuraMaxTicks()));
4566 case 48391: // Owlkin Frenzy 2% base mana
4567 m_modifier
.m_amount
= m_target
->GetCreateMana() * 2 / 100;
4569 case 57669: // Replenishment (0.2% from max)
4570 case 61782: // Infinite Replenishment
4571 m_modifier
.m_amount
= m_target
->GetMaxPower(POWER_MANA
) * 2 / 1000;
4578 m_isPeriodic
= apply
;
4581 void Aura::HandleAuraPowerBurn(bool apply
, bool /*Real*/)
4583 m_isPeriodic
= apply
;
4586 void Aura::HandleAuraPeriodicDummy(bool apply
, bool Real
)
4588 // spells required only Real aura add/remove
4592 // For prevent double apply bonuses
4593 bool loading
= (m_target
->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)m_target
)->GetSession()->PlayerLoading());
4595 SpellEntry
const*spell
= GetSpellProto();
4596 switch( spell
->SpellFamilyName
)
4598 case SPELLFAMILY_ROGUE
:
4604 // Master of Subtlety
4605 case 31666: m_target
->RemoveAurasDueToSpell(31665); break;
4607 case 58428: m_target
->RemoveAurasDueToSpell(58427); break;
4612 case SPELLFAMILY_HUNTER
:
4614 Unit
* caster
= GetCaster();
4617 if (apply
&& !loading
&& caster
)
4618 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 14 / 100);
4623 m_isPeriodic
= apply
;
4626 void Aura::HandlePeriodicHeal(bool apply
, bool /*Real*/)
4628 m_isPeriodic
= apply
;
4631 void Aura::HandlePeriodicDamage(bool apply
, bool Real
)
4633 // spells required only Real aura add/remove
4637 m_isPeriodic
= apply
;
4639 // For prevent double apply bonuses
4640 bool loading
= (m_target
->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)m_target
)->GetSession()->PlayerLoading());
4642 // Custom damage calculation after
4648 Unit
*caster
= GetCaster();
4652 switch (m_spellProto
->SpellFamilyName
)
4654 case SPELLFAMILY_GENERIC
:
4657 if ( m_spellProto
->SpellIconID
== 147 && m_spellProto
->SpellVisual
[0] == 0 )
4659 // $AP*0.18/6 bonus per tick
4660 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 3 / 100);
4665 case SPELLFAMILY_WARRIOR
:
4668 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000020))
4670 // $0.2*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick
4671 float ap
= caster
->GetTotalAttackPowerValue(BASE_ATTACK
);
4672 int32 mws
= caster
->GetAttackTime(BASE_ATTACK
);
4673 float mwb_min
= caster
->GetWeaponDamageRange(BASE_ATTACK
,MINDAMAGE
);
4674 float mwb_max
= caster
->GetWeaponDamageRange(BASE_ATTACK
,MAXDAMAGE
);
4675 m_modifier
.m_amount
+=int32(((mwb_min
+mwb_max
)/2+ap
*mws
/14000)*0.2f
);
4680 case SPELLFAMILY_DRUID
:
4683 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000001000) && m_spellProto
->Effect
[2]==SPELL_EFFECT_ADD_COMBO_POINTS
)
4685 // $AP*0.18/3 bonus per tick
4686 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 6 / 100);
4690 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x000000010000000000))
4692 // $AP*0.05/5 bonus per tick
4693 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) / 100);
4697 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x000000000000800000))
4700 if (caster
->GetTypeId() != TYPEID_PLAYER
)
4703 uint8 cp
= ((Player
*)caster
)->GetComboPoints();
4705 // Idol of Feral Shadows. Cant be handled as SpellMod in SpellAura:Dummy due its dependency from CPs
4706 Unit::AuraList
const& dummyAuras
= caster
->GetAurasByType(SPELL_AURA_DUMMY
);
4707 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
4709 if((*itr
)->GetId()==34241)
4711 m_modifier
.m_amount
+= cp
* (*itr
)->GetModifier()->m_amount
;
4715 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * cp
/ 100);
4719 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x1000000000000000))
4722 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 15 / 100);
4727 case SPELLFAMILY_ROGUE
:
4730 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x000000000000100000))
4732 if (caster
->GetTypeId() != TYPEID_PLAYER
)
4734 //1 point : ${($m1+$b1*1+0.015*$AP)*4} damage over 8 secs
4735 //2 points: ${($m1+$b1*2+0.024*$AP)*5} damage over 10 secs
4736 //3 points: ${($m1+$b1*3+0.03*$AP)*6} damage over 12 secs
4737 //4 points: ${($m1+$b1*4+0.03428571*$AP)*7} damage over 14 secs
4738 //5 points: ${($m1+$b1*5+0.0375*$AP)*8} damage over 16 secs
4739 float AP_per_combo
[6] = {0.0f
, 0.015f
, 0.024f
, 0.03f
, 0.03428571f
, 0.0375f
};
4740 uint8 cp
= ((Player
*)caster
)->GetComboPoints();
4742 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * AP_per_combo
[cp
]);
4746 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x000000000000000100))
4748 // $AP*0.07 bonus per tick
4749 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 7 / 100);
4753 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000010000))
4755 // 0.08*$AP / 4 * amount of stack
4756 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 2 * GetStackAmount() / 100);
4761 case SPELLFAMILY_HUNTER
:
4764 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000004000))
4766 // $RAP*0.2/5 bonus per tick
4767 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 0.2 / 5);
4771 if ((m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000004)) && m_spellProto
->SpellIconID
== 678)
4773 // $RAP*0.1/5 bonus per tick
4774 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 10 / 500);
4783 // remove time effects
4786 // Parasitic Shadowfiend - handle summoning of two Shadowfiends on DoT expire
4787 if(m_spellProto
->Id
== 41917)
4788 m_target
->CastSpell(m_target
, 41915, true);
4792 void Aura::HandlePeriodicDamagePCT(bool apply
, bool /*Real*/)
4794 m_isPeriodic
= apply
;
4797 void Aura::HandlePeriodicLeech(bool apply
, bool /*Real*/)
4799 m_isPeriodic
= apply
;
4802 void Aura::HandlePeriodicManaLeech(bool apply
, bool /*Real*/)
4804 m_isPeriodic
= apply
;
4807 void Aura::HandlePeriodicHealthFunnel(bool apply
, bool /*Real*/)
4809 m_isPeriodic
= apply
;
4812 /*********************************************************/
4813 /*** MODIFY STATS ***/
4814 /*********************************************************/
4816 /********************************/
4817 /*** RESISTANCE ***/
4818 /********************************/
4820 void Aura::HandleAuraModResistanceExclusive(bool apply
, bool /*Real*/)
4822 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
4824 if(m_modifier
.m_miscvalue
& int32(1<<x
))
4826 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), BASE_VALUE
, float(m_modifier
.m_amount
), apply
);
4827 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4828 m_target
->ApplyResistanceBuffModsMod(SpellSchools(x
), m_positive
, m_modifier
.m_amount
, apply
);
4833 void Aura::HandleAuraModResistance(bool apply
, bool /*Real*/)
4835 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
4837 if(m_modifier
.m_miscvalue
& int32(1<<x
))
4839 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4840 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4841 m_target
->ApplyResistanceBuffModsMod(SpellSchools(x
), m_positive
, m_modifier
.m_amount
, apply
);
4846 void Aura::HandleAuraModBaseResistancePCT(bool apply
, bool /*Real*/)
4848 // only players have base stats
4849 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4851 //pets only have base armor
4852 if(((Creature
*)m_target
)->isPet() && (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
4853 m_target
->HandleStatModifier(UNIT_MOD_ARMOR
, BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4857 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
4859 if(m_modifier
.m_miscvalue
& int32(1<<x
))
4860 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4865 void Aura::HandleModResistancePercent(bool apply
, bool /*Real*/)
4867 for(int8 i
= SPELL_SCHOOL_NORMAL
; i
< MAX_SPELL_SCHOOL
; i
++)
4869 if(m_modifier
.m_miscvalue
& int32(1<<i
))
4871 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ i
), TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4872 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4874 m_target
->ApplyResistanceBuffModsPercentMod(SpellSchools(i
), true, m_modifier
.m_amount
, apply
);
4875 m_target
->ApplyResistanceBuffModsPercentMod(SpellSchools(i
), false, m_modifier
.m_amount
, apply
);
4881 void Aura::HandleModBaseResistance(bool apply
, bool /*Real*/)
4883 // only players have base stats
4884 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4886 //only pets have base stats
4887 if(((Creature
*)m_target
)->isPet() && (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
4888 m_target
->HandleStatModifier(UNIT_MOD_ARMOR
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4892 for(int i
= SPELL_SCHOOL_NORMAL
; i
< MAX_SPELL_SCHOOL
; i
++)
4893 if(m_modifier
.m_miscvalue
& (1<<i
))
4894 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ i
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4898 /********************************/
4900 /********************************/
4902 void Aura::HandleAuraModStat(bool apply
, bool /*Real*/)
4904 if (m_modifier
.m_miscvalue
< -2 || m_modifier
.m_miscvalue
> 4)
4906 sLog
.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ",GetId(),GetEffIndex(),m_modifier
.m_miscvalue
);
4910 for(int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; i
++)
4912 // -1 or -2 is all stats ( misc < -2 checked in function beginning )
4913 if (m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
== i
)
4915 //m_target->ApplyStatMod(Stats(i), m_modifier.m_amount,apply);
4916 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4917 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4918 m_target
->ApplyStatBuffMod(Stats(i
), m_modifier
.m_amount
, apply
);
4923 void Aura::HandleModPercentStat(bool apply
, bool /*Real*/)
4925 if (m_modifier
.m_miscvalue
< -1 || m_modifier
.m_miscvalue
> 4)
4927 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
4931 // only players have base stats
4932 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
4935 for (int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; ++i
)
4937 if(m_modifier
.m_miscvalue
== i
|| m_modifier
.m_miscvalue
== -1)
4938 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4942 void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool /*Real*/)
4944 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4947 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4948 // This information for client side use only
4949 // Recalculate bonus
4950 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4953 void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool /*Real*/)
4955 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4958 // Recalculate bonus
4959 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4962 void Aura::HandleAuraModDispelResist(bool apply
, bool Real
)
4967 if(GetId() == 33206)
4968 m_target
->CastSpell(m_target
, 44416, true, NULL
, this, GetCasterGUID());
4971 void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool /*Real*/)
4973 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4976 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4977 // This information for client side use only
4978 // Recalculate bonus
4979 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4982 void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool /*Real*/)
4984 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4987 // Recalculate bonus
4988 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4991 void Aura::HandleModHealingDone(bool /*apply*/, bool /*Real*/)
4993 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4995 // implemented in Unit::SpellHealingBonus
4996 // this information is for client side only
4997 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
5000 void Aura::HandleModTotalPercentStat(bool apply
, bool /*Real*/)
5002 if (m_modifier
.m_miscvalue
< -1 || m_modifier
.m_miscvalue
> 4)
5004 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
5008 //save current and max HP before applying aura
5009 uint32 curHPValue
= m_target
->GetHealth();
5010 uint32 maxHPValue
= m_target
->GetMaxHealth();
5012 for (int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; i
++)
5014 if(m_modifier
.m_miscvalue
== i
|| m_modifier
.m_miscvalue
== -1)
5016 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5017 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
5018 m_target
->ApplyStatPercentBuffMod(Stats(i
), m_modifier
.m_amount
, apply
);
5022 //recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag)
5023 if ((m_modifier
.m_miscvalue
== STAT_STAMINA
) && (maxHPValue
> 0) && (m_spellProto
->Attributes
& 0x10))
5025 // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed
5026 uint32 newHPValue
= (m_target
->GetMaxHealth() * curHPValue
) / maxHPValue
;
5027 m_target
->SetHealth(newHPValue
);
5031 void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool /*Real*/)
5033 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5036 if(m_modifier
.m_miscvalue
!= SPELL_SCHOOL_MASK_NORMAL
)
5038 // support required adding replace UpdateArmor by loop by UpdateResistence at intellect update
5039 // and include in UpdateResistence same code as in UpdateArmor for aura mod apply.
5040 sLog
.outError("Aura SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT(182) need adding support for non-armor resistances!");
5044 // Recalculate Armor
5045 m_target
->UpdateArmor();
5048 /********************************/
5049 /*** HEAL & ENERGIZE ***/
5050 /********************************/
5051 void Aura::HandleAuraModTotalHealthPercentRegen(bool apply
, bool /*Real*/)
5053 m_isPeriodic
= apply
;
5056 void Aura::HandleAuraModTotalManaPercentRegen(bool apply
, bool /*Real*/)
5058 if(m_modifier
.periodictime
== 0)
5059 m_modifier
.periodictime
= 1000;
5061 m_periodicTimer
= m_modifier
.periodictime
;
5062 m_isPeriodic
= apply
;
5065 void Aura::HandleModRegen(bool apply
, bool /*Real*/) // eating
5067 if(m_modifier
.periodictime
== 0)
5068 m_modifier
.periodictime
= 5000;
5070 m_periodicTimer
= 5000;
5071 m_isPeriodic
= apply
;
5074 void Aura::HandleModPowerRegen(bool apply
, bool Real
) // drinking
5079 Powers pt
= m_target
->getPowerType();
5080 if(m_modifier
.periodictime
== 0)
5082 // Anger Management (only spell use this aura for rage)
5083 if (pt
== POWER_RAGE
)
5084 m_modifier
.periodictime
= 3000;
5086 m_modifier
.periodictime
= 2000;
5089 m_periodicTimer
= 5000;
5091 if (m_target
->GetTypeId() == TYPEID_PLAYER
&& m_modifier
.m_miscvalue
== POWER_MANA
)
5092 ((Player
*)m_target
)->UpdateManaRegen();
5094 m_isPeriodic
= apply
;
5097 void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real
)
5099 // spells required only Real aura add/remove
5103 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
5106 // Update manaregen value
5107 if (m_modifier
.m_miscvalue
== POWER_MANA
)
5108 ((Player
*)m_target
)->UpdateManaRegen();
5111 void Aura::HandleModManaRegen(bool /*apply*/, bool Real
)
5113 // spells required only Real aura add/remove
5117 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
5120 //Note: an increase in regen does NOT cause threat.
5121 ((Player
*)m_target
)->UpdateManaRegen();
5124 void Aura::HandleComprehendLanguage(bool apply
, bool /*Real*/)
5127 m_target
->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_COMPREHEND_LANG
);
5129 m_target
->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_COMPREHEND_LANG
);
5132 void Aura::HandleAuraModIncreaseHealth(bool apply
, bool Real
)
5134 // Special case with temporary increase max/current health
5137 case 12976: // Warrior Last Stand triggered spell
5138 case 28726: // Nightmare Seed ( Nightmare Seed )
5139 case 34511: // Valor (Bulwark of Kings, Bulwark of the Ancient Kings)
5140 case 44055: case 55915: case 55917: case 67596: // Tremendous Fortitude (Battlemaster's Alacrity)
5141 case 50322: // Survival Instincts
5142 case 54443: // Demonic Empowerment (Voidwalker)
5148 // Demonic Empowerment (Voidwalker) - special case, store percent in data
5149 // recalculate to full amount at apply for proper remove
5150 if (GetId() == 54443)
5151 m_modifier
.m_amount
= m_target
->GetMaxHealth() * m_modifier
.m_amount
/ 100;
5153 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5154 m_target
->ModifyHealth(m_modifier
.m_amount
);
5158 if (int32(m_target
->GetHealth()) > m_modifier
.m_amount
)
5159 m_target
->ModifyHealth(-m_modifier
.m_amount
);
5161 m_target
->SetHealth(1);
5162 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5170 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5173 void Aura::HandleAuraModIncreaseMaxHealth(bool apply
, bool /*Real*/)
5175 uint32 oldhealth
= m_target
->GetHealth();
5176 double healthPercentage
= (double)oldhealth
/ (double)m_target
->GetMaxHealth();
5178 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5180 // refresh percentage
5183 uint32 newhealth
= uint32(ceil((double)m_target
->GetMaxHealth() * healthPercentage
));
5187 m_target
->SetHealth(newhealth
);
5191 void Aura::HandleAuraModIncreaseEnergy(bool apply
, bool Real
)
5193 Powers powerType
= m_target
->getPowerType();
5194 if(int32(powerType
) != m_modifier
.m_miscvalue
)
5197 UnitMods unitMod
= UnitMods(UNIT_MOD_POWER_START
+ powerType
);
5199 // Special case with temporary increase max/current power (percent)
5200 if (GetId()==64904) // Hymn of Hope
5204 uint32 val
= m_target
->GetPower(powerType
);
5205 m_target
->HandleStatModifier(unitMod
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5206 m_target
->SetPower(powerType
, apply
? val
*(100+m_modifier
.m_amount
)/100 : val
*100/(100+m_modifier
.m_amount
));
5211 // generic flat case
5212 m_target
->HandleStatModifier(unitMod
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5215 void Aura::HandleAuraModIncreaseEnergyPercent(bool apply
, bool /*Real*/)
5217 Powers powerType
= m_target
->getPowerType();
5218 if(int32(powerType
) != m_modifier
.m_miscvalue
)
5221 UnitMods unitMod
= UnitMods(UNIT_MOD_POWER_START
+ powerType
);
5223 m_target
->HandleStatModifier(unitMod
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5226 void Aura::HandleAuraModIncreaseHealthPercent(bool apply
, bool /*Real*/)
5228 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5231 void Aura::HandleAuraIncreaseBaseHealthPercent(bool apply
, bool /*Real*/)
5233 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, BASE_PCT
, float(m_modifier
.m_amount
), apply
);
5236 /********************************/
5238 /********************************/
5240 void Aura::HandleAuraModParryPercent(bool /*apply*/, bool /*Real*/)
5242 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5245 ((Player
*)m_target
)->UpdateParryPercentage();
5248 void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool /*Real*/)
5250 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5253 ((Player
*)m_target
)->UpdateDodgePercentage();
5254 //sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount));
5257 void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool /*Real*/)
5259 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5262 ((Player
*)m_target
)->UpdateBlockPercentage();
5263 //sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount));
5266 void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real
)
5268 // spells required only Real aura add/remove
5272 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5275 ((Player
*)m_target
)->UpdateManaRegen();
5278 void Aura::HandleAuraModCritPercent(bool apply
, bool Real
)
5280 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5283 // apply item specific bonuses for already equipped weapon
5286 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
5287 if(Item
* pItem
= ((Player
*)m_target
)->GetWeaponForAttack(WeaponAttackType(i
),true,false))
5288 ((Player
*)m_target
)->_ApplyWeaponDependentAuraCritMod(pItem
, WeaponAttackType(i
), this, apply
);
5291 // mods must be applied base at equipped weapon class and subclass comparison
5292 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5293 // m_modifier.m_miscvalue comparison with item generated damage types
5295 if (GetSpellProto()->EquippedItemClass
== -1)
5297 ((Player
*)m_target
)->HandleBaseModValue(CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
5298 ((Player
*)m_target
)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
5299 ((Player
*)m_target
)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
5303 // done in Player::_ApplyWeaponDependentAuraMods
5307 void Aura::HandleModHitChance(bool apply
, bool /*Real*/)
5309 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5311 ((Player
*)m_target
)->UpdateMeleeHitChances();
5312 ((Player
*)m_target
)->UpdateRangedHitChances();
5316 m_target
->m_modMeleeHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
5317 m_target
->m_modRangedHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
5321 void Aura::HandleModSpellHitChance(bool apply
, bool /*Real*/)
5323 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5325 ((Player
*)m_target
)->UpdateSpellHitChances();
5329 m_target
->m_modSpellHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
5333 void Aura::HandleModSpellCritChance(bool apply
, bool Real
)
5335 // spells required only Real aura add/remove
5339 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5341 ((Player
*)m_target
)->UpdateAllSpellCritChances();
5345 m_target
->m_baseSpellCritChance
+= apply
? m_modifier
.m_amount
:(-m_modifier
.m_amount
);
5349 void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real
)
5351 // spells required only Real aura add/remove
5355 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5358 for(int school
= SPELL_SCHOOL_NORMAL
; school
< MAX_SPELL_SCHOOL
; ++school
)
5359 if (m_modifier
.m_miscvalue
& (1<<school
))
5360 ((Player
*)m_target
)->UpdateSpellCritChance(school
);
5363 /********************************/
5364 /*** ATTACK SPEED ***/
5365 /********************************/
5367 void Aura::HandleModCastingSpeed(bool apply
, bool /*Real*/)
5369 m_target
->ApplyCastTimePercentMod(m_modifier
.m_amount
,apply
);
5372 void Aura::HandleModMeleeRangedSpeedPct(bool apply
, bool /*Real*/)
5374 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
, m_modifier
.m_amount
, apply
);
5375 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
, m_modifier
.m_amount
, apply
);
5376 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
5379 void Aura::HandleModCombatSpeedPct(bool apply
, bool /*Real*/)
5381 m_target
->ApplyCastTimePercentMod(m_modifier
.m_amount
, apply
);
5382 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
, m_modifier
.m_amount
, apply
);
5383 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
, m_modifier
.m_amount
, apply
);
5384 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
5387 void Aura::HandleModAttackSpeed(bool apply
, bool /*Real*/)
5389 if(!m_target
->isAlive() )
5392 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
,m_modifier
.m_amount
,apply
);
5395 void Aura::HandleHaste(bool apply
, bool /*Real*/)
5397 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
, m_modifier
.m_amount
, apply
);
5398 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
, m_modifier
.m_amount
, apply
);
5399 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
5402 void Aura::HandleAuraModRangedHaste(bool apply
, bool /*Real*/)
5404 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
5407 void Aura::HandleRangedAmmoHaste(bool apply
, bool /*Real*/)
5409 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5411 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
,m_modifier
.m_amount
, apply
);
5414 /********************************/
5415 /*** ATTACK POWER ***/
5416 /********************************/
5418 void Aura::HandleAuraModAttackPower(bool apply
, bool /*Real*/)
5420 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5423 void Aura::HandleAuraModRangedAttackPower(bool apply
, bool /*Real*/)
5425 if((m_target
->getClassMask() & CLASSMASK_WAND_USERS
)!=0)
5428 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5431 void Aura::HandleAuraModAttackPowerPercent(bool apply
, bool /*Real*/)
5433 //UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1
5434 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5437 void Aura::HandleAuraModRangedAttackPowerPercent(bool apply
, bool /*Real*/)
5439 if((m_target
->getClassMask() & CLASSMASK_WAND_USERS
)!=0)
5442 //UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1
5443 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5446 void Aura::HandleAuraModRangedAttackPowerOfStatPercent(bool /*apply*/, bool Real
)
5448 // spells required only Real aura add/remove
5452 // Recalculate bonus
5453 if(m_target
->GetTypeId() == TYPEID_PLAYER
&& !(m_target
->getClassMask() & CLASSMASK_WAND_USERS
))
5454 ((Player
*)m_target
)->UpdateAttackPowerAndDamage(true);
5457 void Aura::HandleAuraModAttackPowerOfStatPercent(bool /*apply*/, bool Real
)
5459 // spells required only Real aura add/remove
5463 // Recalculate bonus
5464 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5465 ((Player
*)m_target
)->UpdateAttackPowerAndDamage(false);
5468 void Aura::HandleAuraModAttackPowerOfArmor(bool /*apply*/, bool Real
)
5470 // spells required only Real aura add/remove
5474 // Recalculate bonus
5475 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5476 ((Player
*)m_target
)->UpdateAttackPowerAndDamage(false);
5478 /********************************/
5479 /*** DAMAGE BONUS ***/
5480 /********************************/
5481 void Aura::HandleModDamageDone(bool apply
, bool Real
)
5483 // apply item specific bonuses for already equipped weapon
5484 if(Real
&& m_target
->GetTypeId() == TYPEID_PLAYER
)
5486 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
5487 if(Item
* pItem
= ((Player
*)m_target
)->GetWeaponForAttack(WeaponAttackType(i
),true,false))
5488 ((Player
*)m_target
)->_ApplyWeaponDependentAuraDamageMod(pItem
, WeaponAttackType(i
), this, apply
);
5491 // m_modifier.m_miscvalue is bitmask of spell schools
5492 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5493 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wands
5494 // 127 - full bitmask any damages
5496 // mods must be applied base at equipped weapon class and subclass comparison
5497 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5498 // m_modifier.m_miscvalue comparison with item generated damage types
5500 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
) != 0)
5502 // apply generic physical damage bonuses including wand case
5503 if (GetSpellProto()->EquippedItemClass
== -1 || m_target
->GetTypeId() != TYPEID_PLAYER
)
5505 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5506 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5507 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5511 // done in Player::_ApplyWeaponDependentAuraMods
5514 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5517 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS
, m_modifier
.m_amount
, apply
);
5519 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG
, m_modifier
.m_amount
, apply
);
5523 // Skip non magic case for speedup
5524 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_MAGIC
) == 0)
5527 if( GetSpellProto()->EquippedItemClass
!= -1 || GetSpellProto()->EquippedItemInventoryTypeMask
!= 0 )
5529 // wand magic case (skip generic to all item spell bonuses)
5530 // done in Player::_ApplyWeaponDependentAuraMods
5532 // Skip item specific requirements for not wand magic damage
5536 // Magic damage modifiers implemented in Unit::SpellDamageBonus
5537 // This information for client side use only
5538 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5542 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; ++i
)
5544 if((m_modifier
.m_miscvalue
& (1<<i
)) != 0)
5545 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS
+ i
, m_modifier
.m_amount
, apply
);
5550 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; ++i
)
5552 if((m_modifier
.m_miscvalue
& (1<<i
)) != 0)
5553 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG
+ i
, m_modifier
.m_amount
, apply
);
5556 Pet
* pet
= m_target
->GetPet();
5558 pet
->UpdateAttackPowerAndDamage();
5562 void Aura::HandleModDamagePercentDone(bool apply
, bool Real
)
5564 sLog
.outDebug("AURA MOD DAMAGE type:%u negative:%u", m_modifier
.m_miscvalue
, m_positive
? 0 : 1);
5566 // apply item specific bonuses for already equipped weapon
5567 if(Real
&& m_target
->GetTypeId() == TYPEID_PLAYER
)
5569 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
5570 if(Item
* pItem
= ((Player
*)m_target
)->GetWeaponForAttack(WeaponAttackType(i
),true,false))
5571 ((Player
*)m_target
)->_ApplyWeaponDependentAuraDamageMod(pItem
, WeaponAttackType(i
), this, apply
);
5574 // m_modifier.m_miscvalue is bitmask of spell schools
5575 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5576 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wand
5577 // 127 - full bitmask any damages
5579 // mods must be applied base at equipped weapon class and subclass comparison
5580 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5581 // m_modifier.m_miscvalue comparison with item generated damage types
5583 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
) != 0)
5585 // apply generic physical damage bonuses including wand case
5586 if (GetSpellProto()->EquippedItemClass
== -1 || m_target
->GetTypeId() != TYPEID_PLAYER
)
5588 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5589 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5590 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5594 // done in Player::_ApplyWeaponDependentAuraMods
5596 // For show in client
5597 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5598 m_target
->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT
, m_modifier
.m_amount
/100.0f
, apply
);
5601 // Skip non magic case for speedup
5602 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_MAGIC
) == 0)
5605 if( GetSpellProto()->EquippedItemClass
!= -1 || GetSpellProto()->EquippedItemInventoryTypeMask
!= 0 )
5607 // wand magic case (skip generic to all item spell bonuses)
5608 // done in Player::_ApplyWeaponDependentAuraMods
5610 // Skip item specific requirements for not wand magic damage
5614 // Magic damage percent modifiers implemented in Unit::SpellDamageBonus
5615 // Send info to client
5616 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5617 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; ++i
)
5618 m_target
->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT
+ i
, m_modifier
.m_amount
/100.0f
, apply
);
5621 void Aura::HandleModOffhandDamagePercent(bool apply
, bool Real
)
5623 // spells required only Real aura add/remove
5627 sLog
.outDebug("AURA MOD OFFHAND DAMAGE");
5629 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5632 /********************************/
5633 /*** POWER COST ***/
5634 /********************************/
5636 void Aura::HandleModPowerCostPCT(bool apply
, bool Real
)
5638 // spells required only Real aura add/remove
5642 float amount
= m_modifier
.m_amount
/100.0f
;
5643 for(int i
= 0; i
< MAX_SPELL_SCHOOL
; ++i
)
5644 if(m_modifier
.m_miscvalue
& (1<<i
))
5645 m_target
->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER
+ i
, amount
, apply
);
5648 void Aura::HandleModPowerCost(bool apply
, bool Real
)
5650 // spells required only Real aura add/remove
5654 for(int i
= 0; i
< MAX_SPELL_SCHOOL
; ++i
)
5655 if(m_modifier
.m_miscvalue
& (1<<i
))
5656 m_target
->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER
+ i
, m_modifier
.m_amount
, apply
);
5659 void Aura::HandleNoReagentUseAura(bool /*Apply*/, bool Real
)
5661 // spells required only Real aura add/remove
5664 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5666 uint32 mask
[3] = {0, 0, 0};
5667 Unit::AuraList
const& noReagent
= m_target
->GetAurasByType(SPELL_AURA_NO_REAGENT_USE
);
5668 for(Unit::AuraList::const_iterator i
= noReagent
.begin(); i
!= noReagent
.end(); ++i
)
5670 uint32
const *ptr
= (*i
)->getAuraSpellClassMask();
5676 m_target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
+0, mask
[0]);
5677 m_target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
+1, mask
[1]);
5678 m_target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
+2, mask
[2]);
5681 /*********************************************************/
5683 /*********************************************************/
5685 void Aura::HandleShapeshiftBoosts(bool apply
)
5687 uint32 spellId1
= 0;
5688 uint32 spellId2
= 0;
5689 uint32 HotWSpellId
= 0;
5690 uint32 MasterShaperSpellId
= 0;
5692 uint32 form
= GetModifier()->m_miscvalue
;
5698 HotWSpellId
= 24900;
5699 MasterShaperSpellId
= 48420;
5704 MasterShaperSpellId
= 48422;
5715 HotWSpellId
= 24899;
5716 MasterShaperSpellId
= 48418;
5721 HotWSpellId
= 24899;
5722 MasterShaperSpellId
= 48418;
5724 case FORM_BATTLESTANCE
:
5727 case FORM_DEFENSIVESTANCE
:
5730 case FORM_BERSERKERSTANCE
:
5735 MasterShaperSpellId
= 48421;
5741 case FORM_FLIGHT_EPIC
:
5745 case FORM_METAMORPHOSIS
:
5749 case FORM_SPIRITOFREDEMPTION
:
5751 spellId2
= 27795; // must be second, this important at aura remove to prevent to early iterator invalidation.
5756 if(m_target
->GetTypeId() == TYPEID_PLAYER
) // Spell 49868 have same category as main form spell and share cooldown
5757 ((Player
*)m_target
)->RemoveSpellCooldown(49868);
5759 case FORM_GHOSTWOLF
:
5765 case FORM_CREATURECAT
:
5766 case FORM_CREATUREBEAR
:
5773 m_target
->CastSpell(m_target
, spellId1
, true, NULL
, this );
5775 m_target
->CastSpell(m_target
, spellId2
, true, NULL
, this);
5777 if (m_target
->GetTypeId() == TYPEID_PLAYER
)
5779 const PlayerSpellMap
& sp_list
= ((Player
*)m_target
)->GetSpellMap();
5780 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
5782 if (itr
->second
->state
== PLAYERSPELL_REMOVED
) continue;
5783 if (itr
->first
==spellId1
|| itr
->first
==spellId2
) continue;
5784 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
5785 if (!spellInfo
|| !(spellInfo
->Attributes
& (SPELL_ATTR_PASSIVE
| (1<<7))))
5787 if (spellInfo
->Stances
& (1<<(form
-1)))
5788 m_target
->CastSpell(m_target
, itr
->first
, true, NULL
, this);
5791 // Master Shapeshifter
5792 if (MasterShaperSpellId
)
5794 Unit::AuraList
const& ShapeShifterAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
5795 for(Unit::AuraList::const_iterator i
= ShapeShifterAuras
.begin(); i
!= ShapeShifterAuras
.end(); i
++)
5797 if ((*i
)->GetSpellProto()->SpellIconID
== 2851)
5799 int32 ShiftMod
= (*i
)->GetModifier()->m_amount
;
5800 m_target
->CastCustomSpell(m_target
, MasterShaperSpellId
, &ShiftMod
, NULL
, NULL
, true);
5806 // Leader of the Pack
5807 if (((Player
*)m_target
)->HasSpell(17007))
5809 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(24932);
5810 if (spellInfo
&& spellInfo
->Stances
& (1<<(form
-1)))
5811 m_target
->CastSpell(m_target
, 24932, true, NULL
, this);
5815 if (form
== FORM_CAT
&& ((Player
*)m_target
)->HasAura(52610))
5816 m_target
->CastSpell(m_target
, 62071, true);
5818 // Improved Moonkin Form
5819 if (form
== FORM_MOONKIN
)
5821 Unit::AuraList
const& dummyAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
5822 for(Unit::AuraList::const_iterator i
= dummyAuras
.begin(); i
!= dummyAuras
.end(); i
++)
5824 if ((*i
)->GetSpellProto()->SpellFamilyName
==SPELLFAMILY_DRUID
&&
5825 (*i
)->GetSpellProto()->SpellIconID
== 2855)
5827 uint32 spell_id
= 0;
5828 switch((*i
)->GetId())
5830 case 48384:spell_id
=50170;break;//Rank 1
5831 case 48395:spell_id
=50171;break;//Rank 2
5832 case 48396:spell_id
=50172;break;//Rank 3
5834 sLog
.outError("Aura::HandleShapeshiftBoosts: Not handled rank of IMF (Spell: %u)",(*i
)->GetId());
5839 m_target
->CastSpell(m_target
, spell_id
, true, NULL
, this);
5845 // Heart of the Wild
5848 Unit::AuraList
const& mModTotalStatPct
= m_target
->GetAurasByType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
);
5849 for(Unit::AuraList::const_iterator i
= mModTotalStatPct
.begin(); i
!= mModTotalStatPct
.end(); ++i
)
5851 if ((*i
)->GetSpellProto()->SpellIconID
== 240 && (*i
)->GetModifier()->m_miscvalue
== 3)
5853 int32 HotWMod
= (*i
)->GetModifier()->m_amount
;
5854 if(GetModifier()->m_miscvalue
== FORM_CAT
)
5857 m_target
->CastCustomSpell(m_target
, HotWSpellId
, &HotWMod
, NULL
, NULL
, true, NULL
, this);
5867 m_target
->RemoveAurasDueToSpell(spellId1
);
5869 m_target
->RemoveAurasDueToSpell(spellId2
);
5870 if(MasterShaperSpellId
)
5871 m_target
->RemoveAurasDueToSpell(MasterShaperSpellId
);
5873 Unit::AuraMap
& tAuras
= m_target
->GetAuras();
5874 for (Unit::AuraMap::iterator itr
= tAuras
.begin(); itr
!= tAuras
.end();)
5876 if (itr
->second
->IsRemovedOnShapeLost())
5878 m_target
->RemoveAurasDueToSpell(itr
->second
->GetId());
5879 itr
= tAuras
.begin();
5887 void Aura::HandleSpellSpecificBoosts(bool apply
)
5889 bool cast_at_remove
= false; // if spell must be casted at last aura from stack remove
5890 uint32 spellId1
= 0;
5891 uint32 spellId2
= 0;
5892 uint32 spellId3
= 0;
5893 uint32 spellId4
= 0;
5895 switch(GetSpellProto()->SpellFamilyName
)
5897 case SPELLFAMILY_GENERIC
:
5899 // Illusionary Barrier
5900 if(GetId() == 57350 && !apply
&& m_target
->getPowerType() == POWER_MANA
)
5902 cast_at_remove
= true;
5903 spellId1
= 60242; // Darkmoon Card: Illusion
5909 case SPELLFAMILY_MAGE
:
5911 // Ice Barrier (non stacking from one caster)
5912 if (m_spellProto
->SpellIconID
== 32)
5914 if (!apply
&& (m_removeMode
== AURA_REMOVE_BY_DISPEL
|| (m_removeMode
== AURA_REMOVE_BY_DEFAULT
&& !GetModifier()->m_amount
)))
5916 Unit::AuraList
const& dummyAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
5917 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
5919 // Shattered Barrier
5920 if ((*itr
)->GetSpellProto()->SpellIconID
== 2945)
5922 cast_at_remove
= true;
5923 // first rank have 50% chance
5924 if ((*itr
)->GetId() != 44745 || roll_chance_i(50))
5933 // Combustion (remove triggered aura stack)
5934 else if (m_spellProto
->Id
== 11129)
5941 // Combustion (remove main aura)
5942 else if (m_spellProto
->Id
== 28682)
5953 case SPELLFAMILY_WARRIOR
:
5957 // Remove Blood Frenzy only if target no longer has any Deep Wound or Rend (applying is handled by procs)
5958 if (GetSpellProto()->Mechanic
!= MECHANIC_BLEED
)
5961 // If target still has one of Warrior's bleeds, do nothing
5962 Unit::AuraList
const& PeriodicDamage
= m_target
->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE
);
5963 for(Unit::AuraList::const_iterator i
= PeriodicDamage
.begin(); i
!= PeriodicDamage
.end(); ++i
)
5964 if( (*i
)->GetCasterGUID() == GetCasterGUID() &&
5965 (*i
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_WARRIOR
&&
5966 (*i
)->GetSpellProto()->Mechanic
== MECHANIC_BLEED
)
5969 spellId1
= 30069; // Blood Frenzy (Rank 1)
5970 spellId2
= 30070; // Blood Frenzy (Rank 2)
5974 case SPELLFAMILY_WARLOCK
:
5976 // Fear (non stacking)
5977 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000040000000000))
5981 Unit
* caster
= GetCaster();
5985 Unit::AuraList
const& dummyAuras
= caster
->GetAurasByType(SPELL_AURA_DUMMY
);
5986 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
5988 SpellEntry
const* dummyEntry
= (*itr
)->GetSpellProto();
5990 if (dummyEntry
->SpellFamilyName
== SPELLFAMILY_WARLOCK
&& dummyEntry
->SpellIconID
== 98)
5992 cast_at_remove
= true;
5993 switch((*itr
)->GetModifier()->m_amount
)
5996 case 0: spellId1
= 60946; break;
5998 case 1: spellId1
= 60947; break;
6011 case SPELLFAMILY_PRIEST
:
6013 // Shadow Word: Pain (need visual check fro skip improvement talent) or Vampiric Touch
6014 if (m_spellProto
->SpellIconID
== 234 && m_spellProto
->SpellVisual
[0] || m_spellProto
->SpellIconID
== 2213)
6016 if (!apply
&& m_removeMode
== AURA_REMOVE_BY_DISPEL
)
6018 Unit
* caster
= GetCaster();
6022 Unit::AuraList
const& dummyAuras
= caster
->GetAurasByType(SPELL_AURA_DUMMY
);
6023 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
6026 if ((*itr
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_PRIEST
6027 && (*itr
)->GetSpellProto()->SpellIconID
== 178)
6030 int32 basepoints0
= (*itr
)->GetModifier()->m_amount
* caster
->GetCreateMana() / 100;
6031 caster
->CastCustomSpell(caster
, 64103, &basepoints0
, NULL
, NULL
, true, NULL
, this);
6042 // Abolish Disease (remove 1 more poison effect with Body and Soul)
6048 Unit::AuraList
const& dummyAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
6049 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
6051 SpellEntry
const* dummyEntry
= (*itr
)->GetSpellProto();
6052 // Body and Soul (talent ranks)
6053 if (dummyEntry
->SpellFamilyName
== SPELLFAMILY_PRIEST
&& dummyEntry
->SpellIconID
== 2218 &&
6054 dummyEntry
->SpellVisual
[0]==0)
6056 chance
= (*itr
)->GetSpellProto()->CalculateSimpleValue(1);
6061 if(roll_chance_i(chance
))
6062 spellId1
= 64134; // Body and Soul (periodic dispel effect)
6065 spellId1
= 64134; // Body and Soul (periodic dispel effect)
6068 // Dispersion mana reg and immunity
6070 spellId1
= 60069; // Dispersion
6071 spellId2
= 63230; // Dispersion
6078 case SPELLFAMILY_ROGUE
:
6079 // Sprint (skip non player casted spells by category)
6080 if (GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000000040) && GetSpellProto()->Category
== 44)
6082 if(!apply
|| m_target
->HasAura(58039)) // Glyph of Blurred Speed
6083 spellId1
= 61922; // Sprint (waterwalk)
6090 case SPELLFAMILY_HUNTER
:
6092 // The Beast Within and Bestial Wrath - immunity
6093 if (GetId() == 19574 || GetId() == 34471)
6100 // Aspect of the Dragonhawk dodge
6101 else if (GetSpellProto()->SpellFamilyFlags2
& 0x00001000)
6105 // triggered spell have same category as main spell and cooldown
6106 if (apply
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
6107 ((Player
*)m_target
)->RemoveSpellCooldown(61848);
6113 case SPELLFAMILY_PALADIN
:
6115 if (m_spellProto
->Id
== 31884) // Avenging Wrath
6118 spellId1
= 57318; // Sanctified Wrath (triggered)
6122 Unit::AuraList
const& dummyAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
6123 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
6125 if ((*itr
)->GetSpellProto()->SpellIconID
== 3029)
6127 percent
= (*itr
)->GetModifier()->m_amount
;
6132 // apply in special way
6135 spellId1
= 57318; // Sanctified Wrath (triggered)
6136 // prevent aura deletion, specially in multi-boost case
6138 m_target
->CastCustomSpell(m_target
, spellId1
, &percent
, &percent
, NULL
, true, NULL
, this);
6146 // Only process on player casting paladin aura
6147 // all aura bonuses applied also in aura area effect way to caster
6148 if (GetCasterGUID() != m_target
->GetGUID() || !IS_PLAYER_GUID(GetCasterGUID()))
6151 if (GetSpellSpecific(m_spellProto
->Id
) != SPELL_AURA
)
6154 // Sanctified Retribution and Swift Retribution (they share one aura), but not Retribution Aura (already gets modded)
6155 if ((GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000000008))==0)
6156 spellId1
= 63531; // placeholder for talent spell mods
6157 // Improved Concentration Aura (auras bonus)
6158 spellId2
= 63510; // placeholder for talent spell mods
6159 // Improved Devotion Aura (auras bonus)
6160 spellId3
= 63514; // placeholder for talent spell mods
6163 case SPELLFAMILY_DEATHKNIGHT
:
6165 if (GetSpellSpecific(m_spellProto
->Id
) != SPELL_PRESENCE
)
6168 // Frost Presence health
6169 if (GetId() == 48263)
6171 // Unholy Presence move speed
6172 else if (GetId() == 48265)
6183 // prevent aura deletion, specially in multi-boost case
6186 if (apply
|| cast_at_remove
)
6189 m_target
->CastSpell(m_target
, spellId1
, true, NULL
, this);
6190 if (spellId2
&& !IsDeleted())
6191 m_target
->CastSpell(m_target
, spellId2
, true, NULL
, this);
6192 if (spellId3
&& !IsDeleted())
6193 m_target
->CastSpell(m_target
, spellId3
, true, NULL
, this);
6194 if (spellId4
&& !IsDeleted())
6195 m_target
->CastSpell(m_target
, spellId4
, true, NULL
, this);
6200 m_target
->RemoveAurasByCasterSpell(spellId1
, GetCasterGUID());
6202 m_target
->RemoveAurasByCasterSpell(spellId2
, GetCasterGUID());
6204 m_target
->RemoveAurasByCasterSpell(spellId3
, GetCasterGUID());
6206 m_target
->RemoveAurasByCasterSpell(spellId4
, GetCasterGUID());
6212 void Aura::HandleAuraEmpathy(bool apply
, bool /*Real*/)
6214 if(m_target
->GetTypeId() != TYPEID_UNIT
)
6217 CreatureInfo
const * ci
= ObjectMgr::GetCreatureTemplate(m_target
->GetEntry());
6218 if(ci
&& ci
->type
== CREATURE_TYPE_BEAST
)
6219 m_target
->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_SPECIALINFO
, apply
);
6222 void Aura::HandleAuraUntrackable(bool apply
, bool /*Real*/)
6225 m_target
->SetByteFlag(UNIT_FIELD_BYTES_1
, 3, UNIT_BYTE1_FLAG_UNTRACKABLE
);
6227 m_target
->RemoveByteFlag(UNIT_FIELD_BYTES_1
, 3, UNIT_BYTE1_FLAG_UNTRACKABLE
);
6230 void Aura::HandleAuraModPacify(bool apply
, bool /*Real*/)
6232 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
6236 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PACIFIED
);
6238 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PACIFIED
);
6241 void Aura::HandleAuraModPacifyAndSilence(bool apply
, bool Real
)
6243 HandleAuraModPacify(apply
, Real
);
6244 HandleAuraModSilence(apply
, Real
);
6247 void Aura::HandleAuraGhost(bool apply
, bool /*Real*/)
6249 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
6254 m_target
->SetFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
);
6258 m_target
->RemoveFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
);
6262 void Aura::HandleAuraAllowFlight(bool apply
, bool Real
)
6264 // all applied/removed only at real aura add/remove
6271 data
.Initialize(SMSG_MOVE_SET_CAN_FLY
, 12);
6273 data
.Initialize(SMSG_MOVE_UNSET_CAN_FLY
, 12);
6274 data
.append(m_target
->GetPackGUID());
6275 data
<< uint32(0); // unk
6276 m_target
->SendMessageToSet(&data
, true);
6279 void Aura::HandleModRating(bool apply
, bool Real
)
6281 // spells required only Real aura add/remove
6285 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
6288 for (uint32 rating
= 0; rating
< MAX_COMBAT_RATING
; ++rating
)
6289 if (m_modifier
.m_miscvalue
& (1 << rating
))
6290 ((Player
*)m_target
)->ApplyRatingMod(CombatRating(rating
), m_modifier
.m_amount
, apply
);
6293 void Aura::HandleModRatingFromStat(bool apply
, bool Real
)
6295 // spells required only Real aura add/remove
6299 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
6301 // Just recalculate ratings
6302 for (uint32 rating
= 0; rating
< MAX_COMBAT_RATING
; ++rating
)
6303 if (m_modifier
.m_miscvalue
& (1 << rating
))
6304 ((Player
*)m_target
)->ApplyRatingMod(CombatRating(rating
), 0, apply
);
6307 void Aura::HandleForceMoveForward(bool apply
, bool Real
)
6309 if(!Real
|| m_target
->GetTypeId() != TYPEID_PLAYER
)
6312 m_target
->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FORCE_MOVE
);
6314 m_target
->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FORCE_MOVE
);
6317 void Aura::HandleAuraModExpertise(bool /*apply*/, bool /*Real*/)
6319 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
6322 ((Player
*)m_target
)->UpdateExpertise(BASE_ATTACK
);
6323 ((Player
*)m_target
)->UpdateExpertise(OFF_ATTACK
);
6326 void Aura::HandleModTargetResistance(bool apply
, bool Real
)
6328 // spells required only Real aura add/remove
6331 // applied to damage as HandleNoImmediateEffect in Unit::CalcAbsorbResist and Unit::CalcArmorReducedDamage
6333 // show armor penetration
6334 if (m_target
->GetTypeId() == TYPEID_PLAYER
&& (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
6335 m_target
->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE
, m_modifier
.m_amount
, apply
);
6337 // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy
6338 if (m_target
->GetTypeId() == TYPEID_PLAYER
&& (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_SPELL
)==SPELL_SCHOOL_MASK_SPELL
)
6339 m_target
->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE
, m_modifier
.m_amount
, apply
);
6342 void Aura::HandleShieldBlockValue(bool apply
, bool /*Real*/)
6344 BaseModType modType
= FLAT_MOD
;
6345 if(m_modifier
.m_auraname
== SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT
)
6348 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
6349 ((Player
*)m_target
)->HandleBaseModValue(SHIELD_BLOCK_VALUE
, modType
, float(m_modifier
.m_amount
), apply
);
6352 void Aura::HandleAuraRetainComboPoints(bool apply
, bool Real
)
6354 // spells required only Real aura add/remove
6358 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
6361 Player
*target
= (Player
*)m_target
;
6363 // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler
6364 // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost)
6365 if( !apply
&& m_duration
==0 && target
->GetComboTarget())
6366 if(Unit
* unit
= ObjectAccessor::GetUnit(*m_target
,target
->GetComboTarget()))
6367 target
->AddComboPoints(unit
, -m_modifier
.m_amount
);
6370 void Aura::HandleModUnattackable( bool Apply
, bool Real
)
6374 m_target
->CombatStop();
6375 m_target
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
);
6377 m_target
->ApplyModFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_NON_ATTACKABLE
,Apply
);
6380 void Aura::HandleSpiritOfRedemption( bool apply
, bool Real
)
6382 // spells required only Real aura add/remove
6386 // prepare spirit state
6389 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
6391 // disable breath/etc timers
6392 ((Player
*)m_target
)->StopMirrorTimers();
6394 // set stand state (expected in this form)
6395 if(!m_target
->IsStandState())
6396 m_target
->SetStandState(UNIT_STAND_STATE_STAND
);
6399 m_target
->SetHealth(1);
6403 m_target
->DealDamage(m_target
, m_target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, GetSpellProto(), false);
6406 void Aura::CleanupTriggeredSpells()
6408 uint32 tSpellId
= m_spellProto
->EffectTriggerSpell
[GetEffIndex()];
6412 SpellEntry
const* tProto
= sSpellStore
.LookupEntry(tSpellId
);
6416 if(GetSpellDuration(tProto
) != -1)
6419 // needed for spell 43680, maybe others
6420 // TODO: is there a spell flag, which can solve this in a more sophisticated way?
6421 if(m_spellProto
->EffectApplyAuraName
[GetEffIndex()] == SPELL_AURA_PERIODIC_TRIGGER_SPELL
&&
6422 GetSpellDuration(m_spellProto
) == m_spellProto
->EffectAmplitude
[GetEffIndex()])
6424 m_target
->RemoveAurasDueToSpell(tSpellId
);
6427 void Aura::HandleSchoolAbsorb(bool apply
, bool Real
)
6432 Unit
* caster
= GetCaster();
6438 // prevent double apply bonuses
6439 if (m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading())
6441 float DoneActualBenefit
= 0.0f
;
6442 switch(m_spellProto
->SpellFamilyName
)
6444 case SPELLFAMILY_PRIEST
:
6445 // Power Word: Shield
6446 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000001))
6447 //+80.68% from +spell bonus
6448 DoneActualBenefit
= caster
->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto
)) * 0.8068f
;
6450 case SPELLFAMILY_MAGE
:
6451 // Frost Ward, Fire Ward
6452 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000108))
6453 //+10% from +spell bonus
6454 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.1f
;
6456 else if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000100000000))
6457 //+80.67% from +spell bonus
6458 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.8067f
;
6460 case SPELLFAMILY_WARLOCK
:
6462 if (m_spellProto
->SpellFamilyFlags2
& 0x00000040)
6463 //+30% from +spell bonus
6464 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.30f
;
6466 case SPELLFAMILY_PALADIN
:
6468 // (check not strictly needed, only Sacred Shield has SPELL_AURA_SCHOOL_ABSORB in SPELLFAMILY_PALADIN at this time)
6469 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0008000000000000))
6471 // +75% from spell power
6472 DoneActualBenefit
= caster
->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto
)) * 0.75f
;
6479 DoneActualBenefit
*= caster
->CalculateLevelPenalty(GetSpellProto());
6481 m_modifier
.m_amount
+= (int32
)DoneActualBenefit
;
6487 // Power Word: Shield
6488 m_spellProto
->SpellFamilyName
== SPELLFAMILY_PRIEST
&& m_spellProto
->Mechanic
== MECHANIC_SHIELD
&&
6489 (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000001)) &&
6490 // completely absorbed or dispelled
6491 ((m_removeMode
== AURA_REMOVE_BY_DEFAULT
&& !m_modifier
.m_amount
) || m_removeMode
== AURA_REMOVE_BY_DISPEL
))
6493 Unit::AuraList
const& vDummyAuras
= caster
->GetAurasByType(SPELL_AURA_DUMMY
);
6494 for(Unit::AuraList::const_iterator itr
= vDummyAuras
.begin(); itr
!= vDummyAuras
.end(); ++itr
)
6496 SpellEntry
const* vSpell
= (*itr
)->GetSpellProto();
6498 // Rapture (main spell)
6499 if(vSpell
->SpellFamilyName
== SPELLFAMILY_PRIEST
&& vSpell
->SpellIconID
== 2894 && vSpell
->Effect
[1])
6501 switch((*itr
)->GetEffIndex())
6506 int32 manapct1000
= 5 * ((*itr
)->GetModifier()->m_amount
+ sSpellMgr
.GetSpellRank(vSpell
->Id
));
6507 int32 basepoints0
= caster
->GetMaxPower(POWER_MANA
) * manapct1000
/ 1000;
6508 caster
->CastCustomSpell(caster
, 47755, &basepoints0
, NULL
, NULL
, true);
6514 if (!roll_chance_i((*itr
)->GetModifier()->m_amount
) || caster
->HasAura(63853))
6517 switch(m_target
->getPowerType())
6519 case POWER_RUNIC_POWER
:
6520 m_target
->CastSpell(m_target
, 63652, true, NULL
, NULL
, m_caster_guid
);
6523 m_target
->CastSpell(m_target
, 63653, true, NULL
, NULL
, m_caster_guid
);
6527 int32 basepoints0
= m_target
->GetMaxPower(POWER_MANA
) * 2 / 100;
6528 m_target
->CastCustomSpell(m_target
, 63654, &basepoints0
, NULL
, NULL
, true);
6532 m_target
->CastSpell(m_target
, 63655, true, NULL
, NULL
, m_caster_guid
);
6539 caster
->CastSpell(caster
, 63853, true);
6543 sLog
.outError("Changes in R-dummy spell???: effect 3");
6552 void Aura::PeriodicTick()
6554 switch(m_modifier
.m_auraname
)
6556 case SPELL_AURA_PERIODIC_DAMAGE
:
6557 case SPELL_AURA_PERIODIC_DAMAGE_PERCENT
:
6559 Unit
*pCaster
= GetCaster();
6563 if( GetSpellProto()->Effect
[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
6564 pCaster
->SpellHitResult(m_target
, GetSpellProto(), false) != SPELL_MISS_NONE
)
6567 // Check for immune (not use charges)
6568 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6571 // some auras remove at specific health level or more
6572 if(m_modifier
.m_auraname
== SPELL_AURA_PERIODIC_DAMAGE
)
6576 case 43093: case 31956: case 38801:
6577 case 35321: case 38363: case 39215:
6578 if(m_target
->GetHealth() == m_target
->GetMaxHealth() )
6580 m_target
->RemoveAurasDueToSpell(GetId());
6587 GetEffIndex() < 2 && GetSpellProto()->Effect
[GetEffIndex()] == SPELL_EFFECT_DUMMY
?
6588 pCaster
->CalculateSpellDamage(GetSpellProto(), GetEffIndex() + 1, GetSpellProto()->EffectBasePoints
[GetEffIndex() + 1], m_target
) :
6590 if(m_target
->GetHealth() * 100 >= m_target
->GetMaxHealth() * percent
)
6592 m_target
->RemoveAurasDueToSpell(GetId());
6604 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
6606 // ignore non positive values (can be result apply spellmods to aura damage
6607 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
6611 if(m_modifier
.m_auraname
== SPELL_AURA_PERIODIC_DAMAGE
)
6615 // SpellDamageBonus for magic spells
6616 if(GetSpellProto()->DmgClass
== SPELL_DAMAGE_CLASS_NONE
|| GetSpellProto()->DmgClass
== SPELL_DAMAGE_CLASS_MAGIC
)
6617 pdamage
= pCaster
->SpellDamageBonus(m_target
, GetSpellProto(), pdamage
, DOT
, GetStackAmount());
6618 // MeleeDamagebonus for weapon based spells
6621 WeaponAttackType attackType
= GetWeaponAttackType(GetSpellProto());
6622 pdamage
= pCaster
->MeleeDamageBonus(m_target
, pdamage
, attackType
, GetSpellProto(), DOT
, GetStackAmount());
6625 // Calculate armor mitigation if it is a physical spell
6626 // But not for bleed mechanic spells
6627 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL
&&
6628 GetEffectMechanic(GetSpellProto(), m_effIndex
) != MECHANIC_BLEED
)
6630 uint32 pdamageReductedArmor
= pCaster
->CalcArmorReducedDamage(m_target
, pdamage
);
6631 cleanDamage
.damage
+= pdamage
- pdamageReductedArmor
;
6632 pdamage
= pdamageReductedArmor
;
6635 // Curse of Agony damage-per-tick calculation
6636 if (GetSpellProto()->SpellFamilyName
==SPELLFAMILY_WARLOCK
&& (GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000000400)) && GetSpellProto()->SpellIconID
==544)
6638 // 1..4 ticks, 1/2 from normal tick damage
6639 if (GetAuraTicks() <= 4)
6640 pdamage
= pdamage
/2;
6641 // 9..12 ticks, 3/2 from normal tick damage
6642 else if(GetAuraTicks() >= 9)
6643 pdamage
+= (pdamage
+ 1) / 2; // +1 prevent 0.5 damage possible lost at 1..4 ticks
6644 // 5..8 ticks have normal tick damage
6648 pdamage
= uint32(m_target
->GetMaxHealth()*amount
/100);
6650 // This method can modify pdamage
6651 bool isCrit
= IsCritFromAbilityAura(pCaster
, pdamage
);
6653 // send critical in hit info for threat calculation
6656 cleanDamage
.hitOutCome
= MELEE_HIT_CRIT
;
6657 // Resilience - reduce crit damage
6658 pdamage
-= m_target
->GetSpellCritDamageReduction(pdamage
);
6661 // only from players
6662 // FIXME: need use SpellDamageBonus instead?
6663 if (IS_PLAYER_GUID(m_caster_guid
))
6664 pdamage
-= m_target
->GetSpellDamageReduction(pdamage
);
6666 pCaster
->CalcAbsorbResist(m_target
, GetSpellSchoolMask(GetSpellProto()), DOT
, pdamage
, &absorb
, &resist
, !(GetSpellProto()->AttributesEx2
& SPELL_ATTR_EX2_CANT_REFLECTED
));
6668 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
6669 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId(),absorb
);
6671 pCaster
->DealDamageMods(m_target
, pdamage
, &absorb
);
6673 SpellPeriodicAuraLogInfo
pInfo(this, pdamage
, 0, absorb
, resist
, 0.0f
, isCrit
);
6674 m_target
->SendPeriodicAuraLog(&pInfo
);
6677 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
6678 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
6679 pdamage
= (pdamage
<= absorb
+ resist
) ? 0 : (pdamage
- absorb
- resist
);
6681 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
6682 pCaster
->ProcDamageAndSpell(m_target
, procAttacker
, procVictim
, PROC_EX_NORMAL_HIT
, pdamage
, BASE_ATTACK
, GetSpellProto());
6684 pCaster
->DealDamage(m_target
, pdamage
, &cleanDamage
, DOT
, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
6687 case SPELL_AURA_PERIODIC_LEECH
:
6688 case SPELL_AURA_PERIODIC_HEALTH_FUNNEL
:
6690 Unit
*pCaster
= GetCaster();
6694 if(!pCaster
->isAlive())
6697 if( GetSpellProto()->Effect
[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
6698 pCaster
->SpellHitResult(m_target
, GetSpellProto(), false) != SPELL_MISS_NONE
)
6702 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6707 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
6709 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
6711 //Calculate armor mitigation if it is a physical spell
6712 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL
)
6714 uint32 pdamageReductedArmor
= pCaster
->CalcArmorReducedDamage(m_target
, pdamage
);
6715 cleanDamage
.damage
+= pdamage
- pdamageReductedArmor
;
6716 pdamage
= pdamageReductedArmor
;
6719 pdamage
= pCaster
->SpellDamageBonus(m_target
, GetSpellProto(), pdamage
, DOT
, GetStackAmount());
6721 pCaster
->CalcAbsorbResist(m_target
, GetSpellSchoolMask(GetSpellProto()), DOT
, pdamage
, &absorb
, &resist
, !(GetSpellProto()->AttributesEx2
& SPELL_ATTR_EX2_CANT_REFLECTED
));
6723 if(m_target
->GetHealth() < pdamage
)
6724 pdamage
= uint32(m_target
->GetHealth());
6726 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
6727 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId(),absorb
);
6729 pCaster
->SendSpellNonMeleeDamageLog(m_target
, GetId(), pdamage
, GetSpellSchoolMask(GetSpellProto()), absorb
, resist
, false, 0);
6731 float multiplier
= GetSpellProto()->EffectMultipleValue
[GetEffIndex()] > 0 ? GetSpellProto()->EffectMultipleValue
[GetEffIndex()] : 1;
6734 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
6735 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
6736 pdamage
= (pdamage
<= absorb
+ resist
) ? 0 : (pdamage
-absorb
-resist
);
6738 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
6739 pCaster
->ProcDamageAndSpell(m_target
, procAttacker
, procVictim
, PROC_EX_NORMAL_HIT
, pdamage
, BASE_ATTACK
, GetSpellProto());
6740 int32 new_damage
= pCaster
->DealDamage(m_target
, pdamage
, &cleanDamage
, DOT
, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), false);
6742 if (!m_target
->isAlive() && pCaster
->IsNonMeleeSpellCasted(false))
6743 for (uint32 i
= CURRENT_FIRST_NON_MELEE_SPELL
; i
< CURRENT_MAX_SPELL
; ++i
)
6744 if (Spell
* spell
= pCaster
->GetCurrentSpell(CurrentSpellTypes(i
)))
6745 if (spell
->m_spellInfo
->Id
== GetId())
6749 if(Player
*modOwner
= pCaster
->GetSpellModOwner())
6750 modOwner
->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE
, multiplier
);
6752 uint32 heal
= pCaster
->SpellHealingBonus(pCaster
, GetSpellProto(), uint32(new_damage
* multiplier
), DOT
, GetStackAmount());
6754 int32 gain
= pCaster
->DealHeal(pCaster
, heal
, GetSpellProto());
6755 pCaster
->getHostileRefManager().threatAssist(pCaster
, gain
* 0.5f
, GetSpellProto());
6758 case SPELL_AURA_PERIODIC_HEAL
:
6759 case SPELL_AURA_OBS_MOD_HEALTH
:
6761 Unit
*pCaster
= GetCaster();
6765 // heal for caster damage (must be alive)
6766 if(m_target
!= pCaster
&& GetSpellProto()->SpellVisual
[0] == 163 && !pCaster
->isAlive())
6769 // ignore non positive values (can be result apply spellmods to aura damage
6770 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
6774 if(m_modifier
.m_auraname
==SPELL_AURA_OBS_MOD_HEALTH
)
6775 pdamage
= uint32(m_target
->GetMaxHealth() * amount
/ 100);
6780 // Wild Growth (1/7 - 6 + 2*ramainTicks) %
6781 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_DRUID
&& m_spellProto
->SpellIconID
== 2864)
6783 int32 ticks
= GetAuraMaxTicks();
6784 int32 remainingTicks
= ticks
- GetAuraTicks();
6785 pdamage
= int32(pdamage
) + int32(amount
)*ticks
*(-6+2*remainingTicks
)/100;
6789 pdamage
= pCaster
->SpellHealingBonus(m_target
, GetSpellProto(), pdamage
, DOT
, GetStackAmount());
6791 // This method can modify pdamage
6792 bool isCrit
= IsCritFromAbilityAura(pCaster
, pdamage
);
6794 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) heal of %u (TypeId: %u) for %u health inflicted by %u",
6795 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
6797 SpellPeriodicAuraLogInfo
pInfo(this, pdamage
, 0, 0, 0, 0.0f
, isCrit
);
6798 m_target
->SendPeriodicAuraLog(&pInfo
);
6800 int32 gain
= m_target
->ModifyHealth(pdamage
);
6803 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
;
6804 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;
6805 pCaster
->ProcDamageAndSpell(m_target
, procAttacker
, procVictim
, PROC_EX_NORMAL_HIT
, gain
, BASE_ATTACK
, m_spellProto
);
6807 // add HoTs to amount healed in bgs
6808 if( pCaster
->GetTypeId() == TYPEID_PLAYER
)
6809 if( BattleGround
*bg
= ((Player
*)pCaster
)->GetBattleGround() )
6810 bg
->UpdatePlayerScore(((Player
*)pCaster
), SCORE_HEALING_DONE
, gain
);
6812 m_target
->getHostileRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, GetSpellProto());
6814 SpellEntry
const* spellProto
= GetSpellProto();
6816 // heal for caster damage
6817 if(m_target
!= pCaster
&& spellProto
->SpellVisual
[0] == 163)
6819 uint32 dmg
= spellProto
->manaPerSecond
;
6820 if(pCaster
->GetHealth() <= dmg
&& pCaster
->GetTypeId()==TYPEID_PLAYER
)
6822 pCaster
->RemoveAurasDueToSpell(GetId());
6824 // finish current generic/channeling spells, don't affect autorepeat
6825 pCaster
->FinishSpell(CURRENT_GENERIC_SPELL
);
6826 pCaster
->FinishSpell(CURRENT_CHANNELED_SPELL
);
6830 uint32 damage
= gain
;
6832 pCaster
->DealDamageMods(pCaster
, damage
, &absorb
);
6833 pCaster
->SendSpellNonMeleeDamageLog(pCaster
, GetId(), damage
, GetSpellSchoolMask(GetSpellProto()), absorb
, 0, false, 0, false);
6835 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
6836 pCaster
->DealDamage(pCaster
, damage
, &cleanDamage
, NODAMAGE
, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
6840 // uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;// | PROC_FLAG_SUCCESSFUL_HEAL;
6841 // uint32 procVictim = 0;//ROC_FLAG_ON_TAKE_PERIODIC | PROC_FLAG_TAKEN_HEAL;
6842 // ignore item heals
6843 // if(procSpell && !haveCastItem)
6844 // pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto);
6847 case SPELL_AURA_PERIODIC_MANA_LEECH
:
6849 if(m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
>= MAX_POWERS
)
6852 Powers power
= Powers(m_modifier
.m_miscvalue
);
6854 // power type might have changed between aura applying and tick (druid's shapeshift)
6855 if(m_target
->getPowerType() != power
)
6858 Unit
*pCaster
= GetCaster();
6862 if(!pCaster
->isAlive())
6865 if( GetSpellProto()->Effect
[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
6866 pCaster
->SpellHitResult(m_target
, GetSpellProto(), false) != SPELL_MISS_NONE
)
6869 // Check for immune (not use charges)
6870 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6873 // ignore non positive values (can be result apply spellmods to aura damage
6874 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
6876 // Special case: draining x% of mana (up to a maximum of 2*x% of the caster's maximum mana)
6877 // It's mana percent cost spells, m_modifier.m_amount is percent drain from target
6878 if (m_spellProto
->ManaCostPercentage
)
6881 uint32 maxmana
= pCaster
->GetMaxPower(power
) * pdamage
* 2 / 100;
6882 pdamage
= m_target
->GetMaxPower(power
) * pdamage
/ 100;
6883 if(pdamage
> maxmana
)
6887 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u",
6888 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
6890 int32 drain_amount
= m_target
->GetPower(power
) > pdamage
? pdamage
: m_target
->GetPower(power
);
6892 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
6893 if (power
== POWER_MANA
)
6894 drain_amount
-= m_target
->GetSpellCritDamageReduction(drain_amount
);
6896 m_target
->ModifyPower(power
, -drain_amount
);
6898 float gain_multiplier
= 0;
6900 if(pCaster
->GetMaxPower(power
) > 0)
6902 gain_multiplier
= GetSpellProto()->EffectMultipleValue
[GetEffIndex()];
6904 if(Player
*modOwner
= pCaster
->GetSpellModOwner())
6905 modOwner
->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE
, gain_multiplier
);
6908 SpellPeriodicAuraLogInfo
pInfo(this, drain_amount
, 0, 0, 0, gain_multiplier
);
6909 m_target
->SendPeriodicAuraLog(&pInfo
);
6911 int32 gain_amount
= int32(drain_amount
* gain_multiplier
);
6915 int32 gain
= pCaster
->ModifyPower(power
, gain_amount
);
6916 m_target
->AddThreat(pCaster
, float(gain
) * 0.5f
, pInfo
.critical
, GetSpellSchoolMask(GetSpellProto()), GetSpellProto());
6920 case SPELL_AURA_PERIODIC_ENERGIZE
:
6922 // ignore non positive values (can be result apply spellmods to aura damage
6923 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
6925 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u",
6926 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
6928 if(m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
>= MAX_POWERS
)
6931 Powers power
= Powers(m_modifier
.m_miscvalue
);
6933 if(m_target
->GetMaxPower(power
) == 0)
6936 SpellPeriodicAuraLogInfo
pInfo(this, pdamage
, 0, 0, 0, 0.0f
);
6937 m_target
->SendPeriodicAuraLog(&pInfo
);
6939 int32 gain
= m_target
->ModifyPower(power
,pdamage
);
6941 if(Unit
* pCaster
= GetCaster())
6942 m_target
->getHostileRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, GetSpellProto());
6945 case SPELL_AURA_OBS_MOD_MANA
:
6947 // ignore non positive values (can be result apply spellmods to aura damage
6948 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
6950 uint32 pdamage
= uint32(m_target
->GetMaxPower(POWER_MANA
) * amount
/ 100);
6952 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u mana inflicted by %u",
6953 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
6955 if(m_target
->GetMaxPower(POWER_MANA
) == 0)
6958 SpellPeriodicAuraLogInfo
pInfo(this, pdamage
, 0, 0, 0, 0.0f
);
6959 m_target
->SendPeriodicAuraLog(&pInfo
);
6961 int32 gain
= m_target
->ModifyPower(POWER_MANA
, pdamage
);
6963 if(Unit
* pCaster
= GetCaster())
6964 m_target
->getHostileRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, GetSpellProto());
6967 case SPELL_AURA_POWER_BURN_MANA
:
6969 Unit
*pCaster
= GetCaster();
6973 // Check for immune (not use charges)
6974 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6977 int32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
6979 Powers powerType
= Powers(m_modifier
.m_miscvalue
);
6981 if(!m_target
->isAlive() || m_target
->getPowerType() != powerType
)
6984 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
6985 if (powerType
== POWER_MANA
)
6986 pdamage
-= m_target
->GetSpellCritDamageReduction(pdamage
);
6988 uint32 gain
= uint32(-m_target
->ModifyPower(powerType
, -pdamage
));
6990 gain
= uint32(gain
* GetSpellProto()->EffectMultipleValue
[GetEffIndex()]);
6992 SpellEntry
const* spellProto
= GetSpellProto();
6993 // maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG
6994 SpellNonMeleeDamage
damageInfo(pCaster
, m_target
, spellProto
->Id
, spellProto
->SchoolMask
);
6995 pCaster
->CalculateSpellDamage(&damageInfo
, gain
, spellProto
);
6997 pCaster
->DealDamageMods(damageInfo
.target
, damageInfo
.damage
, &damageInfo
.absorb
);
6999 pCaster
->SendSpellNonMeleeDamageLog(&damageInfo
);
7002 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
7003 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
7004 uint32 procEx
= createProcExtendMask(&damageInfo
, SPELL_MISS_NONE
);
7005 if (damageInfo
.damage
)
7006 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
7008 pCaster
->ProcDamageAndSpell(damageInfo
.target
, procAttacker
, procVictim
, procEx
, damageInfo
.damage
, BASE_ATTACK
, spellProto
);
7010 pCaster
->DealSpellDamage(&damageInfo
, true);
7013 case SPELL_AURA_MOD_REGEN
:
7015 int32 gain
= m_target
->ModifyHealth(m_modifier
.m_amount
);
7016 if (Unit
*caster
= GetCaster())
7017 m_target
->getHostileRefManager().threatAssist(caster
, float(gain
) * 0.5f
, GetSpellProto());
7020 case SPELL_AURA_MOD_POWER_REGEN
:
7022 Powers pt
= m_target
->getPowerType();
7023 if(int32(pt
) != m_modifier
.m_miscvalue
)
7026 if ( GetSpellProto()->AuraInterruptFlags
& AURA_INTERRUPT_FLAG_NOT_SEATED
)
7029 m_target
->HandleEmoteCommand(EMOTE_ONESHOT_EAT
);
7031 else if( GetId() == 20577 )
7034 m_target
->HandleEmoteCommand(EMOTE_STATE_CANNIBALIZE
);
7038 // amount = 1+ 16 = 17 = 3,4*5 = 10,2*5/3
7039 // so 17 is rounded amount for 5 sec tick grow ~ 1 range grow in 3 sec
7040 if(pt
== POWER_RAGE
)
7041 m_target
->ModifyPower(pt
, m_modifier
.m_amount
* 3 / 5);
7044 // Here tick dummy auras
7045 case SPELL_AURA_DUMMY
: // some spells have dummy aura
7046 case SPELL_AURA_PERIODIC_DUMMY
:
7048 PeriodicDummyTick();
7051 case SPELL_AURA_PERIODIC_TRIGGER_SPELL
:
7056 case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
:
7058 TriggerSpellWithValue();
7066 void Aura::PeriodicDummyTick()
7068 SpellEntry
const* spell
= GetSpellProto();
7069 switch (spell
->SpellFamilyName
)
7071 case SPELLFAMILY_GENERIC
:
7089 case 49472: // Drink Coffee
7093 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
7095 // Search SPELL_AURA_MOD_POWER_REGEN aura for this spell and add bonus
7096 Unit::AuraList
const& aura
= m_target
->GetAurasByType(SPELL_AURA_MOD_POWER_REGEN
);
7097 for(Unit::AuraList::const_iterator i
= aura
.begin(); i
!= aura
.end(); ++i
)
7099 if ((*i
)->GetId() == GetId())
7101 (*i
)->GetModifier()->m_amount
= m_modifier
.m_amount
;
7102 ((Player
*)m_target
)->UpdateManaRegen();
7104 m_isPeriodic
= false;
7113 // Possibly need cast one of them (but
7114 // 7038 Forsaken Skill: Swords
7115 // 7039 Forsaken Skill: Axes
7116 // 7040 Forsaken Skill: Daggers
7117 // 7041 Forsaken Skill: Maces
7118 // 7042 Forsaken Skill: Staves
7119 // 7043 Forsaken Skill: Bows
7120 // 7044 Forsaken Skill: Guns
7121 // 7045 Forsaken Skill: 2H Axes
7122 // 7046 Forsaken Skill: 2H Maces
7123 // 7047 Forsaken Skill: 2H Swords
7124 // 7048 Forsaken Skill: Defense
7125 // 7049 Forsaken Skill: Fire
7126 // 7050 Forsaken Skill: Frost
7127 // 7051 Forsaken Skill: Holy
7128 // 7053 Forsaken Skill: Shadow
7131 case 7057: // Haunting Spirits
7132 if (roll_chance_i(33))
7133 m_target
->CastSpell(m_target
,m_modifier
.m_amount
,true,NULL
,this);
7136 // case 19230: break;
7137 // // Gossip NPC Periodic - Talk
7138 // case 33208: break;
7139 // // Gossip NPC Periodic - Despawn
7140 // case 33209: break;
7142 // case 36207: break;
7143 // // Simon Game START timer, (DND)
7144 // case 39993: break;
7145 // // Knockdown Fel Cannon: break; The Aggro Burst
7146 // case 40119: break;
7147 // // Old Mount Spell
7148 // case 40154: break;
7150 // case 40581: break;
7151 // // Ethereal Ring: break; The Bolt Burst
7152 // case 40801: break;
7153 // // Crystal Prison
7154 // case 40846: break;
7156 // case 41054: break;
7158 // case 41404: break;
7159 // // Ethereal Ring Visual, Lightning Aura
7160 // case 41477: break;
7161 // // Ethereal Ring Visual, Lightning Aura (Fork)
7162 // case 41525: break;
7163 // // Ethereal Ring Visual, Lightning Jumper Aura
7164 // case 41567: break;
7166 // case 41955: break;
7167 // // Headless Horseman - Fire
7168 // case 42074: break;
7169 // // Headless Horseman - Visual - Large Fire
7170 // case 42075: break;
7171 // // Headless Horseman - Start Fire, Periodic Aura
7172 // case 42140: break;
7173 // // Ram Speed Boost
7174 // case 42152: break;
7175 // // Headless Horseman - Fires Out Victory Aura
7176 // case 42235: break;
7177 // // Pumpkin Life Cycle
7178 // case 42280: break;
7179 // // Brewfest Request Chick Chuck Mug Aura
7180 // case 42537: break;
7182 // case 42596: break;
7183 // // Headless Horseman Climax, Head: Periodic
7184 // case 42603: break;
7186 // case 42621: break;
7187 // // Headless Horseman - Conflagrate, Periodic Aura
7188 // case 42637: break;
7189 // // Headless Horseman - Create Pumpkin Treats Aura
7190 // case 42774: break;
7191 // // Headless Horseman Climax - Summoning Rhyme Aura
7192 // case 42879: break;
7194 // case 42919: break;
7196 // case 42924: break;
7198 // case 42992: break;
7200 // case 42993: break;
7202 // case 42994: break;
7203 // // Ram Level - Neutral
7204 // case 43310: break;
7205 // // Headless Horseman - Maniacal Laugh, Maniacal, Delayed 17
7206 // case 43884: break;
7208 // case 43963: break;
7209 // // Headless Horseman - Maniacal Laugh, Maniacal, other, Delayed 17
7210 // case 44000: break;
7211 // // Energy Feedback
7212 // case 44328: break;
7213 // // Romantic Picnic
7214 // case 45102: break;
7215 // // Romantic Picnic
7216 // case 45123: break;
7217 // // Looking for Love
7218 // case 45124: break;
7219 // // Kite - Lightning Strike Kite Aura
7220 // case 45197: break;
7221 // // Rocket Chicken
7222 // case 45202: break;
7223 // // Copy Offhand Weapon
7224 // case 45205: break;
7225 // // Upper Deck - Kite - Lightning Periodic Aura
7226 // case 45207: break;
7227 // // Kite -Sky Lightning Strike Kite Aura
7228 // case 45251: break;
7229 // // Ribbon Pole Dancer Check Aura
7230 // case 45390: break;
7231 // // Holiday - Midsummer, Ribbon Pole Periodic Visual
7232 // case 45406: break;
7234 // case 45472: break;
7235 // // Alliance Flag, Extra Damage Debuff
7236 // case 45898: break;
7237 // // Horde Flag, Extra Damage Debuff
7238 // case 45899: break;
7239 // // Ahune - Summoning Rhyme Aura
7240 // case 45926: break;
7241 // // Ahune - Slippery Floor
7242 // case 45945: break;
7243 // // Ahune's Shield
7244 // case 45954: break;
7245 // // Nether Vapor Lightning
7246 // case 45960: break;
7248 // case 45996: break;
7249 case 46041: // Summon Blood Elves Periodic
7250 m_target
->CastSpell(m_target
, 46037, true, NULL
, this);
7251 m_target
->CastSpell(m_target
, roll_chance_i(50) ? 46038 : 46039, true, NULL
, this);
7252 m_target
->CastSpell(m_target
, 46040, true, NULL
, this);
7254 // // Transform Visual Missile Periodic
7255 // case 46205: break;
7256 // // Find Opening Beam End
7257 // case 46333: break;
7258 // // Ice Spear Control Aura
7259 // case 46371: break;
7260 // // Hailstone Chill
7261 // case 46458: break;
7262 // // Hailstone Chill, Internal
7263 // case 46465: break;
7264 // // Chill, Internal Shifter
7265 // case 46549: break;
7266 // // Summon Ice Spear Knockback Delayer
7267 // case 46878: break;
7268 // // Burninate Effect
7269 // case 47214: break;
7270 // // Fizzcrank Practice Parachute
7271 // case 47228: break;
7272 // // Send Mug Control Aura
7273 // case 47369: break;
7274 // // Direbrew's Disarm (precast)
7275 // case 47407: break;
7276 // // Mole Machine Port Schedule
7277 // case 47489: break;
7278 // case 47941: break; // Crystal Spike
7279 // case 48200: break; // Healer Aura
7280 case 48630: // Summon Gauntlet Mobs Periodic
7281 case 59275: // Below may need some adjustment, pattern for amount of summon and where is not verified 100% (except for odd/even tick)
7283 bool chance
= roll_chance_i(50);
7285 m_target
->CastSpell(m_target
, chance
? 48631 : 48632, true, NULL
, this);
7287 if (GetAuraTicks() % 2) // which doctor at odd tick
7288 m_target
->CastSpell(m_target
, chance
? 48636 : 48635, true, NULL
, this);
7289 else // or harponeer, at even tick
7290 m_target
->CastSpell(m_target
, chance
? 48634 : 48633, true, NULL
, this);
7294 // case 49313: break; // Proximity Mine Area Aura
7295 // // Mole Machine Portal Schedule
7296 // case 49466: break;
7297 // case 49555: break; // Corpse Explode
7298 // case 49592: break; // Temporal Rift
7299 // case 49957: break; // Cutting Laser
7300 // case 50085: break; // Slow Fall
7301 // // Listening to Music
7302 // case 50493: break;
7303 // // Love Rocket Barrage
7304 // case 50530: break;
7305 case 50789: // Summon iron dwarf (left or right)
7307 m_target
->CastSpell(m_target
, roll_chance_i(50) ? 50790 : 50791, true, NULL
, this);
7309 case 50792: // Summon iron trogg (left or right)
7311 m_target
->CastSpell(m_target
, roll_chance_i(50) ? 50793 : 50794, true, NULL
, this);
7313 case 50801: // Summon malformed ooze (left or right)
7315 m_target
->CastSpell(m_target
, roll_chance_i(50) ? 50802 : 50803, true, NULL
, this);
7317 case 50824: // Summon earthen dwarf
7318 m_target
->CastSpell(m_target
, roll_chance_i(50) ? 50825 : 50826, true, NULL
, this);
7320 case 52441: // Cool Down
7321 m_target
->CastSpell(m_target
, 52443, true);
7323 case 53520: // Carrion Beetles
7324 m_target
->CastSpell(m_target
, 53521, true, NULL
, this);
7325 m_target
->CastSpell(m_target
, 53521, true, NULL
, this);
7327 case 55592: // Clean
7330 case 0: m_target
->CastSpell(m_target
, 55731, true); break;
7331 case 1: m_target
->CastSpell(m_target
, 55738, true); break;
7332 case 2: m_target
->CastSpell(m_target
, 55739, true); break;
7335 // Exist more after, need add later
7340 if (spell
->SpellIconID
== 2983)
7342 Unit
*target
=m_target
->getVictim();
7343 if (target
&& (m_target
->GetHealth() * 100 / m_target
->GetMaxHealth() > target
->GetHealth() * 100 / target
->GetMaxHealth()))
7345 if(!m_target
->HasAura(58670))
7347 int32 basepoints
= GetBasePoints();
7348 m_target
->CastCustomSpell(m_target
, 58670, &basepoints
, 0, 0, true);
7352 m_target
->RemoveAurasDueToSpell(58670);
7355 case SPELLFAMILY_MAGE
:
7358 // if (spell->Id == 55342)
7362 case SPELLFAMILY_DRUID
:
7366 // Frenzied Regeneration
7369 // Converts up to 10 rage per second into health for $d. Each point of rage is converted into ${$m2/10}.1% of max health.
7370 // Should be manauser
7371 if (m_target
->getPowerType() != POWER_RAGE
)
7373 uint32 rage
= m_target
->GetPower(POWER_RAGE
);
7377 int32 mod
= (rage
< 100) ? rage
: 100;
7378 int32 points
= m_target
->CalculateSpellDamage(spell
, 1, spell
->EffectBasePoints
[1], m_target
);
7379 int32 regen
= m_target
->GetMaxHealth() * (mod
* points
/ 10) / 1000;
7380 m_target
->CastCustomSpell(m_target
, 22845, ®en
, NULL
, NULL
, true, NULL
, this);
7381 m_target
->SetPower(POWER_RAGE
, rage
-mod
);
7392 case SPELLFAMILY_ROGUE
:
7399 if (m_target
->hasUnitState(UNIT_STAT_STUNNED
) || m_target
->HasAuraType(SPELL_AURA_MOD_FEAR
))
7402 std::list
<Unit
*> targets
;
7405 float radius
= GetSpellMaxRange(sSpellRangeStore
.LookupEntry(spell
->rangeIndex
));
7407 CellPair
p(MaNGOS::ComputeCellPair(m_target
->GetPositionX(),m_target
->GetPositionY()));
7409 cell
.data
.Part
.reserved
= ALL_DISTRICT
;
7411 MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck
u_check(m_target
, m_target
, radius
);
7412 MaNGOS::UnitListSearcher
<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck
> checker(m_target
, targets
, u_check
);
7414 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck
>, GridTypeMapContainer
> grid_object_checker(checker
);
7415 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck
>, WorldTypeMapContainer
> world_object_checker(checker
);
7417 CellLock
<GridReadGuard
> cell_lock(cell
, p
);
7419 cell_lock
->Visit(cell_lock
, grid_object_checker
, *m_target
->GetMap(), *m_target
, radius
);
7420 cell_lock
->Visit(cell_lock
, world_object_checker
, *m_target
->GetMap(), *m_target
, radius
);
7426 std::list
<Unit
*>::const_iterator itr
= targets
.begin();
7427 std::advance(itr
, rand()%targets
.size());
7428 Unit
* target
= *itr
;
7430 m_target
->CastSpell(target
, 57840, true);
7431 m_target
->CastSpell(target
, 57841, true);
7439 case SPELLFAMILY_HUNTER
:
7442 if (spell
->SpellFamilyFlags
& UI64LIT(0x8000000000000000))
7444 m_target
->CastCustomSpell(m_target
, 53352, &m_modifier
.m_amount
, 0, 0, true, 0, this, GetCasterGUID());
7452 // Feeding Frenzy Rank 1
7454 if ( m_target
->GetHealth() * 100 < m_target
->GetMaxHealth() * 35 )
7455 m_target
->CastSpell(m_target
, 60096, true, 0, this);
7457 // Feeding Frenzy Rank 2
7459 if ( m_target
->GetHealth() * 100 < m_target
->GetMaxHealth() * 35 )
7460 m_target
->CastSpell(m_target
, 60097, true, 0, this);
7467 case SPELLFAMILY_SHAMAN
:
7470 if (spell
->Id
== 52179)
7472 // Periodic need for remove visual on stun/fear/silence lost
7473 if (!(m_target
->GetUInt32Value(UNIT_FIELD_FLAGS
)&(UNIT_FLAG_STUNNED
|UNIT_FLAG_FLEEING
|UNIT_FLAG_SILENCED
)))
7474 m_target
->RemoveAurasDueToSpell(52179);
7479 case SPELLFAMILY_DEATHKNIGHT
:
7482 if (spell
->SpellFamilyFlags
& UI64LIT(0x0000000000000020))
7484 if (Unit
*caster
= GetCaster())
7485 caster
->CastCustomSpell(m_target
, 52212, &m_modifier
.m_amount
, NULL
, NULL
, true, NULL
, this);
7489 // if (spell->SpellFamilyFlags & UI64LIT(0x0000000000001000))
7492 if (spell
->SpellFamilyFlags
& UI64LIT(0x0000400000000000))
7494 // Get 0 effect aura
7495 Aura
*slow
= m_target
->GetAura(GetId(), 0);
7498 slow
->ApplyModifier(false, true);
7499 Modifier
*mod
= slow
->GetModifier();
7500 mod
->m_amount
+= m_modifier
.m_amount
;
7501 if (mod
->m_amount
> 0) mod
->m_amount
= 0;
7502 slow
->ApplyModifier(true, true);
7507 // if (spell->SpellFamilyFlags & UI64LIT(0x0000008000000000))
7509 // Death Rune Mastery
7510 // if (spell->SpellFamilyFlags & UI64LIT(0x0000000000004000))
7513 if (spell
->SpellIconID
== 2653)
7515 // Increases your attack power by $s1 for every $s2 armor value you have.
7516 // Calculate AP bonus (from 1 efect of this spell)
7517 int32 apBonus
= m_modifier
.m_amount
* m_target
->GetArmor() / m_target
->CalculateSpellDamage(spell
, 1, spell
->EffectBasePoints
[1], m_target
);
7518 m_target
->CastCustomSpell(m_target
, 61217, &apBonus
, &apBonus
, NULL
, true, NULL
, this);
7522 // if (spell->SpellIconID == 22)
7524 // Blood of the North
7525 // if (spell->SpellIconID == 30412)
7534 void Aura::HandlePreventFleeing(bool apply
, bool Real
)
7539 Unit::AuraList
const& fearAuras
= m_target
->GetAurasByType(SPELL_AURA_MOD_FEAR
);
7540 if( !fearAuras
.empty() )
7543 m_target
->SetFeared(false, fearAuras
.front()->GetCasterGUID());
7545 m_target
->SetFeared(true);
7549 void Aura::HandleManaShield(bool apply
, bool Real
)
7554 // prevent double apply bonuses
7555 if(apply
&& (m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading()))
7557 if(Unit
* caster
= GetCaster())
7559 float DoneActualBenefit
= 0.0f
;
7560 switch(m_spellProto
->SpellFamilyName
)
7562 case SPELLFAMILY_MAGE
:
7563 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000008000))
7566 // +50% from +spd bonus
7567 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.5f
;
7575 DoneActualBenefit
*= caster
->CalculateLevelPenalty(GetSpellProto());
7577 m_modifier
.m_amount
+= (int32
)DoneActualBenefit
;
7582 void Aura::HandleArenaPreparation(bool apply
, bool Real
)
7588 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PREPARATION
);
7590 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PREPARATION
);
7594 * Such auras are applied from a caster(=player) to a vehicle.
7595 * This has been verified using spell #49256
7597 void Aura::HandleAuraControlVehicle(bool apply
, bool Real
)
7602 Unit
*player
= GetCaster();
7603 Vehicle
*vehicle
= dynamic_cast<Vehicle
*>(m_target
);
7604 if(!player
|| player
->GetTypeId() != TYPEID_PLAYER
|| !vehicle
)
7609 if(Pet
*pet
= player
->GetPet())
7610 pet
->Remove(PET_SAVE_AS_CURRENT
);
7611 ((Player
*)player
)->EnterVehicle(vehicle
);
7615 SpellEntry
const *spell
= GetSpellProto();
7617 // some SPELL_AURA_CONTROL_VEHICLE auras have a dummy effect on the player - remove them
7618 player
->RemoveAurasDueToSpell(spell
->Id
);
7620 ((Player
*)player
)->ExitVehicle(vehicle
);
7624 void Aura::HandleAuraConvertRune(bool apply
, bool Real
)
7629 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
7632 Player
*plr
= (Player
*)m_target
;
7634 if(plr
->getClass() != CLASS_DEATH_KNIGHT
)
7637 // how to determine what rune need to be converted?
7638 for(uint32 i
= 0; i
< MAX_RUNES
; ++i
)
7642 if(!plr
->GetRuneCooldown(i
))
7644 plr
->ConvertRune(i
, RuneType(GetSpellProto()->EffectMiscValueB
[m_effIndex
]));
7650 if(plr
->GetCurrentRune(i
) == RuneType(GetSpellProto()->EffectMiscValueB
[m_effIndex
]))
7652 plr
->ConvertRune(i
, plr
->GetBaseRune(i
));
7659 void Aura::HandlePhase(bool apply
, bool Real
)
7664 // always non stackable
7667 Unit::AuraList
const& phases
= m_target
->GetAurasByType(SPELL_AURA_PHASE
);
7669 m_target
->RemoveAurasDueToSpell(phases
.front()->GetId(), this);
7672 // no-phase is also phase state so same code for apply and remove
7674 // phase auras normally not expected at BG but anyway better check
7675 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
7677 // drop flag at invisible in bg
7678 if(((Player
*)m_target
)->InBattleGround())
7679 if(BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround())
7680 bg
->EventPlayerDroppedFlag((Player
*)m_target
);
7682 // GM-mode have mask 0xFFFFFFFF
7683 if(!((Player
*)m_target
)->isGameMaster())
7684 m_target
->SetPhaseMask(apply
? GetMiscValue() : PHASEMASK_NORMAL
, false);
7686 ((Player
*)m_target
)->GetSession()->SendSetPhaseShift(apply
? GetMiscValue() : PHASEMASK_NORMAL
);
7688 if(GetEffIndex()==0)
7690 SpellAreaForAreaMapBounds saBounds
= sSpellMgr
.GetSpellAreaForAuraMapBounds(GetId());
7691 if(saBounds
.first
!= saBounds
.second
)
7694 m_target
->GetZoneAndAreaId(zone
, area
);
7696 for(SpellAreaForAreaMap::const_iterator itr
= saBounds
.first
; itr
!= saBounds
.second
; ++itr
)
7698 // some auras remove at aura remove
7699 if(!itr
->second
->IsFitToRequirements((Player
*)m_target
, zone
, area
))
7700 m_target
->RemoveAurasDueToSpell(itr
->second
->spellId
);
7701 // some auras applied at aura apply
7702 else if(itr
->second
->autocast
)
7704 if( !m_target
->HasAura(itr
->second
->spellId
, 0) )
7705 m_target
->CastSpell(m_target
, itr
->second
->spellId
, true);
7712 m_target
->SetPhaseMask(apply
? GetMiscValue() : PHASEMASK_NORMAL
, false);
7714 // need triggering visibility update base at phase update of not GM invisible (other GMs anyway see in any phases)
7715 if(m_target
->GetVisibility() != VISIBILITY_OFF
)
7716 m_target
->SetVisibility(m_target
->GetVisibility());
7719 void Aura::UnregisterSingleCastAura()
7721 if (IsSingleTarget())
7723 if(Unit
* caster
= GetCaster())
7725 caster
->GetSingleCastAuras().remove(this);
7729 sLog
.outError("Couldn't find the caster of the single target aura (SpellId %u), may crash later!", GetId());
7732 m_isSingleTargetAura
= false;
7736 void Aura::HandleAuraSafeFall( bool Apply
, bool Real
)
7738 // implemented in WorldSession::HandleMovementOpcodes
7740 // only special case
7741 if(Apply
&& Real
&& GetId() == 32474 && m_target
->GetTypeId() == TYPEID_PLAYER
)
7742 ((Player
*)m_target
)->ActivateTaxiPathTo(506, GetId());
7745 bool Aura::IsCritFromAbilityAura(Unit
* caster
, uint32
& damage
)
7747 Unit::AuraList
const& auras
= caster
->GetAurasByType(SPELL_AURA_ABILITY_PERIODIC_CRIT
);
7748 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
7750 if (!(*itr
)->isAffectedOnSpell(m_spellProto
))
7752 if (!caster
->isSpellCrit(m_target
, m_spellProto
, GetSpellSchoolMask(m_spellProto
)))
7755 damage
= caster
->SpellCriticalDamageBonus(m_spellProto
, damage
, m_target
);
7761 void Aura::HandleModTargetArmorPct(bool apply
, bool Real
)
7763 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
7766 ((Player
*)m_target
)->UpdateArmorPenetration();
7769 void Aura::HandleAuraModAllCritChance(bool apply
, bool Real
)
7771 // spells required only Real aura add/remove
7775 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
7778 ((Player
*)m_target
)->HandleBaseModValue(CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
7779 ((Player
*)m_target
)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
7780 ((Player
*)m_target
)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
7782 // included in Player::UpdateSpellCritChance calculation
7783 ((Player
*)m_target
)->UpdateAllSpellCritChances();
7786 void Aura::HandleAllowOnlyAbility(bool apply
, bool Real
)
7793 m_target
->setAttackTimer(BASE_ATTACK
,m_duration
);
7794 m_target
->setAttackTimer(RANGED_ATTACK
,m_duration
);
7795 m_target
->setAttackTimer(OFF_ATTACK
,m_duration
);
7799 m_target
->resetAttackTimer(BASE_ATTACK
);
7800 m_target
->resetAttackTimer(RANGED_ATTACK
);
7801 m_target
->resetAttackTimer(OFF_ATTACK
);
7804 m_target
->UpdateDamagePhysical(BASE_ATTACK
);
7805 m_target
->UpdateDamagePhysical(RANGED_ATTACK
);
7806 m_target
->UpdateDamagePhysical(OFF_ATTACK
);