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::MeleeDamageBonusTaken and Unit::SpellBaseDamageBonusTaken
68 &Aura::HandleNoImmediateEffect
, // 15 SPELL_AURA_DAMAGE_SHIELD implemented in Unit::DealMeleeDamage
69 &Aura::HandleModStealth
, // 16 SPELL_AURA_MOD_STEALTH
70 &Aura::HandleNoImmediateEffect
, // 17 SPELL_AURA_MOD_STEALTH_DETECT implemented in Unit::isVisibleForOrDetect
71 &Aura::HandleInvisibility
, // 18 SPELL_AURA_MOD_INVISIBILITY
72 &Aura::HandleInvisibilityDetect
, // 19 SPELL_AURA_MOD_INVISIBILITY_DETECTION
73 &Aura::HandleAuraModTotalHealthPercentRegen
, // 20 SPELL_AURA_OBS_MOD_HEALTH
74 &Aura::HandleAuraModTotalManaPercentRegen
, // 21 SPELL_AURA_OBS_MOD_MANA
75 &Aura::HandleAuraModResistance
, // 22 SPELL_AURA_MOD_RESISTANCE
76 &Aura::HandlePeriodicTriggerSpell
, // 23 SPELL_AURA_PERIODIC_TRIGGER_SPELL
77 &Aura::HandlePeriodicEnergize
, // 24 SPELL_AURA_PERIODIC_ENERGIZE
78 &Aura::HandleAuraModPacify
, // 25 SPELL_AURA_MOD_PACIFY
79 &Aura::HandleAuraModRoot
, // 26 SPELL_AURA_MOD_ROOT
80 &Aura::HandleAuraModSilence
, // 27 SPELL_AURA_MOD_SILENCE
81 &Aura::HandleNoImmediateEffect
, // 28 SPELL_AURA_REFLECT_SPELLS implement in Unit::SpellHitResult
82 &Aura::HandleAuraModStat
, // 29 SPELL_AURA_MOD_STAT
83 &Aura::HandleAuraModSkill
, // 30 SPELL_AURA_MOD_SKILL
84 &Aura::HandleAuraModIncreaseSpeed
, // 31 SPELL_AURA_MOD_INCREASE_SPEED
85 &Aura::HandleAuraModIncreaseMountedSpeed
, // 32 SPELL_AURA_MOD_INCREASE_MOUNTED_SPEED
86 &Aura::HandleAuraModDecreaseSpeed
, // 33 SPELL_AURA_MOD_DECREASE_SPEED
87 &Aura::HandleAuraModIncreaseHealth
, // 34 SPELL_AURA_MOD_INCREASE_HEALTH
88 &Aura::HandleAuraModIncreaseEnergy
, // 35 SPELL_AURA_MOD_INCREASE_ENERGY
89 &Aura::HandleAuraModShapeshift
, // 36 SPELL_AURA_MOD_SHAPESHIFT
90 &Aura::HandleAuraModEffectImmunity
, // 37 SPELL_AURA_EFFECT_IMMUNITY
91 &Aura::HandleAuraModStateImmunity
, // 38 SPELL_AURA_STATE_IMMUNITY
92 &Aura::HandleAuraModSchoolImmunity
, // 39 SPELL_AURA_SCHOOL_IMMUNITY
93 &Aura::HandleAuraModDmgImmunity
, // 40 SPELL_AURA_DAMAGE_IMMUNITY
94 &Aura::HandleAuraModDispelImmunity
, // 41 SPELL_AURA_DISPEL_IMMUNITY
95 &Aura::HandleAuraProcTriggerSpell
, // 42 SPELL_AURA_PROC_TRIGGER_SPELL implemented in Unit::ProcDamageAndSpellFor and Unit::HandleProcTriggerSpell
96 &Aura::HandleNoImmediateEffect
, // 43 SPELL_AURA_PROC_TRIGGER_DAMAGE implemented in Unit::ProcDamageAndSpellFor
97 &Aura::HandleAuraTrackCreatures
, // 44 SPELL_AURA_TRACK_CREATURES
98 &Aura::HandleAuraTrackResources
, // 45 SPELL_AURA_TRACK_RESOURCES
99 &Aura::HandleUnused
, // 46 SPELL_AURA_46 (used in test spells 54054 and 54058, and spell 48050) (3.0.8a-3.2.2a)
100 &Aura::HandleAuraModParryPercent
, // 47 SPELL_AURA_MOD_PARRY_PERCENT
101 &Aura::HandleNULL
, // 48 SPELL_AURA_48 spell Napalm (area damage spell with additional delayed damage effect)
102 &Aura::HandleAuraModDodgePercent
, // 49 SPELL_AURA_MOD_DODGE_PERCENT
103 &Aura::HandleNoImmediateEffect
, // 50 SPELL_AURA_MOD_CRITICAL_HEALING_AMOUNT implemented in Unit::SpellCriticalHealingBonus
104 &Aura::HandleAuraModBlockPercent
, // 51 SPELL_AURA_MOD_BLOCK_PERCENT
105 &Aura::HandleAuraModCritPercent
, // 52 SPELL_AURA_MOD_CRIT_PERCENT
106 &Aura::HandlePeriodicLeech
, // 53 SPELL_AURA_PERIODIC_LEECH
107 &Aura::HandleModHitChance
, // 54 SPELL_AURA_MOD_HIT_CHANCE
108 &Aura::HandleModSpellHitChance
, // 55 SPELL_AURA_MOD_SPELL_HIT_CHANCE
109 &Aura::HandleAuraTransform
, // 56 SPELL_AURA_TRANSFORM
110 &Aura::HandleModSpellCritChance
, // 57 SPELL_AURA_MOD_SPELL_CRIT_CHANCE
111 &Aura::HandleAuraModIncreaseSwimSpeed
, // 58 SPELL_AURA_MOD_INCREASE_SWIM_SPEED
112 &Aura::HandleNoImmediateEffect
, // 59 SPELL_AURA_MOD_DAMAGE_DONE_CREATURE implemented in Unit::MeleeDamageBonusDone and Unit::SpellDamageBonusDone
113 &Aura::HandleAuraModPacifyAndSilence
, // 60 SPELL_AURA_MOD_PACIFY_SILENCE
114 &Aura::HandleAuraModScale
, // 61 SPELL_AURA_MOD_SCALE
115 &Aura::HandlePeriodicHealthFunnel
, // 62 SPELL_AURA_PERIODIC_HEALTH_FUNNEL
116 &Aura::HandleUnused
, // 63 unused (3.0.8a-3.2.2a) old SPELL_AURA_PERIODIC_MANA_FUNNEL
117 &Aura::HandlePeriodicManaLeech
, // 64 SPELL_AURA_PERIODIC_MANA_LEECH
118 &Aura::HandleModCastingSpeed
, // 65 SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK
119 &Aura::HandleFeignDeath
, // 66 SPELL_AURA_FEIGN_DEATH
120 &Aura::HandleAuraModDisarm
, // 67 SPELL_AURA_MOD_DISARM
121 &Aura::HandleAuraModStalked
, // 68 SPELL_AURA_MOD_STALKED
122 &Aura::HandleSchoolAbsorb
, // 69 SPELL_AURA_SCHOOL_ABSORB implemented in Unit::CalculateAbsorbAndResist
123 &Aura::HandleUnused
, // 70 SPELL_AURA_EXTRA_ATTACKS Useless, used by only one spell 41560 that has only visual effect (3.2.2a)
124 &Aura::HandleModSpellCritChanceShool
, // 71 SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL
125 &Aura::HandleModPowerCostPCT
, // 72 SPELL_AURA_MOD_POWER_COST_SCHOOL_PCT
126 &Aura::HandleModPowerCost
, // 73 SPELL_AURA_MOD_POWER_COST_SCHOOL
127 &Aura::HandleNoImmediateEffect
, // 74 SPELL_AURA_REFLECT_SPELLS_SCHOOL implemented in Unit::SpellHitResult
128 &Aura::HandleNoImmediateEffect
, // 75 SPELL_AURA_MOD_LANGUAGE implemented in WorldSession::HandleMessagechatOpcode
129 &Aura::HandleFarSight
, // 76 SPELL_AURA_FAR_SIGHT
130 &Aura::HandleModMechanicImmunity
, // 77 SPELL_AURA_MECHANIC_IMMUNITY
131 &Aura::HandleAuraMounted
, // 78 SPELL_AURA_MOUNTED
132 &Aura::HandleModDamagePercentDone
, // 79 SPELL_AURA_MOD_DAMAGE_PERCENT_DONE
133 &Aura::HandleModPercentStat
, // 80 SPELL_AURA_MOD_PERCENT_STAT
134 &Aura::HandleNoImmediateEffect
, // 81 SPELL_AURA_SPLIT_DAMAGE_PCT implemented in Unit::CalculateAbsorbAndResist
135 &Aura::HandleWaterBreathing
, // 82 SPELL_AURA_WATER_BREATHING
136 &Aura::HandleModBaseResistance
, // 83 SPELL_AURA_MOD_BASE_RESISTANCE
137 &Aura::HandleModRegen
, // 84 SPELL_AURA_MOD_REGEN
138 &Aura::HandleModPowerRegen
, // 85 SPELL_AURA_MOD_POWER_REGEN
139 &Aura::HandleChannelDeathItem
, // 86 SPELL_AURA_CHANNEL_DEATH_ITEM
140 &Aura::HandleNoImmediateEffect
, // 87 SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN implemented in Unit::MeleeDamageBonusTaken and Unit::SpellDamageBonusTaken
141 &Aura::HandleNoImmediateEffect
, // 88 SPELL_AURA_MOD_HEALTH_REGEN_PERCENT implemented in Player::RegenerateHealth
142 &Aura::HandlePeriodicDamagePCT
, // 89 SPELL_AURA_PERIODIC_DAMAGE_PERCENT
143 &Aura::HandleUnused
, // 90 unused (3.0.8a-3.2.2a) old SPELL_AURA_MOD_RESIST_CHANCE
144 &Aura::HandleNoImmediateEffect
, // 91 SPELL_AURA_MOD_DETECT_RANGE implemented in Creature::GetAttackDistance
145 &Aura::HandlePreventFleeing
, // 92 SPELL_AURA_PREVENTS_FLEEING
146 &Aura::HandleModUnattackable
, // 93 SPELL_AURA_MOD_UNATTACKABLE
147 &Aura::HandleNoImmediateEffect
, // 94 SPELL_AURA_INTERRUPT_REGEN implemented in Player::RegenerateAll
148 &Aura::HandleAuraGhost
, // 95 SPELL_AURA_GHOST
149 &Aura::HandleNoImmediateEffect
, // 96 SPELL_AURA_SPELL_MAGNET implemented in Unit::SelectMagnetTarget
150 &Aura::HandleManaShield
, // 97 SPELL_AURA_MANA_SHIELD implemented in Unit::CalculateAbsorbAndResist
151 &Aura::HandleAuraModSkill
, // 98 SPELL_AURA_MOD_SKILL_TALENT
152 &Aura::HandleAuraModAttackPower
, // 99 SPELL_AURA_MOD_ATTACK_POWER
153 &Aura::HandleUnused
, //100 SPELL_AURA_AURAS_VISIBLE obsolete 3.x? all player can see all auras now, but still have 2 spells including GM-spell (1852,2855)
154 &Aura::HandleModResistancePercent
, //101 SPELL_AURA_MOD_RESISTANCE_PCT
155 &Aura::HandleNoImmediateEffect
, //102 SPELL_AURA_MOD_MELEE_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonusDone
156 &Aura::HandleAuraModTotalThreat
, //103 SPELL_AURA_MOD_TOTAL_THREAT
157 &Aura::HandleAuraWaterWalk
, //104 SPELL_AURA_WATER_WALK
158 &Aura::HandleAuraFeatherFall
, //105 SPELL_AURA_FEATHER_FALL
159 &Aura::HandleAuraHover
, //106 SPELL_AURA_HOVER
160 &Aura::HandleAddModifier
, //107 SPELL_AURA_ADD_FLAT_MODIFIER
161 &Aura::HandleAddModifier
, //108 SPELL_AURA_ADD_PCT_MODIFIER
162 &Aura::HandleNoImmediateEffect
, //109 SPELL_AURA_ADD_TARGET_TRIGGER
163 &Aura::HandleModPowerRegenPCT
, //110 SPELL_AURA_MOD_POWER_REGEN_PERCENT
164 &Aura::HandleNoImmediateEffect
, //111 SPELL_AURA_ADD_CASTER_HIT_TRIGGER implemented in Unit::SelectMagnetTarget
165 &Aura::HandleNoImmediateEffect
, //112 SPELL_AURA_OVERRIDE_CLASS_SCRIPTS implemented in diff functions.
166 &Aura::HandleNoImmediateEffect
, //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonusTaken
167 &Aura::HandleNoImmediateEffect
, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonusTaken
168 &Aura::HandleNoImmediateEffect
, //115 SPELL_AURA_MOD_HEALING implemented in Unit::SpellBaseHealingBonusTaken
169 &Aura::HandleNoImmediateEffect
, //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT imppemented in Player::RegenerateAll and Player::RegenerateHealth
170 &Aura::HandleNoImmediateEffect
, //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE implemented in Unit::MagicSpellHitResult
171 &Aura::HandleNoImmediateEffect
, //118 SPELL_AURA_MOD_HEALING_PCT implemented in Unit::SpellHealingBonusTaken
172 &Aura::HandleUnused
, //119 unused (3.0.8a-3.2.2a) old SPELL_AURA_SHARE_PET_TRACKING
173 &Aura::HandleAuraUntrackable
, //120 SPELL_AURA_UNTRACKABLE
174 &Aura::HandleAuraEmpathy
, //121 SPELL_AURA_EMPATHY
175 &Aura::HandleModOffhandDamagePercent
, //122 SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT
176 &Aura::HandleModTargetResistance
, //123 SPELL_AURA_MOD_TARGET_RESISTANCE
177 &Aura::HandleAuraModRangedAttackPower
, //124 SPELL_AURA_MOD_RANGED_ATTACK_POWER
178 &Aura::HandleNoImmediateEffect
, //125 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonusTaken
179 &Aura::HandleNoImmediateEffect
, //126 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonusTaken
180 &Aura::HandleNoImmediateEffect
, //127 SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonusDone
181 &Aura::HandleModPossessPet
, //128 SPELL_AURA_MOD_POSSESS_PET
182 &Aura::HandleAuraModIncreaseSpeed
, //129 SPELL_AURA_MOD_SPEED_ALWAYS
183 &Aura::HandleAuraModIncreaseMountedSpeed
, //130 SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS
184 &Aura::HandleNoImmediateEffect
, //131 SPELL_AURA_MOD_RANGED_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonusDone
185 &Aura::HandleAuraModIncreaseEnergyPercent
, //132 SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT
186 &Aura::HandleAuraModIncreaseHealthPercent
, //133 SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT
187 &Aura::HandleAuraModRegenInterrupt
, //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT
188 &Aura::HandleModHealingDone
, //135 SPELL_AURA_MOD_HEALING_DONE
189 &Aura::HandleNoImmediateEffect
, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonusDone
190 &Aura::HandleModTotalPercentStat
, //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
191 &Aura::HandleHaste
, //138 SPELL_AURA_MOD_HASTE
192 &Aura::HandleForceReaction
, //139 SPELL_AURA_FORCE_REACTION
193 &Aura::HandleAuraModRangedHaste
, //140 SPELL_AURA_MOD_RANGED_HASTE
194 &Aura::HandleRangedAmmoHaste
, //141 SPELL_AURA_MOD_RANGED_AMMO_HASTE
195 &Aura::HandleAuraModBaseResistancePCT
, //142 SPELL_AURA_MOD_BASE_RESISTANCE_PCT
196 &Aura::HandleAuraModResistanceExclusive
, //143 SPELL_AURA_MOD_RESISTANCE_EXCLUSIVE
197 &Aura::HandleAuraSafeFall
, //144 SPELL_AURA_SAFE_FALL implemented in WorldSession::HandleMovementOpcodes
198 &Aura::HandleAuraModPetTalentsPoints
, //145 SPELL_AURA_MOD_PET_TALENT_POINTS
199 &Aura::HandleNoImmediateEffect
, //146 SPELL_AURA_ALLOW_TAME_PET_TYPE implemented in Player::CanTameExoticPets
200 &Aura::HandleModMechanicImmunityMask
, //147 SPELL_AURA_MECHANIC_IMMUNITY_MASK implemented in Unit::IsImmunedToSpell and Unit::IsImmunedToSpellEffect (check part)
201 &Aura::HandleAuraRetainComboPoints
, //148 SPELL_AURA_RETAIN_COMBO_POINTS
202 &Aura::HandleNoImmediateEffect
, //149 SPELL_AURA_REDUCE_PUSHBACK implemented in Spell::Delayed and Spell::DelayedChannel
203 &Aura::HandleShieldBlockValue
, //150 SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT
204 &Aura::HandleAuraTrackStealthed
, //151 SPELL_AURA_TRACK_STEALTHED
205 &Aura::HandleNoImmediateEffect
, //152 SPELL_AURA_MOD_DETECTED_RANGE implemented in Creature::GetAttackDistance
206 &Aura::HandleNoImmediateEffect
, //153 SPELL_AURA_SPLIT_DAMAGE_FLAT implemented in Unit::CalculateAbsorbAndResist
207 &Aura::HandleNoImmediateEffect
, //154 SPELL_AURA_MOD_STEALTH_LEVEL implemented in Unit::isVisibleForOrDetect
208 &Aura::HandleNoImmediateEffect
, //155 SPELL_AURA_MOD_WATER_BREATHING implemented in Player::getMaxTimer
209 &Aura::HandleNoImmediateEffect
, //156 SPELL_AURA_MOD_REPUTATION_GAIN implemented in Player::CalculateReputationGain
210 &Aura::HandleUnused
, //157 SPELL_AURA_PET_DAMAGE_MULTI (single test like spell 20782, also single for 214 aura)
211 &Aura::HandleShieldBlockValue
, //158 SPELL_AURA_MOD_SHIELD_BLOCKVALUE
212 &Aura::HandleNoImmediateEffect
, //159 SPELL_AURA_NO_PVP_CREDIT implemented in Player::RewardHonor
213 &Aura::HandleNoImmediateEffect
, //160 SPELL_AURA_MOD_AOE_AVOIDANCE implemented in Unit::MagicSpellHitResult
214 &Aura::HandleNoImmediateEffect
, //161 SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT implemented in Player::RegenerateAll and Player::RegenerateHealth
215 &Aura::HandleAuraPowerBurn
, //162 SPELL_AURA_POWER_BURN_MANA
216 &Aura::HandleNoImmediateEffect
, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS implemented in Unit::CalculateMeleeDamage and Unit::SpellCriticalDamageBonus
217 &Aura::HandleUnused
, //164 unused (3.0.8a-3.2.2a), only one test spell 10654
218 &Aura::HandleNoImmediateEffect
, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonusDone
219 &Aura::HandleAuraModAttackPowerPercent
, //166 SPELL_AURA_MOD_ATTACK_POWER_PCT
220 &Aura::HandleAuraModRangedAttackPowerPercent
, //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT
221 &Aura::HandleNoImmediateEffect
, //168 SPELL_AURA_MOD_DAMAGE_DONE_VERSUS implemented in Unit::SpellDamageBonusDone, Unit::MeleeDamageBonusDone
222 &Aura::HandleNoImmediateEffect
, //169 SPELL_AURA_MOD_CRIT_PERCENT_VERSUS implemented in Unit::DealDamageBySchool, Unit::DoAttackDamage, Unit::SpellCriticalBonus
223 &Aura::HandleNULL
, //170 SPELL_AURA_DETECT_AMORE different spells that ignore transformation effects
224 &Aura::HandleAuraModIncreaseSpeed
, //171 SPELL_AURA_MOD_SPEED_NOT_STACK
225 &Aura::HandleAuraModIncreaseMountedSpeed
, //172 SPELL_AURA_MOD_MOUNTED_SPEED_NOT_STACK
226 &Aura::HandleUnused
, //173 unused (3.0.8a-3.2.2a) no spells, old SPELL_AURA_ALLOW_CHAMPION_SPELLS only for Proclaim Champion spell
227 &Aura::HandleModSpellDamagePercentFromStat
, //174 SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT implemented in Unit::SpellBaseDamageBonusDone
228 &Aura::HandleModSpellHealingPercentFromStat
, //175 SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT implemented in Unit::SpellBaseHealingBonusDone
229 &Aura::HandleSpiritOfRedemption
, //176 SPELL_AURA_SPIRIT_OF_REDEMPTION only for Spirit of Redemption spell, die at aura end
230 &Aura::HandleNULL
, //177 SPELL_AURA_AOE_CHARM (22 spells)
231 &Aura::HandleNoImmediateEffect
, //178 SPELL_AURA_MOD_DEBUFF_RESISTANCE implemented in Unit::MagicSpellHitResult
232 &Aura::HandleNoImmediateEffect
, //179 SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE implemented in Unit::SpellCriticalBonus
233 &Aura::HandleNoImmediateEffect
, //180 SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS implemented in Unit::SpellDamageBonusDone
234 &Aura::HandleUnused
, //181 unused (3.0.8a-3.2.2a) old SPELL_AURA_MOD_FLAT_SPELL_CRIT_DAMAGE_VERSUS
235 &Aura::HandleAuraModResistenceOfStatPercent
, //182 SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT
236 &Aura::HandleNoImmediateEffect
, //183 SPELL_AURA_MOD_CRITICAL_THREAT only used in 28746, implemented in ThreatCalcHelper::calcThreat
237 &Aura::HandleNoImmediateEffect
, //184 SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
238 &Aura::HandleNoImmediateEffect
, //185 SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
239 &Aura::HandleNoImmediateEffect
, //186 SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE implemented in Unit::MagicSpellHitResult
240 &Aura::HandleNoImmediateEffect
, //187 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance
241 &Aura::HandleNoImmediateEffect
, //188 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance
242 &Aura::HandleModRating
, //189 SPELL_AURA_MOD_RATING
243 &Aura::HandleNoImmediateEffect
, //190 SPELL_AURA_MOD_FACTION_REPUTATION_GAIN implemented in Player::CalculateReputationGain
244 &Aura::HandleAuraModUseNormalSpeed
, //191 SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED
245 &Aura::HandleModMeleeRangedSpeedPct
, //192 SPELL_AURA_HASTE_MELEE
246 &Aura::HandleModCombatSpeedPct
, //193 SPELL_AURA_HASTE_ALL (in fact combat (any type attack) speed pct)
247 &Aura::HandleNoImmediateEffect
, //194 SPELL_AURA_MOD_IGNORE_ABSORB_SCHOOL implement in Unit::CalcNotIgnoreAbsorbDamage
248 &Aura::HandleNoImmediateEffect
, //195 SPELL_AURA_MOD_IGNORE_ABSORB_FOR_SPELL implement in Unit::CalcNotIgnoreAbsorbDamage
249 &Aura::HandleNULL
, //196 SPELL_AURA_MOD_COOLDOWN (single spell 24818 in 3.2.2a)
250 &Aura::HandleNoImmediateEffect
, //197 SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE implemented in Unit::SpellCriticalBonus Unit::GetUnitCriticalChance
251 &Aura::HandleUnused
, //198 unused (3.0.8a-3.2.2a) old SPELL_AURA_MOD_ALL_WEAPON_SKILLS
252 &Aura::HandleNoImmediateEffect
, //199 SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT implemented in Unit::MagicSpellHitResult
253 &Aura::HandleNoImmediateEffect
, //200 SPELL_AURA_MOD_KILL_XP_PCT implemented in Player::GiveXP
254 &Aura::HandleAuraAllowFlight
, //201 SPELL_AURA_FLY this aura enable flight mode...
255 &Aura::HandleNoImmediateEffect
, //202 SPELL_AURA_CANNOT_BE_DODGED implemented in Unit::RollPhysicalOutcomeAgainst
256 &Aura::HandleNoImmediateEffect
, //203 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE implemented in Unit::CalculateMeleeDamage and Unit::SpellCriticalDamageBonus
257 &Aura::HandleNoImmediateEffect
, //204 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE implemented in Unit::CalculateMeleeDamage and Unit::SpellCriticalDamageBonus
258 &Aura::HandleNoImmediateEffect
, //205 SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_DAMAGE implemented in Unit::SpellCriticalDamageBonus
259 &Aura::HandleAuraModIncreaseFlightSpeed
, //206 SPELL_AURA_MOD_FLIGHT_SPEED
260 &Aura::HandleAuraModIncreaseFlightSpeed
, //207 SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED
261 &Aura::HandleAuraModIncreaseFlightSpeed
, //208 SPELL_AURA_MOD_FLIGHT_SPEED_STACKING
262 &Aura::HandleAuraModIncreaseFlightSpeed
, //209 SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED_STACKING
263 &Aura::HandleAuraModIncreaseFlightSpeed
, //210 SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACKING
264 &Aura::HandleAuraModIncreaseFlightSpeed
, //211 SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED_NOT_STACKING
265 &Aura::HandleAuraModRangedAttackPowerOfStatPercent
, //212 SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT
266 &Aura::HandleNoImmediateEffect
, //213 SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT implemented in Player::RewardRage
267 &Aura::HandleUnused
, //214 Tamed Pet Passive (single test like spell 20782, also single for 157 aura)
268 &Aura::HandleArenaPreparation
, //215 SPELL_AURA_ARENA_PREPARATION
269 &Aura::HandleModCastingSpeed
, //216 SPELL_AURA_HASTE_SPELLS
270 &Aura::HandleUnused
, //217 unused (3.0.8a-3.2.2a)
271 &Aura::HandleAuraModRangedHaste
, //218 SPELL_AURA_HASTE_RANGED
272 &Aura::HandleModManaRegen
, //219 SPELL_AURA_MOD_MANA_REGEN_FROM_STAT
273 &Aura::HandleModRatingFromStat
, //220 SPELL_AURA_MOD_RATING_FROM_STAT
274 &Aura::HandleNULL
, //221 ignored
275 &Aura::HandleUnused
, //222 unused (3.0.8a-3.2.2a) only for spell 44586 that not used in real spell cast
276 &Aura::HandleNULL
, //223 dummy code (cast damage spell to attacker) and another dymmy (jump to another nearby raid member)
277 &Aura::HandleUnused
, //224 unused (3.0.8a-3.2.2a)
278 &Aura::HandleNoImmediateEffect
, //225 SPELL_AURA_PRAYER_OF_MENDING
279 &Aura::HandleAuraPeriodicDummy
, //226 SPELL_AURA_PERIODIC_DUMMY
280 &Aura::HandlePeriodicTriggerSpellWithValue
, //227 SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
281 &Aura::HandleNoImmediateEffect
, //228 SPELL_AURA_DETECT_STEALTH
282 &Aura::HandleNoImmediateEffect
, //229 SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE implemented in Unit::SpellDamageBonusTaken
283 &Aura::HandleAuraModIncreaseMaxHealth
, //230 Commanding Shout
284 &Aura::HandleNoImmediateEffect
, //231 SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE
285 &Aura::HandleNoImmediateEffect
, //232 SPELL_AURA_MECHANIC_DURATION_MOD implement in Unit::CalculateSpellDuration
286 &Aura::HandleNULL
, //233 set model id to the one of the creature with id m_modifier.m_miscvalue
287 &Aura::HandleNoImmediateEffect
, //234 SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK implement in Unit::CalculateSpellDuration
288 &Aura::HandleAuraModDispelResist
, //235 SPELL_AURA_MOD_DISPEL_RESIST implement in Unit::MagicSpellHitResult
289 &Aura::HandleAuraControlVehicle
, //236 SPELL_AURA_CONTROL_VEHICLE
290 &Aura::HandleModSpellDamagePercentFromAttackPower
, //237 SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER implemented in Unit::SpellBaseDamageBonusDone
291 &Aura::HandleModSpellHealingPercentFromAttackPower
, //238 SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER implemented in Unit::SpellBaseHealingBonusDone
292 &Aura::HandleAuraModScale
, //239 SPELL_AURA_MOD_SCALE_2 only in Noggenfogger Elixir (16595) before 2.3.0 aura 61
293 &Aura::HandleAuraModExpertise
, //240 SPELL_AURA_MOD_EXPERTISE
294 &Aura::HandleForceMoveForward
, //241 Forces the player to move forward
295 &Aura::HandleUnused
, //242 SPELL_AURA_MOD_SPELL_DAMAGE_FROM_HEALING (only 2 test spels in 3.2.2a)
296 &Aura::HandleNULL
, //243 faction reaction override spells
297 &Aura::HandleComprehendLanguage
, //244 SPELL_AURA_COMPREHEND_LANGUAGE
298 &Aura::HandleNoImmediateEffect
, //245 SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS implemented in Unit::CalculateSpellDuration
299 &Aura::HandleNoImmediateEffect
, //246 SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL implemented in Unit::CalculateSpellDuration
300 &Aura::HandleNULL
, //247 target to become a clone of the caster
301 &Aura::HandleNoImmediateEffect
, //248 SPELL_AURA_MOD_COMBAT_RESULT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
302 &Aura::HandleAuraConvertRune
, //249 SPELL_AURA_CONVERT_RUNE
303 &Aura::HandleAuraModIncreaseHealth
, //250 SPELL_AURA_MOD_INCREASE_HEALTH_2
304 &Aura::HandleNULL
, //251 SPELL_AURA_MOD_ENEMY_DODGE
305 &Aura::HandleModCombatSpeedPct
, //252 SPELL_AURA_SLOW_ALL
306 &Aura::HandleNoImmediateEffect
, //253 SPELL_AURA_MOD_BLOCK_CRIT_CHANCE implemented in Unit::CalculateMeleeDamage
307 &Aura::HandleNULL
, //254 SPELL_AURA_MOD_DISARM_SHIELD disarm Shield
308 &Aura::HandleNoImmediateEffect
, //255 SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT implemented in Unit::SpellDamageBonusTaken
309 &Aura::HandleNoReagentUseAura
, //256 SPELL_AURA_NO_REAGENT_USE Use SpellClassMask for spell select
310 &Aura::HandleNULL
, //257 SPELL_AURA_MOD_TARGET_RESIST_BY_SPELL_CLASS Use SpellClassMask for spell select
311 &Aura::HandleNULL
, //258 SPELL_AURA_MOD_SPELL_VISUAL
312 &Aura::HandleNULL
, //259 corrupt healing over time spell
313 &Aura::HandleNoImmediateEffect
, //260 SPELL_AURA_SCREEN_EFFECT (miscvalue = id in ScreenEffect.dbc) not required any code
314 &Aura::HandlePhase
, //261 SPELL_AURA_PHASE undetectable invisibility? implemented in Unit::isVisibleForOrDetect
315 &Aura::HandleNULL
, //262 ignore combat/aura state?
316 &Aura::HandleAllowOnlyAbility
, //263 SPELL_AURA_ALLOW_ONLY_ABILITY player can use only abilities set in SpellClassMask
317 &Aura::HandleUnused
, //264 unused (3.0.8a-3.2.2a)
318 &Aura::HandleUnused
, //265 unused (3.0.8a-3.2.2a)
319 &Aura::HandleUnused
, //266 unused (3.0.8a-3.2.2a)
320 &Aura::HandleNoImmediateEffect
, //267 SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL implemented in Unit::IsImmunedToSpellEffect
321 &Aura::HandleAuraModAttackPowerOfStatPercent
, //268 SPELL_AURA_MOD_ATTACK_POWER_OF_STAT_PERCENT
322 &Aura::HandleNoImmediateEffect
, //269 SPELL_AURA_MOD_IGNORE_DAMAGE_REDUCTION_SCHOOL implemented in Unit::CalcNotIgnoreDamageRedunction
323 &Aura::HandleUnused
, //270 SPELL_AURA_MOD_IGNORE_TARGET_RESIST (unused in 3.2.2a)
324 &Aura::HandleNoImmediateEffect
, //271 SPELL_AURA_MOD_DAMAGE_FROM_CASTER implemented in Unit::SpellDamageBonusTaken
325 &Aura::HandleNoImmediateEffect
, //272 SPELL_AURA_MAELSTROM_WEAPON (unclear use for aura, it used in (3.2.2a...3.3.0) in single spell 53817 that spellmode stacked and charged spell expected to be drop as stack
326 &Aura::HandleNoImmediateEffect
, //273 SPELL_AURA_X_RAY (client side implementation)
327 &Aura::HandleNULL
, //274 proc free shot?
328 &Aura::HandleNoImmediateEffect
, //275 SPELL_AURA_MOD_IGNORE_SHAPESHIFT Use SpellClassMask for spell select
329 &Aura::HandleNULL
, //276 mod damage % mechanic?
330 &Aura::HandleNoImmediateEffect
, //277 SPELL_AURA_MOD_MAX_AFFECTED_TARGETS Use SpellClassMask for spell select
331 &Aura::HandleNULL
, //278 SPELL_AURA_MOD_DISARM_RANGED disarm ranged weapon
332 &Aura::HandleNULL
, //279 visual effects? 58836 and 57507
333 &Aura::HandleModTargetArmorPct
, //280 SPELL_AURA_MOD_TARGET_ARMOR_PCT
334 &Aura::HandleNoImmediateEffect
, //281 SPELL_AURA_MOD_HONOR_GAIN implemented in Player::RewardHonor
335 &Aura::HandleAuraIncreaseBaseHealthPercent
, //282 SPELL_AURA_INCREASE_BASE_HEALTH_PERCENT
336 &Aura::HandleNoImmediateEffect
, //283 SPELL_AURA_MOD_HEALING_RECEIVED implemented in Unit::SpellHealingBonusTaken
337 &Aura::HandleNULL
, //284 51 spells
338 &Aura::HandleAuraModAttackPowerOfArmor
, //285 SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR implemented in Player::UpdateAttackPowerAndDamage
339 &Aura::HandleNoImmediateEffect
, //286 SPELL_AURA_ABILITY_PERIODIC_CRIT implemented in Aura::IsCritFromAbilityAura called from Aura::PeriodicTick
340 &Aura::HandleNoImmediateEffect
, //287 SPELL_AURA_DEFLECT_SPELLS implemented in Unit::MagicSpellHitResult and Unit::MeleeSpellHitResult
341 &Aura::HandleNULL
, //288 increase parry/deflect, prevent attack (single spell used 67801)
342 &Aura::HandleUnused
, //289 unused (3.2.2a)
343 &Aura::HandleAuraModAllCritChance
, //290 SPELL_AURA_MOD_ALL_CRIT_CHANCE
344 &Aura::HandleNoImmediateEffect
, //291 SPELL_AURA_MOD_QUEST_XP_PCT implemented in Player::GiveXP
345 &Aura::HandleNULL
, //292 call stabled pet
346 &Aura::HandleNULL
, //293 3 spells
347 &Aura::HandleNULL
, //294 2 spells, possible prevent mana regen
348 &Aura::HandleUnused
, //295 unused (3.2.2a)
349 &Aura::HandleNULL
, //296 2 spells
350 &Aura::HandleNULL
, //297 1 spell (counter spell school?)
351 &Aura::HandleUnused
, //298 unused (3.2.2a)
352 &Aura::HandleUnused
, //299 unused (3.2.2a)
353 &Aura::HandleNULL
, //300 3 spells (share damage?)
354 &Aura::HandleNULL
, //301 5 spells
355 &Aura::HandleUnused
, //302 unused (3.2.2a)
356 &Aura::HandleNULL
, //303 17 spells
357 &Aura::HandleNULL
, //304 2 spells (alcohol effect?)
358 &Aura::HandleAuraModIncreaseSpeed
, //305 SPELL_AURA_MOD_MINIMUM_SPEED
359 &Aura::HandleNULL
, //306 1 spell
360 &Aura::HandleNULL
, //307 absorb healing?
361 &Aura::HandleNULL
, //308 new aura for hunter traps
362 &Aura::HandleNULL
, //309 absorb healing?
363 &Aura::HandleNULL
, //310 pet avoidance passive?
364 &Aura::HandleNULL
, //311 0 spells in 3.3
365 &Aura::HandleNULL
, //312 0 spells in 3.3
366 &Aura::HandleNULL
, //313 0 spells in 3.3
367 &Aura::HandleNULL
, //314 1 test spell (reduce duration of silince/magic)
368 &Aura::HandleNULL
, //315 underwater walking
369 &Aura::HandleNULL
//316 makes haste affect HOT/DOT ticks
372 static AuraType
const frozenAuraTypes
[] = { SPELL_AURA_MOD_ROOT
, SPELL_AURA_MOD_STUN
, SPELL_AURA_NONE
};
374 Aura::Aura(SpellEntry
const* spellproto
, SpellEffectIndex eff
, int32
*currentBasePoints
, Unit
*target
, Unit
*caster
, Item
* castItem
) :
375 m_spellmod(NULL
), m_caster_guid(0), m_target(target
), m_castItemGuid(castItem
?castItem
->GetGUID():0),
376 m_timeCla(1000), m_periodicTimer(0), m_periodicTick(0), m_removeMode(AURA_REMOVE_BY_DEFAULT
), m_AuraDRGroup(DIMINISHING_NONE
),
377 m_effIndex(eff
), m_auraSlot(MAX_AURAS
), m_auraFlags(AFLAG_NONE
), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),
378 m_positive(false), m_permanent(false), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false),
379 m_isRemovedOnShapeLost(true), m_in_use(0), m_deleted(false)
383 ASSERT(spellproto
&& spellproto
== sSpellStore
.LookupEntry( spellproto
->Id
) && "`info` must be pointer to sSpellStore element");
385 m_spellProto
= spellproto
;
387 m_currentBasePoints
= currentBasePoints
? *currentBasePoints
: m_spellProto
->CalculateSimpleValue(eff
);
389 m_isPassive
= IsPassiveSpell(GetId());
390 m_positive
= IsPositiveEffect(GetId(), m_effIndex
);
392 m_isSingleTargetAura
= IsSingleTargetSpell(m_spellProto
);
394 m_applyTime
= time(NULL
);
399 m_caster_guid
= target
->GetGUID();
400 damage
= m_currentBasePoints
;
401 m_maxduration
= target
->CalculateSpellDuration(m_spellProto
, m_effIndex
, target
);
405 m_caster_guid
= caster
->GetGUID();
407 damage
= caster
->CalculateSpellDamage(target
, m_spellProto
, m_effIndex
, &m_currentBasePoints
);
408 m_maxduration
= caster
->CalculateSpellDuration(m_spellProto
, m_effIndex
, target
);
410 if (!damage
&& castItem
&& castItem
->GetItemSuffixFactor())
412 ItemRandomSuffixEntry
const *item_rand_suffix
= sItemRandomSuffixStore
.LookupEntry(abs(castItem
->GetItemRandomPropertyId()));
415 for (int k
= 0; k
< 3; ++k
)
417 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(item_rand_suffix
->enchant_id
[k
]);
420 for (int t
= 0; t
< 3; ++t
)
421 if(pEnchant
->spellid
[t
] == m_spellProto
->Id
)
423 damage
= uint32((item_rand_suffix
->prefix
[k
]*castItem
->GetItemSuffixFactor()) / 10000 );
435 if(m_maxduration
== -1 || m_isPassive
&& m_spellProto
->DurationIndex
== 0)
438 Player
* modOwner
= caster
? caster
->GetSpellModOwner() : NULL
;
440 if(!m_permanent
&& modOwner
)
442 modOwner
->ApplySpellMod(GetId(), SPELLMOD_DURATION
, m_maxduration
);
443 // Get zero duration aura after - need set m_maxduration > 0 for apply/remove aura work
444 if (m_maxduration
<=0)
448 m_duration
= m_maxduration
;
450 DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST
, "Aura: construct Spellid : %u, Aura : %u Duration : %d Target : %d Damage : %d", m_spellProto
->Id
, m_spellProto
->EffectApplyAuraName
[eff
], m_maxduration
, m_spellProto
->EffectImplicitTargetA
[eff
],damage
);
452 SetModifier(AuraType(m_spellProto
->EffectApplyAuraName
[eff
]), damage
, m_spellProto
->EffectAmplitude
[eff
], m_spellProto
->EffectMiscValue
[eff
]);
454 // Apply periodic time mod
455 if(modOwner
&& m_modifier
.periodictime
)
456 modOwner
->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME
, m_modifier
.periodictime
);
458 // Start periodic on next tick or at aura apply
459 if (!(m_spellProto
->AttributesEx5
& SPELL_ATTR_EX5_START_PERIODIC_AT_APPLY
))
460 m_periodicTimer
+= m_modifier
.periodictime
;
462 m_isDeathPersist
= IsDeathPersistentSpell(m_spellProto
);
464 m_procCharges
= m_spellProto
->procCharges
;
466 modOwner
->ApplySpellMod(GetId(), SPELLMOD_CHARGES
, m_procCharges
);
468 m_isRemovedOnShapeLost
= (m_caster_guid
==m_target
->GetGUID() &&
469 m_spellProto
->Stances
&&
470 !(m_spellProto
->AttributesEx2
& SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT
) &&
471 !(m_spellProto
->Attributes
& SPELL_ATTR_NOT_SHAPESHIFT
));
473 if (caster
&& m_spellProto
->Id
== 22959) // Improved Scorch
475 // Glyph of Improved Scorch
476 if (Aura
* glyph
= caster
->GetDummyAura(56371))
477 m_stackAmount
= glyph
->GetModifier()->m_amount
;
485 AreaAura::AreaAura(SpellEntry
const* spellproto
, SpellEffectIndex eff
, int32
*currentBasePoints
, Unit
*target
,
486 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
490 // caster==NULL in constructor args if target==caster in fact
491 Unit
* caster_ptr
= caster
? caster
: target
;
493 m_radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(GetSpellProto()->EffectRadiusIndex
[m_effIndex
]));
494 if(Player
* modOwner
= caster_ptr
->GetSpellModOwner())
495 modOwner
->ApplySpellMod(GetId(), SPELLMOD_RADIUS
, m_radius
);
497 switch(spellproto
->Effect
[eff
])
499 case SPELL_EFFECT_APPLY_AREA_AURA_PARTY
:
500 m_areaAuraType
= AREA_AURA_PARTY
;
501 if (target
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)target
)->isTotem())
502 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
504 case SPELL_EFFECT_APPLY_AREA_AURA_RAID
:
505 m_areaAuraType
= AREA_AURA_RAID
;
506 if (target
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)target
)->isTotem())
507 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
508 // Light's Beacon not applied to caster itself (TODO: more generic check for another simialr spell if any?)
509 else if (target
== caster_ptr
&& m_spellProto
->Id
== 53651)
510 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
512 case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
:
513 m_areaAuraType
= AREA_AURA_FRIEND
;
515 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
:
516 m_areaAuraType
= AREA_AURA_ENEMY
;
517 if (target
== caster_ptr
)
518 m_modifier
.m_auraname
= SPELL_AURA_NONE
; // Do not do any effect on self
520 case SPELL_EFFECT_APPLY_AREA_AURA_PET
:
521 m_areaAuraType
= AREA_AURA_PET
;
523 case SPELL_EFFECT_APPLY_AREA_AURA_OWNER
:
524 m_areaAuraType
= AREA_AURA_OWNER
;
525 if (target
== caster_ptr
)
526 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
529 sLog
.outError("Wrong spell effect in AreaAura constructor");
535 AreaAura::~AreaAura()
539 PersistentAreaAura::PersistentAreaAura(SpellEntry
const* spellproto
, SpellEffectIndex eff
, int32
*currentBasePoints
, Unit
*target
,
540 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
542 m_isPersistent
= true;
545 PersistentAreaAura::~PersistentAreaAura()
549 SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry
const* spellproto
, SpellEffectIndex eff
, int32
*currentBasePoints
, Unit
*target
,
550 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
553 m_casters_target_guid
= caster
->GetTypeId()==TYPEID_PLAYER
? ((Player
*)caster
)->GetSelection() : caster
->GetTargetGUID();
555 m_casters_target_guid
= 0;
558 SingleEnemyTargetAura::~SingleEnemyTargetAura()
562 Unit
* SingleEnemyTargetAura::GetTriggerTarget() const
564 return ObjectAccessor::GetUnit(*m_target
, m_casters_target_guid
);
567 Aura
* CreateAura(SpellEntry
const* spellproto
, SpellEffectIndex eff
, int32
*currentBasePoints
, Unit
*target
, Unit
*caster
, Item
* castItem
)
569 if (IsAreaAuraEffect(spellproto
->Effect
[eff
]))
570 return new AreaAura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
572 uint32 triggeredSpellId
= spellproto
->EffectTriggerSpell
[eff
];
574 if(SpellEntry
const* triggeredSpellInfo
= sSpellStore
.LookupEntry(triggeredSpellId
))
575 for (int i
= 0; i
< MAX_EFFECT_INDEX
; ++i
)
576 if (triggeredSpellInfo
->EffectImplicitTargetA
[i
] == TARGET_SINGLE_ENEMY
)
577 return new SingleEnemyTargetAura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
579 return new Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
582 Unit
* Aura::GetCaster() const
584 if(m_caster_guid
== m_target
->GetGUID())
587 //return ObjectAccessor::GetUnit(*m_target,m_caster_guid);
588 //must return caster even if it's in another grid/map
589 Unit
*unit
= ObjectAccessor::GetUnitInWorld(*m_target
,m_caster_guid
);
590 return unit
&& unit
->IsInWorld() ? unit
: NULL
;
593 void Aura::SetModifier(AuraType t
, int32 a
, uint32 pt
, int32 miscValue
)
595 m_modifier
.m_auraname
= t
;
596 m_modifier
.m_amount
= a
;
597 m_modifier
.m_miscvalue
= miscValue
;
598 m_modifier
.periodictime
= pt
;
601 void Aura::Update(uint32 diff
)
610 // GetEffIndex()==0 prevent double/triple apply manaPerSecond/manaPerSecondPerLevel to same spell with many auras
611 // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0
612 if (GetEffIndex() == EFFECT_INDEX_0
&& m_timeCla
<= 0)
614 if(Unit
* caster
= GetCaster())
616 Powers powertype
= Powers(m_spellProto
->powerType
);
617 int32 manaPerSecond
= m_spellProto
->manaPerSecond
+ m_spellProto
->manaPerSecondPerLevel
* caster
->getLevel();
618 m_timeCla
= 1*IN_MILLISECONDS
;
621 if(powertype
==POWER_HEALTH
)
622 caster
->ModifyHealth(-manaPerSecond
);
624 caster
->ModifyPower(powertype
,-manaPerSecond
);
630 // Channeled aura required check distance from caster
631 if(IsChanneledSpell(m_spellProto
) && m_caster_guid
!= m_target
->GetGUID())
633 Unit
* caster
= GetCaster();
636 m_target
->RemoveAura(GetId(), GetEffIndex());
640 // need check distance for channeled target only
641 if (caster
->GetChannelObjectGUID() == m_target
->GetGUID())
644 float max_range
= GetSpellMaxRange(sSpellRangeStore
.LookupEntry(m_spellProto
->rangeIndex
));
646 if(Player
* modOwner
= caster
->GetSpellModOwner())
647 modOwner
->ApplySpellMod(GetId(), SPELLMOD_RANGE
, max_range
, NULL
);
649 if(!caster
->IsWithinDistInMap(m_target
, max_range
))
651 m_target
->RemoveAura(GetId(), GetEffIndex());
657 if(m_isPeriodic
&& (m_duration
>= 0 || m_isPassive
|| m_permanent
))
659 m_periodicTimer
-= diff
;
660 if(m_periodicTimer
<= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N
662 // update before applying (aura can be removed in TriggerSpell or PeriodicTick calls)
663 m_periodicTimer
+= m_modifier
.periodictime
;
664 ++m_periodicTick
; // for some infinity auras in some cases can overflow and reset
670 void AreaAura::Update(uint32 diff
)
672 // update for the caster of the aura
673 if(m_caster_guid
== m_target
->GetGUID())
675 Unit
* caster
= m_target
;
677 if( !caster
->hasUnitState(UNIT_STAT_ISOLATED
) )
679 Unit
* owner
= caster
->GetCharmerOrOwner();
682 std::list
<Unit
*> targets
;
684 switch(m_areaAuraType
)
686 case AREA_AURA_PARTY
:
688 Group
*pGroup
= NULL
;
690 if (owner
->GetTypeId() == TYPEID_PLAYER
)
691 pGroup
= ((Player
*)owner
)->GetGroup();
695 uint8 subgroup
= ((Player
*)owner
)->GetSubGroup();
696 for(GroupReference
*itr
= pGroup
->GetFirstMember(); itr
!= NULL
; itr
= itr
->next())
698 Player
* Target
= itr
->getSource();
699 if(Target
&& Target
->isAlive() && Target
->GetSubGroup()==subgroup
&& caster
->IsFriendlyTo(Target
))
701 if(caster
->IsWithinDistInMap(Target
, m_radius
))
702 targets
.push_back(Target
);
703 Pet
*pet
= Target
->GetPet();
704 if(pet
&& pet
->isAlive() && caster
->IsWithinDistInMap(pet
, m_radius
))
705 targets
.push_back(pet
);
712 if( owner
!= caster
&& caster
->IsWithinDistInMap(owner
, m_radius
) )
713 targets
.push_back(owner
);
715 Unit
* pet
= caster
->GetPet();
716 if( pet
&& caster
->IsWithinDistInMap(pet
, m_radius
))
717 targets
.push_back(pet
);
723 Group
*pGroup
= NULL
;
725 if (owner
->GetTypeId() == TYPEID_PLAYER
)
726 pGroup
= ((Player
*)owner
)->GetGroup();
730 for(GroupReference
*itr
= pGroup
->GetFirstMember(); itr
!= NULL
; itr
= itr
->next())
732 Player
* Target
= itr
->getSource();
733 if(Target
&& Target
->isAlive() && caster
->IsFriendlyTo(Target
))
735 if(caster
->IsWithinDistInMap(Target
, m_radius
))
736 targets
.push_back(Target
);
737 Pet
*pet
= Target
->GetPet();
738 if(pet
&& pet
->isAlive() && caster
->IsWithinDistInMap(pet
, m_radius
))
739 targets
.push_back(pet
);
746 if( owner
!= caster
&& caster
->IsWithinDistInMap(owner
, m_radius
) )
747 targets
.push_back(owner
);
749 Unit
* pet
= caster
->GetPet();
750 if( pet
&& caster
->IsWithinDistInMap(pet
, m_radius
))
751 targets
.push_back(pet
);
755 case AREA_AURA_FRIEND
:
757 MaNGOS::AnyFriendlyUnitInObjectRangeCheck
u_check(caster
, m_radius
);
758 MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
> searcher(caster
,targets
, u_check
);
759 Cell::VisitAllObjects(caster
, searcher
, m_radius
);
762 case AREA_AURA_ENEMY
:
764 MaNGOS::AnyAoETargetUnitInObjectRangeCheck
u_check(caster
, m_radius
); // No GetCharmer in searcher
765 MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
> searcher(caster
, targets
, u_check
);
766 Cell::VisitAllObjects(caster
, searcher
, m_radius
);
769 case AREA_AURA_OWNER
:
772 if(owner
!= caster
&& caster
->IsWithinDistInMap(owner
, m_radius
))
773 targets
.push_back(owner
);
778 for(std::list
<Unit
*>::iterator tIter
= targets
.begin(); tIter
!= targets
.end(); tIter
++)
780 // flag for seelction is need apply aura to current iteration target
783 // we need ignore present caster self applied are auras sometime
784 // in cases if this only auras applied for spell effect
785 Unit::spellEffectPair spair
= Unit::spellEffectPair(GetId(), m_effIndex
);
786 for(Unit::AuraMap::const_iterator i
= (*tIter
)->GetAuras().lower_bound(spair
); i
!= (*tIter
)->GetAuras().upper_bound(spair
); ++i
)
788 if (i
->second
->IsDeleted())
791 switch(m_areaAuraType
)
793 case AREA_AURA_ENEMY
:
794 // non caster self-casted auras (non stacked)
795 if(i
->second
->GetModifier()->m_auraname
!= SPELL_AURA_NONE
)
799 // non caster self-casted auras (stacked from diff. casters)
800 if(i
->second
->GetModifier()->m_auraname
!= SPELL_AURA_NONE
|| i
->second
->GetCasterGUID() == GetCasterGUID())
804 // in generic case not allow stacking area auras
816 if(SpellEntry
const *actualSpellInfo
= sSpellMgr
.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter
)->getLevel()))
818 int32 actualBasePoints
= m_currentBasePoints
;
819 // recalculate basepoints for lower rank (all AreaAura spell not use custom basepoints?)
820 if(actualSpellInfo
!= GetSpellProto())
821 actualBasePoints
= actualSpellInfo
->CalculateSimpleValue(m_effIndex
);
822 AreaAura
*aur
= new AreaAura(actualSpellInfo
, m_effIndex
, &actualBasePoints
, (*tIter
), caster
, NULL
);
823 aur
->SetAuraDuration(GetAuraDuration());
824 (*tIter
)->AddAura(aur
);
830 else // aura at non-caster
832 Unit
* caster
= GetCaster();
836 // remove aura if out-of-range from caster (after teleport for example)
837 // or caster is isolated or caster no longer has the aura
838 // or caster is (no longer) friendly
839 bool needFriendly
= (m_areaAuraType
== AREA_AURA_ENEMY
? false : true);
840 if( !caster
|| caster
->hasUnitState(UNIT_STAT_ISOLATED
) ||
841 !caster
->IsWithinDistInMap(m_target
, m_radius
) ||
842 !caster
->HasAura(GetId(), GetEffIndex()) ||
843 caster
->IsFriendlyTo(m_target
) != needFriendly
846 m_target
->RemoveAurasByCasterSpell(GetId(), GetEffIndex(),GetCasterGUID());
848 else if( m_areaAuraType
== AREA_AURA_PARTY
) // check if in same sub group
850 // not check group if target == owner or target == pet
851 if (caster
->GetCharmerOrOwnerGUID() != m_target
->GetGUID() && caster
->GetGUID() != m_target
->GetCharmerOrOwnerGUID())
853 Player
* check
= caster
->GetCharmerOrOwnerPlayerOrPlayerItself();
855 Group
*pGroup
= check
? check
->GetGroup() : NULL
;
858 Player
* checkTarget
= m_target
->GetCharmerOrOwnerPlayerOrPlayerItself();
859 if(!checkTarget
|| !pGroup
->SameSubGroup(check
, checkTarget
))
860 m_target
->RemoveAura(GetId(), GetEffIndex());
863 m_target
->RemoveAura(GetId(), GetEffIndex());
866 else if( m_areaAuraType
== AREA_AURA_RAID
) // TODO: fix me!
868 // not check group if target == owner or target == pet
869 if (caster
->GetCharmerOrOwnerGUID() != m_target
->GetGUID() && caster
->GetGUID() != m_target
->GetCharmerOrOwnerGUID())
871 Player
* check
= caster
->GetCharmerOrOwnerPlayerOrPlayerItself();
873 Group
*pGroup
= check
? check
->GetGroup() : NULL
;
876 Player
* checkTarget
= m_target
->GetCharmerOrOwnerPlayerOrPlayerItself();
878 m_target
->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
881 m_target
->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
884 else if( m_areaAuraType
== AREA_AURA_PET
|| m_areaAuraType
== AREA_AURA_OWNER
)
886 if( m_target
->GetGUID() != caster
->GetCharmerOrOwnerGUID() )
887 m_target
->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
892 void PersistentAreaAura::Update(uint32 diff
)
896 // remove the aura if its caster or the dynamic object causing it was removed
897 // or if the target moves too far from the dynamic object
898 if(Unit
*caster
= GetCaster())
900 DynamicObject
*dynObj
= caster
->GetDynObject(GetId(), GetEffIndex());
903 if (!m_target
->IsWithinDistInMap(dynObj
, dynObj
->GetRadius()))
915 m_target
->RemoveAura(GetId(), GetEffIndex());
918 void Aura::ApplyModifier(bool apply
, bool Real
)
920 AuraType aura
= m_modifier
.m_auraname
;
923 if(aura
< TOTAL_AURAS
)
924 (*this.*AuraHandler
[aura
])(apply
, Real
);
928 bool Aura::IsNeedVisibleSlot(Unit
const* caster
) const
930 bool totemAura
= caster
&& caster
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)caster
)->isTotem();
932 // special area auras cases
933 switch(m_spellProto
->Effect
[GetEffIndex()])
935 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
:
936 return m_target
!= caster
;
937 case SPELL_EFFECT_APPLY_AREA_AURA_PET
:
938 case SPELL_EFFECT_APPLY_AREA_AURA_OWNER
:
939 case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
:
940 case SPELL_EFFECT_APPLY_AREA_AURA_PARTY
:
941 case SPELL_EFFECT_APPLY_AREA_AURA_RAID
:
942 // passive auras (except totem auras) do not get placed in caster slot
943 return (m_target
!= caster
|| totemAura
|| !m_isPassive
) && m_modifier
.m_auraname
!= SPELL_AURA_NONE
;
948 // passive auras (except totem auras) do not get placed in the slots
949 return !m_isPassive
|| totemAura
;
952 void Aura::_AddAura()
959 // Second aura if some spell
960 bool secondaura
= false;
961 // Try find slot for aura
962 uint8 slot
= NULL_AURA_SLOT
;
963 // Lookup for some spell auras (and get slot from it)
964 for(uint8 i
= 0; i
< MAX_EFFECT_INDEX
; ++i
)
966 Unit::spellEffectPair spair
= Unit::spellEffectPair(GetId(), SpellEffectIndex(i
));
967 for(Unit::AuraMap::const_iterator itr
= m_target
->GetAuras().lower_bound(spair
); itr
!= m_target
->GetAuras().upper_bound(spair
); ++itr
)
969 // allow use single slot only by auras from same caster
970 if(itr
->second
->GetCasterGUID()==GetCasterGUID() &&
971 !isWeaponBuffCoexistableWith(itr
->second
))
973 slot
= itr
->second
->GetAuraSlot();
982 if (!secondaura
&& m_target
->GetVisibleAurasCount() < MAX_AURAS
)
984 Unit::VisibleAuraMap
const *visibleAuras
= m_target
->GetVisibleAuras();
985 for(uint8 i
= 0; i
< MAX_AURAS
; ++i
)
987 Unit::VisibleAuraMap::const_iterator itr
= visibleAuras
->find(i
);
988 if(itr
== visibleAuras
->end())
991 // update for out of range group members (on 1 slot use)
992 m_target
->UpdateAuraForGroup(slot
);
998 Unit
* caster
= GetCaster();
1000 // set infinity cooldown state for spells
1001 if(caster
&& caster
->GetTypeId() == TYPEID_PLAYER
)
1003 if (m_spellProto
->Attributes
& SPELL_ATTR_DISABLED_WHILE_ACTIVE
)
1005 Item
* castItem
= m_castItemGuid
? ((Player
*)caster
)->GetItemByGuid(m_castItemGuid
) : NULL
;
1006 ((Player
*)caster
)->AddSpellAndCategoryCooldowns(m_spellProto
,castItem
? castItem
->GetEntry() : 0, NULL
,true);
1010 if (IsNeedVisibleSlot(caster
))
1012 SetAuraSlot( slot
);
1013 if(slot
< MAX_AURAS
) // slot found send data to client
1016 SetAuraFlags((1 << GetEffIndex()) | ((GetCasterGUID() == GetTarget()->GetGUID()) ? AFLAG_NOT_CASTER
: AFLAG_NONE
) | ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION
: AFLAG_NONE
) | (IsPositive() ? AFLAG_POSITIVE
: AFLAG_NEGATIVE
));
1017 SetAuraLevel(caster
? caster
->getLevel() : sWorld
.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL
));
1018 SendAuraUpdate(false);
1021 //*****************************************************
1022 // Update target aura state flag (at 1 aura apply)
1023 // TODO: Make it easer
1024 //*****************************************************
1027 // Sitdown on apply aura req seated
1028 if (m_spellProto
->AuraInterruptFlags
& AURA_INTERRUPT_FLAG_NOT_SEATED
&& !m_target
->IsSitState())
1029 m_target
->SetStandState(UNIT_STAND_STATE_SIT
);
1031 // register aura diminishing on apply
1032 if (getDiminishGroup() != DIMINISHING_NONE
)
1033 m_target
->ApplyDiminishingAura(getDiminishGroup(), true);
1035 // Update Seals information
1036 if (IsSealSpell(m_spellProto
))
1037 m_target
->ModifyAuraState(AURA_STATE_JUDGEMENT
, true);
1039 // Conflagrate aura state on Immolate and Shadowflame
1040 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARLOCK
&&
1042 ((m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000004)) ||
1044 (m_spellProto
->SpellFamilyFlags2
& 0x00000002)))
1045 m_target
->ModifyAuraState(AURA_STATE_CONFLAGRATE
, true);
1047 // Faerie Fire (druid versions)
1048 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_DRUID
&& (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000400)))
1049 m_target
->ModifyAuraState(AURA_STATE_FAERIE_FIRE
, true);
1052 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0004000000000000)))
1053 m_target
->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH
, true);
1055 // Swiftmend state on Regrowth & Rejuvenation
1056 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_DRUID
&& (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x50)))
1057 m_target
->ModifyAuraState(AURA_STATE_SWIFTMEND
, true);
1059 // Deadly poison aura state
1060 if(m_spellProto
->SpellFamilyName
== SPELLFAMILY_ROGUE
&& (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x10000)))
1061 m_target
->ModifyAuraState(AURA_STATE_DEADLY_POISON
, true);
1063 // Enrage aura state
1064 if(m_spellProto
->Dispel
== DISPEL_ENRAGE
)
1065 m_target
->ModifyAuraState(AURA_STATE_ENRAGE
, true);
1070 bool Aura::_RemoveAura()
1072 // Remove all triggered by aura spells vs unlimited duration
1073 // except same aura replace case
1074 if(m_removeMode
!=AURA_REMOVE_BY_STACK
)
1075 CleanupTriggeredSpells();
1077 Unit
* caster
= GetCaster();
1079 if(caster
&& IsPersistent())
1081 DynamicObject
*dynObj
= caster
->GetDynObject(GetId(), GetEffIndex());
1083 dynObj
->RemoveAffected(m_target
);
1086 //passive auras do not get put in slots
1087 // Note: but totem can be not accessible for aura target in time remove (to far for find in grid)
1088 //if(m_isPassive && !(caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem()))
1091 uint8 slot
= GetAuraSlot();
1093 if(slot
>= MAX_AURAS
) // slot not set
1096 if(m_target
->GetVisibleAura(slot
) == 0)
1099 bool lastaura
= true;
1101 // find other aura in same slot (current already removed from list)
1102 for(int i
= 0; i
< MAX_EFFECT_INDEX
; ++i
)
1104 Unit::spellEffectPair spair
= Unit::spellEffectPair(GetId(), SpellEffectIndex(i
));
1105 for(Unit::AuraMap::const_iterator itr
= m_target
->GetAuras().lower_bound(spair
); itr
!= m_target
->GetAuras().upper_bound(spair
); ++itr
)
1107 if(itr
->second
->GetAuraSlot() == slot
)
1117 // only remove icon when the last aura of the spell is removed (current aura already removed from list)
1121 // unregister aura diminishing (and store last time)
1122 if (getDiminishGroup() != DIMINISHING_NONE
)
1123 m_target
->ApplyDiminishingAura(getDiminishGroup(), false);
1126 SetAuraFlags(AFLAG_NONE
);
1129 if (m_removeMode
!= AURA_REMOVE_BY_DELETE
)
1131 SendAuraUpdate(true);
1133 // update for out of range group members
1134 m_target
->UpdateAuraForGroup(slot
);
1136 //*****************************************************
1137 // Update target aura state flag (at last aura remove)
1138 //*****************************************************
1139 // Enrage aura state
1140 if(m_spellProto
->Dispel
== DISPEL_ENRAGE
)
1141 m_target
->ModifyAuraState(AURA_STATE_ENRAGE
, false);
1143 uint32 removeState
= 0;
1144 uint64 removeFamilyFlag
= m_spellProto
->SpellFamilyFlags
;
1145 uint32 removeFamilyFlag2
= m_spellProto
->SpellFamilyFlags2
;
1146 switch(m_spellProto
->SpellFamilyName
)
1148 case SPELLFAMILY_PALADIN
:
1149 if (IsSealSpell(m_spellProto
))
1150 removeState
= AURA_STATE_JUDGEMENT
; // Update Seals information
1152 case SPELLFAMILY_WARLOCK
:
1153 // Conflagrate aura state on Immolate and Shadowflame,
1154 if ((m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000004)) ||
1155 (m_spellProto
->SpellFamilyFlags2
& 0x00000002))
1157 removeFamilyFlag
= UI64LIT(0x0000000000000004);
1158 removeFamilyFlag2
= 0x00000002;
1159 removeState
= AURA_STATE_CONFLAGRATE
;
1162 case SPELLFAMILY_DRUID
:
1163 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000400))
1164 removeState
= AURA_STATE_FAERIE_FIRE
; // Faerie Fire (druid versions)
1165 else if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x50))
1167 removeFamilyFlag
= 0x50;
1168 removeState
= AURA_STATE_SWIFTMEND
; // Swiftmend aura state
1171 case SPELLFAMILY_WARRIOR
:
1172 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0004000000000000))
1173 removeState
= AURA_STATE_WARRIOR_VICTORY_RUSH
; // Victorious
1175 case SPELLFAMILY_ROGUE
:
1176 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x10000))
1177 removeState
= AURA_STATE_DEADLY_POISON
; // Deadly poison aura state
1179 case SPELLFAMILY_HUNTER
:
1180 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x1000000000000000))
1181 removeState
= AURA_STATE_FAERIE_FIRE
; // Sting (hunter versions)
1184 // Remove state (but need check other auras for it)
1188 Unit::AuraMap
& Auras
= m_target
->GetAuras();
1189 for(Unit::AuraMap::iterator i
= Auras
.begin(); i
!= Auras
.end(); ++i
)
1191 SpellEntry
const *auraSpellInfo
= (*i
).second
->GetSpellProto();
1192 if(auraSpellInfo
->SpellFamilyName
== m_spellProto
->SpellFamilyName
&&
1193 (auraSpellInfo
->SpellFamilyFlags
& removeFamilyFlag
|| auraSpellInfo
->SpellFamilyFlags2
& removeFamilyFlag2
))
1199 // this has been last aura
1201 m_target
->ModifyAuraState(AuraState(removeState
), false);
1204 // reset cooldown state for spells
1205 if(caster
&& caster
->GetTypeId() == TYPEID_PLAYER
)
1207 if ( GetSpellProto()->Attributes
& SPELL_ATTR_DISABLED_WHILE_ACTIVE
)
1208 // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
1209 ((Player
*)caster
)->SendCooldownEvent(GetSpellProto());
1216 void Aura::SendAuraUpdate(bool remove
)
1218 WorldPacket
data(SMSG_AURA_UPDATE
);
1219 data
<< m_target
->GetPackGUID();
1220 data
<< uint8(GetAuraSlot());
1221 data
<< uint32(remove
? 0 : GetId());
1225 m_target
->SendMessageToSet(&data
, true);
1229 uint8 auraFlags
= GetAuraFlags();
1230 data
<< uint8(auraFlags
);
1231 data
<< uint8(GetAuraLevel());
1232 data
<< uint8(m_procCharges
? m_procCharges
*m_stackAmount
: m_stackAmount
);
1234 if(!(auraFlags
& AFLAG_NOT_CASTER
))
1236 data
.appendPackGUID(GetCasterGUID());
1239 if(auraFlags
& AFLAG_DURATION
)
1241 data
<< uint32(GetAuraMaxDuration());
1242 data
<< uint32(GetAuraDuration());
1245 m_target
->SendMessageToSet(&data
, true);
1248 void Aura::SetStackAmount(uint8 stackAmount
)
1250 Unit
*target
= GetTarget();
1251 Unit
*caster
= GetCaster();
1252 if (!target
|| !caster
)
1255 bool refresh
= stackAmount
>= m_stackAmount
;
1256 if (stackAmount
!= m_stackAmount
)
1258 m_stackAmount
= stackAmount
;
1259 int32 amount
= m_stackAmount
* caster
->CalculateSpellDamage(target
, m_spellProto
, m_effIndex
, &m_currentBasePoints
);
1260 // Reapply if amount change
1261 if (amount
!=m_modifier
.m_amount
)
1263 ApplyModifier(false, true);
1264 m_modifier
.m_amount
= amount
;
1265 ApplyModifier(true, true);
1270 // Stack increased refresh duration
1273 // Stack decreased only send update
1274 SendAuraUpdate(false);
1277 bool Aura::modStackAmount(int32 num
)
1280 if (!m_spellProto
->StackAmount
)
1283 // Modify stack but limit it
1284 int32 stackAmount
= m_stackAmount
+ num
;
1285 if (stackAmount
> (int32
)m_spellProto
->StackAmount
)
1286 stackAmount
= m_spellProto
->StackAmount
;
1287 else if (stackAmount
<=0) // Last aura from stack removed
1290 return true; // need remove aura
1293 // Update stack amount
1294 SetStackAmount(stackAmount
);
1298 void Aura::RefreshAura()
1300 m_duration
= m_maxduration
;
1301 SendAuraUpdate(false);
1304 bool Aura::isAffectedOnSpell(SpellEntry
const *spell
) const
1306 // Check family name
1307 if (spell
->SpellFamilyName
!= m_spellProto
->SpellFamilyName
)
1309 // Check EffectClassMask
1310 uint32
const *ptr
= getAuraSpellClassMask();
1311 if (((uint64
*)ptr
)[0] & spell
->SpellFamilyFlags
)
1313 if (ptr
[2] & spell
->SpellFamilyFlags2
)
1318 void Aura::ReapplyAffectedPassiveAuras( Unit
* target
, bool owner_mode
)
1320 std::set
<uint32
> affectedSelf
;
1321 std::set
<uint32
> affectedAuraCaster
;
1323 for(Unit::AuraMap::const_iterator itr
= target
->GetAuras().begin(); itr
!= target
->GetAuras().end(); ++itr
)
1325 // permanent passive or permanent area aura
1326 // passive spells can be affected only by own or owner spell mods)
1327 if (itr
->second
->IsPermanent() && (owner_mode
&& itr
->second
->IsPassive() || itr
->second
->IsAreaAura()) &&
1328 // non deleted and not same aura (any with same spell id)
1329 !itr
->second
->IsDeleted() && itr
->second
->GetId() != GetId() &&
1330 // and affected by aura
1331 isAffectedOnSpell(itr
->second
->GetSpellProto()))
1333 // only applied by self or aura caster
1334 if (itr
->second
->GetCasterGUID() == target
->GetGUID())
1335 affectedSelf
.insert(itr
->second
->GetId());
1336 else if (itr
->second
->GetCasterGUID() == GetCasterGUID())
1337 affectedAuraCaster
.insert(itr
->second
->GetId());
1341 for(std::set
<uint32
>::const_iterator set_itr
= affectedSelf
.begin(); set_itr
!= affectedSelf
.end(); ++set_itr
)
1343 target
->RemoveAurasDueToSpell(*set_itr
);
1344 target
->CastSpell(m_target
, *set_itr
, true);
1347 if (!affectedAuraCaster
.empty())
1349 Unit
* caster
= GetCaster();
1350 for(std::set
<uint32
>::const_iterator set_itr
= affectedAuraCaster
.begin(); set_itr
!= affectedAuraCaster
.end(); ++set_itr
)
1352 target
->RemoveAurasDueToSpell(*set_itr
);
1354 caster
->CastSpell(m_target
, *set_itr
, true);
1359 struct ReapplyAffectedPassiveAurasHelper
1361 explicit ReapplyAffectedPassiveAurasHelper(Aura
* _aura
) : aura(_aura
) {}
1362 void operator()(Unit
* unit
) const { aura
->ReapplyAffectedPassiveAuras(unit
, true); }
1366 void Aura::ReapplyAffectedPassiveAuras()
1368 // not reapply spell mods with charges (use original value because processed and at remove)
1369 if (GetSpellProto()->procCharges
)
1372 // not reapply some spell mods ops (mostly speedup case)
1373 switch (m_modifier
.m_miscvalue
)
1375 case SPELLMOD_DURATION
:
1376 case SPELLMOD_CHARGES
:
1377 case SPELLMOD_NOT_LOSE_CASTING_TIME
:
1378 case SPELLMOD_CASTING_TIME
:
1379 case SPELLMOD_COOLDOWN
:
1381 case SPELLMOD_ACTIVATION_TIME
:
1382 case SPELLMOD_CASTING_TIME_OLD
:
1386 // reapply talents to own passive persistent auras
1387 ReapplyAffectedPassiveAuras(GetTarget(), true);
1389 // re-apply talents/passives/area auras applied to pet/totems (it affected by player spellmods)
1390 GetTarget()->CallForAllControlledUnits(ReapplyAffectedPassiveAurasHelper(this),true,false,false);
1392 // re-apply talents/passives/area auras applied to group members (it affected by player spellmods)
1393 if (Group
* group
= ((Player
*)GetTarget())->GetGroup())
1394 for(GroupReference
*itr
= group
->GetFirstMember(); itr
!= NULL
; itr
= itr
->next())
1395 if (Player
* member
= itr
->getSource())
1396 if (member
!= GetTarget() && member
->IsInMap(GetTarget()))
1397 ReapplyAffectedPassiveAuras(member
, false);
1401 bool Aura::isWeaponBuffCoexistableWith(Aura
* ref
)
1407 // Exclude Non-generic Buffs [ie: Runeforging] and Executioner-Enchant
1408 if (GetSpellProto()->SpellFamilyName
!= SPELLFAMILY_GENERIC
|| GetId() == 42976)
1411 // Exclude Stackable Buffs [ie: Blood Reserve]
1412 if (GetSpellProto()->StackAmount
)
1415 // only self applied player buffs
1416 if (m_target
->GetTypeId() != TYPEID_PLAYER
|| m_target
->GetGUID() != GetCasterGUID())
1419 Item
* castItem
= ((Player
*)m_target
)->GetItemByGuid(GetCastItemGUID());
1423 // Limit to Weapon-Slots
1424 if (!castItem
->IsEquipped() ||
1425 (castItem
->GetSlot() != EQUIPMENT_SLOT_MAINHAND
&& castItem
->GetSlot() != EQUIPMENT_SLOT_OFFHAND
))
1428 // form different weapons
1429 return ref
->GetCastItemGUID() != GetCastItemGUID();
1432 /*********************************************************/
1433 /*** BASIC AURA FUNCTION ***/
1434 /*********************************************************/
1435 void Aura::HandleAddModifier(bool apply
, bool Real
)
1437 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
|| !Real
)
1440 if(m_modifier
.m_miscvalue
>= MAX_SPELLMOD
)
1445 // Add custom charges for some mod aura
1446 switch (GetSpellProto()->Id
)
1448 case 17941: // Shadow Trance
1449 case 22008: // Netherwind Focus
1450 case 31834: // Light's Grace
1451 case 34754: // Clearcasting
1452 case 34936: // Backlash
1453 case 44401: // Missile Barrage
1454 case 48108: // Hot Streak
1455 case 51124: // Killing Machine
1456 case 54741: // Firestarter
1457 case 57761: // Fireball!
1458 case 64823: // Elune's Wrath (Balance druid t8 set
1463 m_spellmod
= new SpellModifier(
1464 SpellModOp(m_modifier
.m_miscvalue
),
1465 SpellModType(m_modifier
.m_auraname
), // SpellModType value == spell aura types
1466 m_modifier
.m_amount
,
1468 // prevent expire spell mods with (charges > 0 && m_stackAmount > 1)
1469 // all this spell expected expire not at use but at spell proc event check
1470 GetSpellProto()->StackAmount
> 1 ? 0 : m_procCharges
);
1473 ((Player
*)GetTarget())->AddSpellMod(m_spellmod
, apply
);
1475 ReapplyAffectedPassiveAuras();
1478 void Aura::TriggerSpell()
1480 const uint64
& casterGUID
= GetCasterGUID();
1481 Unit
* triggerTarget
= GetTriggerTarget();
1483 if(!casterGUID
|| !triggerTarget
)
1486 // generic casting code with custom spells and target/caster customs
1487 uint32 trigger_spell_id
= GetSpellProto()->EffectTriggerSpell
[m_effIndex
];
1489 SpellEntry
const *triggeredSpellInfo
= sSpellStore
.LookupEntry(trigger_spell_id
);
1490 SpellEntry
const *auraSpellInfo
= GetSpellProto();
1491 uint32 auraId
= auraSpellInfo
->Id
;
1492 Unit
* target
= GetTarget();
1494 // specific code for cases with no trigger spell provided in field
1495 if (triggeredSpellInfo
== NULL
)
1497 switch(auraSpellInfo
->SpellFamilyName
)
1499 case SPELLFAMILY_GENERIC
:
1503 // // Periodic Mana Burn
1505 // // Polymorphic Ray
1506 // case 6965: break;
1507 // Thaumaturgy Channel
1508 case 9712: trigger_spell_id
= 21029; break;
1509 // // Egan's Blaster
1510 // case 17368: break;
1512 // case 18347: break;
1513 // // Ranshalla Waiting
1514 // case 18953: break;
1516 // case 19695: break;
1517 // // Frostwolf Muzzle DND
1518 // case 21794: break;
1519 // // Alterac Ram Collar DND
1520 // case 21866: break;
1521 // // Celebras Waiting
1522 // case 21916: break;
1523 // Brood Affliction: Bronze
1526 target
->CastSpell(target
, 23171, true, NULL
, this);
1530 // case 23184: break;
1534 int32 heal
= triggerTarget
->GetMaxHealth() / 10;
1535 triggerTarget
->DealHeal(triggerTarget
, heal
, auraSpellInfo
);
1537 if (int32 mana
= triggerTarget
->GetMaxPower(POWER_MANA
))
1540 triggerTarget
->EnergizeBySpell(triggerTarget
, 23493, mana
, POWER_MANA
);
1544 // // Stoneclaw Totem Passive TEST
1545 // case 23792: break;
1547 // case 24018: break;
1548 // // Mark of Arlokk
1549 // case 24210: break;
1551 // case 24379: break;
1553 // case 24716: break;
1555 // case 24780: break;
1557 // case 24832: break;
1558 // Shadow Bolt Whirl
1561 uint32 spellForTick
[8] = { 24820, 24821, 24822, 24823, 24835, 24836, 24837, 24838 };
1562 uint32 tick
= GetAuraTicks();
1565 trigger_spell_id
= spellForTick
[tick
];
1567 // casted in left/right (but triggered spell have wide forward cone)
1568 float forward
= target
->GetOrientation();
1569 float angle
= target
->GetOrientation() + ( tick
% 2 == 0 ? M_PI_F
/ 2 : - M_PI_F
/ 2);
1570 target
->SetOrientation(angle
);
1571 triggerTarget
->CastSpell(triggerTarget
, trigger_spell_id
, true, NULL
, this, casterGUID
);
1572 target
->SetOrientation(forward
);
1577 // case 24918: break;
1578 // // Mark of Nature
1579 // case 25041: break;
1581 // case 25152: break;
1585 int32 bpDamage
= triggerTarget
->GetMaxHealth()*10/100;
1586 triggerTarget
->CastCustomSpell(triggerTarget
, 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
= triggerTarget
->GetMaxHealth()*26/100;
1613 triggerTarget
->CastCustomSpell(triggerTarget
, 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(triggerTarget
->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 triggerTarget
->GetTypeId() == TYPEID_UNIT
&&
1670 ((Creature
*)triggerTarget
)->GetCreatureInfo()->type
== CREATURE_TYPE_GAS_CLOUD
)
1672 Player
* player
= (Player
*)caster
;
1673 Creature
* creature
= (Creature
*)triggerTarget
;
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 target
->CastSpell(target
,31350,true);
1703 target
->DealDamage(target
, target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
1709 // Summon Elemental after create item
1710 triggerTarget
->SummonCreature(17870, 0, 0, 0, triggerTarget
->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN
, 0);
1713 // // Bloodmyst Tesla
1714 // case 31611: break;
1718 int32 damage
= m_modifier
.m_amount
* ((GetAuraDuration() + m_modifier
.periodictime
) / GetAuraMaxDuration());
1719 triggerTarget
->CastCustomSpell(triggerTarget
, 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 triggerTarget
->CastSpell(triggerTarget
, spell_id
, true, NULL
, this, casterGUID
);
1738 for(uint32 spell_id
= 34314; spell_id
!= 34317; ++spell_id
)
1739 triggerTarget
->CastSpell(triggerTarget
, 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 target
->CastSpell(target
, 38530, true);
1824 // Absorb Eye of Grillok (Zezzak's Shard)
1827 if(target
->GetTypeId() != TYPEID_UNIT
)
1830 if (Unit
* caster
= GetCaster())
1831 caster
->CastSpell(caster
, 38495, true, NULL
, this);
1835 Creature
* creatureTarget
= (Creature
*)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 (triggerTarget
->GetTypeId() != TYPEID_PLAYER
)
1969 // Reset reapply counter at move
1970 if (((Player
*)triggerTarget
)->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 (triggerTarget
->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
= target
->GetPower(POWER_RAGE
);
2018 if(lRage
> 100) // rage stored as rage*10
2020 target
->ModifyPower(POWER_RAGE
, -lRage
);
2021 int32 FRTriggerBasePoints
= int32(lRage
*LifePerRage
/10);
2022 target
->CastCustomSpell(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
= triggerTarget
->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 triggerTarget
->RemoveAurasDueToSpell(28820);
2085 // Totemic Mastery (Skyshatter Regalia (Shaman Tier 6) - bonus)
2088 if(triggerTarget
->IsAllTotemSlotsUsed())
2089 triggerTarget
->CastSpell(triggerTarget
, 38437, true, NULL
, this);
2091 triggerTarget
->RemoveAurasDueToSpell(38437);
2103 // Reget trigger spell proto
2104 triggeredSpellInfo
= sSpellStore
.LookupEntry(trigger_spell_id
);
2108 // Spell exist but require custom code
2114 // TODO: spell casted by result in correct way mostly
2116 // 1) target show casting at each triggered cast: target don't must show casting animation for any triggered spell
2117 // but must show affect apply like item casting
2118 // 2) maybe aura must be replace by new with accumulative stat mods instead stacking
2120 // prevent cast by triggered auras
2121 if(casterGUID
== triggerTarget
->GetGUID())
2124 // stop triggering after each affected stats lost > 90
2125 int32 intelectLoss
= 0;
2126 int32 spiritLoss
= 0;
2128 Unit::AuraList
const& mModStat
= triggerTarget
->GetAurasByType(SPELL_AURA_MOD_STAT
);
2129 for(Unit::AuraList::const_iterator i
= mModStat
.begin(); i
!= mModStat
.end(); ++i
)
2131 if ((*i
)->GetId() == 1010)
2133 switch((*i
)->GetModifier()->m_miscvalue
)
2135 case STAT_INTELLECT
: intelectLoss
+= (*i
)->GetModifier()->m_amount
; break;
2136 case STAT_SPIRIT
: spiritLoss
+= (*i
)->GetModifier()->m_amount
; break;
2142 if(intelectLoss
<= -90 && spiritLoss
<= -90)
2150 triggerTarget
->CastCustomSpell(triggerTarget
, trigger_spell_id
, &m_modifier
.m_amount
, NULL
, NULL
, true, NULL
, this);
2155 triggerTarget
->CastSpell(triggerTarget
, trigger_spell_id
, true, NULL
, this, casterGUID
);
2157 // Rod of Purification - for quest 10839 (Veil Skith: Darkstone of Terokk)
2160 if(Unit
* caster
= GetCaster())
2161 caster
->CastSpell(triggerTarget
, trigger_spell_id
, true, NULL
, this);
2166 // original caster must be target (beacon)
2167 target
->CastSpell(target
, trigger_spell_id
, true, NULL
, this, target
->GetGUID());
2169 // Rapid Recuperation (triggered energize have baspioints == 0)
2173 int32 mana
= target
->GetMaxPower(POWER_MANA
) * m_modifier
.m_amount
/ 100;
2174 triggerTarget
->CastCustomSpell(triggerTarget
, trigger_spell_id
, &mana
, NULL
, NULL
, true, NULL
, this);
2180 // All ok cast by default case
2181 if(triggeredSpellInfo
)
2182 triggerTarget
->CastSpell(triggerTarget
, triggeredSpellInfo
, true, NULL
, this, casterGUID
);
2185 if (Unit
* caster
= GetCaster())
2187 if(triggerTarget
->GetTypeId() != TYPEID_UNIT
|| !Script
->EffectDummyCreature(caster
, GetId(), GetEffIndex(), (Creature
*)triggerTarget
))
2188 sLog
.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex());
2193 void Aura::TriggerSpellWithValue()
2195 const uint64
& casterGUID
= GetCasterGUID();
2196 Unit
* target
= GetTriggerTarget();
2198 if(!casterGUID
|| !target
)
2201 // generic casting code with custom spells and target/caster customs
2202 uint32 trigger_spell_id
= GetSpellProto()->EffectTriggerSpell
[m_effIndex
];
2203 int32 basepoints0
= GetModifier()->m_amount
;
2205 target
->CastCustomSpell(target
, trigger_spell_id
, &basepoints0
, NULL
, NULL
, true, NULL
, this, casterGUID
);
2208 /*********************************************************/
2209 /*** AURA EFFECTS ***/
2210 /*********************************************************/
2212 void Aura::HandleAuraDummy(bool apply
, bool Real
)
2214 // spells required only Real aura add/remove
2218 Unit
*target
= GetTarget();
2223 switch(GetSpellProto()->SpellFamilyName
)
2225 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 (target
->CanHaveThreatList())
2232 if (Unit
* caster
= GetCaster())
2233 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_MILLISECONDS
;
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 target
->CastSpell(target
, 51581, true, NULL
, this);
2250 case 43873: // Headless Horseman Laugh
2251 target
->PlayDistanceSound(11965);
2253 case 46354: // Blood Elf Illusion
2254 if (Unit
* caster
= GetCaster())
2256 switch(caster
->getGender())
2259 caster
->CastSpell(target
, 46356, true, NULL
, this);
2262 caster
->CastSpell(target
, 46355, true, NULL
, this);
2269 case 46699: // Requires No Ammo
2270 if (target
->GetTypeId() == TYPEID_PLAYER
)
2271 // not use ammo and not allow use
2272 ((Player
*)target
)->RemoveAmmo();
2274 case 48025: // Headless Horseman's Mount
2275 Spell::SelectMountByAreaAndSkill(target
, 51621, 48024, 51617, 48023, 0);
2277 case 62061: // Festive Holiday Mount
2278 if (target
->HasAuraType(SPELL_AURA_MOUNTED
))
2279 // Reindeer Transformation
2280 target
->CastSpell(target
, 25860, true, NULL
, this);
2282 case 63624: // Learn a Second Talent Specialization
2283 // Teach Learn Talent Specialization Switches, required for client triggered casts, allow after 30 sec delay
2284 if (target
->GetTypeId() == TYPEID_PLAYER
)
2285 ((Player
*)target
)->learnSpell(63680, false);
2287 case 63651: // Revert to One Talent Specialization
2288 // Teach Learn Talent Specialization Switches, remove
2289 if (target
->GetTypeId() == TYPEID_PLAYER
)
2290 ((Player
*)target
)->removeSpell(63680);
2292 case 71342: // Big Love Rocket
2293 Spell::SelectMountByAreaAndSkill(target
, 71344, 71345, 71346, 71347, 0);
2295 case 72286: // Invincible
2296 Spell::SelectMountByAreaAndSkill(target
, 72281, 72282, 72283, 72284, 0);
2298 case 74856: // Blazing Hippogryph
2299 Spell::SelectMountByAreaAndSkill(target
, 0, 0, 74854, 74855, 0);
2301 case 75614: // Celestial Steed
2302 Spell::SelectMountByAreaAndSkill(target
, 75619, 75620, 75617, 75618, 76153);
2307 case SPELLFAMILY_WARRIOR
:
2310 if (GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000000004))
2312 // Must be casting target
2313 if (!target
->IsNonMeleeSpellCasted(false))
2316 Unit
* caster
= GetCaster();
2320 Unit::AuraList
const& modifierAuras
= caster
->GetAurasByType(SPELL_AURA_ADD_FLAT_MODIFIER
);
2321 for(Unit::AuraList::const_iterator itr
= modifierAuras
.begin(); itr
!= modifierAuras
.end(); ++itr
)
2323 // Unrelenting Assault
2324 if ((*itr
)->GetSpellProto()->SpellFamilyName
==SPELLFAMILY_WARRIOR
&& (*itr
)->GetSpellProto()->SpellIconID
== 2775)
2326 switch ((*itr
)->GetSpellProto()->Id
)
2328 case 46859: // Unrelenting Assault, rank 1
2329 target
->CastSpell(target
,64849,true,NULL
,(*itr
));
2331 case 46860: // Unrelenting Assault, rank 2
2332 target
->CastSpell(target
,64850,true,NULL
,(*itr
));
2344 case SPELLFAMILY_SHAMAN
:
2347 if (GetId() == 55198)
2349 // apply max stack bufs
2350 SpellEntry
const* buffEntry
= sSpellStore
.LookupEntry(55166);
2354 for(uint32 k
= 0; k
< buffEntry
->StackAmount
; ++k
)
2355 target
->CastSpell(target
, buffEntry
, true, NULL
, this);
2358 else if ((GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x40000000000)))
2360 // prevent double apply bonuses
2361 if (target
->GetTypeId() != TYPEID_PLAYER
|| !((Player
*)target
)->GetSession()->PlayerLoading())
2363 if (Unit
* caster
= GetCaster())
2365 m_modifier
.m_amount
= caster
->SpellHealingBonusDone(target
, GetSpellProto(), m_modifier
.m_amount
, SPELL_DIRECT_DAMAGE
);
2366 m_modifier
.m_amount
= target
->SpellHealingBonusTaken(caster
, GetSpellProto(), m_modifier
.m_amount
, SPELL_DIRECT_DAMAGE
);
2378 if (target
->GetTypeId() == TYPEID_PLAYER
&&
2379 (GetSpellProto()->Effect
[EFFECT_INDEX_0
] == 72 || GetSpellProto()->Effect
[EFFECT_INDEX_0
] == 6 &&
2380 (GetSpellProto()->EffectApplyAuraName
[EFFECT_INDEX_0
] == 1 || GetSpellProto()->EffectApplyAuraName
[EFFECT_INDEX_0
] == 128)))
2382 // spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425
2383 ((Player
*)target
)->SetFarSightGUID(0);
2384 WorldPacket
data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE
, 0);
2385 ((Player
*)target
)->GetSession()->SendPacket(&data
);
2389 if (IsQuestTameSpell(GetId()) && target
->isAlive())
2391 Unit
* caster
= GetCaster();
2392 if (!caster
|| !caster
->isAlive())
2395 uint32 finalSpelId
= 0;
2398 case 19548: finalSpelId
= 19597; break;
2399 case 19674: finalSpelId
= 19677; break;
2400 case 19687: finalSpelId
= 19676; break;
2401 case 19688: finalSpelId
= 19678; break;
2402 case 19689: finalSpelId
= 19679; break;
2403 case 19692: finalSpelId
= 19680; break;
2404 case 19693: finalSpelId
= 19684; break;
2405 case 19694: finalSpelId
= 19681; break;
2406 case 19696: finalSpelId
= 19682; break;
2407 case 19697: finalSpelId
= 19683; break;
2408 case 19699: finalSpelId
= 19685; break;
2409 case 19700: finalSpelId
= 19686; break;
2410 case 30646: finalSpelId
= 30647; break;
2411 case 30653: finalSpelId
= 30648; break;
2412 case 30654: finalSpelId
= 30652; break;
2413 case 30099: finalSpelId
= 30100; break;
2414 case 30102: finalSpelId
= 30103; break;
2415 case 30105: finalSpelId
= 30104; break;
2419 caster
->CastSpell(target
, finalSpelId
, true, NULL
, this);
2426 case 12479: // Hex of Jammal'an
2427 target
->CastSpell(target
, 12480, true, NULL
, this);
2429 case 28169: // Mutating Injection
2431 // Mutagen Explosion
2432 target
->CastSpell(target
, 28206, true, NULL
, this);
2434 target
->CastSpell(target
, 28240, true, NULL
, this);
2437 case 32286: // Focus Target Visual
2439 if (m_removeMode
== AURA_REMOVE_BY_DEFAULT
)
2440 target
->CastSpell(target
, 32301, true, NULL
, this);
2444 case 36730: // Flame Strike
2446 target
->CastSpell(target
, 36731, true, NULL
, this);
2449 case 44191: // Flame Strike
2451 if (target
->GetMap()->IsDungeon())
2453 uint32 spellId
= target
->GetMap()->IsRegularDifficulty() ? 44190 : 46163;
2455 target
->CastSpell(target
, spellId
, true, NULL
, this);
2459 case 45934: // Dark Fiend
2461 // Kill target if dispelled
2462 if (m_removeMode
==AURA_REMOVE_BY_DISPEL
)
2463 target
->DealDamage(target
, target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
2466 case 46308: // Burning Winds
2468 // casted only at creatures at spawn
2469 target
->CastSpell(target
, 47287, true, NULL
, this);
2472 case 51870: // Collect Hair Sample
2474 if (Unit
* pCaster
= GetCaster())
2476 if (m_removeMode
== AURA_REMOVE_BY_DEFAULT
)
2477 pCaster
->CastSpell(target
, 51872, true, NULL
, this);
2482 case 58600: // Restricted Flight Area
2484 // Remove Flight Auras
2485 target
->CastSpell(target
, 58601, true);
2487 target
->CastSpell(target
, 45472, true);
2493 if (GetSpellProto()->SpellFamilyName
== SPELLFAMILY_MAGE
&& (GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x2000000000000)))
2495 // Zero duration is equal to AURA_REMOVE_BY_DEFAULT. We can't use it directly, as it is set even
2496 // when removing aura from one target due to casting Living Bomb at other.
2497 if (m_duration
== 0 || m_removeMode
== AURA_REMOVE_BY_DISPEL
)
2498 target
->CastSpell(target
,m_modifier
.m_amount
,true,NULL
,this);
2503 if (m_removeMode
== AURA_REMOVE_BY_DEATH
)
2505 // Stop caster Arcane Missle chanelling on death
2506 if (GetSpellProto()->SpellFamilyName
== SPELLFAMILY_MAGE
&& (GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000000800)))
2508 if (Unit
* caster
= GetCaster())
2509 caster
->InterruptSpell(CURRENT_CHANNELED_SPELL
);
2516 // AT APPLY & REMOVE
2518 switch(GetSpellProto()->SpellFamilyName
)
2520 case SPELLFAMILY_GENERIC
:
2524 case 11196: // Recently Bandaged
2525 target
->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC
, GetMiscValue(), apply
);
2527 case 24658: // Unstable Power
2529 uint32 spellId
= 24659;
2532 SpellEntry
const *spell
= sSpellStore
.LookupEntry(spellId
);
2533 Unit
* caster
= GetCaster();
2534 if (!spell
|| !caster
)
2537 for (uint32 i
= 0; i
< spell
->StackAmount
; ++i
)
2538 caster
->CastSpell(target
, spellId
, true, NULL
, NULL
, GetCasterGUID());
2542 target
->RemoveAurasDueToSpell(spellId
);
2545 case 24661: // Restless Strength
2547 uint32 spellId
= 24662;
2550 SpellEntry
const* spell
= sSpellStore
.LookupEntry(spellId
);
2551 Unit
* caster
= GetCaster();
2552 if (!spell
|| !caster
)
2555 for (uint32 i
=0; i
< spell
->StackAmount
; ++i
)
2556 caster
->CastSpell(target
, spell
->Id
, true, NULL
, NULL
, GetCasterGUID());
2560 target
->RemoveAurasDueToSpell(spellId
);
2563 case 29266: // Permanent Feign Death
2564 case 31261: // Permanent Feign Death (Root)
2565 case 37493: // Feign Death
2566 case 51329: // Feign Death
2567 case 52593: // Bloated Abomination Feign Death
2568 case 55795: // Falling Dragon Feign Death
2569 case 57626: // Feign Death
2570 case 57685: // Permanent Feign Death
2571 case 58768: // Permanent Feign Death (Freeze Jumpend)
2572 case 58806: // Permanent Feign Death (Drowned Anim)
2573 case 58951: // Permanent Feign Death
2574 case 64461: // Permanent Feign Death (No Anim) (Root)
2575 case 65985: // Permanent Feign Death (Root Silence Pacify)
2576 case 70592: // Permanent Feign Death
2577 case 70628: // Permanent Feign Death
2578 case 70630: // Frozen Aftermath - Feign Death
2579 case 71598: // Feign Death
2581 // Unclear what the difference really is between them.
2582 // Some has effect1 that makes the difference, however not all.
2583 // Some appear to be used depending on creature location, in water, at solid ground, in air/suspended, etc
2584 // For now, just handle all the same way
2585 if (target
->GetTypeId() == TYPEID_UNIT
)
2586 target
->SetFeignDeath(apply
);
2590 case 35356: // Spawn Feign Death
2591 case 35357: // Spawn Feign Death
2592 case 42557: // Feign Death
2594 if (target
->GetTypeId() == TYPEID_UNIT
)
2596 // Flags not set like it's done in SetFeignDeath() and apparently always applied at spawn of creature
2597 // All three does however have SPELL_EFFECT_SPAWN(46) as effect1
2598 // It is possible this effect will remove some flags, and then the three here can be handled "normally"
2601 target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_29
);
2602 target
->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FEIGN_DEATH
);
2604 target
->addUnitState(UNIT_STAT_DIED
);
2608 target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_29
);
2609 target
->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FEIGN_DEATH
);
2611 target
->clearUnitState(UNIT_STAT_DIED
);
2616 case 40133: //Summon Fire Elemental
2618 Unit
* caster
= GetCaster();
2622 Unit
*owner
= caster
->GetOwner();
2623 if (owner
&& owner
->GetTypeId() == TYPEID_PLAYER
)
2626 owner
->CastSpell(owner
, 8985, true);
2628 ((Player
*)owner
)->RemovePet(NULL
, PET_SAVE_NOT_IN_SLOT
, true);
2632 case 40132: //Summon Earth Elemental
2634 Unit
* caster
= GetCaster();
2638 Unit
*owner
= caster
->GetOwner();
2639 if (owner
&& owner
->GetTypeId() == TYPEID_PLAYER
)
2642 owner
->CastSpell(owner
, 19704, true);
2644 ((Player
*)owner
)->RemovePet(NULL
, PET_SAVE_NOT_IN_SLOT
, true);
2648 case 40214: //Dragonmaw Illusion
2652 target
->CastSpell(target
, 40216, true);
2653 target
->CastSpell(target
, 42016, true);
2657 target
->RemoveAurasDueToSpell(40216);
2658 target
->RemoveAurasDueToSpell(42016);
2662 case 58204: // LK Intro VO (1)
2663 if (target
->GetTypeId() == TYPEID_PLAYER
)
2667 target
->PlayDirectSound(14970, (Player
*)target
);
2668 // continue in 58205
2670 target
->CastSpell(target
, 58205, true);
2673 case 58205: // LK Intro VO (2)
2674 if (target
->GetTypeId() == TYPEID_PLAYER
)
2678 target
->PlayDirectSound(14971, (Player
*)target
);
2681 target
->PlayDirectSound(14972, (Player
*)target
);
2687 target
->m_AuraFlags
|= UNIT_AURAFLAG_ALIVE_INVISIBLE
;
2689 target
->m_AuraFlags
|= ~UNIT_AURAFLAG_ALIVE_INVISIBLE
;
2694 case SPELLFAMILY_MAGE
:
2696 case SPELLFAMILY_WARLOCK
:
2699 if (GetSpellProto()->SpellIconID
== 3172 && (GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0004000000000000)))
2701 // NOTE: for avoid use additional field damage stored in dummy value (replace unused 100%
2703 m_modifier
.m_amount
= 0; // use value as damage counter instead redundent 100% percent
2706 int32 bp0
= m_modifier
.m_amount
;
2708 if (Unit
* caster
= GetCaster())
2709 target
->CastCustomSpell(caster
,48210,&bp0
,NULL
,NULL
,true);
2714 case SPELLFAMILY_PRIEST
:
2716 // Pain and Suffering
2717 if (GetSpellProto()->SpellIconID
== 2874 && target
->GetTypeId()==TYPEID_PLAYER
)
2721 // Reduce backfire damage (dot damage) from Shadow Word: Death
2722 // aura have wrong effectclassmask, so use hardcoded value
2723 m_spellmod
= new SpellModifier(SPELLMOD_DOT
,SPELLMOD_PCT
,m_modifier
.m_amount
,GetId(),UI64LIT(0x0000200000000000));
2725 ((Player
*)target
)->AddSpellMod(m_spellmod
, apply
);
2730 case SPELLFAMILY_DRUID
:
2734 case 34246: // Idol of the Emerald Queen
2735 case 60779: // Idol of Lush Moss
2737 if (target
->GetTypeId() != TYPEID_PLAYER
)
2741 // dummy not have proper effectclassmask
2742 m_spellmod
= new SpellModifier(SPELLMOD_DOT
,SPELLMOD_FLAT
,m_modifier
.m_amount
/7,GetId(),UI64LIT(0x001000000000));
2744 ((Player
*)target
)->AddSpellMod(m_spellmod
, apply
);
2747 case 52610: // Savage Roar
2751 if (target
->m_form
!= FORM_CAT
)
2754 target
->CastSpell(target
, 62071, true);
2757 target
->RemoveAurasDueToSpell(62071);
2760 case 61336: // Survival Instincts
2764 if (!target
->IsInFeralForm())
2767 int32 bp0
= int32(target
->GetMaxHealth() * m_modifier
.m_amount
/ 100);
2768 target
->CastCustomSpell(target
, 50322, &bp0
, NULL
, NULL
, true);
2771 target
->RemoveAurasDueToSpell(50322);
2777 if (GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x1000000000))
2781 if (Unit
* caster
= GetCaster())
2783 // prevent double apply bonuses
2784 if (target
->GetTypeId() != TYPEID_PLAYER
|| !((Player
*)target
)->GetSession()->PlayerLoading())
2786 m_modifier
.m_amount
= caster
->SpellHealingBonusDone(target
, GetSpellProto(), m_modifier
.m_amount
, SPELL_DIRECT_DAMAGE
);
2787 m_modifier
.m_amount
= target
->SpellHealingBonusTaken(caster
, GetSpellProto(), m_modifier
.m_amount
, SPELL_DIRECT_DAMAGE
);
2793 // Final heal only on dispelled or duration end
2794 if (!(GetAuraDuration() <= 0 || m_removeMode
== AURA_REMOVE_BY_DISPEL
))
2797 // have a look if there is still some other Lifebloom dummy aura
2798 Unit::AuraList
const& auras
= target
->GetAurasByType(SPELL_AURA_DUMMY
);
2799 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!=auras
.end(); ++itr
)
2800 if ((*itr
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_DRUID
&&
2801 ((*itr
)->GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x1000000000)))
2805 if (target
->IsInWorld() && GetStackAmount() > 0)
2807 int32 amount
= m_modifier
.m_amount
/ GetStackAmount();
2808 target
->CastCustomSpell(target
, 33778, &amount
, NULL
, NULL
, true, NULL
, this, GetCasterGUID());
2810 if (Unit
* caster
= GetCaster())
2812 int32 returnmana
= (GetSpellProto()->ManaCostPercentage
* caster
->GetCreateMana() / 100) * GetStackAmount() / 2;
2813 caster
->CastCustomSpell(caster
, 64372, &returnmana
, NULL
, NULL
, true, NULL
, this, GetCasterGUID());
2820 // Predatory Strikes
2821 if (target
->GetTypeId()==TYPEID_PLAYER
&& GetSpellProto()->SpellIconID
== 1563)
2823 ((Player
*)target
)->UpdateAttackPowerAndDamage();
2827 // Improved Moonkin Form
2828 if (GetSpellProto()->SpellIconID
== 2855)
2833 case 48384: spell_id
= 50170; break; //Rank 1
2834 case 48395: spell_id
= 50171; break; //Rank 2
2835 case 48396: spell_id
= 50172; break; //Rank 3
2837 sLog
.outError("HandleAuraDummy: Not handled rank of IMF (Spell: %u)",GetId());
2843 if (target
->m_form
!= FORM_MOONKIN
)
2846 target
->CastSpell(target
, spell_id
, true);
2849 target
->RemoveAurasDueToSpell(spell_id
);
2854 case SPELLFAMILY_HUNTER
:
2856 case SPELLFAMILY_PALADIN
:
2859 case 20911: // Blessing of Sanctuary
2860 case 25899: // Greater Blessing of Sanctuary
2863 target
->CastSpell(target
, 67480, true, NULL
, this);
2865 target
->RemoveAurasDueToSpell(67480);
2870 case SPELLFAMILY_SHAMAN
:
2875 if (PetAura
const* petSpell
= sSpellMgr
.GetPetAura(GetId(), m_effIndex
))
2878 target
->AddPetAura(petSpell
);
2880 target
->RemovePetAura(petSpell
);
2884 if (GetEffIndex() == EFFECT_INDEX_0
&& target
->GetTypeId() == TYPEID_PLAYER
)
2886 SpellAreaForAreaMapBounds saBounds
= sSpellMgr
.GetSpellAreaForAuraMapBounds(GetId());
2887 if (saBounds
.first
!= saBounds
.second
)
2890 target
->GetZoneAndAreaId(zone
, area
);
2892 for(SpellAreaForAreaMap::const_iterator itr
= saBounds
.first
; itr
!= saBounds
.second
; ++itr
)
2894 // some auras remove at aura remove
2895 if (!itr
->second
->IsFitToRequirements((Player
*)target
, zone
, area
))
2896 target
->RemoveAurasDueToSpell(itr
->second
->spellId
);
2897 // some auras applied at aura apply
2898 else if (itr
->second
->autocast
)
2900 if (!target
->HasAura(itr
->second
->spellId
, EFFECT_INDEX_0
))
2901 target
->CastSpell(target
, itr
->second
->spellId
, true);
2907 // script has to "handle with care", only use where data are not ok to use in the above code.
2908 if (target
->GetTypeId() == TYPEID_UNIT
)
2909 Script
->EffectAuraDummy(this, apply
);
2912 void Aura::HandleAuraMounted(bool apply
, bool Real
)
2914 // only at real add/remove aura
2918 Unit
*target
= GetTarget();
2922 CreatureInfo
const* ci
= ObjectMgr::GetCreatureTemplate(m_modifier
.m_miscvalue
);
2925 sLog
.outErrorDb("AuraMounted: `creature_template`='%u' not found in database (only need it modelid)", m_modifier
.m_miscvalue
);
2930 if (target
->GetTypeId()==TYPEID_PLAYER
)
2931 team
= ((Player
*)target
)->GetTeam();
2933 uint32 display_id
= sObjectMgr
.ChooseDisplayId(team
,ci
);
2934 CreatureModelInfo
const *minfo
= sObjectMgr
.GetCreatureModelRandomGender(display_id
);
2936 display_id
= minfo
->modelid
;
2938 target
->Mount(display_id
, GetId());
2946 void Aura::HandleAuraWaterWalk(bool apply
, bool Real
)
2948 // only at real add/remove aura
2954 data
.Initialize(SMSG_MOVE_WATER_WALK
, 8+4);
2956 data
.Initialize(SMSG_MOVE_LAND_WALK
, 8+4);
2957 data
<< GetTarget()->GetPackGUID();
2959 GetTarget()->SendMessageToSet(&data
, true);
2962 void Aura::HandleAuraFeatherFall(bool apply
, bool Real
)
2964 // only at real add/remove aura
2967 Unit
*target
= GetTarget();
2970 data
.Initialize(SMSG_MOVE_FEATHER_FALL
, 8+4);
2972 data
.Initialize(SMSG_MOVE_NORMAL_FALL
, 8+4);
2973 data
<< target
->GetPackGUID();
2975 target
->SendMessageToSet(&data
, true);
2977 // start fall from current height
2978 if(!apply
&& target
->GetTypeId() == TYPEID_PLAYER
)
2979 ((Player
*)target
)->SetFallInformation(0, target
->GetPositionZ());
2982 void Aura::HandleAuraHover(bool apply
, bool Real
)
2984 // only at real add/remove aura
2990 data
.Initialize(SMSG_MOVE_SET_HOVER
, 8+4);
2992 data
.Initialize(SMSG_MOVE_UNSET_HOVER
, 8+4);
2993 data
<< GetTarget()->GetPackGUID();
2995 GetTarget()->SendMessageToSet(&data
, true);
2998 void Aura::HandleWaterBreathing(bool /*apply*/, bool /*Real*/)
3000 // update timers in client
3001 if(GetTarget()->GetTypeId()==TYPEID_PLAYER
)
3002 ((Player
*)GetTarget())->UpdateMirrorTimers();
3005 void Aura::HandleAuraModShapeshift(bool apply
, bool Real
)
3011 Powers PowerType
= POWER_MANA
;
3012 ShapeshiftForm form
= ShapeshiftForm(m_modifier
.m_miscvalue
);
3014 Unit
*target
= GetTarget();
3016 SpellShapeshiftEntry
const* ssEntry
= sSpellShapeshiftStore
.LookupEntry(form
);
3019 sLog
.outError("Unknown shapeshift form %u in spell %u", form
, GetId());
3023 if (ssEntry
->modelID_A
)
3025 // i will asume that creatures will always take the defined model from the dbc
3026 // since no field in creature_templates describes wether an alliance or
3027 // horde modelid should be used at shapeshifting
3028 if (target
->GetTypeId() != TYPEID_PLAYER
)
3029 modelid
= ssEntry
->modelID_A
;
3032 // players are a bit difficult since the dbc has seldomly an horde modelid
3033 // so we add hacks here to set the right model
3034 if (Player::TeamForRace(target
->getRace()) == ALLIANCE
)
3035 modelid
= ssEntry
->modelID_A
;
3036 else // 3.2.3 only the moonkin form has this information
3037 modelid
= ssEntry
->modelID_H
;
3039 // no model found, if player is horde we look here for our hardcoded modelids
3040 if (!modelid
&& Player::TeamForRace(target
->getRace()) == HORDE
)
3055 case FORM_FLIGHT_EPIC
:
3058 // per default use alliance modelid
3059 // mostly horde and alliance share the same
3061 modelid
= ssEntry
->modelID_A
;
3068 // now only powertype must be set
3072 PowerType
= POWER_ENERGY
;
3076 case FORM_BATTLESTANCE
:
3077 case FORM_BERSERKERSTANCE
:
3078 case FORM_DEFENSIVESTANCE
:
3079 PowerType
= POWER_RAGE
;
3085 // remove polymorph before changing display id to keep new display id
3094 case FORM_FLIGHT_EPIC
:
3098 // remove movement affects
3099 target
->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT
);
3100 Unit::AuraList
const& slowingAuras
= target
->GetAurasByType(SPELL_AURA_MOD_DECREASE_SPEED
);
3101 for (Unit::AuraList::const_iterator iter
= slowingAuras
.begin(); iter
!= slowingAuras
.end();)
3103 SpellEntry
const* aurSpellInfo
= (*iter
)->GetSpellProto();
3105 uint32 aurMechMask
= GetAllSpellMechanicMask(aurSpellInfo
);
3107 // If spell that caused this aura has Croud Control or Daze effect
3108 if((aurMechMask
& MECHANIC_NOT_REMOVED_BY_SHAPESHIFT
) ||
3109 // some Daze spells have these parameters instead of MECHANIC_DAZE (skip snare spells)
3110 aurSpellInfo
->SpellIconID
== 15 && aurSpellInfo
->Dispel
== 0 &&
3111 (aurMechMask
& (1 << (MECHANIC_SNARE
-1)))==0)
3117 // All OK, remove aura now
3118 target
->RemoveAurasDueToSpellByCancel(aurSpellInfo
->Id
);
3119 iter
= slowingAuras
.begin();
3122 // and polymorphic affects
3123 if(target
->IsPolymorphed())
3124 target
->RemoveAurasDueToSpell(target
->getTransForm());
3134 // remove other shapeshift before applying a new one
3135 if(target
->m_ShapeShiftFormSpellId
)
3136 target
->RemoveAurasDueToSpell(target
->m_ShapeShiftFormSpellId
, this);
3138 target
->SetByteValue(UNIT_FIELD_BYTES_2
, 3, form
);
3141 target
->SetDisplayId(modelid
);
3143 if(PowerType
!= POWER_MANA
)
3145 // reset power to default values only at power change
3146 if(target
->getPowerType() != PowerType
)
3147 target
->setPowerType(PowerType
);
3155 // get furor proc chance
3156 int32 furorChance
= 0;
3157 Unit::AuraList
const& mDummy
= target
->GetAurasByType(SPELL_AURA_DUMMY
);
3158 for(Unit::AuraList::const_iterator i
= mDummy
.begin(); i
!= mDummy
.end(); ++i
)
3160 if ((*i
)->GetSpellProto()->SpellIconID
== 238)
3162 furorChance
= (*i
)->GetModifier()->m_amount
;
3167 if (m_modifier
.m_miscvalue
== FORM_CAT
)
3169 // Furor chance is now amount allowed to save energy for cat form
3170 // without talent it reset to 0
3171 if ((int32
)target
->GetPower(POWER_ENERGY
) > furorChance
)
3173 target
->SetPower(POWER_ENERGY
, 0);
3174 target
->CastCustomSpell(target
, 17099, &furorChance
, NULL
, NULL
, this);
3177 else if(furorChance
) // only if talent known
3179 target
->SetPower(POWER_RAGE
, 0);
3180 if(irand(1,100) <= furorChance
)
3181 target
->CastSpell(target
, 17057, true, NULL
, this);
3185 case FORM_BATTLESTANCE
:
3186 case FORM_DEFENSIVESTANCE
:
3187 case FORM_BERSERKERSTANCE
:
3189 uint32 Rage_val
= 0;
3190 // Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch)
3191 if(target
->GetTypeId() == TYPEID_PLAYER
)
3193 PlayerSpellMap
const& sp_list
= ((Player
*)target
)->GetSpellMap();
3194 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
3196 if(itr
->second
.state
== PLAYERSPELL_REMOVED
) continue;
3197 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
3198 if (spellInfo
&& spellInfo
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& spellInfo
->SpellIconID
== 139)
3199 Rage_val
+= target
->CalculateSpellDamage(target
, spellInfo
, EFFECT_INDEX_0
) * 10;
3203 if (target
->GetPower(POWER_RAGE
) > Rage_val
)
3204 target
->SetPower(POWER_RAGE
, Rage_val
);
3212 target
->m_ShapeShiftFormSpellId
= GetId();
3213 target
->m_form
= form
;
3215 // a form can give the player a new castbar with some spells.. this is a clientside process..
3216 // serverside just needs to register the new spells so that player isn't kicked as cheater
3217 if (target
->GetTypeId() == TYPEID_PLAYER
)
3218 for (uint32 i
= 0; i
< 8; ++i
)
3219 if (ssEntry
->spellId
[i
])
3220 ((Player
*)target
)->addSpell(ssEntry
->spellId
[i
], true, false, false, false);
3226 target
->SetDisplayId(target
->GetNativeDisplayId());
3227 target
->SetByteValue(UNIT_FIELD_BYTES_2
, 3, FORM_NONE
);
3228 if(target
->getClass() == CLASS_DRUID
)
3229 target
->setPowerType(POWER_MANA
);
3230 target
->m_ShapeShiftFormSpellId
= 0;
3231 target
->m_form
= FORM_NONE
;
3235 // Nordrassil Harness - bonus
3239 if(Aura
* dummy
= target
->GetDummyAura(37315) )
3240 target
->CastSpell(target
, 37316, true, NULL
, dummy
);
3242 // Nordrassil Regalia - bonus
3244 if(Aura
* dummy
= target
->GetDummyAura(37324) )
3245 target
->CastSpell(target
, 37325, true, NULL
, dummy
);
3251 // look at the comment in apply-part
3252 if (target
->GetTypeId() == TYPEID_PLAYER
)
3253 for (uint32 i
= 0; i
< 8; ++i
)
3254 if (ssEntry
->spellId
[i
])
3255 ((Player
*)target
)->removeSpell(ssEntry
->spellId
[i
], false, false, false);
3259 // adding/removing linked auras
3260 // add/remove the shapeshift aura's boosts
3261 HandleShapeshiftBoosts(apply
);
3263 if(target
->GetTypeId() == TYPEID_PLAYER
)
3264 ((Player
*)target
)->InitDataForForm();
3267 void Aura::HandleAuraTransform(bool apply
, bool Real
)
3269 Unit
*target
= GetTarget();
3272 // special case (spell specific functionality)
3273 if (m_modifier
.m_miscvalue
== 0)
3275 // player applied only
3276 if (target
->GetTypeId() != TYPEID_PLAYER
)
3284 uint32 orb_model
= target
->GetNativeDisplayId();
3288 case 1479: target
->SetDisplayId(10134); break;
3290 case 1478: target
->SetDisplayId(10135); break;
3292 case 59: target
->SetDisplayId(10136); break;
3294 case 49: target
->SetDisplayId(10137); break;
3296 case 50: target
->SetDisplayId(10138); break;
3298 case 51: target
->SetDisplayId(10139); break;
3300 case 52: target
->SetDisplayId(10140); break;
3302 case 53: target
->SetDisplayId(10141); break;
3304 case 54: target
->SetDisplayId(10142); break;
3306 case 55: target
->SetDisplayId(10143); break;
3308 case 56: target
->SetDisplayId(10144); break;
3310 case 58: target
->SetDisplayId(10145); break;
3312 case 57: target
->SetDisplayId(10146); break;
3314 case 60: target
->SetDisplayId(10147); break;
3316 case 1563: target
->SetDisplayId(10148); break;
3318 case 1564: target
->SetDisplayId(10149); break;
3320 case 15475: target
->SetDisplayId(17830); break;
3322 case 15476: target
->SetDisplayId(17829); break;
3324 case 16126: target
->SetDisplayId(17828); break;
3326 case 16125: target
->SetDisplayId(17827); break;
3332 case 42365: target
->SetDisplayId(21723); break;
3337 switch(target
->getGender())
3340 target
->SetDisplayId(29203); // Chapman
3344 target
->SetDisplayId(29204); // Catrina
3356 CreatureInfo
const * ci
= ObjectMgr::GetCreatureTemplate(m_modifier
.m_miscvalue
);
3359 model_id
= 16358; // pig pink ^_^
3360 sLog
.outError("Auras: unknown creature id = %d (only need its modelid) Form Spell Aura Transform in Spell ID = %d", m_modifier
.m_miscvalue
, GetId());
3363 model_id
= ci
->DisplayID_A
[0]; // Will use the default model here
3365 // Polymorph (sheep/penguin case)
3366 if (GetSpellProto()->SpellFamilyName
== SPELLFAMILY_MAGE
&& GetSpellProto()->SpellIconID
== 82)
3367 if (Unit
* caster
= GetCaster())
3368 if (caster
->HasAura(52648)) // Glyph of the Penguin
3371 target
->SetDisplayId(model_id
);
3373 // creature case, need to update equipment
3374 if (ci
&& target
->GetTypeId() == TYPEID_UNIT
)
3375 ((Creature
*)target
)->LoadEquipment(ci
->equipmentId
, true);
3377 // Dragonmaw Illusion (set mount model also)
3378 if(GetId()==42016 && target
->GetMountID() && !target
->GetAurasByType(SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED
).empty())
3379 target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
,16314);
3382 // update active transform spell only not set or not overwriting negative by positive case
3383 if (!target
->getTransForm() || !IsPositiveSpell(GetId()) || IsPositiveSpell(target
->getTransForm()))
3384 target
->setTransForm(GetId());
3387 if (Real
&& target
->GetTypeId() == TYPEID_PLAYER
&& target
->IsPolymorphed())
3389 // for players, start regeneration after 1s (in polymorph fast regeneration case)
3390 // only if caster is Player (after patch 2.4.2)
3391 if (IS_PLAYER_GUID(GetCasterGUID()) )
3392 ((Player
*)target
)->setRegenTimer(1*IN_MILLISECONDS
);
3394 //dismount polymorphed target (after patch 2.4.2)
3395 if (target
->IsMounted())
3396 target
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
3401 // ApplyModifier(true) will reapply it if need
3402 target
->setTransForm(0);
3403 target
->SetDisplayId(target
->GetNativeDisplayId());
3405 // apply default equipment for creature case
3406 if (target
->GetTypeId() == TYPEID_UNIT
)
3407 ((Creature
*)target
)->LoadEquipment(((Creature
*)target
)->GetCreatureInfo()->equipmentId
, true);
3409 // re-apply some from still active with preference negative cases
3410 Unit::AuraList
const& otherTransforms
= target
->GetAurasByType(SPELL_AURA_TRANSFORM
);
3411 if (!otherTransforms
.empty())
3413 // look for other transform auras
3414 Aura
* handledAura
= *otherTransforms
.begin();
3415 for(Unit::AuraList::const_iterator i
= otherTransforms
.begin();i
!= otherTransforms
.end(); ++i
)
3417 // negative auras are preferred
3418 if (!IsPositiveSpell((*i
)->GetSpellProto()->Id
))
3424 handledAura
->ApplyModifier(true);
3427 // Dragonmaw Illusion (restore mount model)
3428 if (GetId() == 42016 && target
->GetMountID() == 16314)
3430 if (!target
->GetAurasByType(SPELL_AURA_MOUNTED
).empty())
3432 uint32 cr_id
= target
->GetAurasByType(SPELL_AURA_MOUNTED
).front()->GetModifier()->m_miscvalue
;
3433 if (CreatureInfo
const* ci
= ObjectMgr::GetCreatureTemplate(cr_id
))
3436 if (target
->GetTypeId() == TYPEID_PLAYER
)
3437 team
= ((Player
*)target
)->GetTeam();
3439 uint32 display_id
= sObjectMgr
.ChooseDisplayId(team
, ci
);
3440 CreatureModelInfo
const *minfo
= sObjectMgr
.GetCreatureModelRandomGender(display_id
);
3442 display_id
= minfo
->modelid
;
3444 target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
, display_id
);
3451 void Aura::HandleForceReaction(bool apply
, bool Real
)
3453 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
3459 Player
* player
= (Player
*)GetTarget();
3461 uint32 faction_id
= m_modifier
.m_miscvalue
;
3462 ReputationRank faction_rank
= ReputationRank(m_modifier
.m_amount
);
3464 player
->GetReputationMgr().ApplyForceReaction(faction_id
, faction_rank
, apply
);
3465 player
->GetReputationMgr().SendForceReactions();
3467 // stop fighting if at apply forced rank friendly or at remove real rank friendly
3468 if (apply
&& faction_rank
>= REP_FRIENDLY
|| !apply
&& player
->GetReputationRank(faction_id
) >= REP_FRIENDLY
)
3469 player
->StopAttackFaction(faction_id
);
3472 void Aura::HandleAuraModSkill(bool apply
, bool /*Real*/)
3474 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
3477 uint32 prot
=GetSpellProto()->EffectMiscValue
[m_effIndex
];
3478 int32 points
= GetModifier()->m_amount
;
3480 ((Player
*)GetTarget())->ModifySkillBonus(prot
, (apply
? points
: -points
), m_modifier
.m_auraname
== SPELL_AURA_MOD_SKILL_TALENT
);
3481 if(prot
== SKILL_DEFENSE
)
3482 ((Player
*)GetTarget())->UpdateDefenseBonusesMod();
3485 void Aura::HandleChannelDeathItem(bool apply
, bool Real
)
3489 if(m_removeMode
!= AURA_REMOVE_BY_DEATH
)
3492 if (m_modifier
.m_amount
<= 0)
3495 SpellEntry
const *spellInfo
= GetSpellProto();
3496 if(spellInfo
->EffectItemType
[m_effIndex
] == 0)
3499 Unit
* victim
= GetTarget();
3500 Unit
* caster
= GetCaster();
3501 if (!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3504 // Soul Shard (target req.)
3505 if (spellInfo
->EffectItemType
[m_effIndex
] == 6265)
3507 // Only from non-grey units
3508 if (!((Player
*)caster
)->isHonorOrXPTarget(victim
) ||
3509 victim
->GetTypeId() == TYPEID_UNIT
&& !((Player
*)caster
)->isAllowedToLoot((Creature
*)victim
))
3514 uint32 noSpaceForCount
= 0;
3515 uint32 count
= m_modifier
.m_amount
;
3517 ItemPosCountVec dest
;
3518 uint8 msg
= ((Player
*)caster
)->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, spellInfo
->EffectItemType
[m_effIndex
], count
, &noSpaceForCount
);
3519 if( msg
!= EQUIP_ERR_OK
)
3521 count
-=noSpaceForCount
;
3522 ((Player
*)caster
)->SendEquipError( msg
, NULL
, NULL
, spellInfo
->EffectItemType
[m_effIndex
] );
3527 Item
* newitem
= ((Player
*)caster
)->StoreNewItem(dest
, spellInfo
->EffectItemType
[m_effIndex
], true);
3528 ((Player
*)caster
)->SendNewItem(newitem
, count
, true, true);
3530 // Soul Shard (glyph bonus)
3531 if (spellInfo
->EffectItemType
[m_effIndex
] == 6265)
3533 // Glyph of Soul Shard
3534 if (caster
->HasAura(58070) && roll_chance_i(40))
3535 caster
->CastSpell(caster
, 58068, true, NULL
, this);
3540 void Aura::HandleBindSight(bool apply
, bool /*Real*/)
3542 Unit
* caster
= GetCaster();
3543 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3546 ((Player
*)caster
)->SetFarSightGUID(apply
? GetTarget()->GetGUID() : 0);
3549 void Aura::HandleFarSight(bool apply
, bool /*Real*/)
3551 Unit
* caster
= GetCaster();
3552 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3555 ((Player
*)caster
)->SetFarSightGUID(apply
? GetTarget()->GetGUID() : 0);
3558 void Aura::HandleAuraTrackCreatures(bool apply
, bool /*Real*/)
3560 if(GetTarget()->GetTypeId()!=TYPEID_PLAYER
)
3564 GetTarget()->RemoveNoStackAurasDueToAura(this);
3565 GetTarget()->SetUInt32Value(PLAYER_TRACK_CREATURES
, apply
? ((uint32
)1)<<(m_modifier
.m_miscvalue
-1) : 0 );
3568 void Aura::HandleAuraTrackResources(bool apply
, bool /*Real*/)
3570 if(GetTarget()->GetTypeId()!=TYPEID_PLAYER
)
3574 GetTarget()->RemoveNoStackAurasDueToAura(this);
3575 GetTarget()->SetUInt32Value(PLAYER_TRACK_RESOURCES
, apply
? ((uint32
)1)<<(m_modifier
.m_miscvalue
-1): 0 );
3578 void Aura::HandleAuraTrackStealthed(bool apply
, bool /*Real*/)
3580 if(GetTarget()->GetTypeId()!=TYPEID_PLAYER
)
3584 GetTarget()->RemoveNoStackAurasDueToAura(this);
3586 GetTarget()->ApplyModFlag(PLAYER_FIELD_BYTES
, PLAYER_FIELD_BYTE_TRACK_STEALTHED
, apply
);
3589 void Aura::HandleAuraModScale(bool apply
, bool /*Real*/)
3591 GetTarget()->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X
, float(m_modifier
.m_amount
), apply
);
3594 void Aura::HandleModPossess(bool apply
, bool Real
)
3599 Unit
*target
= GetTarget();
3601 // not possess yourself
3602 if(GetCasterGUID() == target
->GetGUID())
3605 Unit
* caster
= GetCaster();
3606 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3609 Player
* p_caster
= (Player
*)caster
;
3614 target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PLAYER_CONTROLLED
);
3616 target
->SetCharmerGUID(p_caster
->GetGUID());
3617 target
->setFaction(p_caster
->getFaction());
3619 p_caster
->SetCharm(target
);
3621 p_caster
->SetFarSightGUID(target
->GetGUID());
3622 p_caster
->SetClientControl(target
, 1);
3623 p_caster
->SetMover(target
);
3625 target
->CombatStop();
3626 target
->DeleteThreatList();
3628 if(target
->GetTypeId() == TYPEID_UNIT
)
3630 target
->StopMoving();
3631 target
->GetMotionMaster()->Clear();
3632 target
->GetMotionMaster()->MoveIdle();
3634 else if(target
->GetTypeId() == TYPEID_PLAYER
)
3636 ((Player
*)target
)->SetClientControl(target
, 0);
3639 if(CharmInfo
*charmInfo
= target
->InitCharmInfo(target
))
3640 charmInfo
->InitPossessCreateSpells();
3642 p_caster
->PossessSpellInitialize();
3646 p_caster
->InterruptSpell(CURRENT_CHANNELED_SPELL
); // the spell is not automatically canceled when interrupted, do it now
3647 p_caster
->SetCharm(NULL
);
3649 p_caster
->SetFarSightGUID(0);
3650 p_caster
->SetClientControl(target
, 0);
3651 p_caster
->SetMover(NULL
);
3653 p_caster
->RemovePetActionBar();
3655 // on delete only do caster related effects
3656 if(m_removeMode
== AURA_REMOVE_BY_DELETE
)
3659 target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PLAYER_CONTROLLED
);
3661 target
->SetCharmerGUID(0);
3663 if(target
->GetTypeId() == TYPEID_PLAYER
)
3665 ((Player
*)target
)->setFactionForRace(target
->getRace());
3666 ((Player
*)target
)->SetClientControl(target
, 1);
3668 else if(target
->GetTypeId() == TYPEID_UNIT
)
3670 CreatureInfo
const *cinfo
= ((Creature
*)target
)->GetCreatureInfo();
3671 target
->setFaction(cinfo
->faction_A
);
3674 if(target
->GetTypeId() == TYPEID_UNIT
)
3676 ((Creature
*)target
)->AIM_Initialize();
3678 if (((Creature
*)target
)->AI())
3679 ((Creature
*)target
)->AI()->AttackedBy(caster
);
3684 void Aura::HandleModPossessPet(bool apply
, bool Real
)
3689 Unit
* caster
= GetCaster();
3690 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3693 Pet
*pet
= caster
->GetPet();
3694 if(!pet
|| pet
!= GetTarget())
3697 Player
* p_caster
= (Player
*)caster
;
3700 pet
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PLAYER_CONTROLLED
);
3702 pet
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PLAYER_CONTROLLED
);
3704 p_caster
->SetFarSightGUID(apply
? pet
->GetGUID() : 0);
3705 p_caster
->SetCharm(apply
? pet
: NULL
);
3706 p_caster
->SetClientControl(pet
, apply
? 1 : 0);
3707 ((Player
*)caster
)->SetMover(apply
? pet
: NULL
);
3712 pet
->GetMotionMaster()->Clear();
3713 pet
->GetMotionMaster()->MoveIdle();
3718 pet
->GetMotionMaster()->MoveFollow(caster
, PET_FOLLOW_DIST
, PET_FOLLOW_ANGLE
);
3719 pet
->AddSplineFlag(SPLINEFLAG_WALKMODE
);
3723 void Aura::HandleAuraModPetTalentsPoints(bool /*Apply*/, bool Real
)
3728 // Recalculate pet talent points
3729 if (Pet
*pet
=GetTarget()->GetPet())
3730 pet
->InitTalentForLevel();
3733 void Aura::HandleModCharm(bool apply
, bool Real
)
3738 Unit
*target
= GetTarget();
3740 // not charm yourself
3741 if(GetCasterGUID() == target
->GetGUID())
3744 Unit
* caster
= GetCaster();
3750 if (target
->GetCharmerGUID())
3752 target
->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM
);
3753 target
->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS
);
3756 target
->SetCharmerGUID(GetCasterGUID());
3757 target
->setFaction(caster
->getFaction());
3758 target
->CastStop(target
== caster
? GetId() : 0);
3759 caster
->SetCharm(target
);
3761 target
->CombatStop();
3762 target
->DeleteThreatList();
3764 if(target
->GetTypeId() == TYPEID_UNIT
)
3766 ((Creature
*)target
)->AIM_Initialize();
3767 CharmInfo
*charmInfo
= target
->InitCharmInfo(target
);
3768 charmInfo
->InitCharmCreateSpells();
3769 charmInfo
->SetReactState( REACT_DEFENSIVE
);
3771 if(caster
->GetTypeId() == TYPEID_PLAYER
&& caster
->getClass() == CLASS_WARLOCK
)
3773 CreatureInfo
const *cinfo
= ((Creature
*)target
)->GetCreatureInfo();
3774 if(cinfo
&& cinfo
->type
== CREATURE_TYPE_DEMON
)
3776 // creature with pet number expected have class set
3777 if(target
->GetByteValue(UNIT_FIELD_BYTES_0
, 1)==0)
3779 if(cinfo
->unit_class
==0)
3780 sLog
.outErrorDb("Creature (Entry: %u) have unit_class = 0 but used in charmed spell, that will be result client crash.",cinfo
->Entry
);
3782 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
);
3784 target
->SetByteValue(UNIT_FIELD_BYTES_0
, 1, CLASS_MAGE
);
3787 //just to enable stat window
3788 charmInfo
->SetPetNumber(sObjectMgr
.GeneratePetNumber(), true);
3789 //if charmed two demons the same session, the 2nd gets the 1st one's name
3790 target
->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP
, uint32(time(NULL
)));
3795 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3796 ((Player
*)caster
)->CharmSpellInitialize();
3800 target
->SetCharmerGUID(0);
3802 if(target
->GetTypeId() == TYPEID_PLAYER
)
3803 ((Player
*)target
)->setFactionForRace(target
->getRace());
3806 CreatureInfo
const *cinfo
= ((Creature
*)target
)->GetCreatureInfo();
3809 if(((Creature
*)target
)->isPet())
3811 if(Unit
* owner
= target
->GetOwner())
3812 target
->setFaction(owner
->getFaction());
3814 target
->setFaction(cinfo
->faction_A
);
3816 else if(cinfo
) // normal creature
3817 target
->setFaction(cinfo
->faction_A
);
3819 // restore UNIT_FIELD_BYTES_0
3820 if(cinfo
&& caster
->GetTypeId() == TYPEID_PLAYER
&& caster
->getClass() == CLASS_WARLOCK
&& cinfo
->type
== CREATURE_TYPE_DEMON
)
3822 // DB must have proper class set in field at loading, not req. restore, including workaround case at apply
3823 // m_target->SetByteValue(UNIT_FIELD_BYTES_0, 1, cinfo->unit_class);
3825 if(target
->GetCharmInfo())
3826 target
->GetCharmInfo()->SetPetNumber(0, true);
3828 sLog
.outError("Aura::HandleModCharm: target (GUID: %u TypeId: %u) has a charm aura but no charm info!", target
->GetGUIDLow(), target
->GetTypeId());
3832 caster
->SetCharm(NULL
);
3834 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3835 ((Player
*)caster
)->RemovePetActionBar();
3837 if(target
->GetTypeId() == TYPEID_UNIT
)
3839 ((Creature
*)target
)->AIM_Initialize();
3840 if (((Creature
*)target
)->AI())
3841 ((Creature
*)target
)->AI()->AttackedBy(caster
);
3846 void Aura::HandleModConfuse(bool apply
, bool Real
)
3851 GetTarget()->SetConfused(apply
, GetCasterGUID(), GetId());
3854 void Aura::HandleModFear(bool apply
, bool Real
)
3859 GetTarget()->SetFeared(apply
, GetCasterGUID(), GetId());
3862 void Aura::HandleFeignDeath(bool apply
, bool Real
)
3867 GetTarget()->SetFeignDeath(apply
, GetCasterGUID(), GetId());
3870 void Aura::HandleAuraModDisarm(bool apply
, bool Real
)
3875 Unit
*target
= GetTarget();
3877 if(!apply
&& target
->HasAuraType(SPELL_AURA_MOD_DISARM
))
3880 // not sure for it's correctness
3882 target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_DISARMED
);
3884 target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_DISARMED
);
3886 // only at real add/remove aura
3887 if (target
->GetTypeId() != TYPEID_PLAYER
)
3890 // main-hand attack speed already set to special value for feral form already and don't must change and reset at remove.
3891 if (target
->IsInFeralForm())
3895 target
->SetAttackTime(BASE_ATTACK
,BASE_ATTACK_TIME
);
3897 ((Player
*)target
)->SetRegularAttackTime();
3899 target
->UpdateDamagePhysical(BASE_ATTACK
);
3902 void Aura::HandleAuraModStun(bool apply
, bool Real
)
3907 Unit
*target
= GetTarget();
3911 // Frost stun aura -> freeze/unfreeze target
3912 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_FROST
)
3913 target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
3915 target
->addUnitState(UNIT_STAT_STUNNED
);
3916 target
->SetTargetGUID(0);
3918 target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
3919 target
->CastStop(target
->GetGUID() == GetCasterGUID() ? GetId() : 0);
3921 // Creature specific
3922 if(target
->GetTypeId() != TYPEID_PLAYER
)
3923 target
->StopMoving();
3926 ((Player
*)target
)->m_movementInfo
.SetMovementFlags(MOVEFLAG_NONE
);
3927 target
->SetStandState(UNIT_STAND_STATE_STAND
);// in 1.5 client
3930 WorldPacket
data(SMSG_FORCE_MOVE_ROOT
, 8);
3931 data
<< target
->GetPackGUID();
3933 target
->SendMessageToSet(&data
, true);
3935 // Summon the Naj'entus Spine GameObject on target if spell is Impaling Spine
3936 if(GetId() == 39837)
3938 GameObject
* pObj
= new GameObject
;
3939 if(pObj
->Create(sObjectMgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), 185584, target
->GetMap(), target
->GetPhaseMask(),
3940 target
->GetPositionX(), target
->GetPositionY(), target
->GetPositionZ(), target
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 100, GO_STATE_READY
))
3942 pObj
->SetRespawnTime(GetAuraDuration()/IN_MILLISECONDS
);
3943 pObj
->SetSpellId(GetId());
3944 target
->AddGameObject(pObj
);
3945 target
->GetMap()->Add(pObj
);
3953 // Frost stun aura -> freeze/unfreeze target
3954 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_FROST
)
3956 bool found_another
= false;
3957 for(AuraType
const* itr
= &frozenAuraTypes
[0]; *itr
!= SPELL_AURA_NONE
; ++itr
)
3959 Unit::AuraList
const& auras
= target
->GetAurasByType(*itr
);
3960 for(Unit::AuraList::const_iterator i
= auras
.begin(); i
!= auras
.end(); ++i
)
3962 if( GetSpellSchoolMask((*i
)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST
)
3964 found_another
= true;
3973 target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
3976 // Real remove called after current aura remove from lists, check if other similar auras active
3977 if(target
->HasAuraType(SPELL_AURA_MOD_STUN
))
3980 target
->clearUnitState(UNIT_STAT_STUNNED
);
3981 target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
3983 if(!target
->hasUnitState(UNIT_STAT_ROOT
)) // prevent allow move if have also root effect
3985 if(target
->getVictim() && target
->isAlive())
3986 target
->SetTargetGUID(target
->getVictim()->GetGUID());
3988 WorldPacket
data(SMSG_FORCE_MOVE_UNROOT
, 8+4);
3989 data
<< target
->GetPackGUID();
3991 target
->SendMessageToSet(&data
, true);
3995 if (GetSpellProto()->SpellFamilyName
== SPELLFAMILY_HUNTER
&& GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000100000000000))
3997 Unit
* caster
= GetCaster();
3998 if( !caster
|| caster
->GetTypeId()!=TYPEID_PLAYER
)
4001 uint32 spell_id
= 0;
4005 case 19386: spell_id
= 24131; break;
4006 case 24132: spell_id
= 24134; break;
4007 case 24133: spell_id
= 24135; break;
4008 case 27068: spell_id
= 27069; break;
4009 case 49011: spell_id
= 49009; break;
4010 case 49012: spell_id
= 49010; break;
4012 sLog
.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?",GetId());
4016 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell_id
);
4021 caster
->CastSpell(target
,spellInfo
,true,NULL
,this);
4027 void Aura::HandleModStealth(bool apply
, bool Real
)
4029 Unit
*target
= GetTarget();
4033 // drop flag at stealth in bg
4034 target
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
);
4036 // only at real aura add
4039 target
->SetStandFlags(UNIT_STAND_FLAGS_CREEP
);
4041 if (target
->GetTypeId()==TYPEID_PLAYER
)
4042 target
->SetFlag(PLAYER_FIELD_BYTES2
, 0x2000);
4044 // apply only if not in GM invisibility (and overwrite invisibility state)
4045 if (target
->GetVisibility()!=VISIBILITY_OFF
)
4047 target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
4048 target
->SetVisibility(VISIBILITY_GROUP_STEALTH
);
4051 // apply full stealth period bonuses only at first stealth aura in stack
4052 if(target
->GetAurasByType(SPELL_AURA_MOD_STEALTH
).size()<=1)
4054 Unit::AuraList
const& mDummyAuras
= target
->GetAurasByType(SPELL_AURA_DUMMY
);
4055 for(Unit::AuraList::const_iterator i
= mDummyAuras
.begin();i
!= mDummyAuras
.end(); ++i
)
4057 // Master of Subtlety
4058 if ((*i
)->GetSpellProto()->SpellIconID
== 2114)
4060 target
->RemoveAurasDueToSpell(31666);
4061 int32 bp
= (*i
)->GetModifier()->m_amount
;
4062 target
->CastCustomSpell(target
,31665,&bp
,NULL
,NULL
,true);
4065 else if ((*i
)->GetId() == 58426 && GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000400000))
4067 target
->RemoveAurasDueToSpell(58428);
4068 target
->CastSpell(target
, 58427, true);
4076 // only at real aura remove of _last_ SPELL_AURA_MOD_STEALTH
4077 if (Real
&& !target
->HasAuraType(SPELL_AURA_MOD_STEALTH
))
4079 // if no GM invisibility
4080 if (target
->GetVisibility()!=VISIBILITY_OFF
)
4082 target
->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP
);
4084 if (target
->GetTypeId()==TYPEID_PLAYER
)
4085 target
->RemoveFlag(PLAYER_FIELD_BYTES2
, 0x2000);
4087 // restore invisibility if any
4088 if (target
->HasAuraType(SPELL_AURA_MOD_INVISIBILITY
))
4090 target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
4091 target
->SetVisibility(VISIBILITY_GROUP_INVISIBILITY
);
4094 target
->SetVisibility(VISIBILITY_ON
);
4097 // apply delayed talent bonus remover at last stealth aura remove
4098 Unit::AuraList
const& mDummyAuras
= target
->GetAurasByType(SPELL_AURA_DUMMY
);
4099 for(Unit::AuraList::const_iterator i
= mDummyAuras
.begin();i
!= mDummyAuras
.end(); ++i
)
4101 // Master of Subtlety
4102 if ((*i
)->GetSpellProto()->SpellIconID
== 2114)
4103 target
->CastSpell(target
, 31666, true);
4105 else if ((*i
)->GetId() == 58426 && GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000400000))
4106 target
->CastSpell(target
, 58428, true);
4112 void Aura::HandleInvisibility(bool apply
, bool Real
)
4114 Unit
*target
= GetTarget();
4118 target
->m_invisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
4120 target
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
);
4122 if(Real
&& target
->GetTypeId()==TYPEID_PLAYER
)
4124 // apply glow vision
4125 target
->SetFlag(PLAYER_FIELD_BYTES2
,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
);
4129 // apply only if not in GM invisibility and not stealth
4130 if(target
->GetVisibility() == VISIBILITY_ON
)
4132 // Aura not added yet but visibility code expect temporary add aura
4133 target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
4134 target
->SetVisibility(VISIBILITY_GROUP_INVISIBILITY
);
4139 // recalculate value at modifier remove (current aura already removed)
4140 target
->m_invisibilityMask
= 0;
4141 Unit::AuraList
const& auras
= target
->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY
);
4142 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
4143 target
->m_invisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
4145 // only at real aura remove and if not have different invisibility auras.
4146 if(Real
&& target
->m_invisibilityMask
== 0)
4148 // remove glow vision
4149 if(target
->GetTypeId() == TYPEID_PLAYER
)
4150 target
->RemoveFlag(PLAYER_FIELD_BYTES2
,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
);
4152 // apply only if not in GM invisibility & not stealthed while invisible
4153 if(target
->GetVisibility() != VISIBILITY_OFF
)
4155 // if have stealth aura then already have stealth visibility
4156 if(!target
->HasAuraType(SPELL_AURA_MOD_STEALTH
))
4157 target
->SetVisibility(VISIBILITY_ON
);
4163 void Aura::HandleInvisibilityDetect(bool apply
, bool Real
)
4165 Unit
*target
= GetTarget();
4169 target
->m_detectInvisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
4173 // recalculate value at modifier remove (current aura already removed)
4174 target
->m_detectInvisibilityMask
= 0;
4175 Unit::AuraList
const& auras
= target
->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION
);
4176 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
4177 target
->m_detectInvisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
4179 if(Real
&& target
->GetTypeId()==TYPEID_PLAYER
)
4180 ((Player
*)target
)->UpdateVisibilityForPlayer();
4183 void Aura::HandleAuraModRoot(bool apply
, bool Real
)
4185 // only at real add/remove aura
4189 Unit
*target
= GetTarget();
4193 // Frost root aura -> freeze/unfreeze target
4194 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_FROST
)
4195 target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
4197 target
->addUnitState(UNIT_STAT_ROOT
);
4198 target
->SetTargetGUID(0);
4200 //Save last orientation
4201 if( target
->getVictim() )
4202 target
->SetOrientation(target
->GetAngle(target
->getVictim()));
4204 if(target
->GetTypeId() == TYPEID_PLAYER
)
4206 WorldPacket
data(SMSG_FORCE_MOVE_ROOT
, 10);
4207 data
<< target
->GetPackGUID();
4209 target
->SendMessageToSet(&data
, true);
4211 //Clear unit movement flags
4212 ((Player
*)target
)->m_movementInfo
.SetMovementFlags(MOVEFLAG_NONE
);
4215 target
->StopMoving();
4219 // Frost root aura -> freeze/unfreeze target
4220 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_FROST
)
4222 bool found_another
= false;
4223 for(AuraType
const* itr
= &frozenAuraTypes
[0]; *itr
!= SPELL_AURA_NONE
; ++itr
)
4225 Unit::AuraList
const& auras
= target
->GetAurasByType(*itr
);
4226 for(Unit::AuraList::const_iterator i
= auras
.begin(); i
!= auras
.end(); ++i
)
4228 if( GetSpellSchoolMask((*i
)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST
)
4230 found_another
= true;
4239 target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
4242 // Real remove called after current aura remove from lists, check if other similar auras active
4243 if(target
->HasAuraType(SPELL_AURA_MOD_ROOT
))
4246 target
->clearUnitState(UNIT_STAT_ROOT
);
4248 if(!target
->hasUnitState(UNIT_STAT_STUNNED
)) // prevent allow move if have also stun effect
4250 if(target
->getVictim() && target
->isAlive())
4251 target
->SetTargetGUID(target
->getVictim()->GetGUID());
4253 if(target
->GetTypeId() == TYPEID_PLAYER
)
4255 WorldPacket
data(SMSG_FORCE_MOVE_UNROOT
, 10);
4256 data
<< target
->GetPackGUID();
4258 target
->SendMessageToSet(&data
, true);
4264 void Aura::HandleAuraModSilence(bool apply
, bool Real
)
4266 // only at real add/remove aura
4270 Unit
*target
= GetTarget();
4274 target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_SILENCED
);
4275 // Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE
4276 for (uint32 i
= CURRENT_MELEE_SPELL
; i
< CURRENT_MAX_SPELL
; ++i
)
4277 if (Spell
* spell
= target
->GetCurrentSpell(CurrentSpellTypes(i
)))
4278 if(spell
->m_spellInfo
->PreventionType
== SPELL_PREVENTION_TYPE_SILENCE
)
4279 // Stop spells on prepare or casting state
4280 target
->InterruptSpell(CurrentSpellTypes(i
), false);
4284 // Real remove called after current aura remove from lists, check if other similar auras active
4285 if(target
->HasAuraType(SPELL_AURA_MOD_SILENCE
))
4288 target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_SILENCED
);
4292 void Aura::HandleModThreat(bool apply
, bool Real
)
4294 // only at real add/remove aura
4298 Unit
*target
= GetTarget();
4300 if (!target
->isAlive())
4303 Unit
* caster
= GetCaster();
4305 if (!caster
|| !caster
->isAlive())
4314 level_diff
= target
->getLevel() - 60;
4317 // The Eye of Diminution
4319 level_diff
= target
->getLevel() - 60;
4325 m_modifier
.m_amount
+= multiplier
* level_diff
;
4327 if (target
->GetTypeId() == TYPEID_PLAYER
)
4328 for(int8 x
=0;x
< MAX_SPELL_SCHOOL
;x
++)
4329 if (m_modifier
.m_miscvalue
& int32(1<<x
))
4330 ApplyPercentModFloatVar(target
->m_threatModifier
[x
], float(m_modifier
.m_amount
), apply
);
4333 void Aura::HandleAuraModTotalThreat(bool apply
, bool Real
)
4335 // only at real add/remove aura
4339 Unit
*target
= GetTarget();
4341 if (!target
->isAlive() || target
->GetTypeId() != TYPEID_PLAYER
)
4344 Unit
* caster
= GetCaster();
4346 if (!caster
|| !caster
->isAlive())
4349 float threatMod
= apply
? float(m_modifier
.m_amount
) : float(-m_modifier
.m_amount
);
4351 target
->getHostileRefManager().threatAssist(caster
, threatMod
, GetSpellProto());
4354 void Aura::HandleModTaunt(bool apply
, bool Real
)
4356 // only at real add/remove aura
4360 Unit
*target
= GetTarget();
4362 if (!target
->isAlive() || !target
->CanHaveThreatList())
4365 Unit
* caster
= GetCaster();
4367 if (!caster
|| !caster
->isAlive())
4371 target
->TauntApply(caster
);
4374 // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat
4375 target
->TauntFadeOut(caster
);
4379 /*********************************************************/
4380 /*** MODIFY SPEED ***/
4381 /*********************************************************/
4382 void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real
)
4384 // all applied/removed only at real aura add/remove
4388 GetTarget()->UpdateSpeed(MOVE_RUN
, true);
4391 void Aura::HandleAuraModIncreaseMountedSpeed(bool apply
, bool Real
)
4393 // all applied/removed only at real aura add/remove
4397 Unit
*target
= GetTarget();
4399 target
->UpdateSpeed(MOVE_RUN
, true);
4401 // Festive Holiday Mount
4402 if (apply
&& GetSpellProto()->SpellIconID
!= 1794 && target
->HasAura(62061))
4403 // Reindeer Transformation
4404 target
->CastSpell(target
, 25860, true, NULL
, this);
4407 void Aura::HandleAuraModIncreaseFlightSpeed(bool apply
, bool Real
)
4409 // all applied/removed only at real aura add/remove
4413 Unit
*target
= GetTarget();
4415 // Enable Fly mode for flying mounts
4416 if (m_modifier
.m_auraname
== SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED
)
4420 data
.Initialize(SMSG_MOVE_SET_CAN_FLY
, 12);
4422 data
.Initialize(SMSG_MOVE_UNSET_CAN_FLY
, 12);
4423 data
<< target
->GetPackGUID();
4424 data
<< uint32(0); // unknown
4425 target
->SendMessageToSet(&data
, true);
4427 //Players on flying mounts must be immune to polymorph
4428 if (target
->GetTypeId()==TYPEID_PLAYER
)
4429 target
->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC
,MECHANIC_POLYMORPH
,apply
);
4431 // Dragonmaw Illusion (overwrite mount model, mounted aura already applied)
4432 if (apply
&& target
->HasAura(42016, EFFECT_INDEX_0
) && target
->GetMountID())
4433 target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
,16314);
4435 // Festive Holiday Mount
4436 if (apply
&& GetSpellProto()->SpellIconID
!= 1794 && target
->HasAura(62061))
4437 // Reindeer Transformation
4438 target
->CastSpell(target
, 25860, true, NULL
, this);
4441 // Swift Flight Form check for higher speed flying mounts
4442 if (apply
&& target
->GetTypeId() == TYPEID_PLAYER
&& GetSpellProto()->Id
== 40121)
4444 for (PlayerSpellMap::const_iterator iter
= ((Player
*)target
)->GetSpellMap().begin(); iter
!= ((Player
*)target
)->GetSpellMap().end(); ++iter
)
4446 if (iter
->second
.state
!= PLAYERSPELL_REMOVED
)
4448 bool changedSpeed
= false;
4449 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(iter
->first
);
4450 for(int i
= 0; i
< MAX_EFFECT_INDEX
; ++i
)
4452 if(spellInfo
->EffectApplyAuraName
[i
] == SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED
)
4454 int32 mountSpeed
= spellInfo
->CalculateSimpleValue(SpellEffectIndex(i
));
4455 if (mountSpeed
> m_modifier
.m_amount
)
4457 m_modifier
.m_amount
= mountSpeed
;
4458 changedSpeed
= true;
4469 target
->UpdateSpeed(MOVE_FLIGHT
, true);
4472 void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real
)
4474 // all applied/removed only at real aura add/remove
4478 GetTarget()->UpdateSpeed(MOVE_SWIM
, true);
4481 void Aura::HandleAuraModDecreaseSpeed(bool apply
, bool Real
)
4483 // all applied/removed only at real aura add/remove
4487 Unit
*target
= GetTarget();
4491 // Gronn Lord's Grasp, becomes stoned
4492 if (GetId() == 33572)
4494 if (GetStackAmount() >= 5 && !target
->HasAura(33652))
4495 target
->CastSpell(target
, 33652, true);
4499 target
->UpdateSpeed(MOVE_RUN
, true);
4500 target
->UpdateSpeed(MOVE_SWIM
, true);
4501 target
->UpdateSpeed(MOVE_FLIGHT
, true);
4504 void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real
)
4506 // all applied/removed only at real aura add/remove
4510 Unit
*target
= GetTarget();
4512 target
->UpdateSpeed(MOVE_RUN
, true);
4513 target
->UpdateSpeed(MOVE_SWIM
, true);
4514 target
->UpdateSpeed(MOVE_FLIGHT
, true);
4517 /*********************************************************/
4519 /*********************************************************/
4521 void Aura::HandleModMechanicImmunity(bool apply
, bool /*Real*/)
4523 uint32 misc
= m_modifier
.m_miscvalue
;
4525 // in DBC wrong mechanic immune since 3.0.x
4526 if (GetId() == 25771)
4527 misc
= MECHANIC_IMMUNE_SHIELD
;
4529 Unit
*target
= GetTarget();
4531 if(apply
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
4533 uint32 mechanic
= 1 << (misc
-1);
4535 //immune movement impairment and loss of control
4536 if(GetId()==42292 || GetId()==59752)
4537 mechanic
=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK
;
4539 target
->RemoveAurasAtMechanicImmunity(mechanic
,GetId());
4542 target
->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC
,misc
,apply
);
4545 if (GetSpellProto()->SpellFamilyName
== SPELLFAMILY_HUNTER
&& GetSpellProto()->SpellIconID
== 1680)
4547 // The Beast Within cast on owner if talent present
4548 if (Unit
* owner
= target
->GetOwner())
4550 // Search talent The Beast Within
4551 Unit::AuraList
const& dummyAuras
= owner
->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE
);
4552 for(Unit::AuraList::const_iterator i
= dummyAuras
.begin(); i
!= dummyAuras
.end(); ++i
)
4554 if ((*i
)->GetSpellProto()->SpellIconID
== 2229)
4557 owner
->CastSpell(owner
, 34471, true, NULL
, this);
4559 owner
->RemoveAurasDueToSpell(34471);
4565 // Heroic Fury (Intercept cooldown remove)
4566 else if (apply
&& GetSpellProto()->Id
== 60970 && target
->GetTypeId() == TYPEID_PLAYER
)
4567 ((Player
*)target
)->RemoveSpellCooldown(20252, true);
4570 void Aura::HandleModMechanicImmunityMask(bool apply
, bool /*Real*/)
4572 uint32 mechanic
= m_modifier
.m_miscvalue
;
4574 if(apply
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
4575 GetTarget()->RemoveAurasAtMechanicImmunity(mechanic
,GetId());
4577 // check implemented in Unit::IsImmunedToSpell and Unit::IsImmunedToSpellEffect
4580 //this method is called whenever we add / remove aura which gives m_target some imunity to some spell effect
4581 void Aura::HandleAuraModEffectImmunity(bool apply
, bool /*Real*/)
4583 Unit
*target
= GetTarget();
4585 // when removing flag aura, handle flag drop
4586 if( !apply
&& target
->GetTypeId() == TYPEID_PLAYER
4587 && (GetSpellProto()->AuraInterruptFlags
& AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
) )
4589 if( BattleGround
*bg
= ((Player
*)target
)->GetBattleGround() )
4590 bg
->EventPlayerDroppedFlag(((Player
*)target
));
4593 target
->ApplySpellImmune(GetId(), IMMUNITY_EFFECT
, m_modifier
.m_miscvalue
, apply
);
4596 void Aura::HandleAuraModStateImmunity(bool apply
, bool Real
)
4598 if(apply
&& Real
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
4600 Unit::AuraList
const& auraList
= GetTarget()->GetAurasByType(AuraType(m_modifier
.m_miscvalue
));
4601 for(Unit::AuraList::const_iterator itr
= auraList
.begin(); itr
!= auraList
.end();)
4603 if (auraList
.front() != this) // skip itself aura (it already added)
4605 GetTarget()->RemoveAurasDueToSpell(auraList
.front()->GetId());
4606 itr
= auraList
.begin();
4613 GetTarget()->ApplySpellImmune(GetId(), IMMUNITY_STATE
, m_modifier
.m_miscvalue
, apply
);
4616 void Aura::HandleAuraModSchoolImmunity(bool apply
, bool Real
)
4618 Unit
* target
= GetTarget();
4619 target
->ApplySpellImmune(GetId(), IMMUNITY_SCHOOL
, m_modifier
.m_miscvalue
, apply
);
4621 // remove all flag auras (they are positive, but they must be removed when you are immune)
4622 if( GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
4623 && GetSpellProto()->AttributesEx2
& SPELL_ATTR_EX2_DAMAGE_REDUCED_SHIELD
)
4624 target
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
);
4626 // TODO: optimalize this cycle - use RemoveAurasWithInterruptFlags call or something else
4628 && GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
4629 && IsPositiveSpell(GetId()) ) //Only positive immunity removes auras
4631 uint32 school_mask
= m_modifier
.m_miscvalue
;
4632 Unit::AuraMap
& Auras
= target
->GetAuras();
4633 for(Unit::AuraMap::iterator iter
= Auras
.begin(), next
; iter
!= Auras
.end(); iter
= next
)
4637 SpellEntry
const *spell
= iter
->second
->GetSpellProto();
4638 if((GetSpellSchoolMask(spell
) & school_mask
)//Check for school mask
4639 && !( spell
->Attributes
& SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY
) //Spells unaffected by invulnerability
4640 && !iter
->second
->IsPositive() //Don't remove positive spells
4641 && spell
->Id
!= GetId() ) //Don't remove self
4643 target
->RemoveAurasDueToSpell(spell
->Id
);
4647 next
= Auras
.begin();
4651 if( Real
&& GetSpellProto()->Mechanic
== MECHANIC_BANISH
)
4654 target
->addUnitState(UNIT_STAT_ISOLATED
);
4656 target
->clearUnitState(UNIT_STAT_ISOLATED
);
4660 void Aura::HandleAuraModDmgImmunity(bool apply
, bool /*Real*/)
4662 GetTarget()->ApplySpellImmune(GetId(), IMMUNITY_DAMAGE
, m_modifier
.m_miscvalue
, apply
);
4665 void Aura::HandleAuraModDispelImmunity(bool apply
, bool Real
)
4667 // all applied/removed only at real aura add/remove
4671 GetTarget()->ApplySpellDispelImmunity(GetSpellProto(), DispelType(m_modifier
.m_miscvalue
), apply
);
4674 void Aura::HandleAuraProcTriggerSpell(bool apply
, bool Real
)
4681 // some spell have charges by functionality not have its in spell data
4684 case 28200: // Ascendance (Talisman of Ascendance trinket)
4692 void Aura::HandleAuraModStalked(bool apply
, bool /*Real*/)
4694 // used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND
4696 GetTarget()->SetFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_TRACK_UNIT
);
4698 GetTarget()->RemoveFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_TRACK_UNIT
);
4701 /*********************************************************/
4703 /*********************************************************/
4705 void Aura::HandlePeriodicTriggerSpell(bool apply
, bool /*Real*/)
4707 m_isPeriodic
= apply
;
4709 Unit
*target
= GetTarget();
4715 case 66: // Invisibility
4716 if (m_removeMode
== AURA_REMOVE_BY_EXPIRE
)
4717 target
->CastSpell(target
, 32612, true, NULL
, this);
4720 case 42783: //Wrath of the Astrom...
4721 if (m_removeMode
== AURA_REMOVE_BY_DEFAULT
&& GetEffIndex() + 1 < MAX_EFFECT_INDEX
)
4722 target
->CastSpell(target
, GetSpellProto()->CalculateSimpleValue(SpellEffectIndex(GetEffIndex()+1)), true);
4724 case 51912: // Ultra-Advanced Proto-Typical Shortening Blaster
4725 if (m_removeMode
== AURA_REMOVE_BY_EXPIRE
)
4727 if (Unit
* pCaster
= GetCaster())
4728 pCaster
->CastSpell(target
, GetSpellProto()->EffectTriggerSpell
[GetEffIndex()], true, NULL
, this);
4738 void Aura::HandlePeriodicTriggerSpellWithValue(bool apply
, bool /*Real*/)
4740 m_isPeriodic
= apply
;
4743 void Aura::HandlePeriodicEnergize(bool apply
, bool Real
)
4748 Unit
*target
= GetTarget();
4750 // For prevent double apply bonuses
4751 bool loading
= (target
->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)target
)->GetSession()->PlayerLoading());
4753 if (apply
&& !loading
)
4757 case 54833: // Glyph of Innervate (value%/2 of casters base mana)
4759 if (Unit
* caster
= GetCaster())
4760 m_modifier
.m_amount
= int32(caster
->GetCreateMana() * GetBasePoints() / (200 * GetAuraMaxTicks()));
4764 case 29166: // Innervate (value% of casters base mana)
4766 if (Unit
* caster
= GetCaster())
4768 // Glyph of Innervate
4769 if (caster
->HasAura(54832))
4770 caster
->CastSpell(caster
,54833,true,NULL
,this);
4772 m_modifier
.m_amount
= int32(caster
->GetCreateMana() * GetBasePoints() / (100 * GetAuraMaxTicks()));
4776 case 48391: // Owlkin Frenzy 2% base mana
4777 m_modifier
.m_amount
= target
->GetCreateMana() * 2 / 100;
4779 case 57669: // Replenishment (0.2% from max)
4780 case 61782: // Infinite Replenishment
4781 m_modifier
.m_amount
= target
->GetMaxPower(POWER_MANA
) * 2 / 1000;
4788 m_isPeriodic
= apply
;
4791 void Aura::HandleAuraPowerBurn(bool apply
, bool /*Real*/)
4793 m_isPeriodic
= apply
;
4796 void Aura::HandleAuraPeriodicDummy(bool apply
, bool Real
)
4798 // spells required only Real aura add/remove
4802 Unit
*target
= GetTarget();
4804 // For prevent double apply bonuses
4805 bool loading
= (target
->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)target
)->GetSession()->PlayerLoading());
4807 SpellEntry
const*spell
= GetSpellProto();
4808 switch( spell
->SpellFamilyName
)
4810 case SPELLFAMILY_ROGUE
:
4816 // Master of Subtlety
4817 case 31666: target
->RemoveAurasDueToSpell(31665); break;
4819 case 58428: target
->RemoveAurasDueToSpell(58427); break;
4824 case SPELLFAMILY_HUNTER
:
4826 Unit
* caster
= GetCaster();
4829 if (apply
&& !loading
&& caster
)
4830 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 14 / 100);
4835 m_isPeriodic
= apply
;
4838 void Aura::HandlePeriodicHeal(bool apply
, bool /*Real*/)
4840 m_isPeriodic
= apply
;
4842 Unit
*target
= GetTarget();
4844 // For prevent double apply bonuses
4845 bool loading
= (target
->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)target
)->GetSession()->PlayerLoading());
4847 // Custom damage calculation after
4853 Unit
*caster
= GetCaster();
4857 // Gift of the Naaru (have diff spellfamilies)
4858 if (GetSpellProto()->SpellIconID
== 329 && GetSpellProto()->SpellVisual
[0] == 7625)
4860 int32 ap
= int32 (0.22f
* caster
->GetTotalAttackPowerValue(BASE_ATTACK
));
4861 int32 holy
= caster
->SpellBaseDamageBonusDone(GetSpellSchoolMask(GetSpellProto()));
4864 holy
= int32(holy
* 377 / 1000);
4865 m_modifier
.m_amount
+= ap
> holy
? ap
: holy
;
4868 m_modifier
.m_amount
= caster
->SpellHealingBonusDone(target
, GetSpellProto(), m_modifier
.m_amount
, DOT
, GetStackAmount());
4872 void Aura::HandlePeriodicDamage(bool apply
, bool Real
)
4874 // spells required only Real aura add/remove
4878 m_isPeriodic
= apply
;
4880 Unit
*target
= GetTarget();
4881 SpellEntry
const* spellProto
= GetSpellProto();
4883 // For prevent double apply bonuses
4884 bool loading
= (target
->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)target
)->GetSession()->PlayerLoading());
4886 // Custom damage calculation after
4892 Unit
*caster
= GetCaster();
4896 switch (spellProto
->SpellFamilyName
)
4898 case SPELLFAMILY_GENERIC
:
4901 if (spellProto
->SpellIconID
== 147 && spellProto
->SpellVisual
[0] == 0)
4902 // $AP*0.18/6 bonus per tick
4903 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 3 / 100);
4906 case SPELLFAMILY_WARRIOR
:
4909 if (spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000020))
4911 // $0.2*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick
4912 float ap
= caster
->GetTotalAttackPowerValue(BASE_ATTACK
);
4913 int32 mws
= caster
->GetAttackTime(BASE_ATTACK
);
4914 float mwb_min
= caster
->GetWeaponDamageRange(BASE_ATTACK
,MINDAMAGE
);
4915 float mwb_max
= caster
->GetWeaponDamageRange(BASE_ATTACK
,MAXDAMAGE
);
4916 m_modifier
.m_amount
+=int32(((mwb_min
+mwb_max
)/2+ap
*mws
/14000)*0.2f
);
4917 // If used while target is above 75% health, Rend does 35% more damage
4918 if (spellProto
->CalculateSimpleValue(EFFECT_INDEX_1
) !=0 &&
4919 target
->GetHealth() > target
->GetMaxHealth() * spellProto
->CalculateSimpleValue(EFFECT_INDEX_1
) / 100)
4920 m_modifier
.m_amount
+= m_modifier
.m_amount
* spellProto
->CalculateSimpleValue(EFFECT_INDEX_2
) / 100;
4924 case SPELLFAMILY_WARLOCK
:
4927 if (spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000004000))
4929 if (target
->GetHealth() * 100 / target
->GetMaxHealth() <= 25)
4930 m_modifier
.m_amount
*= 4;
4934 case SPELLFAMILY_DRUID
:
4937 if (spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000001000) && spellProto
->Effect
[EFFECT_INDEX_2
] == SPELL_EFFECT_ADD_COMBO_POINTS
)
4938 // $AP*0.18/3 bonus per tick
4939 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 6 / 100);
4941 if (spellProto
->SpellFamilyFlags
& UI64LIT(0x000000010000000000))
4942 // $AP*0.05/5 bonus per tick
4943 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) / 100);
4945 if (spellProto
->SpellFamilyFlags
& UI64LIT(0x000000000000800000))
4948 if (caster
->GetTypeId() != TYPEID_PLAYER
)
4951 uint8 cp
= ((Player
*)caster
)->GetComboPoints();
4953 // Idol of Feral Shadows. Cant be handled as SpellMod in SpellAura:Dummy due its dependency from CPs
4954 Unit::AuraList
const& dummyAuras
= caster
->GetAurasByType(SPELL_AURA_DUMMY
);
4955 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
4957 if((*itr
)->GetId()==34241)
4959 m_modifier
.m_amount
+= cp
* (*itr
)->GetModifier()->m_amount
;
4963 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * cp
/ 100);
4966 if (spellProto
->SpellFamilyFlags
& UI64LIT(0x1000000000000000))
4968 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 15 / 100);
4971 case SPELLFAMILY_ROGUE
:
4974 if (spellProto
->SpellFamilyFlags
& UI64LIT(0x000000000000100000))
4976 if (caster
->GetTypeId() != TYPEID_PLAYER
)
4978 //1 point : ${($m1+$b1*1+0.015*$AP)*4} damage over 8 secs
4979 //2 points: ${($m1+$b1*2+0.024*$AP)*5} damage over 10 secs
4980 //3 points: ${($m1+$b1*3+0.03*$AP)*6} damage over 12 secs
4981 //4 points: ${($m1+$b1*4+0.03428571*$AP)*7} damage over 14 secs
4982 //5 points: ${($m1+$b1*5+0.0375*$AP)*8} damage over 16 secs
4983 float AP_per_combo
[6] = {0.0f
, 0.015f
, 0.024f
, 0.03f
, 0.03428571f
, 0.0375f
};
4984 uint8 cp
= ((Player
*)caster
)->GetComboPoints();
4986 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * AP_per_combo
[cp
]);
4989 if (spellProto
->SpellFamilyFlags
& UI64LIT(0x000000000000000100))
4990 // $AP*0.07 bonus per tick
4991 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 7 / 100);
4993 if (spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000010000))
4994 // 0.12*$AP / 4 * amount of stack
4995 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 3 * GetStackAmount() / 100);
4998 case SPELLFAMILY_HUNTER
:
5001 if (spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000004000))
5002 // $RAP*0.2/5 bonus per tick
5003 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 0.2 / 5);
5005 if ((spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000004)) && spellProto
->SpellIconID
== 678)
5006 // $RAP*0.1/5 bonus per tick
5007 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 10 / 500);
5010 case SPELLFAMILY_PALADIN
:
5012 // Holy Vengeance / Blood Corruption
5013 if (spellProto
->SpellFamilyFlags
& UI64LIT(0x0000080000000000) && spellProto
->SpellVisual
[0] == 7902)
5015 // AP * 0.025 + SPH * 0.013 bonus per tick
5016 float ap
= caster
->GetTotalAttackPowerValue(BASE_ATTACK
);
5017 int32 holy
= caster
->SpellBaseDamageBonusDone(GetSpellSchoolMask(spellProto
));
5020 m_modifier
.m_amount
+= int32(GetStackAmount()) * (int32(ap
* 0.025f
) + int32(holy
* 13 / 1000));
5024 case SPELLFAMILY_DEATHKNIGHT
:
5026 //Frost Fever and Blood Plague AP scale
5027 if (spellProto
->SpellFamilyFlags
& UI64LIT(0x400080000000000))
5029 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 0.055f
* 1.15f
);
5037 if(m_modifier
.m_auraname
== SPELL_AURA_PERIODIC_DAMAGE
)
5039 // SpellDamageBonusDone for magic spells
5040 if(spellProto
->DmgClass
== SPELL_DAMAGE_CLASS_NONE
|| spellProto
->DmgClass
== SPELL_DAMAGE_CLASS_MAGIC
)
5041 m_modifier
.m_amount
= caster
->SpellDamageBonusDone(target
, GetSpellProto(), m_modifier
.m_amount
, DOT
, GetStackAmount());
5042 // MeleeDamagebonusDone for weapon based spells
5045 WeaponAttackType attackType
= GetWeaponAttackType(GetSpellProto());
5046 m_modifier
.m_amount
= caster
->MeleeDamageBonusDone(target
, m_modifier
.m_amount
, attackType
, GetSpellProto(), DOT
, GetStackAmount());
5050 // remove time effects
5053 // Parasitic Shadowfiend - handle summoning of two Shadowfiends on DoT expire
5054 if(spellProto
->Id
== 41917)
5055 target
->CastSpell(target
, 41915, true);
5059 void Aura::HandlePeriodicDamagePCT(bool apply
, bool /*Real*/)
5061 m_isPeriodic
= apply
;
5064 void Aura::HandlePeriodicLeech(bool apply
, bool /*Real*/)
5066 m_isPeriodic
= apply
;
5068 // For prevent double apply bonuses
5069 bool loading
= (GetTarget()->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)GetTarget())->GetSession()->PlayerLoading());
5071 // Custom damage calculation after
5077 Unit
*caster
= GetCaster();
5081 m_modifier
.m_amount
= caster
->SpellDamageBonusDone(GetTarget(), GetSpellProto(), m_modifier
.m_amount
, DOT
, GetStackAmount());
5085 void Aura::HandlePeriodicManaLeech(bool apply
, bool /*Real*/)
5087 m_isPeriodic
= apply
;
5090 void Aura::HandlePeriodicHealthFunnel(bool apply
, bool /*Real*/)
5092 m_isPeriodic
= apply
;
5094 // For prevent double apply bonuses
5095 bool loading
= (GetTarget()->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)GetTarget())->GetSession()->PlayerLoading());
5097 // Custom damage calculation after
5103 Unit
*caster
= GetCaster();
5107 m_modifier
.m_amount
= caster
->SpellDamageBonusDone(GetTarget(), GetSpellProto(), m_modifier
.m_amount
, DOT
, GetStackAmount());
5111 /*********************************************************/
5112 /*** MODIFY STATS ***/
5113 /*********************************************************/
5115 /********************************/
5116 /*** RESISTANCE ***/
5117 /********************************/
5119 void Aura::HandleAuraModResistanceExclusive(bool apply
, bool /*Real*/)
5121 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
5123 if(m_modifier
.m_miscvalue
& int32(1<<x
))
5125 GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), BASE_VALUE
, float(m_modifier
.m_amount
), apply
);
5126 if(GetTarget()->GetTypeId() == TYPEID_PLAYER
)
5127 GetTarget()->ApplyResistanceBuffModsMod(SpellSchools(x
), m_positive
, float(m_modifier
.m_amount
), apply
);
5132 void Aura::HandleAuraModResistance(bool apply
, bool /*Real*/)
5134 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
5136 if(m_modifier
.m_miscvalue
& int32(1<<x
))
5138 GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5139 if(GetTarget()->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)GetTarget())->isPet())
5140 GetTarget()->ApplyResistanceBuffModsMod(SpellSchools(x
), m_positive
, float(m_modifier
.m_amount
), apply
);
5145 void Aura::HandleAuraModBaseResistancePCT(bool apply
, bool /*Real*/)
5147 // only players have base stats
5148 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5150 //pets only have base armor
5151 if(((Creature
*)GetTarget())->isPet() && (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
5152 GetTarget()->HandleStatModifier(UNIT_MOD_ARMOR
, BASE_PCT
, float(m_modifier
.m_amount
), apply
);
5156 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
5158 if(m_modifier
.m_miscvalue
& int32(1<<x
))
5159 GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), BASE_PCT
, float(m_modifier
.m_amount
), apply
);
5164 void Aura::HandleModResistancePercent(bool apply
, bool /*Real*/)
5166 Unit
*target
= GetTarget();
5168 for(int8 i
= SPELL_SCHOOL_NORMAL
; i
< MAX_SPELL_SCHOOL
; i
++)
5170 if(m_modifier
.m_miscvalue
& int32(1<<i
))
5172 target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ i
), TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5173 if(target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)target
)->isPet())
5175 target
->ApplyResistanceBuffModsPercentMod(SpellSchools(i
), true, float(m_modifier
.m_amount
), apply
);
5176 target
->ApplyResistanceBuffModsPercentMod(SpellSchools(i
), false, float(m_modifier
.m_amount
), apply
);
5182 void Aura::HandleModBaseResistance(bool apply
, bool /*Real*/)
5184 // only players have base stats
5185 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5187 //only pets have base stats
5188 if(((Creature
*)GetTarget())->isPet() && (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
5189 GetTarget()->HandleStatModifier(UNIT_MOD_ARMOR
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5193 for(int i
= SPELL_SCHOOL_NORMAL
; i
< MAX_SPELL_SCHOOL
; i
++)
5194 if(m_modifier
.m_miscvalue
& (1<<i
))
5195 GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ i
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5199 /********************************/
5201 /********************************/
5203 void Aura::HandleAuraModStat(bool apply
, bool /*Real*/)
5205 if (m_modifier
.m_miscvalue
< -2 || m_modifier
.m_miscvalue
> 4)
5207 sLog
.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ",GetId(),GetEffIndex(),m_modifier
.m_miscvalue
);
5211 for(int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; i
++)
5213 // -1 or -2 is all stats ( misc < -2 checked in function beginning )
5214 if (m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
== i
)
5216 //m_target->ApplyStatMod(Stats(i), m_modifier.m_amount,apply);
5217 GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5218 if(GetTarget()->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)GetTarget())->isPet())
5219 GetTarget()->ApplyStatBuffMod(Stats(i
), float(m_modifier
.m_amount
), apply
);
5224 void Aura::HandleModPercentStat(bool apply
, bool /*Real*/)
5226 if (m_modifier
.m_miscvalue
< -1 || m_modifier
.m_miscvalue
> 4)
5228 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
5232 // only players have base stats
5233 if (GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5236 for (int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; ++i
)
5238 if(m_modifier
.m_miscvalue
== i
|| m_modifier
.m_miscvalue
== -1)
5239 GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), BASE_PCT
, float(m_modifier
.m_amount
), apply
);
5243 void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool /*Real*/)
5245 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5248 // Magic damage modifiers implemented in Unit::SpellDamageBonusDone
5249 // This information for client side use only
5250 // Recalculate bonus
5251 ((Player
*)GetTarget())->UpdateSpellDamageAndHealingBonus();
5254 void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool /*Real*/)
5256 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5259 // Recalculate bonus
5260 ((Player
*)GetTarget())->UpdateSpellDamageAndHealingBonus();
5263 void Aura::HandleAuraModDispelResist(bool apply
, bool Real
)
5268 if(GetId() == 33206)
5269 GetTarget()->CastSpell(GetTarget(), 44416, true, NULL
, this, GetCasterGUID());
5272 void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool /*Real*/)
5274 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5277 // Magic damage modifiers implemented in Unit::SpellDamageBonusDone
5278 // This information for client side use only
5279 // Recalculate bonus
5280 ((Player
*)GetTarget())->UpdateSpellDamageAndHealingBonus();
5283 void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool /*Real*/)
5285 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5288 // Recalculate bonus
5289 ((Player
*)GetTarget())->UpdateSpellDamageAndHealingBonus();
5292 void Aura::HandleModHealingDone(bool /*apply*/, bool /*Real*/)
5294 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5296 // implemented in Unit::SpellHealingBonusDone
5297 // this information is for client side only
5298 ((Player
*)GetTarget())->UpdateSpellDamageAndHealingBonus();
5301 void Aura::HandleModTotalPercentStat(bool apply
, bool /*Real*/)
5303 if (m_modifier
.m_miscvalue
< -1 || m_modifier
.m_miscvalue
> 4)
5305 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
5309 Unit
*target
= GetTarget();
5311 //save current and max HP before applying aura
5312 uint32 curHPValue
= target
->GetHealth();
5313 uint32 maxHPValue
= target
->GetMaxHealth();
5315 for (int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; i
++)
5317 if(m_modifier
.m_miscvalue
== i
|| m_modifier
.m_miscvalue
== -1)
5319 target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5320 if(target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)target
)->isPet())
5321 target
->ApplyStatPercentBuffMod(Stats(i
), float(m_modifier
.m_amount
), apply
);
5325 //recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag)
5326 if ((m_modifier
.m_miscvalue
== STAT_STAMINA
) && (maxHPValue
> 0) && (GetSpellProto()->Attributes
& 0x10))
5328 // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed
5329 uint32 newHPValue
= (target
->GetMaxHealth() * curHPValue
) / maxHPValue
;
5330 target
->SetHealth(newHPValue
);
5334 void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool /*Real*/)
5336 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5339 if(m_modifier
.m_miscvalue
!= SPELL_SCHOOL_MASK_NORMAL
)
5341 // support required adding replace UpdateArmor by loop by UpdateResistence at intellect update
5342 // and include in UpdateResistence same code as in UpdateArmor for aura mod apply.
5343 sLog
.outError("Aura SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT(182) need adding support for non-armor resistances!");
5347 // Recalculate Armor
5348 GetTarget()->UpdateArmor();
5351 /********************************/
5352 /*** HEAL & ENERGIZE ***/
5353 /********************************/
5354 void Aura::HandleAuraModTotalHealthPercentRegen(bool apply
, bool /*Real*/)
5356 m_isPeriodic
= apply
;
5359 void Aura::HandleAuraModTotalManaPercentRegen(bool apply
, bool /*Real*/)
5361 if(m_modifier
.periodictime
== 0)
5362 m_modifier
.periodictime
= 1000;
5364 m_periodicTimer
= m_modifier
.periodictime
;
5365 m_isPeriodic
= apply
;
5368 void Aura::HandleModRegen(bool apply
, bool /*Real*/) // eating
5370 if(m_modifier
.periodictime
== 0)
5371 m_modifier
.periodictime
= 5000;
5373 m_periodicTimer
= 5000;
5374 m_isPeriodic
= apply
;
5377 void Aura::HandleModPowerRegen(bool apply
, bool Real
) // drinking
5382 Powers pt
= GetTarget()->getPowerType();
5383 if(m_modifier
.periodictime
== 0)
5385 // Anger Management (only spell use this aura for rage)
5386 if (pt
== POWER_RAGE
)
5387 m_modifier
.periodictime
= 3000;
5389 m_modifier
.periodictime
= 2000;
5392 m_periodicTimer
= 5000;
5394 if (GetTarget()->GetTypeId() == TYPEID_PLAYER
&& m_modifier
.m_miscvalue
== POWER_MANA
)
5395 ((Player
*)GetTarget())->UpdateManaRegen();
5397 m_isPeriodic
= apply
;
5400 void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real
)
5402 // spells required only Real aura add/remove
5406 if (GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5409 // Update manaregen value
5410 if (m_modifier
.m_miscvalue
== POWER_MANA
)
5411 ((Player
*)GetTarget())->UpdateManaRegen();
5414 void Aura::HandleModManaRegen(bool /*apply*/, bool Real
)
5416 // spells required only Real aura add/remove
5420 if (GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5423 //Note: an increase in regen does NOT cause threat.
5424 ((Player
*)GetTarget())->UpdateManaRegen();
5427 void Aura::HandleComprehendLanguage(bool apply
, bool /*Real*/)
5430 GetTarget()->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_COMPREHEND_LANG
);
5432 GetTarget()->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_COMPREHEND_LANG
);
5435 void Aura::HandleAuraModIncreaseHealth(bool apply
, bool Real
)
5437 Unit
*target
= GetTarget();
5439 // Special case with temporary increase max/current health
5442 case 12976: // Warrior Last Stand triggered spell
5443 case 28726: // Nightmare Seed ( Nightmare Seed )
5444 case 31616: // Nature's Guardian
5445 case 34511: // Valor (Bulwark of Kings, Bulwark of the Ancient Kings)
5446 case 44055: case 55915: case 55917: case 67596: // Tremendous Fortitude (Battlemaster's Alacrity)
5447 case 50322: // Survival Instincts
5448 case 54443: // Demonic Empowerment (Voidwalker)
5449 case 55233: // Vampiric Blood
5450 case 59465: // Brood Rage (Ahn'Kahet)
5456 // Demonic Empowerment (Voidwalker) & Vampiric Blood - special cases, store percent in data
5457 // recalculate to full amount at apply for proper remove
5458 if (GetId() == 54443 || GetId() == 55233)
5459 m_modifier
.m_amount
= target
->GetMaxHealth() * m_modifier
.m_amount
/ 100;
5461 target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5462 target
->ModifyHealth(m_modifier
.m_amount
);
5466 if (int32(target
->GetHealth()) > m_modifier
.m_amount
)
5467 target
->ModifyHealth(-m_modifier
.m_amount
);
5469 target
->SetHealth(1);
5470 target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5478 target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5481 void Aura::HandleAuraModIncreaseMaxHealth(bool apply
, bool /*Real*/)
5483 Unit
*target
= GetTarget();
5484 uint32 oldhealth
= target
->GetHealth();
5485 double healthPercentage
= (double)oldhealth
/ (double)target
->GetMaxHealth();
5487 target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5489 // refresh percentage
5492 uint32 newhealth
= uint32(ceil((double)target
->GetMaxHealth() * healthPercentage
));
5496 target
->SetHealth(newhealth
);
5500 void Aura::HandleAuraModIncreaseEnergy(bool apply
, bool Real
)
5502 Unit
*target
= GetTarget();
5503 Powers powerType
= target
->getPowerType();
5504 if(int32(powerType
) != m_modifier
.m_miscvalue
)
5507 UnitMods unitMod
= UnitMods(UNIT_MOD_POWER_START
+ powerType
);
5509 // Special case with temporary increase max/current power (percent)
5510 if (GetId()==64904) // Hymn of Hope
5514 uint32 val
= target
->GetPower(powerType
);
5515 target
->HandleStatModifier(unitMod
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5516 target
->SetPower(powerType
, apply
? val
*(100+m_modifier
.m_amount
)/100 : val
*100/(100+m_modifier
.m_amount
));
5521 // generic flat case
5522 target
->HandleStatModifier(unitMod
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5525 void Aura::HandleAuraModIncreaseEnergyPercent(bool apply
, bool /*Real*/)
5527 Powers powerType
= GetTarget()->getPowerType();
5528 if(int32(powerType
) != m_modifier
.m_miscvalue
)
5531 UnitMods unitMod
= UnitMods(UNIT_MOD_POWER_START
+ powerType
);
5533 GetTarget()->HandleStatModifier(unitMod
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5536 void Aura::HandleAuraModIncreaseHealthPercent(bool apply
, bool /*Real*/)
5538 GetTarget()->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5541 void Aura::HandleAuraIncreaseBaseHealthPercent(bool apply
, bool /*Real*/)
5543 GetTarget()->HandleStatModifier(UNIT_MOD_HEALTH
, BASE_PCT
, float(m_modifier
.m_amount
), apply
);
5546 /********************************/
5548 /********************************/
5550 void Aura::HandleAuraModParryPercent(bool /*apply*/, bool /*Real*/)
5552 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5555 ((Player
*)GetTarget())->UpdateParryPercentage();
5558 void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool /*Real*/)
5560 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5563 ((Player
*)GetTarget())->UpdateDodgePercentage();
5564 //sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount));
5567 void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool /*Real*/)
5569 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5572 ((Player
*)GetTarget())->UpdateBlockPercentage();
5573 //sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount));
5576 void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real
)
5578 // spells required only Real aura add/remove
5582 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5585 ((Player
*)GetTarget())->UpdateManaRegen();
5588 void Aura::HandleAuraModCritPercent(bool apply
, bool Real
)
5590 Unit
*target
= GetTarget();
5592 if(target
->GetTypeId() != TYPEID_PLAYER
)
5595 // apply item specific bonuses for already equipped weapon
5598 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
5599 if(Item
* pItem
= ((Player
*)target
)->GetWeaponForAttack(WeaponAttackType(i
),true,false))
5600 ((Player
*)target
)->_ApplyWeaponDependentAuraCritMod(pItem
, WeaponAttackType(i
), this, apply
);
5603 // mods must be applied base at equipped weapon class and subclass comparison
5604 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5605 // m_modifier.m_miscvalue comparison with item generated damage types
5607 if (GetSpellProto()->EquippedItemClass
== -1)
5609 ((Player
*)target
)->HandleBaseModValue(CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
5610 ((Player
*)target
)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
5611 ((Player
*)target
)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
5615 // done in Player::_ApplyWeaponDependentAuraMods
5619 void Aura::HandleModHitChance(bool apply
, bool /*Real*/)
5621 Unit
*target
= GetTarget();
5623 if(target
->GetTypeId() == TYPEID_PLAYER
)
5625 ((Player
*)target
)->UpdateMeleeHitChances();
5626 ((Player
*)target
)->UpdateRangedHitChances();
5630 target
->m_modMeleeHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
5631 target
->m_modRangedHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
5635 void Aura::HandleModSpellHitChance(bool apply
, bool /*Real*/)
5637 if(GetTarget()->GetTypeId() == TYPEID_PLAYER
)
5639 ((Player
*)GetTarget())->UpdateSpellHitChances();
5643 GetTarget()->m_modSpellHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
5647 void Aura::HandleModSpellCritChance(bool apply
, bool Real
)
5649 // spells required only Real aura add/remove
5653 if(GetTarget()->GetTypeId() == TYPEID_PLAYER
)
5655 ((Player
*)GetTarget())->UpdateAllSpellCritChances();
5659 GetTarget()->m_baseSpellCritChance
+= apply
? m_modifier
.m_amount
:(-m_modifier
.m_amount
);
5663 void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real
)
5665 // spells required only Real aura add/remove
5669 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5672 for(int school
= SPELL_SCHOOL_NORMAL
; school
< MAX_SPELL_SCHOOL
; ++school
)
5673 if (m_modifier
.m_miscvalue
& (1<<school
))
5674 ((Player
*)GetTarget())->UpdateSpellCritChance(school
);
5677 /********************************/
5678 /*** ATTACK SPEED ***/
5679 /********************************/
5681 void Aura::HandleModCastingSpeed(bool apply
, bool /*Real*/)
5683 GetTarget()->ApplyCastTimePercentMod(float(m_modifier
.m_amount
),apply
);
5686 void Aura::HandleModMeleeRangedSpeedPct(bool apply
, bool /*Real*/)
5688 Unit
*target
= GetTarget();
5689 target
->ApplyAttackTimePercentMod(BASE_ATTACK
, float(m_modifier
.m_amount
), apply
);
5690 target
->ApplyAttackTimePercentMod(OFF_ATTACK
, float(m_modifier
.m_amount
), apply
);
5691 target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, float(m_modifier
.m_amount
), apply
);
5694 void Aura::HandleModCombatSpeedPct(bool apply
, bool /*Real*/)
5696 Unit
*target
= GetTarget();
5697 target
->ApplyCastTimePercentMod(float(m_modifier
.m_amount
), apply
);
5698 target
->ApplyAttackTimePercentMod(BASE_ATTACK
, float(m_modifier
.m_amount
), apply
);
5699 target
->ApplyAttackTimePercentMod(OFF_ATTACK
, float(m_modifier
.m_amount
), apply
);
5700 target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, float(m_modifier
.m_amount
), apply
);
5703 void Aura::HandleModAttackSpeed(bool apply
, bool /*Real*/)
5705 GetTarget()->ApplyAttackTimePercentMod(BASE_ATTACK
,float(m_modifier
.m_amount
),apply
);
5708 void Aura::HandleHaste(bool apply
, bool /*Real*/)
5710 Unit
*target
= GetTarget();
5711 target
->ApplyAttackTimePercentMod(BASE_ATTACK
, float(m_modifier
.m_amount
), apply
);
5712 target
->ApplyAttackTimePercentMod(OFF_ATTACK
, float(m_modifier
.m_amount
), apply
);
5713 target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, float(m_modifier
.m_amount
), apply
);
5716 void Aura::HandleAuraModRangedHaste(bool apply
, bool /*Real*/)
5718 GetTarget()->ApplyAttackTimePercentMod(RANGED_ATTACK
, float(m_modifier
.m_amount
), apply
);
5721 void Aura::HandleRangedAmmoHaste(bool apply
, bool /*Real*/)
5723 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
5725 GetTarget()->ApplyAttackTimePercentMod(RANGED_ATTACK
, float(m_modifier
.m_amount
), apply
);
5728 /********************************/
5729 /*** ATTACK POWER ***/
5730 /********************************/
5732 void Aura::HandleAuraModAttackPower(bool apply
, bool /*Real*/)
5734 GetTarget()->HandleStatModifier(UNIT_MOD_ATTACK_POWER
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5737 void Aura::HandleAuraModRangedAttackPower(bool apply
, bool /*Real*/)
5739 if((GetTarget()->getClassMask() & CLASSMASK_WAND_USERS
)!=0)
5742 GetTarget()->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5745 void Aura::HandleAuraModAttackPowerPercent(bool apply
, bool /*Real*/)
5747 //UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1
5748 GetTarget()->HandleStatModifier(UNIT_MOD_ATTACK_POWER
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5751 void Aura::HandleAuraModRangedAttackPowerPercent(bool apply
, bool /*Real*/)
5753 if((GetTarget()->getClassMask() & CLASSMASK_WAND_USERS
)!=0)
5756 //UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1
5757 GetTarget()->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5760 void Aura::HandleAuraModRangedAttackPowerOfStatPercent(bool /*apply*/, bool Real
)
5762 // spells required only Real aura add/remove
5766 // Recalculate bonus
5767 if(GetTarget()->GetTypeId() == TYPEID_PLAYER
&& !(GetTarget()->getClassMask() & CLASSMASK_WAND_USERS
))
5768 ((Player
*)GetTarget())->UpdateAttackPowerAndDamage(true);
5771 void Aura::HandleAuraModAttackPowerOfStatPercent(bool /*apply*/, bool Real
)
5773 // spells required only Real aura add/remove
5777 // Recalculate bonus
5778 if(GetTarget()->GetTypeId() == TYPEID_PLAYER
)
5779 ((Player
*)GetTarget())->UpdateAttackPowerAndDamage(false);
5782 void Aura::HandleAuraModAttackPowerOfArmor(bool /*apply*/, bool Real
)
5784 // spells required only Real aura add/remove
5788 // Recalculate bonus
5789 if(GetTarget()->GetTypeId() == TYPEID_PLAYER
)
5790 ((Player
*)GetTarget())->UpdateAttackPowerAndDamage(false);
5792 /********************************/
5793 /*** DAMAGE BONUS ***/
5794 /********************************/
5795 void Aura::HandleModDamageDone(bool apply
, bool Real
)
5797 Unit
*target
= GetTarget();
5799 // apply item specific bonuses for already equipped weapon
5800 if(Real
&& target
->GetTypeId() == TYPEID_PLAYER
)
5802 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
5803 if(Item
* pItem
= ((Player
*)target
)->GetWeaponForAttack(WeaponAttackType(i
),true,false))
5804 ((Player
*)target
)->_ApplyWeaponDependentAuraDamageMod(pItem
, WeaponAttackType(i
), this, apply
);
5807 // m_modifier.m_miscvalue is bitmask of spell schools
5808 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5809 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wands
5810 // 127 - full bitmask any damages
5812 // mods must be applied base at equipped weapon class and subclass comparison
5813 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5814 // m_modifier.m_miscvalue comparison with item generated damage types
5816 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
) != 0)
5818 // apply generic physical damage bonuses including wand case
5819 if (GetSpellProto()->EquippedItemClass
== -1 || target
->GetTypeId() != TYPEID_PLAYER
)
5821 target
->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5822 target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5823 target
->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5827 // done in Player::_ApplyWeaponDependentAuraMods
5830 if(target
->GetTypeId() == TYPEID_PLAYER
)
5833 target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS
, m_modifier
.m_amount
, apply
);
5835 target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG
, m_modifier
.m_amount
, apply
);
5839 // Skip non magic case for speedup
5840 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_MAGIC
) == 0)
5843 if( GetSpellProto()->EquippedItemClass
!= -1 || GetSpellProto()->EquippedItemInventoryTypeMask
!= 0 )
5845 // wand magic case (skip generic to all item spell bonuses)
5846 // done in Player::_ApplyWeaponDependentAuraMods
5848 // Skip item specific requirements for not wand magic damage
5852 // Magic damage modifiers implemented in Unit::SpellDamageBonusDone
5853 // This information for client side use only
5854 if(target
->GetTypeId() == TYPEID_PLAYER
)
5858 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; ++i
)
5860 if((m_modifier
.m_miscvalue
& (1<<i
)) != 0)
5861 target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS
+ i
, m_modifier
.m_amount
, apply
);
5866 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; ++i
)
5868 if((m_modifier
.m_miscvalue
& (1<<i
)) != 0)
5869 target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG
+ i
, m_modifier
.m_amount
, apply
);
5872 Pet
* pet
= target
->GetPet();
5874 pet
->UpdateAttackPowerAndDamage();
5878 void Aura::HandleModDamagePercentDone(bool apply
, bool Real
)
5880 DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST
, "AURA MOD DAMAGE type:%u negative:%u", m_modifier
.m_miscvalue
, m_positive
? 0 : 1);
5881 Unit
*target
= GetTarget();
5883 // apply item specific bonuses for already equipped weapon
5884 if(Real
&& target
->GetTypeId() == TYPEID_PLAYER
)
5886 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
5887 if(Item
* pItem
= ((Player
*)target
)->GetWeaponForAttack(WeaponAttackType(i
),true,false))
5888 ((Player
*)target
)->_ApplyWeaponDependentAuraDamageMod(pItem
, WeaponAttackType(i
), this, apply
);
5891 // m_modifier.m_miscvalue is bitmask of spell schools
5892 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5893 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wand
5894 // 127 - full bitmask any damages
5896 // mods must be applied base at equipped weapon class and subclass comparison
5897 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5898 // m_modifier.m_miscvalue comparison with item generated damage types
5900 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
) != 0)
5902 // apply generic physical damage bonuses including wand case
5903 if (GetSpellProto()->EquippedItemClass
== -1 || target
->GetTypeId() != TYPEID_PLAYER
)
5905 target
->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5906 target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5907 target
->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5911 // done in Player::_ApplyWeaponDependentAuraMods
5913 // For show in client
5914 if(target
->GetTypeId() == TYPEID_PLAYER
)
5915 target
->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT
, m_modifier
.m_amount
/100.0f
, apply
);
5918 // Skip non magic case for speedup
5919 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_MAGIC
) == 0)
5922 if( GetSpellProto()->EquippedItemClass
!= -1 || GetSpellProto()->EquippedItemInventoryTypeMask
!= 0 )
5924 // wand magic case (skip generic to all item spell bonuses)
5925 // done in Player::_ApplyWeaponDependentAuraMods
5927 // Skip item specific requirements for not wand magic damage
5931 // Magic damage percent modifiers implemented in Unit::SpellDamageBonusDone
5932 // Send info to client
5933 if(target
->GetTypeId() == TYPEID_PLAYER
)
5934 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; ++i
)
5935 target
->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT
+ i
, m_modifier
.m_amount
/100.0f
, apply
);
5938 void Aura::HandleModOffhandDamagePercent(bool apply
, bool Real
)
5940 // spells required only Real aura add/remove
5944 DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST
, "AURA MOD OFFHAND DAMAGE");
5946 GetTarget()->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5949 /********************************/
5950 /*** POWER COST ***/
5951 /********************************/
5953 void Aura::HandleModPowerCostPCT(bool apply
, bool Real
)
5955 // spells required only Real aura add/remove
5959 float amount
= m_modifier
.m_amount
/100.0f
;
5960 for(int i
= 0; i
< MAX_SPELL_SCHOOL
; ++i
)
5961 if(m_modifier
.m_miscvalue
& (1<<i
))
5962 GetTarget()->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER
+ i
, amount
, apply
);
5965 void Aura::HandleModPowerCost(bool apply
, bool Real
)
5967 // spells required only Real aura add/remove
5971 for(int i
= 0; i
< MAX_SPELL_SCHOOL
; ++i
)
5972 if(m_modifier
.m_miscvalue
& (1<<i
))
5973 GetTarget()->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER
+ i
, m_modifier
.m_amount
, apply
);
5976 void Aura::HandleNoReagentUseAura(bool /*Apply*/, bool Real
)
5978 // spells required only Real aura add/remove
5981 Unit
*target
= GetTarget();
5982 if(target
->GetTypeId() != TYPEID_PLAYER
)
5985 uint32 mask
[3] = {0, 0, 0};
5986 Unit::AuraList
const& noReagent
= target
->GetAurasByType(SPELL_AURA_NO_REAGENT_USE
);
5987 for(Unit::AuraList::const_iterator i
= noReagent
.begin(); i
!= noReagent
.end(); ++i
)
5989 uint32
const *ptr
= (*i
)->getAuraSpellClassMask();
5995 target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
+0, mask
[0]);
5996 target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
+1, mask
[1]);
5997 target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
+2, mask
[2]);
6000 /*********************************************************/
6002 /*********************************************************/
6004 void Aura::HandleShapeshiftBoosts(bool apply
)
6006 uint32 spellId1
= 0;
6007 uint32 spellId2
= 0;
6008 uint32 HotWSpellId
= 0;
6009 uint32 MasterShaperSpellId
= 0;
6011 uint32 form
= GetModifier()->m_miscvalue
;
6013 Unit
*target
= GetTarget();
6019 HotWSpellId
= 24900;
6020 MasterShaperSpellId
= 48420;
6025 MasterShaperSpellId
= 48422;
6036 HotWSpellId
= 24899;
6037 MasterShaperSpellId
= 48418;
6042 HotWSpellId
= 24899;
6043 MasterShaperSpellId
= 48418;
6045 case FORM_BATTLESTANCE
:
6048 case FORM_DEFENSIVESTANCE
:
6051 case FORM_BERSERKERSTANCE
:
6056 MasterShaperSpellId
= 48421;
6062 case FORM_FLIGHT_EPIC
:
6066 case FORM_METAMORPHOSIS
:
6070 case FORM_SPIRITOFREDEMPTION
:
6072 spellId2
= 27795; // must be second, this important at aura remove to prevent to early iterator invalidation.
6077 if(target
->GetTypeId() == TYPEID_PLAYER
) // Spell 49868 have same category as main form spell and share cooldown
6078 ((Player
*)target
)->RemoveSpellCooldown(49868);
6080 case FORM_GHOSTWOLF
:
6086 case FORM_CREATURECAT
:
6087 case FORM_CREATUREBEAR
:
6094 target
->CastSpell(target
, spellId1
, true, NULL
, this );
6096 target
->CastSpell(target
, spellId2
, true, NULL
, this);
6098 if (target
->GetTypeId() == TYPEID_PLAYER
)
6100 const PlayerSpellMap
& sp_list
= ((Player
*)target
)->GetSpellMap();
6101 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
6103 if (itr
->second
.state
== PLAYERSPELL_REMOVED
) continue;
6104 if (itr
->first
==spellId1
|| itr
->first
==spellId2
) continue;
6105 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
6106 if (!spellInfo
|| !(spellInfo
->Attributes
& (SPELL_ATTR_PASSIVE
| (1<<7))))
6108 if (spellInfo
->Stances
& (1<<(form
-1)))
6109 target
->CastSpell(target
, itr
->first
, true, NULL
, this);
6112 // Master Shapeshifter
6113 if (MasterShaperSpellId
)
6115 Unit::AuraList
const& ShapeShifterAuras
= target
->GetAurasByType(SPELL_AURA_DUMMY
);
6116 for(Unit::AuraList::const_iterator i
= ShapeShifterAuras
.begin(); i
!= ShapeShifterAuras
.end(); i
++)
6118 if ((*i
)->GetSpellProto()->SpellIconID
== 2851)
6120 int32 ShiftMod
= (*i
)->GetModifier()->m_amount
;
6121 target
->CastCustomSpell(target
, MasterShaperSpellId
, &ShiftMod
, NULL
, NULL
, true);
6127 // Leader of the Pack
6128 if (((Player
*)target
)->HasSpell(17007))
6130 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(24932);
6131 if (spellInfo
&& spellInfo
->Stances
& (1<<(form
-1)))
6132 target
->CastSpell(target
, 24932, true, NULL
, this);
6136 if (form
== FORM_CAT
&& ((Player
*)target
)->HasAura(52610))
6137 target
->CastSpell(target
, 62071, true);
6139 // Improved Moonkin Form
6140 if (form
== FORM_MOONKIN
)
6142 Unit::AuraList
const& dummyAuras
= target
->GetAurasByType(SPELL_AURA_DUMMY
);
6143 for(Unit::AuraList::const_iterator i
= dummyAuras
.begin(); i
!= dummyAuras
.end(); i
++)
6145 if ((*i
)->GetSpellProto()->SpellFamilyName
==SPELLFAMILY_DRUID
&&
6146 (*i
)->GetSpellProto()->SpellIconID
== 2855)
6148 uint32 spell_id
= 0;
6149 switch((*i
)->GetId())
6151 case 48384:spell_id
=50170;break;//Rank 1
6152 case 48395:spell_id
=50171;break;//Rank 2
6153 case 48396:spell_id
=50172;break;//Rank 3
6155 sLog
.outError("Aura::HandleShapeshiftBoosts: Not handled rank of IMF (Spell: %u)",(*i
)->GetId());
6160 target
->CastSpell(target
, spell_id
, true, NULL
, this);
6166 // Heart of the Wild
6169 Unit::AuraList
const& mModTotalStatPct
= target
->GetAurasByType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
);
6170 for(Unit::AuraList::const_iterator i
= mModTotalStatPct
.begin(); i
!= mModTotalStatPct
.end(); ++i
)
6172 if ((*i
)->GetSpellProto()->SpellIconID
== 240 && (*i
)->GetModifier()->m_miscvalue
== 3)
6174 int32 HotWMod
= (*i
)->GetModifier()->m_amount
;
6175 if(GetModifier()->m_miscvalue
== FORM_CAT
)
6178 target
->CastCustomSpell(target
, HotWSpellId
, &HotWMod
, NULL
, NULL
, true, NULL
, this);
6188 target
->RemoveAurasDueToSpell(spellId1
);
6190 target
->RemoveAurasDueToSpell(spellId2
);
6191 if(MasterShaperSpellId
)
6192 target
->RemoveAurasDueToSpell(MasterShaperSpellId
);
6194 Unit::AuraMap
& tAuras
= m_target
->GetAuras();
6195 for (Unit::AuraMap::iterator itr
= tAuras
.begin(); itr
!= tAuras
.end();)
6197 if (itr
->second
->IsRemovedOnShapeLost())
6199 m_target
->RemoveAurasDueToSpell(itr
->second
->GetId());
6200 itr
= tAuras
.begin();
6208 void Aura::HandleSpellSpecificBoosts(bool apply
)
6210 bool cast_at_remove
= false; // if spell must be casted at last aura from stack remove
6211 uint32 spellId1
= 0;
6212 uint32 spellId2
= 0;
6213 uint32 spellId3
= 0;
6214 uint32 spellId4
= 0;
6216 switch(GetSpellProto()->SpellFamilyName
)
6218 case SPELLFAMILY_GENERIC
:
6220 // Illusionary Barrier
6221 if(GetId() == 57350 && !apply
&& m_target
->getPowerType() == POWER_MANA
)
6223 cast_at_remove
= true;
6224 spellId1
= 60242; // Darkmoon Card: Illusion
6230 case SPELLFAMILY_MAGE
:
6232 // Ice Barrier (non stacking from one caster)
6233 if (m_spellProto
->SpellIconID
== 32)
6235 if (!apply
&& (m_removeMode
== AURA_REMOVE_BY_DISPEL
|| m_removeMode
== AURA_REMOVE_BY_SHIELD_BREAK
))
6237 Unit::AuraList
const& dummyAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
6238 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
6240 // Shattered Barrier
6241 if ((*itr
)->GetSpellProto()->SpellIconID
== 2945)
6243 cast_at_remove
= true;
6244 // first rank have 50% chance
6245 if ((*itr
)->GetId() != 44745 || roll_chance_i(50))
6258 case 11129: // Combustion (remove triggered aura stack)
6266 case 28682: // Combustion (remove main aura)
6274 case 44401: // Missile Barrage (triggered)
6275 case 48108: // Hot Streak (triggered)
6276 case 57761: // Fireball! (Brain Freeze triggered)
6279 if (!apply
&& m_removeMode
!= AURA_REMOVE_BY_EXPIRE
)
6281 Unit
* caster
= GetCaster();
6282 // Item - Mage T10 2P Bonus
6283 if (!caster
|| !caster
->HasAura(70752))
6286 cast_at_remove
= true;
6287 spellId1
= 70753; // Pushing the Limit
6298 case SPELLFAMILY_WARRIOR
:
6302 // Remove Blood Frenzy only if target no longer has any Deep Wound or Rend (applying is handled by procs)
6303 if (GetSpellProto()->Mechanic
!= MECHANIC_BLEED
)
6306 // If target still has one of Warrior's bleeds, do nothing
6307 Unit::AuraList
const& PeriodicDamage
= m_target
->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE
);
6308 for(Unit::AuraList::const_iterator i
= PeriodicDamage
.begin(); i
!= PeriodicDamage
.end(); ++i
)
6309 if( (*i
)->GetCasterGUID() == GetCasterGUID() &&
6310 (*i
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_WARRIOR
&&
6311 (*i
)->GetSpellProto()->Mechanic
== MECHANIC_BLEED
)
6314 spellId1
= 30069; // Blood Frenzy (Rank 1)
6315 spellId2
= 30070; // Blood Frenzy (Rank 2)
6319 case SPELLFAMILY_WARLOCK
:
6321 // Fear (non stacking)
6322 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000040000000000))
6326 Unit
* caster
= GetCaster();
6330 Unit::AuraList
const& dummyAuras
= caster
->GetAurasByType(SPELL_AURA_DUMMY
);
6331 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
6333 SpellEntry
const* dummyEntry
= (*itr
)->GetSpellProto();
6335 if (dummyEntry
->SpellFamilyName
== SPELLFAMILY_WARLOCK
&& dummyEntry
->SpellIconID
== 98)
6337 cast_at_remove
= true;
6338 switch((*itr
)->GetModifier()->m_amount
)
6341 case 0: spellId1
= 60946; break;
6343 case 1: spellId1
= 60947; break;
6352 // Shadowflame (DoT)
6353 else if (m_spellProto
->SpellFamilyFlags2
& 0x00000002)
6355 // Glyph of Shadowflame
6359 else if(((caster
= GetCaster())) && caster
->HasAura(63310))
6368 case SPELLFAMILY_PRIEST
:
6370 // Shadow Word: Pain (need visual check fro skip improvement talent) or Vampiric Touch
6371 if (m_spellProto
->SpellIconID
== 234 && m_spellProto
->SpellVisual
[0] || m_spellProto
->SpellIconID
== 2213)
6373 if (!apply
&& m_removeMode
== AURA_REMOVE_BY_DISPEL
)
6375 Unit
* caster
= GetCaster();
6379 Unit::AuraList
const& dummyAuras
= caster
->GetAurasByType(SPELL_AURA_DUMMY
);
6380 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
6383 if ((*itr
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_PRIEST
6384 && (*itr
)->GetSpellProto()->SpellIconID
== 178)
6387 int32 basepoints0
= (*itr
)->GetModifier()->m_amount
* caster
->GetCreateMana() / 100;
6388 caster
->CastCustomSpell(caster
, 64103, &basepoints0
, NULL
, NULL
, true, NULL
, this);
6396 // Power Word: Shield
6397 else if (apply
&& m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000001) && m_spellProto
->Mechanic
== MECHANIC_SHIELD
)
6399 Unit
* caster
= GetCaster();
6403 // Glyph of Power Word: Shield
6404 if (Aura
* glyph
= caster
->GetAura(55672, EFFECT_INDEX_0
))
6406 int32 heal
= (glyph
->GetModifier()->m_amount
* m_modifier
.m_amount
)/100;
6407 caster
->CastCustomSpell(m_target
, 56160, &heal
, NULL
, NULL
, true, 0, this);
6414 // Abolish Disease (remove 1 more poison effect with Body and Soul)
6420 Unit::AuraList
const& dummyAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
6421 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
6423 SpellEntry
const* dummyEntry
= (*itr
)->GetSpellProto();
6424 // Body and Soul (talent ranks)
6425 if (dummyEntry
->SpellFamilyName
== SPELLFAMILY_PRIEST
&& dummyEntry
->SpellIconID
== 2218 &&
6426 dummyEntry
->SpellVisual
[0]==0)
6428 chance
= (*itr
)->GetSpellProto()->CalculateSimpleValue(EFFECT_INDEX_1
);
6433 if(roll_chance_i(chance
))
6434 spellId1
= 64134; // Body and Soul (periodic dispel effect)
6437 spellId1
= 64134; // Body and Soul (periodic dispel effect)
6440 // Dispersion mana reg and immunity
6442 spellId1
= 60069; // Dispersion
6443 spellId2
= 63230; // Dispersion
6450 case SPELLFAMILY_DRUID
:
6453 if (GetId()==22812 && m_target
->HasAura(63057)) // Glyph of Barkskin
6454 spellId1
= 63058; // Glyph - Barkskin 01
6459 case SPELLFAMILY_ROGUE
:
6460 // Sprint (skip non player casted spells by category)
6461 if (GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000000040) && GetSpellProto()->Category
== 44)
6463 if(!apply
|| m_target
->HasAura(58039)) // Glyph of Blurred Speed
6464 spellId1
= 61922; // Sprint (waterwalk)
6471 case SPELLFAMILY_HUNTER
:
6473 // Freezing Trap Effect
6474 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000008))
6478 Unit
*caster
= GetCaster();
6479 // Glyph of Freezing Trap
6480 if (caster
&& caster
->HasAura(56845))
6482 cast_at_remove
= true;
6491 // Aspect of the Dragonhawk dodge
6492 else if (GetSpellProto()->SpellFamilyFlags2
& 0x00001000)
6496 // triggered spell have same category as main spell and cooldown
6497 if (apply
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
6498 ((Player
*)m_target
)->RemoveSpellCooldown(61848);
6504 case SPELLFAMILY_PALADIN
:
6506 if (m_spellProto
->Id
== 31884) // Avenging Wrath
6509 spellId1
= 57318; // Sanctified Wrath (triggered)
6513 Unit::AuraList
const& dummyAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
6514 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
6516 if ((*itr
)->GetSpellProto()->SpellIconID
== 3029)
6518 percent
= (*itr
)->GetModifier()->m_amount
;
6523 // apply in special way
6526 spellId1
= 57318; // Sanctified Wrath (triggered)
6527 // prevent aura deletion, specially in multi-boost case
6529 m_target
->CastCustomSpell(m_target
, spellId1
, &percent
, &percent
, NULL
, true, NULL
, this);
6537 // Only process on player casting paladin aura
6538 // all aura bonuses applied also in aura area effect way to caster
6539 if (GetCasterGUID() != m_target
->GetGUID() || !IS_PLAYER_GUID(GetCasterGUID()))
6542 if (GetSpellSpecific(m_spellProto
->Id
) != SPELL_AURA
)
6545 // Sanctified Retribution and Swift Retribution (they share one aura), but not Retribution Aura (already gets modded)
6546 if ((GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000000008))==0)
6547 spellId1
= 63531; // placeholder for talent spell mods
6548 // Improved Concentration Aura (auras bonus)
6549 spellId2
= 63510; // placeholder for talent spell mods
6550 // Improved Devotion Aura (auras bonus)
6551 spellId3
= 63514; // placeholder for talent spell mods
6554 case SPELLFAMILY_DEATHKNIGHT
:
6556 // second part of spell apply
6559 case 49039: spellId1
= 50397; break; // Lichborne
6561 case 48263: // Frost Presence
6562 case 48265: // Unholy Presence
6563 case 48266: // Blood Presence
6565 // else part one per 3 pair
6566 if (GetId()==48263 || GetId()==48265) // Frost Presence or Unholy Presence
6568 // Improved Blood Presence
6572 Unit::AuraList
const& bloodAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
6573 for(Unit::AuraList::const_iterator itr
= bloodAuras
.begin(); itr
!= bloodAuras
.end(); ++itr
)
6576 if ((*itr
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_DEATHKNIGHT
&&
6577 (*itr
)->GetSpellProto()->SpellIconID
== 2636)
6579 heal_pct
= (*itr
)->GetModifier()->m_amount
;
6586 m_target
->CastCustomSpell(m_target
, 63611, &heal_pct
, NULL
, NULL
, true, NULL
, this);
6588 m_target
->RemoveAurasDueToSpell(63611);
6591 spellId1
= 63611; // Improved Blood Presence, trigger for heal
6593 if (GetId()==48263 || GetId()==48266) // Frost Presence or Blood Presence
6595 // Improved Unholy Presence
6596 int32 power_pct
= 0;
6599 Unit::AuraList
const& unholyAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
6600 for(Unit::AuraList::const_iterator itr
= unholyAuras
.begin(); itr
!= unholyAuras
.end(); ++itr
)
6603 if ((*itr
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_DEATHKNIGHT
&&
6604 (*itr
)->GetSpellProto()->SpellIconID
== 2633)
6606 power_pct
= (*itr
)->GetModifier()->m_amount
;
6612 if (power_pct
|| !apply
)
6613 spellId2
= 49772; // Unholy Presence, speed part, spell1 used for Improvement presence fit to own presence
6616 spellId1
= 49772; // Unholy Presence move speed
6618 if (GetId()==48265 || GetId()==48266) // Unholy Presence or Blood Presence
6620 // Improved Frost Presence
6621 int32 stamina_pct
= 0;
6624 Unit::AuraList
const& frostAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
6625 for(Unit::AuraList::const_iterator itr
= frostAuras
.begin(); itr
!= frostAuras
.end(); ++itr
)
6628 if ((*itr
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_DEATHKNIGHT
&&
6629 (*itr
)->GetSpellProto()->SpellIconID
== 2632)
6631 stamina_pct
= (*itr
)->GetModifier()->m_amount
;
6638 m_target
->CastCustomSpell(m_target
, 61261, &stamina_pct
, NULL
, NULL
, true, NULL
, this);
6640 m_target
->RemoveAurasDueToSpell(61261);
6643 spellId1
= 61261; // Frost Presence, stamina
6645 if (GetId()==48265) // Unholy Presence
6647 // Improved Unholy Presence, special case for own presence
6648 int32 power_pct
= 0;
6651 Unit::AuraList
const& unholyAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
6652 for(Unit::AuraList::const_iterator itr
= unholyAuras
.begin(); itr
!= unholyAuras
.end(); ++itr
)
6655 if ((*itr
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_DEATHKNIGHT
&&
6656 (*itr
)->GetSpellProto()->SpellIconID
== 2633)
6658 power_pct
= (*itr
)->GetModifier()->m_amount
;
6667 m_target
->CastCustomSpell(m_target
, 63622, &bp
, &bp
, &bp
, true, NULL
, this);
6668 m_target
->CastCustomSpell(m_target
, 65095, &bp
, NULL
, NULL
, true, NULL
, this);
6672 m_target
->RemoveAurasDueToSpell(63622);
6673 m_target
->RemoveAurasDueToSpell(65095);
6680 // Improved Blood Presence
6681 if (GetSpellProto()->SpellIconID
== 2632 && GetModifier()->m_auraname
==SPELL_AURA_DUMMY
)
6683 // if presence active: Frost Presence or Unholy Presence
6684 if (apply
&& (m_target
->HasAura(48263) || m_target
->HasAura(48265)))
6686 int32 bp
= GetModifier()->m_amount
;
6687 m_target
->CastCustomSpell(m_target
, 63611, &bp
, NULL
, NULL
, true, NULL
, this);
6690 m_target
->RemoveAurasDueToSpell(63611);
6694 // Improved Frost Presence
6695 if (GetSpellProto()->SpellIconID
== 2636 && GetModifier()->m_auraname
==SPELL_AURA_DUMMY
)
6697 // if presence active: Unholy Presence or Blood Presence
6698 if (apply
&& (m_target
->HasAura(48265) || m_target
->HasAura(48266)))
6700 int32 bp
= GetModifier()->m_amount
;
6701 m_target
->CastCustomSpell(m_target
, 61261, &bp
, NULL
, NULL
, true, NULL
, this);
6704 m_target
->RemoveAurasDueToSpell(61261);
6708 // Improved Unholy Presence
6709 if (GetSpellProto()->SpellIconID
== 2633 && GetModifier()->m_auraname
==SPELL_AURA_DUMMY
)
6711 // if presence active: Unholy Presence
6712 if (apply
&& m_target
->HasAura(48265))
6715 m_target
->CastCustomSpell(m_target
, 63622, &bp
, &bp
, &bp
, true, NULL
, this);
6716 m_target
->CastCustomSpell(m_target
, 65095, &bp
, NULL
, NULL
, true, NULL
, this);
6720 m_target
->RemoveAurasDueToSpell(63622);
6721 m_target
->RemoveAurasDueToSpell(65095);
6724 // if presence active: Frost Presence or Blood Presence
6725 if (!apply
|| m_target
->HasAura(48263) || m_target
->HasAura(48266))
6737 // prevent aura deletion, specially in multi-boost case
6740 if (apply
|| cast_at_remove
)
6743 m_target
->CastSpell(m_target
, spellId1
, true, NULL
, this);
6744 if (spellId2
&& !IsDeleted())
6745 m_target
->CastSpell(m_target
, spellId2
, true, NULL
, this);
6746 if (spellId3
&& !IsDeleted())
6747 m_target
->CastSpell(m_target
, spellId3
, true, NULL
, this);
6748 if (spellId4
&& !IsDeleted())
6749 m_target
->CastSpell(m_target
, spellId4
, true, NULL
, this);
6754 m_target
->RemoveAurasByCasterSpell(spellId1
, GetCasterGUID());
6756 m_target
->RemoveAurasByCasterSpell(spellId2
, GetCasterGUID());
6758 m_target
->RemoveAurasByCasterSpell(spellId3
, GetCasterGUID());
6760 m_target
->RemoveAurasByCasterSpell(spellId4
, GetCasterGUID());
6766 void Aura::HandleAuraEmpathy(bool apply
, bool /*Real*/)
6768 if(GetTarget()->GetTypeId() != TYPEID_UNIT
)
6771 CreatureInfo
const * ci
= ObjectMgr::GetCreatureTemplate(GetTarget()->GetEntry());
6772 if(ci
&& ci
->type
== CREATURE_TYPE_BEAST
)
6773 GetTarget()->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_SPECIALINFO
, apply
);
6776 void Aura::HandleAuraUntrackable(bool apply
, bool /*Real*/)
6779 GetTarget()->SetByteFlag(UNIT_FIELD_BYTES_1
, 3, UNIT_BYTE1_FLAG_UNTRACKABLE
);
6781 GetTarget()->RemoveByteFlag(UNIT_FIELD_BYTES_1
, 3, UNIT_BYTE1_FLAG_UNTRACKABLE
);
6784 void Aura::HandleAuraModPacify(bool apply
, bool /*Real*/)
6786 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
6790 GetTarget()->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PACIFIED
);
6792 GetTarget()->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PACIFIED
);
6795 void Aura::HandleAuraModPacifyAndSilence(bool apply
, bool Real
)
6797 HandleAuraModPacify(apply
, Real
);
6798 HandleAuraModSilence(apply
, Real
);
6801 void Aura::HandleAuraGhost(bool apply
, bool /*Real*/)
6803 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
6808 GetTarget()->SetFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
);
6812 GetTarget()->RemoveFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
);
6816 void Aura::HandleAuraAllowFlight(bool apply
, bool Real
)
6818 // all applied/removed only at real aura add/remove
6825 data
.Initialize(SMSG_MOVE_SET_CAN_FLY
, 12);
6827 data
.Initialize(SMSG_MOVE_UNSET_CAN_FLY
, 12);
6828 data
<< GetTarget()->GetPackGUID();
6829 data
<< uint32(0); // unk
6830 GetTarget()->SendMessageToSet(&data
, true);
6833 void Aura::HandleModRating(bool apply
, bool Real
)
6835 // spells required only Real aura add/remove
6839 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
6842 for (uint32 rating
= 0; rating
< MAX_COMBAT_RATING
; ++rating
)
6843 if (m_modifier
.m_miscvalue
& (1 << rating
))
6844 ((Player
*)GetTarget())->ApplyRatingMod(CombatRating(rating
), m_modifier
.m_amount
, apply
);
6847 void Aura::HandleModRatingFromStat(bool apply
, bool Real
)
6849 // spells required only Real aura add/remove
6853 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
6855 // Just recalculate ratings
6856 for (uint32 rating
= 0; rating
< MAX_COMBAT_RATING
; ++rating
)
6857 if (m_modifier
.m_miscvalue
& (1 << rating
))
6858 ((Player
*)GetTarget())->ApplyRatingMod(CombatRating(rating
), 0, apply
);
6861 void Aura::HandleForceMoveForward(bool apply
, bool Real
)
6863 if(!Real
|| GetTarget()->GetTypeId() != TYPEID_PLAYER
)
6866 GetTarget()->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FORCE_MOVE
);
6868 GetTarget()->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FORCE_MOVE
);
6871 void Aura::HandleAuraModExpertise(bool /*apply*/, bool /*Real*/)
6873 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
6876 ((Player
*)GetTarget())->UpdateExpertise(BASE_ATTACK
);
6877 ((Player
*)GetTarget())->UpdateExpertise(OFF_ATTACK
);
6880 void Aura::HandleModTargetResistance(bool apply
, bool Real
)
6882 // spells required only Real aura add/remove
6885 Unit
*target
= GetTarget();
6886 // applied to damage as HandleNoImmediateEffect in Unit::CalculateAbsorbAndResist and Unit::CalcArmorReducedDamage
6887 // show armor penetration
6888 if (target
->GetTypeId() == TYPEID_PLAYER
&& (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
6889 target
->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE
, m_modifier
.m_amount
, apply
);
6891 // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy
6892 if (target
->GetTypeId() == TYPEID_PLAYER
&& (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_SPELL
)==SPELL_SCHOOL_MASK_SPELL
)
6893 target
->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE
, m_modifier
.m_amount
, apply
);
6896 void Aura::HandleShieldBlockValue(bool apply
, bool /*Real*/)
6898 BaseModType modType
= FLAT_MOD
;
6899 if(m_modifier
.m_auraname
== SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT
)
6902 if(GetTarget()->GetTypeId() == TYPEID_PLAYER
)
6903 ((Player
*)GetTarget())->HandleBaseModValue(SHIELD_BLOCK_VALUE
, modType
, float(m_modifier
.m_amount
), apply
);
6906 void Aura::HandleAuraRetainComboPoints(bool apply
, bool Real
)
6908 // spells required only Real aura add/remove
6912 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
6915 Player
*target
= (Player
*)GetTarget();
6917 // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler
6918 // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost)
6919 if( !apply
&& m_duration
==0 && target
->GetComboTarget())
6920 if(Unit
* unit
= ObjectAccessor::GetUnit(*GetTarget(),target
->GetComboTarget()))
6921 target
->AddComboPoints(unit
, -m_modifier
.m_amount
);
6924 void Aura::HandleModUnattackable( bool Apply
, bool Real
)
6928 GetTarget()->CombatStop();
6929 GetTarget()->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
);
6931 GetTarget()->ApplyModFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_NON_ATTACKABLE
,Apply
);
6934 void Aura::HandleSpiritOfRedemption( bool apply
, bool Real
)
6936 // spells required only Real aura add/remove
6940 Unit
*target
= GetTarget();
6942 // prepare spirit state
6945 if(target
->GetTypeId()==TYPEID_PLAYER
)
6947 // disable breath/etc timers
6948 ((Player
*)target
)->StopMirrorTimers();
6950 // set stand state (expected in this form)
6951 if(!target
->IsStandState())
6952 target
->SetStandState(UNIT_STAND_STATE_STAND
);
6955 target
->SetHealth(1);
6959 target
->DealDamage(target
, target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, GetSpellProto(), false);
6962 void Aura::CleanupTriggeredSpells()
6964 uint32 tSpellId
= m_spellProto
->EffectTriggerSpell
[GetEffIndex()];
6968 SpellEntry
const* tProto
= sSpellStore
.LookupEntry(tSpellId
);
6972 if(GetSpellDuration(tProto
) != -1)
6975 // needed for spell 43680, maybe others
6976 // TODO: is there a spell flag, which can solve this in a more sophisticated way?
6977 if(m_spellProto
->EffectApplyAuraName
[GetEffIndex()] == SPELL_AURA_PERIODIC_TRIGGER_SPELL
&&
6978 GetSpellDuration(m_spellProto
) == m_spellProto
->EffectAmplitude
[GetEffIndex()])
6980 m_target
->RemoveAurasDueToSpell(tSpellId
);
6983 void Aura::HandleSchoolAbsorb(bool apply
, bool Real
)
6988 Unit
* caster
= GetCaster();
6992 Unit
*target
= GetTarget();
6993 SpellEntry
const* spellProto
= GetSpellProto();
6996 // prevent double apply bonuses
6997 if (target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)target
)->GetSession()->PlayerLoading())
6999 float DoneActualBenefit
= 0.0f
;
7000 switch(spellProto
->SpellFamilyName
)
7002 case SPELLFAMILY_PRIEST
:
7003 // Power Word: Shield
7004 if (spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000001))
7006 //+80.68% from +spell bonus
7007 DoneActualBenefit
= caster
->SpellBaseHealingBonusDone(GetSpellSchoolMask(spellProto
)) * 0.8068f
;
7009 Unit::AuraList
const& borrowedTime
= caster
->GetAurasByType(SPELL_AURA_DUMMY
);
7010 for(Unit::AuraList::const_iterator itr
= borrowedTime
.begin(); itr
!= borrowedTime
.end(); ++itr
)
7012 SpellEntry
const* i_spell
= (*itr
)->GetSpellProto();
7013 if(i_spell
->SpellFamilyName
==SPELLFAMILY_PRIEST
&& i_spell
->SpellIconID
== 2899 && i_spell
->EffectMiscValue
[(*itr
)->GetEffIndex()] == 24)
7015 DoneActualBenefit
+= DoneActualBenefit
* (*itr
)->GetModifier()->m_amount
/ 100;
7022 case SPELLFAMILY_MAGE
:
7023 // Frost Ward, Fire Ward
7024 if (spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000108))
7025 //+10% from +spell bonus
7026 DoneActualBenefit
= caster
->SpellBaseDamageBonusDone(GetSpellSchoolMask(spellProto
)) * 0.1f
;
7028 else if (spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000100000000))
7029 //+80.67% from +spell bonus
7030 DoneActualBenefit
= caster
->SpellBaseDamageBonusDone(GetSpellSchoolMask(spellProto
)) * 0.8067f
;
7032 case SPELLFAMILY_WARLOCK
:
7034 if (spellProto
->SpellFamilyFlags2
& 0x00000040)
7035 //+30% from +spell bonus
7036 DoneActualBenefit
= caster
->SpellBaseDamageBonusDone(GetSpellSchoolMask(spellProto
)) * 0.30f
;
7038 case SPELLFAMILY_PALADIN
:
7040 // (check not strictly needed, only Sacred Shield has SPELL_AURA_SCHOOL_ABSORB in SPELLFAMILY_PALADIN at this time)
7041 if (spellProto
->SpellFamilyFlags
& UI64LIT(0x0008000000000000))
7043 // +75% from spell power
7044 DoneActualBenefit
= caster
->SpellBaseHealingBonusDone(GetSpellSchoolMask(spellProto
)) * 0.75f
;
7051 DoneActualBenefit
*= caster
->CalculateLevelPenalty(GetSpellProto());
7053 m_modifier
.m_amount
+= (int32
)DoneActualBenefit
;
7059 // Power Word: Shield
7060 spellProto
->SpellFamilyName
== SPELLFAMILY_PRIEST
&& spellProto
->Mechanic
== MECHANIC_SHIELD
&&
7061 (spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000001)) &&
7062 // completely absorbed or dispelled
7063 (m_removeMode
== AURA_REMOVE_BY_SHIELD_BREAK
|| m_removeMode
== AURA_REMOVE_BY_DISPEL
))
7065 Unit::AuraList
const& vDummyAuras
= caster
->GetAurasByType(SPELL_AURA_DUMMY
);
7066 for(Unit::AuraList::const_iterator itr
= vDummyAuras
.begin(); itr
!= vDummyAuras
.end(); ++itr
)
7068 SpellEntry
const* vSpell
= (*itr
)->GetSpellProto();
7070 // Rapture (main spell)
7071 if(vSpell
->SpellFamilyName
== SPELLFAMILY_PRIEST
&& vSpell
->SpellIconID
== 2894 && vSpell
->Effect
[EFFECT_INDEX_1
])
7073 switch((*itr
)->GetEffIndex())
7075 case EFFECT_INDEX_0
:
7078 int32 manapct1000
= 5 * ((*itr
)->GetModifier()->m_amount
+ sSpellMgr
.GetSpellRank(vSpell
->Id
));
7079 int32 basepoints0
= caster
->GetMaxPower(POWER_MANA
) * manapct1000
/ 1000;
7080 caster
->CastCustomSpell(caster
, 47755, &basepoints0
, NULL
, NULL
, true);
7083 case EFFECT_INDEX_1
:
7086 if (!roll_chance_i((*itr
)->GetModifier()->m_amount
) || caster
->HasAura(63853))
7089 switch(target
->getPowerType())
7091 case POWER_RUNIC_POWER
:
7092 target
->CastSpell(target
, 63652, true, NULL
, NULL
, GetCasterGUID());
7095 target
->CastSpell(target
, 63653, true, NULL
, NULL
, GetCasterGUID());
7099 int32 basepoints0
= target
->GetMaxPower(POWER_MANA
) * 2 / 100;
7100 target
->CastCustomSpell(target
, 63654, &basepoints0
, NULL
, NULL
, true);
7104 target
->CastSpell(target
, 63655, true, NULL
, NULL
, GetCasterGUID());
7111 caster
->CastSpell(caster
, 63853, true);
7115 sLog
.outError("Changes in R-dummy spell???: effect 3");
7124 void Aura::PeriodicTick()
7126 Unit
*target
= GetTarget();
7127 SpellEntry
const* spellProto
= GetSpellProto();
7129 switch(m_modifier
.m_auraname
)
7131 case SPELL_AURA_PERIODIC_DAMAGE
:
7132 case SPELL_AURA_PERIODIC_DAMAGE_PERCENT
:
7134 // don't damage target if not alive, possible death persistent effects
7135 if (!target
->isAlive())
7138 Unit
*pCaster
= GetCaster();
7142 if( spellProto
->Effect
[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
7143 pCaster
->SpellHitResult(target
, spellProto
, false) != SPELL_MISS_NONE
)
7146 // Check for immune (not use charges)
7147 if(target
->IsImmunedToDamage(GetSpellSchoolMask(spellProto
)))
7150 // some auras remove at specific health level or more
7151 if(m_modifier
.m_auraname
== SPELL_AURA_PERIODIC_DAMAGE
)
7155 case 43093: case 31956: case 38801:
7156 case 35321: case 38363: case 39215:
7159 if(target
->GetHealth() == target
->GetMaxHealth() )
7161 target
->RemoveAurasDueToSpell(GetId());
7169 GetEffIndex() < EFFECT_INDEX_2
&& spellProto
->Effect
[GetEffIndex()] == SPELL_EFFECT_DUMMY
?
7170 pCaster
->CalculateSpellDamage(target
, spellProto
, SpellEffectIndex(GetEffIndex() + 1)) :
7172 if(target
->GetHealth() * 100 >= target
->GetMaxHealth() * percent
)
7174 target
->RemoveAurasDueToSpell(GetId());
7186 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
7188 // ignore non positive values (can be result apply spellmods to aura damage
7189 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
7193 if(m_modifier
.m_auraname
== SPELL_AURA_PERIODIC_DAMAGE
)
7196 pdamage
= uint32(target
->GetMaxHealth()*amount
/100);
7199 // SpellDamageBonus for magic spells
7200 if(spellProto
->DmgClass
== SPELL_DAMAGE_CLASS_NONE
|| spellProto
->DmgClass
== SPELL_DAMAGE_CLASS_MAGIC
)
7201 pdamage
= target
->SpellDamageBonusTaken(pCaster
, spellProto
, pdamage
, DOT
, GetStackAmount());
7202 // MeleeDamagebonus for weapon based spells
7205 WeaponAttackType attackType
= GetWeaponAttackType(spellProto
);
7206 pdamage
= target
->MeleeDamageBonusTaken(pCaster
, pdamage
, attackType
, spellProto
, DOT
, GetStackAmount());
7209 // Calculate armor mitigation if it is a physical spell
7210 // But not for bleed mechanic spells
7211 if (GetSpellSchoolMask(spellProto
) & SPELL_SCHOOL_MASK_NORMAL
&&
7212 GetEffectMechanic(spellProto
, m_effIndex
) != MECHANIC_BLEED
)
7214 uint32 pdamageReductedArmor
= pCaster
->CalcArmorReducedDamage(target
, pdamage
);
7215 cleanDamage
.damage
+= pdamage
- pdamageReductedArmor
;
7216 pdamage
= pdamageReductedArmor
;
7219 // Curse of Agony damage-per-tick calculation
7220 if (spellProto
->SpellFamilyName
==SPELLFAMILY_WARLOCK
&& (spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000400)) && spellProto
->SpellIconID
==544)
7222 // 1..4 ticks, 1/2 from normal tick damage
7223 if (GetAuraTicks() <= 4)
7224 pdamage
= pdamage
/2;
7225 // 9..12 ticks, 3/2 from normal tick damage
7226 else if(GetAuraTicks() >= 9)
7227 pdamage
+= (pdamage
+ 1) / 2; // +1 prevent 0.5 damage possible lost at 1..4 ticks
7228 // 5..8 ticks have normal tick damage
7231 // This method can modify pdamage
7232 bool isCrit
= IsCritFromAbilityAura(pCaster
, pdamage
);
7234 // send critical in hit info for threat calculation
7237 cleanDamage
.hitOutCome
= MELEE_HIT_CRIT
;
7238 // Resilience - reduce crit damage
7239 pdamage
-= target
->GetSpellCritDamageReduction(pdamage
);
7242 // only from players
7243 // FIXME: need use SpellDamageBonus instead?
7244 if (pCaster
->GetTypeId() == TYPEID_PLAYER
)
7245 pdamage
-= target
->GetSpellDamageReduction(pdamage
);
7247 target
->CalculateAbsorbAndResist(pCaster
, GetSpellSchoolMask(spellProto
), DOT
, pdamage
, &absorb
, &resist
, !(GetSpellProto()->AttributesEx2
& SPELL_ATTR_EX2_CANT_REFLECTED
));
7249 DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS
, "PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
7250 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target
->GetGUIDLow(), target
->GetTypeId(), pdamage
, GetId(),absorb
);
7252 pCaster
->DealDamageMods(target
, pdamage
, &absorb
);
7255 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
7256 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
7257 pdamage
= (pdamage
<= absorb
+ resist
) ? 0 : (pdamage
- absorb
- resist
);
7259 SpellPeriodicAuraLogInfo
pInfo(this, pdamage
, 0, absorb
, resist
, 0.0f
, isCrit
);
7260 target
->SendPeriodicAuraLog(&pInfo
);
7263 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
7265 pCaster
->ProcDamageAndSpell(target
, procAttacker
, procVictim
, PROC_EX_NORMAL_HIT
, pdamage
, BASE_ATTACK
, spellProto
);
7267 pCaster
->DealDamage(target
, pdamage
, &cleanDamage
, DOT
, GetSpellSchoolMask(spellProto
), spellProto
, true);
7269 // Drain Soul (chance soul shard)
7270 if (pCaster
->GetTypeId() == TYPEID_PLAYER
&& spellProto
->SpellFamilyName
== SPELLFAMILY_WARLOCK
&& spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000004000))
7272 // Only from non-grey units
7273 if (roll_chance_i(10) && // 1-2 from drain with final and without glyph, 0-1 from damage
7274 ((Player
*)pCaster
)->isHonorOrXPTarget(target
) &&
7275 (target
->GetTypeId() != TYPEID_UNIT
|| ((Player
*)pCaster
)->isAllowedToLoot((Creature
*)target
)))
7277 pCaster
->CastSpell(pCaster
, 43836, true, NULL
, this);
7283 case SPELL_AURA_PERIODIC_LEECH
:
7284 case SPELL_AURA_PERIODIC_HEALTH_FUNNEL
:
7286 // don't damage target if not alive, possible death persistent effects
7287 if (!target
->isAlive())
7290 Unit
*pCaster
= GetCaster();
7294 if(!pCaster
->isAlive())
7297 if( spellProto
->Effect
[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
7298 pCaster
->SpellHitResult(target
, spellProto
, false) != SPELL_MISS_NONE
)
7302 if(target
->IsImmunedToDamage(GetSpellSchoolMask(spellProto
)))
7307 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
7309 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
7311 //Calculate armor mitigation if it is a physical spell
7312 if (GetSpellSchoolMask(spellProto
) & SPELL_SCHOOL_MASK_NORMAL
)
7314 uint32 pdamageReductedArmor
= pCaster
->CalcArmorReducedDamage(target
, pdamage
);
7315 cleanDamage
.damage
+= pdamage
- pdamageReductedArmor
;
7316 pdamage
= pdamageReductedArmor
;
7319 pdamage
= target
->SpellDamageBonusTaken(pCaster
, spellProto
, pdamage
, DOT
, GetStackAmount());
7321 bool isCrit
= IsCritFromAbilityAura(pCaster
, pdamage
);
7323 // send critical in hit info for threat calculation
7326 cleanDamage
.hitOutCome
= MELEE_HIT_CRIT
;
7327 // Resilience - reduce crit damage
7328 pdamage
-= target
->GetSpellCritDamageReduction(pdamage
);
7331 // only from players
7332 // FIXME: need use SpellDamageBonus instead?
7333 if (IS_PLAYER_GUID(GetCasterGUID()))
7334 pdamage
-= target
->GetSpellDamageReduction(pdamage
);
7336 target
->CalculateAbsorbAndResist(pCaster
, GetSpellSchoolMask(spellProto
), DOT
, pdamage
, &absorb
, &resist
, !(spellProto
->AttributesEx2
& SPELL_ATTR_EX2_CANT_REFLECTED
));
7338 if(target
->GetHealth() < pdamage
)
7339 pdamage
= uint32(target
->GetHealth());
7341 DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS
, "PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
7342 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target
->GetGUIDLow(), target
->GetTypeId(), pdamage
, GetId(),absorb
);
7344 pCaster
->DealDamageMods(target
, pdamage
, &absorb
);
7346 pCaster
->SendSpellNonMeleeDamageLog(target
, GetId(), pdamage
, GetSpellSchoolMask(spellProto
), absorb
, resist
, false, 0, isCrit
);
7348 float multiplier
= spellProto
->EffectMultipleValue
[GetEffIndex()] > 0 ? spellProto
->EffectMultipleValue
[GetEffIndex()] : 1;
7351 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
7352 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
7353 pdamage
= (pdamage
<= absorb
+ resist
) ? 0 : (pdamage
-absorb
-resist
);
7355 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
7356 pCaster
->ProcDamageAndSpell(target
, procAttacker
, procVictim
, PROC_EX_NORMAL_HIT
, pdamage
, BASE_ATTACK
, spellProto
);
7357 int32 new_damage
= pCaster
->DealDamage(target
, pdamage
, &cleanDamage
, DOT
, GetSpellSchoolMask(spellProto
), spellProto
, false);
7359 if (!target
->isAlive() && pCaster
->IsNonMeleeSpellCasted(false))
7360 for (uint32 i
= CURRENT_FIRST_NON_MELEE_SPELL
; i
< CURRENT_MAX_SPELL
; ++i
)
7361 if (Spell
* spell
= pCaster
->GetCurrentSpell(CurrentSpellTypes(i
)))
7362 if (spell
->m_spellInfo
->Id
== GetId())
7366 if(Player
*modOwner
= pCaster
->GetSpellModOwner())
7367 modOwner
->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE
, multiplier
);
7369 int32 heal
= pCaster
->SpellHealingBonusTaken(pCaster
, spellProto
, int32(new_damage
* multiplier
), DOT
, GetStackAmount());
7371 int32 gain
= pCaster
->DealHeal(pCaster
, heal
, spellProto
);
7372 pCaster
->getHostileRefManager().threatAssist(pCaster
, gain
* 0.5f
, spellProto
);
7375 case SPELL_AURA_PERIODIC_HEAL
:
7376 case SPELL_AURA_OBS_MOD_HEALTH
:
7378 // don't heal target if not alive, mostly death persistent effects from items
7379 if (!target
->isAlive())
7382 Unit
*pCaster
= GetCaster();
7386 // heal for caster damage (must be alive)
7387 if(target
!= pCaster
&& spellProto
->SpellVisual
[0] == 163 && !pCaster
->isAlive())
7390 // ignore non positive values (can be result apply spellmods to aura damage
7391 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
7395 if(m_modifier
.m_auraname
==SPELL_AURA_OBS_MOD_HEALTH
)
7396 pdamage
= uint32(target
->GetMaxHealth() * amount
/ 100);
7401 // Wild Growth (1/7 - 6 + 2*ramainTicks) %
7402 if (spellProto
->SpellFamilyName
== SPELLFAMILY_DRUID
&& spellProto
->SpellIconID
== 2864)
7404 int32 ticks
= GetAuraMaxTicks();
7405 int32 remainingTicks
= ticks
- GetAuraTicks();
7406 int32 addition
= int32(amount
)*ticks
*(-6+2*remainingTicks
)/100;
7408 if (GetAuraTicks() != 1)
7409 // Item - Druid T10 Restoration 2P Bonus
7410 if (Aura
*aura
= pCaster
->GetAura(70658, EFFECT_INDEX_0
))
7411 addition
+= abs(int32((addition
* aura
->GetModifier()->m_amount
) / ((ticks
-1)* 100)));
7413 pdamage
= int32(pdamage
) + addition
;
7417 pdamage
= target
->SpellHealingBonusTaken(pCaster
, spellProto
, pdamage
, DOT
, GetStackAmount());
7419 // This method can modify pdamage
7420 bool isCrit
= IsCritFromAbilityAura(pCaster
, pdamage
);
7422 DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS
, "PeriodicTick: %u (TypeId: %u) heal of %u (TypeId: %u) for %u health inflicted by %u",
7423 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target
->GetGUIDLow(), target
->GetTypeId(), pdamage
, GetId());
7425 int32 gain
= target
->ModifyHealth(pdamage
);
7426 SpellPeriodicAuraLogInfo
pInfo(this, pdamage
, (pdamage
- uint32(gain
)), 0, 0, 0.0f
, isCrit
);
7427 target
->SendPeriodicAuraLog(&pInfo
);
7430 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
;
7431 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;
7432 pCaster
->ProcDamageAndSpell(target
, procAttacker
, procVictim
, PROC_EX_NORMAL_HIT
, gain
, BASE_ATTACK
, spellProto
);
7434 // add HoTs to amount healed in bgs
7435 if( pCaster
->GetTypeId() == TYPEID_PLAYER
)
7436 if( BattleGround
*bg
= ((Player
*)pCaster
)->GetBattleGround() )
7437 bg
->UpdatePlayerScore(((Player
*)pCaster
), SCORE_HEALING_DONE
, gain
);
7439 target
->getHostileRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, spellProto
);
7441 // heal for caster damage
7442 if(target
!= pCaster
&& spellProto
->SpellVisual
[0] == 163)
7444 uint32 dmg
= spellProto
->manaPerSecond
;
7445 if(pCaster
->GetHealth() <= dmg
&& pCaster
->GetTypeId()==TYPEID_PLAYER
)
7447 pCaster
->RemoveAurasDueToSpell(GetId());
7449 // finish current generic/channeling spells, don't affect autorepeat
7450 pCaster
->FinishSpell(CURRENT_GENERIC_SPELL
);
7451 pCaster
->FinishSpell(CURRENT_CHANNELED_SPELL
);
7455 uint32 damage
= gain
;
7457 pCaster
->DealDamageMods(pCaster
, damage
, &absorb
);
7458 pCaster
->SendSpellNonMeleeDamageLog(pCaster
, GetId(), damage
, GetSpellSchoolMask(spellProto
), absorb
, 0, false, 0, false);
7460 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
7461 pCaster
->DealDamage(pCaster
, damage
, &cleanDamage
, NODAMAGE
, GetSpellSchoolMask(spellProto
), spellProto
, true);
7465 // uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;// | PROC_FLAG_SUCCESSFUL_HEAL;
7466 // uint32 procVictim = 0;//ROC_FLAG_ON_TAKE_PERIODIC | PROC_FLAG_TAKEN_HEAL;
7467 // ignore item heals
7468 // if(procSpell && !haveCastItem)
7469 // pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto);
7472 case SPELL_AURA_PERIODIC_MANA_LEECH
:
7474 // don't damage target if not alive, possible death persistent effects
7475 if (!target
->isAlive())
7478 if(m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
>= MAX_POWERS
)
7481 Powers power
= Powers(m_modifier
.m_miscvalue
);
7483 // power type might have changed between aura applying and tick (druid's shapeshift)
7484 if(target
->getPowerType() != power
)
7487 Unit
*pCaster
= GetCaster();
7491 if(!pCaster
->isAlive())
7494 if( GetSpellProto()->Effect
[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
7495 pCaster
->SpellHitResult(target
, spellProto
, false) != SPELL_MISS_NONE
)
7498 // Check for immune (not use charges)
7499 if(target
->IsImmunedToDamage(GetSpellSchoolMask(spellProto
)))
7502 // ignore non positive values (can be result apply spellmods to aura damage
7503 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
7505 // Special case: draining x% of mana (up to a maximum of 2*x% of the caster's maximum mana)
7506 // It's mana percent cost spells, m_modifier.m_amount is percent drain from target
7507 if (spellProto
->ManaCostPercentage
)
7510 uint32 maxmana
= pCaster
->GetMaxPower(power
) * pdamage
* 2 / 100;
7511 pdamage
= target
->GetMaxPower(power
) * pdamage
/ 100;
7512 if(pdamage
> maxmana
)
7516 DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS
, "PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u",
7517 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target
->GetGUIDLow(), target
->GetTypeId(), pdamage
, GetId());
7519 int32 drain_amount
= target
->GetPower(power
) > pdamage
? pdamage
: target
->GetPower(power
);
7521 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
7522 if (power
== POWER_MANA
)
7523 drain_amount
-= target
->GetSpellCritDamageReduction(drain_amount
);
7525 target
->ModifyPower(power
, -drain_amount
);
7527 float gain_multiplier
= 0;
7529 if(pCaster
->GetMaxPower(power
) > 0)
7531 gain_multiplier
= spellProto
->EffectMultipleValue
[GetEffIndex()];
7533 if(Player
*modOwner
= pCaster
->GetSpellModOwner())
7534 modOwner
->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE
, gain_multiplier
);
7537 SpellPeriodicAuraLogInfo
pInfo(this, drain_amount
, 0, 0, 0, gain_multiplier
);
7538 target
->SendPeriodicAuraLog(&pInfo
);
7540 int32 gain_amount
= int32(drain_amount
* gain_multiplier
);
7544 int32 gain
= pCaster
->ModifyPower(power
, gain_amount
);
7545 target
->AddThreat(pCaster
, float(gain
) * 0.5f
, pInfo
.critical
, GetSpellSchoolMask(spellProto
), spellProto
);
7549 case SPELL_AURA_PERIODIC_ENERGIZE
:
7551 // don't energize target if not alive, possible death persistent effects
7552 if (!target
->isAlive())
7555 // ignore non positive values (can be result apply spellmods to aura damage
7556 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
7558 DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS
, "PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u",
7559 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target
->GetGUIDLow(), target
->GetTypeId(), pdamage
, GetId());
7561 if(m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
>= MAX_POWERS
)
7564 Powers power
= Powers(m_modifier
.m_miscvalue
);
7566 if(target
->GetMaxPower(power
) == 0)
7569 SpellPeriodicAuraLogInfo
pInfo(this, pdamage
, 0, 0, 0, 0.0f
);
7570 target
->SendPeriodicAuraLog(&pInfo
);
7572 int32 gain
= target
->ModifyPower(power
,pdamage
);
7574 if(Unit
* pCaster
= GetCaster())
7575 target
->getHostileRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, spellProto
);
7578 case SPELL_AURA_OBS_MOD_MANA
:
7580 // don't energize target if not alive, possible death persistent effects
7581 if (!target
->isAlive())
7584 // ignore non positive values (can be result apply spellmods to aura damage
7585 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
7587 uint32 pdamage
= uint32(target
->GetMaxPower(POWER_MANA
) * amount
/ 100);
7589 DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS
, "PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u mana inflicted by %u",
7590 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), target
->GetGUIDLow(), target
->GetTypeId(), pdamage
, GetId());
7592 if(target
->GetMaxPower(POWER_MANA
) == 0)
7595 SpellPeriodicAuraLogInfo
pInfo(this, pdamage
, 0, 0, 0, 0.0f
);
7596 target
->SendPeriodicAuraLog(&pInfo
);
7598 int32 gain
= target
->ModifyPower(POWER_MANA
, pdamage
);
7600 if(Unit
* pCaster
= GetCaster())
7601 target
->getHostileRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, spellProto
);
7604 case SPELL_AURA_POWER_BURN_MANA
:
7606 // don't mana burn target if not alive, possible death persistent effects
7607 if (!target
->isAlive())
7610 Unit
*pCaster
= GetCaster();
7614 // Check for immune (not use charges)
7615 if(target
->IsImmunedToDamage(GetSpellSchoolMask(spellProto
)))
7618 int32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
7620 Powers powerType
= Powers(m_modifier
.m_miscvalue
);
7622 if(!target
->isAlive() || target
->getPowerType() != powerType
)
7625 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
7626 if (powerType
== POWER_MANA
)
7627 pdamage
-= target
->GetSpellCritDamageReduction(pdamage
);
7629 uint32 gain
= uint32(-target
->ModifyPower(powerType
, -pdamage
));
7631 gain
= uint32(gain
* spellProto
->EffectMultipleValue
[GetEffIndex()]);
7633 // maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG
7634 SpellNonMeleeDamage
damageInfo(pCaster
, target
, spellProto
->Id
, SpellSchoolMask(spellProto
->SchoolMask
));
7635 pCaster
->CalculateSpellDamage(&damageInfo
, gain
, spellProto
);
7637 damageInfo
.target
->CalculateAbsorbResistBlock(pCaster
, &damageInfo
, spellProto
);
7639 pCaster
->DealDamageMods(damageInfo
.target
, damageInfo
.damage
, &damageInfo
.absorb
);
7641 pCaster
->SendSpellNonMeleeDamageLog(&damageInfo
);
7644 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
7645 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
7646 uint32 procEx
= createProcExtendMask(&damageInfo
, SPELL_MISS_NONE
);
7647 if (damageInfo
.damage
)
7648 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
7650 pCaster
->ProcDamageAndSpell(damageInfo
.target
, procAttacker
, procVictim
, procEx
, damageInfo
.damage
, BASE_ATTACK
, spellProto
);
7652 pCaster
->DealSpellDamage(&damageInfo
, true);
7655 case SPELL_AURA_MOD_REGEN
:
7657 // don't heal target if not alive, possible death persistent effects
7658 if (!target
->isAlive())
7661 int32 gain
= target
->ModifyHealth(m_modifier
.m_amount
);
7662 if (Unit
*caster
= GetCaster())
7663 target
->getHostileRefManager().threatAssist(caster
, float(gain
) * 0.5f
, spellProto
);
7666 case SPELL_AURA_MOD_POWER_REGEN
:
7668 // don't energize target if not alive, possible death persistent effects
7669 if (!target
->isAlive())
7672 Powers pt
= target
->getPowerType();
7673 if(int32(pt
) != m_modifier
.m_miscvalue
)
7676 if ( spellProto
->AuraInterruptFlags
& AURA_INTERRUPT_FLAG_NOT_SEATED
)
7679 target
->HandleEmoteCommand(EMOTE_ONESHOT_EAT
);
7681 else if( GetId() == 20577 )
7684 target
->HandleEmoteCommand(EMOTE_STATE_CANNIBALIZE
);
7688 // amount = 1+ 16 = 17 = 3,4*5 = 10,2*5/3
7689 // so 17 is rounded amount for 5 sec tick grow ~ 1 range grow in 3 sec
7690 if(pt
== POWER_RAGE
)
7691 target
->ModifyPower(pt
, m_modifier
.m_amount
* 3 / 5);
7694 // Here tick dummy auras
7695 case SPELL_AURA_DUMMY
: // some spells have dummy aura
7696 case SPELL_AURA_PERIODIC_DUMMY
:
7698 PeriodicDummyTick();
7701 case SPELL_AURA_PERIODIC_TRIGGER_SPELL
:
7706 case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
:
7708 TriggerSpellWithValue();
7716 void Aura::PeriodicDummyTick()
7718 SpellEntry
const* spell
= GetSpellProto();
7719 Unit
*target
= GetTarget();
7720 switch (spell
->SpellFamilyName
)
7722 case SPELLFAMILY_GENERIC
:
7740 case 49472: // Drink Coffee
7744 if (target
->GetTypeId() != TYPEID_PLAYER
)
7746 // Search SPELL_AURA_MOD_POWER_REGEN aura for this spell and add bonus
7747 Unit::AuraList
const& aura
= target
->GetAurasByType(SPELL_AURA_MOD_POWER_REGEN
);
7748 for(Unit::AuraList::const_iterator i
= aura
.begin(); i
!= aura
.end(); ++i
)
7750 if ((*i
)->GetId() == GetId())
7752 (*i
)->GetModifier()->m_amount
= m_modifier
.m_amount
;
7753 ((Player
*)target
)->UpdateManaRegen();
7755 m_isPeriodic
= false;
7764 // Possibly need cast one of them (but
7765 // 7038 Forsaken Skill: Swords
7766 // 7039 Forsaken Skill: Axes
7767 // 7040 Forsaken Skill: Daggers
7768 // 7041 Forsaken Skill: Maces
7769 // 7042 Forsaken Skill: Staves
7770 // 7043 Forsaken Skill: Bows
7771 // 7044 Forsaken Skill: Guns
7772 // 7045 Forsaken Skill: 2H Axes
7773 // 7046 Forsaken Skill: 2H Maces
7774 // 7047 Forsaken Skill: 2H Swords
7775 // 7048 Forsaken Skill: Defense
7776 // 7049 Forsaken Skill: Fire
7777 // 7050 Forsaken Skill: Frost
7778 // 7051 Forsaken Skill: Holy
7779 // 7053 Forsaken Skill: Shadow
7782 case 7057: // Haunting Spirits
7783 if (roll_chance_i(33))
7784 target
->CastSpell(target
,m_modifier
.m_amount
,true,NULL
,this);
7787 // case 19230: break;
7788 // // Gossip NPC Periodic - Talk
7789 // case 33208: break;
7790 // // Gossip NPC Periodic - Despawn
7791 // case 33209: break;
7793 // case 36207: break;
7794 // // Simon Game START timer, (DND)
7795 // case 39993: break;
7796 // // Knockdown Fel Cannon: break; The Aggro Burst
7797 // case 40119: break;
7798 // // Old Mount Spell
7799 // case 40154: break;
7801 // case 40581: break;
7802 // // Ethereal Ring: break; The Bolt Burst
7803 // case 40801: break;
7804 // // Crystal Prison
7805 // case 40846: break;
7807 // case 41054: break;
7809 // case 41404: break;
7810 // // Ethereal Ring Visual, Lightning Aura
7811 // case 41477: break;
7812 // // Ethereal Ring Visual, Lightning Aura (Fork)
7813 // case 41525: break;
7814 // // Ethereal Ring Visual, Lightning Jumper Aura
7815 // case 41567: break;
7817 // case 41955: break;
7818 // // Headless Horseman - Fire
7819 // case 42074: break;
7820 // // Headless Horseman - Visual - Large Fire
7821 // case 42075: break;
7822 // // Headless Horseman - Start Fire, Periodic Aura
7823 // case 42140: break;
7824 // // Ram Speed Boost
7825 // case 42152: break;
7826 // // Headless Horseman - Fires Out Victory Aura
7827 // case 42235: break;
7828 // // Pumpkin Life Cycle
7829 // case 42280: break;
7830 // // Brewfest Request Chick Chuck Mug Aura
7831 // case 42537: break;
7833 // case 42596: break;
7834 // // Headless Horseman Climax, Head: Periodic
7835 // case 42603: break;
7837 // case 42621: break;
7838 // // Headless Horseman - Conflagrate, Periodic Aura
7839 // case 42637: break;
7840 // // Headless Horseman - Create Pumpkin Treats Aura
7841 // case 42774: break;
7842 // // Headless Horseman Climax - Summoning Rhyme Aura
7843 // case 42879: break;
7845 // case 42919: break;
7847 // case 42924: break;
7849 // case 42992: break;
7851 // case 42993: break;
7853 // case 42994: break;
7854 // // Ram Level - Neutral
7855 // case 43310: break;
7856 // // Headless Horseman - Maniacal Laugh, Maniacal, Delayed 17
7857 // case 43884: break;
7859 // case 43963: break;
7860 // // Headless Horseman - Maniacal Laugh, Maniacal, other, Delayed 17
7861 // case 44000: break;
7862 // // Energy Feedback
7863 // case 44328: break;
7864 // // Romantic Picnic
7865 // case 45102: break;
7866 // // Romantic Picnic
7867 // case 45123: break;
7868 // // Looking for Love
7869 // case 45124: break;
7870 // // Kite - Lightning Strike Kite Aura
7871 // case 45197: break;
7872 // // Rocket Chicken
7873 // case 45202: break;
7874 // // Copy Offhand Weapon
7875 // case 45205: break;
7876 // // Upper Deck - Kite - Lightning Periodic Aura
7877 // case 45207: break;
7878 // // Kite -Sky Lightning Strike Kite Aura
7879 // case 45251: break;
7880 // // Ribbon Pole Dancer Check Aura
7881 // case 45390: break;
7882 // // Holiday - Midsummer, Ribbon Pole Periodic Visual
7883 // case 45406: break;
7885 // case 45472: break;
7886 // // Alliance Flag, Extra Damage Debuff
7887 // case 45898: break;
7888 // // Horde Flag, Extra Damage Debuff
7889 // case 45899: break;
7890 // // Ahune - Summoning Rhyme Aura
7891 // case 45926: break;
7892 // // Ahune - Slippery Floor
7893 // case 45945: break;
7894 // // Ahune's Shield
7895 // case 45954: break;
7896 // // Nether Vapor Lightning
7897 // case 45960: break;
7899 // case 45996: break;
7900 case 46041: // Summon Blood Elves Periodic
7901 target
->CastSpell(target
, 46037, true, NULL
, this);
7902 target
->CastSpell(target
, roll_chance_i(50) ? 46038 : 46039, true, NULL
, this);
7903 target
->CastSpell(target
, 46040, true, NULL
, this);
7905 // // Transform Visual Missile Periodic
7906 // case 46205: break;
7907 // // Find Opening Beam End
7908 // case 46333: break;
7909 // // Ice Spear Control Aura
7910 // case 46371: break;
7911 // // Hailstone Chill
7912 // case 46458: break;
7913 // // Hailstone Chill, Internal
7914 // case 46465: break;
7915 // // Chill, Internal Shifter
7916 // case 46549: break;
7917 // // Summon Ice Spear Knockback Delayer
7918 // case 46878: break;
7919 // // Burninate Effect
7920 // case 47214: break;
7921 // // Fizzcrank Practice Parachute
7922 // case 47228: break;
7923 // // Send Mug Control Aura
7924 // case 47369: break;
7925 // // Direbrew's Disarm (precast)
7926 // case 47407: break;
7927 // // Mole Machine Port Schedule
7928 // case 47489: break;
7929 // case 47941: break; // Crystal Spike
7930 // case 48200: break; // Healer Aura
7931 case 48630: // Summon Gauntlet Mobs Periodic
7932 case 59275: // Below may need some adjustment, pattern for amount of summon and where is not verified 100% (except for odd/even tick)
7934 bool chance
= roll_chance_i(50);
7936 target
->CastSpell(target
, chance
? 48631 : 48632, true, NULL
, this);
7938 if (GetAuraTicks() % 2) // which doctor at odd tick
7939 target
->CastSpell(target
, chance
? 48636 : 48635, true, NULL
, this);
7940 else // or harponeer, at even tick
7941 target
->CastSpell(target
, chance
? 48634 : 48633, true, NULL
, this);
7945 // case 49313: break; // Proximity Mine Area Aura
7946 // // Mole Machine Portal Schedule
7947 // case 49466: break;
7948 // case 49555: break; // Corpse Explode
7949 // case 49592: break; // Temporal Rift
7950 // case 49957: break; // Cutting Laser
7951 // case 50085: break; // Slow Fall
7952 // // Listening to Music
7953 // case 50493: break;
7954 // // Love Rocket Barrage
7955 // case 50530: break;
7956 case 50789: // Summon iron dwarf (left or right)
7958 target
->CastSpell(target
, roll_chance_i(50) ? 50790 : 50791, true, NULL
, this);
7960 case 50792: // Summon iron trogg (left or right)
7962 target
->CastSpell(target
, roll_chance_i(50) ? 50793 : 50794, true, NULL
, this);
7964 case 50801: // Summon malformed ooze (left or right)
7966 target
->CastSpell(target
, roll_chance_i(50) ? 50802 : 50803, true, NULL
, this);
7968 case 50824: // Summon earthen dwarf
7969 target
->CastSpell(target
, roll_chance_i(50) ? 50825 : 50826, true, NULL
, this);
7971 case 52441: // Cool Down
7972 target
->CastSpell(target
, 52443, true);
7974 case 53520: // Carrion Beetles
7975 target
->CastSpell(target
, 53521, true, NULL
, this);
7976 target
->CastSpell(target
, 53521, true, NULL
, this);
7978 case 55592: // Clean
7981 case 0: target
->CastSpell(target
, 55731, true); break;
7982 case 1: target
->CastSpell(target
, 55738, true); break;
7983 case 2: target
->CastSpell(target
, 55739, true); break;
7986 // Exist more after, need add later
7991 if (spell
->SpellIconID
== 2983)
7993 Unit
*victim
= target
->getVictim();
7994 if (victim
&& (target
->GetHealth() * 100 / target
->GetMaxHealth() > victim
->GetHealth() * 100 / victim
->GetMaxHealth()))
7996 if(!target
->HasAura(58670))
7998 int32 basepoints
= GetBasePoints();
7999 target
->CastCustomSpell(target
, 58670, &basepoints
, 0, 0, true);
8003 target
->RemoveAurasDueToSpell(58670);
8006 case SPELLFAMILY_MAGE
:
8009 // if (spell->Id == 55342)
8013 case SPELLFAMILY_DRUID
:
8017 // Frenzied Regeneration
8020 // Converts up to 10 rage per second into health for $d. Each point of rage is converted into ${$m2/10}.1% of max health.
8021 // Should be manauser
8022 if (target
->getPowerType() != POWER_RAGE
)
8024 uint32 rage
= target
->GetPower(POWER_RAGE
);
8028 int32 mod
= (rage
< 100) ? rage
: 100;
8029 int32 points
= target
->CalculateSpellDamage(target
, spell
, EFFECT_INDEX_1
);
8030 int32 regen
= target
->GetMaxHealth() * (mod
* points
/ 10) / 1000;
8031 target
->CastCustomSpell(target
, 22845, ®en
, NULL
, NULL
, true, NULL
, this);
8032 target
->SetPower(POWER_RAGE
, rage
-mod
);
8043 case SPELLFAMILY_ROGUE
:
8050 if (target
->hasUnitState(UNIT_STAT_STUNNED
) || target
->isFeared())
8053 std::list
<Unit
*> targets
;
8056 float radius
= GetSpellMaxRange(sSpellRangeStore
.LookupEntry(spell
->rangeIndex
));
8058 MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck
u_check(target
, target
, radius
);
8059 MaNGOS::UnitListSearcher
<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck
> checker(target
, targets
, u_check
);
8060 Cell::VisitAllObjects(target
, checker
, radius
);
8066 std::list
<Unit
*>::const_iterator itr
= targets
.begin();
8067 std::advance(itr
, rand()%targets
.size());
8068 Unit
* victim
= *itr
;
8070 target
->CastSpell(victim
, 57840, true);
8071 target
->CastSpell(victim
, 57841, true);
8079 case SPELLFAMILY_HUNTER
:
8082 if (spell
->SpellFamilyFlags
& UI64LIT(0x8000000000000000))
8084 target
->CastCustomSpell(target
, 53352, &m_modifier
.m_amount
, 0, 0, true, 0, this, GetCasterGUID());
8092 // Feeding Frenzy Rank 1 & 2
8096 Unit
* victim
= target
->getVictim();
8097 if( victim
&& victim
->GetHealth() * 100 < victim
->GetMaxHealth() * 35 )
8098 target
->CastSpell(target
, spell
->Id
== 53511 ? 60096 : 60097, true, NULL
, this);
8106 case SPELLFAMILY_SHAMAN
:
8109 if (spell
->Id
== 52179)
8111 // Periodic need for remove visual on stun/fear/silence lost
8112 if (!(target
->GetUInt32Value(UNIT_FIELD_FLAGS
)&(UNIT_FLAG_STUNNED
|UNIT_FLAG_FLEEING
|UNIT_FLAG_SILENCED
)))
8113 target
->RemoveAurasDueToSpell(52179);
8118 case SPELLFAMILY_DEATHKNIGHT
:
8121 if (spell
->SpellFamilyFlags
& UI64LIT(0x0000000000000020))
8123 if (Unit
*caster
= GetCaster())
8124 caster
->CastCustomSpell(target
, 52212, &m_modifier
.m_amount
, NULL
, NULL
, true, NULL
, this);
8128 // if (spell->SpellFamilyFlags & UI64LIT(0x0000000000001000))
8131 if (spell
->SpellFamilyFlags
& UI64LIT(0x0000400000000000))
8133 // Get 0 effect aura
8134 Aura
*slow
= target
->GetAura(GetId(), EFFECT_INDEX_0
);
8137 slow
->ApplyModifier(false, true);
8138 Modifier
*mod
= slow
->GetModifier();
8139 mod
->m_amount
+= m_modifier
.m_amount
;
8140 if (mod
->m_amount
> 0) mod
->m_amount
= 0;
8141 slow
->ApplyModifier(true, true);
8146 // if (spell->SpellFamilyFlags & UI64LIT(0x0000008000000000))
8148 // Death Rune Mastery
8149 // if (spell->SpellFamilyFlags & UI64LIT(0x0000000000004000))
8152 if (spell
->SpellIconID
== 2653)
8154 // Increases your attack power by $s1 for every $s2 armor value you have.
8155 // Calculate AP bonus (from 1 efect of this spell)
8156 int32 apBonus
= m_modifier
.m_amount
* target
->GetArmor() / target
->CalculateSpellDamage(target
, spell
, EFFECT_INDEX_1
);
8157 target
->CastCustomSpell(target
, 61217, &apBonus
, &apBonus
, NULL
, true, NULL
, this);
8161 // if (spell->SpellIconID == 22)
8163 // Blood of the North
8164 // if (spell->SpellIconID == 30412)
8173 void Aura::HandlePreventFleeing(bool apply
, bool Real
)
8178 Unit::AuraList
const& fearAuras
= GetTarget()->GetAurasByType(SPELL_AURA_MOD_FEAR
);
8179 if( !fearAuras
.empty() )
8182 GetTarget()->SetFeared(false, fearAuras
.front()->GetCasterGUID());
8184 GetTarget()->SetFeared(true);
8188 void Aura::HandleManaShield(bool apply
, bool Real
)
8193 // prevent double apply bonuses
8194 if(apply
&& (GetTarget()->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)GetTarget())->GetSession()->PlayerLoading()))
8196 if(Unit
* caster
= GetCaster())
8198 float DoneActualBenefit
= 0.0f
;
8199 switch(GetSpellProto()->SpellFamilyName
)
8201 case SPELLFAMILY_MAGE
:
8202 if(GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000008000))
8205 // +50% from +spd bonus
8206 DoneActualBenefit
= caster
->SpellBaseDamageBonusDone(GetSpellSchoolMask(GetSpellProto())) * 0.5f
;
8214 DoneActualBenefit
*= caster
->CalculateLevelPenalty(GetSpellProto());
8216 m_modifier
.m_amount
+= (int32
)DoneActualBenefit
;
8221 void Aura::HandleArenaPreparation(bool apply
, bool Real
)
8227 GetTarget()->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PREPARATION
);
8229 GetTarget()->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PREPARATION
);
8233 * Such auras are applied from a caster(=player) to a vehicle.
8234 * This has been verified using spell #49256
8236 void Aura::HandleAuraControlVehicle(bool apply
, bool Real
)
8241 Unit
*player
= GetCaster();
8242 Vehicle
*vehicle
= dynamic_cast<Vehicle
*>(GetTarget());
8243 if(!player
|| player
->GetTypeId() != TYPEID_PLAYER
|| !vehicle
)
8248 if(Pet
*pet
= player
->GetPet())
8249 pet
->Remove(PET_SAVE_AS_CURRENT
);
8250 ((Player
*)player
)->EnterVehicle(vehicle
);
8254 SpellEntry
const *spell
= GetSpellProto();
8256 // some SPELL_AURA_CONTROL_VEHICLE auras have a dummy effect on the player - remove them
8257 player
->RemoveAurasDueToSpell(spell
->Id
);
8259 ((Player
*)player
)->ExitVehicle(vehicle
);
8263 void Aura::HandleAuraConvertRune(bool apply
, bool Real
)
8268 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
8271 Player
*plr
= (Player
*)GetTarget();
8273 if(plr
->getClass() != CLASS_DEATH_KNIGHT
)
8276 RuneType runeFrom
= RuneType(GetSpellProto()->EffectMiscValue
[m_effIndex
]);
8277 RuneType runeTo
= RuneType(GetSpellProto()->EffectMiscValueB
[m_effIndex
]);
8281 for(uint32 i
= 0; i
< MAX_RUNES
; ++i
)
8283 if (plr
->GetCurrentRune(i
) == runeFrom
&& !plr
->GetRuneCooldown(i
))
8285 plr
->ConvertRune(i
, runeTo
);
8292 for(uint32 i
= 0; i
< MAX_RUNES
; ++i
)
8294 if(plr
->GetCurrentRune(i
) == runeTo
&& plr
->GetBaseRune(i
) == runeFrom
)
8296 plr
->ConvertRune(i
, runeFrom
);
8303 void Aura::HandlePhase(bool apply
, bool Real
)
8308 Unit
*target
= GetTarget();
8310 // always non stackable
8313 Unit::AuraList
const& phases
= target
->GetAurasByType(SPELL_AURA_PHASE
);
8315 target
->RemoveAurasDueToSpell(phases
.front()->GetId(), this);
8318 // no-phase is also phase state so same code for apply and remove
8320 // phase auras normally not expected at BG but anyway better check
8321 if(target
->GetTypeId() == TYPEID_PLAYER
)
8323 // drop flag at invisible in bg
8324 if(((Player
*)target
)->InBattleGround())
8325 if(BattleGround
*bg
= ((Player
*)target
)->GetBattleGround())
8326 bg
->EventPlayerDroppedFlag((Player
*)target
);
8328 // GM-mode have mask 0xFFFFFFFF
8329 if(!((Player
*)target
)->isGameMaster())
8330 target
->SetPhaseMask(apply
? GetMiscValue() : PHASEMASK_NORMAL
, false);
8332 ((Player
*)target
)->GetSession()->SendSetPhaseShift(apply
? GetMiscValue() : PHASEMASK_NORMAL
);
8334 if (GetEffIndex() == EFFECT_INDEX_0
)
8336 SpellAreaForAreaMapBounds saBounds
= sSpellMgr
.GetSpellAreaForAuraMapBounds(GetId());
8337 if(saBounds
.first
!= saBounds
.second
)
8340 target
->GetZoneAndAreaId(zone
, area
);
8342 for(SpellAreaForAreaMap::const_iterator itr
= saBounds
.first
; itr
!= saBounds
.second
; ++itr
)
8344 // some auras remove at aura remove
8345 if(!itr
->second
->IsFitToRequirements((Player
*)target
, zone
, area
))
8346 target
->RemoveAurasDueToSpell(itr
->second
->spellId
);
8347 // some auras applied at aura apply
8348 else if(itr
->second
->autocast
)
8350 if (!target
->HasAura(itr
->second
->spellId
, EFFECT_INDEX_0
))
8351 target
->CastSpell(target
, itr
->second
->spellId
, true);
8358 target
->SetPhaseMask(apply
? GetMiscValue() : PHASEMASK_NORMAL
, false);
8360 // need triggering visibility update base at phase update of not GM invisible (other GMs anyway see in any phases)
8361 if(target
->GetVisibility() != VISIBILITY_OFF
)
8362 target
->SetVisibility(target
->GetVisibility());
8365 void Aura::UnregisterSingleCastAura()
8367 if (IsSingleTarget())
8369 if(Unit
* caster
= GetCaster())
8371 caster
->GetSingleCastAuras().remove(this);
8375 sLog
.outError("Couldn't find the caster of the single target aura (SpellId %u), may crash later!", GetId());
8378 m_isSingleTargetAura
= false;
8382 void Aura::HandleAuraSafeFall( bool Apply
, bool Real
)
8384 // implemented in WorldSession::HandleMovementOpcodes
8386 // only special case
8387 if(Apply
&& Real
&& GetId() == 32474 && GetTarget()->GetTypeId() == TYPEID_PLAYER
)
8388 ((Player
*)GetTarget())->ActivateTaxiPathTo(506, GetId());
8391 bool Aura::IsCritFromAbilityAura(Unit
* caster
, uint32
& damage
)
8393 Unit::AuraList
const& auras
= caster
->GetAurasByType(SPELL_AURA_ABILITY_PERIODIC_CRIT
);
8394 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
8396 if (!(*itr
)->isAffectedOnSpell(GetSpellProto()))
8398 if (!caster
->IsSpellCrit(GetTarget(), GetSpellProto(), GetSpellSchoolMask(GetSpellProto())))
8401 damage
= caster
->SpellCriticalDamageBonus(GetSpellProto(), damage
, GetTarget());
8407 void Aura::HandleModTargetArmorPct(bool /*apply*/, bool /*Real*/)
8409 if(GetTarget()->GetTypeId() != TYPEID_PLAYER
)
8412 ((Player
*)GetTarget())->UpdateArmorPenetration();
8415 void Aura::HandleAuraModAllCritChance(bool apply
, bool Real
)
8417 // spells required only Real aura add/remove
8421 Unit
*target
= GetTarget();
8423 if(target
->GetTypeId() != TYPEID_PLAYER
)
8426 ((Player
*)target
)->HandleBaseModValue(CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
8427 ((Player
*)target
)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
8428 ((Player
*)target
)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
8430 // included in Player::UpdateSpellCritChance calculation
8431 ((Player
*)target
)->UpdateAllSpellCritChances();
8434 void Aura::HandleAllowOnlyAbility(bool apply
, bool Real
)
8439 Unit
*target
= GetTarget();
8443 target
->setAttackTimer(BASE_ATTACK
,m_duration
);
8444 target
->setAttackTimer(RANGED_ATTACK
,m_duration
);
8445 target
->setAttackTimer(OFF_ATTACK
,m_duration
);
8449 target
->resetAttackTimer(BASE_ATTACK
);
8450 target
->resetAttackTimer(RANGED_ATTACK
);
8451 target
->resetAttackTimer(OFF_ATTACK
);
8454 target
->UpdateDamagePhysical(BASE_ATTACK
);
8455 target
->UpdateDamagePhysical(RANGED_ATTACK
);
8456 target
->UpdateDamagePhysical(OFF_ATTACK
);