2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "Database/DatabaseEnv.h"
21 #include "WorldPacket.h"
22 #include "WorldSession.h"
25 #include "UpdateMask.h"
27 #include "ObjectMgr.h"
32 #include "SpellAuras.h"
33 #include "DynamicObject.h"
35 #include "UpdateData.h"
36 #include "MapManager.h"
37 #include "ObjectAccessor.h"
38 #include "Policies/SingletonImp.h"
42 #include "BattleGround.h"
43 #include "CreatureAI.h"
45 #include "GridNotifiers.h"
46 #include "GridNotifiersImpl.h"
49 #define NULL_AURA_SLOT 0xFF
51 pAuraHandler AuraHandler
[TOTAL_AURAS
]=
53 &Aura::HandleNULL
, // 0 SPELL_AURA_NONE
54 &Aura::HandleBindSight
, // 1 SPELL_AURA_BIND_SIGHT
55 &Aura::HandleModPossess
, // 2 SPELL_AURA_MOD_POSSESS
56 &Aura::HandlePeriodicDamage
, // 3 SPELL_AURA_PERIODIC_DAMAGE
57 &Aura::HandleAuraDummy
, // 4 SPELL_AURA_DUMMY
58 &Aura::HandleModConfuse
, // 5 SPELL_AURA_MOD_CONFUSE
59 &Aura::HandleModCharm
, // 6 SPELL_AURA_MOD_CHARM
60 &Aura::HandleModFear
, // 7 SPELL_AURA_MOD_FEAR
61 &Aura::HandlePeriodicHeal
, // 8 SPELL_AURA_PERIODIC_HEAL
62 &Aura::HandleModAttackSpeed
, // 9 SPELL_AURA_MOD_ATTACKSPEED
63 &Aura::HandleModThreat
, // 10 SPELL_AURA_MOD_THREAT
64 &Aura::HandleModTaunt
, // 11 SPELL_AURA_MOD_TAUNT
65 &Aura::HandleAuraModStun
, // 12 SPELL_AURA_MOD_STUN
66 &Aura::HandleModDamageDone
, // 13 SPELL_AURA_MOD_DAMAGE_DONE
67 &Aura::HandleNoImmediateEffect
, // 14 SPELL_AURA_MOD_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus
68 &Aura::HandleNoImmediateEffect
, // 15 SPELL_AURA_DAMAGE_SHIELD implemented in Unit::DoAttackDamage
69 &Aura::HandleModStealth
, // 16 SPELL_AURA_MOD_STEALTH
70 &Aura::HandleNoImmediateEffect
, // 17 SPELL_AURA_MOD_STEALTH_DETECT
71 &Aura::HandleInvisibility
, // 18 SPELL_AURA_MOD_INVISIBILITY
72 &Aura::HandleInvisibilityDetect
, // 19 SPELL_AURA_MOD_INVISIBILITY_DETECTION
73 &Aura::HandleAuraModTotalHealthPercentRegen
, // 20 SPELL_AURA_OBS_MOD_HEALTH
74 &Aura::HandleAuraModTotalManaPercentRegen
, // 21 SPELL_AURA_OBS_MOD_MANA
75 &Aura::HandleAuraModResistance
, // 22 SPELL_AURA_MOD_RESISTANCE
76 &Aura::HandlePeriodicTriggerSpell
, // 23 SPELL_AURA_PERIODIC_TRIGGER_SPELL
77 &Aura::HandlePeriodicEnergize
, // 24 SPELL_AURA_PERIODIC_ENERGIZE
78 &Aura::HandleAuraModPacify
, // 25 SPELL_AURA_MOD_PACIFY
79 &Aura::HandleAuraModRoot
, // 26 SPELL_AURA_MOD_ROOT
80 &Aura::HandleAuraModSilence
, // 27 SPELL_AURA_MOD_SILENCE
81 &Aura::HandleNoImmediateEffect
, // 28 SPELL_AURA_REFLECT_SPELLS implement in Unit::SpellHitResult
82 &Aura::HandleAuraModStat
, // 29 SPELL_AURA_MOD_STAT
83 &Aura::HandleAuraModSkill
, // 30 SPELL_AURA_MOD_SKILL
84 &Aura::HandleAuraModIncreaseSpeed
, // 31 SPELL_AURA_MOD_INCREASE_SPEED
85 &Aura::HandleAuraModIncreaseMountedSpeed
, // 32 SPELL_AURA_MOD_INCREASE_MOUNTED_SPEED
86 &Aura::HandleAuraModDecreaseSpeed
, // 33 SPELL_AURA_MOD_DECREASE_SPEED
87 &Aura::HandleAuraModIncreaseHealth
, // 34 SPELL_AURA_MOD_INCREASE_HEALTH
88 &Aura::HandleAuraModIncreaseEnergy
, // 35 SPELL_AURA_MOD_INCREASE_ENERGY
89 &Aura::HandleAuraModShapeshift
, // 36 SPELL_AURA_MOD_SHAPESHIFT
90 &Aura::HandleAuraModEffectImmunity
, // 37 SPELL_AURA_EFFECT_IMMUNITY
91 &Aura::HandleAuraModStateImmunity
, // 38 SPELL_AURA_STATE_IMMUNITY
92 &Aura::HandleAuraModSchoolImmunity
, // 39 SPELL_AURA_SCHOOL_IMMUNITY
93 &Aura::HandleAuraModDmgImmunity
, // 40 SPELL_AURA_DAMAGE_IMMUNITY
94 &Aura::HandleAuraModDispelImmunity
, // 41 SPELL_AURA_DISPEL_IMMUNITY
95 &Aura::HandleAuraProcTriggerSpell
, // 42 SPELL_AURA_PROC_TRIGGER_SPELL implemented in Unit::ProcDamageAndSpellFor and Unit::HandleProcTriggerSpell
96 &Aura::HandleNoImmediateEffect
, // 43 SPELL_AURA_PROC_TRIGGER_DAMAGE implemented in Unit::ProcDamageAndSpellFor
97 &Aura::HandleAuraTrackCreatures
, // 44 SPELL_AURA_TRACK_CREATURES
98 &Aura::HandleAuraTrackResources
, // 45 SPELL_AURA_TRACK_RESOURCES
99 &Aura::HandleUnused
, // 46 SPELL_AURA_46
100 &Aura::HandleAuraModParryPercent
, // 47 SPELL_AURA_MOD_PARRY_PERCENT
101 &Aura::HandleUnused
, // 48 SPELL_AURA_48
102 &Aura::HandleAuraModDodgePercent
, // 49 SPELL_AURA_MOD_DODGE_PERCENT
103 &Aura::HandleNoImmediateEffect
, // 50 SPELL_AURA_MOD_CRITICAL_HEALING_BONUS
104 &Aura::HandleAuraModBlockPercent
, // 51 SPELL_AURA_MOD_BLOCK_PERCENT
105 &Aura::HandleAuraModCritPercent
, // 52 SPELL_AURA_MOD_CRIT_PERCENT
106 &Aura::HandlePeriodicLeech
, // 53 SPELL_AURA_PERIODIC_LEECH
107 &Aura::HandleModHitChance
, // 54 SPELL_AURA_MOD_HIT_CHANCE
108 &Aura::HandleModSpellHitChance
, // 55 SPELL_AURA_MOD_SPELL_HIT_CHANCE
109 &Aura::HandleAuraTransform
, // 56 SPELL_AURA_TRANSFORM
110 &Aura::HandleModSpellCritChance
, // 57 SPELL_AURA_MOD_SPELL_CRIT_CHANCE
111 &Aura::HandleAuraModIncreaseSwimSpeed
, // 58 SPELL_AURA_MOD_INCREASE_SWIM_SPEED
112 &Aura::HandleNoImmediateEffect
, // 59 SPELL_AURA_MOD_DAMAGE_DONE_CREATURE implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus
113 &Aura::HandleAuraModPacifyAndSilence
, // 60 SPELL_AURA_MOD_PACIFY_SILENCE
114 &Aura::HandleAuraModScale
, // 61 SPELL_AURA_MOD_SCALE
115 &Aura::HandlePeriodicHealthFunnel
, // 62 SPELL_AURA_PERIODIC_HEALTH_FUNNEL
116 &Aura::HandleUnused
, // 63 SPELL_AURA_PERIODIC_MANA_FUNNEL obsolete?
117 &Aura::HandlePeriodicManaLeech
, // 64 SPELL_AURA_PERIODIC_MANA_LEECH
118 &Aura::HandleModCastingSpeed
, // 65 SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK
119 &Aura::HandleFeignDeath
, // 66 SPELL_AURA_FEIGN_DEATH
120 &Aura::HandleAuraModDisarm
, // 67 SPELL_AURA_MOD_DISARM
121 &Aura::HandleAuraModStalked
, // 68 SPELL_AURA_MOD_STALKED
122 &Aura::HandleSchoolAbsorb
, // 69 SPELL_AURA_SCHOOL_ABSORB implemented in Unit::CalcAbsorbResist
123 &Aura::HandleUnused
, // 70 SPELL_AURA_EXTRA_ATTACKS Useless, used by only one spell that has only visual effect
124 &Aura::HandleModSpellCritChanceShool
, // 71 SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL
125 &Aura::HandleModPowerCostPCT
, // 72 SPELL_AURA_MOD_POWER_COST_SCHOOL_PCT
126 &Aura::HandleModPowerCost
, // 73 SPELL_AURA_MOD_POWER_COST_SCHOOL
127 &Aura::HandleNoImmediateEffect
, // 74 SPELL_AURA_REFLECT_SPELLS_SCHOOL implemented in Unit::SpellHitResult
128 &Aura::HandleNoImmediateEffect
, // 75 SPELL_AURA_MOD_LANGUAGE
129 &Aura::HandleFarSight
, // 76 SPELL_AURA_FAR_SIGHT
130 &Aura::HandleModMechanicImmunity
, // 77 SPELL_AURA_MECHANIC_IMMUNITY
131 &Aura::HandleAuraMounted
, // 78 SPELL_AURA_MOUNTED
132 &Aura::HandleModDamagePercentDone
, // 79 SPELL_AURA_MOD_DAMAGE_PERCENT_DONE
133 &Aura::HandleModPercentStat
, // 80 SPELL_AURA_MOD_PERCENT_STAT
134 &Aura::HandleNoImmediateEffect
, // 81 SPELL_AURA_SPLIT_DAMAGE_PCT
135 &Aura::HandleWaterBreathing
, // 82 SPELL_AURA_WATER_BREATHING
136 &Aura::HandleModBaseResistance
, // 83 SPELL_AURA_MOD_BASE_RESISTANCE
137 &Aura::HandleModRegen
, // 84 SPELL_AURA_MOD_REGEN
138 &Aura::HandleModPowerRegen
, // 85 SPELL_AURA_MOD_POWER_REGEN
139 &Aura::HandleChannelDeathItem
, // 86 SPELL_AURA_CHANNEL_DEATH_ITEM
140 &Aura::HandleNoImmediateEffect
, // 87 SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus
141 &Aura::HandleNoImmediateEffect
, // 88 SPELL_AURA_MOD_HEALTH_REGEN_PERCENT
142 &Aura::HandlePeriodicDamagePCT
, // 89 SPELL_AURA_PERIODIC_DAMAGE_PERCENT
143 &Aura::HandleUnused
, // 90 SPELL_AURA_MOD_RESIST_CHANCE Useless
144 &Aura::HandleNoImmediateEffect
, // 91 SPELL_AURA_MOD_DETECT_RANGE implemented in Creature::GetAttackDistance
145 &Aura::HandlePreventFleeing
, // 92 SPELL_AURA_PREVENTS_FLEEING
146 &Aura::HandleModUnattackable
, // 93 SPELL_AURA_MOD_UNATTACKABLE
147 &Aura::HandleNoImmediateEffect
, // 94 SPELL_AURA_INTERRUPT_REGEN implemented in Player::RegenerateAll
148 &Aura::HandleAuraGhost
, // 95 SPELL_AURA_GHOST
149 &Aura::HandleNoImmediateEffect
, // 96 SPELL_AURA_SPELL_MAGNET implemented in Spell::SelectMagnetTarget
150 &Aura::HandleManaShield
, // 97 SPELL_AURA_MANA_SHIELD implemented in Unit::CalcAbsorbResist
151 &Aura::HandleAuraModSkill
, // 98 SPELL_AURA_MOD_SKILL_TALENT
152 &Aura::HandleAuraModAttackPower
, // 99 SPELL_AURA_MOD_ATTACK_POWER
153 &Aura::HandleUnused
, //100 SPELL_AURA_AURAS_VISIBLE obsolete? all player can see all auras now
154 &Aura::HandleModResistancePercent
, //101 SPELL_AURA_MOD_RESISTANCE_PCT
155 &Aura::HandleNoImmediateEffect
, //102 SPELL_AURA_MOD_MELEE_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonus
156 &Aura::HandleAuraModTotalThreat
, //103 SPELL_AURA_MOD_TOTAL_THREAT
157 &Aura::HandleAuraWaterWalk
, //104 SPELL_AURA_WATER_WALK
158 &Aura::HandleAuraFeatherFall
, //105 SPELL_AURA_FEATHER_FALL
159 &Aura::HandleAuraHover
, //106 SPELL_AURA_HOVER
160 &Aura::HandleAddModifier
, //107 SPELL_AURA_ADD_FLAT_MODIFIER
161 &Aura::HandleAddModifier
, //108 SPELL_AURA_ADD_PCT_MODIFIER
162 &Aura::HandleAddTargetTrigger
, //109 SPELL_AURA_ADD_TARGET_TRIGGER
163 &Aura::HandleModPowerRegenPCT
, //110 SPELL_AURA_MOD_POWER_REGEN_PERCENT
164 &Aura::HandleNULL
, //111 SPELL_AURA_ADD_CASTER_HIT_TRIGGER
165 &Aura::HandleNoImmediateEffect
, //112 SPELL_AURA_OVERRIDE_CLASS_SCRIPTS
166 &Aura::HandleNoImmediateEffect
, //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus
167 &Aura::HandleNoImmediateEffect
, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus
168 &Aura::HandleNoImmediateEffect
, //115 SPELL_AURA_MOD_HEALING implemented in Unit::SpellBaseHealingBonusForVictim
169 &Aura::HandleNoImmediateEffect
, //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT
170 &Aura::HandleNoImmediateEffect
, //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE implemented in Unit::MagicSpellHitResult
171 &Aura::HandleNoImmediateEffect
, //118 SPELL_AURA_MOD_HEALING_PCT implemented in Unit::SpellHealingBonus
172 &Aura::HandleUnused
, //119 SPELL_AURA_SHARE_PET_TRACKING useless
173 &Aura::HandleAuraUntrackable
, //120 SPELL_AURA_UNTRACKABLE
174 &Aura::HandleAuraEmpathy
, //121 SPELL_AURA_EMPATHY
175 &Aura::HandleModOffhandDamagePercent
, //122 SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT
176 &Aura::HandleModTargetResistance
, //123 SPELL_AURA_MOD_TARGET_RESISTANCE
177 &Aura::HandleAuraModRangedAttackPower
, //124 SPELL_AURA_MOD_RANGED_ATTACK_POWER
178 &Aura::HandleNoImmediateEffect
, //125 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus
179 &Aura::HandleNoImmediateEffect
, //126 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus
180 &Aura::HandleNoImmediateEffect
, //127 SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus
181 &Aura::HandleModPossessPet
, //128 SPELL_AURA_MOD_POSSESS_PET
182 &Aura::HandleAuraModIncreaseSpeed
, //129 SPELL_AURA_MOD_SPEED_ALWAYS
183 &Aura::HandleAuraModIncreaseMountedSpeed
, //130 SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS
184 &Aura::HandleNoImmediateEffect
, //131 SPELL_AURA_MOD_RANGED_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonus
185 &Aura::HandleAuraModIncreaseEnergyPercent
, //132 SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT
186 &Aura::HandleAuraModIncreaseHealthPercent
, //133 SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT
187 &Aura::HandleAuraModRegenInterrupt
, //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT
188 &Aura::HandleModHealingDone
, //135 SPELL_AURA_MOD_HEALING_DONE
189 &Aura::HandleNoImmediateEffect
, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus
190 &Aura::HandleModTotalPercentStat
, //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
191 &Aura::HandleHaste
, //138 SPELL_AURA_MOD_HASTE
192 &Aura::HandleForceReaction
, //139 SPELL_AURA_FORCE_REACTION
193 &Aura::HandleAuraModRangedHaste
, //140 SPELL_AURA_MOD_RANGED_HASTE
194 &Aura::HandleRangedAmmoHaste
, //141 SPELL_AURA_MOD_RANGED_AMMO_HASTE
195 &Aura::HandleAuraModBaseResistancePCT
, //142 SPELL_AURA_MOD_BASE_RESISTANCE_PCT
196 &Aura::HandleAuraModResistanceExclusive
, //143 SPELL_AURA_MOD_RESISTANCE_EXCLUSIVE
197 &Aura::HandleNoImmediateEffect
, //144 SPELL_AURA_SAFE_FALL implemented in WorldSession::HandleMovementOpcodes
198 &Aura::HandleAuraModPetTalentsPoints
, //145 SPELL_AURA_MOD_PET_TALENT_POINTS
199 &Aura::HandleNoImmediateEffect
, //146 SPELL_AURA_ALLOW_TAME_PET_TYPE
200 &Aura::HandleNULL
, //147 SPELL_AURA_ADD_CREATURE_IMMUNITY
201 &Aura::HandleAuraRetainComboPoints
, //148 SPELL_AURA_RETAIN_COMBO_POINTS
202 &Aura::HandleNoImmediateEffect
, //149 SPELL_AURA_REDUCE_PUSHBACK
203 &Aura::HandleShieldBlockValue
, //150 SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT
204 &Aura::HandleAuraTrackStealthed
, //151 SPELL_AURA_TRACK_STEALTHED
205 &Aura::HandleNoImmediateEffect
, //152 SPELL_AURA_MOD_DETECTED_RANGE implemented in Creature::GetAttackDistance
206 &Aura::HandleNoImmediateEffect
, //153 SPELL_AURA_SPLIT_DAMAGE_FLAT
207 &Aura::HandleNoImmediateEffect
, //154 SPELL_AURA_MOD_STEALTH_LEVEL
208 &Aura::HandleNoImmediateEffect
, //155 SPELL_AURA_MOD_WATER_BREATHING
209 &Aura::HandleNoImmediateEffect
, //156 SPELL_AURA_MOD_REPUTATION_GAIN
210 &Aura::HandleNULL
, //157 SPELL_AURA_PET_DAMAGE_MULTI
211 &Aura::HandleShieldBlockValue
, //158 SPELL_AURA_MOD_SHIELD_BLOCKVALUE
212 &Aura::HandleNoImmediateEffect
, //159 SPELL_AURA_NO_PVP_CREDIT only for Honorless Target spell
213 &Aura::HandleNoImmediateEffect
, //160 SPELL_AURA_MOD_AOE_AVOIDANCE implemented in Unit::MagicSpellHitResult
214 &Aura::HandleNoImmediateEffect
, //161 SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT
215 &Aura::HandleAuraPowerBurn
, //162 SPELL_AURA_POWER_BURN_MANA
216 &Aura::HandleNoImmediateEffect
, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE
217 &Aura::HandleUnused
, //164 useless, only one test spell
218 &Aura::HandleNoImmediateEffect
, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus
219 &Aura::HandleAuraModAttackPowerPercent
, //166 SPELL_AURA_MOD_ATTACK_POWER_PCT
220 &Aura::HandleAuraModRangedAttackPowerPercent
, //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT
221 &Aura::HandleNoImmediateEffect
, //168 SPELL_AURA_MOD_DAMAGE_DONE_VERSUS implemented in Unit::SpellDamageBonus, Unit::MeleeDamageBonus
222 &Aura::HandleNoImmediateEffect
, //169 SPELL_AURA_MOD_CRIT_PERCENT_VERSUS implemented in Unit::DealDamageBySchool, Unit::DoAttackDamage, Unit::SpellCriticalBonus
223 &Aura::HandleNULL
, //170 SPELL_AURA_DETECT_AMORE only for Detect Amore spell
224 &Aura::HandleAuraModIncreaseSpeed
, //171 SPELL_AURA_MOD_SPEED_NOT_STACK
225 &Aura::HandleAuraModIncreaseMountedSpeed
, //172 SPELL_AURA_MOD_MOUNTED_SPEED_NOT_STACK
226 &Aura::HandleUnused
, //173 SPELL_AURA_ALLOW_CHAMPION_SPELLS only for Proclaim Champion spell
227 &Aura::HandleModSpellDamagePercentFromStat
, //174 SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT implemented in Unit::SpellBaseDamageBonus
228 &Aura::HandleModSpellHealingPercentFromStat
, //175 SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT implemented in Unit::SpellBaseHealingBonus
229 &Aura::HandleSpiritOfRedemption
, //176 SPELL_AURA_SPIRIT_OF_REDEMPTION only for Spirit of Redemption spell, die at aura end
230 &Aura::HandleNULL
, //177 SPELL_AURA_AOE_CHARM
231 &Aura::HandleNoImmediateEffect
, //178 SPELL_AURA_MOD_DEBUFF_RESISTANCE implemented in Unit::MagicSpellHitResult
232 &Aura::HandleNoImmediateEffect
, //179 SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE implemented in Unit::SpellCriticalBonus
233 &Aura::HandleNoImmediateEffect
, //180 SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS implemented in Unit::SpellDamageBonus
234 &Aura::HandleUnused
, //181 SPELL_AURA_MOD_FLAT_SPELL_CRIT_DAMAGE_VERSUS unused
235 &Aura::HandleAuraModResistenceOfStatPercent
, //182 SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT
236 &Aura::HandleNULL
, //183 SPELL_AURA_MOD_CRITICAL_THREAT
237 &Aura::HandleNoImmediateEffect
, //184 SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
238 &Aura::HandleNoImmediateEffect
, //185 SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
239 &Aura::HandleNoImmediateEffect
, //186 SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE implemented in Unit::MagicSpellHitResult
240 &Aura::HandleNoImmediateEffect
, //187 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance
241 &Aura::HandleNoImmediateEffect
, //188 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance
242 &Aura::HandleModRating
, //189 SPELL_AURA_MOD_RATING
243 &Aura::HandleNULL
, //190 SPELL_AURA_MOD_FACTION_REPUTATION_GAIN
244 &Aura::HandleAuraModUseNormalSpeed
, //191 SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED
245 &Aura::HandleModMeleeRangedSpeedPct
, //192 SPELL_AURA_HASTE_MELEE
246 &Aura::HandleModCombatSpeedPct
, //193 SPELL_AURA_MELEE_SLOW (in fact combat (any type attack) speed pct)
247 &Aura::HandleUnused
, //194 SPELL_AURA_MOD_IGNORE_ABSORB_SCHOOL
248 &Aura::HandleNoImmediateEffect
, //195 SPELL_AURA_MOD_IGNORE_ABSORB_FOR_SPELL implement in Unit::CalculateSpellDamage
249 &Aura::HandleNULL
, //196 SPELL_AURA_MOD_COOLDOWN
250 &Aura::HandleNoImmediateEffect
, //197 SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE implemented in Unit::SpellCriticalBonus Unit::GetUnitCriticalChance
251 &Aura::HandleUnused
, //198 SPELL_AURA_MOD_ALL_WEAPON_SKILLS
252 &Aura::HandleNoImmediateEffect
, //199 SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT implemented in Unit::MagicSpellHitResult
253 &Aura::HandleNoImmediateEffect
, //200 SPELL_AURA_MOD_XP_PCT implemented in Player::GiveXP
254 &Aura::HandleAuraAllowFlight
, //201 SPELL_AURA_FLY this aura enable flight mode...
255 &Aura::HandleNoImmediateEffect
, //202 SPELL_AURA_CANNOT_BE_DODGED implemented in Unit::RollPhysicalOutcomeAgainst
256 &Aura::HandleNoImmediateEffect
, //203 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE implemented in Unit::CalculateMeleeDamage and Unit::CalculateSpellDamage
257 &Aura::HandleNoImmediateEffect
, //204 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE implemented in Unit::CalculateMeleeDamage and Unit::CalculateSpellDamage
258 &Aura::HandleNULL
, //205 vulnerable to school dmg?
259 &Aura::HandleNULL
, //206 SPELL_AURA_MOD_SPEED_MOUNTED
260 &Aura::HandleAuraModIncreaseFlightSpeed
, //207 SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
261 &Aura::HandleAuraModIncreaseFlightSpeed
, //208 SPELL_AURA_MOD_SPEED_FLIGHT, used only in spell: Flight Form (Passive)
262 &Aura::HandleAuraModIncreaseFlightSpeed
, //209 SPELL_AURA_MOD_FLIGHT_SPEED_ALWAYS
263 &Aura::HandleNULL
, //210 Commentator's Command
264 &Aura::HandleAuraModIncreaseFlightSpeed
, //211 SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK
265 &Aura::HandleAuraModRangedAttackPowerOfStatPercent
, //212 SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT
266 &Aura::HandleNoImmediateEffect
, //213 SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT implemented in Player::RewardRage
267 &Aura::HandleNULL
, //214 Tamed Pet Passive
268 &Aura::HandleArenaPreparation
, //215 SPELL_AURA_ARENA_PREPARATION
269 &Aura::HandleModCastingSpeed
, //216 SPELL_AURA_HASTE_SPELLS
270 &Aura::HandleUnused
, //217 unused
271 &Aura::HandleAuraModRangedHaste
, //218 SPELL_AURA_HASTE_RANGED
272 &Aura::HandleModManaRegen
, //219 SPELL_AURA_MOD_MANA_REGEN_FROM_STAT
273 &Aura::HandleModRatingFromStat
, //220 SPELL_AURA_MOD_RATING_FROM_STAT
274 &Aura::HandleNULL
, //221 ignored
275 &Aura::HandleUnused
, //222 unused
276 &Aura::HandleNULL
, //223 Cold Stare
277 &Aura::HandleUnused
, //224 unused
278 &Aura::HandleNoImmediateEffect
, //225 SPELL_AURA_PRAYER_OF_MENDING
279 &Aura::HandleAuraPeriodicDummy
, //226 SPELL_AURA_PERIODIC_DUMMY
280 &Aura::HandlePeriodicTriggerSpellWithValue
, //227 SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
281 &Aura::HandleNoImmediateEffect
, //228 stealth detection
282 &Aura::HandleNULL
, //229 SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE
283 &Aura::HandleAuraModIncreaseMaxHealth
, //230 Commanding Shout
284 &Aura::HandleNoImmediateEffect
, //231 SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE
285 &Aura::HandleNoImmediateEffect
, //232 SPELL_AURA_MECHANIC_DURATION_MOD implement in Unit::CalculateSpellDuration
286 &Aura::HandleNULL
, //233 set model id to the one of the creature with id m_modifier.m_miscvalue
287 &Aura::HandleNoImmediateEffect
, //234 SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK implement in Unit::CalculateSpellDuration
288 &Aura::HandleAuraModDispelResist
, //235 SPELL_AURA_MOD_DISPEL_RESIST implement in Unit::MagicSpellHitResult
289 &Aura::HandleAuraControlVehicle
, //236 SPELL_AURA_CONTROL_VEHICLE
290 &Aura::HandleModSpellDamagePercentFromAttackPower
, //237 SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER implemented in Unit::SpellBaseDamageBonus
291 &Aura::HandleModSpellHealingPercentFromAttackPower
, //238 SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER implemented in Unit::SpellBaseHealingBonus
292 &Aura::HandleAuraModScale
, //239 SPELL_AURA_MOD_SCALE_2 only in Noggenfogger Elixir (16595) before 2.3.0 aura 61
293 &Aura::HandleAuraModExpertise
, //240 SPELL_AURA_MOD_EXPERTISE
294 &Aura::HandleForceMoveForward
, //241 Forces the player to move forward
295 &Aura::HandleUnused
, //242 SPELL_AURA_MOD_SPELL_DAMAGE_FROM_HEALING
296 &Aura::HandleUnused
, //243 used by two test spells
297 &Aura::HandleComprehendLanguage
, //244 Comprehend language
298 &Aura::HandleUnused
, //245 SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS
299 &Aura::HandleNoImmediateEffect
, //246 SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL
300 &Aura::HandleUnused
, //247 unused
301 &Aura::HandleNoImmediateEffect
, //248 SPELL_AURA_MOD_COMBAT_RESULT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
302 &Aura::HandleAuraConvertRune
, //249 SPELL_AURA_CONVERT_RUNE
303 &Aura::HandleAuraModIncreaseHealth
, //250 SPELL_AURA_MOD_INCREASE_HEALTH_2
304 &Aura::HandleNULL
, //251 SPELL_AURA_MOD_ENEMY_DODGE
305 &Aura::HandleNULL
, //252 haste all?
306 &Aura::HandleNULL
, //253 SPELL_AURA_MOD_BLOCK_CRIT_CHANCE
307 &Aura::HandleNULL
, //254 SPELL_AURA_MOD_DISARM_SHIELD disarm Shield
308 &Aura::HandleNoImmediateEffect
, //255 SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT implemented in Unit::SpellDamageBonus
309 &Aura::HandleNoReagentUseAura
, //256 SPELL_AURA_NO_REAGENT_USE Use SpellClassMask for spell select
310 &Aura::HandleNULL
, //257 SPELL_AURA_MOD_TARGET_RESIST_BY_SPELL_CLASS Use SpellClassMask for spell select
311 &Aura::HandleNULL
, //258 SPELL_AURA_MOD_SPELL_VISUAL
312 &Aura::HandleNULL
, //259 corrupt healing over time spell
313 &Aura::HandleNoImmediateEffect
, //260 SPELL_AURA_SCREEN_EFFECT (miscvalue = id in ScreenEffect.dbc) not required any code
314 &Aura::HandlePhase
, //261 SPELL_AURA_PHASE undetactable invisibility? implemented in Unit::isVisibleForOrDetect
315 &Aura::HandleNULL
, //262
316 &Aura::HandleNULL
, //263 SPELL_AURA_ALLOW_ONLY_ABILITY player can use only abilities set in SpellClassMask
317 &Aura::HandleNULL
, //264 unused
318 &Aura::HandleNULL
, //265 unused
319 &Aura::HandleNULL
, //266 unused
320 &Aura::HandleNoImmediateEffect
, //267 SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL implemented in Unit::IsImmunedToSpellEffect
321 &Aura::HandleAuraModAttackPowerOfStatPercent
, //268 SPELL_AURA_MOD_ATTACK_POWER_OF_STAT_PERCENT
322 &Aura::HandleNULL
, //269 ignore DR effects?
323 &Aura::HandleNULL
, //270 SPELL_AURA_MOD_IGNORE_TARGET_RESIST
324 &Aura::HandleNoImmediateEffect
, //271 SPELL_AURA_MOD_DAMAGE_FROM_CASTER implemented in Unit::SpellDamageBonus
325 &Aura::HandleNULL
, //272 reduce spell cast time?
326 &Aura::HandleNULL
, //273
327 &Aura::HandleNULL
, //274 proc free shot?
328 &Aura::HandleNoImmediateEffect
, //275 SPELL_AURA_MOD_IGNORE_SHAPESHIFT Use SpellClassMask for spell select
329 &Aura::HandleNULL
, //276 mod damage % mechanic?
330 &Aura::HandleNoImmediateEffect
, //277 SPELL_AURA_MOD_MAX_AFFECTED_TARGETS Use SpellClassMask for spell select
331 &Aura::HandleNULL
, //278 SPELL_AURA_MOD_DISARM_RANGED disarm ranged weapon
332 &Aura::HandleNULL
, //279
333 &Aura::HandleNULL
, //280 SPELL_AURA_MOD_TARGET_ARMOR_PCT
334 &Aura::HandleNULL
, //281 SPELL_AURA_MOD_HONOR_GAIN
335 &Aura::HandleAuraIncreaseBaseHealthPercent
, //282 SPELL_AURA_INCREASE_BASE_HEALTH_PERCENT
336 &Aura::HandleNoImmediateEffect
//283 SPELL_AURA_MOD_HEALING_RECEIVED implemented in Unit::SpellHealingBonus
339 Aura::Aura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
, Unit
*caster
, Item
* castItem
) :
340 m_spellmod(NULL
), m_caster_guid(0), m_castItemGuid(castItem
?castItem
->GetGUID():0), m_target(target
),
341 m_timeCla(1000), m_periodicTimer(0), m_removeMode(AURA_REMOVE_BY_DEFAULT
), m_AuraDRGroup(DIMINISHING_NONE
),
342 m_effIndex(eff
), m_auraSlot(MAX_AURAS
), m_auraFlags(AFLAG_NONE
), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),
343 m_positive(false), m_permanent(false), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false),
344 m_updated(false), m_isRemovedOnShapeLost(true), m_in_use(false)
348 assert(spellproto
&& spellproto
== sSpellStore
.LookupEntry( spellproto
->Id
) && "`info` must be pointer to sSpellStore element");
350 m_spellProto
= spellproto
;
352 m_currentBasePoints
= currentBasePoints
? *currentBasePoints
: m_spellProto
->EffectBasePoints
[eff
];
354 m_isPassive
= IsPassiveSpell(GetId());
355 m_positive
= IsPositiveEffect(GetId(), m_effIndex
);
357 m_applyTime
= time(NULL
);
362 m_caster_guid
= target
->GetGUID();
363 damage
= m_currentBasePoints
+1; // stored value-1
364 m_maxduration
= target
->CalculateSpellDuration(m_spellProto
, m_effIndex
, target
);
368 m_caster_guid
= caster
->GetGUID();
370 damage
= caster
->CalculateSpellDamage(m_spellProto
,m_effIndex
,m_currentBasePoints
,target
);
371 m_maxduration
= caster
->CalculateSpellDuration(m_spellProto
, m_effIndex
, target
);
373 if (!damage
&& castItem
&& castItem
->GetItemSuffixFactor())
375 ItemRandomSuffixEntry
const *item_rand_suffix
= sItemRandomSuffixStore
.LookupEntry(abs(castItem
->GetItemRandomPropertyId()));
378 for (int k
=0; k
<3; k
++)
380 SpellItemEnchantmentEntry
const *pEnchant
= sSpellItemEnchantmentStore
.LookupEntry(item_rand_suffix
->enchant_id
[k
]);
383 for (int t
=0; t
<3; t
++)
384 if(pEnchant
->spellid
[t
] == m_spellProto
->Id
)
386 damage
= uint32((item_rand_suffix
->prefix
[k
]*castItem
->GetItemSuffixFactor()) / 10000 );
398 if(m_maxduration
== -1 || m_isPassive
&& m_spellProto
->DurationIndex
== 0)
401 Player
* modOwner
= caster
? caster
->GetSpellModOwner() : NULL
;
403 if(!m_permanent
&& modOwner
)
404 modOwner
->ApplySpellMod(GetId(), SPELLMOD_DURATION
, m_maxduration
);
406 m_duration
= m_maxduration
;
408 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
);
411 SetModifier(AuraType(m_spellProto
->EffectApplyAuraName
[eff
]), damage
, m_spellProto
->EffectAmplitude
[eff
], m_spellProto
->EffectMiscValue
[eff
]);
413 // Apply periodic time mod
414 if(modOwner
&& m_modifier
.periodictime
)
415 modOwner
->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME
, m_modifier
.periodictime
);
417 // Start periodic on next tick or at aura apply
418 if (!(m_spellProto
->AttributesEx5
& SPELL_ATTR_EX5_START_PERIODIC_AT_APPLY
))
419 m_periodicTimer
+= m_modifier
.periodictime
;
421 m_isDeathPersist
= IsDeathPersistentSpell(m_spellProto
);
423 m_procCharges
= m_spellProto
->procCharges
;
425 modOwner
->ApplySpellMod(GetId(), SPELLMOD_CHARGES
, m_procCharges
);
427 m_isRemovedOnShapeLost
= (m_caster_guid
==m_target
->GetGUID() &&
428 m_spellProto
->Stances
&&
429 !(m_spellProto
->AttributesEx2
& SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT
) &&
430 !(m_spellProto
->Attributes
& SPELL_ATTR_NOT_SHAPESHIFT
));
437 AreaAura::AreaAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
,
438 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
442 // caster==NULL in constructor args if target==caster in fact
443 Unit
* caster_ptr
= caster
? caster
: target
;
445 m_radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(GetSpellProto()->EffectRadiusIndex
[m_effIndex
]));
446 if(Player
* modOwner
= caster_ptr
->GetSpellModOwner())
447 modOwner
->ApplySpellMod(GetId(), SPELLMOD_RADIUS
, m_radius
);
449 switch(spellproto
->Effect
[eff
])
451 case SPELL_EFFECT_APPLY_AREA_AURA_PARTY
:
452 m_areaAuraType
= AREA_AURA_PARTY
;
453 if(target
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)target
)->isTotem())
454 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
456 case SPELL_EFFECT_APPLY_AREA_AURA_RAID
:
457 m_areaAuraType
= AREA_AURA_RAID
;
458 if(target
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)target
)->isTotem())
459 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
461 case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
:
462 m_areaAuraType
= AREA_AURA_FRIEND
;
464 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
:
465 m_areaAuraType
= AREA_AURA_ENEMY
;
466 if(target
== caster_ptr
)
467 m_modifier
.m_auraname
= SPELL_AURA_NONE
; // Do not do any effect on self
469 case SPELL_EFFECT_APPLY_AREA_AURA_PET
:
470 m_areaAuraType
= AREA_AURA_PET
;
472 case SPELL_EFFECT_APPLY_AREA_AURA_OWNER
:
473 m_areaAuraType
= AREA_AURA_OWNER
;
474 if(target
== caster_ptr
)
475 m_modifier
.m_auraname
= SPELL_AURA_NONE
;
478 sLog
.outError("Wrong spell effect in AreaAura constructor");
484 AreaAura::~AreaAura()
488 PersistentAreaAura::PersistentAreaAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
,
489 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
491 m_isPersistent
= true;
494 PersistentAreaAura::~PersistentAreaAura()
498 SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
,
499 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
)
502 m_casters_target_guid
= caster
->GetTypeId()==TYPEID_PLAYER
? ((Player
*)caster
)->GetSelection() : caster
->GetUInt64Value(UNIT_FIELD_TARGET
);
504 m_casters_target_guid
= 0;
507 SingleEnemyTargetAura::~SingleEnemyTargetAura()
511 Unit
* SingleEnemyTargetAura::GetTriggerTarget() const
513 return ObjectAccessor::GetUnit(*m_target
, m_casters_target_guid
);
516 Aura
* CreateAura(SpellEntry
const* spellproto
, uint32 eff
, int32
*currentBasePoints
, Unit
*target
, Unit
*caster
, Item
* castItem
)
518 if (IsAreaAuraEffect(spellproto
->Effect
[eff
]))
519 return new AreaAura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
521 uint32 triggeredSpellId
= spellproto
->EffectTriggerSpell
[eff
];
523 if(SpellEntry
const* triggeredSpellInfo
= sSpellStore
.LookupEntry(triggeredSpellId
))
524 for (int i
= 0; i
< 3; ++i
)
525 if (triggeredSpellInfo
->EffectImplicitTargetA
[i
] == TARGET_SINGLE_ENEMY
)
526 return new SingleEnemyTargetAura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
528 return new Aura(spellproto
, eff
, currentBasePoints
, target
, caster
, castItem
);
531 Unit
* Aura::GetCaster() const
533 if(m_caster_guid
==m_target
->GetGUID())
536 //return ObjectAccessor::GetUnit(*m_target,m_caster_guid);
537 //must return caster even if it's in another grid/map
538 Unit
*unit
= ObjectAccessor::GetObjectInWorld(m_caster_guid
, (Unit
*)NULL
);
539 return unit
&& unit
->IsInWorld() ? unit
: NULL
;
542 void Aura::SetModifier(AuraType t
, int32 a
, uint32 pt
, int32 miscValue
)
544 m_modifier
.m_auraname
= t
;
545 m_modifier
.m_amount
= a
;
546 m_modifier
.m_miscvalue
= miscValue
;
547 m_modifier
.periodictime
= pt
;
550 void Aura::Update(uint32 diff
)
559 // GetEffIndex()==0 prevent double/triple apply manaPerSecond/manaPerSecondPerLevel to same spell with many auras
560 // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0
561 if(GetEffIndex()==0 && m_timeCla
<= 0)
563 if(Unit
* caster
= GetCaster())
565 Powers powertype
= Powers(m_spellProto
->powerType
);
566 int32 manaPerSecond
= m_spellProto
->manaPerSecond
+ m_spellProto
->manaPerSecondPerLevel
* caster
->getLevel();
570 if(powertype
==POWER_HEALTH
)
571 caster
->ModifyHealth(-manaPerSecond
);
573 caster
->ModifyPower(powertype
,-manaPerSecond
);
579 // Channeled aura required check distance from caster
580 if(IsChanneledSpell(m_spellProto
) && m_caster_guid
!= m_target
->GetGUID())
582 Unit
* caster
= GetCaster();
585 m_target
->RemoveAura(GetId(),GetEffIndex());
592 if (m_spellProto
->EffectRadiusIndex
[GetEffIndex()])
594 radius
= GetSpellRadius(sSpellRadiusStore
.LookupEntry(m_spellProto
->EffectRadiusIndex
[GetEffIndex()]));
595 mod
= SPELLMOD_RADIUS
;
599 radius
= GetSpellMaxRange(sSpellRangeStore
.LookupEntry(m_spellProto
->rangeIndex
));
600 mod
= SPELLMOD_RANGE
;
603 if(Player
* modOwner
= caster
->GetSpellModOwner())
604 modOwner
->ApplySpellMod(GetId(), mod
, radius
,NULL
);
606 if(!caster
->IsWithinDistInMap(m_target
,radius
))
608 m_target
->RemoveAura(GetId(),GetEffIndex());
613 if(m_isPeriodic
&& (m_duration
>= 0 || m_isPassive
|| m_permanent
))
615 m_periodicTimer
-= diff
;
616 if(m_periodicTimer
<= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N
618 // update before applying (aura can be removed in TriggerSpell or PeriodicTick calls)
619 m_periodicTimer
+= m_modifier
.periodictime
;
625 void AreaAura::Update(uint32 diff
)
627 // update for the caster of the aura
628 if(m_caster_guid
== m_target
->GetGUID())
630 Unit
* caster
= m_target
;
632 if( !caster
->hasUnitState(UNIT_STAT_ISOLATED
) )
634 Unit
* owner
= caster
->GetCharmerOrOwner();
637 std::list
<Unit
*> targets
;
639 switch(m_areaAuraType
)
641 case AREA_AURA_PARTY
:
643 Group
*pGroup
= NULL
;
645 if (owner
->GetTypeId() == TYPEID_PLAYER
)
646 pGroup
= ((Player
*)owner
)->GetGroup();
650 uint8 subgroup
= ((Player
*)owner
)->GetSubGroup();
651 for(GroupReference
*itr
= pGroup
->GetFirstMember(); itr
!= NULL
; itr
= itr
->next())
653 Player
* Target
= itr
->getSource();
654 if(Target
&& Target
->isAlive() && Target
->GetSubGroup()==subgroup
&& caster
->IsFriendlyTo(Target
))
656 if(caster
->IsWithinDistInMap(Target
, m_radius
))
657 targets
.push_back(Target
);
658 Pet
*pet
= Target
->GetPet();
659 if(pet
&& pet
->isAlive() && caster
->IsWithinDistInMap(pet
, m_radius
))
660 targets
.push_back(pet
);
667 if( owner
!= caster
&& caster
->IsWithinDistInMap(owner
, m_radius
) )
668 targets
.push_back(owner
);
670 Unit
* pet
= caster
->GetPet();
671 if( pet
&& caster
->IsWithinDistInMap(pet
, m_radius
))
672 targets
.push_back(pet
);
678 Group
*pGroup
= NULL
;
680 if (owner
->GetTypeId() == TYPEID_PLAYER
)
681 pGroup
= ((Player
*)owner
)->GetGroup();
685 uint8 subgroup
= ((Player
*)owner
)->GetSubGroup();
686 for(GroupReference
*itr
= pGroup
->GetFirstMember(); itr
!= NULL
; itr
= itr
->next())
688 Player
* Target
= itr
->getSource();
689 if(Target
&& Target
->isAlive() && caster
->IsFriendlyTo(Target
))
691 if(caster
->IsWithinDistInMap(Target
, m_radius
))
692 targets
.push_back(Target
);
693 Pet
*pet
= Target
->GetPet();
694 if(pet
&& pet
->isAlive() && caster
->IsWithinDistInMap(pet
, m_radius
))
695 targets
.push_back(pet
);
702 if( owner
!= caster
&& caster
->IsWithinDistInMap(owner
, m_radius
) )
703 targets
.push_back(owner
);
705 Unit
* pet
= caster
->GetPet();
706 if( pet
&& caster
->IsWithinDistInMap(pet
, m_radius
))
707 targets
.push_back(pet
);
711 case AREA_AURA_FRIEND
:
713 CellPair
p(MaNGOS::ComputeCellPair(caster
->GetPositionX(), caster
->GetPositionY()));
715 cell
.data
.Part
.reserved
= ALL_DISTRICT
;
718 MaNGOS::AnyFriendlyUnitInObjectRangeCheck
u_check(caster
, owner
, m_radius
);
719 MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
> searcher(caster
,targets
, u_check
);
720 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
>, WorldTypeMapContainer
> world_unit_searcher(searcher
);
721 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyFriendlyUnitInObjectRangeCheck
>, GridTypeMapContainer
> grid_unit_searcher(searcher
);
722 CellLock
<GridReadGuard
> cell_lock(cell
, p
);
723 cell_lock
->Visit(cell_lock
, world_unit_searcher
, *caster
->GetMap());
724 cell_lock
->Visit(cell_lock
, grid_unit_searcher
, *caster
->GetMap());
727 case AREA_AURA_ENEMY
:
729 CellPair
p(MaNGOS::ComputeCellPair(caster
->GetPositionX(), caster
->GetPositionY()));
731 cell
.data
.Part
.reserved
= ALL_DISTRICT
;
734 MaNGOS::AnyAoETargetUnitInObjectRangeCheck
u_check(caster
, owner
, m_radius
); // No GetCharmer in searcher
735 MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
> searcher(caster
, targets
, u_check
);
736 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
>, WorldTypeMapContainer
> world_unit_searcher(searcher
);
737 TypeContainerVisitor
<MaNGOS::UnitListSearcher
<MaNGOS::AnyAoETargetUnitInObjectRangeCheck
>, GridTypeMapContainer
> grid_unit_searcher(searcher
);
738 CellLock
<GridReadGuard
> cell_lock(cell
, p
);
739 cell_lock
->Visit(cell_lock
, world_unit_searcher
, *caster
->GetMap());
740 cell_lock
->Visit(cell_lock
, grid_unit_searcher
, *caster
->GetMap());
743 case AREA_AURA_OWNER
:
747 targets
.push_back(owner
);
752 for(std::list
<Unit
*>::iterator tIter
= targets
.begin(); tIter
!= targets
.end(); tIter
++)
754 if((*tIter
)->HasAura(GetId(), m_effIndex
))
757 if(SpellEntry
const *actualSpellInfo
= spellmgr
.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter
)->getLevel()))
759 int32 actualBasePoints
= m_currentBasePoints
;
760 // recalculate basepoints for lower rank (all AreaAura spell not use custom basepoints?)
761 if(actualSpellInfo
!= GetSpellProto())
762 actualBasePoints
= actualSpellInfo
->EffectBasePoints
[m_effIndex
];
763 AreaAura
*aur
= new AreaAura(actualSpellInfo
, m_effIndex
, &actualBasePoints
, (*tIter
), caster
, NULL
);
764 aur
->SetAuraDuration(GetAuraDuration());
765 (*tIter
)->AddAura(aur
);
771 else // aura at non-caster
773 Unit
* tmp_target
= m_target
;
774 Unit
* caster
= GetCaster();
775 uint32 tmp_spellId
= GetId(), tmp_effIndex
= m_effIndex
;
777 // WARNING: the aura may get deleted during the update
778 // DO NOT access its members after update!
781 // remove aura if out-of-range from caster (after teleport for example)
782 // or caster is isolated or caster no longer has the aura
783 // or caster is (no longer) friendly
784 bool needFriendly
= (m_areaAuraType
== AREA_AURA_ENEMY
? false : true);
785 if( !caster
|| caster
->hasUnitState(UNIT_STAT_ISOLATED
) ||
786 !caster
->IsWithinDistInMap(tmp_target
, m_radius
) ||
787 !caster
->HasAura(tmp_spellId
, tmp_effIndex
) ||
788 caster
->IsFriendlyTo(tmp_target
) != needFriendly
791 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
793 else if( m_areaAuraType
== AREA_AURA_PARTY
) // check if in same sub group
795 // not check group if target == owner or target == pet
796 if (caster
->GetCharmerOrOwnerGUID() != tmp_target
->GetGUID() && caster
->GetGUID() != tmp_target
->GetCharmerOrOwnerGUID())
798 Player
* check
= caster
->GetCharmerOrOwnerPlayerOrPlayerItself();
800 Group
*pGroup
= check
? check
->GetGroup() : NULL
;
803 Player
* checkTarget
= tmp_target
->GetCharmerOrOwnerPlayerOrPlayerItself();
804 if(!checkTarget
|| !pGroup
->SameSubGroup(check
, checkTarget
))
805 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
808 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
811 else if( m_areaAuraType
== AREA_AURA_RAID
) // TODO: fix me!
813 // not check group if target == owner or target == pet
814 if (caster
->GetCharmerOrOwnerGUID() != tmp_target
->GetGUID() && caster
->GetGUID() != tmp_target
->GetCharmerOrOwnerGUID())
816 Player
* check
= caster
->GetCharmerOrOwnerPlayerOrPlayerItself();
818 Group
*pGroup
= check
? check
->GetGroup() : NULL
;
821 Player
* checkTarget
= tmp_target
->GetCharmerOrOwnerPlayerOrPlayerItself();
823 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
826 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
829 else if( m_areaAuraType
== AREA_AURA_PET
|| m_areaAuraType
== AREA_AURA_OWNER
)
831 if( tmp_target
->GetGUID() != caster
->GetCharmerOrOwnerGUID() )
832 tmp_target
->RemoveAura(tmp_spellId
, tmp_effIndex
);
837 void PersistentAreaAura::Update(uint32 diff
)
841 // remove the aura if its caster or the dynamic object causing it was removed
842 // or if the target moves too far from the dynamic object
843 Unit
*caster
= GetCaster();
846 DynamicObject
*dynObj
= caster
->GetDynObject(GetId(), GetEffIndex());
849 if (!m_target
->IsWithinDistInMap(dynObj
, dynObj
->GetRadius()))
858 Unit
*tmp_target
= m_target
;
859 uint32 tmp_id
= GetId(), tmp_index
= GetEffIndex();
861 // WARNING: the aura may get deleted during the update
862 // DO NOT access its members after update!
866 tmp_target
->RemoveAura(tmp_id
, tmp_index
);
869 void Aura::ApplyModifier(bool apply
, bool Real
)
871 AuraType aura
= m_modifier
.m_auraname
;
875 (*this.*AuraHandler
[aura
])(apply
,Real
);
879 void Aura::_AddAura()
886 // Second aura if some spell
887 bool secondaura
= false;
888 // Try find slot for aura
889 uint8 slot
= NULL_AURA_SLOT
;
890 // Lookup for some spell auras (and get slot from it)
891 for(uint8 i
= 0; i
< m_effIndex
; i
++)
893 Unit::spellEffectPair spair
= Unit::spellEffectPair(GetId(), i
);
894 for(Unit::AuraMap::const_iterator itr
= m_target
->GetAuras().lower_bound(spair
); itr
!= m_target
->GetAuras().upper_bound(spair
); ++itr
)
896 // allow use single slot only by auras from same caster
897 if(itr
->second
->GetCasterGUID()==GetCasterGUID())
899 slot
= itr
->second
->GetAuraSlot();
908 if (!secondaura
&& m_target
->GetVisibleAurasCount() < MAX_AURAS
)
910 Unit::VisibleAuraMap
const *visibleAuras
= m_target
->GetVisibleAuras();
911 for(uint8 i
= 0; i
< MAX_AURAS
; ++i
)
913 Unit::VisibleAuraMap::const_iterator itr
= visibleAuras
->find(i
);
914 if(itr
== visibleAuras
->end())
917 // update for out of range group members (on 1 slot use)
918 m_target
->UpdateAuraForGroup(slot
);
924 Unit
* caster
= GetCaster();
926 // passive auras (except totem auras) do not get placed in the slots
927 // area auras with SPELL_AURA_NONE are not shown on target
928 if((!m_isPassive
|| (caster
&& caster
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)caster
)->isTotem())) &&
929 (m_spellProto
->Effect
[GetEffIndex()] != SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
|| m_target
!= caster
))
932 if(slot
< MAX_AURAS
) // slot found send data to client
935 SetAuraFlags((1 << GetEffIndex()) | AFLAG_NOT_CASTER
| ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION
: AFLAG_NONE
) | (IsPositive() ? AFLAG_POSITIVE
: AFLAG_NEGATIVE
));
936 SetAuraLevel(caster
? caster
->getLevel() : sWorld
.getConfig(CONFIG_MAX_PLAYER_LEVEL
));
937 SendAuraUpdate(false);
940 //*****************************************************
941 // Update target aura state flag (at 1 aura apply)
942 // TODO: Make it easer
943 //*****************************************************
946 // Sitdown on apply aura req seated
947 if (m_spellProto
->AuraInterruptFlags
& AURA_INTERRUPT_FLAG_NOT_SEATED
&& !m_target
->IsSitState())
948 m_target
->SetStandState(UNIT_STAND_STATE_SIT
);
950 // register aura diminishing on apply
951 if (getDiminishGroup() != DIMINISHING_NONE
)
952 m_target
->ApplyDiminishingAura(getDiminishGroup(),true);
954 // Update Seals information
955 if (IsSealSpell(m_spellProto
))
956 m_target
->ModifyAuraState(AURA_STATE_JUDGEMENT
, true);
958 // Conflagrate aura state on Immolate
959 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARLOCK
&& m_spellProto
->SpellFamilyFlags
& 4)
960 m_target
->ModifyAuraState(AURA_STATE_IMMOLATE
, true);
962 // Faerie Fire (druid versions)
963 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_DRUID
&& m_spellProto
->SpellFamilyFlags
& 0x0000000000000400LL
)
964 m_target
->ModifyAuraState(AURA_STATE_FAERIE_FIRE
, true);
967 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& m_spellProto
->SpellFamilyFlags
& 0x0004000000000000LL
)
968 m_target
->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH
, true);
970 // Swiftmend state on Regrowth & Rejuvenation
971 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_DRUID
&& m_spellProto
->SpellFamilyFlags
& 0x50 )
972 m_target
->ModifyAuraState(AURA_STATE_SWIFTMEND
, true);
974 // Deadly poison aura state
975 if(m_spellProto
->SpellFamilyName
== SPELLFAMILY_ROGUE
&& m_spellProto
->SpellFamilyFlags
& 0x10000)
976 m_target
->ModifyAuraState(AURA_STATE_DEADLY_POISON
, true);
979 if(m_spellProto
->Dispel
== DISPEL_ENRAGE
)
980 m_target
->ModifyAuraState(AURA_STATE_ENRAGE
, true);
985 void Aura::_RemoveAura()
987 // Remove all triggered by aura spells vs unlimited duration
988 // except same aura replace case
989 if(m_removeMode
!=AURA_REMOVE_BY_STACK
)
990 CleanupTriggeredSpells();
992 Unit
* caster
= GetCaster();
994 if(caster
&& IsPersistent())
996 DynamicObject
*dynObj
= caster
->GetDynObject(GetId(), GetEffIndex());
998 dynObj
->RemoveAffected(m_target
);
1001 //passive auras do not get put in slots
1002 // Note: but totem can be not accessible for aura target in time remove (to far for find in grid)
1003 //if(m_isPassive && !(caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem()))
1006 uint8 slot
= GetAuraSlot();
1008 if(slot
>= MAX_AURAS
) // slot not set
1011 if(m_target
->GetVisibleAura(slot
) == 0)
1014 bool lastaura
= true;
1016 // find other aura in same slot (current already removed from list)
1017 for(uint8 i
= 0; i
< 3; i
++)
1019 Unit::spellEffectPair spair
= Unit::spellEffectPair(GetId(), i
);
1020 for(Unit::AuraMap::const_iterator itr
= m_target
->GetAuras().lower_bound(spair
); itr
!= m_target
->GetAuras().upper_bound(spair
); ++itr
)
1022 if(itr
->second
->GetAuraSlot()==slot
)
1032 // only remove icon when the last aura of the spell is removed (current aura already removed from list)
1035 // unregister aura diminishing (and store last time)
1036 if (getDiminishGroup() != DIMINISHING_NONE
)
1037 m_target
->ApplyDiminishingAura(getDiminishGroup(),false);
1040 SetAuraFlags(AFLAG_NONE
);
1042 SendAuraUpdate(true);
1044 // update for out of range group members
1045 m_target
->UpdateAuraForGroup(slot
);
1047 //*****************************************************
1048 // Update target aura state flag (at last aura remove)
1049 //*****************************************************
1050 // Enrage aura state
1051 if(m_spellProto
->Dispel
== DISPEL_ENRAGE
)
1052 m_target
->ModifyAuraState(AURA_STATE_ENRAGE
, false);
1054 uint32 removeState
= 0;
1055 switch(m_spellProto
->SpellFamilyName
)
1057 case SPELLFAMILY_PALADIN
:
1058 if (IsSealSpell(m_spellProto
))
1059 removeState
= AURA_STATE_JUDGEMENT
; // Update Seals information
1061 case SPELLFAMILY_WARLOCK
:
1062 if(m_spellProto
->SpellFamilyFlags
& 4)
1063 removeState
= AURA_STATE_IMMOLATE
; // Conflagrate aura state
1065 case SPELLFAMILY_DRUID
:
1066 if(m_spellProto
->SpellFamilyFlags
& 0x0000000000000400LL
)
1067 removeState
= AURA_STATE_FAERIE_FIRE
; // Faerie Fire (druid versions)
1068 else if(m_spellProto
->SpellFamilyFlags
& 0x50)
1069 removeState
= AURA_STATE_SWIFTMEND
; // Swiftmend aura state
1071 case SPELLFAMILY_WARRIOR
:
1072 if(m_spellProto
->SpellFamilyFlags
& 0x0004000000000000LL
)
1073 removeState
= AURA_STATE_WARRIOR_VICTORY_RUSH
; // Victorious
1075 case SPELLFAMILY_ROGUE
:
1076 if(m_spellProto
->SpellFamilyFlags
& 0x10000)
1077 removeState
= AURA_STATE_DEADLY_POISON
; // Deadly poison aura state
1079 case SPELLFAMILY_HUNTER
:
1080 if(m_spellProto
->SpellFamilyFlags
& 0x1000000000000000LL
)
1081 removeState
= AURA_STATE_FAERIE_FIRE
; // Sting (hunter versions)
1084 // Remove state (but need check other auras for it)
1088 Unit::AuraMap
& Auras
= m_target
->GetAuras();
1089 for(Unit::AuraMap::iterator i
= Auras
.begin(); i
!= Auras
.end(); ++i
)
1091 SpellEntry
const *auraSpellInfo
= (*i
).second
->GetSpellProto();
1092 if(auraSpellInfo
->SpellFamilyName
== m_spellProto
->SpellFamilyName
&&
1093 auraSpellInfo
->SpellFamilyFlags
== m_spellProto
->SpellFamilyFlags
)
1099 // this has been last aura
1101 m_target
->ModifyAuraState(AuraState(removeState
), false);
1104 // reset cooldown state for spells
1105 if(caster
&& caster
->GetTypeId() == TYPEID_PLAYER
)
1107 if ( GetSpellProto()->Attributes
& SPELL_ATTR_DISABLED_WHILE_ACTIVE
)
1108 ((Player
*)caster
)->SendCooldownEvent(GetSpellProto());
1113 void Aura::SendAuraUpdate(bool remove
)
1115 WorldPacket
data(SMSG_AURA_UPDATE
);
1116 data
.append(m_target
->GetPackGUID());
1117 data
<< uint8(GetAuraSlot());
1118 data
<< uint32(remove
? 0 : GetId());
1122 m_target
->SendMessageToSet(&data
, true);
1126 uint8 auraFlags
= GetAuraFlags();
1127 data
<< uint8(auraFlags
);
1128 data
<< uint8(GetAuraLevel());
1129 data
<< uint8(m_procCharges
? m_procCharges
: m_stackAmount
);
1131 if(!(auraFlags
& AFLAG_NOT_CASTER
))
1133 data
<< uint8(0); // pguid
1136 if(auraFlags
& AFLAG_DURATION
)
1138 data
<< uint32(GetAuraMaxDuration());
1139 data
<< uint32(GetAuraDuration());
1142 m_target
->SendMessageToSet(&data
, true);
1145 void Aura::SetStackAmount(uint8 stackAmount
)
1147 if (stackAmount
!= m_stackAmount
)
1149 Unit
*target
= GetTarget();
1150 Unit
*caster
= GetCaster();
1151 if (!target
|| !caster
)
1153 m_stackAmount
= stackAmount
;
1154 int32 amount
= m_stackAmount
* caster
->CalculateSpellDamage(m_spellProto
, m_effIndex
, m_currentBasePoints
, target
);
1155 // Reapply if amount change
1156 if (amount
!=m_modifier
.m_amount
)
1158 ApplyModifier(false, true);
1159 m_modifier
.m_amount
= amount
;
1160 ApplyModifier(true, true);
1166 bool Aura::modStackAmount(int32 num
)
1169 if (!m_spellProto
->StackAmount
)
1172 // Modify stack but limit it
1173 int32 stackAmount
= m_stackAmount
+ num
;
1174 if (stackAmount
> m_spellProto
->StackAmount
)
1175 stackAmount
= m_spellProto
->StackAmount
;
1176 else if (stackAmount
<=0) // Last aura from stack removed
1179 return true; // need remove aura
1182 // Update stack amount
1183 SetStackAmount(stackAmount
);
1187 void Aura::RefreshAura()
1189 m_duration
= m_maxduration
;
1190 SendAuraUpdate(false);
1193 bool Aura::isAffectedOnSpell(SpellEntry
const *spell
) const
1195 // Check family name
1196 if (spell
->SpellFamilyName
!= m_spellProto
->SpellFamilyName
)
1198 // Check EffectClassMask
1199 uint32
const *ptr
= getAuraSpellClassMask();
1200 if (((uint64
*)ptr
)[0] & spell
->SpellFamilyFlags
)
1202 if (ptr
[2] & spell
->SpellFamilyFlags2
)
1207 /*********************************************************/
1208 /*** BASIC AURA FUNCTION ***/
1209 /*********************************************************/
1210 void Aura::HandleAddModifier(bool apply
, bool Real
)
1212 if(m_target
->GetTypeId() != TYPEID_PLAYER
|| !Real
)
1215 if(m_modifier
.m_miscvalue
>= MAX_SPELLMOD
)
1220 // Add custom charges for some mod aura
1221 switch (m_spellProto
->Id
)
1223 case 17941: // Shadow Trance
1224 case 22008: // Netherwind Focus
1225 case 31834: // Light's Grace
1226 case 34754: // Clearcasting
1227 case 34936: // Backlash
1228 case 48108: // Hot Streak
1229 case 54741: // Firestarter
1230 case 57761: // Fireball!
1235 SpellModifier
*mod
= new SpellModifier
;
1236 mod
->op
= SpellModOp(m_modifier
.m_miscvalue
);
1237 mod
->value
= m_modifier
.m_amount
;
1238 mod
->type
= SpellModType(m_modifier
.m_auraname
); // SpellModType value == spell aura types
1239 mod
->spellId
= GetId();
1242 SpellAffectEntry
const *spellAffect
= spellmgr
.GetSpellAffect(GetId(), m_effIndex
);
1244 ptr
= &spellAffect
->SpellClassMask
[0];
1249 case 0: ptr
= &m_spellProto
->EffectSpellClassMaskA
[0]; break;
1250 case 1: ptr
= &m_spellProto
->EffectSpellClassMaskB
[0]; break;
1251 case 2: ptr
= &m_spellProto
->EffectSpellClassMaskC
[0]; break;
1257 mod
->mask
= (uint64
)ptr
[0] | (uint64
)ptr
[1]<<32;
1258 mod
->mask2
= (uint64
)ptr
[2];
1259 mod
->charges
= m_procCharges
;
1264 uint64 spellFamilyMask
= m_spellmod
->mask
;
1266 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
1268 // reapply some passive spells after add/remove related spellmods
1269 if(m_spellProto
->SpellFamilyName
==SPELLFAMILY_WARRIOR
&& (spellFamilyMask
& 0x0000100000000000LL
))
1271 m_target
->RemoveAurasDueToSpell(45471);
1274 m_target
->CastSpell(m_target
,45471,true);
1277 void Aura::HandleAddTargetTrigger(bool apply
, bool Real
)
1279 // Use SpellModifier structure for check
1280 // used only fields:
1281 // spellId, mask, mask2
1284 SpellModifier
*mod
= new SpellModifier
;
1285 mod
->spellId
= GetId();
1288 SpellAffectEntry
const *spellAffect
= spellmgr
.GetSpellAffect(GetId(), m_effIndex
);
1290 ptr
= &spellAffect
->SpellClassMask
[0];
1295 case 0: ptr
= &m_spellProto
->EffectSpellClassMaskA
[0]; break;
1296 case 1: ptr
= &m_spellProto
->EffectSpellClassMaskB
[0]; break;
1297 case 2: ptr
= &m_spellProto
->EffectSpellClassMaskC
[0]; break;
1303 mod
->mask
= (uint64
)ptr
[0] | (uint64
)ptr
[1]<<32;
1304 mod
->mask2
= (uint64
)ptr
[2];
1314 void Aura::TriggerSpell()
1316 Unit
* caster
= GetCaster();
1317 Unit
* target
= GetTriggerTarget();
1319 if(!caster
|| !target
)
1322 // generic casting code with custom spells and target/caster customs
1323 uint32 trigger_spell_id
= GetSpellProto()->EffectTriggerSpell
[m_effIndex
];
1325 SpellEntry
const *triggeredSpellInfo
= sSpellStore
.LookupEntry(trigger_spell_id
);
1326 SpellEntry
const *auraSpellInfo
= GetSpellProto();
1327 uint32 auraId
= auraSpellInfo
->Id
;
1329 // specific code for cases with no trigger spell provided in field
1330 if (triggeredSpellInfo
== NULL
)
1332 switch(auraSpellInfo
->SpellFamilyName
)
1334 case SPELLFAMILY_GENERIC
:
1338 // Firestone Passive (1-5 ranks)
1345 if (caster
->GetTypeId()!=TYPEID_PLAYER
)
1347 Item
* item
= ((Player
*)caster
)->GetWeaponForAttack(BASE_ATTACK
);
1350 uint32 enchant_id
= 0;
1353 case 758: enchant_id
= 1803; break; // Rank 1
1354 case 17945: enchant_id
= 1823; break; // Rank 2
1355 case 17947: enchant_id
= 1824; break; // Rank 3
1356 case 17949: enchant_id
= 1825; break; // Rank 4
1357 case 27252: enchant_id
= 2645; break; // Rank 5
1361 // remove old enchanting before applying new
1362 ((Player
*)caster
)->ApplyEnchantment(item
,TEMP_ENCHANTMENT_SLOT
,false);
1363 item
->SetEnchantment(TEMP_ENCHANTMENT_SLOT
, enchant_id
, m_modifier
.periodictime
+1000, 0);
1364 // add new enchanting
1365 ((Player
*)caster
)->ApplyEnchantment(item
,TEMP_ENCHANTMENT_SLOT
,true);
1368 // // Periodic Mana Burn
1370 // // Polymorphic Ray
1371 // case 6965: break;
1372 // // Fire Nova (1-7 ranks)
1381 // Thaumaturgy Channel
1382 case 9712: trigger_spell_id
= 21029; break;
1383 // // Egan's Blaster
1384 // case 17368: break;
1386 // case 18347: break;
1387 // // Ranshalla Waiting
1388 // case 18953: break;
1390 // case 19695: break;
1391 // // Frostwolf Muzzle DND
1392 // case 21794: break;
1393 // // Alterac Ram Collar DND
1394 // case 21866: break;
1395 // // Celebras Waiting
1396 // case 21916: break;
1397 // Brood Affliction: Bronze
1400 m_target
->CastSpell(m_target
, 23171, true, 0, this);
1404 // case 23184: break;
1408 int32 heal
= caster
->GetMaxHealth() / 10;
1409 caster
->ModifyHealth( heal
);
1410 caster
->SendHealSpellLog(caster
, 23493, heal
);
1412 int32 mana
= caster
->GetMaxPower(POWER_MANA
);
1416 caster
->ModifyPower( POWER_MANA
, mana
);
1417 caster
->SendEnergizeSpellLog(caster
, 23493, mana
, POWER_MANA
);
1421 // // Stoneclaw Totem Passive TEST
1422 // case 23792: break;
1424 // case 24018: break;
1425 // // Mark of Arlokk
1426 // case 24210: break;
1428 // case 24379: break;
1430 // case 24716: break;
1432 // case 24780: break;
1434 // case 24832: break;
1435 // // Shadow Bolt Whirl
1436 // case 24834: break;
1438 // case 24918: break;
1439 // // Mark of Nature
1440 // case 25041: break;
1442 // case 25152: break;
1444 // case 25371: break;
1446 // case 25572: break;
1448 // case 26009: break;
1450 // case 26136: break;
1452 // case 26196: break;
1454 // case 26615: break;
1456 // case 27177: break;
1457 // // Teleport: IF/UC
1458 // case 27601: break;
1459 // // Five Fat Finger Exploding Heart Technique
1460 // case 27673: break;
1462 // case 27746: break;
1463 // // Steam Tank Passive
1464 // case 27747: break;
1466 // case 27808: break;
1468 // case 27819: break;
1469 // // Controller Timer
1470 // case 28095: break;
1472 // case 28096: break;
1473 // // Stalagg Tesla Passive
1474 // case 28097: break;
1475 // // Feugen Tesla Passive
1476 // case 28109: break;
1478 // case 28111: break;
1479 // // Mark of Didier
1480 // case 28114: break;
1481 // // Communique Timer, camp
1482 // case 28346: break;
1484 // case 28522: break;
1486 // case 29519: break;
1487 // // Inoculate Nestlewood Owlkin
1488 case 29528: trigger_spell_id
= 28713; break;
1490 // case 29768: break;
1492 // case 29788: break;
1494 // case 29793: break;
1496 // case 29794: break;
1497 // // Guardian of Icecrown Passive
1498 // case 29897: break;
1499 // Feed Captured Animal
1500 case 29917: trigger_spell_id
= 29916; break;
1502 // case 29946: break;
1504 // case 29947: break;
1505 // // Mind Exhaustion Passive
1506 // case 30025: break;
1507 // // Nether Beam - Serenity
1508 // case 30401: break;
1512 // move loot to player inventory and despawn target
1513 if(caster
->GetTypeId() ==TYPEID_PLAYER
&&
1514 target
->GetTypeId() == TYPEID_UNIT
&&
1515 ((Creature
*)target
)->GetCreatureInfo()->type
== CREATURE_TYPE_GAS_CLOUD
)
1517 Player
* player
= (Player
*)caster
;
1518 Creature
* creature
= (Creature
*)target
;
1519 // missing lootid has been reported on startup - just return
1520 if (!creature
->GetCreatureInfo()->SkinLootId
)
1523 player
->AutoStoreLoot(creature
->GetCreatureInfo()->SkinLootId
,LootTemplates_Skinning
,true);
1525 creature
->setDeathState(JUST_DIED
);
1526 creature
->RemoveCorpse();
1527 creature
->SetHealth(0); // just for nice GM-mode view
1533 case 30576: trigger_spell_id
= 30571; break;
1535 // case 30598: break;
1541 // // Despawn Self - Smoke cloud
1542 // case 31269: break;
1543 // // Time Rift Periodic
1544 // case 31320: break;
1545 // // Corrupt Medivh
1546 // case 31326: break;
1550 m_target
->CastSpell(m_target
,31350,true);
1551 m_target
->DealDamage(m_target
, m_target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
1557 // Summon Elemental after create item
1558 caster
->SummonCreature(17870, 0, 0, 0, caster
->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN
, 0);
1561 // // Bloodmyst Tesla
1562 // case 31611: break;
1564 // case 31944: break;
1566 // case 32236: break;
1568 // case 32686: break;
1570 // case 33401: break;
1572 // case 33563: break;
1573 // // Murmur's Touch
1574 // case 33711: break;
1578 // cast 24 spells 34269-34289, 34314-34316
1579 for(uint32 spell_id
= 34269; spell_id
!= 34290; ++spell_id
)
1580 caster
->CastSpell(m_target
,spell_id
,true);
1581 for(uint32 spell_id
= 34314; spell_id
!= 34317; ++spell_id
)
1582 caster
->CastSpell(m_target
,spell_id
,true);
1586 // case 34480: break;
1588 // case 34683: break;
1589 // // Frostbite Rotate
1590 // case 34748: break;
1592 // case 34821: break;
1593 // // Interrupt Shutdown
1594 // case 35016: break;
1595 // // Interrupt Shutdown
1596 // case 35176: break;
1598 // case 35268: break;
1599 // // Salaadin's Tesla
1600 // case 35515: break;
1601 // // Ethereal Channel (Red)
1602 // case 35518: break;
1604 // case 35879: break;
1605 // // Dark Portal Storm
1606 // case 36018: break;
1608 // case 36056: break;
1609 // // Living Grove Defender Lifespan
1610 // case 36061: break;
1611 // // Professor Dabiri Talks
1612 // case 36064: break;
1613 // // Kael Gaining Power
1614 // case 36091: break;
1615 // // They Must Burn Bomb Aura
1616 // case 36344: break;
1617 // // They Must Burn Bomb Aura (self)
1618 // case 36350: break;
1619 // // Stolen Ravenous Ravager Egg
1620 // case 36401: break;
1621 // // Activated Cannon
1622 // case 36410: break;
1623 // // Stolen Ravenous Ravager Egg
1624 // case 36418: break;
1625 // // Enchanted Weapons
1626 // case 36510: break;
1627 // // Cursed Scarab Periodic
1628 // case 36556: break;
1629 // // Cursed Scarab Despawn Periodic
1630 // case 36561: break;
1632 // case 36573: break;
1633 // // Cannon Charging (platform)
1634 // case 36785: break;
1635 // // Cannon Charging (self)
1636 // case 36860: break;
1638 case 37027: trigger_spell_id
= 37029; break;
1640 // case 37125: break;
1642 // case 37268: break;
1644 // case 37429: break;
1646 // case 37430: break;
1647 // // Karazhan - Chess NPC AI, Snapshot timer
1648 // case 37440: break;
1649 // // Karazhan - Chess NPC AI, action timer
1650 // case 37504: break;
1651 // // Karazhan - Chess: Is Square OCCUPIED aura (DND)
1652 // case 39400: break;
1654 // case 37546: break;
1655 // // Shriveling Gaze
1656 // case 37589: break;
1657 // // Fake Aggro Radius (2 yd)
1658 // case 37815: break;
1659 // // Corrupt Medivh
1660 // case 37853: break;
1664 m_target
->CastSpell(m_target
, 38530, true);
1667 // Absorb Eye of Grillok (Zezzak's Shard)
1670 if(m_target
->GetTypeId() != TYPEID_UNIT
)
1673 caster
->CastSpell(caster
, 38495, true);
1675 Creature
* creatureTarget
= (Creature
*)m_target
;
1677 creatureTarget
->setDeathState(JUST_DIED
);
1678 creatureTarget
->RemoveCorpse();
1679 creatureTarget
->SetHealth(0); // just for nice GM-mode view
1682 // // Magic Sucker Device timer
1683 // case 38672: break;
1684 // // Tomb Guarding Charging
1685 // case 38751: break;
1686 // // Murmur's Touch
1687 // case 38794: break;
1688 // // Activate Nether-wraith Beacon (31742 Nether-wraith Beacon item)
1689 // case 39105: break;
1690 // // Drain World Tree Visual
1691 // case 39140: break;
1692 // // Quest - Dustin's Undead Dragon Visual aura
1693 // case 39259: break;
1694 // // Hellfire - The Exorcism, Jules releases darkness, aura
1695 // case 39306: break;
1697 // case 39346: break;
1698 // // Enchanted Weapons
1699 // case 39489: break;
1700 // // Shadow Bolt Whirl
1701 // case 39630: break;
1702 // // Shadow Bolt Whirl
1703 // case 39634: break;
1704 // // Shadow Inferno
1705 // case 39645: break;
1706 // Tear of Azzinoth Summon Channel - it's not really supposed to do anything,and this only prevents the console spam
1707 case 39857: trigger_spell_id
= 39856; break;
1708 // // Soulgrinder Ritual Visual (Smashed)
1709 // case 39974: break;
1710 // // Simon Game Pre-game timer
1711 // case 40041: break;
1712 // // Knockdown Fel Cannon: The Aggro Check Aura
1713 // case 40113: break;
1715 // case 40157: break;
1716 // // Demon Transform 2
1717 // case 40398: break;
1718 // // Demon Transform 1
1719 // case 40511: break;
1720 // // Ancient Flames
1721 // case 40657: break;
1722 // // Ethereal Ring Cannon: Cannon Aura
1723 // case 40734: break;
1725 // case 40760: break;
1726 // // Random Periodic
1727 // case 40867: break;
1728 // // Prismatic Shield
1729 // case 40879: break;
1730 // // Aura of Desire
1731 // case 41350: break;
1733 // case 41404: break;
1735 // case 41629: break;
1737 // case 42177: break;
1739 // case 42581: break;
1741 // case 42582: break;
1742 // // Return to the Spirit Realm
1743 // case 44035: break;
1744 // // Curse of Boundless Agony
1745 // case 45050: break;
1747 // case 46240: break;
1748 // Personalized Weather
1749 case 46736: trigger_spell_id
= 46737; break;
1750 // // Stay Submerged
1751 // case 46981: break;
1752 // // Dragonblight Ram
1753 // case 47015: break;
1754 // // Party G.R.E.N.A.D.E.
1755 // case 51510: break;
1761 case SPELLFAMILY_MAGE
:
1769 m_target
->CastSpell(m_target
, 32612, true, NULL
, this);
1777 // case SPELLFAMILY_WARRIOR:
1782 // case 23410: break;
1783 // // Corrupted Totems
1784 // case 23425: break;
1790 // case SPELLFAMILY_PRIEST:
1795 // case 32930: break;
1796 // // Fury of the Dreghood Elders
1797 // case 35460: break;
1803 case SPELLFAMILY_DRUID
:
1808 // trigger_spell_id not set and unknown effect triggered in this case, ignoring for while
1811 // Frenzied Regeneration
1817 int32 LifePerRage
= GetModifier()->m_amount
;
1819 int32 lRage
= m_target
->GetPower(POWER_RAGE
);
1820 if(lRage
> 100) // rage stored as rage*10
1822 m_target
->ModifyPower(POWER_RAGE
, -lRage
);
1823 int32 FRTriggerBasePoints
= int32(lRage
*LifePerRage
/10);
1824 m_target
->CastCustomSpell(m_target
,22845,&FRTriggerBasePoints
,NULL
,NULL
,true,NULL
,this);
1833 // case SPELLFAMILY_HUNTER:
1837 // //Frost Trap Aura
1840 // //Rizzle's Frost Trap
1844 // case 19597: // Tame Ice Claw Bear
1845 // case 19676: // Tame Snow Leopard
1846 // case 19677: // Tame Large Crag Boar
1847 // case 19678: // Tame Adult Plainstrider
1848 // case 19679: // Tame Prairie Stalker
1849 // case 19680: // Tame Swoop
1850 // case 19681: // Tame Dire Mottled Boar
1851 // case 19682: // Tame Surf Crawler
1852 // case 19683: // Tame Armored Scorpid
1853 // case 19684: // Tame Webwood Lurker
1854 // case 19685: // Tame Nightsaber Stalker
1855 // case 19686: // Tame Strigid Screecher
1856 // case 30100: // Tame Crazed Dragonhawk
1857 // case 30103: // Tame Elder Springpaw
1858 // case 30104: // Tame Mistbat
1859 // case 30647: // Tame Barbed Crawler
1860 // case 30648: // Tame Greater Timberstrider
1861 // case 30652: // Tame Nightstalker
1868 case SPELLFAMILY_SHAMAN
:
1872 // Lightning Shield (The Earthshatterer set trigger after cast Lighting Shield)
1875 // Need remove self if Lightning Shield not active
1876 Unit::AuraMap
const& auras
= target
->GetAuras();
1877 for(Unit::AuraMap::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
1879 SpellEntry
const* spell
= itr
->second
->GetSpellProto();
1880 if( spell
->SpellFamilyName
== SPELLFAMILY_SHAMAN
&&
1881 spell
->SpellFamilyFlags
& 0x0000000000000400L
)
1884 target
->RemoveAurasDueToSpell(28820);
1887 // Totemic Mastery (Skyshatter Regalia (Shaman Tier 6) - bonus)
1891 for(int i
= 0; i
< MAX_TOTEM
; ++i
)
1893 if(!caster
->m_TotemSlot
[i
])
1901 caster
->CastSpell(caster
,38437,true);
1903 caster
->RemoveAurasDueToSpell(38437);
1914 // Reget trigger spell proto
1915 triggeredSpellInfo
= sSpellStore
.LookupEntry(trigger_spell_id
);
1916 if(triggeredSpellInfo
== NULL
)
1918 sLog
.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex());
1924 // Spell exist but require custom code
1930 // TODO: spell casted by result in correct way mostly
1932 // 1) target show casting at each triggered cast: target don't must show casting animation for any triggered spell
1933 // but must show affect apply like item casting
1934 // 2) maybe aura must be replace by new with accumulative stat mods instead stacking
1936 // prevent cast by triggered auras
1937 if(m_caster_guid
== m_target
->GetGUID())
1940 // stop triggering after each affected stats lost > 90
1941 int32 intelectLoss
= 0;
1942 int32 spiritLoss
= 0;
1944 Unit::AuraList
const& mModStat
= m_target
->GetAurasByType(SPELL_AURA_MOD_STAT
);
1945 for(Unit::AuraList::const_iterator i
= mModStat
.begin(); i
!= mModStat
.end(); ++i
)
1947 if ((*i
)->GetId() == 1010)
1949 switch((*i
)->GetModifier()->m_miscvalue
)
1951 case STAT_INTELLECT
: intelectLoss
+= (*i
)->GetModifier()->m_amount
; break;
1952 case STAT_SPIRIT
: spiritLoss
+= (*i
)->GetModifier()->m_amount
; break;
1958 if(intelectLoss
<= -90 && spiritLoss
<= -90)
1967 caster
->CastCustomSpell(target
, trigger_spell_id
, &m_modifier
.m_amount
, NULL
, NULL
, true, NULL
, this);
1972 // All ok cast by default case
1973 caster
->CastSpell(target
, triggeredSpellInfo
, true, 0, this);
1976 void Aura::TriggerSpellWithValue()
1978 Unit
* caster
= GetCaster();
1979 Unit
* target
= GetTriggerTarget();
1981 if(!caster
|| !target
)
1984 // generic casting code with custom spells and target/caster customs
1985 uint32 trigger_spell_id
= GetSpellProto()->EffectTriggerSpell
[m_effIndex
];
1986 int32 basepoints0
= this->GetModifier()->m_amount
;
1988 caster
->CastCustomSpell(target
, trigger_spell_id
, &basepoints0
, 0, 0, true, 0, this);
1991 /*********************************************************/
1992 /*** AURA EFFECTS ***/
1993 /*********************************************************/
1995 void Aura::HandleAuraDummy(bool apply
, bool Real
)
1997 // spells required only Real aura add/remove
2001 Unit
* caster
= GetCaster();
2008 case 1515: // Tame beast
2009 // FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness
2010 if( caster
&& m_target
->CanHaveThreatList())
2011 m_target
->AddThreat(caster
, 10.0f
);
2013 case 13139: // net-o-matic
2014 // root to self part of (root_target->charge->root_self sequence
2016 caster
->CastSpell(caster
,13138,true,NULL
,this);
2018 case 39850: // Rocket Blast
2019 if(roll_chance_i(20)) // backfire stun
2020 m_target
->CastSpell(m_target
, 51581, true, NULL
, this);
2022 case 43873: // Headless Horseman Laugh
2023 if(caster
->GetTypeId() == TYPEID_PLAYER
)
2024 ((Player
*)caster
)->PlaySound(11965, false);
2026 case 46354: // Blood Elf Illusion
2029 switch(caster
->getGender())
2032 caster
->CastSpell(m_target
,46356,true,NULL
,this);
2035 caster
->CastSpell(m_target
,46355,true,NULL
,this);
2042 case 46699: // Requires No Ammo
2043 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
2044 ((Player
*)m_target
)->RemoveAmmo(); // not use ammo and not allow use
2049 if ( caster
&& GetSpellProto()->SpellFamilyName
== SPELLFAMILY_SHAMAN
&& (GetSpellProto()->SpellFamilyFlags
& 0x40000000000LL
))
2051 // prevent double apply bonuses
2052 if(m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading())
2053 m_modifier
.m_amount
= caster
->SpellHealingBonus(m_target
, GetSpellProto(), m_modifier
.m_amount
, SPELL_DIRECT_DAMAGE
);
2060 if( m_target
->GetTypeId() == TYPEID_PLAYER
&&
2061 ( GetSpellProto()->Effect
[0]==72 || GetSpellProto()->Effect
[0]==6 &&
2062 ( GetSpellProto()->EffectApplyAuraName
[0]==1 || GetSpellProto()->EffectApplyAuraName
[0]==128 ) ) )
2064 // spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425
2065 ((Player
*)m_target
)->SetFarSightGUID(0);
2066 WorldPacket
data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE
, 0);
2067 ((Player
*)m_target
)->GetSession()->SendPacket(&data
);
2071 if( (IsQuestTameSpell(GetId())) && caster
&& caster
->isAlive() && m_target
->isAlive())
2073 uint32 finalSpelId
= 0;
2076 case 19548: finalSpelId
= 19597; break;
2077 case 19674: finalSpelId
= 19677; break;
2078 case 19687: finalSpelId
= 19676; break;
2079 case 19688: finalSpelId
= 19678; break;
2080 case 19689: finalSpelId
= 19679; break;
2081 case 19692: finalSpelId
= 19680; break;
2082 case 19693: finalSpelId
= 19684; break;
2083 case 19694: finalSpelId
= 19681; break;
2084 case 19696: finalSpelId
= 19682; break;
2085 case 19697: finalSpelId
= 19683; break;
2086 case 19699: finalSpelId
= 19685; break;
2087 case 19700: finalSpelId
= 19686; break;
2088 case 30646: finalSpelId
= 30647; break;
2089 case 30653: finalSpelId
= 30648; break;
2090 case 30654: finalSpelId
= 30652; break;
2091 case 30099: finalSpelId
= 30100; break;
2092 case 30102: finalSpelId
= 30103; break;
2093 case 30105: finalSpelId
= 30104; break;
2097 caster
->CastSpell(m_target
,finalSpelId
,true,NULL
,this);
2101 // Waiting to Resurrect
2104 // Waiting to resurrect spell cancel, we must remove player from resurrect queue
2105 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2106 if(BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround())
2107 bg
->RemovePlayerFromResurrectQueue(m_target
->GetGUID());
2114 // Kill target if dispelled
2115 if (m_removeMode
==AURA_REMOVE_BY_DISPEL
)
2116 m_target
->DealDamage(m_target
, m_target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
2121 if(GetId()==46308) // casted only at creatures at spawn
2123 m_target
->CastSpell(m_target
,47287,true,NULL
,this);
2127 if (caster
&& m_removeMode
== AURA_REMOVE_BY_DEATH
)
2129 // Stop caster Arcane Missle chanelling on death
2130 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_MAGE
&&
2131 m_spellProto
->SpellFamilyFlags
&0x0000000000000800LL
)
2133 caster
->InterruptSpell(CURRENT_CHANNELED_SPELL
);
2136 // Stop caster Penance chanelling on death
2137 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_PRIEST
&&
2138 m_spellProto
->SpellFamilyFlags2
& 0x00000080)
2140 caster
->InterruptSpell(CURRENT_CHANNELED_SPELL
);
2147 // AT APPLY & REMOVE
2149 switch(m_spellProto
->SpellFamilyName
)
2151 case SPELLFAMILY_GENERIC
:
2154 if( GetId()==24658 )
2156 uint32 spellId
= 24659;
2159 const SpellEntry
*spell
= sSpellStore
.LookupEntry(spellId
);
2162 for (int i
=0; i
< spell
->StackAmount
; ++i
)
2163 caster
->CastSpell(m_target
, spell
->Id
, true, NULL
, NULL
, GetCasterGUID());
2166 m_target
->RemoveAurasDueToSpell(spellId
);
2169 // Restless Strength
2170 if( GetId()==24661 )
2172 uint32 spellId
= 24662;
2175 const SpellEntry
*spell
= sSpellStore
.LookupEntry(spellId
);
2178 for (int i
=0; i
< spell
->StackAmount
; ++i
)
2179 caster
->CastSpell(m_target
, spell
->Id
, true, NULL
, NULL
, GetCasterGUID());
2182 m_target
->RemoveAurasDueToSpell(spellId
);
2185 //Summon Fire Elemental
2186 if (GetId() == 40133 && caster
)
2188 Unit
*owner
= caster
->GetOwner();
2189 if (owner
&& owner
->GetTypeId() == TYPEID_PLAYER
)
2192 owner
->CastSpell(owner
,8985,true);
2194 ((Player
*)owner
)->RemovePet(NULL
, PET_SAVE_NOT_IN_SLOT
, true);
2199 //Summon Earth Elemental
2200 if (GetId() == 40132 && caster
)
2202 Unit
*owner
= caster
->GetOwner();
2203 if (owner
&& owner
->GetTypeId() == TYPEID_PLAYER
)
2206 owner
->CastSpell(owner
,19704,true);
2208 ((Player
*)owner
)->RemovePet(NULL
, PET_SAVE_NOT_IN_SLOT
, true);
2214 case SPELLFAMILY_MAGE
:
2218 case SPELLFAMILY_PRIEST
:
2220 // Pain and Suffering
2221 if( m_spellProto
->SpellIconID
== 2874 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2225 // Reduce backfire damage (dot damage) from Shadow Word: Death
2226 SpellModifier
*mod
= new SpellModifier
;
2227 mod
->op
= SPELLMOD_DOT
;
2228 mod
->value
= m_modifier
.m_amount
;
2229 mod
->type
= SPELLMOD_PCT
;
2230 mod
->spellId
= GetId();
2231 mod
->mask
= 0x0000000200000000LL
;
2235 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2240 case SPELLFAMILY_DRUID
:
2243 if ( GetSpellProto()->SpellFamilyFlags
& 0x1000000000LL
)
2248 // prevent double apply bonuses
2249 if(m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading())
2250 m_modifier
.m_amount
= caster
->SpellHealingBonus(m_target
, GetSpellProto(), m_modifier
.m_amount
, SPELL_DIRECT_DAMAGE
);
2254 // Final heal only on dispelled or duration end
2255 if ( !(GetAuraDuration() <= 0 || m_removeMode
==AURA_REMOVE_BY_DISPEL
) )
2258 // have a look if there is still some other Lifebloom dummy aura
2259 Unit::AuraList auras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
2260 for(Unit::AuraList::iterator itr
= auras
.begin(); itr
!=auras
.end(); ++itr
)
2261 if((*itr
)->GetSpellProto()->SpellFamilyName
== SPELLFAMILY_DRUID
&&
2262 (*itr
)->GetSpellProto()->SpellFamilyFlags
& 0x1000000000LL
)
2266 if(m_target
->IsInWorld() && m_stackAmount
> 0)
2268 int32 amount
= m_modifier
.m_amount
/ m_stackAmount
;
2269 m_target
->CastCustomSpell(m_target
,33778,&amount
,NULL
,NULL
,true,NULL
,this,GetCasterGUID());
2275 // Predatory Strikes
2276 if(m_target
->GetTypeId()==TYPEID_PLAYER
&& GetSpellProto()->SpellIconID
== 1563)
2278 ((Player
*)m_target
)->UpdateAttackPowerAndDamage();
2281 // Idol of the Emerald Queen
2282 if ( GetId() == 34246 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2286 SpellModifier
*mod
= new SpellModifier
;
2287 mod
->op
= SPELLMOD_DOT
;
2288 mod
->value
= m_modifier
.m_amount
/7;
2289 mod
->type
= SPELLMOD_FLAT
;
2290 mod
->spellId
= GetId();
2291 mod
->mask
= 0x001000000000LL
;
2297 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2302 case SPELLFAMILY_HUNTER
:
2304 // Improved Aspect of the Viper
2305 if( GetId()==38390 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2309 // + effect value for Aspect of the Viper
2310 SpellModifier
*mod
= new SpellModifier
;
2311 mod
->op
= SPELLMOD_EFFECT1
;
2312 mod
->value
= m_modifier
.m_amount
;
2313 mod
->type
= SPELLMOD_FLAT
;
2314 mod
->spellId
= GetId();
2315 mod
->mask
= 0x4000000000000LL
;
2321 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2326 case SPELLFAMILY_SHAMAN
:
2328 // Improved Weapon Totems
2329 if( GetSpellProto()->SpellIconID
== 57 && m_target
->GetTypeId()==TYPEID_PLAYER
)
2333 SpellModifier
*mod
= new SpellModifier
;
2334 mod
->op
= SPELLMOD_EFFECT1
;
2335 mod
->value
= m_modifier
.m_amount
;
2336 mod
->type
= SPELLMOD_PCT
;
2337 mod
->spellId
= GetId();
2341 mod
->mask
= 0x00200000000LL
; // Windfury Totem
2345 mod
->mask
= 0x00400000000LL
; // Flametongue Totem
2353 ((Player
*)m_target
)->AddSpellMod(m_spellmod
, apply
);
2361 if(PetAura
const* petSpell
= spellmgr
.GetPetAura(GetId()))
2364 m_target
->AddPetAura(petSpell
);
2366 m_target
->RemovePetAura(petSpell
);
2371 void Aura::HandleAuraMounted(bool apply
, bool Real
)
2373 // only at real add/remove aura
2379 CreatureInfo
const* ci
= objmgr
.GetCreatureTemplate(m_modifier
.m_miscvalue
);
2382 sLog
.outErrorDb("AuraMounted: `creature_template`='%u' not found in database (only need it modelid)", m_modifier
.m_miscvalue
);
2387 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
2388 team
= ((Player
*)m_target
)->GetTeam();
2390 uint32 display_id
= objmgr
.ChooseDisplayId(team
,ci
);
2391 CreatureModelInfo
const *minfo
= objmgr
.GetCreatureModelRandomGender(display_id
);
2393 display_id
= minfo
->modelid
;
2395 m_target
->Mount(display_id
);
2399 m_target
->Unmount();
2403 void Aura::HandleAuraWaterWalk(bool apply
, bool Real
)
2405 // only at real add/remove aura
2411 data
.Initialize(SMSG_MOVE_WATER_WALK
, 8+4);
2413 data
.Initialize(SMSG_MOVE_LAND_WALK
, 8+4);
2414 data
.append(m_target
->GetPackGUID());
2416 m_target
->SendMessageToSet(&data
,true);
2419 void Aura::HandleAuraFeatherFall(bool apply
, bool Real
)
2421 // only at real add/remove aura
2427 data
.Initialize(SMSG_MOVE_FEATHER_FALL
, 8+4);
2429 data
.Initialize(SMSG_MOVE_NORMAL_FALL
, 8+4);
2430 data
.append(m_target
->GetPackGUID());
2432 m_target
->SendMessageToSet(&data
,true);
2435 void Aura::HandleAuraHover(bool apply
, bool Real
)
2437 // only at real add/remove aura
2443 data
.Initialize(SMSG_MOVE_SET_HOVER
, 8+4);
2445 data
.Initialize(SMSG_MOVE_UNSET_HOVER
, 8+4);
2446 data
.append(m_target
->GetPackGUID());
2448 m_target
->SendMessageToSet(&data
,true);
2451 void Aura::HandleWaterBreathing(bool apply
, bool Real
)
2453 if(!apply
&& !m_target
->HasAuraType(SPELL_AURA_WATER_BREATHING
))
2455 // update for enable timer in case not moving target
2456 if(m_target
->GetTypeId()==TYPEID_PLAYER
&& m_target
->IsInWorld())
2458 ((Player
*)m_target
)->UpdateUnderwaterState(m_target
->GetMap(),m_target
->GetPositionX(),m_target
->GetPositionY(),m_target
->GetPositionZ());
2459 ((Player
*)m_target
)->HandleDrowning();
2464 void Aura::HandleAuraModShapeshift(bool apply
, bool Real
)
2470 Powers PowerType
= POWER_MANA
;
2471 ShapeshiftForm form
= ShapeshiftForm(m_modifier
.m_miscvalue
);
2475 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2479 PowerType
= POWER_ENERGY
;
2485 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2491 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2495 PowerType
= POWER_RAGE
;
2498 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2502 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2506 PowerType
= POWER_RAGE
;
2508 case FORM_CREATUREBEAR
:
2511 case FORM_GHOSTWOLF
:
2515 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2521 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2526 case FORM_FLIGHT_EPIC
:
2527 if(Player::TeamForRace(m_target
->getRace())==ALLIANCE
)
2532 case FORM_METAMORPHOSIS
:
2542 case FORM_BATTLESTANCE
:
2543 case FORM_BERSERKERSTANCE
:
2544 case FORM_DEFENSIVESTANCE
:
2545 PowerType
= POWER_RAGE
;
2547 case FORM_SPIRITOFREDEMPTION
:
2551 sLog
.outError("Auras: Unknown Shapeshift Type: %u", m_modifier
.m_miscvalue
);
2554 // remove polymorph before changing display id to keep new display id
2563 case FORM_FLIGHT_EPIC
:
2566 // remove movement affects
2567 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT
);
2568 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED
);
2570 // and polymorphic affects
2571 if(m_target
->IsPolymorphed())
2572 m_target
->RemoveAurasDueToSpell(m_target
->getTransForm());
2580 // remove other shapeshift before applying a new one
2581 if(m_target
->m_ShapeShiftFormSpellId
)
2582 m_target
->RemoveAurasDueToSpell(m_target
->m_ShapeShiftFormSpellId
,this);
2584 m_target
->SetByteValue(UNIT_FIELD_BYTES_2
, 3, form
);
2587 m_target
->SetDisplayId(modelid
);
2589 if(PowerType
!= POWER_MANA
)
2591 // reset power to default values only at power change
2592 if(m_target
->getPowerType()!=PowerType
)
2593 m_target
->setPowerType(PowerType
);
2601 // get furor proc chance
2602 uint32 FurorChance
= 0;
2603 Unit::AuraList
const& mDummy
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
2604 for(Unit::AuraList::const_iterator i
= mDummy
.begin(); i
!= mDummy
.end(); ++i
)
2606 if ((*i
)->GetSpellProto()->SpellIconID
== 238)
2608 FurorChance
= (*i
)->GetModifier()->m_amount
;
2613 if (m_modifier
.m_miscvalue
== FORM_CAT
)
2615 m_target
->SetPower(POWER_ENERGY
,0);
2616 if(urand(1,100) <= FurorChance
)
2617 m_target
->CastSpell(m_target
,17099,true,NULL
,this);
2621 m_target
->SetPower(POWER_RAGE
,0);
2622 if(urand(1,100) <= FurorChance
)
2623 m_target
->CastSpell(m_target
,17057,true,NULL
,this);
2627 case FORM_BATTLESTANCE
:
2628 case FORM_DEFENSIVESTANCE
:
2629 case FORM_BERSERKERSTANCE
:
2631 uint32 Rage_val
= 0;
2632 // Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch)
2633 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2635 PlayerSpellMap
const& sp_list
= ((Player
*)m_target
)->GetSpellMap();
2636 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
2638 if(itr
->second
->state
== PLAYERSPELL_REMOVED
) continue;
2639 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
2640 if (spellInfo
&& spellInfo
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& spellInfo
->SpellIconID
== 139)
2641 Rage_val
+= m_target
->CalculateSpellDamage(spellInfo
,0,spellInfo
->EffectBasePoints
[0],m_target
) * 10;
2645 if (m_target
->GetPower(POWER_RAGE
) > Rage_val
)
2646 m_target
->SetPower(POWER_RAGE
,Rage_val
);
2654 m_target
->m_ShapeShiftFormSpellId
= GetId();
2655 m_target
->m_form
= form
;
2660 m_target
->SetDisplayId(m_target
->GetNativeDisplayId());
2661 m_target
->SetByteValue(UNIT_FIELD_BYTES_2
, 3, FORM_NONE
);
2662 if(m_target
->getClass() == CLASS_DRUID
)
2663 m_target
->setPowerType(POWER_MANA
);
2664 m_target
->m_ShapeShiftFormSpellId
= 0;
2665 m_target
->m_form
= FORM_NONE
;
2669 // Nordrassil Harness - bonus
2674 if(Aura
* dummy
= m_target
->GetDummyAura(37315) )
2675 m_target
->CastSpell(m_target
,37316,true,NULL
,dummy
);
2678 // Nordrassil Regalia - bonus
2681 if(Aura
* dummy
= m_target
->GetDummyAura(37324) )
2682 m_target
->CastSpell(m_target
,37325,true,NULL
,dummy
);
2688 // adding/removing linked auras
2689 // add/remove the shapeshift aura's boosts
2690 HandleShapeshiftBoosts(apply
);
2692 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
2693 ((Player
*)m_target
)->InitDataForForm();
2696 void Aura::HandleAuraTransform(bool apply
, bool Real
)
2700 // special case (spell specific functionality)
2701 if(m_modifier
.m_miscvalue
==0)
2703 // player applied only
2704 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
2712 uint32 orb_model
= m_target
->GetNativeDisplayId();
2716 case 1479: m_target
->SetDisplayId(10134); break;
2718 case 1478: m_target
->SetDisplayId(10135); break;
2720 case 59: m_target
->SetDisplayId(10136); break;
2722 case 49: m_target
->SetDisplayId(10137); break;
2724 case 50: m_target
->SetDisplayId(10138); break;
2726 case 51: m_target
->SetDisplayId(10139); break;
2728 case 52: m_target
->SetDisplayId(10140); break;
2730 case 53: m_target
->SetDisplayId(10141); break;
2732 case 54: m_target
->SetDisplayId(10142); break;
2734 case 55: m_target
->SetDisplayId(10143); break;
2736 case 56: m_target
->SetDisplayId(10144); break;
2738 case 58: m_target
->SetDisplayId(10145); break;
2740 case 57: m_target
->SetDisplayId(10146); break;
2742 case 60: m_target
->SetDisplayId(10147); break;
2744 case 1563: m_target
->SetDisplayId(10148); break;
2746 case 1564: m_target
->SetDisplayId(10149); break;
2748 case 15475: m_target
->SetDisplayId(17830); break;
2750 case 15476: m_target
->SetDisplayId(17829); break;
2752 case 16126: m_target
->SetDisplayId(17828); break;
2754 case 16125: m_target
->SetDisplayId(17827); break;
2760 case 42365: m_target
->SetDisplayId(21723); break;
2766 CreatureInfo
const * ci
= objmgr
.GetCreatureTemplate(m_modifier
.m_miscvalue
);
2770 m_target
->SetDisplayId(16358);
2771 sLog
.outError("Auras: unknown creature id = %d (only need its modelid) Form Spell Aura Transform in Spell ID = %d", m_modifier
.m_miscvalue
, GetId());
2775 // Will use the default model here
2776 m_target
->SetDisplayId(ci
->DisplayID_A
);
2778 // Dragonmaw Illusion (set mount model also)
2779 if(GetId()==42016 && m_target
->GetMountID() && !m_target
->GetAurasByType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
).empty())
2780 m_target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
,16314);
2782 m_target
->setTransForm(GetId());
2786 if( Real
&& m_target
->GetTypeId() == TYPEID_PLAYER
&& m_target
->IsPolymorphed())
2788 // for players, start regeneration after 1s (in polymorph fast regeneration case)
2789 // only if caster is Player (after patch 2.4.2)
2790 if(IS_PLAYER_GUID(GetCasterGUID()) )
2791 ((Player
*)m_target
)->setRegenTimer(1000);
2793 //dismount polymorphed target (after patch 2.4.2)
2794 if (m_target
->IsMounted())
2795 m_target
->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED
);
2800 Unit::AuraList
const& otherTransforms
= m_target
->GetAurasByType(SPELL_AURA_TRANSFORM
);
2801 if(otherTransforms
.empty())
2803 m_target
->SetDisplayId(m_target
->GetNativeDisplayId());
2804 m_target
->setTransForm(0);
2808 // look for other transform auras
2809 Aura
* handledAura
= *otherTransforms
.begin();
2810 for(Unit::AuraList::const_iterator i
= otherTransforms
.begin();i
!= otherTransforms
.end(); ++i
)
2812 // negative auras are preferred
2813 if(!IsPositiveSpell((*i
)->GetSpellProto()->Id
))
2819 handledAura
->ApplyModifier(true);
2822 // Dragonmaw Illusion (restore mount model)
2823 if(GetId()==42016 && m_target
->GetMountID()==16314)
2825 if(!m_target
->GetAurasByType(SPELL_AURA_MOUNTED
).empty())
2827 uint32 cr_id
= m_target
->GetAurasByType(SPELL_AURA_MOUNTED
).front()->GetModifier()->m_miscvalue
;
2828 if(CreatureInfo
const* ci
= objmgr
.GetCreatureTemplate(cr_id
))
2831 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
2832 team
= ((Player
*)m_target
)->GetTeam();
2834 uint32 display_id
= objmgr
.ChooseDisplayId(team
,ci
);
2835 CreatureModelInfo
const *minfo
= objmgr
.GetCreatureModelRandomGender(display_id
);
2837 display_id
= minfo
->modelid
;
2839 m_target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
,display_id
);
2846 void Aura::HandleForceReaction(bool apply
, bool Real
)
2848 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
2854 Player
* player
= (Player
*)m_target
;
2856 uint32 faction_id
= m_modifier
.m_miscvalue
;
2857 uint32 faction_rank
= m_modifier
.m_amount
;
2860 player
->m_forcedReactions
[faction_id
] = ReputationRank(faction_rank
);
2862 player
->m_forcedReactions
.erase(faction_id
);
2865 data
.Initialize(SMSG_SET_FORCED_REACTIONS
, 4+player
->m_forcedReactions
.size()*(4+4));
2866 data
<< uint32(player
->m_forcedReactions
.size());
2867 for(ForcedReactions::const_iterator itr
= player
->m_forcedReactions
.begin(); itr
!= player
->m_forcedReactions
.end(); ++itr
)
2869 data
<< uint32(itr
->first
); // faction_id (Faction.dbc)
2870 data
<< uint32(itr
->second
); // reputation rank
2872 player
->SendDirectMessage(&data
);
2875 void Aura::HandleAuraModSkill(bool apply
, bool Real
)
2877 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
2880 uint32 prot
=GetSpellProto()->EffectMiscValue
[m_effIndex
];
2881 int32 points
= GetModifier()->m_amount
;
2883 ((Player
*)m_target
)->ModifySkillBonus(prot
,(apply
? points
: -points
),m_modifier
.m_auraname
==SPELL_AURA_MOD_SKILL_TALENT
);
2884 if(prot
== SKILL_DEFENSE
)
2885 ((Player
*)m_target
)->UpdateDefenseBonusesMod();
2888 void Aura::HandleChannelDeathItem(bool apply
, bool Real
)
2892 Unit
* caster
= GetCaster();
2893 Unit
* victim
= GetTarget();
2894 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
|| !victim
|| m_removeMode
!=AURA_REMOVE_BY_DEATH
)
2897 if (m_modifier
.m_amount
<= 0)
2900 SpellEntry
const *spellInfo
= GetSpellProto();
2901 if(spellInfo
->EffectItemType
[m_effIndex
] == 0)
2904 // Soul Shard only from non-grey units
2905 if( spellInfo
->EffectItemType
[m_effIndex
] == 6265 &&
2906 (victim
->getLevel() <= MaNGOS::XP::GetGrayLevel(caster
->getLevel()) ||
2907 victim
->GetTypeId()==TYPEID_UNIT
&& !((Player
*)caster
)->isAllowedToLoot((Creature
*)victim
)) )
2910 uint32 noSpaceForCount
= 0;
2911 uint32 count
= m_modifier
.m_amount
;
2913 ItemPosCountVec dest
;
2914 uint8 msg
= ((Player
*)caster
)->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, spellInfo
->EffectItemType
[m_effIndex
], count
, &noSpaceForCount
);
2915 if( msg
!= EQUIP_ERR_OK
)
2917 count
-=noSpaceForCount
;
2918 ((Player
*)caster
)->SendEquipError( msg
, NULL
, NULL
);
2923 Item
* newitem
= ((Player
*)caster
)->StoreNewItem(dest
, spellInfo
->EffectItemType
[m_effIndex
], true);
2924 ((Player
*)caster
)->SendNewItem(newitem
, count
, true, false);
2928 void Aura::HandleBindSight(bool apply
, bool Real
)
2930 Unit
* caster
= GetCaster();
2931 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
2934 ((Player
*)caster
)->SetFarSightGUID(apply
? m_target
->GetGUID() : 0);
2937 void Aura::HandleFarSight(bool apply
, bool Real
)
2939 Unit
* caster
= GetCaster();
2940 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
2943 ((Player
*)caster
)->SetFarSightGUID(apply
? m_target
->GetGUID() : 0);
2946 void Aura::HandleAuraTrackCreatures(bool apply
, bool Real
)
2948 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
2952 m_target
->RemoveNoStackAurasDueToAura(this);
2953 m_target
->SetUInt32Value(PLAYER_TRACK_CREATURES
, apply
? ((uint32
)1)<<(m_modifier
.m_miscvalue
-1) : 0 );
2956 void Aura::HandleAuraTrackResources(bool apply
, bool Real
)
2958 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
2962 m_target
->RemoveNoStackAurasDueToAura(this);
2963 m_target
->SetUInt32Value(PLAYER_TRACK_RESOURCES
, apply
? ((uint32
)1)<<(m_modifier
.m_miscvalue
-1): 0 );
2966 void Aura::HandleAuraTrackStealthed(bool apply
, bool Real
)
2968 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
2972 m_target
->RemoveNoStackAurasDueToAura(this);
2974 m_target
->ApplyModFlag(PLAYER_FIELD_BYTES
,PLAYER_FIELD_BYTE_TRACK_STEALTHED
,apply
);
2977 void Aura::HandleAuraModScale(bool apply
, bool Real
)
2979 m_target
->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X
,m_modifier
.m_amount
,apply
);
2982 void Aura::HandleModPossess(bool apply
, bool Real
)
2987 if(m_target
->getLevel() > m_modifier
.m_amount
)
2990 // not possess yourself
2991 if(GetCasterGUID() == m_target
->GetGUID())
2994 Unit
* caster
= GetCaster();
3000 m_target
->SetCharmerGUID(GetCasterGUID());
3001 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,caster
->getFaction());
3002 caster
->SetCharm(m_target
);
3004 m_target
->CombatStop();
3005 m_target
->DeleteThreatList();
3006 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3008 m_target
->StopMoving();
3009 m_target
->GetMotionMaster()->Clear();
3010 m_target
->GetMotionMaster()->MoveIdle();
3011 CharmInfo
*charmInfo
= ((Creature
*)m_target
)->InitCharmInfo(m_target
);
3012 charmInfo
->InitPossessCreateSpells();
3015 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3017 ((Player
*)caster
)->PossessSpellInitialize();
3022 m_target
->SetCharmerGUID(0);
3024 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3025 ((Player
*)m_target
)->setFactionForRace(m_target
->getRace());
3026 else if(m_target
->GetTypeId() == TYPEID_UNIT
)
3028 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
3029 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,cinfo
->faction_A
);
3032 caster
->SetCharm(0);
3034 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3036 WorldPacket
data(SMSG_PET_SPELLS
, 8);
3039 ((Player
*)caster
)->GetSession()->SendPacket(&data
);
3041 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3043 ((Creature
*)m_target
)->AIM_Initialize();
3045 if (((Creature
*)m_target
)->AI())
3046 ((Creature
*)m_target
)->AI()->AttackStart(caster
);
3049 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3050 ((Player
*)caster
)->SetFarSightGUID(apply
? m_target
->GetGUID() : 0);
3053 void Aura::HandleModPossessPet(bool apply
, bool Real
)
3058 Unit
* caster
= GetCaster();
3059 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
)
3062 Pet
*pet
= caster
->GetPet();
3063 if(!pet
|| pet
!= m_target
)
3067 pet
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_24
);
3069 pet
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_24
);
3071 ((Player
*)caster
)->SetFarSightGUID(apply
? pet
->GetGUID() : NULL
);
3072 ((Player
*)caster
)->SetCharm(apply
? pet
: NULL
);
3073 ((Player
*)caster
)->SetClientControl(pet
, apply
? 1 : 0);
3078 pet
->GetMotionMaster()->Clear();
3079 pet
->GetMotionMaster()->MoveIdle();
3084 pet
->GetMotionMaster()->MoveFollow(caster
, PET_FOLLOW_DIST
, PET_FOLLOW_ANGLE
);
3085 pet
->SetUnitMovementFlags(MOVEMENTFLAG_NONE
);
3089 void Aura::HandleAuraModPetTalentsPoints(bool Apply
, bool Real
)
3094 // Recalculate pet tlaent points
3095 if (Pet
*pet
=m_target
->GetPet())
3096 pet
->InitTalentForLevel();
3099 void Aura::HandleModCharm(bool apply
, bool Real
)
3104 // not charm yourself
3105 if(GetCasterGUID() == m_target
->GetGUID())
3108 Unit
* caster
= GetCaster();
3112 if(int32(m_target
->getLevel()) <= m_modifier
.m_amount
)
3116 m_target
->SetCharmerGUID(GetCasterGUID());
3117 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,caster
->getFaction());
3118 m_target
->CastStop(m_target
==caster
? GetId() : 0);
3119 caster
->SetCharm(m_target
);
3121 m_target
->CombatStop();
3122 m_target
->DeleteThreatList();
3124 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3126 ((Creature
*)m_target
)->AIM_Initialize();
3127 CharmInfo
*charmInfo
= ((Creature
*)m_target
)->InitCharmInfo(m_target
);
3128 charmInfo
->InitCharmCreateSpells();
3129 charmInfo
->SetReactState( REACT_DEFENSIVE
);
3131 if(caster
->GetTypeId() == TYPEID_PLAYER
&& caster
->getClass() == CLASS_WARLOCK
)
3133 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
3134 if(cinfo
&& cinfo
->type
== CREATURE_TYPE_DEMON
)
3136 //to prevent client crash
3137 m_target
->SetFlag(UNIT_FIELD_BYTES_0
, 2048);
3138 //just to enable stat window
3139 charmInfo
->SetPetNumber(objmgr
.GeneratePetNumber(), true);
3140 //if charmed two demons the same session, the 2nd gets the 1st one's name
3141 m_target
->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP
, time(NULL
));
3146 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3148 ((Player
*)caster
)->CharmSpellInitialize();
3153 m_target
->SetCharmerGUID(0);
3155 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3156 ((Player
*)m_target
)->setFactionForRace(m_target
->getRace());
3159 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
3162 if(((Creature
*)m_target
)->isPet())
3164 if(Unit
* owner
= m_target
->GetOwner())
3165 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,owner
->getFaction());
3167 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,cinfo
->faction_A
);
3169 else if(cinfo
) // normal creature
3170 m_target
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,cinfo
->faction_A
);
3172 // restore UNIT_FIELD_BYTES_0
3173 if(cinfo
&& caster
->GetTypeId() == TYPEID_PLAYER
&& caster
->getClass() == CLASS_WARLOCK
&& cinfo
->type
== CREATURE_TYPE_DEMON
)
3175 CreatureDataAddon
const *cainfo
= ((Creature
*)m_target
)->GetCreatureAddon();
3176 if(cainfo
&& cainfo
->bytes0
!= 0)
3177 m_target
->SetUInt32Value(UNIT_FIELD_BYTES_0
, cainfo
->bytes0
);
3179 m_target
->RemoveFlag(UNIT_FIELD_BYTES_0
, 2048);
3181 if(m_target
->GetCharmInfo())
3182 m_target
->GetCharmInfo()->SetPetNumber(0, true);
3184 sLog
.outError("Aura::HandleModCharm: target="I64FMTD
" with typeid=%d has a charm aura but no charm info!", m_target
->GetGUID(), m_target
->GetTypeId());
3188 caster
->SetCharm(0);
3190 if(caster
->GetTypeId() == TYPEID_PLAYER
)
3192 WorldPacket
data(SMSG_PET_SPELLS
, 8);
3195 ((Player
*)caster
)->GetSession()->SendPacket(&data
);
3197 if(m_target
->GetTypeId() == TYPEID_UNIT
)
3199 ((Creature
*)m_target
)->AIM_Initialize();
3200 if (((Creature
*)m_target
)->AI())
3201 ((Creature
*)m_target
)->AI()->AttackStart(caster
);
3207 void Aura::HandleModConfuse(bool apply
, bool Real
)
3212 m_target
->SetConfused(apply
, GetCasterGUID(), GetId());
3215 void Aura::HandleModFear(bool apply
, bool Real
)
3220 m_target
->SetFeared(apply
, GetCasterGUID(), GetId());
3223 void Aura::HandleFeignDeath(bool apply
, bool Real
)
3228 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
3234 WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9);
3235 data<<m_target->GetGUID();
3237 m_target->SendMessageToSet(&data,true);
3240 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_29
);
3242 m_target
->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FEIGN_DEATH
);
3244 m_target
->SetFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_DEAD
);
3246 m_target
->addUnitState(UNIT_STAT_DIED
);
3247 m_target
->CombatStop();
3249 // prevent interrupt message
3250 if(m_caster_guid
==m_target
->GetGUID() && m_target
->m_currentSpells
[CURRENT_GENERIC_SPELL
])
3251 m_target
->m_currentSpells
[CURRENT_GENERIC_SPELL
]->finish();
3252 m_target
->InterruptNonMeleeSpells(true);
3253 m_target
->getHostilRefManager().deleteReferences();
3258 WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9);
3259 data<<m_target->GetGUID();
3261 m_target->SendMessageToSet(&data,true);
3264 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_UNK_29
);
3266 m_target
->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FEIGN_DEATH
);
3268 m_target
->RemoveFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_DEAD
);
3270 m_target
->clearUnitState(UNIT_STAT_DIED
);
3274 void Aura::HandleAuraModDisarm(bool apply
, bool Real
)
3279 if(!apply
&& m_target
->HasAuraType(SPELL_AURA_MOD_DISARM
))
3282 // not sure for it's correctness
3284 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_DISARMED
);
3286 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_DISARMED
);
3288 // only at real add/remove aura
3289 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
3292 // main-hand attack speed already set to special value for feral form already and don't must change and reset at remove.
3293 if (((Player
*)m_target
)->IsInFeralForm())
3297 m_target
->SetAttackTime(BASE_ATTACK
,BASE_ATTACK_TIME
);
3299 ((Player
*)m_target
)->SetRegularAttackTime();
3301 m_target
->UpdateDamagePhysical(BASE_ATTACK
);
3304 void Aura::HandleAuraModStun(bool apply
, bool Real
)
3311 m_target
->addUnitState(UNIT_STAT_STUNNED
);
3312 m_target
->SetUInt64Value(UNIT_FIELD_TARGET
, 0);
3314 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
3315 m_target
->CastStop(m_target
->GetGUID() == GetCasterGUID() ? GetId() : 0);
3317 // Creature specific
3318 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
3319 ((Creature
*)m_target
)->StopMoving();
3321 m_target
->SetUnitMovementFlags(0); //Clear movement flags
3323 WorldPacket
data(SMSG_FORCE_MOVE_ROOT
, 8);
3325 data
.append(m_target
->GetPackGUID());
3327 m_target
->SendMessageToSet(&data
,true);
3331 // Real remove called after current aura remove from lists, check if other similar auras active
3332 if(m_target
->HasAuraType(SPELL_AURA_MOD_STUN
))
3335 m_target
->clearUnitState(UNIT_STAT_STUNNED
);
3336 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_STUNNED
);
3338 if(!m_target
->hasUnitState(UNIT_STAT_ROOT
)) // prevent allow move if have also root effect
3340 if(m_target
->getVictim() && m_target
->isAlive())
3341 m_target
->SetUInt64Value(UNIT_FIELD_TARGET
,m_target
->getVictim()->GetGUID() );
3343 WorldPacket
data(SMSG_FORCE_MOVE_UNROOT
, 8+4);
3344 data
.append(m_target
->GetPackGUID());
3346 m_target
->SendMessageToSet(&data
,true);
3350 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_HUNTER
&& m_spellProto
->SpellFamilyFlags
& 0x0000100000000000LL
)
3352 Unit
* caster
= GetCaster();
3353 if( !caster
|| caster
->GetTypeId()!=TYPEID_PLAYER
)
3356 uint32 spell_id
= 0;
3360 case 19386: spell_id
= 24131; break;
3361 case 24132: spell_id
= 24134; break;
3362 case 24133: spell_id
= 24135; break;
3363 case 27068: spell_id
= 27069; break;
3364 case 49011: spell_id
= 49009; break;
3365 case 49012: spell_id
= 49010; break;
3367 sLog
.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?",GetId());
3371 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell_id
);
3376 caster
->CastSpell(m_target
,spellInfo
,true,NULL
,this);
3382 void Aura::HandleModStealth(bool apply
, bool Real
)
3386 // drop flag at stealth in bg
3387 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
&& ((Player
*)m_target
)->InBattleGround())
3388 if(BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround())
3389 bg
->EventPlayerDroppedFlag((Player
*)m_target
);
3391 // only at real aura add
3394 m_target
->SetStandFlags(UNIT_STAND_FLAGS_CREEP
);
3395 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
3396 m_target
->SetFlag(PLAYER_FIELD_BYTES2
, 0x2000);
3398 // apply only if not in GM invisibility (and overwrite invisibility state)
3399 if(m_target
->GetVisibility()!=VISIBILITY_OFF
)
3401 m_target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
3402 m_target
->SetVisibility(VISIBILITY_GROUP_STEALTH
);
3408 // only at real aura remove
3411 // if last SPELL_AURA_MOD_STEALTH and no GM invisibility
3412 if(!m_target
->HasAuraType(SPELL_AURA_MOD_STEALTH
) && m_target
->GetVisibility()!=VISIBILITY_OFF
)
3414 m_target
->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP
);
3415 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
3416 m_target
->RemoveFlag(PLAYER_FIELD_BYTES2
, 0x2000);
3418 // restore invisibility if any
3419 if(m_target
->HasAuraType(SPELL_AURA_MOD_INVISIBILITY
))
3421 m_target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
3422 m_target
->SetVisibility(VISIBILITY_GROUP_INVISIBILITY
);
3425 m_target
->SetVisibility(VISIBILITY_ON
);
3430 // Master of Subtlety
3431 Unit::AuraList
const& mDummyAuras
= m_target
->GetAurasByType(SPELL_AURA_DUMMY
);
3432 for(Unit::AuraList::const_iterator i
= mDummyAuras
.begin();i
!= mDummyAuras
.end(); ++i
)
3434 if ((*i
)->GetSpellProto()->SpellIconID
== 2114)
3438 int32 bp
= (*i
)->GetModifier()->m_amount
;
3439 m_target
->CastCustomSpell(m_target
,31665,&bp
,NULL
,NULL
,true);
3442 m_target
->CastSpell(m_target
,31666,true);
3448 void Aura::HandleInvisibility(bool apply
, bool Real
)
3452 m_target
->m_invisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3454 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
3456 // apply glow vision
3457 m_target
->SetFlag(PLAYER_FIELD_BYTES2
,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
);
3459 // drop flag at invisible in bg
3460 if(((Player
*)m_target
)->InBattleGround())
3461 if(BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround())
3462 bg
->EventPlayerDroppedFlag((Player
*)m_target
);
3465 // apply only if not in GM invisibility and not stealth
3466 if(m_target
->GetVisibility()==VISIBILITY_ON
)
3468 // Aura not added yet but visibility code expect temporary add aura
3469 m_target
->SetVisibility(VISIBILITY_GROUP_NO_DETECT
);
3470 m_target
->SetVisibility(VISIBILITY_GROUP_INVISIBILITY
);
3475 // recalculate value at modifier remove (current aura already removed)
3476 m_target
->m_invisibilityMask
= 0;
3477 Unit::AuraList
const& auras
= m_target
->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY
);
3478 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
3479 m_target
->m_invisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3481 // only at real aura remove and if not have different invisibility auras.
3482 if(Real
&& m_target
->m_invisibilityMask
==0)
3484 // remove glow vision
3485 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3486 m_target
->RemoveFlag(PLAYER_FIELD_BYTES2
,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW
);
3488 // apply only if not in GM invisibility & not stealthed while invisible
3489 if(m_target
->GetVisibility()!=VISIBILITY_OFF
)
3491 // if have stealth aura then already have stealth visibility
3492 if(!m_target
->HasAuraType(SPELL_AURA_MOD_STEALTH
))
3493 m_target
->SetVisibility(VISIBILITY_ON
);
3499 void Aura::HandleInvisibilityDetect(bool apply
, bool Real
)
3503 m_target
->m_detectInvisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3507 // recalculate value at modifier remove (current aura already removed)
3508 m_target
->m_detectInvisibilityMask
= 0;
3509 Unit::AuraList
const& auras
= m_target
->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION
);
3510 for(Unit::AuraList::const_iterator itr
= auras
.begin(); itr
!= auras
.end(); ++itr
)
3511 m_target
->m_detectInvisibilityMask
|= (1 << m_modifier
.m_miscvalue
);
3513 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
3514 ObjectAccessor::UpdateVisibilityForPlayer((Player
*)m_target
);
3517 void Aura::HandleAuraModRoot(bool apply
, bool Real
)
3519 // only at real add/remove aura
3523 // Frost root aura -> freeze/unfreeze target
3524 if (GetSpellSchoolMask(m_spellProto
) & SPELL_SCHOOL_MASK_FROST
)
3525 m_target
->ModifyAuraState(AURA_STATE_FROZEN
, apply
);
3527 uint32 apply_stat
= UNIT_STAT_ROOT
;
3530 m_target
->addUnitState(UNIT_STAT_ROOT
);
3531 m_target
->SetUInt64Value (UNIT_FIELD_TARGET
, 0);
3532 // probably wrong (this add skinable flag)
3533 // TODO: find correct flag
3534 // m_target->SetFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
3536 //Save last orientation
3537 if( m_target
->getVictim() )
3538 m_target
->SetOrientation(m_target
->GetAngle(m_target
->getVictim()));
3540 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3542 WorldPacket
data(SMSG_FORCE_MOVE_ROOT
, 10);
3543 data
.append(m_target
->GetPackGUID());
3545 m_target
->SendMessageToSet(&data
,true);
3547 //Clear unit movement flags
3548 m_target
->SetUnitMovementFlags(0);
3551 ((Creature
*)m_target
)->StopMoving();
3555 // Real remove called after current aura remove from lists, check if other similar auras active
3556 if(m_target
->HasAuraType(SPELL_AURA_MOD_ROOT
))
3559 m_target
->clearUnitState(UNIT_STAT_ROOT
);
3560 // probably wrong (this add skinable flag)
3561 // TODO: find correct flag
3562 // m_target->RemoveFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
3564 if(!m_target
->hasUnitState(UNIT_STAT_STUNNED
)) // prevent allow move if have also stun effect
3566 if(m_target
->getVictim() && m_target
->isAlive())
3567 m_target
->SetUInt64Value (UNIT_FIELD_TARGET
,m_target
->getVictim()->GetGUID() );
3569 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3571 WorldPacket
data(SMSG_FORCE_MOVE_UNROOT
, 10);
3572 data
.append(m_target
->GetPackGUID());
3574 m_target
->SendMessageToSet(&data
,true);
3580 void Aura::HandleAuraModSilence(bool apply
, bool Real
)
3582 // only at real add/remove aura
3588 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_SILENCED
);
3589 // Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE
3590 for (uint32 i
= CURRENT_MELEE_SPELL
; i
< CURRENT_MAX_SPELL
;i
++)
3592 Spell
* currentSpell
= m_target
->m_currentSpells
[i
];
3593 if (currentSpell
&& currentSpell
->m_spellInfo
->PreventionType
== SPELL_PREVENTION_TYPE_SILENCE
)
3595 uint32 state
= currentSpell
->getState();
3596 // Stop spells on prepare or casting state
3597 if ( state
== SPELL_STATE_PREPARING
|| state
== SPELL_STATE_CASTING
)
3599 currentSpell
->cancel();
3600 currentSpell
->SetReferencedFromCurrent(false);
3601 m_target
->m_currentSpells
[i
] = NULL
;
3608 // Arcane Torrent (Energy)
3611 Unit
* caster
= GetCaster();
3615 // Search Mana Tap auras on caster
3616 Aura
* dummy
= caster
->GetDummyAura(28734);
3619 int32 bp
= dummy
->GetStackAmount() * 10;
3620 caster
->CastCustomSpell(caster
, 25048, &bp
, NULL
, NULL
, true);
3621 caster
->RemoveAurasDueToSpell(28734);
3628 // Real remove called after current aura remove from lists, check if other similar auras active
3629 if(m_target
->HasAuraType(SPELL_AURA_MOD_SILENCE
))
3632 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_SILENCED
);
3636 void Aura::HandleModThreat(bool apply
, bool Real
)
3638 // only at real add/remove aura
3642 if(!m_target
->isAlive())
3645 Unit
* caster
= GetCaster();
3647 if(!caster
|| !caster
->isAlive())
3656 level_diff
= m_target
->getLevel() - 60;
3659 // The Eye of Diminution
3661 level_diff
= m_target
->getLevel() - 60;
3666 m_modifier
.m_amount
+= multiplier
* level_diff
;
3668 for(int8 x
=0;x
< MAX_SPELL_SCHOOL
;x
++)
3670 if(m_modifier
.m_miscvalue
& int32(1<<x
))
3672 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3673 ApplyPercentModFloatVar(m_target
->m_threatModifier
[x
], m_positive
? m_modifier
.m_amount
: -m_modifier
.m_amount
, apply
);
3678 void Aura::HandleAuraModTotalThreat(bool apply
, bool Real
)
3680 // only at real add/remove aura
3684 if(!m_target
->isAlive() || m_target
->GetTypeId()!= TYPEID_PLAYER
)
3687 Unit
* caster
= GetCaster();
3689 if(!caster
|| !caster
->isAlive())
3692 float threatMod
= 0.0f
;
3694 threatMod
= float(m_modifier
.m_amount
);
3696 threatMod
= float(-m_modifier
.m_amount
);
3698 m_target
->getHostilRefManager().threatAssist(caster
, threatMod
);
3701 void Aura::HandleModTaunt(bool apply
, bool Real
)
3703 // only at real add/remove aura
3707 if(!m_target
->isAlive() || !m_target
->CanHaveThreatList())
3710 Unit
* caster
= GetCaster();
3712 if(!caster
|| !caster
->isAlive() || caster
->GetTypeId() != TYPEID_PLAYER
)
3716 m_target
->TauntApply(caster
);
3719 // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat
3720 m_target
->TauntFadeOut(caster
);
3724 /*********************************************************/
3725 /*** MODIFY SPEED ***/
3726 /*********************************************************/
3727 void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real
)
3729 // all applied/removed only at real aura add/remove
3733 m_target
->UpdateSpeed(MOVE_RUN
, true);
3736 void Aura::HandleAuraModIncreaseMountedSpeed(bool /*apply*/, bool Real
)
3738 // all applied/removed only at real aura add/remove
3742 m_target
->UpdateSpeed(MOVE_RUN
, true);
3745 void Aura::HandleAuraModIncreaseFlightSpeed(bool apply
, bool Real
)
3747 // all applied/removed only at real aura add/remove
3751 // Enable Fly mode for flying mounts
3752 if (m_modifier
.m_auraname
== SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
)
3756 data
.Initialize(SMSG_MOVE_SET_CAN_FLY
, 12);
3758 data
.Initialize(SMSG_MOVE_UNSET_CAN_FLY
, 12);
3759 data
.append(m_target
->GetPackGUID());
3760 data
<< uint32(0); // unknown
3761 m_target
->SendMessageToSet(&data
, true);
3763 //Players on flying mounts must be immune to polymorph
3764 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
3765 m_target
->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC
,MECHANIC_POLYMORPH
,apply
);
3767 // Dragonmaw Illusion (overwrite mount model, mounted aura already applied)
3768 if( apply
&& m_target
->HasAura(42016,0) && m_target
->GetMountID())
3769 m_target
->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID
,16314);
3772 m_target
->UpdateSpeed(MOVE_FLIGHT
, true);
3775 void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real
)
3777 // all applied/removed only at real aura add/remove
3781 m_target
->UpdateSpeed(MOVE_SWIM
, true);
3784 void Aura::HandleAuraModDecreaseSpeed(bool /*apply*/, bool Real
)
3786 // all applied/removed only at real aura add/remove
3790 m_target
->UpdateSpeed(MOVE_RUN
, true);
3791 m_target
->UpdateSpeed(MOVE_SWIM
, true);
3792 m_target
->UpdateSpeed(MOVE_FLIGHT
, true);
3795 void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real
)
3797 // all applied/removed only at real aura add/remove
3801 m_target
->UpdateSpeed(MOVE_RUN
, true);
3802 m_target
->UpdateSpeed(MOVE_SWIM
, true);
3803 m_target
->UpdateSpeed(MOVE_FLIGHT
, true);
3806 /*********************************************************/
3808 /*********************************************************/
3810 void Aura::HandleModMechanicImmunity(bool apply
, bool Real
)
3812 uint32 mechanic
= 1 << m_modifier
.m_miscvalue
;
3814 //immune movement impairment and loss of control
3816 mechanic
=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK
;
3818 if(apply
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
3820 Unit::AuraMap
& Auras
= m_target
->GetAuras();
3821 for(Unit::AuraMap::iterator iter
= Auras
.begin(), next
; iter
!= Auras
.end(); iter
= next
)
3825 SpellEntry
const *spell
= iter
->second
->GetSpellProto();
3826 if (!( spell
->Attributes
& SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY
) && // spells unaffected by invulnerability
3827 spell
->Id
!= GetId())
3829 //check for mechanic mask
3830 if(GetSpellMechanicMask(spell
, iter
->second
->GetEffIndex()) & mechanic
)
3832 m_target
->RemoveAurasDueToSpell(spell
->Id
);
3836 next
= Auras
.begin();
3842 m_target
->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC
,m_modifier
.m_miscvalue
,apply
);
3845 if ( GetSpellProto()->SpellFamilyName
== SPELLFAMILY_HUNTER
&& GetSpellProto()->SpellIconID
== 1680)
3847 // The Beast Within cast on owner if talent present
3848 if ( Unit
* owner
= m_target
->GetOwner() )
3851 Unit::AuraList
const& m_dummyAuras
= owner
->GetAurasByType(SPELL_AURA_DUMMY
);
3852 for(Unit::AuraList::const_iterator i
= m_dummyAuras
.begin(); i
!= m_dummyAuras
.end(); ++i
)
3854 if ( (*i
)->GetSpellProto()->SpellIconID
== 2229 )
3857 owner
->CastSpell(owner
, 34471, true, 0, this);
3859 owner
->RemoveAurasDueToSpell(34471);
3866 // The Beast Within and Bestial Wrath - immunity
3867 if(GetId() == 19574 || GetId() == 34471)
3871 m_target
->CastSpell(m_target
,24395,true);
3872 m_target
->CastSpell(m_target
,24396,true);
3873 m_target
->CastSpell(m_target
,24397,true);
3874 m_target
->CastSpell(m_target
,26592,true);
3878 m_target
->RemoveAurasDueToSpell(24395);
3879 m_target
->RemoveAurasDueToSpell(24396);
3880 m_target
->RemoveAurasDueToSpell(24397);
3881 m_target
->RemoveAurasDueToSpell(26592);
3886 void Aura::HandleAuraModEffectImmunity(bool apply
, bool Real
)
3890 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
3892 if(((Player
*)m_target
)->InBattleGround())
3894 BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround();
3897 switch(bg
->GetTypeID())
3899 case BATTLEGROUND_AV
:
3903 case BATTLEGROUND_WS
:
3905 // Warsong Flag, horde // Silverwing Flag, alliance
3906 if(GetId() == 23333 || GetId() == 23335)
3907 bg
->EventPlayerDroppedFlag(((Player
*)m_target
));
3910 case BATTLEGROUND_AB
:
3914 case BATTLEGROUND_EY
:
3916 if(GetId() == 34976)
3917 bg
->EventPlayerDroppedFlag(((Player
*)m_target
));
3926 m_target
->ApplySpellImmune(GetId(),IMMUNITY_EFFECT
,m_modifier
.m_miscvalue
,apply
);
3929 void Aura::HandleAuraModStateImmunity(bool apply
, bool Real
)
3931 if(apply
&& Real
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
3933 Unit::AuraList
const& auraList
= m_target
->GetAurasByType(AuraType(m_modifier
.m_miscvalue
));
3934 for(Unit::AuraList::const_iterator itr
= auraList
.begin(); itr
!= auraList
.end();)
3936 if (auraList
.front() != this) // skip itself aura (it already added)
3938 m_target
->RemoveAurasDueToSpell(auraList
.front()->GetId());
3939 itr
= auraList
.begin();
3946 m_target
->ApplySpellImmune(GetId(),IMMUNITY_STATE
,m_modifier
.m_miscvalue
,apply
);
3949 void Aura::HandleAuraModSchoolImmunity(bool apply
, bool Real
)
3951 m_target
->ApplySpellImmune(GetId(),IMMUNITY_SCHOOL
,m_modifier
.m_miscvalue
,apply
);
3953 if(Real
&& apply
&& GetSpellProto()->AttributesEx
& SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
)
3955 if(IsPositiveSpell(GetId())) //Only positive immunity removes auras
3957 uint32 school_mask
= m_modifier
.m_miscvalue
;
3958 Unit::AuraMap
& Auras
= m_target
->GetAuras();
3959 for(Unit::AuraMap::iterator iter
= Auras
.begin(), next
; iter
!= Auras
.end(); iter
= next
)
3963 SpellEntry
const *spell
= iter
->second
->GetSpellProto();
3964 if((GetSpellSchoolMask(spell
) & school_mask
)//Check for school mask
3965 && !( spell
->Attributes
& SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY
) //Spells unaffected by invulnerability
3966 && !iter
->second
->IsPositive() //Don't remove positive spells
3967 && spell
->Id
!= GetId() ) //Don't remove self
3969 m_target
->RemoveAurasDueToSpell(spell
->Id
);
3973 next
= Auras
.begin();
3978 if( Real
&& GetSpellProto()->Mechanic
== MECHANIC_BANISH
)
3981 m_target
->addUnitState(UNIT_STAT_ISOLATED
);
3983 m_target
->clearUnitState(UNIT_STAT_ISOLATED
);
3987 void Aura::HandleAuraModDmgImmunity(bool apply
, bool Real
)
3989 m_target
->ApplySpellImmune(GetId(),IMMUNITY_DAMAGE
,m_modifier
.m_miscvalue
,apply
);
3992 void Aura::HandleAuraModDispelImmunity(bool apply
, bool Real
)
3994 // all applied/removed only at real aura add/remove
3998 m_target
->ApplySpellDispelImmunity(m_spellProto
, DispelType(m_modifier
.m_miscvalue
), apply
);
4001 void Aura::HandleAuraProcTriggerSpell(bool apply
, bool Real
)
4008 // some spell have charges by functionality not have its in spell data
4011 case 28200: // Ascendance (Talisman of Ascendance trinket)
4019 void Aura::HandleAuraModStalked(bool apply
, bool Real
)
4021 // used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND
4023 m_target
->SetFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_TRACK_UNIT
);
4025 m_target
->RemoveFlag(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_TRACK_UNIT
);
4028 /*********************************************************/
4030 /*********************************************************/
4032 void Aura::HandlePeriodicTriggerSpell(bool apply
, bool Real
)
4034 m_isPeriodic
= apply
;
4037 void Aura::HandlePeriodicTriggerSpellWithValue(bool apply
, bool Real
)
4039 m_isPeriodic
= apply
;
4042 void Aura::HandlePeriodicEnergize(bool apply
, bool Real
)
4047 m_isPeriodic
= apply
;
4049 // Replenishment (0.25% from max)
4050 // Infinite Replenishment
4051 if (GetId() == 57669 ||
4053 m_modifier
.m_amount
= m_target
->GetMaxPower(POWER_MANA
) * 25 / 10000;
4056 void Aura::HandleAuraPowerBurn(bool apply
, bool Real
)
4058 m_isPeriodic
= apply
;
4061 void Aura::HandleAuraPeriodicDummy(bool apply
, bool Real
)
4063 // spells required only Real aura add/remove
4067 // For prevent double apply bonuses
4068 bool loading
= (m_target
->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)m_target
)->GetSession()->PlayerLoading());
4070 Unit
* caster
= GetCaster();
4072 SpellEntry
const*spell
= GetSpellProto();
4073 switch( spell
->SpellFamilyName
)
4075 case SPELLFAMILY_ROGUE
:
4077 // Master of Subtlety
4078 if (spell
->Id
==31666 && !apply
)
4080 m_target
->RemoveAurasDueToSpell(31665);
4085 case SPELLFAMILY_HUNTER
:
4088 if (apply
&& !loading
&& caster
)
4089 m_modifier
.m_amount
+=caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 8 / 100;
4094 m_isPeriodic
= apply
;
4097 void Aura::HandlePeriodicHeal(bool apply
, bool Real
)
4099 m_isPeriodic
= apply
;
4102 void Aura::HandlePeriodicDamage(bool apply
, bool Real
)
4104 // spells required only Real aura add/remove
4108 m_isPeriodic
= apply
;
4110 // For prevent double apply bonuses
4111 bool loading
= (m_target
->GetTypeId() == TYPEID_PLAYER
&& ((Player
*)m_target
)->GetSession()->PlayerLoading());
4113 // Custom damage calculation after
4114 if (!apply
|| loading
)
4117 Unit
*caster
= GetCaster();
4121 switch (m_spellProto
->SpellFamilyName
)
4123 case SPELLFAMILY_GENERIC
:
4126 if ( m_spellProto
->SpellIconID
== 147 && m_spellProto
->SpellVisual
[0] == 0 )
4128 // $AP*0.18/6 bonus per tick
4129 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 3 / 100);
4134 case SPELLFAMILY_WARRIOR
:
4137 if (m_spellProto
->SpellFamilyFlags
& 0x0000000000000020LL
)
4139 // $0.2*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick
4140 float ap
= caster
->GetTotalAttackPowerValue(BASE_ATTACK
);
4141 int32 mws
= caster
->GetAttackTime(BASE_ATTACK
);
4142 float mwb_min
= caster
->GetWeaponDamageRange(BASE_ATTACK
,MINDAMAGE
);
4143 float mwb_max
= caster
->GetWeaponDamageRange(BASE_ATTACK
,MAXDAMAGE
);
4144 m_modifier
.m_amount
+=int32(((mwb_min
+mwb_max
)/2+ap
*mws
/14000)*0.2f
);
4149 case SPELLFAMILY_DRUID
:
4152 if (m_spellProto
->SpellFamilyFlags
& 0x0000000000001000LL
)
4154 // $AP*0.06 bonus per tick
4155 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 6 / 100);
4159 if (m_spellProto
->SpellFamilyFlags
& 0x000000010000000000LL
)
4161 // $AP*0.05/5 bonus per tick
4162 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) / 100);
4166 if (m_spellProto
->SpellFamilyFlags
& 0x000000000000800000LL
)
4169 if (caster
->GetTypeId() != TYPEID_PLAYER
)
4172 uint8 cp
= ((Player
*)caster
)->GetComboPoints();
4174 // Idol of Feral Shadows. Cant be handled as SpellMod in SpellAura:Dummy due its dependency from CPs
4175 Unit::AuraList
const& dummyAuras
= caster
->GetAurasByType(SPELL_AURA_DUMMY
);
4176 for(Unit::AuraList::const_iterator itr
= dummyAuras
.begin(); itr
!= dummyAuras
.end(); ++itr
)
4178 if((*itr
)->GetId()==34241)
4180 m_modifier
.m_amount
+= cp
* (*itr
)->GetModifier()->m_amount
;
4184 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * cp
/ 100);
4188 if (m_spellProto
->SpellFamilyFlags
& 0x1000000000000000LL
)
4191 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 15 / 100);
4196 case SPELLFAMILY_ROGUE
:
4199 if (m_spellProto
->SpellFamilyFlags
& 0x000000000000100000LL
)
4201 if (caster
->GetTypeId() != TYPEID_PLAYER
)
4203 //1 point : ${($m1+$b1*1+0.015*$AP)*4} damage over 8 secs
4204 //2 points: ${($m1+$b1*2+0.024*$AP)*5} damage over 10 secs
4205 //3 points: ${($m1+$b1*3+0.03*$AP)*6} damage over 12 secs
4206 //4 points: ${($m1+$b1*4+0.03428571*$AP)*7} damage over 14 secs
4207 //5 points: ${($m1+$b1*5+0.0375*$AP)*8} damage over 16 secs
4208 float AP_per_combo
[] = {0, 0.015f
, 0.024, 0.03, 0.03428571, 0.0375};
4209 uint8 cp
= ((Player
*)caster
)->GetComboPoints();
4211 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * AP_per_combo
[cp
]);
4215 if (m_spellProto
->SpellFamilyFlags
& 0x000000000000000100LL
)
4217 // $AP*0.07 bonus per tick
4218 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 7 / 100);
4222 if (m_spellProto
->SpellFamilyFlags
& 0x0000000000010000)
4224 // 0.08*$AP / 4 * amount of stack
4225 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(BASE_ATTACK
) * 2 * GetStackAmount() / 100);
4230 case SPELLFAMILY_HUNTER
:
4233 if (m_spellProto
->SpellFamilyFlags
& 0x0000000000004000LL
)
4235 // $RAP*0.1/5 bonus per tick
4236 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 10 / 500);
4240 if (m_spellProto
->SpellFamilyFlags
& 0x0000000000000004LL
&& m_spellProto
->SpellIconID
== 678)
4242 // $RAP*0.1/5 bonus per tick
4243 m_modifier
.m_amount
+= int32(caster
->GetTotalAttackPowerValue(RANGED_ATTACK
) * 10 / 500);
4253 void Aura::HandlePeriodicDamagePCT(bool apply
, bool Real
)
4255 m_isPeriodic
= apply
;
4258 void Aura::HandlePeriodicLeech(bool apply
, bool Real
)
4260 m_isPeriodic
= apply
;
4263 void Aura::HandlePeriodicManaLeech(bool apply
, bool Real
)
4265 m_isPeriodic
= apply
;
4268 void Aura::HandlePeriodicHealthFunnel(bool apply
, bool Real
)
4270 m_isPeriodic
= apply
;
4273 /*********************************************************/
4274 /*** MODIFY STATS ***/
4275 /*********************************************************/
4277 /********************************/
4278 /*** RESISTANCE ***/
4279 /********************************/
4281 void Aura::HandleAuraModResistanceExclusive(bool apply
, bool Real
)
4283 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
4285 if(m_modifier
.m_miscvalue
& int32(1<<x
))
4287 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), BASE_VALUE
, float(m_modifier
.m_amount
), apply
);
4288 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4289 m_target
->ApplyResistanceBuffModsMod(SpellSchools(x
),m_positive
,m_modifier
.m_amount
, apply
);
4294 void Aura::HandleAuraModResistance(bool apply
, bool Real
)
4296 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
4298 if(m_modifier
.m_miscvalue
& int32(1<<x
))
4300 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4301 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4302 m_target
->ApplyResistanceBuffModsMod(SpellSchools(x
),m_positive
,m_modifier
.m_amount
, apply
);
4307 void Aura::HandleAuraModBaseResistancePCT(bool apply
, bool Real
)
4309 // only players have base stats
4310 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4312 //pets only have base armor
4313 if(((Creature
*)m_target
)->isPet() && (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
4314 m_target
->HandleStatModifier(UNIT_MOD_ARMOR
, BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4318 for(int8 x
= SPELL_SCHOOL_NORMAL
; x
< MAX_SPELL_SCHOOL
;x
++)
4320 if(m_modifier
.m_miscvalue
& int32(1<<x
))
4321 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ x
), BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4326 void Aura::HandleModResistancePercent(bool apply
, bool Real
)
4328 for(int8 i
= SPELL_SCHOOL_NORMAL
; i
< MAX_SPELL_SCHOOL
; i
++)
4330 if(m_modifier
.m_miscvalue
& int32(1<<i
))
4332 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ i
), TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4333 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4335 m_target
->ApplyResistanceBuffModsPercentMod(SpellSchools(i
),true,m_modifier
.m_amount
, apply
);
4336 m_target
->ApplyResistanceBuffModsPercentMod(SpellSchools(i
),false,m_modifier
.m_amount
, apply
);
4342 void Aura::HandleModBaseResistance(bool apply
, bool Real
)
4344 // only players have base stats
4345 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4347 //only pets have base stats
4348 if(((Creature
*)m_target
)->isPet() && (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
4349 m_target
->HandleStatModifier(UNIT_MOD_ARMOR
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4353 for(int i
= SPELL_SCHOOL_NORMAL
; i
< MAX_SPELL_SCHOOL
; i
++)
4354 if(m_modifier
.m_miscvalue
& (1<<i
))
4355 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START
+ i
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4359 /********************************/
4361 /********************************/
4363 void Aura::HandleAuraModStat(bool apply
, bool Real
)
4365 if (m_modifier
.m_miscvalue
< -2 || m_modifier
.m_miscvalue
> 4)
4367 sLog
.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ",GetId(),GetEffIndex(),m_modifier
.m_miscvalue
);
4371 for(int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; i
++)
4373 // -1 or -2 is all stats ( misc < -2 checked in function beginning )
4374 if (m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
== i
)
4376 //m_target->ApplyStatMod(Stats(i), m_modifier.m_amount,apply);
4377 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4378 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4379 m_target
->ApplyStatBuffMod(Stats(i
),m_modifier
.m_amount
,apply
);
4384 void Aura::HandleModPercentStat(bool apply
, bool Real
)
4386 if (m_modifier
.m_miscvalue
< -1 || m_modifier
.m_miscvalue
> 4)
4388 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
4392 // only players have base stats
4393 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
4396 for (int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; ++i
)
4398 if(m_modifier
.m_miscvalue
== i
|| m_modifier
.m_miscvalue
== -1)
4399 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4403 void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool Real
)
4405 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4408 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4409 // This information for client side use only
4410 // Recalculate bonus
4411 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4414 void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool Real
)
4416 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4419 // Recalculate bonus
4420 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4423 void Aura::HandleAuraModDispelResist(bool apply
, bool Real
)
4429 m_target
->CastSpell(m_target
,44416,true,NULL
,this,GetCasterGUID());
4432 void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool Real
)
4434 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4437 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4438 // This information for client side use only
4439 // Recalculate bonus
4440 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4443 void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool Real
)
4445 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4448 // Recalculate bonus
4449 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4452 void Aura::HandleModHealingDone(bool /*apply*/, bool Real
)
4454 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4456 // implemented in Unit::SpellHealingBonus
4457 // this information is for client side only
4458 ((Player
*)m_target
)->UpdateSpellDamageAndHealingBonus();
4461 void Aura::HandleModTotalPercentStat(bool apply
, bool Real
)
4463 if (m_modifier
.m_miscvalue
< -1 || m_modifier
.m_miscvalue
> 4)
4465 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
4469 //save current and max HP before applying aura
4470 uint32 curHPValue
= m_target
->GetHealth();
4471 uint32 maxHPValue
= m_target
->GetMaxHealth();
4473 for (int32 i
= STAT_STRENGTH
; i
< MAX_STATS
; i
++)
4475 if(m_modifier
.m_miscvalue
== i
|| m_modifier
.m_miscvalue
== -1)
4477 m_target
->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START
+ i
), TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4478 if(m_target
->GetTypeId() == TYPEID_PLAYER
|| ((Creature
*)m_target
)->isPet())
4479 m_target
->ApplyStatPercentBuffMod(Stats(i
), m_modifier
.m_amount
, apply
);
4483 //recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag)
4484 if ((m_modifier
.m_miscvalue
== STAT_STAMINA
) && (maxHPValue
> 0) && (m_spellProto
->Attributes
& 0x10))
4486 // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed
4487 uint32 newHPValue
= (m_target
->GetMaxHealth() * curHPValue
) / maxHPValue
;
4488 m_target
->SetHealth(newHPValue
);
4492 void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool Real
)
4494 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4497 if(m_modifier
.m_miscvalue
!= SPELL_SCHOOL_MASK_NORMAL
)
4499 // support required adding replace UpdateArmor by loop by UpdateResistence at intellect update
4500 // and include in UpdateResistence same code as in UpdateArmor for aura mod apply.
4501 sLog
.outError("Aura SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT(182) need adding support for non-armor resistances!");
4505 // Recalculate Armor
4506 m_target
->UpdateArmor();
4509 /********************************/
4510 /*** HEAL & ENERGIZE ***/
4511 /********************************/
4512 void Aura::HandleAuraModTotalHealthPercentRegen(bool apply
, bool Real
)
4514 m_isPeriodic
= apply
;
4517 void Aura::HandleAuraModTotalManaPercentRegen(bool apply
, bool Real
)
4519 if(m_modifier
.periodictime
== 0)
4520 m_modifier
.periodictime
= 1000;
4522 m_periodicTimer
= m_modifier
.periodictime
;
4523 m_isPeriodic
= apply
;
4526 void Aura::HandleModRegen(bool apply
, bool Real
) // eating
4528 if(m_modifier
.periodictime
== 0)
4529 m_modifier
.periodictime
= 5000;
4531 m_periodicTimer
= 5000;
4532 m_isPeriodic
= apply
;
4535 void Aura::HandleModPowerRegen(bool apply
, bool Real
) // drinking
4540 Powers pt
= m_target
->getPowerType();
4541 if(m_modifier
.periodictime
== 0)
4543 if (pt
== POWER_RAGE
)
4544 m_modifier
.periodictime
= 1000;
4546 m_modifier
.periodictime
= 2000;
4549 m_periodicTimer
= 5000;
4551 if (m_target
->GetTypeId() == TYPEID_PLAYER
&& m_modifier
.m_miscvalue
== POWER_MANA
)
4552 ((Player
*)m_target
)->UpdateManaRegen();
4554 m_isPeriodic
= apply
;
4557 void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real
)
4559 // spells required only Real aura add/remove
4563 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
4566 // Update manaregen value
4567 if (m_modifier
.m_miscvalue
== POWER_MANA
)
4568 ((Player
*)m_target
)->UpdateManaRegen();
4571 void Aura::HandleModManaRegen(bool /*apply*/, bool Real
)
4573 // spells required only Real aura add/remove
4577 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
4580 //Note: an increase in regen does NOT cause threat.
4581 ((Player
*)m_target
)->UpdateManaRegen();
4584 void Aura::HandleComprehendLanguage(bool apply
, bool Real
)
4587 m_target
->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_COMPREHEND_LANG
);
4589 m_target
->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_COMPREHEND_LANG
);
4592 void Aura::HandleAuraModIncreaseHealth(bool apply
, bool Real
)
4594 // Special case with temporary increase max/current health
4597 case 12976: // Warrior Last Stand triggered spell
4598 case 28726: // Nightmare Seed ( Nightmare Seed )
4599 case 34511: // Valor (Bulwark of Kings, Bulwark of the Ancient Kings)
4600 case 44055: // Tremendous Fortitude (Battlemaster's Alacrity)
4606 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4607 m_target
->ModifyHealth(m_modifier
.m_amount
);
4611 if (int32(m_target
->GetHealth()) > m_modifier
.m_amount
)
4612 m_target
->ModifyHealth(-m_modifier
.m_amount
);
4614 m_target
->SetHealth(1);
4615 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4623 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4626 void Aura::HandleAuraModIncreaseMaxHealth(bool apply
, bool Real
)
4628 uint32 oldhealth
= m_target
->GetHealth();
4629 double healthPercentage
= (double)oldhealth
/ (double)m_target
->GetMaxHealth();
4631 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4633 // refresh percentage
4636 uint32 newhealth
= uint32(ceil((double)m_target
->GetMaxHealth() * healthPercentage
));
4640 m_target
->SetHealth(newhealth
);
4644 void Aura::HandleAuraModIncreaseEnergy(bool apply
, bool Real
)
4646 Powers powerType
= m_target
->getPowerType();
4647 if(int32(powerType
) != m_modifier
.m_miscvalue
)
4650 UnitMods unitMod
= UnitMods(UNIT_MOD_POWER_START
+ powerType
);
4652 m_target
->HandleStatModifier(unitMod
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4655 void Aura::HandleAuraModIncreaseEnergyPercent(bool apply
, bool /*Real*/)
4657 Powers powerType
= m_target
->getPowerType();
4658 if(int32(powerType
) != m_modifier
.m_miscvalue
)
4661 UnitMods unitMod
= UnitMods(UNIT_MOD_POWER_START
+ powerType
);
4663 m_target
->HandleStatModifier(unitMod
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4666 void Aura::HandleAuraModIncreaseHealthPercent(bool apply
, bool /*Real*/)
4668 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4671 void Aura::HandleAuraIncreaseBaseHealthPercent(bool apply
, bool /*Real*/)
4673 m_target
->HandleStatModifier(UNIT_MOD_HEALTH
, BASE_PCT
, float(m_modifier
.m_amount
), apply
);
4676 /********************************/
4678 /********************************/
4680 void Aura::HandleAuraModParryPercent(bool /*apply*/, bool Real
)
4682 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
4685 ((Player
*)m_target
)->UpdateParryPercentage();
4688 void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool Real
)
4690 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
4693 ((Player
*)m_target
)->UpdateDodgePercentage();
4694 //sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount));
4697 void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool Real
)
4699 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
4702 ((Player
*)m_target
)->UpdateBlockPercentage();
4703 //sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount));
4706 void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real
)
4708 // spells required only Real aura add/remove
4712 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
4715 ((Player
*)m_target
)->UpdateManaRegen();
4718 void Aura::HandleAuraModCritPercent(bool apply
, bool Real
)
4720 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
4723 // apply item specific bonuses for already equipped weapon
4726 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
4727 if(Item
* pItem
= ((Player
*)m_target
)->GetWeaponForAttack(WeaponAttackType(i
)))
4728 ((Player
*)m_target
)->_ApplyWeaponDependentAuraCritMod(pItem
,WeaponAttackType(i
),this,apply
);
4731 // mods must be applied base at equipped weapon class and subclass comparison
4732 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
4733 // m_modifier.m_miscvalue comparison with item generated damage types
4735 if (GetSpellProto()->EquippedItemClass
== -1)
4737 ((Player
*)m_target
)->HandleBaseModValue(CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
4738 ((Player
*)m_target
)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
4739 ((Player
*)m_target
)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE
, FLAT_MOD
, float (m_modifier
.m_amount
), apply
);
4743 // done in Player::_ApplyWeaponDependentAuraMods
4747 void Aura::HandleModHitChance(bool apply
, bool Real
)
4749 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4751 ((Player
*)m_target
)->UpdateMeleeHitChances();
4752 ((Player
*)m_target
)->UpdateRangedHitChances();
4756 m_target
->m_modMeleeHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
4757 m_target
->m_modRangedHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
4761 void Aura::HandleModSpellHitChance(bool apply
, bool Real
)
4763 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4765 ((Player
*)m_target
)->UpdateSpellHitChances();
4769 m_target
->m_modSpellHitChance
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
4773 void Aura::HandleModSpellCritChance(bool apply
, bool Real
)
4775 // spells required only Real aura add/remove
4779 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4781 ((Player
*)m_target
)->UpdateAllSpellCritChances();
4785 m_target
->m_baseSpellCritChance
+= apply
? m_modifier
.m_amount
:(-m_modifier
.m_amount
);
4789 void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real
)
4791 // spells required only Real aura add/remove
4795 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4798 for(int school
= SPELL_SCHOOL_NORMAL
; school
< MAX_SPELL_SCHOOL
; ++school
)
4799 if (m_modifier
.m_miscvalue
& (1<<school
))
4800 ((Player
*)m_target
)->UpdateSpellCritChance(school
);
4803 /********************************/
4804 /*** ATTACK SPEED ***/
4805 /********************************/
4807 void Aura::HandleModCastingSpeed(bool apply
, bool Real
)
4809 m_target
->ApplyCastTimePercentMod(m_modifier
.m_amount
,apply
);
4812 void Aura::HandleModMeleeRangedSpeedPct(bool apply
, bool Real
)
4814 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
,m_modifier
.m_amount
,apply
);
4815 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
,m_modifier
.m_amount
,apply
);
4816 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
4819 void Aura::HandleModCombatSpeedPct(bool apply
, bool Real
)
4821 m_target
->ApplyCastTimePercentMod(m_modifier
.m_amount
,apply
);
4822 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
,m_modifier
.m_amount
,apply
);
4823 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
,m_modifier
.m_amount
,apply
);
4824 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
4827 void Aura::HandleModAttackSpeed(bool apply
, bool Real
)
4829 if(!m_target
->isAlive() )
4832 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
,m_modifier
.m_amount
,apply
);
4835 void Aura::HandleHaste(bool apply
, bool Real
)
4837 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
, m_modifier
.m_amount
,apply
);
4838 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
, m_modifier
.m_amount
,apply
);
4839 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
,m_modifier
.m_amount
,apply
);
4842 void Aura::HandleAuraModRangedHaste(bool apply
, bool Real
)
4844 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
4847 void Aura::HandleRangedAmmoHaste(bool apply
, bool Real
)
4849 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
4851 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
,m_modifier
.m_amount
, apply
);
4854 /********************************/
4855 /*** ATTACK POWER ***/
4856 /********************************/
4858 void Aura::HandleAuraModAttackPower(bool apply
, bool Real
)
4860 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4863 void Aura::HandleAuraModRangedAttackPower(bool apply
, bool Real
)
4865 if((m_target
->getClassMask() & CLASSMASK_WAND_USERS
)!=0)
4868 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4871 void Aura::HandleAuraModAttackPowerPercent(bool apply
, bool Real
)
4873 //UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1
4874 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4877 void Aura::HandleAuraModRangedAttackPowerPercent(bool apply
, bool Real
)
4879 if((m_target
->getClassMask() & CLASSMASK_WAND_USERS
)!=0)
4882 //UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1
4883 m_target
->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
4886 void Aura::HandleAuraModRangedAttackPowerOfStatPercent(bool apply
, bool Real
)
4888 // spells required only Real aura add/remove
4892 // Recalculate bonus
4893 if(m_target
->GetTypeId() == TYPEID_PLAYER
&& !(m_target
->getClassMask() & CLASSMASK_WAND_USERS
))
4894 ((Player
*)m_target
)->UpdateAttackPowerAndDamage(true);
4897 void Aura::HandleAuraModAttackPowerOfStatPercent(bool apply
, bool Real
)
4899 // spells required only Real aura add/remove
4903 // Recalculate bonus
4904 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4905 ((Player
*)m_target
)->UpdateAttackPowerAndDamage(false);
4908 /********************************/
4909 /*** DAMAGE BONUS ***/
4910 /********************************/
4911 void Aura::HandleModDamageDone(bool apply
, bool Real
)
4913 // apply item specific bonuses for already equipped weapon
4914 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
4916 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
4917 if(Item
* pItem
= ((Player
*)m_target
)->GetWeaponForAttack(WeaponAttackType(i
)))
4918 ((Player
*)m_target
)->_ApplyWeaponDependentAuraDamageMod(pItem
,WeaponAttackType(i
),this,apply
);
4921 // m_modifier.m_miscvalue is bitmask of spell schools
4922 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
4923 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wands
4924 // 127 - full bitmask any damages
4926 // mods must be applied base at equipped weapon class and subclass comparison
4927 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
4928 // m_modifier.m_miscvalue comparison with item generated damage types
4930 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
) != 0)
4932 // apply generic physical damage bonuses including wand case
4933 if (GetSpellProto()->EquippedItemClass
== -1 || m_target
->GetTypeId() != TYPEID_PLAYER
)
4935 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4936 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4937 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED
, TOTAL_VALUE
, float(m_modifier
.m_amount
), apply
);
4941 // done in Player::_ApplyWeaponDependentAuraMods
4944 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4947 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS
,m_modifier
.m_amount
,apply
);
4949 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG
,m_modifier
.m_amount
,apply
);
4953 // Skip non magic case for speedup
4954 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_MAGIC
) == 0)
4957 if( GetSpellProto()->EquippedItemClass
!= -1 || GetSpellProto()->EquippedItemInventoryTypeMask
!= 0 )
4959 // wand magic case (skip generic to all item spell bonuses)
4960 // done in Player::_ApplyWeaponDependentAuraMods
4962 // Skip item specific requirements for not wand magic damage
4966 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4967 // This information for client side use only
4968 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
4972 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; i
++)
4974 if((m_modifier
.m_miscvalue
& (1<<i
)) != 0)
4975 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS
+i
,m_modifier
.m_amount
,apply
);
4980 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; i
++)
4982 if((m_modifier
.m_miscvalue
& (1<<i
)) != 0)
4983 m_target
->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG
+i
,m_modifier
.m_amount
,apply
);
4986 Pet
* pet
= m_target
->GetPet();
4988 pet
->UpdateAttackPowerAndDamage();
4992 void Aura::HandleModDamagePercentDone(bool apply
, bool Real
)
4994 sLog
.outDebug("AURA MOD DAMAGE type:%u negative:%u", m_modifier
.m_miscvalue
, m_positive
? 0 : 1);
4996 // apply item specific bonuses for already equipped weapon
4997 if(Real
&& m_target
->GetTypeId()==TYPEID_PLAYER
)
4999 for(int i
= 0; i
< MAX_ATTACK
; ++i
)
5000 if(Item
* pItem
= ((Player
*)m_target
)->GetWeaponForAttack(WeaponAttackType(i
)))
5001 ((Player
*)m_target
)->_ApplyWeaponDependentAuraDamageMod(pItem
,WeaponAttackType(i
),this,apply
);
5004 // m_modifier.m_miscvalue is bitmask of spell schools
5005 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5006 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wand
5007 // 127 - full bitmask any damages
5009 // mods must be applied base at equipped weapon class and subclass comparison
5010 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5011 // m_modifier.m_miscvalue comparison with item generated damage types
5013 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
) != 0)
5015 // apply generic physical damage bonuses including wand case
5016 if (GetSpellProto()->EquippedItemClass
== -1 || m_target
->GetTypeId() != TYPEID_PLAYER
)
5018 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5019 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5020 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5024 // done in Player::_ApplyWeaponDependentAuraMods
5026 // For show in client
5027 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5028 m_target
->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT
,m_modifier
.m_amount
/100.0f
,apply
);
5031 // Skip non magic case for speedup
5032 if((m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_MAGIC
) == 0)
5035 if( GetSpellProto()->EquippedItemClass
!= -1 || GetSpellProto()->EquippedItemInventoryTypeMask
!= 0 )
5037 // wand magic case (skip generic to all item spell bonuses)
5038 // done in Player::_ApplyWeaponDependentAuraMods
5040 // Skip item specific requirements for not wand magic damage
5044 // Magic damage percent modifiers implemented in Unit::SpellDamageBonus
5045 // Send info to client
5046 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5047 for(int i
= SPELL_SCHOOL_HOLY
; i
< MAX_SPELL_SCHOOL
; ++i
)
5048 m_target
->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT
+i
,m_modifier
.m_amount
/100.0f
,apply
);
5051 void Aura::HandleModOffhandDamagePercent(bool apply
, bool Real
)
5053 // spells required only Real aura add/remove
5057 sLog
.outDebug("AURA MOD OFFHAND DAMAGE");
5059 m_target
->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND
, TOTAL_PCT
, float(m_modifier
.m_amount
), apply
);
5062 /********************************/
5063 /*** POWER COST ***/
5064 /********************************/
5066 void Aura::HandleModPowerCostPCT(bool apply
, bool Real
)
5068 // spells required only Real aura add/remove
5072 float amount
= m_modifier
.m_amount
/100.0f
;
5073 for(int i
= 0; i
< MAX_SPELL_SCHOOL
; ++i
)
5074 if(m_modifier
.m_miscvalue
& (1<<i
))
5075 m_target
->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER
+i
,amount
,apply
);
5078 void Aura::HandleModPowerCost(bool apply
, bool Real
)
5080 // spells required only Real aura add/remove
5084 for(int i
= 0; i
< MAX_SPELL_SCHOOL
; ++i
)
5085 if(m_modifier
.m_miscvalue
& (1<<i
))
5086 m_target
->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER
+i
,m_modifier
.m_amount
,apply
);
5089 void Aura::HandleNoReagentUseAura(bool Apply
, bool Real
)
5091 // spells required only Real aura add/remove
5094 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5096 uint32 mask
[3] = {0, 0, 0};
5097 Unit::AuraList
const& noReagent
= m_target
->GetAurasByType(SPELL_AURA_NO_REAGENT_USE
);
5098 for(Unit::AuraList::const_iterator i
= noReagent
.begin(); i
!= noReagent
.end(); ++i
)
5100 uint32
const *ptr
= (*i
)->getAuraSpellClassMask();
5106 m_target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
, mask
[0]);
5107 m_target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
+1, mask
[1]);
5108 m_target
->SetUInt32Value(PLAYER_NO_REAGENT_COST_1
+2, mask
[2]);
5111 /*********************************************************/
5113 /*********************************************************/
5115 void Aura::HandleShapeshiftBoosts(bool apply
)
5118 uint32 spellId2
= 0;
5119 uint32 HotWSpellId
= 0;
5121 switch(GetModifier()->m_miscvalue
)
5125 HotWSpellId
= 24900;
5140 HotWSpellId
= 24899;
5145 HotWSpellId
= 24899;
5147 case FORM_BATTLESTANCE
:
5150 case FORM_DEFENSIVESTANCE
:
5153 case FORM_BERSERKERSTANCE
:
5158 // aura from effect trigger spell
5165 case FORM_FLIGHT_EPIC
:
5169 case FORM_METAMORPHOSIS
:
5173 case FORM_SPIRITOFREDEMPTION
:
5175 spellId2
= 27795; // must be second, this important at aura remove to prevent to early iterator invalidation.
5177 case FORM_GHOSTWOLF
:
5182 case FORM_CREATURECAT
:
5183 case FORM_CREATUREBEAR
:
5188 uint32 form
= GetModifier()->m_miscvalue
-1;
5192 if (spellId
) m_target
->CastSpell(m_target
, spellId
, true, NULL
, this );
5193 if (spellId2
) m_target
->CastSpell(m_target
, spellId2
, true, NULL
, this);
5195 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5197 const PlayerSpellMap
& sp_list
= ((Player
*)m_target
)->GetSpellMap();
5198 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
5200 if(itr
->second
->state
== PLAYERSPELL_REMOVED
) continue;
5201 if(itr
->first
==spellId
|| itr
->first
==spellId2
) continue;
5202 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
5203 if (!spellInfo
|| !(spellInfo
->Attributes
& (SPELL_ATTR_PASSIVE
| (1<<7)))) continue;
5204 if (spellInfo
->Stances
& (1<<form
))
5205 m_target
->CastSpell(m_target
, itr
->first
, true, NULL
, this);
5208 if (((Player
*)m_target
)->HasSpell(17007))
5210 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(24932);
5211 if (spellInfo
&& spellInfo
->Stances
& (1<<form
))
5212 m_target
->CastSpell(m_target
, 24932, true, NULL
, this);
5217 Unit::AuraList
const& mModTotalStatPct
= m_target
->GetAurasByType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
);
5218 for(Unit::AuraList::const_iterator i
= mModTotalStatPct
.begin(); i
!= mModTotalStatPct
.end(); ++i
)
5220 if ((*i
)->GetSpellProto()->SpellIconID
== 240 && (*i
)->GetModifier()->m_miscvalue
== 3)
5222 int32 HotWMod
= (*i
)->GetModifier()->m_amount
;
5223 if(GetModifier()->m_miscvalue
== FORM_CAT
)
5226 m_target
->CastCustomSpell(m_target
, HotWSpellId
, &HotWMod
, NULL
, NULL
, true, NULL
, this);
5235 m_target
->RemoveAurasDueToSpell(spellId
);
5236 m_target
->RemoveAurasDueToSpell(spellId2
);
5238 Unit::AuraMap
& tAuras
= m_target
->GetAuras();
5239 for (Unit::AuraMap::iterator itr
= tAuras
.begin(); itr
!= tAuras
.end();)
5241 if (itr
->second
->IsRemovedOnShapeLost())
5243 m_target
->RemoveAurasDueToSpell(itr
->second
->GetId());
5244 itr
= tAuras
.begin();
5253 /*double healthPercentage = (double)m_target->GetHealth() / (double)m_target->GetMaxHealth();
5254 m_target->SetHealth(uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage)));*/
5257 void Aura::HandleAuraEmpathy(bool apply
, bool Real
)
5259 if(m_target
->GetTypeId() != TYPEID_UNIT
)
5262 CreatureInfo
const * ci
= objmgr
.GetCreatureTemplate(m_target
->GetEntry());
5263 if(ci
&& ci
->type
== CREATURE_TYPE_BEAST
)
5264 m_target
->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_SPECIALINFO
, apply
);
5267 void Aura::HandleAuraUntrackable(bool apply
, bool Real
)
5270 m_target
->SetByteFlag(UNIT_FIELD_BYTES_1
, 3, UNIT_BYTE1_FLAG_UNTRACKABLE
);
5272 m_target
->RemoveByteFlag(UNIT_FIELD_BYTES_1
, 3, UNIT_BYTE1_FLAG_UNTRACKABLE
);
5275 void Aura::HandleAuraModPacify(bool apply
, bool Real
)
5277 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5281 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PACIFIED
);
5283 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PACIFIED
);
5286 void Aura::HandleAuraModPacifyAndSilence(bool apply
, bool Real
)
5288 HandleAuraModPacify(apply
,Real
);
5289 HandleAuraModSilence(apply
,Real
);
5292 void Aura::HandleAuraGhost(bool apply
, bool Real
)
5294 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5299 m_target
->SetFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
);
5303 m_target
->RemoveFlag(PLAYER_FLAGS
, PLAYER_FLAGS_GHOST
);
5307 void Aura::HandleAuraAllowFlight(bool apply
, bool Real
)
5309 // all applied/removed only at real aura add/remove
5316 data
.Initialize(SMSG_MOVE_SET_CAN_FLY
, 12);
5318 data
.Initialize(SMSG_MOVE_UNSET_CAN_FLY
, 12);
5319 data
.append(m_target
->GetPackGUID());
5320 data
<< uint32(0); // unk
5321 m_target
->SendMessageToSet(&data
, true);
5324 void Aura::HandleModRating(bool apply
, bool Real
)
5326 // spells required only Real aura add/remove
5330 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5333 for (uint32 rating
= 0; rating
< MAX_COMBAT_RATING
; ++rating
)
5334 if (m_modifier
.m_miscvalue
& (1 << rating
))
5335 ((Player
*)m_target
)->ApplyRatingMod(CombatRating(rating
), m_modifier
.m_amount
, apply
);
5338 void Aura::HandleModRatingFromStat(bool apply
, bool Real
)
5340 // spells required only Real aura add/remove
5344 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5346 // Just recalculate ratings
5347 for (uint32 rating
= 0; rating
< MAX_COMBAT_RATING
; ++rating
)
5348 if (m_modifier
.m_miscvalue
& (1 << rating
))
5349 ((Player
*)m_target
)->ApplyRatingMod(CombatRating(rating
), 0, apply
);
5352 void Aura::HandleForceMoveForward(bool apply
, bool Real
)
5354 if(!Real
|| m_target
->GetTypeId() != TYPEID_PLAYER
)
5357 m_target
->SetFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FORCE_MOVE
);
5359 m_target
->RemoveFlag(UNIT_FIELD_FLAGS_2
, UNIT_FLAG2_FORCE_MOVE
);
5362 void Aura::HandleAuraModExpertise(bool /*apply*/, bool Real
)
5364 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5367 ((Player
*)m_target
)->UpdateExpertise(BASE_ATTACK
);
5368 ((Player
*)m_target
)->UpdateExpertise(OFF_ATTACK
);
5371 void Aura::HandleModTargetResistance(bool apply
, bool Real
)
5373 // spells required only Real aura add/remove
5376 // applied to damage as HandleNoImmediateEffect in Unit::CalcAbsorbResist and Unit::CalcArmorReducedDamage
5378 // show armor penetration
5379 if (m_target
->GetTypeId() == TYPEID_PLAYER
&& (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_NORMAL
))
5380 m_target
->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE
,m_modifier
.m_amount
, apply
);
5382 // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy
5383 if (m_target
->GetTypeId() == TYPEID_PLAYER
&& (m_modifier
.m_miscvalue
& SPELL_SCHOOL_MASK_SPELL
)==SPELL_SCHOOL_MASK_SPELL
)
5384 m_target
->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE
,m_modifier
.m_amount
, apply
);
5387 void Aura::HandleShieldBlockValue(bool apply
, bool Real
)
5389 BaseModType modType
= FLAT_MOD
;
5390 if(m_modifier
.m_auraname
== SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT
)
5393 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
5394 ((Player
*)m_target
)->HandleBaseModValue(SHIELD_BLOCK_VALUE
, modType
, float(m_modifier
.m_amount
), apply
);
5397 void Aura::HandleAuraRetainComboPoints(bool apply
, bool Real
)
5399 // spells required only Real aura add/remove
5403 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
5406 Player
*target
= (Player
*)m_target
;
5408 // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler
5409 // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost)
5410 if( !apply
&& m_duration
==0 && target
->GetComboTarget())
5411 if(Unit
* unit
= ObjectAccessor::GetUnit(*m_target
,target
->GetComboTarget()))
5412 target
->AddComboPoints(unit
, -m_modifier
.m_amount
);
5415 void Aura::HandleModUnattackable( bool Apply
, bool Real
)
5418 m_target
->CombatStop();
5420 m_target
->ApplyModFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_NON_ATTACKABLE
,Apply
);
5423 void Aura::HandleSpiritOfRedemption( bool apply
, bool Real
)
5425 // spells required only Real aura add/remove
5429 // prepare spirit state
5432 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
5434 // disable breath/etc timers
5435 ((Player
*)m_target
)->StopMirrorTimers();
5437 // set stand state (expected in this form)
5438 if(!m_target
->IsStandState())
5439 m_target
->SetStandState(UNIT_STAND_STATE_STAND
);
5442 m_target
->SetHealth(1);
5446 m_target
->DealDamage(m_target
, m_target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, GetSpellProto(), false);
5449 void Aura::CleanupTriggeredSpells()
5451 if (m_spellProto
->SpellFamilyName
== SPELLFAMILY_WARRIOR
&& m_spellProto
->SpellFamilyFlags
& 0x0000001000000020LL
)
5453 // Blood Frenzy remove
5454 m_target
->RemoveAurasDueToSpell(30069);
5455 m_target
->RemoveAurasDueToSpell(30070);
5459 uint32 tSpellId
= m_spellProto
->EffectTriggerSpell
[GetEffIndex()];
5463 SpellEntry
const* tProto
= sSpellStore
.LookupEntry(tSpellId
);
5467 if(GetSpellDuration(tProto
) != -1)
5470 // needed for spell 43680, maybe others
5471 // TODO: is there a spell flag, which can solve this in a more sophisticated way?
5472 if(m_spellProto
->EffectApplyAuraName
[GetEffIndex()] == SPELL_AURA_PERIODIC_TRIGGER_SPELL
&&
5473 GetSpellDuration(m_spellProto
) == m_spellProto
->EffectAmplitude
[GetEffIndex()])
5475 m_target
->RemoveAurasDueToSpell(tSpellId
);
5478 void Aura::HandleSchoolAbsorb(bool apply
, bool Real
)
5483 // prevent double apply bonuses
5484 if(apply
&& (m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading()))
5486 if(Unit
* caster
= GetCaster())
5488 float DoneActualBenefit
= 0.0f
;
5489 switch(m_spellProto
->SpellFamilyName
)
5491 case SPELLFAMILY_PRIEST
:
5492 if(m_spellProto
->SpellFamilyFlags
== 0x1) //PW:S
5494 //+30% from +healing bonus
5495 DoneActualBenefit
= caster
->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto
)) * 0.3f
;
5499 case SPELLFAMILY_MAGE
:
5500 if(m_spellProto
->SpellFamilyFlags
== 0x80100 || m_spellProto
->SpellFamilyFlags
== 0x8 || m_spellProto
->SpellFamilyFlags
== 0x100000000LL
)
5502 //frost ward, fire ward, ice barrier
5503 //+10% from +spd bonus
5504 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.1f
;
5508 case SPELLFAMILY_WARLOCK
:
5509 if(m_spellProto
->SpellFamilyFlags
== 0x00)
5512 //+10% from +spd bonus
5513 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.1f
;
5521 DoneActualBenefit
*= caster
->CalculateLevelPenalty(GetSpellProto());
5523 m_modifier
.m_amount
+= (int32
)DoneActualBenefit
;
5528 void Aura::PeriodicTick()
5530 if(!m_target
->isAlive())
5533 switch(m_modifier
.m_auraname
)
5535 case SPELL_AURA_PERIODIC_DAMAGE
:
5536 case SPELL_AURA_PERIODIC_DAMAGE_PERCENT
:
5538 Unit
*pCaster
= GetCaster();
5542 if( GetSpellProto()->Effect
[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
5543 pCaster
->SpellHitResult(m_target
,GetSpellProto(),false)!=SPELL_MISS_NONE
)
5546 // Check for immune (not use charges)
5547 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5550 // some auras remove at specific health level or more
5551 if(m_modifier
.m_auraname
==SPELL_AURA_PERIODIC_DAMAGE
)
5555 case 43093: case 31956: case 38801:
5556 case 35321: case 38363: case 39215:
5557 if(m_target
->GetHealth() == m_target
->GetMaxHealth() )
5559 m_target
->RemoveAurasDueToSpell(GetId());
5566 GetEffIndex() < 2 && GetSpellProto()->Effect
[GetEffIndex()]==SPELL_EFFECT_DUMMY
?
5567 pCaster
->CalculateSpellDamage(GetSpellProto(),GetEffIndex()+1,GetSpellProto()->EffectBasePoints
[GetEffIndex()+1],m_target
) :
5569 if(m_target
->GetHealth()*100 >= m_target
->GetMaxHealth()*percent
)
5571 m_target
->RemoveAurasDueToSpell(GetId());
5583 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
5585 // ignore non positive values (can be result apply spellmods to aura damage
5586 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5590 if(m_modifier
.m_auraname
== SPELL_AURA_PERIODIC_DAMAGE
)
5594 // Calculate armor mitigation if it is a physical spell
5595 // But not for bleed mechanic spells
5596 if ( GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL
&&
5597 GetEffectMechanic(GetSpellProto(), m_effIndex
) != MECHANIC_BLEED
)
5599 uint32 pdamageReductedArmor
= pCaster
->CalcArmorReducedDamage(m_target
, pdamage
);
5600 cleanDamage
.damage
+= pdamage
- pdamageReductedArmor
;
5601 pdamage
= pdamageReductedArmor
;
5604 pdamage
= pCaster
->SpellDamageBonus(m_target
, GetSpellProto(), pdamage
, DOT
, GetStackAmount());
5606 // Curse of Agony damage-per-tick calculation
5607 if (GetSpellProto()->SpellFamilyName
==SPELLFAMILY_WARLOCK
&& (GetSpellProto()->SpellFamilyFlags
& 0x0000000000000400LL
) && GetSpellProto()->SpellIconID
==544)
5609 // 1..4 ticks, 1/2 from normal tick damage
5610 if (m_duration
>=((m_maxduration
-m_modifier
.periodictime
)*2/3))
5611 pdamage
= pdamage
/2;
5612 // 9..12 ticks, 3/2 from normal tick damage
5613 else if(m_duration
<((m_maxduration
-m_modifier
.periodictime
)/3))
5614 pdamage
+= (pdamage
+1)/2; // +1 prevent 0.5 damage possible lost at 1..4 ticks
5615 // 5..8 ticks have normal tick damage
5619 pdamage
= uint32(m_target
->GetMaxHealth()*amount
/100);
5621 //As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit
5622 // Reduce dot damage from resilience for players
5623 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
5624 pdamage
-=((Player
*)m_target
)->GetDotDamageReduction(pdamage
);
5626 pCaster
->CalcAbsorbResist(m_target
, GetSpellSchoolMask(GetSpellProto()), DOT
, pdamage
, &absorb
, &resist
);
5628 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
5629 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId(),absorb
);
5631 WorldPacket
data(SMSG_PERIODICAURALOG
, (21+16));// we guess size
5632 data
.append(m_target
->GetPackGUID());
5633 data
.appendPackGUID(GetCasterGUID());
5634 data
<< uint32(GetId());
5636 data
<< uint32(m_modifier
.m_auraname
);
5637 data
<< (uint32
)pdamage
;
5638 data
<< uint32(0); // overkill
5639 data
<< (uint32
)GetSpellSchoolMask(GetSpellProto()); // will be mask in 2.4.x
5640 data
<< (uint32
)absorb
;
5641 data
<< (uint32
)resist
;
5642 m_target
->SendMessageToSet(&data
,true);
5644 Unit
* target
= m_target
; // aura can be deleted in DealDamage
5645 SpellEntry
const* spellProto
= GetSpellProto();
5648 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
;// | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
5649 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
5650 pdamage
= (pdamage
<= absorb
+resist
) ? 0 : (pdamage
-absorb
-resist
);
5652 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
5653 pCaster
->ProcDamageAndSpell(target
, procAttacker
, procVictim
, PROC_EX_NORMAL_HIT
, pdamage
, BASE_ATTACK
, spellProto
);
5655 pCaster
->DealDamage(target
, pdamage
, &cleanDamage
, DOT
, GetSpellSchoolMask(spellProto
), spellProto
, true);
5658 case SPELL_AURA_PERIODIC_LEECH
:
5659 case SPELL_AURA_PERIODIC_HEALTH_FUNNEL
:
5661 Unit
*pCaster
= GetCaster();
5665 if(!pCaster
->isAlive())
5668 if( GetSpellProto()->Effect
[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
5669 pCaster
->SpellHitResult(m_target
,GetSpellProto(),false)!=SPELL_MISS_NONE
)
5673 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5678 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
5680 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5682 //Calculate armor mitigation if it is a physical spell
5683 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL
)
5685 uint32 pdamageReductedArmor
= pCaster
->CalcArmorReducedDamage(m_target
, pdamage
);
5686 cleanDamage
.damage
+= pdamage
- pdamageReductedArmor
;
5687 pdamage
= pdamageReductedArmor
;
5690 pdamage
= pCaster
->SpellDamageBonus(m_target
, GetSpellProto(), pdamage
, DOT
, GetStackAmount());
5692 //As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit
5693 // Reduce dot damage from resilience for players
5694 if (m_target
->GetTypeId()==TYPEID_PLAYER
)
5695 pdamage
-=((Player
*)m_target
)->GetDotDamageReduction(pdamage
);
5697 pCaster
->CalcAbsorbResist(m_target
, GetSpellSchoolMask(GetSpellProto()), DOT
, pdamage
, &absorb
, &resist
);
5699 if(m_target
->GetHealth() < pdamage
)
5700 pdamage
= uint32(m_target
->GetHealth());
5702 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
5703 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId(),absorb
);
5705 pCaster
->SendSpellNonMeleeDamageLog(m_target
, GetId(), pdamage
, GetSpellSchoolMask(GetSpellProto()), absorb
, resist
, false, 0);
5708 Unit
* target
= m_target
; // aura can be deleted in DealDamage
5709 SpellEntry
const* spellProto
= GetSpellProto();
5710 float multiplier
= spellProto
->EffectMultipleValue
[GetEffIndex()] > 0 ? spellProto
->EffectMultipleValue
[GetEffIndex()] : 1;
5711 int32 stackAmount
= GetStackAmount();
5714 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
;// | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
5715 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
5716 pdamage
= (pdamage
<= absorb
+resist
) ? 0 : (pdamage
-absorb
-resist
);
5718 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
5719 pCaster
->ProcDamageAndSpell(target
, procAttacker
, procVictim
, PROC_EX_NORMAL_HIT
, pdamage
, BASE_ATTACK
, spellProto
);
5720 int32 new_damage
= pCaster
->DealDamage(target
, pdamage
, &cleanDamage
, DOT
, GetSpellSchoolMask(spellProto
), spellProto
, false);
5722 if (!target
->isAlive() && pCaster
->IsNonMeleeSpellCasted(false))
5724 for (uint32 i
= CURRENT_FIRST_NON_MELEE_SPELL
; i
< CURRENT_MAX_SPELL
; i
++)
5726 if (pCaster
->m_currentSpells
[i
] && pCaster
->m_currentSpells
[i
]->m_spellInfo
->Id
== spellProto
->Id
)
5727 pCaster
->m_currentSpells
[i
]->cancel();
5732 if(Player
*modOwner
= pCaster
->GetSpellModOwner())
5733 modOwner
->ApplySpellMod(spellProto
->Id
, SPELLMOD_MULTIPLE_VALUE
, multiplier
);
5735 uint32 heal
= pCaster
->SpellHealingBonus(pCaster
, spellProto
, uint32(new_damage
* multiplier
), DOT
, stackAmount
);
5737 int32 gain
= pCaster
->ModifyHealth(heal
);
5738 pCaster
->getHostilRefManager().threatAssist(pCaster
, gain
* 0.5f
, spellProto
);
5740 pCaster
->SendHealSpellLog(pCaster
, spellProto
->Id
, heal
);
5743 case SPELL_AURA_PERIODIC_HEAL
:
5744 case SPELL_AURA_OBS_MOD_HEALTH
:
5746 Unit
*pCaster
= GetCaster();
5750 // heal for caster damage (must be alive)
5751 if(m_target
!= pCaster
&& GetSpellProto()->SpellVisual
[0]==163 && !pCaster
->isAlive())
5754 // ignore non positive values (can be result apply spellmods to aura damage
5755 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5759 if(m_modifier
.m_auraname
==SPELL_AURA_OBS_MOD_HEALTH
)
5760 pdamage
= uint32(m_target
->GetMaxHealth() * amount
/100);
5764 pdamage
= pCaster
->SpellHealingBonus(m_target
, GetSpellProto(), pdamage
, DOT
, GetStackAmount());
5766 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) heal of %u (TypeId: %u) for %u health inflicted by %u",
5767 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
5769 WorldPacket
data(SMSG_PERIODICAURALOG
, (21+16));// we guess size
5770 data
.append(m_target
->GetPackGUID());
5771 data
.appendPackGUID(GetCasterGUID());
5772 data
<< uint32(GetId());
5774 data
<< uint32(m_modifier
.m_auraname
);
5775 data
<< (uint32
)pdamage
;
5776 data
<< uint32(0); // wotlk
5777 m_target
->SendMessageToSet(&data
,true);
5779 int32 gain
= m_target
->ModifyHealth(pdamage
);
5781 // add HoTs to amount healed in bgs
5782 if( pCaster
->GetTypeId() == TYPEID_PLAYER
)
5783 if( BattleGround
*bg
= ((Player
*)pCaster
)->GetBattleGround() )
5784 bg
->UpdatePlayerScore(((Player
*)pCaster
), SCORE_HEALING_DONE
, gain
);
5786 //Do check before because m_modifier.auraName can be invalidate by DealDamage.
5787 bool procSpell
= (m_modifier
.m_auraname
== SPELL_AURA_PERIODIC_HEAL
&& m_target
!= pCaster
);
5789 m_target
->getHostilRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, GetSpellProto());
5791 Unit
* target
= m_target
; // aura can be deleted in DealDamage
5792 SpellEntry
const* spellProto
= GetSpellProto();
5793 bool haveCastItem
= GetCastItemGUID()!=0;
5795 // heal for caster damage
5796 if(m_target
!=pCaster
&& spellProto
->SpellVisual
[0]==163)
5798 uint32 dmg
= spellProto
->manaPerSecond
;
5799 if(pCaster
->GetHealth() <= dmg
&& pCaster
->GetTypeId()==TYPEID_PLAYER
)
5801 pCaster
->RemoveAurasDueToSpell(GetId());
5803 // finish current generic/channeling spells, don't affect autorepeat
5804 if(pCaster
->m_currentSpells
[CURRENT_GENERIC_SPELL
])
5806 pCaster
->m_currentSpells
[CURRENT_GENERIC_SPELL
]->finish();
5808 if(pCaster
->m_currentSpells
[CURRENT_CHANNELED_SPELL
])
5810 pCaster
->m_currentSpells
[CURRENT_CHANNELED_SPELL
]->SendChannelUpdate(0);
5811 pCaster
->m_currentSpells
[CURRENT_CHANNELED_SPELL
]->finish();
5816 pCaster
->SendSpellNonMeleeDamageLog(pCaster
, GetId(), gain
, GetSpellSchoolMask(GetSpellProto()), 0, 0, false, 0, false);
5818 CleanDamage cleanDamage
= CleanDamage(0, BASE_ATTACK
, MELEE_HIT_NORMAL
);
5819 pCaster
->DealDamage(pCaster
, gain
, &cleanDamage
, NODAMAGE
, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
5823 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
;// | PROC_FLAG_SUCCESSFUL_HEAL;
5824 uint32 procVictim
= 0;//ROC_FLAG_ON_TAKE_PERIODIC | PROC_FLAG_TAKEN_HEAL;
5825 // ignore item heals
5826 // if(procSpell && !haveCastItem)
5827 // pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto);
5830 case SPELL_AURA_PERIODIC_MANA_LEECH
:
5832 Unit
*pCaster
= GetCaster();
5836 if(!pCaster
->isAlive())
5839 if( GetSpellProto()->Effect
[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA
&&
5840 pCaster
->SpellHitResult(m_target
,GetSpellProto(),false)!=SPELL_MISS_NONE
)
5843 // Check for immune (not use charges)
5844 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5847 // ignore non positive values (can be result apply spellmods to aura damage
5848 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5850 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u",
5851 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
5853 if(m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
>= MAX_POWERS
)
5856 Powers power
= Powers(m_modifier
.m_miscvalue
);
5858 // power type might have changed between aura applying and tick (druid's shapeshift)
5859 if(m_target
->getPowerType() != power
)
5862 int32 drain_amount
= m_target
->GetPower(power
) > pdamage
? pdamage
: m_target
->GetPower(power
);
5864 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
5865 if (power
== POWER_MANA
&& m_target
->GetTypeId() == TYPEID_PLAYER
)
5866 drain_amount
-= ((Player
*)m_target
)->GetSpellCritDamageReduction(drain_amount
);
5868 m_target
->ModifyPower(power
, -drain_amount
);
5870 float gain_multiplier
= 0;
5872 if(pCaster
->GetMaxPower(power
) > 0)
5874 gain_multiplier
= GetSpellProto()->EffectMultipleValue
[GetEffIndex()];
5876 if(Player
*modOwner
= pCaster
->GetSpellModOwner())
5877 modOwner
->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE
, gain_multiplier
);
5880 WorldPacket
data(SMSG_PERIODICAURALOG
, (21+16));// we guess size
5881 data
.append(m_target
->GetPackGUID());
5882 data
.appendPackGUID(GetCasterGUID());
5883 data
<< uint32(GetId());
5885 data
<< uint32(m_modifier
.m_auraname
);
5886 data
<< (uint32
)power
; // power type
5887 data
<< (uint32
)drain_amount
;
5888 data
<< (float)gain_multiplier
;
5889 m_target
->SendMessageToSet(&data
,true);
5891 int32 gain_amount
= int32(drain_amount
*gain_multiplier
);
5895 int32 gain
= pCaster
->ModifyPower(power
,gain_amount
);
5896 m_target
->AddThreat(pCaster
, float(gain
) * 0.5f
, GetSpellSchoolMask(GetSpellProto()), GetSpellProto());
5900 case SPELL_AURA_PERIODIC_ENERGIZE
:
5902 // ignore non positive values (can be result apply spellmods to aura damage
5903 uint32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5905 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u",
5906 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
5908 if(m_modifier
.m_miscvalue
< 0 || m_modifier
.m_miscvalue
>= MAX_POWERS
)
5911 Powers power
= Powers(m_modifier
.m_miscvalue
);
5913 if(m_target
->GetMaxPower(power
) == 0)
5916 WorldPacket
data(SMSG_PERIODICAURALOG
, (21+16));// we guess size
5917 data
.append(m_target
->GetPackGUID());
5918 data
.appendPackGUID(GetCasterGUID());
5919 data
<< uint32(GetId());
5921 data
<< uint32(m_modifier
.m_auraname
);
5922 data
<< (uint32
)power
; // power type
5923 data
<< (uint32
)pdamage
;
5924 m_target
->SendMessageToSet(&data
,true);
5926 int32 gain
= m_target
->ModifyPower(power
,pdamage
);
5928 if(Unit
* pCaster
= GetCaster())
5929 m_target
->getHostilRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, GetSpellProto());
5932 case SPELL_AURA_OBS_MOD_MANA
:
5934 // ignore non positive values (can be result apply spellmods to aura damage
5935 uint32 amount
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5937 uint32 pdamage
= uint32(m_target
->GetMaxPower(POWER_MANA
) * amount
/100);
5939 sLog
.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u mana inflicted by %u",
5940 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target
->GetGUIDLow(), m_target
->GetTypeId(), pdamage
, GetId());
5942 if(m_target
->GetMaxPower(POWER_MANA
) == 0)
5945 WorldPacket
data(SMSG_PERIODICAURALOG
, (21+16));// we guess size
5946 data
.append(m_target
->GetPackGUID());
5947 data
.appendPackGUID(GetCasterGUID());
5948 data
<< uint32(GetId());
5950 data
<< uint32(m_modifier
.m_auraname
);
5951 data
<< (uint32
)0; // ?
5952 data
<< (uint32
)pdamage
;
5953 m_target
->SendMessageToSet(&data
,true);
5955 int32 gain
= m_target
->ModifyPower(POWER_MANA
, pdamage
);
5957 if(Unit
* pCaster
= GetCaster())
5958 m_target
->getHostilRefManager().threatAssist(pCaster
, float(gain
) * 0.5f
, GetSpellProto());
5961 case SPELL_AURA_POWER_BURN_MANA
:
5963 Unit
*pCaster
= GetCaster();
5967 // Check for immune (not use charges)
5968 if(m_target
->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5971 int32 pdamage
= m_modifier
.m_amount
> 0 ? m_modifier
.m_amount
: 0;
5973 Powers powerType
= Powers(m_modifier
.m_miscvalue
);
5975 if(!m_target
->isAlive() || m_target
->getPowerType() != powerType
)
5978 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
5979 if (powerType
== POWER_MANA
&& m_target
->GetTypeId() == TYPEID_PLAYER
)
5980 pdamage
-= ((Player
*)m_target
)->GetSpellCritDamageReduction(pdamage
);
5982 uint32 gain
= uint32(-m_target
->ModifyPower(powerType
, -pdamage
));
5984 gain
= uint32(gain
* GetSpellProto()->EffectMultipleValue
[GetEffIndex()]);
5986 SpellEntry
const* spellProto
= GetSpellProto();
5987 //maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG
5988 SpellNonMeleeDamage
damageInfo(pCaster
, m_target
, spellProto
->Id
, spellProto
->SchoolMask
);
5989 pCaster
->CalculateSpellDamage(&damageInfo
, gain
, spellProto
);
5990 pCaster
->SendSpellNonMeleeDamageLog(&damageInfo
);
5993 uint32 procAttacker
= PROC_FLAG_ON_DO_PERIODIC
;// | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
5994 uint32 procVictim
= PROC_FLAG_ON_TAKE_PERIODIC
;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
5995 uint32 procEx
= createProcExtendMask(&damageInfo
, SPELL_MISS_NONE
);
5996 if (damageInfo
.damage
)
5997 procVictim
|=PROC_FLAG_TAKEN_ANY_DAMAGE
;
5999 pCaster
->ProcDamageAndSpell(damageInfo
.target
, procAttacker
, procVictim
, procEx
, damageInfo
.damage
, BASE_ATTACK
, spellProto
);
6001 pCaster
->DealSpellDamage(&damageInfo
, true);
6004 case SPELL_AURA_MOD_REGEN
:
6006 int32 gain
= m_target
->ModifyHealth(m_modifier
.m_amount
);
6007 if (Unit
*caster
= GetCaster())
6008 m_target
->getHostilRefManager().threatAssist(caster
, float(gain
) * 0.5f
, GetSpellProto());
6011 case SPELL_AURA_MOD_POWER_REGEN
:
6013 Powers pt
= m_target
->getPowerType();
6014 if(int32(pt
) != m_modifier
.m_miscvalue
)
6017 if ( GetSpellProto()->AuraInterruptFlags
& AURA_INTERRUPT_FLAG_NOT_SEATED
)
6020 m_target
->HandleEmoteCommand(EMOTE_ONESHOT_EAT
);
6022 else if( GetId() == 20577 )
6025 m_target
->HandleEmoteCommand(EMOTE_STATE_CANNIBALIZE
);
6028 // Warrior talent, gain 1 rage every 3 seconds while in combat
6029 if(pt
== POWER_RAGE
&& m_target
->isInCombat())
6030 m_target
->ModifyPower(pt
, m_modifier
.m_amount
*10/17);
6033 // Here tick dummy auras
6034 case SPELL_AURA_PERIODIC_DUMMY
:
6036 PeriodicDummyTick();
6039 case SPELL_AURA_PERIODIC_TRIGGER_SPELL
:
6044 case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
:
6046 TriggerSpellWithValue();
6054 void Aura::PeriodicDummyTick()
6056 Unit
*caster
= GetCaster();
6057 SpellEntry
const* spell
= GetSpellProto();
6058 switch (spell
->SpellFamilyName
)
6060 case SPELLFAMILY_GENERIC
:
6076 case 49472: // Drink Coffee
6079 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
6081 // Search SPELL_AURA_MOD_POWER_REGEN aura for this spell and add bonus
6082 Unit::AuraList
const& aura
= m_target
->GetAurasByType(SPELL_AURA_MOD_POWER_REGEN
);
6083 for(Unit::AuraList::const_iterator i
= aura
.begin(); i
!= aura
.end(); ++i
)
6085 if ((*i
)->GetId() == GetId())
6087 (*i
)->GetModifier()->m_amount
= m_modifier
.m_amount
;
6088 ((Player
*)m_target
)->UpdateManaRegen();
6090 m_isPeriodic
= false;
6099 // Possibly need cast one of them (but
6100 // 7038 Forsaken Skill: Swords
6101 // 7039 Forsaken Skill: Axes
6102 // 7040 Forsaken Skill: Daggers
6103 // 7041 Forsaken Skill: Maces
6104 // 7042 Forsaken Skill: Staves
6105 // 7043 Forsaken Skill: Bows
6106 // 7044 Forsaken Skill: Guns
6107 // 7045 Forsaken Skill: 2H Axes
6108 // 7046 Forsaken Skill: 2H Maces
6109 // 7047 Forsaken Skill: 2H Swords
6110 // 7048 Forsaken Skill: Defense
6111 // 7049 Forsaken Skill: Fire
6112 // 7050 Forsaken Skill: Frost
6113 // 7051 Forsaken Skill: Holy
6114 // 7053 Forsaken Skill: Shadow
6118 // case 19230: break;
6119 // // Gossip NPC Periodic - Talk
6120 // case 33208: break;
6121 // // Gossip NPC Periodic - Despawn
6122 // case 33209: break;
6124 // case 36207: break;
6125 // // Simon Game START timer, (DND)
6126 // case 39993: break;
6127 // // Knockdown Fel Cannon: break; The Aggro Burst
6128 // case 40119: break;
6129 // // Old Mount Spell
6130 // case 40154: break;
6132 // case 40581: break;
6133 // // Ethereal Ring: break; The Bolt Burst
6134 // case 40801: break;
6135 // // Crystal Prison
6136 // case 40846: break;
6138 // case 41054: break;
6140 // case 41404: break;
6141 // // Ethereal Ring Visual, Lightning Aura
6142 // case 41477: break;
6143 // // Ethereal Ring Visual, Lightning Aura (Fork)
6144 // case 41525: break;
6145 // // Ethereal Ring Visual, Lightning Jumper Aura
6146 // case 41567: break;
6148 // case 41955: break;
6149 // // Headless Horseman - Fire
6150 // case 42074: break;
6151 // // Headless Horseman - Visual - Large Fire
6152 // case 42075: break;
6153 // // Headless Horseman - Start Fire, Periodic Aura
6154 // case 42140: break;
6155 // // Ram Speed Boost
6156 // case 42152: break;
6157 // // Headless Horseman - Fires Out Victory Aura
6158 // case 42235: break;
6159 // // Pumpkin Life Cycle
6160 // case 42280: break;
6161 // // Brewfest Request Chick Chuck Mug Aura
6162 // case 42537: break;
6164 // case 42596: break;
6165 // // Headless Horseman Climax, Head: Periodic
6166 // case 42603: break;
6168 // case 42621: break;
6169 // // Headless Horseman - Conflagrate, Periodic Aura
6170 // case 42637: break;
6171 // // Headless Horseman - Create Pumpkin Treats Aura
6172 // case 42774: break;
6173 // // Headless Horseman Climax - Summoning Rhyme Aura
6174 // case 42879: break;
6176 // case 42919: break;
6178 // case 42924: break;
6180 // case 42992: break;
6182 // case 42993: break;
6184 // case 42994: break;
6185 // // Ram Level - Neutral
6186 // case 43310: break;
6187 // // Headless Horseman - Maniacal Laugh, Maniacal, Delayed 17
6188 // case 43884: break;
6190 // case 43963: break;
6191 // // Headless Horseman - Maniacal Laugh, Maniacal, other, Delayed 17
6192 // case 44000: break;
6193 // // Energy Feedback
6194 // case 44328: break;
6195 // // Romantic Picnic
6196 // case 45102: break;
6197 // // Romantic Picnic
6198 // case 45123: break;
6199 // // Looking for Love
6200 // case 45124: break;
6201 // // Kite - Lightning Strike Kite Aura
6202 // case 45197: break;
6203 // // Rocket Chicken
6204 // case 45202: break;
6205 // // Copy Offhand Weapon
6206 // case 45205: break;
6207 // // Upper Deck - Kite - Lightning Periodic Aura
6208 // case 45207: break;
6209 // // Kite -Sky Lightning Strike Kite Aura
6210 // case 45251: break;
6211 // // Ribbon Pole Dancer Check Aura
6212 // case 45390: break;
6213 // // Holiday - Midsummer, Ribbon Pole Periodic Visual
6214 // case 45406: break;
6216 // case 45472: break;
6217 // // Alliance Flag, Extra Damage Debuff
6218 // case 45898: break;
6219 // // Horde Flag, Extra Damage Debuff
6220 // case 45899: break;
6221 // // Ahune - Summoning Rhyme Aura
6222 // case 45926: break;
6223 // // Ahune - Slippery Floor
6224 // case 45945: break;
6225 // // Ahune's Shield
6226 // case 45954: break;
6227 // // Nether Vapor Lightning
6228 // case 45960: break;
6230 // case 45996: break;
6231 // // Summon Blood Elves Periodic
6232 // case 46041: break;
6233 // // Transform Visual Missile Periodic
6234 // case 46205: break;
6235 // // Find Opening Beam End
6236 // case 46333: break;
6237 // // Ice Spear Control Aura
6238 // case 46371: break;
6239 // // Hailstone Chill
6240 // case 46458: break;
6241 // // Hailstone Chill, Internal
6242 // case 46465: break;
6243 // // Chill, Internal Shifter
6244 // case 46549: break;
6245 // // Summon Ice Spear Knockback Delayer
6246 // case 46878: break;
6247 // // Burninate Effect
6248 // case 47214: break;
6249 // // Fizzcrank Practice Parachute
6250 // case 47228: break;
6251 // // Send Mug Control Aura
6252 // case 47369: break;
6253 // // Direbrew's Disarm (precast)
6254 // case 47407: break;
6255 // // Mole Machine Port Schedule
6256 // case 47489: break;
6257 // case 47941: break; // Crystal Spike
6258 // case 48200: break; // Healer Aura
6259 // case 48630: break; // Summon Gauntlet Mobs Periodic
6260 // case 49313: break; // Proximity Mine Area Aura
6261 // // Mole Machine Portal Schedule
6262 // case 49466: break;
6263 // case 49555: break; // Corpse Explode
6264 // case 49592: break; // Temporal Rift
6265 // case 49957: break; // Cutting Laser
6266 // case 50085: break; // Slow Fall
6267 // // Listening to Music
6268 // case 50493: break;
6269 // // Love Rocket Barrage
6270 // case 50530: break;
6271 // Exist more after, need add later
6276 case SPELLFAMILY_MAGE
:
6279 // if (spell->Id == 55342)
6283 case SPELLFAMILY_WARRIOR
:
6285 // Armored to the Teeth
6286 if (spell
->SpellIconID
== 3516)
6288 // Increases your attack power by $s1 for every $s2 armor value you have.
6289 // Calculate AP bonus (from 1 efect of this spell)
6290 int32 apBonus
= m_modifier
.m_amount
* m_target
->GetArmor() / m_target
->CalculateSpellDamage(spell
, 1, spell
->EffectBasePoints
[1], m_target
);
6291 m_target
->CastCustomSpell(m_target
, 61217, &apBonus
, &apBonus
, 0, true, 0, this);
6296 case SPELLFAMILY_DRUID
:
6300 // Frenzied Regeneration
6303 // Converts up to 10 rage per second into health for $d. Each point of rage is converted into ${$m2/10}.1% of max health.
6304 // Should be manauser
6305 if (m_target
->getPowerType()!=POWER_RAGE
)
6307 uint32 rage
= m_target
->GetPower(POWER_RAGE
);
6311 int32 mod
= (rage
< 100) ? rage
: 100;
6312 int32 points
= m_target
->CalculateSpellDamage(spell
, 1, spell
->EffectBasePoints
[1], m_target
);
6313 int32 regen
= m_target
->GetMaxHealth() * (mod
* points
/ 10) / 1000;
6314 m_target
->CastCustomSpell(m_target
, 22845, ®en
, 0, 0, true, 0, this);
6315 m_target
->SetPower(POWER_RAGE
, rage
-mod
);
6326 case SPELLFAMILY_ROGUE
:
6328 // switch (spell->Id)
6330 // Master of Subtlety
6331 // case 31666: break;
6333 // case 51690: break;
6335 // case 58428: break;
6341 case SPELLFAMILY_HUNTER
:
6344 if (spell
->SpellFamilyFlags
& 0x8000000000000000LL
)
6348 int32 damage
= m_modifier
.m_amount
;
6349 // Full damage to target at 0 tick
6350 if (m_duration
> m_modifier
.periodictime
)
6352 caster
->CastCustomSpell(m_target
, 53352, &damage
, 0, 0, true, 0, this);
6356 caster
->CastCustomSpell(m_target
, 56298, &damage
, 0, 0, true, 0, this);
6364 // Feeding Frenzy Rank 1
6366 if ( m_target
->GetHealth() * 100 < m_target
->GetMaxHealth() * 35 )
6367 m_target
->CastSpell(m_target
, 60096, true, 0, this);
6369 // Feeding Frenzy Rank 2
6371 if ( m_target
->GetHealth() * 100 < m_target
->GetMaxHealth() * 35 )
6372 m_target
->CastSpell(m_target
, 60097, true, 0, this);
6379 case SPELLFAMILY_SHAMAN
:
6382 if (spell
->Id
== 52179)
6384 // Periodic need for remove visual on stun/fear/silence lost
6385 if (!(m_target
->GetUInt32Value(UNIT_FIELD_FLAGS
)&(UNIT_FLAG_STUNNED
|UNIT_FLAG_FLEEING
|UNIT_FLAG_SILENCED
)))
6386 m_target
->RemoveAurasDueToSpell(52179);
6391 case SPELLFAMILY_DEATHKNIGHT
:
6394 if (spell
->SpellFamilyFlags
& 0x0000000000000020LL
)
6397 caster
->CastCustomSpell(m_target
, 52212, &m_modifier
.m_amount
, NULL
, NULL
, true, 0, this);
6401 // if (spell->SpellFamilyFlags & 0x0000000000001000LL)
6404 if (spell
->SpellFamilyFlags
& 0x0000400000000000LL
)
6406 // Get 0 effect aura
6407 Aura
*slow
= m_target
->GetAura(GetId(), 0);
6410 slow
->ApplyModifier(false, true);
6411 Modifier
*mod
= slow
->GetModifier();
6412 mod
->m_amount
+= m_modifier
.m_amount
;
6413 if (mod
->m_amount
> 0) mod
->m_amount
= 0;
6414 slow
->ApplyModifier(true, true);
6419 // if (spell->SpellFamilyFlags & 0x0000008000000000LL)
6421 // Death Rune Mastery
6422 // if (spell->SpellFamilyFlags & 0x0000000000004000LL)
6425 if (spell
->SpellIconID
== 2653)
6427 // Increases your attack power by $s1 for every $s2 armor value you have.
6428 // Calculate AP bonus (from 1 efect of this spell)
6429 int32 apBonus
= m_modifier
.m_amount
* m_target
->GetArmor() / m_target
->CalculateSpellDamage(spell
, 1, spell
->EffectBasePoints
[1], m_target
);
6430 m_target
->CastCustomSpell(m_target
, 61217, &apBonus
, &apBonus
, 0, true, 0, this);
6434 // if (spell->SpellIconID == 22)
6436 // Blood of the North
6437 // if (spell->SpellIconID == 30412)
6446 void Aura::HandlePreventFleeing(bool apply
, bool Real
)
6451 Unit::AuraList
const& fearAuras
= m_target
->GetAurasByType(SPELL_AURA_MOD_FEAR
);
6452 if( !fearAuras
.empty() )
6455 m_target
->SetFeared(false, fearAuras
.front()->GetCasterGUID());
6457 m_target
->SetFeared(true);
6461 void Aura::HandleManaShield(bool apply
, bool Real
)
6466 // prevent double apply bonuses
6467 if(apply
&& (m_target
->GetTypeId()!=TYPEID_PLAYER
|| !((Player
*)m_target
)->GetSession()->PlayerLoading()))
6469 if(Unit
* caster
= GetCaster())
6471 float DoneActualBenefit
= 0.0f
;
6472 switch(m_spellProto
->SpellFamilyName
)
6474 case SPELLFAMILY_MAGE
:
6475 if(m_spellProto
->SpellFamilyFlags
& 0x8000)
6478 // +50% from +spd bonus
6479 DoneActualBenefit
= caster
->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto
)) * 0.5f
;
6487 DoneActualBenefit
*= caster
->CalculateLevelPenalty(GetSpellProto());
6489 m_modifier
.m_amount
+= (int32
)DoneActualBenefit
;
6494 void Aura::HandleArenaPreparation(bool apply
, bool Real
)
6500 m_target
->SetFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PREPARATION
);
6502 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, UNIT_FLAG_PREPARATION
);
6505 void Aura::HandleAuraControlVehicle(bool apply
, bool Real
)
6510 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
6513 if(Pet
*pet
= m_target
->GetPet())
6514 pet
->Remove(PET_SAVE_AS_CURRENT
);
6516 WorldPacket
data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA
, 0);
6517 ((Player
*)m_target
)->GetSession()->SendPacket(&data
);
6520 void Aura::HandleAuraConvertRune(bool apply
, bool Real
)
6525 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
6528 Player
*plr
= (Player
*)m_target
;
6530 if(plr
->getClass() != CLASS_DEATH_KNIGHT
)
6533 // how to determine what rune need to be converted?
6534 for(uint32 i
= 0; i
< MAX_RUNES
; ++i
)
6538 if(!plr
->GetRuneCooldown(i
))
6540 plr
->ConvertRune(i
, GetSpellProto()->EffectMiscValueB
[m_effIndex
]);
6546 if(plr
->GetCurrentRune(i
) == GetSpellProto()->EffectMiscValueB
[m_effIndex
])
6548 plr
->ConvertRune(i
, plr
->GetBaseRune(i
));
6555 void Aura::HandlePhase(bool apply
, bool Real
)
6560 // always non stackable
6563 Unit::AuraList
const& phases
= m_target
->GetAurasByType(SPELL_AURA_PHASE
);
6565 m_target
->RemoveAurasDueToSpell(phases
.front()->GetId(),this);
6568 // no-phase is also phase state so same code for apply and remove
6570 // phase auras normally not expected at BG but anyway better check
6571 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
6573 // drop flag at invisible in bg
6574 if(((Player
*)m_target
)->InBattleGround())
6575 if(BattleGround
*bg
= ((Player
*)m_target
)->GetBattleGround())
6576 bg
->EventPlayerDroppedFlag((Player
*)m_target
);
6578 // GM-mode have mask 0xFFFFFFFF
6579 if(!((Player
*)m_target
)->isGameMaster())
6580 m_target
->SetPhaseMask(apply
? GetMiscValue() : PHASEMASK_NORMAL
,false);
6583 m_target
->SetPhaseMask(apply
? GetMiscValue() : PHASEMASK_NORMAL
,false);
6585 // need triggering visibility update base at phase update of not GM invisible (other GMs anyway see in any phases)
6586 if(m_target
->GetVisibility()!=VISIBILITY_OFF
)
6587 m_target
->SetVisibility(m_target
->GetVisibility());