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 "SpellAuras.h"
33 #include "DynamicObject.h"
35 #include "UpdateData.h"
36 #include "MapManager.h"
37 #include "ObjectAccessor.h"
38 #include "Policies/SingletonImp.h"
42 #include "BattleGround.h"
43 #include "CreatureAI.h"
45 #include "GridNotifiers.h"
46 #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_BONUS
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 Spell::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::HandleNULL
, //111 SPELL_AURA_ADD_CASTER_HIT_TRIGGER chance redirect attack to caster
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::HandleNoImmediateEffect
, //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::HandleNULL
, //190 SPELL_AURA_MOD_FACTION_REPUTATION_GAIN
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
343 Aura::Aura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
, Unit
*caster
, Item
* castItem
) :
344 m_spellmod(NULL
), m_caster_guid(0), m_castItemGuid(castItem
?castItem
->GetGUID():0), m_target(target
),
345 m_timeCla(1000), m_periodicTimer(0), m_removeMode(AURA_REMOVE_BY_DEFAULT
), m_AuraDRGroup(DIMINISHING_NONE
),
346 m_effIndex(eff
), m_auraSlot(MAX_AURAS
), m_auraFlags(AFLAG_NONE
), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),
347 m_positive(false), m_permanent(false), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false),
348 m_updated(false), m_isRemovedOnShapeLost(true), m_in_use(false)
352 assert(spellproto
&& spellproto
== sSpellStore
.LookupEntry( spellproto
->Id
) && "`info` must be pointer to sSpellStore element");
354 m_spellProto
= spellproto
;
356 m_currentBasePoints
= currentBasePoints
? *currentBasePoints
: m_spellProto
->EffectBasePoints
[eff
];
358 m_isPassive
= IsPassiveSpell(GetId());
359 m_positive
= IsPositiveEffect(GetId(), m_effIndex
);
361 m_applyTime
= time(NULL
);
366 m_caster_guid
= target
->GetGUID();
367 damage
= m_currentBasePoints
+1; // stored value-1
368 m_maxduration
= target
->CalculateSpellDuration(m_spellProto
, m_effIndex
, target
);
372 m_caster_guid
= caster
->GetGUID();
374 damage
= caster
->CalculateSpellDamage(m_spellProto
,m_effIndex
,m_currentBasePoints
,target
);
375 m_maxduration
= caster
->CalculateSpellDuration(m_spellProto
, m_effIndex
, target
);
377 if (!damage
&& castItem
&& castItem
->GetItemSuffixFactor())
379 ItemRandomSuffixEntry
const *item_rand_suffix
= sItemRandomSuffixStore
.LookupEntry(abs(castItem
->GetItemRandomPropertyId()));
382 for (int k
=0; k
<3; k
++)
384 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(item_rand_suffix
->enchant_id
[k
]);
387 for (int t
=0; t
<3; t
++)
388 if(pEnchant
->spellid
[t
] == m_spellProto
->Id
)
390 damage
= uint32((item_rand_suffix
->prefix
[k
]*castItem
->GetItemSuffixFactor()) / 10000 );
402 if(m_maxduration
== -1 || m_isPassive
&& m_spellProto
->DurationIndex
== 0)
405 Player
* modOwner
= caster
? caster
->GetSpellModOwner() : NULL
;
407 if(!m_permanent
&& modOwner
)
409 modOwner
->ApplySpellMod(GetId(), SPELLMOD_DURATION
, m_maxduration
);
410 // Get zero duration aura after - need set m_maxduration > 0 for apply/remove aura work
411 if (m_maxduration
<=0)
415 m_duration
= m_maxduration
;
417 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
);
420 SetModifier(AuraType(m_spellProto
->EffectApplyAuraName
[eff
]), damage
, m_spellProto
->EffectAmplitude
[eff
], m_spellProto
->EffectMiscValue
[eff
]);
422 // Apply periodic time mod
423 if(modOwner
&& m_modifier
.periodictime
)
424 modOwner
->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME
, m_modifier
.periodictime
);
426 // Start periodic on next tick or at aura apply
427 if (!(m_spellProto
->AttributesEx5
& SPELL_ATTR_EX5_START_PERIODIC_AT_APPLY
))
428 m_periodicTimer
+= m_modifier
.periodictime
;
430 m_isDeathPersist
= IsDeathPersistentSpell(m_spellProto
);
432 m_procCharges
= m_spellProto
->procCharges
;
434 modOwner
->ApplySpellMod(GetId(), SPELLMOD_CHARGES
, m_procCharges
);
436 m_isRemovedOnShapeLost
= (m_caster_guid
==m_target
->GetGUID() &&
437 m_spellProto
->Stances
&&
438 !(m_spellProto
->AttributesEx2
& SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT
) &&
439 !(m_spellProto
->Attributes
& SPELL_ATTR_NOT_SHAPESHIFT
));
446 AreaAura::AreaAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
,
447 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
451 // caster==NULL in constructor args if target==caster in fact
452 Unit
* caster_ptr
= caster
? caster
: target
;
454 m_radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(GetSpellProto()->EffectRadiusIndex
[m_effIndex
]));
455 if(Player
* modOwner
= caster_ptr
->GetSpellModOwner())
456 modOwner
->ApplySpellMod(GetId(), SPELLMOD_RADIUS
, m_radius
);
458 switch(spellproto
->Effect
[eff
])
460 case SPELL_EFFECT_APPLY_AREA_AURA_PARTY
:
461 m_areaAuraType
= AREA_AURA_PARTY
;
462 if(target
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)target
)->isTotem())
463 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
465 case SPELL_EFFECT_APPLY_AREA_AURA_RAID
:
466 m_areaAuraType
= AREA_AURA_RAID
;
467 if(target
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)target
)->isTotem())
468 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
470 case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
:
471 m_areaAuraType
= AREA_AURA_FRIEND
;
473 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
:
474 m_areaAuraType
= AREA_AURA_ENEMY
;
475 if(target
== caster_ptr
)
476 m_modifier
.m_auraname
= SPELL_AURA_NONE
; // Do not do any effect on self
478 case SPELL_EFFECT_APPLY_AREA_AURA_PET
:
479 m_areaAuraType
= AREA_AURA_PET
;
481 case SPELL_EFFECT_APPLY_AREA_AURA_OWNER
:
482 m_areaAuraType
= AREA_AURA_OWNER
;
483 if(target
== caster_ptr
)
484 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
487 sLog
.outError("Wrong spell effect in AreaAura constructor");
493 AreaAura::~AreaAura()
497 PersistentAreaAura::PersistentAreaAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
,
498 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
500 m_isPersistent
= true;
503 PersistentAreaAura::~PersistentAreaAura()
507 SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
,
508 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
511 m_casters_target_guid
= caster
->GetTypeId()==TYPEID_PLAYER
? ((Player
*)caster
)->GetSelection() : caster
->GetUInt64Value(UNIT_FIELD_TARGET
);
513 m_casters_target_guid
= 0;
516 SingleEnemyTargetAura::~SingleEnemyTargetAura()
520 Unit
* SingleEnemyTargetAura::GetTriggerTarget() const
522 return ObjectAccessor::GetUnit(*m_target
, m_casters_target_guid
);
525 Aura
* CreateAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
, Unit
*caster
, Item
* castItem
)
527 if (IsAreaAuraEffect(spellproto
->Effect
[eff
]))
528 return new AreaAura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
530 uint32 triggeredSpellId
= spellproto
->EffectTriggerSpell
[eff
];
532 if(SpellEntry
const* triggeredSpellInfo
= sSpellStore
.LookupEntry(triggeredSpellId
))
533 for (int i
= 0; i
< 3; ++i
)
534 if (triggeredSpellInfo
->EffectImplicitTargetA
[i
] == TARGET_SINGLE_ENEMY
)
535 return new SingleEnemyTargetAura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
537 return new Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
540 Unit
* Aura::GetCaster() const
542 if(m_caster_guid
==m_target
->GetGUID())
545 //return ObjectAccessor::GetUnit(*m_target,m_caster_guid);
546 //must return caster even if it's in another grid/map
547 Unit
*unit
= ObjectAccessor::GetObjectInWorld(m_caster_guid
, (Unit
*)NULL
);
548 return unit
&& unit
->IsInWorld() ? unit
: NULL
;
551 void Aura::SetModifier(AuraType t
, int32 a
, uint32 pt
, int32 miscValue
)
553 m_modifier
.m_auraname
= t
;
554 m_modifier
.m_amount
= a
;
555 m_modifier
.m_miscvalue
= miscValue
;
556 m_modifier
.periodictime
= pt
;
559 void Aura::Update(uint32 diff
)
568 // GetEffIndex()==0 prevent double/triple apply manaPerSecond/manaPerSecondPerLevel to same spell with many auras
569 // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0
570 if(GetEffIndex()==0 && m_timeCla
<= 0)
572 if(Unit
* caster
= GetCaster())
574 Powers powertype
= Powers(m_spellProto
->powerType
);
575 int32 manaPerSecond
= m_spellProto
->manaPerSecond
+ m_spellProto
->manaPerSecondPerLevel
* caster
->getLevel();
579 if(powertype
==POWER_HEALTH
)
580 caster
->ModifyHealth(-manaPerSecond
);
582 caster
->ModifyPower(powertype
,-manaPerSecond
);
588 // Channeled aura required check distance from caster
589 if(IsChanneledSpell(m_spellProto
) && m_caster_guid
!= m_target
->GetGUID())
591 Unit
* caster
= GetCaster();
594 m_target
->RemoveAura(GetId(),GetEffIndex());
601 if (m_spellProto
->EffectRadiusIndex
[GetEffIndex()])
603 radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellProto
->EffectRadiusIndex
[GetEffIndex()]));
604 mod
= SPELLMOD_RADIUS
;
608 radius
= GetSpellMaxRange(sSpellRangeStore
.LookupEntry(m_spellProto
->rangeIndex
));
609 mod
= SPELLMOD_RANGE
;
612 if(Player
* modOwner
= caster
->GetSpellModOwner())
613 modOwner
->ApplySpellMod(GetId(), mod
, radius
,NULL
);
615 if(!caster
->IsWithinDistInMap(m_target
,radius
))
617 m_target
->RemoveAura(GetId(),GetEffIndex());
622 if(m_isPeriodic
&& (m_duration
>= 0 || m_isPassive
|| m_permanent
))
624 m_periodicTimer
-= diff
;
625 if(m_periodicTimer
<= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N
627 // update before applying (aura can be removed in TriggerSpell or PeriodicTick calls)
628 m_periodicTimer
+= m_modifier
.periodictime
;
634 void AreaAura::Update(uint32 diff
)
636 // update for the caster of the aura
637 if(m_caster_guid
== m_target
->GetGUID())
639 Unit
* caster
= m_target
;
641 if( !caster
->hasUnitState(UNIT_STAT_ISOLATED
) )
643 Unit
* owner
= caster
->GetCharmerOrOwner();
646 std::list
<Unit
*> targets
;
648 switch(m_areaAuraType
)
650 case AREA_AURA_PARTY
:
652 Group
*pGroup
= NULL
;
654 if (owner
->GetTypeId() == TYPEID_PLAYER
)
655 pGroup
= ((Player
*)owner
)->GetGroup();
659 uint8 subgroup
= ((Player
*)owner
)->GetSubGroup();
660 for(GroupReference
*itr
= pGroup
->GetFirstMember(); itr
!= NULL
; itr
= itr
->next())
662 Player
* Target
= itr
->getSource();
663 if(Target
&& Target
->isAlive() && Target
->GetSubGroup()==subgroup
&& caster
->IsFriendlyTo(Target
))
665 if(caster
->IsWithinDistInMap(Target
, m_radius
))
666 targets
.push_back(Target
);
667 Pet
*pet
= Target
->GetPet();
668 if(pet
&& pet
->isAlive() && caster
->IsWithinDistInMap(pet
, m_radius
))
669 targets
.push_back(pet
);
676 if( owner
!= caster
&& caster
->IsWithinDistInMap(owner
, m_radius
) )
677 targets
.push_back(owner
);
679 Unit
* pet
= caster
->GetPet();
680 if( pet
&& caster
->IsWithinDistInMap(pet
, m_radius
))
681 targets
.push_back(pet
);
687 Group
*pGroup
= NULL
;
689 if (owner
->GetTypeId() == TYPEID_PLAYER
)
690 pGroup
= ((Player
*)owner
)->GetGroup();
694 uint8 subgroup
= ((Player
*)owner
)->GetSubGroup();
695 for(GroupReference
*itr
= pGroup
->GetFirstMember(); itr
!= NULL
; itr
= itr
->next())
697 Player
* Target
= itr
->getSource();
698 if(Target
&& Target
->isAlive() && caster
->IsFriendlyTo(Target
))
700 if(caster
->IsWithinDistInMap(Target
, m_radius
))
701 targets
.push_back(Target
);
702 Pet
*pet
= Target
->GetPet();
703 if(pet
&& pet
->isAlive() && caster
->IsWithinDistInMap(pet
, m_radius
))
704 targets
.push_back(pet
);
711 if( owner
!= caster
&& caster
->IsWithinDistInMap(owner
, m_radius
) )
712 targets
.push_back(owner
);
714 Unit
* pet
= caster
->GetPet();
715 if( pet
&& caster
->IsWithinDistInMap(pet
, m_radius
))
716 targets
.push_back(pet
);
720 case AREA_AURA_FRIEND
:
722 CellPair
p(MaNGOS::ComputeCellPair(caster
->GetPositionX(), caster
->GetPositionY()));
724 cell
.data
.Part
.reserved
= ALL_DISTRICT
;
727 MaNGOS::AnyFriendlyUnitInObjectRangeCheck
u_check(caster
, owner
, m_radius
);
728 MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
> searcher(caster
,targets
, u_check
);
729 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
>, WorldTypeMapContainer
> world_unit_searcher(searcher
);
730 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
>, GridTypeMapContainer
> grid_unit_searcher(searcher
);
731 CellLock
<GridReadGuard
> cell_lock(cell
, p
);
732 cell_lock
->Visit(cell_lock
, world_unit_searcher
, *caster
->GetMap());
733 cell_lock
->Visit(cell_lock
, grid_unit_searcher
, *caster
->GetMap());
736 case AREA_AURA_ENEMY
:
738 CellPair
p(MaNGOS::ComputeCellPair(caster
->GetPositionX(), caster
->GetPositionY()));
740 cell
.data
.Part
.reserved
= ALL_DISTRICT
;
743 MaNGOS::AnyAoETargetUnitInObjectRangeCheck
u_check(caster
, owner
, m_radius
); // No GetCharmer in searcher
744 MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
> searcher(caster
, targets
, u_check
);
745 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
>, WorldTypeMapContainer
> world_unit_searcher(searcher
);
746 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
>, GridTypeMapContainer
> grid_unit_searcher(searcher
);
747 CellLock
<GridReadGuard
> cell_lock(cell
, p
);
748 cell_lock
->Visit(cell_lock
, world_unit_searcher
, *caster
->GetMap());
749 cell_lock
->Visit(cell_lock
, grid_unit_searcher
, *caster
->GetMap());
752 case AREA_AURA_OWNER
:
756 targets
.push_back(owner
);
761 for(std::list
<Unit
*>::iterator tIter
= targets
.begin(); tIter
!= targets
.end(); tIter
++)
763 if((*tIter
)->HasAura(GetId(), m_effIndex
))
766 if(SpellEntry
const *actualSpellInfo
= spellmgr
.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter
)->getLevel()))
768 int32 actualBasePoints
= m_currentBasePoints
;
769 // recalculate basepoints for lower rank (all AreaAura spell not use custom basepoints?)
770 if(actualSpellInfo
!= GetSpellProto())
771 actualBasePoints
= actualSpellInfo
->EffectBasePoints
[m_effIndex
];
772 AreaAura
*aur
= new AreaAura(actualSpellInfo
, m_effIndex
, &actualBasePoints
, (*tIter
), caster
, NULL
);
773 aur
->SetAuraDuration(GetAuraDuration());
774 (*tIter
)->AddAura(aur
);
780 else // aura at non-caster
782 Unit
* tmp_target
= m_target
;
783 Unit
* caster
= GetCaster();
784 uint32 tmp_spellId
= GetId(), tmp_effIndex
= m_effIndex
;
786 // WARNING: the aura may get deleted during the update
787 // DO NOT access its members after update!
790 // remove aura if out-of-range from caster (after teleport for example)
791 // or caster is isolated or caster no longer has the aura
792 // or caster is (no longer) friendly
793 bool needFriendly
= (m_areaAuraType
== AREA_AURA_ENEMY
? false : true);
794 if( !caster
|| caster
->hasUnitState(UNIT_STAT_ISOLATED
) ||
795 !caster
->IsWithinDistInMap(tmp_target
, m_radius
) ||
796 !caster
->HasAura(tmp_spellId
, tmp_effIndex
) ||
797 caster
->IsFriendlyTo(tmp_target
) != needFriendly
800 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
802 else if( m_areaAuraType
== AREA_AURA_PARTY
) // check if in same sub group
804 // not check group if target == owner or target == pet
805 if (caster
->GetCharmerOrOwnerGUID() != tmp_target
->GetGUID() && caster
->GetGUID() != tmp_target
->GetCharmerOrOwnerGUID())
807 Player
* check
= caster
->GetCharmerOrOwnerPlayerOrPlayerItself();
809 Group
*pGroup
= check
? check
->GetGroup() : NULL
;
812 Player
* checkTarget
= tmp_target
->GetCharmerOrOwnerPlayerOrPlayerItself();
813 if(!checkTarget
|| !pGroup
->SameSubGroup(check
, checkTarget
))
814 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
817 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
820 else if( m_areaAuraType
== AREA_AURA_RAID
) // TODO: fix me!
822 // not check group if target == owner or target == pet
823 if (caster
->GetCharmerOrOwnerGUID() != tmp_target
->GetGUID() && caster
->GetGUID() != tmp_target
->GetCharmerOrOwnerGUID())
825 Player
* check
= caster
->GetCharmerOrOwnerPlayerOrPlayerItself();
827 Group
*pGroup
= check
? check
->GetGroup() : NULL
;
830 Player
* checkTarget
= tmp_target
->GetCharmerOrOwnerPlayerOrPlayerItself();
832 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
835 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
838 else if( m_areaAuraType
== AREA_AURA_PET
|| m_areaAuraType
== AREA_AURA_OWNER
)
840 if( tmp_target
->GetGUID() != caster
->GetCharmerOrOwnerGUID() )
841 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
846 void PersistentAreaAura::Update(uint32 diff
)
850 // remove the aura if its caster or the dynamic object causing it was removed
851 // or if the target moves too far from the dynamic object
852 Unit
*caster
= GetCaster();
855 DynamicObject
*dynObj
= caster
->GetDynObject(GetId(), GetEffIndex());
858 if (!m_target
->IsWithinDistInMap(dynObj
, dynObj
->GetRadius()))
867 Unit
*tmp_target
= m_target
;
868 uint32 tmp_id
= GetId(), tmp_index
= GetEffIndex();
870 // WARNING: the aura may get deleted during the update
871 // DO NOT access its members after update!
875 tmp_target
->RemoveAura(tmp_id
, tmp_index
);
878 void Aura::ApplyModifier(bool apply
, bool Real
)
880 AuraType aura
= m_modifier
.m_auraname
;
884 (*this.*AuraHandler
[aura
])(apply
,Real
);
888 void Aura::_AddAura()
895 // Second aura if some spell
896 bool secondaura
= false;
897 // Try find slot for aura
898 uint8 slot
= NULL_AURA_SLOT
;
899 // Lookup for some spell auras (and get slot from it)
900 for(uint8 i
= 0; i
< m_effIndex
; i
++)
902 Unit::spellEffectPair spair
= Unit::spellEffectPair(GetId(), i
);
903 for(Unit::AuraMap::const_iterator itr
= m_target
->GetAuras().lower_bound(spair
); itr
!= m_target
->GetAuras().upper_bound(spair
); ++itr
)
905 // allow use single slot only by auras from same caster
906 if(itr
->second
->GetCasterGUID()==GetCasterGUID())
908 slot
= itr
->second
->GetAuraSlot();
917 if (!secondaura
&& m_target
->GetVisibleAurasCount() < MAX_AURAS
)
919 Unit::VisibleAuraMap
const *visibleAuras
= m_target
->GetVisibleAuras();
920 for(uint8 i
= 0; i
< MAX_AURAS
; ++i
)
922 Unit::VisibleAuraMap::const_iterator itr
= visibleAuras
->find(i
);
923 if(itr
== visibleAuras
->end())
926 // update for out of range group members (on 1 slot use)
927 m_target
->UpdateAuraForGroup(slot
);
933 Unit
* caster
= GetCaster();
935 // passive auras (except totem auras) do not get placed in the slots
936 // area auras with SPELL_AURA_NONE are not shown on target
937 if((!m_isPassive
|| (caster
&& caster
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)caster
)->isTotem())) &&
938 (m_spellProto
->Effect
[GetEffIndex()] != SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
|| m_target
!= caster
))
941 if(slot
< MAX_AURAS
) // slot found send data to client
944 SetAuraFlags((1 << GetEffIndex()) | AFLAG_NOT_CASTER
| ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION
: AFLAG_NONE
) | (IsPositive() ? AFLAG_POSITIVE
: AFLAG_NEGATIVE
));
945 SetAuraLevel(caster
? caster
->getLevel() : sWorld
.getConfig(CONFIG_MAX_PLAYER_LEVEL
));
946 SendAuraUpdate(false);
949 //*****************************************************
950 // Update target aura state flag (at 1 aura apply)
951 // TODO: Make it easer
952 //*****************************************************
955 // Sitdown on apply aura req seated
956 if (m_spellProto
->AuraInterruptFlags
& AURA_INTERRUPT_FLAG_NOT_SEATED
&& !m_target
->IsSitState())
957 m_target
->SetStandState(UNIT_STAND_STATE_SIT
);
959 // register aura diminishing on apply
960 if (getDiminishGroup() != DIMINISHING_NONE
)
961 m_target
->ApplyDiminishingAura(getDiminishGroup(),true);
963 // Update Seals information
964 if (IsSealSpell(m_spellProto
))
965 m_target
->ModifyAuraState(AURA_STATE_JUDGEMENT
, true);
967 // Conflagrate aura state on Immolate
968 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARLOCK
&& m_spellProto
->SpellFamilyFlags
& 4)
969 m_target
->ModifyAuraState(AURA_STATE_IMMOLATE
, true);
971 // Faerie Fire (druid versions)
972 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_DRUID
&& m_spellProto
->SpellFamilyFlags
& 0x0000000000000400LL
)
973 m_target
->ModifyAuraState(AURA_STATE_FAERIE_FIRE
, true);
976 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& m_spellProto
->SpellFamilyFlags
& 0x0004000000000000LL
)
977 m_target
->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH
, true);
979 // Swiftmend state on Regrowth & Rejuvenation
980 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_DRUID
&& m_spellProto
->SpellFamilyFlags
& 0x50 )
981 m_target
->ModifyAuraState(AURA_STATE_SWIFTMEND
, true);
983 // Deadly poison aura state
984 if(m_spellProto
->SpellFamilyName
== SPELLFAMILY_ROGUE
&& m_spellProto
->SpellFamilyFlags
& 0x10000)
985 m_target
->ModifyAuraState(AURA_STATE_DEADLY_POISON
, true);
988 if(m_spellProto
->Dispel
== DISPEL_ENRAGE
)
989 m_target
->ModifyAuraState(AURA_STATE_ENRAGE
, true);
994 void Aura::_RemoveAura()
996 // Remove all triggered by aura spells vs unlimited duration
997 // except same aura replace case
998 if(m_removeMode
!=AURA_REMOVE_BY_STACK
)
999 CleanupTriggeredSpells();
1001 Unit
* caster
= GetCaster();
1003 if(caster
&& IsPersistent())
1005 DynamicObject
*dynObj
= caster
->GetDynObject(GetId(), GetEffIndex());
1007 dynObj
->RemoveAffected(m_target
);
1010 //passive auras do not get put in slots
1011 // Note: but totem can be not accessible for aura target in time remove (to far for find in grid)
1012 //if(m_isPassive && !(caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem()))
1015 uint8 slot
= GetAuraSlot();
1017 if(slot
>= MAX_AURAS
) // slot not set
1020 if(m_target
->GetVisibleAura(slot
) == 0)
1023 bool lastaura
= true;
1025 // find other aura in same slot (current already removed from list)
1026 for(uint8 i
= 0; i
< 3; i
++)
1028 Unit::spellEffectPair spair
= Unit::spellEffectPair(GetId(), i
);
1029 for(Unit::AuraMap::const_iterator itr
= m_target
->GetAuras().lower_bound(spair
); itr
!= m_target
->GetAuras().upper_bound(spair
); ++itr
)
1031 if(itr
->second
->GetAuraSlot()==slot
)
1041 // only remove icon when the last aura of the spell is removed (current aura already removed from list)
1044 // unregister aura diminishing (and store last time)
1045 if (getDiminishGroup() != DIMINISHING_NONE
)
1046 m_target
->ApplyDiminishingAura(getDiminishGroup(),false);
1049 SetAuraFlags(AFLAG_NONE
);
1051 SendAuraUpdate(true);
1053 // update for out of range group members
1054 m_target
->UpdateAuraForGroup(slot
);
1056 //*****************************************************
1057 // Update target aura state flag (at last aura remove)
1058 //*****************************************************
1059 // Enrage aura state
1060 if(m_spellProto
->Dispel
== DISPEL_ENRAGE
)
1061 m_target
->ModifyAuraState(AURA_STATE_ENRAGE
, false);
1063 uint32 removeState
= 0;
1064 switch(m_spellProto
->SpellFamilyName
)
1066 case SPELLFAMILY_PALADIN
:
1067 if (IsSealSpell(m_spellProto
))
1068 removeState
= AURA_STATE_JUDGEMENT
; // Update Seals information
1070 case SPELLFAMILY_WARLOCK
:
1071 if(m_spellProto
->SpellFamilyFlags
& 4)
1072 removeState
= AURA_STATE_IMMOLATE
; // Conflagrate aura state
1074 case SPELLFAMILY_DRUID
:
1075 if(m_spellProto
->SpellFamilyFlags
& 0x0000000000000400LL
)
1076 removeState
= AURA_STATE_FAERIE_FIRE
; // Faerie Fire (druid versions)
1077 else if(m_spellProto
->SpellFamilyFlags
& 0x50)
1078 removeState
= AURA_STATE_SWIFTMEND
; // Swiftmend aura state
1080 case SPELLFAMILY_WARRIOR
:
1081 if(m_spellProto
->SpellFamilyFlags
& 0x0004000000000000LL
)
1082 removeState
= AURA_STATE_WARRIOR_VICTORY_RUSH
; // Victorious
1084 case SPELLFAMILY_ROGUE
:
1085 if(m_spellProto
->SpellFamilyFlags
& 0x10000)
1086 removeState
= AURA_STATE_DEADLY_POISON
; // Deadly poison aura state
1088 case SPELLFAMILY_HUNTER
:
1089 if(m_spellProto
->SpellFamilyFlags
& 0x1000000000000000LL
)
1090 removeState
= AURA_STATE_FAERIE_FIRE
; // Sting (hunter versions)
1093 // Remove state (but need check other auras for it)
1097 Unit::AuraMap
& Auras
= m_target
->GetAuras();
1098 for(Unit::AuraMap::iterator i
= Auras
.begin(); i
!= Auras
.end(); ++i
)
1100 SpellEntry
const *auraSpellInfo
= (*i
).second
->GetSpellProto();
1101 if(auraSpellInfo
->SpellFamilyName
== m_spellProto
->SpellFamilyName
&&
1102 auraSpellInfo
->SpellFamilyFlags
== m_spellProto
->SpellFamilyFlags
)
1108 // this has been last aura
1110 m_target
->ModifyAuraState(AuraState(removeState
), false);
1113 // reset cooldown state for spells
1114 if(caster
&& caster
->GetTypeId() == TYPEID_PLAYER
)
1116 if ( GetSpellProto()->Attributes
& SPELL_ATTR_DISABLED_WHILE_ACTIVE
)
1117 ((Player
*)caster
)->SendCooldownEvent(GetSpellProto());
1122 void Aura::SendAuraUpdate(bool remove
)
1124 WorldPacket
data(SMSG_AURA_UPDATE
);
1125 data
.append(m_target
->GetPackGUID());
1126 data
<< uint8(GetAuraSlot());
1127 data
<< uint32(remove
? 0 : GetId());
1131 m_target
->SendMessageToSet(&data
, true);
1135 uint8 auraFlags
= GetAuraFlags();
1136 data
<< uint8(auraFlags
);
1137 data
<< uint8(GetAuraLevel());
1138 data
<< uint8(m_procCharges
? m_procCharges
: m_stackAmount
);
1140 if(!(auraFlags
& AFLAG_NOT_CASTER
))
1142 data
<< uint8(0); // pguid
1145 if(auraFlags
& AFLAG_DURATION
)
1147 data
<< uint32(GetAuraMaxDuration());
1148 data
<< uint32(GetAuraDuration());
1151 m_target
->SendMessageToSet(&data
, true);
1154 void Aura::SetStackAmount(uint8 stackAmount
)
1156 if (stackAmount
!= m_stackAmount
)
1158 Unit
*target
= GetTarget();
1159 Unit
*caster
= GetCaster();
1160 if (!target
|| !caster
)
1162 m_stackAmount
= stackAmount
;
1163 int32 amount
= m_stackAmount
* caster
->CalculateSpellDamage(m_spellProto
, m_effIndex
, m_currentBasePoints
, target
);
1164 // Reapply if amount change
1165 if (amount
!=m_modifier
.m_amount
)
1167 ApplyModifier(false, true);
1168 m_modifier
.m_amount
= amount
;
1169 ApplyModifier(true, true);
1175 bool Aura::modStackAmount(int32 num
)
1178 if (!m_spellProto
->StackAmount
)
1181 // Modify stack but limit it
1182 int32 stackAmount
= m_stackAmount
+ num
;
1183 if (stackAmount
> m_spellProto
->StackAmount
)
1184 stackAmount
= m_spellProto
->StackAmount
;
1185 else if (stackAmount
<=0) // Last aura from stack removed
1188 return true; // need remove aura
1191 // Update stack amount
1192 SetStackAmount(stackAmount
);
1196 void Aura::RefreshAura()
1198 m_duration
= m_maxduration
;
1199 SendAuraUpdate(false);
1202 bool Aura::isAffectedOnSpell(SpellEntry
const *spell
) const
1204 // Check family name
1205 if (spell
->SpellFamilyName
!= m_spellProto
->SpellFamilyName
)
1207 // Check EffectClassMask
1208 uint32
const *ptr
= getAuraSpellClassMask();
1209 if (((uint64
*)ptr
)[0] & spell
->SpellFamilyFlags
)
1211 if (ptr
[2] & spell
->SpellFamilyFlags2
)
1216 /*********************************************************/
1217 /*** BASIC AURA FUNCTION ***/
1218 /*********************************************************/
1219 void Aura::HandleAddModifier(bool apply
, bool Real
)
1221 if(m_target
->GetTypeId() != TYPEID_PLAYER
|| !Real
)
1224 if(m_modifier
.m_miscvalue
>= MAX_SPELLMOD
)
1229 // Add custom charges for some mod aura
1230 switch (m_spellProto
->Id
)
1232 case 17941: // Shadow Trance
1233 case 22008: // Netherwind Focus
1234 case 31834: // Light's Grace
1235 case 34754: // Clearcasting
1236 case 34936: // Backlash
1237 case 48108: // Hot Streak
1238 case 54741: // Firestarter
1239 case 57761: // Fireball!
1244 SpellModifier
*mod
= new SpellModifier
;
1245 mod
->op
= SpellModOp(m_modifier
.m_miscvalue
);
1246 mod
->value
= m_modifier
.m_amount
;
1247 mod
->type
= SpellModType(m_modifier
.m_auraname
); // SpellModType value == spell aura types
1248 mod
->spellId
= GetId();
1251 SpellAffectEntry
const *spellAffect
= spellmgr
.GetSpellAffect(GetId(), m_effIndex
);
1253 ptr
= &spellAffect
->SpellClassMask
[0];
1258 case 0: ptr
= &m_spellProto
->EffectSpellClassMaskA
[0]; break;
1259 case 1: ptr
= &m_spellProto
->EffectSpellClassMaskB
[0]; break;
1260 case 2: ptr
= &m_spellProto
->EffectSpellClassMaskC
[0]; break;
1266 mod
->mask
= (uint64
)ptr
[0] | (uint64
)ptr
[1]<<32;
1267 mod
->mask2
= (uint64
)ptr
[2];
1268 mod
->charges
= m_procCharges
;
1273 uint64 spellFamilyMask
= m_spellmod
->mask
;
1275 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
1277 // reapply some passive spells after add/remove related spellmods
1278 if(m_spellProto
->SpellFamilyName
==SPELLFAMILY_WARRIOR
&& (spellFamilyMask
& 0x0000100000000000LL
))
1280 m_target
->RemoveAurasDueToSpell(45471);
1283 m_target
->CastSpell(m_target
,45471,true);
1286 void Aura::HandleAddTargetTrigger(bool apply
, bool Real
)
1288 // Use SpellModifier structure for check
1289 // used only fields:
1290 // spellId, mask, mask2
1293 SpellModifier
*mod
= new SpellModifier
;
1294 mod
->spellId
= GetId();
1297 SpellAffectEntry
const *spellAffect
= spellmgr
.GetSpellAffect(GetId(), m_effIndex
);
1299 ptr
= &spellAffect
->SpellClassMask
[0];
1304 case 0: ptr
= &m_spellProto
->EffectSpellClassMaskA
[0]; break;
1305 case 1: ptr
= &m_spellProto
->EffectSpellClassMaskB
[0]; break;
1306 case 2: ptr
= &m_spellProto
->EffectSpellClassMaskC
[0]; break;
1312 mod
->mask
= (uint64
)ptr
[0] | (uint64
)ptr
[1]<<32;
1313 mod
->mask2
= (uint64
)ptr
[2];
1323 void Aura::TriggerSpell()
1325 Unit
* caster
= GetCaster();
1326 Unit
* target
= GetTriggerTarget();
1328 if(!caster
|| !target
)
1331 // generic casting code with custom spells and target/caster customs
1332 uint32 trigger_spell_id
= GetSpellProto()->EffectTriggerSpell
[m_effIndex
];
1334 SpellEntry
const *triggeredSpellInfo
= sSpellStore
.LookupEntry(trigger_spell_id
);
1335 SpellEntry
const *auraSpellInfo
= GetSpellProto();
1336 uint32 auraId
= auraSpellInfo
->Id
;
1338 // specific code for cases with no trigger spell provided in field
1339 if (triggeredSpellInfo
== NULL
)
1341 switch(auraSpellInfo
->SpellFamilyName
)
1343 case SPELLFAMILY_GENERIC
:
1347 // Firestone Passive (1-5 ranks)
1354 if (caster
->GetTypeId()!=TYPEID_PLAYER
)
1356 Item
* item
= ((Player
*)caster
)->GetWeaponForAttack(BASE_ATTACK
);
1359 uint32 enchant_id
= 0;
1362 case 758: enchant_id
= 1803; break; // Rank 1
1363 case 17945: enchant_id
= 1823; break; // Rank 2
1364 case 17947: enchant_id
= 1824; break; // Rank 3
1365 case 17949: enchant_id
= 1825; break; // Rank 4
1366 case 27252: enchant_id
= 2645; break; // Rank 5
1370 // remove old enchanting before applying new
1371 ((Player
*)caster
)->ApplyEnchantment(item
,TEMP_ENCHANTMENT_SLOT
,false);
1372 item
->SetEnchantment(TEMP_ENCHANTMENT_SLOT
, enchant_id
, m_modifier
.periodictime
+1000, 0);
1373 // add new enchanting
1374 ((Player
*)caster
)->ApplyEnchantment(item
,TEMP_ENCHANTMENT_SLOT
,true);
1377 // // Periodic Mana Burn
1379 // // Polymorphic Ray
1380 // case 6965: break;
1381 // // Fire Nova (1-7 ranks)
1390 // Thaumaturgy Channel
1391 case 9712: trigger_spell_id
= 21029; break;
1392 // // Egan's Blaster
1393 // case 17368: break;
1395 // case 18347: break;
1396 // // Ranshalla Waiting
1397 // case 18953: break;
1399 // case 19695: break;
1400 // // Frostwolf Muzzle DND
1401 // case 21794: break;
1402 // // Alterac Ram Collar DND
1403 // case 21866: break;
1404 // // Celebras Waiting
1405 // case 21916: break;
1406 // Brood Affliction: Bronze
1409 m_target
->CastSpell(m_target
, 23171, true, 0, this);
1413 // case 23184: break;
1417 int32 heal
= caster
->GetMaxHealth() / 10;
1418 caster
->ModifyHealth( heal
);
1419 caster
->SendHealSpellLog(caster
, 23493, heal
);
1421 int32 mana
= caster
->GetMaxPower(POWER_MANA
);
1425 caster
->ModifyPower( POWER_MANA
, mana
);
1426 caster
->SendEnergizeSpellLog(caster
, 23493, mana
, POWER_MANA
);
1430 // // Stoneclaw Totem Passive TEST
1431 // case 23792: break;
1433 // case 24018: break;
1434 // // Mark of Arlokk
1435 // case 24210: break;
1437 // case 24379: break;
1439 // case 24716: break;
1441 // case 24780: break;
1443 // case 24832: break;
1444 // // Shadow Bolt Whirl
1445 // case 24834: break;
1447 // case 24918: break;
1448 // // Mark of Nature
1449 // case 25041: break;
1451 // case 25152: break;
1453 // case 25371: break;
1455 // case 25572: break;
1457 // case 26009: break;
1459 // case 26136: break;
1461 // case 26196: break;
1463 // case 26615: break;
1465 // case 27177: break;
1466 // // Teleport: IF/UC
1467 // case 27601: break;
1468 // // Five Fat Finger Exploding Heart Technique
1469 // case 27673: break;
1471 // case 27746: break;
1472 // // Steam Tank Passive
1473 // case 27747: break;
1475 // case 27808: break;
1477 // case 27819: break;
1478 // // Controller Timer
1479 // case 28095: break;
1481 // case 28096: break;
1482 // // Stalagg Tesla Passive
1483 // case 28097: break;
1484 // // Feugen Tesla Passive
1485 // case 28109: break;
1487 // case 28111: break;
1488 // // Mark of Didier
1489 // case 28114: break;
1490 // // Communique Timer, camp
1491 // case 28346: break;
1493 // case 28522: break;
1495 // case 29519: break;
1496 // // Inoculate Nestlewood Owlkin
1497 case 29528: trigger_spell_id
= 28713; break;
1499 // case 29768: break;
1501 // case 29788: break;
1503 // case 29793: break;
1505 // case 29794: break;
1506 // // Guardian of Icecrown Passive
1507 // case 29897: break;
1508 // Feed Captured Animal
1509 case 29917: trigger_spell_id
= 29916; break;
1511 // case 29946: break;
1513 // case 29947: break;
1514 // // Mind Exhaustion Passive
1515 // case 30025: break;
1516 // // Nether Beam - Serenity
1517 // case 30401: break;
1521 // move loot to player inventory and despawn target
1522 if(caster
->GetTypeId() ==TYPEID_PLAYER
&&
1523 target
->GetTypeId() == TYPEID_UNIT
&&
1524 ((Creature
*)target
)->GetCreatureInfo()->type
== CREATURE_TYPE_GAS_CLOUD
)
1526 Player
* player
= (Player
*)caster
;
1527 Creature
* creature
= (Creature
*)target
;
1528 // missing lootid has been reported on startup - just return
1529 if (!creature
->GetCreatureInfo()->SkinLootId
)
1532 player
->AutoStoreLoot(creature
->GetCreatureInfo()->SkinLootId
,LootTemplates_Skinning
,true);
1534 creature
->setDeathState(JUST_DIED
);
1535 creature
->RemoveCorpse();
1536 creature
->SetHealth(0); // just for nice GM-mode view
1542 case 30576: trigger_spell_id
= 30571; break;
1544 // case 30598: break;
1550 // // Despawn Self - Smoke cloud
1551 // case 31269: break;
1552 // // Time Rift Periodic
1553 // case 31320: break;
1554 // // Corrupt Medivh
1555 // case 31326: break;
1559 m_target
->CastSpell(m_target
,31350,true);
1560 m_target
->DealDamage(m_target
, m_target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
1566 // Summon Elemental after create item
1567 caster
->SummonCreature(17870, 0, 0, 0, caster
->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN
, 0);
1570 // // Bloodmyst Tesla
1571 // case 31611: break;
1573 // case 31944: break;
1575 // case 32236: break;
1577 // case 32686: break;
1579 // case 33401: break;
1581 // case 33563: break;
1582 // // Murmur's Touch
1583 // case 33711: break;
1587 // cast 24 spells 34269-34289, 34314-34316
1588 for(uint32 spell_id
= 34269; spell_id
!= 34290; ++spell_id
)
1589 caster
->CastSpell(m_target
,spell_id
,true);
1590 for(uint32 spell_id
= 34314; spell_id
!= 34317; ++spell_id
)
1591 caster
->CastSpell(m_target
,spell_id
,true);
1595 // case 34480: break;
1597 // case 34683: break;
1598 // // Frostbite Rotate
1599 // case 34748: break;
1601 // case 34821: break;
1602 // // Interrupt Shutdown
1603 // case 35016: break;
1604 // // Interrupt Shutdown
1605 // case 35176: break;
1607 // case 35268: break;
1608 // // Salaadin's Tesla
1609 // case 35515: break;
1610 // // Ethereal Channel (Red)
1611 // case 35518: break;
1613 // case 35879: break;
1614 // // Dark Portal Storm
1615 // case 36018: break;
1617 // case 36056: break;
1618 // // Living Grove Defender Lifespan
1619 // case 36061: break;
1620 // // Professor Dabiri Talks
1621 // case 36064: break;
1622 // // Kael Gaining Power
1623 // case 36091: break;
1624 // // They Must Burn Bomb Aura
1625 // case 36344: break;
1626 // // They Must Burn Bomb Aura (self)
1627 // case 36350: break;
1628 // // Stolen Ravenous Ravager Egg
1629 // case 36401: break;
1630 // // Activated Cannon
1631 // case 36410: break;
1632 // // Stolen Ravenous Ravager Egg
1633 // case 36418: break;
1634 // // Enchanted Weapons
1635 // case 36510: break;
1636 // // Cursed Scarab Periodic
1637 // case 36556: break;
1638 // // Cursed Scarab Despawn Periodic
1639 // case 36561: break;
1641 // case 36573: break;
1642 // // Cannon Charging (platform)
1643 // case 36785: break;
1644 // // Cannon Charging (self)
1645 // case 36860: break;
1647 case 37027: trigger_spell_id
= 37029; break;
1649 // case 37125: break;
1651 // case 37268: break;
1653 // case 37429: break;
1655 // case 37430: break;
1656 // // Karazhan - Chess NPC AI, Snapshot timer
1657 // case 37440: break;
1658 // // Karazhan - Chess NPC AI, action timer
1659 // case 37504: break;
1660 // // Karazhan - Chess: Is Square OCCUPIED aura (DND)
1661 // case 39400: break;
1663 // case 37546: break;
1664 // // Shriveling Gaze
1665 // case 37589: break;
1666 // // Fake Aggro Radius (2 yd)
1667 // case 37815: break;
1668 // // Corrupt Medivh
1669 // case 37853: break;
1673 m_target
->CastSpell(m_target
, 38530, true);
1676 // Absorb Eye of Grillok (Zezzak's Shard)
1679 if(m_target
->GetTypeId() != TYPEID_UNIT
)
1682 caster
->CastSpell(caster
, 38495, true);
1684 Creature
* creatureTarget
= (Creature
*)m_target
;
1686 creatureTarget
->setDeathState(JUST_DIED
);
1687 creatureTarget
->RemoveCorpse();
1688 creatureTarget
->SetHealth(0); // just for nice GM-mode view
1691 // // Magic Sucker Device timer
1692 // case 38672: break;
1693 // // Tomb Guarding Charging
1694 // case 38751: break;
1695 // // Murmur's Touch
1696 // case 38794: break;
1697 // // Activate Nether-wraith Beacon (31742 Nether-wraith Beacon item)
1698 // case 39105: break;
1699 // // Drain World Tree Visual
1700 // case 39140: break;
1701 // // Quest - Dustin's Undead Dragon Visual aura
1702 // case 39259: break;
1703 // // Hellfire - The Exorcism, Jules releases darkness, aura
1704 // case 39306: break;
1706 // case 39346: break;
1707 // // Enchanted Weapons
1708 // case 39489: break;
1709 // // Shadow Bolt Whirl
1710 // case 39630: break;
1711 // // Shadow Bolt Whirl
1712 // case 39634: break;
1713 // // Shadow Inferno
1714 // case 39645: break;
1715 // Tear of Azzinoth Summon Channel - it's not really supposed to do anything,and this only prevents the console spam
1716 case 39857: trigger_spell_id
= 39856; break;
1717 // // Soulgrinder Ritual Visual (Smashed)
1718 // case 39974: break;
1719 // // Simon Game Pre-game timer
1720 // case 40041: break;
1721 // // Knockdown Fel Cannon: The Aggro Check Aura
1722 // case 40113: break;
1724 // case 40157: break;
1725 // // Demon Transform 2
1726 // case 40398: break;
1727 // // Demon Transform 1
1728 // case 40511: break;
1729 // // Ancient Flames
1730 // case 40657: break;
1731 // // Ethereal Ring Cannon: Cannon Aura
1732 // case 40734: break;
1734 // case 40760: break;
1735 // // Random Periodic
1736 // case 40867: break;
1737 // // Prismatic Shield
1738 // case 40879: break;
1739 // // Aura of Desire
1740 // case 41350: break;
1742 // case 41404: break;
1744 // case 41629: break;
1746 // case 42177: break;
1748 // case 42581: break;
1750 // case 42582: break;
1751 // // Return to the Spirit Realm
1752 // case 44035: break;
1753 // // Curse of Boundless Agony
1754 // case 45050: break;
1756 // case 46240: break;
1757 // Personalized Weather
1758 case 46736: trigger_spell_id
= 46737; break;
1759 // // Stay Submerged
1760 // case 46981: break;
1761 // // Dragonblight Ram
1762 // case 47015: break;
1763 // // Party G.R.E.N.A.D.E.
1764 // case 51510: break;
1770 case SPELLFAMILY_MAGE
:
1776 // Here need periodic triger reducing threat spell (or do it manually)
1783 // case SPELLFAMILY_WARRIOR:
1788 // case 23410: break;
1789 // // Corrupted Totems
1790 // case 23425: break;
1796 // case SPELLFAMILY_PRIEST:
1801 // case 32930: break;
1802 // // Fury of the Dreghood Elders
1803 // case 35460: break;
1809 case SPELLFAMILY_DRUID
:
1814 // trigger_spell_id not set and unknown effect triggered in this case, ignoring for while
1817 // Frenzied Regeneration
1823 int32 LifePerRage
= GetModifier()->m_amount
;
1825 int32 lRage
= m_target
->GetPower(POWER_RAGE
);
1826 if(lRage
> 100) // rage stored as rage*10
1828 m_target
->ModifyPower(POWER_RAGE
, -lRage
);
1829 int32 FRTriggerBasePoints
= int32(lRage
*LifePerRage
/10);
1830 m_target
->CastCustomSpell(m_target
,22845,&FRTriggerBasePoints
,NULL
,NULL
,true,NULL
,this);
1839 // case SPELLFAMILY_HUNTER:
1843 // //Frost Trap Aura
1846 // //Rizzle's Frost Trap
1850 // case 19597: // Tame Ice Claw Bear
1851 // case 19676: // Tame Snow Leopard
1852 // case 19677: // Tame Large Crag Boar
1853 // case 19678: // Tame Adult Plainstrider
1854 // case 19679: // Tame Prairie Stalker
1855 // case 19680: // Tame Swoop
1856 // case 19681: // Tame Dire Mottled Boar
1857 // case 19682: // Tame Surf Crawler
1858 // case 19683: // Tame Armored Scorpid
1859 // case 19684: // Tame Webwood Lurker
1860 // case 19685: // Tame Nightsaber Stalker
1861 // case 19686: // Tame Strigid Screecher
1862 // case 30100: // Tame Crazed Dragonhawk
1863 // case 30103: // Tame Elder Springpaw
1864 // case 30104: // Tame Mistbat
1865 // case 30647: // Tame Barbed Crawler
1866 // case 30648: // Tame Greater Timberstrider
1867 // case 30652: // Tame Nightstalker
1874 case SPELLFAMILY_SHAMAN
:
1878 // Lightning Shield (The Earthshatterer set trigger after cast Lighting Shield)
1881 // Need remove self if Lightning Shield not active
1882 Unit::AuraMap
const& auras
= target
->GetAuras();
1883 for(Unit::AuraMap::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
1885 SpellEntry
const* spell
= itr
->second
->GetSpellProto();
1886 if( spell
->SpellFamilyName
== SPELLFAMILY_SHAMAN
&&
1887 spell
->SpellFamilyFlags
& 0x0000000000000400L
)
1890 target
->RemoveAurasDueToSpell(28820);
1893 // Totemic Mastery (Skyshatter Regalia (Shaman Tier 6) - bonus)
1897 for(int i
= 0; i
< MAX_TOTEM
; ++i
)
1899 if(!caster
->m_TotemSlot
[i
])
1907 caster
->CastSpell(caster
,38437,true);
1909 caster
->RemoveAurasDueToSpell(38437);
1920 // Reget trigger spell proto
1921 triggeredSpellInfo
= sSpellStore
.LookupEntry(trigger_spell_id
);
1922 if(triggeredSpellInfo
== NULL
)
1924 sLog
.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex());
1930 // Spell exist but require custom code
1936 // TODO: spell casted by result in correct way mostly
1938 // 1) target show casting at each triggered cast: target don't must show casting animation for any triggered spell
1939 // but must show affect apply like item casting
1940 // 2) maybe aura must be replace by new with accumulative stat mods instead stacking
1942 // prevent cast by triggered auras
1943 if(m_caster_guid
== m_target
->GetGUID())
1946 // stop triggering after each affected stats lost > 90
1947 int32 intelectLoss
= 0;
1948 int32 spiritLoss
= 0;
1950 Unit::AuraList
const& mModStat
= m_target
->GetAurasByType(SPELL_AURA_MOD_STAT
);
1951 for(Unit::AuraList::const_iterator i
= mModStat
.begin(); i
!= mModStat
.end(); ++i
)
1953 if ((*i
)->GetId() == 1010)
1955 switch((*i
)->GetModifier()->m_miscvalue
)
1957 case STAT_INTELLECT
: intelectLoss
+= (*i
)->GetModifier()->m_amount
; break;
1958 case STAT_SPIRIT
: spiritLoss
+= (*i
)->GetModifier()->m_amount
; break;
1964 if(intelectLoss
<= -90 && spiritLoss
<= -90)
1973 caster
->CastCustomSpell(target
, trigger_spell_id
, &m_modifier
.m_amount
, NULL
, NULL
, true, NULL
, this);
1978 // All ok cast by default case
1979 caster
->CastSpell(target
, triggeredSpellInfo
, true, 0, this);
1982 void Aura::TriggerSpellWithValue()
1984 Unit
* caster
= GetCaster();
1985 Unit
* target
= GetTriggerTarget();
1987 if(!caster
|| !target
)
1990 // generic casting code with custom spells and target/caster customs
1991 uint32 trigger_spell_id
= GetSpellProto()->EffectTriggerSpell
[m_effIndex
];
1992 int32 basepoints0
= this->GetModifier()->m_amount
;
1994 caster
->CastCustomSpell(target
, trigger_spell_id
, &basepoints0
, 0, 0, true, 0, this);
1997 /*********************************************************/
1998 /*** AURA EFFECTS ***/
1999 /*********************************************************/
2001 void Aura::HandleAuraDummy(bool apply
, bool Real
)
2003 // spells required only Real aura add/remove
2007 Unit
* caster
= GetCaster();
2014 case 1515: // Tame beast
2015 // FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness
2016 if( caster
&& m_target
->CanHaveThreatList())
2017 m_target
->AddThreat(caster
, 10.0f
);
2019 case 13139: // net-o-matic
2020 // root to self part of (root_target->charge->root_self sequence
2022 caster
->CastSpell(caster
,13138,true,NULL
,this);
2024 case 39850: // Rocket Blast
2025 if(roll_chance_i(20)) // backfire stun
2026 m_target
->CastSpell(m_target
, 51581, true, NULL
, this);
2028 case 43873: // Headless Horseman Laugh
2029 if(caster
->GetTypeId() == TYPEID_PLAYER
)
2030 ((Player
*)caster
)->PlaySound(11965, false);
2032 case 46354: // Blood Elf Illusion
2035 switch(caster
->getGender())
2038 caster
->CastSpell(m_target
,46356,true,NULL
,this);
2041 caster
->CastSpell(m_target
,46355,true,NULL
,this);
2048 case 46699: // Requires No Ammo
2049 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
2050 ((Player
*)m_target
)->RemoveAmmo(); // not use ammo and not allow use
2055 if ( caster
&& GetSpellProto()->SpellFamilyName
== SPELLFAMILY_SHAMAN
&& (GetSpellProto()->SpellFamilyFlags
& 0x40000000000LL
))
2057 // prevent double apply bonuses
2058 if(m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading())
2059 m_modifier
.m_amount
= caster
->SpellHealingBonus(m_target
, GetSpellProto(), m_modifier
.m_amount
, SPELL_DIRECT_DAMAGE
);
2066 if( m_target
->GetTypeId() == TYPEID_PLAYER
&&
2067 ( GetSpellProto()->Effect
[0]==72 || GetSpellProto()->Effect
[0]==6 &&
2068 ( GetSpellProto()->EffectApplyAuraName
[0]==1 || GetSpellProto()->EffectApplyAuraName
[0]==128 ) ) )
2070 // spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425
2071 ((Player
*)m_target
)->SetFarSightGUID(0);
2072 WorldPacket
data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE
, 0);
2073 ((Player
*)m_target
)->GetSession()->SendPacket(&data
);
2077 if( (IsQuestTameSpell(GetId())) && caster
&& caster
->isAlive() && m_target
->isAlive())
2079 uint32 finalSpelId
= 0;
2082 case 19548: finalSpelId
= 19597; break;
2083 case 19674: finalSpelId
= 19677; break;
2084 case 19687: finalSpelId
= 19676; break;
2085 case 19688: finalSpelId
= 19678; break;
2086 case 19689: finalSpelId
= 19679; break;
2087 case 19692: finalSpelId
= 19680; break;
2088 case 19693: finalSpelId
= 19684; break;
2089 case 19694: finalSpelId
= 19681; break;
2090 case 19696: finalSpelId
= 19682; break;
2091 case 19697: finalSpelId
= 19683; break;
2092 case 19699: finalSpelId
= 19685; break;
2093 case 19700: finalSpelId
= 19686; break;
2094 case 30646: finalSpelId
= 30647; break;
2095 case 30653: finalSpelId
= 30648; break;
2096 case 30654: finalSpelId
= 30652; break;
2097 case 30099: finalSpelId
= 30100; break;
2098 case 30102: finalSpelId
= 30103; break;
2099 case 30105: finalSpelId
= 30104; break;
2103 caster
->CastSpell(m_target
,finalSpelId
,true,NULL
,this);
2107 // Waiting to Resurrect
2110 // Waiting to resurrect spell cancel, we must remove player from resurrect queue
2111 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2112 if(BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround())
2113 bg
->RemovePlayerFromResurrectQueue(m_target
->GetGUID());
2120 // Kill target if dispelled
2121 if (m_removeMode
==AURA_REMOVE_BY_DISPEL
)
2122 m_target
->DealDamage(m_target
, m_target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
2127 if(GetId()==46308) // casted only at creatures at spawn
2129 m_target
->CastSpell(m_target
,47287,true,NULL
,this);
2133 if (caster
&& m_removeMode
== AURA_REMOVE_BY_DEATH
)
2135 // Stop caster Arcane Missle chanelling on death
2136 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_MAGE
&&
2137 m_spellProto
->SpellFamilyFlags
&0x0000000000000800LL
)
2139 caster
->InterruptSpell(CURRENT_CHANNELED_SPELL
);
2142 // Stop caster Penance chanelling on death
2143 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_PRIEST
&&
2144 m_spellProto
->SpellFamilyFlags2
& 0x00000080)
2146 caster
->InterruptSpell(CURRENT_CHANNELED_SPELL
);
2153 // AT APPLY & REMOVE
2155 switch(m_spellProto
->SpellFamilyName
)
2157 case SPELLFAMILY_GENERIC
:
2160 if( GetId()==24658 )
2162 uint32 spellId
= 24659;
2165 const SpellEntry
*spell
= sSpellStore
.LookupEntry(spellId
);
2168 for (int i
=0; i
< spell
->StackAmount
; ++i
)
2169 caster
->CastSpell(m_target
, spell
->Id
, true, NULL
, NULL
, GetCasterGUID());
2172 m_target
->RemoveAurasDueToSpell(spellId
);
2175 // Restless Strength
2176 if( GetId()==24661 )
2178 uint32 spellId
= 24662;
2181 const SpellEntry
*spell
= sSpellStore
.LookupEntry(spellId
);
2184 for (int i
=0; i
< spell
->StackAmount
; ++i
)
2185 caster
->CastSpell(m_target
, spell
->Id
, true, NULL
, NULL
, GetCasterGUID());
2188 m_target
->RemoveAurasDueToSpell(spellId
);
2191 //Summon Fire Elemental
2192 if (GetId() == 40133 && caster
)
2194 Unit
*owner
= caster
->GetOwner();
2195 if (owner
&& owner
->GetTypeId() == TYPEID_PLAYER
)
2198 owner
->CastSpell(owner
,8985,true);
2200 ((Player
*)owner
)->RemovePet(NULL
, PET_SAVE_NOT_IN_SLOT
, true);
2205 //Summon Earth Elemental
2206 if (GetId() == 40132 && caster
)
2208 Unit
*owner
= caster
->GetOwner();
2209 if (owner
&& owner
->GetTypeId() == TYPEID_PLAYER
)
2212 owner
->CastSpell(owner
,19704,true);
2214 ((Player
*)owner
)->RemovePet(NULL
, PET_SAVE_NOT_IN_SLOT
, true);
2220 case SPELLFAMILY_MAGE
:
2224 case SPELLFAMILY_PRIEST
:
2226 // Pain and Suffering
2227 if( m_spellProto
->SpellIconID
== 2874 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2231 // Reduce backfire damage (dot damage) from Shadow Word: Death
2232 SpellModifier
*mod
= new SpellModifier
;
2233 mod
->op
= SPELLMOD_DOT
;
2234 mod
->value
= m_modifier
.m_amount
;
2235 mod
->type
= SPELLMOD_PCT
;
2236 mod
->spellId
= GetId();
2237 mod
->mask
= 0x0000000200000000LL
;
2241 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2246 case SPELLFAMILY_DRUID
:
2249 if ( GetSpellProto()->SpellFamilyFlags
& 0x1000000000LL
)
2254 // prevent double apply bonuses
2255 if(m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading())
2256 m_modifier
.m_amount
= caster
->SpellHealingBonus(m_target
, GetSpellProto(), m_modifier
.m_amount
, SPELL_DIRECT_DAMAGE
);
2260 // Final heal only on dispelled or duration end
2261 if ( !(GetAuraDuration() <= 0 || m_removeMode
==AURA_REMOVE_BY_DISPEL
) )
2264 // have a look if there is still some other Lifebloom dummy aura
2265 Unit::AuraList auras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
2266 for(Unit::AuraList::iterator itr
= auras
.begin(); itr
!=auras
.end(); ++itr
)
2267 if((*itr
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_DRUID
&&
2268 (*itr
)->GetSpellProto()->SpellFamilyFlags
& 0x1000000000LL
)
2272 if(m_target
->IsInWorld() && m_stackAmount
> 0)
2274 int32 amount
= m_modifier
.m_amount
/ m_stackAmount
;
2275 m_target
->CastCustomSpell(m_target
,33778,&amount
,NULL
,NULL
,true,NULL
,this,GetCasterGUID());
2281 // Predatory Strikes
2282 if(m_target
->GetTypeId()==TYPEID_PLAYER
&& GetSpellProto()->SpellIconID
== 1563)
2284 ((Player
*)m_target
)->UpdateAttackPowerAndDamage();
2287 // Idol of the Emerald Queen
2288 if ( GetId() == 34246 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2292 SpellModifier
*mod
= new SpellModifier
;
2293 mod
->op
= SPELLMOD_DOT
;
2294 mod
->value
= m_modifier
.m_amount
/7;
2295 mod
->type
= SPELLMOD_FLAT
;
2296 mod
->spellId
= GetId();
2297 mod
->mask
= 0x001000000000LL
;
2303 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2308 case SPELLFAMILY_HUNTER
:
2310 // Improved Aspect of the Viper
2311 if( GetId()==38390 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2315 // + effect value for Aspect of the Viper
2316 SpellModifier
*mod
= new SpellModifier
;
2317 mod
->op
= SPELLMOD_EFFECT1
;
2318 mod
->value
= m_modifier
.m_amount
;
2319 mod
->type
= SPELLMOD_FLAT
;
2320 mod
->spellId
= GetId();
2321 mod
->mask
= 0x4000000000000LL
;
2327 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2332 case SPELLFAMILY_SHAMAN
:
2334 // Improved Weapon Totems
2335 if( GetSpellProto()->SpellIconID
== 57 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2339 SpellModifier
*mod
= new SpellModifier
;
2340 mod
->op
= SPELLMOD_EFFECT1
;
2341 mod
->value
= m_modifier
.m_amount
;
2342 mod
->type
= SPELLMOD_PCT
;
2343 mod
->spellId
= GetId();
2347 mod
->mask
= 0x00200000000LL
; // Windfury Totem
2351 mod
->mask
= 0x00400000000LL
; // Flametongue Totem
2359 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2367 if(PetAura
const* petSpell
= spellmgr
.GetPetAura(GetId()))
2370 m_target
->AddPetAura(petSpell
);
2372 m_target
->RemovePetAura(petSpell
);
2377 void Aura::HandleAuraMounted(bool apply
, bool Real
)
2379 // only at real add/remove aura
2385 CreatureInfo
const* ci
= objmgr
.GetCreatureTemplate(m_modifier
.m_miscvalue
);
2388 sLog
.outErrorDb("AuraMounted: `creature_template`='%u' not found in database (only need it modelid)", m_modifier
.m_miscvalue
);
2393 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
2394 team
= ((Player
*)m_target
)->GetTeam();
2396 uint32 display_id
= objmgr
.ChooseDisplayId(team
,ci
);
2397 CreatureModelInfo
const *minfo
= objmgr
.GetCreatureModelRandomGender(display_id
);
2399 display_id
= minfo
->modelid
;
2401 m_target
->Mount(display_id
);
2405 m_target
->Unmount();
2409 void Aura::HandleAuraWaterWalk(bool apply
, bool Real
)
2411 // only at real add/remove aura
2417 data
.Initialize(SMSG_MOVE_WATER_WALK
, 8+4);
2419 data
.Initialize(SMSG_MOVE_LAND_WALK
, 8+4);
2420 data
.append(m_target
->GetPackGUID());
2422 m_target
->SendMessageToSet(&data
,true);
2425 void Aura::HandleAuraFeatherFall(bool apply
, bool Real
)
2427 // only at real add/remove aura
2433 data
.Initialize(SMSG_MOVE_FEATHER_FALL
, 8+4);
2435 data
.Initialize(SMSG_MOVE_NORMAL_FALL
, 8+4);
2436 data
.append(m_target
->GetPackGUID());
2438 m_target
->SendMessageToSet(&data
,true);
2441 void Aura::HandleAuraHover(bool apply
, bool Real
)
2443 // only at real add/remove aura
2449 data
.Initialize(SMSG_MOVE_SET_HOVER
, 8+4);
2451 data
.Initialize(SMSG_MOVE_UNSET_HOVER
, 8+4);
2452 data
.append(m_target
->GetPackGUID());
2454 m_target
->SendMessageToSet(&data
,true);
2457 void Aura::HandleWaterBreathing(bool apply
, bool Real
)
2459 if(!apply
&& !m_target
->HasAuraType(SPELL_AURA_WATER_BREATHING
))
2461 // update for enable timer in case not moving target
2462 if(m_target
->GetTypeId()==TYPEID_PLAYER
&& m_target
->IsInWorld())
2464 ((Player
*)m_target
)->UpdateUnderwaterState(m_target
->GetMap(),m_target
->GetPositionX(),m_target
->GetPositionY(),m_target
->GetPositionZ());
2465 ((Player
*)m_target
)->HandleDrowning();
2470 void Aura::HandleAuraModShapeshift(bool apply
, bool Real
)
2476 Powers PowerType
= POWER_MANA
;
2477 ShapeshiftForm form
= ShapeshiftForm(m_modifier
.m_miscvalue
);
2481 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2485 PowerType
= POWER_ENERGY
;
2491 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2497 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2501 PowerType
= POWER_RAGE
;
2504 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2508 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2512 PowerType
= POWER_RAGE
;
2514 case FORM_CREATUREBEAR
:
2517 case FORM_GHOSTWOLF
:
2521 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2527 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2532 case FORM_FLIGHT_EPIC
:
2533 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2538 case FORM_METAMORPHOSIS
:
2548 case FORM_BATTLESTANCE
:
2549 case FORM_BERSERKERSTANCE
:
2550 case FORM_DEFENSIVESTANCE
:
2551 PowerType
= POWER_RAGE
;
2553 case FORM_SPIRITOFREDEMPTION
:
2557 sLog
.outError("Auras: Unknown Shapeshift Type: %u", m_modifier
.m_miscvalue
);
2560 // remove polymorph before changing display id to keep new display id
2569 case FORM_FLIGHT_EPIC
:
2572 // remove movement affects
2573 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT
);
2574 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED
);
2576 // and polymorphic affects
2577 if(m_target
->IsPolymorphed())
2578 m_target
->RemoveAurasDueToSpell(m_target
->getTransForm());
2586 // remove other shapeshift before applying a new one
2587 if(m_target
->m_ShapeShiftFormSpellId
)
2588 m_target
->RemoveAurasDueToSpell(m_target
->m_ShapeShiftFormSpellId
,this);
2590 m_target
->SetByteValue(UNIT_FIELD_BYTES_2
, 3, form
);
2593 m_target
->SetDisplayId(modelid
);
2595 if(PowerType
!= POWER_MANA
)
2597 // reset power to default values only at power change
2598 if(m_target
->getPowerType()!=PowerType
)
2599 m_target
->setPowerType(PowerType
);
2607 // get furor proc chance
2608 uint32 FurorChance
= 0;
2609 Unit::AuraList
const& mDummy
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
2610 for(Unit::AuraList::const_iterator i
= mDummy
.begin(); i
!= mDummy
.end(); ++i
)
2612 if ((*i
)->GetSpellProto()->SpellIconID
== 238)
2614 FurorChance
= (*i
)->GetModifier()->m_amount
;
2619 if (m_modifier
.m_miscvalue
== FORM_CAT
)
2621 m_target
->SetPower(POWER_ENERGY
,0);
2622 if(urand(1,100) <= FurorChance
)
2623 m_target
->CastSpell(m_target
,17099,true,NULL
,this);
2627 m_target
->SetPower(POWER_RAGE
,0);
2628 if(urand(1,100) <= FurorChance
)
2629 m_target
->CastSpell(m_target
,17057,true,NULL
,this);
2633 case FORM_BATTLESTANCE
:
2634 case FORM_DEFENSIVESTANCE
:
2635 case FORM_BERSERKERSTANCE
:
2637 uint32 Rage_val
= 0;
2638 // Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch)
2639 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2641 PlayerSpellMap
const& sp_list
= ((Player
*)m_target
)->GetSpellMap();
2642 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
2644 if(itr
->second
->state
== PLAYERSPELL_REMOVED
) continue;
2645 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
2646 if (spellInfo
&& spellInfo
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& spellInfo
->SpellIconID
== 139)
2647 Rage_val
+= m_target
->CalculateSpellDamage(spellInfo
,0,spellInfo
->EffectBasePoints
[0],m_target
) * 10;
2651 if (m_target
->GetPower(POWER_RAGE
) > Rage_val
)
2652 m_target
->SetPower(POWER_RAGE
,Rage_val
);
2660 m_target
->m_ShapeShiftFormSpellId
= GetId();
2661 m_target
->m_form
= form
;
2666 m_target
->SetDisplayId(m_target
->GetNativeDisplayId());
2667 m_target
->SetByteValue(UNIT_FIELD_BYTES_2
, 3, FORM_NONE
);
2668 if(m_target
->getClass() == CLASS_DRUID
)
2669 m_target
->setPowerType(POWER_MANA
);
2670 m_target
->m_ShapeShiftFormSpellId
= 0;
2671 m_target
->m_form
= FORM_NONE
;
2675 // Nordrassil Harness - bonus
2680 if(Aura
* dummy
= m_target
->GetDummyAura(37315) )
2681 m_target
->CastSpell(m_target
,37316,true,NULL
,dummy
);
2684 // Nordrassil Regalia - bonus
2687 if(Aura
* dummy
= m_target
->GetDummyAura(37324) )
2688 m_target
->CastSpell(m_target
,37325,true,NULL
,dummy
);
2694 // adding/removing linked auras
2695 // add/remove the shapeshift aura's boosts
2696 HandleShapeshiftBoosts(apply
);
2698 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
2699 ((Player
*)m_target
)->InitDataForForm();
2702 void Aura::HandleAuraTransform(bool apply
, bool Real
)
2706 // special case (spell specific functionality)
2707 if(m_modifier
.m_miscvalue
==0)
2709 // player applied only
2710 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
2718 uint32 orb_model
= m_target
->GetNativeDisplayId();
2722 case 1479: m_target
->SetDisplayId(10134); break;
2724 case 1478: m_target
->SetDisplayId(10135); break;
2726 case 59: m_target
->SetDisplayId(10136); break;
2728 case 49: m_target
->SetDisplayId(10137); break;
2730 case 50: m_target
->SetDisplayId(10138); break;
2732 case 51: m_target
->SetDisplayId(10139); break;
2734 case 52: m_target
->SetDisplayId(10140); break;
2736 case 53: m_target
->SetDisplayId(10141); break;
2738 case 54: m_target
->SetDisplayId(10142); break;
2740 case 55: m_target
->SetDisplayId(10143); break;
2742 case 56: m_target
->SetDisplayId(10144); break;
2744 case 58: m_target
->SetDisplayId(10145); break;
2746 case 57: m_target
->SetDisplayId(10146); break;
2748 case 60: m_target
->SetDisplayId(10147); break;
2750 case 1563: m_target
->SetDisplayId(10148); break;
2752 case 1564: m_target
->SetDisplayId(10149); break;
2754 case 15475: m_target
->SetDisplayId(17830); break;
2756 case 15476: m_target
->SetDisplayId(17829); break;
2758 case 16126: m_target
->SetDisplayId(17828); break;
2760 case 16125: m_target
->SetDisplayId(17827); break;
2766 case 42365: m_target
->SetDisplayId(21723); break;
2772 CreatureInfo
const * ci
= objmgr
.GetCreatureTemplate(m_modifier
.m_miscvalue
);
2776 m_target
->SetDisplayId(16358);
2777 sLog
.outError("Auras: unknown creature id = %d (only need its modelid) Form Spell Aura Transform in Spell ID = %d", m_modifier
.m_miscvalue
, GetId());
2781 // Will use the default model here
2782 m_target
->SetDisplayId(ci
->DisplayID_A
);
2784 // Dragonmaw Illusion (set mount model also)
2785 if(GetId()==42016 && m_target
->GetMountID() && !m_target
->GetAurasByType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
).empty())
2786 m_target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
,16314);
2788 m_target
->setTransForm(GetId());
2792 if( Real
&& m_target
->GetTypeId() == TYPEID_PLAYER
&& m_target
->IsPolymorphed())
2794 // for players, start regeneration after 1s (in polymorph fast regeneration case)
2795 // only if caster is Player (after patch 2.4.2)
2796 if(IS_PLAYER_GUID(GetCasterGUID()) )
2797 ((Player
*)m_target
)->setRegenTimer(1000);
2799 //dismount polymorphed target (after patch 2.4.2)
2800 if (m_target
->IsMounted())
2801 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
2806 Unit::AuraList
const& otherTransforms
= m_target
->GetAurasByType(SPELL_AURA_TRANSFORM
);
2807 if(otherTransforms
.empty())
2809 m_target
->SetDisplayId(m_target
->GetNativeDisplayId());
2810 m_target
->setTransForm(0);
2814 // look for other transform auras
2815 Aura
* handledAura
= *otherTransforms
.begin();
2816 for(Unit::AuraList::const_iterator i
= otherTransforms
.begin();i
!= otherTransforms
.end(); ++i
)
2818 // negative auras are preferred
2819 if(!IsPositiveSpell((*i
)->GetSpellProto()->Id
))
2825 handledAura
->ApplyModifier(true);
2828 // Dragonmaw Illusion (restore mount model)
2829 if(GetId()==42016 && m_target
->GetMountID()==16314)
2831 if(!m_target
->GetAurasByType(SPELL_AURA_MOUNTED
).empty())
2833 uint32 cr_id
= m_target
->GetAurasByType(SPELL_AURA_MOUNTED
).front()->GetModifier()->m_miscvalue
;
2834 if(CreatureInfo
const* ci
= objmgr
.GetCreatureTemplate(cr_id
))
2837 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
2838 team
= ((Player
*)m_target
)->GetTeam();
2840 uint32 display_id
= objmgr
.ChooseDisplayId(team
,ci
);
2841 CreatureModelInfo
const *minfo
= objmgr
.GetCreatureModelRandomGender(display_id
);
2843 display_id
= minfo
->modelid
;
2845 m_target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
,display_id
);
2852 void Aura::HandleForceReaction(bool apply
, bool Real
)
2854 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
2860 Player
* player
= (Player
*)m_target
;
2862 uint32 faction_id
= m_modifier
.m_miscvalue
;
2863 uint32 faction_rank
= m_modifier
.m_amount
;
2866 player
->m_forcedReactions
[faction_id
] = ReputationRank(faction_rank
);
2868 player
->m_forcedReactions
.erase(faction_id
);
2871 data
.Initialize(SMSG_SET_FORCED_REACTIONS
, 4+player
->m_forcedReactions
.size()*(4+4));
2872 data
<< uint32(player
->m_forcedReactions
.size());
2873 for(ForcedReactions::const_iterator itr
= player
->m_forcedReactions
.begin(); itr
!= player
->m_forcedReactions
.end(); ++itr
)
2875 data
<< uint32(itr
->first
); // faction_id (Faction.dbc)
2876 data
<< uint32(itr
->second
); // reputation rank
2878 player
->SendDirectMessage(&data
);
2881 void Aura::HandleAuraModSkill(bool apply
, bool Real
)
2883 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
2886 uint32 prot
=GetSpellProto()->EffectMiscValue
[m_effIndex
];
2887 int32 points
= GetModifier()->m_amount
;
2889 ((Player
*)m_target
)->ModifySkillBonus(prot
,(apply
? points
: -points
),m_modifier
.m_auraname
==SPELL_AURA_MOD_SKILL_TALENT
);
2890 if(prot
== SKILL_DEFENSE
)
2891 ((Player
*)m_target
)->UpdateDefenseBonusesMod();
2894 void Aura::HandleChannelDeathItem(bool apply
, bool Real
)
2898 Unit
* caster
= GetCaster();
2899 Unit
* victim
= GetTarget();
2900 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
|| !victim
|| m_removeMode
!=AURA_REMOVE_BY_DEATH
)
2903 if (m_modifier
.m_amount
<= 0)
2906 SpellEntry
const *spellInfo
= GetSpellProto();
2907 if(spellInfo
->EffectItemType
[m_effIndex
] == 0)
2910 // Soul Shard only from non-grey units
2911 if( spellInfo
->EffectItemType
[m_effIndex
] == 6265 &&
2912 (victim
->getLevel() <= MaNGOS::XP::GetGrayLevel(caster
->getLevel()) ||
2913 victim
->GetTypeId()==TYPEID_UNIT
&& !((Player
*)caster
)->isAllowedToLoot((Creature
*)victim
)) )
2916 uint32 noSpaceForCount
= 0;
2917 uint32 count
= m_modifier
.m_amount
;
2919 ItemPosCountVec dest
;
2920 uint8 msg
= ((Player
*)caster
)->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, spellInfo
->EffectItemType
[m_effIndex
], count
, &noSpaceForCount
);
2921 if( msg
!= EQUIP_ERR_OK
)
2923 count
-=noSpaceForCount
;
2924 ((Player
*)caster
)->SendEquipError( msg
, NULL
, NULL
);
2929 Item
* newitem
= ((Player
*)caster
)->StoreNewItem(dest
, spellInfo
->EffectItemType
[m_effIndex
], true);
2930 ((Player
*)caster
)->SendNewItem(newitem
, count
, true, false);
2934 void Aura::HandleBindSight(bool apply
, bool Real
)
2936 Unit
* caster
= GetCaster();
2937 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
2940 ((Player
*)caster
)->SetFarSightGUID(apply
? m_target
->GetGUID() : 0);
2943 void Aura::HandleFarSight(bool apply
, bool Real
)
2945 Unit
* caster
= GetCaster();
2946 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
2949 ((Player
*)caster
)->SetFarSightGUID(apply
? m_target
->GetGUID() : 0);
2952 void Aura::HandleAuraTrackCreatures(bool apply
, bool Real
)
2954 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
2958 m_target
->RemoveNoStackAurasDueToAura(this);
2959 m_target
->SetUInt32Value(PLAYER_TRACK_CREATURES
, apply
? ((uint32
)1)<<(m_modifier
.m_miscvalue
-1) : 0 );
2962 void Aura::HandleAuraTrackResources(bool apply
, bool Real
)
2964 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
2968 m_target
->RemoveNoStackAurasDueToAura(this);
2969 m_target
->SetUInt32Value(PLAYER_TRACK_RESOURCES
, apply
? ((uint32
)1)<<(m_modifier
.m_miscvalue
-1): 0 );
2972 void Aura::HandleAuraTrackStealthed(bool apply
, bool Real
)
2974 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
2978 m_target
->RemoveNoStackAurasDueToAura(this);
2980 m_target
->ApplyModFlag(PLAYER_FIELD_BYTES
,PLAYER_FIELD_BYTE_TRACK_STEALTHED
,apply
);
2983 void Aura::HandleAuraModScale(bool apply
, bool Real
)
2985 m_target
->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X
,m_modifier
.m_amount
,apply
);
2988 void Aura::HandleModPossess(bool apply
, bool Real
)
2993 if(m_target
->getLevel() > m_modifier
.m_amount
)
2996 // not possess yourself
2997 if(GetCasterGUID() == m_target
->GetGUID())
3000 Unit
* caster
= GetCaster();
3006 m_target
->SetCharmerGUID(GetCasterGUID());
3007 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,caster
->getFaction());
3008 caster
->SetCharm(m_target
);
3010 m_target
->CombatStop();
3011 m_target
->DeleteThreatList();
3012 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3014 m_target
->StopMoving();
3015 m_target
->GetMotionMaster()->Clear();
3016 m_target
->GetMotionMaster()->MoveIdle();
3017 CharmInfo
*charmInfo
= ((Creature
*)m_target
)->InitCharmInfo(m_target
);
3018 charmInfo
->InitPossessCreateSpells();
3021 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3023 ((Player
*)caster
)->PossessSpellInitialize();
3028 m_target
->SetCharmerGUID(0);
3030 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3031 ((Player
*)m_target
)->setFactionForRace(m_target
->getRace());
3032 else if(m_target
->GetTypeId() == TYPEID_UNIT
)
3034 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
3035 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,cinfo
->faction_A
);
3038 caster
->SetCharm(0);
3040 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3042 WorldPacket
data(SMSG_PET_SPELLS
, 8);
3045 ((Player
*)caster
)->GetSession()->SendPacket(&data
);
3047 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3049 ((Creature
*)m_target
)->AIM_Initialize();
3051 if (((Creature
*)m_target
)->AI())
3052 ((Creature
*)m_target
)->AI()->AttackStart(caster
);
3055 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3056 ((Player
*)caster
)->SetFarSightGUID(apply
? m_target
->GetGUID() : 0);
3059 void Aura::HandleModPossessPet(bool apply
, bool Real
)
3064 Unit
* caster
= GetCaster();
3065 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3068 Pet
*pet
= caster
->GetPet();
3069 if(!pet
|| pet
!= m_target
)
3073 pet
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_24
);
3075 pet
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_24
);
3077 ((Player
*)caster
)->SetFarSightGUID(apply
? pet
->GetGUID() : NULL
);
3078 ((Player
*)caster
)->SetCharm(apply
? pet
: NULL
);
3079 ((Player
*)caster
)->SetClientControl(pet
, apply
? 1 : 0);
3084 pet
->GetMotionMaster()->Clear();
3085 pet
->GetMotionMaster()->MoveIdle();
3090 pet
->GetMotionMaster()->MoveFollow(caster
, PET_FOLLOW_DIST
, PET_FOLLOW_ANGLE
);
3091 pet
->SetUnitMovementFlags(MOVEMENTFLAG_NONE
);
3095 void Aura::HandleAuraModPetTalentsPoints(bool Apply
, bool Real
)
3100 // Recalculate pet tlaent points
3101 if (Pet
*pet
=m_target
->GetPet())
3102 pet
->InitTalentForLevel();
3105 void Aura::HandleModCharm(bool apply
, bool Real
)
3110 // not charm yourself
3111 if(GetCasterGUID() == m_target
->GetGUID())
3114 Unit
* caster
= GetCaster();
3118 if(int32(m_target
->getLevel()) <= m_modifier
.m_amount
)
3122 m_target
->SetCharmerGUID(GetCasterGUID());
3123 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,caster
->getFaction());
3124 m_target
->CastStop(m_target
==caster
? GetId() : 0);
3125 caster
->SetCharm(m_target
);
3127 m_target
->CombatStop();
3128 m_target
->DeleteThreatList();
3130 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3132 ((Creature
*)m_target
)->AIM_Initialize();
3133 CharmInfo
*charmInfo
= ((Creature
*)m_target
)->InitCharmInfo(m_target
);
3134 charmInfo
->InitCharmCreateSpells();
3135 charmInfo
->SetReactState( REACT_DEFENSIVE
);
3137 if(caster
->GetTypeId() == TYPEID_PLAYER
&& caster
->getClass() == CLASS_WARLOCK
)
3139 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
3140 if(cinfo
&& cinfo
->type
== CREATURE_TYPE_DEMON
)
3142 //to prevent client crash
3143 m_target
->SetFlag(UNIT_FIELD_BYTES_0
, 2048);
3144 //just to enable stat window
3145 charmInfo
->SetPetNumber(objmgr
.GeneratePetNumber(), true);
3146 //if charmed two demons the same session, the 2nd gets the 1st one's name
3147 m_target
->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP
, time(NULL
));
3152 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3154 ((Player
*)caster
)->CharmSpellInitialize();
3159 m_target
->SetCharmerGUID(0);
3161 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3162 ((Player
*)m_target
)->setFactionForRace(m_target
->getRace());
3165 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
3168 if(((Creature
*)m_target
)->isPet())
3170 if(Unit
* owner
= m_target
->GetOwner())
3171 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,owner
->getFaction());
3173 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,cinfo
->faction_A
);
3175 else if(cinfo
) // normal creature
3176 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,cinfo
->faction_A
);
3178 // restore UNIT_FIELD_BYTES_0
3179 if(cinfo
&& caster
->GetTypeId() == TYPEID_PLAYER
&& caster
->getClass() == CLASS_WARLOCK
&& cinfo
->type
== CREATURE_TYPE_DEMON
)
3181 CreatureDataAddon
const *cainfo
= ((Creature
*)m_target
)->GetCreatureAddon();
3182 if(cainfo
&& cainfo
->bytes0
!= 0)
3183 m_target
->SetUInt32Value(UNIT_FIELD_BYTES_0
, cainfo
->bytes0
);
3185 m_target
->RemoveFlag(UNIT_FIELD_BYTES_0
, 2048);
3187 if(m_target
->GetCharmInfo())
3188 m_target
->GetCharmInfo()->SetPetNumber(0, true);
3190 sLog
.outError("Aura::HandleModCharm: target="I64FMTD
" with typeid=%d has a charm aura but no charm info!", m_target
->GetGUID(), m_target
->GetTypeId());
3194 caster
->SetCharm(0);
3196 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3198 WorldPacket
data(SMSG_PET_SPELLS
, 8);
3201 ((Player
*)caster
)->GetSession()->SendPacket(&data
);
3203 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3205 ((Creature
*)m_target
)->AIM_Initialize();
3206 if (((Creature
*)m_target
)->AI())
3207 ((Creature
*)m_target
)->AI()->AttackStart(caster
);
3213 void Aura::HandleModConfuse(bool apply
, bool Real
)
3218 m_target
->SetConfused(apply
, GetCasterGUID(), GetId());
3221 void Aura::HandleModFear(bool apply
, bool Real
)
3226 m_target
->SetFeared(apply
, GetCasterGUID(), GetId());
3229 void Aura::HandleFeignDeath(bool apply
, bool Real
)
3234 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
3240 WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9);
3241 data<<m_target->GetGUID();
3243 m_target->SendMessageToSet(&data,true);
3246 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_29
);
3248 m_target
->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FEIGN_DEATH
);
3250 m_target
->SetFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_DEAD
);
3252 m_target
->addUnitState(UNIT_STAT_DIED
);
3253 m_target
->CombatStop();
3255 // prevent interrupt message
3256 if(m_caster_guid
==m_target
->GetGUID() && m_target
->m_currentSpells
[CURRENT_GENERIC_SPELL
])
3257 m_target
->m_currentSpells
[CURRENT_GENERIC_SPELL
]->finish();
3258 m_target
->InterruptNonMeleeSpells(true);
3259 m_target
->getHostilRefManager().deleteReferences();
3264 WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9);
3265 data<<m_target->GetGUID();
3267 m_target->SendMessageToSet(&data,true);
3270 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_29
);
3272 m_target
->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FEIGN_DEATH
);
3274 m_target
->RemoveFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_DEAD
);
3276 m_target
->clearUnitState(UNIT_STAT_DIED
);
3280 void Aura::HandleAuraModDisarm(bool apply
, bool Real
)
3285 if(!apply
&& m_target
->HasAuraType(SPELL_AURA_MOD_DISARM
))
3288 // not sure for it's correctness
3290 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_DISARMED
);
3292 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_DISARMED
);
3294 // only at real add/remove aura
3295 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
3298 // main-hand attack speed already set to special value for feral form already and don't must change and reset at remove.
3299 if (((Player
*)m_target
)->IsInFeralForm())
3303 m_target
->SetAttackTime(BASE_ATTACK
,BASE_ATTACK_TIME
);
3305 ((Player
*)m_target
)->SetRegularAttackTime();
3307 m_target
->UpdateDamagePhysical(BASE_ATTACK
);
3310 void Aura::HandleAuraModStun(bool apply
, bool Real
)
3317 m_target
->addUnitState(UNIT_STAT_STUNNED
);
3318 m_target
->SetUInt64Value(UNIT_FIELD_TARGET
, 0);
3320 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
3321 m_target
->CastStop(m_target
->GetGUID() == GetCasterGUID() ? GetId() : 0);
3323 // Creature specific
3324 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
3325 ((Creature
*)m_target
)->StopMoving();
3327 m_target
->SetUnitMovementFlags(0); //Clear movement flags
3329 WorldPacket
data(SMSG_FORCE_MOVE_ROOT
, 8);
3331 data
.append(m_target
->GetPackGUID());
3333 m_target
->SendMessageToSet(&data
,true);
3337 // Real remove called after current aura remove from lists, check if other similar auras active
3338 if(m_target
->HasAuraType(SPELL_AURA_MOD_STUN
))
3341 m_target
->clearUnitState(UNIT_STAT_STUNNED
);
3342 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
3344 if(!m_target
->hasUnitState(UNIT_STAT_ROOT
)) // prevent allow move if have also root effect
3346 if(m_target
->getVictim() && m_target
->isAlive())
3347 m_target
->SetUInt64Value(UNIT_FIELD_TARGET
,m_target
->getVictim()->GetGUID() );
3349 WorldPacket
data(SMSG_FORCE_MOVE_UNROOT
, 8+4);
3350 data
.append(m_target
->GetPackGUID());
3352 m_target
->SendMessageToSet(&data
,true);
3356 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_HUNTER
&& m_spellProto
->SpellFamilyFlags
& 0x0000100000000000LL
)
3358 Unit
* caster
= GetCaster();
3359 if( !caster
|| caster
->GetTypeId()!=TYPEID_PLAYER
)
3362 uint32 spell_id
= 0;
3366 case 19386: spell_id
= 24131; break;
3367 case 24132: spell_id
= 24134; break;
3368 case 24133: spell_id
= 24135; break;
3369 case 27068: spell_id
= 27069; break;
3370 case 49011: spell_id
= 49009; break;
3371 case 49012: spell_id
= 49010; break;
3373 sLog
.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?",GetId());
3377 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell_id
);
3382 caster
->CastSpell(m_target
,spellInfo
,true,NULL
,this);
3388 void Aura::HandleModStealth(bool apply
, bool Real
)
3392 // drop flag at stealth in bg
3393 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
&& ((Player
*)m_target
)->InBattleGround())
3394 if(BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround())
3395 bg
->EventPlayerDroppedFlag((Player
*)m_target
);
3397 // only at real aura add
3400 m_target
->SetStandFlags(UNIT_STAND_FLAGS_CREEP
);
3401 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
3402 m_target
->SetFlag(PLAYER_FIELD_BYTES2
, 0x2000);
3404 // apply only if not in GM invisibility (and overwrite invisibility state)
3405 if(m_target
->GetVisibility()!=VISIBILITY_OFF
)
3407 m_target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
3408 m_target
->SetVisibility(VISIBILITY_GROUP_STEALTH
);
3414 // only at real aura remove
3417 // if last SPELL_AURA_MOD_STEALTH and no GM invisibility
3418 if(!m_target
->HasAuraType(SPELL_AURA_MOD_STEALTH
) && m_target
->GetVisibility()!=VISIBILITY_OFF
)
3420 m_target
->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP
);
3421 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
3422 m_target
->RemoveFlag(PLAYER_FIELD_BYTES2
, 0x2000);
3424 // restore invisibility if any
3425 if(m_target
->HasAuraType(SPELL_AURA_MOD_INVISIBILITY
))
3427 m_target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
3428 m_target
->SetVisibility(VISIBILITY_GROUP_INVISIBILITY
);
3431 m_target
->SetVisibility(VISIBILITY_ON
);
3436 // Master of Subtlety
3437 Unit::AuraList
const& mDummyAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
3438 for(Unit::AuraList::const_iterator i
= mDummyAuras
.begin();i
!= mDummyAuras
.end(); ++i
)
3440 if ((*i
)->GetSpellProto()->SpellIconID
== 2114)
3444 int32 bp
= (*i
)->GetModifier()->m_amount
;
3445 m_target
->CastCustomSpell(m_target
,31665,&bp
,NULL
,NULL
,true);
3448 m_target
->CastSpell(m_target
,31666,true);
3454 void Aura::HandleInvisibility(bool apply
, bool Real
)
3458 m_target
->m_invisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3460 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
3462 // apply glow vision
3463 m_target
->SetFlag(PLAYER_FIELD_BYTES2
,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
);
3465 // drop flag at invisible in bg
3466 if(((Player
*)m_target
)->InBattleGround())
3467 if(BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround())
3468 bg
->EventPlayerDroppedFlag((Player
*)m_target
);
3471 // apply only if not in GM invisibility and not stealth
3472 if(m_target
->GetVisibility()==VISIBILITY_ON
)
3474 // Aura not added yet but visibility code expect temporary add aura
3475 m_target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
3476 m_target
->SetVisibility(VISIBILITY_GROUP_INVISIBILITY
);
3481 // recalculate value at modifier remove (current aura already removed)
3482 m_target
->m_invisibilityMask
= 0;
3483 Unit::AuraList
const& auras
= m_target
->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY
);
3484 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
3485 m_target
->m_invisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3487 // only at real aura remove and if not have different invisibility auras.
3488 if(Real
&& m_target
->m_invisibilityMask
==0)
3490 // remove glow vision
3491 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3492 m_target
->RemoveFlag(PLAYER_FIELD_BYTES2
,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
);
3494 // apply only if not in GM invisibility & not stealthed while invisible
3495 if(m_target
->GetVisibility()!=VISIBILITY_OFF
)
3497 // if have stealth aura then already have stealth visibility
3498 if(!m_target
->HasAuraType(SPELL_AURA_MOD_STEALTH
))
3499 m_target
->SetVisibility(VISIBILITY_ON
);
3505 void Aura::HandleInvisibilityDetect(bool apply
, bool Real
)
3509 m_target
->m_detectInvisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3513 // recalculate value at modifier remove (current aura already removed)
3514 m_target
->m_detectInvisibilityMask
= 0;
3515 Unit::AuraList
const& auras
= m_target
->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION
);
3516 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
3517 m_target
->m_detectInvisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3519 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
3520 ObjectAccessor::UpdateVisibilityForPlayer((Player
*)m_target
);
3523 void Aura::HandleAuraModRoot(bool apply
, bool Real
)
3525 // only at real add/remove aura
3529 // Frost root aura -> freeze/unfreeze target
3530 if (GetSpellSchoolMask(m_spellProto
) & SPELL_SCHOOL_MASK_FROST
)
3531 m_target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
3533 uint32 apply_stat
= UNIT_STAT_ROOT
;
3536 m_target
->addUnitState(UNIT_STAT_ROOT
);
3537 m_target
->SetUInt64Value (UNIT_FIELD_TARGET
, 0);
3538 // probably wrong (this add skinable flag)
3539 // TODO: find correct flag
3540 // m_target->SetFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
3542 //Save last orientation
3543 if( m_target
->getVictim() )
3544 m_target
->SetOrientation(m_target
->GetAngle(m_target
->getVictim()));
3546 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3548 WorldPacket
data(SMSG_FORCE_MOVE_ROOT
, 10);
3549 data
.append(m_target
->GetPackGUID());
3551 m_target
->SendMessageToSet(&data
,true);
3553 //Clear unit movement flags
3554 m_target
->SetUnitMovementFlags(0);
3557 ((Creature
*)m_target
)->StopMoving();
3561 // Real remove called after current aura remove from lists, check if other similar auras active
3562 if(m_target
->HasAuraType(SPELL_AURA_MOD_ROOT
))
3565 m_target
->clearUnitState(UNIT_STAT_ROOT
);
3566 // probably wrong (this add skinable flag)
3567 // TODO: find correct flag
3568 // m_target->RemoveFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
3570 if(!m_target
->hasUnitState(UNIT_STAT_STUNNED
)) // prevent allow move if have also stun effect
3572 if(m_target
->getVictim() && m_target
->isAlive())
3573 m_target
->SetUInt64Value (UNIT_FIELD_TARGET
,m_target
->getVictim()->GetGUID() );
3575 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3577 WorldPacket
data(SMSG_FORCE_MOVE_UNROOT
, 10);
3578 data
.append(m_target
->GetPackGUID());
3580 m_target
->SendMessageToSet(&data
,true);
3586 void Aura::HandleAuraModSilence(bool apply
, bool Real
)
3588 // only at real add/remove aura
3594 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_SILENCED
);
3595 // Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE
3596 for (uint32 i
= CURRENT_MELEE_SPELL
; i
< CURRENT_MAX_SPELL
;i
++)
3598 Spell
* currentSpell
= m_target
->m_currentSpells
[i
];
3599 if (currentSpell
&& currentSpell
->m_spellInfo
->PreventionType
== SPELL_PREVENTION_TYPE_SILENCE
)
3601 uint32 state
= currentSpell
->getState();
3602 // Stop spells on prepare or casting state
3603 if ( state
== SPELL_STATE_PREPARING
|| state
== SPELL_STATE_CASTING
)
3605 currentSpell
->cancel();
3606 currentSpell
->SetReferencedFromCurrent(false);
3607 m_target
->m_currentSpells
[i
] = NULL
;
3614 // Arcane Torrent (Energy)
3617 Unit
* caster
= GetCaster();
3621 // Search Mana Tap auras on caster
3622 Aura
* dummy
= caster
->GetDummyAura(28734);
3625 int32 bp
= dummy
->GetStackAmount() * 10;
3626 caster
->CastCustomSpell(caster
, 25048, &bp
, NULL
, NULL
, true);
3627 caster
->RemoveAurasDueToSpell(28734);
3634 // Real remove called after current aura remove from lists, check if other similar auras active
3635 if(m_target
->HasAuraType(SPELL_AURA_MOD_SILENCE
))
3638 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_SILENCED
);
3642 void Aura::HandleModThreat(bool apply
, bool Real
)
3644 // only at real add/remove aura
3648 if(!m_target
->isAlive())
3651 Unit
* caster
= GetCaster();
3653 if(!caster
|| !caster
->isAlive())
3662 level_diff
= m_target
->getLevel() - 60;
3665 // The Eye of Diminution
3667 level_diff
= m_target
->getLevel() - 60;
3672 m_modifier
.m_amount
+= multiplier
* level_diff
;
3674 for(int8 x
=0;x
< MAX_SPELL_SCHOOL
;x
++)
3676 if(m_modifier
.m_miscvalue
& int32(1<<x
))
3678 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3679 ApplyPercentModFloatVar(m_target
->m_threatModifier
[x
], m_positive
? m_modifier
.m_amount
: -m_modifier
.m_amount
, apply
);
3684 void Aura::HandleAuraModTotalThreat(bool apply
, bool Real
)
3686 // only at real add/remove aura
3690 if(!m_target
->isAlive() || m_target
->GetTypeId()!= TYPEID_PLAYER
)
3693 Unit
* caster
= GetCaster();
3695 if(!caster
|| !caster
->isAlive())
3698 float threatMod
= 0.0f
;
3700 threatMod
= float(m_modifier
.m_amount
);
3702 threatMod
= float(-m_modifier
.m_amount
);
3704 m_target
->getHostilRefManager().threatAssist(caster
, threatMod
);
3707 void Aura::HandleModTaunt(bool apply
, bool Real
)
3709 // only at real add/remove aura
3713 if(!m_target
->isAlive() || !m_target
->CanHaveThreatList())
3716 Unit
* caster
= GetCaster();
3718 if(!caster
|| !caster
->isAlive() || caster
->GetTypeId() != TYPEID_PLAYER
)
3722 m_target
->TauntApply(caster
);
3725 // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat
3726 m_target
->TauntFadeOut(caster
);
3730 /*********************************************************/
3731 /*** MODIFY SPEED ***/
3732 /*********************************************************/
3733 void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real
)
3735 // all applied/removed only at real aura add/remove
3739 m_target
->UpdateSpeed(MOVE_RUN
, true);
3742 void Aura::HandleAuraModIncreaseMountedSpeed(bool /*apply*/, bool Real
)
3744 // all applied/removed only at real aura add/remove
3748 m_target
->UpdateSpeed(MOVE_RUN
, true);
3751 void Aura::HandleAuraModIncreaseFlightSpeed(bool apply
, bool Real
)
3753 // all applied/removed only at real aura add/remove
3757 // Enable Fly mode for flying mounts
3758 if (m_modifier
.m_auraname
== SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
)
3762 data
.Initialize(SMSG_MOVE_SET_CAN_FLY
, 12);
3764 data
.Initialize(SMSG_MOVE_UNSET_CAN_FLY
, 12);
3765 data
.append(m_target
->GetPackGUID());
3766 data
<< uint32(0); // unknown
3767 m_target
->SendMessageToSet(&data
, true);
3769 //Players on flying mounts must be immune to polymorph
3770 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
3771 m_target
->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC
,MECHANIC_POLYMORPH
,apply
);
3773 // Dragonmaw Illusion (overwrite mount model, mounted aura already applied)
3774 if( apply
&& m_target
->HasAura(42016,0) && m_target
->GetMountID())
3775 m_target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
,16314);
3778 m_target
->UpdateSpeed(MOVE_FLIGHT
, true);
3781 void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real
)
3783 // all applied/removed only at real aura add/remove
3787 m_target
->UpdateSpeed(MOVE_SWIM
, true);
3790 void Aura::HandleAuraModDecreaseSpeed(bool /*apply*/, bool Real
)
3792 // all applied/removed only at real aura add/remove
3796 m_target
->UpdateSpeed(MOVE_RUN
, true);
3797 m_target
->UpdateSpeed(MOVE_SWIM
, true);
3798 m_target
->UpdateSpeed(MOVE_FLIGHT
, true);
3801 void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real
)
3803 // all applied/removed only at real aura add/remove
3807 m_target
->UpdateSpeed(MOVE_RUN
, true);
3808 m_target
->UpdateSpeed(MOVE_SWIM
, true);
3809 m_target
->UpdateSpeed(MOVE_FLIGHT
, true);
3812 /*********************************************************/
3814 /*********************************************************/
3816 void Aura::HandleModMechanicImmunity(bool apply
, bool Real
)
3818 uint32 mechanic
= 1 << m_modifier
.m_miscvalue
;
3820 //immune movement impairment and loss of control
3821 if(GetId()==42292 || GetId()==59752)
3822 mechanic
=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK
;
3824 if(apply
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
3826 Unit::AuraMap
& Auras
= m_target
->GetAuras();
3827 for(Unit::AuraMap::iterator iter
= Auras
.begin(), next
; iter
!= Auras
.end(); iter
= next
)
3831 SpellEntry
const *spell
= iter
->second
->GetSpellProto();
3832 if (!( spell
->Attributes
& SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY
) && // spells unaffected by invulnerability
3833 spell
->Id
!= GetId())
3835 //check for mechanic mask
3836 if(GetSpellMechanicMask(spell
, iter
->second
->GetEffIndex()) & mechanic
)
3838 m_target
->RemoveAurasDueToSpell(spell
->Id
);
3842 next
= Auras
.begin();
3848 m_target
->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC
,m_modifier
.m_miscvalue
,apply
);
3851 if ( GetSpellProto()->SpellFamilyName
== SPELLFAMILY_HUNTER
&& GetSpellProto()->SpellIconID
== 1680)
3853 // The Beast Within cast on owner if talent present
3854 if ( Unit
* owner
= m_target
->GetOwner() )
3857 Unit::AuraList
const& m_dummyAuras
= owner
->GetAurasByType(SPELL_AURA_DUMMY
);
3858 for(Unit::AuraList::const_iterator i
= m_dummyAuras
.begin(); i
!= m_dummyAuras
.end(); ++i
)
3860 if ( (*i
)->GetSpellProto()->SpellIconID
== 2229 )
3863 owner
->CastSpell(owner
, 34471, true, 0, this);
3865 owner
->RemoveAurasDueToSpell(34471);
3872 // The Beast Within and Bestial Wrath - immunity
3873 if(GetId() == 19574 || GetId() == 34471)
3877 m_target
->CastSpell(m_target
,24395,true);
3878 m_target
->CastSpell(m_target
,24396,true);
3879 m_target
->CastSpell(m_target
,24397,true);
3880 m_target
->CastSpell(m_target
,26592,true);
3884 m_target
->RemoveAurasDueToSpell(24395);
3885 m_target
->RemoveAurasDueToSpell(24396);
3886 m_target
->RemoveAurasDueToSpell(24397);
3887 m_target
->RemoveAurasDueToSpell(26592);
3892 void Aura::HandleAuraModEffectImmunity(bool apply
, bool Real
)
3896 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3898 if(((Player
*)m_target
)->InBattleGround())
3900 BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround();
3903 switch(bg
->GetTypeID())
3905 case BATTLEGROUND_AV
:
3909 case BATTLEGROUND_WS
:
3911 // Warsong Flag, horde // Silverwing Flag, alliance
3912 if(GetId() == 23333 || GetId() == 23335)
3913 bg
->EventPlayerDroppedFlag(((Player
*)m_target
));
3916 case BATTLEGROUND_AB
:
3920 case BATTLEGROUND_EY
:
3922 if(GetId() == 34976)
3923 bg
->EventPlayerDroppedFlag(((Player
*)m_target
));
3932 m_target
->ApplySpellImmune(GetId(),IMMUNITY_EFFECT
,m_modifier
.m_miscvalue
,apply
);
3935 void Aura::HandleAuraModStateImmunity(bool apply
, bool Real
)
3937 if(apply
&& Real
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
3939 Unit::AuraList
const& auraList
= m_target
->GetAurasByType(AuraType(m_modifier
.m_miscvalue
));
3940 for(Unit::AuraList::const_iterator itr
= auraList
.begin(); itr
!= auraList
.end();)
3942 if (auraList
.front() != this) // skip itself aura (it already added)
3944 m_target
->RemoveAurasDueToSpell(auraList
.front()->GetId());
3945 itr
= auraList
.begin();
3952 m_target
->ApplySpellImmune(GetId(),IMMUNITY_STATE
,m_modifier
.m_miscvalue
,apply
);
3955 void Aura::HandleAuraModSchoolImmunity(bool apply
, bool Real
)
3957 m_target
->ApplySpellImmune(GetId(),IMMUNITY_SCHOOL
,m_modifier
.m_miscvalue
,apply
);
3959 if(Real
&& apply
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
3961 if(IsPositiveSpell(GetId())) //Only positive immunity removes auras
3963 uint32 school_mask
= m_modifier
.m_miscvalue
;
3964 Unit::AuraMap
& Auras
= m_target
->GetAuras();
3965 for(Unit::AuraMap::iterator iter
= Auras
.begin(), next
; iter
!= Auras
.end(); iter
= next
)
3969 SpellEntry
const *spell
= iter
->second
->GetSpellProto();
3970 if((GetSpellSchoolMask(spell
) & school_mask
)//Check for school mask
3971 && !( spell
->Attributes
& SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY
) //Spells unaffected by invulnerability
3972 && !iter
->second
->IsPositive() //Don't remove positive spells
3973 && spell
->Id
!= GetId() ) //Don't remove self
3975 m_target
->RemoveAurasDueToSpell(spell
->Id
);
3979 next
= Auras
.begin();
3984 if( Real
&& GetSpellProto()->Mechanic
== MECHANIC_BANISH
)
3987 m_target
->addUnitState(UNIT_STAT_ISOLATED
);
3989 m_target
->clearUnitState(UNIT_STAT_ISOLATED
);
3993 void Aura::HandleAuraModDmgImmunity(bool apply
, bool Real
)
3995 m_target
->ApplySpellImmune(GetId(),IMMUNITY_DAMAGE
,m_modifier
.m_miscvalue
,apply
);
3998 void Aura::HandleAuraModDispelImmunity(bool apply
, bool Real
)
4000 // all applied/removed only at real aura add/remove
4004 m_target
->ApplySpellDispelImmunity(m_spellProto
, DispelType(m_modifier
.m_miscvalue
), apply
);
4007 void Aura::HandleAuraProcTriggerSpell(bool apply
, bool Real
)
4014 // some spell have charges by functionality not have its in spell data
4017 case 28200: // Ascendance (Talisman of Ascendance trinket)
4025 void Aura::HandleAuraModStalked(bool apply
, bool Real
)
4027 // used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND
4029 m_target
->SetFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_TRACK_UNIT
);
4031 m_target
->RemoveFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_TRACK_UNIT
);
4034 /*********************************************************/
4036 /*********************************************************/
4038 void Aura::HandlePeriodicTriggerSpell(bool apply
, bool Real
)
4040 m_isPeriodic
= apply
;
4041 if (m_spellProto
->Id
== 66 && !apply
)
4043 if (m_removeMode
== AURA_REMOVE_BY_DEFAULT
&& m_duration
<=0)
4044 m_target
->CastSpell(m_target
, 32612, true, NULL
, this);
4048 void Aura::HandlePeriodicTriggerSpellWithValue(bool apply
, bool Real
)
4050 m_isPeriodic
= apply
;
4053 void Aura::HandlePeriodicEnergize(bool apply
, bool Real
)
4058 m_isPeriodic
= apply
;
4060 // Replenishment (0.25% from max)
4061 // Infinite Replenishment
4062 if (GetId() == 57669 ||
4064 m_modifier
.m_amount
= m_target
->GetMaxPower(POWER_MANA
) * 25 / 10000;
4067 void Aura::HandleAuraPowerBurn(bool apply
, bool Real
)
4069 m_isPeriodic
= apply
;
4072 void Aura::HandleAuraPeriodicDummy(bool apply
, bool Real
)
4074 // spells required only Real aura add/remove
4078 // For prevent double apply bonuses
4079 bool loading
= (m_target
->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)m_target
)->GetSession()->PlayerLoading());
4081 Unit
* caster
= GetCaster();
4083 SpellEntry
const*spell
= GetSpellProto();
4084 switch( spell
->SpellFamilyName
)
4086 case SPELLFAMILY_ROGUE
:
4088 // Master of Subtlety
4089 if (spell
->Id
==31666 && !apply
)
4091 m_target
->RemoveAurasDueToSpell(31665);
4096 case SPELLFAMILY_HUNTER
:
4099 if (apply
&& !loading
&& caster
)
4100 m_modifier
.m_amount
+=caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 8 / 100;
4105 m_isPeriodic
= apply
;
4108 void Aura::HandlePeriodicHeal(bool apply
, bool Real
)
4110 m_isPeriodic
= apply
;
4113 void Aura::HandlePeriodicDamage(bool apply
, bool Real
)
4115 // spells required only Real aura add/remove
4119 m_isPeriodic
= apply
;
4121 // For prevent double apply bonuses
4122 bool loading
= (m_target
->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)m_target
)->GetSession()->PlayerLoading());
4124 // Custom damage calculation after
4125 if (!apply
|| loading
)
4128 Unit
*caster
= GetCaster();
4132 switch (m_spellProto
->SpellFamilyName
)
4134 case SPELLFAMILY_GENERIC
:
4137 if ( m_spellProto
->SpellIconID
== 147 && m_spellProto
->SpellVisual
[0] == 0 )
4139 // $AP*0.18/6 bonus per tick
4140 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 3 / 100);
4145 case SPELLFAMILY_WARRIOR
:
4148 if (m_spellProto
->SpellFamilyFlags
& 0x0000000000000020LL
)
4150 // $0.2*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick
4151 float ap
= caster
->GetTotalAttackPowerValue(BASE_ATTACK
);
4152 int32 mws
= caster
->GetAttackTime(BASE_ATTACK
);
4153 float mwb_min
= caster
->GetWeaponDamageRange(BASE_ATTACK
,MINDAMAGE
);
4154 float mwb_max
= caster
->GetWeaponDamageRange(BASE_ATTACK
,MAXDAMAGE
);
4155 m_modifier
.m_amount
+=int32(((mwb_min
+mwb_max
)/2+ap
*mws
/14000)*0.2f
);
4160 case SPELLFAMILY_DRUID
:
4163 if (m_spellProto
->SpellFamilyFlags
& 0x0000000000001000LL
)
4165 // $AP*0.06 bonus per tick
4166 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 6 / 100);
4170 if (m_spellProto
->SpellFamilyFlags
& 0x000000010000000000LL
)
4172 // $AP*0.05/5 bonus per tick
4173 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) / 100);
4177 if (m_spellProto
->SpellFamilyFlags
& 0x000000000000800000LL
)
4180 if (caster
->GetTypeId() != TYPEID_PLAYER
)
4183 uint8 cp
= ((Player
*)caster
)->GetComboPoints();
4185 // Idol of Feral Shadows. Cant be handled as SpellMod in SpellAura:Dummy due its dependency from CPs
4186 Unit::AuraList
const& dummyAuras
= caster
->GetAurasByType(SPELL_AURA_DUMMY
);
4187 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
4189 if((*itr
)->GetId()==34241)
4191 m_modifier
.m_amount
+= cp
* (*itr
)->GetModifier()->m_amount
;
4195 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * cp
/ 100);
4199 if (m_spellProto
->SpellFamilyFlags
& 0x1000000000000000LL
)
4202 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 15 / 100);
4207 case SPELLFAMILY_ROGUE
:
4210 if (m_spellProto
->SpellFamilyFlags
& 0x000000000000100000LL
)
4212 if (caster
->GetTypeId() != TYPEID_PLAYER
)
4214 //1 point : ${($m1+$b1*1+0.015*$AP)*4} damage over 8 secs
4215 //2 points: ${($m1+$b1*2+0.024*$AP)*5} damage over 10 secs
4216 //3 points: ${($m1+$b1*3+0.03*$AP)*6} damage over 12 secs
4217 //4 points: ${($m1+$b1*4+0.03428571*$AP)*7} damage over 14 secs
4218 //5 points: ${($m1+$b1*5+0.0375*$AP)*8} damage over 16 secs
4219 float AP_per_combo
[] = {0, 0.015f
, 0.024, 0.03, 0.03428571, 0.0375};
4220 uint8 cp
= ((Player
*)caster
)->GetComboPoints();
4222 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * AP_per_combo
[cp
]);
4226 if (m_spellProto
->SpellFamilyFlags
& 0x000000000000000100LL
)
4228 // $AP*0.07 bonus per tick
4229 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 7 / 100);
4233 if (m_spellProto
->SpellFamilyFlags
& 0x0000000000010000)
4235 // 0.08*$AP / 4 * amount of stack
4236 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 2 * GetStackAmount() / 100);
4241 case SPELLFAMILY_HUNTER
:
4244 if (m_spellProto
->SpellFamilyFlags
& 0x0000000000004000LL
)
4246 // $RAP*0.1/5 bonus per tick
4247 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 10 / 500);
4251 if (m_spellProto
->SpellFamilyFlags
& 0x0000000000000004LL
&& m_spellProto
->SpellIconID
== 678)
4253 // $RAP*0.1/5 bonus per tick
4254 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 10 / 500);
4264 void Aura::HandlePeriodicDamagePCT(bool apply
, bool Real
)
4266 m_isPeriodic
= apply
;
4269 void Aura::HandlePeriodicLeech(bool apply
, bool Real
)
4271 m_isPeriodic
= apply
;
4274 void Aura::HandlePeriodicManaLeech(bool apply
, bool Real
)
4276 m_isPeriodic
= apply
;
4279 void Aura::HandlePeriodicHealthFunnel(bool apply
, bool Real
)
4281 m_isPeriodic
= apply
;
4284 /*********************************************************/
4285 /*** MODIFY STATS ***/
4286 /*********************************************************/
4288 /********************************/
4289 /*** RESISTANCE ***/
4290 /********************************/
4292 void Aura::HandleAuraModResistanceExclusive(bool apply
, bool Real
)
4294 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
4296 if(m_modifier
.m_miscvalue
& int32(1<<x
))
4298 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), BASE_VALUE
, float(m_modifier
.m_amount
), apply
);
4299 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4300 m_target
->ApplyResistanceBuffModsMod(SpellSchools(x
),m_positive
,m_modifier
.m_amount
, apply
);
4305 void Aura::HandleAuraModResistance(bool apply
, bool Real
)
4307 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
4309 if(m_modifier
.m_miscvalue
& int32(1<<x
))
4311 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4312 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4313 m_target
->ApplyResistanceBuffModsMod(SpellSchools(x
),m_positive
,m_modifier
.m_amount
, apply
);
4318 void Aura::HandleAuraModBaseResistancePCT(bool apply
, bool Real
)
4320 // only players have base stats
4321 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4323 //pets only have base armor
4324 if(((Creature
*)m_target
)->isPet() && (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
4325 m_target
->HandleStatModifier(UNIT_MOD_ARMOR
, BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4329 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
4331 if(m_modifier
.m_miscvalue
& int32(1<<x
))
4332 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4337 void Aura::HandleModResistancePercent(bool apply
, bool Real
)
4339 for(int8 i
= SPELL_SCHOOL_NORMAL
; i
< MAX_SPELL_SCHOOL
; i
++)
4341 if(m_modifier
.m_miscvalue
& int32(1<<i
))
4343 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ i
), TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4344 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4346 m_target
->ApplyResistanceBuffModsPercentMod(SpellSchools(i
),true,m_modifier
.m_amount
, apply
);
4347 m_target
->ApplyResistanceBuffModsPercentMod(SpellSchools(i
),false,m_modifier
.m_amount
, apply
);
4353 void Aura::HandleModBaseResistance(bool apply
, bool Real
)
4355 // only players have base stats
4356 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4358 //only pets have base stats
4359 if(((Creature
*)m_target
)->isPet() && (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
4360 m_target
->HandleStatModifier(UNIT_MOD_ARMOR
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4364 for(int i
= SPELL_SCHOOL_NORMAL
; i
< MAX_SPELL_SCHOOL
; i
++)
4365 if(m_modifier
.m_miscvalue
& (1<<i
))
4366 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ i
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4370 /********************************/
4372 /********************************/
4374 void Aura::HandleAuraModStat(bool apply
, bool Real
)
4376 if (m_modifier
.m_miscvalue
< -2 || m_modifier
.m_miscvalue
> 4)
4378 sLog
.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ",GetId(),GetEffIndex(),m_modifier
.m_miscvalue
);
4382 for(int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; i
++)
4384 // -1 or -2 is all stats ( misc < -2 checked in function beginning )
4385 if (m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
== i
)
4387 //m_target->ApplyStatMod(Stats(i), m_modifier.m_amount,apply);
4388 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4389 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4390 m_target
->ApplyStatBuffMod(Stats(i
),m_modifier
.m_amount
,apply
);
4395 void Aura::HandleModPercentStat(bool apply
, bool Real
)
4397 if (m_modifier
.m_miscvalue
< -1 || m_modifier
.m_miscvalue
> 4)
4399 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
4403 // only players have base stats
4404 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
4407 for (int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; ++i
)
4409 if(m_modifier
.m_miscvalue
== i
|| m_modifier
.m_miscvalue
== -1)
4410 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4414 void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool Real
)
4416 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4419 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4420 // This information for client side use only
4421 // Recalculate bonus
4422 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4425 void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool Real
)
4427 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4430 // Recalculate bonus
4431 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4434 void Aura::HandleAuraModDispelResist(bool apply
, bool Real
)
4440 m_target
->CastSpell(m_target
,44416,true,NULL
,this,GetCasterGUID());
4443 void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool Real
)
4445 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4448 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4449 // This information for client side use only
4450 // Recalculate bonus
4451 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4454 void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool Real
)
4456 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4459 // Recalculate bonus
4460 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4463 void Aura::HandleModHealingDone(bool /*apply*/, bool Real
)
4465 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4467 // implemented in Unit::SpellHealingBonus
4468 // this information is for client side only
4469 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4472 void Aura::HandleModTotalPercentStat(bool apply
, bool Real
)
4474 if (m_modifier
.m_miscvalue
< -1 || m_modifier
.m_miscvalue
> 4)
4476 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
4480 //save current and max HP before applying aura
4481 uint32 curHPValue
= m_target
->GetHealth();
4482 uint32 maxHPValue
= m_target
->GetMaxHealth();
4484 for (int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; i
++)
4486 if(m_modifier
.m_miscvalue
== i
|| m_modifier
.m_miscvalue
== -1)
4488 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4489 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4490 m_target
->ApplyStatPercentBuffMod(Stats(i
), m_modifier
.m_amount
, apply
);
4494 //recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag)
4495 if ((m_modifier
.m_miscvalue
== STAT_STAMINA
) && (maxHPValue
> 0) && (m_spellProto
->Attributes
& 0x10))
4497 // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed
4498 uint32 newHPValue
= (m_target
->GetMaxHealth() * curHPValue
) / maxHPValue
;
4499 m_target
->SetHealth(newHPValue
);
4503 void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool Real
)
4505 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4508 if(m_modifier
.m_miscvalue
!= SPELL_SCHOOL_MASK_NORMAL
)
4510 // support required adding replace UpdateArmor by loop by UpdateResistence at intellect update
4511 // and include in UpdateResistence same code as in UpdateArmor for aura mod apply.
4512 sLog
.outError("Aura SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT(182) need adding support for non-armor resistances!");
4516 // Recalculate Armor
4517 m_target
->UpdateArmor();
4520 /********************************/
4521 /*** HEAL & ENERGIZE ***/
4522 /********************************/
4523 void Aura::HandleAuraModTotalHealthPercentRegen(bool apply
, bool Real
)
4525 m_isPeriodic
= apply
;
4528 void Aura::HandleAuraModTotalManaPercentRegen(bool apply
, bool Real
)
4530 if(m_modifier
.periodictime
== 0)
4531 m_modifier
.periodictime
= 1000;
4533 m_periodicTimer
= m_modifier
.periodictime
;
4534 m_isPeriodic
= apply
;
4537 void Aura::HandleModRegen(bool apply
, bool Real
) // eating
4539 if(m_modifier
.periodictime
== 0)
4540 m_modifier
.periodictime
= 5000;
4542 m_periodicTimer
= 5000;
4543 m_isPeriodic
= apply
;
4546 void Aura::HandleModPowerRegen(bool apply
, bool Real
) // drinking
4551 Powers pt
= m_target
->getPowerType();
4552 if(m_modifier
.periodictime
== 0)
4554 // Anger Management (only spell use this aura for rage)
4555 if (pt
== POWER_RAGE
)
4556 m_modifier
.periodictime
= 3000;
4558 m_modifier
.periodictime
= 2000;
4561 m_periodicTimer
= 5000;
4563 if (m_target
->GetTypeId() == TYPEID_PLAYER
&& m_modifier
.m_miscvalue
== POWER_MANA
)
4564 ((Player
*)m_target
)->UpdateManaRegen();
4566 m_isPeriodic
= apply
;
4569 void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real
)
4571 // spells required only Real aura add/remove
4575 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
4578 // Update manaregen value
4579 if (m_modifier
.m_miscvalue
== POWER_MANA
)
4580 ((Player
*)m_target
)->UpdateManaRegen();
4583 void Aura::HandleModManaRegen(bool /*apply*/, bool Real
)
4585 // spells required only Real aura add/remove
4589 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
4592 //Note: an increase in regen does NOT cause threat.
4593 ((Player
*)m_target
)->UpdateManaRegen();
4596 void Aura::HandleComprehendLanguage(bool apply
, bool Real
)
4599 m_target
->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_COMPREHEND_LANG
);
4601 m_target
->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_COMPREHEND_LANG
);
4604 void Aura::HandleAuraModIncreaseHealth(bool apply
, bool Real
)
4606 // Special case with temporary increase max/current health
4609 case 12976: // Warrior Last Stand triggered spell
4610 case 28726: // Nightmare Seed ( Nightmare Seed )
4611 case 34511: // Valor (Bulwark of Kings, Bulwark of the Ancient Kings)
4612 case 44055: // Tremendous Fortitude (Battlemaster's Alacrity)
4618 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4619 m_target
->ModifyHealth(m_modifier
.m_amount
);
4623 if (int32(m_target
->GetHealth()) > m_modifier
.m_amount
)
4624 m_target
->ModifyHealth(-m_modifier
.m_amount
);
4626 m_target
->SetHealth(1);
4627 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4635 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4638 void Aura::HandleAuraModIncreaseMaxHealth(bool apply
, bool Real
)
4640 uint32 oldhealth
= m_target
->GetHealth();
4641 double healthPercentage
= (double)oldhealth
/ (double)m_target
->GetMaxHealth();
4643 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4645 // refresh percentage
4648 uint32 newhealth
= uint32(ceil((double)m_target
->GetMaxHealth() * healthPercentage
));
4652 m_target
->SetHealth(newhealth
);
4656 void Aura::HandleAuraModIncreaseEnergy(bool apply
, bool Real
)
4658 Powers powerType
= m_target
->getPowerType();
4659 if(int32(powerType
) != m_modifier
.m_miscvalue
)
4662 UnitMods unitMod
= UnitMods(UNIT_MOD_POWER_START
+ powerType
);
4664 m_target
->HandleStatModifier(unitMod
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4667 void Aura::HandleAuraModIncreaseEnergyPercent(bool apply
, bool /*Real*/)
4669 Powers powerType
= m_target
->getPowerType();
4670 if(int32(powerType
) != m_modifier
.m_miscvalue
)
4673 UnitMods unitMod
= UnitMods(UNIT_MOD_POWER_START
+ powerType
);
4675 m_target
->HandleStatModifier(unitMod
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4678 void Aura::HandleAuraModIncreaseHealthPercent(bool apply
, bool /*Real*/)
4680 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4683 void Aura::HandleAuraIncreaseBaseHealthPercent(bool apply
, bool /*Real*/)
4685 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4688 /********************************/
4690 /********************************/
4692 void Aura::HandleAuraModParryPercent(bool /*apply*/, bool Real
)
4694 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
4697 ((Player
*)m_target
)->UpdateParryPercentage();
4700 void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool Real
)
4702 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
4705 ((Player
*)m_target
)->UpdateDodgePercentage();
4706 //sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount));
4709 void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool Real
)
4711 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
4714 ((Player
*)m_target
)->UpdateBlockPercentage();
4715 //sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount));
4718 void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real
)
4720 // spells required only Real aura add/remove
4724 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
4727 ((Player
*)m_target
)->UpdateManaRegen();
4730 void Aura::HandleAuraModCritPercent(bool apply
, bool Real
)
4732 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
4735 // apply item specific bonuses for already equipped weapon
4738 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
4739 if(Item
* pItem
= ((Player
*)m_target
)->GetWeaponForAttack(WeaponAttackType(i
)))
4740 ((Player
*)m_target
)->_ApplyWeaponDependentAuraCritMod(pItem
,WeaponAttackType(i
),this,apply
);
4743 // mods must be applied base at equipped weapon class and subclass comparison
4744 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
4745 // m_modifier.m_miscvalue comparison with item generated damage types
4747 if (GetSpellProto()->EquippedItemClass
== -1)
4749 ((Player
*)m_target
)->HandleBaseModValue(CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
4750 ((Player
*)m_target
)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
4751 ((Player
*)m_target
)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
4755 // done in Player::_ApplyWeaponDependentAuraMods
4759 void Aura::HandleModHitChance(bool apply
, bool Real
)
4761 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4763 ((Player
*)m_target
)->UpdateMeleeHitChances();
4764 ((Player
*)m_target
)->UpdateRangedHitChances();
4768 m_target
->m_modMeleeHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
4769 m_target
->m_modRangedHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
4773 void Aura::HandleModSpellHitChance(bool apply
, bool Real
)
4775 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4777 ((Player
*)m_target
)->UpdateSpellHitChances();
4781 m_target
->m_modSpellHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
4785 void Aura::HandleModSpellCritChance(bool apply
, bool Real
)
4787 // spells required only Real aura add/remove
4791 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4793 ((Player
*)m_target
)->UpdateAllSpellCritChances();
4797 m_target
->m_baseSpellCritChance
+= apply
? m_modifier
.m_amount
:(-m_modifier
.m_amount
);
4801 void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real
)
4803 // spells required only Real aura add/remove
4807 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4810 for(int school
= SPELL_SCHOOL_NORMAL
; school
< MAX_SPELL_SCHOOL
; ++school
)
4811 if (m_modifier
.m_miscvalue
& (1<<school
))
4812 ((Player
*)m_target
)->UpdateSpellCritChance(school
);
4815 /********************************/
4816 /*** ATTACK SPEED ***/
4817 /********************************/
4819 void Aura::HandleModCastingSpeed(bool apply
, bool Real
)
4821 m_target
->ApplyCastTimePercentMod(m_modifier
.m_amount
,apply
);
4824 void Aura::HandleModMeleeRangedSpeedPct(bool apply
, bool Real
)
4826 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
,m_modifier
.m_amount
,apply
);
4827 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
,m_modifier
.m_amount
,apply
);
4828 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
4831 void Aura::HandleModCombatSpeedPct(bool apply
, bool Real
)
4833 m_target
->ApplyCastTimePercentMod(m_modifier
.m_amount
,apply
);
4834 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
,m_modifier
.m_amount
,apply
);
4835 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
,m_modifier
.m_amount
,apply
);
4836 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
4839 void Aura::HandleModAttackSpeed(bool apply
, bool Real
)
4841 if(!m_target
->isAlive() )
4844 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
,m_modifier
.m_amount
,apply
);
4847 void Aura::HandleHaste(bool apply
, bool Real
)
4849 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
, m_modifier
.m_amount
,apply
);
4850 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
, m_modifier
.m_amount
,apply
);
4851 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
,m_modifier
.m_amount
,apply
);
4854 void Aura::HandleAuraModRangedHaste(bool apply
, bool Real
)
4856 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
4859 void Aura::HandleRangedAmmoHaste(bool apply
, bool Real
)
4861 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4863 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
,m_modifier
.m_amount
, apply
);
4866 /********************************/
4867 /*** ATTACK POWER ***/
4868 /********************************/
4870 void Aura::HandleAuraModAttackPower(bool apply
, bool Real
)
4872 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4875 void Aura::HandleAuraModRangedAttackPower(bool apply
, bool Real
)
4877 if((m_target
->getClassMask() & CLASSMASK_WAND_USERS
)!=0)
4880 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4883 void Aura::HandleAuraModAttackPowerPercent(bool apply
, bool Real
)
4885 //UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1
4886 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4889 void Aura::HandleAuraModRangedAttackPowerPercent(bool apply
, bool Real
)
4891 if((m_target
->getClassMask() & CLASSMASK_WAND_USERS
)!=0)
4894 //UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1
4895 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4898 void Aura::HandleAuraModRangedAttackPowerOfStatPercent(bool apply
, bool Real
)
4900 // spells required only Real aura add/remove
4904 // Recalculate bonus
4905 if(m_target
->GetTypeId() == TYPEID_PLAYER
&& !(m_target
->getClassMask() & CLASSMASK_WAND_USERS
))
4906 ((Player
*)m_target
)->UpdateAttackPowerAndDamage(true);
4909 void Aura::HandleAuraModAttackPowerOfStatPercent(bool apply
, bool Real
)
4911 // spells required only Real aura add/remove
4915 // Recalculate bonus
4916 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4917 ((Player
*)m_target
)->UpdateAttackPowerAndDamage(false);
4920 /********************************/
4921 /*** DAMAGE BONUS ***/
4922 /********************************/
4923 void Aura::HandleModDamageDone(bool apply
, bool Real
)
4925 // apply item specific bonuses for already equipped weapon
4926 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
4928 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
4929 if(Item
* pItem
= ((Player
*)m_target
)->GetWeaponForAttack(WeaponAttackType(i
)))
4930 ((Player
*)m_target
)->_ApplyWeaponDependentAuraDamageMod(pItem
,WeaponAttackType(i
),this,apply
);
4933 // m_modifier.m_miscvalue is bitmask of spell schools
4934 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
4935 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wands
4936 // 127 - full bitmask any damages
4938 // mods must be applied base at equipped weapon class and subclass comparison
4939 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
4940 // m_modifier.m_miscvalue comparison with item generated damage types
4942 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
) != 0)
4944 // apply generic physical damage bonuses including wand case
4945 if (GetSpellProto()->EquippedItemClass
== -1 || m_target
->GetTypeId() != TYPEID_PLAYER
)
4947 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4948 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4949 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4953 // done in Player::_ApplyWeaponDependentAuraMods
4956 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4959 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS
,m_modifier
.m_amount
,apply
);
4961 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG
,m_modifier
.m_amount
,apply
);
4965 // Skip non magic case for speedup
4966 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_MAGIC
) == 0)
4969 if( GetSpellProto()->EquippedItemClass
!= -1 || GetSpellProto()->EquippedItemInventoryTypeMask
!= 0 )
4971 // wand magic case (skip generic to all item spell bonuses)
4972 // done in Player::_ApplyWeaponDependentAuraMods
4974 // Skip item specific requirements for not wand magic damage
4978 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4979 // This information for client side use only
4980 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4984 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; i
++)
4986 if((m_modifier
.m_miscvalue
& (1<<i
)) != 0)
4987 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS
+i
,m_modifier
.m_amount
,apply
);
4992 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; i
++)
4994 if((m_modifier
.m_miscvalue
& (1<<i
)) != 0)
4995 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG
+i
,m_modifier
.m_amount
,apply
);
4998 Pet
* pet
= m_target
->GetPet();
5000 pet
->UpdateAttackPowerAndDamage();
5004 void Aura::HandleModDamagePercentDone(bool apply
, bool Real
)
5006 sLog
.outDebug("AURA MOD DAMAGE type:%u negative:%u", m_modifier
.m_miscvalue
, m_positive
? 0 : 1);
5008 // apply item specific bonuses for already equipped weapon
5009 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
5011 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
5012 if(Item
* pItem
= ((Player
*)m_target
)->GetWeaponForAttack(WeaponAttackType(i
)))
5013 ((Player
*)m_target
)->_ApplyWeaponDependentAuraDamageMod(pItem
,WeaponAttackType(i
),this,apply
);
5016 // m_modifier.m_miscvalue is bitmask of spell schools
5017 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5018 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wand
5019 // 127 - full bitmask any damages
5021 // mods must be applied base at equipped weapon class and subclass comparison
5022 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5023 // m_modifier.m_miscvalue comparison with item generated damage types
5025 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
) != 0)
5027 // apply generic physical damage bonuses including wand case
5028 if (GetSpellProto()->EquippedItemClass
== -1 || m_target
->GetTypeId() != TYPEID_PLAYER
)
5030 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5031 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5032 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5036 // done in Player::_ApplyWeaponDependentAuraMods
5038 // For show in client
5039 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5040 m_target
->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT
,m_modifier
.m_amount
/100.0f
,apply
);
5043 // Skip non magic case for speedup
5044 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_MAGIC
) == 0)
5047 if( GetSpellProto()->EquippedItemClass
!= -1 || GetSpellProto()->EquippedItemInventoryTypeMask
!= 0 )
5049 // wand magic case (skip generic to all item spell bonuses)
5050 // done in Player::_ApplyWeaponDependentAuraMods
5052 // Skip item specific requirements for not wand magic damage
5056 // Magic damage percent modifiers implemented in Unit::SpellDamageBonus
5057 // Send info to client
5058 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5059 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; ++i
)
5060 m_target
->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT
+i
,m_modifier
.m_amount
/100.0f
,apply
);
5063 void Aura::HandleModOffhandDamagePercent(bool apply
, bool Real
)
5065 // spells required only Real aura add/remove
5069 sLog
.outDebug("AURA MOD OFFHAND DAMAGE");
5071 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5074 /********************************/
5075 /*** POWER COST ***/
5076 /********************************/
5078 void Aura::HandleModPowerCostPCT(bool apply
, bool Real
)
5080 // spells required only Real aura add/remove
5084 float amount
= m_modifier
.m_amount
/100.0f
;
5085 for(int i
= 0; i
< MAX_SPELL_SCHOOL
; ++i
)
5086 if(m_modifier
.m_miscvalue
& (1<<i
))
5087 m_target
->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER
+i
,amount
,apply
);
5090 void Aura::HandleModPowerCost(bool apply
, bool Real
)
5092 // spells required only Real aura add/remove
5096 for(int i
= 0; i
< MAX_SPELL_SCHOOL
; ++i
)
5097 if(m_modifier
.m_miscvalue
& (1<<i
))
5098 m_target
->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER
+i
,m_modifier
.m_amount
,apply
);
5101 void Aura::HandleNoReagentUseAura(bool Apply
, bool Real
)
5103 // spells required only Real aura add/remove
5106 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5108 uint32 mask
[3] = {0, 0, 0};
5109 Unit::AuraList
const& noReagent
= m_target
->GetAurasByType(SPELL_AURA_NO_REAGENT_USE
);
5110 for(Unit::AuraList::const_iterator i
= noReagent
.begin(); i
!= noReagent
.end(); ++i
)
5112 uint32
const *ptr
= (*i
)->getAuraSpellClassMask();
5118 m_target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
, mask
[0]);
5119 m_target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
+1, mask
[1]);
5120 m_target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
+2, mask
[2]);
5123 /*********************************************************/
5125 /*********************************************************/
5127 void Aura::HandleShapeshiftBoosts(bool apply
)
5130 uint32 spellId2
= 0;
5131 uint32 HotWSpellId
= 0;
5133 switch(GetModifier()->m_miscvalue
)
5137 HotWSpellId
= 24900;
5152 HotWSpellId
= 24899;
5157 HotWSpellId
= 24899;
5159 case FORM_BATTLESTANCE
:
5162 case FORM_DEFENSIVESTANCE
:
5165 case FORM_BERSERKERSTANCE
:
5170 // aura from effect trigger spell
5177 case FORM_FLIGHT_EPIC
:
5181 case FORM_METAMORPHOSIS
:
5185 case FORM_SPIRITOFREDEMPTION
:
5187 spellId2
= 27795; // must be second, this important at aura remove to prevent to early iterator invalidation.
5189 case FORM_GHOSTWOLF
:
5194 case FORM_CREATURECAT
:
5195 case FORM_CREATUREBEAR
:
5200 uint32 form
= GetModifier()->m_miscvalue
-1;
5204 if (spellId
) m_target
->CastSpell(m_target
, spellId
, true, NULL
, this );
5205 if (spellId2
) m_target
->CastSpell(m_target
, spellId2
, true, NULL
, this);
5207 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5209 const PlayerSpellMap
& sp_list
= ((Player
*)m_target
)->GetSpellMap();
5210 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
5212 if(itr
->second
->state
== PLAYERSPELL_REMOVED
) continue;
5213 if(itr
->first
==spellId
|| itr
->first
==spellId2
) continue;
5214 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
5215 if (!spellInfo
|| !(spellInfo
->Attributes
& (SPELL_ATTR_PASSIVE
| (1<<7)))) continue;
5216 if (spellInfo
->Stances
& (1<<form
))
5217 m_target
->CastSpell(m_target
, itr
->first
, true, NULL
, this);
5220 if (((Player
*)m_target
)->HasSpell(17007))
5222 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(24932);
5223 if (spellInfo
&& spellInfo
->Stances
& (1<<form
))
5224 m_target
->CastSpell(m_target
, 24932, true, NULL
, this);
5229 Unit::AuraList
const& mModTotalStatPct
= m_target
->GetAurasByType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
);
5230 for(Unit::AuraList::const_iterator i
= mModTotalStatPct
.begin(); i
!= mModTotalStatPct
.end(); ++i
)
5232 if ((*i
)->GetSpellProto()->SpellIconID
== 240 && (*i
)->GetModifier()->m_miscvalue
== 3)
5234 int32 HotWMod
= (*i
)->GetModifier()->m_amount
;
5235 if(GetModifier()->m_miscvalue
== FORM_CAT
)
5238 m_target
->CastCustomSpell(m_target
, HotWSpellId
, &HotWMod
, NULL
, NULL
, true, NULL
, this);
5247 m_target
->RemoveAurasDueToSpell(spellId
);
5248 m_target
->RemoveAurasDueToSpell(spellId2
);
5250 Unit::AuraMap
& tAuras
= m_target
->GetAuras();
5251 for (Unit::AuraMap::iterator itr
= tAuras
.begin(); itr
!= tAuras
.end();)
5253 if (itr
->second
->IsRemovedOnShapeLost())
5255 m_target
->RemoveAurasDueToSpell(itr
->second
->GetId());
5256 itr
= tAuras
.begin();
5265 /*double healthPercentage = (double)m_target->GetHealth() / (double)m_target->GetMaxHealth();
5266 m_target->SetHealth(uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage)));*/
5269 void Aura::HandleAuraEmpathy(bool apply
, bool Real
)
5271 if(m_target
->GetTypeId() != TYPEID_UNIT
)
5274 CreatureInfo
const * ci
= objmgr
.GetCreatureTemplate(m_target
->GetEntry());
5275 if(ci
&& ci
->type
== CREATURE_TYPE_BEAST
)
5276 m_target
->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_SPECIALINFO
, apply
);
5279 void Aura::HandleAuraUntrackable(bool apply
, bool Real
)
5282 m_target
->SetByteFlag(UNIT_FIELD_BYTES_1
, 3, UNIT_BYTE1_FLAG_UNTRACKABLE
);
5284 m_target
->RemoveByteFlag(UNIT_FIELD_BYTES_1
, 3, UNIT_BYTE1_FLAG_UNTRACKABLE
);
5287 void Aura::HandleAuraModPacify(bool apply
, bool Real
)
5289 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5293 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PACIFIED
);
5295 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PACIFIED
);
5298 void Aura::HandleAuraModPacifyAndSilence(bool apply
, bool Real
)
5300 HandleAuraModPacify(apply
,Real
);
5301 HandleAuraModSilence(apply
,Real
);
5304 void Aura::HandleAuraGhost(bool apply
, bool Real
)
5306 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5311 m_target
->SetFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
);
5315 m_target
->RemoveFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
);
5319 void Aura::HandleAuraAllowFlight(bool apply
, bool Real
)
5321 // all applied/removed only at real aura add/remove
5328 data
.Initialize(SMSG_MOVE_SET_CAN_FLY
, 12);
5330 data
.Initialize(SMSG_MOVE_UNSET_CAN_FLY
, 12);
5331 data
.append(m_target
->GetPackGUID());
5332 data
<< uint32(0); // unk
5333 m_target
->SendMessageToSet(&data
, true);
5336 void Aura::HandleModRating(bool apply
, bool Real
)
5338 // spells required only Real aura add/remove
5342 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5345 for (uint32 rating
= 0; rating
< MAX_COMBAT_RATING
; ++rating
)
5346 if (m_modifier
.m_miscvalue
& (1 << rating
))
5347 ((Player
*)m_target
)->ApplyRatingMod(CombatRating(rating
), m_modifier
.m_amount
, apply
);
5350 void Aura::HandleModRatingFromStat(bool apply
, bool Real
)
5352 // spells required only Real aura add/remove
5356 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5358 // Just recalculate ratings
5359 for (uint32 rating
= 0; rating
< MAX_COMBAT_RATING
; ++rating
)
5360 if (m_modifier
.m_miscvalue
& (1 << rating
))
5361 ((Player
*)m_target
)->ApplyRatingMod(CombatRating(rating
), 0, apply
);
5364 void Aura::HandleForceMoveForward(bool apply
, bool Real
)
5366 if(!Real
|| m_target
->GetTypeId() != TYPEID_PLAYER
)
5369 m_target
->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FORCE_MOVE
);
5371 m_target
->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FORCE_MOVE
);
5374 void Aura::HandleAuraModExpertise(bool /*apply*/, bool Real
)
5376 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5379 ((Player
*)m_target
)->UpdateExpertise(BASE_ATTACK
);
5380 ((Player
*)m_target
)->UpdateExpertise(OFF_ATTACK
);
5383 void Aura::HandleModTargetResistance(bool apply
, bool Real
)
5385 // spells required only Real aura add/remove
5388 // applied to damage as HandleNoImmediateEffect in Unit::CalcAbsorbResist and Unit::CalcArmorReducedDamage
5390 // show armor penetration
5391 if (m_target
->GetTypeId() == TYPEID_PLAYER
&& (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
5392 m_target
->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE
,m_modifier
.m_amount
, apply
);
5394 // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy
5395 if (m_target
->GetTypeId() == TYPEID_PLAYER
&& (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_SPELL
)==SPELL_SCHOOL_MASK_SPELL
)
5396 m_target
->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE
,m_modifier
.m_amount
, apply
);
5399 void Aura::HandleShieldBlockValue(bool apply
, bool Real
)
5401 BaseModType modType
= FLAT_MOD
;
5402 if(m_modifier
.m_auraname
== SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT
)
5405 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5406 ((Player
*)m_target
)->HandleBaseModValue(SHIELD_BLOCK_VALUE
, modType
, float(m_modifier
.m_amount
), apply
);
5409 void Aura::HandleAuraRetainComboPoints(bool apply
, bool Real
)
5411 // spells required only Real aura add/remove
5415 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5418 Player
*target
= (Player
*)m_target
;
5420 // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler
5421 // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost)
5422 if( !apply
&& m_duration
==0 && target
->GetComboTarget())
5423 if(Unit
* unit
= ObjectAccessor::GetUnit(*m_target
,target
->GetComboTarget()))
5424 target
->AddComboPoints(unit
, -m_modifier
.m_amount
);
5427 void Aura::HandleModUnattackable( bool Apply
, bool Real
)
5430 m_target
->CombatStop();
5432 m_target
->ApplyModFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_NON_ATTACKABLE
,Apply
);
5435 void Aura::HandleSpiritOfRedemption( bool apply
, bool Real
)
5437 // spells required only Real aura add/remove
5441 // prepare spirit state
5444 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
5446 // disable breath/etc timers
5447 ((Player
*)m_target
)->StopMirrorTimers();
5449 // set stand state (expected in this form)
5450 if(!m_target
->IsStandState())
5451 m_target
->SetStandState(UNIT_STAND_STATE_STAND
);
5454 m_target
->SetHealth(1);
5458 m_target
->DealDamage(m_target
, m_target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, GetSpellProto(), false);
5461 void Aura::CleanupTriggeredSpells()
5463 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& m_spellProto
->SpellFamilyFlags
& 0x0000001000000020LL
)
5465 // Blood Frenzy remove
5466 m_target
->RemoveAurasDueToSpell(30069);
5467 m_target
->RemoveAurasDueToSpell(30070);
5471 uint32 tSpellId
= m_spellProto
->EffectTriggerSpell
[GetEffIndex()];
5475 SpellEntry
const* tProto
= sSpellStore
.LookupEntry(tSpellId
);
5479 if(GetSpellDuration(tProto
) != -1)
5482 // needed for spell 43680, maybe others
5483 // TODO: is there a spell flag, which can solve this in a more sophisticated way?
5484 if(m_spellProto
->EffectApplyAuraName
[GetEffIndex()] == SPELL_AURA_PERIODIC_TRIGGER_SPELL
&&
5485 GetSpellDuration(m_spellProto
) == m_spellProto
->EffectAmplitude
[GetEffIndex()])
5487 m_target
->RemoveAurasDueToSpell(tSpellId
);
5490 void Aura::HandleSchoolAbsorb(bool apply
, bool Real
)
5495 // prevent double apply bonuses
5496 if(apply
&& (m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading()))
5498 if(Unit
* caster
= GetCaster())
5500 float DoneActualBenefit
= 0.0f
;
5501 switch(m_spellProto
->SpellFamilyName
)
5503 case SPELLFAMILY_PRIEST
:
5504 if(m_spellProto
->SpellFamilyFlags
== 0x1) //PW:S
5506 //+30% from +healing bonus
5507 DoneActualBenefit
= caster
->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto
)) * 0.3f
;
5511 case SPELLFAMILY_MAGE
:
5512 if(m_spellProto
->SpellFamilyFlags
== 0x80100 || m_spellProto
->SpellFamilyFlags
== 0x8 || m_spellProto
->SpellFamilyFlags
== 0x100000000LL
)
5514 //frost ward, fire ward, ice barrier
5515 //+10% from +spd bonus
5516 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.1f
;
5520 case SPELLFAMILY_WARLOCK
:
5521 if(m_spellProto
->SpellFamilyFlags
== 0x00)
5524 //+10% from +spd bonus
5525 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.1f
;
5533 DoneActualBenefit
*= caster
->CalculateLevelPenalty(GetSpellProto());
5535 m_modifier
.m_amount
+= (int32
)DoneActualBenefit
;
5540 void Aura::PeriodicTick()
5542 if(!m_target
->isAlive())
5545 switch(m_modifier
.m_auraname
)
5547 case SPELL_AURA_PERIODIC_DAMAGE
:
5548 case SPELL_AURA_PERIODIC_DAMAGE_PERCENT
:
5550 Unit
*pCaster
= GetCaster();
5554 if( GetSpellProto()->Effect
[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
5555 pCaster
->SpellHitResult(m_target
,GetSpellProto(),false)!=SPELL_MISS_NONE
)
5558 // Check for immune (not use charges)
5559 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5562 // some auras remove at specific health level or more
5563 if(m_modifier
.m_auraname
==SPELL_AURA_PERIODIC_DAMAGE
)
5567 case 43093: case 31956: case 38801:
5568 case 35321: case 38363: case 39215:
5569 if(m_target
->GetHealth() == m_target
->GetMaxHealth() )
5571 m_target
->RemoveAurasDueToSpell(GetId());
5578 GetEffIndex() < 2 && GetSpellProto()->Effect
[GetEffIndex()]==SPELL_EFFECT_DUMMY
?
5579 pCaster
->CalculateSpellDamage(GetSpellProto(),GetEffIndex()+1,GetSpellProto()->EffectBasePoints
[GetEffIndex()+1],m_target
) :
5581 if(m_target
->GetHealth()*100 >= m_target
->GetMaxHealth()*percent
)
5583 m_target
->RemoveAurasDueToSpell(GetId());
5595 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
5597 // ignore non positive values (can be result apply spellmods to aura damage
5598 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5602 if(m_modifier
.m_auraname
== SPELL_AURA_PERIODIC_DAMAGE
)
5606 // Calculate armor mitigation if it is a physical spell
5607 // But not for bleed mechanic spells
5608 if ( GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL
&&
5609 GetEffectMechanic(GetSpellProto(), m_effIndex
) != MECHANIC_BLEED
)
5611 uint32 pdamageReductedArmor
= pCaster
->CalcArmorReducedDamage(m_target
, pdamage
);
5612 cleanDamage
.damage
+= pdamage
- pdamageReductedArmor
;
5613 pdamage
= pdamageReductedArmor
;
5616 pdamage
= pCaster
->SpellDamageBonus(m_target
, GetSpellProto(), pdamage
, DOT
, GetStackAmount());
5618 // Curse of Agony damage-per-tick calculation
5619 if (GetSpellProto()->SpellFamilyName
==SPELLFAMILY_WARLOCK
&& (GetSpellProto()->SpellFamilyFlags
& 0x0000000000000400LL
) && GetSpellProto()->SpellIconID
==544)
5621 // 1..4 ticks, 1/2 from normal tick damage
5622 if (m_duration
>=((m_maxduration
-m_modifier
.periodictime
)*2/3))
5623 pdamage
= pdamage
/2;
5624 // 9..12 ticks, 3/2 from normal tick damage
5625 else if(m_duration
<((m_maxduration
-m_modifier
.periodictime
)/3))
5626 pdamage
+= (pdamage
+1)/2; // +1 prevent 0.5 damage possible lost at 1..4 ticks
5627 // 5..8 ticks have normal tick damage
5631 pdamage
= uint32(m_target
->GetMaxHealth()*amount
/100);
5633 //As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit
5634 // Reduce dot damage from resilience for players
5635 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
5636 pdamage
-=((Player
*)m_target
)->GetDotDamageReduction(pdamage
);
5638 pCaster
->CalcAbsorbResist(m_target
, GetSpellSchoolMask(GetSpellProto()), DOT
, pdamage
, &absorb
, &resist
);
5640 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
5641 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId(),absorb
);
5643 WorldPacket
data(SMSG_PERIODICAURALOG
, (21+16));// we guess size
5644 data
.append(m_target
->GetPackGUID());
5645 data
.appendPackGUID(GetCasterGUID());
5646 data
<< uint32(GetId());
5648 data
<< uint32(m_modifier
.m_auraname
);
5649 data
<< (uint32
)pdamage
;
5650 data
<< uint32(0); // overkill
5651 data
<< (uint32
)GetSpellSchoolMask(GetSpellProto()); // will be mask in 2.4.x
5652 data
<< (uint32
)absorb
;
5653 data
<< (uint32
)resist
;
5654 m_target
->SendMessageToSet(&data
,true);
5656 Unit
* target
= m_target
; // aura can be deleted in DealDamage
5657 SpellEntry
const* spellProto
= GetSpellProto();
5660 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
;// | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
5661 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
5662 pdamage
= (pdamage
<= absorb
+resist
) ? 0 : (pdamage
-absorb
-resist
);
5664 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
5665 pCaster
->ProcDamageAndSpell(target
, procAttacker
, procVictim
, PROC_EX_NORMAL_HIT
, pdamage
, BASE_ATTACK
, spellProto
);
5667 pCaster
->DealDamage(target
, pdamage
, &cleanDamage
, DOT
, GetSpellSchoolMask(spellProto
), spellProto
, true);
5670 case SPELL_AURA_PERIODIC_LEECH
:
5671 case SPELL_AURA_PERIODIC_HEALTH_FUNNEL
:
5673 Unit
*pCaster
= GetCaster();
5677 if(!pCaster
->isAlive())
5680 if( GetSpellProto()->Effect
[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
5681 pCaster
->SpellHitResult(m_target
,GetSpellProto(),false)!=SPELL_MISS_NONE
)
5685 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5690 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
5692 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5694 //Calculate armor mitigation if it is a physical spell
5695 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL
)
5697 uint32 pdamageReductedArmor
= pCaster
->CalcArmorReducedDamage(m_target
, pdamage
);
5698 cleanDamage
.damage
+= pdamage
- pdamageReductedArmor
;
5699 pdamage
= pdamageReductedArmor
;
5702 pdamage
= pCaster
->SpellDamageBonus(m_target
, GetSpellProto(), pdamage
, DOT
, GetStackAmount());
5704 //As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit
5705 // Reduce dot damage from resilience for players
5706 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
5707 pdamage
-=((Player
*)m_target
)->GetDotDamageReduction(pdamage
);
5709 pCaster
->CalcAbsorbResist(m_target
, GetSpellSchoolMask(GetSpellProto()), DOT
, pdamage
, &absorb
, &resist
);
5711 if(m_target
->GetHealth() < pdamage
)
5712 pdamage
= uint32(m_target
->GetHealth());
5714 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
5715 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId(),absorb
);
5717 pCaster
->SendSpellNonMeleeDamageLog(m_target
, GetId(), pdamage
, GetSpellSchoolMask(GetSpellProto()), absorb
, resist
, false, 0);
5720 Unit
* target
= m_target
; // aura can be deleted in DealDamage
5721 SpellEntry
const* spellProto
= GetSpellProto();
5722 float multiplier
= spellProto
->EffectMultipleValue
[GetEffIndex()] > 0 ? spellProto
->EffectMultipleValue
[GetEffIndex()] : 1;
5723 int32 stackAmount
= GetStackAmount();
5726 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
;// | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
5727 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
5728 pdamage
= (pdamage
<= absorb
+resist
) ? 0 : (pdamage
-absorb
-resist
);
5730 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
5731 pCaster
->ProcDamageAndSpell(target
, procAttacker
, procVictim
, PROC_EX_NORMAL_HIT
, pdamage
, BASE_ATTACK
, spellProto
);
5732 int32 new_damage
= pCaster
->DealDamage(target
, pdamage
, &cleanDamage
, DOT
, GetSpellSchoolMask(spellProto
), spellProto
, false);
5734 if (!target
->isAlive() && pCaster
->IsNonMeleeSpellCasted(false))
5736 for (uint32 i
= CURRENT_FIRST_NON_MELEE_SPELL
; i
< CURRENT_MAX_SPELL
; i
++)
5738 if (pCaster
->m_currentSpells
[i
] && pCaster
->m_currentSpells
[i
]->m_spellInfo
->Id
== spellProto
->Id
)
5739 pCaster
->m_currentSpells
[i
]->cancel();
5744 if(Player
*modOwner
= pCaster
->GetSpellModOwner())
5745 modOwner
->ApplySpellMod(spellProto
->Id
, SPELLMOD_MULTIPLE_VALUE
, multiplier
);
5747 uint32 heal
= pCaster
->SpellHealingBonus(pCaster
, spellProto
, uint32(new_damage
* multiplier
), DOT
, stackAmount
);
5749 int32 gain
= pCaster
->ModifyHealth(heal
);
5750 pCaster
->getHostilRefManager().threatAssist(pCaster
, gain
* 0.5f
, spellProto
);
5752 pCaster
->SendHealSpellLog(pCaster
, spellProto
->Id
, heal
);
5755 case SPELL_AURA_PERIODIC_HEAL
:
5756 case SPELL_AURA_OBS_MOD_HEALTH
:
5758 Unit
*pCaster
= GetCaster();
5762 // heal for caster damage (must be alive)
5763 if(m_target
!= pCaster
&& GetSpellProto()->SpellVisual
[0]==163 && !pCaster
->isAlive())
5766 // ignore non positive values (can be result apply spellmods to aura damage
5767 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5771 if(m_modifier
.m_auraname
==SPELL_AURA_OBS_MOD_HEALTH
)
5772 pdamage
= uint32(m_target
->GetMaxHealth() * amount
/100);
5776 pdamage
= pCaster
->SpellHealingBonus(m_target
, GetSpellProto(), pdamage
, DOT
, GetStackAmount());
5778 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) heal of %u (TypeId: %u) for %u health inflicted by %u",
5779 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
5781 WorldPacket
data(SMSG_PERIODICAURALOG
, (21+16));// we guess size
5782 data
.append(m_target
->GetPackGUID());
5783 data
.appendPackGUID(GetCasterGUID());
5784 data
<< uint32(GetId());
5786 data
<< uint32(m_modifier
.m_auraname
);
5787 data
<< (uint32
)pdamage
;
5788 data
<< uint32(0); // wotlk
5789 m_target
->SendMessageToSet(&data
,true);
5791 int32 gain
= m_target
->ModifyHealth(pdamage
);
5793 // add HoTs to amount healed in bgs
5794 if( pCaster
->GetTypeId() == TYPEID_PLAYER
)
5795 if( BattleGround
*bg
= ((Player
*)pCaster
)->GetBattleGround() )
5796 bg
->UpdatePlayerScore(((Player
*)pCaster
), SCORE_HEALING_DONE
, gain
);
5798 //Do check before because m_modifier.auraName can be invalidate by DealDamage.
5799 bool procSpell
= (m_modifier
.m_auraname
== SPELL_AURA_PERIODIC_HEAL
&& m_target
!= pCaster
);
5801 m_target
->getHostilRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, GetSpellProto());
5803 Unit
* target
= m_target
; // aura can be deleted in DealDamage
5804 SpellEntry
const* spellProto
= GetSpellProto();
5805 bool haveCastItem
= GetCastItemGUID()!=0;
5807 // heal for caster damage
5808 if(m_target
!=pCaster
&& spellProto
->SpellVisual
[0]==163)
5810 uint32 dmg
= spellProto
->manaPerSecond
;
5811 if(pCaster
->GetHealth() <= dmg
&& pCaster
->GetTypeId()==TYPEID_PLAYER
)
5813 pCaster
->RemoveAurasDueToSpell(GetId());
5815 // finish current generic/channeling spells, don't affect autorepeat
5816 if(pCaster
->m_currentSpells
[CURRENT_GENERIC_SPELL
])
5818 pCaster
->m_currentSpells
[CURRENT_GENERIC_SPELL
]->finish();
5820 if(pCaster
->m_currentSpells
[CURRENT_CHANNELED_SPELL
])
5822 pCaster
->m_currentSpells
[CURRENT_CHANNELED_SPELL
]->SendChannelUpdate(0);
5823 pCaster
->m_currentSpells
[CURRENT_CHANNELED_SPELL
]->finish();
5828 pCaster
->SendSpellNonMeleeDamageLog(pCaster
, GetId(), gain
, GetSpellSchoolMask(GetSpellProto()), 0, 0, false, 0, false);
5830 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
5831 pCaster
->DealDamage(pCaster
, gain
, &cleanDamage
, NODAMAGE
, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
5835 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
;// | PROC_FLAG_SUCCESSFUL_HEAL;
5836 uint32 procVictim
= 0;//ROC_FLAG_ON_TAKE_PERIODIC | PROC_FLAG_TAKEN_HEAL;
5837 // ignore item heals
5838 // if(procSpell && !haveCastItem)
5839 // pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto);
5842 case SPELL_AURA_PERIODIC_MANA_LEECH
:
5844 Unit
*pCaster
= GetCaster();
5848 if(!pCaster
->isAlive())
5851 if( GetSpellProto()->Effect
[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
5852 pCaster
->SpellHitResult(m_target
,GetSpellProto(),false)!=SPELL_MISS_NONE
)
5855 // Check for immune (not use charges)
5856 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5859 // ignore non positive values (can be result apply spellmods to aura damage
5860 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5862 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u",
5863 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
5865 if(m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
>= MAX_POWERS
)
5868 Powers power
= Powers(m_modifier
.m_miscvalue
);
5870 // power type might have changed between aura applying and tick (druid's shapeshift)
5871 if(m_target
->getPowerType() != power
)
5874 int32 drain_amount
= m_target
->GetPower(power
) > pdamage
? pdamage
: m_target
->GetPower(power
);
5876 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
5877 if (power
== POWER_MANA
&& m_target
->GetTypeId() == TYPEID_PLAYER
)
5878 drain_amount
-= ((Player
*)m_target
)->GetSpellCritDamageReduction(drain_amount
);
5880 m_target
->ModifyPower(power
, -drain_amount
);
5882 float gain_multiplier
= 0;
5884 if(pCaster
->GetMaxPower(power
) > 0)
5886 gain_multiplier
= GetSpellProto()->EffectMultipleValue
[GetEffIndex()];
5888 if(Player
*modOwner
= pCaster
->GetSpellModOwner())
5889 modOwner
->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE
, gain_multiplier
);
5892 WorldPacket
data(SMSG_PERIODICAURALOG
, (21+16));// we guess size
5893 data
.append(m_target
->GetPackGUID());
5894 data
.appendPackGUID(GetCasterGUID());
5895 data
<< uint32(GetId());
5897 data
<< uint32(m_modifier
.m_auraname
);
5898 data
<< (uint32
)power
; // power type
5899 data
<< (uint32
)drain_amount
;
5900 data
<< (float)gain_multiplier
;
5901 m_target
->SendMessageToSet(&data
,true);
5903 int32 gain_amount
= int32(drain_amount
*gain_multiplier
);
5907 int32 gain
= pCaster
->ModifyPower(power
,gain_amount
);
5908 m_target
->AddThreat(pCaster
, float(gain
) * 0.5f
, GetSpellSchoolMask(GetSpellProto()), GetSpellProto());
5912 case SPELL_AURA_PERIODIC_ENERGIZE
:
5914 // ignore non positive values (can be result apply spellmods to aura damage
5915 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5917 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u",
5918 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
5920 if(m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
>= MAX_POWERS
)
5923 Powers power
= Powers(m_modifier
.m_miscvalue
);
5925 if(m_target
->GetMaxPower(power
) == 0)
5928 WorldPacket
data(SMSG_PERIODICAURALOG
, (21+16));// we guess size
5929 data
.append(m_target
->GetPackGUID());
5930 data
.appendPackGUID(GetCasterGUID());
5931 data
<< uint32(GetId());
5933 data
<< uint32(m_modifier
.m_auraname
);
5934 data
<< (uint32
)power
; // power type
5935 data
<< (uint32
)pdamage
;
5936 m_target
->SendMessageToSet(&data
,true);
5938 int32 gain
= m_target
->ModifyPower(power
,pdamage
);
5940 if(Unit
* pCaster
= GetCaster())
5941 m_target
->getHostilRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, GetSpellProto());
5944 case SPELL_AURA_OBS_MOD_MANA
:
5946 // ignore non positive values (can be result apply spellmods to aura damage
5947 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5949 uint32 pdamage
= uint32(m_target
->GetMaxPower(POWER_MANA
) * amount
/100);
5951 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u mana inflicted by %u",
5952 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
5954 if(m_target
->GetMaxPower(POWER_MANA
) == 0)
5957 WorldPacket
data(SMSG_PERIODICAURALOG
, (21+16));// we guess size
5958 data
.append(m_target
->GetPackGUID());
5959 data
.appendPackGUID(GetCasterGUID());
5960 data
<< uint32(GetId());
5962 data
<< uint32(m_modifier
.m_auraname
);
5963 data
<< (uint32
)0; // ?
5964 data
<< (uint32
)pdamage
;
5965 m_target
->SendMessageToSet(&data
,true);
5967 int32 gain
= m_target
->ModifyPower(POWER_MANA
, pdamage
);
5969 if(Unit
* pCaster
= GetCaster())
5970 m_target
->getHostilRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, GetSpellProto());
5973 case SPELL_AURA_POWER_BURN_MANA
:
5975 Unit
*pCaster
= GetCaster();
5979 // Check for immune (not use charges)
5980 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5983 int32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5985 Powers powerType
= Powers(m_modifier
.m_miscvalue
);
5987 if(!m_target
->isAlive() || m_target
->getPowerType() != powerType
)
5990 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
5991 if (powerType
== POWER_MANA
&& m_target
->GetTypeId() == TYPEID_PLAYER
)
5992 pdamage
-= ((Player
*)m_target
)->GetSpellCritDamageReduction(pdamage
);
5994 uint32 gain
= uint32(-m_target
->ModifyPower(powerType
, -pdamage
));
5996 gain
= uint32(gain
* GetSpellProto()->EffectMultipleValue
[GetEffIndex()]);
5998 SpellEntry
const* spellProto
= GetSpellProto();
5999 //maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG
6000 SpellNonMeleeDamage
damageInfo(pCaster
, m_target
, spellProto
->Id
, spellProto
->SchoolMask
);
6001 pCaster
->CalculateSpellDamage(&damageInfo
, gain
, spellProto
);
6002 pCaster
->SendSpellNonMeleeDamageLog(&damageInfo
);
6005 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
;// | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
6006 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
6007 uint32 procEx
= createProcExtendMask(&damageInfo
, SPELL_MISS_NONE
);
6008 if (damageInfo
.damage
)
6009 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
6011 pCaster
->ProcDamageAndSpell(damageInfo
.target
, procAttacker
, procVictim
, procEx
, damageInfo
.damage
, BASE_ATTACK
, spellProto
);
6013 pCaster
->DealSpellDamage(&damageInfo
, true);
6016 case SPELL_AURA_MOD_REGEN
:
6018 int32 gain
= m_target
->ModifyHealth(m_modifier
.m_amount
);
6019 if (Unit
*caster
= GetCaster())
6020 m_target
->getHostilRefManager().threatAssist(caster
, float(gain
) * 0.5f
, GetSpellProto());
6023 case SPELL_AURA_MOD_POWER_REGEN
:
6025 Powers pt
= m_target
->getPowerType();
6026 if(int32(pt
) != m_modifier
.m_miscvalue
)
6029 if ( GetSpellProto()->AuraInterruptFlags
& AURA_INTERRUPT_FLAG_NOT_SEATED
)
6032 m_target
->HandleEmoteCommand(EMOTE_ONESHOT_EAT
);
6034 else if( GetId() == 20577 )
6037 m_target
->HandleEmoteCommand(EMOTE_STATE_CANNIBALIZE
);
6041 // amount = 1+ 16 = 17 = 3,4*5 = 10,2*5/3
6042 // so 17 is rounded amount for 5 sec tick grow ~ 1 range grow in 3 sec
6043 if(pt
== POWER_RAGE
)
6044 m_target
->ModifyPower(pt
, m_modifier
.m_amount
*3/5);
6047 // Here tick dummy auras
6048 case SPELL_AURA_PERIODIC_DUMMY
:
6050 PeriodicDummyTick();
6053 case SPELL_AURA_PERIODIC_TRIGGER_SPELL
:
6058 case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
:
6060 TriggerSpellWithValue();
6068 void Aura::PeriodicDummyTick()
6070 Unit
*caster
= GetCaster();
6071 SpellEntry
const* spell
= GetSpellProto();
6072 switch (spell
->SpellFamilyName
)
6074 case SPELLFAMILY_GENERIC
:
6090 case 49472: // Drink Coffee
6093 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
6095 // Search SPELL_AURA_MOD_POWER_REGEN aura for this spell and add bonus
6096 Unit::AuraList
const& aura
= m_target
->GetAurasByType(SPELL_AURA_MOD_POWER_REGEN
);
6097 for(Unit::AuraList::const_iterator i
= aura
.begin(); i
!= aura
.end(); ++i
)
6099 if ((*i
)->GetId() == GetId())
6101 (*i
)->GetModifier()->m_amount
= m_modifier
.m_amount
;
6102 ((Player
*)m_target
)->UpdateManaRegen();
6104 m_isPeriodic
= false;
6113 // Possibly need cast one of them (but
6114 // 7038 Forsaken Skill: Swords
6115 // 7039 Forsaken Skill: Axes
6116 // 7040 Forsaken Skill: Daggers
6117 // 7041 Forsaken Skill: Maces
6118 // 7042 Forsaken Skill: Staves
6119 // 7043 Forsaken Skill: Bows
6120 // 7044 Forsaken Skill: Guns
6121 // 7045 Forsaken Skill: 2H Axes
6122 // 7046 Forsaken Skill: 2H Maces
6123 // 7047 Forsaken Skill: 2H Swords
6124 // 7048 Forsaken Skill: Defense
6125 // 7049 Forsaken Skill: Fire
6126 // 7050 Forsaken Skill: Frost
6127 // 7051 Forsaken Skill: Holy
6128 // 7053 Forsaken Skill: Shadow
6132 // case 19230: break;
6133 // // Gossip NPC Periodic - Talk
6134 // case 33208: break;
6135 // // Gossip NPC Periodic - Despawn
6136 // case 33209: break;
6138 // case 36207: break;
6139 // // Simon Game START timer, (DND)
6140 // case 39993: break;
6141 // // Knockdown Fel Cannon: break; The Aggro Burst
6142 // case 40119: break;
6143 // // Old Mount Spell
6144 // case 40154: break;
6146 // case 40581: break;
6147 // // Ethereal Ring: break; The Bolt Burst
6148 // case 40801: break;
6149 // // Crystal Prison
6150 // case 40846: break;
6152 // case 41054: break;
6154 // case 41404: break;
6155 // // Ethereal Ring Visual, Lightning Aura
6156 // case 41477: break;
6157 // // Ethereal Ring Visual, Lightning Aura (Fork)
6158 // case 41525: break;
6159 // // Ethereal Ring Visual, Lightning Jumper Aura
6160 // case 41567: break;
6162 // case 41955: break;
6163 // // Headless Horseman - Fire
6164 // case 42074: break;
6165 // // Headless Horseman - Visual - Large Fire
6166 // case 42075: break;
6167 // // Headless Horseman - Start Fire, Periodic Aura
6168 // case 42140: break;
6169 // // Ram Speed Boost
6170 // case 42152: break;
6171 // // Headless Horseman - Fires Out Victory Aura
6172 // case 42235: break;
6173 // // Pumpkin Life Cycle
6174 // case 42280: break;
6175 // // Brewfest Request Chick Chuck Mug Aura
6176 // case 42537: break;
6178 // case 42596: break;
6179 // // Headless Horseman Climax, Head: Periodic
6180 // case 42603: break;
6182 // case 42621: break;
6183 // // Headless Horseman - Conflagrate, Periodic Aura
6184 // case 42637: break;
6185 // // Headless Horseman - Create Pumpkin Treats Aura
6186 // case 42774: break;
6187 // // Headless Horseman Climax - Summoning Rhyme Aura
6188 // case 42879: break;
6190 // case 42919: break;
6192 // case 42924: break;
6194 // case 42992: break;
6196 // case 42993: break;
6198 // case 42994: break;
6199 // // Ram Level - Neutral
6200 // case 43310: break;
6201 // // Headless Horseman - Maniacal Laugh, Maniacal, Delayed 17
6202 // case 43884: break;
6204 // case 43963: break;
6205 // // Headless Horseman - Maniacal Laugh, Maniacal, other, Delayed 17
6206 // case 44000: break;
6207 // // Energy Feedback
6208 // case 44328: break;
6209 // // Romantic Picnic
6210 // case 45102: break;
6211 // // Romantic Picnic
6212 // case 45123: break;
6213 // // Looking for Love
6214 // case 45124: break;
6215 // // Kite - Lightning Strike Kite Aura
6216 // case 45197: break;
6217 // // Rocket Chicken
6218 // case 45202: break;
6219 // // Copy Offhand Weapon
6220 // case 45205: break;
6221 // // Upper Deck - Kite - Lightning Periodic Aura
6222 // case 45207: break;
6223 // // Kite -Sky Lightning Strike Kite Aura
6224 // case 45251: break;
6225 // // Ribbon Pole Dancer Check Aura
6226 // case 45390: break;
6227 // // Holiday - Midsummer, Ribbon Pole Periodic Visual
6228 // case 45406: break;
6230 // case 45472: break;
6231 // // Alliance Flag, Extra Damage Debuff
6232 // case 45898: break;
6233 // // Horde Flag, Extra Damage Debuff
6234 // case 45899: break;
6235 // // Ahune - Summoning Rhyme Aura
6236 // case 45926: break;
6237 // // Ahune - Slippery Floor
6238 // case 45945: break;
6239 // // Ahune's Shield
6240 // case 45954: break;
6241 // // Nether Vapor Lightning
6242 // case 45960: break;
6244 // case 45996: break;
6245 // // Summon Blood Elves Periodic
6246 // case 46041: break;
6247 // // Transform Visual Missile Periodic
6248 // case 46205: break;
6249 // // Find Opening Beam End
6250 // case 46333: break;
6251 // // Ice Spear Control Aura
6252 // case 46371: break;
6253 // // Hailstone Chill
6254 // case 46458: break;
6255 // // Hailstone Chill, Internal
6256 // case 46465: break;
6257 // // Chill, Internal Shifter
6258 // case 46549: break;
6259 // // Summon Ice Spear Knockback Delayer
6260 // case 46878: break;
6261 // // Burninate Effect
6262 // case 47214: break;
6263 // // Fizzcrank Practice Parachute
6264 // case 47228: break;
6265 // // Send Mug Control Aura
6266 // case 47369: break;
6267 // // Direbrew's Disarm (precast)
6268 // case 47407: break;
6269 // // Mole Machine Port Schedule
6270 // case 47489: break;
6271 // case 47941: break; // Crystal Spike
6272 // case 48200: break; // Healer Aura
6273 // case 48630: break; // Summon Gauntlet Mobs Periodic
6274 // case 49313: break; // Proximity Mine Area Aura
6275 // // Mole Machine Portal Schedule
6276 // case 49466: break;
6277 // case 49555: break; // Corpse Explode
6278 // case 49592: break; // Temporal Rift
6279 // case 49957: break; // Cutting Laser
6280 // case 50085: break; // Slow Fall
6281 // // Listening to Music
6282 // case 50493: break;
6283 // // Love Rocket Barrage
6284 // case 50530: break;
6285 // Exist more after, need add later
6290 case SPELLFAMILY_MAGE
:
6293 // if (spell->Id == 55342)
6297 case SPELLFAMILY_WARRIOR
:
6299 // Armored to the Teeth
6300 if (spell
->SpellIconID
== 3516)
6302 // Increases your attack power by $s1 for every $s2 armor value you have.
6303 // Calculate AP bonus (from 1 efect of this spell)
6304 int32 apBonus
= m_modifier
.m_amount
* m_target
->GetArmor() / m_target
->CalculateSpellDamage(spell
, 1, spell
->EffectBasePoints
[1], m_target
);
6305 m_target
->CastCustomSpell(m_target
, 61217, &apBonus
, &apBonus
, 0, true, 0, this);
6310 case SPELLFAMILY_DRUID
:
6314 // Frenzied Regeneration
6317 // Converts up to 10 rage per second into health for $d. Each point of rage is converted into ${$m2/10}.1% of max health.
6318 // Should be manauser
6319 if (m_target
->getPowerType()!=POWER_RAGE
)
6321 uint32 rage
= m_target
->GetPower(POWER_RAGE
);
6325 int32 mod
= (rage
< 100) ? rage
: 100;
6326 int32 points
= m_target
->CalculateSpellDamage(spell
, 1, spell
->EffectBasePoints
[1], m_target
);
6327 int32 regen
= m_target
->GetMaxHealth() * (mod
* points
/ 10) / 1000;
6328 m_target
->CastCustomSpell(m_target
, 22845, ®en
, 0, 0, true, 0, this);
6329 m_target
->SetPower(POWER_RAGE
, rage
-mod
);
6340 case SPELLFAMILY_ROGUE
:
6342 // switch (spell->Id)
6344 // Master of Subtlety
6345 // case 31666: break;
6347 // case 51690: break;
6349 // case 58428: break;
6355 case SPELLFAMILY_HUNTER
:
6358 if (spell
->SpellFamilyFlags
& 0x8000000000000000LL
)
6362 int32 damage
= m_modifier
.m_amount
;
6363 // Full damage to target at 0 tick
6364 if (m_duration
> m_modifier
.periodictime
)
6366 caster
->CastCustomSpell(m_target
, 53352, &damage
, 0, 0, true, 0, this);
6370 caster
->CastCustomSpell(m_target
, 56298, &damage
, 0, 0, true, 0, this);
6378 // Feeding Frenzy Rank 1
6380 if ( m_target
->GetHealth() * 100 < m_target
->GetMaxHealth() * 35 )
6381 m_target
->CastSpell(m_target
, 60096, true, 0, this);
6383 // Feeding Frenzy Rank 2
6385 if ( m_target
->GetHealth() * 100 < m_target
->GetMaxHealth() * 35 )
6386 m_target
->CastSpell(m_target
, 60097, true, 0, this);
6393 case SPELLFAMILY_SHAMAN
:
6396 if (spell
->Id
== 52179)
6398 // Periodic need for remove visual on stun/fear/silence lost
6399 if (!(m_target
->GetUInt32Value(UNIT_FIELD_FLAGS
)&(UNIT_FLAG_STUNNED
|UNIT_FLAG_FLEEING
|UNIT_FLAG_SILENCED
)))
6400 m_target
->RemoveAurasDueToSpell(52179);
6405 case SPELLFAMILY_DEATHKNIGHT
:
6408 if (spell
->SpellFamilyFlags
& 0x0000000000000020LL
)
6411 caster
->CastCustomSpell(m_target
, 52212, &m_modifier
.m_amount
, NULL
, NULL
, true, 0, this);
6415 // if (spell->SpellFamilyFlags & 0x0000000000001000LL)
6418 if (spell
->SpellFamilyFlags
& 0x0000400000000000LL
)
6420 // Get 0 effect aura
6421 Aura
*slow
= m_target
->GetAura(GetId(), 0);
6424 slow
->ApplyModifier(false, true);
6425 Modifier
*mod
= slow
->GetModifier();
6426 mod
->m_amount
+= m_modifier
.m_amount
;
6427 if (mod
->m_amount
> 0) mod
->m_amount
= 0;
6428 slow
->ApplyModifier(true, true);
6433 // if (spell->SpellFamilyFlags & 0x0000008000000000LL)
6435 // Death Rune Mastery
6436 // if (spell->SpellFamilyFlags & 0x0000000000004000LL)
6439 if (spell
->SpellIconID
== 2653)
6441 // Increases your attack power by $s1 for every $s2 armor value you have.
6442 // Calculate AP bonus (from 1 efect of this spell)
6443 int32 apBonus
= m_modifier
.m_amount
* m_target
->GetArmor() / m_target
->CalculateSpellDamage(spell
, 1, spell
->EffectBasePoints
[1], m_target
);
6444 m_target
->CastCustomSpell(m_target
, 61217, &apBonus
, &apBonus
, 0, true, 0, this);
6448 // if (spell->SpellIconID == 22)
6450 // Blood of the North
6451 // if (spell->SpellIconID == 30412)
6460 void Aura::HandlePreventFleeing(bool apply
, bool Real
)
6465 Unit::AuraList
const& fearAuras
= m_target
->GetAurasByType(SPELL_AURA_MOD_FEAR
);
6466 if( !fearAuras
.empty() )
6469 m_target
->SetFeared(false, fearAuras
.front()->GetCasterGUID());
6471 m_target
->SetFeared(true);
6475 void Aura::HandleManaShield(bool apply
, bool Real
)
6480 // prevent double apply bonuses
6481 if(apply
&& (m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading()))
6483 if(Unit
* caster
= GetCaster())
6485 float DoneActualBenefit
= 0.0f
;
6486 switch(m_spellProto
->SpellFamilyName
)
6488 case SPELLFAMILY_MAGE
:
6489 if(m_spellProto
->SpellFamilyFlags
& 0x8000)
6492 // +50% from +spd bonus
6493 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.5f
;
6501 DoneActualBenefit
*= caster
->CalculateLevelPenalty(GetSpellProto());
6503 m_modifier
.m_amount
+= (int32
)DoneActualBenefit
;
6508 void Aura::HandleArenaPreparation(bool apply
, bool Real
)
6514 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PREPARATION
);
6516 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PREPARATION
);
6519 void Aura::HandleAuraControlVehicle(bool apply
, bool Real
)
6524 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
6527 if(Pet
*pet
= m_target
->GetPet())
6528 pet
->Remove(PET_SAVE_AS_CURRENT
);
6530 WorldPacket
data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA
, 0);
6531 ((Player
*)m_target
)->GetSession()->SendPacket(&data
);
6534 void Aura::HandleAuraConvertRune(bool apply
, bool Real
)
6539 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
6542 Player
*plr
= (Player
*)m_target
;
6544 if(plr
->getClass() != CLASS_DEATH_KNIGHT
)
6547 // how to determine what rune need to be converted?
6548 for(uint32 i
= 0; i
< MAX_RUNES
; ++i
)
6552 if(!plr
->GetRuneCooldown(i
))
6554 plr
->ConvertRune(i
, GetSpellProto()->EffectMiscValueB
[m_effIndex
]);
6560 if(plr
->GetCurrentRune(i
) == GetSpellProto()->EffectMiscValueB
[m_effIndex
])
6562 plr
->ConvertRune(i
, plr
->GetBaseRune(i
));
6569 void Aura::HandlePhase(bool apply
, bool Real
)
6574 // always non stackable
6577 Unit::AuraList
const& phases
= m_target
->GetAurasByType(SPELL_AURA_PHASE
);
6579 m_target
->RemoveAurasDueToSpell(phases
.front()->GetId(),this);
6582 // no-phase is also phase state so same code for apply and remove
6584 // phase auras normally not expected at BG but anyway better check
6585 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
6587 // drop flag at invisible in bg
6588 if(((Player
*)m_target
)->InBattleGround())
6589 if(BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround())
6590 bg
->EventPlayerDroppedFlag((Player
*)m_target
);
6592 // GM-mode have mask 0xFFFFFFFF
6593 if(!((Player
*)m_target
)->isGameMaster())
6594 m_target
->SetPhaseMask(apply
? GetMiscValue() : PHASEMASK_NORMAL
,false);
6596 ((Player
*)m_target
)->GetSession()->SendSetPhaseShift(apply
? GetMiscValue() : PHASEMASK_NORMAL
);
6599 m_target
->SetPhaseMask(apply
? GetMiscValue() : PHASEMASK_NORMAL
,false);
6601 // need triggering visibility update base at phase update of not GM invisible (other GMs anyway see in any phases)
6602 if(m_target
->GetVisibility()!=VISIBILITY_OFF
)
6603 m_target
->SetVisibility(m_target
->GetVisibility());