2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "Database/DatabaseEnv.h"
21 #include "WorldPacket.h"
22 #include "WorldSession.h"
25 #include "UpdateMask.h"
27 #include "ObjectMgr.h"
32 #include "DynamicObject.h"
34 #include "UpdateData.h"
35 #include "ObjectAccessor.h"
36 #include "Policies/SingletonImp.h"
40 #include "BattleGround.h"
41 #include "CreatureAI.h"
42 #include "ScriptCalls.h"
44 #include "GridNotifiers.h"
45 #include "GridNotifiersImpl.h"
48 #define NULL_AURA_SLOT 0xFF
50 pAuraHandler AuraHandler
[TOTAL_AURAS
]=
52 &Aura::HandleNULL
, // 0 SPELL_AURA_NONE
53 &Aura::HandleBindSight
, // 1 SPELL_AURA_BIND_SIGHT
54 &Aura::HandleModPossess
, // 2 SPELL_AURA_MOD_POSSESS
55 &Aura::HandlePeriodicDamage
, // 3 SPELL_AURA_PERIODIC_DAMAGE
56 &Aura::HandleAuraDummy
, // 4 SPELL_AURA_DUMMY
57 &Aura::HandleModConfuse
, // 5 SPELL_AURA_MOD_CONFUSE
58 &Aura::HandleModCharm
, // 6 SPELL_AURA_MOD_CHARM
59 &Aura::HandleModFear
, // 7 SPELL_AURA_MOD_FEAR
60 &Aura::HandlePeriodicHeal
, // 8 SPELL_AURA_PERIODIC_HEAL
61 &Aura::HandleModAttackSpeed
, // 9 SPELL_AURA_MOD_ATTACKSPEED
62 &Aura::HandleModThreat
, // 10 SPELL_AURA_MOD_THREAT
63 &Aura::HandleModTaunt
, // 11 SPELL_AURA_MOD_TAUNT
64 &Aura::HandleAuraModStun
, // 12 SPELL_AURA_MOD_STUN
65 &Aura::HandleModDamageDone
, // 13 SPELL_AURA_MOD_DAMAGE_DONE
66 &Aura::HandleNoImmediateEffect
, // 14 SPELL_AURA_MOD_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus
67 &Aura::HandleNoImmediateEffect
, // 15 SPELL_AURA_DAMAGE_SHIELD implemented in Unit::DoAttackDamage
68 &Aura::HandleModStealth
, // 16 SPELL_AURA_MOD_STEALTH
69 &Aura::HandleNoImmediateEffect
, // 17 SPELL_AURA_MOD_STEALTH_DETECT
70 &Aura::HandleInvisibility
, // 18 SPELL_AURA_MOD_INVISIBILITY
71 &Aura::HandleInvisibilityDetect
, // 19 SPELL_AURA_MOD_INVISIBILITY_DETECTION
72 &Aura::HandleAuraModTotalHealthPercentRegen
, // 20 SPELL_AURA_OBS_MOD_HEALTH
73 &Aura::HandleAuraModTotalManaPercentRegen
, // 21 SPELL_AURA_OBS_MOD_MANA
74 &Aura::HandleAuraModResistance
, // 22 SPELL_AURA_MOD_RESISTANCE
75 &Aura::HandlePeriodicTriggerSpell
, // 23 SPELL_AURA_PERIODIC_TRIGGER_SPELL
76 &Aura::HandlePeriodicEnergize
, // 24 SPELL_AURA_PERIODIC_ENERGIZE
77 &Aura::HandleAuraModPacify
, // 25 SPELL_AURA_MOD_PACIFY
78 &Aura::HandleAuraModRoot
, // 26 SPELL_AURA_MOD_ROOT
79 &Aura::HandleAuraModSilence
, // 27 SPELL_AURA_MOD_SILENCE
80 &Aura::HandleNoImmediateEffect
, // 28 SPELL_AURA_REFLECT_SPELLS implement in Unit::SpellHitResult
81 &Aura::HandleAuraModStat
, // 29 SPELL_AURA_MOD_STAT
82 &Aura::HandleAuraModSkill
, // 30 SPELL_AURA_MOD_SKILL
83 &Aura::HandleAuraModIncreaseSpeed
, // 31 SPELL_AURA_MOD_INCREASE_SPEED
84 &Aura::HandleAuraModIncreaseMountedSpeed
, // 32 SPELL_AURA_MOD_INCREASE_MOUNTED_SPEED
85 &Aura::HandleAuraModDecreaseSpeed
, // 33 SPELL_AURA_MOD_DECREASE_SPEED
86 &Aura::HandleAuraModIncreaseHealth
, // 34 SPELL_AURA_MOD_INCREASE_HEALTH
87 &Aura::HandleAuraModIncreaseEnergy
, // 35 SPELL_AURA_MOD_INCREASE_ENERGY
88 &Aura::HandleAuraModShapeshift
, // 36 SPELL_AURA_MOD_SHAPESHIFT
89 &Aura::HandleAuraModEffectImmunity
, // 37 SPELL_AURA_EFFECT_IMMUNITY
90 &Aura::HandleAuraModStateImmunity
, // 38 SPELL_AURA_STATE_IMMUNITY
91 &Aura::HandleAuraModSchoolImmunity
, // 39 SPELL_AURA_SCHOOL_IMMUNITY
92 &Aura::HandleAuraModDmgImmunity
, // 40 SPELL_AURA_DAMAGE_IMMUNITY
93 &Aura::HandleAuraModDispelImmunity
, // 41 SPELL_AURA_DISPEL_IMMUNITY
94 &Aura::HandleAuraProcTriggerSpell
, // 42 SPELL_AURA_PROC_TRIGGER_SPELL implemented in Unit::ProcDamageAndSpellFor and Unit::HandleProcTriggerSpell
95 &Aura::HandleNoImmediateEffect
, // 43 SPELL_AURA_PROC_TRIGGER_DAMAGE implemented in Unit::ProcDamageAndSpellFor
96 &Aura::HandleAuraTrackCreatures
, // 44 SPELL_AURA_TRACK_CREATURES
97 &Aura::HandleAuraTrackResources
, // 45 SPELL_AURA_TRACK_RESOURCES
98 &Aura::HandleUnused
, // 46 SPELL_AURA_46 (used in test spells 54054 and 54058, and spell 48050) (3.0.8a)
99 &Aura::HandleAuraModParryPercent
, // 47 SPELL_AURA_MOD_PARRY_PERCENT
100 &Aura::HandleNULL
, // 48 SPELL_AURA_48 spell Napalm (area damage spell with additional delayed damage effect)
101 &Aura::HandleAuraModDodgePercent
, // 49 SPELL_AURA_MOD_DODGE_PERCENT
102 &Aura::HandleNoImmediateEffect
, // 50 SPELL_AURA_MOD_CRITICAL_HEALING_BONUS
103 &Aura::HandleAuraModBlockPercent
, // 51 SPELL_AURA_MOD_BLOCK_PERCENT
104 &Aura::HandleAuraModCritPercent
, // 52 SPELL_AURA_MOD_CRIT_PERCENT
105 &Aura::HandlePeriodicLeech
, // 53 SPELL_AURA_PERIODIC_LEECH
106 &Aura::HandleModHitChance
, // 54 SPELL_AURA_MOD_HIT_CHANCE
107 &Aura::HandleModSpellHitChance
, // 55 SPELL_AURA_MOD_SPELL_HIT_CHANCE
108 &Aura::HandleAuraTransform
, // 56 SPELL_AURA_TRANSFORM
109 &Aura::HandleModSpellCritChance
, // 57 SPELL_AURA_MOD_SPELL_CRIT_CHANCE
110 &Aura::HandleAuraModIncreaseSwimSpeed
, // 58 SPELL_AURA_MOD_INCREASE_SWIM_SPEED
111 &Aura::HandleNoImmediateEffect
, // 59 SPELL_AURA_MOD_DAMAGE_DONE_CREATURE implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus
112 &Aura::HandleAuraModPacifyAndSilence
, // 60 SPELL_AURA_MOD_PACIFY_SILENCE
113 &Aura::HandleAuraModScale
, // 61 SPELL_AURA_MOD_SCALE
114 &Aura::HandlePeriodicHealthFunnel
, // 62 SPELL_AURA_PERIODIC_HEALTH_FUNNEL
115 &Aura::HandleUnused
, // 63 unused (3.0.8a) old SPELL_AURA_PERIODIC_MANA_FUNNEL
116 &Aura::HandlePeriodicManaLeech
, // 64 SPELL_AURA_PERIODIC_MANA_LEECH
117 &Aura::HandleModCastingSpeed
, // 65 SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK
118 &Aura::HandleFeignDeath
, // 66 SPELL_AURA_FEIGN_DEATH
119 &Aura::HandleAuraModDisarm
, // 67 SPELL_AURA_MOD_DISARM
120 &Aura::HandleAuraModStalked
, // 68 SPELL_AURA_MOD_STALKED
121 &Aura::HandleSchoolAbsorb
, // 69 SPELL_AURA_SCHOOL_ABSORB implemented in Unit::CalcAbsorbResist
122 &Aura::HandleUnused
, // 70 SPELL_AURA_EXTRA_ATTACKS Useless, used by only one spell that has only visual effect
123 &Aura::HandleModSpellCritChanceShool
, // 71 SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL
124 &Aura::HandleModPowerCostPCT
, // 72 SPELL_AURA_MOD_POWER_COST_SCHOOL_PCT
125 &Aura::HandleModPowerCost
, // 73 SPELL_AURA_MOD_POWER_COST_SCHOOL
126 &Aura::HandleNoImmediateEffect
, // 74 SPELL_AURA_REFLECT_SPELLS_SCHOOL implemented in Unit::SpellHitResult
127 &Aura::HandleNoImmediateEffect
, // 75 SPELL_AURA_MOD_LANGUAGE
128 &Aura::HandleFarSight
, // 76 SPELL_AURA_FAR_SIGHT
129 &Aura::HandleModMechanicImmunity
, // 77 SPELL_AURA_MECHANIC_IMMUNITY
130 &Aura::HandleAuraMounted
, // 78 SPELL_AURA_MOUNTED
131 &Aura::HandleModDamagePercentDone
, // 79 SPELL_AURA_MOD_DAMAGE_PERCENT_DONE
132 &Aura::HandleModPercentStat
, // 80 SPELL_AURA_MOD_PERCENT_STAT
133 &Aura::HandleNoImmediateEffect
, // 81 SPELL_AURA_SPLIT_DAMAGE_PCT
134 &Aura::HandleWaterBreathing
, // 82 SPELL_AURA_WATER_BREATHING
135 &Aura::HandleModBaseResistance
, // 83 SPELL_AURA_MOD_BASE_RESISTANCE
136 &Aura::HandleModRegen
, // 84 SPELL_AURA_MOD_REGEN
137 &Aura::HandleModPowerRegen
, // 85 SPELL_AURA_MOD_POWER_REGEN
138 &Aura::HandleChannelDeathItem
, // 86 SPELL_AURA_CHANNEL_DEATH_ITEM
139 &Aura::HandleNoImmediateEffect
, // 87 SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus
140 &Aura::HandleNoImmediateEffect
, // 88 SPELL_AURA_MOD_HEALTH_REGEN_PERCENT
141 &Aura::HandlePeriodicDamagePCT
, // 89 SPELL_AURA_PERIODIC_DAMAGE_PERCENT
142 &Aura::HandleUnused
, // 90 unused (3.0.8a) old SPELL_AURA_MOD_RESIST_CHANCE
143 &Aura::HandleNoImmediateEffect
, // 91 SPELL_AURA_MOD_DETECT_RANGE implemented in Creature::GetAttackDistance
144 &Aura::HandlePreventFleeing
, // 92 SPELL_AURA_PREVENTS_FLEEING
145 &Aura::HandleModUnattackable
, // 93 SPELL_AURA_MOD_UNATTACKABLE
146 &Aura::HandleNoImmediateEffect
, // 94 SPELL_AURA_INTERRUPT_REGEN implemented in Player::RegenerateAll
147 &Aura::HandleAuraGhost
, // 95 SPELL_AURA_GHOST
148 &Aura::HandleNoImmediateEffect
, // 96 SPELL_AURA_SPELL_MAGNET implemented in Spell::SelectMagnetTarget
149 &Aura::HandleManaShield
, // 97 SPELL_AURA_MANA_SHIELD implemented in Unit::CalcAbsorbResist
150 &Aura::HandleAuraModSkill
, // 98 SPELL_AURA_MOD_SKILL_TALENT
151 &Aura::HandleAuraModAttackPower
, // 99 SPELL_AURA_MOD_ATTACK_POWER
152 &Aura::HandleUnused
, //100 SPELL_AURA_AURAS_VISIBLE obsolete? all player can see all auras now, but still have spells including GM-spell
153 &Aura::HandleModResistancePercent
, //101 SPELL_AURA_MOD_RESISTANCE_PCT
154 &Aura::HandleNoImmediateEffect
, //102 SPELL_AURA_MOD_MELEE_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonus
155 &Aura::HandleAuraModTotalThreat
, //103 SPELL_AURA_MOD_TOTAL_THREAT
156 &Aura::HandleAuraWaterWalk
, //104 SPELL_AURA_WATER_WALK
157 &Aura::HandleAuraFeatherFall
, //105 SPELL_AURA_FEATHER_FALL
158 &Aura::HandleAuraHover
, //106 SPELL_AURA_HOVER
159 &Aura::HandleAddModifier
, //107 SPELL_AURA_ADD_FLAT_MODIFIER
160 &Aura::HandleAddModifier
, //108 SPELL_AURA_ADD_PCT_MODIFIER
161 &Aura::HandleAddTargetTrigger
, //109 SPELL_AURA_ADD_TARGET_TRIGGER
162 &Aura::HandleModPowerRegenPCT
, //110 SPELL_AURA_MOD_POWER_REGEN_PERCENT
163 &Aura::HandleNULL
, //111 SPELL_AURA_ADD_CASTER_HIT_TRIGGER chance redirect attack to caster
164 &Aura::HandleNoImmediateEffect
, //112 SPELL_AURA_OVERRIDE_CLASS_SCRIPTS
165 &Aura::HandleNoImmediateEffect
, //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus
166 &Aura::HandleNoImmediateEffect
, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus
167 &Aura::HandleNoImmediateEffect
, //115 SPELL_AURA_MOD_HEALING implemented in Unit::SpellBaseHealingBonusForVictim
168 &Aura::HandleNoImmediateEffect
, //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT
169 &Aura::HandleNoImmediateEffect
, //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE implemented in Unit::MagicSpellHitResult
170 &Aura::HandleNoImmediateEffect
, //118 SPELL_AURA_MOD_HEALING_PCT implemented in Unit::SpellHealingBonus
171 &Aura::HandleUnused
, //119 unused (3.0.8a) old SPELL_AURA_SHARE_PET_TRACKING
172 &Aura::HandleAuraUntrackable
, //120 SPELL_AURA_UNTRACKABLE
173 &Aura::HandleAuraEmpathy
, //121 SPELL_AURA_EMPATHY
174 &Aura::HandleModOffhandDamagePercent
, //122 SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT
175 &Aura::HandleModTargetResistance
, //123 SPELL_AURA_MOD_TARGET_RESISTANCE
176 &Aura::HandleAuraModRangedAttackPower
, //124 SPELL_AURA_MOD_RANGED_ATTACK_POWER
177 &Aura::HandleNoImmediateEffect
, //125 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus
178 &Aura::HandleNoImmediateEffect
, //126 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus
179 &Aura::HandleNoImmediateEffect
, //127 SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus
180 &Aura::HandleModPossessPet
, //128 SPELL_AURA_MOD_POSSESS_PET
181 &Aura::HandleAuraModIncreaseSpeed
, //129 SPELL_AURA_MOD_SPEED_ALWAYS
182 &Aura::HandleAuraModIncreaseMountedSpeed
, //130 SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS
183 &Aura::HandleNoImmediateEffect
, //131 SPELL_AURA_MOD_RANGED_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonus
184 &Aura::HandleAuraModIncreaseEnergyPercent
, //132 SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT
185 &Aura::HandleAuraModIncreaseHealthPercent
, //133 SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT
186 &Aura::HandleAuraModRegenInterrupt
, //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT
187 &Aura::HandleModHealingDone
, //135 SPELL_AURA_MOD_HEALING_DONE
188 &Aura::HandleNoImmediateEffect
, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus
189 &Aura::HandleModTotalPercentStat
, //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
190 &Aura::HandleHaste
, //138 SPELL_AURA_MOD_HASTE
191 &Aura::HandleForceReaction
, //139 SPELL_AURA_FORCE_REACTION
192 &Aura::HandleAuraModRangedHaste
, //140 SPELL_AURA_MOD_RANGED_HASTE
193 &Aura::HandleRangedAmmoHaste
, //141 SPELL_AURA_MOD_RANGED_AMMO_HASTE
194 &Aura::HandleAuraModBaseResistancePCT
, //142 SPELL_AURA_MOD_BASE_RESISTANCE_PCT
195 &Aura::HandleAuraModResistanceExclusive
, //143 SPELL_AURA_MOD_RESISTANCE_EXCLUSIVE
196 &Aura::HandleNoImmediateEffect
, //144 SPELL_AURA_SAFE_FALL implemented in WorldSession::HandleMovementOpcodes
197 &Aura::HandleAuraModPetTalentsPoints
, //145 SPELL_AURA_MOD_PET_TALENT_POINTS
198 &Aura::HandleNoImmediateEffect
, //146 SPELL_AURA_ALLOW_TAME_PET_TYPE
199 &Aura::HandleNULL
, //147 SPELL_AURA_ADD_CREATURE_IMMUNITY
200 &Aura::HandleAuraRetainComboPoints
, //148 SPELL_AURA_RETAIN_COMBO_POINTS
201 &Aura::HandleNoImmediateEffect
, //149 SPELL_AURA_REDUCE_PUSHBACK
202 &Aura::HandleShieldBlockValue
, //150 SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT
203 &Aura::HandleAuraTrackStealthed
, //151 SPELL_AURA_TRACK_STEALTHED
204 &Aura::HandleNoImmediateEffect
, //152 SPELL_AURA_MOD_DETECTED_RANGE implemented in Creature::GetAttackDistance
205 &Aura::HandleNoImmediateEffect
, //153 SPELL_AURA_SPLIT_DAMAGE_FLAT
206 &Aura::HandleNoImmediateEffect
, //154 SPELL_AURA_MOD_STEALTH_LEVEL
207 &Aura::HandleNoImmediateEffect
, //155 SPELL_AURA_MOD_WATER_BREATHING
208 &Aura::HandleNoImmediateEffect
, //156 SPELL_AURA_MOD_REPUTATION_GAIN
209 &Aura::HandleNULL
, //157 SPELL_AURA_PET_DAMAGE_MULTI
210 &Aura::HandleShieldBlockValue
, //158 SPELL_AURA_MOD_SHIELD_BLOCKVALUE
211 &Aura::HandleNoImmediateEffect
, //159 SPELL_AURA_NO_PVP_CREDIT only for Honorless Target spell
212 &Aura::HandleNoImmediateEffect
, //160 SPELL_AURA_MOD_AOE_AVOIDANCE implemented in Unit::MagicSpellHitResult
213 &Aura::HandleNoImmediateEffect
, //161 SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT
214 &Aura::HandleAuraPowerBurn
, //162 SPELL_AURA_POWER_BURN_MANA
215 &Aura::HandleNoImmediateEffect
, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE
216 &Aura::HandleUnused
, //164 unused (3.0.8a), only one test spell
217 &Aura::HandleNoImmediateEffect
, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus
218 &Aura::HandleAuraModAttackPowerPercent
, //166 SPELL_AURA_MOD_ATTACK_POWER_PCT
219 &Aura::HandleAuraModRangedAttackPowerPercent
, //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT
220 &Aura::HandleNoImmediateEffect
, //168 SPELL_AURA_MOD_DAMAGE_DONE_VERSUS implemented in Unit::SpellDamageBonus, Unit::MeleeDamageBonus
221 &Aura::HandleNoImmediateEffect
, //169 SPELL_AURA_MOD_CRIT_PERCENT_VERSUS implemented in Unit::DealDamageBySchool, Unit::DoAttackDamage, Unit::SpellCriticalBonus
222 &Aura::HandleNULL
, //170 SPELL_AURA_DETECT_AMORE different spells that ignore transformation effects
223 &Aura::HandleAuraModIncreaseSpeed
, //171 SPELL_AURA_MOD_SPEED_NOT_STACK
224 &Aura::HandleAuraModIncreaseMountedSpeed
, //172 SPELL_AURA_MOD_MOUNTED_SPEED_NOT_STACK
225 &Aura::HandleUnused
, //173 unused (3.0.8a) no spells, old SPELL_AURA_ALLOW_CHAMPION_SPELLS only for Proclaim Champion spell
226 &Aura::HandleModSpellDamagePercentFromStat
, //174 SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT implemented in Unit::SpellBaseDamageBonus
227 &Aura::HandleModSpellHealingPercentFromStat
, //175 SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT implemented in Unit::SpellBaseHealingBonus
228 &Aura::HandleSpiritOfRedemption
, //176 SPELL_AURA_SPIRIT_OF_REDEMPTION only for Spirit of Redemption spell, die at aura end
229 &Aura::HandleNULL
, //177 SPELL_AURA_AOE_CHARM
230 &Aura::HandleNoImmediateEffect
, //178 SPELL_AURA_MOD_DEBUFF_RESISTANCE implemented in Unit::MagicSpellHitResult
231 &Aura::HandleNoImmediateEffect
, //179 SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE implemented in Unit::SpellCriticalBonus
232 &Aura::HandleNoImmediateEffect
, //180 SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS implemented in Unit::SpellDamageBonus
233 &Aura::HandleUnused
, //181 unused (3.0.8a) old SPELL_AURA_MOD_FLAT_SPELL_CRIT_DAMAGE_VERSUS
234 &Aura::HandleAuraModResistenceOfStatPercent
, //182 SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT
235 &Aura::HandleNULL
, //183 SPELL_AURA_MOD_CRITICAL_THREAT only used in 28746
236 &Aura::HandleNoImmediateEffect
, //184 SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
237 &Aura::HandleNoImmediateEffect
, //185 SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
238 &Aura::HandleNoImmediateEffect
, //186 SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE implemented in Unit::MagicSpellHitResult
239 &Aura::HandleNoImmediateEffect
, //187 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance
240 &Aura::HandleNoImmediateEffect
, //188 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance
241 &Aura::HandleModRating
, //189 SPELL_AURA_MOD_RATING
242 &Aura::HandleNULL
, //190 SPELL_AURA_MOD_FACTION_REPUTATION_GAIN
243 &Aura::HandleAuraModUseNormalSpeed
, //191 SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED
244 &Aura::HandleModMeleeRangedSpeedPct
, //192 SPELL_AURA_HASTE_MELEE
245 &Aura::HandleModCombatSpeedPct
, //193 SPELL_AURA_MELEE_SLOW (in fact combat (any type attack) speed pct)
246 &Aura::HandleNULL
, //194 SPELL_AURA_MOD_IGNORE_ABSORB_SCHOOL
247 &Aura::HandleNoImmediateEffect
, //195 SPELL_AURA_MOD_IGNORE_ABSORB_FOR_SPELL implement in Unit::CalculateSpellDamage
248 &Aura::HandleNULL
, //196 SPELL_AURA_MOD_COOLDOWN
249 &Aura::HandleNoImmediateEffect
, //197 SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE implemented in Unit::SpellCriticalBonus Unit::GetUnitCriticalChance
250 &Aura::HandleUnused
, //198 unused (3.0.8a) old SPELL_AURA_MOD_ALL_WEAPON_SKILLS
251 &Aura::HandleNoImmediateEffect
, //199 SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT implemented in Unit::MagicSpellHitResult
252 &Aura::HandleNoImmediateEffect
, //200 SPELL_AURA_MOD_XP_PCT implemented in Player::GiveXP
253 &Aura::HandleAuraAllowFlight
, //201 SPELL_AURA_FLY this aura enable flight mode...
254 &Aura::HandleNoImmediateEffect
, //202 SPELL_AURA_CANNOT_BE_DODGED implemented in Unit::RollPhysicalOutcomeAgainst
255 &Aura::HandleNoImmediateEffect
, //203 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE implemented in Unit::CalculateMeleeDamage and Unit::CalculateSpellDamage
256 &Aura::HandleNoImmediateEffect
, //204 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE implemented in Unit::CalculateMeleeDamage and Unit::CalculateSpellDamage
257 &Aura::HandleNULL
, //205 vulnerable to school dmg?
258 &Aura::HandleNULL
, //206 SPELL_AURA_MOD_SPEED_MOUNTED
259 &Aura::HandleAuraModIncreaseFlightSpeed
, //207 SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
260 &Aura::HandleAuraModIncreaseFlightSpeed
, //208 SPELL_AURA_MOD_SPEED_FLIGHT, used only in spell: Flight Form (Passive)
261 &Aura::HandleAuraModIncreaseFlightSpeed
, //209 SPELL_AURA_MOD_FLIGHT_SPEED_ALWAYS
262 &Aura::HandleNULL
, //210 Commentator's Command
263 &Aura::HandleAuraModIncreaseFlightSpeed
, //211 SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK
264 &Aura::HandleAuraModRangedAttackPowerOfStatPercent
, //212 SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT
265 &Aura::HandleNoImmediateEffect
, //213 SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT implemented in Player::RewardRage
266 &Aura::HandleNULL
, //214 Tamed Pet Passive
267 &Aura::HandleArenaPreparation
, //215 SPELL_AURA_ARENA_PREPARATION
268 &Aura::HandleModCastingSpeed
, //216 SPELL_AURA_HASTE_SPELLS
269 &Aura::HandleUnused
, //217 unused (3.0.8a)
270 &Aura::HandleAuraModRangedHaste
, //218 SPELL_AURA_HASTE_RANGED
271 &Aura::HandleModManaRegen
, //219 SPELL_AURA_MOD_MANA_REGEN_FROM_STAT
272 &Aura::HandleModRatingFromStat
, //220 SPELL_AURA_MOD_RATING_FROM_STAT
273 &Aura::HandleNULL
, //221 ignored
274 &Aura::HandleUnused
, //222 unused (3.0.8a) only for spell 44586 that not used in real spell cast
275 &Aura::HandleNULL
, //223 Cold Stare
276 &Aura::HandleUnused
, //224 unused (3.0.8a)
277 &Aura::HandleNoImmediateEffect
, //225 SPELL_AURA_PRAYER_OF_MENDING
278 &Aura::HandleAuraPeriodicDummy
, //226 SPELL_AURA_PERIODIC_DUMMY
279 &Aura::HandlePeriodicTriggerSpellWithValue
, //227 SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
280 &Aura::HandleNoImmediateEffect
, //228 stealth detection
281 &Aura::HandleNULL
, //229 SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE
282 &Aura::HandleAuraModIncreaseMaxHealth
, //230 Commanding Shout
283 &Aura::HandleNoImmediateEffect
, //231 SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE
284 &Aura::HandleNoImmediateEffect
, //232 SPELL_AURA_MECHANIC_DURATION_MOD implement in Unit::CalculateSpellDuration
285 &Aura::HandleNULL
, //233 set model id to the one of the creature with id m_modifier.m_miscvalue
286 &Aura::HandleNoImmediateEffect
, //234 SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK implement in Unit::CalculateSpellDuration
287 &Aura::HandleAuraModDispelResist
, //235 SPELL_AURA_MOD_DISPEL_RESIST implement in Unit::MagicSpellHitResult
288 &Aura::HandleAuraControlVehicle
, //236 SPELL_AURA_CONTROL_VEHICLE
289 &Aura::HandleModSpellDamagePercentFromAttackPower
, //237 SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER implemented in Unit::SpellBaseDamageBonus
290 &Aura::HandleModSpellHealingPercentFromAttackPower
, //238 SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER implemented in Unit::SpellBaseHealingBonus
291 &Aura::HandleAuraModScale
, //239 SPELL_AURA_MOD_SCALE_2 only in Noggenfogger Elixir (16595) before 2.3.0 aura 61
292 &Aura::HandleAuraModExpertise
, //240 SPELL_AURA_MOD_EXPERTISE
293 &Aura::HandleForceMoveForward
, //241 Forces the player to move forward
294 &Aura::HandleUnused
, //242 SPELL_AURA_MOD_SPELL_DAMAGE_FROM_HEALING
295 &Aura::HandleNULL
, //243 faction reaction override spells
296 &Aura::HandleComprehendLanguage
, //244 Comprehend language
297 &Aura::HandleNULL
, //245 SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS
298 &Aura::HandleNoImmediateEffect
, //246 SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL
299 &Aura::HandleNULL
, //247 target to become a clone of the caster
300 &Aura::HandleNoImmediateEffect
, //248 SPELL_AURA_MOD_COMBAT_RESULT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
301 &Aura::HandleAuraConvertRune
, //249 SPELL_AURA_CONVERT_RUNE
302 &Aura::HandleAuraModIncreaseHealth
, //250 SPELL_AURA_MOD_INCREASE_HEALTH_2
303 &Aura::HandleNULL
, //251 SPELL_AURA_MOD_ENEMY_DODGE
304 &Aura::HandleNULL
, //252 haste all?
305 &Aura::HandleNULL
, //253 SPELL_AURA_MOD_BLOCK_CRIT_CHANCE
306 &Aura::HandleNULL
, //254 SPELL_AURA_MOD_DISARM_SHIELD disarm Shield
307 &Aura::HandleNoImmediateEffect
, //255 SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT implemented in Unit::SpellDamageBonus
308 &Aura::HandleNoReagentUseAura
, //256 SPELL_AURA_NO_REAGENT_USE Use SpellClassMask for spell select
309 &Aura::HandleNULL
, //257 SPELL_AURA_MOD_TARGET_RESIST_BY_SPELL_CLASS Use SpellClassMask for spell select
310 &Aura::HandleNULL
, //258 SPELL_AURA_MOD_SPELL_VISUAL
311 &Aura::HandleNULL
, //259 corrupt healing over time spell
312 &Aura::HandleNoImmediateEffect
, //260 SPELL_AURA_SCREEN_EFFECT (miscvalue = id in ScreenEffect.dbc) not required any code
313 &Aura::HandlePhase
, //261 SPELL_AURA_PHASE undetactable invisibility? implemented in Unit::isVisibleForOrDetect
314 &Aura::HandleNULL
, //262
315 &Aura::HandleNULL
, //263 SPELL_AURA_ALLOW_ONLY_ABILITY player can use only abilities set in SpellClassMask
316 &Aura::HandleUnused
, //264 unused (3.0.8a)
317 &Aura::HandleUnused
, //265 unused (3.0.8a)
318 &Aura::HandleUnused
, //266 unused (3.0.8a)
319 &Aura::HandleNoImmediateEffect
, //267 SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL implemented in Unit::IsImmunedToSpellEffect
320 &Aura::HandleAuraModAttackPowerOfStatPercent
, //268 SPELL_AURA_MOD_ATTACK_POWER_OF_STAT_PERCENT
321 &Aura::HandleNULL
, //269 ignore DR effects?
322 &Aura::HandleNULL
, //270 SPELL_AURA_MOD_IGNORE_TARGET_RESIST
323 &Aura::HandleNoImmediateEffect
, //271 SPELL_AURA_MOD_DAMAGE_FROM_CASTER implemented in Unit::SpellDamageBonus
324 &Aura::HandleNULL
, //272 reduce spell cast time?
325 &Aura::HandleNULL
, //273
326 &Aura::HandleNULL
, //274 proc free shot?
327 &Aura::HandleNoImmediateEffect
, //275 SPELL_AURA_MOD_IGNORE_SHAPESHIFT Use SpellClassMask for spell select
328 &Aura::HandleNULL
, //276 mod damage % mechanic?
329 &Aura::HandleNoImmediateEffect
, //277 SPELL_AURA_MOD_MAX_AFFECTED_TARGETS Use SpellClassMask for spell select
330 &Aura::HandleNULL
, //278 SPELL_AURA_MOD_DISARM_RANGED disarm ranged weapon
331 &Aura::HandleNULL
, //279 visual effects? 58836 and 57507
332 &Aura::HandleNULL
, //280 SPELL_AURA_MOD_TARGET_ARMOR_PCT
333 &Aura::HandleNULL
, //281 SPELL_AURA_MOD_HONOR_GAIN
334 &Aura::HandleAuraIncreaseBaseHealthPercent
, //282 SPELL_AURA_INCREASE_BASE_HEALTH_PERCENT
335 &Aura::HandleNoImmediateEffect
, //283 SPELL_AURA_MOD_HEALING_RECEIVED implemented in Unit::SpellHealingBonus
336 &Aura::HandleUnused
, //284 not used by any spells (3.08a)
337 &Aura::HandleUnused
, //285 not used by any spells (3.08a)
338 &Aura::HandleUnused
, //286 not used by any spells (3.08a)
339 &Aura::HandleNoImmediateEffect
, //287 SPELL_AURA_DEFLECT_SPELLS implemented in Unit::MagicSpellHitResult and Unit::MeleeSpellHitResult
340 &Aura::HandleUnused
, //288 not used by any spells (3.09) except 1 test spell.
343 static AuraType
const frozenAuraTypes
[] = { SPELL_AURA_MOD_ROOT
, SPELL_AURA_MOD_STUN
, SPELL_AURA_NONE
};
345 Aura::Aura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
, Unit
*caster
, Item
* castItem
) :
346 m_spellmod(NULL
), m_caster_guid(0), m_castItemGuid(castItem
?castItem
->GetGUID():0), m_target(target
),
347 m_timeCla(1000), m_periodicTimer(0), m_removeMode(AURA_REMOVE_BY_DEFAULT
), m_AuraDRGroup(DIMINISHING_NONE
),
348 m_effIndex(eff
), m_auraSlot(MAX_AURAS
), m_auraFlags(AFLAG_NONE
), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),
349 m_positive(false), m_permanent(false), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false),
350 m_updated(false), m_isRemovedOnShapeLost(true), m_in_use(false)
354 assert(spellproto
&& spellproto
== sSpellStore
.LookupEntry( spellproto
->Id
) && "`info` must be pointer to sSpellStore element");
356 m_spellProto
= spellproto
;
358 m_currentBasePoints
= currentBasePoints
? *currentBasePoints
: m_spellProto
->EffectBasePoints
[eff
];
360 m_isPassive
= IsPassiveSpell(GetId());
361 m_positive
= IsPositiveEffect(GetId(), m_effIndex
);
363 m_applyTime
= time(NULL
);
368 m_caster_guid
= target
->GetGUID();
369 damage
= m_currentBasePoints
+1; // stored value-1
370 m_maxduration
= target
->CalculateSpellDuration(m_spellProto
, m_effIndex
, target
);
374 m_caster_guid
= caster
->GetGUID();
376 damage
= caster
->CalculateSpellDamage(m_spellProto
,m_effIndex
,m_currentBasePoints
,target
);
377 m_maxduration
= caster
->CalculateSpellDuration(m_spellProto
, m_effIndex
, target
);
379 if (!damage
&& castItem
&& castItem
->GetItemSuffixFactor())
381 ItemRandomSuffixEntry
const *item_rand_suffix
= sItemRandomSuffixStore
.LookupEntry(abs(castItem
->GetItemRandomPropertyId()));
384 for (int k
=0; k
<3; k
++)
386 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(item_rand_suffix
->enchant_id
[k
]);
389 for (int t
=0; t
<3; t
++)
390 if(pEnchant
->spellid
[t
] == m_spellProto
->Id
)
392 damage
= uint32((item_rand_suffix
->prefix
[k
]*castItem
->GetItemSuffixFactor()) / 10000 );
404 if(m_maxduration
== -1 || m_isPassive
&& m_spellProto
->DurationIndex
== 0)
407 Player
* modOwner
= caster
? caster
->GetSpellModOwner() : NULL
;
409 if(!m_permanent
&& modOwner
)
411 modOwner
->ApplySpellMod(GetId(), SPELLMOD_DURATION
, m_maxduration
);
412 // Get zero duration aura after - need set m_maxduration > 0 for apply/remove aura work
413 if (m_maxduration
<=0)
417 m_duration
= m_maxduration
;
419 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
);
422 SetModifier(AuraType(m_spellProto
->EffectApplyAuraName
[eff
]), damage
, m_spellProto
->EffectAmplitude
[eff
], m_spellProto
->EffectMiscValue
[eff
]);
424 // Apply periodic time mod
425 if(modOwner
&& m_modifier
.periodictime
)
426 modOwner
->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME
, m_modifier
.periodictime
);
428 // Start periodic on next tick or at aura apply
429 if (!(m_spellProto
->AttributesEx5
& SPELL_ATTR_EX5_START_PERIODIC_AT_APPLY
))
430 m_periodicTimer
+= m_modifier
.periodictime
;
432 m_isDeathPersist
= IsDeathPersistentSpell(m_spellProto
);
434 m_procCharges
= m_spellProto
->procCharges
;
436 modOwner
->ApplySpellMod(GetId(), SPELLMOD_CHARGES
, m_procCharges
);
438 m_isRemovedOnShapeLost
= (m_caster_guid
==m_target
->GetGUID() &&
439 m_spellProto
->Stances
&&
440 !(m_spellProto
->AttributesEx2
& SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT
) &&
441 !(m_spellProto
->Attributes
& SPELL_ATTR_NOT_SHAPESHIFT
));
448 AreaAura::AreaAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
,
449 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
453 // caster==NULL in constructor args if target==caster in fact
454 Unit
* caster_ptr
= caster
? caster
: target
;
456 m_radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(GetSpellProto()->EffectRadiusIndex
[m_effIndex
]));
457 if(Player
* modOwner
= caster_ptr
->GetSpellModOwner())
458 modOwner
->ApplySpellMod(GetId(), SPELLMOD_RADIUS
, m_radius
);
460 switch(spellproto
->Effect
[eff
])
462 case SPELL_EFFECT_APPLY_AREA_AURA_PARTY
:
463 m_areaAuraType
= AREA_AURA_PARTY
;
464 if(target
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)target
)->isTotem())
465 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
467 case SPELL_EFFECT_APPLY_AREA_AURA_RAID
:
468 m_areaAuraType
= AREA_AURA_RAID
;
469 if(target
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)target
)->isTotem())
470 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
472 case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
:
473 m_areaAuraType
= AREA_AURA_FRIEND
;
475 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
:
476 m_areaAuraType
= AREA_AURA_ENEMY
;
477 if(target
== caster_ptr
)
478 m_modifier
.m_auraname
= SPELL_AURA_NONE
; // Do not do any effect on self
480 case SPELL_EFFECT_APPLY_AREA_AURA_PET
:
481 m_areaAuraType
= AREA_AURA_PET
;
483 case SPELL_EFFECT_APPLY_AREA_AURA_OWNER
:
484 m_areaAuraType
= AREA_AURA_OWNER
;
485 if(target
== caster_ptr
)
486 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
489 sLog
.outError("Wrong spell effect in AreaAura constructor");
495 AreaAura::~AreaAura()
499 PersistentAreaAura::PersistentAreaAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
,
500 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
502 m_isPersistent
= true;
505 PersistentAreaAura::~PersistentAreaAura()
509 SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
,
510 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
513 m_casters_target_guid
= caster
->GetTypeId()==TYPEID_PLAYER
? ((Player
*)caster
)->GetSelection() : caster
->GetUInt64Value(UNIT_FIELD_TARGET
);
515 m_casters_target_guid
= 0;
518 SingleEnemyTargetAura::~SingleEnemyTargetAura()
522 Unit
* SingleEnemyTargetAura::GetTriggerTarget() const
524 return ObjectAccessor::GetUnit(*m_target
, m_casters_target_guid
);
527 Aura
* CreateAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
, Unit
*caster
, Item
* castItem
)
529 if (IsAreaAuraEffect(spellproto
->Effect
[eff
]))
530 return new AreaAura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
532 uint32 triggeredSpellId
= spellproto
->EffectTriggerSpell
[eff
];
534 if(SpellEntry
const* triggeredSpellInfo
= sSpellStore
.LookupEntry(triggeredSpellId
))
535 for (int i
= 0; i
< 3; ++i
)
536 if (triggeredSpellInfo
->EffectImplicitTargetA
[i
] == TARGET_SINGLE_ENEMY
)
537 return new SingleEnemyTargetAura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
539 return new Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
542 Unit
* Aura::GetCaster() const
544 if(m_caster_guid
==m_target
->GetGUID())
547 //return ObjectAccessor::GetUnit(*m_target,m_caster_guid);
548 //must return caster even if it's in another grid/map
549 Unit
*unit
= ObjectAccessor::GetObjectInWorld(m_caster_guid
, (Unit
*)NULL
);
550 return unit
&& unit
->IsInWorld() ? unit
: NULL
;
553 void Aura::SetModifier(AuraType t
, int32 a
, uint32 pt
, int32 miscValue
)
555 m_modifier
.m_auraname
= t
;
556 m_modifier
.m_amount
= a
;
557 m_modifier
.m_miscvalue
= miscValue
;
558 m_modifier
.periodictime
= pt
;
561 void Aura::Update(uint32 diff
)
570 // GetEffIndex()==0 prevent double/triple apply manaPerSecond/manaPerSecondPerLevel to same spell with many auras
571 // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0
572 if(GetEffIndex()==0 && m_timeCla
<= 0)
574 if(Unit
* caster
= GetCaster())
576 Powers powertype
= Powers(m_spellProto
->powerType
);
577 int32 manaPerSecond
= m_spellProto
->manaPerSecond
+ m_spellProto
->manaPerSecondPerLevel
* caster
->getLevel();
578 m_timeCla
= 1*IN_MILISECONDS
;
581 if(powertype
==POWER_HEALTH
)
582 caster
->ModifyHealth(-manaPerSecond
);
584 caster
->ModifyPower(powertype
,-manaPerSecond
);
590 // Channeled aura required check distance from caster
591 if(IsChanneledSpell(m_spellProto
) && m_caster_guid
!= m_target
->GetGUID())
593 Unit
* caster
= GetCaster();
596 m_target
->RemoveAura(GetId(),GetEffIndex());
603 if (m_spellProto
->EffectRadiusIndex
[GetEffIndex()])
605 radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellProto
->EffectRadiusIndex
[GetEffIndex()]));
606 mod
= SPELLMOD_RADIUS
;
610 radius
= GetSpellMaxRange(sSpellRangeStore
.LookupEntry(m_spellProto
->rangeIndex
));
611 mod
= SPELLMOD_RANGE
;
614 if(Player
* modOwner
= caster
->GetSpellModOwner())
615 modOwner
->ApplySpellMod(GetId(), mod
, radius
,NULL
);
617 if(!caster
->IsWithinDistInMap(m_target
,radius
))
619 m_target
->RemoveAura(GetId(),GetEffIndex());
624 if(m_isPeriodic
&& (m_duration
>= 0 || m_isPassive
|| m_permanent
))
626 m_periodicTimer
-= diff
;
627 if(m_periodicTimer
<= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N
629 // update before applying (aura can be removed in TriggerSpell or PeriodicTick calls)
630 m_periodicTimer
+= m_modifier
.periodictime
;
636 void AreaAura::Update(uint32 diff
)
638 // update for the caster of the aura
639 if(m_caster_guid
== m_target
->GetGUID())
641 Unit
* caster
= m_target
;
643 if( !caster
->hasUnitState(UNIT_STAT_ISOLATED
) )
645 Unit
* owner
= caster
->GetCharmerOrOwner();
648 std::list
<Unit
*> targets
;
650 switch(m_areaAuraType
)
652 case AREA_AURA_PARTY
:
654 Group
*pGroup
= NULL
;
656 if (owner
->GetTypeId() == TYPEID_PLAYER
)
657 pGroup
= ((Player
*)owner
)->GetGroup();
661 uint8 subgroup
= ((Player
*)owner
)->GetSubGroup();
662 for(GroupReference
*itr
= pGroup
->GetFirstMember(); itr
!= NULL
; itr
= itr
->next())
664 Player
* Target
= itr
->getSource();
665 if(Target
&& Target
->isAlive() && Target
->GetSubGroup()==subgroup
&& caster
->IsFriendlyTo(Target
))
667 if(caster
->IsWithinDistInMap(Target
, m_radius
))
668 targets
.push_back(Target
);
669 Pet
*pet
= Target
->GetPet();
670 if(pet
&& pet
->isAlive() && caster
->IsWithinDistInMap(pet
, m_radius
))
671 targets
.push_back(pet
);
678 if( owner
!= caster
&& caster
->IsWithinDistInMap(owner
, m_radius
) )
679 targets
.push_back(owner
);
681 Unit
* pet
= caster
->GetPet();
682 if( pet
&& caster
->IsWithinDistInMap(pet
, m_radius
))
683 targets
.push_back(pet
);
689 Group
*pGroup
= NULL
;
691 if (owner
->GetTypeId() == TYPEID_PLAYER
)
692 pGroup
= ((Player
*)owner
)->GetGroup();
696 uint8 subgroup
= ((Player
*)owner
)->GetSubGroup();
697 for(GroupReference
*itr
= pGroup
->GetFirstMember(); itr
!= NULL
; itr
= itr
->next())
699 Player
* Target
= itr
->getSource();
700 if(Target
&& Target
->isAlive() && caster
->IsFriendlyTo(Target
))
702 if(caster
->IsWithinDistInMap(Target
, m_radius
))
703 targets
.push_back(Target
);
704 Pet
*pet
= Target
->GetPet();
705 if(pet
&& pet
->isAlive() && caster
->IsWithinDistInMap(pet
, m_radius
))
706 targets
.push_back(pet
);
713 if( owner
!= caster
&& caster
->IsWithinDistInMap(owner
, m_radius
) )
714 targets
.push_back(owner
);
716 Unit
* pet
= caster
->GetPet();
717 if( pet
&& caster
->IsWithinDistInMap(pet
, m_radius
))
718 targets
.push_back(pet
);
722 case AREA_AURA_FRIEND
:
724 CellPair
p(MaNGOS::ComputeCellPair(caster
->GetPositionX(), caster
->GetPositionY()));
726 cell
.data
.Part
.reserved
= ALL_DISTRICT
;
729 MaNGOS::AnyFriendlyUnitInObjectRangeCheck
u_check(caster
, owner
, m_radius
);
730 MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
> searcher(caster
,targets
, u_check
);
731 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
>, WorldTypeMapContainer
> world_unit_searcher(searcher
);
732 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
>, GridTypeMapContainer
> grid_unit_searcher(searcher
);
733 CellLock
<GridReadGuard
> cell_lock(cell
, p
);
734 cell_lock
->Visit(cell_lock
, world_unit_searcher
, *caster
->GetMap());
735 cell_lock
->Visit(cell_lock
, grid_unit_searcher
, *caster
->GetMap());
738 case AREA_AURA_ENEMY
:
740 CellPair
p(MaNGOS::ComputeCellPair(caster
->GetPositionX(), caster
->GetPositionY()));
742 cell
.data
.Part
.reserved
= ALL_DISTRICT
;
745 MaNGOS::AnyAoETargetUnitInObjectRangeCheck
u_check(caster
, owner
, m_radius
); // No GetCharmer in searcher
746 MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
> searcher(caster
, targets
, u_check
);
747 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
>, WorldTypeMapContainer
> world_unit_searcher(searcher
);
748 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
>, GridTypeMapContainer
> grid_unit_searcher(searcher
);
749 CellLock
<GridReadGuard
> cell_lock(cell
, p
);
750 cell_lock
->Visit(cell_lock
, world_unit_searcher
, *caster
->GetMap());
751 cell_lock
->Visit(cell_lock
, grid_unit_searcher
, *caster
->GetMap());
754 case AREA_AURA_OWNER
:
758 targets
.push_back(owner
);
763 for(std::list
<Unit
*>::iterator tIter
= targets
.begin(); tIter
!= targets
.end(); tIter
++)
765 if((*tIter
)->HasAura(GetId(), m_effIndex
))
768 if(SpellEntry
const *actualSpellInfo
= spellmgr
.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter
)->getLevel()))
770 int32 actualBasePoints
= m_currentBasePoints
;
771 // recalculate basepoints for lower rank (all AreaAura spell not use custom basepoints?)
772 if(actualSpellInfo
!= GetSpellProto())
773 actualBasePoints
= actualSpellInfo
->EffectBasePoints
[m_effIndex
];
774 AreaAura
*aur
= new AreaAura(actualSpellInfo
, m_effIndex
, &actualBasePoints
, (*tIter
), caster
, NULL
);
775 aur
->SetAuraDuration(GetAuraDuration());
776 (*tIter
)->AddAura(aur
);
782 else // aura at non-caster
784 Unit
* tmp_target
= m_target
;
785 Unit
* caster
= GetCaster();
786 uint32 tmp_spellId
= GetId(), tmp_effIndex
= m_effIndex
;
788 // WARNING: the aura may get deleted during the update
789 // DO NOT access its members after update!
792 // remove aura if out-of-range from caster (after teleport for example)
793 // or caster is isolated or caster no longer has the aura
794 // or caster is (no longer) friendly
795 bool needFriendly
= (m_areaAuraType
== AREA_AURA_ENEMY
? false : true);
796 if( !caster
|| caster
->hasUnitState(UNIT_STAT_ISOLATED
) ||
797 !caster
->IsWithinDistInMap(tmp_target
, m_radius
) ||
798 !caster
->HasAura(tmp_spellId
, tmp_effIndex
) ||
799 caster
->IsFriendlyTo(tmp_target
) != needFriendly
802 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
804 else if( m_areaAuraType
== AREA_AURA_PARTY
) // check if in same sub group
806 // not check group if target == owner or target == pet
807 if (caster
->GetCharmerOrOwnerGUID() != tmp_target
->GetGUID() && caster
->GetGUID() != tmp_target
->GetCharmerOrOwnerGUID())
809 Player
* check
= caster
->GetCharmerOrOwnerPlayerOrPlayerItself();
811 Group
*pGroup
= check
? check
->GetGroup() : NULL
;
814 Player
* checkTarget
= tmp_target
->GetCharmerOrOwnerPlayerOrPlayerItself();
815 if(!checkTarget
|| !pGroup
->SameSubGroup(check
, checkTarget
))
816 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
819 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
822 else if( m_areaAuraType
== AREA_AURA_RAID
) // TODO: fix me!
824 // not check group if target == owner or target == pet
825 if (caster
->GetCharmerOrOwnerGUID() != tmp_target
->GetGUID() && caster
->GetGUID() != tmp_target
->GetCharmerOrOwnerGUID())
827 Player
* check
= caster
->GetCharmerOrOwnerPlayerOrPlayerItself();
829 Group
*pGroup
= check
? check
->GetGroup() : NULL
;
832 Player
* checkTarget
= tmp_target
->GetCharmerOrOwnerPlayerOrPlayerItself();
834 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
837 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
840 else if( m_areaAuraType
== AREA_AURA_PET
|| m_areaAuraType
== AREA_AURA_OWNER
)
842 if( tmp_target
->GetGUID() != caster
->GetCharmerOrOwnerGUID() )
843 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
848 void PersistentAreaAura::Update(uint32 diff
)
852 // remove the aura if its caster or the dynamic object causing it was removed
853 // or if the target moves too far from the dynamic object
854 Unit
*caster
= GetCaster();
857 DynamicObject
*dynObj
= caster
->GetDynObject(GetId(), GetEffIndex());
860 if (!m_target
->IsWithinDistInMap(dynObj
, dynObj
->GetRadius()))
869 Unit
*tmp_target
= m_target
;
870 uint32 tmp_id
= GetId(), tmp_index
= GetEffIndex();
872 // WARNING: the aura may get deleted during the update
873 // DO NOT access its members after update!
877 tmp_target
->RemoveAura(tmp_id
, tmp_index
);
880 void Aura::ApplyModifier(bool apply
, bool Real
)
882 AuraType aura
= m_modifier
.m_auraname
;
886 (*this.*AuraHandler
[aura
])(apply
,Real
);
890 void Aura::_AddAura()
897 // Second aura if some spell
898 bool secondaura
= false;
899 // Try find slot for aura
900 uint8 slot
= NULL_AURA_SLOT
;
901 // Lookup for some spell auras (and get slot from it)
902 for(uint8 i
= 0; i
< m_effIndex
; i
++)
904 Unit::spellEffectPair spair
= Unit::spellEffectPair(GetId(), i
);
905 for(Unit::AuraMap::const_iterator itr
= m_target
->GetAuras().lower_bound(spair
); itr
!= m_target
->GetAuras().upper_bound(spair
); ++itr
)
907 // allow use single slot only by auras from same caster
908 if(itr
->second
->GetCasterGUID()==GetCasterGUID())
910 slot
= itr
->second
->GetAuraSlot();
919 if (!secondaura
&& m_target
->GetVisibleAurasCount() < MAX_AURAS
)
921 Unit::VisibleAuraMap
const *visibleAuras
= m_target
->GetVisibleAuras();
922 for(uint8 i
= 0; i
< MAX_AURAS
; ++i
)
924 Unit::VisibleAuraMap::const_iterator itr
= visibleAuras
->find(i
);
925 if(itr
== visibleAuras
->end())
928 // update for out of range group members (on 1 slot use)
929 m_target
->UpdateAuraForGroup(slot
);
935 Unit
* caster
= GetCaster();
937 // set infinity cooldown state for spells
938 if(caster
&& caster
->GetTypeId() == TYPEID_PLAYER
)
940 if (m_spellProto
->Attributes
& SPELL_ATTR_DISABLED_WHILE_ACTIVE
)
942 Item
* castItem
= m_castItemGuid
? ((Player
*)caster
)->GetItemByGuid(m_castItemGuid
) : NULL
;
943 ((Player
*)caster
)->AddSpellAndCategoryCooldowns(m_spellProto
,castItem
? castItem
->GetEntry() : 0, NULL
,true);
947 // passive auras (except totem auras) do not get placed in the slots
948 // area auras with SPELL_AURA_NONE are not shown on target
949 if((!m_isPassive
|| (caster
&& caster
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)caster
)->isTotem())) &&
950 (m_spellProto
->Effect
[GetEffIndex()] != SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
|| m_target
!= caster
))
953 if(slot
< MAX_AURAS
) // slot found send data to client
956 SetAuraFlags((1 << GetEffIndex()) | AFLAG_NOT_CASTER
| ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION
: AFLAG_NONE
) | (IsPositive() ? AFLAG_POSITIVE
: AFLAG_NEGATIVE
));
957 SetAuraLevel(caster
? caster
->getLevel() : sWorld
.getConfig(CONFIG_MAX_PLAYER_LEVEL
));
958 SendAuraUpdate(false);
961 //*****************************************************
962 // Update target aura state flag (at 1 aura apply)
963 // TODO: Make it easer
964 //*****************************************************
967 // Sitdown on apply aura req seated
968 if (m_spellProto
->AuraInterruptFlags
& AURA_INTERRUPT_FLAG_NOT_SEATED
&& !m_target
->IsSitState())
969 m_target
->SetStandState(UNIT_STAND_STATE_SIT
);
971 // register aura diminishing on apply
972 if (getDiminishGroup() != DIMINISHING_NONE
)
973 m_target
->ApplyDiminishingAura(getDiminishGroup(),true);
975 // Update Seals information
976 if (IsSealSpell(m_spellProto
))
977 m_target
->ModifyAuraState(AURA_STATE_JUDGEMENT
, true);
979 // Conflagrate aura state on Immolate
980 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARLOCK
&& m_spellProto
->SpellFamilyFlags
& 4)
981 m_target
->ModifyAuraState(AURA_STATE_IMMOLATE
, true);
983 // Faerie Fire (druid versions)
984 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_DRUID
&& m_spellProto
->SpellFamilyFlags
& 0x0000000000000400LL
)
985 m_target
->ModifyAuraState(AURA_STATE_FAERIE_FIRE
, true);
988 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& m_spellProto
->SpellFamilyFlags
& 0x0004000000000000LL
)
989 m_target
->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH
, true);
991 // Swiftmend state on Regrowth & Rejuvenation
992 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_DRUID
&& m_spellProto
->SpellFamilyFlags
& 0x50 )
993 m_target
->ModifyAuraState(AURA_STATE_SWIFTMEND
, true);
995 // Deadly poison aura state
996 if(m_spellProto
->SpellFamilyName
== SPELLFAMILY_ROGUE
&& m_spellProto
->SpellFamilyFlags
& 0x10000)
997 m_target
->ModifyAuraState(AURA_STATE_DEADLY_POISON
, true);
1000 if(m_spellProto
->Dispel
== DISPEL_ENRAGE
)
1001 m_target
->ModifyAuraState(AURA_STATE_ENRAGE
, true);
1006 void Aura::_RemoveAura()
1008 // Remove all triggered by aura spells vs unlimited duration
1009 // except same aura replace case
1010 if(m_removeMode
!=AURA_REMOVE_BY_STACK
)
1011 CleanupTriggeredSpells();
1013 Unit
* caster
= GetCaster();
1015 if(caster
&& IsPersistent())
1017 DynamicObject
*dynObj
= caster
->GetDynObject(GetId(), GetEffIndex());
1019 dynObj
->RemoveAffected(m_target
);
1022 //passive auras do not get put in slots
1023 // Note: but totem can be not accessible for aura target in time remove (to far for find in grid)
1024 //if(m_isPassive && !(caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem()))
1027 uint8 slot
= GetAuraSlot();
1029 if(slot
>= MAX_AURAS
) // slot not set
1032 if(m_target
->GetVisibleAura(slot
) == 0)
1035 bool lastaura
= true;
1037 // find other aura in same slot (current already removed from list)
1038 for(uint8 i
= 0; i
< 3; i
++)
1040 Unit::spellEffectPair spair
= Unit::spellEffectPair(GetId(), i
);
1041 for(Unit::AuraMap::const_iterator itr
= m_target
->GetAuras().lower_bound(spair
); itr
!= m_target
->GetAuras().upper_bound(spair
); ++itr
)
1043 if(itr
->second
->GetAuraSlot()==slot
)
1053 // only remove icon when the last aura of the spell is removed (current aura already removed from list)
1056 // unregister aura diminishing (and store last time)
1057 if (getDiminishGroup() != DIMINISHING_NONE
)
1058 m_target
->ApplyDiminishingAura(getDiminishGroup(),false);
1061 SetAuraFlags(AFLAG_NONE
);
1063 SendAuraUpdate(true);
1065 // update for out of range group members
1066 m_target
->UpdateAuraForGroup(slot
);
1068 //*****************************************************
1069 // Update target aura state flag (at last aura remove)
1070 //*****************************************************
1071 // Enrage aura state
1072 if(m_spellProto
->Dispel
== DISPEL_ENRAGE
)
1073 m_target
->ModifyAuraState(AURA_STATE_ENRAGE
, false);
1075 uint32 removeState
= 0;
1076 switch(m_spellProto
->SpellFamilyName
)
1078 case SPELLFAMILY_PALADIN
:
1079 if (IsSealSpell(m_spellProto
))
1080 removeState
= AURA_STATE_JUDGEMENT
; // Update Seals information
1082 case SPELLFAMILY_WARLOCK
:
1083 if(m_spellProto
->SpellFamilyFlags
& 4)
1084 removeState
= AURA_STATE_IMMOLATE
; // Conflagrate aura state
1086 case SPELLFAMILY_DRUID
:
1087 if(m_spellProto
->SpellFamilyFlags
& 0x0000000000000400LL
)
1088 removeState
= AURA_STATE_FAERIE_FIRE
; // Faerie Fire (druid versions)
1089 else if(m_spellProto
->SpellFamilyFlags
& 0x50)
1090 removeState
= AURA_STATE_SWIFTMEND
; // Swiftmend aura state
1092 case SPELLFAMILY_WARRIOR
:
1093 if(m_spellProto
->SpellFamilyFlags
& 0x0004000000000000LL
)
1094 removeState
= AURA_STATE_WARRIOR_VICTORY_RUSH
; // Victorious
1096 case SPELLFAMILY_ROGUE
:
1097 if(m_spellProto
->SpellFamilyFlags
& 0x10000)
1098 removeState
= AURA_STATE_DEADLY_POISON
; // Deadly poison aura state
1100 case SPELLFAMILY_HUNTER
:
1101 if(m_spellProto
->SpellFamilyFlags
& 0x1000000000000000LL
)
1102 removeState
= AURA_STATE_FAERIE_FIRE
; // Sting (hunter versions)
1105 // Remove state (but need check other auras for it)
1109 Unit::AuraMap
& Auras
= m_target
->GetAuras();
1110 for(Unit::AuraMap::iterator i
= Auras
.begin(); i
!= Auras
.end(); ++i
)
1112 SpellEntry
const *auraSpellInfo
= (*i
).second
->GetSpellProto();
1113 if(auraSpellInfo
->SpellFamilyName
== m_spellProto
->SpellFamilyName
&&
1114 auraSpellInfo
->SpellFamilyFlags
== m_spellProto
->SpellFamilyFlags
)
1120 // this has been last aura
1122 m_target
->ModifyAuraState(AuraState(removeState
), false);
1125 // reset cooldown state for spells
1126 if(caster
&& caster
->GetTypeId() == TYPEID_PLAYER
)
1128 if ( GetSpellProto()->Attributes
& SPELL_ATTR_DISABLED_WHILE_ACTIVE
)
1129 // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
1130 ((Player
*)caster
)->SendCooldownEvent(GetSpellProto());
1135 void Aura::SendAuraUpdate(bool remove
)
1137 WorldPacket
data(SMSG_AURA_UPDATE
);
1138 data
.append(m_target
->GetPackGUID());
1139 data
<< uint8(GetAuraSlot());
1140 data
<< uint32(remove
? 0 : GetId());
1144 m_target
->SendMessageToSet(&data
, true);
1148 uint8 auraFlags
= GetAuraFlags();
1149 data
<< uint8(auraFlags
);
1150 data
<< uint8(GetAuraLevel());
1151 data
<< uint8(m_procCharges
? m_procCharges
: m_stackAmount
);
1153 if(!(auraFlags
& AFLAG_NOT_CASTER
))
1155 data
<< uint8(0); // pguid
1158 if(auraFlags
& AFLAG_DURATION
)
1160 data
<< uint32(GetAuraMaxDuration());
1161 data
<< uint32(GetAuraDuration());
1164 m_target
->SendMessageToSet(&data
, true);
1167 void Aura::SetStackAmount(uint8 stackAmount
)
1169 if (stackAmount
!= m_stackAmount
)
1171 Unit
*target
= GetTarget();
1172 Unit
*caster
= GetCaster();
1173 if (!target
|| !caster
)
1175 m_stackAmount
= stackAmount
;
1176 int32 amount
= m_stackAmount
* caster
->CalculateSpellDamage(m_spellProto
, m_effIndex
, m_currentBasePoints
, target
);
1177 // Reapply if amount change
1178 if (amount
!=m_modifier
.m_amount
)
1180 ApplyModifier(false, true);
1181 m_modifier
.m_amount
= amount
;
1182 ApplyModifier(true, true);
1188 bool Aura::modStackAmount(int32 num
)
1191 if (!m_spellProto
->StackAmount
)
1194 // Modify stack but limit it
1195 int32 stackAmount
= m_stackAmount
+ num
;
1196 if (stackAmount
> m_spellProto
->StackAmount
)
1197 stackAmount
= m_spellProto
->StackAmount
;
1198 else if (stackAmount
<=0) // Last aura from stack removed
1201 return true; // need remove aura
1204 // Update stack amount
1205 SetStackAmount(stackAmount
);
1209 void Aura::RefreshAura()
1211 m_duration
= m_maxduration
;
1212 SendAuraUpdate(false);
1215 bool Aura::isAffectedOnSpell(SpellEntry
const *spell
) const
1217 // Check family name
1218 if (spell
->SpellFamilyName
!= m_spellProto
->SpellFamilyName
)
1220 // Check EffectClassMask
1221 uint32
const *ptr
= getAuraSpellClassMask();
1222 if (((uint64
*)ptr
)[0] & spell
->SpellFamilyFlags
)
1224 if (ptr
[2] & spell
->SpellFamilyFlags2
)
1229 /*********************************************************/
1230 /*** BASIC AURA FUNCTION ***/
1231 /*********************************************************/
1232 void Aura::HandleAddModifier(bool apply
, bool Real
)
1234 if(m_target
->GetTypeId() != TYPEID_PLAYER
|| !Real
)
1237 if(m_modifier
.m_miscvalue
>= MAX_SPELLMOD
)
1242 // Add custom charges for some mod aura
1243 switch (m_spellProto
->Id
)
1245 case 17941: // Shadow Trance
1246 case 22008: // Netherwind Focus
1247 case 31834: // Light's Grace
1248 case 34754: // Clearcasting
1249 case 34936: // Backlash
1250 case 48108: // Hot Streak
1251 case 54741: // Firestarter
1252 case 57761: // Fireball!
1257 SpellModifier
*mod
= new SpellModifier
;
1258 mod
->op
= SpellModOp(m_modifier
.m_miscvalue
);
1259 mod
->value
= m_modifier
.m_amount
;
1260 mod
->type
= SpellModType(m_modifier
.m_auraname
); // SpellModType value == spell aura types
1261 mod
->spellId
= GetId();
1264 SpellAffectEntry
const *spellAffect
= spellmgr
.GetSpellAffect(GetId(), m_effIndex
);
1266 ptr
= &spellAffect
->SpellClassMask
[0];
1271 case 0: ptr
= &m_spellProto
->EffectSpellClassMaskA
[0]; break;
1272 case 1: ptr
= &m_spellProto
->EffectSpellClassMaskB
[0]; break;
1273 case 2: ptr
= &m_spellProto
->EffectSpellClassMaskC
[0]; break;
1279 mod
->mask
= (uint64
)ptr
[0] | (uint64
)ptr
[1]<<32;
1280 mod
->mask2
= (uint64
)ptr
[2];
1281 mod
->charges
= m_procCharges
;
1286 uint64 spellFamilyMask
= m_spellmod
->mask
;
1288 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
1290 // reapply some passive spells after add/remove related spellmods
1291 if(m_spellProto
->SpellFamilyName
==SPELLFAMILY_WARRIOR
&& (spellFamilyMask
& 0x0000100000000000LL
))
1293 m_target
->RemoveAurasDueToSpell(45471);
1296 m_target
->CastSpell(m_target
,45471,true);
1299 void Aura::HandleAddTargetTrigger(bool apply
, bool Real
)
1301 // Use SpellModifier structure for check
1302 // used only fields:
1303 // spellId, mask, mask2
1306 SpellModifier
*mod
= new SpellModifier
;
1307 mod
->spellId
= GetId();
1310 SpellAffectEntry
const *spellAffect
= spellmgr
.GetSpellAffect(GetId(), m_effIndex
);
1312 ptr
= &spellAffect
->SpellClassMask
[0];
1317 case 0: ptr
= &m_spellProto
->EffectSpellClassMaskA
[0]; break;
1318 case 1: ptr
= &m_spellProto
->EffectSpellClassMaskB
[0]; break;
1319 case 2: ptr
= &m_spellProto
->EffectSpellClassMaskC
[0]; break;
1325 mod
->mask
= (uint64
)ptr
[0] | (uint64
)ptr
[1]<<32;
1326 mod
->mask2
= (uint64
)ptr
[2];
1336 void Aura::TriggerSpell()
1338 Unit
* caster
= GetCaster();
1339 Unit
* target
= GetTriggerTarget();
1341 if(!caster
|| !target
)
1344 // generic casting code with custom spells and target/caster customs
1345 uint32 trigger_spell_id
= GetSpellProto()->EffectTriggerSpell
[m_effIndex
];
1347 SpellEntry
const *triggeredSpellInfo
= sSpellStore
.LookupEntry(trigger_spell_id
);
1348 SpellEntry
const *auraSpellInfo
= GetSpellProto();
1349 uint32 auraId
= auraSpellInfo
->Id
;
1351 // specific code for cases with no trigger spell provided in field
1352 if (triggeredSpellInfo
== NULL
)
1354 switch(auraSpellInfo
->SpellFamilyName
)
1356 case SPELLFAMILY_GENERIC
:
1360 // Firestone Passive (1-5 ranks)
1367 if (caster
->GetTypeId()!=TYPEID_PLAYER
)
1369 Item
* item
= ((Player
*)caster
)->GetWeaponForAttack(BASE_ATTACK
);
1372 uint32 enchant_id
= 0;
1375 case 758: enchant_id
= 1803; break; // Rank 1
1376 case 17945: enchant_id
= 1823; break; // Rank 2
1377 case 17947: enchant_id
= 1824; break; // Rank 3
1378 case 17949: enchant_id
= 1825; break; // Rank 4
1379 case 27252: enchant_id
= 2645; break; // Rank 5
1383 // remove old enchanting before applying new
1384 ((Player
*)caster
)->ApplyEnchantment(item
,TEMP_ENCHANTMENT_SLOT
,false);
1385 item
->SetEnchantment(TEMP_ENCHANTMENT_SLOT
, enchant_id
, m_modifier
.periodictime
+1000, 0);
1386 // add new enchanting
1387 ((Player
*)caster
)->ApplyEnchantment(item
,TEMP_ENCHANTMENT_SLOT
,true);
1390 // // Periodic Mana Burn
1392 // // Polymorphic Ray
1393 // case 6965: break;
1394 // // Fire Nova (1-7 ranks)
1403 // Thaumaturgy Channel
1404 case 9712: trigger_spell_id
= 21029; break;
1405 // // Egan's Blaster
1406 // case 17368: break;
1408 // case 18347: break;
1409 // // Ranshalla Waiting
1410 // case 18953: break;
1412 // case 19695: break;
1413 // // Frostwolf Muzzle DND
1414 // case 21794: break;
1415 // // Alterac Ram Collar DND
1416 // case 21866: break;
1417 // // Celebras Waiting
1418 // case 21916: break;
1419 // Brood Affliction: Bronze
1422 m_target
->CastSpell(m_target
, 23171, true, 0, this);
1426 // case 23184: break;
1430 int32 heal
= caster
->GetMaxHealth() / 10;
1431 caster
->ModifyHealth( heal
);
1432 caster
->SendHealSpellLog(caster
, 23493, heal
);
1434 int32 mana
= caster
->GetMaxPower(POWER_MANA
);
1438 caster
->ModifyPower( POWER_MANA
, mana
);
1439 caster
->SendEnergizeSpellLog(caster
, 23493, mana
, POWER_MANA
);
1443 // // Stoneclaw Totem Passive TEST
1444 // case 23792: break;
1446 // case 24018: break;
1447 // // Mark of Arlokk
1448 // case 24210: break;
1450 // case 24379: break;
1452 // case 24716: break;
1454 // case 24780: break;
1456 // case 24832: break;
1457 // // Shadow Bolt Whirl
1458 // case 24834: break;
1460 // case 24918: break;
1461 // // Mark of Nature
1462 // case 25041: break;
1464 // case 25152: break;
1466 // case 25371: break;
1468 // case 25572: break;
1470 // case 26009: break;
1472 // case 26136: break;
1474 // case 26196: break;
1476 // case 26615: break;
1478 // case 27177: break;
1479 // // Teleport: IF/UC
1480 // case 27601: break;
1481 // // Five Fat Finger Exploding Heart Technique
1482 // case 27673: break;
1484 // case 27746: break;
1485 // // Steam Tank Passive
1486 // case 27747: break;
1488 // case 27808: break;
1490 // case 27819: break;
1491 // // Controller Timer
1492 // case 28095: break;
1494 // case 28096: break;
1495 // // Stalagg Tesla Passive
1496 // case 28097: break;
1497 // // Feugen Tesla Passive
1498 // case 28109: break;
1500 // case 28111: break;
1501 // // Mark of Didier
1502 // case 28114: break;
1503 // // Communique Timer, camp
1504 // case 28346: break;
1506 // case 28522: break;
1508 // case 29519: break;
1509 // Inoculate Nestlewood Owlkin
1511 if(target
->GetTypeId()!=TYPEID_UNIT
)// prevent error reports in case ignored player target
1515 // case 29768: break;
1517 // case 29788: break;
1519 // case 29793: break;
1521 // case 29794: break;
1522 // // Guardian of Icecrown Passive
1523 // case 29897: break;
1524 // Feed Captured Animal
1525 case 29917: trigger_spell_id
= 29916; break;
1527 // case 29946: break;
1529 // case 29947: break;
1530 // // Mind Exhaustion Passive
1531 // case 30025: break;
1532 // // Nether Beam - Serenity
1533 // case 30401: break;
1537 // move loot to player inventory and despawn target
1538 if(caster
->GetTypeId() ==TYPEID_PLAYER
&&
1539 target
->GetTypeId() == TYPEID_UNIT
&&
1540 ((Creature
*)target
)->GetCreatureInfo()->type
== CREATURE_TYPE_GAS_CLOUD
)
1542 Player
* player
= (Player
*)caster
;
1543 Creature
* creature
= (Creature
*)target
;
1544 // missing lootid has been reported on startup - just return
1545 if (!creature
->GetCreatureInfo()->SkinLootId
)
1548 player
->AutoStoreLoot(creature
->GetCreatureInfo()->SkinLootId
,LootTemplates_Skinning
,true);
1550 creature
->setDeathState(JUST_DIED
);
1551 creature
->RemoveCorpse();
1552 creature
->SetHealth(0); // just for nice GM-mode view
1557 case 30576: trigger_spell_id
= 30571; break;
1559 // case 30598: break;
1565 // // Despawn Self - Smoke cloud
1566 // case 31269: break;
1567 // // Time Rift Periodic
1568 // case 31320: break;
1569 // // Corrupt Medivh
1570 // case 31326: break;
1574 m_target
->CastSpell(m_target
,31350,true);
1575 m_target
->DealDamage(m_target
, m_target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
1581 // Summon Elemental after create item
1582 caster
->SummonCreature(17870, 0, 0, 0, caster
->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN
, 0);
1585 // // Bloodmyst Tesla
1586 // case 31611: break;
1588 // case 31944: break;
1590 // case 32236: break;
1592 // case 32686: break;
1594 // case 33401: break;
1596 // case 33563: break;
1597 // // Murmur's Touch
1598 // case 33711: break;
1602 // cast 24 spells 34269-34289, 34314-34316
1603 for(uint32 spell_id
= 34269; spell_id
!= 34290; ++spell_id
)
1604 caster
->CastSpell(m_target
,spell_id
,true);
1605 for(uint32 spell_id
= 34314; spell_id
!= 34317; ++spell_id
)
1606 caster
->CastSpell(m_target
,spell_id
,true);
1610 // case 34480: break;
1612 // case 34683: break;
1613 // // Frostbite Rotate
1614 // case 34748: break;
1616 // case 34821: break;
1617 // // Interrupt Shutdown
1618 // case 35016: break;
1619 // // Interrupt Shutdown
1620 // case 35176: break;
1622 // case 35268: break;
1623 // // Salaadin's Tesla
1624 // case 35515: break;
1625 // // Ethereal Channel (Red)
1626 // case 35518: break;
1628 // case 35879: break;
1629 // // Dark Portal Storm
1630 // case 36018: break;
1632 // case 36056: break;
1633 // // Living Grove Defender Lifespan
1634 // case 36061: break;
1635 // // Professor Dabiri Talks
1636 // case 36064: break;
1637 // // Kael Gaining Power
1638 // case 36091: break;
1639 // // They Must Burn Bomb Aura
1640 // case 36344: break;
1641 // // They Must Burn Bomb Aura (self)
1642 // case 36350: break;
1643 // // Stolen Ravenous Ravager Egg
1644 // case 36401: break;
1645 // // Activated Cannon
1646 // case 36410: break;
1647 // // Stolen Ravenous Ravager Egg
1648 // case 36418: break;
1649 // // Enchanted Weapons
1650 // case 36510: break;
1651 // // Cursed Scarab Periodic
1652 // case 36556: break;
1653 // // Cursed Scarab Despawn Periodic
1654 // case 36561: break;
1656 // case 36573: break;
1657 // // Cannon Charging (platform)
1658 // case 36785: break;
1659 // // Cannon Charging (self)
1660 // case 36860: break;
1662 case 37027: trigger_spell_id
= 37029; break;
1664 // case 37125: break;
1666 // case 37268: break;
1668 // case 37429: break;
1670 // case 37430: break;
1671 // // Karazhan - Chess NPC AI, Snapshot timer
1672 // case 37440: break;
1673 // // Karazhan - Chess NPC AI, action timer
1674 // case 37504: break;
1675 // // Karazhan - Chess: Is Square OCCUPIED aura (DND)
1676 // case 39400: break;
1678 // case 37546: break;
1679 // // Shriveling Gaze
1680 // case 37589: break;
1681 // // Fake Aggro Radius (2 yd)
1682 // case 37815: break;
1683 // // Corrupt Medivh
1684 // case 37853: break;
1688 m_target
->CastSpell(m_target
, 38530, true);
1691 // Absorb Eye of Grillok (Zezzak's Shard)
1694 if(m_target
->GetTypeId() != TYPEID_UNIT
)
1697 caster
->CastSpell(caster
, 38495, true);
1699 Creature
* creatureTarget
= (Creature
*)m_target
;
1701 creatureTarget
->setDeathState(JUST_DIED
);
1702 creatureTarget
->RemoveCorpse();
1703 creatureTarget
->SetHealth(0); // just for nice GM-mode view
1706 // // Magic Sucker Device timer
1707 // case 38672: break;
1708 // // Tomb Guarding Charging
1709 // case 38751: break;
1710 // // Murmur's Touch
1711 // case 38794: break;
1712 // // Activate Nether-wraith Beacon (31742 Nether-wraith Beacon item)
1713 // case 39105: break;
1714 // // Drain World Tree Visual
1715 // case 39140: break;
1716 // // Quest - Dustin's Undead Dragon Visual aura
1717 // case 39259: break;
1718 // // Hellfire - The Exorcism, Jules releases darkness, aura
1719 // case 39306: break;
1721 // case 39346: break;
1722 // // Enchanted Weapons
1723 // case 39489: break;
1724 // // Shadow Bolt Whirl
1725 // case 39630: break;
1726 // // Shadow Bolt Whirl
1727 // case 39634: break;
1728 // // Shadow Inferno
1729 // case 39645: break;
1730 // Tear of Azzinoth Summon Channel - it's not really supposed to do anything,and this only prevents the console spam
1731 case 39857: trigger_spell_id
= 39856; break;
1732 // // Soulgrinder Ritual Visual (Smashed)
1733 // case 39974: break;
1734 // // Simon Game Pre-game timer
1735 // case 40041: break;
1736 // // Knockdown Fel Cannon: The Aggro Check Aura
1737 // case 40113: break;
1739 // case 40157: break;
1740 // // Demon Transform 2
1741 // case 40398: break;
1742 // // Demon Transform 1
1743 // case 40511: break;
1744 // // Ancient Flames
1745 // case 40657: break;
1746 // // Ethereal Ring Cannon: Cannon Aura
1747 // case 40734: break;
1749 // case 40760: break;
1750 // // Random Periodic
1751 // case 40867: break;
1752 // // Prismatic Shield
1753 // case 40879: break;
1754 // // Aura of Desire
1755 // case 41350: break;
1757 // case 41404: break;
1759 // case 41629: break;
1761 // case 42177: break;
1763 // case 42581: break;
1765 // case 42582: break;
1766 // // Return to the Spirit Realm
1767 // case 44035: break;
1768 // // Curse of Boundless Agony
1769 // case 45050: break;
1771 // case 46240: break;
1772 // Personalized Weather
1773 case 46736: trigger_spell_id
= 46737; break;
1774 // // Stay Submerged
1775 // case 46981: break;
1776 // // Dragonblight Ram
1777 // case 47015: break;
1778 // // Party G.R.E.N.A.D.E.
1779 // case 51510: break;
1785 case SPELLFAMILY_MAGE
:
1791 // Here need periodic triger reducing threat spell (or do it manually)
1798 // case SPELLFAMILY_WARRIOR:
1803 // case 23410: break;
1804 // // Corrupted Totems
1805 // case 23425: break;
1811 // case SPELLFAMILY_PRIEST:
1816 // case 32930: break;
1817 // // Fury of the Dreghood Elders
1818 // case 35460: break;
1824 case SPELLFAMILY_DRUID
:
1829 // trigger_spell_id not set and unknown effect triggered in this case, ignoring for while
1832 // Frenzied Regeneration
1838 int32 LifePerRage
= GetModifier()->m_amount
;
1840 int32 lRage
= m_target
->GetPower(POWER_RAGE
);
1841 if(lRage
> 100) // rage stored as rage*10
1843 m_target
->ModifyPower(POWER_RAGE
, -lRage
);
1844 int32 FRTriggerBasePoints
= int32(lRage
*LifePerRage
/10);
1845 m_target
->CastCustomSpell(m_target
,22845,&FRTriggerBasePoints
,NULL
,NULL
,true,NULL
,this);
1854 // case SPELLFAMILY_HUNTER:
1858 // //Frost Trap Aura
1861 // //Rizzle's Frost Trap
1865 // case 19597: // Tame Ice Claw Bear
1866 // case 19676: // Tame Snow Leopard
1867 // case 19677: // Tame Large Crag Boar
1868 // case 19678: // Tame Adult Plainstrider
1869 // case 19679: // Tame Prairie Stalker
1870 // case 19680: // Tame Swoop
1871 // case 19681: // Tame Dire Mottled Boar
1872 // case 19682: // Tame Surf Crawler
1873 // case 19683: // Tame Armored Scorpid
1874 // case 19684: // Tame Webwood Lurker
1875 // case 19685: // Tame Nightsaber Stalker
1876 // case 19686: // Tame Strigid Screecher
1877 // case 30100: // Tame Crazed Dragonhawk
1878 // case 30103: // Tame Elder Springpaw
1879 // case 30104: // Tame Mistbat
1880 // case 30647: // Tame Barbed Crawler
1881 // case 30648: // Tame Greater Timberstrider
1882 // case 30652: // Tame Nightstalker
1889 case SPELLFAMILY_SHAMAN
:
1893 // Lightning Shield (The Earthshatterer set trigger after cast Lighting Shield)
1896 // Need remove self if Lightning Shield not active
1897 Unit::AuraMap
const& auras
= target
->GetAuras();
1898 for(Unit::AuraMap::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
1900 SpellEntry
const* spell
= itr
->second
->GetSpellProto();
1901 if( spell
->SpellFamilyName
== SPELLFAMILY_SHAMAN
&&
1902 spell
->SpellFamilyFlags
& 0x0000000000000400L
)
1905 target
->RemoveAurasDueToSpell(28820);
1908 // Totemic Mastery (Skyshatter Regalia (Shaman Tier 6) - bonus)
1912 for(int i
= 0; i
< MAX_TOTEM
; ++i
)
1914 if(!caster
->m_TotemSlot
[i
])
1922 caster
->CastSpell(caster
,38437,true);
1924 caster
->RemoveAurasDueToSpell(38437);
1936 // Reget trigger spell proto
1937 triggeredSpellInfo
= sSpellStore
.LookupEntry(trigger_spell_id
);
1941 // Spell exist but require custom code
1947 // TODO: spell casted by result in correct way mostly
1949 // 1) target show casting at each triggered cast: target don't must show casting animation for any triggered spell
1950 // but must show affect apply like item casting
1951 // 2) maybe aura must be replace by new with accumulative stat mods instead stacking
1953 // prevent cast by triggered auras
1954 if(m_caster_guid
== m_target
->GetGUID())
1957 // stop triggering after each affected stats lost > 90
1958 int32 intelectLoss
= 0;
1959 int32 spiritLoss
= 0;
1961 Unit::AuraList
const& mModStat
= m_target
->GetAurasByType(SPELL_AURA_MOD_STAT
);
1962 for(Unit::AuraList::const_iterator i
= mModStat
.begin(); i
!= mModStat
.end(); ++i
)
1964 if ((*i
)->GetId() == 1010)
1966 switch((*i
)->GetModifier()->m_miscvalue
)
1968 case STAT_INTELLECT
: intelectLoss
+= (*i
)->GetModifier()->m_amount
; break;
1969 case STAT_SPIRIT
: spiritLoss
+= (*i
)->GetModifier()->m_amount
; break;
1975 if(intelectLoss
<= -90 && spiritLoss
<= -90)
1984 caster
->CastCustomSpell(target
, trigger_spell_id
, &m_modifier
.m_amount
, NULL
, NULL
, true, NULL
, this);
1990 // All ok cast by default case
1991 if(triggeredSpellInfo
)
1992 caster
->CastSpell(target
, triggeredSpellInfo
, true, 0, this);
1993 else if(target
->GetTypeId()!=TYPEID_UNIT
|| !Script
->EffectDummyCreature(caster
, GetId(), GetEffIndex(), (Creature
*)target
))
1994 sLog
.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex());
1997 void Aura::TriggerSpellWithValue()
1999 Unit
* caster
= GetCaster();
2000 Unit
* target
= GetTriggerTarget();
2002 if(!caster
|| !target
)
2005 // generic casting code with custom spells and target/caster customs
2006 uint32 trigger_spell_id
= GetSpellProto()->EffectTriggerSpell
[m_effIndex
];
2007 int32 basepoints0
= this->GetModifier()->m_amount
;
2009 caster
->CastCustomSpell(target
, trigger_spell_id
, &basepoints0
, 0, 0, true, 0, this);
2012 /*********************************************************/
2013 /*** AURA EFFECTS ***/
2014 /*********************************************************/
2016 void Aura::HandleAuraDummy(bool apply
, bool Real
)
2018 // spells required only Real aura add/remove
2022 Unit
* caster
= GetCaster();
2029 case 1515: // Tame beast
2030 // FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness
2031 if( caster
&& m_target
->CanHaveThreatList())
2032 m_target
->AddThreat(caster
, 10.0f
);
2034 case 13139: // net-o-matic
2035 // root to self part of (root_target->charge->root_self sequence
2037 caster
->CastSpell(caster
,13138,true,NULL
,this);
2039 case 39850: // Rocket Blast
2040 if(roll_chance_i(20)) // backfire stun
2041 m_target
->CastSpell(m_target
, 51581, true, NULL
, this);
2043 case 43873: // Headless Horseman Laugh
2044 if(caster
->GetTypeId() == TYPEID_PLAYER
)
2045 ((Player
*)caster
)->PlaySound(11965, false);
2047 case 46354: // Blood Elf Illusion
2050 switch(caster
->getGender())
2053 caster
->CastSpell(m_target
,46356,true,NULL
,this);
2056 caster
->CastSpell(m_target
,46355,true,NULL
,this);
2063 case 46699: // Requires No Ammo
2064 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
2065 ((Player
*)m_target
)->RemoveAmmo(); // not use ammo and not allow use
2070 if ( caster
&& GetSpellProto()->SpellFamilyName
== SPELLFAMILY_SHAMAN
&& (GetSpellProto()->SpellFamilyFlags
& 0x40000000000LL
))
2072 // prevent double apply bonuses
2073 if(m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading())
2074 m_modifier
.m_amount
= caster
->SpellHealingBonus(m_target
, GetSpellProto(), m_modifier
.m_amount
, SPELL_DIRECT_DAMAGE
);
2081 if( m_target
->GetTypeId() == TYPEID_PLAYER
&&
2082 ( GetSpellProto()->Effect
[0]==72 || GetSpellProto()->Effect
[0]==6 &&
2083 ( GetSpellProto()->EffectApplyAuraName
[0]==1 || GetSpellProto()->EffectApplyAuraName
[0]==128 ) ) )
2085 // spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425
2086 ((Player
*)m_target
)->SetFarSightGUID(0);
2087 WorldPacket
data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE
, 0);
2088 ((Player
*)m_target
)->GetSession()->SendPacket(&data
);
2092 if( (IsQuestTameSpell(GetId())) && caster
&& caster
->isAlive() && m_target
->isAlive())
2094 uint32 finalSpelId
= 0;
2097 case 19548: finalSpelId
= 19597; break;
2098 case 19674: finalSpelId
= 19677; break;
2099 case 19687: finalSpelId
= 19676; break;
2100 case 19688: finalSpelId
= 19678; break;
2101 case 19689: finalSpelId
= 19679; break;
2102 case 19692: finalSpelId
= 19680; break;
2103 case 19693: finalSpelId
= 19684; break;
2104 case 19694: finalSpelId
= 19681; break;
2105 case 19696: finalSpelId
= 19682; break;
2106 case 19697: finalSpelId
= 19683; break;
2107 case 19699: finalSpelId
= 19685; break;
2108 case 19700: finalSpelId
= 19686; break;
2109 case 30646: finalSpelId
= 30647; break;
2110 case 30653: finalSpelId
= 30648; break;
2111 case 30654: finalSpelId
= 30652; break;
2112 case 30099: finalSpelId
= 30100; break;
2113 case 30102: finalSpelId
= 30103; break;
2114 case 30105: finalSpelId
= 30104; break;
2118 caster
->CastSpell(m_target
,finalSpelId
,true,NULL
,this);
2124 case 2584: // Waiting to Resurrect
2126 // Waiting to resurrect spell cancel, we must remove player from resurrect queue
2127 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2128 if(BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround())
2129 bg
->RemovePlayerFromResurrectQueue(m_target
->GetGUID());
2132 case 45934: // Dark Fiend
2134 // Kill target if dispelled
2135 if (m_removeMode
==AURA_REMOVE_BY_DISPEL
)
2136 m_target
->DealDamage(m_target
, m_target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
2139 case 46308: // Burning Winds
2141 // casted only at creatures at spawn
2142 m_target
->CastSpell(m_target
,47287,true,NULL
,this);
2147 if (caster
&& m_removeMode
== AURA_REMOVE_BY_DEATH
)
2149 // Stop caster Arcane Missle chanelling on death
2150 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_MAGE
&&
2151 m_spellProto
->SpellFamilyFlags
&0x0000000000000800LL
)
2153 caster
->InterruptSpell(CURRENT_CHANNELED_SPELL
);
2156 // Stop caster Penance chanelling on death
2157 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_PRIEST
&&
2158 m_spellProto
->SpellFamilyFlags2
& 0x00000080)
2160 caster
->InterruptSpell(CURRENT_CHANNELED_SPELL
);
2167 // AT APPLY & REMOVE
2169 switch(m_spellProto
->SpellFamilyName
)
2171 case SPELLFAMILY_GENERIC
:
2174 if( GetId()==24658 )
2176 uint32 spellId
= 24659;
2179 const SpellEntry
*spell
= sSpellStore
.LookupEntry(spellId
);
2182 for (int i
=0; i
< spell
->StackAmount
; ++i
)
2183 caster
->CastSpell(m_target
, spell
->Id
, true, NULL
, NULL
, GetCasterGUID());
2186 m_target
->RemoveAurasDueToSpell(spellId
);
2189 // Restless Strength
2190 if( GetId()==24661 )
2192 uint32 spellId
= 24662;
2195 const SpellEntry
*spell
= sSpellStore
.LookupEntry(spellId
);
2198 for (int i
=0; i
< spell
->StackAmount
; ++i
)
2199 caster
->CastSpell(m_target
, spell
->Id
, true, NULL
, NULL
, GetCasterGUID());
2202 m_target
->RemoveAurasDueToSpell(spellId
);
2205 //Summon Fire Elemental
2206 if (GetId() == 40133 && caster
)
2208 Unit
*owner
= caster
->GetOwner();
2209 if (owner
&& owner
->GetTypeId() == TYPEID_PLAYER
)
2212 owner
->CastSpell(owner
,8985,true);
2214 ((Player
*)owner
)->RemovePet(NULL
, PET_SAVE_NOT_IN_SLOT
, true);
2219 //Summon Earth Elemental
2220 if (GetId() == 40132 && caster
)
2222 Unit
*owner
= caster
->GetOwner();
2223 if (owner
&& owner
->GetTypeId() == TYPEID_PLAYER
)
2226 owner
->CastSpell(owner
,19704,true);
2228 ((Player
*)owner
)->RemovePet(NULL
, PET_SAVE_NOT_IN_SLOT
, true);
2234 case SPELLFAMILY_MAGE
:
2238 case SPELLFAMILY_PRIEST
:
2240 // Pain and Suffering
2241 if( m_spellProto
->SpellIconID
== 2874 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2245 // Reduce backfire damage (dot damage) from Shadow Word: Death
2246 SpellModifier
*mod
= new SpellModifier
;
2247 mod
->op
= SPELLMOD_DOT
;
2248 mod
->value
= m_modifier
.m_amount
;
2249 mod
->type
= SPELLMOD_PCT
;
2250 mod
->spellId
= GetId();
2251 mod
->mask
= 0x0000000200000000LL
;
2255 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2260 case SPELLFAMILY_DRUID
:
2264 case 34246: // Idol of the Emerald Queen
2266 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
2271 SpellModifier
*mod
= new SpellModifier
;
2272 mod
->op
= SPELLMOD_DOT
;
2273 mod
->value
= m_modifier
.m_amount
/7;
2274 mod
->type
= SPELLMOD_FLAT
;
2275 mod
->spellId
= GetId();
2276 mod
->mask
= 0x001000000000LL
;
2282 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2285 case 61336: // Survival Instincts
2289 if (!m_target
->IsInFeralForm())
2292 int32 bp0
= int32(m_target
->GetMaxHealth() * m_modifier
.m_amount
/ 100);
2293 m_target
->CastCustomSpell(m_target
, 50322, &bp0
, NULL
, NULL
, true);
2296 m_target
-> RemoveAurasDueToSpell(50322);
2302 if ( GetSpellProto()->SpellFamilyFlags
& 0x1000000000LL
)
2307 // prevent double apply bonuses
2308 if(m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading())
2309 m_modifier
.m_amount
= caster
->SpellHealingBonus(m_target
, GetSpellProto(), m_modifier
.m_amount
, SPELL_DIRECT_DAMAGE
);
2313 // Final heal only on dispelled or duration end
2314 if ( !(GetAuraDuration() <= 0 || m_removeMode
==AURA_REMOVE_BY_DISPEL
) )
2317 // have a look if there is still some other Lifebloom dummy aura
2318 Unit::AuraList auras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
2319 for(Unit::AuraList::iterator itr
= auras
.begin(); itr
!=auras
.end(); ++itr
)
2320 if((*itr
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_DRUID
&&
2321 (*itr
)->GetSpellProto()->SpellFamilyFlags
& 0x1000000000LL
)
2325 if(m_target
->IsInWorld() && m_stackAmount
> 0)
2327 int32 amount
= m_modifier
.m_amount
/ m_stackAmount
;
2328 m_target
->CastCustomSpell(m_target
,33778,&amount
,NULL
,NULL
,true,NULL
,this,GetCasterGUID());
2334 // Predatory Strikes
2335 if(m_target
->GetTypeId()==TYPEID_PLAYER
&& GetSpellProto()->SpellIconID
== 1563)
2337 ((Player
*)m_target
)->UpdateAttackPowerAndDamage();
2342 case SPELLFAMILY_HUNTER
:
2344 // Improved Aspect of the Viper
2345 if( GetId()==38390 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2349 // + effect value for Aspect of the Viper
2350 SpellModifier
*mod
= new SpellModifier
;
2351 mod
->op
= SPELLMOD_EFFECT1
;
2352 mod
->value
= m_modifier
.m_amount
;
2353 mod
->type
= SPELLMOD_FLAT
;
2354 mod
->spellId
= GetId();
2355 mod
->mask
= 0x4000000000000LL
;
2361 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2366 case SPELLFAMILY_SHAMAN
:
2368 // Improved Weapon Totems
2369 if( GetSpellProto()->SpellIconID
== 57 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2373 SpellModifier
*mod
= new SpellModifier
;
2374 mod
->op
= SPELLMOD_EFFECT1
;
2375 mod
->value
= m_modifier
.m_amount
;
2376 mod
->type
= SPELLMOD_PCT
;
2377 mod
->spellId
= GetId();
2381 mod
->mask
= 0x00200000000LL
; // Windfury Totem
2385 mod
->mask
= 0x00400000000LL
; // Flametongue Totem
2393 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2401 if(PetAura
const* petSpell
= spellmgr
.GetPetAura(GetId()))
2404 m_target
->AddPetAura(petSpell
);
2406 m_target
->RemovePetAura(petSpell
);
2410 if(GetEffIndex()==0 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2412 SpellAreaForAreaMapBounds saBounds
= spellmgr
.GetSpellAreaForAuraMapBounds(GetId());
2413 if(saBounds
.first
!= saBounds
.second
)
2416 m_target
->GetZoneAndAreaId(zone
,area
);
2418 for(SpellAreaForAreaMap::const_iterator itr
= saBounds
.first
; itr
!= saBounds
.second
; ++itr
)
2420 // some auras remove at aura remove
2421 if(!itr
->second
->IsFitToRequirements((Player
*)m_target
,zone
,area
))
2422 m_target
->RemoveAurasDueToSpell(itr
->second
->spellId
);
2423 // some auras applied at aura apply
2424 else if(itr
->second
->autocast
)
2426 if( !m_target
->HasAura(itr
->second
->spellId
,0) )
2427 m_target
->CastSpell(m_target
,itr
->second
->spellId
,true);
2434 void Aura::HandleAuraMounted(bool apply
, bool Real
)
2436 // only at real add/remove aura
2442 CreatureInfo
const* ci
= objmgr
.GetCreatureTemplate(m_modifier
.m_miscvalue
);
2445 sLog
.outErrorDb("AuraMounted: `creature_template`='%u' not found in database (only need it modelid)", m_modifier
.m_miscvalue
);
2450 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
2451 team
= ((Player
*)m_target
)->GetTeam();
2453 uint32 display_id
= objmgr
.ChooseDisplayId(team
,ci
);
2454 CreatureModelInfo
const *minfo
= objmgr
.GetCreatureModelRandomGender(display_id
);
2456 display_id
= minfo
->modelid
;
2458 m_target
->Mount(display_id
);
2462 m_target
->Unmount();
2466 void Aura::HandleAuraWaterWalk(bool apply
, bool Real
)
2468 // only at real add/remove aura
2474 data
.Initialize(SMSG_MOVE_WATER_WALK
, 8+4);
2476 data
.Initialize(SMSG_MOVE_LAND_WALK
, 8+4);
2477 data
.append(m_target
->GetPackGUID());
2479 m_target
->SendMessageToSet(&data
,true);
2482 void Aura::HandleAuraFeatherFall(bool apply
, bool Real
)
2484 // only at real add/remove aura
2490 data
.Initialize(SMSG_MOVE_FEATHER_FALL
, 8+4);
2492 data
.Initialize(SMSG_MOVE_NORMAL_FALL
, 8+4);
2493 data
.append(m_target
->GetPackGUID());
2495 m_target
->SendMessageToSet(&data
,true);
2498 void Aura::HandleAuraHover(bool apply
, bool Real
)
2500 // only at real add/remove aura
2506 data
.Initialize(SMSG_MOVE_SET_HOVER
, 8+4);
2508 data
.Initialize(SMSG_MOVE_UNSET_HOVER
, 8+4);
2509 data
.append(m_target
->GetPackGUID());
2511 m_target
->SendMessageToSet(&data
,true);
2514 void Aura::HandleWaterBreathing(bool apply
, bool Real
)
2516 // update timers in client
2517 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
2518 ((Player
*)m_target
)->UpdateMirrorTimers();
2521 void Aura::HandleAuraModShapeshift(bool apply
, bool Real
)
2527 Powers PowerType
= POWER_MANA
;
2528 ShapeshiftForm form
= ShapeshiftForm(m_modifier
.m_miscvalue
);
2532 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2536 PowerType
= POWER_ENERGY
;
2542 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2548 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2552 PowerType
= POWER_RAGE
;
2555 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2559 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2563 PowerType
= POWER_RAGE
;
2565 case FORM_CREATUREBEAR
:
2568 case FORM_GHOSTWOLF
:
2572 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2578 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2583 case FORM_FLIGHT_EPIC
:
2584 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2589 case FORM_METAMORPHOSIS
:
2599 case FORM_BATTLESTANCE
:
2600 case FORM_BERSERKERSTANCE
:
2601 case FORM_DEFENSIVESTANCE
:
2602 PowerType
= POWER_RAGE
;
2604 case FORM_SPIRITOFREDEMPTION
:
2608 sLog
.outError("Auras: Unknown Shapeshift Type: %u", m_modifier
.m_miscvalue
);
2611 // remove polymorph before changing display id to keep new display id
2620 case FORM_FLIGHT_EPIC
:
2623 // remove movement affects
2624 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT
);
2625 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED
);
2627 // and polymorphic affects
2628 if(m_target
->IsPolymorphed())
2629 m_target
->RemoveAurasDueToSpell(m_target
->getTransForm());
2637 // remove other shapeshift before applying a new one
2638 if(m_target
->m_ShapeShiftFormSpellId
)
2639 m_target
->RemoveAurasDueToSpell(m_target
->m_ShapeShiftFormSpellId
,this);
2641 m_target
->SetByteValue(UNIT_FIELD_BYTES_2
, 3, form
);
2644 m_target
->SetDisplayId(modelid
);
2646 if(PowerType
!= POWER_MANA
)
2648 // reset power to default values only at power change
2649 if(m_target
->getPowerType()!=PowerType
)
2650 m_target
->setPowerType(PowerType
);
2658 // get furor proc chance
2659 uint32 FurorChance
= 0;
2660 Unit::AuraList
const& mDummy
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
2661 for(Unit::AuraList::const_iterator i
= mDummy
.begin(); i
!= mDummy
.end(); ++i
)
2663 if ((*i
)->GetSpellProto()->SpellIconID
== 238)
2665 FurorChance
= (*i
)->GetModifier()->m_amount
;
2670 if (m_modifier
.m_miscvalue
== FORM_CAT
)
2672 m_target
->SetPower(POWER_ENERGY
,0);
2673 if(urand(1,100) <= FurorChance
)
2674 m_target
->CastSpell(m_target
,17099,true,NULL
,this);
2678 m_target
->SetPower(POWER_RAGE
,0);
2679 if(urand(1,100) <= FurorChance
)
2680 m_target
->CastSpell(m_target
,17057,true,NULL
,this);
2684 case FORM_BATTLESTANCE
:
2685 case FORM_DEFENSIVESTANCE
:
2686 case FORM_BERSERKERSTANCE
:
2688 uint32 Rage_val
= 0;
2689 // Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch)
2690 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2692 PlayerSpellMap
const& sp_list
= ((Player
*)m_target
)->GetSpellMap();
2693 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
2695 if(itr
->second
->state
== PLAYERSPELL_REMOVED
) continue;
2696 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
2697 if (spellInfo
&& spellInfo
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& spellInfo
->SpellIconID
== 139)
2698 Rage_val
+= m_target
->CalculateSpellDamage(spellInfo
,0,spellInfo
->EffectBasePoints
[0],m_target
) * 10;
2702 if (m_target
->GetPower(POWER_RAGE
) > Rage_val
)
2703 m_target
->SetPower(POWER_RAGE
,Rage_val
);
2711 m_target
->m_ShapeShiftFormSpellId
= GetId();
2712 m_target
->m_form
= form
;
2717 m_target
->SetDisplayId(m_target
->GetNativeDisplayId());
2718 m_target
->SetByteValue(UNIT_FIELD_BYTES_2
, 3, FORM_NONE
);
2719 if(m_target
->getClass() == CLASS_DRUID
)
2720 m_target
->setPowerType(POWER_MANA
);
2721 m_target
->m_ShapeShiftFormSpellId
= 0;
2722 m_target
->m_form
= FORM_NONE
;
2726 // Nordrassil Harness - bonus
2731 if(Aura
* dummy
= m_target
->GetDummyAura(37315) )
2732 m_target
->CastSpell(m_target
,37316,true,NULL
,dummy
);
2735 // Nordrassil Regalia - bonus
2738 if(Aura
* dummy
= m_target
->GetDummyAura(37324) )
2739 m_target
->CastSpell(m_target
,37325,true,NULL
,dummy
);
2745 // adding/removing linked auras
2746 // add/remove the shapeshift aura's boosts
2747 HandleShapeshiftBoosts(apply
);
2749 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
2750 ((Player
*)m_target
)->InitDataForForm();
2753 void Aura::HandleAuraTransform(bool apply
, bool Real
)
2757 // special case (spell specific functionality)
2758 if(m_modifier
.m_miscvalue
==0)
2760 // player applied only
2761 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
2769 uint32 orb_model
= m_target
->GetNativeDisplayId();
2773 case 1479: m_target
->SetDisplayId(10134); break;
2775 case 1478: m_target
->SetDisplayId(10135); break;
2777 case 59: m_target
->SetDisplayId(10136); break;
2779 case 49: m_target
->SetDisplayId(10137); break;
2781 case 50: m_target
->SetDisplayId(10138); break;
2783 case 51: m_target
->SetDisplayId(10139); break;
2785 case 52: m_target
->SetDisplayId(10140); break;
2787 case 53: m_target
->SetDisplayId(10141); break;
2789 case 54: m_target
->SetDisplayId(10142); break;
2791 case 55: m_target
->SetDisplayId(10143); break;
2793 case 56: m_target
->SetDisplayId(10144); break;
2795 case 58: m_target
->SetDisplayId(10145); break;
2797 case 57: m_target
->SetDisplayId(10146); break;
2799 case 60: m_target
->SetDisplayId(10147); break;
2801 case 1563: m_target
->SetDisplayId(10148); break;
2803 case 1564: m_target
->SetDisplayId(10149); break;
2805 case 15475: m_target
->SetDisplayId(17830); break;
2807 case 15476: m_target
->SetDisplayId(17829); break;
2809 case 16126: m_target
->SetDisplayId(17828); break;
2811 case 16125: m_target
->SetDisplayId(17827); break;
2817 case 42365: m_target
->SetDisplayId(21723); break;
2823 CreatureInfo
const * ci
= objmgr
.GetCreatureTemplate(m_modifier
.m_miscvalue
);
2827 m_target
->SetDisplayId(16358);
2828 sLog
.outError("Auras: unknown creature id = %d (only need its modelid) Form Spell Aura Transform in Spell ID = %d", m_modifier
.m_miscvalue
, GetId());
2832 // Will use the default model here
2833 m_target
->SetDisplayId(ci
->DisplayID_A
);
2835 // Dragonmaw Illusion (set mount model also)
2836 if(GetId()==42016 && m_target
->GetMountID() && !m_target
->GetAurasByType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
).empty())
2837 m_target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
,16314);
2839 m_target
->setTransForm(GetId());
2843 if( Real
&& m_target
->GetTypeId() == TYPEID_PLAYER
&& m_target
->IsPolymorphed())
2845 // for players, start regeneration after 1s (in polymorph fast regeneration case)
2846 // only if caster is Player (after patch 2.4.2)
2847 if(IS_PLAYER_GUID(GetCasterGUID()) )
2848 ((Player
*)m_target
)->setRegenTimer(1*IN_MILISECONDS
);
2850 //dismount polymorphed target (after patch 2.4.2)
2851 if (m_target
->IsMounted())
2852 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
2857 Unit::AuraList
const& otherTransforms
= m_target
->GetAurasByType(SPELL_AURA_TRANSFORM
);
2858 if(otherTransforms
.empty())
2860 m_target
->SetDisplayId(m_target
->GetNativeDisplayId());
2861 m_target
->setTransForm(0);
2865 // look for other transform auras
2866 Aura
* handledAura
= *otherTransforms
.begin();
2867 for(Unit::AuraList::const_iterator i
= otherTransforms
.begin();i
!= otherTransforms
.end(); ++i
)
2869 // negative auras are preferred
2870 if(!IsPositiveSpell((*i
)->GetSpellProto()->Id
))
2876 handledAura
->ApplyModifier(true);
2879 // Dragonmaw Illusion (restore mount model)
2880 if(GetId()==42016 && m_target
->GetMountID()==16314)
2882 if(!m_target
->GetAurasByType(SPELL_AURA_MOUNTED
).empty())
2884 uint32 cr_id
= m_target
->GetAurasByType(SPELL_AURA_MOUNTED
).front()->GetModifier()->m_miscvalue
;
2885 if(CreatureInfo
const* ci
= objmgr
.GetCreatureTemplate(cr_id
))
2888 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
2889 team
= ((Player
*)m_target
)->GetTeam();
2891 uint32 display_id
= objmgr
.ChooseDisplayId(team
,ci
);
2892 CreatureModelInfo
const *minfo
= objmgr
.GetCreatureModelRandomGender(display_id
);
2894 display_id
= minfo
->modelid
;
2896 m_target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
,display_id
);
2903 void Aura::HandleForceReaction(bool apply
, bool Real
)
2905 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
2911 Player
* player
= (Player
*)m_target
;
2913 uint32 faction_id
= m_modifier
.m_miscvalue
;
2914 uint32 faction_rank
= m_modifier
.m_amount
;
2917 player
->m_forcedReactions
[faction_id
] = ReputationRank(faction_rank
);
2919 player
->m_forcedReactions
.erase(faction_id
);
2922 data
.Initialize(SMSG_SET_FORCED_REACTIONS
, 4+player
->m_forcedReactions
.size()*(4+4));
2923 data
<< uint32(player
->m_forcedReactions
.size());
2924 for(ForcedReactions::const_iterator itr
= player
->m_forcedReactions
.begin(); itr
!= player
->m_forcedReactions
.end(); ++itr
)
2926 data
<< uint32(itr
->first
); // faction_id (Faction.dbc)
2927 data
<< uint32(itr
->second
); // reputation rank
2929 player
->SendDirectMessage(&data
);
2932 void Aura::HandleAuraModSkill(bool apply
, bool Real
)
2934 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
2937 uint32 prot
=GetSpellProto()->EffectMiscValue
[m_effIndex
];
2938 int32 points
= GetModifier()->m_amount
;
2940 ((Player
*)m_target
)->ModifySkillBonus(prot
,(apply
? points
: -points
),m_modifier
.m_auraname
==SPELL_AURA_MOD_SKILL_TALENT
);
2941 if(prot
== SKILL_DEFENSE
)
2942 ((Player
*)m_target
)->UpdateDefenseBonusesMod();
2945 void Aura::HandleChannelDeathItem(bool apply
, bool Real
)
2949 Unit
* caster
= GetCaster();
2950 Unit
* victim
= GetTarget();
2951 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
|| !victim
|| m_removeMode
!=AURA_REMOVE_BY_DEATH
)
2954 if (m_modifier
.m_amount
<= 0)
2957 SpellEntry
const *spellInfo
= GetSpellProto();
2958 if(spellInfo
->EffectItemType
[m_effIndex
] == 0)
2961 // Soul Shard only from non-grey units
2962 if( spellInfo
->EffectItemType
[m_effIndex
] == 6265 &&
2963 (victim
->getLevel() <= MaNGOS::XP::GetGrayLevel(caster
->getLevel()) ||
2964 victim
->GetTypeId()==TYPEID_UNIT
&& !((Player
*)caster
)->isAllowedToLoot((Creature
*)victim
)) )
2967 uint32 noSpaceForCount
= 0;
2968 uint32 count
= m_modifier
.m_amount
;
2970 ItemPosCountVec dest
;
2971 uint8 msg
= ((Player
*)caster
)->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, spellInfo
->EffectItemType
[m_effIndex
], count
, &noSpaceForCount
);
2972 if( msg
!= EQUIP_ERR_OK
)
2974 count
-=noSpaceForCount
;
2975 ((Player
*)caster
)->SendEquipError( msg
, NULL
, NULL
);
2980 Item
* newitem
= ((Player
*)caster
)->StoreNewItem(dest
, spellInfo
->EffectItemType
[m_effIndex
], true);
2981 ((Player
*)caster
)->SendNewItem(newitem
, count
, true, false);
2985 void Aura::HandleBindSight(bool apply
, bool Real
)
2987 Unit
* caster
= GetCaster();
2988 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
2991 ((Player
*)caster
)->SetFarSightGUID(apply
? m_target
->GetGUID() : 0);
2994 void Aura::HandleFarSight(bool apply
, bool Real
)
2996 Unit
* caster
= GetCaster();
2997 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3000 ((Player
*)caster
)->SetFarSightGUID(apply
? m_target
->GetGUID() : 0);
3003 void Aura::HandleAuraTrackCreatures(bool apply
, bool Real
)
3005 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
3009 m_target
->RemoveNoStackAurasDueToAura(this);
3010 m_target
->SetUInt32Value(PLAYER_TRACK_CREATURES
, apply
? ((uint32
)1)<<(m_modifier
.m_miscvalue
-1) : 0 );
3013 void Aura::HandleAuraTrackResources(bool apply
, bool Real
)
3015 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
3019 m_target
->RemoveNoStackAurasDueToAura(this);
3020 m_target
->SetUInt32Value(PLAYER_TRACK_RESOURCES
, apply
? ((uint32
)1)<<(m_modifier
.m_miscvalue
-1): 0 );
3023 void Aura::HandleAuraTrackStealthed(bool apply
, bool Real
)
3025 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
3029 m_target
->RemoveNoStackAurasDueToAura(this);
3031 m_target
->ApplyModFlag(PLAYER_FIELD_BYTES
,PLAYER_FIELD_BYTE_TRACK_STEALTHED
,apply
);
3034 void Aura::HandleAuraModScale(bool apply
, bool Real
)
3036 m_target
->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X
,m_modifier
.m_amount
,apply
);
3039 void Aura::HandleModPossess(bool apply
, bool Real
)
3044 if(m_target
->getLevel() > m_modifier
.m_amount
)
3047 // not possess yourself
3048 if(GetCasterGUID() == m_target
->GetGUID())
3051 Unit
* caster
= GetCaster();
3057 m_target
->SetCharmerGUID(GetCasterGUID());
3058 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,caster
->getFaction());
3059 caster
->SetCharm(m_target
);
3061 m_target
->CombatStop();
3062 m_target
->DeleteThreatList();
3063 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3065 m_target
->StopMoving();
3066 m_target
->GetMotionMaster()->Clear();
3067 m_target
->GetMotionMaster()->MoveIdle();
3068 CharmInfo
*charmInfo
= ((Creature
*)m_target
)->InitCharmInfo(m_target
);
3069 charmInfo
->InitPossessCreateSpells();
3072 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3074 ((Player
*)caster
)->PossessSpellInitialize();
3079 m_target
->SetCharmerGUID(0);
3081 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3082 ((Player
*)m_target
)->setFactionForRace(m_target
->getRace());
3083 else if(m_target
->GetTypeId() == TYPEID_UNIT
)
3085 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
3086 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,cinfo
->faction_A
);
3089 caster
->SetCharm(0);
3091 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3093 WorldPacket
data(SMSG_PET_SPELLS
, 8);
3096 ((Player
*)caster
)->GetSession()->SendPacket(&data
);
3098 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3100 ((Creature
*)m_target
)->AIM_Initialize();
3102 if (((Creature
*)m_target
)->AI())
3103 ((Creature
*)m_target
)->AI()->AttackStart(caster
);
3106 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3107 ((Player
*)caster
)->SetFarSightGUID(apply
? m_target
->GetGUID() : 0);
3110 void Aura::HandleModPossessPet(bool apply
, bool Real
)
3115 Unit
* caster
= GetCaster();
3116 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3119 Pet
*pet
= caster
->GetPet();
3120 if(!pet
|| pet
!= m_target
)
3124 pet
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_24
);
3126 pet
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_24
);
3128 ((Player
*)caster
)->SetFarSightGUID(apply
? pet
->GetGUID() : 0);
3129 ((Player
*)caster
)->SetCharm(apply
? pet
: NULL
);
3130 ((Player
*)caster
)->SetClientControl(pet
, apply
? 1 : 0);
3135 pet
->GetMotionMaster()->Clear();
3136 pet
->GetMotionMaster()->MoveIdle();
3141 pet
->GetMotionMaster()->MoveFollow(caster
, PET_FOLLOW_DIST
, PET_FOLLOW_ANGLE
);
3142 pet
->SetUnitMovementFlags(MOVEMENTFLAG_NONE
);
3146 void Aura::HandleAuraModPetTalentsPoints(bool Apply
, bool Real
)
3151 // Recalculate pet tlaent points
3152 if (Pet
*pet
=m_target
->GetPet())
3153 pet
->InitTalentForLevel();
3156 void Aura::HandleModCharm(bool apply
, bool Real
)
3161 // not charm yourself
3162 if(GetCasterGUID() == m_target
->GetGUID())
3165 Unit
* caster
= GetCaster();
3169 if(int32(m_target
->getLevel()) <= m_modifier
.m_amount
)
3173 m_target
->SetCharmerGUID(GetCasterGUID());
3174 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,caster
->getFaction());
3175 m_target
->CastStop(m_target
==caster
? GetId() : 0);
3176 caster
->SetCharm(m_target
);
3178 m_target
->CombatStop();
3179 m_target
->DeleteThreatList();
3181 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3183 ((Creature
*)m_target
)->AIM_Initialize();
3184 CharmInfo
*charmInfo
= ((Creature
*)m_target
)->InitCharmInfo(m_target
);
3185 charmInfo
->InitCharmCreateSpells();
3186 charmInfo
->SetReactState( REACT_DEFENSIVE
);
3188 if(caster
->GetTypeId() == TYPEID_PLAYER
&& caster
->getClass() == CLASS_WARLOCK
)
3190 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
3191 if(cinfo
&& cinfo
->type
== CREATURE_TYPE_DEMON
)
3193 //to prevent client crash
3194 m_target
->SetFlag(UNIT_FIELD_BYTES_0
, 2048);
3195 //just to enable stat window
3196 charmInfo
->SetPetNumber(objmgr
.GeneratePetNumber(), true);
3197 //if charmed two demons the same session, the 2nd gets the 1st one's name
3198 m_target
->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP
, time(NULL
));
3203 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3205 ((Player
*)caster
)->CharmSpellInitialize();
3210 m_target
->SetCharmerGUID(0);
3212 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3213 ((Player
*)m_target
)->setFactionForRace(m_target
->getRace());
3216 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
3219 if(((Creature
*)m_target
)->isPet())
3221 if(Unit
* owner
= m_target
->GetOwner())
3222 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,owner
->getFaction());
3224 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,cinfo
->faction_A
);
3226 else if(cinfo
) // normal creature
3227 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,cinfo
->faction_A
);
3229 // restore UNIT_FIELD_BYTES_0
3230 if(cinfo
&& caster
->GetTypeId() == TYPEID_PLAYER
&& caster
->getClass() == CLASS_WARLOCK
&& cinfo
->type
== CREATURE_TYPE_DEMON
)
3232 CreatureDataAddon
const *cainfo
= ((Creature
*)m_target
)->GetCreatureAddon();
3233 if(cainfo
&& cainfo
->bytes0
!= 0)
3234 m_target
->SetUInt32Value(UNIT_FIELD_BYTES_0
, cainfo
->bytes0
);
3236 m_target
->RemoveFlag(UNIT_FIELD_BYTES_0
, 2048);
3238 if(m_target
->GetCharmInfo())
3239 m_target
->GetCharmInfo()->SetPetNumber(0, true);
3241 sLog
.outError("Aura::HandleModCharm: target="I64FMTD
" with typeid=%d has a charm aura but no charm info!", m_target
->GetGUID(), m_target
->GetTypeId());
3245 caster
->SetCharm(0);
3247 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3249 WorldPacket
data(SMSG_PET_SPELLS
, 8);
3252 ((Player
*)caster
)->GetSession()->SendPacket(&data
);
3254 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3256 ((Creature
*)m_target
)->AIM_Initialize();
3257 if (((Creature
*)m_target
)->AI())
3258 ((Creature
*)m_target
)->AI()->AttackStart(caster
);
3264 void Aura::HandleModConfuse(bool apply
, bool Real
)
3269 m_target
->SetConfused(apply
, GetCasterGUID(), GetId());
3272 void Aura::HandleModFear(bool apply
, bool Real
)
3277 m_target
->SetFeared(apply
, GetCasterGUID(), GetId());
3280 void Aura::HandleFeignDeath(bool apply
, bool Real
)
3285 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
3291 WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9);
3292 data<<m_target->GetGUID();
3294 m_target->SendMessageToSet(&data,true);
3297 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_29
);
3299 m_target
->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FEIGN_DEATH
);
3301 m_target
->SetFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_DEAD
);
3303 m_target
->addUnitState(UNIT_STAT_DIED
);
3304 m_target
->CombatStop();
3306 // prevent interrupt message
3307 if(m_caster_guid
==m_target
->GetGUID() && m_target
->m_currentSpells
[CURRENT_GENERIC_SPELL
])
3308 m_target
->m_currentSpells
[CURRENT_GENERIC_SPELL
]->finish();
3309 m_target
->InterruptNonMeleeSpells(true);
3310 m_target
->getHostilRefManager().deleteReferences();
3315 WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9);
3316 data<<m_target->GetGUID();
3318 m_target->SendMessageToSet(&data,true);
3321 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_29
);
3323 m_target
->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FEIGN_DEATH
);
3325 m_target
->RemoveFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_DEAD
);
3327 m_target
->clearUnitState(UNIT_STAT_DIED
);
3331 void Aura::HandleAuraModDisarm(bool apply
, bool Real
)
3336 if(!apply
&& m_target
->HasAuraType(SPELL_AURA_MOD_DISARM
))
3339 // not sure for it's correctness
3341 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_DISARMED
);
3343 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_DISARMED
);
3345 // only at real add/remove aura
3346 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
3349 // main-hand attack speed already set to special value for feral form already and don't must change and reset at remove.
3350 if (m_target
->IsInFeralForm())
3354 m_target
->SetAttackTime(BASE_ATTACK
,BASE_ATTACK_TIME
);
3356 ((Player
*)m_target
)->SetRegularAttackTime();
3358 m_target
->UpdateDamagePhysical(BASE_ATTACK
);
3361 void Aura::HandleAuraModStun(bool apply
, bool Real
)
3368 // Frost stun aura -> freeze/unfreeze target
3369 if (GetSpellSchoolMask(m_spellProto
) & SPELL_SCHOOL_MASK_FROST
)
3370 m_target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
3372 m_target
->addUnitState(UNIT_STAT_STUNNED
);
3373 m_target
->SetUInt64Value(UNIT_FIELD_TARGET
, 0);
3375 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
3376 m_target
->CastStop(m_target
->GetGUID() == GetCasterGUID() ? GetId() : 0);
3378 // Creature specific
3379 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
3380 ((Creature
*)m_target
)->StopMoving();
3382 m_target
->SetUnitMovementFlags(0); //Clear movement flags
3384 WorldPacket
data(SMSG_FORCE_MOVE_ROOT
, 8);
3386 data
.append(m_target
->GetPackGUID());
3388 m_target
->SendMessageToSet(&data
,true);
3392 // Frost stun aura -> freeze/unfreeze target
3393 if (GetSpellSchoolMask(m_spellProto
) & SPELL_SCHOOL_MASK_FROST
)
3395 bool found_another
= false;
3396 for(AuraType
const* itr
= &frozenAuraTypes
[0]; *itr
!= SPELL_AURA_NONE
; ++itr
)
3398 Unit::AuraList
const& auras
= m_target
->GetAurasByType(*itr
);
3399 for(Unit::AuraList::const_iterator i
= auras
.begin(); i
!= auras
.end(); ++i
)
3401 if( GetSpellSchoolMask((*i
)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST
)
3403 found_another
= true;
3412 m_target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
3415 // Real remove called after current aura remove from lists, check if other similar auras active
3416 if(m_target
->HasAuraType(SPELL_AURA_MOD_STUN
))
3419 m_target
->clearUnitState(UNIT_STAT_STUNNED
);
3420 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
3422 if(!m_target
->hasUnitState(UNIT_STAT_ROOT
)) // prevent allow move if have also root effect
3424 if(m_target
->getVictim() && m_target
->isAlive())
3425 m_target
->SetUInt64Value(UNIT_FIELD_TARGET
,m_target
->getVictim()->GetGUID() );
3427 WorldPacket
data(SMSG_FORCE_MOVE_UNROOT
, 8+4);
3428 data
.append(m_target
->GetPackGUID());
3430 m_target
->SendMessageToSet(&data
,true);
3434 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_HUNTER
&& m_spellProto
->SpellFamilyFlags
& 0x0000100000000000LL
)
3436 Unit
* caster
= GetCaster();
3437 if( !caster
|| caster
->GetTypeId()!=TYPEID_PLAYER
)
3440 uint32 spell_id
= 0;
3444 case 19386: spell_id
= 24131; break;
3445 case 24132: spell_id
= 24134; break;
3446 case 24133: spell_id
= 24135; break;
3447 case 27068: spell_id
= 27069; break;
3448 case 49011: spell_id
= 49009; break;
3449 case 49012: spell_id
= 49010; break;
3451 sLog
.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?",GetId());
3455 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell_id
);
3460 caster
->CastSpell(m_target
,spellInfo
,true,NULL
,this);
3466 void Aura::HandleModStealth(bool apply
, bool Real
)
3470 // drop flag at stealth in bg
3471 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
&& ((Player
*)m_target
)->InBattleGround())
3472 if(BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround())
3473 bg
->EventPlayerDroppedFlag((Player
*)m_target
);
3475 // only at real aura add
3478 m_target
->SetStandFlags(UNIT_STAND_FLAGS_CREEP
);
3479 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
3480 m_target
->SetFlag(PLAYER_FIELD_BYTES2
, 0x2000);
3482 // apply only if not in GM invisibility (and overwrite invisibility state)
3483 if(m_target
->GetVisibility()!=VISIBILITY_OFF
)
3485 m_target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
3486 m_target
->SetVisibility(VISIBILITY_GROUP_STEALTH
);
3492 // only at real aura remove
3495 // if last SPELL_AURA_MOD_STEALTH and no GM invisibility
3496 if(!m_target
->HasAuraType(SPELL_AURA_MOD_STEALTH
) && m_target
->GetVisibility()!=VISIBILITY_OFF
)
3498 m_target
->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP
);
3499 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
3500 m_target
->RemoveFlag(PLAYER_FIELD_BYTES2
, 0x2000);
3502 // restore invisibility if any
3503 if(m_target
->HasAuraType(SPELL_AURA_MOD_INVISIBILITY
))
3505 m_target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
3506 m_target
->SetVisibility(VISIBILITY_GROUP_INVISIBILITY
);
3509 m_target
->SetVisibility(VISIBILITY_ON
);
3514 // Master of Subtlety
3515 Unit::AuraList
const& mDummyAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
3516 for(Unit::AuraList::const_iterator i
= mDummyAuras
.begin();i
!= mDummyAuras
.end(); ++i
)
3518 if ((*i
)->GetSpellProto()->SpellIconID
== 2114)
3522 int32 bp
= (*i
)->GetModifier()->m_amount
;
3523 m_target
->CastCustomSpell(m_target
,31665,&bp
,NULL
,NULL
,true);
3526 m_target
->CastSpell(m_target
,31666,true);
3532 void Aura::HandleInvisibility(bool apply
, bool Real
)
3536 m_target
->m_invisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3538 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
3540 // apply glow vision
3541 m_target
->SetFlag(PLAYER_FIELD_BYTES2
,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
);
3543 // drop flag at invisible in bg
3544 if(((Player
*)m_target
)->InBattleGround())
3545 if(BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround())
3546 bg
->EventPlayerDroppedFlag((Player
*)m_target
);
3549 // apply only if not in GM invisibility and not stealth
3550 if(m_target
->GetVisibility()==VISIBILITY_ON
)
3552 // Aura not added yet but visibility code expect temporary add aura
3553 m_target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
3554 m_target
->SetVisibility(VISIBILITY_GROUP_INVISIBILITY
);
3559 // recalculate value at modifier remove (current aura already removed)
3560 m_target
->m_invisibilityMask
= 0;
3561 Unit::AuraList
const& auras
= m_target
->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY
);
3562 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
3563 m_target
->m_invisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3565 // only at real aura remove and if not have different invisibility auras.
3566 if(Real
&& m_target
->m_invisibilityMask
==0)
3568 // remove glow vision
3569 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3570 m_target
->RemoveFlag(PLAYER_FIELD_BYTES2
,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
);
3572 // apply only if not in GM invisibility & not stealthed while invisible
3573 if(m_target
->GetVisibility()!=VISIBILITY_OFF
)
3575 // if have stealth aura then already have stealth visibility
3576 if(!m_target
->HasAuraType(SPELL_AURA_MOD_STEALTH
))
3577 m_target
->SetVisibility(VISIBILITY_ON
);
3583 void Aura::HandleInvisibilityDetect(bool apply
, bool Real
)
3587 m_target
->m_detectInvisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3591 // recalculate value at modifier remove (current aura already removed)
3592 m_target
->m_detectInvisibilityMask
= 0;
3593 Unit::AuraList
const& auras
= m_target
->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION
);
3594 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
3595 m_target
->m_detectInvisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3597 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
3598 ObjectAccessor::UpdateVisibilityForPlayer((Player
*)m_target
);
3601 void Aura::HandleAuraModRoot(bool apply
, bool Real
)
3603 // only at real add/remove aura
3607 uint32 apply_stat
= UNIT_STAT_ROOT
;
3610 // Frost root aura -> freeze/unfreeze target
3611 if (GetSpellSchoolMask(m_spellProto
) & SPELL_SCHOOL_MASK_FROST
)
3612 m_target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
3614 m_target
->addUnitState(UNIT_STAT_ROOT
);
3615 m_target
->SetUInt64Value (UNIT_FIELD_TARGET
, 0);
3616 // probably wrong (this add skinable flag)
3617 // TODO: find correct flag
3618 // m_target->SetFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
3620 //Save last orientation
3621 if( m_target
->getVictim() )
3622 m_target
->SetOrientation(m_target
->GetAngle(m_target
->getVictim()));
3624 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3626 WorldPacket
data(SMSG_FORCE_MOVE_ROOT
, 10);
3627 data
.append(m_target
->GetPackGUID());
3629 m_target
->SendMessageToSet(&data
,true);
3631 //Clear unit movement flags
3632 m_target
->SetUnitMovementFlags(0);
3635 ((Creature
*)m_target
)->StopMoving();
3639 // Frost root aura -> freeze/unfreeze target
3640 if (GetSpellSchoolMask(m_spellProto
) & SPELL_SCHOOL_MASK_FROST
)
3642 bool found_another
= false;
3643 for(AuraType
const* itr
= &frozenAuraTypes
[0]; *itr
!= SPELL_AURA_NONE
; ++itr
)
3645 Unit::AuraList
const& auras
= m_target
->GetAurasByType(*itr
);
3646 for(Unit::AuraList::const_iterator i
= auras
.begin(); i
!= auras
.end(); ++i
)
3648 if( GetSpellSchoolMask((*i
)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST
)
3650 found_another
= true;
3659 m_target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
3662 // Real remove called after current aura remove from lists, check if other similar auras active
3663 if(m_target
->HasAuraType(SPELL_AURA_MOD_ROOT
))
3666 m_target
->clearUnitState(UNIT_STAT_ROOT
);
3667 // probably wrong (this add skinable flag)
3668 // TODO: find correct flag
3669 // m_target->RemoveFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
3671 if(!m_target
->hasUnitState(UNIT_STAT_STUNNED
)) // prevent allow move if have also stun effect
3673 if(m_target
->getVictim() && m_target
->isAlive())
3674 m_target
->SetUInt64Value (UNIT_FIELD_TARGET
,m_target
->getVictim()->GetGUID() );
3676 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3678 WorldPacket
data(SMSG_FORCE_MOVE_UNROOT
, 10);
3679 data
.append(m_target
->GetPackGUID());
3681 m_target
->SendMessageToSet(&data
,true);
3687 void Aura::HandleAuraModSilence(bool apply
, bool Real
)
3689 // only at real add/remove aura
3695 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_SILENCED
);
3696 // Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE
3697 for (uint32 i
= CURRENT_MELEE_SPELL
; i
< CURRENT_MAX_SPELL
;i
++)
3699 Spell
* currentSpell
= m_target
->m_currentSpells
[i
];
3700 if (currentSpell
&& currentSpell
->m_spellInfo
->PreventionType
== SPELL_PREVENTION_TYPE_SILENCE
)
3702 uint32 state
= currentSpell
->getState();
3703 // Stop spells on prepare or casting state
3704 if ( state
== SPELL_STATE_PREPARING
|| state
== SPELL_STATE_CASTING
)
3706 currentSpell
->cancel();
3707 currentSpell
->SetReferencedFromCurrent(false);
3708 m_target
->m_currentSpells
[i
] = NULL
;
3715 // Arcane Torrent (Energy)
3718 Unit
* caster
= GetCaster();
3722 // Search Mana Tap auras on caster
3723 Aura
* dummy
= caster
->GetDummyAura(28734);
3726 int32 bp
= dummy
->GetStackAmount() * 10;
3727 caster
->CastCustomSpell(caster
, 25048, &bp
, NULL
, NULL
, true);
3728 caster
->RemoveAurasDueToSpell(28734);
3735 // Real remove called after current aura remove from lists, check if other similar auras active
3736 if(m_target
->HasAuraType(SPELL_AURA_MOD_SILENCE
))
3739 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_SILENCED
);
3743 void Aura::HandleModThreat(bool apply
, bool Real
)
3745 // only at real add/remove aura
3749 if(!m_target
->isAlive())
3752 Unit
* caster
= GetCaster();
3754 if(!caster
|| !caster
->isAlive())
3763 level_diff
= m_target
->getLevel() - 60;
3766 // The Eye of Diminution
3768 level_diff
= m_target
->getLevel() - 60;
3773 m_modifier
.m_amount
+= multiplier
* level_diff
;
3775 for(int8 x
=0;x
< MAX_SPELL_SCHOOL
;x
++)
3777 if(m_modifier
.m_miscvalue
& int32(1<<x
))
3779 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3780 ApplyPercentModFloatVar(m_target
->m_threatModifier
[x
], m_positive
? m_modifier
.m_amount
: -m_modifier
.m_amount
, apply
);
3785 void Aura::HandleAuraModTotalThreat(bool apply
, bool Real
)
3787 // only at real add/remove aura
3791 if(!m_target
->isAlive() || m_target
->GetTypeId()!= TYPEID_PLAYER
)
3794 Unit
* caster
= GetCaster();
3796 if(!caster
|| !caster
->isAlive())
3799 float threatMod
= 0.0f
;
3801 threatMod
= float(m_modifier
.m_amount
);
3803 threatMod
= float(-m_modifier
.m_amount
);
3805 m_target
->getHostilRefManager().threatAssist(caster
, threatMod
);
3808 void Aura::HandleModTaunt(bool apply
, bool Real
)
3810 // only at real add/remove aura
3814 if(!m_target
->isAlive() || !m_target
->CanHaveThreatList())
3817 Unit
* caster
= GetCaster();
3819 if(!caster
|| !caster
->isAlive() || caster
->GetTypeId() != TYPEID_PLAYER
)
3823 m_target
->TauntApply(caster
);
3826 // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat
3827 m_target
->TauntFadeOut(caster
);
3831 /*********************************************************/
3832 /*** MODIFY SPEED ***/
3833 /*********************************************************/
3834 void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real
)
3836 // all applied/removed only at real aura add/remove
3840 m_target
->UpdateSpeed(MOVE_RUN
, true);
3843 void Aura::HandleAuraModIncreaseMountedSpeed(bool /*apply*/, bool Real
)
3845 // all applied/removed only at real aura add/remove
3849 m_target
->UpdateSpeed(MOVE_RUN
, true);
3852 void Aura::HandleAuraModIncreaseFlightSpeed(bool apply
, bool Real
)
3854 // all applied/removed only at real aura add/remove
3858 // Enable Fly mode for flying mounts
3859 if (m_modifier
.m_auraname
== SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
)
3863 data
.Initialize(SMSG_MOVE_SET_CAN_FLY
, 12);
3865 data
.Initialize(SMSG_MOVE_UNSET_CAN_FLY
, 12);
3866 data
.append(m_target
->GetPackGUID());
3867 data
<< uint32(0); // unknown
3868 m_target
->SendMessageToSet(&data
, true);
3870 //Players on flying mounts must be immune to polymorph
3871 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
3872 m_target
->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC
,MECHANIC_POLYMORPH
,apply
);
3874 // Dragonmaw Illusion (overwrite mount model, mounted aura already applied)
3875 if( apply
&& m_target
->HasAura(42016,0) && m_target
->GetMountID())
3876 m_target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
,16314);
3879 m_target
->UpdateSpeed(MOVE_FLIGHT
, true);
3882 void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real
)
3884 // all applied/removed only at real aura add/remove
3888 m_target
->UpdateSpeed(MOVE_SWIM
, true);
3891 void Aura::HandleAuraModDecreaseSpeed(bool /*apply*/, bool Real
)
3893 // all applied/removed only at real aura add/remove
3897 m_target
->UpdateSpeed(MOVE_RUN
, true);
3898 m_target
->UpdateSpeed(MOVE_SWIM
, true);
3899 m_target
->UpdateSpeed(MOVE_FLIGHT
, true);
3902 void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real
)
3904 // all applied/removed only at real aura add/remove
3908 m_target
->UpdateSpeed(MOVE_RUN
, true);
3909 m_target
->UpdateSpeed(MOVE_SWIM
, true);
3910 m_target
->UpdateSpeed(MOVE_FLIGHT
, true);
3913 /*********************************************************/
3915 /*********************************************************/
3917 void Aura::HandleModMechanicImmunity(bool apply
, bool Real
)
3919 uint32 mechanic
= 1 << m_modifier
.m_miscvalue
;
3921 //immune movement impairment and loss of control
3922 if(GetId()==42292 || GetId()==59752)
3923 mechanic
=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK
;
3925 if(apply
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
3927 Unit::AuraMap
& Auras
= m_target
->GetAuras();
3928 for(Unit::AuraMap::iterator iter
= Auras
.begin(), next
; iter
!= Auras
.end(); iter
= next
)
3932 SpellEntry
const *spell
= iter
->second
->GetSpellProto();
3933 if (!( spell
->Attributes
& SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY
) && // spells unaffected by invulnerability
3934 spell
->Id
!= GetId())
3936 //check for mechanic mask
3937 if(GetSpellMechanicMask(spell
, iter
->second
->GetEffIndex()) & mechanic
)
3939 m_target
->RemoveAurasDueToSpell(spell
->Id
);
3943 next
= Auras
.begin();
3949 m_target
->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC
,m_modifier
.m_miscvalue
,apply
);
3952 if ( GetSpellProto()->SpellFamilyName
== SPELLFAMILY_HUNTER
&& GetSpellProto()->SpellIconID
== 1680)
3954 // The Beast Within cast on owner if talent present
3955 if ( Unit
* owner
= m_target
->GetOwner() )
3958 Unit::AuraList
const& m_dummyAuras
= owner
->GetAurasByType(SPELL_AURA_DUMMY
);
3959 for(Unit::AuraList::const_iterator i
= m_dummyAuras
.begin(); i
!= m_dummyAuras
.end(); ++i
)
3961 if ( (*i
)->GetSpellProto()->SpellIconID
== 2229 )
3964 owner
->CastSpell(owner
, 34471, true, 0, this);
3966 owner
->RemoveAurasDueToSpell(34471);
3973 // The Beast Within and Bestial Wrath - immunity
3974 if(GetId() == 19574 || GetId() == 34471)
3978 m_target
->CastSpell(m_target
,24395,true);
3979 m_target
->CastSpell(m_target
,24396,true);
3980 m_target
->CastSpell(m_target
,24397,true);
3981 m_target
->CastSpell(m_target
,26592,true);
3985 m_target
->RemoveAurasDueToSpell(24395);
3986 m_target
->RemoveAurasDueToSpell(24396);
3987 m_target
->RemoveAurasDueToSpell(24397);
3988 m_target
->RemoveAurasDueToSpell(26592);
3993 void Aura::HandleAuraModEffectImmunity(bool apply
, bool Real
)
3997 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3999 if(((Player
*)m_target
)->InBattleGround())
4001 BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround();
4004 switch(bg
->GetTypeID())
4006 case BATTLEGROUND_AV
:
4010 case BATTLEGROUND_WS
:
4012 // Warsong Flag, horde // Silverwing Flag, alliance
4013 if(GetId() == 23333 || GetId() == 23335)
4014 bg
->EventPlayerDroppedFlag(((Player
*)m_target
));
4017 case BATTLEGROUND_AB
:
4021 case BATTLEGROUND_EY
:
4023 if(GetId() == 34976)
4024 bg
->EventPlayerDroppedFlag(((Player
*)m_target
));
4033 m_target
->ApplySpellImmune(GetId(),IMMUNITY_EFFECT
,m_modifier
.m_miscvalue
,apply
);
4036 void Aura::HandleAuraModStateImmunity(bool apply
, bool Real
)
4038 if(apply
&& Real
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
4040 Unit::AuraList
const& auraList
= m_target
->GetAurasByType(AuraType(m_modifier
.m_miscvalue
));
4041 for(Unit::AuraList::const_iterator itr
= auraList
.begin(); itr
!= auraList
.end();)
4043 if (auraList
.front() != this) // skip itself aura (it already added)
4045 m_target
->RemoveAurasDueToSpell(auraList
.front()->GetId());
4046 itr
= auraList
.begin();
4053 m_target
->ApplySpellImmune(GetId(),IMMUNITY_STATE
,m_modifier
.m_miscvalue
,apply
);
4056 void Aura::HandleAuraModSchoolImmunity(bool apply
, bool Real
)
4058 m_target
->ApplySpellImmune(GetId(),IMMUNITY_SCHOOL
,m_modifier
.m_miscvalue
,apply
);
4060 if(Real
&& apply
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
4062 if(IsPositiveSpell(GetId())) //Only positive immunity removes auras
4064 uint32 school_mask
= m_modifier
.m_miscvalue
;
4065 Unit::AuraMap
& Auras
= m_target
->GetAuras();
4066 for(Unit::AuraMap::iterator iter
= Auras
.begin(), next
; iter
!= Auras
.end(); iter
= next
)
4070 SpellEntry
const *spell
= iter
->second
->GetSpellProto();
4071 if((GetSpellSchoolMask(spell
) & school_mask
)//Check for school mask
4072 && !( spell
->Attributes
& SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY
) //Spells unaffected by invulnerability
4073 && !iter
->second
->IsPositive() //Don't remove positive spells
4074 && spell
->Id
!= GetId() ) //Don't remove self
4076 m_target
->RemoveAurasDueToSpell(spell
->Id
);
4080 next
= Auras
.begin();
4085 if( Real
&& GetSpellProto()->Mechanic
== MECHANIC_BANISH
)
4088 m_target
->addUnitState(UNIT_STAT_ISOLATED
);
4090 m_target
->clearUnitState(UNIT_STAT_ISOLATED
);
4094 void Aura::HandleAuraModDmgImmunity(bool apply
, bool Real
)
4096 m_target
->ApplySpellImmune(GetId(),IMMUNITY_DAMAGE
,m_modifier
.m_miscvalue
,apply
);
4099 void Aura::HandleAuraModDispelImmunity(bool apply
, bool Real
)
4101 // all applied/removed only at real aura add/remove
4105 m_target
->ApplySpellDispelImmunity(m_spellProto
, DispelType(m_modifier
.m_miscvalue
), apply
);
4108 void Aura::HandleAuraProcTriggerSpell(bool apply
, bool Real
)
4115 // some spell have charges by functionality not have its in spell data
4118 case 28200: // Ascendance (Talisman of Ascendance trinket)
4126 void Aura::HandleAuraModStalked(bool apply
, bool Real
)
4128 // used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND
4130 m_target
->SetFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_TRACK_UNIT
);
4132 m_target
->RemoveFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_TRACK_UNIT
);
4135 /*********************************************************/
4137 /*********************************************************/
4139 void Aura::HandlePeriodicTriggerSpell(bool apply
, bool Real
)
4141 m_isPeriodic
= apply
;
4142 if (m_spellProto
->Id
== 66 && !apply
)
4144 if (m_removeMode
== AURA_REMOVE_BY_DEFAULT
&& m_duration
<=0)
4145 m_target
->CastSpell(m_target
, 32612, true, NULL
, this);
4149 void Aura::HandlePeriodicTriggerSpellWithValue(bool apply
, bool Real
)
4151 m_isPeriodic
= apply
;
4154 void Aura::HandlePeriodicEnergize(bool apply
, bool Real
)
4159 m_isPeriodic
= apply
;
4161 // Replenishment (0.25% from max)
4162 // Infinite Replenishment
4163 if (GetId() == 57669 ||
4165 m_modifier
.m_amount
= m_target
->GetMaxPower(POWER_MANA
) * 25 / 10000;
4168 void Aura::HandleAuraPowerBurn(bool apply
, bool Real
)
4170 m_isPeriodic
= apply
;
4173 void Aura::HandleAuraPeriodicDummy(bool apply
, bool Real
)
4175 // spells required only Real aura add/remove
4179 // For prevent double apply bonuses
4180 bool loading
= (m_target
->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)m_target
)->GetSession()->PlayerLoading());
4182 Unit
* caster
= GetCaster();
4184 SpellEntry
const*spell
= GetSpellProto();
4185 switch( spell
->SpellFamilyName
)
4187 case SPELLFAMILY_ROGUE
:
4189 // Master of Subtlety
4190 if (spell
->Id
==31666 && !apply
)
4192 m_target
->RemoveAurasDueToSpell(31665);
4197 case SPELLFAMILY_HUNTER
:
4200 if (apply
&& !loading
&& caster
)
4201 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 8 / 100);
4206 m_isPeriodic
= apply
;
4209 void Aura::HandlePeriodicHeal(bool apply
, bool Real
)
4211 m_isPeriodic
= apply
;
4214 void Aura::HandlePeriodicDamage(bool apply
, bool Real
)
4216 // spells required only Real aura add/remove
4220 m_isPeriodic
= apply
;
4222 // For prevent double apply bonuses
4223 bool loading
= (m_target
->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)m_target
)->GetSession()->PlayerLoading());
4225 // Custom damage calculation after
4226 if (!apply
|| loading
)
4229 Unit
*caster
= GetCaster();
4233 switch (m_spellProto
->SpellFamilyName
)
4235 case SPELLFAMILY_GENERIC
:
4238 if ( m_spellProto
->SpellIconID
== 147 && m_spellProto
->SpellVisual
[0] == 0 )
4240 // $AP*0.18/6 bonus per tick
4241 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 3 / 100);
4246 case SPELLFAMILY_WARRIOR
:
4249 if (m_spellProto
->SpellFamilyFlags
& 0x0000000000000020LL
)
4251 // $0.2*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick
4252 float ap
= caster
->GetTotalAttackPowerValue(BASE_ATTACK
);
4253 int32 mws
= caster
->GetAttackTime(BASE_ATTACK
);
4254 float mwb_min
= caster
->GetWeaponDamageRange(BASE_ATTACK
,MINDAMAGE
);
4255 float mwb_max
= caster
->GetWeaponDamageRange(BASE_ATTACK
,MAXDAMAGE
);
4256 m_modifier
.m_amount
+=int32(((mwb_min
+mwb_max
)/2+ap
*mws
/14000)*0.2f
);
4261 case SPELLFAMILY_DRUID
:
4264 if (m_spellProto
->SpellFamilyFlags
& 0x0000000000001000LL
)
4266 // $AP*0.06 bonus per tick
4267 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 6 / 100);
4271 if (m_spellProto
->SpellFamilyFlags
& 0x000000010000000000LL
)
4273 // $AP*0.05/5 bonus per tick
4274 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) / 100);
4278 if (m_spellProto
->SpellFamilyFlags
& 0x000000000000800000LL
)
4281 if (caster
->GetTypeId() != TYPEID_PLAYER
)
4284 uint8 cp
= ((Player
*)caster
)->GetComboPoints();
4286 // Idol of Feral Shadows. Cant be handled as SpellMod in SpellAura:Dummy due its dependency from CPs
4287 Unit::AuraList
const& dummyAuras
= caster
->GetAurasByType(SPELL_AURA_DUMMY
);
4288 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
4290 if((*itr
)->GetId()==34241)
4292 m_modifier
.m_amount
+= cp
* (*itr
)->GetModifier()->m_amount
;
4296 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * cp
/ 100);
4300 if (m_spellProto
->SpellFamilyFlags
& 0x1000000000000000LL
)
4303 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 15 / 100);
4308 case SPELLFAMILY_ROGUE
:
4311 if (m_spellProto
->SpellFamilyFlags
& 0x000000000000100000LL
)
4313 if (caster
->GetTypeId() != TYPEID_PLAYER
)
4315 //1 point : ${($m1+$b1*1+0.015*$AP)*4} damage over 8 secs
4316 //2 points: ${($m1+$b1*2+0.024*$AP)*5} damage over 10 secs
4317 //3 points: ${($m1+$b1*3+0.03*$AP)*6} damage over 12 secs
4318 //4 points: ${($m1+$b1*4+0.03428571*$AP)*7} damage over 14 secs
4319 //5 points: ${($m1+$b1*5+0.0375*$AP)*8} damage over 16 secs
4320 float AP_per_combo
[] = {0, 0.015f
, 0.024, 0.03, 0.03428571, 0.0375};
4321 uint8 cp
= ((Player
*)caster
)->GetComboPoints();
4323 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * AP_per_combo
[cp
]);
4327 if (m_spellProto
->SpellFamilyFlags
& 0x000000000000000100LL
)
4329 // $AP*0.07 bonus per tick
4330 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 7 / 100);
4334 if (m_spellProto
->SpellFamilyFlags
& 0x0000000000010000)
4336 // 0.08*$AP / 4 * amount of stack
4337 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 2 * GetStackAmount() / 100);
4342 case SPELLFAMILY_HUNTER
:
4345 if (m_spellProto
->SpellFamilyFlags
& 0x0000000000004000LL
)
4347 // $RAP*0.1/5 bonus per tick
4348 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 10 / 500);
4352 if (m_spellProto
->SpellFamilyFlags
& 0x0000000000000004LL
&& m_spellProto
->SpellIconID
== 678)
4354 // $RAP*0.1/5 bonus per tick
4355 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 10 / 500);
4365 void Aura::HandlePeriodicDamagePCT(bool apply
, bool Real
)
4367 m_isPeriodic
= apply
;
4370 void Aura::HandlePeriodicLeech(bool apply
, bool Real
)
4372 m_isPeriodic
= apply
;
4375 void Aura::HandlePeriodicManaLeech(bool apply
, bool Real
)
4377 m_isPeriodic
= apply
;
4380 void Aura::HandlePeriodicHealthFunnel(bool apply
, bool Real
)
4382 m_isPeriodic
= apply
;
4385 /*********************************************************/
4386 /*** MODIFY STATS ***/
4387 /*********************************************************/
4389 /********************************/
4390 /*** RESISTANCE ***/
4391 /********************************/
4393 void Aura::HandleAuraModResistanceExclusive(bool apply
, bool Real
)
4395 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
4397 if(m_modifier
.m_miscvalue
& int32(1<<x
))
4399 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), BASE_VALUE
, float(m_modifier
.m_amount
), apply
);
4400 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4401 m_target
->ApplyResistanceBuffModsMod(SpellSchools(x
),m_positive
,m_modifier
.m_amount
, apply
);
4406 void Aura::HandleAuraModResistance(bool apply
, bool Real
)
4408 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
4410 if(m_modifier
.m_miscvalue
& int32(1<<x
))
4412 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4413 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4414 m_target
->ApplyResistanceBuffModsMod(SpellSchools(x
),m_positive
,m_modifier
.m_amount
, apply
);
4419 void Aura::HandleAuraModBaseResistancePCT(bool apply
, bool Real
)
4421 // only players have base stats
4422 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4424 //pets only have base armor
4425 if(((Creature
*)m_target
)->isPet() && (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
4426 m_target
->HandleStatModifier(UNIT_MOD_ARMOR
, BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4430 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
4432 if(m_modifier
.m_miscvalue
& int32(1<<x
))
4433 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4438 void Aura::HandleModResistancePercent(bool apply
, bool Real
)
4440 for(int8 i
= SPELL_SCHOOL_NORMAL
; i
< MAX_SPELL_SCHOOL
; i
++)
4442 if(m_modifier
.m_miscvalue
& int32(1<<i
))
4444 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ i
), TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4445 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4447 m_target
->ApplyResistanceBuffModsPercentMod(SpellSchools(i
),true,m_modifier
.m_amount
, apply
);
4448 m_target
->ApplyResistanceBuffModsPercentMod(SpellSchools(i
),false,m_modifier
.m_amount
, apply
);
4454 void Aura::HandleModBaseResistance(bool apply
, bool Real
)
4456 // only players have base stats
4457 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4459 //only pets have base stats
4460 if(((Creature
*)m_target
)->isPet() && (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
4461 m_target
->HandleStatModifier(UNIT_MOD_ARMOR
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4465 for(int i
= SPELL_SCHOOL_NORMAL
; i
< MAX_SPELL_SCHOOL
; i
++)
4466 if(m_modifier
.m_miscvalue
& (1<<i
))
4467 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ i
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4471 /********************************/
4473 /********************************/
4475 void Aura::HandleAuraModStat(bool apply
, bool Real
)
4477 if (m_modifier
.m_miscvalue
< -2 || m_modifier
.m_miscvalue
> 4)
4479 sLog
.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ",GetId(),GetEffIndex(),m_modifier
.m_miscvalue
);
4483 for(int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; i
++)
4485 // -1 or -2 is all stats ( misc < -2 checked in function beginning )
4486 if (m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
== i
)
4488 //m_target->ApplyStatMod(Stats(i), m_modifier.m_amount,apply);
4489 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4490 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4491 m_target
->ApplyStatBuffMod(Stats(i
),m_modifier
.m_amount
,apply
);
4496 void Aura::HandleModPercentStat(bool apply
, bool Real
)
4498 if (m_modifier
.m_miscvalue
< -1 || m_modifier
.m_miscvalue
> 4)
4500 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
4504 // only players have base stats
4505 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
4508 for (int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; ++i
)
4510 if(m_modifier
.m_miscvalue
== i
|| m_modifier
.m_miscvalue
== -1)
4511 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4515 void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool Real
)
4517 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4520 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4521 // This information for client side use only
4522 // Recalculate bonus
4523 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4526 void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool Real
)
4528 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4531 // Recalculate bonus
4532 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4535 void Aura::HandleAuraModDispelResist(bool apply
, bool Real
)
4541 m_target
->CastSpell(m_target
,44416,true,NULL
,this,GetCasterGUID());
4544 void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool Real
)
4546 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4549 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4550 // This information for client side use only
4551 // Recalculate bonus
4552 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4555 void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool Real
)
4557 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4560 // Recalculate bonus
4561 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4564 void Aura::HandleModHealingDone(bool /*apply*/, bool Real
)
4566 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4568 // implemented in Unit::SpellHealingBonus
4569 // this information is for client side only
4570 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4573 void Aura::HandleModTotalPercentStat(bool apply
, bool Real
)
4575 if (m_modifier
.m_miscvalue
< -1 || m_modifier
.m_miscvalue
> 4)
4577 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
4581 //save current and max HP before applying aura
4582 uint32 curHPValue
= m_target
->GetHealth();
4583 uint32 maxHPValue
= m_target
->GetMaxHealth();
4585 for (int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; i
++)
4587 if(m_modifier
.m_miscvalue
== i
|| m_modifier
.m_miscvalue
== -1)
4589 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4590 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4591 m_target
->ApplyStatPercentBuffMod(Stats(i
), m_modifier
.m_amount
, apply
);
4595 //recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag)
4596 if ((m_modifier
.m_miscvalue
== STAT_STAMINA
) && (maxHPValue
> 0) && (m_spellProto
->Attributes
& 0x10))
4598 // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed
4599 uint32 newHPValue
= (m_target
->GetMaxHealth() * curHPValue
) / maxHPValue
;
4600 m_target
->SetHealth(newHPValue
);
4604 void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool Real
)
4606 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4609 if(m_modifier
.m_miscvalue
!= SPELL_SCHOOL_MASK_NORMAL
)
4611 // support required adding replace UpdateArmor by loop by UpdateResistence at intellect update
4612 // and include in UpdateResistence same code as in UpdateArmor for aura mod apply.
4613 sLog
.outError("Aura SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT(182) need adding support for non-armor resistances!");
4617 // Recalculate Armor
4618 m_target
->UpdateArmor();
4621 /********************************/
4622 /*** HEAL & ENERGIZE ***/
4623 /********************************/
4624 void Aura::HandleAuraModTotalHealthPercentRegen(bool apply
, bool Real
)
4626 m_isPeriodic
= apply
;
4629 void Aura::HandleAuraModTotalManaPercentRegen(bool apply
, bool Real
)
4631 if(m_modifier
.periodictime
== 0)
4632 m_modifier
.periodictime
= 1000;
4634 m_periodicTimer
= m_modifier
.periodictime
;
4635 m_isPeriodic
= apply
;
4638 void Aura::HandleModRegen(bool apply
, bool Real
) // eating
4640 if(m_modifier
.periodictime
== 0)
4641 m_modifier
.periodictime
= 5000;
4643 m_periodicTimer
= 5000;
4644 m_isPeriodic
= apply
;
4647 void Aura::HandleModPowerRegen(bool apply
, bool Real
) // drinking
4652 Powers pt
= m_target
->getPowerType();
4653 if(m_modifier
.periodictime
== 0)
4655 // Anger Management (only spell use this aura for rage)
4656 if (pt
== POWER_RAGE
)
4657 m_modifier
.periodictime
= 3000;
4659 m_modifier
.periodictime
= 2000;
4662 m_periodicTimer
= 5000;
4664 if (m_target
->GetTypeId() == TYPEID_PLAYER
&& m_modifier
.m_miscvalue
== POWER_MANA
)
4665 ((Player
*)m_target
)->UpdateManaRegen();
4667 m_isPeriodic
= apply
;
4670 void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real
)
4672 // spells required only Real aura add/remove
4676 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
4679 // Update manaregen value
4680 if (m_modifier
.m_miscvalue
== POWER_MANA
)
4681 ((Player
*)m_target
)->UpdateManaRegen();
4684 void Aura::HandleModManaRegen(bool /*apply*/, bool Real
)
4686 // spells required only Real aura add/remove
4690 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
4693 //Note: an increase in regen does NOT cause threat.
4694 ((Player
*)m_target
)->UpdateManaRegen();
4697 void Aura::HandleComprehendLanguage(bool apply
, bool Real
)
4700 m_target
->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_COMPREHEND_LANG
);
4702 m_target
->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_COMPREHEND_LANG
);
4705 void Aura::HandleAuraModIncreaseHealth(bool apply
, bool Real
)
4707 // Special case with temporary increase max/current health
4710 case 12976: // Warrior Last Stand triggered spell
4711 case 28726: // Nightmare Seed ( Nightmare Seed )
4712 case 34511: // Valor (Bulwark of Kings, Bulwark of the Ancient Kings)
4713 case 44055: // Tremendous Fortitude (Battlemaster's Alacrity)
4714 case 50322: // Survival Instincts
4720 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4721 m_target
->ModifyHealth(m_modifier
.m_amount
);
4725 if (int32(m_target
->GetHealth()) > m_modifier
.m_amount
)
4726 m_target
->ModifyHealth(-m_modifier
.m_amount
);
4728 m_target
->SetHealth(1);
4729 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4737 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4740 void Aura::HandleAuraModIncreaseMaxHealth(bool apply
, bool Real
)
4742 uint32 oldhealth
= m_target
->GetHealth();
4743 double healthPercentage
= (double)oldhealth
/ (double)m_target
->GetMaxHealth();
4745 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4747 // refresh percentage
4750 uint32 newhealth
= uint32(ceil((double)m_target
->GetMaxHealth() * healthPercentage
));
4754 m_target
->SetHealth(newhealth
);
4758 void Aura::HandleAuraModIncreaseEnergy(bool apply
, bool Real
)
4760 Powers powerType
= m_target
->getPowerType();
4761 if(int32(powerType
) != m_modifier
.m_miscvalue
)
4764 UnitMods unitMod
= UnitMods(UNIT_MOD_POWER_START
+ powerType
);
4766 m_target
->HandleStatModifier(unitMod
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4769 void Aura::HandleAuraModIncreaseEnergyPercent(bool apply
, bool /*Real*/)
4771 Powers powerType
= m_target
->getPowerType();
4772 if(int32(powerType
) != m_modifier
.m_miscvalue
)
4775 UnitMods unitMod
= UnitMods(UNIT_MOD_POWER_START
+ powerType
);
4777 m_target
->HandleStatModifier(unitMod
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4780 void Aura::HandleAuraModIncreaseHealthPercent(bool apply
, bool /*Real*/)
4782 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4785 void Aura::HandleAuraIncreaseBaseHealthPercent(bool apply
, bool /*Real*/)
4787 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4790 /********************************/
4792 /********************************/
4794 void Aura::HandleAuraModParryPercent(bool /*apply*/, bool Real
)
4796 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
4799 ((Player
*)m_target
)->UpdateParryPercentage();
4802 void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool Real
)
4804 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
4807 ((Player
*)m_target
)->UpdateDodgePercentage();
4808 //sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount));
4811 void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool Real
)
4813 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
4816 ((Player
*)m_target
)->UpdateBlockPercentage();
4817 //sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount));
4820 void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real
)
4822 // spells required only Real aura add/remove
4826 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
4829 ((Player
*)m_target
)->UpdateManaRegen();
4832 void Aura::HandleAuraModCritPercent(bool apply
, bool Real
)
4834 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
4837 // apply item specific bonuses for already equipped weapon
4840 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
4841 if(Item
* pItem
= ((Player
*)m_target
)->GetWeaponForAttack(WeaponAttackType(i
)))
4842 ((Player
*)m_target
)->_ApplyWeaponDependentAuraCritMod(pItem
,WeaponAttackType(i
),this,apply
);
4845 // mods must be applied base at equipped weapon class and subclass comparison
4846 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
4847 // m_modifier.m_miscvalue comparison with item generated damage types
4849 if (GetSpellProto()->EquippedItemClass
== -1)
4851 ((Player
*)m_target
)->HandleBaseModValue(CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
4852 ((Player
*)m_target
)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
4853 ((Player
*)m_target
)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
4857 // done in Player::_ApplyWeaponDependentAuraMods
4861 void Aura::HandleModHitChance(bool apply
, bool Real
)
4863 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4865 ((Player
*)m_target
)->UpdateMeleeHitChances();
4866 ((Player
*)m_target
)->UpdateRangedHitChances();
4870 m_target
->m_modMeleeHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
4871 m_target
->m_modRangedHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
4875 void Aura::HandleModSpellHitChance(bool apply
, bool Real
)
4877 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4879 ((Player
*)m_target
)->UpdateSpellHitChances();
4883 m_target
->m_modSpellHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
4887 void Aura::HandleModSpellCritChance(bool apply
, bool Real
)
4889 // spells required only Real aura add/remove
4893 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4895 ((Player
*)m_target
)->UpdateAllSpellCritChances();
4899 m_target
->m_baseSpellCritChance
+= apply
? m_modifier
.m_amount
:(-m_modifier
.m_amount
);
4903 void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real
)
4905 // spells required only Real aura add/remove
4909 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4912 for(int school
= SPELL_SCHOOL_NORMAL
; school
< MAX_SPELL_SCHOOL
; ++school
)
4913 if (m_modifier
.m_miscvalue
& (1<<school
))
4914 ((Player
*)m_target
)->UpdateSpellCritChance(school
);
4917 /********************************/
4918 /*** ATTACK SPEED ***/
4919 /********************************/
4921 void Aura::HandleModCastingSpeed(bool apply
, bool Real
)
4923 m_target
->ApplyCastTimePercentMod(m_modifier
.m_amount
,apply
);
4926 void Aura::HandleModMeleeRangedSpeedPct(bool apply
, bool Real
)
4928 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
,m_modifier
.m_amount
,apply
);
4929 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
,m_modifier
.m_amount
,apply
);
4930 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
4933 void Aura::HandleModCombatSpeedPct(bool apply
, bool Real
)
4935 m_target
->ApplyCastTimePercentMod(m_modifier
.m_amount
,apply
);
4936 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
,m_modifier
.m_amount
,apply
);
4937 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
,m_modifier
.m_amount
,apply
);
4938 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
4941 void Aura::HandleModAttackSpeed(bool apply
, bool Real
)
4943 if(!m_target
->isAlive() )
4946 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
,m_modifier
.m_amount
,apply
);
4949 void Aura::HandleHaste(bool apply
, bool Real
)
4951 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
, m_modifier
.m_amount
,apply
);
4952 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
, m_modifier
.m_amount
,apply
);
4953 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
,m_modifier
.m_amount
,apply
);
4956 void Aura::HandleAuraModRangedHaste(bool apply
, bool Real
)
4958 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
4961 void Aura::HandleRangedAmmoHaste(bool apply
, bool Real
)
4963 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4965 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
,m_modifier
.m_amount
, apply
);
4968 /********************************/
4969 /*** ATTACK POWER ***/
4970 /********************************/
4972 void Aura::HandleAuraModAttackPower(bool apply
, bool Real
)
4974 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4977 void Aura::HandleAuraModRangedAttackPower(bool apply
, bool Real
)
4979 if((m_target
->getClassMask() & CLASSMASK_WAND_USERS
)!=0)
4982 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4985 void Aura::HandleAuraModAttackPowerPercent(bool apply
, bool Real
)
4987 //UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1
4988 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4991 void Aura::HandleAuraModRangedAttackPowerPercent(bool apply
, bool Real
)
4993 if((m_target
->getClassMask() & CLASSMASK_WAND_USERS
)!=0)
4996 //UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1
4997 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5000 void Aura::HandleAuraModRangedAttackPowerOfStatPercent(bool apply
, bool Real
)
5002 // spells required only Real aura add/remove
5006 // Recalculate bonus
5007 if(m_target
->GetTypeId() == TYPEID_PLAYER
&& !(m_target
->getClassMask() & CLASSMASK_WAND_USERS
))
5008 ((Player
*)m_target
)->UpdateAttackPowerAndDamage(true);
5011 void Aura::HandleAuraModAttackPowerOfStatPercent(bool apply
, bool Real
)
5013 // spells required only Real aura add/remove
5017 // Recalculate bonus
5018 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5019 ((Player
*)m_target
)->UpdateAttackPowerAndDamage(false);
5022 /********************************/
5023 /*** DAMAGE BONUS ***/
5024 /********************************/
5025 void Aura::HandleModDamageDone(bool apply
, bool Real
)
5027 // apply item specific bonuses for already equipped weapon
5028 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
5030 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
5031 if(Item
* pItem
= ((Player
*)m_target
)->GetWeaponForAttack(WeaponAttackType(i
)))
5032 ((Player
*)m_target
)->_ApplyWeaponDependentAuraDamageMod(pItem
,WeaponAttackType(i
),this,apply
);
5035 // m_modifier.m_miscvalue is bitmask of spell schools
5036 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5037 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wands
5038 // 127 - full bitmask any damages
5040 // mods must be applied base at equipped weapon class and subclass comparison
5041 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5042 // m_modifier.m_miscvalue comparison with item generated damage types
5044 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
) != 0)
5046 // apply generic physical damage bonuses including wand case
5047 if (GetSpellProto()->EquippedItemClass
== -1 || m_target
->GetTypeId() != TYPEID_PLAYER
)
5049 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5050 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5051 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
5055 // done in Player::_ApplyWeaponDependentAuraMods
5058 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5061 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS
,m_modifier
.m_amount
,apply
);
5063 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG
,m_modifier
.m_amount
,apply
);
5067 // Skip non magic case for speedup
5068 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_MAGIC
) == 0)
5071 if( GetSpellProto()->EquippedItemClass
!= -1 || GetSpellProto()->EquippedItemInventoryTypeMask
!= 0 )
5073 // wand magic case (skip generic to all item spell bonuses)
5074 // done in Player::_ApplyWeaponDependentAuraMods
5076 // Skip item specific requirements for not wand magic damage
5080 // Magic damage modifiers implemented in Unit::SpellDamageBonus
5081 // This information for client side use only
5082 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5086 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; i
++)
5088 if((m_modifier
.m_miscvalue
& (1<<i
)) != 0)
5089 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS
+i
,m_modifier
.m_amount
,apply
);
5094 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; i
++)
5096 if((m_modifier
.m_miscvalue
& (1<<i
)) != 0)
5097 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG
+i
,m_modifier
.m_amount
,apply
);
5100 Pet
* pet
= m_target
->GetPet();
5102 pet
->UpdateAttackPowerAndDamage();
5106 void Aura::HandleModDamagePercentDone(bool apply
, bool Real
)
5108 sLog
.outDebug("AURA MOD DAMAGE type:%u negative:%u", m_modifier
.m_miscvalue
, m_positive
? 0 : 1);
5110 // apply item specific bonuses for already equipped weapon
5111 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
5113 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
5114 if(Item
* pItem
= ((Player
*)m_target
)->GetWeaponForAttack(WeaponAttackType(i
)))
5115 ((Player
*)m_target
)->_ApplyWeaponDependentAuraDamageMod(pItem
,WeaponAttackType(i
),this,apply
);
5118 // m_modifier.m_miscvalue is bitmask of spell schools
5119 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5120 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wand
5121 // 127 - full bitmask any damages
5123 // mods must be applied base at equipped weapon class and subclass comparison
5124 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5125 // m_modifier.m_miscvalue comparison with item generated damage types
5127 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
) != 0)
5129 // apply generic physical damage bonuses including wand case
5130 if (GetSpellProto()->EquippedItemClass
== -1 || m_target
->GetTypeId() != TYPEID_PLAYER
)
5132 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5133 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5134 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5138 // done in Player::_ApplyWeaponDependentAuraMods
5140 // For show in client
5141 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5142 m_target
->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT
,m_modifier
.m_amount
/100.0f
,apply
);
5145 // Skip non magic case for speedup
5146 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_MAGIC
) == 0)
5149 if( GetSpellProto()->EquippedItemClass
!= -1 || GetSpellProto()->EquippedItemInventoryTypeMask
!= 0 )
5151 // wand magic case (skip generic to all item spell bonuses)
5152 // done in Player::_ApplyWeaponDependentAuraMods
5154 // Skip item specific requirements for not wand magic damage
5158 // Magic damage percent modifiers implemented in Unit::SpellDamageBonus
5159 // Send info to client
5160 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5161 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; ++i
)
5162 m_target
->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT
+i
,m_modifier
.m_amount
/100.0f
,apply
);
5165 void Aura::HandleModOffhandDamagePercent(bool apply
, bool Real
)
5167 // spells required only Real aura add/remove
5171 sLog
.outDebug("AURA MOD OFFHAND DAMAGE");
5173 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5176 /********************************/
5177 /*** POWER COST ***/
5178 /********************************/
5180 void Aura::HandleModPowerCostPCT(bool apply
, bool Real
)
5182 // spells required only Real aura add/remove
5186 float amount
= m_modifier
.m_amount
/100.0f
;
5187 for(int i
= 0; i
< MAX_SPELL_SCHOOL
; ++i
)
5188 if(m_modifier
.m_miscvalue
& (1<<i
))
5189 m_target
->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER
+i
,amount
,apply
);
5192 void Aura::HandleModPowerCost(bool apply
, bool Real
)
5194 // spells required only Real aura add/remove
5198 for(int i
= 0; i
< MAX_SPELL_SCHOOL
; ++i
)
5199 if(m_modifier
.m_miscvalue
& (1<<i
))
5200 m_target
->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER
+i
,m_modifier
.m_amount
,apply
);
5203 void Aura::HandleNoReagentUseAura(bool Apply
, bool Real
)
5205 // spells required only Real aura add/remove
5208 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5210 uint32 mask
[3] = {0, 0, 0};
5211 Unit::AuraList
const& noReagent
= m_target
->GetAurasByType(SPELL_AURA_NO_REAGENT_USE
);
5212 for(Unit::AuraList::const_iterator i
= noReagent
.begin(); i
!= noReagent
.end(); ++i
)
5214 uint32
const *ptr
= (*i
)->getAuraSpellClassMask();
5220 m_target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
, mask
[0]);
5221 m_target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
+1, mask
[1]);
5222 m_target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
+2, mask
[2]);
5225 /*********************************************************/
5227 /*********************************************************/
5229 void Aura::HandleShapeshiftBoosts(bool apply
)
5232 uint32 spellId2
= 0;
5233 uint32 HotWSpellId
= 0;
5235 switch(GetModifier()->m_miscvalue
)
5239 HotWSpellId
= 24900;
5254 HotWSpellId
= 24899;
5259 HotWSpellId
= 24899;
5261 case FORM_BATTLESTANCE
:
5264 case FORM_DEFENSIVESTANCE
:
5267 case FORM_BERSERKERSTANCE
:
5272 // aura from effect trigger spell
5279 case FORM_FLIGHT_EPIC
:
5283 case FORM_METAMORPHOSIS
:
5287 case FORM_SPIRITOFREDEMPTION
:
5289 spellId2
= 27795; // must be second, this important at aura remove to prevent to early iterator invalidation.
5291 case FORM_GHOSTWOLF
:
5296 case FORM_CREATURECAT
:
5297 case FORM_CREATUREBEAR
:
5302 uint32 form
= GetModifier()->m_miscvalue
-1;
5306 if (spellId
) m_target
->CastSpell(m_target
, spellId
, true, NULL
, this );
5307 if (spellId2
) m_target
->CastSpell(m_target
, spellId2
, true, NULL
, this);
5309 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5311 const PlayerSpellMap
& sp_list
= ((Player
*)m_target
)->GetSpellMap();
5312 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
5314 if(itr
->second
->state
== PLAYERSPELL_REMOVED
) continue;
5315 if(itr
->first
==spellId
|| itr
->first
==spellId2
) continue;
5316 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
5317 if (!spellInfo
|| !(spellInfo
->Attributes
& (SPELL_ATTR_PASSIVE
| (1<<7)))) continue;
5318 if (spellInfo
->Stances
& (1<<form
))
5319 m_target
->CastSpell(m_target
, itr
->first
, true, NULL
, this);
5322 if (((Player
*)m_target
)->HasSpell(17007))
5324 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(24932);
5325 if (spellInfo
&& spellInfo
->Stances
& (1<<form
))
5326 m_target
->CastSpell(m_target
, 24932, true, NULL
, this);
5331 Unit::AuraList
const& mModTotalStatPct
= m_target
->GetAurasByType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
);
5332 for(Unit::AuraList::const_iterator i
= mModTotalStatPct
.begin(); i
!= mModTotalStatPct
.end(); ++i
)
5334 if ((*i
)->GetSpellProto()->SpellIconID
== 240 && (*i
)->GetModifier()->m_miscvalue
== 3)
5336 int32 HotWMod
= (*i
)->GetModifier()->m_amount
;
5337 if(GetModifier()->m_miscvalue
== FORM_CAT
)
5340 m_target
->CastCustomSpell(m_target
, HotWSpellId
, &HotWMod
, NULL
, NULL
, true, NULL
, this);
5349 m_target
->RemoveAurasDueToSpell(spellId
);
5350 m_target
->RemoveAurasDueToSpell(spellId2
);
5352 Unit::AuraMap
& tAuras
= m_target
->GetAuras();
5353 for (Unit::AuraMap::iterator itr
= tAuras
.begin(); itr
!= tAuras
.end();)
5355 if (itr
->second
->IsRemovedOnShapeLost())
5357 m_target
->RemoveAurasDueToSpell(itr
->second
->GetId());
5358 itr
= tAuras
.begin();
5367 /*double healthPercentage = (double)m_target->GetHealth() / (double)m_target->GetMaxHealth();
5368 m_target->SetHealth(uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage)));*/
5371 void Aura::HandleAuraEmpathy(bool apply
, bool Real
)
5373 if(m_target
->GetTypeId() != TYPEID_UNIT
)
5376 CreatureInfo
const * ci
= objmgr
.GetCreatureTemplate(m_target
->GetEntry());
5377 if(ci
&& ci
->type
== CREATURE_TYPE_BEAST
)
5378 m_target
->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_SPECIALINFO
, apply
);
5381 void Aura::HandleAuraUntrackable(bool apply
, bool Real
)
5384 m_target
->SetByteFlag(UNIT_FIELD_BYTES_1
, 3, UNIT_BYTE1_FLAG_UNTRACKABLE
);
5386 m_target
->RemoveByteFlag(UNIT_FIELD_BYTES_1
, 3, UNIT_BYTE1_FLAG_UNTRACKABLE
);
5389 void Aura::HandleAuraModPacify(bool apply
, bool Real
)
5391 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5395 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PACIFIED
);
5397 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PACIFIED
);
5400 void Aura::HandleAuraModPacifyAndSilence(bool apply
, bool Real
)
5402 HandleAuraModPacify(apply
,Real
);
5403 HandleAuraModSilence(apply
,Real
);
5406 void Aura::HandleAuraGhost(bool apply
, bool Real
)
5408 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5413 m_target
->SetFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
);
5417 m_target
->RemoveFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
);
5421 void Aura::HandleAuraAllowFlight(bool apply
, bool Real
)
5423 // all applied/removed only at real aura add/remove
5430 data
.Initialize(SMSG_MOVE_SET_CAN_FLY
, 12);
5432 data
.Initialize(SMSG_MOVE_UNSET_CAN_FLY
, 12);
5433 data
.append(m_target
->GetPackGUID());
5434 data
<< uint32(0); // unk
5435 m_target
->SendMessageToSet(&data
, true);
5438 void Aura::HandleModRating(bool apply
, bool Real
)
5440 // spells required only Real aura add/remove
5444 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5447 for (uint32 rating
= 0; rating
< MAX_COMBAT_RATING
; ++rating
)
5448 if (m_modifier
.m_miscvalue
& (1 << rating
))
5449 ((Player
*)m_target
)->ApplyRatingMod(CombatRating(rating
), m_modifier
.m_amount
, apply
);
5452 void Aura::HandleModRatingFromStat(bool apply
, bool Real
)
5454 // spells required only Real aura add/remove
5458 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5460 // Just recalculate ratings
5461 for (uint32 rating
= 0; rating
< MAX_COMBAT_RATING
; ++rating
)
5462 if (m_modifier
.m_miscvalue
& (1 << rating
))
5463 ((Player
*)m_target
)->ApplyRatingMod(CombatRating(rating
), 0, apply
);
5466 void Aura::HandleForceMoveForward(bool apply
, bool Real
)
5468 if(!Real
|| m_target
->GetTypeId() != TYPEID_PLAYER
)
5471 m_target
->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FORCE_MOVE
);
5473 m_target
->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FORCE_MOVE
);
5476 void Aura::HandleAuraModExpertise(bool /*apply*/, bool Real
)
5478 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5481 ((Player
*)m_target
)->UpdateExpertise(BASE_ATTACK
);
5482 ((Player
*)m_target
)->UpdateExpertise(OFF_ATTACK
);
5485 void Aura::HandleModTargetResistance(bool apply
, bool Real
)
5487 // spells required only Real aura add/remove
5490 // applied to damage as HandleNoImmediateEffect in Unit::CalcAbsorbResist and Unit::CalcArmorReducedDamage
5492 // show armor penetration
5493 if (m_target
->GetTypeId() == TYPEID_PLAYER
&& (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
5494 m_target
->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE
,m_modifier
.m_amount
, apply
);
5496 // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy
5497 if (m_target
->GetTypeId() == TYPEID_PLAYER
&& (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_SPELL
)==SPELL_SCHOOL_MASK_SPELL
)
5498 m_target
->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE
,m_modifier
.m_amount
, apply
);
5501 void Aura::HandleShieldBlockValue(bool apply
, bool Real
)
5503 BaseModType modType
= FLAT_MOD
;
5504 if(m_modifier
.m_auraname
== SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT
)
5507 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5508 ((Player
*)m_target
)->HandleBaseModValue(SHIELD_BLOCK_VALUE
, modType
, float(m_modifier
.m_amount
), apply
);
5511 void Aura::HandleAuraRetainComboPoints(bool apply
, bool Real
)
5513 // spells required only Real aura add/remove
5517 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5520 Player
*target
= (Player
*)m_target
;
5522 // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler
5523 // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost)
5524 if( !apply
&& m_duration
==0 && target
->GetComboTarget())
5525 if(Unit
* unit
= ObjectAccessor::GetUnit(*m_target
,target
->GetComboTarget()))
5526 target
->AddComboPoints(unit
, -m_modifier
.m_amount
);
5529 void Aura::HandleModUnattackable( bool Apply
, bool Real
)
5532 m_target
->CombatStop();
5534 m_target
->ApplyModFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_NON_ATTACKABLE
,Apply
);
5537 void Aura::HandleSpiritOfRedemption( bool apply
, bool Real
)
5539 // spells required only Real aura add/remove
5543 // prepare spirit state
5546 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
5548 // disable breath/etc timers
5549 ((Player
*)m_target
)->StopMirrorTimers();
5551 // set stand state (expected in this form)
5552 if(!m_target
->IsStandState())
5553 m_target
->SetStandState(UNIT_STAND_STATE_STAND
);
5556 m_target
->SetHealth(1);
5560 m_target
->DealDamage(m_target
, m_target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, GetSpellProto(), false);
5563 void Aura::CleanupTriggeredSpells()
5565 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& m_spellProto
->SpellFamilyFlags
& 0x0000001000000020LL
)
5567 // Blood Frenzy remove
5568 m_target
->RemoveAurasDueToSpell(30069);
5569 m_target
->RemoveAurasDueToSpell(30070);
5573 uint32 tSpellId
= m_spellProto
->EffectTriggerSpell
[GetEffIndex()];
5577 SpellEntry
const* tProto
= sSpellStore
.LookupEntry(tSpellId
);
5581 if(GetSpellDuration(tProto
) != -1)
5584 // needed for spell 43680, maybe others
5585 // TODO: is there a spell flag, which can solve this in a more sophisticated way?
5586 if(m_spellProto
->EffectApplyAuraName
[GetEffIndex()] == SPELL_AURA_PERIODIC_TRIGGER_SPELL
&&
5587 GetSpellDuration(m_spellProto
) == m_spellProto
->EffectAmplitude
[GetEffIndex()])
5589 m_target
->RemoveAurasDueToSpell(tSpellId
);
5592 void Aura::HandleSchoolAbsorb(bool apply
, bool Real
)
5597 // prevent double apply bonuses
5598 if(apply
&& (m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading()))
5600 if(Unit
* caster
= GetCaster())
5602 float DoneActualBenefit
= 0.0f
;
5603 switch(m_spellProto
->SpellFamilyName
)
5605 case SPELLFAMILY_PRIEST
:
5606 if(m_spellProto
->SpellFamilyFlags
== 0x1) //PW:S
5608 //+30% from +healing bonus
5609 DoneActualBenefit
= caster
->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto
)) * 0.3f
;
5613 case SPELLFAMILY_MAGE
:
5614 if(m_spellProto
->SpellFamilyFlags
== 0x80100 || m_spellProto
->SpellFamilyFlags
== 0x8 || m_spellProto
->SpellFamilyFlags
== 0x100000000LL
)
5616 //frost ward, fire ward, ice barrier
5617 //+10% from +spd bonus
5618 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.1f
;
5622 case SPELLFAMILY_WARLOCK
:
5623 if(m_spellProto
->SpellFamilyFlags
== 0x00)
5626 //+10% from +spd bonus
5627 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.1f
;
5635 DoneActualBenefit
*= caster
->CalculateLevelPenalty(GetSpellProto());
5637 m_modifier
.m_amount
+= (int32
)DoneActualBenefit
;
5642 void Aura::PeriodicTick()
5644 if(!m_target
->isAlive())
5647 switch(m_modifier
.m_auraname
)
5649 case SPELL_AURA_PERIODIC_DAMAGE
:
5650 case SPELL_AURA_PERIODIC_DAMAGE_PERCENT
:
5652 Unit
*pCaster
= GetCaster();
5656 if( GetSpellProto()->Effect
[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
5657 pCaster
->SpellHitResult(m_target
,GetSpellProto(),false)!=SPELL_MISS_NONE
)
5660 // Check for immune (not use charges)
5661 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5664 // some auras remove at specific health level or more
5665 if(m_modifier
.m_auraname
==SPELL_AURA_PERIODIC_DAMAGE
)
5669 case 43093: case 31956: case 38801:
5670 case 35321: case 38363: case 39215:
5671 if(m_target
->GetHealth() == m_target
->GetMaxHealth() )
5673 m_target
->RemoveAurasDueToSpell(GetId());
5680 GetEffIndex() < 2 && GetSpellProto()->Effect
[GetEffIndex()]==SPELL_EFFECT_DUMMY
?
5681 pCaster
->CalculateSpellDamage(GetSpellProto(),GetEffIndex()+1,GetSpellProto()->EffectBasePoints
[GetEffIndex()+1],m_target
) :
5683 if(m_target
->GetHealth()*100 >= m_target
->GetMaxHealth()*percent
)
5685 m_target
->RemoveAurasDueToSpell(GetId());
5697 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
5699 // ignore non positive values (can be result apply spellmods to aura damage
5700 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5704 if(m_modifier
.m_auraname
== SPELL_AURA_PERIODIC_DAMAGE
)
5708 // Calculate armor mitigation if it is a physical spell
5709 // But not for bleed mechanic spells
5710 if ( GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL
&&
5711 GetEffectMechanic(GetSpellProto(), m_effIndex
) != MECHANIC_BLEED
)
5713 uint32 pdamageReductedArmor
= pCaster
->CalcArmorReducedDamage(m_target
, pdamage
);
5714 cleanDamage
.damage
+= pdamage
- pdamageReductedArmor
;
5715 pdamage
= pdamageReductedArmor
;
5718 pdamage
= pCaster
->SpellDamageBonus(m_target
, GetSpellProto(), pdamage
, DOT
, GetStackAmount());
5720 // Curse of Agony damage-per-tick calculation
5721 if (GetSpellProto()->SpellFamilyName
==SPELLFAMILY_WARLOCK
&& (GetSpellProto()->SpellFamilyFlags
& 0x0000000000000400LL
) && GetSpellProto()->SpellIconID
==544)
5723 // 1..4 ticks, 1/2 from normal tick damage
5724 if (m_duration
>=((m_maxduration
-m_modifier
.periodictime
)*2/3))
5725 pdamage
= pdamage
/2;
5726 // 9..12 ticks, 3/2 from normal tick damage
5727 else if(m_duration
<((m_maxduration
-m_modifier
.periodictime
)/3))
5728 pdamage
+= (pdamage
+1)/2; // +1 prevent 0.5 damage possible lost at 1..4 ticks
5729 // 5..8 ticks have normal tick damage
5733 pdamage
= uint32(m_target
->GetMaxHealth()*amount
/100);
5735 //As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit
5736 // Reduce dot damage from resilience for players
5737 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
5738 pdamage
-=((Player
*)m_target
)->GetDotDamageReduction(pdamage
);
5740 pCaster
->CalcAbsorbResist(m_target
, GetSpellSchoolMask(GetSpellProto()), DOT
, pdamage
, &absorb
, &resist
);
5742 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
5743 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId(),absorb
);
5745 WorldPacket
data(SMSG_PERIODICAURALOG
, (21+16));// we guess size
5746 data
.append(m_target
->GetPackGUID());
5747 data
.appendPackGUID(GetCasterGUID());
5748 data
<< uint32(GetId());
5750 data
<< uint32(m_modifier
.m_auraname
);
5751 data
<< (uint32
)pdamage
;
5752 data
<< uint32(0); // overkill
5753 data
<< (uint32
)GetSpellSchoolMask(GetSpellProto()); // will be mask in 2.4.x
5754 data
<< (uint32
)absorb
;
5755 data
<< (uint32
)resist
;
5756 m_target
->SendMessageToSet(&data
,true);
5758 Unit
* target
= m_target
; // aura can be deleted in DealDamage
5759 SpellEntry
const* spellProto
= GetSpellProto();
5762 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
;// | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
5763 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
5764 pdamage
= (pdamage
<= absorb
+resist
) ? 0 : (pdamage
-absorb
-resist
);
5766 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
5767 pCaster
->ProcDamageAndSpell(target
, procAttacker
, procVictim
, PROC_EX_NORMAL_HIT
, pdamage
, BASE_ATTACK
, spellProto
);
5769 pCaster
->DealDamage(target
, pdamage
, &cleanDamage
, DOT
, GetSpellSchoolMask(spellProto
), spellProto
, true);
5772 case SPELL_AURA_PERIODIC_LEECH
:
5773 case SPELL_AURA_PERIODIC_HEALTH_FUNNEL
:
5775 Unit
*pCaster
= GetCaster();
5779 if(!pCaster
->isAlive())
5782 if( GetSpellProto()->Effect
[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
5783 pCaster
->SpellHitResult(m_target
,GetSpellProto(),false)!=SPELL_MISS_NONE
)
5787 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5792 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
5794 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5796 //Calculate armor mitigation if it is a physical spell
5797 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL
)
5799 uint32 pdamageReductedArmor
= pCaster
->CalcArmorReducedDamage(m_target
, pdamage
);
5800 cleanDamage
.damage
+= pdamage
- pdamageReductedArmor
;
5801 pdamage
= pdamageReductedArmor
;
5804 pdamage
= pCaster
->SpellDamageBonus(m_target
, GetSpellProto(), pdamage
, DOT
, GetStackAmount());
5806 //As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit
5807 // Reduce dot damage from resilience for players
5808 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
5809 pdamage
-=((Player
*)m_target
)->GetDotDamageReduction(pdamage
);
5811 pCaster
->CalcAbsorbResist(m_target
, GetSpellSchoolMask(GetSpellProto()), DOT
, pdamage
, &absorb
, &resist
);
5813 if(m_target
->GetHealth() < pdamage
)
5814 pdamage
= uint32(m_target
->GetHealth());
5816 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
5817 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId(),absorb
);
5819 pCaster
->SendSpellNonMeleeDamageLog(m_target
, GetId(), pdamage
, GetSpellSchoolMask(GetSpellProto()), absorb
, resist
, false, 0);
5822 Unit
* target
= m_target
; // aura can be deleted in DealDamage
5823 SpellEntry
const* spellProto
= GetSpellProto();
5824 float multiplier
= spellProto
->EffectMultipleValue
[GetEffIndex()] > 0 ? spellProto
->EffectMultipleValue
[GetEffIndex()] : 1;
5825 int32 stackAmount
= GetStackAmount();
5828 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
;// | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
5829 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
5830 pdamage
= (pdamage
<= absorb
+resist
) ? 0 : (pdamage
-absorb
-resist
);
5832 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
5833 pCaster
->ProcDamageAndSpell(target
, procAttacker
, procVictim
, PROC_EX_NORMAL_HIT
, pdamage
, BASE_ATTACK
, spellProto
);
5834 int32 new_damage
= pCaster
->DealDamage(target
, pdamage
, &cleanDamage
, DOT
, GetSpellSchoolMask(spellProto
), spellProto
, false);
5836 if (!target
->isAlive() && pCaster
->IsNonMeleeSpellCasted(false))
5838 for (uint32 i
= CURRENT_FIRST_NON_MELEE_SPELL
; i
< CURRENT_MAX_SPELL
; i
++)
5840 if (pCaster
->m_currentSpells
[i
] && pCaster
->m_currentSpells
[i
]->m_spellInfo
->Id
== spellProto
->Id
)
5841 pCaster
->m_currentSpells
[i
]->cancel();
5846 if(Player
*modOwner
= pCaster
->GetSpellModOwner())
5847 modOwner
->ApplySpellMod(spellProto
->Id
, SPELLMOD_MULTIPLE_VALUE
, multiplier
);
5849 uint32 heal
= pCaster
->SpellHealingBonus(pCaster
, spellProto
, uint32(new_damage
* multiplier
), DOT
, stackAmount
);
5851 int32 gain
= pCaster
->ModifyHealth(heal
);
5852 pCaster
->getHostilRefManager().threatAssist(pCaster
, gain
* 0.5f
, spellProto
);
5854 pCaster
->SendHealSpellLog(pCaster
, spellProto
->Id
, heal
);
5857 case SPELL_AURA_PERIODIC_HEAL
:
5858 case SPELL_AURA_OBS_MOD_HEALTH
:
5860 Unit
*pCaster
= GetCaster();
5864 // heal for caster damage (must be alive)
5865 if(m_target
!= pCaster
&& GetSpellProto()->SpellVisual
[0]==163 && !pCaster
->isAlive())
5868 // ignore non positive values (can be result apply spellmods to aura damage
5869 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5873 if(m_modifier
.m_auraname
==SPELL_AURA_OBS_MOD_HEALTH
)
5874 pdamage
= uint32(m_target
->GetMaxHealth() * amount
/100);
5878 pdamage
= pCaster
->SpellHealingBonus(m_target
, GetSpellProto(), pdamage
, DOT
, GetStackAmount());
5880 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) heal of %u (TypeId: %u) for %u health inflicted by %u",
5881 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
5883 WorldPacket
data(SMSG_PERIODICAURALOG
, (21+16));// we guess size
5884 data
.append(m_target
->GetPackGUID());
5885 data
.appendPackGUID(GetCasterGUID());
5886 data
<< uint32(GetId());
5888 data
<< uint32(m_modifier
.m_auraname
);
5889 data
<< (uint32
)pdamage
;
5890 data
<< uint32(0); // wotlk
5891 m_target
->SendMessageToSet(&data
,true);
5893 int32 gain
= m_target
->ModifyHealth(pdamage
);
5895 // add HoTs to amount healed in bgs
5896 if( pCaster
->GetTypeId() == TYPEID_PLAYER
)
5897 if( BattleGround
*bg
= ((Player
*)pCaster
)->GetBattleGround() )
5898 bg
->UpdatePlayerScore(((Player
*)pCaster
), SCORE_HEALING_DONE
, gain
);
5900 //Do check before because m_modifier.auraName can be invalidate by DealDamage.
5901 bool procSpell
= (m_modifier
.m_auraname
== SPELL_AURA_PERIODIC_HEAL
&& m_target
!= pCaster
);
5903 m_target
->getHostilRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, GetSpellProto());
5905 Unit
* target
= m_target
; // aura can be deleted in DealDamage
5906 SpellEntry
const* spellProto
= GetSpellProto();
5907 bool haveCastItem
= GetCastItemGUID()!=0;
5909 // heal for caster damage
5910 if(m_target
!=pCaster
&& spellProto
->SpellVisual
[0]==163)
5912 uint32 dmg
= spellProto
->manaPerSecond
;
5913 if(pCaster
->GetHealth() <= dmg
&& pCaster
->GetTypeId()==TYPEID_PLAYER
)
5915 pCaster
->RemoveAurasDueToSpell(GetId());
5917 // finish current generic/channeling spells, don't affect autorepeat
5918 if(pCaster
->m_currentSpells
[CURRENT_GENERIC_SPELL
])
5920 pCaster
->m_currentSpells
[CURRENT_GENERIC_SPELL
]->finish();
5922 if(pCaster
->m_currentSpells
[CURRENT_CHANNELED_SPELL
])
5924 pCaster
->m_currentSpells
[CURRENT_CHANNELED_SPELL
]->SendChannelUpdate(0);
5925 pCaster
->m_currentSpells
[CURRENT_CHANNELED_SPELL
]->finish();
5930 pCaster
->SendSpellNonMeleeDamageLog(pCaster
, GetId(), gain
, GetSpellSchoolMask(GetSpellProto()), 0, 0, false, 0, false);
5932 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
5933 pCaster
->DealDamage(pCaster
, gain
, &cleanDamage
, NODAMAGE
, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
5937 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
;// | PROC_FLAG_SUCCESSFUL_HEAL;
5938 uint32 procVictim
= 0;//ROC_FLAG_ON_TAKE_PERIODIC | PROC_FLAG_TAKEN_HEAL;
5939 // ignore item heals
5940 // if(procSpell && !haveCastItem)
5941 // pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto);
5944 case SPELL_AURA_PERIODIC_MANA_LEECH
:
5946 if(m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
>= MAX_POWERS
)
5949 Powers power
= Powers(m_modifier
.m_miscvalue
);
5951 // power type might have changed between aura applying and tick (druid's shapeshift)
5952 if(m_target
->getPowerType() != power
)
5955 Unit
*pCaster
= GetCaster();
5959 if(!pCaster
->isAlive())
5962 if( GetSpellProto()->Effect
[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
5963 pCaster
->SpellHitResult(m_target
,GetSpellProto(),false)!=SPELL_MISS_NONE
)
5966 // Check for immune (not use charges)
5967 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5970 // ignore non positive values (can be result apply spellmods to aura damage
5971 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5973 // Special case: draining x% of mana (up to a maximum of 2*x% of the caster's maximum mana)
5974 // It's mana percent cost spells, m_modifier.m_amount is percent drain from target
5975 if (m_spellProto
->ManaCostPercentage
)
5978 uint32 maxmana
= pCaster
->GetMaxPower(power
) * pdamage
* 2 / 100;
5979 pdamage
= m_target
->GetMaxPower(power
) * pdamage
/ 100;
5980 if(pdamage
> maxmana
)
5984 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u",
5985 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
5987 int32 drain_amount
= m_target
->GetPower(power
) > pdamage
? pdamage
: m_target
->GetPower(power
);
5989 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
5990 if (power
== POWER_MANA
&& m_target
->GetTypeId() == TYPEID_PLAYER
)
5991 drain_amount
-= ((Player
*)m_target
)->GetSpellCritDamageReduction(drain_amount
);
5993 m_target
->ModifyPower(power
, -drain_amount
);
5995 float gain_multiplier
= 0;
5997 if(pCaster
->GetMaxPower(power
) > 0)
5999 gain_multiplier
= GetSpellProto()->EffectMultipleValue
[GetEffIndex()];
6001 if(Player
*modOwner
= pCaster
->GetSpellModOwner())
6002 modOwner
->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE
, gain_multiplier
);
6005 WorldPacket
data(SMSG_PERIODICAURALOG
, (21+16));// we guess size
6006 data
.append(m_target
->GetPackGUID());
6007 data
.appendPackGUID(GetCasterGUID());
6008 data
<< uint32(GetId());
6010 data
<< uint32(m_modifier
.m_auraname
);
6011 data
<< (uint32
)power
; // power type
6012 data
<< (uint32
)drain_amount
;
6013 data
<< (float)gain_multiplier
;
6014 m_target
->SendMessageToSet(&data
,true);
6016 int32 gain_amount
= int32(drain_amount
*gain_multiplier
);
6020 int32 gain
= pCaster
->ModifyPower(power
,gain_amount
);
6021 m_target
->AddThreat(pCaster
, float(gain
) * 0.5f
, GetSpellSchoolMask(GetSpellProto()), GetSpellProto());
6025 case SPELL_AURA_PERIODIC_ENERGIZE
:
6027 // ignore non positive values (can be result apply spellmods to aura damage
6028 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
6030 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u",
6031 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
6033 if(m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
>= MAX_POWERS
)
6036 Powers power
= Powers(m_modifier
.m_miscvalue
);
6038 if(m_target
->GetMaxPower(power
) == 0)
6041 WorldPacket
data(SMSG_PERIODICAURALOG
, (21+16));// we guess size
6042 data
.append(m_target
->GetPackGUID());
6043 data
.appendPackGUID(GetCasterGUID());
6044 data
<< uint32(GetId());
6046 data
<< uint32(m_modifier
.m_auraname
);
6047 data
<< (uint32
)power
; // power type
6048 data
<< (uint32
)pdamage
;
6049 m_target
->SendMessageToSet(&data
,true);
6051 int32 gain
= m_target
->ModifyPower(power
,pdamage
);
6053 if(Unit
* pCaster
= GetCaster())
6054 m_target
->getHostilRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, GetSpellProto());
6057 case SPELL_AURA_OBS_MOD_MANA
:
6059 // ignore non positive values (can be result apply spellmods to aura damage
6060 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
6062 uint32 pdamage
= uint32(m_target
->GetMaxPower(POWER_MANA
) * amount
/100);
6064 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u mana inflicted by %u",
6065 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
6067 if(m_target
->GetMaxPower(POWER_MANA
) == 0)
6070 WorldPacket
data(SMSG_PERIODICAURALOG
, (21+16));// we guess size
6071 data
.append(m_target
->GetPackGUID());
6072 data
.appendPackGUID(GetCasterGUID());
6073 data
<< uint32(GetId());
6075 data
<< uint32(m_modifier
.m_auraname
);
6076 data
<< (uint32
)0; // ?
6077 data
<< (uint32
)pdamage
;
6078 m_target
->SendMessageToSet(&data
,true);
6080 int32 gain
= m_target
->ModifyPower(POWER_MANA
, pdamage
);
6082 if(Unit
* pCaster
= GetCaster())
6083 m_target
->getHostilRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, GetSpellProto());
6086 case SPELL_AURA_POWER_BURN_MANA
:
6088 Unit
*pCaster
= GetCaster();
6092 // Check for immune (not use charges)
6093 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6096 int32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
6098 Powers powerType
= Powers(m_modifier
.m_miscvalue
);
6100 if(!m_target
->isAlive() || m_target
->getPowerType() != powerType
)
6103 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
6104 if (powerType
== POWER_MANA
&& m_target
->GetTypeId() == TYPEID_PLAYER
)
6105 pdamage
-= ((Player
*)m_target
)->GetSpellCritDamageReduction(pdamage
);
6107 uint32 gain
= uint32(-m_target
->ModifyPower(powerType
, -pdamage
));
6109 gain
= uint32(gain
* GetSpellProto()->EffectMultipleValue
[GetEffIndex()]);
6111 SpellEntry
const* spellProto
= GetSpellProto();
6112 //maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG
6113 SpellNonMeleeDamage
damageInfo(pCaster
, m_target
, spellProto
->Id
, spellProto
->SchoolMask
);
6114 pCaster
->CalculateSpellDamage(&damageInfo
, gain
, spellProto
);
6115 pCaster
->SendSpellNonMeleeDamageLog(&damageInfo
);
6118 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
;// | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
6119 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
6120 uint32 procEx
= createProcExtendMask(&damageInfo
, SPELL_MISS_NONE
);
6121 if (damageInfo
.damage
)
6122 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
6124 pCaster
->ProcDamageAndSpell(damageInfo
.target
, procAttacker
, procVictim
, procEx
, damageInfo
.damage
, BASE_ATTACK
, spellProto
);
6126 pCaster
->DealSpellDamage(&damageInfo
, true);
6129 case SPELL_AURA_MOD_REGEN
:
6131 int32 gain
= m_target
->ModifyHealth(m_modifier
.m_amount
);
6132 if (Unit
*caster
= GetCaster())
6133 m_target
->getHostilRefManager().threatAssist(caster
, float(gain
) * 0.5f
, GetSpellProto());
6136 case SPELL_AURA_MOD_POWER_REGEN
:
6138 Powers pt
= m_target
->getPowerType();
6139 if(int32(pt
) != m_modifier
.m_miscvalue
)
6142 if ( GetSpellProto()->AuraInterruptFlags
& AURA_INTERRUPT_FLAG_NOT_SEATED
)
6145 m_target
->HandleEmoteCommand(EMOTE_ONESHOT_EAT
);
6147 else if( GetId() == 20577 )
6150 m_target
->HandleEmoteCommand(EMOTE_STATE_CANNIBALIZE
);
6154 // amount = 1+ 16 = 17 = 3,4*5 = 10,2*5/3
6155 // so 17 is rounded amount for 5 sec tick grow ~ 1 range grow in 3 sec
6156 if(pt
== POWER_RAGE
)
6157 m_target
->ModifyPower(pt
, m_modifier
.m_amount
*3/5);
6160 // Here tick dummy auras
6161 case SPELL_AURA_PERIODIC_DUMMY
:
6163 PeriodicDummyTick();
6166 case SPELL_AURA_PERIODIC_TRIGGER_SPELL
:
6171 case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
:
6173 TriggerSpellWithValue();
6181 void Aura::PeriodicDummyTick()
6183 Unit
*caster
= GetCaster();
6184 SpellEntry
const* spell
= GetSpellProto();
6185 switch (spell
->SpellFamilyName
)
6187 case SPELLFAMILY_GENERIC
:
6203 case 49472: // Drink Coffee
6206 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
6208 // Search SPELL_AURA_MOD_POWER_REGEN aura for this spell and add bonus
6209 Unit::AuraList
const& aura
= m_target
->GetAurasByType(SPELL_AURA_MOD_POWER_REGEN
);
6210 for(Unit::AuraList::const_iterator i
= aura
.begin(); i
!= aura
.end(); ++i
)
6212 if ((*i
)->GetId() == GetId())
6214 (*i
)->GetModifier()->m_amount
= m_modifier
.m_amount
;
6215 ((Player
*)m_target
)->UpdateManaRegen();
6217 m_isPeriodic
= false;
6226 // Possibly need cast one of them (but
6227 // 7038 Forsaken Skill: Swords
6228 // 7039 Forsaken Skill: Axes
6229 // 7040 Forsaken Skill: Daggers
6230 // 7041 Forsaken Skill: Maces
6231 // 7042 Forsaken Skill: Staves
6232 // 7043 Forsaken Skill: Bows
6233 // 7044 Forsaken Skill: Guns
6234 // 7045 Forsaken Skill: 2H Axes
6235 // 7046 Forsaken Skill: 2H Maces
6236 // 7047 Forsaken Skill: 2H Swords
6237 // 7048 Forsaken Skill: Defense
6238 // 7049 Forsaken Skill: Fire
6239 // 7050 Forsaken Skill: Frost
6240 // 7051 Forsaken Skill: Holy
6241 // 7053 Forsaken Skill: Shadow
6245 // case 19230: break;
6246 // // Gossip NPC Periodic - Talk
6247 // case 33208: break;
6248 // // Gossip NPC Periodic - Despawn
6249 // case 33209: break;
6251 // case 36207: break;
6252 // // Simon Game START timer, (DND)
6253 // case 39993: break;
6254 // // Knockdown Fel Cannon: break; The Aggro Burst
6255 // case 40119: break;
6256 // // Old Mount Spell
6257 // case 40154: break;
6259 // case 40581: break;
6260 // // Ethereal Ring: break; The Bolt Burst
6261 // case 40801: break;
6262 // // Crystal Prison
6263 // case 40846: break;
6265 // case 41054: break;
6267 // case 41404: break;
6268 // // Ethereal Ring Visual, Lightning Aura
6269 // case 41477: break;
6270 // // Ethereal Ring Visual, Lightning Aura (Fork)
6271 // case 41525: break;
6272 // // Ethereal Ring Visual, Lightning Jumper Aura
6273 // case 41567: break;
6275 // case 41955: break;
6276 // // Headless Horseman - Fire
6277 // case 42074: break;
6278 // // Headless Horseman - Visual - Large Fire
6279 // case 42075: break;
6280 // // Headless Horseman - Start Fire, Periodic Aura
6281 // case 42140: break;
6282 // // Ram Speed Boost
6283 // case 42152: break;
6284 // // Headless Horseman - Fires Out Victory Aura
6285 // case 42235: break;
6286 // // Pumpkin Life Cycle
6287 // case 42280: break;
6288 // // Brewfest Request Chick Chuck Mug Aura
6289 // case 42537: break;
6291 // case 42596: break;
6292 // // Headless Horseman Climax, Head: Periodic
6293 // case 42603: break;
6295 // case 42621: break;
6296 // // Headless Horseman - Conflagrate, Periodic Aura
6297 // case 42637: break;
6298 // // Headless Horseman - Create Pumpkin Treats Aura
6299 // case 42774: break;
6300 // // Headless Horseman Climax - Summoning Rhyme Aura
6301 // case 42879: break;
6303 // case 42919: break;
6305 // case 42924: break;
6307 // case 42992: break;
6309 // case 42993: break;
6311 // case 42994: break;
6312 // // Ram Level - Neutral
6313 // case 43310: break;
6314 // // Headless Horseman - Maniacal Laugh, Maniacal, Delayed 17
6315 // case 43884: break;
6317 // case 43963: break;
6318 // // Headless Horseman - Maniacal Laugh, Maniacal, other, Delayed 17
6319 // case 44000: break;
6320 // // Energy Feedback
6321 // case 44328: break;
6322 // // Romantic Picnic
6323 // case 45102: break;
6324 // // Romantic Picnic
6325 // case 45123: break;
6326 // // Looking for Love
6327 // case 45124: break;
6328 // // Kite - Lightning Strike Kite Aura
6329 // case 45197: break;
6330 // // Rocket Chicken
6331 // case 45202: break;
6332 // // Copy Offhand Weapon
6333 // case 45205: break;
6334 // // Upper Deck - Kite - Lightning Periodic Aura
6335 // case 45207: break;
6336 // // Kite -Sky Lightning Strike Kite Aura
6337 // case 45251: break;
6338 // // Ribbon Pole Dancer Check Aura
6339 // case 45390: break;
6340 // // Holiday - Midsummer, Ribbon Pole Periodic Visual
6341 // case 45406: break;
6343 // case 45472: break;
6344 // // Alliance Flag, Extra Damage Debuff
6345 // case 45898: break;
6346 // // Horde Flag, Extra Damage Debuff
6347 // case 45899: break;
6348 // // Ahune - Summoning Rhyme Aura
6349 // case 45926: break;
6350 // // Ahune - Slippery Floor
6351 // case 45945: break;
6352 // // Ahune's Shield
6353 // case 45954: break;
6354 // // Nether Vapor Lightning
6355 // case 45960: break;
6357 // case 45996: break;
6358 // // Summon Blood Elves Periodic
6359 // case 46041: break;
6360 // // Transform Visual Missile Periodic
6361 // case 46205: break;
6362 // // Find Opening Beam End
6363 // case 46333: break;
6364 // // Ice Spear Control Aura
6365 // case 46371: break;
6366 // // Hailstone Chill
6367 // case 46458: break;
6368 // // Hailstone Chill, Internal
6369 // case 46465: break;
6370 // // Chill, Internal Shifter
6371 // case 46549: break;
6372 // // Summon Ice Spear Knockback Delayer
6373 // case 46878: break;
6374 // // Burninate Effect
6375 // case 47214: break;
6376 // // Fizzcrank Practice Parachute
6377 // case 47228: break;
6378 // // Send Mug Control Aura
6379 // case 47369: break;
6380 // // Direbrew's Disarm (precast)
6381 // case 47407: break;
6382 // // Mole Machine Port Schedule
6383 // case 47489: break;
6384 // case 47941: break; // Crystal Spike
6385 // case 48200: break; // Healer Aura
6386 // case 48630: break; // Summon Gauntlet Mobs Periodic
6387 // case 49313: break; // Proximity Mine Area Aura
6388 // // Mole Machine Portal Schedule
6389 // case 49466: break;
6390 // case 49555: break; // Corpse Explode
6391 // case 49592: break; // Temporal Rift
6392 // case 49957: break; // Cutting Laser
6393 // case 50085: break; // Slow Fall
6394 // // Listening to Music
6395 // case 50493: break;
6396 // // Love Rocket Barrage
6397 // case 50530: break;
6398 // Exist more after, need add later
6403 case SPELLFAMILY_MAGE
:
6406 // if (spell->Id == 55342)
6410 case SPELLFAMILY_WARRIOR
:
6412 // Armored to the Teeth
6413 if (spell
->SpellIconID
== 3516)
6415 // Increases your attack power by $s1 for every $s2 armor value you have.
6416 // Calculate AP bonus (from 1 efect of this spell)
6417 int32 apBonus
= m_modifier
.m_amount
* m_target
->GetArmor() / m_target
->CalculateSpellDamage(spell
, 1, spell
->EffectBasePoints
[1], m_target
);
6418 m_target
->CastCustomSpell(m_target
, 61217, &apBonus
, &apBonus
, 0, true, 0, this);
6423 case SPELLFAMILY_DRUID
:
6427 // Frenzied Regeneration
6430 // Converts up to 10 rage per second into health for $d. Each point of rage is converted into ${$m2/10}.1% of max health.
6431 // Should be manauser
6432 if (m_target
->getPowerType()!=POWER_RAGE
)
6434 uint32 rage
= m_target
->GetPower(POWER_RAGE
);
6438 int32 mod
= (rage
< 100) ? rage
: 100;
6439 int32 points
= m_target
->CalculateSpellDamage(spell
, 1, spell
->EffectBasePoints
[1], m_target
);
6440 int32 regen
= m_target
->GetMaxHealth() * (mod
* points
/ 10) / 1000;
6441 m_target
->CastCustomSpell(m_target
, 22845, ®en
, 0, 0, true, 0, this);
6442 m_target
->SetPower(POWER_RAGE
, rage
-mod
);
6453 case SPELLFAMILY_ROGUE
:
6455 // switch (spell->Id)
6457 // Master of Subtlety
6458 // case 31666: break;
6460 // case 51690: break;
6462 // case 58428: break;
6468 case SPELLFAMILY_HUNTER
:
6471 if (spell
->SpellFamilyFlags
& 0x8000000000000000LL
)
6475 int32 damage
= m_modifier
.m_amount
;
6476 // Full damage to target at 0 tick
6477 if (m_duration
> m_modifier
.periodictime
)
6479 caster
->CastCustomSpell(m_target
, 53352, &damage
, 0, 0, true, 0, this);
6483 caster
->CastCustomSpell(m_target
, 56298, &damage
, 0, 0, true, 0, this);
6491 // Feeding Frenzy Rank 1
6493 if ( m_target
->GetHealth() * 100 < m_target
->GetMaxHealth() * 35 )
6494 m_target
->CastSpell(m_target
, 60096, true, 0, this);
6496 // Feeding Frenzy Rank 2
6498 if ( m_target
->GetHealth() * 100 < m_target
->GetMaxHealth() * 35 )
6499 m_target
->CastSpell(m_target
, 60097, true, 0, this);
6506 case SPELLFAMILY_SHAMAN
:
6509 if (spell
->Id
== 52179)
6511 // Periodic need for remove visual on stun/fear/silence lost
6512 if (!(m_target
->GetUInt32Value(UNIT_FIELD_FLAGS
)&(UNIT_FLAG_STUNNED
|UNIT_FLAG_FLEEING
|UNIT_FLAG_SILENCED
)))
6513 m_target
->RemoveAurasDueToSpell(52179);
6518 case SPELLFAMILY_DEATHKNIGHT
:
6521 if (spell
->SpellFamilyFlags
& 0x0000000000000020LL
)
6524 caster
->CastCustomSpell(m_target
, 52212, &m_modifier
.m_amount
, NULL
, NULL
, true, 0, this);
6528 // if (spell->SpellFamilyFlags & 0x0000000000001000LL)
6531 if (spell
->SpellFamilyFlags
& 0x0000400000000000LL
)
6533 // Get 0 effect aura
6534 Aura
*slow
= m_target
->GetAura(GetId(), 0);
6537 slow
->ApplyModifier(false, true);
6538 Modifier
*mod
= slow
->GetModifier();
6539 mod
->m_amount
+= m_modifier
.m_amount
;
6540 if (mod
->m_amount
> 0) mod
->m_amount
= 0;
6541 slow
->ApplyModifier(true, true);
6546 // if (spell->SpellFamilyFlags & 0x0000008000000000LL)
6548 // Death Rune Mastery
6549 // if (spell->SpellFamilyFlags & 0x0000000000004000LL)
6552 if (spell
->SpellIconID
== 2653)
6554 // Increases your attack power by $s1 for every $s2 armor value you have.
6555 // Calculate AP bonus (from 1 efect of this spell)
6556 int32 apBonus
= m_modifier
.m_amount
* m_target
->GetArmor() / m_target
->CalculateSpellDamage(spell
, 1, spell
->EffectBasePoints
[1], m_target
);
6557 m_target
->CastCustomSpell(m_target
, 61217, &apBonus
, &apBonus
, 0, true, 0, this);
6561 // if (spell->SpellIconID == 22)
6563 // Blood of the North
6564 // if (spell->SpellIconID == 30412)
6573 void Aura::HandlePreventFleeing(bool apply
, bool Real
)
6578 Unit::AuraList
const& fearAuras
= m_target
->GetAurasByType(SPELL_AURA_MOD_FEAR
);
6579 if( !fearAuras
.empty() )
6582 m_target
->SetFeared(false, fearAuras
.front()->GetCasterGUID());
6584 m_target
->SetFeared(true);
6588 void Aura::HandleManaShield(bool apply
, bool Real
)
6593 // prevent double apply bonuses
6594 if(apply
&& (m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading()))
6596 if(Unit
* caster
= GetCaster())
6598 float DoneActualBenefit
= 0.0f
;
6599 switch(m_spellProto
->SpellFamilyName
)
6601 case SPELLFAMILY_MAGE
:
6602 if(m_spellProto
->SpellFamilyFlags
& 0x8000)
6605 // +50% from +spd bonus
6606 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.5f
;
6614 DoneActualBenefit
*= caster
->CalculateLevelPenalty(GetSpellProto());
6616 m_modifier
.m_amount
+= (int32
)DoneActualBenefit
;
6621 void Aura::HandleArenaPreparation(bool apply
, bool Real
)
6627 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PREPARATION
);
6629 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PREPARATION
);
6632 void Aura::HandleAuraControlVehicle(bool apply
, bool Real
)
6637 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
6640 if(Pet
*pet
= m_target
->GetPet())
6641 pet
->Remove(PET_SAVE_AS_CURRENT
);
6643 WorldPacket
data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA
, 0);
6644 ((Player
*)m_target
)->GetSession()->SendPacket(&data
);
6647 void Aura::HandleAuraConvertRune(bool apply
, bool Real
)
6652 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
6655 Player
*plr
= (Player
*)m_target
;
6657 if(plr
->getClass() != CLASS_DEATH_KNIGHT
)
6660 // how to determine what rune need to be converted?
6661 for(uint32 i
= 0; i
< MAX_RUNES
; ++i
)
6665 if(!plr
->GetRuneCooldown(i
))
6667 plr
->ConvertRune(i
, GetSpellProto()->EffectMiscValueB
[m_effIndex
]);
6673 if(plr
->GetCurrentRune(i
) == GetSpellProto()->EffectMiscValueB
[m_effIndex
])
6675 plr
->ConvertRune(i
, plr
->GetBaseRune(i
));
6682 void Aura::HandlePhase(bool apply
, bool Real
)
6687 // always non stackable
6690 Unit::AuraList
const& phases
= m_target
->GetAurasByType(SPELL_AURA_PHASE
);
6692 m_target
->RemoveAurasDueToSpell(phases
.front()->GetId(),this);
6695 // no-phase is also phase state so same code for apply and remove
6697 // phase auras normally not expected at BG but anyway better check
6698 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
6700 // drop flag at invisible in bg
6701 if(((Player
*)m_target
)->InBattleGround())
6702 if(BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround())
6703 bg
->EventPlayerDroppedFlag((Player
*)m_target
);
6705 // GM-mode have mask 0xFFFFFFFF
6706 if(!((Player
*)m_target
)->isGameMaster())
6707 m_target
->SetPhaseMask(apply
? GetMiscValue() : PHASEMASK_NORMAL
,false);
6709 ((Player
*)m_target
)->GetSession()->SendSetPhaseShift(apply
? GetMiscValue() : PHASEMASK_NORMAL
);
6711 if(GetEffIndex()==0)
6713 SpellAreaForAreaMapBounds saBounds
= spellmgr
.GetSpellAreaForAuraMapBounds(GetId());
6714 if(saBounds
.first
!= saBounds
.second
)
6717 m_target
->GetZoneAndAreaId(zone
,area
);
6719 for(SpellAreaForAreaMap::const_iterator itr
= saBounds
.first
; itr
!= saBounds
.second
; ++itr
)
6721 // some auras remove at aura remove
6722 if(!itr
->second
->IsFitToRequirements((Player
*)m_target
,zone
,area
))
6723 m_target
->RemoveAurasDueToSpell(itr
->second
->spellId
);
6724 // some auras applied at aura apply
6725 else if(itr
->second
->autocast
)
6727 if( !m_target
->HasAura(itr
->second
->spellId
,0) )
6728 m_target
->CastSpell(m_target
,itr
->second
->spellId
,true);
6735 m_target
->SetPhaseMask(apply
? GetMiscValue() : PHASEMASK_NORMAL
,false);
6737 // need triggering visibility update base at phase update of not GM invisible (other GMs anyway see in any phases)
6738 if(m_target
->GetVisibility()!=VISIBILITY_OFF
)
6739 m_target
->SetVisibility(m_target
->GetVisibility());