2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "Database/DatabaseEnv.h"
21 #include "WorldPacket.h"
22 #include "WorldSession.h"
25 #include "UpdateMask.h"
27 #include "ObjectMgr.h"
32 #include "DynamicObject.h"
34 #include "UpdateData.h"
35 #include "ObjectAccessor.h"
36 #include "Policies/SingletonImp.h"
40 #include "BattleGround.h"
41 #include "CreatureAI.h"
42 #include "ScriptCalls.h"
44 #include "GridNotifiers.h"
45 #include "GridNotifiersImpl.h"
49 #define NULL_AURA_SLOT 0xFF
51 pAuraHandler AuraHandler
[TOTAL_AURAS
]=
53 &Aura::HandleNULL
, // 0 SPELL_AURA_NONE
54 &Aura::HandleBindSight
, // 1 SPELL_AURA_BIND_SIGHT
55 &Aura::HandleModPossess
, // 2 SPELL_AURA_MOD_POSSESS
56 &Aura::HandlePeriodicDamage
, // 3 SPELL_AURA_PERIODIC_DAMAGE
57 &Aura::HandleAuraDummy
, // 4 SPELL_AURA_DUMMY
58 &Aura::HandleModConfuse
, // 5 SPELL_AURA_MOD_CONFUSE
59 &Aura::HandleModCharm
, // 6 SPELL_AURA_MOD_CHARM
60 &Aura::HandleModFear
, // 7 SPELL_AURA_MOD_FEAR
61 &Aura::HandlePeriodicHeal
, // 8 SPELL_AURA_PERIODIC_HEAL
62 &Aura::HandleModAttackSpeed
, // 9 SPELL_AURA_MOD_ATTACKSPEED
63 &Aura::HandleModThreat
, // 10 SPELL_AURA_MOD_THREAT
64 &Aura::HandleModTaunt
, // 11 SPELL_AURA_MOD_TAUNT
65 &Aura::HandleAuraModStun
, // 12 SPELL_AURA_MOD_STUN
66 &Aura::HandleModDamageDone
, // 13 SPELL_AURA_MOD_DAMAGE_DONE
67 &Aura::HandleNoImmediateEffect
, // 14 SPELL_AURA_MOD_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus
68 &Aura::HandleNoImmediateEffect
, // 15 SPELL_AURA_DAMAGE_SHIELD implemented in Unit::DoAttackDamage
69 &Aura::HandleModStealth
, // 16 SPELL_AURA_MOD_STEALTH
70 &Aura::HandleNoImmediateEffect
, // 17 SPELL_AURA_MOD_STEALTH_DETECT
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)
100 &Aura::HandleAuraModParryPercent
, // 47 SPELL_AURA_MOD_PARRY_PERCENT
101 &Aura::HandleNULL
, // 48 SPELL_AURA_48 spell Napalm (area damage spell with additional delayed damage effect)
102 &Aura::HandleAuraModDodgePercent
, // 49 SPELL_AURA_MOD_DODGE_PERCENT
103 &Aura::HandleNoImmediateEffect
, // 50 SPELL_AURA_MOD_CRITICAL_HEALING_AMOUNT implemented in Unit::SpellCriticalHealingBonus
104 &Aura::HandleAuraModBlockPercent
, // 51 SPELL_AURA_MOD_BLOCK_PERCENT
105 &Aura::HandleAuraModCritPercent
, // 52 SPELL_AURA_MOD_CRIT_PERCENT
106 &Aura::HandlePeriodicLeech
, // 53 SPELL_AURA_PERIODIC_LEECH
107 &Aura::HandleModHitChance
, // 54 SPELL_AURA_MOD_HIT_CHANCE
108 &Aura::HandleModSpellHitChance
, // 55 SPELL_AURA_MOD_SPELL_HIT_CHANCE
109 &Aura::HandleAuraTransform
, // 56 SPELL_AURA_TRANSFORM
110 &Aura::HandleModSpellCritChance
, // 57 SPELL_AURA_MOD_SPELL_CRIT_CHANCE
111 &Aura::HandleAuraModIncreaseSwimSpeed
, // 58 SPELL_AURA_MOD_INCREASE_SWIM_SPEED
112 &Aura::HandleNoImmediateEffect
, // 59 SPELL_AURA_MOD_DAMAGE_DONE_CREATURE implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus
113 &Aura::HandleAuraModPacifyAndSilence
, // 60 SPELL_AURA_MOD_PACIFY_SILENCE
114 &Aura::HandleAuraModScale
, // 61 SPELL_AURA_MOD_SCALE
115 &Aura::HandlePeriodicHealthFunnel
, // 62 SPELL_AURA_PERIODIC_HEALTH_FUNNEL
116 &Aura::HandleUnused
, // 63 unused (3.0.8a) old SPELL_AURA_PERIODIC_MANA_FUNNEL
117 &Aura::HandlePeriodicManaLeech
, // 64 SPELL_AURA_PERIODIC_MANA_LEECH
118 &Aura::HandleModCastingSpeed
, // 65 SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK
119 &Aura::HandleFeignDeath
, // 66 SPELL_AURA_FEIGN_DEATH
120 &Aura::HandleAuraModDisarm
, // 67 SPELL_AURA_MOD_DISARM
121 &Aura::HandleAuraModStalked
, // 68 SPELL_AURA_MOD_STALKED
122 &Aura::HandleSchoolAbsorb
, // 69 SPELL_AURA_SCHOOL_ABSORB implemented in Unit::CalcAbsorbResist
123 &Aura::HandleUnused
, // 70 SPELL_AURA_EXTRA_ATTACKS Useless, used by only one spell that has only visual effect
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
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
135 &Aura::HandleWaterBreathing
, // 82 SPELL_AURA_WATER_BREATHING
136 &Aura::HandleModBaseResistance
, // 83 SPELL_AURA_MOD_BASE_RESISTANCE
137 &Aura::HandleModRegen
, // 84 SPELL_AURA_MOD_REGEN
138 &Aura::HandleModPowerRegen
, // 85 SPELL_AURA_MOD_POWER_REGEN
139 &Aura::HandleChannelDeathItem
, // 86 SPELL_AURA_CHANNEL_DEATH_ITEM
140 &Aura::HandleNoImmediateEffect
, // 87 SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus
141 &Aura::HandleNoImmediateEffect
, // 88 SPELL_AURA_MOD_HEALTH_REGEN_PERCENT
142 &Aura::HandlePeriodicDamagePCT
, // 89 SPELL_AURA_PERIODIC_DAMAGE_PERCENT
143 &Aura::HandleUnused
, // 90 unused (3.0.8a) old SPELL_AURA_MOD_RESIST_CHANCE
144 &Aura::HandleNoImmediateEffect
, // 91 SPELL_AURA_MOD_DETECT_RANGE implemented in Creature::GetAttackDistance
145 &Aura::HandlePreventFleeing
, // 92 SPELL_AURA_PREVENTS_FLEEING
146 &Aura::HandleModUnattackable
, // 93 SPELL_AURA_MOD_UNATTACKABLE
147 &Aura::HandleNoImmediateEffect
, // 94 SPELL_AURA_INTERRUPT_REGEN implemented in Player::RegenerateAll
148 &Aura::HandleAuraGhost
, // 95 SPELL_AURA_GHOST
149 &Aura::HandleNoImmediateEffect
, // 96 SPELL_AURA_SPELL_MAGNET implemented in Unit::SelectMagnetTarget
150 &Aura::HandleManaShield
, // 97 SPELL_AURA_MANA_SHIELD implemented in Unit::CalcAbsorbResist
151 &Aura::HandleAuraModSkill
, // 98 SPELL_AURA_MOD_SKILL_TALENT
152 &Aura::HandleAuraModAttackPower
, // 99 SPELL_AURA_MOD_ATTACK_POWER
153 &Aura::HandleUnused
, //100 SPELL_AURA_AURAS_VISIBLE obsolete? all player can see all auras now, but still have spells including GM-spell
154 &Aura::HandleModResistancePercent
, //101 SPELL_AURA_MOD_RESISTANCE_PCT
155 &Aura::HandleNoImmediateEffect
, //102 SPELL_AURA_MOD_MELEE_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonus
156 &Aura::HandleAuraModTotalThreat
, //103 SPELL_AURA_MOD_TOTAL_THREAT
157 &Aura::HandleAuraWaterWalk
, //104 SPELL_AURA_WATER_WALK
158 &Aura::HandleAuraFeatherFall
, //105 SPELL_AURA_FEATHER_FALL
159 &Aura::HandleAuraHover
, //106 SPELL_AURA_HOVER
160 &Aura::HandleAddModifier
, //107 SPELL_AURA_ADD_FLAT_MODIFIER
161 &Aura::HandleAddModifier
, //108 SPELL_AURA_ADD_PCT_MODIFIER
162 &Aura::HandleAddTargetTrigger
, //109 SPELL_AURA_ADD_TARGET_TRIGGER
163 &Aura::HandleModPowerRegenPCT
, //110 SPELL_AURA_MOD_POWER_REGEN_PERCENT
164 &Aura::HandleNoImmediateEffect
, //111 SPELL_AURA_ADD_CASTER_HIT_TRIGGER implemented in Unit::SelectMagnetTarget
165 &Aura::HandleNoImmediateEffect
, //112 SPELL_AURA_OVERRIDE_CLASS_SCRIPTS
166 &Aura::HandleNoImmediateEffect
, //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus
167 &Aura::HandleNoImmediateEffect
, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus
168 &Aura::HandleNoImmediateEffect
, //115 SPELL_AURA_MOD_HEALING implemented in Unit::SpellBaseHealingBonusForVictim
169 &Aura::HandleNoImmediateEffect
, //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT
170 &Aura::HandleNoImmediateEffect
, //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE implemented in Unit::MagicSpellHitResult
171 &Aura::HandleNoImmediateEffect
, //118 SPELL_AURA_MOD_HEALING_PCT implemented in Unit::SpellHealingBonus
172 &Aura::HandleUnused
, //119 unused (3.0.8a) old SPELL_AURA_SHARE_PET_TRACKING
173 &Aura::HandleAuraUntrackable
, //120 SPELL_AURA_UNTRACKABLE
174 &Aura::HandleAuraEmpathy
, //121 SPELL_AURA_EMPATHY
175 &Aura::HandleModOffhandDamagePercent
, //122 SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT
176 &Aura::HandleModTargetResistance
, //123 SPELL_AURA_MOD_TARGET_RESISTANCE
177 &Aura::HandleAuraModRangedAttackPower
, //124 SPELL_AURA_MOD_RANGED_ATTACK_POWER
178 &Aura::HandleNoImmediateEffect
, //125 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus
179 &Aura::HandleNoImmediateEffect
, //126 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus
180 &Aura::HandleNoImmediateEffect
, //127 SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus
181 &Aura::HandleModPossessPet
, //128 SPELL_AURA_MOD_POSSESS_PET
182 &Aura::HandleAuraModIncreaseSpeed
, //129 SPELL_AURA_MOD_SPEED_ALWAYS
183 &Aura::HandleAuraModIncreaseMountedSpeed
, //130 SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS
184 &Aura::HandleNoImmediateEffect
, //131 SPELL_AURA_MOD_RANGED_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonus
185 &Aura::HandleAuraModIncreaseEnergyPercent
, //132 SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT
186 &Aura::HandleAuraModIncreaseHealthPercent
, //133 SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT
187 &Aura::HandleAuraModRegenInterrupt
, //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT
188 &Aura::HandleModHealingDone
, //135 SPELL_AURA_MOD_HEALING_DONE
189 &Aura::HandleNoImmediateEffect
, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus
190 &Aura::HandleModTotalPercentStat
, //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
191 &Aura::HandleHaste
, //138 SPELL_AURA_MOD_HASTE
192 &Aura::HandleForceReaction
, //139 SPELL_AURA_FORCE_REACTION
193 &Aura::HandleAuraModRangedHaste
, //140 SPELL_AURA_MOD_RANGED_HASTE
194 &Aura::HandleRangedAmmoHaste
, //141 SPELL_AURA_MOD_RANGED_AMMO_HASTE
195 &Aura::HandleAuraModBaseResistancePCT
, //142 SPELL_AURA_MOD_BASE_RESISTANCE_PCT
196 &Aura::HandleAuraModResistanceExclusive
, //143 SPELL_AURA_MOD_RESISTANCE_EXCLUSIVE
197 &Aura::HandleAuraSafeFall
, //144 SPELL_AURA_SAFE_FALL implemented in WorldSession::HandleMovementOpcodes
198 &Aura::HandleAuraModPetTalentsPoints
, //145 SPELL_AURA_MOD_PET_TALENT_POINTS
199 &Aura::HandleNoImmediateEffect
, //146 SPELL_AURA_ALLOW_TAME_PET_TYPE
200 &Aura::HandleNULL
, //147 SPELL_AURA_ADD_CREATURE_IMMUNITY
201 &Aura::HandleAuraRetainComboPoints
, //148 SPELL_AURA_RETAIN_COMBO_POINTS
202 &Aura::HandleNoImmediateEffect
, //149 SPELL_AURA_REDUCE_PUSHBACK
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
207 &Aura::HandleNoImmediateEffect
, //154 SPELL_AURA_MOD_STEALTH_LEVEL
208 &Aura::HandleNoImmediateEffect
, //155 SPELL_AURA_MOD_WATER_BREATHING
209 &Aura::HandleNoImmediateEffect
, //156 SPELL_AURA_MOD_REPUTATION_GAIN
210 &Aura::HandleNULL
, //157 SPELL_AURA_PET_DAMAGE_MULTI
211 &Aura::HandleShieldBlockValue
, //158 SPELL_AURA_MOD_SHIELD_BLOCKVALUE
212 &Aura::HandleNoImmediateEffect
, //159 SPELL_AURA_NO_PVP_CREDIT only for Honorless Target spell
213 &Aura::HandleNoImmediateEffect
, //160 SPELL_AURA_MOD_AOE_AVOIDANCE implemented in Unit::MagicSpellHitResult
214 &Aura::HandleNoImmediateEffect
, //161 SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT
215 &Aura::HandleAuraPowerBurn
, //162 SPELL_AURA_POWER_BURN_MANA
216 &Aura::HandleNoImmediateEffect
, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE
217 &Aura::HandleUnused
, //164 unused (3.0.8a), only one test spell
218 &Aura::HandleNoImmediateEffect
, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus
219 &Aura::HandleAuraModAttackPowerPercent
, //166 SPELL_AURA_MOD_ATTACK_POWER_PCT
220 &Aura::HandleAuraModRangedAttackPowerPercent
, //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT
221 &Aura::HandleNoImmediateEffect
, //168 SPELL_AURA_MOD_DAMAGE_DONE_VERSUS implemented in Unit::SpellDamageBonus, Unit::MeleeDamageBonus
222 &Aura::HandleNoImmediateEffect
, //169 SPELL_AURA_MOD_CRIT_PERCENT_VERSUS implemented in Unit::DealDamageBySchool, Unit::DoAttackDamage, Unit::SpellCriticalBonus
223 &Aura::HandleNULL
, //170 SPELL_AURA_DETECT_AMORE different spells that ignore transformation effects
224 &Aura::HandleAuraModIncreaseSpeed
, //171 SPELL_AURA_MOD_SPEED_NOT_STACK
225 &Aura::HandleAuraModIncreaseMountedSpeed
, //172 SPELL_AURA_MOD_MOUNTED_SPEED_NOT_STACK
226 &Aura::HandleUnused
, //173 unused (3.0.8a) no spells, old SPELL_AURA_ALLOW_CHAMPION_SPELLS only for Proclaim Champion spell
227 &Aura::HandleModSpellDamagePercentFromStat
, //174 SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT implemented in Unit::SpellBaseDamageBonus
228 &Aura::HandleModSpellHealingPercentFromStat
, //175 SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT implemented in Unit::SpellBaseHealingBonus
229 &Aura::HandleSpiritOfRedemption
, //176 SPELL_AURA_SPIRIT_OF_REDEMPTION only for Spirit of Redemption spell, die at aura end
230 &Aura::HandleNULL
, //177 SPELL_AURA_AOE_CHARM
231 &Aura::HandleNoImmediateEffect
, //178 SPELL_AURA_MOD_DEBUFF_RESISTANCE implemented in Unit::MagicSpellHitResult
232 &Aura::HandleNoImmediateEffect
, //179 SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE implemented in Unit::SpellCriticalBonus
233 &Aura::HandleNoImmediateEffect
, //180 SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS implemented in Unit::SpellDamageBonus
234 &Aura::HandleUnused
, //181 unused (3.0.8a) old SPELL_AURA_MOD_FLAT_SPELL_CRIT_DAMAGE_VERSUS
235 &Aura::HandleAuraModResistenceOfStatPercent
, //182 SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT
236 &Aura::HandleNULL
, //183 SPELL_AURA_MOD_CRITICAL_THREAT only used in 28746
237 &Aura::HandleNoImmediateEffect
, //184 SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
238 &Aura::HandleNoImmediateEffect
, //185 SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
239 &Aura::HandleNoImmediateEffect
, //186 SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE implemented in Unit::MagicSpellHitResult
240 &Aura::HandleNoImmediateEffect
, //187 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance
241 &Aura::HandleNoImmediateEffect
, //188 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance
242 &Aura::HandleModRating
, //189 SPELL_AURA_MOD_RATING
243 &Aura::HandleNoImmediateEffect
, //190 SPELL_AURA_MOD_FACTION_REPUTATION_GAIN implemented in Player::CalculateReputationGain
244 &Aura::HandleAuraModUseNormalSpeed
, //191 SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED
245 &Aura::HandleModMeleeRangedSpeedPct
, //192 SPELL_AURA_HASTE_MELEE
246 &Aura::HandleModCombatSpeedPct
, //193 SPELL_AURA_MELEE_SLOW (in fact combat (any type attack) speed pct)
247 &Aura::HandleNULL
, //194 SPELL_AURA_MOD_IGNORE_ABSORB_SCHOOL
248 &Aura::HandleNoImmediateEffect
, //195 SPELL_AURA_MOD_IGNORE_ABSORB_FOR_SPELL implement in Unit::CalculateSpellDamage
249 &Aura::HandleNULL
, //196 SPELL_AURA_MOD_COOLDOWN
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) 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_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::CalculateSpellDamage
257 &Aura::HandleNoImmediateEffect
, //204 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE implemented in Unit::CalculateMeleeDamage and Unit::CalculateSpellDamage
258 &Aura::HandleNULL
, //205 vulnerable to school dmg?
259 &Aura::HandleNULL
, //206 SPELL_AURA_MOD_SPEED_MOUNTED
260 &Aura::HandleAuraModIncreaseFlightSpeed
, //207 SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
261 &Aura::HandleAuraModIncreaseFlightSpeed
, //208 SPELL_AURA_MOD_SPEED_FLIGHT, used only in spell: Flight Form (Passive)
262 &Aura::HandleAuraModIncreaseFlightSpeed
, //209 SPELL_AURA_MOD_FLIGHT_SPEED_ALWAYS
263 &Aura::HandleNULL
, //210 Commentator's Command
264 &Aura::HandleAuraModIncreaseFlightSpeed
, //211 SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK
265 &Aura::HandleAuraModRangedAttackPowerOfStatPercent
, //212 SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT
266 &Aura::HandleNoImmediateEffect
, //213 SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT implemented in Player::RewardRage
267 &Aura::HandleNULL
, //214 Tamed Pet Passive
268 &Aura::HandleArenaPreparation
, //215 SPELL_AURA_ARENA_PREPARATION
269 &Aura::HandleModCastingSpeed
, //216 SPELL_AURA_HASTE_SPELLS
270 &Aura::HandleUnused
, //217 unused (3.0.8a)
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) only for spell 44586 that not used in real spell cast
276 &Aura::HandleNULL
, //223 Cold Stare
277 &Aura::HandleUnused
, //224 unused (3.0.8a)
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 stealth detection
282 &Aura::HandleNULL
, //229 SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE
283 &Aura::HandleAuraModIncreaseMaxHealth
, //230 Commanding Shout
284 &Aura::HandleNoImmediateEffect
, //231 SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE
285 &Aura::HandleNoImmediateEffect
, //232 SPELL_AURA_MECHANIC_DURATION_MOD implement in Unit::CalculateSpellDuration
286 &Aura::HandleNULL
, //233 set model id to the one of the creature with id m_modifier.m_miscvalue
287 &Aura::HandleNoImmediateEffect
, //234 SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK implement in Unit::CalculateSpellDuration
288 &Aura::HandleAuraModDispelResist
, //235 SPELL_AURA_MOD_DISPEL_RESIST implement in Unit::MagicSpellHitResult
289 &Aura::HandleAuraControlVehicle
, //236 SPELL_AURA_CONTROL_VEHICLE
290 &Aura::HandleModSpellDamagePercentFromAttackPower
, //237 SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER implemented in Unit::SpellBaseDamageBonus
291 &Aura::HandleModSpellHealingPercentFromAttackPower
, //238 SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER implemented in Unit::SpellBaseHealingBonus
292 &Aura::HandleAuraModScale
, //239 SPELL_AURA_MOD_SCALE_2 only in Noggenfogger Elixir (16595) before 2.3.0 aura 61
293 &Aura::HandleAuraModExpertise
, //240 SPELL_AURA_MOD_EXPERTISE
294 &Aura::HandleForceMoveForward
, //241 Forces the player to move forward
295 &Aura::HandleUnused
, //242 SPELL_AURA_MOD_SPELL_DAMAGE_FROM_HEALING
296 &Aura::HandleNULL
, //243 faction reaction override spells
297 &Aura::HandleComprehendLanguage
, //244 Comprehend language
298 &Aura::HandleNULL
, //245 SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS
299 &Aura::HandleNoImmediateEffect
, //246 SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL
300 &Aura::HandleNULL
, //247 target to become a clone of the caster
301 &Aura::HandleNoImmediateEffect
, //248 SPELL_AURA_MOD_COMBAT_RESULT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
302 &Aura::HandleAuraConvertRune
, //249 SPELL_AURA_CONVERT_RUNE
303 &Aura::HandleAuraModIncreaseHealth
, //250 SPELL_AURA_MOD_INCREASE_HEALTH_2
304 &Aura::HandleNULL
, //251 SPELL_AURA_MOD_ENEMY_DODGE
305 &Aura::HandleNULL
, //252 haste all?
306 &Aura::HandleNULL
, //253 SPELL_AURA_MOD_BLOCK_CRIT_CHANCE
307 &Aura::HandleNULL
, //254 SPELL_AURA_MOD_DISARM_SHIELD disarm Shield
308 &Aura::HandleNoImmediateEffect
, //255 SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT implemented in Unit::SpellDamageBonus
309 &Aura::HandleNoReagentUseAura
, //256 SPELL_AURA_NO_REAGENT_USE Use SpellClassMask for spell select
310 &Aura::HandleNULL
, //257 SPELL_AURA_MOD_TARGET_RESIST_BY_SPELL_CLASS Use SpellClassMask for spell select
311 &Aura::HandleNULL
, //258 SPELL_AURA_MOD_SPELL_VISUAL
312 &Aura::HandleNULL
, //259 corrupt healing over time spell
313 &Aura::HandleNoImmediateEffect
, //260 SPELL_AURA_SCREEN_EFFECT (miscvalue = id in ScreenEffect.dbc) not required any code
314 &Aura::HandlePhase
, //261 SPELL_AURA_PHASE undetactable invisibility? implemented in Unit::isVisibleForOrDetect
315 &Aura::HandleNULL
, //262
316 &Aura::HandleNULL
, //263 SPELL_AURA_ALLOW_ONLY_ABILITY player can use only abilities set in SpellClassMask
317 &Aura::HandleUnused
, //264 unused (3.0.8a)
318 &Aura::HandleUnused
, //265 unused (3.0.8a)
319 &Aura::HandleUnused
, //266 unused (3.0.8a)
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::HandleNULL
, //269 ignore DR effects?
323 &Aura::HandleNULL
, //270 SPELL_AURA_MOD_IGNORE_TARGET_RESIST
324 &Aura::HandleNoImmediateEffect
, //271 SPELL_AURA_MOD_DAMAGE_FROM_CASTER implemented in Unit::SpellDamageBonus
325 &Aura::HandleNULL
, //272 reduce spell cast time?
326 &Aura::HandleNULL
, //273
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::HandleNULL
, //280 SPELL_AURA_MOD_TARGET_ARMOR_PCT
334 &Aura::HandleNULL
, //281 SPELL_AURA_MOD_HONOR_GAIN
335 &Aura::HandleAuraIncreaseBaseHealthPercent
, //282 SPELL_AURA_INCREASE_BASE_HEALTH_PERCENT
336 &Aura::HandleNoImmediateEffect
, //283 SPELL_AURA_MOD_HEALING_RECEIVED implemented in Unit::SpellHealingBonus
337 &Aura::HandleUnused
, //284 not used by any spells (3.08a)
338 &Aura::HandleUnused
, //285 not used by any spells (3.08a)
339 &Aura::HandleUnused
, //286 not used by any spells (3.08a)
340 &Aura::HandleNoImmediateEffect
, //287 SPELL_AURA_DEFLECT_SPELLS implemented in Unit::MagicSpellHitResult and Unit::MeleeSpellHitResult
341 &Aura::HandleUnused
, //288 not used by any spells (3.09) except 1 test spell.
342 &Aura::HandleUnused
, //289 unused
343 &Aura::HandleUnused
, //290 unused
344 &Aura::HandleUnused
, //291 unused
345 &Aura::HandleNULL
, //292 call stabled pet
346 &Aura::HandleNULL
, //293 2 test spells
347 &Aura::HandleNULL
//294 2 spells, possible prevent mana regen
350 static AuraType
const frozenAuraTypes
[] = { SPELL_AURA_MOD_ROOT
, SPELL_AURA_MOD_STUN
, SPELL_AURA_NONE
};
352 Aura::Aura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
, Unit
*caster
, Item
* castItem
) :
353 m_spellmod(NULL
), m_caster_guid(0), m_target(target
), m_castItemGuid(castItem
?castItem
->GetGUID():0),
354 m_timeCla(1000), m_periodicTimer(0), m_removeMode(AURA_REMOVE_BY_DEFAULT
), m_AuraDRGroup(DIMINISHING_NONE
),
355 m_effIndex(eff
), m_auraSlot(MAX_AURAS
), m_auraFlags(AFLAG_NONE
), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),
356 m_positive(false), m_permanent(false), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false),
357 m_isRemovedOnShapeLost(true), m_updated(false), m_in_use(false)
361 assert(spellproto
&& spellproto
== sSpellStore
.LookupEntry( spellproto
->Id
) && "`info` must be pointer to sSpellStore element");
363 m_spellProto
= spellproto
;
365 m_currentBasePoints
= currentBasePoints
? *currentBasePoints
: m_spellProto
->EffectBasePoints
[eff
];
367 m_isPassive
= IsPassiveSpell(GetId());
368 m_positive
= IsPositiveEffect(GetId(), m_effIndex
);
370 m_isSingleTargetAura
= IsSingleTargetSpell(m_spellProto
);
372 m_applyTime
= time(NULL
);
377 m_caster_guid
= target
->GetGUID();
378 damage
= m_currentBasePoints
+1; // stored value-1
379 m_maxduration
= target
->CalculateSpellDuration(m_spellProto
, m_effIndex
, target
);
383 m_caster_guid
= caster
->GetGUID();
385 damage
= caster
->CalculateSpellDamage(m_spellProto
,m_effIndex
,m_currentBasePoints
,target
);
386 m_maxduration
= caster
->CalculateSpellDuration(m_spellProto
, m_effIndex
, target
);
388 if (!damage
&& castItem
&& castItem
->GetItemSuffixFactor())
390 ItemRandomSuffixEntry
const *item_rand_suffix
= sItemRandomSuffixStore
.LookupEntry(abs(castItem
->GetItemRandomPropertyId()));
393 for (int k
= 0; k
< 3; ++k
)
395 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(item_rand_suffix
->enchant_id
[k
]);
398 for (int t
= 0; t
< 3; ++t
)
399 if(pEnchant
->spellid
[t
] == m_spellProto
->Id
)
401 damage
= uint32((item_rand_suffix
->prefix
[k
]*castItem
->GetItemSuffixFactor()) / 10000 );
413 if(m_maxduration
== -1 || m_isPassive
&& m_spellProto
->DurationIndex
== 0)
416 Player
* modOwner
= caster
? caster
->GetSpellModOwner() : NULL
;
418 if(!m_permanent
&& modOwner
)
420 modOwner
->ApplySpellMod(GetId(), SPELLMOD_DURATION
, m_maxduration
);
421 // Get zero duration aura after - need set m_maxduration > 0 for apply/remove aura work
422 if (m_maxduration
<=0)
426 m_duration
= m_maxduration
;
428 sLog
.outDebug("Aura: construct Spellid : %u, Aura : %u Duration : %d Target : %d Damage : %d", m_spellProto
->Id
, m_spellProto
->EffectApplyAuraName
[eff
], m_maxduration
, m_spellProto
->EffectImplicitTargetA
[eff
],damage
);
431 SetModifier(AuraType(m_spellProto
->EffectApplyAuraName
[eff
]), damage
, m_spellProto
->EffectAmplitude
[eff
], m_spellProto
->EffectMiscValue
[eff
]);
433 // Apply periodic time mod
434 if(modOwner
&& m_modifier
.periodictime
)
435 modOwner
->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME
, m_modifier
.periodictime
);
437 // Start periodic on next tick or at aura apply
438 if (!(m_spellProto
->AttributesEx5
& SPELL_ATTR_EX5_START_PERIODIC_AT_APPLY
))
439 m_periodicTimer
+= m_modifier
.periodictime
;
441 m_isDeathPersist
= IsDeathPersistentSpell(m_spellProto
);
443 m_procCharges
= m_spellProto
->procCharges
;
445 modOwner
->ApplySpellMod(GetId(), SPELLMOD_CHARGES
, m_procCharges
);
447 m_isRemovedOnShapeLost
= (m_caster_guid
==m_target
->GetGUID() &&
448 m_spellProto
->Stances
&&
449 !(m_spellProto
->AttributesEx2
& SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT
) &&
450 !(m_spellProto
->Attributes
& SPELL_ATTR_NOT_SHAPESHIFT
));
457 AreaAura::AreaAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
,
458 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
462 // caster==NULL in constructor args if target==caster in fact
463 Unit
* caster_ptr
= caster
? caster
: target
;
465 m_radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(GetSpellProto()->EffectRadiusIndex
[m_effIndex
]));
466 if(Player
* modOwner
= caster_ptr
->GetSpellModOwner())
467 modOwner
->ApplySpellMod(GetId(), SPELLMOD_RADIUS
, m_radius
);
469 switch(spellproto
->Effect
[eff
])
471 case SPELL_EFFECT_APPLY_AREA_AURA_PARTY
:
472 m_areaAuraType
= AREA_AURA_PARTY
;
473 if (target
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)target
)->isTotem())
474 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
476 case SPELL_EFFECT_APPLY_AREA_AURA_RAID
:
477 m_areaAuraType
= AREA_AURA_RAID
;
478 if (target
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)target
)->isTotem())
479 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
481 case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
:
482 m_areaAuraType
= AREA_AURA_FRIEND
;
484 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
:
485 m_areaAuraType
= AREA_AURA_ENEMY
;
486 if (target
== caster_ptr
)
487 m_modifier
.m_auraname
= SPELL_AURA_NONE
; // Do not do any effect on self
489 case SPELL_EFFECT_APPLY_AREA_AURA_PET
:
490 m_areaAuraType
= AREA_AURA_PET
;
492 case SPELL_EFFECT_APPLY_AREA_AURA_OWNER
:
493 m_areaAuraType
= AREA_AURA_OWNER
;
494 if (target
== caster_ptr
)
495 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
498 sLog
.outError("Wrong spell effect in AreaAura constructor");
504 AreaAura::~AreaAura()
508 PersistentAreaAura::PersistentAreaAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
,
509 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
511 m_isPersistent
= true;
514 PersistentAreaAura::~PersistentAreaAura()
518 SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
,
519 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
522 m_casters_target_guid
= caster
->GetTypeId()==TYPEID_PLAYER
? ((Player
*)caster
)->GetSelection() : caster
->GetUInt64Value(UNIT_FIELD_TARGET
);
524 m_casters_target_guid
= 0;
527 SingleEnemyTargetAura::~SingleEnemyTargetAura()
531 Unit
* SingleEnemyTargetAura::GetTriggerTarget() const
533 return ObjectAccessor::GetUnit(*m_target
, m_casters_target_guid
);
536 Aura
* CreateAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
, Unit
*caster
, Item
* castItem
)
538 if (IsAreaAuraEffect(spellproto
->Effect
[eff
]))
539 return new AreaAura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
541 uint32 triggeredSpellId
= spellproto
->EffectTriggerSpell
[eff
];
543 if(SpellEntry
const* triggeredSpellInfo
= sSpellStore
.LookupEntry(triggeredSpellId
))
544 for (int i
= 0; i
< 3; ++i
)
545 if (triggeredSpellInfo
->EffectImplicitTargetA
[i
] == TARGET_SINGLE_ENEMY
)
546 return new SingleEnemyTargetAura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
548 return new Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
551 Unit
* Aura::GetCaster() const
553 if(m_caster_guid
==m_target
->GetGUID())
556 //return ObjectAccessor::GetUnit(*m_target,m_caster_guid);
557 //must return caster even if it's in another grid/map
558 Unit
*unit
= ObjectAccessor::GetObjectInWorld(m_caster_guid
, (Unit
*)NULL
);
559 return unit
&& unit
->IsInWorld() ? unit
: NULL
;
562 void Aura::SetModifier(AuraType t
, int32 a
, uint32 pt
, int32 miscValue
)
564 m_modifier
.m_auraname
= t
;
565 m_modifier
.m_amount
= a
;
566 m_modifier
.m_miscvalue
= miscValue
;
567 m_modifier
.periodictime
= pt
;
570 void Aura::Update(uint32 diff
)
579 // GetEffIndex()==0 prevent double/triple apply manaPerSecond/manaPerSecondPerLevel to same spell with many auras
580 // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0
581 if(GetEffIndex()==0 && m_timeCla
<= 0)
583 if(Unit
* caster
= GetCaster())
585 Powers powertype
= Powers(m_spellProto
->powerType
);
586 int32 manaPerSecond
= m_spellProto
->manaPerSecond
+ m_spellProto
->manaPerSecondPerLevel
* caster
->getLevel();
587 m_timeCla
= 1*IN_MILISECONDS
;
590 if(powertype
==POWER_HEALTH
)
591 caster
->ModifyHealth(-manaPerSecond
);
593 caster
->ModifyPower(powertype
,-manaPerSecond
);
599 // Channeled aura required check distance from caster
600 if(IsChanneledSpell(m_spellProto
) && m_caster_guid
!= m_target
->GetGUID())
602 Unit
* caster
= GetCaster();
605 m_target
->RemoveAura(GetId(), GetEffIndex());
612 if (m_spellProto
->EffectRadiusIndex
[GetEffIndex()])
614 radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellProto
->EffectRadiusIndex
[GetEffIndex()]));
615 mod
= SPELLMOD_RADIUS
;
619 radius
= GetSpellMaxRange(sSpellRangeStore
.LookupEntry(m_spellProto
->rangeIndex
));
620 mod
= SPELLMOD_RANGE
;
623 if(Player
* modOwner
= caster
->GetSpellModOwner())
624 modOwner
->ApplySpellMod(GetId(), mod
, radius
, NULL
);
626 if(!caster
->IsWithinDistInMap(m_target
, radius
))
628 m_target
->RemoveAura(GetId(), GetEffIndex());
633 if(m_isPeriodic
&& (m_duration
>= 0 || m_isPassive
|| m_permanent
))
635 m_periodicTimer
-= diff
;
636 if(m_periodicTimer
<= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N
638 // update before applying (aura can be removed in TriggerSpell or PeriodicTick calls)
639 m_periodicTimer
+= m_modifier
.periodictime
;
645 void AreaAura::Update(uint32 diff
)
647 // update for the caster of the aura
648 if(m_caster_guid
== m_target
->GetGUID())
650 Unit
* caster
= m_target
;
652 if( !caster
->hasUnitState(UNIT_STAT_ISOLATED
) )
654 Unit
* owner
= caster
->GetCharmerOrOwner();
657 std::list
<Unit
*> targets
;
659 switch(m_areaAuraType
)
661 case AREA_AURA_PARTY
:
663 Group
*pGroup
= NULL
;
665 if (owner
->GetTypeId() == TYPEID_PLAYER
)
666 pGroup
= ((Player
*)owner
)->GetGroup();
670 uint8 subgroup
= ((Player
*)owner
)->GetSubGroup();
671 for(GroupReference
*itr
= pGroup
->GetFirstMember(); itr
!= NULL
; itr
= itr
->next())
673 Player
* Target
= itr
->getSource();
674 if(Target
&& Target
->isAlive() && Target
->GetSubGroup()==subgroup
&& caster
->IsFriendlyTo(Target
))
676 if(caster
->IsWithinDistInMap(Target
, m_radius
))
677 targets
.push_back(Target
);
678 Pet
*pet
= Target
->GetPet();
679 if(pet
&& pet
->isAlive() && caster
->IsWithinDistInMap(pet
, m_radius
))
680 targets
.push_back(pet
);
687 if( owner
!= caster
&& caster
->IsWithinDistInMap(owner
, m_radius
) )
688 targets
.push_back(owner
);
690 Unit
* pet
= caster
->GetPet();
691 if( pet
&& caster
->IsWithinDistInMap(pet
, m_radius
))
692 targets
.push_back(pet
);
698 Group
*pGroup
= NULL
;
700 if (owner
->GetTypeId() == TYPEID_PLAYER
)
701 pGroup
= ((Player
*)owner
)->GetGroup();
705 for(GroupReference
*itr
= pGroup
->GetFirstMember(); itr
!= NULL
; itr
= itr
->next())
707 Player
* Target
= itr
->getSource();
708 if(Target
&& Target
->isAlive() && caster
->IsFriendlyTo(Target
))
710 if(caster
->IsWithinDistInMap(Target
, m_radius
))
711 targets
.push_back(Target
);
712 Pet
*pet
= Target
->GetPet();
713 if(pet
&& pet
->isAlive() && caster
->IsWithinDistInMap(pet
, m_radius
))
714 targets
.push_back(pet
);
721 if( owner
!= caster
&& caster
->IsWithinDistInMap(owner
, m_radius
) )
722 targets
.push_back(owner
);
724 Unit
* pet
= caster
->GetPet();
725 if( pet
&& caster
->IsWithinDistInMap(pet
, m_radius
))
726 targets
.push_back(pet
);
730 case AREA_AURA_FRIEND
:
732 CellPair
p(MaNGOS::ComputeCellPair(caster
->GetPositionX(), caster
->GetPositionY()));
734 cell
.data
.Part
.reserved
= ALL_DISTRICT
;
737 MaNGOS::AnyFriendlyUnitInObjectRangeCheck
u_check(caster
, owner
, m_radius
);
738 MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
> searcher(caster
,targets
, u_check
);
739 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
>, WorldTypeMapContainer
> world_unit_searcher(searcher
);
740 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
>, GridTypeMapContainer
> grid_unit_searcher(searcher
);
741 CellLock
<GridReadGuard
> cell_lock(cell
, p
);
742 cell_lock
->Visit(cell_lock
, world_unit_searcher
, *caster
->GetMap());
743 cell_lock
->Visit(cell_lock
, grid_unit_searcher
, *caster
->GetMap());
746 case AREA_AURA_ENEMY
:
748 CellPair
p(MaNGOS::ComputeCellPair(caster
->GetPositionX(), caster
->GetPositionY()));
750 cell
.data
.Part
.reserved
= ALL_DISTRICT
;
753 MaNGOS::AnyAoETargetUnitInObjectRangeCheck
u_check(caster
, owner
, m_radius
); // No GetCharmer in searcher
754 MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
> searcher(caster
, targets
, u_check
);
755 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
>, WorldTypeMapContainer
> world_unit_searcher(searcher
);
756 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
>, GridTypeMapContainer
> grid_unit_searcher(searcher
);
757 CellLock
<GridReadGuard
> cell_lock(cell
, p
);
758 cell_lock
->Visit(cell_lock
, world_unit_searcher
, *caster
->GetMap());
759 cell_lock
->Visit(cell_lock
, grid_unit_searcher
, *caster
->GetMap());
762 case AREA_AURA_OWNER
:
766 targets
.push_back(owner
);
771 for(std::list
<Unit
*>::iterator tIter
= targets
.begin(); tIter
!= targets
.end(); tIter
++)
773 if((*tIter
)->HasAura(GetId(), m_effIndex
))
776 if(SpellEntry
const *actualSpellInfo
= spellmgr
.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter
)->getLevel()))
778 int32 actualBasePoints
= m_currentBasePoints
;
779 // recalculate basepoints for lower rank (all AreaAura spell not use custom basepoints?)
780 if(actualSpellInfo
!= GetSpellProto())
781 actualBasePoints
= actualSpellInfo
->EffectBasePoints
[m_effIndex
];
782 AreaAura
*aur
= new AreaAura(actualSpellInfo
, m_effIndex
, &actualBasePoints
, (*tIter
), caster
, NULL
);
783 aur
->SetAuraDuration(GetAuraDuration());
784 (*tIter
)->AddAura(aur
);
790 else // aura at non-caster
792 Unit
* tmp_target
= m_target
;
793 Unit
* caster
= GetCaster();
794 uint32 tmp_spellId
= GetId(), tmp_effIndex
= m_effIndex
;
796 // WARNING: the aura may get deleted during the update
797 // DO NOT access its members after update!
800 // remove aura if out-of-range from caster (after teleport for example)
801 // or caster is isolated or caster no longer has the aura
802 // or caster is (no longer) friendly
803 bool needFriendly
= (m_areaAuraType
== AREA_AURA_ENEMY
? false : true);
804 if( !caster
|| caster
->hasUnitState(UNIT_STAT_ISOLATED
) ||
805 !caster
->IsWithinDistInMap(tmp_target
, m_radius
) ||
806 !caster
->HasAura(tmp_spellId
, tmp_effIndex
) ||
807 caster
->IsFriendlyTo(tmp_target
) != needFriendly
810 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
812 else if( m_areaAuraType
== AREA_AURA_PARTY
) // check if in same sub group
814 // not check group if target == owner or target == pet
815 if (caster
->GetCharmerOrOwnerGUID() != tmp_target
->GetGUID() && caster
->GetGUID() != tmp_target
->GetCharmerOrOwnerGUID())
817 Player
* check
= caster
->GetCharmerOrOwnerPlayerOrPlayerItself();
819 Group
*pGroup
= check
? check
->GetGroup() : NULL
;
822 Player
* checkTarget
= tmp_target
->GetCharmerOrOwnerPlayerOrPlayerItself();
823 if(!checkTarget
|| !pGroup
->SameSubGroup(check
, checkTarget
))
824 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
827 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
830 else if( m_areaAuraType
== AREA_AURA_RAID
) // TODO: fix me!
832 // not check group if target == owner or target == pet
833 if (caster
->GetCharmerOrOwnerGUID() != tmp_target
->GetGUID() && caster
->GetGUID() != tmp_target
->GetCharmerOrOwnerGUID())
835 Player
* check
= caster
->GetCharmerOrOwnerPlayerOrPlayerItself();
837 Group
*pGroup
= check
? check
->GetGroup() : NULL
;
840 Player
* checkTarget
= tmp_target
->GetCharmerOrOwnerPlayerOrPlayerItself();
842 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
845 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
848 else if( m_areaAuraType
== AREA_AURA_PET
|| m_areaAuraType
== AREA_AURA_OWNER
)
850 if( tmp_target
->GetGUID() != caster
->GetCharmerOrOwnerGUID() )
851 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
856 void PersistentAreaAura::Update(uint32 diff
)
860 // remove the aura if its caster or the dynamic object causing it was removed
861 // or if the target moves too far from the dynamic object
862 Unit
*caster
= GetCaster();
865 DynamicObject
*dynObj
= caster
->GetDynObject(GetId(), GetEffIndex());
868 if (!m_target
->IsWithinDistInMap(dynObj
, dynObj
->GetRadius()))
877 Unit
*tmp_target
= m_target
;
878 uint32 tmp_id
= GetId(), tmp_index
= GetEffIndex();
880 // WARNING: the aura may get deleted during the update
881 // DO NOT access its members after update!
885 tmp_target
->RemoveAura(tmp_id
, tmp_index
);
888 void Aura::ApplyModifier(bool apply
, bool Real
)
890 AuraType aura
= m_modifier
.m_auraname
;
893 if(aura
< TOTAL_AURAS
)
894 (*this.*AuraHandler
[aura
])(apply
, Real
);
898 void Aura::_AddAura()
905 // Second aura if some spell
906 bool secondaura
= false;
907 // Try find slot for aura
908 uint8 slot
= NULL_AURA_SLOT
;
909 // Lookup for some spell auras (and get slot from it)
910 for(uint8 i
= 0; i
< m_effIndex
; ++i
)
912 Unit::spellEffectPair spair
= Unit::spellEffectPair(GetId(), i
);
913 for(Unit::AuraMap::const_iterator itr
= m_target
->GetAuras().lower_bound(spair
); itr
!= m_target
->GetAuras().upper_bound(spair
); ++itr
)
915 // allow use single slot only by auras from same caster
916 if(itr
->second
->GetCasterGUID()==GetCasterGUID())
918 slot
= itr
->second
->GetAuraSlot();
927 if (!secondaura
&& m_target
->GetVisibleAurasCount() < MAX_AURAS
)
929 Unit::VisibleAuraMap
const *visibleAuras
= m_target
->GetVisibleAuras();
930 for(uint8 i
= 0; i
< MAX_AURAS
; ++i
)
932 Unit::VisibleAuraMap::const_iterator itr
= visibleAuras
->find(i
);
933 if(itr
== visibleAuras
->end())
936 // update for out of range group members (on 1 slot use)
937 m_target
->UpdateAuraForGroup(slot
);
943 Unit
* caster
= GetCaster();
945 // set infinity cooldown state for spells
946 if(caster
&& caster
->GetTypeId() == TYPEID_PLAYER
)
948 if (m_spellProto
->Attributes
& SPELL_ATTR_DISABLED_WHILE_ACTIVE
)
950 Item
* castItem
= m_castItemGuid
? ((Player
*)caster
)->GetItemByGuid(m_castItemGuid
) : NULL
;
951 ((Player
*)caster
)->AddSpellAndCategoryCooldowns(m_spellProto
,castItem
? castItem
->GetEntry() : 0, NULL
,true);
955 // passive auras (except totem auras) do not get placed in the slots
956 // area auras with SPELL_AURA_NONE are not shown on target
957 if((!m_isPassive
|| (caster
&& caster
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)caster
)->isTotem())) &&
958 (m_spellProto
->Effect
[GetEffIndex()] != SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
|| m_target
!= caster
))
961 if(slot
< MAX_AURAS
) // slot found send data to client
964 SetAuraFlags((1 << GetEffIndex()) | AFLAG_NOT_CASTER
| ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION
: AFLAG_NONE
) | (IsPositive() ? AFLAG_POSITIVE
: AFLAG_NEGATIVE
));
965 SetAuraLevel(caster
? caster
->getLevel() : sWorld
.getConfig(CONFIG_MAX_PLAYER_LEVEL
));
966 SendAuraUpdate(false);
969 //*****************************************************
970 // Update target aura state flag (at 1 aura apply)
971 // TODO: Make it easer
972 //*****************************************************
975 // Sitdown on apply aura req seated
976 if (m_spellProto
->AuraInterruptFlags
& AURA_INTERRUPT_FLAG_NOT_SEATED
&& !m_target
->IsSitState())
977 m_target
->SetStandState(UNIT_STAND_STATE_SIT
);
979 // register aura diminishing on apply
980 if (getDiminishGroup() != DIMINISHING_NONE
)
981 m_target
->ApplyDiminishingAura(getDiminishGroup(), true);
983 // Update Seals information
984 if (IsSealSpell(m_spellProto
))
985 m_target
->ModifyAuraState(AURA_STATE_JUDGEMENT
, true);
987 // Conflagrate aura state on Immolate
988 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARLOCK
&& m_spellProto
->SpellFamilyFlags
& 4)
989 m_target
->ModifyAuraState(AURA_STATE_IMMOLATE
, true);
991 // Faerie Fire (druid versions)
992 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_DRUID
&& (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000400)))
993 m_target
->ModifyAuraState(AURA_STATE_FAERIE_FIRE
, true);
996 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0004000000000000)))
997 m_target
->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH
, true);
999 // Swiftmend state on Regrowth & Rejuvenation
1000 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_DRUID
&& (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x50)))
1001 m_target
->ModifyAuraState(AURA_STATE_SWIFTMEND
, true);
1003 // Deadly poison aura state
1004 if(m_spellProto
->SpellFamilyName
== SPELLFAMILY_ROGUE
&& (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x10000)))
1005 m_target
->ModifyAuraState(AURA_STATE_DEADLY_POISON
, true);
1007 // Enrage aura state
1008 if(m_spellProto
->Dispel
== DISPEL_ENRAGE
)
1009 m_target
->ModifyAuraState(AURA_STATE_ENRAGE
, true);
1014 void Aura::_RemoveAura()
1016 // Remove all triggered by aura spells vs unlimited duration
1017 // except same aura replace case
1018 if(m_removeMode
!=AURA_REMOVE_BY_STACK
)
1019 CleanupTriggeredSpells();
1021 Unit
* caster
= GetCaster();
1023 if(caster
&& IsPersistent())
1025 DynamicObject
*dynObj
= caster
->GetDynObject(GetId(), GetEffIndex());
1027 dynObj
->RemoveAffected(m_target
);
1030 //passive auras do not get put in slots
1031 // Note: but totem can be not accessible for aura target in time remove (to far for find in grid)
1032 //if(m_isPassive && !(caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem()))
1035 uint8 slot
= GetAuraSlot();
1037 if(slot
>= MAX_AURAS
) // slot not set
1040 if(m_target
->GetVisibleAura(slot
) == 0)
1043 bool lastaura
= true;
1045 // find other aura in same slot (current already removed from list)
1046 for(uint8 i
= 0; i
< 3; ++i
)
1048 Unit::spellEffectPair spair
= Unit::spellEffectPair(GetId(), i
);
1049 for(Unit::AuraMap::const_iterator itr
= m_target
->GetAuras().lower_bound(spair
); itr
!= m_target
->GetAuras().upper_bound(spair
); ++itr
)
1051 if(itr
->second
->GetAuraSlot() == slot
)
1061 // only remove icon when the last aura of the spell is removed (current aura already removed from list)
1064 // unregister aura diminishing (and store last time)
1065 if (getDiminishGroup() != DIMINISHING_NONE
)
1066 m_target
->ApplyDiminishingAura(getDiminishGroup(), false);
1069 SetAuraFlags(AFLAG_NONE
);
1071 SendAuraUpdate(true);
1073 // update for out of range group members
1074 m_target
->UpdateAuraForGroup(slot
);
1076 //*****************************************************
1077 // Update target aura state flag (at last aura remove)
1078 //*****************************************************
1079 // Enrage aura state
1080 if(m_spellProto
->Dispel
== DISPEL_ENRAGE
)
1081 m_target
->ModifyAuraState(AURA_STATE_ENRAGE
, false);
1083 uint32 removeState
= 0;
1084 uint64 removeFamilyFlag
= m_spellProto
->SpellFamilyFlags
;
1085 switch(m_spellProto
->SpellFamilyName
)
1087 case SPELLFAMILY_PALADIN
:
1088 if (IsSealSpell(m_spellProto
))
1089 removeState
= AURA_STATE_JUDGEMENT
; // Update Seals information
1091 case SPELLFAMILY_WARLOCK
:
1092 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x4))
1093 removeState
= AURA_STATE_IMMOLATE
; // Conflagrate aura state
1095 case SPELLFAMILY_DRUID
:
1096 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000400))
1097 removeState
= AURA_STATE_FAERIE_FIRE
; // Faerie Fire (druid versions)
1098 else if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x50))
1100 removeFamilyFlag
= 0x50;
1101 removeState
= AURA_STATE_SWIFTMEND
; // Swiftmend aura state
1104 case SPELLFAMILY_WARRIOR
:
1105 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0004000000000000))
1106 removeState
= AURA_STATE_WARRIOR_VICTORY_RUSH
; // Victorious
1108 case SPELLFAMILY_ROGUE
:
1109 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x10000))
1110 removeState
= AURA_STATE_DEADLY_POISON
; // Deadly poison aura state
1112 case SPELLFAMILY_HUNTER
:
1113 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x1000000000000000))
1114 removeState
= AURA_STATE_FAERIE_FIRE
; // Sting (hunter versions)
1117 // Remove state (but need check other auras for it)
1121 Unit::AuraMap
& Auras
= m_target
->GetAuras();
1122 for(Unit::AuraMap::iterator i
= Auras
.begin(); i
!= Auras
.end(); ++i
)
1124 SpellEntry
const *auraSpellInfo
= (*i
).second
->GetSpellProto();
1125 if(auraSpellInfo
->SpellFamilyName
== m_spellProto
->SpellFamilyName
&&
1126 auraSpellInfo
->SpellFamilyFlags
& removeFamilyFlag
)
1132 // this has been last aura
1134 m_target
->ModifyAuraState(AuraState(removeState
), false);
1137 // reset cooldown state for spells
1138 if(caster
&& caster
->GetTypeId() == TYPEID_PLAYER
)
1140 if ( GetSpellProto()->Attributes
& SPELL_ATTR_DISABLED_WHILE_ACTIVE
)
1141 // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
1142 ((Player
*)caster
)->SendCooldownEvent(GetSpellProto());
1147 void Aura::SendAuraUpdate(bool remove
)
1149 WorldPacket
data(SMSG_AURA_UPDATE
);
1150 data
.append(m_target
->GetPackGUID());
1151 data
<< uint8(GetAuraSlot());
1152 data
<< uint32(remove
? 0 : GetId());
1156 m_target
->SendMessageToSet(&data
, true);
1160 uint8 auraFlags
= GetAuraFlags();
1161 data
<< uint8(auraFlags
);
1162 data
<< uint8(GetAuraLevel());
1163 data
<< uint8(m_procCharges
? m_procCharges
: m_stackAmount
);
1165 if(!(auraFlags
& AFLAG_NOT_CASTER
))
1167 data
<< uint8(0); // pguid
1170 if(auraFlags
& AFLAG_DURATION
)
1172 data
<< uint32(GetAuraMaxDuration());
1173 data
<< uint32(GetAuraDuration());
1176 m_target
->SendMessageToSet(&data
, true);
1179 void Aura::SetStackAmount(uint8 stackAmount
)
1181 if (stackAmount
!= m_stackAmount
)
1183 Unit
*target
= GetTarget();
1184 Unit
*caster
= GetCaster();
1185 if (!target
|| !caster
)
1187 m_stackAmount
= stackAmount
;
1188 int32 amount
= m_stackAmount
* caster
->CalculateSpellDamage(m_spellProto
, m_effIndex
, m_currentBasePoints
, target
);
1189 // Reapply if amount change
1190 if (amount
!=m_modifier
.m_amount
)
1192 ApplyModifier(false, true);
1193 m_modifier
.m_amount
= amount
;
1194 ApplyModifier(true, true);
1200 bool Aura::modStackAmount(int32 num
)
1203 if (!m_spellProto
->StackAmount
)
1206 // Modify stack but limit it
1207 int32 stackAmount
= m_stackAmount
+ num
;
1208 if (stackAmount
> m_spellProto
->StackAmount
)
1209 stackAmount
= m_spellProto
->StackAmount
;
1210 else if (stackAmount
<=0) // Last aura from stack removed
1213 return true; // need remove aura
1216 // Update stack amount
1217 SetStackAmount(stackAmount
);
1221 void Aura::RefreshAura()
1223 m_duration
= m_maxduration
;
1224 SendAuraUpdate(false);
1227 bool Aura::isAffectedOnSpell(SpellEntry
const *spell
) const
1229 // Check family name
1230 if (spell
->SpellFamilyName
!= m_spellProto
->SpellFamilyName
)
1232 // Check EffectClassMask
1233 uint32
const *ptr
= getAuraSpellClassMask();
1234 if (((uint64
*)ptr
)[0] & spell
->SpellFamilyFlags
)
1236 if (ptr
[2] & spell
->SpellFamilyFlags2
)
1241 /*********************************************************/
1242 /*** BASIC AURA FUNCTION ***/
1243 /*********************************************************/
1244 void Aura::HandleAddModifier(bool apply
, bool Real
)
1246 if(m_target
->GetTypeId() != TYPEID_PLAYER
|| !Real
)
1249 if(m_modifier
.m_miscvalue
>= MAX_SPELLMOD
)
1254 // Add custom charges for some mod aura
1255 switch (m_spellProto
->Id
)
1257 case 17941: // Shadow Trance
1258 case 22008: // Netherwind Focus
1259 case 31834: // Light's Grace
1260 case 34754: // Clearcasting
1261 case 34936: // Backlash
1262 case 48108: // Hot Streak
1263 case 51124: // Killing Machine
1264 case 54741: // Firestarter
1265 case 57761: // Fireball!
1270 SpellModifier
*mod
= new SpellModifier
;
1271 mod
->op
= SpellModOp(m_modifier
.m_miscvalue
);
1272 mod
->value
= m_modifier
.m_amount
;
1273 mod
->type
= SpellModType(m_modifier
.m_auraname
); // SpellModType value == spell aura types
1274 mod
->spellId
= GetId();
1277 SpellAffectEntry
const *spellAffect
= spellmgr
.GetSpellAffect(GetId(), m_effIndex
);
1279 ptr
= &spellAffect
->SpellClassMask
[0];
1284 case 0: ptr
= &m_spellProto
->EffectSpellClassMaskA
[0]; break;
1285 case 1: ptr
= &m_spellProto
->EffectSpellClassMaskB
[0]; break;
1286 case 2: ptr
= &m_spellProto
->EffectSpellClassMaskC
[0]; break;
1292 mod
->mask
= (uint64
)ptr
[0] | (uint64
)ptr
[1]<<32;
1293 mod
->mask2
= (uint64
)ptr
[2];
1294 mod
->charges
= m_procCharges
;
1299 uint64 spellFamilyMask
= m_spellmod
->mask
;
1301 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
1303 // reapply some passive spells after add/remove related spellmods
1304 if(m_spellProto
->SpellFamilyName
==SPELLFAMILY_WARRIOR
&& (spellFamilyMask
& UI64LIT(0x0000100000000000)))
1306 m_target
->RemoveAurasDueToSpell(45471);
1309 m_target
->CastSpell(m_target
, 45471, true);
1312 void Aura::HandleAddTargetTrigger(bool apply
, bool /*Real*/)
1314 // Use SpellModifier structure for check
1315 // used only fields:
1316 // spellId, mask, mask2
1319 SpellModifier
*mod
= new SpellModifier
;
1320 mod
->spellId
= GetId();
1323 SpellAffectEntry
const *spellAffect
= spellmgr
.GetSpellAffect(GetId(), m_effIndex
);
1325 ptr
= &spellAffect
->SpellClassMask
[0];
1330 case 0: ptr
= &m_spellProto
->EffectSpellClassMaskA
[0]; break;
1331 case 1: ptr
= &m_spellProto
->EffectSpellClassMaskB
[0]; break;
1332 case 2: ptr
= &m_spellProto
->EffectSpellClassMaskC
[0]; break;
1338 mod
->mask
= (uint64
)ptr
[0] | (uint64
)ptr
[1]<<32;
1339 mod
->mask2
= (uint64
)ptr
[2];
1349 void Aura::TriggerSpell()
1351 Unit
* caster
= GetCaster();
1352 Unit
* target
= GetTriggerTarget();
1354 if(!caster
|| !target
)
1357 // generic casting code with custom spells and target/caster customs
1358 uint32 trigger_spell_id
= GetSpellProto()->EffectTriggerSpell
[m_effIndex
];
1360 SpellEntry
const *triggeredSpellInfo
= sSpellStore
.LookupEntry(trigger_spell_id
);
1361 SpellEntry
const *auraSpellInfo
= GetSpellProto();
1362 uint32 auraId
= auraSpellInfo
->Id
;
1364 // specific code for cases with no trigger spell provided in field
1365 if (triggeredSpellInfo
== NULL
)
1367 switch(auraSpellInfo
->SpellFamilyName
)
1369 case SPELLFAMILY_GENERIC
:
1373 // Firestone Passive (1-5 ranks)
1380 if (caster
->GetTypeId()!=TYPEID_PLAYER
)
1382 Item
* item
= ((Player
*)caster
)->GetWeaponForAttack(BASE_ATTACK
);
1385 uint32 enchant_id
= 0;
1388 case 758: enchant_id
= 1803; break; // Rank 1
1389 case 17945: enchant_id
= 1823; break; // Rank 2
1390 case 17947: enchant_id
= 1824; break; // Rank 3
1391 case 17949: enchant_id
= 1825; break; // Rank 4
1392 case 27252: enchant_id
= 2645; break; // Rank 5
1396 // remove old enchanting before applying new
1397 ((Player
*)caster
)->ApplyEnchantment(item
,TEMP_ENCHANTMENT_SLOT
,false);
1398 item
->SetEnchantment(TEMP_ENCHANTMENT_SLOT
, enchant_id
, m_modifier
.periodictime
+1000, 0);
1399 // add new enchanting
1400 ((Player
*)caster
)->ApplyEnchantment(item
,TEMP_ENCHANTMENT_SLOT
,true);
1403 // // Periodic Mana Burn
1405 // // Polymorphic Ray
1406 // case 6965: break;
1407 // // Fire Nova (1-7 ranks)
1416 // Thaumaturgy Channel
1417 case 9712: trigger_spell_id
= 21029; break;
1418 // // Egan's Blaster
1419 // case 17368: break;
1421 // case 18347: break;
1422 // // Ranshalla Waiting
1423 // case 18953: break;
1425 // case 19695: break;
1426 // // Frostwolf Muzzle DND
1427 // case 21794: break;
1428 // // Alterac Ram Collar DND
1429 // case 21866: break;
1430 // // Celebras Waiting
1431 // case 21916: break;
1432 // Brood Affliction: Bronze
1435 m_target
->CastSpell(m_target
, 23171, true, 0, this);
1439 // case 23184: break;
1443 int32 heal
= caster
->GetMaxHealth() / 10;
1444 caster
->DealHeal(caster
, heal
, auraSpellInfo
);
1446 int32 mana
= caster
->GetMaxPower(POWER_MANA
);
1450 caster
->EnergizeBySpell(caster
, 23493, mana
, POWER_MANA
);
1454 // // Stoneclaw Totem Passive TEST
1455 // case 23792: break;
1457 // case 24018: break;
1458 // // Mark of Arlokk
1459 // case 24210: break;
1461 // case 24379: break;
1463 // case 24716: break;
1465 // case 24780: break;
1467 // case 24832: break;
1468 // // Shadow Bolt Whirl
1469 // case 24834: break;
1471 // case 24918: break;
1472 // // Mark of Nature
1473 // case 25041: break;
1475 // case 25152: break;
1477 // case 25371: break;
1479 // case 25572: break;
1481 // case 26009: break;
1483 // case 26136: break;
1485 // case 26196: break;
1487 // case 26615: break;
1489 // case 27177: break;
1490 // // Teleport: IF/UC
1491 // case 27601: break;
1492 // // Five Fat Finger Exploding Heart Technique
1493 // case 27673: break;
1495 // case 27746: break;
1496 // // Steam Tank Passive
1497 // case 27747: break;
1501 int32 bpDamage
= target
->GetMaxHealth()*26/100;
1502 caster
->CastCustomSpell(target
, 29879, &bpDamage
, NULL
, NULL
, true, NULL
, this);
1506 // case 27819: break;
1507 // // Controller Timer
1508 // case 28095: break;
1510 // case 28096: break;
1511 // // Stalagg Tesla Passive
1512 // case 28097: break;
1513 // // Feugen Tesla Passive
1514 // case 28109: break;
1516 // case 28111: break;
1517 // // Mark of Didier
1518 // case 28114: break;
1519 // // Communique Timer, camp
1520 // case 28346: break;
1522 // case 28522: break;
1524 // case 29519: break;
1525 // Inoculate Nestlewood Owlkin
1527 if(target
->GetTypeId() != TYPEID_UNIT
)// prevent error reports in case ignored player target
1531 // case 29768: break;
1533 // case 29788: break;
1535 // case 29793: break;
1537 // case 29794: break;
1538 // // Guardian of Icecrown Passive
1539 // case 29897: break;
1540 // Feed Captured Animal
1541 case 29917: trigger_spell_id
= 29916; break;
1543 // case 29946: break;
1545 // case 29947: break;
1546 // // Mind Exhaustion Passive
1547 // case 30025: break;
1548 // // Nether Beam - Serenity
1549 // case 30401: break;
1553 // move loot to player inventory and despawn target
1554 if(caster
->GetTypeId() ==TYPEID_PLAYER
&&
1555 target
->GetTypeId() == TYPEID_UNIT
&&
1556 ((Creature
*)target
)->GetCreatureInfo()->type
== CREATURE_TYPE_GAS_CLOUD
)
1558 Player
* player
= (Player
*)caster
;
1559 Creature
* creature
= (Creature
*)target
;
1560 // missing lootid has been reported on startup - just return
1561 if (!creature
->GetCreatureInfo()->SkinLootId
)
1564 player
->AutoStoreLoot(creature
->GetCreatureInfo()->SkinLootId
,LootTemplates_Skinning
,true);
1566 creature
->setDeathState(JUST_DIED
);
1567 creature
->RemoveCorpse();
1568 creature
->SetHealth(0); // just for nice GM-mode view
1573 case 30576: trigger_spell_id
= 30571; break;
1575 // case 30598: break;
1581 // // Despawn Self - Smoke cloud
1582 // case 31269: break;
1583 // // Time Rift Periodic
1584 // case 31320: break;
1585 // // Corrupt Medivh
1586 // case 31326: break;
1590 m_target
->CastSpell(m_target
,31350,true);
1591 m_target
->DealDamage(m_target
, m_target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
1597 // Summon Elemental after create item
1598 caster
->SummonCreature(17870, 0, 0, 0, caster
->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN
, 0);
1601 // // Bloodmyst Tesla
1602 // case 31611: break;
1604 // case 31944: break;
1606 // case 32236: break;
1608 // case 32686: break;
1610 // case 33401: break;
1612 // case 33563: break;
1613 // // Murmur's Touch
1614 // case 33711: break;
1618 // cast 24 spells 34269-34289, 34314-34316
1619 for(uint32 spell_id
= 34269; spell_id
!= 34290; ++spell_id
)
1620 caster
->CastSpell(m_target
, spell_id
, true);
1621 for(uint32 spell_id
= 34314; spell_id
!= 34317; ++spell_id
)
1622 caster
->CastSpell(m_target
, spell_id
, true);
1626 // case 34480: break;
1628 // case 34683: break;
1629 // // Frostbite Rotate
1630 // case 34748: break;
1632 // case 34821: break;
1633 // // Interrupt Shutdown
1634 // case 35016: break;
1635 // // Interrupt Shutdown
1636 // case 35176: break;
1638 // case 35268: break;
1639 // // Salaadin's Tesla
1640 // case 35515: break;
1641 // // Ethereal Channel (Red)
1642 // case 35518: break;
1644 // case 35879: break;
1645 // // Dark Portal Storm
1646 // case 36018: break;
1648 // case 36056: break;
1649 // // Living Grove Defender Lifespan
1650 // case 36061: break;
1651 // // Professor Dabiri Talks
1652 // case 36064: break;
1653 // // Kael Gaining Power
1654 // case 36091: break;
1655 // // They Must Burn Bomb Aura
1656 // case 36344: break;
1657 // // They Must Burn Bomb Aura (self)
1658 // case 36350: break;
1659 // // Stolen Ravenous Ravager Egg
1660 // case 36401: break;
1661 // // Activated Cannon
1662 // case 36410: break;
1663 // // Stolen Ravenous Ravager Egg
1664 // case 36418: break;
1665 // // Enchanted Weapons
1666 // case 36510: break;
1667 // // Cursed Scarab Periodic
1668 // case 36556: break;
1669 // // Cursed Scarab Despawn Periodic
1670 // case 36561: break;
1672 // case 36573: break;
1673 // // Cannon Charging (platform)
1674 // case 36785: break;
1675 // // Cannon Charging (self)
1676 // case 36860: break;
1678 case 37027: trigger_spell_id
= 37029; break;
1680 // case 37125: break;
1682 // case 37268: break;
1684 // case 37429: break;
1686 // case 37430: break;
1687 // // Karazhan - Chess NPC AI, Snapshot timer
1688 // case 37440: break;
1689 // // Karazhan - Chess NPC AI, action timer
1690 // case 37504: break;
1691 // // Karazhan - Chess: Is Square OCCUPIED aura (DND)
1692 // case 39400: break;
1694 // case 37546: break;
1695 // // Shriveling Gaze
1696 // case 37589: break;
1697 // // Fake Aggro Radius (2 yd)
1698 // case 37815: break;
1699 // // Corrupt Medivh
1700 // case 37853: break;
1704 m_target
->CastSpell(m_target
, 38530, true);
1707 // Absorb Eye of Grillok (Zezzak's Shard)
1710 if(m_target
->GetTypeId() != TYPEID_UNIT
)
1713 caster
->CastSpell(caster
, 38495, true);
1715 Creature
* creatureTarget
= (Creature
*)m_target
;
1717 creatureTarget
->setDeathState(JUST_DIED
);
1718 creatureTarget
->RemoveCorpse();
1719 creatureTarget
->SetHealth(0); // just for nice GM-mode view
1722 // // Magic Sucker Device timer
1723 // case 38672: break;
1724 // // Tomb Guarding Charging
1725 // case 38751: break;
1726 // // Murmur's Touch
1727 // case 38794: break;
1728 // // Activate Nether-wraith Beacon (31742 Nether-wraith Beacon item)
1729 // case 39105: break;
1730 // // Drain World Tree Visual
1731 // case 39140: break;
1732 // // Quest - Dustin's Undead Dragon Visual aura
1733 // case 39259: break;
1734 // // Hellfire - The Exorcism, Jules releases darkness, aura
1735 // case 39306: break;
1737 // case 39346: break;
1738 // // Enchanted Weapons
1739 // case 39489: break;
1740 // // Shadow Bolt Whirl
1741 // case 39630: break;
1742 // // Shadow Bolt Whirl
1743 // case 39634: break;
1744 // // Shadow Inferno
1745 // case 39645: break;
1746 // Tear of Azzinoth Summon Channel - it's not really supposed to do anything,and this only prevents the console spam
1747 case 39857: trigger_spell_id
= 39856; break;
1748 // // Soulgrinder Ritual Visual (Smashed)
1749 // case 39974: break;
1750 // // Simon Game Pre-game timer
1751 // case 40041: break;
1752 // // Knockdown Fel Cannon: The Aggro Check Aura
1753 // case 40113: break;
1755 // case 40157: break;
1756 // // Demon Transform 2
1757 // case 40398: break;
1758 // // Demon Transform 1
1759 // case 40511: break;
1760 // // Ancient Flames
1761 // case 40657: break;
1762 // // Ethereal Ring Cannon: Cannon Aura
1763 // case 40734: break;
1765 // case 40760: break;
1766 // // Random Periodic
1767 // case 40867: break;
1768 // // Prismatic Shield
1769 // case 40879: break;
1770 // // Aura of Desire
1771 // case 41350: break;
1773 // case 41404: break;
1775 // case 41629: break;
1777 // case 42177: break;
1779 // case 42581: break;
1781 // case 42582: break;
1782 // // Return to the Spirit Realm
1783 // case 44035: break;
1784 // // Curse of Boundless Agony
1785 // case 45050: break;
1787 // case 46240: break;
1788 // Personalized Weather
1789 case 46736: trigger_spell_id
= 46737; break;
1790 // // Stay Submerged
1791 // case 46981: break;
1792 // // Dragonblight Ram
1793 // case 47015: break;
1794 // // Party G.R.E.N.A.D.E.
1795 // case 51510: break;
1801 case SPELLFAMILY_MAGE
:
1807 // Here need periodic triger reducing threat spell (or do it manually)
1814 // case SPELLFAMILY_WARRIOR:
1819 // case 23410: break;
1820 // // Corrupted Totems
1821 // case 23425: break;
1827 // case SPELLFAMILY_PRIEST:
1832 // case 32930: break;
1833 // // Fury of the Dreghood Elders
1834 // case 35460: break;
1840 case SPELLFAMILY_DRUID
:
1845 // trigger_spell_id not set and unknown effect triggered in this case, ignoring for while
1848 // Frenzied Regeneration
1854 int32 LifePerRage
= GetModifier()->m_amount
;
1856 int32 lRage
= m_target
->GetPower(POWER_RAGE
);
1857 if(lRage
> 100) // rage stored as rage*10
1859 m_target
->ModifyPower(POWER_RAGE
, -lRage
);
1860 int32 FRTriggerBasePoints
= int32(lRage
*LifePerRage
/10);
1861 m_target
->CastCustomSpell(m_target
, 22845, &FRTriggerBasePoints
, NULL
, NULL
, true, NULL
, this);
1870 // case SPELLFAMILY_HUNTER:
1874 // //Frost Trap Aura
1877 // //Rizzle's Frost Trap
1881 // case 19597: // Tame Ice Claw Bear
1882 // case 19676: // Tame Snow Leopard
1883 // case 19677: // Tame Large Crag Boar
1884 // case 19678: // Tame Adult Plainstrider
1885 // case 19679: // Tame Prairie Stalker
1886 // case 19680: // Tame Swoop
1887 // case 19681: // Tame Dire Mottled Boar
1888 // case 19682: // Tame Surf Crawler
1889 // case 19683: // Tame Armored Scorpid
1890 // case 19684: // Tame Webwood Lurker
1891 // case 19685: // Tame Nightsaber Stalker
1892 // case 19686: // Tame Strigid Screecher
1893 // case 30100: // Tame Crazed Dragonhawk
1894 // case 30103: // Tame Elder Springpaw
1895 // case 30104: // Tame Mistbat
1896 // case 30647: // Tame Barbed Crawler
1897 // case 30648: // Tame Greater Timberstrider
1898 // case 30652: // Tame Nightstalker
1905 case SPELLFAMILY_SHAMAN
:
1909 // Lightning Shield (The Earthshatterer set trigger after cast Lighting Shield)
1912 // Need remove self if Lightning Shield not active
1913 Unit::AuraMap
const& auras
= target
->GetAuras();
1914 for(Unit::AuraMap::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
1916 SpellEntry
const* spell
= itr
->second
->GetSpellProto();
1917 if( spell
->SpellFamilyName
== SPELLFAMILY_SHAMAN
&&
1918 (spell
->SpellFamilyFlags
& UI64LIT(0x0000000000000400)))
1921 target
->RemoveAurasDueToSpell(28820);
1924 // Totemic Mastery (Skyshatter Regalia (Shaman Tier 6) - bonus)
1928 for(int i
= 0; i
< MAX_TOTEM
; ++i
)
1930 if(!caster
->m_TotemSlot
[i
])
1938 caster
->CastSpell(caster
, 38437, true);
1940 caster
->RemoveAurasDueToSpell(38437);
1952 // Reget trigger spell proto
1953 triggeredSpellInfo
= sSpellStore
.LookupEntry(trigger_spell_id
);
1957 // Spell exist but require custom code
1963 // TODO: spell casted by result in correct way mostly
1965 // 1) target show casting at each triggered cast: target don't must show casting animation for any triggered spell
1966 // but must show affect apply like item casting
1967 // 2) maybe aura must be replace by new with accumulative stat mods instead stacking
1969 // prevent cast by triggered auras
1970 if(m_caster_guid
== m_target
->GetGUID())
1973 // stop triggering after each affected stats lost > 90
1974 int32 intelectLoss
= 0;
1975 int32 spiritLoss
= 0;
1977 Unit::AuraList
const& mModStat
= m_target
->GetAurasByType(SPELL_AURA_MOD_STAT
);
1978 for(Unit::AuraList::const_iterator i
= mModStat
.begin(); i
!= mModStat
.end(); ++i
)
1980 if ((*i
)->GetId() == 1010)
1982 switch((*i
)->GetModifier()->m_miscvalue
)
1984 case STAT_INTELLECT
: intelectLoss
+= (*i
)->GetModifier()->m_amount
; break;
1985 case STAT_SPIRIT
: spiritLoss
+= (*i
)->GetModifier()->m_amount
; break;
1991 if(intelectLoss
<= -90 && spiritLoss
<= -90)
2000 caster
->CastCustomSpell(target
, trigger_spell_id
, &m_modifier
.m_amount
, NULL
, NULL
, true, NULL
, this);
2006 // All ok cast by default case
2007 if(triggeredSpellInfo
)
2008 caster
->CastSpell(target
, triggeredSpellInfo
, true, 0, this);
2009 else if(target
->GetTypeId()!=TYPEID_UNIT
|| !Script
->EffectDummyCreature(caster
, GetId(), GetEffIndex(), (Creature
*)target
))
2010 sLog
.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex());
2013 void Aura::TriggerSpellWithValue()
2015 Unit
* caster
= GetCaster();
2016 Unit
* target
= GetTriggerTarget();
2018 if(!caster
|| !target
)
2021 // generic casting code with custom spells and target/caster customs
2022 uint32 trigger_spell_id
= GetSpellProto()->EffectTriggerSpell
[m_effIndex
];
2023 int32 basepoints0
= this->GetModifier()->m_amount
;
2025 caster
->CastCustomSpell(target
, trigger_spell_id
, &basepoints0
, NULL
, NULL
, true, NULL
, this);
2028 /*********************************************************/
2029 /*** AURA EFFECTS ***/
2030 /*********************************************************/
2032 void Aura::HandleAuraDummy(bool apply
, bool Real
)
2034 // spells required only Real aura add/remove
2038 Unit
* caster
= GetCaster();
2045 case 1515: // Tame beast
2046 // FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness
2047 if( caster
&& m_target
->CanHaveThreatList())
2048 m_target
->AddThreat(caster
, 10.0f
);
2050 case 13139: // net-o-matic
2051 // root to self part of (root_target->charge->root_self sequence
2053 caster
->CastSpell(caster
, 13138, true, NULL
, this);
2055 case 39850: // Rocket Blast
2056 if(roll_chance_i(20)) // backfire stun
2057 m_target
->CastSpell(m_target
, 51581, true, NULL
, this);
2059 case 43873: // Headless Horseman Laugh
2060 m_target
->PlayDistanceSound(11965);
2062 case 46354: // Blood Elf Illusion
2065 switch(caster
->getGender())
2068 caster
->CastSpell(m_target
, 46356, true, NULL
, this);
2071 caster
->CastSpell(m_target
, 46355, true, NULL
, this);
2078 case 46699: // Requires No Ammo
2079 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2080 ((Player
*)m_target
)->RemoveAmmo(); // not use ammo and not allow use
2085 if ( caster
&& GetSpellProto()->SpellFamilyName
== SPELLFAMILY_SHAMAN
&& (GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x40000000000)))
2087 // prevent double apply bonuses
2088 if(m_target
->GetTypeId() != TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading())
2089 m_modifier
.m_amount
= caster
->SpellHealingBonus(m_target
, GetSpellProto(), m_modifier
.m_amount
, SPELL_DIRECT_DAMAGE
);
2096 if( m_target
->GetTypeId() == TYPEID_PLAYER
&&
2097 ( GetSpellProto()->Effect
[0]==72 || GetSpellProto()->Effect
[0]==6 &&
2098 ( GetSpellProto()->EffectApplyAuraName
[0]==1 || GetSpellProto()->EffectApplyAuraName
[0]==128 ) ) )
2100 // spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425
2101 ((Player
*)m_target
)->SetFarSightGUID(0);
2102 WorldPacket
data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE
, 0);
2103 ((Player
*)m_target
)->GetSession()->SendPacket(&data
);
2107 if( (IsQuestTameSpell(GetId())) && caster
&& caster
->isAlive() && m_target
->isAlive())
2109 uint32 finalSpelId
= 0;
2112 case 19548: finalSpelId
= 19597; break;
2113 case 19674: finalSpelId
= 19677; break;
2114 case 19687: finalSpelId
= 19676; break;
2115 case 19688: finalSpelId
= 19678; break;
2116 case 19689: finalSpelId
= 19679; break;
2117 case 19692: finalSpelId
= 19680; break;
2118 case 19693: finalSpelId
= 19684; break;
2119 case 19694: finalSpelId
= 19681; break;
2120 case 19696: finalSpelId
= 19682; break;
2121 case 19697: finalSpelId
= 19683; break;
2122 case 19699: finalSpelId
= 19685; break;
2123 case 19700: finalSpelId
= 19686; break;
2124 case 30646: finalSpelId
= 30647; break;
2125 case 30653: finalSpelId
= 30648; break;
2126 case 30654: finalSpelId
= 30652; break;
2127 case 30099: finalSpelId
= 30100; break;
2128 case 30102: finalSpelId
= 30103; break;
2129 case 30105: finalSpelId
= 30104; break;
2133 caster
->CastSpell(m_target
, finalSpelId
, true, NULL
, this);
2139 case 2584: // Waiting to Resurrect
2141 // Waiting to resurrect spell cancel, we must remove player from resurrect queue
2142 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2143 if(BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround())
2144 bg
->RemovePlayerFromResurrectQueue(m_target
->GetGUID());
2147 case 45934: // Dark Fiend
2149 // Kill target if dispelled
2150 if (m_removeMode
==AURA_REMOVE_BY_DISPEL
)
2151 m_target
->DealDamage(m_target
, m_target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
2154 case 46308: // Burning Winds
2156 // casted only at creatures at spawn
2157 m_target
->CastSpell(m_target
, 47287, true, NULL
, this);
2162 if (caster
&& m_removeMode
== AURA_REMOVE_BY_DEATH
)
2164 // Stop caster Arcane Missle chanelling on death
2165 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_MAGE
&&
2166 (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000800)))
2168 caster
->InterruptSpell(CURRENT_CHANNELED_SPELL
);
2171 // Stop caster Penance chanelling on death
2172 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_PRIEST
&&
2173 (m_spellProto
->SpellFamilyFlags2
& UI64LIT(0x00000080)))
2175 caster
->InterruptSpell(CURRENT_CHANNELED_SPELL
);
2182 // AT APPLY & REMOVE
2184 switch(m_spellProto
->SpellFamilyName
)
2186 case SPELLFAMILY_GENERIC
:
2193 uint32 spellId
= 24659;
2194 if (apply
&& caster
)
2196 const SpellEntry
*spell
= sSpellStore
.LookupEntry(spellId
);
2200 for (int i
=0; i
< spell
->StackAmount
; ++i
)
2201 caster
->CastSpell(m_target
, spell
->Id
, true, NULL
, NULL
, GetCasterGUID());
2204 m_target
->RemoveAurasDueToSpell(spellId
);
2207 // Restless Strength
2210 uint32 spellId
= 24662;
2211 if (apply
&& caster
)
2213 const SpellEntry
*spell
= sSpellStore
.LookupEntry(spellId
);
2216 for (int i
=0; i
< spell
->StackAmount
; ++i
)
2217 caster
->CastSpell(m_target
, spell
->Id
, true, NULL
, NULL
, GetCasterGUID());
2220 m_target
->RemoveAurasDueToSpell(spellId
);
2223 //Summon Fire Elemental
2229 Unit
*owner
= caster
->GetOwner();
2230 if (owner
&& owner
->GetTypeId() == TYPEID_PLAYER
)
2233 owner
->CastSpell(owner
, 8985, true);
2235 ((Player
*)owner
)->RemovePet(NULL
, PET_SAVE_NOT_IN_SLOT
, true);
2239 //Summon Earth Elemental
2245 Unit
*owner
= caster
->GetOwner();
2246 if (owner
&& owner
->GetTypeId() == TYPEID_PLAYER
)
2249 owner
->CastSpell(owner
, 19704, true);
2251 ((Player
*)owner
)->RemovePet(NULL
, PET_SAVE_NOT_IN_SLOT
, true);
2257 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2261 m_target
->PlayDirectSound(14970, (Player
*)m_target
);
2262 // continue in 58205
2264 m_target
->CastSpell(m_target
, 58205, true);
2269 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2273 m_target
->PlayDirectSound(14971, (Player
*)m_target
);
2276 m_target
->PlayDirectSound(14972, (Player
*)m_target
);
2282 case SPELLFAMILY_MAGE
:
2286 case SPELLFAMILY_PRIEST
:
2288 // Pain and Suffering
2289 if( m_spellProto
->SpellIconID
== 2874 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2293 // Reduce backfire damage (dot damage) from Shadow Word: Death
2294 SpellModifier
*mod
= new SpellModifier
;
2295 mod
->op
= SPELLMOD_DOT
;
2296 mod
->value
= m_modifier
.m_amount
;
2297 mod
->type
= SPELLMOD_PCT
;
2298 mod
->spellId
= GetId();
2299 mod
->mask
= UI64LIT(0x0000200000000000);
2300 mod
->mask2
= UI64LIT(0x0);
2303 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2308 case SPELLFAMILY_DRUID
:
2312 case 34246: // Idol of the Emerald Queen
2313 case 60779: // Idol of Lush Moss
2315 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
2320 SpellModifier
*mod
= new SpellModifier
;
2321 mod
->op
= SPELLMOD_DOT
;
2322 mod
->value
= m_modifier
.m_amount
/7;
2323 mod
->type
= SPELLMOD_FLAT
;
2324 mod
->spellId
= GetId();
2325 mod
->mask
= UI64LIT(0x001000000000);
2326 mod
->mask2
= UI64LIT(0x0);
2331 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2334 case 61336: // Survival Instincts
2338 if (!m_target
->IsInFeralForm())
2341 int32 bp0
= int32(m_target
->GetMaxHealth() * m_modifier
.m_amount
/ 100);
2342 m_target
->CastCustomSpell(m_target
, 50322, &bp0
, NULL
, NULL
, true);
2345 m_target
-> RemoveAurasDueToSpell(50322);
2351 if (GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x1000000000))
2356 // prevent double apply bonuses
2357 if(m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading())
2358 m_modifier
.m_amount
= caster
->SpellHealingBonus(m_target
, GetSpellProto(), m_modifier
.m_amount
, SPELL_DIRECT_DAMAGE
);
2362 // Final heal only on dispelled or duration end
2363 if ( !(GetAuraDuration() <= 0 || m_removeMode
== AURA_REMOVE_BY_DISPEL
) )
2366 // have a look if there is still some other Lifebloom dummy aura
2367 Unit::AuraList auras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
2368 for(Unit::AuraList::iterator itr
= auras
.begin(); itr
!=auras
.end(); ++itr
)
2369 if((*itr
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_DRUID
&&
2370 ((*itr
)->GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x1000000000)))
2374 if(m_target
->IsInWorld() && m_stackAmount
> 0)
2376 int32 amount
= m_modifier
.m_amount
/ m_stackAmount
;
2377 m_target
->CastCustomSpell(m_target
, 33778, &amount
, NULL
, NULL
, true, NULL
, this, GetCasterGUID());
2383 // Predatory Strikes
2384 if(m_target
->GetTypeId()==TYPEID_PLAYER
&& GetSpellProto()->SpellIconID
== 1563)
2386 ((Player
*)m_target
)->UpdateAttackPowerAndDamage();
2391 case SPELLFAMILY_HUNTER
:
2393 case SPELLFAMILY_SHAMAN
:
2395 // Improved Weapon Totems
2396 if( GetSpellProto()->SpellIconID
== 57 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2400 SpellModifier
*mod
= new SpellModifier
;
2401 mod
->op
= SPELLMOD_EFFECT1
;
2402 mod
->value
= m_modifier
.m_amount
;
2403 mod
->type
= SPELLMOD_PCT
;
2404 mod
->spellId
= GetId();
2409 mod
->mask
= UI64LIT(0x00200000000);
2410 mod
->mask2
= UI64LIT(0x0);
2413 // Flametongue Totem
2414 mod
->mask
= UI64LIT(0x00400000000);
2415 mod
->mask2
= UI64LIT(0x0);
2422 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2430 if(PetAura
const* petSpell
= spellmgr
.GetPetAura(GetId()))
2433 m_target
->AddPetAura(petSpell
);
2435 m_target
->RemovePetAura(petSpell
);
2439 if(GetEffIndex()==0 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2441 SpellAreaForAreaMapBounds saBounds
= spellmgr
.GetSpellAreaForAuraMapBounds(GetId());
2442 if(saBounds
.first
!= saBounds
.second
)
2445 m_target
->GetZoneAndAreaId(zone
, area
);
2447 for(SpellAreaForAreaMap::const_iterator itr
= saBounds
.first
; itr
!= saBounds
.second
; ++itr
)
2449 // some auras remove at aura remove
2450 if(!itr
->second
->IsFitToRequirements((Player
*)m_target
, zone
, area
))
2451 m_target
->RemoveAurasDueToSpell(itr
->second
->spellId
);
2452 // some auras applied at aura apply
2453 else if(itr
->second
->autocast
)
2455 if( !m_target
->HasAura(itr
->second
->spellId
, 0) )
2456 m_target
->CastSpell(m_target
, itr
->second
->spellId
, true);
2463 void Aura::HandleAuraMounted(bool apply
, bool Real
)
2465 // only at real add/remove aura
2471 CreatureInfo
const* ci
= objmgr
.GetCreatureTemplate(m_modifier
.m_miscvalue
);
2474 sLog
.outErrorDb("AuraMounted: `creature_template`='%u' not found in database (only need it modelid)", m_modifier
.m_miscvalue
);
2479 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
2480 team
= ((Player
*)m_target
)->GetTeam();
2482 uint32 display_id
= objmgr
.ChooseDisplayId(team
,ci
);
2483 CreatureModelInfo
const *minfo
= objmgr
.GetCreatureModelRandomGender(display_id
);
2485 display_id
= minfo
->modelid
;
2487 m_target
->Mount(display_id
);
2491 m_target
->Unmount();
2495 void Aura::HandleAuraWaterWalk(bool apply
, bool Real
)
2497 // only at real add/remove aura
2503 data
.Initialize(SMSG_MOVE_WATER_WALK
, 8+4);
2505 data
.Initialize(SMSG_MOVE_LAND_WALK
, 8+4);
2506 data
.append(m_target
->GetPackGUID());
2508 m_target
->SendMessageToSet(&data
, true);
2511 void Aura::HandleAuraFeatherFall(bool apply
, bool Real
)
2513 // only at real add/remove aura
2519 data
.Initialize(SMSG_MOVE_FEATHER_FALL
, 8+4);
2521 data
.Initialize(SMSG_MOVE_NORMAL_FALL
, 8+4);
2522 data
.append(m_target
->GetPackGUID());
2524 m_target
->SendMessageToSet(&data
, true);
2527 void Aura::HandleAuraHover(bool apply
, bool Real
)
2529 // only at real add/remove aura
2535 data
.Initialize(SMSG_MOVE_SET_HOVER
, 8+4);
2537 data
.Initialize(SMSG_MOVE_UNSET_HOVER
, 8+4);
2538 data
.append(m_target
->GetPackGUID());
2540 m_target
->SendMessageToSet(&data
, true);
2543 void Aura::HandleWaterBreathing(bool /*apply*/, bool /*Real*/)
2545 // update timers in client
2546 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
2547 ((Player
*)m_target
)->UpdateMirrorTimers();
2550 void Aura::HandleAuraModShapeshift(bool apply
, bool Real
)
2556 Powers PowerType
= POWER_MANA
;
2557 ShapeshiftForm form
= ShapeshiftForm(m_modifier
.m_miscvalue
);
2561 if(Player::TeamForRace(m_target
->getRace()) == ALLIANCE
)
2565 PowerType
= POWER_ENERGY
;
2571 if(Player::TeamForRace(m_target
->getRace()) == ALLIANCE
)
2577 if(Player::TeamForRace(m_target
->getRace()) == ALLIANCE
)
2581 PowerType
= POWER_RAGE
;
2584 if(Player::TeamForRace(m_target
->getRace()) == ALLIANCE
)
2588 if(Player::TeamForRace(m_target
->getRace()) == ALLIANCE
)
2592 PowerType
= POWER_RAGE
;
2594 case FORM_CREATUREBEAR
:
2597 case FORM_GHOSTWOLF
:
2601 if(Player::TeamForRace(m_target
->getRace()) == ALLIANCE
)
2607 if(Player::TeamForRace(m_target
->getRace()) == ALLIANCE
)
2612 case FORM_FLIGHT_EPIC
:
2613 if(Player::TeamForRace(m_target
->getRace()) == ALLIANCE
)
2618 case FORM_METAMORPHOSIS
:
2628 case FORM_BATTLESTANCE
:
2629 case FORM_BERSERKERSTANCE
:
2630 case FORM_DEFENSIVESTANCE
:
2631 PowerType
= POWER_RAGE
;
2633 case FORM_SPIRITOFREDEMPTION
:
2637 sLog
.outError("Auras: Unknown Shapeshift Type: %u", m_modifier
.m_miscvalue
);
2640 // remove polymorph before changing display id to keep new display id
2649 case FORM_FLIGHT_EPIC
:
2652 // remove movement affects
2653 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT
);
2654 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED
);
2656 // and polymorphic affects
2657 if(m_target
->IsPolymorphed())
2658 m_target
->RemoveAurasDueToSpell(m_target
->getTransForm());
2666 // remove other shapeshift before applying a new one
2667 if(m_target
->m_ShapeShiftFormSpellId
)
2668 m_target
->RemoveAurasDueToSpell(m_target
->m_ShapeShiftFormSpellId
, this);
2670 m_target
->SetByteValue(UNIT_FIELD_BYTES_2
, 3, form
);
2673 m_target
->SetDisplayId(modelid
);
2675 if(PowerType
!= POWER_MANA
)
2677 // reset power to default values only at power change
2678 if(m_target
->getPowerType() != PowerType
)
2679 m_target
->setPowerType(PowerType
);
2687 // get furor proc chance
2688 uint32 FurorChance
= 0;
2689 Unit::AuraList
const& mDummy
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
2690 for(Unit::AuraList::const_iterator i
= mDummy
.begin(); i
!= mDummy
.end(); ++i
)
2692 if ((*i
)->GetSpellProto()->SpellIconID
== 238)
2694 FurorChance
= (*i
)->GetModifier()->m_amount
;
2699 if (m_modifier
.m_miscvalue
== FORM_CAT
)
2701 m_target
->SetPower(POWER_ENERGY
, 0);
2702 if(urand(1,100) <= FurorChance
)
2703 m_target
->CastSpell(m_target
, 17099, true, NULL
, this);
2707 m_target
->SetPower(POWER_RAGE
, 0);
2708 if(urand(1,100) <= FurorChance
)
2709 m_target
->CastSpell(m_target
, 17057, true, NULL
, this);
2713 case FORM_BATTLESTANCE
:
2714 case FORM_DEFENSIVESTANCE
:
2715 case FORM_BERSERKERSTANCE
:
2717 uint32 Rage_val
= 0;
2718 // Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch)
2719 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2721 PlayerSpellMap
const& sp_list
= ((Player
*)m_target
)->GetSpellMap();
2722 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
2724 if(itr
->second
->state
== PLAYERSPELL_REMOVED
) continue;
2725 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
2726 if (spellInfo
&& spellInfo
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& spellInfo
->SpellIconID
== 139)
2727 Rage_val
+= m_target
->CalculateSpellDamage(spellInfo
, 0, spellInfo
->EffectBasePoints
[0], m_target
) * 10;
2731 if (m_target
->GetPower(POWER_RAGE
) > Rage_val
)
2732 m_target
->SetPower(POWER_RAGE
, Rage_val
);
2740 m_target
->m_ShapeShiftFormSpellId
= GetId();
2741 m_target
->m_form
= form
;
2746 m_target
->SetDisplayId(m_target
->GetNativeDisplayId());
2747 m_target
->SetByteValue(UNIT_FIELD_BYTES_2
, 3, FORM_NONE
);
2748 if(m_target
->getClass() == CLASS_DRUID
)
2749 m_target
->setPowerType(POWER_MANA
);
2750 m_target
->m_ShapeShiftFormSpellId
= 0;
2751 m_target
->m_form
= FORM_NONE
;
2755 // Nordrassil Harness - bonus
2759 if(Aura
* dummy
= m_target
->GetDummyAura(37315) )
2760 m_target
->CastSpell(m_target
, 37316, true, NULL
, dummy
);
2762 // Nordrassil Regalia - bonus
2764 if(Aura
* dummy
= m_target
->GetDummyAura(37324) )
2765 m_target
->CastSpell(m_target
, 37325, true, NULL
, dummy
);
2772 // adding/removing linked auras
2773 // add/remove the shapeshift aura's boosts
2774 HandleShapeshiftBoosts(apply
);
2776 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2777 ((Player
*)m_target
)->InitDataForForm();
2780 void Aura::HandleAuraTransform(bool apply
, bool Real
)
2784 // special case (spell specific functionality)
2785 if (m_modifier
.m_miscvalue
== 0)
2787 // player applied only
2788 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
2796 uint32 orb_model
= m_target
->GetNativeDisplayId();
2800 case 1479: m_target
->SetDisplayId(10134); break;
2802 case 1478: m_target
->SetDisplayId(10135); break;
2804 case 59: m_target
->SetDisplayId(10136); break;
2806 case 49: m_target
->SetDisplayId(10137); break;
2808 case 50: m_target
->SetDisplayId(10138); break;
2810 case 51: m_target
->SetDisplayId(10139); break;
2812 case 52: m_target
->SetDisplayId(10140); break;
2814 case 53: m_target
->SetDisplayId(10141); break;
2816 case 54: m_target
->SetDisplayId(10142); break;
2818 case 55: m_target
->SetDisplayId(10143); break;
2820 case 56: m_target
->SetDisplayId(10144); break;
2822 case 58: m_target
->SetDisplayId(10145); break;
2824 case 57: m_target
->SetDisplayId(10146); break;
2826 case 60: m_target
->SetDisplayId(10147); break;
2828 case 1563: m_target
->SetDisplayId(10148); break;
2830 case 1564: m_target
->SetDisplayId(10149); break;
2832 case 15475: m_target
->SetDisplayId(17830); break;
2834 case 15476: m_target
->SetDisplayId(17829); break;
2836 case 16126: m_target
->SetDisplayId(17828); break;
2838 case 16125: m_target
->SetDisplayId(17827); break;
2844 case 42365: m_target
->SetDisplayId(21723); break;
2850 CreatureInfo
const * ci
= objmgr
.GetCreatureTemplate(m_modifier
.m_miscvalue
);
2854 m_target
->SetDisplayId(16358);
2855 sLog
.outError("Auras: unknown creature id = %d (only need its modelid) Form Spell Aura Transform in Spell ID = %d", m_modifier
.m_miscvalue
, GetId());
2859 // Will use the default model here
2860 m_target
->SetDisplayId(ci
->DisplayID_A
[0]);
2862 // Dragonmaw Illusion (set mount model also)
2863 if(GetId()==42016 && m_target
->GetMountID() && !m_target
->GetAurasByType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
).empty())
2864 m_target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
,16314);
2868 // update active transform spell only not set or not overwriting negative by positive case
2869 if (!m_target
->getTransForm() || !IsPositiveSpell(GetId()) || IsPositiveSpell(m_target
->getTransForm()))
2870 m_target
->setTransForm(GetId());
2873 if (Real
&& m_target
->GetTypeId() == TYPEID_PLAYER
&& m_target
->IsPolymorphed())
2875 // for players, start regeneration after 1s (in polymorph fast regeneration case)
2876 // only if caster is Player (after patch 2.4.2)
2877 if (IS_PLAYER_GUID(GetCasterGUID()) )
2878 ((Player
*)m_target
)->setRegenTimer(1*IN_MILISECONDS
);
2880 //dismount polymorphed target (after patch 2.4.2)
2881 if (m_target
->IsMounted())
2882 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
2887 // ApplyModifier(true) will reapply it if need
2888 m_target
->setTransForm(0);
2889 m_target
->SetDisplayId(m_target
->GetNativeDisplayId());
2891 // re-aplly some from still active with preference negative cases
2892 Unit::AuraList
const& otherTransforms
= m_target
->GetAurasByType(SPELL_AURA_TRANSFORM
);
2893 if (!otherTransforms
.empty())
2895 // look for other transform auras
2896 Aura
* handledAura
= *otherTransforms
.begin();
2897 for(Unit::AuraList::const_iterator i
= otherTransforms
.begin();i
!= otherTransforms
.end(); ++i
)
2899 // negative auras are preferred
2900 if (!IsPositiveSpell((*i
)->GetSpellProto()->Id
))
2906 handledAura
->ApplyModifier(true);
2909 // Dragonmaw Illusion (restore mount model)
2910 if (GetId() == 42016 && m_target
->GetMountID() == 16314)
2912 if (!m_target
->GetAurasByType(SPELL_AURA_MOUNTED
).empty())
2914 uint32 cr_id
= m_target
->GetAurasByType(SPELL_AURA_MOUNTED
).front()->GetModifier()->m_miscvalue
;
2915 if (CreatureInfo
const* ci
= objmgr
.GetCreatureTemplate(cr_id
))
2918 if (m_target
->GetTypeId() == TYPEID_PLAYER
)
2919 team
= ((Player
*)m_target
)->GetTeam();
2921 uint32 display_id
= objmgr
.ChooseDisplayId(team
, ci
);
2922 CreatureModelInfo
const *minfo
= objmgr
.GetCreatureModelRandomGender(display_id
);
2924 display_id
= minfo
->modelid
;
2926 m_target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
, display_id
);
2933 void Aura::HandleForceReaction(bool apply
, bool Real
)
2935 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
2941 Player
* player
= (Player
*)m_target
;
2943 uint32 faction_id
= m_modifier
.m_miscvalue
;
2944 uint32 faction_rank
= m_modifier
.m_amount
;
2946 player
->GetReputationMgr().ApplyForceReaction(faction_id
, ReputationRank(faction_rank
), apply
);
2947 player
->GetReputationMgr().SendForceReactions();
2950 void Aura::HandleAuraModSkill(bool apply
, bool /*Real*/)
2952 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
2955 uint32 prot
=GetSpellProto()->EffectMiscValue
[m_effIndex
];
2956 int32 points
= GetModifier()->m_amount
;
2958 ((Player
*)m_target
)->ModifySkillBonus(prot
, (apply
? points
: -points
), m_modifier
.m_auraname
== SPELL_AURA_MOD_SKILL_TALENT
);
2959 if(prot
== SKILL_DEFENSE
)
2960 ((Player
*)m_target
)->UpdateDefenseBonusesMod();
2963 void Aura::HandleChannelDeathItem(bool apply
, bool Real
)
2967 Unit
* caster
= GetCaster();
2968 Unit
* victim
= GetTarget();
2969 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
|| !victim
|| m_removeMode
!= AURA_REMOVE_BY_DEATH
)
2972 if (m_modifier
.m_amount
<= 0)
2975 SpellEntry
const *spellInfo
= GetSpellProto();
2976 if(spellInfo
->EffectItemType
[m_effIndex
] == 0)
2979 // Soul Shard only from non-grey units
2980 if( spellInfo
->EffectItemType
[m_effIndex
] == 6265 &&
2981 (victim
->getLevel() <= MaNGOS::XP::GetGrayLevel(caster
->getLevel()) ||
2982 victim
->GetTypeId()==TYPEID_UNIT
&& !((Player
*)caster
)->isAllowedToLoot((Creature
*)victim
)) )
2985 uint32 noSpaceForCount
= 0;
2986 uint32 count
= m_modifier
.m_amount
;
2988 ItemPosCountVec dest
;
2989 uint8 msg
= ((Player
*)caster
)->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, spellInfo
->EffectItemType
[m_effIndex
], count
, &noSpaceForCount
);
2990 if( msg
!= EQUIP_ERR_OK
)
2992 count
-=noSpaceForCount
;
2993 ((Player
*)caster
)->SendEquipError( msg
, NULL
, NULL
);
2998 Item
* newitem
= ((Player
*)caster
)->StoreNewItem(dest
, spellInfo
->EffectItemType
[m_effIndex
], true);
2999 ((Player
*)caster
)->SendNewItem(newitem
, count
, true, false);
3003 void Aura::HandleBindSight(bool apply
, bool /*Real*/)
3005 Unit
* caster
= GetCaster();
3006 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3009 ((Player
*)caster
)->SetFarSightGUID(apply
? m_target
->GetGUID() : 0);
3012 void Aura::HandleFarSight(bool apply
, bool /*Real*/)
3014 Unit
* caster
= GetCaster();
3015 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3018 ((Player
*)caster
)->SetFarSightGUID(apply
? m_target
->GetGUID() : 0);
3021 void Aura::HandleAuraTrackCreatures(bool apply
, bool /*Real*/)
3023 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
3027 m_target
->RemoveNoStackAurasDueToAura(this);
3028 m_target
->SetUInt32Value(PLAYER_TRACK_CREATURES
, apply
? ((uint32
)1)<<(m_modifier
.m_miscvalue
-1) : 0 );
3031 void Aura::HandleAuraTrackResources(bool apply
, bool /*Real*/)
3033 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
3037 m_target
->RemoveNoStackAurasDueToAura(this);
3038 m_target
->SetUInt32Value(PLAYER_TRACK_RESOURCES
, apply
? ((uint32
)1)<<(m_modifier
.m_miscvalue
-1): 0 );
3041 void Aura::HandleAuraTrackStealthed(bool apply
, bool /*Real*/)
3043 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
3047 m_target
->RemoveNoStackAurasDueToAura(this);
3049 m_target
->ApplyModFlag(PLAYER_FIELD_BYTES
, PLAYER_FIELD_BYTE_TRACK_STEALTHED
, apply
);
3052 void Aura::HandleAuraModScale(bool apply
, bool /*Real*/)
3054 m_target
->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X
, m_modifier
.m_amount
, apply
);
3057 void Aura::HandleModPossess(bool apply
, bool Real
)
3062 if(m_target
->getLevel() > m_modifier
.m_amount
)
3065 // not possess yourself
3066 if(GetCasterGUID() == m_target
->GetGUID())
3069 Unit
* caster
= GetCaster();
3075 m_target
->SetCharmerGUID(GetCasterGUID());
3076 m_target
->setFaction(caster
->getFaction());
3078 caster
->SetCharm(m_target
);
3080 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3082 ((Player
*)caster
)->SetFarSightGUID(m_target
->GetGUID());
3083 ((Player
*)caster
)->SetClientControl(m_target
, 1);
3086 m_target
->CombatStop();
3087 m_target
->DeleteThreatList();
3088 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3090 m_target
->StopMoving();
3091 m_target
->GetMotionMaster()->Clear();
3092 m_target
->GetMotionMaster()->MoveIdle();
3094 else if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3096 ((Player
*)m_target
)->SetClientControl(m_target
, 0);
3099 if(CharmInfo
*charmInfo
= m_target
->InitCharmInfo(m_target
))
3100 charmInfo
->InitPossessCreateSpells();
3102 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3103 ((Player
*)caster
)->PossessSpellInitialize();
3107 m_target
->SetCharmerGUID(0);
3108 caster
->InterruptSpell(CURRENT_CHANNELED_SPELL
); // the spell is not automatically canceled when interrupted, do it now
3110 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3112 ((Player
*)m_target
)->setFactionForRace(m_target
->getRace());
3113 ((Player
*)m_target
)->SetClientControl(m_target
, 1);
3115 else if(m_target
->GetTypeId() == TYPEID_UNIT
)
3117 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
3118 m_target
->setFaction(cinfo
->faction_A
);
3121 caster
->SetCharm(NULL
);
3123 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3125 ((Player
*)caster
)->SetFarSightGUID(0);
3126 ((Player
*)caster
)->SetClientControl(m_target
, 0);
3128 WorldPacket
data(SMSG_PET_SPELLS
, 8);
3130 ((Player
*)caster
)->GetSession()->SendPacket(&data
);
3133 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3135 ((Creature
*)m_target
)->AIM_Initialize();
3137 if (((Creature
*)m_target
)->AI())
3138 ((Creature
*)m_target
)->AI()->AttackedBy(caster
);
3143 void Aura::HandleModPossessPet(bool apply
, bool Real
)
3148 Unit
* caster
= GetCaster();
3149 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3152 Pet
*pet
= caster
->GetPet();
3153 if(!pet
|| pet
!= m_target
)
3157 pet
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_24
);
3159 pet
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_24
);
3161 ((Player
*)caster
)->SetFarSightGUID(apply
? pet
->GetGUID() : 0);
3162 ((Player
*)caster
)->SetCharm(apply
? pet
: NULL
);
3163 ((Player
*)caster
)->SetClientControl(pet
, apply
? 1 : 0);
3168 pet
->GetMotionMaster()->Clear();
3169 pet
->GetMotionMaster()->MoveIdle();
3174 pet
->GetMotionMaster()->MoveFollow(caster
, PET_FOLLOW_DIST
, PET_FOLLOW_ANGLE
);
3175 pet
->SetUnitMovementFlags(MONSTER_MOVE_WALK
);
3179 void Aura::HandleAuraModPetTalentsPoints(bool /*Apply*/, bool Real
)
3184 // Recalculate pet talent points
3185 if (Pet
*pet
=m_target
->GetPet())
3186 pet
->InitTalentForLevel();
3189 void Aura::HandleModCharm(bool apply
, bool Real
)
3194 // not charm yourself
3195 if(GetCasterGUID() == m_target
->GetGUID())
3198 Unit
* caster
= GetCaster();
3202 if(int32(m_target
->getLevel()) <= m_modifier
.m_amount
)
3206 m_target
->SetCharmerGUID(GetCasterGUID());
3207 m_target
->setFaction(caster
->getFaction());
3208 m_target
->CastStop(m_target
== caster
? GetId() : 0);
3209 caster
->SetCharm(m_target
);
3211 m_target
->CombatStop();
3212 m_target
->DeleteThreatList();
3214 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3216 ((Creature
*)m_target
)->AIM_Initialize();
3217 CharmInfo
*charmInfo
= m_target
->InitCharmInfo(m_target
);
3218 charmInfo
->InitCharmCreateSpells();
3219 charmInfo
->SetReactState( REACT_DEFENSIVE
);
3221 if(caster
->GetTypeId() == TYPEID_PLAYER
&& caster
->getClass() == CLASS_WARLOCK
)
3223 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
3224 if(cinfo
&& cinfo
->type
== CREATURE_TYPE_DEMON
)
3226 //does not appear to have relevance. Why code added initially? See note below at !apply
3227 //to prevent client crash
3228 //m_target->SetFlag(UNIT_FIELD_BYTES_0, 2048);
3229 //just to enable stat window
3230 charmInfo
->SetPetNumber(objmgr
.GeneratePetNumber(), true);
3231 //if charmed two demons the same session, the 2nd gets the 1st one's name
3232 m_target
->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP
, time(NULL
));
3237 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3239 ((Player
*)caster
)->CharmSpellInitialize();
3244 m_target
->SetCharmerGUID(0);
3246 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3247 ((Player
*)m_target
)->setFactionForRace(m_target
->getRace());
3250 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
3253 if(((Creature
*)m_target
)->isPet())
3255 if(Unit
* owner
= m_target
->GetOwner())
3256 m_target
->setFaction(owner
->getFaction());
3258 m_target
->setFaction(cinfo
->faction_A
);
3260 else if(cinfo
) // normal creature
3261 m_target
->setFaction(cinfo
->faction_A
);
3263 // restore UNIT_FIELD_BYTES_0
3264 if(cinfo
&& caster
->GetTypeId() == TYPEID_PLAYER
&& caster
->getClass() == CLASS_WARLOCK
&& cinfo
->type
== CREATURE_TYPE_DEMON
)
3266 //does not appear to have relevance. Why code added initially? Class, gender, powertype should be same.
3267 //db field removed and replaced with better way to set class, restore using this if problems
3268 /*CreatureDataAddon const *cainfo = ((Creature*)m_target)->GetCreatureAddon();
3269 if(cainfo && cainfo->bytes0 != 0)
3270 m_target->SetUInt32Value(UNIT_FIELD_BYTES_0, cainfo->bytes0);
3272 m_target->RemoveFlag(UNIT_FIELD_BYTES_0, 2048);*/
3274 if(m_target
->GetCharmInfo())
3275 m_target
->GetCharmInfo()->SetPetNumber(0, true);
3277 sLog
.outError("Aura::HandleModCharm: target (GUID: %u TypeId: %u) has a charm aura but no charm info!", m_target
->GetGUIDLow(), m_target
->GetTypeId());
3281 caster
->SetCharm(NULL
);
3283 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3285 WorldPacket
data(SMSG_PET_SPELLS
, 8);
3287 ((Player
*)caster
)->GetSession()->SendPacket(&data
);
3289 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3291 ((Creature
*)m_target
)->AIM_Initialize();
3292 if (((Creature
*)m_target
)->AI())
3293 ((Creature
*)m_target
)->AI()->AttackedBy(caster
);
3299 void Aura::HandleModConfuse(bool apply
, bool Real
)
3304 m_target
->SetConfused(apply
, GetCasterGUID(), GetId());
3307 void Aura::HandleModFear(bool apply
, bool Real
)
3312 m_target
->SetFeared(apply
, GetCasterGUID(), GetId());
3315 void Aura::HandleFeignDeath(bool apply
, bool Real
)
3320 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
3326 WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9);
3327 data<<m_target->GetGUID();
3329 m_target->SendMessageToSet(&data,true);
3332 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_29
);
3334 m_target
->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FEIGN_DEATH
);
3336 m_target
->SetFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_DEAD
);
3338 m_target
->addUnitState(UNIT_STAT_DIED
);
3339 m_target
->CombatStop();
3340 m_target
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
);
3342 // prevent interrupt message
3343 if(m_caster_guid
==m_target
->GetGUID() && m_target
->m_currentSpells
[CURRENT_GENERIC_SPELL
])
3344 m_target
->m_currentSpells
[CURRENT_GENERIC_SPELL
]->finish();
3345 m_target
->InterruptNonMeleeSpells(true);
3346 m_target
->getHostilRefManager().deleteReferences();
3351 WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9);
3352 data<<m_target->GetGUID();
3354 m_target->SendMessageToSet(&data,true);
3357 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_29
);
3359 m_target
->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FEIGN_DEATH
);
3361 m_target
->RemoveFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_DEAD
);
3363 m_target
->clearUnitState(UNIT_STAT_DIED
);
3367 void Aura::HandleAuraModDisarm(bool apply
, bool Real
)
3372 if(!apply
&& m_target
->HasAuraType(SPELL_AURA_MOD_DISARM
))
3375 // not sure for it's correctness
3377 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_DISARMED
);
3379 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_DISARMED
);
3381 // only at real add/remove aura
3382 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
3385 // main-hand attack speed already set to special value for feral form already and don't must change and reset at remove.
3386 if (m_target
->IsInFeralForm())
3390 m_target
->SetAttackTime(BASE_ATTACK
,BASE_ATTACK_TIME
);
3392 ((Player
*)m_target
)->SetRegularAttackTime();
3394 m_target
->UpdateDamagePhysical(BASE_ATTACK
);
3397 void Aura::HandleAuraModStun(bool apply
, bool Real
)
3404 // Frost stun aura -> freeze/unfreeze target
3405 if (GetSpellSchoolMask(m_spellProto
) & SPELL_SCHOOL_MASK_FROST
)
3406 m_target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
3408 m_target
->addUnitState(UNIT_STAT_STUNNED
);
3409 m_target
->SetUInt64Value(UNIT_FIELD_TARGET
, 0);
3411 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
3412 m_target
->CastStop(m_target
->GetGUID() == GetCasterGUID() ? GetId() : 0);
3414 // Creature specific
3415 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
3416 ((Creature
*)m_target
)->StopMoving();
3419 ((Player
*)m_target
)->m_movementInfo
.flags
= 0; // Clear movement flags
3420 m_target
->SetStandState(UNIT_STAND_STATE_STAND
);// in 1.5 client
3423 WorldPacket
data(SMSG_FORCE_MOVE_ROOT
, 8);
3424 data
.append(m_target
->GetPackGUID());
3426 m_target
->SendMessageToSet(&data
, true);
3428 // Summon the Naj'entus Spine GameObject on target if spell is Impaling Spine
3429 if(GetId() == 39837)
3431 GameObject
* pObj
= new GameObject
;
3432 if(pObj
->Create(objmgr
.GenerateLowGuid(HIGHGUID_GAMEOBJECT
), 185584, m_target
->GetMap(), m_target
->GetPhaseMask(),
3433 m_target
->GetPositionX(), m_target
->GetPositionY(), m_target
->GetPositionZ(), m_target
->GetOrientation(), 0.0f
, 0.0f
, 0.0f
, 0.0f
, 100, GO_STATE_READY
))
3435 pObj
->SetRespawnTime(GetAuraDuration()/IN_MILISECONDS
);
3436 pObj
->SetSpellId(GetId());
3437 m_target
->AddGameObject(pObj
);
3438 m_target
->GetMap()->Add(pObj
);
3446 // Frost stun aura -> freeze/unfreeze target
3447 if (GetSpellSchoolMask(m_spellProto
) & SPELL_SCHOOL_MASK_FROST
)
3449 bool found_another
= false;
3450 for(AuraType
const* itr
= &frozenAuraTypes
[0]; *itr
!= SPELL_AURA_NONE
; ++itr
)
3452 Unit::AuraList
const& auras
= m_target
->GetAurasByType(*itr
);
3453 for(Unit::AuraList::const_iterator i
= auras
.begin(); i
!= auras
.end(); ++i
)
3455 if( GetSpellSchoolMask((*i
)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST
)
3457 found_another
= true;
3466 m_target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
3469 // Real remove called after current aura remove from lists, check if other similar auras active
3470 if(m_target
->HasAuraType(SPELL_AURA_MOD_STUN
))
3473 m_target
->clearUnitState(UNIT_STAT_STUNNED
);
3474 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
3476 if(!m_target
->hasUnitState(UNIT_STAT_ROOT
)) // prevent allow move if have also root effect
3478 if(m_target
->getVictim() && m_target
->isAlive())
3479 m_target
->SetUInt64Value(UNIT_FIELD_TARGET
,m_target
->getVictim()->GetGUID() );
3481 WorldPacket
data(SMSG_FORCE_MOVE_UNROOT
, 8+4);
3482 data
.append(m_target
->GetPackGUID());
3484 m_target
->SendMessageToSet(&data
, true);
3488 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_HUNTER
&& m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000100000000000))
3490 Unit
* caster
= GetCaster();
3491 if( !caster
|| caster
->GetTypeId()!=TYPEID_PLAYER
)
3494 uint32 spell_id
= 0;
3498 case 19386: spell_id
= 24131; break;
3499 case 24132: spell_id
= 24134; break;
3500 case 24133: spell_id
= 24135; break;
3501 case 27068: spell_id
= 27069; break;
3502 case 49011: spell_id
= 49009; break;
3503 case 49012: spell_id
= 49010; break;
3505 sLog
.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?",GetId());
3509 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell_id
);
3514 caster
->CastSpell(m_target
,spellInfo
,true,NULL
,this);
3520 void Aura::HandleModStealth(bool apply
, bool Real
)
3522 Unit
* pTarget
= m_target
;
3523 SpellEntry
const* pSpellInfo
= GetSpellProto();
3527 // drop flag at stealth in bg
3528 pTarget
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
);
3530 // only at real aura add
3533 pTarget
->SetStandFlags(UNIT_STAND_FLAGS_CREEP
);
3535 if (pTarget
->GetTypeId()==TYPEID_PLAYER
)
3536 pTarget
->SetFlag(PLAYER_FIELD_BYTES2
, 0x2000);
3538 // apply only if not in GM invisibility (and overwrite invisibility state)
3539 if (pTarget
->GetVisibility()!=VISIBILITY_OFF
)
3541 pTarget
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
3542 pTarget
->SetVisibility(VISIBILITY_GROUP_STEALTH
);
3545 // apply full stealth period bonuses only at first stealth aura in stack
3546 if(pTarget
->GetAurasByType(SPELL_AURA_MOD_STEALTH
).size()<=1)
3548 Unit::AuraList
const& mDummyAuras
= pTarget
->GetAurasByType(SPELL_AURA_DUMMY
);
3549 for(Unit::AuraList::const_iterator i
= mDummyAuras
.begin();i
!= mDummyAuras
.end(); ++i
)
3551 // Master of Subtlety
3552 if ((*i
)->GetSpellProto()->SpellIconID
== 2114)
3554 pTarget
->RemoveAurasDueToSpell(31666);
3555 int32 bp
= (*i
)->GetModifier()->m_amount
;
3556 pTarget
->CastCustomSpell(pTarget
,31665,&bp
,NULL
,NULL
,true);
3559 else if ((*i
)->GetId() == 58426 && pSpellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000400000))
3561 pTarget
->RemoveAurasDueToSpell(58428);
3562 pTarget
->CastSpell(pTarget
, 58427, true);
3570 // only at real aura remove of _last_ SPELL_AURA_MOD_STEALTH
3571 if (Real
&& !pTarget
->HasAuraType(SPELL_AURA_MOD_STEALTH
))
3573 // if no GM invisibility
3574 if(pTarget
->GetVisibility()!=VISIBILITY_OFF
)
3576 pTarget
->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP
);
3578 if (pTarget
->GetTypeId()==TYPEID_PLAYER
)
3579 pTarget
->RemoveFlag(PLAYER_FIELD_BYTES2
, 0x2000);
3581 // restore invisibility if any
3582 if (pTarget
->HasAuraType(SPELL_AURA_MOD_INVISIBILITY
))
3584 pTarget
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
3585 pTarget
->SetVisibility(VISIBILITY_GROUP_INVISIBILITY
);
3588 pTarget
->SetVisibility(VISIBILITY_ON
);
3591 // apply delayed talent bonus remover at last stealth aura remove
3592 Unit::AuraList
const& mDummyAuras
= pTarget
->GetAurasByType(SPELL_AURA_DUMMY
);
3593 for(Unit::AuraList::const_iterator i
= mDummyAuras
.begin();i
!= mDummyAuras
.end(); ++i
)
3595 // Master of Subtlety
3596 if ((*i
)->GetSpellProto()->SpellIconID
== 2114)
3597 pTarget
->CastSpell(pTarget
, 31666, true);
3599 else if ((*i
)->GetId() == 58426 && pSpellInfo
->SpellFamilyFlags
& UI64LIT(0x0000000000400000))
3600 pTarget
->CastSpell(pTarget
, 58428, true);
3606 void Aura::HandleInvisibility(bool apply
, bool Real
)
3610 m_target
->m_invisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3612 m_target
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
);
3614 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
3616 // apply glow vision
3617 m_target
->SetFlag(PLAYER_FIELD_BYTES2
,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
);
3621 // apply only if not in GM invisibility and not stealth
3622 if(m_target
->GetVisibility() == VISIBILITY_ON
)
3624 // Aura not added yet but visibility code expect temporary add aura
3625 m_target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
3626 m_target
->SetVisibility(VISIBILITY_GROUP_INVISIBILITY
);
3631 // recalculate value at modifier remove (current aura already removed)
3632 m_target
->m_invisibilityMask
= 0;
3633 Unit::AuraList
const& auras
= m_target
->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY
);
3634 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
3635 m_target
->m_invisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3637 // only at real aura remove and if not have different invisibility auras.
3638 if(Real
&& m_target
->m_invisibilityMask
== 0)
3640 // remove glow vision
3641 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3642 m_target
->RemoveFlag(PLAYER_FIELD_BYTES2
,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
);
3644 // apply only if not in GM invisibility & not stealthed while invisible
3645 if(m_target
->GetVisibility() != VISIBILITY_OFF
)
3647 // if have stealth aura then already have stealth visibility
3648 if(!m_target
->HasAuraType(SPELL_AURA_MOD_STEALTH
))
3649 m_target
->SetVisibility(VISIBILITY_ON
);
3655 void Aura::HandleInvisibilityDetect(bool apply
, bool Real
)
3659 m_target
->m_detectInvisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3663 // recalculate value at modifier remove (current aura already removed)
3664 m_target
->m_detectInvisibilityMask
= 0;
3665 Unit::AuraList
const& auras
= m_target
->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION
);
3666 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
3667 m_target
->m_detectInvisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3669 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
3670 ObjectAccessor::UpdateVisibilityForPlayer((Player
*)m_target
);
3673 void Aura::HandleAuraModRoot(bool apply
, bool Real
)
3675 // only at real add/remove aura
3681 // Frost root aura -> freeze/unfreeze target
3682 if (GetSpellSchoolMask(m_spellProto
) & SPELL_SCHOOL_MASK_FROST
)
3683 m_target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
3685 m_target
->addUnitState(UNIT_STAT_ROOT
);
3686 m_target
->SetUInt64Value (UNIT_FIELD_TARGET
, 0);
3687 // probably wrong (this add skinable flag)
3688 // TODO: find correct flag
3689 //m_target->SetFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
3691 //Save last orientation
3692 if( m_target
->getVictim() )
3693 m_target
->SetOrientation(m_target
->GetAngle(m_target
->getVictim()));
3695 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3697 WorldPacket
data(SMSG_FORCE_MOVE_ROOT
, 10);
3698 data
.append(m_target
->GetPackGUID());
3700 m_target
->SendMessageToSet(&data
, true);
3702 //Clear unit movement flags
3703 ((Player
*)m_target
)->m_movementInfo
.flags
= 0;
3706 ((Creature
*)m_target
)->StopMoving();
3710 // Frost root aura -> freeze/unfreeze target
3711 if (GetSpellSchoolMask(m_spellProto
) & SPELL_SCHOOL_MASK_FROST
)
3713 bool found_another
= false;
3714 for(AuraType
const* itr
= &frozenAuraTypes
[0]; *itr
!= SPELL_AURA_NONE
; ++itr
)
3716 Unit::AuraList
const& auras
= m_target
->GetAurasByType(*itr
);
3717 for(Unit::AuraList::const_iterator i
= auras
.begin(); i
!= auras
.end(); ++i
)
3719 if( GetSpellSchoolMask((*i
)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST
)
3721 found_another
= true;
3730 m_target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
3733 // Real remove called after current aura remove from lists, check if other similar auras active
3734 if(m_target
->HasAuraType(SPELL_AURA_MOD_ROOT
))
3737 m_target
->clearUnitState(UNIT_STAT_ROOT
);
3738 // probably wrong (this add skinable flag)
3739 // TODO: find correct flag
3740 //m_target->RemoveFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
3742 if(!m_target
->hasUnitState(UNIT_STAT_STUNNED
)) // prevent allow move if have also stun effect
3744 if(m_target
->getVictim() && m_target
->isAlive())
3745 m_target
->SetUInt64Value (UNIT_FIELD_TARGET
, m_target
->getVictim()->GetGUID() );
3747 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3749 WorldPacket
data(SMSG_FORCE_MOVE_UNROOT
, 10);
3750 data
.append(m_target
->GetPackGUID());
3752 m_target
->SendMessageToSet(&data
, true);
3758 void Aura::HandleAuraModSilence(bool apply
, bool Real
)
3760 // only at real add/remove aura
3766 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_SILENCED
);
3767 // Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE
3768 for (uint32 i
= CURRENT_MELEE_SPELL
; i
< CURRENT_MAX_SPELL
;i
++)
3769 if (m_target
->m_currentSpells
[i
] && m_target
->m_currentSpells
[i
]->m_spellInfo
->PreventionType
== SPELL_PREVENTION_TYPE_SILENCE
)
3770 m_target
->InterruptSpell(i
, false); // Stop spells on prepare or casting state
3774 // Real remove called after current aura remove from lists, check if other similar auras active
3775 if(m_target
->HasAuraType(SPELL_AURA_MOD_SILENCE
))
3778 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_SILENCED
);
3782 void Aura::HandleModThreat(bool apply
, bool Real
)
3784 // only at real add/remove aura
3788 if(!m_target
->isAlive())
3791 Unit
* caster
= GetCaster();
3793 if(!caster
|| !caster
->isAlive())
3802 level_diff
= m_target
->getLevel() - 60;
3805 // The Eye of Diminution
3807 level_diff
= m_target
->getLevel() - 60;
3812 m_modifier
.m_amount
+= multiplier
* level_diff
;
3814 for(int8 x
=0;x
< MAX_SPELL_SCHOOL
;x
++)
3816 if(m_modifier
.m_miscvalue
& int32(1<<x
))
3818 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3819 ApplyPercentModFloatVar(m_target
->m_threatModifier
[x
], m_positive
? m_modifier
.m_amount
: -m_modifier
.m_amount
, apply
);
3824 void Aura::HandleAuraModTotalThreat(bool apply
, bool Real
)
3826 // only at real add/remove aura
3830 if(!m_target
->isAlive() || m_target
->GetTypeId()!= TYPEID_PLAYER
)
3833 Unit
* caster
= GetCaster();
3835 if(!caster
|| !caster
->isAlive())
3838 float threatMod
= 0.0f
;
3840 threatMod
= float(m_modifier
.m_amount
);
3842 threatMod
= float(-m_modifier
.m_amount
);
3844 m_target
->getHostilRefManager().threatAssist(caster
, threatMod
);
3847 void Aura::HandleModTaunt(bool apply
, bool Real
)
3849 // only at real add/remove aura
3853 if(!m_target
->isAlive() || !m_target
->CanHaveThreatList())
3856 Unit
* caster
= GetCaster();
3858 if(!caster
|| !caster
->isAlive() || caster
->GetTypeId() != TYPEID_PLAYER
)
3862 m_target
->TauntApply(caster
);
3865 // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat
3866 m_target
->TauntFadeOut(caster
);
3870 /*********************************************************/
3871 /*** MODIFY SPEED ***/
3872 /*********************************************************/
3873 void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real
)
3875 // all applied/removed only at real aura add/remove
3879 m_target
->UpdateSpeed(MOVE_RUN
, true);
3882 void Aura::HandleAuraModIncreaseMountedSpeed(bool /*apply*/, bool Real
)
3884 // all applied/removed only at real aura add/remove
3888 m_target
->UpdateSpeed(MOVE_RUN
, true);
3891 void Aura::HandleAuraModIncreaseFlightSpeed(bool apply
, bool Real
)
3893 // all applied/removed only at real aura add/remove
3897 // Enable Fly mode for flying mounts
3898 if (m_modifier
.m_auraname
== SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
)
3902 data
.Initialize(SMSG_MOVE_SET_CAN_FLY
, 12);
3904 data
.Initialize(SMSG_MOVE_UNSET_CAN_FLY
, 12);
3905 data
.append(m_target
->GetPackGUID());
3906 data
<< uint32(0); // unknown
3907 m_target
->SendMessageToSet(&data
, true);
3909 //Players on flying mounts must be immune to polymorph
3910 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
3911 m_target
->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC
,MECHANIC_POLYMORPH
,apply
);
3913 // Dragonmaw Illusion (overwrite mount model, mounted aura already applied)
3914 if( apply
&& m_target
->HasAura(42016,0) && m_target
->GetMountID())
3915 m_target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
,16314);
3918 m_target
->UpdateSpeed(MOVE_FLIGHT
, true);
3921 void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real
)
3923 // all applied/removed only at real aura add/remove
3927 m_target
->UpdateSpeed(MOVE_SWIM
, true);
3930 void Aura::HandleAuraModDecreaseSpeed(bool /*apply*/, bool Real
)
3932 // all applied/removed only at real aura add/remove
3936 m_target
->UpdateSpeed(MOVE_RUN
, true);
3937 m_target
->UpdateSpeed(MOVE_SWIM
, true);
3938 m_target
->UpdateSpeed(MOVE_FLIGHT
, true);
3941 void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real
)
3943 // all applied/removed only at real aura add/remove
3947 m_target
->UpdateSpeed(MOVE_RUN
, true);
3948 m_target
->UpdateSpeed(MOVE_SWIM
, true);
3949 m_target
->UpdateSpeed(MOVE_FLIGHT
, true);
3952 /*********************************************************/
3954 /*********************************************************/
3956 void Aura::HandleModMechanicImmunity(bool apply
, bool /*Real*/)
3958 // cache values in local vars for prevent access to possible deleted aura data
3959 SpellEntry
const* spellInfo
= GetSpellProto();
3960 uint32 misc
= m_modifier
.m_miscvalue
;
3961 Unit
* target
= m_target
;
3963 if(apply
&& spellInfo
->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
3965 uint32 mechanic
= 1 << m_modifier
.m_miscvalue
;
3967 //immune movement impairment and loss of control
3968 if(GetId()==42292 || GetId()==59752)
3969 mechanic
=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK
;
3971 Unit::AuraMap
& Auras
= target
->GetAuras();
3972 for(Unit::AuraMap::iterator iter
= Auras
.begin(), next
; iter
!= Auras
.end(); iter
= next
)
3976 SpellEntry
const *spell
= iter
->second
->GetSpellProto();
3977 if (!( spell
->Attributes
& SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY
) && // spells unaffected by invulnerability
3978 spell
->Id
!= spellInfo
->Id
)
3980 //check for mechanic mask
3981 if(GetSpellMechanicMask(spell
, iter
->second
->GetEffIndex()) & mechanic
)
3983 target
->RemoveAurasDueToSpell(spell
->Id
);
3987 next
= Auras
.begin();
3993 target
->ApplySpellImmune(spellInfo
->Id
,IMMUNITY_MECHANIC
,misc
,apply
);
3996 if (spellInfo
->SpellFamilyName
== SPELLFAMILY_HUNTER
&& spellInfo
->SpellIconID
== 1680)
3998 // The Beast Within cast on owner if talent present
3999 if (Unit
* owner
= target
->GetOwner())
4002 Unit::AuraList
const& dummyAuras
= owner
->GetAurasByType(SPELL_AURA_DUMMY
);
4003 for(Unit::AuraList::const_iterator i
= dummyAuras
.begin(); i
!= dummyAuras
.end(); ++i
)
4005 if ((*i
)->GetSpellProto()->SpellIconID
== 2229)
4008 owner
->CastSpell(owner
, 34471, true, 0, this);
4010 owner
->RemoveAurasDueToSpell(34471);
4017 // The Beast Within and Bestial Wrath - immunity
4018 if (spellInfo
->Id
== 19574 || spellInfo
->Id
== 34471)
4022 target
->CastSpell(target
, 24395, true);
4023 target
->CastSpell(target
, 24396, true);
4024 target
->CastSpell(target
, 24397, true);
4025 target
->CastSpell(target
, 26592, true);
4029 target
->RemoveAurasDueToSpell(24395);
4030 target
->RemoveAurasDueToSpell(24396);
4031 target
->RemoveAurasDueToSpell(24397);
4032 target
->RemoveAurasDueToSpell(26592);
4037 //this method is called whenever we add / remove aura which gives m_target some imunity to some spell effect
4038 void Aura::HandleAuraModEffectImmunity(bool apply
, bool /*Real*/)
4040 // when removing flag aura, handle flag drop
4041 if( !apply
&& m_target
->GetTypeId() == TYPEID_PLAYER
4042 && (GetSpellProto()->AuraInterruptFlags
& AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
) )
4044 if( BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround() )
4045 bg
->EventPlayerDroppedFlag(((Player
*)m_target
));
4048 m_target
->ApplySpellImmune(GetId(), IMMUNITY_EFFECT
, m_modifier
.m_miscvalue
, apply
);
4051 void Aura::HandleAuraModStateImmunity(bool apply
, bool Real
)
4053 if(apply
&& Real
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
4055 Unit::AuraList
const& auraList
= m_target
->GetAurasByType(AuraType(m_modifier
.m_miscvalue
));
4056 for(Unit::AuraList::const_iterator itr
= auraList
.begin(); itr
!= auraList
.end();)
4058 if (auraList
.front() != this) // skip itself aura (it already added)
4060 m_target
->RemoveAurasDueToSpell(auraList
.front()->GetId());
4061 itr
= auraList
.begin();
4068 m_target
->ApplySpellImmune(GetId(), IMMUNITY_STATE
, m_modifier
.m_miscvalue
, apply
);
4071 void Aura::HandleAuraModSchoolImmunity(bool apply
, bool Real
)
4073 m_target
->ApplySpellImmune(GetId(), IMMUNITY_SCHOOL
, m_modifier
.m_miscvalue
, apply
);
4075 // remove all flag auras (they are positive, but they must be removed when you are immune)
4076 if( this->GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
4077 && this->GetSpellProto()->AttributesEx2
& SPELL_ATTR_EX2_DAMAGE_REDUCED_SHIELD
)
4078 m_target
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
);
4080 // TODO: optimalize this cycle - use RemoveAurasWithInterruptFlags call or something else
4082 && GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
4083 && IsPositiveSpell(GetId()) ) //Only positive immunity removes auras
4085 uint32 school_mask
= m_modifier
.m_miscvalue
;
4086 Unit::AuraMap
& Auras
= m_target
->GetAuras();
4087 for(Unit::AuraMap::iterator iter
= Auras
.begin(), next
; iter
!= Auras
.end(); iter
= next
)
4091 SpellEntry
const *spell
= iter
->second
->GetSpellProto();
4092 if((GetSpellSchoolMask(spell
) & school_mask
)//Check for school mask
4093 && !( spell
->Attributes
& SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY
) //Spells unaffected by invulnerability
4094 && !iter
->second
->IsPositive() //Don't remove positive spells
4095 && spell
->Id
!= GetId() ) //Don't remove self
4097 m_target
->RemoveAurasDueToSpell(spell
->Id
);
4101 next
= Auras
.begin();
4105 if( Real
&& GetSpellProto()->Mechanic
== MECHANIC_BANISH
)
4108 m_target
->addUnitState(UNIT_STAT_ISOLATED
);
4110 m_target
->clearUnitState(UNIT_STAT_ISOLATED
);
4114 void Aura::HandleAuraModDmgImmunity(bool apply
, bool /*Real*/)
4116 m_target
->ApplySpellImmune(GetId(), IMMUNITY_DAMAGE
, m_modifier
.m_miscvalue
, apply
);
4119 void Aura::HandleAuraModDispelImmunity(bool apply
, bool Real
)
4121 // all applied/removed only at real aura add/remove
4125 m_target
->ApplySpellDispelImmunity(m_spellProto
, DispelType(m_modifier
.m_miscvalue
), apply
);
4128 void Aura::HandleAuraProcTriggerSpell(bool apply
, bool Real
)
4135 // some spell have charges by functionality not have its in spell data
4138 case 28200: // Ascendance (Talisman of Ascendance trinket)
4146 void Aura::HandleAuraModStalked(bool apply
, bool /*Real*/)
4148 // used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND
4150 m_target
->SetFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_TRACK_UNIT
);
4152 m_target
->RemoveFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_TRACK_UNIT
);
4155 /*********************************************************/
4157 /*********************************************************/
4159 void Aura::HandlePeriodicTriggerSpell(bool apply
, bool /*Real*/)
4161 m_isPeriodic
= apply
;
4162 if (m_spellProto
->Id
== 66 && !apply
)
4164 if (m_removeMode
== AURA_REMOVE_BY_DEFAULT
&& m_duration
<=0)
4165 m_target
->CastSpell(m_target
, 32612, true, NULL
, this);
4169 void Aura::HandlePeriodicTriggerSpellWithValue(bool apply
, bool /*Real*/)
4171 m_isPeriodic
= apply
;
4174 void Aura::HandlePeriodicEnergize(bool apply
, bool Real
)
4179 m_isPeriodic
= apply
;
4181 // Replenishment (0.25% from max)
4182 // Infinite Replenishment
4183 if (GetId() == 57669 ||
4185 m_modifier
.m_amount
= m_target
->GetMaxPower(POWER_MANA
) * 25 / 10000;
4188 void Aura::HandleAuraPowerBurn(bool apply
, bool /*Real*/)
4190 m_isPeriodic
= apply
;
4193 void Aura::HandleAuraPeriodicDummy(bool apply
, bool Real
)
4195 // spells required only Real aura add/remove
4199 // For prevent double apply bonuses
4200 bool loading
= (m_target
->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)m_target
)->GetSession()->PlayerLoading());
4202 Unit
* caster
= GetCaster();
4204 SpellEntry
const*spell
= GetSpellProto();
4205 switch( spell
->SpellFamilyName
)
4207 case SPELLFAMILY_ROGUE
:
4213 // Master of Subtlety
4214 case 31666: m_target
->RemoveAurasDueToSpell(31665); break;
4216 case 58428: m_target
->RemoveAurasDueToSpell(58427); break;
4221 case SPELLFAMILY_HUNTER
:
4224 if (apply
&& !loading
&& caster
)
4225 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 8 / 100);
4230 m_isPeriodic
= apply
;
4233 void Aura::HandlePeriodicHeal(bool apply
, bool /*Real*/)
4235 m_isPeriodic
= apply
;
4238 void Aura::HandlePeriodicDamage(bool apply
, bool Real
)
4240 // spells required only Real aura add/remove
4244 m_isPeriodic
= apply
;
4246 // For prevent double apply bonuses
4247 bool loading
= (m_target
->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)m_target
)->GetSession()->PlayerLoading());
4249 // Custom damage calculation after
4255 Unit
*caster
= GetCaster();
4259 switch (m_spellProto
->SpellFamilyName
)
4261 case SPELLFAMILY_GENERIC
:
4264 if ( m_spellProto
->SpellIconID
== 147 && m_spellProto
->SpellVisual
[0] == 0 )
4266 // $AP*0.18/6 bonus per tick
4267 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 3 / 100);
4272 case SPELLFAMILY_WARRIOR
:
4275 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000020))
4277 // $0.2*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick
4278 float ap
= caster
->GetTotalAttackPowerValue(BASE_ATTACK
);
4279 int32 mws
= caster
->GetAttackTime(BASE_ATTACK
);
4280 float mwb_min
= caster
->GetWeaponDamageRange(BASE_ATTACK
,MINDAMAGE
);
4281 float mwb_max
= caster
->GetWeaponDamageRange(BASE_ATTACK
,MAXDAMAGE
);
4282 m_modifier
.m_amount
+=int32(((mwb_min
+mwb_max
)/2+ap
*mws
/14000)*0.2f
);
4287 case SPELLFAMILY_DRUID
:
4290 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000001000))
4292 // $AP*0.06 bonus per tick
4293 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 6 / 100);
4297 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x000000010000000000))
4299 // $AP*0.05/5 bonus per tick
4300 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) / 100);
4304 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x000000000000800000))
4307 if (caster
->GetTypeId() != TYPEID_PLAYER
)
4310 uint8 cp
= ((Player
*)caster
)->GetComboPoints();
4312 // Idol of Feral Shadows. Cant be handled as SpellMod in SpellAura:Dummy due its dependency from CPs
4313 Unit::AuraList
const& dummyAuras
= caster
->GetAurasByType(SPELL_AURA_DUMMY
);
4314 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
4316 if((*itr
)->GetId()==34241)
4318 m_modifier
.m_amount
+= cp
* (*itr
)->GetModifier()->m_amount
;
4322 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * cp
/ 100);
4326 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x1000000000000000))
4329 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 15 / 100);
4334 case SPELLFAMILY_ROGUE
:
4337 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x000000000000100000))
4339 if (caster
->GetTypeId() != TYPEID_PLAYER
)
4341 //1 point : ${($m1+$b1*1+0.015*$AP)*4} damage over 8 secs
4342 //2 points: ${($m1+$b1*2+0.024*$AP)*5} damage over 10 secs
4343 //3 points: ${($m1+$b1*3+0.03*$AP)*6} damage over 12 secs
4344 //4 points: ${($m1+$b1*4+0.03428571*$AP)*7} damage over 14 secs
4345 //5 points: ${($m1+$b1*5+0.0375*$AP)*8} damage over 16 secs
4346 float AP_per_combo
[6] = {0.0f
, 0.015f
, 0.024f
, 0.03f
, 0.03428571f
, 0.0375f
};
4347 uint8 cp
= ((Player
*)caster
)->GetComboPoints();
4349 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * AP_per_combo
[cp
]);
4353 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x000000000000000100))
4355 // $AP*0.07 bonus per tick
4356 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 7 / 100);
4360 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000010000))
4362 // 0.08*$AP / 4 * amount of stack
4363 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 2 * GetStackAmount() / 100);
4368 case SPELLFAMILY_HUNTER
:
4371 if (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000004000))
4373 // $RAP*0.1/5 bonus per tick
4374 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 10 / 500);
4378 if ((m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000000000000004)) && m_spellProto
->SpellIconID
== 678)
4380 // $RAP*0.1/5 bonus per tick
4381 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 10 / 500);
4390 // remove time effects
4393 // Parasitic Shadowfiend - handle summoning of two Shadowfiends on DoT expire
4394 if(m_spellProto
->Id
== 41917)
4395 m_target
->CastSpell(m_target
, 41915, true);
4399 void Aura::HandlePeriodicDamagePCT(bool apply
, bool /*Real*/)
4401 m_isPeriodic
= apply
;
4404 void Aura::HandlePeriodicLeech(bool apply
, bool /*Real*/)
4406 m_isPeriodic
= apply
;
4409 void Aura::HandlePeriodicManaLeech(bool apply
, bool /*Real*/)
4411 m_isPeriodic
= apply
;
4414 void Aura::HandlePeriodicHealthFunnel(bool apply
, bool /*Real*/)
4416 m_isPeriodic
= apply
;
4419 /*********************************************************/
4420 /*** MODIFY STATS ***/
4421 /*********************************************************/
4423 /********************************/
4424 /*** RESISTANCE ***/
4425 /********************************/
4427 void Aura::HandleAuraModResistanceExclusive(bool apply
, bool /*Real*/)
4429 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
4431 if(m_modifier
.m_miscvalue
& int32(1<<x
))
4433 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), BASE_VALUE
, float(m_modifier
.m_amount
), apply
);
4434 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4435 m_target
->ApplyResistanceBuffModsMod(SpellSchools(x
), m_positive
, m_modifier
.m_amount
, apply
);
4440 void Aura::HandleAuraModResistance(bool apply
, bool /*Real*/)
4442 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
4444 if(m_modifier
.m_miscvalue
& int32(1<<x
))
4446 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4447 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4448 m_target
->ApplyResistanceBuffModsMod(SpellSchools(x
), m_positive
, m_modifier
.m_amount
, apply
);
4453 void Aura::HandleAuraModBaseResistancePCT(bool apply
, bool /*Real*/)
4455 // only players have base stats
4456 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4458 //pets only have base armor
4459 if(((Creature
*)m_target
)->isPet() && (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
4460 m_target
->HandleStatModifier(UNIT_MOD_ARMOR
, BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4464 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
4466 if(m_modifier
.m_miscvalue
& int32(1<<x
))
4467 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4472 void Aura::HandleModResistancePercent(bool apply
, bool /*Real*/)
4474 for(int8 i
= SPELL_SCHOOL_NORMAL
; i
< MAX_SPELL_SCHOOL
; i
++)
4476 if(m_modifier
.m_miscvalue
& int32(1<<i
))
4478 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ i
), TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4479 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4481 m_target
->ApplyResistanceBuffModsPercentMod(SpellSchools(i
), true, m_modifier
.m_amount
, apply
);
4482 m_target
->ApplyResistanceBuffModsPercentMod(SpellSchools(i
), false, m_modifier
.m_amount
, apply
);
4488 void Aura::HandleModBaseResistance(bool apply
, bool /*Real*/)
4490 // only players have base stats
4491 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4493 //only pets have base stats
4494 if(((Creature
*)m_target
)->isPet() && (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
4495 m_target
->HandleStatModifier(UNIT_MOD_ARMOR
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4499 for(int i
= SPELL_SCHOOL_NORMAL
; i
< MAX_SPELL_SCHOOL
; i
++)
4500 if(m_modifier
.m_miscvalue
& (1<<i
))
4501 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ i
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4505 /********************************/
4507 /********************************/
4509 void Aura::HandleAuraModStat(bool apply
, bool /*Real*/)
4511 if (m_modifier
.m_miscvalue
< -2 || m_modifier
.m_miscvalue
> 4)
4513 sLog
.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ",GetId(),GetEffIndex(),m_modifier
.m_miscvalue
);
4517 for(int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; i
++)
4519 // -1 or -2 is all stats ( misc < -2 checked in function beginning )
4520 if (m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
== i
)
4522 //m_target->ApplyStatMod(Stats(i), m_modifier.m_amount,apply);
4523 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4524 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4525 m_target
->ApplyStatBuffMod(Stats(i
), m_modifier
.m_amount
, apply
);
4530 void Aura::HandleModPercentStat(bool apply
, bool /*Real*/)
4532 if (m_modifier
.m_miscvalue
< -1 || m_modifier
.m_miscvalue
> 4)
4534 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
4538 // only players have base stats
4539 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
4542 for (int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; ++i
)
4544 if(m_modifier
.m_miscvalue
== i
|| m_modifier
.m_miscvalue
== -1)
4545 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4549 void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool /*Real*/)
4551 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4554 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4555 // This information for client side use only
4556 // Recalculate bonus
4557 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4560 void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool /*Real*/)
4562 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4565 // Recalculate bonus
4566 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4569 void Aura::HandleAuraModDispelResist(bool apply
, bool Real
)
4574 if(GetId() == 33206)
4575 m_target
->CastSpell(m_target
, 44416, true, NULL
, this, GetCasterGUID());
4578 void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool /*Real*/)
4580 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4583 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4584 // This information for client side use only
4585 // Recalculate bonus
4586 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4589 void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool /*Real*/)
4591 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4594 // Recalculate bonus
4595 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4598 void Aura::HandleModHealingDone(bool /*apply*/, bool /*Real*/)
4600 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4602 // implemented in Unit::SpellHealingBonus
4603 // this information is for client side only
4604 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4607 void Aura::HandleModTotalPercentStat(bool apply
, bool /*Real*/)
4609 if (m_modifier
.m_miscvalue
< -1 || m_modifier
.m_miscvalue
> 4)
4611 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
4615 //save current and max HP before applying aura
4616 uint32 curHPValue
= m_target
->GetHealth();
4617 uint32 maxHPValue
= m_target
->GetMaxHealth();
4619 for (int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; i
++)
4621 if(m_modifier
.m_miscvalue
== i
|| m_modifier
.m_miscvalue
== -1)
4623 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4624 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4625 m_target
->ApplyStatPercentBuffMod(Stats(i
), m_modifier
.m_amount
, apply
);
4629 //recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag)
4630 if ((m_modifier
.m_miscvalue
== STAT_STAMINA
) && (maxHPValue
> 0) && (m_spellProto
->Attributes
& 0x10))
4632 // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed
4633 uint32 newHPValue
= (m_target
->GetMaxHealth() * curHPValue
) / maxHPValue
;
4634 m_target
->SetHealth(newHPValue
);
4638 void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool /*Real*/)
4640 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4643 if(m_modifier
.m_miscvalue
!= SPELL_SCHOOL_MASK_NORMAL
)
4645 // support required adding replace UpdateArmor by loop by UpdateResistence at intellect update
4646 // and include in UpdateResistence same code as in UpdateArmor for aura mod apply.
4647 sLog
.outError("Aura SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT(182) need adding support for non-armor resistances!");
4651 // Recalculate Armor
4652 m_target
->UpdateArmor();
4655 /********************************/
4656 /*** HEAL & ENERGIZE ***/
4657 /********************************/
4658 void Aura::HandleAuraModTotalHealthPercentRegen(bool apply
, bool /*Real*/)
4660 m_isPeriodic
= apply
;
4663 void Aura::HandleAuraModTotalManaPercentRegen(bool apply
, bool /*Real*/)
4665 if(m_modifier
.periodictime
== 0)
4666 m_modifier
.periodictime
= 1000;
4668 m_periodicTimer
= m_modifier
.periodictime
;
4669 m_isPeriodic
= apply
;
4672 void Aura::HandleModRegen(bool apply
, bool /*Real*/) // eating
4674 if(m_modifier
.periodictime
== 0)
4675 m_modifier
.periodictime
= 5000;
4677 m_periodicTimer
= 5000;
4678 m_isPeriodic
= apply
;
4681 void Aura::HandleModPowerRegen(bool apply
, bool Real
) // drinking
4686 Powers pt
= m_target
->getPowerType();
4687 if(m_modifier
.periodictime
== 0)
4689 // Anger Management (only spell use this aura for rage)
4690 if (pt
== POWER_RAGE
)
4691 m_modifier
.periodictime
= 3000;
4693 m_modifier
.periodictime
= 2000;
4696 m_periodicTimer
= 5000;
4698 if (m_target
->GetTypeId() == TYPEID_PLAYER
&& m_modifier
.m_miscvalue
== POWER_MANA
)
4699 ((Player
*)m_target
)->UpdateManaRegen();
4701 m_isPeriodic
= apply
;
4704 void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real
)
4706 // spells required only Real aura add/remove
4710 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
4713 // Update manaregen value
4714 if (m_modifier
.m_miscvalue
== POWER_MANA
)
4715 ((Player
*)m_target
)->UpdateManaRegen();
4718 void Aura::HandleModManaRegen(bool /*apply*/, bool Real
)
4720 // spells required only Real aura add/remove
4724 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
4727 //Note: an increase in regen does NOT cause threat.
4728 ((Player
*)m_target
)->UpdateManaRegen();
4731 void Aura::HandleComprehendLanguage(bool apply
, bool /*Real*/)
4734 m_target
->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_COMPREHEND_LANG
);
4736 m_target
->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_COMPREHEND_LANG
);
4739 void Aura::HandleAuraModIncreaseHealth(bool apply
, bool Real
)
4741 // Special case with temporary increase max/current health
4744 case 12976: // Warrior Last Stand triggered spell
4745 case 28726: // Nightmare Seed ( Nightmare Seed )
4746 case 34511: // Valor (Bulwark of Kings, Bulwark of the Ancient Kings)
4747 case 44055: // Tremendous Fortitude (Battlemaster's Alacrity)
4748 case 50322: // Survival Instincts
4754 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4755 m_target
->ModifyHealth(m_modifier
.m_amount
);
4759 if (int32(m_target
->GetHealth()) > m_modifier
.m_amount
)
4760 m_target
->ModifyHealth(-m_modifier
.m_amount
);
4762 m_target
->SetHealth(1);
4763 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4771 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4774 void Aura::HandleAuraModIncreaseMaxHealth(bool apply
, bool /*Real*/)
4776 uint32 oldhealth
= m_target
->GetHealth();
4777 double healthPercentage
= (double)oldhealth
/ (double)m_target
->GetMaxHealth();
4779 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4781 // refresh percentage
4784 uint32 newhealth
= uint32(ceil((double)m_target
->GetMaxHealth() * healthPercentage
));
4788 m_target
->SetHealth(newhealth
);
4792 void Aura::HandleAuraModIncreaseEnergy(bool apply
, bool /*Real*/)
4794 Powers powerType
= m_target
->getPowerType();
4795 if(int32(powerType
) != m_modifier
.m_miscvalue
)
4798 UnitMods unitMod
= UnitMods(UNIT_MOD_POWER_START
+ powerType
);
4800 m_target
->HandleStatModifier(unitMod
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4803 void Aura::HandleAuraModIncreaseEnergyPercent(bool apply
, bool /*Real*/)
4805 Powers powerType
= m_target
->getPowerType();
4806 if(int32(powerType
) != m_modifier
.m_miscvalue
)
4809 UnitMods unitMod
= UnitMods(UNIT_MOD_POWER_START
+ powerType
);
4811 m_target
->HandleStatModifier(unitMod
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4814 void Aura::HandleAuraModIncreaseHealthPercent(bool apply
, bool /*Real*/)
4816 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4819 void Aura::HandleAuraIncreaseBaseHealthPercent(bool apply
, bool /*Real*/)
4821 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4824 /********************************/
4826 /********************************/
4828 void Aura::HandleAuraModParryPercent(bool /*apply*/, bool /*Real*/)
4830 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4833 ((Player
*)m_target
)->UpdateParryPercentage();
4836 void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool /*Real*/)
4838 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4841 ((Player
*)m_target
)->UpdateDodgePercentage();
4842 //sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount));
4845 void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool /*Real*/)
4847 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4850 ((Player
*)m_target
)->UpdateBlockPercentage();
4851 //sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount));
4854 void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real
)
4856 // spells required only Real aura add/remove
4860 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4863 ((Player
*)m_target
)->UpdateManaRegen();
4866 void Aura::HandleAuraModCritPercent(bool apply
, bool Real
)
4868 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4871 // apply item specific bonuses for already equipped weapon
4874 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
4875 if(Item
* pItem
= ((Player
*)m_target
)->GetWeaponForAttack(WeaponAttackType(i
)))
4876 ((Player
*)m_target
)->_ApplyWeaponDependentAuraCritMod(pItem
, WeaponAttackType(i
), this, apply
);
4879 // mods must be applied base at equipped weapon class and subclass comparison
4880 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
4881 // m_modifier.m_miscvalue comparison with item generated damage types
4883 if (GetSpellProto()->EquippedItemClass
== -1)
4885 ((Player
*)m_target
)->HandleBaseModValue(CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
4886 ((Player
*)m_target
)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
4887 ((Player
*)m_target
)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
4891 // done in Player::_ApplyWeaponDependentAuraMods
4895 void Aura::HandleModHitChance(bool apply
, bool /*Real*/)
4897 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4899 ((Player
*)m_target
)->UpdateMeleeHitChances();
4900 ((Player
*)m_target
)->UpdateRangedHitChances();
4904 m_target
->m_modMeleeHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
4905 m_target
->m_modRangedHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
4909 void Aura::HandleModSpellHitChance(bool apply
, bool /*Real*/)
4911 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4913 ((Player
*)m_target
)->UpdateSpellHitChances();
4917 m_target
->m_modSpellHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
4921 void Aura::HandleModSpellCritChance(bool apply
, bool Real
)
4923 // spells required only Real aura add/remove
4927 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4929 ((Player
*)m_target
)->UpdateAllSpellCritChances();
4933 m_target
->m_baseSpellCritChance
+= apply
? m_modifier
.m_amount
:(-m_modifier
.m_amount
);
4937 void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real
)
4939 // spells required only Real aura add/remove
4943 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4946 for(int school
= SPELL_SCHOOL_NORMAL
; school
< MAX_SPELL_SCHOOL
; ++school
)
4947 if (m_modifier
.m_miscvalue
& (1<<school
))
4948 ((Player
*)m_target
)->UpdateSpellCritChance(school
);
4951 /********************************/
4952 /*** ATTACK SPEED ***/
4953 /********************************/
4955 void Aura::HandleModCastingSpeed(bool apply
, bool /*Real*/)
4957 m_target
->ApplyCastTimePercentMod(m_modifier
.m_amount
,apply
);
4960 void Aura::HandleModMeleeRangedSpeedPct(bool apply
, bool /*Real*/)
4962 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
, m_modifier
.m_amount
, apply
);
4963 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
, m_modifier
.m_amount
, apply
);
4964 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
4967 void Aura::HandleModCombatSpeedPct(bool apply
, bool /*Real*/)
4969 m_target
->ApplyCastTimePercentMod(m_modifier
.m_amount
, apply
);
4970 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
, m_modifier
.m_amount
, apply
);
4971 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
, m_modifier
.m_amount
, apply
);
4972 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
4975 void Aura::HandleModAttackSpeed(bool apply
, bool /*Real*/)
4977 if(!m_target
->isAlive() )
4980 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
,m_modifier
.m_amount
,apply
);
4983 void Aura::HandleHaste(bool apply
, bool /*Real*/)
4985 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
, m_modifier
.m_amount
, apply
);
4986 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
, m_modifier
.m_amount
, apply
);
4987 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
4990 void Aura::HandleAuraModRangedHaste(bool apply
, bool /*Real*/)
4992 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
4995 void Aura::HandleRangedAmmoHaste(bool apply
, bool /*Real*/)
4997 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4999 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
,m_modifier
.m_amount
, apply
);
5002 /********************************/
5003 /*** ATTACK POWER ***/
5004 /********************************/
5006 void Aura::HandleAuraModAttackPower(bool apply
, bool /*Real*/)
5008 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5011 void Aura::HandleAuraModRangedAttackPower(bool apply
, bool /*Real*/)
5013 if((m_target
->getClassMask() & CLASSMASK_WAND_USERS
)!=0)
5016 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5019 void Aura::HandleAuraModAttackPowerPercent(bool apply
, bool /*Real*/)
5021 //UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1
5022 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5025 void Aura::HandleAuraModRangedAttackPowerPercent(bool apply
, bool /*Real*/)
5027 if((m_target
->getClassMask() & CLASSMASK_WAND_USERS
)!=0)
5030 //UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1
5031 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5034 void Aura::HandleAuraModRangedAttackPowerOfStatPercent(bool /*apply*/, bool Real
)
5036 // spells required only Real aura add/remove
5040 // Recalculate bonus
5041 if(m_target
->GetTypeId() == TYPEID_PLAYER
&& !(m_target
->getClassMask() & CLASSMASK_WAND_USERS
))
5042 ((Player
*)m_target
)->UpdateAttackPowerAndDamage(true);
5045 void Aura::HandleAuraModAttackPowerOfStatPercent(bool /*apply*/, bool Real
)
5047 // spells required only Real aura add/remove
5051 // Recalculate bonus
5052 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5053 ((Player
*)m_target
)->UpdateAttackPowerAndDamage(false);
5056 /********************************/
5057 /*** DAMAGE BONUS ***/
5058 /********************************/
5059 void Aura::HandleModDamageDone(bool apply
, bool Real
)
5061 // apply item specific bonuses for already equipped weapon
5062 if(Real
&& m_target
->GetTypeId() == TYPEID_PLAYER
)
5064 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
5065 if(Item
* pItem
= ((Player
*)m_target
)->GetWeaponForAttack(WeaponAttackType(i
)))
5066 ((Player
*)m_target
)->_ApplyWeaponDependentAuraDamageMod(pItem
, WeaponAttackType(i
), this, apply
);
5069 // m_modifier.m_miscvalue is bitmask of spell schools
5070 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5071 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wands
5072 // 127 - full bitmask any damages
5074 // mods must be applied base at equipped weapon class and subclass comparison
5075 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5076 // m_modifier.m_miscvalue comparison with item generated damage types
5078 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
) != 0)
5080 // apply generic physical damage bonuses including wand case
5081 if (GetSpellProto()->EquippedItemClass
== -1 || m_target
->GetTypeId() != TYPEID_PLAYER
)
5083 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5084 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5085 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5089 // done in Player::_ApplyWeaponDependentAuraMods
5092 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5095 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS
, m_modifier
.m_amount
, apply
);
5097 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG
, m_modifier
.m_amount
, apply
);
5101 // Skip non magic case for speedup
5102 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_MAGIC
) == 0)
5105 if( GetSpellProto()->EquippedItemClass
!= -1 || GetSpellProto()->EquippedItemInventoryTypeMask
!= 0 )
5107 // wand magic case (skip generic to all item spell bonuses)
5108 // done in Player::_ApplyWeaponDependentAuraMods
5110 // Skip item specific requirements for not wand magic damage
5114 // Magic damage modifiers implemented in Unit::SpellDamageBonus
5115 // This information for client side use only
5116 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5120 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; ++i
)
5122 if((m_modifier
.m_miscvalue
& (1<<i
)) != 0)
5123 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS
+ i
, m_modifier
.m_amount
, apply
);
5128 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; ++i
)
5130 if((m_modifier
.m_miscvalue
& (1<<i
)) != 0)
5131 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG
+ i
, m_modifier
.m_amount
, apply
);
5134 Pet
* pet
= m_target
->GetPet();
5136 pet
->UpdateAttackPowerAndDamage();
5140 void Aura::HandleModDamagePercentDone(bool apply
, bool Real
)
5142 sLog
.outDebug("AURA MOD DAMAGE type:%u negative:%u", m_modifier
.m_miscvalue
, m_positive
? 0 : 1);
5144 // apply item specific bonuses for already equipped weapon
5145 if(Real
&& m_target
->GetTypeId() == TYPEID_PLAYER
)
5147 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
5148 if(Item
* pItem
= ((Player
*)m_target
)->GetWeaponForAttack(WeaponAttackType(i
)))
5149 ((Player
*)m_target
)->_ApplyWeaponDependentAuraDamageMod(pItem
, WeaponAttackType(i
), this, apply
);
5152 // m_modifier.m_miscvalue is bitmask of spell schools
5153 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5154 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wand
5155 // 127 - full bitmask any damages
5157 // mods must be applied base at equipped weapon class and subclass comparison
5158 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5159 // m_modifier.m_miscvalue comparison with item generated damage types
5161 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
) != 0)
5163 // apply generic physical damage bonuses including wand case
5164 if (GetSpellProto()->EquippedItemClass
== -1 || m_target
->GetTypeId() != TYPEID_PLAYER
)
5166 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5167 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5168 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5172 // done in Player::_ApplyWeaponDependentAuraMods
5174 // For show in client
5175 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5176 m_target
->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT
, m_modifier
.m_amount
/100.0f
, apply
);
5179 // Skip non magic case for speedup
5180 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_MAGIC
) == 0)
5183 if( GetSpellProto()->EquippedItemClass
!= -1 || GetSpellProto()->EquippedItemInventoryTypeMask
!= 0 )
5185 // wand magic case (skip generic to all item spell bonuses)
5186 // done in Player::_ApplyWeaponDependentAuraMods
5188 // Skip item specific requirements for not wand magic damage
5192 // Magic damage percent modifiers implemented in Unit::SpellDamageBonus
5193 // Send info to client
5194 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5195 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; ++i
)
5196 m_target
->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT
+ i
, m_modifier
.m_amount
/100.0f
, apply
);
5199 void Aura::HandleModOffhandDamagePercent(bool apply
, bool Real
)
5201 // spells required only Real aura add/remove
5205 sLog
.outDebug("AURA MOD OFFHAND DAMAGE");
5207 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5210 /********************************/
5211 /*** POWER COST ***/
5212 /********************************/
5214 void Aura::HandleModPowerCostPCT(bool apply
, bool Real
)
5216 // spells required only Real aura add/remove
5220 float amount
= m_modifier
.m_amount
/100.0f
;
5221 for(int i
= 0; i
< MAX_SPELL_SCHOOL
; ++i
)
5222 if(m_modifier
.m_miscvalue
& (1<<i
))
5223 m_target
->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER
+ i
, amount
, apply
);
5226 void Aura::HandleModPowerCost(bool apply
, bool Real
)
5228 // spells required only Real aura add/remove
5232 for(int i
= 0; i
< MAX_SPELL_SCHOOL
; ++i
)
5233 if(m_modifier
.m_miscvalue
& (1<<i
))
5234 m_target
->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER
+ i
, m_modifier
.m_amount
, apply
);
5237 void Aura::HandleNoReagentUseAura(bool /*Apply*/, bool Real
)
5239 // spells required only Real aura add/remove
5242 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5244 uint32 mask
[3] = {0, 0, 0};
5245 Unit::AuraList
const& noReagent
= m_target
->GetAurasByType(SPELL_AURA_NO_REAGENT_USE
);
5246 for(Unit::AuraList::const_iterator i
= noReagent
.begin(); i
!= noReagent
.end(); ++i
)
5248 uint32
const *ptr
= (*i
)->getAuraSpellClassMask();
5254 m_target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
+0, mask
[0]);
5255 m_target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
+1, mask
[1]);
5256 m_target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
+2, mask
[2]);
5259 /*********************************************************/
5261 /*********************************************************/
5263 void Aura::HandleShapeshiftBoosts(bool apply
)
5266 uint32 spellId2
= 0;
5267 uint32 HotWSpellId
= 0;
5269 switch(GetModifier()->m_miscvalue
)
5273 HotWSpellId
= 24900;
5288 HotWSpellId
= 24899;
5293 HotWSpellId
= 24899;
5295 case FORM_BATTLESTANCE
:
5298 case FORM_DEFENSIVESTANCE
:
5301 case FORM_BERSERKERSTANCE
:
5306 // aura from effect trigger spell
5313 case FORM_FLIGHT_EPIC
:
5317 case FORM_METAMORPHOSIS
:
5321 case FORM_SPIRITOFREDEMPTION
:
5323 spellId2
= 27795; // must be second, this important at aura remove to prevent to early iterator invalidation.
5325 case FORM_GHOSTWOLF
:
5330 case FORM_CREATURECAT
:
5331 case FORM_CREATUREBEAR
:
5336 uint32 form
= GetModifier()->m_miscvalue
-1;
5340 if (spellId
) m_target
->CastSpell(m_target
, spellId
, true, NULL
, this );
5341 if (spellId2
) m_target
->CastSpell(m_target
, spellId2
, true, NULL
, this);
5343 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5345 const PlayerSpellMap
& sp_list
= ((Player
*)m_target
)->GetSpellMap();
5346 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
5348 if(itr
->second
->state
== PLAYERSPELL_REMOVED
) continue;
5349 if(itr
->first
==spellId
|| itr
->first
==spellId2
) continue;
5350 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
5351 if (!spellInfo
|| !(spellInfo
->Attributes
& (SPELL_ATTR_PASSIVE
| (1<<7))))
5353 if (spellInfo
->Stances
& (1<<form
))
5354 m_target
->CastSpell(m_target
, itr
->first
, true, NULL
, this);
5357 if (((Player
*)m_target
)->HasSpell(17007))
5359 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(24932);
5360 if (spellInfo
&& spellInfo
->Stances
& (1<<form
))
5361 m_target
->CastSpell(m_target
, 24932, true, NULL
, this);
5366 Unit::AuraList
const& mModTotalStatPct
= m_target
->GetAurasByType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
);
5367 for(Unit::AuraList::const_iterator i
= mModTotalStatPct
.begin(); i
!= mModTotalStatPct
.end(); ++i
)
5369 if ((*i
)->GetSpellProto()->SpellIconID
== 240 && (*i
)->GetModifier()->m_miscvalue
== 3)
5371 int32 HotWMod
= (*i
)->GetModifier()->m_amount
;
5372 if(GetModifier()->m_miscvalue
== FORM_CAT
)
5375 m_target
->CastCustomSpell(m_target
, HotWSpellId
, &HotWMod
, NULL
, NULL
, true, NULL
, this);
5384 m_target
->RemoveAurasDueToSpell(spellId
);
5385 m_target
->RemoveAurasDueToSpell(spellId2
);
5387 Unit::AuraMap
& tAuras
= m_target
->GetAuras();
5388 for (Unit::AuraMap::iterator itr
= tAuras
.begin(); itr
!= tAuras
.end();)
5390 if (itr
->second
->IsRemovedOnShapeLost())
5392 m_target
->RemoveAurasDueToSpell(itr
->second
->GetId());
5393 itr
= tAuras
.begin();
5402 /*double healthPercentage = (double)m_target->GetHealth() / (double)m_target->GetMaxHealth();
5403 m_target->SetHealth(uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage)));*/
5406 void Aura::HandleAuraEmpathy(bool apply
, bool /*Real*/)
5408 if(m_target
->GetTypeId() != TYPEID_UNIT
)
5411 CreatureInfo
const * ci
= objmgr
.GetCreatureTemplate(m_target
->GetEntry());
5412 if(ci
&& ci
->type
== CREATURE_TYPE_BEAST
)
5413 m_target
->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_SPECIALINFO
, apply
);
5416 void Aura::HandleAuraUntrackable(bool apply
, bool /*Real*/)
5419 m_target
->SetByteFlag(UNIT_FIELD_BYTES_1
, 3, UNIT_BYTE1_FLAG_UNTRACKABLE
);
5421 m_target
->RemoveByteFlag(UNIT_FIELD_BYTES_1
, 3, UNIT_BYTE1_FLAG_UNTRACKABLE
);
5424 void Aura::HandleAuraModPacify(bool apply
, bool /*Real*/)
5426 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5430 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PACIFIED
);
5432 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PACIFIED
);
5435 void Aura::HandleAuraModPacifyAndSilence(bool apply
, bool Real
)
5437 HandleAuraModPacify(apply
, Real
);
5438 HandleAuraModSilence(apply
, Real
);
5441 void Aura::HandleAuraGhost(bool apply
, bool /*Real*/)
5443 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5448 m_target
->SetFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
);
5452 m_target
->RemoveFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
);
5456 void Aura::HandleAuraAllowFlight(bool apply
, bool Real
)
5458 // all applied/removed only at real aura add/remove
5465 data
.Initialize(SMSG_MOVE_SET_CAN_FLY
, 12);
5467 data
.Initialize(SMSG_MOVE_UNSET_CAN_FLY
, 12);
5468 data
.append(m_target
->GetPackGUID());
5469 data
<< uint32(0); // unk
5470 m_target
->SendMessageToSet(&data
, true);
5473 void Aura::HandleModRating(bool apply
, bool Real
)
5475 // spells required only Real aura add/remove
5479 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5482 for (uint32 rating
= 0; rating
< MAX_COMBAT_RATING
; ++rating
)
5483 if (m_modifier
.m_miscvalue
& (1 << rating
))
5484 ((Player
*)m_target
)->ApplyRatingMod(CombatRating(rating
), m_modifier
.m_amount
, apply
);
5487 void Aura::HandleModRatingFromStat(bool apply
, bool Real
)
5489 // spells required only Real aura add/remove
5493 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5495 // Just recalculate ratings
5496 for (uint32 rating
= 0; rating
< MAX_COMBAT_RATING
; ++rating
)
5497 if (m_modifier
.m_miscvalue
& (1 << rating
))
5498 ((Player
*)m_target
)->ApplyRatingMod(CombatRating(rating
), 0, apply
);
5501 void Aura::HandleForceMoveForward(bool apply
, bool Real
)
5503 if(!Real
|| m_target
->GetTypeId() != TYPEID_PLAYER
)
5506 m_target
->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FORCE_MOVE
);
5508 m_target
->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FORCE_MOVE
);
5511 void Aura::HandleAuraModExpertise(bool /*apply*/, bool /*Real*/)
5513 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5516 ((Player
*)m_target
)->UpdateExpertise(BASE_ATTACK
);
5517 ((Player
*)m_target
)->UpdateExpertise(OFF_ATTACK
);
5520 void Aura::HandleModTargetResistance(bool apply
, bool Real
)
5522 // spells required only Real aura add/remove
5525 // applied to damage as HandleNoImmediateEffect in Unit::CalcAbsorbResist and Unit::CalcArmorReducedDamage
5527 // show armor penetration
5528 if (m_target
->GetTypeId() == TYPEID_PLAYER
&& (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
5529 m_target
->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE
, m_modifier
.m_amount
, apply
);
5531 // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy
5532 if (m_target
->GetTypeId() == TYPEID_PLAYER
&& (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_SPELL
)==SPELL_SCHOOL_MASK_SPELL
)
5533 m_target
->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE
, m_modifier
.m_amount
, apply
);
5536 void Aura::HandleShieldBlockValue(bool apply
, bool /*Real*/)
5538 BaseModType modType
= FLAT_MOD
;
5539 if(m_modifier
.m_auraname
== SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT
)
5542 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5543 ((Player
*)m_target
)->HandleBaseModValue(SHIELD_BLOCK_VALUE
, modType
, float(m_modifier
.m_amount
), apply
);
5546 void Aura::HandleAuraRetainComboPoints(bool apply
, bool Real
)
5548 // spells required only Real aura add/remove
5552 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5555 Player
*target
= (Player
*)m_target
;
5557 // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler
5558 // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost)
5559 if( !apply
&& m_duration
==0 && target
->GetComboTarget())
5560 if(Unit
* unit
= ObjectAccessor::GetUnit(*m_target
,target
->GetComboTarget()))
5561 target
->AddComboPoints(unit
, -m_modifier
.m_amount
);
5564 void Aura::HandleModUnattackable( bool Apply
, bool Real
)
5568 m_target
->CombatStop();
5569 m_target
->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION
);
5571 m_target
->ApplyModFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_NON_ATTACKABLE
,Apply
);
5574 void Aura::HandleSpiritOfRedemption( bool apply
, bool Real
)
5576 // spells required only Real aura add/remove
5580 // prepare spirit state
5583 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
5585 // disable breath/etc timers
5586 ((Player
*)m_target
)->StopMirrorTimers();
5588 // set stand state (expected in this form)
5589 if(!m_target
->IsStandState())
5590 m_target
->SetStandState(UNIT_STAND_STATE_STAND
);
5593 m_target
->SetHealth(1);
5597 m_target
->DealDamage(m_target
, m_target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, GetSpellProto(), false);
5600 void Aura::CleanupTriggeredSpells()
5602 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& (m_spellProto
->SpellFamilyFlags
& UI64LIT(0x0000001000000020)))
5604 // Blood Frenzy remove
5605 m_target
->RemoveAurasDueToSpell(30069);
5606 m_target
->RemoveAurasDueToSpell(30070);
5610 uint32 tSpellId
= m_spellProto
->EffectTriggerSpell
[GetEffIndex()];
5614 SpellEntry
const* tProto
= sSpellStore
.LookupEntry(tSpellId
);
5618 if(GetSpellDuration(tProto
) != -1)
5621 // needed for spell 43680, maybe others
5622 // TODO: is there a spell flag, which can solve this in a more sophisticated way?
5623 if(m_spellProto
->EffectApplyAuraName
[GetEffIndex()] == SPELL_AURA_PERIODIC_TRIGGER_SPELL
&&
5624 GetSpellDuration(m_spellProto
) == m_spellProto
->EffectAmplitude
[GetEffIndex()])
5626 m_target
->RemoveAurasDueToSpell(tSpellId
);
5629 void Aura::HandleSchoolAbsorb(bool apply
, bool Real
)
5634 // prevent double apply bonuses
5635 if(apply
&& (m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading()))
5637 if(Unit
* caster
= GetCaster())
5639 float DoneActualBenefit
= 0.0f
;
5640 switch(m_spellProto
->SpellFamilyName
)
5642 case SPELLFAMILY_PRIEST
:
5643 if(m_spellProto
->SpellFamilyFlags
== 0x1) //PW:S
5645 //+30% from +healing bonus
5646 DoneActualBenefit
= caster
->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto
)) * 0.3f
;
5650 case SPELLFAMILY_MAGE
:
5651 if (m_spellProto
->SpellFamilyFlags
== UI64LIT(0x80100) ||
5652 m_spellProto
->SpellFamilyFlags
== UI64LIT(0x8) ||
5653 m_spellProto
->SpellFamilyFlags
== UI64LIT(0x100000000))
5655 //frost ward, fire ward, ice barrier
5656 //+10% from +spd bonus
5657 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.1f
;
5661 case SPELLFAMILY_WARLOCK
:
5662 if(m_spellProto
->SpellFamilyFlags
== 0x00)
5665 //+10% from +spd bonus
5666 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.1f
;
5674 DoneActualBenefit
*= caster
->CalculateLevelPenalty(GetSpellProto());
5676 m_modifier
.m_amount
+= (int32
)DoneActualBenefit
;
5681 void Aura::PeriodicTick()
5683 if(!m_target
->isAlive())
5686 switch(m_modifier
.m_auraname
)
5688 case SPELL_AURA_PERIODIC_DAMAGE
:
5689 case SPELL_AURA_PERIODIC_DAMAGE_PERCENT
:
5691 Unit
*pCaster
= GetCaster();
5695 if( GetSpellProto()->Effect
[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
5696 pCaster
->SpellHitResult(m_target
, GetSpellProto(), false) != SPELL_MISS_NONE
)
5699 // Check for immune (not use charges)
5700 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5703 // some auras remove at specific health level or more
5704 if(m_modifier
.m_auraname
== SPELL_AURA_PERIODIC_DAMAGE
)
5708 case 43093: case 31956: case 38801:
5709 case 35321: case 38363: case 39215:
5710 if(m_target
->GetHealth() == m_target
->GetMaxHealth() )
5712 m_target
->RemoveAurasDueToSpell(GetId());
5719 GetEffIndex() < 2 && GetSpellProto()->Effect
[GetEffIndex()] == SPELL_EFFECT_DUMMY
?
5720 pCaster
->CalculateSpellDamage(GetSpellProto(), GetEffIndex() + 1, GetSpellProto()->EffectBasePoints
[GetEffIndex() + 1], m_target
) :
5722 if(m_target
->GetHealth() * 100 >= m_target
->GetMaxHealth() * percent
)
5724 m_target
->RemoveAurasDueToSpell(GetId());
5736 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
5738 // ignore non positive values (can be result apply spellmods to aura damage
5739 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5743 if(m_modifier
.m_auraname
== SPELL_AURA_PERIODIC_DAMAGE
)
5747 // Calculate armor mitigation if it is a physical spell
5748 // But not for bleed mechanic spells
5749 if ( GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL
&&
5750 GetEffectMechanic(GetSpellProto(), m_effIndex
) != MECHANIC_BLEED
)
5752 uint32 pdamageReductedArmor
= pCaster
->CalcArmorReducedDamage(m_target
, pdamage
);
5753 cleanDamage
.damage
+= pdamage
- pdamageReductedArmor
;
5754 pdamage
= pdamageReductedArmor
;
5757 pdamage
= pCaster
->SpellDamageBonus(m_target
, GetSpellProto(), pdamage
, DOT
, GetStackAmount());
5759 // Curse of Agony damage-per-tick calculation
5760 if (GetSpellProto()->SpellFamilyName
==SPELLFAMILY_WARLOCK
&& (GetSpellProto()->SpellFamilyFlags
& UI64LIT(0x0000000000000400)) && GetSpellProto()->SpellIconID
==544)
5762 // 1..4 ticks, 1/2 from normal tick damage
5763 if (m_duration
>= ((m_maxduration
-m_modifier
.periodictime
) * 2 / 3))
5764 pdamage
= pdamage
/2;
5765 // 9..12 ticks, 3/2 from normal tick damage
5766 else if(m_duration
< ((m_maxduration
-m_modifier
.periodictime
) / 3))
5767 pdamage
+= (pdamage
+ 1) / 2; // +1 prevent 0.5 damage possible lost at 1..4 ticks
5768 // 5..8 ticks have normal tick damage
5772 pdamage
= uint32(m_target
->GetMaxHealth()*amount
/100);
5774 // As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit
5775 // Reduce dot damage from resilience for players
5776 if (m_target
->GetTypeId() == TYPEID_PLAYER
)
5777 pdamage
-=((Player
*)m_target
)->GetDotDamageReduction(pdamage
);
5779 pCaster
->CalcAbsorbResist(m_target
, GetSpellSchoolMask(GetSpellProto()), DOT
, pdamage
, &absorb
, &resist
);
5781 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
5782 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId(),absorb
);
5784 pCaster
->DealDamageMods(m_target
, pdamage
, &absorb
);
5786 SpellPeriodicAuraLogInfo
pInfo(this, pdamage
, 0, absorb
, resist
, 0.0f
);
5787 m_target
->SendPeriodicAuraLog(&pInfo
);
5789 Unit
* target
= m_target
; // aura can be deleted in DealDamage
5790 SpellEntry
const* spellProto
= GetSpellProto();
5793 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
5794 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
5795 pdamage
= (pdamage
<= absorb
+ resist
) ? 0 : (pdamage
- absorb
- resist
);
5797 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
5798 pCaster
->ProcDamageAndSpell(target
, procAttacker
, procVictim
, PROC_EX_NORMAL_HIT
, pdamage
, BASE_ATTACK
, spellProto
);
5800 pCaster
->DealDamage(target
, pdamage
, &cleanDamage
, DOT
, GetSpellSchoolMask(spellProto
), spellProto
, true);
5803 case SPELL_AURA_PERIODIC_LEECH
:
5804 case SPELL_AURA_PERIODIC_HEALTH_FUNNEL
:
5806 Unit
*pCaster
= GetCaster();
5810 if(!pCaster
->isAlive())
5813 if( GetSpellProto()->Effect
[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
5814 pCaster
->SpellHitResult(m_target
, GetSpellProto(), false) != SPELL_MISS_NONE
)
5818 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5823 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
5825 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5827 //Calculate armor mitigation if it is a physical spell
5828 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL
)
5830 uint32 pdamageReductedArmor
= pCaster
->CalcArmorReducedDamage(m_target
, pdamage
);
5831 cleanDamage
.damage
+= pdamage
- pdamageReductedArmor
;
5832 pdamage
= pdamageReductedArmor
;
5835 pdamage
= pCaster
->SpellDamageBonus(m_target
, GetSpellProto(), pdamage
, DOT
, GetStackAmount());
5837 // As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit
5838 // Reduce dot damage from resilience for players
5839 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
5840 pdamage
-=((Player
*)m_target
)->GetDotDamageReduction(pdamage
);
5842 pCaster
->CalcAbsorbResist(m_target
, GetSpellSchoolMask(GetSpellProto()), DOT
, pdamage
, &absorb
, &resist
);
5844 if(m_target
->GetHealth() < pdamage
)
5845 pdamage
= uint32(m_target
->GetHealth());
5847 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
5848 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId(),absorb
);
5850 pCaster
->SendSpellNonMeleeDamageLog(m_target
, GetId(), pdamage
, GetSpellSchoolMask(GetSpellProto()), absorb
, resist
, false, 0);
5852 Unit
* target
= m_target
; // aura can be deleted in DealDamage
5853 SpellEntry
const* spellProto
= GetSpellProto();
5854 float multiplier
= spellProto
->EffectMultipleValue
[GetEffIndex()] > 0 ? spellProto
->EffectMultipleValue
[GetEffIndex()] : 1;
5855 int32 stackAmount
= GetStackAmount();
5858 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
5859 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
5860 pdamage
= (pdamage
<= absorb
+ resist
) ? 0 : (pdamage
-absorb
-resist
);
5862 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
5863 pCaster
->ProcDamageAndSpell(target
, procAttacker
, procVictim
, PROC_EX_NORMAL_HIT
, pdamage
, BASE_ATTACK
, spellProto
);
5864 int32 new_damage
= pCaster
->DealDamage(target
, pdamage
, &cleanDamage
, DOT
, GetSpellSchoolMask(spellProto
), spellProto
, false);
5866 if (!target
->isAlive() && pCaster
->IsNonMeleeSpellCasted(false))
5868 for (uint32 i
= CURRENT_FIRST_NON_MELEE_SPELL
; i
< CURRENT_MAX_SPELL
; ++i
)
5870 if (pCaster
->m_currentSpells
[i
] && pCaster
->m_currentSpells
[i
]->m_spellInfo
->Id
== spellProto
->Id
)
5871 pCaster
->m_currentSpells
[i
]->cancel();
5876 if(Player
*modOwner
= pCaster
->GetSpellModOwner())
5877 modOwner
->ApplySpellMod(spellProto
->Id
, SPELLMOD_MULTIPLE_VALUE
, multiplier
);
5879 uint32 heal
= pCaster
->SpellHealingBonus(pCaster
, spellProto
, uint32(new_damage
* multiplier
), DOT
, stackAmount
);
5881 int32 gain
= pCaster
->DealHeal(pCaster
, heal
, spellProto
);
5882 pCaster
->getHostilRefManager().threatAssist(pCaster
, gain
* 0.5f
, spellProto
);
5885 case SPELL_AURA_PERIODIC_HEAL
:
5886 case SPELL_AURA_OBS_MOD_HEALTH
:
5888 Unit
*pCaster
= GetCaster();
5892 // heal for caster damage (must be alive)
5893 if(m_target
!= pCaster
&& GetSpellProto()->SpellVisual
[0] == 163 && !pCaster
->isAlive())
5896 // ignore non positive values (can be result apply spellmods to aura damage
5897 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5901 if(m_modifier
.m_auraname
==SPELL_AURA_OBS_MOD_HEALTH
)
5902 pdamage
= uint32(m_target
->GetMaxHealth() * amount
/ 100);
5906 pdamage
= pCaster
->SpellHealingBonus(m_target
, GetSpellProto(), pdamage
, DOT
, GetStackAmount());
5908 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) heal of %u (TypeId: %u) for %u health inflicted by %u",
5909 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
5911 SpellPeriodicAuraLogInfo
pInfo(this, pdamage
, 0, 0, 0, 0.0f
);
5912 m_target
->SendPeriodicAuraLog(&pInfo
);
5914 int32 gain
= m_target
->ModifyHealth(pdamage
);
5916 // add HoTs to amount healed in bgs
5917 if( pCaster
->GetTypeId() == TYPEID_PLAYER
)
5918 if( BattleGround
*bg
= ((Player
*)pCaster
)->GetBattleGround() )
5919 bg
->UpdatePlayerScore(((Player
*)pCaster
), SCORE_HEALING_DONE
, gain
);
5921 m_target
->getHostilRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, GetSpellProto());
5923 SpellEntry
const* spellProto
= GetSpellProto();
5925 // heal for caster damage
5926 if(m_target
!= pCaster
&& spellProto
->SpellVisual
[0] == 163)
5928 uint32 dmg
= spellProto
->manaPerSecond
;
5929 if(pCaster
->GetHealth() <= dmg
&& pCaster
->GetTypeId()==TYPEID_PLAYER
)
5931 pCaster
->RemoveAurasDueToSpell(GetId());
5933 // finish current generic/channeling spells, don't affect autorepeat
5934 if(pCaster
->m_currentSpells
[CURRENT_GENERIC_SPELL
])
5936 pCaster
->m_currentSpells
[CURRENT_GENERIC_SPELL
]->finish();
5938 if(pCaster
->m_currentSpells
[CURRENT_CHANNELED_SPELL
])
5940 pCaster
->m_currentSpells
[CURRENT_CHANNELED_SPELL
]->SendChannelUpdate(0);
5941 pCaster
->m_currentSpells
[CURRENT_CHANNELED_SPELL
]->finish();
5946 uint32 damage
= gain
;
5948 pCaster
->DealDamageMods(pCaster
, damage
, &absorb
);
5949 pCaster
->SendSpellNonMeleeDamageLog(pCaster
, GetId(), damage
, GetSpellSchoolMask(GetSpellProto()), absorb
, 0, false, 0, false);
5951 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
5952 pCaster
->DealDamage(pCaster
, damage
, &cleanDamage
, NODAMAGE
, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
5956 // uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;// | PROC_FLAG_SUCCESSFUL_HEAL;
5957 // uint32 procVictim = 0;//ROC_FLAG_ON_TAKE_PERIODIC | PROC_FLAG_TAKEN_HEAL;
5958 // ignore item heals
5959 // if(procSpell && !haveCastItem)
5960 // pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto);
5963 case SPELL_AURA_PERIODIC_MANA_LEECH
:
5965 if(m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
>= MAX_POWERS
)
5968 Powers power
= Powers(m_modifier
.m_miscvalue
);
5970 // power type might have changed between aura applying and tick (druid's shapeshift)
5971 if(m_target
->getPowerType() != power
)
5974 Unit
*pCaster
= GetCaster();
5978 if(!pCaster
->isAlive())
5981 if( GetSpellProto()->Effect
[GetEffIndex()] == SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
5982 pCaster
->SpellHitResult(m_target
, GetSpellProto(), false) != SPELL_MISS_NONE
)
5985 // Check for immune (not use charges)
5986 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5989 // ignore non positive values (can be result apply spellmods to aura damage
5990 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5992 // Special case: draining x% of mana (up to a maximum of 2*x% of the caster's maximum mana)
5993 // It's mana percent cost spells, m_modifier.m_amount is percent drain from target
5994 if (m_spellProto
->ManaCostPercentage
)
5997 uint32 maxmana
= pCaster
->GetMaxPower(power
) * pdamage
* 2 / 100;
5998 pdamage
= m_target
->GetMaxPower(power
) * pdamage
/ 100;
5999 if(pdamage
> maxmana
)
6003 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u",
6004 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
6006 int32 drain_amount
= m_target
->GetPower(power
) > pdamage
? pdamage
: m_target
->GetPower(power
);
6008 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
6009 if (power
== POWER_MANA
&& m_target
->GetTypeId() == TYPEID_PLAYER
)
6010 drain_amount
-= ((Player
*)m_target
)->GetSpellCritDamageReduction(drain_amount
);
6012 m_target
->ModifyPower(power
, -drain_amount
);
6014 float gain_multiplier
= 0;
6016 if(pCaster
->GetMaxPower(power
) > 0)
6018 gain_multiplier
= GetSpellProto()->EffectMultipleValue
[GetEffIndex()];
6020 if(Player
*modOwner
= pCaster
->GetSpellModOwner())
6021 modOwner
->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE
, gain_multiplier
);
6024 SpellPeriodicAuraLogInfo
pInfo(this, drain_amount
, 0, 0, 0, gain_multiplier
);
6025 m_target
->SendPeriodicAuraLog(&pInfo
);
6027 int32 gain_amount
= int32(drain_amount
* gain_multiplier
);
6031 int32 gain
= pCaster
->ModifyPower(power
, gain_amount
);
6032 m_target
->AddThreat(pCaster
, float(gain
) * 0.5f
, GetSpellSchoolMask(GetSpellProto()), GetSpellProto());
6036 case SPELL_AURA_PERIODIC_ENERGIZE
:
6038 // ignore non positive values (can be result apply spellmods to aura damage
6039 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
6041 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u",
6042 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
6044 if(m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
>= MAX_POWERS
)
6047 Powers power
= Powers(m_modifier
.m_miscvalue
);
6049 if(m_target
->GetMaxPower(power
) == 0)
6052 SpellPeriodicAuraLogInfo
pInfo(this, pdamage
, 0, 0, 0, 0.0f
);
6053 m_target
->SendPeriodicAuraLog(&pInfo
);
6055 int32 gain
= m_target
->ModifyPower(power
,pdamage
);
6057 if(Unit
* pCaster
= GetCaster())
6058 m_target
->getHostilRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, GetSpellProto());
6061 case SPELL_AURA_OBS_MOD_MANA
:
6063 // ignore non positive values (can be result apply spellmods to aura damage
6064 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
6066 uint32 pdamage
= uint32(m_target
->GetMaxPower(POWER_MANA
) * amount
/ 100);
6068 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u mana inflicted by %u",
6069 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
6071 if(m_target
->GetMaxPower(POWER_MANA
) == 0)
6074 SpellPeriodicAuraLogInfo
pInfo(this, pdamage
, 0, 0, 0, 0.0f
);
6075 m_target
->SendPeriodicAuraLog(&pInfo
);
6077 int32 gain
= m_target
->ModifyPower(POWER_MANA
, pdamage
);
6079 if(Unit
* pCaster
= GetCaster())
6080 m_target
->getHostilRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, GetSpellProto());
6083 case SPELL_AURA_POWER_BURN_MANA
:
6085 Unit
*pCaster
= GetCaster();
6089 // Check for immune (not use charges)
6090 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6093 int32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
6095 Powers powerType
= Powers(m_modifier
.m_miscvalue
);
6097 if(!m_target
->isAlive() || m_target
->getPowerType() != powerType
)
6100 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
6101 if (powerType
== POWER_MANA
&& m_target
->GetTypeId() == TYPEID_PLAYER
)
6102 pdamage
-= ((Player
*)m_target
)->GetSpellCritDamageReduction(pdamage
);
6104 uint32 gain
= uint32(-m_target
->ModifyPower(powerType
, -pdamage
));
6106 gain
= uint32(gain
* GetSpellProto()->EffectMultipleValue
[GetEffIndex()]);
6108 SpellEntry
const* spellProto
= GetSpellProto();
6109 // maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG
6110 SpellNonMeleeDamage
damageInfo(pCaster
, m_target
, spellProto
->Id
, spellProto
->SchoolMask
);
6111 pCaster
->CalculateSpellDamage(&damageInfo
, gain
, spellProto
);
6113 pCaster
->DealDamageMods(damageInfo
.target
, damageInfo
.damage
, &damageInfo
.absorb
);
6115 pCaster
->SendSpellNonMeleeDamageLog(&damageInfo
);
6118 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
; // | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
6119 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
6120 uint32 procEx
= createProcExtendMask(&damageInfo
, SPELL_MISS_NONE
);
6121 if (damageInfo
.damage
)
6122 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
6124 pCaster
->ProcDamageAndSpell(damageInfo
.target
, procAttacker
, procVictim
, procEx
, damageInfo
.damage
, BASE_ATTACK
, spellProto
);
6126 pCaster
->DealSpellDamage(&damageInfo
, true);
6129 case SPELL_AURA_MOD_REGEN
:
6131 int32 gain
= m_target
->ModifyHealth(m_modifier
.m_amount
);
6132 if (Unit
*caster
= GetCaster())
6133 m_target
->getHostilRefManager().threatAssist(caster
, float(gain
) * 0.5f
, GetSpellProto());
6136 case SPELL_AURA_MOD_POWER_REGEN
:
6138 Powers pt
= m_target
->getPowerType();
6139 if(int32(pt
) != m_modifier
.m_miscvalue
)
6142 if ( GetSpellProto()->AuraInterruptFlags
& AURA_INTERRUPT_FLAG_NOT_SEATED
)
6145 m_target
->HandleEmoteCommand(EMOTE_ONESHOT_EAT
);
6147 else if( GetId() == 20577 )
6150 m_target
->HandleEmoteCommand(EMOTE_STATE_CANNIBALIZE
);
6154 // amount = 1+ 16 = 17 = 3,4*5 = 10,2*5/3
6155 // so 17 is rounded amount for 5 sec tick grow ~ 1 range grow in 3 sec
6156 if(pt
== POWER_RAGE
)
6157 m_target
->ModifyPower(pt
, m_modifier
.m_amount
* 3 / 5);
6160 // Here tick dummy auras
6161 case SPELL_AURA_PERIODIC_DUMMY
:
6163 PeriodicDummyTick();
6166 case SPELL_AURA_PERIODIC_TRIGGER_SPELL
:
6171 case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
:
6173 TriggerSpellWithValue();
6181 void Aura::PeriodicDummyTick()
6183 Unit
*caster
= GetCaster();
6184 SpellEntry
const* spell
= GetSpellProto();
6185 switch (spell
->SpellFamilyName
)
6187 case SPELLFAMILY_GENERIC
:
6203 case 49472: // Drink Coffee
6206 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
6208 // Search SPELL_AURA_MOD_POWER_REGEN aura for this spell and add bonus
6209 Unit::AuraList
const& aura
= m_target
->GetAurasByType(SPELL_AURA_MOD_POWER_REGEN
);
6210 for(Unit::AuraList::const_iterator i
= aura
.begin(); i
!= aura
.end(); ++i
)
6212 if ((*i
)->GetId() == GetId())
6214 (*i
)->GetModifier()->m_amount
= m_modifier
.m_amount
;
6215 ((Player
*)m_target
)->UpdateManaRegen();
6217 m_isPeriodic
= false;
6226 // Possibly need cast one of them (but
6227 // 7038 Forsaken Skill: Swords
6228 // 7039 Forsaken Skill: Axes
6229 // 7040 Forsaken Skill: Daggers
6230 // 7041 Forsaken Skill: Maces
6231 // 7042 Forsaken Skill: Staves
6232 // 7043 Forsaken Skill: Bows
6233 // 7044 Forsaken Skill: Guns
6234 // 7045 Forsaken Skill: 2H Axes
6235 // 7046 Forsaken Skill: 2H Maces
6236 // 7047 Forsaken Skill: 2H Swords
6237 // 7048 Forsaken Skill: Defense
6238 // 7049 Forsaken Skill: Fire
6239 // 7050 Forsaken Skill: Frost
6240 // 7051 Forsaken Skill: Holy
6241 // 7053 Forsaken Skill: Shadow
6245 // case 19230: break;
6246 // // Gossip NPC Periodic - Talk
6247 // case 33208: break;
6248 // // Gossip NPC Periodic - Despawn
6249 // case 33209: break;
6251 // case 36207: break;
6252 // // Simon Game START timer, (DND)
6253 // case 39993: break;
6254 // // Knockdown Fel Cannon: break; The Aggro Burst
6255 // case 40119: break;
6256 // // Old Mount Spell
6257 // case 40154: break;
6259 // case 40581: break;
6260 // // Ethereal Ring: break; The Bolt Burst
6261 // case 40801: break;
6262 // // Crystal Prison
6263 // case 40846: break;
6265 // case 41054: break;
6267 // case 41404: break;
6268 // // Ethereal Ring Visual, Lightning Aura
6269 // case 41477: break;
6270 // // Ethereal Ring Visual, Lightning Aura (Fork)
6271 // case 41525: break;
6272 // // Ethereal Ring Visual, Lightning Jumper Aura
6273 // case 41567: break;
6275 // case 41955: break;
6276 // // Headless Horseman - Fire
6277 // case 42074: break;
6278 // // Headless Horseman - Visual - Large Fire
6279 // case 42075: break;
6280 // // Headless Horseman - Start Fire, Periodic Aura
6281 // case 42140: break;
6282 // // Ram Speed Boost
6283 // case 42152: break;
6284 // // Headless Horseman - Fires Out Victory Aura
6285 // case 42235: break;
6286 // // Pumpkin Life Cycle
6287 // case 42280: break;
6288 // // Brewfest Request Chick Chuck Mug Aura
6289 // case 42537: break;
6291 // case 42596: break;
6292 // // Headless Horseman Climax, Head: Periodic
6293 // case 42603: break;
6295 // case 42621: break;
6296 // // Headless Horseman - Conflagrate, Periodic Aura
6297 // case 42637: break;
6298 // // Headless Horseman - Create Pumpkin Treats Aura
6299 // case 42774: break;
6300 // // Headless Horseman Climax - Summoning Rhyme Aura
6301 // case 42879: break;
6303 // case 42919: break;
6305 // case 42924: break;
6307 // case 42992: break;
6309 // case 42993: break;
6311 // case 42994: break;
6312 // // Ram Level - Neutral
6313 // case 43310: break;
6314 // // Headless Horseman - Maniacal Laugh, Maniacal, Delayed 17
6315 // case 43884: break;
6317 // case 43963: break;
6318 // // Headless Horseman - Maniacal Laugh, Maniacal, other, Delayed 17
6319 // case 44000: break;
6320 // // Energy Feedback
6321 // case 44328: break;
6322 // // Romantic Picnic
6323 // case 45102: break;
6324 // // Romantic Picnic
6325 // case 45123: break;
6326 // // Looking for Love
6327 // case 45124: break;
6328 // // Kite - Lightning Strike Kite Aura
6329 // case 45197: break;
6330 // // Rocket Chicken
6331 // case 45202: break;
6332 // // Copy Offhand Weapon
6333 // case 45205: break;
6334 // // Upper Deck - Kite - Lightning Periodic Aura
6335 // case 45207: break;
6336 // // Kite -Sky Lightning Strike Kite Aura
6337 // case 45251: break;
6338 // // Ribbon Pole Dancer Check Aura
6339 // case 45390: break;
6340 // // Holiday - Midsummer, Ribbon Pole Periodic Visual
6341 // case 45406: break;
6343 // case 45472: break;
6344 // // Alliance Flag, Extra Damage Debuff
6345 // case 45898: break;
6346 // // Horde Flag, Extra Damage Debuff
6347 // case 45899: break;
6348 // // Ahune - Summoning Rhyme Aura
6349 // case 45926: break;
6350 // // Ahune - Slippery Floor
6351 // case 45945: break;
6352 // // Ahune's Shield
6353 // case 45954: break;
6354 // // Nether Vapor Lightning
6355 // case 45960: break;
6357 // case 45996: break;
6358 // // Summon Blood Elves Periodic
6359 // case 46041: break;
6360 // // Transform Visual Missile Periodic
6361 // case 46205: break;
6362 // // Find Opening Beam End
6363 // case 46333: break;
6364 // // Ice Spear Control Aura
6365 // case 46371: break;
6366 // // Hailstone Chill
6367 // case 46458: break;
6368 // // Hailstone Chill, Internal
6369 // case 46465: break;
6370 // // Chill, Internal Shifter
6371 // case 46549: break;
6372 // // Summon Ice Spear Knockback Delayer
6373 // case 46878: break;
6374 // // Burninate Effect
6375 // case 47214: break;
6376 // // Fizzcrank Practice Parachute
6377 // case 47228: break;
6378 // // Send Mug Control Aura
6379 // case 47369: break;
6380 // // Direbrew's Disarm (precast)
6381 // case 47407: break;
6382 // // Mole Machine Port Schedule
6383 // case 47489: break;
6384 // case 47941: break; // Crystal Spike
6385 // case 48200: break; // Healer Aura
6386 // case 48630: break; // Summon Gauntlet Mobs Periodic
6387 // case 49313: break; // Proximity Mine Area Aura
6388 // // Mole Machine Portal Schedule
6389 // case 49466: break;
6390 // case 49555: break; // Corpse Explode
6391 // case 49592: break; // Temporal Rift
6392 // case 49957: break; // Cutting Laser
6393 // case 50085: break; // Slow Fall
6394 // // Listening to Music
6395 // case 50493: break;
6396 // // Love Rocket Barrage
6397 // case 50530: break;
6398 // Exist more after, need add later
6403 case SPELLFAMILY_MAGE
:
6406 // if (spell->Id == 55342)
6410 case SPELLFAMILY_WARRIOR
:
6412 // Armored to the Teeth
6413 if (spell
->SpellIconID
== 3516)
6415 // Increases your attack power by $s1 for every $s2 armor value you have.
6416 // Calculate AP bonus (from 1 efect of this spell)
6417 int32 apBonus
= m_modifier
.m_amount
* m_target
->GetArmor() / m_target
->CalculateSpellDamage(spell
, 1, spell
->EffectBasePoints
[1], m_target
);
6418 m_target
->CastCustomSpell(m_target
, 61217, &apBonus
, &apBonus
, NULL
, true, NULL
, this);
6423 case SPELLFAMILY_DRUID
:
6427 // Frenzied Regeneration
6430 // Converts up to 10 rage per second into health for $d. Each point of rage is converted into ${$m2/10}.1% of max health.
6431 // Should be manauser
6432 if (m_target
->getPowerType() != POWER_RAGE
)
6434 uint32 rage
= m_target
->GetPower(POWER_RAGE
);
6438 int32 mod
= (rage
< 100) ? rage
: 100;
6439 int32 points
= m_target
->CalculateSpellDamage(spell
, 1, spell
->EffectBasePoints
[1], m_target
);
6440 int32 regen
= m_target
->GetMaxHealth() * (mod
* points
/ 10) / 1000;
6441 m_target
->CastCustomSpell(m_target
, 22845, ®en
, NULL
, NULL
, true, NULL
, this);
6442 m_target
->SetPower(POWER_RAGE
, rage
-mod
);
6453 case SPELLFAMILY_ROGUE
:
6459 std::list
<Unit
*> targets
;
6462 float radius
= GetSpellMaxRange(sSpellRangeStore
.LookupEntry(spell
->rangeIndex
));
6464 CellPair
p(MaNGOS::ComputeCellPair(caster
->GetPositionX(),caster
->GetPositionY()));
6466 cell
.data
.Part
.reserved
= ALL_DISTRICT
;
6468 MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck
u_check(caster
, caster
, radius
);
6469 MaNGOS::UnitListSearcher
<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck
> checker(caster
,targets
, u_check
);
6471 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck
>, GridTypeMapContainer
> grid_object_checker(checker
);
6472 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyUnfriendlyVisibleUnitInObjectRangeCheck
>, WorldTypeMapContainer
> world_object_checker(checker
);
6474 CellLock
<GridReadGuard
> cell_lock(cell
, p
);
6476 cell_lock
->Visit(cell_lock
, grid_object_checker
, *caster
->GetMap());
6477 cell_lock
->Visit(cell_lock
, world_object_checker
, *caster
->GetMap());
6483 std::list
<Unit
*>::const_iterator itr
= targets
.begin();
6484 std::advance(itr
, rand()%targets
.size());
6485 Unit
* target
= *itr
;
6487 caster
->CastSpell(target
, 57840, true);
6488 caster
->CastSpell(target
, 57841, true);
6491 // Master of Subtlety
6492 // case 31666: break;
6494 // case 51690: break;
6496 // case 58428: break;
6502 case SPELLFAMILY_HUNTER
:
6505 if (spell
->SpellFamilyFlags
& UI64LIT(0x8000000000000000))
6509 int32 damage
= m_modifier
.m_amount
;
6510 // Full damage to target at 0 tick
6511 if (m_duration
> m_modifier
.periodictime
)
6513 caster
->CastCustomSpell(m_target
, 53352, &damage
, NULL
, NULL
, true, NULL
, this);
6517 caster
->CastCustomSpell(m_target
, 56298, &damage
, NULL
, NULL
, true, NULL
, this);
6525 // Feeding Frenzy Rank 1
6527 if ( m_target
->GetHealth() * 100 < m_target
->GetMaxHealth() * 35 )
6528 m_target
->CastSpell(m_target
, 60096, true, 0, this);
6530 // Feeding Frenzy Rank 2
6532 if ( m_target
->GetHealth() * 100 < m_target
->GetMaxHealth() * 35 )
6533 m_target
->CastSpell(m_target
, 60097, true, 0, this);
6540 case SPELLFAMILY_SHAMAN
:
6543 if (spell
->Id
== 52179)
6545 // Periodic need for remove visual on stun/fear/silence lost
6546 if (!(m_target
->GetUInt32Value(UNIT_FIELD_FLAGS
)&(UNIT_FLAG_STUNNED
|UNIT_FLAG_FLEEING
|UNIT_FLAG_SILENCED
)))
6547 m_target
->RemoveAurasDueToSpell(52179);
6552 case SPELLFAMILY_DEATHKNIGHT
:
6555 if (spell
->SpellFamilyFlags
& UI64LIT(0x0000000000000020))
6558 caster
->CastCustomSpell(m_target
, 52212, &m_modifier
.m_amount
, NULL
, NULL
, true, NULL
, this);
6562 // if (spell->SpellFamilyFlags & UI64LIT(0x0000000000001000))
6565 if (spell
->SpellFamilyFlags
& UI64LIT(0x0000400000000000))
6567 // Get 0 effect aura
6568 Aura
*slow
= m_target
->GetAura(GetId(), 0);
6571 slow
->ApplyModifier(false, true);
6572 Modifier
*mod
= slow
->GetModifier();
6573 mod
->m_amount
+= m_modifier
.m_amount
;
6574 if (mod
->m_amount
> 0) mod
->m_amount
= 0;
6575 slow
->ApplyModifier(true, true);
6580 // if (spell->SpellFamilyFlags & UI64LIT(0x0000008000000000))
6582 // Death Rune Mastery
6583 // if (spell->SpellFamilyFlags & UI64LIT(0x0000000000004000))
6586 if (spell
->SpellIconID
== 2653)
6588 // Increases your attack power by $s1 for every $s2 armor value you have.
6589 // Calculate AP bonus (from 1 efect of this spell)
6590 int32 apBonus
= m_modifier
.m_amount
* m_target
->GetArmor() / m_target
->CalculateSpellDamage(spell
, 1, spell
->EffectBasePoints
[1], m_target
);
6591 m_target
->CastCustomSpell(m_target
, 61217, &apBonus
, &apBonus
, NULL
, true, NULL
, this);
6595 // if (spell->SpellIconID == 22)
6597 // Blood of the North
6598 // if (spell->SpellIconID == 30412)
6607 void Aura::HandlePreventFleeing(bool apply
, bool Real
)
6612 Unit::AuraList
const& fearAuras
= m_target
->GetAurasByType(SPELL_AURA_MOD_FEAR
);
6613 if( !fearAuras
.empty() )
6616 m_target
->SetFeared(false, fearAuras
.front()->GetCasterGUID());
6618 m_target
->SetFeared(true);
6622 void Aura::HandleManaShield(bool apply
, bool Real
)
6627 // prevent double apply bonuses
6628 if(apply
&& (m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading()))
6630 if(Unit
* caster
= GetCaster())
6632 float DoneActualBenefit
= 0.0f
;
6633 switch(m_spellProto
->SpellFamilyName
)
6635 case SPELLFAMILY_MAGE
:
6636 if(m_spellProto
->SpellFamilyFlags
& UI64LIT(0x8000))
6639 // +50% from +spd bonus
6640 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.5f
;
6648 DoneActualBenefit
*= caster
->CalculateLevelPenalty(GetSpellProto());
6650 m_modifier
.m_amount
+= (int32
)DoneActualBenefit
;
6655 void Aura::HandleArenaPreparation(bool apply
, bool Real
)
6661 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PREPARATION
);
6663 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PREPARATION
);
6667 * Such auras are applied from a caster(=player) to a vehicle.
6668 * This has been verified using spell #49256
6670 void Aura::HandleAuraControlVehicle(bool apply
, bool Real
)
6675 Unit
*player
= GetCaster();
6676 Vehicle
*vehicle
= dynamic_cast<Vehicle
*>(m_target
);
6677 if(!player
|| player
->GetTypeId() != TYPEID_PLAYER
|| !vehicle
)
6682 if(Pet
*pet
= player
->GetPet())
6683 pet
->Remove(PET_SAVE_AS_CURRENT
);
6684 ((Player
*)player
)->EnterVehicle(vehicle
);
6688 SpellEntry
const *spell
= GetSpellProto();
6690 // some SPELL_AURA_CONTROL_VEHICLE auras have a dummy effect on the player - remove them
6691 player
->RemoveAurasDueToSpell(spell
->Id
);
6693 ((Player
*)player
)->ExitVehicle(vehicle
);
6697 void Aura::HandleAuraConvertRune(bool apply
, bool Real
)
6702 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
6705 Player
*plr
= (Player
*)m_target
;
6707 if(plr
->getClass() != CLASS_DEATH_KNIGHT
)
6710 // how to determine what rune need to be converted?
6711 for(uint32 i
= 0; i
< MAX_RUNES
; ++i
)
6715 if(!plr
->GetRuneCooldown(i
))
6717 plr
->ConvertRune(i
, GetSpellProto()->EffectMiscValueB
[m_effIndex
]);
6723 if(plr
->GetCurrentRune(i
) == GetSpellProto()->EffectMiscValueB
[m_effIndex
])
6725 plr
->ConvertRune(i
, plr
->GetBaseRune(i
));
6732 void Aura::HandlePhase(bool apply
, bool Real
)
6737 // always non stackable
6740 Unit::AuraList
const& phases
= m_target
->GetAurasByType(SPELL_AURA_PHASE
);
6742 m_target
->RemoveAurasDueToSpell(phases
.front()->GetId(), this);
6745 // no-phase is also phase state so same code for apply and remove
6747 // phase auras normally not expected at BG but anyway better check
6748 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
6750 // drop flag at invisible in bg
6751 if(((Player
*)m_target
)->InBattleGround())
6752 if(BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround())
6753 bg
->EventPlayerDroppedFlag((Player
*)m_target
);
6755 // GM-mode have mask 0xFFFFFFFF
6756 if(!((Player
*)m_target
)->isGameMaster())
6757 m_target
->SetPhaseMask(apply
? GetMiscValue() : PHASEMASK_NORMAL
, false);
6759 ((Player
*)m_target
)->GetSession()->SendSetPhaseShift(apply
? GetMiscValue() : PHASEMASK_NORMAL
);
6761 if(GetEffIndex()==0)
6763 SpellAreaForAreaMapBounds saBounds
= spellmgr
.GetSpellAreaForAuraMapBounds(GetId());
6764 if(saBounds
.first
!= saBounds
.second
)
6767 m_target
->GetZoneAndAreaId(zone
, area
);
6769 for(SpellAreaForAreaMap::const_iterator itr
= saBounds
.first
; itr
!= saBounds
.second
; ++itr
)
6771 // some auras remove at aura remove
6772 if(!itr
->second
->IsFitToRequirements((Player
*)m_target
, zone
, area
))
6773 m_target
->RemoveAurasDueToSpell(itr
->second
->spellId
);
6774 // some auras applied at aura apply
6775 else if(itr
->second
->autocast
)
6777 if( !m_target
->HasAura(itr
->second
->spellId
, 0) )
6778 m_target
->CastSpell(m_target
, itr
->second
->spellId
, true);
6785 m_target
->SetPhaseMask(apply
? GetMiscValue() : PHASEMASK_NORMAL
, false);
6787 // need triggering visibility update base at phase update of not GM invisible (other GMs anyway see in any phases)
6788 if(m_target
->GetVisibility() != VISIBILITY_OFF
)
6789 m_target
->SetVisibility(m_target
->GetVisibility());
6792 void Aura::UnregisterSingleCastAura()
6794 if (IsSingleTarget())
6796 Unit
* caster
= NULL
;
6797 caster
= GetCaster();
6800 caster
->GetSingleCastAuras().remove(this);
6804 sLog
.outError("Couldn't find the caster of the single target aura, may crash later!");
6807 m_isSingleTargetAura
= false;
6811 void Aura::HandleAuraSafeFall( bool Apply
, bool Real
)
6813 // implemented in WorldSession::HandleMovementOpcodes
6815 // only special case
6816 if(Apply
&& Real
&& GetId() == 32474 && m_target
->GetTypeId() == TYPEID_PLAYER
)
6817 ((Player
*)m_target
)->ActivateTaxiPathTo(506, GetId());