Merge commit 'origin/master' into 310
[AHbot.git] / src / game / SpellAuras.cpp
blob09f28fe298a0bbb5a5331bb6024ba76bc546e988
1 /*
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
19 #include "Common.h"
20 #include "Database/DatabaseEnv.h"
21 #include "WorldPacket.h"
22 #include "WorldSession.h"
23 #include "Opcodes.h"
24 #include "Log.h"
25 #include "UpdateMask.h"
26 #include "World.h"
27 #include "ObjectMgr.h"
28 #include "SpellMgr.h"
29 #include "Player.h"
30 #include "Unit.h"
31 #include "Spell.h"
32 #include "DynamicObject.h"
33 #include "Group.h"
34 #include "UpdateData.h"
35 #include "ObjectAccessor.h"
36 #include "Policies/SingletonImp.h"
37 #include "Totem.h"
38 #include "Creature.h"
39 #include "Formulas.h"
40 #include "BattleGround.h"
41 #include "CreatureAI.h"
42 #include "ScriptCalls.h"
43 #include "Util.h"
44 #include "GridNotifiers.h"
45 #include "GridNotifiersImpl.h"
46 #include "Vehicle.h"
47 #include "CellImpl.h"
49 #define NULL_AURA_SLOT 0xFF
51 pAuraHandler AuraHandler[TOTAL_AURAS]=
53 &Aura::HandleNULL, // 0 SPELL_AURA_NONE
54 &Aura::HandleBindSight, // 1 SPELL_AURA_BIND_SIGHT
55 &Aura::HandleModPossess, // 2 SPELL_AURA_MOD_POSSESS
56 &Aura::HandlePeriodicDamage, // 3 SPELL_AURA_PERIODIC_DAMAGE
57 &Aura::HandleAuraDummy, // 4 SPELL_AURA_DUMMY
58 &Aura::HandleModConfuse, // 5 SPELL_AURA_MOD_CONFUSE
59 &Aura::HandleModCharm, // 6 SPELL_AURA_MOD_CHARM
60 &Aura::HandleModFear, // 7 SPELL_AURA_MOD_FEAR
61 &Aura::HandlePeriodicHeal, // 8 SPELL_AURA_PERIODIC_HEAL
62 &Aura::HandleModAttackSpeed, // 9 SPELL_AURA_MOD_ATTACKSPEED
63 &Aura::HandleModThreat, // 10 SPELL_AURA_MOD_THREAT
64 &Aura::HandleModTaunt, // 11 SPELL_AURA_MOD_TAUNT
65 &Aura::HandleAuraModStun, // 12 SPELL_AURA_MOD_STUN
66 &Aura::HandleModDamageDone, // 13 SPELL_AURA_MOD_DAMAGE_DONE
67 &Aura::HandleNoImmediateEffect, // 14 SPELL_AURA_MOD_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus
68 &Aura::HandleNoImmediateEffect, // 15 SPELL_AURA_DAMAGE_SHIELD implemented in Unit::DoAttackDamage
69 &Aura::HandleModStealth, // 16 SPELL_AURA_MOD_STEALTH
70 &Aura::HandleNoImmediateEffect, // 17 SPELL_AURA_MOD_STEALTH_DETECT
71 &Aura::HandleInvisibility, // 18 SPELL_AURA_MOD_INVISIBILITY
72 &Aura::HandleInvisibilityDetect, // 19 SPELL_AURA_MOD_INVISIBILITY_DETECTION
73 &Aura::HandleAuraModTotalHealthPercentRegen, // 20 SPELL_AURA_OBS_MOD_HEALTH
74 &Aura::HandleAuraModTotalManaPercentRegen, // 21 SPELL_AURA_OBS_MOD_MANA
75 &Aura::HandleAuraModResistance, // 22 SPELL_AURA_MOD_RESISTANCE
76 &Aura::HandlePeriodicTriggerSpell, // 23 SPELL_AURA_PERIODIC_TRIGGER_SPELL
77 &Aura::HandlePeriodicEnergize, // 24 SPELL_AURA_PERIODIC_ENERGIZE
78 &Aura::HandleAuraModPacify, // 25 SPELL_AURA_MOD_PACIFY
79 &Aura::HandleAuraModRoot, // 26 SPELL_AURA_MOD_ROOT
80 &Aura::HandleAuraModSilence, // 27 SPELL_AURA_MOD_SILENCE
81 &Aura::HandleNoImmediateEffect, // 28 SPELL_AURA_REFLECT_SPELLS implement in Unit::SpellHitResult
82 &Aura::HandleAuraModStat, // 29 SPELL_AURA_MOD_STAT
83 &Aura::HandleAuraModSkill, // 30 SPELL_AURA_MOD_SKILL
84 &Aura::HandleAuraModIncreaseSpeed, // 31 SPELL_AURA_MOD_INCREASE_SPEED
85 &Aura::HandleAuraModIncreaseMountedSpeed, // 32 SPELL_AURA_MOD_INCREASE_MOUNTED_SPEED
86 &Aura::HandleAuraModDecreaseSpeed, // 33 SPELL_AURA_MOD_DECREASE_SPEED
87 &Aura::HandleAuraModIncreaseHealth, // 34 SPELL_AURA_MOD_INCREASE_HEALTH
88 &Aura::HandleAuraModIncreaseEnergy, // 35 SPELL_AURA_MOD_INCREASE_ENERGY
89 &Aura::HandleAuraModShapeshift, // 36 SPELL_AURA_MOD_SHAPESHIFT
90 &Aura::HandleAuraModEffectImmunity, // 37 SPELL_AURA_EFFECT_IMMUNITY
91 &Aura::HandleAuraModStateImmunity, // 38 SPELL_AURA_STATE_IMMUNITY
92 &Aura::HandleAuraModSchoolImmunity, // 39 SPELL_AURA_SCHOOL_IMMUNITY
93 &Aura::HandleAuraModDmgImmunity, // 40 SPELL_AURA_DAMAGE_IMMUNITY
94 &Aura::HandleAuraModDispelImmunity, // 41 SPELL_AURA_DISPEL_IMMUNITY
95 &Aura::HandleAuraProcTriggerSpell, // 42 SPELL_AURA_PROC_TRIGGER_SPELL implemented in Unit::ProcDamageAndSpellFor and Unit::HandleProcTriggerSpell
96 &Aura::HandleNoImmediateEffect, // 43 SPELL_AURA_PROC_TRIGGER_DAMAGE implemented in Unit::ProcDamageAndSpellFor
97 &Aura::HandleAuraTrackCreatures, // 44 SPELL_AURA_TRACK_CREATURES
98 &Aura::HandleAuraTrackResources, // 45 SPELL_AURA_TRACK_RESOURCES
99 &Aura::HandleUnused, // 46 SPELL_AURA_46 (used in test spells 54054 and 54058, and spell 48050) (3.0.8a)
100 &Aura::HandleAuraModParryPercent, // 47 SPELL_AURA_MOD_PARRY_PERCENT
101 &Aura::HandleNULL, // 48 SPELL_AURA_48 spell Napalm (area damage spell with additional delayed damage effect)
102 &Aura::HandleAuraModDodgePercent, // 49 SPELL_AURA_MOD_DODGE_PERCENT
103 &Aura::HandleNoImmediateEffect, // 50 SPELL_AURA_MOD_CRITICAL_HEALING_BONUS
104 &Aura::HandleAuraModBlockPercent, // 51 SPELL_AURA_MOD_BLOCK_PERCENT
105 &Aura::HandleAuraModCritPercent, // 52 SPELL_AURA_MOD_CRIT_PERCENT
106 &Aura::HandlePeriodicLeech, // 53 SPELL_AURA_PERIODIC_LEECH
107 &Aura::HandleModHitChance, // 54 SPELL_AURA_MOD_HIT_CHANCE
108 &Aura::HandleModSpellHitChance, // 55 SPELL_AURA_MOD_SPELL_HIT_CHANCE
109 &Aura::HandleAuraTransform, // 56 SPELL_AURA_TRANSFORM
110 &Aura::HandleModSpellCritChance, // 57 SPELL_AURA_MOD_SPELL_CRIT_CHANCE
111 &Aura::HandleAuraModIncreaseSwimSpeed, // 58 SPELL_AURA_MOD_INCREASE_SWIM_SPEED
112 &Aura::HandleNoImmediateEffect, // 59 SPELL_AURA_MOD_DAMAGE_DONE_CREATURE implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus
113 &Aura::HandleAuraModPacifyAndSilence, // 60 SPELL_AURA_MOD_PACIFY_SILENCE
114 &Aura::HandleAuraModScale, // 61 SPELL_AURA_MOD_SCALE
115 &Aura::HandlePeriodicHealthFunnel, // 62 SPELL_AURA_PERIODIC_HEALTH_FUNNEL
116 &Aura::HandleUnused, // 63 unused (3.0.8a) old SPELL_AURA_PERIODIC_MANA_FUNNEL
117 &Aura::HandlePeriodicManaLeech, // 64 SPELL_AURA_PERIODIC_MANA_LEECH
118 &Aura::HandleModCastingSpeed, // 65 SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK
119 &Aura::HandleFeignDeath, // 66 SPELL_AURA_FEIGN_DEATH
120 &Aura::HandleAuraModDisarm, // 67 SPELL_AURA_MOD_DISARM
121 &Aura::HandleAuraModStalked, // 68 SPELL_AURA_MOD_STALKED
122 &Aura::HandleSchoolAbsorb, // 69 SPELL_AURA_SCHOOL_ABSORB implemented in Unit::CalcAbsorbResist
123 &Aura::HandleUnused, // 70 SPELL_AURA_EXTRA_ATTACKS Useless, used by only one spell that has only visual effect
124 &Aura::HandleModSpellCritChanceShool, // 71 SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL
125 &Aura::HandleModPowerCostPCT, // 72 SPELL_AURA_MOD_POWER_COST_SCHOOL_PCT
126 &Aura::HandleModPowerCost, // 73 SPELL_AURA_MOD_POWER_COST_SCHOOL
127 &Aura::HandleNoImmediateEffect, // 74 SPELL_AURA_REFLECT_SPELLS_SCHOOL implemented in Unit::SpellHitResult
128 &Aura::HandleNoImmediateEffect, // 75 SPELL_AURA_MOD_LANGUAGE
129 &Aura::HandleFarSight, // 76 SPELL_AURA_FAR_SIGHT
130 &Aura::HandleModMechanicImmunity, // 77 SPELL_AURA_MECHANIC_IMMUNITY
131 &Aura::HandleAuraMounted, // 78 SPELL_AURA_MOUNTED
132 &Aura::HandleModDamagePercentDone, // 79 SPELL_AURA_MOD_DAMAGE_PERCENT_DONE
133 &Aura::HandleModPercentStat, // 80 SPELL_AURA_MOD_PERCENT_STAT
134 &Aura::HandleNoImmediateEffect, // 81 SPELL_AURA_SPLIT_DAMAGE_PCT
135 &Aura::HandleWaterBreathing, // 82 SPELL_AURA_WATER_BREATHING
136 &Aura::HandleModBaseResistance, // 83 SPELL_AURA_MOD_BASE_RESISTANCE
137 &Aura::HandleModRegen, // 84 SPELL_AURA_MOD_REGEN
138 &Aura::HandleModPowerRegen, // 85 SPELL_AURA_MOD_POWER_REGEN
139 &Aura::HandleChannelDeathItem, // 86 SPELL_AURA_CHANNEL_DEATH_ITEM
140 &Aura::HandleNoImmediateEffect, // 87 SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus
141 &Aura::HandleNoImmediateEffect, // 88 SPELL_AURA_MOD_HEALTH_REGEN_PERCENT
142 &Aura::HandlePeriodicDamagePCT, // 89 SPELL_AURA_PERIODIC_DAMAGE_PERCENT
143 &Aura::HandleUnused, // 90 unused (3.0.8a) old SPELL_AURA_MOD_RESIST_CHANCE
144 &Aura::HandleNoImmediateEffect, // 91 SPELL_AURA_MOD_DETECT_RANGE implemented in Creature::GetAttackDistance
145 &Aura::HandlePreventFleeing, // 92 SPELL_AURA_PREVENTS_FLEEING
146 &Aura::HandleModUnattackable, // 93 SPELL_AURA_MOD_UNATTACKABLE
147 &Aura::HandleNoImmediateEffect, // 94 SPELL_AURA_INTERRUPT_REGEN implemented in Player::RegenerateAll
148 &Aura::HandleAuraGhost, // 95 SPELL_AURA_GHOST
149 &Aura::HandleNoImmediateEffect, // 96 SPELL_AURA_SPELL_MAGNET implemented in Unit::SelectMagnetTarget
150 &Aura::HandleManaShield, // 97 SPELL_AURA_MANA_SHIELD implemented in Unit::CalcAbsorbResist
151 &Aura::HandleAuraModSkill, // 98 SPELL_AURA_MOD_SKILL_TALENT
152 &Aura::HandleAuraModAttackPower, // 99 SPELL_AURA_MOD_ATTACK_POWER
153 &Aura::HandleUnused, //100 SPELL_AURA_AURAS_VISIBLE obsolete? all player can see all auras now, but still have spells including GM-spell
154 &Aura::HandleModResistancePercent, //101 SPELL_AURA_MOD_RESISTANCE_PCT
155 &Aura::HandleNoImmediateEffect, //102 SPELL_AURA_MOD_MELEE_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonus
156 &Aura::HandleAuraModTotalThreat, //103 SPELL_AURA_MOD_TOTAL_THREAT
157 &Aura::HandleAuraWaterWalk, //104 SPELL_AURA_WATER_WALK
158 &Aura::HandleAuraFeatherFall, //105 SPELL_AURA_FEATHER_FALL
159 &Aura::HandleAuraHover, //106 SPELL_AURA_HOVER
160 &Aura::HandleAddModifier, //107 SPELL_AURA_ADD_FLAT_MODIFIER
161 &Aura::HandleAddModifier, //108 SPELL_AURA_ADD_PCT_MODIFIER
162 &Aura::HandleAddTargetTrigger, //109 SPELL_AURA_ADD_TARGET_TRIGGER
163 &Aura::HandleModPowerRegenPCT, //110 SPELL_AURA_MOD_POWER_REGEN_PERCENT
164 &Aura::HandleNoImmediateEffect, //111 SPELL_AURA_ADD_CASTER_HIT_TRIGGER implemented in Unit::SelectMagnetTarget
165 &Aura::HandleNoImmediateEffect, //112 SPELL_AURA_OVERRIDE_CLASS_SCRIPTS
166 &Aura::HandleNoImmediateEffect, //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus
167 &Aura::HandleNoImmediateEffect, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus
168 &Aura::HandleNoImmediateEffect, //115 SPELL_AURA_MOD_HEALING implemented in Unit::SpellBaseHealingBonusForVictim
169 &Aura::HandleNoImmediateEffect, //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT
170 &Aura::HandleNoImmediateEffect, //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE implemented in Unit::MagicSpellHitResult
171 &Aura::HandleNoImmediateEffect, //118 SPELL_AURA_MOD_HEALING_PCT implemented in Unit::SpellHealingBonus
172 &Aura::HandleUnused, //119 unused (3.0.8a) old SPELL_AURA_SHARE_PET_TRACKING
173 &Aura::HandleAuraUntrackable, //120 SPELL_AURA_UNTRACKABLE
174 &Aura::HandleAuraEmpathy, //121 SPELL_AURA_EMPATHY
175 &Aura::HandleModOffhandDamagePercent, //122 SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT
176 &Aura::HandleModTargetResistance, //123 SPELL_AURA_MOD_TARGET_RESISTANCE
177 &Aura::HandleAuraModRangedAttackPower, //124 SPELL_AURA_MOD_RANGED_ATTACK_POWER
178 &Aura::HandleNoImmediateEffect, //125 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus
179 &Aura::HandleNoImmediateEffect, //126 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus
180 &Aura::HandleNoImmediateEffect, //127 SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus
181 &Aura::HandleModPossessPet, //128 SPELL_AURA_MOD_POSSESS_PET
182 &Aura::HandleAuraModIncreaseSpeed, //129 SPELL_AURA_MOD_SPEED_ALWAYS
183 &Aura::HandleAuraModIncreaseMountedSpeed, //130 SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS
184 &Aura::HandleNoImmediateEffect, //131 SPELL_AURA_MOD_RANGED_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonus
185 &Aura::HandleAuraModIncreaseEnergyPercent, //132 SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT
186 &Aura::HandleAuraModIncreaseHealthPercent, //133 SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT
187 &Aura::HandleAuraModRegenInterrupt, //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT
188 &Aura::HandleModHealingDone, //135 SPELL_AURA_MOD_HEALING_DONE
189 &Aura::HandleNoImmediateEffect, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus
190 &Aura::HandleModTotalPercentStat, //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
191 &Aura::HandleHaste, //138 SPELL_AURA_MOD_HASTE
192 &Aura::HandleForceReaction, //139 SPELL_AURA_FORCE_REACTION
193 &Aura::HandleAuraModRangedHaste, //140 SPELL_AURA_MOD_RANGED_HASTE
194 &Aura::HandleRangedAmmoHaste, //141 SPELL_AURA_MOD_RANGED_AMMO_HASTE
195 &Aura::HandleAuraModBaseResistancePCT, //142 SPELL_AURA_MOD_BASE_RESISTANCE_PCT
196 &Aura::HandleAuraModResistanceExclusive, //143 SPELL_AURA_MOD_RESISTANCE_EXCLUSIVE
197 &Aura::HandleAuraSafeFall, //144 SPELL_AURA_SAFE_FALL implemented in WorldSession::HandleMovementOpcodes
198 &Aura::HandleAuraModPetTalentsPoints, //145 SPELL_AURA_MOD_PET_TALENT_POINTS
199 &Aura::HandleNoImmediateEffect, //146 SPELL_AURA_ALLOW_TAME_PET_TYPE
200 &Aura::HandleNULL, //147 SPELL_AURA_ADD_CREATURE_IMMUNITY
201 &Aura::HandleAuraRetainComboPoints, //148 SPELL_AURA_RETAIN_COMBO_POINTS
202 &Aura::HandleNoImmediateEffect, //149 SPELL_AURA_REDUCE_PUSHBACK
203 &Aura::HandleShieldBlockValue, //150 SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT
204 &Aura::HandleAuraTrackStealthed, //151 SPELL_AURA_TRACK_STEALTHED
205 &Aura::HandleNoImmediateEffect, //152 SPELL_AURA_MOD_DETECTED_RANGE implemented in Creature::GetAttackDistance
206 &Aura::HandleNoImmediateEffect, //153 SPELL_AURA_SPLIT_DAMAGE_FLAT
207 &Aura::HandleNoImmediateEffect, //154 SPELL_AURA_MOD_STEALTH_LEVEL
208 &Aura::HandleNoImmediateEffect, //155 SPELL_AURA_MOD_WATER_BREATHING
209 &Aura::HandleNoImmediateEffect, //156 SPELL_AURA_MOD_REPUTATION_GAIN
210 &Aura::HandleNULL, //157 SPELL_AURA_PET_DAMAGE_MULTI
211 &Aura::HandleShieldBlockValue, //158 SPELL_AURA_MOD_SHIELD_BLOCKVALUE
212 &Aura::HandleNoImmediateEffect, //159 SPELL_AURA_NO_PVP_CREDIT only for Honorless Target spell
213 &Aura::HandleNoImmediateEffect, //160 SPELL_AURA_MOD_AOE_AVOIDANCE implemented in Unit::MagicSpellHitResult
214 &Aura::HandleNoImmediateEffect, //161 SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT
215 &Aura::HandleAuraPowerBurn, //162 SPELL_AURA_POWER_BURN_MANA
216 &Aura::HandleNoImmediateEffect, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE
217 &Aura::HandleUnused, //164 unused (3.0.8a), only one test spell
218 &Aura::HandleNoImmediateEffect, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus
219 &Aura::HandleAuraModAttackPowerPercent, //166 SPELL_AURA_MOD_ATTACK_POWER_PCT
220 &Aura::HandleAuraModRangedAttackPowerPercent, //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT
221 &Aura::HandleNoImmediateEffect, //168 SPELL_AURA_MOD_DAMAGE_DONE_VERSUS implemented in Unit::SpellDamageBonus, Unit::MeleeDamageBonus
222 &Aura::HandleNoImmediateEffect, //169 SPELL_AURA_MOD_CRIT_PERCENT_VERSUS implemented in Unit::DealDamageBySchool, Unit::DoAttackDamage, Unit::SpellCriticalBonus
223 &Aura::HandleNULL, //170 SPELL_AURA_DETECT_AMORE different spells that ignore transformation effects
224 &Aura::HandleAuraModIncreaseSpeed, //171 SPELL_AURA_MOD_SPEED_NOT_STACK
225 &Aura::HandleAuraModIncreaseMountedSpeed, //172 SPELL_AURA_MOD_MOUNTED_SPEED_NOT_STACK
226 &Aura::HandleUnused, //173 unused (3.0.8a) no spells, old SPELL_AURA_ALLOW_CHAMPION_SPELLS only for Proclaim Champion spell
227 &Aura::HandleModSpellDamagePercentFromStat, //174 SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT implemented in Unit::SpellBaseDamageBonus
228 &Aura::HandleModSpellHealingPercentFromStat, //175 SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT implemented in Unit::SpellBaseHealingBonus
229 &Aura::HandleSpiritOfRedemption, //176 SPELL_AURA_SPIRIT_OF_REDEMPTION only for Spirit of Redemption spell, die at aura end
230 &Aura::HandleNULL, //177 SPELL_AURA_AOE_CHARM
231 &Aura::HandleNoImmediateEffect, //178 SPELL_AURA_MOD_DEBUFF_RESISTANCE implemented in Unit::MagicSpellHitResult
232 &Aura::HandleNoImmediateEffect, //179 SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE implemented in Unit::SpellCriticalBonus
233 &Aura::HandleNoImmediateEffect, //180 SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS implemented in Unit::SpellDamageBonus
234 &Aura::HandleUnused, //181 unused (3.0.8a) old SPELL_AURA_MOD_FLAT_SPELL_CRIT_DAMAGE_VERSUS
235 &Aura::HandleAuraModResistenceOfStatPercent, //182 SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT
236 &Aura::HandleNULL, //183 SPELL_AURA_MOD_CRITICAL_THREAT only used in 28746
237 &Aura::HandleNoImmediateEffect, //184 SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
238 &Aura::HandleNoImmediateEffect, //185 SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
239 &Aura::HandleNoImmediateEffect, //186 SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE implemented in Unit::MagicSpellHitResult
240 &Aura::HandleNoImmediateEffect, //187 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance
241 &Aura::HandleNoImmediateEffect, //188 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance
242 &Aura::HandleModRating, //189 SPELL_AURA_MOD_RATING
243 &Aura::HandleNULL, //190 SPELL_AURA_MOD_FACTION_REPUTATION_GAIN
244 &Aura::HandleAuraModUseNormalSpeed, //191 SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED
245 &Aura::HandleModMeleeRangedSpeedPct, //192 SPELL_AURA_HASTE_MELEE
246 &Aura::HandleModCombatSpeedPct, //193 SPELL_AURA_MELEE_SLOW (in fact combat (any type attack) speed pct)
247 &Aura::HandleNULL, //194 SPELL_AURA_MOD_IGNORE_ABSORB_SCHOOL
248 &Aura::HandleNoImmediateEffect, //195 SPELL_AURA_MOD_IGNORE_ABSORB_FOR_SPELL implement in Unit::CalculateSpellDamage
249 &Aura::HandleNULL, //196 SPELL_AURA_MOD_COOLDOWN
250 &Aura::HandleNoImmediateEffect, //197 SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE implemented in Unit::SpellCriticalBonus Unit::GetUnitCriticalChance
251 &Aura::HandleUnused, //198 unused (3.0.8a) old SPELL_AURA_MOD_ALL_WEAPON_SKILLS
252 &Aura::HandleNoImmediateEffect, //199 SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT implemented in Unit::MagicSpellHitResult
253 &Aura::HandleNoImmediateEffect, //200 SPELL_AURA_MOD_XP_PCT implemented in Player::GiveXP
254 &Aura::HandleAuraAllowFlight, //201 SPELL_AURA_FLY this aura enable flight mode...
255 &Aura::HandleNoImmediateEffect, //202 SPELL_AURA_CANNOT_BE_DODGED implemented in Unit::RollPhysicalOutcomeAgainst
256 &Aura::HandleNoImmediateEffect, //203 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE implemented in Unit::CalculateMeleeDamage and Unit::CalculateSpellDamage
257 &Aura::HandleNoImmediateEffect, //204 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE implemented in Unit::CalculateMeleeDamage and Unit::CalculateSpellDamage
258 &Aura::HandleNULL, //205 vulnerable to school dmg?
259 &Aura::HandleNULL, //206 SPELL_AURA_MOD_SPEED_MOUNTED
260 &Aura::HandleAuraModIncreaseFlightSpeed, //207 SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
261 &Aura::HandleAuraModIncreaseFlightSpeed, //208 SPELL_AURA_MOD_SPEED_FLIGHT, used only in spell: Flight Form (Passive)
262 &Aura::HandleAuraModIncreaseFlightSpeed, //209 SPELL_AURA_MOD_FLIGHT_SPEED_ALWAYS
263 &Aura::HandleNULL, //210 Commentator's Command
264 &Aura::HandleAuraModIncreaseFlightSpeed, //211 SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK
265 &Aura::HandleAuraModRangedAttackPowerOfStatPercent, //212 SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT
266 &Aura::HandleNoImmediateEffect, //213 SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT implemented in Player::RewardRage
267 &Aura::HandleNULL, //214 Tamed Pet Passive
268 &Aura::HandleArenaPreparation, //215 SPELL_AURA_ARENA_PREPARATION
269 &Aura::HandleModCastingSpeed, //216 SPELL_AURA_HASTE_SPELLS
270 &Aura::HandleUnused, //217 unused (3.0.8a)
271 &Aura::HandleAuraModRangedHaste, //218 SPELL_AURA_HASTE_RANGED
272 &Aura::HandleModManaRegen, //219 SPELL_AURA_MOD_MANA_REGEN_FROM_STAT
273 &Aura::HandleModRatingFromStat, //220 SPELL_AURA_MOD_RATING_FROM_STAT
274 &Aura::HandleNULL, //221 ignored
275 &Aura::HandleUnused, //222 unused (3.0.8a) only for spell 44586 that not used in real spell cast
276 &Aura::HandleNULL, //223 Cold Stare
277 &Aura::HandleUnused, //224 unused (3.0.8a)
278 &Aura::HandleNoImmediateEffect, //225 SPELL_AURA_PRAYER_OF_MENDING
279 &Aura::HandleAuraPeriodicDummy, //226 SPELL_AURA_PERIODIC_DUMMY
280 &Aura::HandlePeriodicTriggerSpellWithValue, //227 SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
281 &Aura::HandleNoImmediateEffect, //228 stealth detection
282 &Aura::HandleNULL, //229 SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE
283 &Aura::HandleAuraModIncreaseMaxHealth, //230 Commanding Shout
284 &Aura::HandleNoImmediateEffect, //231 SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE
285 &Aura::HandleNoImmediateEffect, //232 SPELL_AURA_MECHANIC_DURATION_MOD implement in Unit::CalculateSpellDuration
286 &Aura::HandleNULL, //233 set model id to the one of the creature with id m_modifier.m_miscvalue
287 &Aura::HandleNoImmediateEffect, //234 SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK implement in Unit::CalculateSpellDuration
288 &Aura::HandleAuraModDispelResist, //235 SPELL_AURA_MOD_DISPEL_RESIST implement in Unit::MagicSpellHitResult
289 &Aura::HandleAuraControlVehicle, //236 SPELL_AURA_CONTROL_VEHICLE
290 &Aura::HandleModSpellDamagePercentFromAttackPower, //237 SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER implemented in Unit::SpellBaseDamageBonus
291 &Aura::HandleModSpellHealingPercentFromAttackPower, //238 SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER implemented in Unit::SpellBaseHealingBonus
292 &Aura::HandleAuraModScale, //239 SPELL_AURA_MOD_SCALE_2 only in Noggenfogger Elixir (16595) before 2.3.0 aura 61
293 &Aura::HandleAuraModExpertise, //240 SPELL_AURA_MOD_EXPERTISE
294 &Aura::HandleForceMoveForward, //241 Forces the player to move forward
295 &Aura::HandleUnused, //242 SPELL_AURA_MOD_SPELL_DAMAGE_FROM_HEALING
296 &Aura::HandleNULL, //243 faction reaction override spells
297 &Aura::HandleComprehendLanguage, //244 Comprehend language
298 &Aura::HandleNULL, //245 SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS
299 &Aura::HandleNoImmediateEffect, //246 SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL
300 &Aura::HandleNULL, //247 target to become a clone of the caster
301 &Aura::HandleNoImmediateEffect, //248 SPELL_AURA_MOD_COMBAT_RESULT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
302 &Aura::HandleAuraConvertRune, //249 SPELL_AURA_CONVERT_RUNE
303 &Aura::HandleAuraModIncreaseHealth, //250 SPELL_AURA_MOD_INCREASE_HEALTH_2
304 &Aura::HandleNULL, //251 SPELL_AURA_MOD_ENEMY_DODGE
305 &Aura::HandleNULL, //252 haste all?
306 &Aura::HandleNULL, //253 SPELL_AURA_MOD_BLOCK_CRIT_CHANCE
307 &Aura::HandleNULL, //254 SPELL_AURA_MOD_DISARM_SHIELD disarm Shield
308 &Aura::HandleNoImmediateEffect, //255 SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT implemented in Unit::SpellDamageBonus
309 &Aura::HandleNoReagentUseAura, //256 SPELL_AURA_NO_REAGENT_USE Use SpellClassMask for spell select
310 &Aura::HandleNULL, //257 SPELL_AURA_MOD_TARGET_RESIST_BY_SPELL_CLASS Use SpellClassMask for spell select
311 &Aura::HandleNULL, //258 SPELL_AURA_MOD_SPELL_VISUAL
312 &Aura::HandleNULL, //259 corrupt healing over time spell
313 &Aura::HandleNoImmediateEffect, //260 SPELL_AURA_SCREEN_EFFECT (miscvalue = id in ScreenEffect.dbc) not required any code
314 &Aura::HandlePhase, //261 SPELL_AURA_PHASE undetactable invisibility? implemented in Unit::isVisibleForOrDetect
315 &Aura::HandleNULL, //262
316 &Aura::HandleNULL, //263 SPELL_AURA_ALLOW_ONLY_ABILITY player can use only abilities set in SpellClassMask
317 &Aura::HandleUnused, //264 unused (3.0.8a)
318 &Aura::HandleUnused, //265 unused (3.0.8a)
319 &Aura::HandleUnused, //266 unused (3.0.8a)
320 &Aura::HandleNoImmediateEffect, //267 SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL implemented in Unit::IsImmunedToSpellEffect
321 &Aura::HandleAuraModAttackPowerOfStatPercent, //268 SPELL_AURA_MOD_ATTACK_POWER_OF_STAT_PERCENT
322 &Aura::HandleNULL, //269 ignore DR effects?
323 &Aura::HandleNULL, //270 SPELL_AURA_MOD_IGNORE_TARGET_RESIST
324 &Aura::HandleNoImmediateEffect, //271 SPELL_AURA_MOD_DAMAGE_FROM_CASTER implemented in Unit::SpellDamageBonus
325 &Aura::HandleNULL, //272 reduce spell cast time?
326 &Aura::HandleNULL, //273
327 &Aura::HandleNULL, //274 proc free shot?
328 &Aura::HandleNoImmediateEffect, //275 SPELL_AURA_MOD_IGNORE_SHAPESHIFT Use SpellClassMask for spell select
329 &Aura::HandleNULL, //276 mod damage % mechanic?
330 &Aura::HandleNoImmediateEffect, //277 SPELL_AURA_MOD_MAX_AFFECTED_TARGETS Use SpellClassMask for spell select
331 &Aura::HandleNULL, //278 SPELL_AURA_MOD_DISARM_RANGED disarm ranged weapon
332 &Aura::HandleNULL, //279 visual effects? 58836 and 57507
333 &Aura::HandleNULL, //280 SPELL_AURA_MOD_TARGET_ARMOR_PCT
334 &Aura::HandleNULL, //281 SPELL_AURA_MOD_HONOR_GAIN
335 &Aura::HandleAuraIncreaseBaseHealthPercent, //282 SPELL_AURA_INCREASE_BASE_HEALTH_PERCENT
336 &Aura::HandleNoImmediateEffect, //283 SPELL_AURA_MOD_HEALING_RECEIVED implemented in Unit::SpellHealingBonus
337 &Aura::HandleUnused, //284 not used by any spells (3.08a)
338 &Aura::HandleUnused, //285 not used by any spells (3.08a)
339 &Aura::HandleUnused, //286 not used by any spells (3.08a)
340 &Aura::HandleNoImmediateEffect, //287 SPELL_AURA_DEFLECT_SPELLS implemented in Unit::MagicSpellHitResult and Unit::MeleeSpellHitResult
341 &Aura::HandleUnused, //288 not used by any spells (3.09) except 1 test spell.
342 &Aura::HandleUnused, //289 unused
343 &Aura::HandleUnused, //290 unused
344 &Aura::HandleUnused, //291 unused
345 &Aura::HandleNULL, //292 call stabled pet
346 &Aura::HandleNULL, //293 2 test spells
347 &Aura::HandleNULL //294 2 spells, possible prevent mana regen
350 static AuraType const frozenAuraTypes[] = { SPELL_AURA_MOD_ROOT, SPELL_AURA_MOD_STUN, SPELL_AURA_NONE };
352 Aura::Aura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) :
353 m_spellmod(NULL), m_caster_guid(0), m_target(target), m_castItemGuid(castItem?castItem->GetGUID():0),
354 m_timeCla(1000), m_periodicTimer(0), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE),
355 m_effIndex(eff), m_auraSlot(MAX_AURAS), m_auraFlags(AFLAG_NONE), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),
356 m_positive(false), m_permanent(false), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false),
357 m_isRemovedOnShapeLost(true), m_updated(false), m_in_use(false)
359 assert(target);
361 assert(spellproto && spellproto == sSpellStore.LookupEntry( spellproto->Id ) && "`info` must be pointer to sSpellStore element");
363 m_spellProto = spellproto;
365 m_currentBasePoints = currentBasePoints ? *currentBasePoints : m_spellProto->EffectBasePoints[eff];
367 m_isPassive = IsPassiveSpell(GetId());
368 m_positive = IsPositiveEffect(GetId(), m_effIndex);
370 m_isSingleTargetAura = IsSingleTargetSpell(m_spellProto);
372 m_applyTime = time(NULL);
374 int32 damage;
375 if(!caster)
377 m_caster_guid = target->GetGUID();
378 damage = m_currentBasePoints+1; // stored value-1
379 m_maxduration = target->CalculateSpellDuration(m_spellProto, m_effIndex, target);
381 else
383 m_caster_guid = caster->GetGUID();
385 damage = caster->CalculateSpellDamage(m_spellProto,m_effIndex,m_currentBasePoints,target);
386 m_maxduration = caster->CalculateSpellDuration(m_spellProto, m_effIndex, target);
388 if (!damage && castItem && castItem->GetItemSuffixFactor())
390 ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(castItem->GetItemRandomPropertyId()));
391 if(item_rand_suffix)
393 for (int k=0; k<3; k++)
395 SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(item_rand_suffix->enchant_id[k]);
396 if(pEnchant)
398 for (int t=0; t<3; t++)
399 if(pEnchant->spellid[t] == m_spellProto->Id)
401 damage = uint32((item_rand_suffix->prefix[k]*castItem->GetItemSuffixFactor()) / 10000 );
402 break;
406 if(damage)
407 break;
413 if(m_maxduration == -1 || m_isPassive && m_spellProto->DurationIndex == 0)
414 m_permanent = true;
416 Player* modOwner = caster ? caster->GetSpellModOwner() : NULL;
418 if(!m_permanent && modOwner)
420 modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, m_maxduration);
421 // Get zero duration aura after - need set m_maxduration > 0 for apply/remove aura work
422 if (m_maxduration<=0)
423 m_maxduration = 1;
426 m_duration = m_maxduration;
428 sLog.outDebug("Aura: construct Spellid : %u, Aura : %u Duration : %d Target : %d Damage : %d", m_spellProto->Id, m_spellProto->EffectApplyAuraName[eff], m_maxduration, m_spellProto->EffectImplicitTargetA[eff],damage);
430 m_effIndex = eff;
431 SetModifier(AuraType(m_spellProto->EffectApplyAuraName[eff]), damage, m_spellProto->EffectAmplitude[eff], m_spellProto->EffectMiscValue[eff]);
433 // Apply periodic time mod
434 if(modOwner && m_modifier.periodictime)
435 modOwner->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME, m_modifier.periodictime);
437 // Start periodic on next tick or at aura apply
438 if (!(m_spellProto->AttributesEx5 & SPELL_ATTR_EX5_START_PERIODIC_AT_APPLY))
439 m_periodicTimer += m_modifier.periodictime;
441 m_isDeathPersist = IsDeathPersistentSpell(m_spellProto);
443 m_procCharges = m_spellProto->procCharges;
444 if(modOwner)
445 modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges);
447 m_isRemovedOnShapeLost = (m_caster_guid==m_target->GetGUID() &&
448 m_spellProto->Stances &&
449 !(m_spellProto->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT) &&
450 !(m_spellProto->Attributes & SPELL_ATTR_NOT_SHAPESHIFT));
453 Aura::~Aura()
457 AreaAura::AreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target,
458 Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
460 m_isAreaAura = true;
462 // caster==NULL in constructor args if target==caster in fact
463 Unit* caster_ptr = caster ? caster : target;
465 m_radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(GetSpellProto()->EffectRadiusIndex[m_effIndex]));
466 if(Player* modOwner = caster_ptr->GetSpellModOwner())
467 modOwner->ApplySpellMod(GetId(), SPELLMOD_RADIUS, m_radius);
469 switch(spellproto->Effect[eff])
471 case SPELL_EFFECT_APPLY_AREA_AURA_PARTY:
472 m_areaAuraType = AREA_AURA_PARTY;
473 if (target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isTotem())
474 m_modifier.m_auraname = SPELL_AURA_NONE;
475 break;
476 case SPELL_EFFECT_APPLY_AREA_AURA_RAID:
477 m_areaAuraType = AREA_AURA_RAID;
478 if (target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isTotem())
479 m_modifier.m_auraname = SPELL_AURA_NONE;
480 break;
481 case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND:
482 m_areaAuraType = AREA_AURA_FRIEND;
483 break;
484 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY:
485 m_areaAuraType = AREA_AURA_ENEMY;
486 if (target == caster_ptr)
487 m_modifier.m_auraname = SPELL_AURA_NONE; // Do not do any effect on self
488 break;
489 case SPELL_EFFECT_APPLY_AREA_AURA_PET:
490 m_areaAuraType = AREA_AURA_PET;
491 break;
492 case SPELL_EFFECT_APPLY_AREA_AURA_OWNER:
493 m_areaAuraType = AREA_AURA_OWNER;
494 if (target == caster_ptr)
495 m_modifier.m_auraname = SPELL_AURA_NONE;
496 break;
497 default:
498 sLog.outError("Wrong spell effect in AreaAura constructor");
499 ASSERT(false);
500 break;
504 AreaAura::~AreaAura()
508 PersistentAreaAura::PersistentAreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target,
509 Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
511 m_isPersistent = true;
514 PersistentAreaAura::~PersistentAreaAura()
518 SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target,
519 Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
521 if (caster)
522 m_casters_target_guid = caster->GetTypeId()==TYPEID_PLAYER ? ((Player*)caster)->GetSelection() : caster->GetUInt64Value(UNIT_FIELD_TARGET);
523 else
524 m_casters_target_guid = 0;
527 SingleEnemyTargetAura::~SingleEnemyTargetAura()
531 Unit* SingleEnemyTargetAura::GetTriggerTarget() const
533 return ObjectAccessor::GetUnit(*m_target, m_casters_target_guid);
536 Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem)
538 if (IsAreaAuraEffect(spellproto->Effect[eff]))
539 return new AreaAura(spellproto, eff, currentBasePoints, target, caster, castItem);
541 uint32 triggeredSpellId = spellproto->EffectTriggerSpell[eff];
543 if(SpellEntry const* triggeredSpellInfo = sSpellStore.LookupEntry(triggeredSpellId))
544 for (int i = 0; i < 3; ++i)
545 if (triggeredSpellInfo->EffectImplicitTargetA[i] == TARGET_SINGLE_ENEMY)
546 return new SingleEnemyTargetAura(spellproto, eff, currentBasePoints, target, caster, castItem);
548 return new Aura(spellproto, eff, currentBasePoints, target, caster, castItem);
551 Unit* Aura::GetCaster() const
553 if(m_caster_guid==m_target->GetGUID())
554 return m_target;
556 //return ObjectAccessor::GetUnit(*m_target,m_caster_guid);
557 //must return caster even if it's in another grid/map
558 Unit *unit = ObjectAccessor::GetObjectInWorld(m_caster_guid, (Unit*)NULL);
559 return unit && unit->IsInWorld() ? unit : NULL;
562 void Aura::SetModifier(AuraType t, int32 a, uint32 pt, int32 miscValue)
564 m_modifier.m_auraname = t;
565 m_modifier.m_amount = a;
566 m_modifier.m_miscvalue = miscValue;
567 m_modifier.periodictime = pt;
570 void Aura::Update(uint32 diff)
572 if (m_duration > 0)
574 m_duration -= diff;
575 if (m_duration < 0)
576 m_duration = 0;
577 m_timeCla -= diff;
579 // GetEffIndex()==0 prevent double/triple apply manaPerSecond/manaPerSecondPerLevel to same spell with many auras
580 // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0
581 if(GetEffIndex()==0 && m_timeCla <= 0)
583 if(Unit* caster = GetCaster())
585 Powers powertype = Powers(m_spellProto->powerType);
586 int32 manaPerSecond = m_spellProto->manaPerSecond + m_spellProto->manaPerSecondPerLevel * caster->getLevel();
587 m_timeCla = 1*IN_MILISECONDS;
588 if (manaPerSecond)
590 if(powertype==POWER_HEALTH)
591 caster->ModifyHealth(-manaPerSecond);
592 else
593 caster->ModifyPower(powertype,-manaPerSecond);
599 // Channeled aura required check distance from caster
600 if(IsChanneledSpell(m_spellProto) && m_caster_guid != m_target->GetGUID())
602 Unit* caster = GetCaster();
603 if(!caster)
605 m_target->RemoveAura(GetId(),GetEffIndex());
606 return;
609 // Get spell range
610 float radius;
611 SpellModOp mod;
612 if (m_spellProto->EffectRadiusIndex[GetEffIndex()])
614 radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellProto->EffectRadiusIndex[GetEffIndex()]));
615 mod = SPELLMOD_RADIUS;
617 else
619 radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellProto->rangeIndex));
620 mod = SPELLMOD_RANGE;
623 if(Player* modOwner = caster->GetSpellModOwner())
624 modOwner->ApplySpellMod(GetId(), mod, radius,NULL);
626 if(!caster->IsWithinDistInMap(m_target,radius))
628 m_target->RemoveAura(GetId(),GetEffIndex());
629 return;
633 if(m_isPeriodic && (m_duration >= 0 || m_isPassive || m_permanent))
635 m_periodicTimer -= diff;
636 if(m_periodicTimer <= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N
638 // update before applying (aura can be removed in TriggerSpell or PeriodicTick calls)
639 m_periodicTimer += m_modifier.periodictime;
640 PeriodicTick();
645 void AreaAura::Update(uint32 diff)
647 // update for the caster of the aura
648 if(m_caster_guid == m_target->GetGUID())
650 Unit* caster = m_target;
652 if( !caster->hasUnitState(UNIT_STAT_ISOLATED) )
654 Unit* owner = caster->GetCharmerOrOwner();
655 if (!owner)
656 owner = caster;
657 std::list<Unit *> targets;
659 switch(m_areaAuraType)
661 case AREA_AURA_PARTY:
663 Group *pGroup = NULL;
665 if (owner->GetTypeId() == TYPEID_PLAYER)
666 pGroup = ((Player*)owner)->GetGroup();
668 if( pGroup)
670 uint8 subgroup = ((Player*)owner)->GetSubGroup();
671 for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
673 Player* Target = itr->getSource();
674 if(Target && Target->isAlive() && Target->GetSubGroup()==subgroup && caster->IsFriendlyTo(Target))
676 if(caster->IsWithinDistInMap(Target, m_radius))
677 targets.push_back(Target);
678 Pet *pet = Target->GetPet();
679 if(pet && pet->isAlive() && caster->IsWithinDistInMap(pet, m_radius))
680 targets.push_back(pet);
684 else
686 // add owner
687 if( owner != caster && caster->IsWithinDistInMap(owner, m_radius) )
688 targets.push_back(owner);
689 // add caster's pet
690 Unit* pet = caster->GetPet();
691 if( pet && caster->IsWithinDistInMap(pet, m_radius))
692 targets.push_back(pet);
694 break;
696 case AREA_AURA_RAID:
698 Group *pGroup = NULL;
700 if (owner->GetTypeId() == TYPEID_PLAYER)
701 pGroup = ((Player*)owner)->GetGroup();
703 if( pGroup)
705 for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
707 Player* Target = itr->getSource();
708 if(Target && Target->isAlive() && caster->IsFriendlyTo(Target))
710 if(caster->IsWithinDistInMap(Target, m_radius))
711 targets.push_back(Target);
712 Pet *pet = Target->GetPet();
713 if(pet && pet->isAlive() && caster->IsWithinDistInMap(pet, m_radius))
714 targets.push_back(pet);
718 else
720 // add owner
721 if( owner != caster && caster->IsWithinDistInMap(owner, m_radius) )
722 targets.push_back(owner);
723 // add caster's pet
724 Unit* pet = caster->GetPet();
725 if( pet && caster->IsWithinDistInMap(pet, m_radius))
726 targets.push_back(pet);
728 break;
730 case AREA_AURA_FRIEND:
732 CellPair p(MaNGOS::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY()));
733 Cell cell(p);
734 cell.data.Part.reserved = ALL_DISTRICT;
735 cell.SetNoCreate();
737 MaNGOS::AnyFriendlyUnitInObjectRangeCheck u_check(caster, owner, m_radius);
738 MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck> searcher(caster,targets, u_check);
739 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
740 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
741 CellLock<GridReadGuard> cell_lock(cell, p);
742 cell_lock->Visit(cell_lock, world_unit_searcher, *caster->GetMap());
743 cell_lock->Visit(cell_lock, grid_unit_searcher, *caster->GetMap());
744 break;
746 case AREA_AURA_ENEMY:
748 CellPair p(MaNGOS::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY()));
749 Cell cell(p);
750 cell.data.Part.reserved = ALL_DISTRICT;
751 cell.SetNoCreate();
753 MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(caster, owner, m_radius); // No GetCharmer in searcher
754 MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(caster, targets, u_check);
755 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
756 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
757 CellLock<GridReadGuard> cell_lock(cell, p);
758 cell_lock->Visit(cell_lock, world_unit_searcher, *caster->GetMap());
759 cell_lock->Visit(cell_lock, grid_unit_searcher, *caster->GetMap());
760 break;
762 case AREA_AURA_OWNER:
763 case AREA_AURA_PET:
765 if(owner != caster)
766 targets.push_back(owner);
767 break;
771 for(std::list<Unit *>::iterator tIter = targets.begin(); tIter != targets.end(); tIter++)
773 if((*tIter)->HasAura(GetId(), m_effIndex))
774 continue;
776 if(SpellEntry const *actualSpellInfo = spellmgr.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter)->getLevel()))
778 int32 actualBasePoints = m_currentBasePoints;
779 // recalculate basepoints for lower rank (all AreaAura spell not use custom basepoints?)
780 if(actualSpellInfo != GetSpellProto())
781 actualBasePoints = actualSpellInfo->EffectBasePoints[m_effIndex];
782 AreaAura *aur = new AreaAura(actualSpellInfo, m_effIndex, &actualBasePoints, (*tIter), caster, NULL);
783 aur->SetAuraDuration(GetAuraDuration());
784 (*tIter)->AddAura(aur);
788 Aura::Update(diff);
790 else // aura at non-caster
792 Unit * tmp_target = m_target;
793 Unit* caster = GetCaster();
794 uint32 tmp_spellId = GetId(), tmp_effIndex = m_effIndex;
796 // WARNING: the aura may get deleted during the update
797 // DO NOT access its members after update!
798 Aura::Update(diff);
800 // remove aura if out-of-range from caster (after teleport for example)
801 // or caster is isolated or caster no longer has the aura
802 // or caster is (no longer) friendly
803 bool needFriendly = (m_areaAuraType == AREA_AURA_ENEMY ? false : true);
804 if( !caster || caster->hasUnitState(UNIT_STAT_ISOLATED) ||
805 !caster->IsWithinDistInMap(tmp_target, m_radius) ||
806 !caster->HasAura(tmp_spellId, tmp_effIndex) ||
807 caster->IsFriendlyTo(tmp_target) != needFriendly
810 tmp_target->RemoveAura(tmp_spellId, tmp_effIndex);
812 else if( m_areaAuraType == AREA_AURA_PARTY) // check if in same sub group
814 // not check group if target == owner or target == pet
815 if (caster->GetCharmerOrOwnerGUID() != tmp_target->GetGUID() && caster->GetGUID() != tmp_target->GetCharmerOrOwnerGUID())
817 Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself();
819 Group *pGroup = check ? check->GetGroup() : NULL;
820 if( pGroup )
822 Player* checkTarget = tmp_target->GetCharmerOrOwnerPlayerOrPlayerItself();
823 if(!checkTarget || !pGroup->SameSubGroup(check, checkTarget))
824 tmp_target->RemoveAura(tmp_spellId, tmp_effIndex);
826 else
827 tmp_target->RemoveAura(tmp_spellId, tmp_effIndex);
830 else if( m_areaAuraType == AREA_AURA_RAID) // TODO: fix me!
832 // not check group if target == owner or target == pet
833 if (caster->GetCharmerOrOwnerGUID() != tmp_target->GetGUID() && caster->GetGUID() != tmp_target->GetCharmerOrOwnerGUID())
835 Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself();
837 Group *pGroup = check ? check->GetGroup() : NULL;
838 if( pGroup )
840 Player* checkTarget = tmp_target->GetCharmerOrOwnerPlayerOrPlayerItself();
841 if(!checkTarget)
842 tmp_target->RemoveAura(tmp_spellId, tmp_effIndex);
844 else
845 tmp_target->RemoveAura(tmp_spellId, tmp_effIndex);
848 else if( m_areaAuraType == AREA_AURA_PET || m_areaAuraType == AREA_AURA_OWNER )
850 if( tmp_target->GetGUID() != caster->GetCharmerOrOwnerGUID() )
851 tmp_target->RemoveAura(tmp_spellId, tmp_effIndex);
856 void PersistentAreaAura::Update(uint32 diff)
858 bool remove = false;
860 // remove the aura if its caster or the dynamic object causing it was removed
861 // or if the target moves too far from the dynamic object
862 Unit *caster = GetCaster();
863 if (caster)
865 DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex());
866 if (dynObj)
868 if (!m_target->IsWithinDistInMap(dynObj, dynObj->GetRadius()))
869 remove = true;
871 else
872 remove = true;
874 else
875 remove = true;
877 Unit *tmp_target = m_target;
878 uint32 tmp_id = GetId(), tmp_index = GetEffIndex();
880 // WARNING: the aura may get deleted during the update
881 // DO NOT access its members after update!
882 Aura::Update(diff);
884 if(remove)
885 tmp_target->RemoveAura(tmp_id, tmp_index);
888 void Aura::ApplyModifier(bool apply, bool Real)
890 AuraType aura = m_modifier.m_auraname;
892 m_in_use = true;
893 if(aura<TOTAL_AURAS)
894 (*this.*AuraHandler [aura])(apply,Real);
895 m_in_use = false;
898 void Aura::_AddAura()
900 if (!GetId())
901 return;
902 if(!m_target)
903 return;
905 // Second aura if some spell
906 bool secondaura = false;
907 // Try find slot for aura
908 uint8 slot = NULL_AURA_SLOT;
909 // Lookup for some spell auras (and get slot from it)
910 for(uint8 i = 0; i < m_effIndex; i++)
912 Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), i);
913 for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr)
915 // allow use single slot only by auras from same caster
916 if(itr->second->GetCasterGUID()==GetCasterGUID())
918 slot = itr->second->GetAuraSlot();
919 secondaura = true;
920 break;
923 if (secondaura)
924 break;
926 // Lookup free slot
927 if (!secondaura && m_target->GetVisibleAurasCount() < MAX_AURAS)
929 Unit::VisibleAuraMap const *visibleAuras = m_target->GetVisibleAuras();
930 for(uint8 i = 0; i < MAX_AURAS; ++i)
932 Unit::VisibleAuraMap::const_iterator itr = visibleAuras->find(i);
933 if(itr == visibleAuras->end())
935 slot = i;
936 // update for out of range group members (on 1 slot use)
937 m_target->UpdateAuraForGroup(slot);
938 break;
943 Unit* caster = GetCaster();
945 // set infinity cooldown state for spells
946 if(caster && caster->GetTypeId() == TYPEID_PLAYER)
948 if (m_spellProto->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE)
950 Item* castItem = m_castItemGuid ? ((Player*)caster)->GetItemByGuid(m_castItemGuid) : NULL;
951 ((Player*)caster)->AddSpellAndCategoryCooldowns(m_spellProto,castItem ? castItem->GetEntry() : 0, NULL,true);
955 // passive auras (except totem auras) do not get placed in the slots
956 // area auras with SPELL_AURA_NONE are not shown on target
957 if((!m_isPassive || (caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem())) &&
958 (m_spellProto->Effect[GetEffIndex()] != SPELL_EFFECT_APPLY_AREA_AURA_ENEMY || m_target != caster))
960 SetAuraSlot( slot );
961 if(slot < MAX_AURAS) // slot found send data to client
963 SetAura(false);
964 SetAuraFlags((1 << GetEffIndex()) | AFLAG_NOT_CASTER | ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION : AFLAG_NONE) | (IsPositive() ? AFLAG_POSITIVE : AFLAG_NEGATIVE));
965 SetAuraLevel(caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
966 SendAuraUpdate(false);
969 //*****************************************************
970 // Update target aura state flag (at 1 aura apply)
971 // TODO: Make it easer
972 //*****************************************************
973 if (!secondaura)
975 // Sitdown on apply aura req seated
976 if (m_spellProto->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED && !m_target->IsSitState())
977 m_target->SetStandState(UNIT_STAND_STATE_SIT);
979 // register aura diminishing on apply
980 if (getDiminishGroup() != DIMINISHING_NONE )
981 m_target->ApplyDiminishingAura(getDiminishGroup(),true);
983 // Update Seals information
984 if (IsSealSpell(m_spellProto))
985 m_target->ModifyAuraState(AURA_STATE_JUDGEMENT, true);
987 // Conflagrate aura state on Immolate
988 if (m_spellProto->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellProto->SpellFamilyFlags & 4)
989 m_target->ModifyAuraState(AURA_STATE_IMMOLATE, true);
991 // Faerie Fire (druid versions)
992 if (m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && m_spellProto->SpellFamilyFlags & 0x0000000000000400LL)
993 m_target->ModifyAuraState(AURA_STATE_FAERIE_FIRE, true);
995 // Victorious
996 if (m_spellProto->SpellFamilyName == SPELLFAMILY_WARRIOR && m_spellProto->SpellFamilyFlags & 0x0004000000000000LL)
997 m_target->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH, true);
999 // Swiftmend state on Regrowth & Rejuvenation
1000 if (m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && m_spellProto->SpellFamilyFlags & 0x50 )
1001 m_target->ModifyAuraState(AURA_STATE_SWIFTMEND, true);
1003 // Deadly poison aura state
1004 if(m_spellProto->SpellFamilyName == SPELLFAMILY_ROGUE && m_spellProto->SpellFamilyFlags & 0x10000)
1005 m_target->ModifyAuraState(AURA_STATE_DEADLY_POISON, true);
1007 // Enrage aura state
1008 if(m_spellProto->Dispel == DISPEL_ENRAGE)
1009 m_target->ModifyAuraState(AURA_STATE_ENRAGE, true);
1014 void Aura::_RemoveAura()
1016 // Remove all triggered by aura spells vs unlimited duration
1017 // except same aura replace case
1018 if(m_removeMode!=AURA_REMOVE_BY_STACK)
1019 CleanupTriggeredSpells();
1021 Unit* caster = GetCaster();
1023 if(caster && IsPersistent())
1025 DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex());
1026 if (dynObj)
1027 dynObj->RemoveAffected(m_target);
1030 //passive auras do not get put in slots
1031 // Note: but totem can be not accessible for aura target in time remove (to far for find in grid)
1032 //if(m_isPassive && !(caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem()))
1033 // return;
1035 uint8 slot = GetAuraSlot();
1037 if(slot >= MAX_AURAS) // slot not set
1038 return;
1040 if(m_target->GetVisibleAura(slot) == 0)
1041 return;
1043 bool lastaura = true;
1045 // find other aura in same slot (current already removed from list)
1046 for(uint8 i = 0; i < 3; i++)
1048 Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), i);
1049 for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr)
1051 if(itr->second->GetAuraSlot()==slot)
1053 lastaura = false;
1054 break;
1057 if(!lastaura)
1058 break;
1061 // only remove icon when the last aura of the spell is removed (current aura already removed from list)
1062 if (lastaura)
1064 // unregister aura diminishing (and store last time)
1065 if (getDiminishGroup() != DIMINISHING_NONE )
1066 m_target->ApplyDiminishingAura(getDiminishGroup(),false);
1068 SetAura(true);
1069 SetAuraFlags(AFLAG_NONE);
1070 SetAuraLevel(0);
1071 SendAuraUpdate(true);
1073 // update for out of range group members
1074 m_target->UpdateAuraForGroup(slot);
1076 //*****************************************************
1077 // Update target aura state flag (at last aura remove)
1078 //*****************************************************
1079 // Enrage aura state
1080 if(m_spellProto->Dispel == DISPEL_ENRAGE)
1081 m_target->ModifyAuraState(AURA_STATE_ENRAGE, false);
1083 uint32 removeState = 0;
1084 switch(m_spellProto->SpellFamilyName)
1086 case SPELLFAMILY_PALADIN:
1087 if (IsSealSpell(m_spellProto))
1088 removeState = AURA_STATE_JUDGEMENT; // Update Seals information
1089 break;
1090 case SPELLFAMILY_WARLOCK:
1091 if(m_spellProto->SpellFamilyFlags & 4)
1092 removeState = AURA_STATE_IMMOLATE; // Conflagrate aura state
1093 break;
1094 case SPELLFAMILY_DRUID:
1095 if(m_spellProto->SpellFamilyFlags & 0x0000000000000400LL)
1096 removeState = AURA_STATE_FAERIE_FIRE; // Faerie Fire (druid versions)
1097 else if(m_spellProto->SpellFamilyFlags & 0x50)
1098 removeState = AURA_STATE_SWIFTMEND; // Swiftmend aura state
1099 break;
1100 case SPELLFAMILY_WARRIOR:
1101 if(m_spellProto->SpellFamilyFlags & 0x0004000000000000LL)
1102 removeState = AURA_STATE_WARRIOR_VICTORY_RUSH; // Victorious
1103 break;
1104 case SPELLFAMILY_ROGUE:
1105 if(m_spellProto->SpellFamilyFlags & 0x10000)
1106 removeState = AURA_STATE_DEADLY_POISON; // Deadly poison aura state
1107 break;
1108 case SPELLFAMILY_HUNTER:
1109 if(m_spellProto->SpellFamilyFlags & 0x1000000000000000LL)
1110 removeState = AURA_STATE_FAERIE_FIRE; // Sting (hunter versions)
1113 // Remove state (but need check other auras for it)
1114 if (removeState)
1116 bool found = false;
1117 Unit::AuraMap& Auras = m_target->GetAuras();
1118 for(Unit::AuraMap::iterator i = Auras.begin(); i != Auras.end(); ++i)
1120 SpellEntry const *auraSpellInfo = (*i).second->GetSpellProto();
1121 if(auraSpellInfo->SpellFamilyName == m_spellProto->SpellFamilyName &&
1122 auraSpellInfo->SpellFamilyFlags == m_spellProto->SpellFamilyFlags )
1124 found = true;
1125 break;
1128 // this has been last aura
1129 if(!found)
1130 m_target->ModifyAuraState(AuraState(removeState), false);
1133 // reset cooldown state for spells
1134 if(caster && caster->GetTypeId() == TYPEID_PLAYER)
1136 if ( GetSpellProto()->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE )
1137 // note: item based cooldowns and cooldown spell mods with charges ignored (unknown existed cases)
1138 ((Player*)caster)->SendCooldownEvent(GetSpellProto());
1143 void Aura::SendAuraUpdate(bool remove)
1145 WorldPacket data(SMSG_AURA_UPDATE);
1146 data.append(m_target->GetPackGUID());
1147 data << uint8(GetAuraSlot());
1148 data << uint32(remove ? 0 : GetId());
1150 if(remove)
1152 m_target->SendMessageToSet(&data, true);
1153 return;
1156 uint8 auraFlags = GetAuraFlags();
1157 data << uint8(auraFlags);
1158 data << uint8(GetAuraLevel());
1159 data << uint8(m_procCharges ? m_procCharges : m_stackAmount);
1161 if(!(auraFlags & AFLAG_NOT_CASTER))
1163 data << uint8(0); // pguid
1166 if(auraFlags & AFLAG_DURATION)
1168 data << uint32(GetAuraMaxDuration());
1169 data << uint32(GetAuraDuration());
1172 m_target->SendMessageToSet(&data, true);
1175 void Aura::SetStackAmount(uint8 stackAmount)
1177 if (stackAmount != m_stackAmount)
1179 Unit *target = GetTarget();
1180 Unit *caster = GetCaster();
1181 if (!target || !caster)
1182 return;
1183 m_stackAmount = stackAmount;
1184 int32 amount = m_stackAmount * caster->CalculateSpellDamage(m_spellProto, m_effIndex, m_currentBasePoints, target);
1185 // Reapply if amount change
1186 if (amount!=m_modifier.m_amount)
1188 ApplyModifier(false, true);
1189 m_modifier.m_amount = amount;
1190 ApplyModifier(true, true);
1193 RefreshAura();
1196 bool Aura::modStackAmount(int32 num)
1198 // Can`t mod
1199 if (!m_spellProto->StackAmount)
1200 return true;
1202 // Modify stack but limit it
1203 int32 stackAmount = m_stackAmount + num;
1204 if (stackAmount > m_spellProto->StackAmount)
1205 stackAmount = m_spellProto->StackAmount;
1206 else if (stackAmount <=0) // Last aura from stack removed
1208 m_stackAmount = 0;
1209 return true; // need remove aura
1212 // Update stack amount
1213 SetStackAmount(stackAmount);
1214 return false;
1217 void Aura::RefreshAura()
1219 m_duration = m_maxduration;
1220 SendAuraUpdate(false);
1223 bool Aura::isAffectedOnSpell(SpellEntry const *spell) const
1225 // Check family name
1226 if (spell->SpellFamilyName != m_spellProto->SpellFamilyName)
1227 return false;
1228 // Check EffectClassMask
1229 uint32 const *ptr = getAuraSpellClassMask();
1230 if (((uint64*)ptr)[0] & spell->SpellFamilyFlags)
1231 return true;
1232 if (ptr[2] & spell->SpellFamilyFlags2)
1233 return true;
1234 return false;
1237 /*********************************************************/
1238 /*** BASIC AURA FUNCTION ***/
1239 /*********************************************************/
1240 void Aura::HandleAddModifier(bool apply, bool Real)
1242 if(m_target->GetTypeId() != TYPEID_PLAYER || !Real)
1243 return;
1245 if(m_modifier.m_miscvalue >= MAX_SPELLMOD)
1246 return;
1248 if (apply)
1250 // Add custom charges for some mod aura
1251 switch (m_spellProto->Id)
1253 case 17941: // Shadow Trance
1254 case 22008: // Netherwind Focus
1255 case 31834: // Light's Grace
1256 case 34754: // Clearcasting
1257 case 34936: // Backlash
1258 case 48108: // Hot Streak
1259 case 51124: // Killing Machine
1260 case 54741: // Firestarter
1261 case 57761: // Fireball!
1262 SetAuraCharges(1);
1263 break;
1266 SpellModifier *mod = new SpellModifier;
1267 mod->op = SpellModOp(m_modifier.m_miscvalue);
1268 mod->value = m_modifier.m_amount;
1269 mod->type = SpellModType(m_modifier.m_auraname); // SpellModType value == spell aura types
1270 mod->spellId = GetId();
1272 uint32 const *ptr;
1273 SpellAffectEntry const *spellAffect = spellmgr.GetSpellAffect(GetId(), m_effIndex);
1274 if (spellAffect)
1275 ptr = &spellAffect->SpellClassMask[0];
1276 else
1278 switch (m_effIndex)
1280 case 0: ptr = &m_spellProto->EffectSpellClassMaskA[0]; break;
1281 case 1: ptr = &m_spellProto->EffectSpellClassMaskB[0]; break;
1282 case 2: ptr = &m_spellProto->EffectSpellClassMaskC[0]; break;
1283 default:
1284 return;
1288 mod->mask = (uint64)ptr[0] | (uint64)ptr[1]<<32;
1289 mod->mask2= (uint64)ptr[2];
1290 mod->charges = m_procCharges;
1292 m_spellmod = mod;
1295 uint64 spellFamilyMask = m_spellmod->mask;
1297 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
1299 // reapply some passive spells after add/remove related spellmods
1300 if(m_spellProto->SpellFamilyName==SPELLFAMILY_WARRIOR && (spellFamilyMask & 0x0000100000000000LL))
1302 m_target->RemoveAurasDueToSpell(45471);
1304 if(apply)
1305 m_target->CastSpell(m_target,45471,true);
1308 void Aura::HandleAddTargetTrigger(bool apply, bool /*Real*/)
1310 // Use SpellModifier structure for check
1311 // used only fields:
1312 // spellId, mask, mask2
1313 if (apply)
1315 SpellModifier *mod = new SpellModifier;
1316 mod->spellId = GetId();
1318 uint32 const *ptr;
1319 SpellAffectEntry const *spellAffect = spellmgr.GetSpellAffect(GetId(), m_effIndex);
1320 if (spellAffect)
1321 ptr = &spellAffect->SpellClassMask[0];
1322 else
1324 switch (m_effIndex)
1326 case 0: ptr = &m_spellProto->EffectSpellClassMaskA[0]; break;
1327 case 1: ptr = &m_spellProto->EffectSpellClassMaskB[0]; break;
1328 case 2: ptr = &m_spellProto->EffectSpellClassMaskC[0]; break;
1329 default:
1330 return;
1334 mod->mask = (uint64)ptr[0] | (uint64)ptr[1]<<32;
1335 mod->mask2= (uint64)ptr[2];
1336 m_spellmod = mod;
1338 else
1340 delete m_spellmod;
1341 m_spellmod = NULL;
1345 void Aura::TriggerSpell()
1347 Unit* caster = GetCaster();
1348 Unit* target = GetTriggerTarget();
1350 if(!caster || !target)
1351 return;
1353 // generic casting code with custom spells and target/caster customs
1354 uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex];
1356 SpellEntry const *triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id);
1357 SpellEntry const *auraSpellInfo = GetSpellProto();
1358 uint32 auraId = auraSpellInfo->Id;
1360 // specific code for cases with no trigger spell provided in field
1361 if (triggeredSpellInfo == NULL)
1363 switch(auraSpellInfo->SpellFamilyName)
1365 case SPELLFAMILY_GENERIC:
1367 switch(auraId)
1369 // Firestone Passive (1-5 ranks)
1370 case 758:
1371 case 17945:
1372 case 17947:
1373 case 17949:
1374 case 27252:
1376 if (caster->GetTypeId()!=TYPEID_PLAYER)
1377 return;
1378 Item* item = ((Player*)caster)->GetWeaponForAttack(BASE_ATTACK);
1379 if (!item)
1380 return;
1381 uint32 enchant_id = 0;
1382 switch (GetId())
1384 case 758: enchant_id = 1803; break; // Rank 1
1385 case 17945: enchant_id = 1823; break; // Rank 2
1386 case 17947: enchant_id = 1824; break; // Rank 3
1387 case 17949: enchant_id = 1825; break; // Rank 4
1388 case 27252: enchant_id = 2645; break; // Rank 5
1389 default:
1390 return;
1392 // remove old enchanting before applying new
1393 ((Player*)caster)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,false);
1394 item->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, m_modifier.periodictime+1000, 0);
1395 // add new enchanting
1396 ((Player*)caster)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,true);
1397 return;
1399 // // Periodic Mana Burn
1400 // case 812: break;
1401 // // Polymorphic Ray
1402 // case 6965: break;
1403 // // Fire Nova (1-7 ranks)
1404 // case 8350:
1405 // case 8508:
1406 // case 8509:
1407 // case 11312:
1408 // case 11313:
1409 // case 25540:
1410 // case 25544:
1411 // break;
1412 // Thaumaturgy Channel
1413 case 9712: trigger_spell_id = 21029; break;
1414 // // Egan's Blaster
1415 // case 17368: break;
1416 // // Haunted
1417 // case 18347: break;
1418 // // Ranshalla Waiting
1419 // case 18953: break;
1420 // // Inferno
1421 // case 19695: break;
1422 // // Frostwolf Muzzle DND
1423 // case 21794: break;
1424 // // Alterac Ram Collar DND
1425 // case 21866: break;
1426 // // Celebras Waiting
1427 // case 21916: break;
1428 // Brood Affliction: Bronze
1429 case 23170:
1431 m_target->CastSpell(m_target, 23171, true, 0, this);
1432 return;
1434 // // Mark of Frost
1435 // case 23184: break;
1436 // Restoration
1437 case 23493:
1439 int32 heal = caster->GetMaxHealth() / 10;
1440 caster->DealHeal(caster, heal, auraSpellInfo);
1442 int32 mana = caster->GetMaxPower(POWER_MANA);
1443 if (mana)
1445 mana /= 10;
1446 caster->ModifyPower( POWER_MANA, mana );
1447 caster->SendEnergizeSpellLog(caster, 23493, mana, POWER_MANA);
1449 return;
1451 // // Stoneclaw Totem Passive TEST
1452 // case 23792: break;
1453 // // Axe Flurry
1454 // case 24018: break;
1455 // // Mark of Arlokk
1456 // case 24210: break;
1457 // // Restoration
1458 // case 24379: break;
1459 // // Happy Pet
1460 // case 24716: break;
1461 // // Dream Fog
1462 // case 24780: break;
1463 // // Cannon Prep
1464 // case 24832: break;
1465 // // Shadow Bolt Whirl
1466 // case 24834: break;
1467 // // Stink Trap
1468 // case 24918: break;
1469 // // Mark of Nature
1470 // case 25041: break;
1471 // // Agro Drones
1472 // case 25152: break;
1473 // // Consume
1474 // case 25371: break;
1475 // // Pain Spike
1476 // case 25572: break;
1477 // // Rotate 360
1478 // case 26009: break;
1479 // // Rotate -360
1480 // case 26136: break;
1481 // // Consume
1482 // case 26196: break;
1483 // // Berserk
1484 // case 26615: break;
1485 // // Defile
1486 // case 27177: break;
1487 // // Teleport: IF/UC
1488 // case 27601: break;
1489 // // Five Fat Finger Exploding Heart Technique
1490 // case 27673: break;
1491 // // Nitrous Boost
1492 // case 27746: break;
1493 // // Steam Tank Passive
1494 // case 27747: break;
1495 // Frost Blast
1496 case 27808:
1498 int32 bpDamage = target->GetMaxHealth()*26/100;
1499 caster->CastCustomSpell(target,29879,&bpDamage,NULL,NULL,true,NULL,this);
1500 return;
1502 // // Detonate Mana
1503 // case 27819: break;
1504 // // Controller Timer
1505 // case 28095: break;
1506 // // Stalagg Chain
1507 // case 28096: break;
1508 // // Stalagg Tesla Passive
1509 // case 28097: break;
1510 // // Feugen Tesla Passive
1511 // case 28109: break;
1512 // // Feugen Chain
1513 // case 28111: break;
1514 // // Mark of Didier
1515 // case 28114: break;
1516 // // Communique Timer, camp
1517 // case 28346: break;
1518 // // Icebolt
1519 // case 28522: break;
1520 // // Silithyst
1521 // case 29519: break;
1522 // Inoculate Nestlewood Owlkin
1523 case 29528:
1524 if(target->GetTypeId()!=TYPEID_UNIT)// prevent error reports in case ignored player target
1525 return;
1526 break;
1527 // // Overload
1528 // case 29768: break;
1529 // // Return Fire
1530 // case 29788: break;
1531 // // Return Fire
1532 // case 29793: break;
1533 // // Return Fire
1534 // case 29794: break;
1535 // // Guardian of Icecrown Passive
1536 // case 29897: break;
1537 // Feed Captured Animal
1538 case 29917: trigger_spell_id = 29916; break;
1539 // // Flame Wreath
1540 // case 29946: break;
1541 // // Flame Wreath
1542 // case 29947: break;
1543 // // Mind Exhaustion Passive
1544 // case 30025: break;
1545 // // Nether Beam - Serenity
1546 // case 30401: break;
1547 // Extract Gas
1548 case 30427:
1550 // move loot to player inventory and despawn target
1551 if(caster->GetTypeId() ==TYPEID_PLAYER &&
1552 target->GetTypeId() == TYPEID_UNIT &&
1553 ((Creature*)target)->GetCreatureInfo()->type == CREATURE_TYPE_GAS_CLOUD)
1555 Player* player = (Player*)caster;
1556 Creature* creature = (Creature*)target;
1557 // missing lootid has been reported on startup - just return
1558 if (!creature->GetCreatureInfo()->SkinLootId)
1559 return;
1561 player->AutoStoreLoot(creature->GetCreatureInfo()->SkinLootId,LootTemplates_Skinning,true);
1563 creature->setDeathState(JUST_DIED);
1564 creature->RemoveCorpse();
1565 creature->SetHealth(0); // just for nice GM-mode view
1567 return;
1569 // Quake
1570 case 30576: trigger_spell_id = 30571; break;
1571 // // Burning Maul
1572 // case 30598: break;
1573 // // Regeneration
1574 // case 30799:
1575 // case 30800:
1576 // case 30801:
1577 // break;
1578 // // Despawn Self - Smoke cloud
1579 // case 31269: break;
1580 // // Time Rift Periodic
1581 // case 31320: break;
1582 // // Corrupt Medivh
1583 // case 31326: break;
1584 // Doom
1585 case 31347:
1587 m_target->CastSpell(m_target,31350,true);
1588 m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
1589 return;
1591 // Spellcloth
1592 case 31373:
1594 // Summon Elemental after create item
1595 caster->SummonCreature(17870, 0, 0, 0, caster->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0);
1596 return;
1598 // // Bloodmyst Tesla
1599 // case 31611: break;
1600 // // Doomfire
1601 // case 31944: break;
1602 // // Teleport Test
1603 // case 32236: break;
1604 // // Earthquake
1605 // case 32686: break;
1606 // // Possess
1607 // case 33401: break;
1608 // // Draw Shadows
1609 // case 33563: break;
1610 // // Murmur's Touch
1611 // case 33711: break;
1612 // Flame Quills
1613 case 34229:
1615 // cast 24 spells 34269-34289, 34314-34316
1616 for(uint32 spell_id = 34269; spell_id != 34290; ++spell_id)
1617 caster->CastSpell(m_target,spell_id,true);
1618 for(uint32 spell_id = 34314; spell_id != 34317; ++spell_id)
1619 caster->CastSpell(m_target,spell_id,true);
1620 return;
1622 // // Gravity Lapse
1623 // case 34480: break;
1624 // // Tornado
1625 // case 34683: break;
1626 // // Frostbite Rotate
1627 // case 34748: break;
1628 // // Arcane Flurry
1629 // case 34821: break;
1630 // // Interrupt Shutdown
1631 // case 35016: break;
1632 // // Interrupt Shutdown
1633 // case 35176: break;
1634 // // Inferno
1635 // case 35268: break;
1636 // // Salaadin's Tesla
1637 // case 35515: break;
1638 // // Ethereal Channel (Red)
1639 // case 35518: break;
1640 // // Nether Vapor
1641 // case 35879: break;
1642 // // Dark Portal Storm
1643 // case 36018: break;
1644 // // Burning Maul
1645 // case 36056: break;
1646 // // Living Grove Defender Lifespan
1647 // case 36061: break;
1648 // // Professor Dabiri Talks
1649 // case 36064: break;
1650 // // Kael Gaining Power
1651 // case 36091: break;
1652 // // They Must Burn Bomb Aura
1653 // case 36344: break;
1654 // // They Must Burn Bomb Aura (self)
1655 // case 36350: break;
1656 // // Stolen Ravenous Ravager Egg
1657 // case 36401: break;
1658 // // Activated Cannon
1659 // case 36410: break;
1660 // // Stolen Ravenous Ravager Egg
1661 // case 36418: break;
1662 // // Enchanted Weapons
1663 // case 36510: break;
1664 // // Cursed Scarab Periodic
1665 // case 36556: break;
1666 // // Cursed Scarab Despawn Periodic
1667 // case 36561: break;
1668 // // Vision Guide
1669 // case 36573: break;
1670 // // Cannon Charging (platform)
1671 // case 36785: break;
1672 // // Cannon Charging (self)
1673 // case 36860: break;
1674 // Remote Toy
1675 case 37027: trigger_spell_id = 37029; break;
1676 // // Mark of Death
1677 // case 37125: break;
1678 // // Arcane Flurry
1679 // case 37268: break;
1680 // // Spout
1681 // case 37429: break;
1682 // // Spout
1683 // case 37430: break;
1684 // // Karazhan - Chess NPC AI, Snapshot timer
1685 // case 37440: break;
1686 // // Karazhan - Chess NPC AI, action timer
1687 // case 37504: break;
1688 // // Karazhan - Chess: Is Square OCCUPIED aura (DND)
1689 // case 39400: break;
1690 // // Banish
1691 // case 37546: break;
1692 // // Shriveling Gaze
1693 // case 37589: break;
1694 // // Fake Aggro Radius (2 yd)
1695 // case 37815: break;
1696 // // Corrupt Medivh
1697 // case 37853: break;
1698 // Eye of Grillok
1699 case 38495:
1701 m_target->CastSpell(m_target, 38530, true);
1702 return;
1704 // Absorb Eye of Grillok (Zezzak's Shard)
1705 case 38554:
1707 if(m_target->GetTypeId() != TYPEID_UNIT)
1708 return;
1710 caster->CastSpell(caster, 38495, true);
1712 Creature* creatureTarget = (Creature*)m_target;
1714 creatureTarget->setDeathState(JUST_DIED);
1715 creatureTarget->RemoveCorpse();
1716 creatureTarget->SetHealth(0); // just for nice GM-mode view
1717 return;
1719 // // Magic Sucker Device timer
1720 // case 38672: break;
1721 // // Tomb Guarding Charging
1722 // case 38751: break;
1723 // // Murmur's Touch
1724 // case 38794: break;
1725 // // Activate Nether-wraith Beacon (31742 Nether-wraith Beacon item)
1726 // case 39105: break;
1727 // // Drain World Tree Visual
1728 // case 39140: break;
1729 // // Quest - Dustin's Undead Dragon Visual aura
1730 // case 39259: break;
1731 // // Hellfire - The Exorcism, Jules releases darkness, aura
1732 // case 39306: break;
1733 // // Inferno
1734 // case 39346: break;
1735 // // Enchanted Weapons
1736 // case 39489: break;
1737 // // Shadow Bolt Whirl
1738 // case 39630: break;
1739 // // Shadow Bolt Whirl
1740 // case 39634: break;
1741 // // Shadow Inferno
1742 // case 39645: break;
1743 // Tear of Azzinoth Summon Channel - it's not really supposed to do anything,and this only prevents the console spam
1744 case 39857: trigger_spell_id = 39856; break;
1745 // // Soulgrinder Ritual Visual (Smashed)
1746 // case 39974: break;
1747 // // Simon Game Pre-game timer
1748 // case 40041: break;
1749 // // Knockdown Fel Cannon: The Aggro Check Aura
1750 // case 40113: break;
1751 // // Spirit Lance
1752 // case 40157: break;
1753 // // Demon Transform 2
1754 // case 40398: break;
1755 // // Demon Transform 1
1756 // case 40511: break;
1757 // // Ancient Flames
1758 // case 40657: break;
1759 // // Ethereal Ring Cannon: Cannon Aura
1760 // case 40734: break;
1761 // // Cage Trap
1762 // case 40760: break;
1763 // // Random Periodic
1764 // case 40867: break;
1765 // // Prismatic Shield
1766 // case 40879: break;
1767 // // Aura of Desire
1768 // case 41350: break;
1769 // // Dementia
1770 // case 41404: break;
1771 // // Chaos Form
1772 // case 41629: break;
1773 // // Alert Drums
1774 // case 42177: break;
1775 // // Spout
1776 // case 42581: break;
1777 // // Spout
1778 // case 42582: break;
1779 // // Return to the Spirit Realm
1780 // case 44035: break;
1781 // // Curse of Boundless Agony
1782 // case 45050: break;
1783 // // Earthquake
1784 // case 46240: break;
1785 // Personalized Weather
1786 case 46736: trigger_spell_id = 46737; break;
1787 // // Stay Submerged
1788 // case 46981: break;
1789 // // Dragonblight Ram
1790 // case 47015: break;
1791 // // Party G.R.E.N.A.D.E.
1792 // case 51510: break;
1793 default:
1794 break;
1796 break;
1798 case SPELLFAMILY_MAGE:
1800 switch(auraId)
1802 // Invisibility
1803 case 66:
1804 // Here need periodic triger reducing threat spell (or do it manually)
1805 return;
1806 default:
1807 break;
1809 break;
1811 // case SPELLFAMILY_WARRIOR:
1812 // {
1813 // switch(auraId)
1814 // {
1815 // // Wild Magic
1816 // case 23410: break;
1817 // // Corrupted Totems
1818 // case 23425: break;
1819 // default:
1820 // break;
1821 // }
1822 // break;
1823 // }
1824 // case SPELLFAMILY_PRIEST:
1825 // {
1826 // switch(auraId)
1827 // {
1828 // // Blue Beam
1829 // case 32930: break;
1830 // // Fury of the Dreghood Elders
1831 // case 35460: break;
1832 // default:
1833 // break;
1834 // }
1835 // break;
1836 // }
1837 case SPELLFAMILY_DRUID:
1839 switch(auraId)
1841 // Cat Form
1842 // trigger_spell_id not set and unknown effect triggered in this case, ignoring for while
1843 case 768:
1844 return;
1845 // Frenzied Regeneration
1846 case 22842:
1847 case 22895:
1848 case 22896:
1849 case 26999:
1851 int32 LifePerRage = GetModifier()->m_amount;
1853 int32 lRage = m_target->GetPower(POWER_RAGE);
1854 if(lRage > 100) // rage stored as rage*10
1855 lRage = 100;
1856 m_target->ModifyPower(POWER_RAGE, -lRage);
1857 int32 FRTriggerBasePoints = int32(lRage*LifePerRage/10);
1858 m_target->CastCustomSpell(m_target,22845,&FRTriggerBasePoints,NULL,NULL,true,NULL,this);
1859 return;
1861 default:
1862 break;
1864 break;
1867 // case SPELLFAMILY_HUNTER:
1868 // {
1869 // switch(auraId)
1870 // {
1871 // //Frost Trap Aura
1872 // case 13810:
1873 // return;
1874 // //Rizzle's Frost Trap
1875 // case 39900:
1876 // return;
1877 // // Tame spells
1878 // case 19597: // Tame Ice Claw Bear
1879 // case 19676: // Tame Snow Leopard
1880 // case 19677: // Tame Large Crag Boar
1881 // case 19678: // Tame Adult Plainstrider
1882 // case 19679: // Tame Prairie Stalker
1883 // case 19680: // Tame Swoop
1884 // case 19681: // Tame Dire Mottled Boar
1885 // case 19682: // Tame Surf Crawler
1886 // case 19683: // Tame Armored Scorpid
1887 // case 19684: // Tame Webwood Lurker
1888 // case 19685: // Tame Nightsaber Stalker
1889 // case 19686: // Tame Strigid Screecher
1890 // case 30100: // Tame Crazed Dragonhawk
1891 // case 30103: // Tame Elder Springpaw
1892 // case 30104: // Tame Mistbat
1893 // case 30647: // Tame Barbed Crawler
1894 // case 30648: // Tame Greater Timberstrider
1895 // case 30652: // Tame Nightstalker
1896 // return;
1897 // default:
1898 // break;
1899 // }
1900 // break;
1901 // }
1902 case SPELLFAMILY_SHAMAN:
1904 switch(auraId)
1906 // Lightning Shield (The Earthshatterer set trigger after cast Lighting Shield)
1907 case 28820:
1909 // Need remove self if Lightning Shield not active
1910 Unit::AuraMap const& auras = target->GetAuras();
1911 for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
1913 SpellEntry const* spell = itr->second->GetSpellProto();
1914 if( spell->SpellFamilyName == SPELLFAMILY_SHAMAN &&
1915 spell->SpellFamilyFlags & 0x0000000000000400L)
1916 return;
1918 target->RemoveAurasDueToSpell(28820);
1919 return;
1921 // Totemic Mastery (Skyshatter Regalia (Shaman Tier 6) - bonus)
1922 case 38443:
1924 bool all = true;
1925 for(int i = 0; i < MAX_TOTEM; ++i)
1927 if(!caster->m_TotemSlot[i])
1929 all = false;
1930 break;
1934 if(all)
1935 caster->CastSpell(caster,38437,true);
1936 else
1937 caster->RemoveAurasDueToSpell(38437);
1938 return;
1940 default:
1941 break;
1943 break;
1945 default:
1946 break;
1949 // Reget trigger spell proto
1950 triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id);
1952 else
1954 // Spell exist but require custom code
1955 switch(auraId)
1957 // Curse of Idiocy
1958 case 1010:
1960 // TODO: spell casted by result in correct way mostly
1961 // BUT:
1962 // 1) target show casting at each triggered cast: target don't must show casting animation for any triggered spell
1963 // but must show affect apply like item casting
1964 // 2) maybe aura must be replace by new with accumulative stat mods instead stacking
1966 // prevent cast by triggered auras
1967 if(m_caster_guid == m_target->GetGUID())
1968 return;
1970 // stop triggering after each affected stats lost > 90
1971 int32 intelectLoss = 0;
1972 int32 spiritLoss = 0;
1974 Unit::AuraList const& mModStat = m_target->GetAurasByType(SPELL_AURA_MOD_STAT);
1975 for(Unit::AuraList::const_iterator i = mModStat.begin(); i != mModStat.end(); ++i)
1977 if ((*i)->GetId() == 1010)
1979 switch((*i)->GetModifier()->m_miscvalue)
1981 case STAT_INTELLECT: intelectLoss += (*i)->GetModifier()->m_amount; break;
1982 case STAT_SPIRIT: spiritLoss += (*i)->GetModifier()->m_amount; break;
1983 default: break;
1988 if(intelectLoss <= -90 && spiritLoss <= -90)
1989 return;
1991 caster = target;
1992 break;
1994 // Mana Tide
1995 case 16191:
1997 caster->CastCustomSpell(target, trigger_spell_id, &m_modifier.m_amount, NULL, NULL, true, NULL, this);
1998 return;
2003 // All ok cast by default case
2004 if(triggeredSpellInfo)
2005 caster->CastSpell(target, triggeredSpellInfo, true, 0, this);
2006 else if(target->GetTypeId()!=TYPEID_UNIT || !Script->EffectDummyCreature(caster, GetId(), GetEffIndex(), (Creature*)target))
2007 sLog.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex());
2010 void Aura::TriggerSpellWithValue()
2012 Unit* caster = GetCaster();
2013 Unit* target = GetTriggerTarget();
2015 if(!caster || !target)
2016 return;
2018 // generic casting code with custom spells and target/caster customs
2019 uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex];
2020 int32 basepoints0 = this->GetModifier()->m_amount;
2022 caster->CastCustomSpell(target, trigger_spell_id, &basepoints0, 0, 0, true, 0, this);
2025 /*********************************************************/
2026 /*** AURA EFFECTS ***/
2027 /*********************************************************/
2029 void Aura::HandleAuraDummy(bool apply, bool Real)
2031 // spells required only Real aura add/remove
2032 if(!Real)
2033 return;
2035 Unit* caster = GetCaster();
2037 // AT APPLY
2038 if(apply)
2040 switch(GetId())
2042 case 1515: // Tame beast
2043 // FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness
2044 if( caster && m_target->CanHaveThreatList())
2045 m_target->AddThreat(caster, 10.0f);
2046 return;
2047 case 13139: // net-o-matic
2048 // root to self part of (root_target->charge->root_self sequence
2049 if(caster)
2050 caster->CastSpell(caster,13138,true,NULL,this);
2051 return;
2052 case 39850: // Rocket Blast
2053 if(roll_chance_i(20)) // backfire stun
2054 m_target->CastSpell(m_target, 51581, true, NULL, this);
2055 return;
2056 case 43873: // Headless Horseman Laugh
2057 m_target->PlayDistanceSound(11965);
2058 return;
2059 case 46354: // Blood Elf Illusion
2060 if(caster)
2062 switch(caster->getGender())
2064 case GENDER_FEMALE:
2065 caster->CastSpell(m_target,46356,true,NULL,this);
2066 break;
2067 case GENDER_MALE:
2068 caster->CastSpell(m_target,46355,true,NULL,this);
2069 break;
2070 default:
2071 break;
2074 return;
2075 case 46699: // Requires No Ammo
2076 if(m_target->GetTypeId()==TYPEID_PLAYER)
2077 ((Player*)m_target)->RemoveAmmo(); // not use ammo and not allow use
2078 return;
2081 // Earth Shield
2082 if ( caster && GetSpellProto()->SpellFamilyName == SPELLFAMILY_SHAMAN && (GetSpellProto()->SpellFamilyFlags & 0x40000000000LL))
2084 // prevent double apply bonuses
2085 if(m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())
2086 m_modifier.m_amount = caster->SpellHealingBonus(m_target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE);
2087 return;
2090 // AT REMOVE
2091 else
2093 if( m_target->GetTypeId() == TYPEID_PLAYER &&
2094 ( GetSpellProto()->Effect[0]==72 || GetSpellProto()->Effect[0]==6 &&
2095 ( GetSpellProto()->EffectApplyAuraName[0]==1 || GetSpellProto()->EffectApplyAuraName[0]==128 ) ) )
2097 // spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425
2098 ((Player*)m_target)->SetFarSightGUID(0);
2099 WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0);
2100 ((Player*)m_target)->GetSession()->SendPacket(&data);
2101 return;
2104 if( (IsQuestTameSpell(GetId())) && caster && caster->isAlive() && m_target->isAlive())
2106 uint32 finalSpelId = 0;
2107 switch(GetId())
2109 case 19548: finalSpelId = 19597; break;
2110 case 19674: finalSpelId = 19677; break;
2111 case 19687: finalSpelId = 19676; break;
2112 case 19688: finalSpelId = 19678; break;
2113 case 19689: finalSpelId = 19679; break;
2114 case 19692: finalSpelId = 19680; break;
2115 case 19693: finalSpelId = 19684; break;
2116 case 19694: finalSpelId = 19681; break;
2117 case 19696: finalSpelId = 19682; break;
2118 case 19697: finalSpelId = 19683; break;
2119 case 19699: finalSpelId = 19685; break;
2120 case 19700: finalSpelId = 19686; break;
2121 case 30646: finalSpelId = 30647; break;
2122 case 30653: finalSpelId = 30648; break;
2123 case 30654: finalSpelId = 30652; break;
2124 case 30099: finalSpelId = 30100; break;
2125 case 30102: finalSpelId = 30103; break;
2126 case 30105: finalSpelId = 30104; break;
2129 if(finalSpelId)
2130 caster->CastSpell(m_target,finalSpelId,true,NULL,this);
2131 return;
2134 switch(GetId())
2136 case 2584: // Waiting to Resurrect
2138 // Waiting to resurrect spell cancel, we must remove player from resurrect queue
2139 if(m_target->GetTypeId() == TYPEID_PLAYER)
2140 if(BattleGround *bg = ((Player*)m_target)->GetBattleGround())
2141 bg->RemovePlayerFromResurrectQueue(m_target->GetGUID());
2142 return;
2144 case 45934: // Dark Fiend
2146 // Kill target if dispelled
2147 if (m_removeMode==AURA_REMOVE_BY_DISPEL)
2148 m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
2149 return;
2151 case 46308: // Burning Winds
2153 // casted only at creatures at spawn
2154 m_target->CastSpell(m_target,47287,true,NULL,this);
2155 return;
2159 if (caster && m_removeMode == AURA_REMOVE_BY_DEATH)
2161 // Stop caster Arcane Missle chanelling on death
2162 if (m_spellProto->SpellFamilyName == SPELLFAMILY_MAGE &&
2163 m_spellProto->SpellFamilyFlags&0x0000000000000800LL)
2165 caster->InterruptSpell(CURRENT_CHANNELED_SPELL);
2166 return;
2168 // Stop caster Penance chanelling on death
2169 if (m_spellProto->SpellFamilyName == SPELLFAMILY_PRIEST &&
2170 m_spellProto->SpellFamilyFlags2 & 0x00000080)
2172 caster->InterruptSpell(CURRENT_CHANNELED_SPELL);
2173 return;
2179 // AT APPLY & REMOVE
2181 switch(m_spellProto->SpellFamilyName)
2183 case SPELLFAMILY_GENERIC:
2185 switch(GetId())
2187 // Unstable Power
2188 case 24658:
2190 uint32 spellId = 24659;
2191 if (apply && caster)
2193 const SpellEntry *spell = sSpellStore.LookupEntry(spellId);
2194 if (!spell)
2195 return;
2197 for (int i=0; i < spell->StackAmount; ++i)
2198 caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID());
2199 return;
2201 m_target->RemoveAurasDueToSpell(spellId);
2202 return;
2204 // Restless Strength
2205 case 24661:
2207 uint32 spellId = 24662;
2208 if (apply && caster)
2210 const SpellEntry *spell = sSpellStore.LookupEntry(spellId);
2211 if (!spell)
2212 return;
2213 for (int i=0; i < spell->StackAmount; ++i)
2214 caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID());
2215 return;
2217 m_target->RemoveAurasDueToSpell(spellId);
2218 return;
2220 //Summon Fire Elemental
2221 case 40133:
2223 if (!caster)
2224 return;
2226 Unit *owner = caster->GetOwner();
2227 if (owner && owner->GetTypeId() == TYPEID_PLAYER)
2229 if(apply)
2230 owner->CastSpell(owner,8985,true);
2231 else
2232 ((Player*)owner)->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true);
2234 return;
2236 //Summon Earth Elemental
2237 case 40132 :
2239 if (!caster)
2240 return;
2242 Unit *owner = caster->GetOwner();
2243 if (owner && owner->GetTypeId() == TYPEID_PLAYER)
2245 if(apply)
2246 owner->CastSpell(owner,19704,true);
2247 else
2248 ((Player*)owner)->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true);
2250 return;
2252 // LK Intro VO (1)
2253 case 58204:
2254 if(m_target->GetTypeId() == TYPEID_PLAYER)
2256 // Play part 1
2257 if(apply)
2258 m_target->PlayDirectSound(14970, (Player *)m_target);
2259 // continue in 58205
2260 else
2261 m_target->CastSpell(m_target, 58205, true);
2263 return;
2264 // LK Intro VO (2)
2265 case 58205:
2266 if(m_target->GetTypeId() == TYPEID_PLAYER)
2268 // Play part 2
2269 if(apply)
2270 m_target->PlayDirectSound(14971, (Player *)m_target);
2271 // Play part 3
2272 else
2273 m_target->PlayDirectSound(14972, (Player *)m_target);
2275 return;
2277 break;
2279 case SPELLFAMILY_MAGE:
2281 break;
2283 case SPELLFAMILY_PRIEST:
2285 // Pain and Suffering
2286 if( m_spellProto->SpellIconID == 2874 && m_target->GetTypeId()==TYPEID_PLAYER )
2288 if(apply)
2290 // Reduce backfire damage (dot damage) from Shadow Word: Death
2291 SpellModifier *mod = new SpellModifier;
2292 mod->op = SPELLMOD_DOT;
2293 mod->value = m_modifier.m_amount;
2294 mod->type = SPELLMOD_PCT;
2295 mod->spellId = GetId();
2296 mod->mask = 0x0000200000000000LL;
2297 mod->mask2= 0LL;
2298 m_spellmod = mod;
2300 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
2301 return;
2303 break;
2305 case SPELLFAMILY_DRUID:
2307 switch(GetId())
2309 case 34246: // Idol of the Emerald Queen
2310 case 60779: // Idol of Lush Moss
2312 if (m_target->GetTypeId() != TYPEID_PLAYER)
2313 return;
2315 if(apply)
2317 SpellModifier *mod = new SpellModifier;
2318 mod->op = SPELLMOD_DOT;
2319 mod->value = m_modifier.m_amount/7;
2320 mod->type = SPELLMOD_FLAT;
2321 mod->spellId = GetId();
2322 mod->mask = 0x001000000000LL;
2323 mod->mask2= 0LL;
2325 m_spellmod = mod;
2328 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
2329 return;
2331 case 61336: // Survival Instincts
2333 if(apply)
2335 if (!m_target->IsInFeralForm())
2336 return;
2338 int32 bp0 = int32(m_target->GetMaxHealth() * m_modifier.m_amount / 100);
2339 m_target->CastCustomSpell(m_target, 50322, &bp0, NULL, NULL, true);
2341 else
2342 m_target-> RemoveAurasDueToSpell(50322);
2343 return;
2347 // Lifebloom
2348 if ( GetSpellProto()->SpellFamilyFlags & 0x1000000000LL )
2350 if ( apply )
2352 if ( caster )
2353 // prevent double apply bonuses
2354 if(m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())
2355 m_modifier.m_amount = caster->SpellHealingBonus(m_target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE);
2357 else
2359 // Final heal only on dispelled or duration end
2360 if ( !(GetAuraDuration() <= 0 || m_removeMode==AURA_REMOVE_BY_DISPEL) )
2361 return;
2363 // have a look if there is still some other Lifebloom dummy aura
2364 Unit::AuraList auras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
2365 for(Unit::AuraList::iterator itr = auras.begin(); itr!=auras.end(); ++itr)
2366 if((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID &&
2367 (*itr)->GetSpellProto()->SpellFamilyFlags & 0x1000000000LL)
2368 return;
2370 // final heal
2371 if(m_target->IsInWorld() && m_stackAmount > 0)
2373 int32 amount = m_modifier.m_amount / m_stackAmount;
2374 m_target->CastCustomSpell(m_target,33778,&amount,NULL,NULL,true,NULL,this,GetCasterGUID());
2377 return;
2380 // Predatory Strikes
2381 if(m_target->GetTypeId()==TYPEID_PLAYER && GetSpellProto()->SpellIconID == 1563)
2383 ((Player*)m_target)->UpdateAttackPowerAndDamage();
2384 return;
2386 break;
2388 case SPELLFAMILY_HUNTER:
2390 // Improved Aspect of the Viper
2391 if( GetId()==38390 && m_target->GetTypeId()==TYPEID_PLAYER )
2393 if(apply)
2395 // + effect value for Aspect of the Viper
2396 SpellModifier *mod = new SpellModifier;
2397 mod->op = SPELLMOD_EFFECT1;
2398 mod->value = m_modifier.m_amount;
2399 mod->type = SPELLMOD_FLAT;
2400 mod->spellId = GetId();
2401 mod->mask = 0x4000000000000LL;
2402 mod->mask2= 0LL;
2404 m_spellmod = mod;
2407 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
2408 return;
2410 break;
2412 case SPELLFAMILY_SHAMAN:
2414 // Improved Weapon Totems
2415 if( GetSpellProto()->SpellIconID == 57 && m_target->GetTypeId()==TYPEID_PLAYER )
2417 if(apply)
2419 SpellModifier *mod = new SpellModifier;
2420 mod->op = SPELLMOD_EFFECT1;
2421 mod->value = m_modifier.m_amount;
2422 mod->type = SPELLMOD_PCT;
2423 mod->spellId = GetId();
2424 switch (m_effIndex)
2426 case 0:
2427 mod->mask = 0x00200000000LL; // Windfury Totem
2428 mod->mask2= 0LL;
2429 break;
2430 case 1:
2431 mod->mask = 0x00400000000LL; // Flametongue Totem
2432 mod->mask2= 0LL;
2433 break;
2436 m_spellmod = mod;
2439 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
2440 return;
2442 break;
2446 // pet auras
2447 if(PetAura const* petSpell = spellmgr.GetPetAura(GetId()))
2449 if(apply)
2450 m_target->AddPetAura(petSpell);
2451 else
2452 m_target->RemovePetAura(petSpell);
2453 return;
2456 if(GetEffIndex()==0 && m_target->GetTypeId()==TYPEID_PLAYER)
2458 SpellAreaForAreaMapBounds saBounds = spellmgr.GetSpellAreaForAuraMapBounds(GetId());
2459 if(saBounds.first != saBounds.second)
2461 uint32 zone, area;
2462 m_target->GetZoneAndAreaId(zone,area);
2464 for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
2466 // some auras remove at aura remove
2467 if(!itr->second->IsFitToRequirements((Player*)m_target,zone,area))
2468 m_target->RemoveAurasDueToSpell(itr->second->spellId);
2469 // some auras applied at aura apply
2470 else if(itr->second->autocast)
2472 if( !m_target->HasAura(itr->second->spellId,0) )
2473 m_target->CastSpell(m_target,itr->second->spellId,true);
2480 void Aura::HandleAuraMounted(bool apply, bool Real)
2482 // only at real add/remove aura
2483 if(!Real)
2484 return;
2486 if(apply)
2488 CreatureInfo const* ci = objmgr.GetCreatureTemplate(m_modifier.m_miscvalue);
2489 if(!ci)
2491 sLog.outErrorDb("AuraMounted: `creature_template`='%u' not found in database (only need it modelid)", m_modifier.m_miscvalue);
2492 return;
2495 uint32 team = 0;
2496 if (m_target->GetTypeId()==TYPEID_PLAYER)
2497 team = ((Player*)m_target)->GetTeam();
2499 uint32 display_id = objmgr.ChooseDisplayId(team,ci);
2500 CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id);
2501 if (minfo)
2502 display_id = minfo->modelid;
2504 m_target->Mount(display_id);
2506 else
2508 m_target->Unmount();
2512 void Aura::HandleAuraWaterWalk(bool apply, bool Real)
2514 // only at real add/remove aura
2515 if(!Real)
2516 return;
2518 WorldPacket data;
2519 if(apply)
2520 data.Initialize(SMSG_MOVE_WATER_WALK, 8+4);
2521 else
2522 data.Initialize(SMSG_MOVE_LAND_WALK, 8+4);
2523 data.append(m_target->GetPackGUID());
2524 data << uint32(0);
2525 m_target->SendMessageToSet(&data,true);
2528 void Aura::HandleAuraFeatherFall(bool apply, bool Real)
2530 // only at real add/remove aura
2531 if(!Real)
2532 return;
2534 WorldPacket data;
2535 if(apply)
2536 data.Initialize(SMSG_MOVE_FEATHER_FALL, 8+4);
2537 else
2538 data.Initialize(SMSG_MOVE_NORMAL_FALL, 8+4);
2539 data.append(m_target->GetPackGUID());
2540 data << (uint32)0;
2541 m_target->SendMessageToSet(&data,true);
2544 void Aura::HandleAuraHover(bool apply, bool Real)
2546 // only at real add/remove aura
2547 if(!Real)
2548 return;
2550 WorldPacket data;
2551 if(apply)
2552 data.Initialize(SMSG_MOVE_SET_HOVER, 8+4);
2553 else
2554 data.Initialize(SMSG_MOVE_UNSET_HOVER, 8+4);
2555 data.append(m_target->GetPackGUID());
2556 data << uint32(0);
2557 m_target->SendMessageToSet(&data,true);
2560 void Aura::HandleWaterBreathing(bool /*apply*/, bool /*Real*/)
2562 // update timers in client
2563 if(m_target->GetTypeId()==TYPEID_PLAYER)
2564 ((Player*)m_target)->UpdateMirrorTimers();
2567 void Aura::HandleAuraModShapeshift(bool apply, bool Real)
2569 if(!Real)
2570 return;
2572 uint32 modelid = 0;
2573 Powers PowerType = POWER_MANA;
2574 ShapeshiftForm form = ShapeshiftForm(m_modifier.m_miscvalue);
2575 switch(form)
2577 case FORM_CAT:
2578 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2579 modelid = 892;
2580 else
2581 modelid = 8571;
2582 PowerType = POWER_ENERGY;
2583 break;
2584 case FORM_TRAVEL:
2585 modelid = 632;
2586 break;
2587 case FORM_AQUA:
2588 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2589 modelid = 2428;
2590 else
2591 modelid = 2428;
2592 break;
2593 case FORM_BEAR:
2594 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2595 modelid = 2281;
2596 else
2597 modelid = 2289;
2598 PowerType = POWER_RAGE;
2599 break;
2600 case FORM_GHOUL:
2601 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2602 modelid = 10045;
2603 break;
2604 case FORM_DIREBEAR:
2605 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2606 modelid = 2281;
2607 else
2608 modelid = 2289;
2609 PowerType = POWER_RAGE;
2610 break;
2611 case FORM_CREATUREBEAR:
2612 modelid = 902;
2613 break;
2614 case FORM_GHOSTWOLF:
2615 modelid = 4613;
2616 break;
2617 case FORM_FLIGHT:
2618 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2619 modelid = 20857;
2620 else
2621 modelid = 20872;
2622 break;
2623 case FORM_MOONKIN:
2624 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2625 modelid = 15374;
2626 else
2627 modelid = 15375;
2628 break;
2629 case FORM_FLIGHT_EPIC:
2630 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2631 modelid = 21243;
2632 else
2633 modelid = 21244;
2634 break;
2635 case FORM_METAMORPHOSIS:
2636 modelid = 25277;
2637 break;
2638 case FORM_AMBIENT:
2639 case FORM_SHADOW:
2640 case FORM_STEALTH:
2641 break;
2642 case FORM_TREE:
2643 modelid = 864;
2644 break;
2645 case FORM_BATTLESTANCE:
2646 case FORM_BERSERKERSTANCE:
2647 case FORM_DEFENSIVESTANCE:
2648 PowerType = POWER_RAGE;
2649 break;
2650 case FORM_SPIRITOFREDEMPTION:
2651 modelid = 16031;
2652 break;
2653 default:
2654 sLog.outError("Auras: Unknown Shapeshift Type: %u", m_modifier.m_miscvalue);
2657 // remove polymorph before changing display id to keep new display id
2658 switch ( form )
2660 case FORM_CAT:
2661 case FORM_TREE:
2662 case FORM_TRAVEL:
2663 case FORM_AQUA:
2664 case FORM_BEAR:
2665 case FORM_DIREBEAR:
2666 case FORM_FLIGHT_EPIC:
2667 case FORM_FLIGHT:
2668 case FORM_MOONKIN:
2669 // remove movement affects
2670 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT);
2671 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED);
2673 // and polymorphic affects
2674 if(m_target->IsPolymorphed())
2675 m_target->RemoveAurasDueToSpell(m_target->getTransForm());
2676 break;
2677 default:
2678 break;
2681 if(apply)
2683 // remove other shapeshift before applying a new one
2684 if(m_target->m_ShapeShiftFormSpellId)
2685 m_target->RemoveAurasDueToSpell(m_target->m_ShapeShiftFormSpellId,this);
2687 m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, form);
2689 if(modelid > 0)
2690 m_target->SetDisplayId(modelid);
2692 if(PowerType != POWER_MANA)
2694 // reset power to default values only at power change
2695 if(m_target->getPowerType()!=PowerType)
2696 m_target->setPowerType(PowerType);
2698 switch(form)
2700 case FORM_CAT:
2701 case FORM_BEAR:
2702 case FORM_DIREBEAR:
2704 // get furor proc chance
2705 uint32 FurorChance = 0;
2706 Unit::AuraList const& mDummy = m_target->GetAurasByType(SPELL_AURA_DUMMY);
2707 for(Unit::AuraList::const_iterator i = mDummy.begin(); i != mDummy.end(); ++i)
2709 if ((*i)->GetSpellProto()->SpellIconID == 238)
2711 FurorChance = (*i)->GetModifier()->m_amount;
2712 break;
2716 if (m_modifier.m_miscvalue == FORM_CAT)
2718 m_target->SetPower(POWER_ENERGY,0);
2719 if(urand(1,100) <= FurorChance)
2720 m_target->CastSpell(m_target,17099,true,NULL,this);
2722 else
2724 m_target->SetPower(POWER_RAGE,0);
2725 if(urand(1,100) <= FurorChance)
2726 m_target->CastSpell(m_target,17057,true,NULL,this);
2728 break;
2730 case FORM_BATTLESTANCE:
2731 case FORM_DEFENSIVESTANCE:
2732 case FORM_BERSERKERSTANCE:
2734 uint32 Rage_val = 0;
2735 // Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch)
2736 if(m_target->GetTypeId() == TYPEID_PLAYER)
2738 PlayerSpellMap const& sp_list = ((Player *)m_target)->GetSpellMap();
2739 for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
2741 if(itr->second->state == PLAYERSPELL_REMOVED) continue;
2742 SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
2743 if (spellInfo && spellInfo->SpellFamilyName == SPELLFAMILY_WARRIOR && spellInfo->SpellIconID == 139)
2744 Rage_val += m_target->CalculateSpellDamage(spellInfo,0,spellInfo->EffectBasePoints[0],m_target) * 10;
2748 if (m_target->GetPower(POWER_RAGE) > Rage_val)
2749 m_target->SetPower(POWER_RAGE,Rage_val);
2750 break;
2752 default:
2753 break;
2757 m_target->m_ShapeShiftFormSpellId = GetId();
2758 m_target->m_form = form;
2760 else
2762 if(modelid > 0)
2763 m_target->SetDisplayId(m_target->GetNativeDisplayId());
2764 m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, FORM_NONE);
2765 if(m_target->getClass() == CLASS_DRUID)
2766 m_target->setPowerType(POWER_MANA);
2767 m_target->m_ShapeShiftFormSpellId = 0;
2768 m_target->m_form = FORM_NONE;
2770 switch(form)
2772 // Nordrassil Harness - bonus
2773 case FORM_BEAR:
2774 case FORM_DIREBEAR:
2775 case FORM_CAT:
2776 if(Aura* dummy = m_target->GetDummyAura(37315) )
2777 m_target->CastSpell(m_target,37316,true,NULL,dummy);
2778 break;
2779 // Nordrassil Regalia - bonus
2780 case FORM_MOONKIN:
2781 if(Aura* dummy = m_target->GetDummyAura(37324) )
2782 m_target->CastSpell(m_target,37325,true,NULL,dummy);
2783 break;
2784 default:
2785 break;
2789 // adding/removing linked auras
2790 // add/remove the shapeshift aura's boosts
2791 HandleShapeshiftBoosts(apply);
2793 if(m_target->GetTypeId()==TYPEID_PLAYER)
2794 ((Player*)m_target)->InitDataForForm();
2797 void Aura::HandleAuraTransform(bool apply, bool Real)
2799 if (apply)
2801 // special case (spell specific functionality)
2802 if (m_modifier.m_miscvalue==0)
2804 // player applied only
2805 if (m_target->GetTypeId()!=TYPEID_PLAYER)
2806 return;
2808 switch (GetId())
2810 // Orb of Deception
2811 case 16739:
2813 uint32 orb_model = m_target->GetNativeDisplayId();
2814 switch(orb_model)
2816 // Troll Female
2817 case 1479: m_target->SetDisplayId(10134); break;
2818 // Troll Male
2819 case 1478: m_target->SetDisplayId(10135); break;
2820 // Tauren Male
2821 case 59: m_target->SetDisplayId(10136); break;
2822 // Human Male
2823 case 49: m_target->SetDisplayId(10137); break;
2824 // Human Female
2825 case 50: m_target->SetDisplayId(10138); break;
2826 // Orc Male
2827 case 51: m_target->SetDisplayId(10139); break;
2828 // Orc Female
2829 case 52: m_target->SetDisplayId(10140); break;
2830 // Dwarf Male
2831 case 53: m_target->SetDisplayId(10141); break;
2832 // Dwarf Female
2833 case 54: m_target->SetDisplayId(10142); break;
2834 // NightElf Male
2835 case 55: m_target->SetDisplayId(10143); break;
2836 // NightElf Female
2837 case 56: m_target->SetDisplayId(10144); break;
2838 // Undead Female
2839 case 58: m_target->SetDisplayId(10145); break;
2840 // Undead Male
2841 case 57: m_target->SetDisplayId(10146); break;
2842 // Tauren Female
2843 case 60: m_target->SetDisplayId(10147); break;
2844 // Gnome Male
2845 case 1563: m_target->SetDisplayId(10148); break;
2846 // Gnome Female
2847 case 1564: m_target->SetDisplayId(10149); break;
2848 // BloodElf Female
2849 case 15475: m_target->SetDisplayId(17830); break;
2850 // BloodElf Male
2851 case 15476: m_target->SetDisplayId(17829); break;
2852 // Dranei Female
2853 case 16126: m_target->SetDisplayId(17828); break;
2854 // Dranei Male
2855 case 16125: m_target->SetDisplayId(17827); break;
2856 default: break;
2858 break;
2860 // Murloc costume
2861 case 42365: m_target->SetDisplayId(21723); break;
2862 default: break;
2865 else
2867 CreatureInfo const * ci = objmgr.GetCreatureTemplate(m_modifier.m_miscvalue);
2868 if (!ci)
2870 //pig pink ^_^
2871 m_target->SetDisplayId(16358);
2872 sLog.outError("Auras: unknown creature id = %d (only need its modelid) Form Spell Aura Transform in Spell ID = %d", m_modifier.m_miscvalue, GetId());
2874 else
2876 // Will use the default model here
2877 m_target->SetDisplayId(ci->DisplayID_A);
2879 // Dragonmaw Illusion (set mount model also)
2880 if(GetId()==42016 && m_target->GetMountID() && !m_target->GetAurasByType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED).empty())
2881 m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314);
2885 // update active transform spell only not set or not overwriting negative by positive case
2886 if (!m_target->getTransForm() || !IsPositiveSpell(GetId()) || IsPositiveSpell(m_target->getTransForm()))
2887 m_target->setTransForm(GetId());
2889 // polymorph case
2890 if (Real && m_target->GetTypeId() == TYPEID_PLAYER && m_target->IsPolymorphed())
2892 // for players, start regeneration after 1s (in polymorph fast regeneration case)
2893 // only if caster is Player (after patch 2.4.2)
2894 if (IS_PLAYER_GUID(GetCasterGUID()) )
2895 ((Player*)m_target)->setRegenTimer(1*IN_MILISECONDS);
2897 //dismount polymorphed target (after patch 2.4.2)
2898 if (m_target->IsMounted())
2899 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
2902 else
2904 // ApplyModifier(true) will reapply it if need
2905 m_target->setTransForm(0);
2906 m_target->SetDisplayId(m_target->GetNativeDisplayId());
2908 // re-aplly some from still active with preference negative cases
2909 Unit::AuraList const& otherTransforms = m_target->GetAurasByType(SPELL_AURA_TRANSFORM);
2910 if (!otherTransforms.empty())
2912 // look for other transform auras
2913 Aura* handledAura = *otherTransforms.begin();
2914 for(Unit::AuraList::const_iterator i = otherTransforms.begin();i != otherTransforms.end(); ++i)
2916 // negative auras are preferred
2917 if (!IsPositiveSpell((*i)->GetSpellProto()->Id))
2919 handledAura = *i;
2920 break;
2923 handledAura->ApplyModifier(true);
2926 // Dragonmaw Illusion (restore mount model)
2927 if (GetId()==42016 && m_target->GetMountID()==16314)
2929 if (!m_target->GetAurasByType(SPELL_AURA_MOUNTED).empty())
2931 uint32 cr_id = m_target->GetAurasByType(SPELL_AURA_MOUNTED).front()->GetModifier()->m_miscvalue;
2932 if (CreatureInfo const* ci = objmgr.GetCreatureTemplate(cr_id))
2934 uint32 team = 0;
2935 if (m_target->GetTypeId()==TYPEID_PLAYER)
2936 team = ((Player*)m_target)->GetTeam();
2938 uint32 display_id = objmgr.ChooseDisplayId(team,ci);
2939 CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id);
2940 if (minfo)
2941 display_id = minfo->modelid;
2943 m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,display_id);
2950 void Aura::HandleForceReaction(bool apply, bool Real)
2952 if(m_target->GetTypeId() != TYPEID_PLAYER)
2953 return;
2955 if(!Real)
2956 return;
2958 Player* player = (Player*)m_target;
2960 uint32 faction_id = m_modifier.m_miscvalue;
2961 uint32 faction_rank = m_modifier.m_amount;
2963 player->GetReputationMgr().ApplyForceReaction(faction_id,ReputationRank(faction_rank),apply);
2964 player->GetReputationMgr().SendForceReactions();
2967 void Aura::HandleAuraModSkill(bool apply, bool /*Real*/)
2969 if(m_target->GetTypeId() != TYPEID_PLAYER)
2970 return;
2972 uint32 prot=GetSpellProto()->EffectMiscValue[m_effIndex];
2973 int32 points = GetModifier()->m_amount;
2975 ((Player*)m_target)->ModifySkillBonus(prot,(apply ? points: -points),m_modifier.m_auraname==SPELL_AURA_MOD_SKILL_TALENT);
2976 if(prot == SKILL_DEFENSE)
2977 ((Player*)m_target)->UpdateDefenseBonusesMod();
2980 void Aura::HandleChannelDeathItem(bool apply, bool Real)
2982 if(Real && !apply)
2984 Unit* caster = GetCaster();
2985 Unit* victim = GetTarget();
2986 if(!caster || caster->GetTypeId() != TYPEID_PLAYER || !victim || m_removeMode!=AURA_REMOVE_BY_DEATH)
2987 return;
2988 // Item amount
2989 if (m_modifier.m_amount <= 0)
2990 return;
2992 SpellEntry const *spellInfo = GetSpellProto();
2993 if(spellInfo->EffectItemType[m_effIndex] == 0)
2994 return;
2996 // Soul Shard only from non-grey units
2997 if( spellInfo->EffectItemType[m_effIndex] == 6265 &&
2998 (victim->getLevel() <= MaNGOS::XP::GetGrayLevel(caster->getLevel()) ||
2999 victim->GetTypeId()==TYPEID_UNIT && !((Player*)caster)->isAllowedToLoot((Creature*)victim)) )
3000 return;
3001 //Adding items
3002 uint32 noSpaceForCount = 0;
3003 uint32 count = m_modifier.m_amount;
3005 ItemPosCountVec dest;
3006 uint8 msg = ((Player*)caster)->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, spellInfo->EffectItemType[m_effIndex], count, &noSpaceForCount);
3007 if( msg != EQUIP_ERR_OK )
3009 count-=noSpaceForCount;
3010 ((Player*)caster)->SendEquipError( msg, NULL, NULL );
3011 if (count==0)
3012 return;
3015 Item* newitem = ((Player*)caster)->StoreNewItem(dest, spellInfo->EffectItemType[m_effIndex], true);
3016 ((Player*)caster)->SendNewItem(newitem, count, true, false);
3020 void Aura::HandleBindSight(bool apply, bool /*Real*/)
3022 Unit* caster = GetCaster();
3023 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3024 return;
3026 ((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);
3029 void Aura::HandleFarSight(bool apply, bool /*Real*/)
3031 Unit* caster = GetCaster();
3032 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3033 return;
3035 ((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);
3038 void Aura::HandleAuraTrackCreatures(bool apply, bool /*Real*/)
3040 if(m_target->GetTypeId()!=TYPEID_PLAYER)
3041 return;
3043 if(apply)
3044 m_target->RemoveNoStackAurasDueToAura(this);
3045 m_target->SetUInt32Value(PLAYER_TRACK_CREATURES, apply ? ((uint32)1)<<(m_modifier.m_miscvalue-1) : 0 );
3048 void Aura::HandleAuraTrackResources(bool apply, bool /*Real*/)
3050 if(m_target->GetTypeId()!=TYPEID_PLAYER)
3051 return;
3053 if(apply)
3054 m_target->RemoveNoStackAurasDueToAura(this);
3055 m_target->SetUInt32Value(PLAYER_TRACK_RESOURCES, apply ? ((uint32)1)<<(m_modifier.m_miscvalue-1): 0 );
3058 void Aura::HandleAuraTrackStealthed(bool apply, bool /*Real*/)
3060 if(m_target->GetTypeId()!=TYPEID_PLAYER)
3061 return;
3063 if(apply)
3064 m_target->RemoveNoStackAurasDueToAura(this);
3066 m_target->ApplyModFlag(PLAYER_FIELD_BYTES,PLAYER_FIELD_BYTE_TRACK_STEALTHED,apply);
3069 void Aura::HandleAuraModScale(bool apply, bool /*Real*/)
3071 m_target->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X,m_modifier.m_amount,apply);
3074 void Aura::HandleModPossess(bool apply, bool Real)
3076 if(!Real)
3077 return;
3079 if(m_target->getLevel() > m_modifier.m_amount)
3080 return;
3082 // not possess yourself
3083 if(GetCasterGUID() == m_target->GetGUID())
3084 return;
3086 Unit* caster = GetCaster();
3087 if(!caster)
3088 return;
3090 if( apply )
3092 m_target->SetCharmerGUID(GetCasterGUID());
3093 m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,caster->getFaction());
3095 caster->SetCharm(m_target);
3097 if(caster->GetTypeId() == TYPEID_PLAYER)
3099 ((Player*)caster)->SetFarSightGUID(m_target->GetGUID());
3100 ((Player*)caster)->SetClientControl(m_target, 1);
3103 m_target->CombatStop();
3104 m_target->DeleteThreatList();
3105 if(m_target->GetTypeId() == TYPEID_UNIT)
3107 m_target->StopMoving();
3108 m_target->GetMotionMaster()->Clear();
3109 m_target->GetMotionMaster()->MoveIdle();
3111 else if(m_target->GetTypeId() == TYPEID_PLAYER)
3113 ((Player*)m_target)->SetClientControl(m_target, 0);
3116 if(CharmInfo *charmInfo = m_target->InitCharmInfo(m_target))
3117 charmInfo->InitPossessCreateSpells();
3119 if(caster->GetTypeId() == TYPEID_PLAYER)
3120 ((Player*)caster)->PossessSpellInitialize();
3122 else
3124 m_target->SetCharmerGUID(0);
3125 caster->InterruptSpell(CURRENT_CHANNELED_SPELL); // the spell is not automatically canceled when interrupted, do it now
3127 if(m_target->GetTypeId() == TYPEID_PLAYER)
3129 ((Player*)m_target)->setFactionForRace(m_target->getRace());
3130 ((Player*)m_target)->SetClientControl(m_target, 1);
3132 else if(m_target->GetTypeId() == TYPEID_UNIT)
3134 CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
3135 m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,cinfo->faction_A);
3138 caster->SetCharm(NULL);
3140 if(caster->GetTypeId() == TYPEID_PLAYER)
3142 ((Player*)caster)->SetFarSightGUID(0);
3143 ((Player*)caster)->SetClientControl(m_target,0);
3145 WorldPacket data(SMSG_PET_SPELLS, 8);
3146 data << uint64(0);
3147 ((Player*)caster)->GetSession()->SendPacket(&data);
3150 if(m_target->GetTypeId() == TYPEID_UNIT)
3152 ((Creature*)m_target)->AIM_Initialize();
3154 if (((Creature*)m_target)->AI())
3155 ((Creature*)m_target)->AI()->AttackedBy(caster);
3160 void Aura::HandleModPossessPet(bool apply, bool Real)
3162 if(!Real)
3163 return;
3165 Unit* caster = GetCaster();
3166 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3167 return;
3169 Pet *pet = caster->GetPet();
3170 if(!pet || pet != m_target)
3171 return;
3173 if(apply)
3174 pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_24);
3175 else
3176 pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_24);
3178 ((Player*)caster)->SetFarSightGUID(apply ? pet->GetGUID() : 0);
3179 ((Player*)caster)->SetCharm(apply ? pet : NULL);
3180 ((Player*)caster)->SetClientControl(pet, apply ? 1 : 0);
3182 if(apply)
3184 pet->StopMoving();
3185 pet->GetMotionMaster()->Clear();
3186 pet->GetMotionMaster()->MoveIdle();
3188 else
3190 pet->AttackStop();
3191 pet->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
3192 pet->SetUnitMovementFlags(MONSTER_MOVE_WALK);
3196 void Aura::HandleAuraModPetTalentsPoints(bool /*Apply*/, bool Real)
3198 if(!Real)
3199 return;
3201 // Recalculate pet talent points
3202 if (Pet *pet=m_target->GetPet())
3203 pet->InitTalentForLevel();
3206 void Aura::HandleModCharm(bool apply, bool Real)
3208 if(!Real)
3209 return;
3211 // not charm yourself
3212 if(GetCasterGUID() == m_target->GetGUID())
3213 return;
3215 Unit* caster = GetCaster();
3216 if(!caster)
3217 return;
3219 if(int32(m_target->getLevel()) <= m_modifier.m_amount)
3221 if( apply )
3223 m_target->SetCharmerGUID(GetCasterGUID());
3224 m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,caster->getFaction());
3225 m_target->CastStop(m_target==caster ? GetId() : 0);
3226 caster->SetCharm(m_target);
3228 m_target->CombatStop();
3229 m_target->DeleteThreatList();
3231 if(m_target->GetTypeId() == TYPEID_UNIT)
3233 ((Creature*)m_target)->AIM_Initialize();
3234 CharmInfo *charmInfo = m_target->InitCharmInfo(m_target);
3235 charmInfo->InitCharmCreateSpells();
3236 charmInfo->SetReactState( REACT_DEFENSIVE );
3238 if(caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK)
3240 CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
3241 if(cinfo && cinfo->type == CREATURE_TYPE_DEMON)
3243 //to prevent client crash
3244 m_target->SetFlag(UNIT_FIELD_BYTES_0, 2048);
3245 //just to enable stat window
3246 charmInfo->SetPetNumber(objmgr.GeneratePetNumber(), true);
3247 //if charmed two demons the same session, the 2nd gets the 1st one's name
3248 m_target->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL));
3253 if(caster->GetTypeId() == TYPEID_PLAYER)
3255 ((Player*)caster)->CharmSpellInitialize();
3258 else
3260 m_target->SetCharmerGUID(0);
3262 if(m_target->GetTypeId() == TYPEID_PLAYER)
3263 ((Player*)m_target)->setFactionForRace(m_target->getRace());
3264 else
3266 CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
3268 // restore faction
3269 if(((Creature*)m_target)->isPet())
3271 if(Unit* owner = m_target->GetOwner())
3272 m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,owner->getFaction());
3273 else if(cinfo)
3274 m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,cinfo->faction_A);
3276 else if(cinfo) // normal creature
3277 m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,cinfo->faction_A);
3279 // restore UNIT_FIELD_BYTES_0
3280 if(cinfo && caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK && cinfo->type == CREATURE_TYPE_DEMON)
3282 CreatureDataAddon const *cainfo = ((Creature*)m_target)->GetCreatureAddon();
3283 if(cainfo && cainfo->bytes0 != 0)
3284 m_target->SetUInt32Value(UNIT_FIELD_BYTES_0, cainfo->bytes0);
3285 else
3286 m_target->RemoveFlag(UNIT_FIELD_BYTES_0, 2048);
3288 if(m_target->GetCharmInfo())
3289 m_target->GetCharmInfo()->SetPetNumber(0, true);
3290 else
3291 sLog.outError("Aura::HandleModCharm: target="I64FMTD" with typeid=%d has a charm aura but no charm info!", m_target->GetGUID(), m_target->GetTypeId());
3295 caster->SetCharm(NULL);
3297 if(caster->GetTypeId() == TYPEID_PLAYER)
3299 WorldPacket data(SMSG_PET_SPELLS, 8);
3300 data << uint64(0);
3301 ((Player*)caster)->GetSession()->SendPacket(&data);
3303 if(m_target->GetTypeId() == TYPEID_UNIT)
3305 ((Creature*)m_target)->AIM_Initialize();
3306 if (((Creature*)m_target)->AI())
3307 ((Creature*)m_target)->AI()->AttackedBy(caster);
3313 void Aura::HandleModConfuse(bool apply, bool Real)
3315 if(!Real)
3316 return;
3318 m_target->SetConfused(apply, GetCasterGUID(), GetId());
3321 void Aura::HandleModFear(bool apply, bool Real)
3323 if (!Real)
3324 return;
3326 m_target->SetFeared(apply, GetCasterGUID(), GetId());
3329 void Aura::HandleFeignDeath(bool apply, bool Real)
3331 if(!Real)
3332 return;
3334 if(m_target->GetTypeId() != TYPEID_PLAYER)
3335 return;
3337 if( apply )
3340 WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9);
3341 data<<m_target->GetGUID();
3342 data<<uint8(0);
3343 m_target->SendMessageToSet(&data,true);
3345 // blizz like 2.0.x
3346 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29);
3347 // blizz like 2.0.x
3348 m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
3349 // blizz like 2.0.x
3350 m_target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
3352 m_target->addUnitState(UNIT_STAT_DIED);
3353 m_target->CombatStop();
3354 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
3356 // prevent interrupt message
3357 if(m_caster_guid==m_target->GetGUID() && m_target->m_currentSpells[CURRENT_GENERIC_SPELL])
3358 m_target->m_currentSpells[CURRENT_GENERIC_SPELL]->finish();
3359 m_target->InterruptNonMeleeSpells(true);
3360 m_target->getHostilRefManager().deleteReferences();
3362 else
3365 WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9);
3366 data<<m_target->GetGUID();
3367 data<<uint8(1);
3368 m_target->SendMessageToSet(&data,true);
3370 // blizz like 2.0.x
3371 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29);
3372 // blizz like 2.0.x
3373 m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
3374 // blizz like 2.0.x
3375 m_target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
3377 m_target->clearUnitState(UNIT_STAT_DIED);
3381 void Aura::HandleAuraModDisarm(bool apply, bool Real)
3383 if(!Real)
3384 return;
3386 if(!apply && m_target->HasAuraType(SPELL_AURA_MOD_DISARM))
3387 return;
3389 // not sure for it's correctness
3390 if(apply)
3391 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
3392 else
3393 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
3395 // only at real add/remove aura
3396 if (m_target->GetTypeId() != TYPEID_PLAYER)
3397 return;
3399 // main-hand attack speed already set to special value for feral form already and don't must change and reset at remove.
3400 if (m_target->IsInFeralForm())
3401 return;
3403 if (apply)
3404 m_target->SetAttackTime(BASE_ATTACK,BASE_ATTACK_TIME);
3405 else
3406 ((Player *)m_target)->SetRegularAttackTime();
3408 m_target->UpdateDamagePhysical(BASE_ATTACK);
3411 void Aura::HandleAuraModStun(bool apply, bool Real)
3413 if(!Real)
3414 return;
3416 if (apply)
3418 // Frost stun aura -> freeze/unfreeze target
3419 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
3420 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
3422 m_target->addUnitState(UNIT_STAT_STUNNED);
3423 m_target->SetUInt64Value(UNIT_FIELD_TARGET, 0);
3425 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
3426 m_target->CastStop(m_target->GetGUID() == GetCasterGUID() ? GetId() : 0);
3428 // Creature specific
3429 if(m_target->GetTypeId() != TYPEID_PLAYER)
3430 ((Creature*)m_target)->StopMoving();
3431 else
3432 ((Player*)m_target)->m_movementInfo.flags = 0; //Clear movement flags
3434 WorldPacket data(SMSG_FORCE_MOVE_ROOT, 8);
3436 data.append(m_target->GetPackGUID());
3437 data << uint32(0);
3438 m_target->SendMessageToSet(&data,true);
3440 // Summon the Naj'entus Spine GameObject on target if spell is Impaling Spine
3441 if(GetId() == 39837)
3443 GameObject* pObj = new GameObject;
3444 if(pObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 185584, m_target->GetMap(), m_target->GetPhaseMask(),
3445 m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
3447 pObj->SetRespawnTime(GetAuraDuration()/IN_MILISECONDS);
3448 pObj->SetSpellId(GetId());
3449 m_target->AddGameObject(pObj);
3450 m_target->GetMap()->Add(pObj);
3452 else
3453 delete pObj;
3456 else
3458 // Frost stun aura -> freeze/unfreeze target
3459 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
3461 bool found_another = false;
3462 for(AuraType const* itr = &frozenAuraTypes[0]; *itr != SPELL_AURA_NONE; ++itr)
3464 Unit::AuraList const& auras = m_target->GetAurasByType(*itr);
3465 for(Unit::AuraList::const_iterator i = auras.begin(); i != auras.end(); ++i)
3467 if( GetSpellSchoolMask((*i)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST)
3469 found_another = true;
3470 break;
3473 if(found_another)
3474 break;
3477 if(!found_another)
3478 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
3481 // Real remove called after current aura remove from lists, check if other similar auras active
3482 if(m_target->HasAuraType(SPELL_AURA_MOD_STUN))
3483 return;
3485 m_target->clearUnitState(UNIT_STAT_STUNNED);
3486 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
3488 if(!m_target->hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect
3490 if(m_target->getVictim() && m_target->isAlive())
3491 m_target->SetUInt64Value(UNIT_FIELD_TARGET,m_target->getVictim()->GetGUID() );
3493 WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 8+4);
3494 data.append(m_target->GetPackGUID());
3495 data << uint32(0);
3496 m_target->SendMessageToSet(&data,true);
3499 // Wyvern Sting
3500 if (m_spellProto->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellProto->SpellFamilyFlags & 0x0000100000000000LL)
3502 Unit* caster = GetCaster();
3503 if( !caster || caster->GetTypeId()!=TYPEID_PLAYER )
3504 return;
3506 uint32 spell_id = 0;
3508 switch(GetId())
3510 case 19386: spell_id = 24131; break;
3511 case 24132: spell_id = 24134; break;
3512 case 24133: spell_id = 24135; break;
3513 case 27068: spell_id = 27069; break;
3514 case 49011: spell_id = 49009; break;
3515 case 49012: spell_id = 49010; break;
3516 default:
3517 sLog.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?",GetId());
3518 return;
3521 SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id);
3523 if(!spellInfo)
3524 return;
3526 caster->CastSpell(m_target,spellInfo,true,NULL,this);
3527 return;
3532 void Aura::HandleModStealth(bool apply, bool Real)
3534 Unit* pTarget = m_target;
3535 SpellEntry const* pSpellInfo = GetSpellProto();
3537 if (apply)
3539 // drop flag at stealth in bg
3540 pTarget->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
3542 // only at real aura add
3543 if (Real)
3545 pTarget->SetStandFlags(UNIT_STAND_FLAGS_CREEP);
3547 if (pTarget->GetTypeId()==TYPEID_PLAYER)
3548 pTarget->SetFlag(PLAYER_FIELD_BYTES2, 0x2000);
3550 // apply only if not in GM invisibility (and overwrite invisibility state)
3551 if (pTarget->GetVisibility()!=VISIBILITY_OFF)
3553 pTarget->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
3554 pTarget->SetVisibility(VISIBILITY_GROUP_STEALTH);
3557 // apply full stealth period bonuses only at first stealth aura in stack
3558 if(pTarget->GetAurasByType(SPELL_AURA_MOD_STEALTH).size()<=1)
3560 Unit::AuraList const& mDummyAuras = pTarget->GetAurasByType(SPELL_AURA_DUMMY);
3561 for(Unit::AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i)
3563 // Master of Subtlety
3564 if ((*i)->GetSpellProto()->SpellIconID == 2114)
3566 pTarget->RemoveAurasDueToSpell(31666);
3567 int32 bp = (*i)->GetModifier()->m_amount;
3568 pTarget->CastCustomSpell(pTarget,31665,&bp,NULL,NULL,true);
3570 // Overkill
3571 else if ((*i)->GetId() == 58426 && pSpellInfo->SpellFamilyFlags & 0x0000000000400000LL)
3573 pTarget->RemoveAurasDueToSpell(58428);
3574 pTarget->CastSpell(pTarget, 58427, true);
3580 else
3582 // only at real aura remove of _last_ SPELL_AURA_MOD_STEALTH
3583 if (Real && !pTarget->HasAuraType(SPELL_AURA_MOD_STEALTH))
3585 // if no GM invisibility
3586 if(pTarget->GetVisibility()!=VISIBILITY_OFF)
3588 pTarget->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP);
3590 if (pTarget->GetTypeId()==TYPEID_PLAYER)
3591 pTarget->RemoveFlag(PLAYER_FIELD_BYTES2, 0x2000);
3593 // restore invisibility if any
3594 if (pTarget->HasAuraType(SPELL_AURA_MOD_INVISIBILITY))
3596 pTarget->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
3597 pTarget->SetVisibility(VISIBILITY_GROUP_INVISIBILITY);
3599 else
3600 pTarget->SetVisibility(VISIBILITY_ON);
3603 // apply delayed talent bonus remover at last stealth aura remove
3604 Unit::AuraList const& mDummyAuras = pTarget->GetAurasByType(SPELL_AURA_DUMMY);
3605 for(Unit::AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i)
3607 // Master of Subtlety
3608 if ((*i)->GetSpellProto()->SpellIconID == 2114)
3609 pTarget->CastSpell(pTarget,31666,true);
3610 // Overkill
3611 else if ((*i)->GetId() == 58426 && pSpellInfo->SpellFamilyFlags & 0x0000000000400000LL)
3612 pTarget->CastSpell(pTarget, 58428, true);
3618 void Aura::HandleInvisibility(bool apply, bool Real)
3620 if(apply)
3622 m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue);
3624 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
3626 if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
3628 // apply glow vision
3629 m_target->SetFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
3633 // apply only if not in GM invisibility and not stealth
3634 if(m_target->GetVisibility()==VISIBILITY_ON)
3636 // Aura not added yet but visibility code expect temporary add aura
3637 m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
3638 m_target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY);
3641 else
3643 // recalculate value at modifier remove (current aura already removed)
3644 m_target->m_invisibilityMask = 0;
3645 Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY);
3646 for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
3647 m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue);
3649 // only at real aura remove and if not have different invisibility auras.
3650 if(Real && m_target->m_invisibilityMask==0)
3652 // remove glow vision
3653 if(m_target->GetTypeId() == TYPEID_PLAYER)
3654 m_target->RemoveFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
3656 // apply only if not in GM invisibility & not stealthed while invisible
3657 if(m_target->GetVisibility()!=VISIBILITY_OFF)
3659 // if have stealth aura then already have stealth visibility
3660 if(!m_target->HasAuraType(SPELL_AURA_MOD_STEALTH))
3661 m_target->SetVisibility(VISIBILITY_ON);
3667 void Aura::HandleInvisibilityDetect(bool apply, bool Real)
3669 if(apply)
3671 m_target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue);
3673 else
3675 // recalculate value at modifier remove (current aura already removed)
3676 m_target->m_detectInvisibilityMask = 0;
3677 Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION);
3678 for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
3679 m_target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue);
3681 if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
3682 ObjectAccessor::UpdateVisibilityForPlayer((Player*)m_target);
3685 void Aura::HandleAuraModRoot(bool apply, bool Real)
3687 // only at real add/remove aura
3688 if(!Real)
3689 return;
3691 if (apply)
3693 // Frost root aura -> freeze/unfreeze target
3694 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
3695 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
3697 m_target->addUnitState(UNIT_STAT_ROOT);
3698 m_target->SetUInt64Value (UNIT_FIELD_TARGET, 0);
3699 // probably wrong (this add skinable flag)
3700 // TODO: find correct flag
3701 //m_target->SetFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
3703 //Save last orientation
3704 if( m_target->getVictim() )
3705 m_target->SetOrientation(m_target->GetAngle(m_target->getVictim()));
3707 if(m_target->GetTypeId() == TYPEID_PLAYER)
3709 WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10);
3710 data.append(m_target->GetPackGUID());
3711 data << (uint32)2;
3712 m_target->SendMessageToSet(&data,true);
3714 //Clear unit movement flags
3715 ((Player*)m_target)->m_movementInfo.flags = 0;
3717 else
3718 ((Creature *)m_target)->StopMoving();
3720 else
3722 // Frost root aura -> freeze/unfreeze target
3723 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
3725 bool found_another = false;
3726 for(AuraType const* itr = &frozenAuraTypes[0]; *itr != SPELL_AURA_NONE; ++itr)
3728 Unit::AuraList const& auras = m_target->GetAurasByType(*itr);
3729 for(Unit::AuraList::const_iterator i = auras.begin(); i != auras.end(); ++i)
3731 if( GetSpellSchoolMask((*i)->GetSpellProto()) & SPELL_SCHOOL_MASK_FROST)
3733 found_another = true;
3734 break;
3737 if(found_another)
3738 break;
3741 if(!found_another)
3742 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
3745 // Real remove called after current aura remove from lists, check if other similar auras active
3746 if(m_target->HasAuraType(SPELL_AURA_MOD_ROOT))
3747 return;
3749 m_target->clearUnitState(UNIT_STAT_ROOT);
3750 // probably wrong (this add skinable flag)
3751 // TODO: find correct flag
3752 //m_target->RemoveFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
3754 if(!m_target->hasUnitState(UNIT_STAT_STUNNED)) // prevent allow move if have also stun effect
3756 if(m_target->getVictim() && m_target->isAlive())
3757 m_target->SetUInt64Value (UNIT_FIELD_TARGET,m_target->getVictim()->GetGUID() );
3759 if(m_target->GetTypeId() == TYPEID_PLAYER)
3761 WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 10);
3762 data.append(m_target->GetPackGUID());
3763 data << (uint32)2;
3764 m_target->SendMessageToSet(&data,true);
3770 void Aura::HandleAuraModSilence(bool apply, bool Real)
3772 // only at real add/remove aura
3773 if(!Real)
3774 return;
3776 if(apply)
3778 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED);
3779 // Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE
3780 for (uint32 i = CURRENT_MELEE_SPELL; i < CURRENT_MAX_SPELL;i++)
3781 if (m_target->m_currentSpells[i] && m_target->m_currentSpells[i]->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
3782 m_target->InterruptSpell(i,false); // Stop spells on prepare or casting state
3784 switch (GetId())
3786 // Arcane Torrent (Energy)
3787 case 25046:
3789 Unit * caster = GetCaster();
3790 if (!caster)
3791 return;
3793 // Search Mana Tap auras on caster
3794 Aura * dummy = caster->GetDummyAura(28734);
3795 if (dummy)
3797 int32 bp = dummy->GetStackAmount() * 10;
3798 caster->CastCustomSpell(caster, 25048, &bp, NULL, NULL, true);
3799 caster->RemoveAurasDueToSpell(28734);
3804 else
3806 // Real remove called after current aura remove from lists, check if other similar auras active
3807 if(m_target->HasAuraType(SPELL_AURA_MOD_SILENCE))
3808 return;
3810 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED);
3814 void Aura::HandleModThreat(bool apply, bool Real)
3816 // only at real add/remove aura
3817 if(!Real)
3818 return;
3820 if(!m_target->isAlive())
3821 return;
3823 Unit* caster = GetCaster();
3825 if(!caster || !caster->isAlive())
3826 return;
3828 int level_diff = 0;
3829 int multiplier = 0;
3830 switch (GetId())
3832 // Arcane Shroud
3833 case 26400:
3834 level_diff = m_target->getLevel() - 60;
3835 multiplier = 2;
3836 break;
3837 // The Eye of Diminution
3838 case 28862:
3839 level_diff = m_target->getLevel() - 60;
3840 multiplier = 1;
3841 break;
3843 if (level_diff > 0)
3844 m_modifier.m_amount += multiplier * level_diff;
3846 for(int8 x=0;x < MAX_SPELL_SCHOOL;x++)
3848 if(m_modifier.m_miscvalue & int32(1<<x))
3850 if(m_target->GetTypeId() == TYPEID_PLAYER)
3851 ApplyPercentModFloatVar(m_target->m_threatModifier[x], m_positive ? m_modifier.m_amount : -m_modifier.m_amount, apply);
3856 void Aura::HandleAuraModTotalThreat(bool apply, bool Real)
3858 // only at real add/remove aura
3859 if(!Real)
3860 return;
3862 if(!m_target->isAlive() || m_target->GetTypeId()!= TYPEID_PLAYER)
3863 return;
3865 Unit* caster = GetCaster();
3867 if(!caster || !caster->isAlive())
3868 return;
3870 float threatMod = 0.0f;
3871 if(apply)
3872 threatMod = float(m_modifier.m_amount);
3873 else
3874 threatMod = float(-m_modifier.m_amount);
3876 m_target->getHostilRefManager().threatAssist(caster, threatMod);
3879 void Aura::HandleModTaunt(bool apply, bool Real)
3881 // only at real add/remove aura
3882 if(!Real)
3883 return;
3885 if(!m_target->isAlive() || !m_target->CanHaveThreatList())
3886 return;
3888 Unit* caster = GetCaster();
3890 if(!caster || !caster->isAlive() || caster->GetTypeId() != TYPEID_PLAYER)
3891 return;
3893 if(apply)
3894 m_target->TauntApply(caster);
3895 else
3897 // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat
3898 m_target->TauntFadeOut(caster);
3902 /*********************************************************/
3903 /*** MODIFY SPEED ***/
3904 /*********************************************************/
3905 void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real)
3907 // all applied/removed only at real aura add/remove
3908 if(!Real)
3909 return;
3911 m_target->UpdateSpeed(MOVE_RUN, true);
3914 void Aura::HandleAuraModIncreaseMountedSpeed(bool /*apply*/, bool Real)
3916 // all applied/removed only at real aura add/remove
3917 if(!Real)
3918 return;
3920 m_target->UpdateSpeed(MOVE_RUN, true);
3923 void Aura::HandleAuraModIncreaseFlightSpeed(bool apply, bool Real)
3925 // all applied/removed only at real aura add/remove
3926 if(!Real)
3927 return;
3929 // Enable Fly mode for flying mounts
3930 if (m_modifier.m_auraname == SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED)
3932 WorldPacket data;
3933 if(apply)
3934 data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
3935 else
3936 data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
3937 data.append(m_target->GetPackGUID());
3938 data << uint32(0); // unknown
3939 m_target->SendMessageToSet(&data, true);
3941 //Players on flying mounts must be immune to polymorph
3942 if (m_target->GetTypeId()==TYPEID_PLAYER)
3943 m_target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,MECHANIC_POLYMORPH,apply);
3945 // Dragonmaw Illusion (overwrite mount model, mounted aura already applied)
3946 if( apply && m_target->HasAura(42016,0) && m_target->GetMountID())
3947 m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314);
3950 m_target->UpdateSpeed(MOVE_FLIGHT, true);
3953 void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real)
3955 // all applied/removed only at real aura add/remove
3956 if(!Real)
3957 return;
3959 m_target->UpdateSpeed(MOVE_SWIM, true);
3962 void Aura::HandleAuraModDecreaseSpeed(bool /*apply*/, bool Real)
3964 // all applied/removed only at real aura add/remove
3965 if(!Real)
3966 return;
3968 m_target->UpdateSpeed(MOVE_RUN, true);
3969 m_target->UpdateSpeed(MOVE_SWIM, true);
3970 m_target->UpdateSpeed(MOVE_FLIGHT, true);
3973 void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real)
3975 // all applied/removed only at real aura add/remove
3976 if(!Real)
3977 return;
3979 m_target->UpdateSpeed(MOVE_RUN, true);
3980 m_target->UpdateSpeed(MOVE_SWIM, true);
3981 m_target->UpdateSpeed(MOVE_FLIGHT, true);
3984 /*********************************************************/
3985 /*** IMMUNITY ***/
3986 /*********************************************************/
3988 void Aura::HandleModMechanicImmunity(bool apply, bool /*Real*/)
3990 uint32 mechanic = 1 << m_modifier.m_miscvalue;
3992 //immune movement impairment and loss of control
3993 if(GetId()==42292 || GetId()==59752)
3994 mechanic=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
3996 // cache values in local vars for prevent access to possible deleted aura data
3997 SpellEntry const* spellInfo = GetSpellProto();
3998 uint32 misc = m_modifier.m_miscvalue;
3999 Unit* target = m_target;
4001 if(apply && spellInfo->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
4003 Unit::AuraMap& Auras = target->GetAuras();
4004 for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next)
4006 next = iter;
4007 ++next;
4008 SpellEntry const *spell = iter->second->GetSpellProto();
4009 if (!( spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) && // spells unaffected by invulnerability
4010 spell->Id != spellInfo->Id)
4012 //check for mechanic mask
4013 if(GetSpellMechanicMask(spell, iter->second->GetEffIndex()) & mechanic)
4015 target->RemoveAurasDueToSpell(spell->Id);
4016 if(Auras.empty())
4017 break;
4018 else
4019 next = Auras.begin();
4025 target->ApplySpellImmune(spellInfo->Id,IMMUNITY_MECHANIC,misc,apply);
4027 // Bestial Wrath
4028 if (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && spellInfo->SpellIconID == 1680)
4030 // The Beast Within cast on owner if talent present
4031 if (Unit* owner = target->GetOwner())
4033 // Search talent
4034 Unit::AuraList const& dummyAuras = owner->GetAurasByType(SPELL_AURA_DUMMY);
4035 for(Unit::AuraList::const_iterator i = dummyAuras.begin(); i != dummyAuras.end(); ++i)
4037 if ((*i)->GetSpellProto()->SpellIconID == 2229)
4039 if (apply)
4040 owner->CastSpell(owner, 34471, true, 0, this);
4041 else
4042 owner->RemoveAurasDueToSpell(34471);
4043 break;
4049 // The Beast Within and Bestial Wrath - immunity
4050 if (spellInfo->Id == 19574 || spellInfo->Id == 34471)
4052 if (apply)
4054 target->CastSpell(target,24395,true);
4055 target->CastSpell(target,24396,true);
4056 target->CastSpell(target,24397,true);
4057 target->CastSpell(target,26592,true);
4059 else
4061 target->RemoveAurasDueToSpell(24395);
4062 target->RemoveAurasDueToSpell(24396);
4063 target->RemoveAurasDueToSpell(24397);
4064 target->RemoveAurasDueToSpell(26592);
4069 //this method is called whenever we add / remove aura which gives m_target some imunity to some spell effect
4070 void Aura::HandleAuraModEffectImmunity(bool apply, bool /*Real*/)
4072 // when removing flag aura, handle flag drop
4073 if( !apply && m_target->GetTypeId() == TYPEID_PLAYER
4074 && (GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION) )
4076 if( BattleGround *bg = ((Player*)m_target)->GetBattleGround() )
4077 bg->EventPlayerDroppedFlag(((Player*)m_target));
4080 m_target->ApplySpellImmune(GetId(),IMMUNITY_EFFECT,m_modifier.m_miscvalue,apply);
4083 void Aura::HandleAuraModStateImmunity(bool apply, bool Real)
4085 if(apply && Real && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
4087 Unit::AuraList const& auraList = m_target->GetAurasByType(AuraType(m_modifier.m_miscvalue));
4088 for(Unit::AuraList::const_iterator itr = auraList.begin(); itr != auraList.end();)
4090 if (auraList.front() != this) // skip itself aura (it already added)
4092 m_target->RemoveAurasDueToSpell(auraList.front()->GetId());
4093 itr = auraList.begin();
4095 else
4096 ++itr;
4100 m_target->ApplySpellImmune(GetId(),IMMUNITY_STATE,m_modifier.m_miscvalue,apply);
4103 void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real)
4105 m_target->ApplySpellImmune(GetId(),IMMUNITY_SCHOOL,m_modifier.m_miscvalue,apply);
4107 // remove all flag auras (they are positive, but they must be removed when you are immune)
4108 if( this->GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
4109 && this->GetSpellProto()->AttributesEx2 & SPELL_ATTR_EX2_DAMAGE_REDUCED_SHIELD )
4110 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
4112 // TODO: optimalize this cycle - use RemoveAurasWithInterruptFlags call or something else
4113 if( Real && apply
4114 && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
4115 && IsPositiveSpell(GetId()) ) //Only positive immunity removes auras
4117 uint32 school_mask = m_modifier.m_miscvalue;
4118 Unit::AuraMap& Auras = m_target->GetAuras();
4119 for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next)
4121 next = iter;
4122 ++next;
4123 SpellEntry const *spell = iter->second->GetSpellProto();
4124 if((GetSpellSchoolMask(spell) & school_mask)//Check for school mask
4125 && !( spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) //Spells unaffected by invulnerability
4126 && !iter->second->IsPositive() //Don't remove positive spells
4127 && spell->Id != GetId() ) //Don't remove self
4129 m_target->RemoveAurasDueToSpell(spell->Id);
4130 if(Auras.empty())
4131 break;
4132 else
4133 next = Auras.begin();
4137 if( Real && GetSpellProto()->Mechanic == MECHANIC_BANISH )
4139 if( apply )
4140 m_target->addUnitState(UNIT_STAT_ISOLATED);
4141 else
4142 m_target->clearUnitState(UNIT_STAT_ISOLATED);
4146 void Aura::HandleAuraModDmgImmunity(bool apply, bool /*Real*/)
4148 m_target->ApplySpellImmune(GetId(),IMMUNITY_DAMAGE,m_modifier.m_miscvalue,apply);
4151 void Aura::HandleAuraModDispelImmunity(bool apply, bool Real)
4153 // all applied/removed only at real aura add/remove
4154 if(!Real)
4155 return;
4157 m_target->ApplySpellDispelImmunity(m_spellProto, DispelType(m_modifier.m_miscvalue), apply);
4160 void Aura::HandleAuraProcTriggerSpell(bool apply, bool Real)
4162 if(!Real)
4163 return;
4165 if(apply)
4167 // some spell have charges by functionality not have its in spell data
4168 switch (GetId())
4170 case 28200: // Ascendance (Talisman of Ascendance trinket)
4171 SetAuraCharges(6);
4172 break;
4173 default: break;
4178 void Aura::HandleAuraModStalked(bool apply, bool /*Real*/)
4180 // used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND
4181 if(apply)
4182 m_target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT);
4183 else
4184 m_target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT);
4187 /*********************************************************/
4188 /*** PERIODIC ***/
4189 /*********************************************************/
4191 void Aura::HandlePeriodicTriggerSpell(bool apply, bool /*Real*/)
4193 m_isPeriodic = apply;
4194 if (m_spellProto->Id == 66 && !apply)
4196 if (m_removeMode == AURA_REMOVE_BY_DEFAULT && m_duration<=0)
4197 m_target->CastSpell(m_target, 32612, true, NULL, this);
4201 void Aura::HandlePeriodicTriggerSpellWithValue(bool apply, bool /*Real*/)
4203 m_isPeriodic = apply;
4206 void Aura::HandlePeriodicEnergize(bool apply, bool Real)
4208 if (!Real)
4209 return;
4211 m_isPeriodic = apply;
4213 // Replenishment (0.25% from max)
4214 // Infinite Replenishment
4215 if (GetId() == 57669 ||
4216 GetId() == 61782)
4217 m_modifier.m_amount = m_target->GetMaxPower(POWER_MANA) * 25 / 10000;
4220 void Aura::HandleAuraPowerBurn(bool apply, bool /*Real*/)
4222 m_isPeriodic = apply;
4225 void Aura::HandleAuraPeriodicDummy(bool apply, bool Real)
4227 // spells required only Real aura add/remove
4228 if(!Real)
4229 return;
4231 // For prevent double apply bonuses
4232 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
4234 Unit* caster = GetCaster();
4236 SpellEntry const*spell = GetSpellProto();
4237 switch( spell->SpellFamilyName)
4239 case SPELLFAMILY_ROGUE:
4241 if(!apply)
4243 switch(spell->Id)
4245 // Master of Subtlety
4246 case 31666: m_target->RemoveAurasDueToSpell(31665); break;
4247 // Overkill
4248 case 58428: m_target->RemoveAurasDueToSpell(58427); break;
4251 break;
4253 case SPELLFAMILY_HUNTER:
4255 // Explosive Shot
4256 if (apply && !loading && caster)
4257 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 8 / 100);
4258 break;
4262 m_isPeriodic = apply;
4265 void Aura::HandlePeriodicHeal(bool apply, bool /*Real*/)
4267 m_isPeriodic = apply;
4270 void Aura::HandlePeriodicDamage(bool apply, bool Real)
4272 // spells required only Real aura add/remove
4273 if(!Real)
4274 return;
4276 m_isPeriodic = apply;
4278 // For prevent double apply bonuses
4279 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
4281 // Custom damage calculation after
4282 if (apply)
4284 if(loading)
4285 return;
4287 Unit *caster = GetCaster();
4288 if (!caster)
4289 return;
4291 switch (m_spellProto->SpellFamilyName)
4293 case SPELLFAMILY_GENERIC:
4295 // Pounce Bleed
4296 if ( m_spellProto->SpellIconID == 147 && m_spellProto->SpellVisual[0] == 0 )
4298 // $AP*0.18/6 bonus per tick
4299 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 3 / 100);
4300 return;
4302 break;
4304 case SPELLFAMILY_WARRIOR:
4306 // Rend
4307 if (m_spellProto->SpellFamilyFlags & 0x0000000000000020LL)
4309 // $0.2*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick
4310 float ap = caster->GetTotalAttackPowerValue(BASE_ATTACK);
4311 int32 mws = caster->GetAttackTime(BASE_ATTACK);
4312 float mwb_min = caster->GetWeaponDamageRange(BASE_ATTACK,MINDAMAGE);
4313 float mwb_max = caster->GetWeaponDamageRange(BASE_ATTACK,MAXDAMAGE);
4314 m_modifier.m_amount+=int32(((mwb_min+mwb_max)/2+ap*mws/14000)*0.2f);
4315 return;
4317 break;
4319 case SPELLFAMILY_DRUID:
4321 // Rake
4322 if (m_spellProto->SpellFamilyFlags & 0x0000000000001000LL)
4324 // $AP*0.06 bonus per tick
4325 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 6 / 100);
4326 return;
4328 // Lacerate
4329 if (m_spellProto->SpellFamilyFlags & 0x000000010000000000LL)
4331 // $AP*0.05/5 bonus per tick
4332 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100);
4333 return;
4335 // Rip
4336 if (m_spellProto->SpellFamilyFlags & 0x000000000000800000LL)
4338 // 0.01*$AP*cp
4339 if (caster->GetTypeId() != TYPEID_PLAYER)
4340 return;
4342 uint8 cp = ((Player*)caster)->GetComboPoints();
4344 // Idol of Feral Shadows. Cant be handled as SpellMod in SpellAura:Dummy due its dependency from CPs
4345 Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY);
4346 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
4348 if((*itr)->GetId()==34241)
4350 m_modifier.m_amount += cp * (*itr)->GetModifier()->m_amount;
4351 break;
4354 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * cp / 100);
4355 return;
4357 // Lock Jaw
4358 if (m_spellProto->SpellFamilyFlags & 0x1000000000000000LL)
4360 // 0.15*$AP
4361 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 15 / 100);
4362 return;
4364 break;
4366 case SPELLFAMILY_ROGUE:
4368 // Rupture
4369 if (m_spellProto->SpellFamilyFlags & 0x000000000000100000LL)
4371 if (caster->GetTypeId() != TYPEID_PLAYER)
4372 return;
4373 //1 point : ${($m1+$b1*1+0.015*$AP)*4} damage over 8 secs
4374 //2 points: ${($m1+$b1*2+0.024*$AP)*5} damage over 10 secs
4375 //3 points: ${($m1+$b1*3+0.03*$AP)*6} damage over 12 secs
4376 //4 points: ${($m1+$b1*4+0.03428571*$AP)*7} damage over 14 secs
4377 //5 points: ${($m1+$b1*5+0.0375*$AP)*8} damage over 16 secs
4378 float AP_per_combo[6] = {0.0f, 0.015f, 0.024f, 0.03f, 0.03428571f, 0.0375f};
4379 uint8 cp = ((Player*)caster)->GetComboPoints();
4380 if (cp > 5) cp = 5;
4381 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * AP_per_combo[cp]);
4382 return;
4384 // Garrote
4385 if (m_spellProto->SpellFamilyFlags & 0x000000000000000100LL)
4387 // $AP*0.07 bonus per tick
4388 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 7 / 100);
4389 return;
4391 // Deadly Poison
4392 if (m_spellProto->SpellFamilyFlags & 0x0000000000010000)
4394 // 0.08*$AP / 4 * amount of stack
4395 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 2 * GetStackAmount() / 100);
4396 return;
4398 break;
4400 case SPELLFAMILY_HUNTER:
4402 // Serpent Sting
4403 if (m_spellProto->SpellFamilyFlags & 0x0000000000004000LL)
4405 // $RAP*0.1/5 bonus per tick
4406 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 10 / 500);
4407 return;
4409 // Immolation Trap
4410 if (m_spellProto->SpellFamilyFlags & 0x0000000000000004LL && m_spellProto->SpellIconID == 678)
4412 // $RAP*0.1/5 bonus per tick
4413 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 10 / 500);
4414 return;
4416 break;
4418 default:
4419 break;
4422 // remove time effects
4423 else
4425 // Parasitic Shadowfiend - handle summoning of two Shadowfiends on DoT expire
4426 if(m_spellProto->Id == 41917)
4427 m_target->CastSpell(m_target, 41915, true);
4431 void Aura::HandlePeriodicDamagePCT(bool apply, bool /*Real*/)
4433 m_isPeriodic = apply;
4436 void Aura::HandlePeriodicLeech(bool apply, bool /*Real*/)
4438 m_isPeriodic = apply;
4441 void Aura::HandlePeriodicManaLeech(bool apply, bool /*Real*/)
4443 m_isPeriodic = apply;
4446 void Aura::HandlePeriodicHealthFunnel(bool apply, bool /*Real*/)
4448 m_isPeriodic = apply;
4451 /*********************************************************/
4452 /*** MODIFY STATS ***/
4453 /*********************************************************/
4455 /********************************/
4456 /*** RESISTANCE ***/
4457 /********************************/
4459 void Aura::HandleAuraModResistanceExclusive(bool apply, bool /*Real*/)
4461 for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++)
4463 if(m_modifier.m_miscvalue & int32(1<<x))
4465 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_VALUE, float(m_modifier.m_amount), apply);
4466 if(m_target->GetTypeId() == TYPEID_PLAYER)
4467 m_target->ApplyResistanceBuffModsMod(SpellSchools(x),m_positive,m_modifier.m_amount, apply);
4472 void Aura::HandleAuraModResistance(bool apply, bool /*Real*/)
4474 for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++)
4476 if(m_modifier.m_miscvalue & int32(1<<x))
4478 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), TOTAL_VALUE, float(m_modifier.m_amount), apply);
4479 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
4480 m_target->ApplyResistanceBuffModsMod(SpellSchools(x),m_positive,m_modifier.m_amount, apply);
4485 void Aura::HandleAuraModBaseResistancePCT(bool apply, bool /*Real*/)
4487 // only players have base stats
4488 if(m_target->GetTypeId() != TYPEID_PLAYER)
4490 //pets only have base armor
4491 if(((Creature*)m_target)->isPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL))
4492 m_target->HandleStatModifier(UNIT_MOD_ARMOR, BASE_PCT, float(m_modifier.m_amount), apply);
4494 else
4496 for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++)
4498 if(m_modifier.m_miscvalue & int32(1<<x))
4499 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_PCT, float(m_modifier.m_amount), apply);
4504 void Aura::HandleModResistancePercent(bool apply, bool /*Real*/)
4506 for(int8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++)
4508 if(m_modifier.m_miscvalue & int32(1<<i))
4510 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply);
4511 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
4513 m_target->ApplyResistanceBuffModsPercentMod(SpellSchools(i),true,m_modifier.m_amount, apply);
4514 m_target->ApplyResistanceBuffModsPercentMod(SpellSchools(i),false,m_modifier.m_amount, apply);
4520 void Aura::HandleModBaseResistance(bool apply, bool /*Real*/)
4522 // only players have base stats
4523 if(m_target->GetTypeId() != TYPEID_PLAYER)
4525 //only pets have base stats
4526 if(((Creature*)m_target)->isPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL))
4527 m_target->HandleStatModifier(UNIT_MOD_ARMOR, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4529 else
4531 for(int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++)
4532 if(m_modifier.m_miscvalue & (1<<i))
4533 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply);
4537 /********************************/
4538 /*** STAT ***/
4539 /********************************/
4541 void Aura::HandleAuraModStat(bool apply, bool /*Real*/)
4543 if (m_modifier.m_miscvalue < -2 || m_modifier.m_miscvalue > 4)
4545 sLog.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ",GetId(),GetEffIndex(),m_modifier.m_miscvalue);
4546 return;
4549 for(int32 i = STAT_STRENGTH; i < MAX_STATS; i++)
4551 // -1 or -2 is all stats ( misc < -2 checked in function beginning )
4552 if (m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue == i)
4554 //m_target->ApplyStatMod(Stats(i), m_modifier.m_amount,apply);
4555 m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply);
4556 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
4557 m_target->ApplyStatBuffMod(Stats(i),m_modifier.m_amount,apply);
4562 void Aura::HandleModPercentStat(bool apply, bool /*Real*/)
4564 if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4)
4566 sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
4567 return;
4570 // only players have base stats
4571 if (m_target->GetTypeId() != TYPEID_PLAYER)
4572 return;
4574 for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i)
4576 if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1)
4577 m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), BASE_PCT, float(m_modifier.m_amount), apply);
4581 void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool /*Real*/)
4583 if(m_target->GetTypeId() != TYPEID_PLAYER)
4584 return;
4586 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4587 // This information for client side use only
4588 // Recalculate bonus
4589 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4592 void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool /*Real*/)
4594 if(m_target->GetTypeId() != TYPEID_PLAYER)
4595 return;
4597 // Recalculate bonus
4598 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4601 void Aura::HandleAuraModDispelResist(bool apply, bool Real)
4603 if(!Real || !apply)
4604 return;
4606 if(GetId()==33206)
4607 m_target->CastSpell(m_target,44416,true,NULL,this,GetCasterGUID());
4610 void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool /*Real*/)
4612 if(m_target->GetTypeId() != TYPEID_PLAYER)
4613 return;
4615 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4616 // This information for client side use only
4617 // Recalculate bonus
4618 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4621 void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool /*Real*/)
4623 if(m_target->GetTypeId() != TYPEID_PLAYER)
4624 return;
4626 // Recalculate bonus
4627 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4630 void Aura::HandleModHealingDone(bool /*apply*/, bool /*Real*/)
4632 if(m_target->GetTypeId() != TYPEID_PLAYER)
4633 return;
4634 // implemented in Unit::SpellHealingBonus
4635 // this information is for client side only
4636 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4639 void Aura::HandleModTotalPercentStat(bool apply, bool /*Real*/)
4641 if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4)
4643 sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
4644 return;
4647 //save current and max HP before applying aura
4648 uint32 curHPValue = m_target->GetHealth();
4649 uint32 maxHPValue = m_target->GetMaxHealth();
4651 for (int32 i = STAT_STRENGTH; i < MAX_STATS; i++)
4653 if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1)
4655 m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply);
4656 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
4657 m_target->ApplyStatPercentBuffMod(Stats(i), m_modifier.m_amount, apply );
4661 //recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag)
4662 if ((m_modifier.m_miscvalue == STAT_STAMINA) && (maxHPValue > 0) && (m_spellProto->Attributes & 0x10))
4664 // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed
4665 uint32 newHPValue = (m_target->GetMaxHealth() * curHPValue) / maxHPValue;
4666 m_target->SetHealth(newHPValue);
4670 void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool /*Real*/)
4672 if(m_target->GetTypeId() != TYPEID_PLAYER)
4673 return;
4675 if(m_modifier.m_miscvalue != SPELL_SCHOOL_MASK_NORMAL)
4677 // support required adding replace UpdateArmor by loop by UpdateResistence at intellect update
4678 // and include in UpdateResistence same code as in UpdateArmor for aura mod apply.
4679 sLog.outError("Aura SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT(182) need adding support for non-armor resistances!");
4680 return;
4683 // Recalculate Armor
4684 m_target->UpdateArmor();
4687 /********************************/
4688 /*** HEAL & ENERGIZE ***/
4689 /********************************/
4690 void Aura::HandleAuraModTotalHealthPercentRegen(bool apply, bool /*Real*/)
4692 m_isPeriodic = apply;
4695 void Aura::HandleAuraModTotalManaPercentRegen(bool apply, bool /*Real*/)
4697 if(m_modifier.periodictime == 0)
4698 m_modifier.periodictime = 1000;
4700 m_periodicTimer = m_modifier.periodictime;
4701 m_isPeriodic = apply;
4704 void Aura::HandleModRegen(bool apply, bool /*Real*/) // eating
4706 if(m_modifier.periodictime == 0)
4707 m_modifier.periodictime = 5000;
4709 m_periodicTimer = 5000;
4710 m_isPeriodic = apply;
4713 void Aura::HandleModPowerRegen(bool apply, bool Real) // drinking
4715 if (!Real)
4716 return;
4718 Powers pt = m_target->getPowerType();
4719 if(m_modifier.periodictime == 0)
4721 // Anger Management (only spell use this aura for rage)
4722 if (pt == POWER_RAGE)
4723 m_modifier.periodictime = 3000;
4724 else
4725 m_modifier.periodictime = 2000;
4728 m_periodicTimer = 5000;
4730 if (m_target->GetTypeId() == TYPEID_PLAYER && m_modifier.m_miscvalue == POWER_MANA)
4731 ((Player*)m_target)->UpdateManaRegen();
4733 m_isPeriodic = apply;
4736 void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real)
4738 // spells required only Real aura add/remove
4739 if(!Real)
4740 return;
4742 if (m_target->GetTypeId() != TYPEID_PLAYER)
4743 return;
4745 // Update manaregen value
4746 if (m_modifier.m_miscvalue == POWER_MANA)
4747 ((Player*)m_target)->UpdateManaRegen();
4750 void Aura::HandleModManaRegen(bool /*apply*/, bool Real)
4752 // spells required only Real aura add/remove
4753 if(!Real)
4754 return;
4756 if (m_target->GetTypeId() != TYPEID_PLAYER)
4757 return;
4759 //Note: an increase in regen does NOT cause threat.
4760 ((Player*)m_target)->UpdateManaRegen();
4763 void Aura::HandleComprehendLanguage(bool apply, bool /*Real*/)
4765 if(apply)
4766 m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG);
4767 else
4768 m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG);
4771 void Aura::HandleAuraModIncreaseHealth(bool apply, bool Real)
4773 // Special case with temporary increase max/current health
4774 switch(GetId())
4776 case 12976: // Warrior Last Stand triggered spell
4777 case 28726: // Nightmare Seed ( Nightmare Seed )
4778 case 34511: // Valor (Bulwark of Kings, Bulwark of the Ancient Kings)
4779 case 44055: // Tremendous Fortitude (Battlemaster's Alacrity)
4780 case 50322: // Survival Instincts
4782 if(Real)
4784 if(apply)
4786 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4787 m_target->ModifyHealth(m_modifier.m_amount);
4789 else
4791 if (int32(m_target->GetHealth()) > m_modifier.m_amount)
4792 m_target->ModifyHealth(-m_modifier.m_amount);
4793 else
4794 m_target->SetHealth(1);
4795 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4798 return;
4802 // generic case
4803 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4806 void Aura::HandleAuraModIncreaseMaxHealth(bool apply, bool /*Real*/)
4808 uint32 oldhealth = m_target->GetHealth();
4809 double healthPercentage = (double)oldhealth / (double)m_target->GetMaxHealth();
4811 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4813 // refresh percentage
4814 if(oldhealth > 0)
4816 uint32 newhealth = uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage));
4817 if(newhealth==0)
4818 newhealth = 1;
4820 m_target->SetHealth(newhealth);
4824 void Aura::HandleAuraModIncreaseEnergy(bool apply, bool /*Real*/)
4826 Powers powerType = m_target->getPowerType();
4827 if(int32(powerType) != m_modifier.m_miscvalue)
4828 return;
4830 UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType);
4832 m_target->HandleStatModifier(unitMod, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4835 void Aura::HandleAuraModIncreaseEnergyPercent(bool apply, bool /*Real*/)
4837 Powers powerType = m_target->getPowerType();
4838 if(int32(powerType) != m_modifier.m_miscvalue)
4839 return;
4841 UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType);
4843 m_target->HandleStatModifier(unitMod, TOTAL_PCT, float(m_modifier.m_amount), apply);
4846 void Aura::HandleAuraModIncreaseHealthPercent(bool apply, bool /*Real*/)
4848 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_PCT, float(m_modifier.m_amount), apply);
4851 void Aura::HandleAuraIncreaseBaseHealthPercent(bool apply, bool /*Real*/)
4853 m_target->HandleStatModifier(UNIT_MOD_HEALTH, BASE_PCT, float(m_modifier.m_amount), apply);
4856 /********************************/
4857 /*** FIGHT ***/
4858 /********************************/
4860 void Aura::HandleAuraModParryPercent(bool /*apply*/, bool /*Real*/)
4862 if(m_target->GetTypeId()!=TYPEID_PLAYER)
4863 return;
4865 ((Player*)m_target)->UpdateParryPercentage();
4868 void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool /*Real*/)
4870 if(m_target->GetTypeId()!=TYPEID_PLAYER)
4871 return;
4873 ((Player*)m_target)->UpdateDodgePercentage();
4874 //sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount));
4877 void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool /*Real*/)
4879 if(m_target->GetTypeId()!=TYPEID_PLAYER)
4880 return;
4882 ((Player*)m_target)->UpdateBlockPercentage();
4883 //sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount));
4886 void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real)
4888 // spells required only Real aura add/remove
4889 if(!Real)
4890 return;
4892 if(m_target->GetTypeId()!=TYPEID_PLAYER)
4893 return;
4895 ((Player*)m_target)->UpdateManaRegen();
4898 void Aura::HandleAuraModCritPercent(bool apply, bool Real)
4900 if(m_target->GetTypeId()!=TYPEID_PLAYER)
4901 return;
4903 // apply item specific bonuses for already equipped weapon
4904 if(Real)
4906 for(int i = 0; i < MAX_ATTACK; ++i)
4907 if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i)))
4908 ((Player*)m_target)->_ApplyWeaponDependentAuraCritMod(pItem,WeaponAttackType(i),this,apply);
4911 // mods must be applied base at equipped weapon class and subclass comparison
4912 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
4913 // m_modifier.m_miscvalue comparison with item generated damage types
4915 if (GetSpellProto()->EquippedItemClass == -1)
4917 ((Player*)m_target)->HandleBaseModValue(CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
4918 ((Player*)m_target)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
4919 ((Player*)m_target)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
4921 else
4923 // done in Player::_ApplyWeaponDependentAuraMods
4927 void Aura::HandleModHitChance(bool apply, bool /*Real*/)
4929 if(m_target->GetTypeId() == TYPEID_PLAYER)
4931 ((Player*)m_target)->UpdateMeleeHitChances();
4932 ((Player*)m_target)->UpdateRangedHitChances();
4934 else
4936 m_target->m_modMeleeHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount);
4937 m_target->m_modRangedHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount);
4941 void Aura::HandleModSpellHitChance(bool apply, bool /*Real*/)
4943 if(m_target->GetTypeId() == TYPEID_PLAYER)
4945 ((Player*)m_target)->UpdateSpellHitChances();
4947 else
4949 m_target->m_modSpellHitChance += apply ? m_modifier.m_amount: (-m_modifier.m_amount);
4953 void Aura::HandleModSpellCritChance(bool apply, bool Real)
4955 // spells required only Real aura add/remove
4956 if(!Real)
4957 return;
4959 if(m_target->GetTypeId() == TYPEID_PLAYER)
4961 ((Player*)m_target)->UpdateAllSpellCritChances();
4963 else
4965 m_target->m_baseSpellCritChance += apply ? m_modifier.m_amount:(-m_modifier.m_amount);
4969 void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real)
4971 // spells required only Real aura add/remove
4972 if(!Real)
4973 return;
4975 if(m_target->GetTypeId() != TYPEID_PLAYER)
4976 return;
4978 for(int school = SPELL_SCHOOL_NORMAL; school < MAX_SPELL_SCHOOL; ++school)
4979 if (m_modifier.m_miscvalue & (1<<school))
4980 ((Player*)m_target)->UpdateSpellCritChance(school);
4983 /********************************/
4984 /*** ATTACK SPEED ***/
4985 /********************************/
4987 void Aura::HandleModCastingSpeed(bool apply, bool /*Real*/)
4989 m_target->ApplyCastTimePercentMod(m_modifier.m_amount,apply);
4992 void Aura::HandleModMeleeRangedSpeedPct(bool apply, bool /*Real*/)
4994 m_target->ApplyAttackTimePercentMod(BASE_ATTACK,m_modifier.m_amount,apply);
4995 m_target->ApplyAttackTimePercentMod(OFF_ATTACK,m_modifier.m_amount,apply);
4996 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply);
4999 void Aura::HandleModCombatSpeedPct(bool apply, bool /*Real*/)
5001 m_target->ApplyCastTimePercentMod(m_modifier.m_amount,apply);
5002 m_target->ApplyAttackTimePercentMod(BASE_ATTACK,m_modifier.m_amount,apply);
5003 m_target->ApplyAttackTimePercentMod(OFF_ATTACK,m_modifier.m_amount,apply);
5004 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply);
5007 void Aura::HandleModAttackSpeed(bool apply, bool /*Real*/)
5009 if(!m_target->isAlive() )
5010 return;
5012 m_target->ApplyAttackTimePercentMod(BASE_ATTACK,m_modifier.m_amount,apply);
5015 void Aura::HandleHaste(bool apply, bool /*Real*/)
5017 m_target->ApplyAttackTimePercentMod(BASE_ATTACK, m_modifier.m_amount,apply);
5018 m_target->ApplyAttackTimePercentMod(OFF_ATTACK, m_modifier.m_amount,apply);
5019 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK,m_modifier.m_amount,apply);
5022 void Aura::HandleAuraModRangedHaste(bool apply, bool /*Real*/)
5024 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply);
5027 void Aura::HandleRangedAmmoHaste(bool apply, bool /*Real*/)
5029 if(m_target->GetTypeId() != TYPEID_PLAYER)
5030 return;
5031 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK,m_modifier.m_amount, apply);
5034 /********************************/
5035 /*** ATTACK POWER ***/
5036 /********************************/
5038 void Aura::HandleAuraModAttackPower(bool apply, bool /*Real*/)
5040 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5043 void Aura::HandleAuraModRangedAttackPower(bool apply, bool /*Real*/)
5045 if((m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0)
5046 return;
5048 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5051 void Aura::HandleAuraModAttackPowerPercent(bool apply, bool /*Real*/)
5053 //UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1
5054 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_PCT, float(m_modifier.m_amount), apply);
5057 void Aura::HandleAuraModRangedAttackPowerPercent(bool apply, bool /*Real*/)
5059 if((m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0)
5060 return;
5062 //UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1
5063 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply);
5066 void Aura::HandleAuraModRangedAttackPowerOfStatPercent(bool /*apply*/, bool Real)
5068 // spells required only Real aura add/remove
5069 if(!Real)
5070 return;
5072 // Recalculate bonus
5073 if(m_target->GetTypeId() == TYPEID_PLAYER && !(m_target->getClassMask() & CLASSMASK_WAND_USERS))
5074 ((Player*)m_target)->UpdateAttackPowerAndDamage(true);
5077 void Aura::HandleAuraModAttackPowerOfStatPercent(bool /*apply*/, bool Real)
5079 // spells required only Real aura add/remove
5080 if(!Real)
5081 return;
5083 // Recalculate bonus
5084 if(m_target->GetTypeId() == TYPEID_PLAYER)
5085 ((Player*)m_target)->UpdateAttackPowerAndDamage(false);
5088 /********************************/
5089 /*** DAMAGE BONUS ***/
5090 /********************************/
5091 void Aura::HandleModDamageDone(bool apply, bool Real)
5093 // apply item specific bonuses for already equipped weapon
5094 if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
5096 for(int i = 0; i < MAX_ATTACK; ++i)
5097 if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i)))
5098 ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem,WeaponAttackType(i),this,apply);
5101 // m_modifier.m_miscvalue is bitmask of spell schools
5102 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5103 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wands
5104 // 127 - full bitmask any damages
5106 // mods must be applied base at equipped weapon class and subclass comparison
5107 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5108 // m_modifier.m_miscvalue comparison with item generated damage types
5110 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0)
5112 // apply generic physical damage bonuses including wand case
5113 if (GetSpellProto()->EquippedItemClass == -1 || m_target->GetTypeId() != TYPEID_PLAYER)
5115 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5116 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5117 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply);
5119 else
5121 // done in Player::_ApplyWeaponDependentAuraMods
5124 if(m_target->GetTypeId() == TYPEID_PLAYER)
5126 if(m_positive)
5127 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS,m_modifier.m_amount,apply);
5128 else
5129 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG,m_modifier.m_amount,apply);
5133 // Skip non magic case for speedup
5134 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0)
5135 return;
5137 if( GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0 )
5139 // wand magic case (skip generic to all item spell bonuses)
5140 // done in Player::_ApplyWeaponDependentAuraMods
5142 // Skip item specific requirements for not wand magic damage
5143 return;
5146 // Magic damage modifiers implemented in Unit::SpellDamageBonus
5147 // This information for client side use only
5148 if(m_target->GetTypeId() == TYPEID_PLAYER)
5150 if(m_positive)
5152 for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; i++)
5154 if((m_modifier.m_miscvalue & (1<<i)) != 0)
5155 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i,m_modifier.m_amount,apply);
5158 else
5160 for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; i++)
5162 if((m_modifier.m_miscvalue & (1<<i)) != 0)
5163 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG+i,m_modifier.m_amount,apply);
5166 Pet* pet = m_target->GetPet();
5167 if(pet)
5168 pet->UpdateAttackPowerAndDamage();
5172 void Aura::HandleModDamagePercentDone(bool apply, bool Real)
5174 sLog.outDebug("AURA MOD DAMAGE type:%u negative:%u", m_modifier.m_miscvalue, m_positive ? 0 : 1);
5176 // apply item specific bonuses for already equipped weapon
5177 if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
5179 for(int i = 0; i < MAX_ATTACK; ++i)
5180 if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i)))
5181 ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem,WeaponAttackType(i),this,apply);
5184 // m_modifier.m_miscvalue is bitmask of spell schools
5185 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5186 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wand
5187 // 127 - full bitmask any damages
5189 // mods must be applied base at equipped weapon class and subclass comparison
5190 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5191 // m_modifier.m_miscvalue comparison with item generated damage types
5193 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0)
5195 // apply generic physical damage bonuses including wand case
5196 if (GetSpellProto()->EquippedItemClass == -1 || m_target->GetTypeId() != TYPEID_PLAYER)
5198 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT, float(m_modifier.m_amount), apply);
5199 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply);
5200 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply);
5202 else
5204 // done in Player::_ApplyWeaponDependentAuraMods
5206 // For show in client
5207 if(m_target->GetTypeId() == TYPEID_PLAYER)
5208 m_target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT,m_modifier.m_amount/100.0f,apply);
5211 // Skip non magic case for speedup
5212 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0)
5213 return;
5215 if( GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0 )
5217 // wand magic case (skip generic to all item spell bonuses)
5218 // done in Player::_ApplyWeaponDependentAuraMods
5220 // Skip item specific requirements for not wand magic damage
5221 return;
5224 // Magic damage percent modifiers implemented in Unit::SpellDamageBonus
5225 // Send info to client
5226 if(m_target->GetTypeId() == TYPEID_PLAYER)
5227 for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
5228 m_target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT+i,m_modifier.m_amount/100.0f,apply);
5231 void Aura::HandleModOffhandDamagePercent(bool apply, bool Real)
5233 // spells required only Real aura add/remove
5234 if(!Real)
5235 return;
5237 sLog.outDebug("AURA MOD OFFHAND DAMAGE");
5239 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply);
5242 /********************************/
5243 /*** POWER COST ***/
5244 /********************************/
5246 void Aura::HandleModPowerCostPCT(bool apply, bool Real)
5248 // spells required only Real aura add/remove
5249 if(!Real)
5250 return;
5252 float amount = m_modifier.m_amount/100.0f;
5253 for(int i = 0; i < MAX_SPELL_SCHOOL; ++i)
5254 if(m_modifier.m_miscvalue & (1<<i))
5255 m_target->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+i,amount,apply);
5258 void Aura::HandleModPowerCost(bool apply, bool Real)
5260 // spells required only Real aura add/remove
5261 if(!Real)
5262 return;
5264 for(int i = 0; i < MAX_SPELL_SCHOOL; ++i)
5265 if(m_modifier.m_miscvalue & (1<<i))
5266 m_target->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER+i,m_modifier.m_amount,apply);
5269 void Aura::HandleNoReagentUseAura(bool /*Apply*/, bool Real)
5271 // spells required only Real aura add/remove
5272 if(!Real)
5273 return;
5274 if(m_target->GetTypeId() != TYPEID_PLAYER)
5275 return;
5276 uint32 mask[3] = {0, 0, 0};
5277 Unit::AuraList const& noReagent = m_target->GetAurasByType(SPELL_AURA_NO_REAGENT_USE);
5278 for(Unit::AuraList::const_iterator i = noReagent.begin(); i != noReagent.end(); ++i)
5280 uint32 const *ptr = (*i)->getAuraSpellClassMask();
5281 mask[0]|=ptr[0];
5282 mask[1]|=ptr[1];
5283 mask[2]|=ptr[2];
5286 m_target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1 , mask[0]);
5287 m_target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1+1, mask[1]);
5288 m_target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1+2, mask[2]);
5291 /*********************************************************/
5292 /*** OTHERS ***/
5293 /*********************************************************/
5295 void Aura::HandleShapeshiftBoosts(bool apply)
5297 uint32 spellId = 0;
5298 uint32 spellId2 = 0;
5299 uint32 HotWSpellId = 0;
5301 switch(GetModifier()->m_miscvalue)
5303 case FORM_CAT:
5304 spellId = 3025;
5305 HotWSpellId = 24900;
5306 break;
5307 case FORM_TREE:
5308 spellId = 5420;
5309 spellId2 = 34123;
5310 break;
5311 case FORM_TRAVEL:
5312 spellId = 5419;
5313 break;
5314 case FORM_AQUA:
5315 spellId = 5421;
5316 break;
5317 case FORM_BEAR:
5318 spellId = 1178;
5319 spellId2 = 21178;
5320 HotWSpellId = 24899;
5321 break;
5322 case FORM_DIREBEAR:
5323 spellId = 9635;
5324 spellId2 = 21178;
5325 HotWSpellId = 24899;
5326 break;
5327 case FORM_BATTLESTANCE:
5328 spellId = 21156;
5329 break;
5330 case FORM_DEFENSIVESTANCE:
5331 spellId = 7376;
5332 break;
5333 case FORM_BERSERKERSTANCE:
5334 spellId = 7381;
5335 break;
5336 case FORM_MOONKIN:
5337 spellId = 24905;
5338 // aura from effect trigger spell
5339 spellId2 = 24907;
5340 break;
5341 case FORM_FLIGHT:
5342 spellId = 33948;
5343 spellId2 = 34764;
5344 break;
5345 case FORM_FLIGHT_EPIC:
5346 spellId = 40122;
5347 spellId2 = 40121;
5348 break;
5349 case FORM_METAMORPHOSIS:
5350 spellId = 54817;
5351 spellId2 = 54879;
5352 break;
5353 case FORM_SPIRITOFREDEMPTION:
5354 spellId = 27792;
5355 spellId2 = 27795; // must be second, this important at aura remove to prevent to early iterator invalidation.
5356 break;
5357 case FORM_GHOSTWOLF:
5358 case FORM_AMBIENT:
5359 case FORM_GHOUL:
5360 case FORM_SHADOW:
5361 case FORM_STEALTH:
5362 case FORM_CREATURECAT:
5363 case FORM_CREATUREBEAR:
5364 spellId = 0;
5365 break;
5368 uint32 form = GetModifier()->m_miscvalue-1;
5370 if(apply)
5372 if (spellId) m_target->CastSpell(m_target, spellId, true, NULL, this );
5373 if (spellId2) m_target->CastSpell(m_target, spellId2, true, NULL, this);
5375 if(m_target->GetTypeId() == TYPEID_PLAYER)
5377 const PlayerSpellMap& sp_list = ((Player *)m_target)->GetSpellMap();
5378 for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
5380 if(itr->second->state == PLAYERSPELL_REMOVED) continue;
5381 if(itr->first==spellId || itr->first==spellId2) continue;
5382 SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
5383 if (!spellInfo || !(spellInfo->Attributes & (SPELL_ATTR_PASSIVE | (1<<7)))) continue;
5384 if (spellInfo->Stances & (1<<form))
5385 m_target->CastSpell(m_target, itr->first, true, NULL, this);
5387 //LotP
5388 if (((Player*)m_target)->HasSpell(17007))
5390 SpellEntry const *spellInfo = sSpellStore.LookupEntry(24932);
5391 if (spellInfo && spellInfo->Stances & (1<<form))
5392 m_target->CastSpell(m_target, 24932, true, NULL, this);
5394 // HotW
5395 if (HotWSpellId)
5397 Unit::AuraList const& mModTotalStatPct = m_target->GetAurasByType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE);
5398 for(Unit::AuraList::const_iterator i = mModTotalStatPct.begin(); i != mModTotalStatPct.end(); ++i)
5400 if ((*i)->GetSpellProto()->SpellIconID == 240 && (*i)->GetModifier()->m_miscvalue == 3)
5402 int32 HotWMod = (*i)->GetModifier()->m_amount;
5403 if(GetModifier()->m_miscvalue == FORM_CAT)
5404 HotWMod /= 2;
5406 m_target->CastCustomSpell(m_target, HotWSpellId, &HotWMod, NULL, NULL, true, NULL, this);
5407 break;
5413 else
5415 m_target->RemoveAurasDueToSpell(spellId);
5416 m_target->RemoveAurasDueToSpell(spellId2);
5418 Unit::AuraMap& tAuras = m_target->GetAuras();
5419 for (Unit::AuraMap::iterator itr = tAuras.begin(); itr != tAuras.end();)
5421 if (itr->second->IsRemovedOnShapeLost())
5423 m_target->RemoveAurasDueToSpell(itr->second->GetId());
5424 itr = tAuras.begin();
5426 else
5428 ++itr;
5433 /*double healthPercentage = (double)m_target->GetHealth() / (double)m_target->GetMaxHealth();
5434 m_target->SetHealth(uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage)));*/
5437 void Aura::HandleAuraEmpathy(bool apply, bool /*Real*/)
5439 if(m_target->GetTypeId() != TYPEID_UNIT)
5440 return;
5442 CreatureInfo const * ci = objmgr.GetCreatureTemplate(m_target->GetEntry());
5443 if(ci && ci->type == CREATURE_TYPE_BEAST)
5444 m_target->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO, apply);
5447 void Aura::HandleAuraUntrackable(bool apply, bool /*Real*/)
5449 if(apply)
5450 m_target->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE);
5451 else
5452 m_target->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE);
5455 void Aura::HandleAuraModPacify(bool apply, bool /*Real*/)
5457 if(m_target->GetTypeId() != TYPEID_PLAYER)
5458 return;
5460 if(apply)
5461 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
5462 else
5463 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
5466 void Aura::HandleAuraModPacifyAndSilence(bool apply, bool Real)
5468 HandleAuraModPacify(apply,Real);
5469 HandleAuraModSilence(apply,Real);
5472 void Aura::HandleAuraGhost(bool apply, bool /*Real*/)
5474 if(m_target->GetTypeId() != TYPEID_PLAYER)
5475 return;
5477 if(apply)
5479 m_target->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST);
5481 else
5483 m_target->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST);
5487 void Aura::HandleAuraAllowFlight(bool apply, bool Real)
5489 // all applied/removed only at real aura add/remove
5490 if(!Real)
5491 return;
5493 // allow fly
5494 WorldPacket data;
5495 if(apply)
5496 data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
5497 else
5498 data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
5499 data.append(m_target->GetPackGUID());
5500 data << uint32(0); // unk
5501 m_target->SendMessageToSet(&data, true);
5504 void Aura::HandleModRating(bool apply, bool Real)
5506 // spells required only Real aura add/remove
5507 if(!Real)
5508 return;
5510 if(m_target->GetTypeId() != TYPEID_PLAYER)
5511 return;
5513 for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating)
5514 if (m_modifier.m_miscvalue & (1 << rating))
5515 ((Player*)m_target)->ApplyRatingMod(CombatRating(rating), m_modifier.m_amount, apply);
5518 void Aura::HandleModRatingFromStat(bool apply, bool Real)
5520 // spells required only Real aura add/remove
5521 if(!Real)
5522 return;
5524 if(m_target->GetTypeId() != TYPEID_PLAYER)
5525 return;
5526 // Just recalculate ratings
5527 for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating)
5528 if (m_modifier.m_miscvalue & (1 << rating))
5529 ((Player*)m_target)->ApplyRatingMod(CombatRating(rating), 0, apply);
5532 void Aura::HandleForceMoveForward(bool apply, bool Real)
5534 if(!Real || m_target->GetTypeId() != TYPEID_PLAYER)
5535 return;
5536 if(apply)
5537 m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE);
5538 else
5539 m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE);
5542 void Aura::HandleAuraModExpertise(bool /*apply*/, bool /*Real*/)
5544 if(m_target->GetTypeId() != TYPEID_PLAYER)
5545 return;
5547 ((Player*)m_target)->UpdateExpertise(BASE_ATTACK);
5548 ((Player*)m_target)->UpdateExpertise(OFF_ATTACK);
5551 void Aura::HandleModTargetResistance(bool apply, bool Real)
5553 // spells required only Real aura add/remove
5554 if(!Real)
5555 return;
5556 // applied to damage as HandleNoImmediateEffect in Unit::CalcAbsorbResist and Unit::CalcArmorReducedDamage
5558 // show armor penetration
5559 if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL))
5560 m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE,m_modifier.m_amount, apply);
5562 // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy
5563 if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_SPELL)==SPELL_SCHOOL_MASK_SPELL)
5564 m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE,m_modifier.m_amount, apply);
5567 void Aura::HandleShieldBlockValue(bool apply, bool /*Real*/)
5569 BaseModType modType = FLAT_MOD;
5570 if(m_modifier.m_auraname == SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT)
5571 modType = PCT_MOD;
5573 if(m_target->GetTypeId() == TYPEID_PLAYER)
5574 ((Player*)m_target)->HandleBaseModValue(SHIELD_BLOCK_VALUE, modType, float(m_modifier.m_amount), apply);
5577 void Aura::HandleAuraRetainComboPoints(bool apply, bool Real)
5579 // spells required only Real aura add/remove
5580 if(!Real)
5581 return;
5583 if(m_target->GetTypeId() != TYPEID_PLAYER)
5584 return;
5586 Player *target = (Player*)m_target;
5588 // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler
5589 // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost)
5590 if( !apply && m_duration==0 && target->GetComboTarget())
5591 if(Unit* unit = ObjectAccessor::GetUnit(*m_target,target->GetComboTarget()))
5592 target->AddComboPoints(unit, -m_modifier.m_amount);
5595 void Aura::HandleModUnattackable( bool Apply, bool Real )
5597 if(Real && Apply)
5599 m_target->CombatStop();
5600 m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
5602 m_target->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE,Apply);
5605 void Aura::HandleSpiritOfRedemption( bool apply, bool Real )
5607 // spells required only Real aura add/remove
5608 if(!Real)
5609 return;
5611 // prepare spirit state
5612 if(apply)
5614 if(m_target->GetTypeId()==TYPEID_PLAYER)
5616 // disable breath/etc timers
5617 ((Player*)m_target)->StopMirrorTimers();
5619 // set stand state (expected in this form)
5620 if(!m_target->IsStandState())
5621 m_target->SetStandState(UNIT_STAND_STATE_STAND);
5624 m_target->SetHealth(1);
5626 // die at aura end
5627 else
5628 m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, GetSpellProto(), false);
5631 void Aura::CleanupTriggeredSpells()
5633 if (m_spellProto->SpellFamilyName == SPELLFAMILY_WARRIOR && m_spellProto->SpellFamilyFlags & 0x0000001000000020LL)
5635 // Blood Frenzy remove
5636 m_target->RemoveAurasDueToSpell(30069);
5637 m_target->RemoveAurasDueToSpell(30070);
5638 return;
5641 uint32 tSpellId = m_spellProto->EffectTriggerSpell[GetEffIndex()];
5642 if(!tSpellId)
5643 return;
5645 SpellEntry const* tProto = sSpellStore.LookupEntry(tSpellId);
5646 if(!tProto)
5647 return;
5649 if(GetSpellDuration(tProto) != -1)
5650 return;
5652 // needed for spell 43680, maybe others
5653 // TODO: is there a spell flag, which can solve this in a more sophisticated way?
5654 if(m_spellProto->EffectApplyAuraName[GetEffIndex()] == SPELL_AURA_PERIODIC_TRIGGER_SPELL &&
5655 GetSpellDuration(m_spellProto) == m_spellProto->EffectAmplitude[GetEffIndex()])
5656 return;
5657 m_target->RemoveAurasDueToSpell(tSpellId);
5660 void Aura::HandleSchoolAbsorb(bool apply, bool Real)
5662 if(!Real)
5663 return;
5665 // prevent double apply bonuses
5666 if(apply && (m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading()))
5668 if(Unit* caster = GetCaster())
5670 float DoneActualBenefit = 0.0f;
5671 switch(m_spellProto->SpellFamilyName)
5673 case SPELLFAMILY_PRIEST:
5674 if(m_spellProto->SpellFamilyFlags == 0x1) //PW:S
5676 //+30% from +healing bonus
5677 DoneActualBenefit = caster->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto)) * 0.3f;
5678 break;
5680 break;
5681 case SPELLFAMILY_MAGE:
5682 if(m_spellProto->SpellFamilyFlags == 0x80100 || m_spellProto->SpellFamilyFlags == 0x8 || m_spellProto->SpellFamilyFlags == 0x100000000LL)
5684 //frost ward, fire ward, ice barrier
5685 //+10% from +spd bonus
5686 DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.1f;
5687 break;
5689 break;
5690 case SPELLFAMILY_WARLOCK:
5691 if(m_spellProto->SpellFamilyFlags == 0x00)
5693 //shadow ward
5694 //+10% from +spd bonus
5695 DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.1f;
5696 break;
5698 break;
5699 default:
5700 break;
5703 DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto());
5705 m_modifier.m_amount += (int32)DoneActualBenefit;
5710 void Aura::PeriodicTick()
5712 if(!m_target->isAlive())
5713 return;
5715 switch(m_modifier.m_auraname)
5717 case SPELL_AURA_PERIODIC_DAMAGE:
5718 case SPELL_AURA_PERIODIC_DAMAGE_PERCENT:
5720 Unit *pCaster = GetCaster();
5721 if(!pCaster)
5722 return;
5724 if( GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA &&
5725 pCaster->SpellHitResult(m_target,GetSpellProto(),false)!=SPELL_MISS_NONE)
5726 return;
5728 // Check for immune (not use charges)
5729 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5730 return;
5732 // some auras remove at specific health level or more
5733 if(m_modifier.m_auraname==SPELL_AURA_PERIODIC_DAMAGE)
5735 switch(GetId())
5737 case 43093: case 31956: case 38801:
5738 case 35321: case 38363: case 39215:
5739 if(m_target->GetHealth() == m_target->GetMaxHealth() )
5741 m_target->RemoveAurasDueToSpell(GetId());
5742 return;
5744 break;
5745 case 38772:
5747 uint32 percent =
5748 GetEffIndex() < 2 && GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_DUMMY ?
5749 pCaster->CalculateSpellDamage(GetSpellProto(),GetEffIndex()+1,GetSpellProto()->EffectBasePoints[GetEffIndex()+1],m_target) :
5750 100;
5751 if(m_target->GetHealth()*100 >= m_target->GetMaxHealth()*percent )
5753 m_target->RemoveAurasDueToSpell(GetId());
5754 return;
5756 break;
5758 default:
5759 break;
5763 uint32 absorb=0;
5764 uint32 resist=0;
5765 CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
5767 // ignore non positive values (can be result apply spellmods to aura damage
5768 uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
5770 uint32 pdamage;
5772 if(m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE)
5774 pdamage = amount;
5776 // Calculate armor mitigation if it is a physical spell
5777 // But not for bleed mechanic spells
5778 if ( GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL &&
5779 GetEffectMechanic(GetSpellProto(), m_effIndex) != MECHANIC_BLEED)
5781 uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage);
5782 cleanDamage.damage += pdamage - pdamageReductedArmor;
5783 pdamage = pdamageReductedArmor;
5786 pdamage = pCaster->SpellDamageBonus(m_target, GetSpellProto(), pdamage, DOT, GetStackAmount());
5788 // Curse of Agony damage-per-tick calculation
5789 if (GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags & 0x0000000000000400LL) && GetSpellProto()->SpellIconID==544)
5791 // 1..4 ticks, 1/2 from normal tick damage
5792 if (m_duration>=((m_maxduration-m_modifier.periodictime)*2/3))
5793 pdamage = pdamage/2;
5794 // 9..12 ticks, 3/2 from normal tick damage
5795 else if(m_duration<((m_maxduration-m_modifier.periodictime)/3))
5796 pdamage += (pdamage+1)/2; // +1 prevent 0.5 damage possible lost at 1..4 ticks
5797 // 5..8 ticks have normal tick damage
5800 else
5801 pdamage = uint32(m_target->GetMaxHealth()*amount/100);
5803 //As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit
5804 // Reduce dot damage from resilience for players
5805 if (m_target->GetTypeId()==TYPEID_PLAYER)
5806 pdamage-=((Player*)m_target)->GetDotDamageReduction(pdamage);
5808 pCaster->CalcAbsorbResist(m_target, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist);
5810 sLog.outDetail("PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
5811 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb);
5813 WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size
5814 data.append(m_target->GetPackGUID());
5815 data.appendPackGUID(GetCasterGUID());
5816 data << uint32(GetId());
5817 data << uint32(1);
5818 data << uint32(m_modifier.m_auraname);
5819 data << (uint32)pdamage;
5820 data << uint32(0); // overkill
5821 data << (uint32)GetSpellSchoolMask(GetSpellProto()); // will be mask in 2.4.x
5822 data << (uint32)absorb;
5823 data << (uint32)resist;
5824 m_target->SendMessageToSet(&data,true);
5826 Unit* target = m_target; // aura can be deleted in DealDamage
5827 SpellEntry const* spellProto = GetSpellProto();
5829 // Set trigger flag
5830 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;// | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
5831 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
5832 pdamage = (pdamage <= absorb+resist) ? 0 : (pdamage-absorb-resist);
5833 if (pdamage)
5834 procVictim|=PROC_FLAG_TAKEN_ANY_DAMAGE;
5835 pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto);
5837 pCaster->DealDamage(target, pdamage, &cleanDamage, DOT, GetSpellSchoolMask(spellProto), spellProto, true);
5838 break;
5840 case SPELL_AURA_PERIODIC_LEECH:
5841 case SPELL_AURA_PERIODIC_HEALTH_FUNNEL:
5843 Unit *pCaster = GetCaster();
5844 if(!pCaster)
5845 return;
5847 if(!pCaster->isAlive())
5848 return;
5850 if( GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA &&
5851 pCaster->SpellHitResult(m_target,GetSpellProto(),false)!=SPELL_MISS_NONE)
5852 return;
5854 // Check for immune
5855 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5856 return;
5858 uint32 absorb=0;
5859 uint32 resist=0;
5860 CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
5862 uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
5864 //Calculate armor mitigation if it is a physical spell
5865 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL)
5867 uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage);
5868 cleanDamage.damage += pdamage - pdamageReductedArmor;
5869 pdamage = pdamageReductedArmor;
5872 pdamage = pCaster->SpellDamageBonus(m_target, GetSpellProto(), pdamage, DOT, GetStackAmount());
5874 //As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit
5875 // Reduce dot damage from resilience for players
5876 if (m_target->GetTypeId()==TYPEID_PLAYER)
5877 pdamage-=((Player*)m_target)->GetDotDamageReduction(pdamage);
5879 pCaster->CalcAbsorbResist(m_target, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist);
5881 if(m_target->GetHealth() < pdamage)
5882 pdamage = uint32(m_target->GetHealth());
5884 sLog.outDetail("PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
5885 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb);
5887 pCaster->SendSpellNonMeleeDamageLog(m_target, GetId(), pdamage, GetSpellSchoolMask(GetSpellProto()), absorb, resist, false, 0);
5890 Unit* target = m_target; // aura can be deleted in DealDamage
5891 SpellEntry const* spellProto = GetSpellProto();
5892 float multiplier = spellProto->EffectMultipleValue[GetEffIndex()] > 0 ? spellProto->EffectMultipleValue[GetEffIndex()] : 1;
5893 int32 stackAmount = GetStackAmount();
5895 // Set trigger flag
5896 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;// | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
5897 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
5898 pdamage = (pdamage <= absorb+resist) ? 0 : (pdamage-absorb-resist);
5899 if (pdamage)
5900 procVictim|=PROC_FLAG_TAKEN_ANY_DAMAGE;
5901 pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto);
5902 int32 new_damage = pCaster->DealDamage(target, pdamage, &cleanDamage, DOT, GetSpellSchoolMask(spellProto), spellProto, false);
5904 if (!target->isAlive() && pCaster->IsNonMeleeSpellCasted(false))
5906 for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++)
5908 if (pCaster->m_currentSpells[i] && pCaster->m_currentSpells[i]->m_spellInfo->Id == spellProto->Id)
5909 pCaster->m_currentSpells[i]->cancel();
5914 if(Player *modOwner = pCaster->GetSpellModOwner())
5915 modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_MULTIPLE_VALUE, multiplier);
5917 uint32 heal = pCaster->SpellHealingBonus(pCaster, spellProto, uint32(new_damage * multiplier), DOT, stackAmount);
5919 int32 gain = pCaster->DealHeal(pCaster, heal, spellProto);
5920 pCaster->getHostilRefManager().threatAssist(pCaster, gain * 0.5f, spellProto);
5921 break;
5923 case SPELL_AURA_PERIODIC_HEAL:
5924 case SPELL_AURA_OBS_MOD_HEALTH:
5926 Unit *pCaster = GetCaster();
5927 if(!pCaster)
5928 return;
5930 // heal for caster damage (must be alive)
5931 if(m_target != pCaster && GetSpellProto()->SpellVisual[0]==163 && !pCaster->isAlive())
5932 return;
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;
5939 if(m_modifier.m_auraname==SPELL_AURA_OBS_MOD_HEALTH)
5940 pdamage = uint32(m_target->GetMaxHealth() * amount/100);
5941 else
5942 pdamage = amount;
5944 pdamage = pCaster->SpellHealingBonus(m_target, GetSpellProto(), pdamage, DOT, GetStackAmount());
5946 sLog.outDetail("PeriodicTick: %u (TypeId: %u) heal of %u (TypeId: %u) for %u health inflicted by %u",
5947 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
5949 WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size
5950 data.append(m_target->GetPackGUID());
5951 data.appendPackGUID(GetCasterGUID());
5952 data << uint32(GetId());
5953 data << uint32(1);
5954 data << uint32(m_modifier.m_auraname);
5955 data << (uint32)pdamage;
5956 data << uint32(0); // wotlk
5957 m_target->SendMessageToSet(&data,true);
5959 int32 gain = m_target->ModifyHealth(pdamage);
5961 // add HoTs to amount healed in bgs
5962 if( pCaster->GetTypeId() == TYPEID_PLAYER )
5963 if( BattleGround *bg = ((Player*)pCaster)->GetBattleGround() )
5964 bg->UpdatePlayerScore(((Player*)pCaster), SCORE_HEALING_DONE, gain);
5966 m_target->getHostilRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto());
5968 SpellEntry const* spellProto = GetSpellProto();
5970 // heal for caster damage
5971 if(m_target!=pCaster && spellProto->SpellVisual[0]==163)
5973 uint32 dmg = spellProto->manaPerSecond;
5974 if(pCaster->GetHealth() <= dmg && pCaster->GetTypeId()==TYPEID_PLAYER)
5976 pCaster->RemoveAurasDueToSpell(GetId());
5978 // finish current generic/channeling spells, don't affect autorepeat
5979 if(pCaster->m_currentSpells[CURRENT_GENERIC_SPELL])
5981 pCaster->m_currentSpells[CURRENT_GENERIC_SPELL]->finish();
5983 if(pCaster->m_currentSpells[CURRENT_CHANNELED_SPELL])
5985 pCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]->SendChannelUpdate(0);
5986 pCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]->finish();
5989 else
5991 pCaster->SendSpellNonMeleeDamageLog(pCaster, GetId(), gain, GetSpellSchoolMask(GetSpellProto()), 0, 0, false, 0, false);
5993 CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
5994 pCaster->DealDamage(pCaster, gain, &cleanDamage, NODAMAGE, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
5998 // uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;// | PROC_FLAG_SUCCESSFUL_HEAL;
5999 // uint32 procVictim = 0;//ROC_FLAG_ON_TAKE_PERIODIC | PROC_FLAG_TAKEN_HEAL;
6000 // ignore item heals
6001 // if(procSpell && !haveCastItem)
6002 // pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto);
6003 break;
6005 case SPELL_AURA_PERIODIC_MANA_LEECH:
6007 if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS)
6008 return;
6010 Powers power = Powers(m_modifier.m_miscvalue);
6012 // power type might have changed between aura applying and tick (druid's shapeshift)
6013 if(m_target->getPowerType() != power)
6014 return;
6016 Unit *pCaster = GetCaster();
6017 if(!pCaster)
6018 return;
6020 if(!pCaster->isAlive())
6021 return;
6023 if( GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA &&
6024 pCaster->SpellHitResult(m_target,GetSpellProto(),false)!=SPELL_MISS_NONE)
6025 return;
6027 // Check for immune (not use charges)
6028 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6029 return;
6031 // ignore non positive values (can be result apply spellmods to aura damage
6032 uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6034 // Special case: draining x% of mana (up to a maximum of 2*x% of the caster's maximum mana)
6035 // It's mana percent cost spells, m_modifier.m_amount is percent drain from target
6036 if (m_spellProto->ManaCostPercentage)
6038 // max value
6039 uint32 maxmana = pCaster->GetMaxPower(power) * pdamage * 2 / 100;
6040 pdamage = m_target->GetMaxPower(power) * pdamage / 100;
6041 if(pdamage > maxmana)
6042 pdamage = maxmana;
6045 sLog.outDetail("PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u",
6046 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
6048 int32 drain_amount = m_target->GetPower(power) > pdamage ? pdamage : m_target->GetPower(power);
6050 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
6051 if (power == POWER_MANA && m_target->GetTypeId() == TYPEID_PLAYER)
6052 drain_amount -= ((Player*)m_target)->GetSpellCritDamageReduction(drain_amount);
6054 m_target->ModifyPower(power, -drain_amount);
6056 float gain_multiplier = 0;
6058 if(pCaster->GetMaxPower(power) > 0)
6060 gain_multiplier = GetSpellProto()->EffectMultipleValue[GetEffIndex()];
6062 if(Player *modOwner = pCaster->GetSpellModOwner())
6063 modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, gain_multiplier);
6066 WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size
6067 data.append(m_target->GetPackGUID());
6068 data.appendPackGUID(GetCasterGUID());
6069 data << uint32(GetId());
6070 data << uint32(1);
6071 data << uint32(m_modifier.m_auraname);
6072 data << (uint32)power; // power type
6073 data << (uint32)drain_amount;
6074 data << (float)gain_multiplier;
6075 m_target->SendMessageToSet(&data,true);
6077 int32 gain_amount = int32(drain_amount*gain_multiplier);
6079 if(gain_amount)
6081 int32 gain = pCaster->ModifyPower(power,gain_amount);
6082 m_target->AddThreat(pCaster, float(gain) * 0.5f, GetSpellSchoolMask(GetSpellProto()), GetSpellProto());
6084 break;
6086 case SPELL_AURA_PERIODIC_ENERGIZE:
6088 // ignore non positive values (can be result apply spellmods to aura damage
6089 uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6091 sLog.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u",
6092 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
6094 if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS)
6095 break;
6097 Powers power = Powers(m_modifier.m_miscvalue);
6099 if(m_target->GetMaxPower(power) == 0)
6100 break;
6102 WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size
6103 data.append(m_target->GetPackGUID());
6104 data.appendPackGUID(GetCasterGUID());
6105 data << uint32(GetId());
6106 data << uint32(1);
6107 data << uint32(m_modifier.m_auraname);
6108 data << (uint32)power; // power type
6109 data << (uint32)pdamage;
6110 m_target->SendMessageToSet(&data,true);
6112 int32 gain = m_target->ModifyPower(power,pdamage);
6114 if(Unit* pCaster = GetCaster())
6115 m_target->getHostilRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto());
6116 break;
6118 case SPELL_AURA_OBS_MOD_MANA:
6120 // ignore non positive values (can be result apply spellmods to aura damage
6121 uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6123 uint32 pdamage = uint32(m_target->GetMaxPower(POWER_MANA) * amount/100);
6125 sLog.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u mana inflicted by %u",
6126 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
6128 if(m_target->GetMaxPower(POWER_MANA) == 0)
6129 break;
6131 WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size
6132 data.append(m_target->GetPackGUID());
6133 data.appendPackGUID(GetCasterGUID());
6134 data << uint32(GetId());
6135 data << uint32(1);
6136 data << uint32(m_modifier.m_auraname);
6137 data << (uint32)0; // ?
6138 data << (uint32)pdamage;
6139 m_target->SendMessageToSet(&data,true);
6141 int32 gain = m_target->ModifyPower(POWER_MANA, pdamage);
6143 if(Unit* pCaster = GetCaster())
6144 m_target->getHostilRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto());
6145 break;
6147 case SPELL_AURA_POWER_BURN_MANA:
6149 Unit *pCaster = GetCaster();
6150 if(!pCaster)
6151 return;
6153 // Check for immune (not use charges)
6154 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
6155 return;
6157 int32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
6159 Powers powerType = Powers(m_modifier.m_miscvalue);
6161 if(!m_target->isAlive() || m_target->getPowerType() != powerType)
6162 return;
6164 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
6165 if (powerType == POWER_MANA && m_target->GetTypeId() == TYPEID_PLAYER)
6166 pdamage -= ((Player*)m_target)->GetSpellCritDamageReduction(pdamage);
6168 uint32 gain = uint32(-m_target->ModifyPower(powerType, -pdamage));
6170 gain = uint32(gain * GetSpellProto()->EffectMultipleValue[GetEffIndex()]);
6172 SpellEntry const* spellProto = GetSpellProto();
6173 //maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG
6174 SpellNonMeleeDamage damageInfo(pCaster, m_target, spellProto->Id, spellProto->SchoolMask);
6175 pCaster->CalculateSpellDamage(&damageInfo, gain, spellProto);
6176 pCaster->SendSpellNonMeleeDamageLog(&damageInfo);
6178 // Set trigger flag
6179 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;// | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
6180 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
6181 uint32 procEx = createProcExtendMask(&damageInfo, SPELL_MISS_NONE);
6182 if (damageInfo.damage)
6183 procVictim|=PROC_FLAG_TAKEN_ANY_DAMAGE;
6185 pCaster->ProcDamageAndSpell(damageInfo.target, procAttacker, procVictim, procEx, damageInfo.damage, BASE_ATTACK, spellProto);
6187 pCaster->DealSpellDamage(&damageInfo, true);
6188 break;
6190 case SPELL_AURA_MOD_REGEN:
6192 int32 gain = m_target->ModifyHealth(m_modifier.m_amount);
6193 if (Unit *caster = GetCaster())
6194 m_target->getHostilRefManager().threatAssist(caster, float(gain) * 0.5f, GetSpellProto());
6195 break;
6197 case SPELL_AURA_MOD_POWER_REGEN:
6199 Powers pt = m_target->getPowerType();
6200 if(int32(pt) != m_modifier.m_miscvalue)
6201 return;
6203 if ( GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED )
6205 // eating anim
6206 m_target->HandleEmoteCommand(EMOTE_ONESHOT_EAT);
6208 else if( GetId() == 20577 )
6210 // cannibalize anim
6211 m_target->HandleEmoteCommand(EMOTE_STATE_CANNIBALIZE);
6214 // Anger Management
6215 // amount = 1+ 16 = 17 = 3,4*5 = 10,2*5/3
6216 // so 17 is rounded amount for 5 sec tick grow ~ 1 range grow in 3 sec
6217 if(pt == POWER_RAGE)
6218 m_target->ModifyPower(pt, m_modifier.m_amount*3/5);
6219 break;
6221 // Here tick dummy auras
6222 case SPELL_AURA_PERIODIC_DUMMY:
6224 PeriodicDummyTick();
6225 break;
6227 case SPELL_AURA_PERIODIC_TRIGGER_SPELL:
6229 TriggerSpell();
6230 break;
6232 case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE:
6234 TriggerSpellWithValue();
6235 break;
6237 default:
6238 break;
6242 void Aura::PeriodicDummyTick()
6244 Unit *caster = GetCaster();
6245 SpellEntry const* spell = GetSpellProto();
6246 switch (spell->SpellFamilyName)
6248 case SPELLFAMILY_GENERIC:
6249 switch (spell->Id)
6251 // Drink
6252 case 430:
6253 case 431:
6254 case 432:
6255 case 1133:
6256 case 1135:
6257 case 1137:
6258 case 10250:
6259 case 22734:
6260 case 27089:
6261 case 34291:
6262 case 43706:
6263 case 46755:
6264 case 49472: // Drink Coffee
6265 case 61830:
6267 if (m_target->GetTypeId() != TYPEID_PLAYER)
6268 return;
6269 // Search SPELL_AURA_MOD_POWER_REGEN aura for this spell and add bonus
6270 Unit::AuraList const& aura = m_target->GetAurasByType(SPELL_AURA_MOD_POWER_REGEN);
6271 for(Unit::AuraList::const_iterator i = aura.begin(); i != aura.end(); ++i)
6273 if ((*i)->GetId() == GetId())
6275 (*i)->GetModifier()->m_amount = m_modifier.m_amount;
6276 ((Player*)m_target)->UpdateManaRegen();
6277 // Disable continue
6278 m_isPeriodic = false;
6279 return;
6282 return;
6284 // Forsaken Skills
6285 case 7054:
6287 // Possibly need cast one of them (but
6288 // 7038 Forsaken Skill: Swords
6289 // 7039 Forsaken Skill: Axes
6290 // 7040 Forsaken Skill: Daggers
6291 // 7041 Forsaken Skill: Maces
6292 // 7042 Forsaken Skill: Staves
6293 // 7043 Forsaken Skill: Bows
6294 // 7044 Forsaken Skill: Guns
6295 // 7045 Forsaken Skill: 2H Axes
6296 // 7046 Forsaken Skill: 2H Maces
6297 // 7047 Forsaken Skill: 2H Swords
6298 // 7048 Forsaken Skill: Defense
6299 // 7049 Forsaken Skill: Fire
6300 // 7050 Forsaken Skill: Frost
6301 // 7051 Forsaken Skill: Holy
6302 // 7053 Forsaken Skill: Shadow
6303 return;
6305 // // Panda
6306 // case 19230: break;
6307 // // Gossip NPC Periodic - Talk
6308 // case 33208: break;
6309 // // Gossip NPC Periodic - Despawn
6310 // case 33209: break;
6311 // // Steal Weapon
6312 // case 36207: break;
6313 // // Simon Game START timer, (DND)
6314 // case 39993: break;
6315 // // Knockdown Fel Cannon: break; The Aggro Burst
6316 // case 40119: break;
6317 // // Old Mount Spell
6318 // case 40154: break;
6319 // // Magnetic Pull
6320 // case 40581: break;
6321 // // Ethereal Ring: break; The Bolt Burst
6322 // case 40801: break;
6323 // // Crystal Prison
6324 // case 40846: break;
6325 // // Copy Weapon
6326 // case 41054: break;
6327 // // Dementia
6328 // case 41404: break;
6329 // // Ethereal Ring Visual, Lightning Aura
6330 // case 41477: break;
6331 // // Ethereal Ring Visual, Lightning Aura (Fork)
6332 // case 41525: break;
6333 // // Ethereal Ring Visual, Lightning Jumper Aura
6334 // case 41567: break;
6335 // // No Man's Land
6336 // case 41955: break;
6337 // // Headless Horseman - Fire
6338 // case 42074: break;
6339 // // Headless Horseman - Visual - Large Fire
6340 // case 42075: break;
6341 // // Headless Horseman - Start Fire, Periodic Aura
6342 // case 42140: break;
6343 // // Ram Speed Boost
6344 // case 42152: break;
6345 // // Headless Horseman - Fires Out Victory Aura
6346 // case 42235: break;
6347 // // Pumpkin Life Cycle
6348 // case 42280: break;
6349 // // Brewfest Request Chick Chuck Mug Aura
6350 // case 42537: break;
6351 // // Squashling
6352 // case 42596: break;
6353 // // Headless Horseman Climax, Head: Periodic
6354 // case 42603: break;
6355 // // Fire Bomb
6356 // case 42621: break;
6357 // // Headless Horseman - Conflagrate, Periodic Aura
6358 // case 42637: break;
6359 // // Headless Horseman - Create Pumpkin Treats Aura
6360 // case 42774: break;
6361 // // Headless Horseman Climax - Summoning Rhyme Aura
6362 // case 42879: break;
6363 // // Tricky Treat
6364 // case 42919: break;
6365 // // Giddyup!
6366 // case 42924: break;
6367 // // Ram - Trot
6368 // case 42992: break;
6369 // // Ram - Canter
6370 // case 42993: break;
6371 // // Ram - Gallop
6372 // case 42994: break;
6373 // // Ram Level - Neutral
6374 // case 43310: break;
6375 // // Headless Horseman - Maniacal Laugh, Maniacal, Delayed 17
6376 // case 43884: break;
6377 // // Wretched!
6378 // case 43963: break;
6379 // // Headless Horseman - Maniacal Laugh, Maniacal, other, Delayed 17
6380 // case 44000: break;
6381 // // Energy Feedback
6382 // case 44328: break;
6383 // // Romantic Picnic
6384 // case 45102: break;
6385 // // Romantic Picnic
6386 // case 45123: break;
6387 // // Looking for Love
6388 // case 45124: break;
6389 // // Kite - Lightning Strike Kite Aura
6390 // case 45197: break;
6391 // // Rocket Chicken
6392 // case 45202: break;
6393 // // Copy Offhand Weapon
6394 // case 45205: break;
6395 // // Upper Deck - Kite - Lightning Periodic Aura
6396 // case 45207: break;
6397 // // Kite -Sky Lightning Strike Kite Aura
6398 // case 45251: break;
6399 // // Ribbon Pole Dancer Check Aura
6400 // case 45390: break;
6401 // // Holiday - Midsummer, Ribbon Pole Periodic Visual
6402 // case 45406: break;
6403 // // Parachute
6404 // case 45472: break;
6405 // // Alliance Flag, Extra Damage Debuff
6406 // case 45898: break;
6407 // // Horde Flag, Extra Damage Debuff
6408 // case 45899: break;
6409 // // Ahune - Summoning Rhyme Aura
6410 // case 45926: break;
6411 // // Ahune - Slippery Floor
6412 // case 45945: break;
6413 // // Ahune's Shield
6414 // case 45954: break;
6415 // // Nether Vapor Lightning
6416 // case 45960: break;
6417 // // Darkness
6418 // case 45996: break;
6419 // // Summon Blood Elves Periodic
6420 // case 46041: break;
6421 // // Transform Visual Missile Periodic
6422 // case 46205: break;
6423 // // Find Opening Beam End
6424 // case 46333: break;
6425 // // Ice Spear Control Aura
6426 // case 46371: break;
6427 // // Hailstone Chill
6428 // case 46458: break;
6429 // // Hailstone Chill, Internal
6430 // case 46465: break;
6431 // // Chill, Internal Shifter
6432 // case 46549: break;
6433 // // Summon Ice Spear Knockback Delayer
6434 // case 46878: break;
6435 // // Burninate Effect
6436 // case 47214: break;
6437 // // Fizzcrank Practice Parachute
6438 // case 47228: break;
6439 // // Send Mug Control Aura
6440 // case 47369: break;
6441 // // Direbrew's Disarm (precast)
6442 // case 47407: break;
6443 // // Mole Machine Port Schedule
6444 // case 47489: break;
6445 // case 47941: break; // Crystal Spike
6446 // case 48200: break; // Healer Aura
6447 // case 48630: break; // Summon Gauntlet Mobs Periodic
6448 // case 49313: break; // Proximity Mine Area Aura
6449 // // Mole Machine Portal Schedule
6450 // case 49466: break;
6451 // case 49555: break; // Corpse Explode
6452 // case 49592: break; // Temporal Rift
6453 // case 49957: break; // Cutting Laser
6454 // case 50085: break; // Slow Fall
6455 // // Listening to Music
6456 // case 50493: break;
6457 // // Love Rocket Barrage
6458 // case 50530: break;
6459 // Exist more after, need add later
6460 default:
6461 break;
6463 break;
6464 case SPELLFAMILY_MAGE:
6466 // Mirror Image
6467 // if (spell->Id == 55342)
6468 // return;
6469 break;
6471 case SPELLFAMILY_WARRIOR:
6473 // Armored to the Teeth
6474 if (spell->SpellIconID == 3516)
6476 // Increases your attack power by $s1 for every $s2 armor value you have.
6477 // Calculate AP bonus (from 1 efect of this spell)
6478 int32 apBonus = m_modifier.m_amount * m_target->GetArmor() / m_target->CalculateSpellDamage(spell, 1, spell->EffectBasePoints[1], m_target);
6479 m_target->CastCustomSpell(m_target, 61217, &apBonus, &apBonus, 0, true, 0, this);
6480 return;
6482 break;
6484 case SPELLFAMILY_DRUID:
6486 switch (spell->Id)
6488 // Frenzied Regeneration
6489 case 22842:
6491 // Converts up to 10 rage per second into health for $d. Each point of rage is converted into ${$m2/10}.1% of max health.
6492 // Should be manauser
6493 if (m_target->getPowerType()!=POWER_RAGE)
6494 return;
6495 uint32 rage = m_target->GetPower(POWER_RAGE);
6496 // Nothing todo
6497 if (rage == 0)
6498 return;
6499 int32 mod = (rage < 100) ? rage : 100;
6500 int32 points = m_target->CalculateSpellDamage(spell, 1, spell->EffectBasePoints[1], m_target);
6501 int32 regen = m_target->GetMaxHealth() * (mod * points / 10) / 1000;
6502 m_target->CastCustomSpell(m_target, 22845, &regen, 0, 0, true, 0, this);
6503 m_target->SetPower(POWER_RAGE, rage-mod);
6504 return;
6506 // Force of Nature
6507 case 33831:
6508 return;
6509 default:
6510 break;
6512 break;
6514 case SPELLFAMILY_ROGUE:
6516 // switch (spell->Id)
6517 // {
6518 // Master of Subtlety
6519 // case 31666: break;
6520 // Killing Spree
6521 // case 51690: break;
6522 // Overkill
6523 // case 58428: break;
6524 // default:
6525 // break;
6526 // }
6527 break;
6529 case SPELLFAMILY_HUNTER:
6531 // Explosive Shot
6532 if (spell->SpellFamilyFlags & 0x8000000000000000LL)
6534 if (!caster)
6535 return;
6536 int32 damage = m_modifier.m_amount;
6537 // Full damage to target at 0 tick
6538 if (m_duration > m_modifier.periodictime)
6540 caster->CastCustomSpell(m_target, 53352, &damage, 0, 0, true, 0, this);
6541 return;
6543 damage/=4;
6544 caster->CastCustomSpell(m_target, 56298, &damage, 0, 0, true, 0, this);
6545 return;
6547 switch (spell->Id)
6549 // Harpooner's Mark
6550 // case 40084:
6551 // return;
6552 // Feeding Frenzy Rank 1
6553 case 53511:
6554 if ( m_target->GetHealth() * 100 < m_target->GetMaxHealth() * 35 )
6555 m_target->CastSpell(m_target, 60096, true, 0, this);
6556 return;
6557 // Feeding Frenzy Rank 2
6558 case 53512:
6559 if ( m_target->GetHealth() * 100 < m_target->GetMaxHealth() * 35 )
6560 m_target->CastSpell(m_target, 60097, true, 0, this);
6561 return;
6562 default:
6563 break;
6565 break;
6567 case SPELLFAMILY_SHAMAN:
6569 // Astral Shift
6570 if (spell->Id == 52179)
6572 // Periodic need for remove visual on stun/fear/silence lost
6573 if (!(m_target->GetUInt32Value(UNIT_FIELD_FLAGS)&(UNIT_FLAG_STUNNED|UNIT_FLAG_FLEEING|UNIT_FLAG_SILENCED)))
6574 m_target->RemoveAurasDueToSpell(52179);
6575 return;
6577 break;
6579 case SPELLFAMILY_DEATHKNIGHT:
6581 // Death and Decay
6582 if (spell->SpellFamilyFlags & 0x0000000000000020LL)
6584 if (caster)
6585 caster->CastCustomSpell(m_target, 52212, &m_modifier.m_amount, NULL, NULL, true, 0, this);
6586 return;
6588 // Raise Dead
6589 // if (spell->SpellFamilyFlags & 0x0000000000001000LL)
6590 // return;
6591 // Chains of Ice
6592 if (spell->SpellFamilyFlags & 0x0000400000000000LL)
6594 // Get 0 effect aura
6595 Aura *slow = m_target->GetAura(GetId(), 0);
6596 if (slow)
6598 slow->ApplyModifier(false, true);
6599 Modifier *mod = slow->GetModifier();
6600 mod->m_amount+= m_modifier.m_amount;
6601 if (mod->m_amount > 0) mod->m_amount = 0;
6602 slow->ApplyModifier(true, true);
6604 return;
6606 // Summon Gargoyle
6607 // if (spell->SpellFamilyFlags & 0x0000008000000000LL)
6608 // return;
6609 // Death Rune Mastery
6610 // if (spell->SpellFamilyFlags & 0x0000000000004000LL)
6611 // return;
6612 // Bladed Armor
6613 if (spell->SpellIconID == 2653)
6615 // Increases your attack power by $s1 for every $s2 armor value you have.
6616 // Calculate AP bonus (from 1 efect of this spell)
6617 int32 apBonus = m_modifier.m_amount * m_target->GetArmor() / m_target->CalculateSpellDamage(spell, 1, spell->EffectBasePoints[1], m_target);
6618 m_target->CastCustomSpell(m_target, 61217, &apBonus, &apBonus, 0, true, 0, this);
6619 return;
6621 // Reaping
6622 // if (spell->SpellIconID == 22)
6623 // return;
6624 // Blood of the North
6625 // if (spell->SpellIconID == 30412)
6626 // return;
6627 break;
6629 default:
6630 break;
6634 void Aura::HandlePreventFleeing(bool apply, bool Real)
6636 if(!Real)
6637 return;
6639 Unit::AuraList const& fearAuras = m_target->GetAurasByType(SPELL_AURA_MOD_FEAR);
6640 if( !fearAuras.empty() )
6642 if (apply)
6643 m_target->SetFeared(false, fearAuras.front()->GetCasterGUID());
6644 else
6645 m_target->SetFeared(true);
6649 void Aura::HandleManaShield(bool apply, bool Real)
6651 if(!Real)
6652 return;
6654 // prevent double apply bonuses
6655 if(apply && (m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading()))
6657 if(Unit* caster = GetCaster())
6659 float DoneActualBenefit = 0.0f;
6660 switch(m_spellProto->SpellFamilyName)
6662 case SPELLFAMILY_MAGE:
6663 if(m_spellProto->SpellFamilyFlags & 0x8000)
6665 // Mana Shield
6666 // +50% from +spd bonus
6667 DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.5f;
6668 break;
6670 break;
6671 default:
6672 break;
6675 DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto());
6677 m_modifier.m_amount += (int32)DoneActualBenefit;
6682 void Aura::HandleArenaPreparation(bool apply, bool Real)
6684 if(!Real)
6685 return;
6687 if(apply)
6688 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION);
6689 else
6690 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION);
6694 * Such auras are applied from a caster(=player) to a vehicle.
6695 * This has been verified using spell #49256
6697 void Aura::HandleAuraControlVehicle(bool apply, bool Real)
6699 if(!Real)
6700 return;
6702 Unit *player = GetCaster();
6703 Vehicle *vehicle = dynamic_cast<Vehicle*>(m_target);
6704 if(!player || player->GetTypeId()!=TYPEID_PLAYER || !vehicle)
6705 return;
6707 if (apply)
6709 if(Pet *pet = player->GetPet())
6710 pet->Remove(PET_SAVE_AS_CURRENT);
6711 ((Player*)player)->EnterVehicle(vehicle);
6713 else
6715 SpellEntry const *spell = GetSpellProto();
6717 // some SPELL_AURA_CONTROL_VEHICLE auras have a dummy effect on the player - remove them
6718 player->RemoveAurasDueToSpell(spell->Id);
6720 ((Player*)player)->ExitVehicle(vehicle);
6724 void Aura::HandleAuraConvertRune(bool apply, bool Real)
6726 if(!Real)
6727 return;
6729 if(m_target->GetTypeId() != TYPEID_PLAYER)
6730 return;
6732 Player *plr = (Player*)m_target;
6734 if(plr->getClass() != CLASS_DEATH_KNIGHT)
6735 return;
6737 // how to determine what rune need to be converted?
6738 for(uint32 i = 0; i < MAX_RUNES; ++i)
6740 if(apply)
6742 if(!plr->GetRuneCooldown(i))
6744 plr->ConvertRune(i, GetSpellProto()->EffectMiscValueB[m_effIndex]);
6745 break;
6748 else
6750 if(plr->GetCurrentRune(i) == GetSpellProto()->EffectMiscValueB[m_effIndex])
6752 plr->ConvertRune(i, plr->GetBaseRune(i));
6753 break;
6759 void Aura::HandlePhase(bool apply, bool Real)
6761 if(!Real)
6762 return;
6764 // always non stackable
6765 if(apply)
6767 Unit::AuraList const& phases = m_target->GetAurasByType(SPELL_AURA_PHASE);
6768 if(!phases.empty())
6769 m_target->RemoveAurasDueToSpell(phases.front()->GetId(),this);
6772 // no-phase is also phase state so same code for apply and remove
6774 // phase auras normally not expected at BG but anyway better check
6775 if(m_target->GetTypeId()==TYPEID_PLAYER)
6777 // drop flag at invisible in bg
6778 if(((Player*)m_target)->InBattleGround())
6779 if(BattleGround *bg = ((Player*)m_target)->GetBattleGround())
6780 bg->EventPlayerDroppedFlag((Player*)m_target);
6782 // GM-mode have mask 0xFFFFFFFF
6783 if(!((Player*)m_target)->isGameMaster())
6784 m_target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL,false);
6786 ((Player*)m_target)->GetSession()->SendSetPhaseShift(apply ? GetMiscValue() : PHASEMASK_NORMAL);
6788 if(GetEffIndex()==0)
6790 SpellAreaForAreaMapBounds saBounds = spellmgr.GetSpellAreaForAuraMapBounds(GetId());
6791 if(saBounds.first != saBounds.second)
6793 uint32 zone, area;
6794 m_target->GetZoneAndAreaId(zone,area);
6796 for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
6798 // some auras remove at aura remove
6799 if(!itr->second->IsFitToRequirements((Player*)m_target,zone,area))
6800 m_target->RemoveAurasDueToSpell(itr->second->spellId);
6801 // some auras applied at aura apply
6802 else if(itr->second->autocast)
6804 if( !m_target->HasAura(itr->second->spellId,0) )
6805 m_target->CastSpell(m_target,itr->second->spellId,true);
6811 else
6812 m_target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL,false);
6814 // need triggering visibility update base at phase update of not GM invisible (other GMs anyway see in any phases)
6815 if(m_target->GetVisibility()!=VISIBILITY_OFF)
6816 m_target->SetVisibility(m_target->GetVisibility());
6819 void Aura::UnregisterSingleCastAura()
6821 if (IsSingleTarget())
6823 Unit* caster = NULL;
6824 caster = GetCaster();
6825 if(caster)
6827 caster->GetSingleCastAuras().remove(this);
6829 else
6831 sLog.outError("Couldn't find the caster of the single target aura, may crash later!");
6832 assert(false);
6834 m_isSingleTargetAura = false;
6838 void Aura::HandleAuraSafeFall( bool Apply, bool Real )
6840 // implemented in WorldSession::HandleMovementOpcodes
6842 // only special case
6843 if(Apply && Real && GetId()==32474 && m_target->GetTypeId()==TYPEID_PLAYER)
6844 ((Player*)m_target)->ActivateTaxiPathTo(506,GetId());