[7272] Trailing whitespace cleaning
[getmangos.git] / src / game / SpellAuras.cpp
blobbe292b7f892cb79e4958babd9fefc210ac297b27
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 "SpellAuras.h"
33 #include "DynamicObject.h"
34 #include "Group.h"
35 #include "UpdateData.h"
36 #include "MapManager.h"
37 #include "ObjectAccessor.h"
38 #include "Policies/SingletonImp.h"
39 #include "Totem.h"
40 #include "Creature.h"
41 #include "Formulas.h"
42 #include "BattleGround.h"
43 #include "CreatureAI.h"
44 #include "Util.h"
45 #include "GridNotifiers.h"
46 #include "GridNotifiersImpl.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
100 &Aura::HandleAuraModParryPercent, // 47 SPELL_AURA_MOD_PARRY_PERCENT
101 &Aura::HandleUnused, // 48 SPELL_AURA_48
102 &Aura::HandleAuraModDodgePercent, // 49 SPELL_AURA_MOD_DODGE_PERCENT
103 &Aura::HandleNoImmediateEffect, // 50 SPELL_AURA_MOD_CRITICAL_HEALING_BONUS
104 &Aura::HandleAuraModBlockPercent, // 51 SPELL_AURA_MOD_BLOCK_PERCENT
105 &Aura::HandleAuraModCritPercent, // 52 SPELL_AURA_MOD_CRIT_PERCENT
106 &Aura::HandlePeriodicLeech, // 53 SPELL_AURA_PERIODIC_LEECH
107 &Aura::HandleModHitChance, // 54 SPELL_AURA_MOD_HIT_CHANCE
108 &Aura::HandleModSpellHitChance, // 55 SPELL_AURA_MOD_SPELL_HIT_CHANCE
109 &Aura::HandleAuraTransform, // 56 SPELL_AURA_TRANSFORM
110 &Aura::HandleModSpellCritChance, // 57 SPELL_AURA_MOD_SPELL_CRIT_CHANCE
111 &Aura::HandleAuraModIncreaseSwimSpeed, // 58 SPELL_AURA_MOD_INCREASE_SWIM_SPEED
112 &Aura::HandleNoImmediateEffect, // 59 SPELL_AURA_MOD_DAMAGE_DONE_CREATURE implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus
113 &Aura::HandleAuraModPacifyAndSilence, // 60 SPELL_AURA_MOD_PACIFY_SILENCE
114 &Aura::HandleAuraModScale, // 61 SPELL_AURA_MOD_SCALE
115 &Aura::HandlePeriodicHealthFunnel, // 62 SPELL_AURA_PERIODIC_HEALTH_FUNNEL
116 &Aura::HandleUnused, // 63 SPELL_AURA_PERIODIC_MANA_FUNNEL obsolete?
117 &Aura::HandlePeriodicManaLeech, // 64 SPELL_AURA_PERIODIC_MANA_LEECH
118 &Aura::HandleModCastingSpeed, // 65 SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK
119 &Aura::HandleFeignDeath, // 66 SPELL_AURA_FEIGN_DEATH
120 &Aura::HandleAuraModDisarm, // 67 SPELL_AURA_MOD_DISARM
121 &Aura::HandleAuraModStalked, // 68 SPELL_AURA_MOD_STALKED
122 &Aura::HandleSchoolAbsorb, // 69 SPELL_AURA_SCHOOL_ABSORB implemented in Unit::CalcAbsorbResist
123 &Aura::HandleUnused, // 70 SPELL_AURA_EXTRA_ATTACKS Useless, used by only one spell that has only visual effect
124 &Aura::HandleModSpellCritChanceShool, // 71 SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL
125 &Aura::HandleModPowerCostPCT, // 72 SPELL_AURA_MOD_POWER_COST_SCHOOL_PCT
126 &Aura::HandleModPowerCost, // 73 SPELL_AURA_MOD_POWER_COST_SCHOOL
127 &Aura::HandleNoImmediateEffect, // 74 SPELL_AURA_REFLECT_SPELLS_SCHOOL implemented in Unit::SpellHitResult
128 &Aura::HandleNoImmediateEffect, // 75 SPELL_AURA_MOD_LANGUAGE
129 &Aura::HandleFarSight, // 76 SPELL_AURA_FAR_SIGHT
130 &Aura::HandleModMechanicImmunity, // 77 SPELL_AURA_MECHANIC_IMMUNITY
131 &Aura::HandleAuraMounted, // 78 SPELL_AURA_MOUNTED
132 &Aura::HandleModDamagePercentDone, // 79 SPELL_AURA_MOD_DAMAGE_PERCENT_DONE
133 &Aura::HandleModPercentStat, // 80 SPELL_AURA_MOD_PERCENT_STAT
134 &Aura::HandleNoImmediateEffect, // 81 SPELL_AURA_SPLIT_DAMAGE_PCT
135 &Aura::HandleWaterBreathing, // 82 SPELL_AURA_WATER_BREATHING
136 &Aura::HandleModBaseResistance, // 83 SPELL_AURA_MOD_BASE_RESISTANCE
137 &Aura::HandleModRegen, // 84 SPELL_AURA_MOD_REGEN
138 &Aura::HandleModPowerRegen, // 85 SPELL_AURA_MOD_POWER_REGEN
139 &Aura::HandleChannelDeathItem, // 86 SPELL_AURA_CHANNEL_DEATH_ITEM
140 &Aura::HandleNoImmediateEffect, // 87 SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN implemented in Unit::MeleeDamageBonus and Unit::SpellDamageBonus
141 &Aura::HandleNoImmediateEffect, // 88 SPELL_AURA_MOD_HEALTH_REGEN_PERCENT
142 &Aura::HandlePeriodicDamagePCT, // 89 SPELL_AURA_PERIODIC_DAMAGE_PERCENT
143 &Aura::HandleUnused, // 90 SPELL_AURA_MOD_RESIST_CHANCE Useless
144 &Aura::HandleNoImmediateEffect, // 91 SPELL_AURA_MOD_DETECT_RANGE implemented in Creature::GetAttackDistance
145 &Aura::HandlePreventFleeing, // 92 SPELL_AURA_PREVENTS_FLEEING
146 &Aura::HandleModUnattackable, // 93 SPELL_AURA_MOD_UNATTACKABLE
147 &Aura::HandleNoImmediateEffect, // 94 SPELL_AURA_INTERRUPT_REGEN implemented in Player::RegenerateAll
148 &Aura::HandleAuraGhost, // 95 SPELL_AURA_GHOST
149 &Aura::HandleNoImmediateEffect, // 96 SPELL_AURA_SPELL_MAGNET implemented in Spell::SelectMagnetTarget
150 &Aura::HandleManaShield, // 97 SPELL_AURA_MANA_SHIELD implemented in Unit::CalcAbsorbResist
151 &Aura::HandleAuraModSkill, // 98 SPELL_AURA_MOD_SKILL_TALENT
152 &Aura::HandleAuraModAttackPower, // 99 SPELL_AURA_MOD_ATTACK_POWER
153 &Aura::HandleUnused, //100 SPELL_AURA_AURAS_VISIBLE obsolete? all player can see all auras now
154 &Aura::HandleModResistancePercent, //101 SPELL_AURA_MOD_RESISTANCE_PCT
155 &Aura::HandleNoImmediateEffect, //102 SPELL_AURA_MOD_MELEE_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonus
156 &Aura::HandleAuraModTotalThreat, //103 SPELL_AURA_MOD_TOTAL_THREAT
157 &Aura::HandleAuraWaterWalk, //104 SPELL_AURA_WATER_WALK
158 &Aura::HandleAuraFeatherFall, //105 SPELL_AURA_FEATHER_FALL
159 &Aura::HandleAuraHover, //106 SPELL_AURA_HOVER
160 &Aura::HandleAddModifier, //107 SPELL_AURA_ADD_FLAT_MODIFIER
161 &Aura::HandleAddModifier, //108 SPELL_AURA_ADD_PCT_MODIFIER
162 &Aura::HandleAddTargetTrigger, //109 SPELL_AURA_ADD_TARGET_TRIGGER
163 &Aura::HandleModPowerRegenPCT, //110 SPELL_AURA_MOD_POWER_REGEN_PERCENT
164 &Aura::HandleNULL, //111 SPELL_AURA_ADD_CASTER_HIT_TRIGGER
165 &Aura::HandleNoImmediateEffect, //112 SPELL_AURA_OVERRIDE_CLASS_SCRIPTS
166 &Aura::HandleNoImmediateEffect, //113 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus
167 &Aura::HandleNoImmediateEffect, //114 SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus
168 &Aura::HandleNoImmediateEffect, //115 SPELL_AURA_MOD_HEALING implemented in Unit::SpellBaseHealingBonusForVictim
169 &Aura::HandleNoImmediateEffect, //116 SPELL_AURA_MOD_REGEN_DURING_COMBAT
170 &Aura::HandleNoImmediateEffect, //117 SPELL_AURA_MOD_MECHANIC_RESISTANCE implemented in Unit::MagicSpellHitResult
171 &Aura::HandleNoImmediateEffect, //118 SPELL_AURA_MOD_HEALING_PCT implemented in Unit::SpellHealingBonus
172 &Aura::HandleUnused, //119 SPELL_AURA_SHARE_PET_TRACKING useless
173 &Aura::HandleAuraUntrackable, //120 SPELL_AURA_UNTRACKABLE
174 &Aura::HandleAuraEmpathy, //121 SPELL_AURA_EMPATHY
175 &Aura::HandleModOffhandDamagePercent, //122 SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT
176 &Aura::HandleModTargetResistance, //123 SPELL_AURA_MOD_TARGET_RESISTANCE
177 &Aura::HandleAuraModRangedAttackPower, //124 SPELL_AURA_MOD_RANGED_ATTACK_POWER
178 &Aura::HandleNoImmediateEffect, //125 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonus
179 &Aura::HandleNoImmediateEffect, //126 SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT implemented in Unit::MeleeDamageBonus
180 &Aura::HandleNoImmediateEffect, //127 SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus
181 &Aura::HandleModPossessPet, //128 SPELL_AURA_MOD_POSSESS_PET
182 &Aura::HandleAuraModIncreaseSpeed, //129 SPELL_AURA_MOD_SPEED_ALWAYS
183 &Aura::HandleAuraModIncreaseMountedSpeed, //130 SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS
184 &Aura::HandleNoImmediateEffect, //131 SPELL_AURA_MOD_RANGED_ATTACK_POWER_VERSUS implemented in Unit::MeleeDamageBonus
185 &Aura::HandleAuraModIncreaseEnergyPercent, //132 SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT
186 &Aura::HandleAuraModIncreaseHealthPercent, //133 SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT
187 &Aura::HandleAuraModRegenInterrupt, //134 SPELL_AURA_MOD_MANA_REGEN_INTERRUPT
188 &Aura::HandleModHealingDone, //135 SPELL_AURA_MOD_HEALING_DONE
189 &Aura::HandleNoImmediateEffect, //136 SPELL_AURA_MOD_HEALING_DONE_PERCENT implemented in Unit::SpellHealingBonus
190 &Aura::HandleModTotalPercentStat, //137 SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE
191 &Aura::HandleHaste, //138 SPELL_AURA_MOD_HASTE
192 &Aura::HandleForceReaction, //139 SPELL_AURA_FORCE_REACTION
193 &Aura::HandleAuraModRangedHaste, //140 SPELL_AURA_MOD_RANGED_HASTE
194 &Aura::HandleRangedAmmoHaste, //141 SPELL_AURA_MOD_RANGED_AMMO_HASTE
195 &Aura::HandleAuraModBaseResistancePCT, //142 SPELL_AURA_MOD_BASE_RESISTANCE_PCT
196 &Aura::HandleAuraModResistanceExclusive, //143 SPELL_AURA_MOD_RESISTANCE_EXCLUSIVE
197 &Aura::HandleNoImmediateEffect, //144 SPELL_AURA_SAFE_FALL implemented in WorldSession::HandleMovementOpcodes
198 &Aura::HandleAuraModPetTalentsPoints, //145 SPELL_AURA_MOD_PET_TALENT_POINTS
199 &Aura::HandleNoImmediateEffect, //146 SPELL_AURA_ALLOW_TAME_PET_TYPE
200 &Aura::HandleNULL, //147 SPELL_AURA_ADD_CREATURE_IMMUNITY
201 &Aura::HandleAuraRetainComboPoints, //148 SPELL_AURA_RETAIN_COMBO_POINTS
202 &Aura::HandleNoImmediateEffect, //149 SPELL_AURA_REDUCE_PUSHBACK
203 &Aura::HandleShieldBlockValue, //150 SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT
204 &Aura::HandleAuraTrackStealthed, //151 SPELL_AURA_TRACK_STEALTHED
205 &Aura::HandleNoImmediateEffect, //152 SPELL_AURA_MOD_DETECTED_RANGE implemented in Creature::GetAttackDistance
206 &Aura::HandleNoImmediateEffect, //153 SPELL_AURA_SPLIT_DAMAGE_FLAT
207 &Aura::HandleNoImmediateEffect, //154 SPELL_AURA_MOD_STEALTH_LEVEL
208 &Aura::HandleNoImmediateEffect, //155 SPELL_AURA_MOD_WATER_BREATHING
209 &Aura::HandleNoImmediateEffect, //156 SPELL_AURA_MOD_REPUTATION_GAIN
210 &Aura::HandleNULL, //157 SPELL_AURA_PET_DAMAGE_MULTI
211 &Aura::HandleShieldBlockValue, //158 SPELL_AURA_MOD_SHIELD_BLOCKVALUE
212 &Aura::HandleNoImmediateEffect, //159 SPELL_AURA_NO_PVP_CREDIT only for Honorless Target spell
213 &Aura::HandleNoImmediateEffect, //160 SPELL_AURA_MOD_AOE_AVOIDANCE implemented in Unit::MagicSpellHitResult
214 &Aura::HandleNoImmediateEffect, //161 SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT
215 &Aura::HandleAuraPowerBurn, //162 SPELL_AURA_POWER_BURN_MANA
216 &Aura::HandleNoImmediateEffect, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE
217 &Aura::HandleUnused, //164 useless, only one test spell
218 &Aura::HandleNoImmediateEffect, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus
219 &Aura::HandleAuraModAttackPowerPercent, //166 SPELL_AURA_MOD_ATTACK_POWER_PCT
220 &Aura::HandleAuraModRangedAttackPowerPercent, //167 SPELL_AURA_MOD_RANGED_ATTACK_POWER_PCT
221 &Aura::HandleNoImmediateEffect, //168 SPELL_AURA_MOD_DAMAGE_DONE_VERSUS implemented in Unit::SpellDamageBonus, Unit::MeleeDamageBonus
222 &Aura::HandleNoImmediateEffect, //169 SPELL_AURA_MOD_CRIT_PERCENT_VERSUS implemented in Unit::DealDamageBySchool, Unit::DoAttackDamage, Unit::SpellCriticalBonus
223 &Aura::HandleNULL, //170 SPELL_AURA_DETECT_AMORE only for Detect Amore spell
224 &Aura::HandleAuraModIncreaseSpeed, //171 SPELL_AURA_MOD_SPEED_NOT_STACK
225 &Aura::HandleAuraModIncreaseMountedSpeed, //172 SPELL_AURA_MOD_MOUNTED_SPEED_NOT_STACK
226 &Aura::HandleUnused, //173 SPELL_AURA_ALLOW_CHAMPION_SPELLS only for Proclaim Champion spell
227 &Aura::HandleModSpellDamagePercentFromStat, //174 SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT implemented in Unit::SpellBaseDamageBonus
228 &Aura::HandleModSpellHealingPercentFromStat, //175 SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT implemented in Unit::SpellBaseHealingBonus
229 &Aura::HandleSpiritOfRedemption, //176 SPELL_AURA_SPIRIT_OF_REDEMPTION only for Spirit of Redemption spell, die at aura end
230 &Aura::HandleNULL, //177 SPELL_AURA_AOE_CHARM
231 &Aura::HandleNoImmediateEffect, //178 SPELL_AURA_MOD_DEBUFF_RESISTANCE implemented in Unit::MagicSpellHitResult
232 &Aura::HandleNoImmediateEffect, //179 SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE implemented in Unit::SpellCriticalBonus
233 &Aura::HandleNoImmediateEffect, //180 SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS implemented in Unit::SpellDamageBonus
234 &Aura::HandleUnused, //181 SPELL_AURA_MOD_FLAT_SPELL_CRIT_DAMAGE_VERSUS unused
235 &Aura::HandleAuraModResistenceOfStatPercent, //182 SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT
236 &Aura::HandleNULL, //183 SPELL_AURA_MOD_CRITICAL_THREAT
237 &Aura::HandleNoImmediateEffect, //184 SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
238 &Aura::HandleNoImmediateEffect, //185 SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
239 &Aura::HandleNoImmediateEffect, //186 SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE implemented in Unit::MagicSpellHitResult
240 &Aura::HandleNoImmediateEffect, //187 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance
241 &Aura::HandleNoImmediateEffect, //188 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_CHANCE implemented in Unit::GetUnitCriticalChance
242 &Aura::HandleModRating, //189 SPELL_AURA_MOD_RATING
243 &Aura::HandleNULL, //190 SPELL_AURA_MOD_FACTION_REPUTATION_GAIN
244 &Aura::HandleAuraModUseNormalSpeed, //191 SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED
245 &Aura::HandleModMeleeRangedSpeedPct, //192 SPELL_AURA_HASTE_MELEE
246 &Aura::HandleModCombatSpeedPct, //193 SPELL_AURA_MELEE_SLOW (in fact combat (any type attack) speed pct)
247 &Aura::HandleUnused, //194 SPELL_AURA_MOD_IGNORE_ABSORB_SCHOOL
248 &Aura::HandleNoImmediateEffect, //195 SPELL_AURA_MOD_IGNORE_ABSORB_FOR_SPELL implement in Unit::CalculateSpellDamage
249 &Aura::HandleNULL, //196 SPELL_AURA_MOD_COOLDOWN
250 &Aura::HandleNoImmediateEffect, //197 SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE implemented in Unit::SpellCriticalBonus Unit::GetUnitCriticalChance
251 &Aura::HandleUnused, //198 SPELL_AURA_MOD_ALL_WEAPON_SKILLS
252 &Aura::HandleNoImmediateEffect, //199 SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT implemented in Unit::MagicSpellHitResult
253 &Aura::HandleNoImmediateEffect, //200 SPELL_AURA_MOD_XP_PCT implemented in Player::GiveXP
254 &Aura::HandleAuraAllowFlight, //201 SPELL_AURA_FLY this aura enable flight mode...
255 &Aura::HandleNoImmediateEffect, //202 SPELL_AURA_CANNOT_BE_DODGED implemented in Unit::RollPhysicalOutcomeAgainst
256 &Aura::HandleNoImmediateEffect, //203 SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE implemented in Unit::CalculateMeleeDamage and Unit::CalculateSpellDamage
257 &Aura::HandleNoImmediateEffect, //204 SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE implemented in Unit::CalculateMeleeDamage and Unit::CalculateSpellDamage
258 &Aura::HandleNULL, //205 vulnerable to school dmg?
259 &Aura::HandleNULL, //206 SPELL_AURA_MOD_SPEED_MOUNTED
260 &Aura::HandleAuraModIncreaseFlightSpeed, //207 SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED
261 &Aura::HandleAuraModIncreaseFlightSpeed, //208 SPELL_AURA_MOD_SPEED_FLIGHT, used only in spell: Flight Form (Passive)
262 &Aura::HandleAuraModIncreaseFlightSpeed, //209 SPELL_AURA_MOD_FLIGHT_SPEED_ALWAYS
263 &Aura::HandleNULL, //210 Commentator's Command
264 &Aura::HandleAuraModIncreaseFlightSpeed, //211 SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACK
265 &Aura::HandleAuraModRangedAttackPowerOfStatPercent, //212 SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT
266 &Aura::HandleNoImmediateEffect, //213 SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT implemented in Player::RewardRage
267 &Aura::HandleNULL, //214 Tamed Pet Passive
268 &Aura::HandleArenaPreparation, //215 SPELL_AURA_ARENA_PREPARATION
269 &Aura::HandleModCastingSpeed, //216 SPELL_AURA_HASTE_SPELLS
270 &Aura::HandleUnused, //217 unused
271 &Aura::HandleAuraModRangedHaste, //218 SPELL_AURA_HASTE_RANGED
272 &Aura::HandleModManaRegen, //219 SPELL_AURA_MOD_MANA_REGEN_FROM_STAT
273 &Aura::HandleModRatingFromStat, //220 SPELL_AURA_MOD_RATING_FROM_STAT
274 &Aura::HandleNULL, //221 ignored
275 &Aura::HandleUnused, //222 unused
276 &Aura::HandleNULL, //223 Cold Stare
277 &Aura::HandleUnused, //224 unused
278 &Aura::HandleNoImmediateEffect, //225 SPELL_AURA_PRAYER_OF_MENDING
279 &Aura::HandleAuraPeriodicDummy, //226 SPELL_AURA_PERIODIC_DUMMY
280 &Aura::HandlePeriodicTriggerSpellWithValue, //227 SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE
281 &Aura::HandleNoImmediateEffect, //228 stealth detection
282 &Aura::HandleNULL, //229 SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE
283 &Aura::HandleAuraModIncreaseMaxHealth, //230 Commanding Shout
284 &Aura::HandleNoImmediateEffect, //231 SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE
285 &Aura::HandleNoImmediateEffect, //232 SPELL_AURA_MECHANIC_DURATION_MOD implement in Unit::CalculateSpellDuration
286 &Aura::HandleNULL, //233 set model id to the one of the creature with id m_modifier.m_miscvalue
287 &Aura::HandleNoImmediateEffect, //234 SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK implement in Unit::CalculateSpellDuration
288 &Aura::HandleAuraModDispelResist, //235 SPELL_AURA_MOD_DISPEL_RESIST implement in Unit::MagicSpellHitResult
289 &Aura::HandleAuraControlVehicle, //236 SPELL_AURA_CONTROL_VEHICLE
290 &Aura::HandleModSpellDamagePercentFromAttackPower, //237 SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER implemented in Unit::SpellBaseDamageBonus
291 &Aura::HandleModSpellHealingPercentFromAttackPower, //238 SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER implemented in Unit::SpellBaseHealingBonus
292 &Aura::HandleAuraModScale, //239 SPELL_AURA_MOD_SCALE_2 only in Noggenfogger Elixir (16595) before 2.3.0 aura 61
293 &Aura::HandleAuraModExpertise, //240 SPELL_AURA_MOD_EXPERTISE
294 &Aura::HandleForceMoveForward, //241 Forces the player to move forward
295 &Aura::HandleUnused, //242 SPELL_AURA_MOD_SPELL_DAMAGE_FROM_HEALING
296 &Aura::HandleUnused, //243 used by two test spells
297 &Aura::HandleComprehendLanguage, //244 Comprehend language
298 &Aura::HandleUnused, //245 SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS
299 &Aura::HandleNoImmediateEffect, //246 SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL
300 &Aura::HandleUnused, //247 unused
301 &Aura::HandleNoImmediateEffect, //248 SPELL_AURA_MOD_COMBAT_RESULT_CHANCE implemented in Unit::RollMeleeOutcomeAgainst
302 &Aura::HandleAuraConvertRune, //249 SPELL_AURA_CONVERT_RUNE
303 &Aura::HandleAuraModIncreaseHealth, //250 SPELL_AURA_MOD_INCREASE_HEALTH_2
304 &Aura::HandleNULL, //251 SPELL_AURA_MOD_ENEMY_DODGE
305 &Aura::HandleNULL, //252 haste all?
306 &Aura::HandleNULL, //253 SPELL_AURA_MOD_BLOCK_CRIT_CHANCE
307 &Aura::HandleNULL, //254 SPELL_AURA_MOD_DISARM_SHIELD disarm Shield
308 &Aura::HandleNoImmediateEffect, //255 SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT implemented in Unit::SpellDamageBonus
309 &Aura::HandleNoReagentUseAura, //256 SPELL_AURA_NO_REAGENT_USE Use SpellClassMask for spell select
310 &Aura::HandleNULL, //257 SPELL_AURA_MOD_TARGET_RESIST_BY_SPELL_CLASS Use SpellClassMask for spell select
311 &Aura::HandleNULL, //258 SPELL_AURA_MOD_SPELL_VISUAL
312 &Aura::HandleNULL, //259 corrupt healing over time spell
313 &Aura::HandleNoImmediateEffect, //260 SPELL_AURA_SCREEN_EFFECT (miscvalue = id in ScreenEffect.dbc) not required any code
314 &Aura::HandlePhase, //261 SPELL_AURA_PHASE undetactable invisibility? implemented in Unit::isVisibleForOrDetect
315 &Aura::HandleNULL, //262
316 &Aura::HandleNULL, //263 SPELL_AURA_ALLOW_ONLY_ABILITY player can use only abilities set in SpellClassMask
317 &Aura::HandleNULL, //264 unused
318 &Aura::HandleNULL, //265 unused
319 &Aura::HandleNULL, //266 unused
320 &Aura::HandleNoImmediateEffect, //267 SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL implemented in Unit::IsImmunedToSpellEffect
321 &Aura::HandleAuraModAttackPowerOfStatPercent, //268 SPELL_AURA_MOD_ATTACK_POWER_OF_STAT_PERCENT
322 &Aura::HandleNULL, //269 ignore DR effects?
323 &Aura::HandleNULL, //270 SPELL_AURA_MOD_IGNORE_TARGET_RESIST
324 &Aura::HandleNoImmediateEffect, //271 SPELL_AURA_MOD_DAMAGE_FROM_CASTER implemented in Unit::SpellDamageBonus
325 &Aura::HandleNULL, //272 reduce spell cast time?
326 &Aura::HandleNULL, //273
327 &Aura::HandleNULL, //274 proc free shot?
328 &Aura::HandleNoImmediateEffect, //275 SPELL_AURA_MOD_IGNORE_SHAPESHIFT Use SpellClassMask for spell select
329 &Aura::HandleNULL, //276 mod damage % mechanic?
330 &Aura::HandleNoImmediateEffect, //277 SPELL_AURA_MOD_MAX_AFFECTED_TARGETS Use SpellClassMask for spell select
331 &Aura::HandleNULL, //278 SPELL_AURA_MOD_DISARM_RANGED disarm ranged weapon
332 &Aura::HandleNULL, //279
333 &Aura::HandleNULL, //280 SPELL_AURA_MOD_TARGET_ARMOR_PCT
334 &Aura::HandleNULL, //281 SPELL_AURA_MOD_HONOR_GAIN
335 &Aura::HandleAuraIncreaseBaseHealthPercent, //282 SPELL_AURA_INCREASE_BASE_HEALTH_PERCENT
336 &Aura::HandleNoImmediateEffect //283 SPELL_AURA_MOD_HEALING_RECEIVED implemented in Unit::SpellHealingBonus
339 Aura::Aura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem) :
340 m_spellmod(NULL), m_caster_guid(0), m_castItemGuid(castItem?castItem->GetGUID():0), m_target(target),
341 m_timeCla(1000), m_periodicTimer(0), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE),
342 m_effIndex(eff), m_auraSlot(MAX_AURAS), m_auraFlags(AFLAG_NONE), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),
343 m_positive(false), m_permanent(false), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false),
344 m_updated(false), m_isRemovedOnShapeLost(true), m_in_use(false)
346 assert(target);
348 assert(spellproto && spellproto == sSpellStore.LookupEntry( spellproto->Id ) && "`info` must be pointer to sSpellStore element");
350 m_spellProto = spellproto;
352 m_currentBasePoints = currentBasePoints ? *currentBasePoints : m_spellProto->EffectBasePoints[eff];
354 m_isPassive = IsPassiveSpell(GetId());
355 m_positive = IsPositiveEffect(GetId(), m_effIndex);
357 m_applyTime = time(NULL);
359 int32 damage;
360 if(!caster)
362 m_caster_guid = target->GetGUID();
363 damage = m_currentBasePoints+1; // stored value-1
364 m_maxduration = target->CalculateSpellDuration(m_spellProto, m_effIndex, target);
366 else
368 m_caster_guid = caster->GetGUID();
370 damage = caster->CalculateSpellDamage(m_spellProto,m_effIndex,m_currentBasePoints,target);
371 m_maxduration = caster->CalculateSpellDuration(m_spellProto, m_effIndex, target);
373 if (!damage && castItem && castItem->GetItemSuffixFactor())
375 ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(castItem->GetItemRandomPropertyId()));
376 if(item_rand_suffix)
378 for (int k=0; k<3; k++)
380 SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(item_rand_suffix->enchant_id[k]);
381 if(pEnchant)
383 for (int t=0; t<3; t++)
384 if(pEnchant->spellid[t] == m_spellProto->Id)
386 damage = uint32((item_rand_suffix->prefix[k]*castItem->GetItemSuffixFactor()) / 10000 );
387 break;
391 if(damage)
392 break;
398 if(m_maxduration == -1 || m_isPassive && m_spellProto->DurationIndex == 0)
399 m_permanent = true;
401 Player* modOwner = caster ? caster->GetSpellModOwner() : NULL;
403 if(!m_permanent && modOwner)
404 modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, m_maxduration);
406 m_duration = m_maxduration;
408 sLog.outDebug("Aura: construct Spellid : %u, Aura : %u Duration : %d Target : %d Damage : %d", m_spellProto->Id, m_spellProto->EffectApplyAuraName[eff], m_maxduration, m_spellProto->EffectImplicitTargetA[eff],damage);
410 m_effIndex = eff;
411 SetModifier(AuraType(m_spellProto->EffectApplyAuraName[eff]), damage, m_spellProto->EffectAmplitude[eff], m_spellProto->EffectMiscValue[eff]);
413 // Apply periodic time mod
414 if(modOwner && m_modifier.periodictime)
415 modOwner->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME, m_modifier.periodictime);
417 // Start periodic on next tick or at aura apply
418 if (!(m_spellProto->AttributesEx5 & SPELL_ATTR_EX5_START_PERIODIC_AT_APPLY))
419 m_periodicTimer += m_modifier.periodictime;
421 m_isDeathPersist = IsDeathPersistentSpell(m_spellProto);
423 m_procCharges = m_spellProto->procCharges;
424 if(modOwner)
425 modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges);
427 m_isRemovedOnShapeLost = (m_caster_guid==m_target->GetGUID() &&
428 m_spellProto->Stances &&
429 !(m_spellProto->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT) &&
430 !(m_spellProto->Attributes & SPELL_ATTR_NOT_SHAPESHIFT));
433 Aura::~Aura()
437 AreaAura::AreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target,
438 Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
440 m_isAreaAura = true;
442 // caster==NULL in constructor args if target==caster in fact
443 Unit* caster_ptr = caster ? caster : target;
445 m_radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(GetSpellProto()->EffectRadiusIndex[m_effIndex]));
446 if(Player* modOwner = caster_ptr->GetSpellModOwner())
447 modOwner->ApplySpellMod(GetId(), SPELLMOD_RADIUS, m_radius);
449 switch(spellproto->Effect[eff])
451 case SPELL_EFFECT_APPLY_AREA_AURA_PARTY:
452 m_areaAuraType = AREA_AURA_PARTY;
453 if(target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isTotem())
454 m_modifier.m_auraname = SPELL_AURA_NONE;
455 break;
456 case SPELL_EFFECT_APPLY_AREA_AURA_RAID:
457 m_areaAuraType = AREA_AURA_RAID;
458 if(target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isTotem())
459 m_modifier.m_auraname = SPELL_AURA_NONE;
460 break;
461 case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND:
462 m_areaAuraType = AREA_AURA_FRIEND;
463 break;
464 case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY:
465 m_areaAuraType = AREA_AURA_ENEMY;
466 if(target == caster_ptr)
467 m_modifier.m_auraname = SPELL_AURA_NONE; // Do not do any effect on self
468 break;
469 case SPELL_EFFECT_APPLY_AREA_AURA_PET:
470 m_areaAuraType = AREA_AURA_PET;
471 break;
472 case SPELL_EFFECT_APPLY_AREA_AURA_OWNER:
473 m_areaAuraType = AREA_AURA_OWNER;
474 if(target == caster_ptr)
475 m_modifier.m_auraname = SPELL_AURA_NONE;
476 break;
477 default:
478 sLog.outError("Wrong spell effect in AreaAura constructor");
479 ASSERT(false);
480 break;
484 AreaAura::~AreaAura()
488 PersistentAreaAura::PersistentAreaAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target,
489 Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
491 m_isPersistent = true;
494 PersistentAreaAura::~PersistentAreaAura()
498 SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target,
499 Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, target, caster, castItem)
501 if (caster)
502 m_casters_target_guid = caster->GetTypeId()==TYPEID_PLAYER ? ((Player*)caster)->GetSelection() : caster->GetUInt64Value(UNIT_FIELD_TARGET);
503 else
504 m_casters_target_guid = 0;
507 SingleEnemyTargetAura::~SingleEnemyTargetAura()
511 Unit* SingleEnemyTargetAura::GetTriggerTarget() const
513 return ObjectAccessor::GetUnit(*m_target, m_casters_target_guid);
516 Aura* CreateAura(SpellEntry const* spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item* castItem)
518 if (IsAreaAuraEffect(spellproto->Effect[eff]))
519 return new AreaAura(spellproto, eff, currentBasePoints, target, caster, castItem);
521 uint32 triggeredSpellId = spellproto->EffectTriggerSpell[eff];
523 if(SpellEntry const* triggeredSpellInfo = sSpellStore.LookupEntry(triggeredSpellId))
524 for (int i = 0; i < 3; ++i)
525 if (triggeredSpellInfo->EffectImplicitTargetA[i] == TARGET_SINGLE_ENEMY)
526 return new SingleEnemyTargetAura(spellproto, eff, currentBasePoints, target, caster, castItem);
528 return new Aura(spellproto, eff, currentBasePoints, target, caster, castItem);
531 Unit* Aura::GetCaster() const
533 if(m_caster_guid==m_target->GetGUID())
534 return m_target;
536 //return ObjectAccessor::GetUnit(*m_target,m_caster_guid);
537 //must return caster even if it's in another grid/map
538 Unit *unit = ObjectAccessor::GetObjectInWorld(m_caster_guid, (Unit*)NULL);
539 return unit && unit->IsInWorld() ? unit : NULL;
542 void Aura::SetModifier(AuraType t, int32 a, uint32 pt, int32 miscValue)
544 m_modifier.m_auraname = t;
545 m_modifier.m_amount = a;
546 m_modifier.m_miscvalue = miscValue;
547 m_modifier.periodictime = pt;
550 void Aura::Update(uint32 diff)
552 if (m_duration > 0)
554 m_duration -= diff;
555 if (m_duration < 0)
556 m_duration = 0;
557 m_timeCla -= diff;
559 // GetEffIndex()==0 prevent double/triple apply manaPerSecond/manaPerSecondPerLevel to same spell with many auras
560 // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0
561 if(GetEffIndex()==0 && m_timeCla <= 0)
563 if(Unit* caster = GetCaster())
565 Powers powertype = Powers(m_spellProto->powerType);
566 int32 manaPerSecond = m_spellProto->manaPerSecond + m_spellProto->manaPerSecondPerLevel * caster->getLevel();
567 m_timeCla = 1000;
568 if (manaPerSecond)
570 if(powertype==POWER_HEALTH)
571 caster->ModifyHealth(-manaPerSecond);
572 else
573 caster->ModifyPower(powertype,-manaPerSecond);
579 // Channeled aura required check distance from caster
580 if(IsChanneledSpell(m_spellProto) && m_caster_guid != m_target->GetGUID())
582 Unit* caster = GetCaster();
583 if(!caster)
585 m_target->RemoveAura(GetId(),GetEffIndex());
586 return;
589 // Get spell range
590 float radius;
591 SpellModOp mod;
592 if (m_spellProto->EffectRadiusIndex[GetEffIndex()])
594 radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellProto->EffectRadiusIndex[GetEffIndex()]));
595 mod = SPELLMOD_RADIUS;
597 else
599 radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellProto->rangeIndex));
600 mod = SPELLMOD_RANGE;
603 if(Player* modOwner = caster->GetSpellModOwner())
604 modOwner->ApplySpellMod(GetId(), mod, radius,NULL);
606 if(!caster->IsWithinDistInMap(m_target,radius))
608 m_target->RemoveAura(GetId(),GetEffIndex());
609 return;
613 if(m_isPeriodic && (m_duration >= 0 || m_isPassive || m_permanent))
615 m_periodicTimer -= diff;
616 if(m_periodicTimer <= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N
618 // update before applying (aura can be removed in TriggerSpell or PeriodicTick calls)
619 m_periodicTimer += m_modifier.periodictime;
620 PeriodicTick();
625 void AreaAura::Update(uint32 diff)
627 // update for the caster of the aura
628 if(m_caster_guid == m_target->GetGUID())
630 Unit* caster = m_target;
632 if( !caster->hasUnitState(UNIT_STAT_ISOLATED) )
634 Unit* owner = caster->GetCharmerOrOwner();
635 if (!owner)
636 owner = caster;
637 std::list<Unit *> targets;
639 switch(m_areaAuraType)
641 case AREA_AURA_PARTY:
643 Group *pGroup = NULL;
645 if (owner->GetTypeId() == TYPEID_PLAYER)
646 pGroup = ((Player*)owner)->GetGroup();
648 if( pGroup)
650 uint8 subgroup = ((Player*)owner)->GetSubGroup();
651 for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
653 Player* Target = itr->getSource();
654 if(Target && Target->isAlive() && Target->GetSubGroup()==subgroup && caster->IsFriendlyTo(Target))
656 if(caster->IsWithinDistInMap(Target, m_radius))
657 targets.push_back(Target);
658 Pet *pet = Target->GetPet();
659 if(pet && pet->isAlive() && caster->IsWithinDistInMap(pet, m_radius))
660 targets.push_back(pet);
664 else
666 // add owner
667 if( owner != caster && caster->IsWithinDistInMap(owner, m_radius) )
668 targets.push_back(owner);
669 // add caster's pet
670 Unit* pet = caster->GetPet();
671 if( pet && caster->IsWithinDistInMap(pet, m_radius))
672 targets.push_back(pet);
674 break;
676 case AREA_AURA_RAID:
678 Group *pGroup = NULL;
680 if (owner->GetTypeId() == TYPEID_PLAYER)
681 pGroup = ((Player*)owner)->GetGroup();
683 if( pGroup)
685 uint8 subgroup = ((Player*)owner)->GetSubGroup();
686 for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
688 Player* Target = itr->getSource();
689 if(Target && Target->isAlive() && caster->IsFriendlyTo(Target))
691 if(caster->IsWithinDistInMap(Target, m_radius))
692 targets.push_back(Target);
693 Pet *pet = Target->GetPet();
694 if(pet && pet->isAlive() && caster->IsWithinDistInMap(pet, m_radius))
695 targets.push_back(pet);
699 else
701 // add owner
702 if( owner != caster && caster->IsWithinDistInMap(owner, m_radius) )
703 targets.push_back(owner);
704 // add caster's pet
705 Unit* pet = caster->GetPet();
706 if( pet && caster->IsWithinDistInMap(pet, m_radius))
707 targets.push_back(pet);
709 break;
711 case AREA_AURA_FRIEND:
713 CellPair p(MaNGOS::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY()));
714 Cell cell(p);
715 cell.data.Part.reserved = ALL_DISTRICT;
716 cell.SetNoCreate();
718 MaNGOS::AnyFriendlyUnitInObjectRangeCheck u_check(caster, owner, m_radius);
719 MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck> searcher(caster,targets, u_check);
720 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
721 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyFriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
722 CellLock<GridReadGuard> cell_lock(cell, p);
723 cell_lock->Visit(cell_lock, world_unit_searcher, *caster->GetMap());
724 cell_lock->Visit(cell_lock, grid_unit_searcher, *caster->GetMap());
725 break;
727 case AREA_AURA_ENEMY:
729 CellPair p(MaNGOS::ComputeCellPair(caster->GetPositionX(), caster->GetPositionY()));
730 Cell cell(p);
731 cell.data.Part.reserved = ALL_DISTRICT;
732 cell.SetNoCreate();
734 MaNGOS::AnyAoETargetUnitInObjectRangeCheck u_check(caster, owner, m_radius); // No GetCharmer in searcher
735 MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck> searcher(caster, targets, u_check);
736 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, WorldTypeMapContainer > world_unit_searcher(searcher);
737 TypeContainerVisitor<MaNGOS::UnitListSearcher<MaNGOS::AnyAoETargetUnitInObjectRangeCheck>, GridTypeMapContainer > grid_unit_searcher(searcher);
738 CellLock<GridReadGuard> cell_lock(cell, p);
739 cell_lock->Visit(cell_lock, world_unit_searcher, *caster->GetMap());
740 cell_lock->Visit(cell_lock, grid_unit_searcher, *caster->GetMap());
741 break;
743 case AREA_AURA_OWNER:
744 case AREA_AURA_PET:
746 if(owner != caster)
747 targets.push_back(owner);
748 break;
752 for(std::list<Unit *>::iterator tIter = targets.begin(); tIter != targets.end(); tIter++)
754 if((*tIter)->HasAura(GetId(), m_effIndex))
755 continue;
757 if(SpellEntry const *actualSpellInfo = spellmgr.SelectAuraRankForPlayerLevel(GetSpellProto(), (*tIter)->getLevel()))
759 int32 actualBasePoints = m_currentBasePoints;
760 // recalculate basepoints for lower rank (all AreaAura spell not use custom basepoints?)
761 if(actualSpellInfo != GetSpellProto())
762 actualBasePoints = actualSpellInfo->EffectBasePoints[m_effIndex];
763 AreaAura *aur = new AreaAura(actualSpellInfo, m_effIndex, &actualBasePoints, (*tIter), caster, NULL);
764 aur->SetAuraDuration(GetAuraDuration());
765 (*tIter)->AddAura(aur);
769 Aura::Update(diff);
771 else // aura at non-caster
773 Unit * tmp_target = m_target;
774 Unit* caster = GetCaster();
775 uint32 tmp_spellId = GetId(), tmp_effIndex = m_effIndex;
777 // WARNING: the aura may get deleted during the update
778 // DO NOT access its members after update!
779 Aura::Update(diff);
781 // remove aura if out-of-range from caster (after teleport for example)
782 // or caster is isolated or caster no longer has the aura
783 // or caster is (no longer) friendly
784 bool needFriendly = (m_areaAuraType == AREA_AURA_ENEMY ? false : true);
785 if( !caster || caster->hasUnitState(UNIT_STAT_ISOLATED) ||
786 !caster->IsWithinDistInMap(tmp_target, m_radius) ||
787 !caster->HasAura(tmp_spellId, tmp_effIndex) ||
788 caster->IsFriendlyTo(tmp_target) != needFriendly
791 tmp_target->RemoveAura(tmp_spellId, tmp_effIndex);
793 else if( m_areaAuraType == AREA_AURA_PARTY) // check if in same sub group
795 // not check group if target == owner or target == pet
796 if (caster->GetCharmerOrOwnerGUID() != tmp_target->GetGUID() && caster->GetGUID() != tmp_target->GetCharmerOrOwnerGUID())
798 Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself();
800 Group *pGroup = check ? check->GetGroup() : NULL;
801 if( pGroup )
803 Player* checkTarget = tmp_target->GetCharmerOrOwnerPlayerOrPlayerItself();
804 if(!checkTarget || !pGroup->SameSubGroup(check, checkTarget))
805 tmp_target->RemoveAura(tmp_spellId, tmp_effIndex);
807 else
808 tmp_target->RemoveAura(tmp_spellId, tmp_effIndex);
811 else if( m_areaAuraType == AREA_AURA_RAID) // TODO: fix me!
813 // not check group if target == owner or target == pet
814 if (caster->GetCharmerOrOwnerGUID() != tmp_target->GetGUID() && caster->GetGUID() != tmp_target->GetCharmerOrOwnerGUID())
816 Player* check = caster->GetCharmerOrOwnerPlayerOrPlayerItself();
818 Group *pGroup = check ? check->GetGroup() : NULL;
819 if( pGroup )
821 Player* checkTarget = tmp_target->GetCharmerOrOwnerPlayerOrPlayerItself();
822 if(!checkTarget)
823 tmp_target->RemoveAura(tmp_spellId, tmp_effIndex);
825 else
826 tmp_target->RemoveAura(tmp_spellId, tmp_effIndex);
829 else if( m_areaAuraType == AREA_AURA_PET || m_areaAuraType == AREA_AURA_OWNER )
831 if( tmp_target->GetGUID() != caster->GetCharmerOrOwnerGUID() )
832 tmp_target->RemoveAura(tmp_spellId, tmp_effIndex);
837 void PersistentAreaAura::Update(uint32 diff)
839 bool remove = false;
841 // remove the aura if its caster or the dynamic object causing it was removed
842 // or if the target moves too far from the dynamic object
843 Unit *caster = GetCaster();
844 if (caster)
846 DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex());
847 if (dynObj)
849 if (!m_target->IsWithinDistInMap(dynObj, dynObj->GetRadius()))
850 remove = true;
852 else
853 remove = true;
855 else
856 remove = true;
858 Unit *tmp_target = m_target;
859 uint32 tmp_id = GetId(), tmp_index = GetEffIndex();
861 // WARNING: the aura may get deleted during the update
862 // DO NOT access its members after update!
863 Aura::Update(diff);
865 if(remove)
866 tmp_target->RemoveAura(tmp_id, tmp_index);
869 void Aura::ApplyModifier(bool apply, bool Real)
871 AuraType aura = m_modifier.m_auraname;
873 m_in_use = true;
874 if(aura<TOTAL_AURAS)
875 (*this.*AuraHandler [aura])(apply,Real);
876 m_in_use = false;
879 void Aura::_AddAura()
881 if (!GetId())
882 return;
883 if(!m_target)
884 return;
886 // Second aura if some spell
887 bool secondaura = false;
888 // Try find slot for aura
889 uint8 slot = NULL_AURA_SLOT;
890 // Lookup for some spell auras (and get slot from it)
891 for(uint8 i = 0; i < m_effIndex; i++)
893 Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), i);
894 for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr)
896 // allow use single slot only by auras from same caster
897 if(itr->second->GetCasterGUID()==GetCasterGUID())
899 slot = itr->second->GetAuraSlot();
900 secondaura = true;
901 break;
904 if (secondaura)
905 break;
907 // Lookup free slot
908 if (!secondaura && m_target->GetVisibleAurasCount() < MAX_AURAS)
910 Unit::VisibleAuraMap const *visibleAuras = m_target->GetVisibleAuras();
911 for(uint8 i = 0; i < MAX_AURAS; ++i)
913 Unit::VisibleAuraMap::const_iterator itr = visibleAuras->find(i);
914 if(itr == visibleAuras->end())
916 slot = i;
917 // update for out of range group members (on 1 slot use)
918 m_target->UpdateAuraForGroup(slot);
919 break;
924 Unit* caster = GetCaster();
926 // passive auras (except totem auras) do not get placed in the slots
927 // area auras with SPELL_AURA_NONE are not shown on target
928 if((!m_isPassive || (caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem())) &&
929 (m_spellProto->Effect[GetEffIndex()] != SPELL_EFFECT_APPLY_AREA_AURA_ENEMY || m_target != caster))
931 SetAuraSlot( slot );
932 if(slot < MAX_AURAS) // slot found send data to client
934 SetAura(false);
935 SetAuraFlags((1 << GetEffIndex()) | AFLAG_NOT_CASTER | ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION : AFLAG_NONE) | (IsPositive() ? AFLAG_POSITIVE : AFLAG_NEGATIVE));
936 SetAuraLevel(caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
937 SendAuraUpdate(false);
940 //*****************************************************
941 // Update target aura state flag (at 1 aura apply)
942 // TODO: Make it easer
943 //*****************************************************
944 if (!secondaura)
946 // Sitdown on apply aura req seated
947 if (m_spellProto->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED && !m_target->IsSitState())
948 m_target->SetStandState(UNIT_STAND_STATE_SIT);
950 // register aura diminishing on apply
951 if (getDiminishGroup() != DIMINISHING_NONE )
952 m_target->ApplyDiminishingAura(getDiminishGroup(),true);
954 // Update Seals information
955 if (IsSealSpell(m_spellProto))
956 m_target->ModifyAuraState(AURA_STATE_JUDGEMENT, true);
958 // Conflagrate aura state on Immolate
959 if (m_spellProto->SpellFamilyName == SPELLFAMILY_WARLOCK && m_spellProto->SpellFamilyFlags & 4)
960 m_target->ModifyAuraState(AURA_STATE_IMMOLATE, true);
962 // Faerie Fire (druid versions)
963 if (m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && m_spellProto->SpellFamilyFlags & 0x0000000000000400LL)
964 m_target->ModifyAuraState(AURA_STATE_FAERIE_FIRE, true);
966 // Victorious
967 if (m_spellProto->SpellFamilyName == SPELLFAMILY_WARRIOR && m_spellProto->SpellFamilyFlags & 0x0004000000000000LL)
968 m_target->ModifyAuraState(AURA_STATE_WARRIOR_VICTORY_RUSH, true);
970 // Swiftmend state on Regrowth & Rejuvenation
971 if (m_spellProto->SpellFamilyName == SPELLFAMILY_DRUID && m_spellProto->SpellFamilyFlags & 0x50 )
972 m_target->ModifyAuraState(AURA_STATE_SWIFTMEND, true);
974 // Deadly poison aura state
975 if(m_spellProto->SpellFamilyName == SPELLFAMILY_ROGUE && m_spellProto->SpellFamilyFlags & 0x10000)
976 m_target->ModifyAuraState(AURA_STATE_DEADLY_POISON, true);
978 // Enrage aura state
979 if(m_spellProto->Dispel == DISPEL_ENRAGE)
980 m_target->ModifyAuraState(AURA_STATE_ENRAGE, true);
985 void Aura::_RemoveAura()
987 // Remove all triggered by aura spells vs unlimited duration
988 // except same aura replace case
989 if(m_removeMode!=AURA_REMOVE_BY_STACK)
990 CleanupTriggeredSpells();
992 Unit* caster = GetCaster();
994 if(caster && IsPersistent())
996 DynamicObject *dynObj = caster->GetDynObject(GetId(), GetEffIndex());
997 if (dynObj)
998 dynObj->RemoveAffected(m_target);
1001 //passive auras do not get put in slots
1002 // Note: but totem can be not accessible for aura target in time remove (to far for find in grid)
1003 //if(m_isPassive && !(caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->isTotem()))
1004 // return;
1006 uint8 slot = GetAuraSlot();
1008 if(slot >= MAX_AURAS) // slot not set
1009 return;
1011 if(m_target->GetVisibleAura(slot) == 0)
1012 return;
1014 bool lastaura = true;
1016 // find other aura in same slot (current already removed from list)
1017 for(uint8 i = 0; i < 3; i++)
1019 Unit::spellEffectPair spair = Unit::spellEffectPair(GetId(), i);
1020 for(Unit::AuraMap::const_iterator itr = m_target->GetAuras().lower_bound(spair); itr != m_target->GetAuras().upper_bound(spair); ++itr)
1022 if(itr->second->GetAuraSlot()==slot)
1024 lastaura = false;
1025 break;
1028 if(!lastaura)
1029 break;
1032 // only remove icon when the last aura of the spell is removed (current aura already removed from list)
1033 if (lastaura)
1035 // unregister aura diminishing (and store last time)
1036 if (getDiminishGroup() != DIMINISHING_NONE )
1037 m_target->ApplyDiminishingAura(getDiminishGroup(),false);
1039 SetAura(true);
1040 SetAuraFlags(AFLAG_NONE);
1041 SetAuraLevel(0);
1042 SendAuraUpdate(true);
1044 // update for out of range group members
1045 m_target->UpdateAuraForGroup(slot);
1047 //*****************************************************
1048 // Update target aura state flag (at last aura remove)
1049 //*****************************************************
1050 // Enrage aura state
1051 if(m_spellProto->Dispel == DISPEL_ENRAGE)
1052 m_target->ModifyAuraState(AURA_STATE_ENRAGE, false);
1054 uint32 removeState = 0;
1055 switch(m_spellProto->SpellFamilyName)
1057 case SPELLFAMILY_PALADIN:
1058 if (IsSealSpell(m_spellProto))
1059 removeState = AURA_STATE_JUDGEMENT; // Update Seals information
1060 break;
1061 case SPELLFAMILY_WARLOCK:
1062 if(m_spellProto->SpellFamilyFlags & 4)
1063 removeState = AURA_STATE_IMMOLATE; // Conflagrate aura state
1064 break;
1065 case SPELLFAMILY_DRUID:
1066 if(m_spellProto->SpellFamilyFlags & 0x0000000000000400LL)
1067 removeState = AURA_STATE_FAERIE_FIRE; // Faerie Fire (druid versions)
1068 else if(m_spellProto->SpellFamilyFlags & 0x50)
1069 removeState = AURA_STATE_SWIFTMEND; // Swiftmend aura state
1070 break;
1071 case SPELLFAMILY_WARRIOR:
1072 if(m_spellProto->SpellFamilyFlags & 0x0004000000000000LL)
1073 removeState = AURA_STATE_WARRIOR_VICTORY_RUSH; // Victorious
1074 break;
1075 case SPELLFAMILY_ROGUE:
1076 if(m_spellProto->SpellFamilyFlags & 0x10000)
1077 removeState = AURA_STATE_DEADLY_POISON; // Deadly poison aura state
1078 break;
1079 case SPELLFAMILY_HUNTER:
1080 if(m_spellProto->SpellFamilyFlags & 0x1000000000000000LL)
1081 removeState = AURA_STATE_FAERIE_FIRE; // Sting (hunter versions)
1084 // Remove state (but need check other auras for it)
1085 if (removeState)
1087 bool found = false;
1088 Unit::AuraMap& Auras = m_target->GetAuras();
1089 for(Unit::AuraMap::iterator i = Auras.begin(); i != Auras.end(); ++i)
1091 SpellEntry const *auraSpellInfo = (*i).second->GetSpellProto();
1092 if(auraSpellInfo->SpellFamilyName == m_spellProto->SpellFamilyName &&
1093 auraSpellInfo->SpellFamilyFlags == m_spellProto->SpellFamilyFlags )
1095 found = true;
1096 break;
1099 // this has been last aura
1100 if(!found)
1101 m_target->ModifyAuraState(AuraState(removeState), false);
1104 // reset cooldown state for spells
1105 if(caster && caster->GetTypeId() == TYPEID_PLAYER)
1107 if ( GetSpellProto()->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE )
1108 ((Player*)caster)->SendCooldownEvent(GetSpellProto());
1113 void Aura::SendAuraUpdate(bool remove)
1115 WorldPacket data(SMSG_AURA_UPDATE);
1116 data.append(m_target->GetPackGUID());
1117 data << uint8(GetAuraSlot());
1118 data << uint32(remove ? 0 : GetId());
1120 if(remove)
1122 m_target->SendMessageToSet(&data, true);
1123 return;
1126 uint8 auraFlags = GetAuraFlags();
1127 data << uint8(auraFlags);
1128 data << uint8(GetAuraLevel());
1129 data << uint8(m_procCharges ? m_procCharges : m_stackAmount);
1131 if(!(auraFlags & AFLAG_NOT_CASTER))
1133 data << uint8(0); // pguid
1136 if(auraFlags & AFLAG_DURATION)
1138 data << uint32(GetAuraMaxDuration());
1139 data << uint32(GetAuraDuration());
1142 m_target->SendMessageToSet(&data, true);
1145 void Aura::SetStackAmount(uint8 stackAmount)
1147 if (stackAmount != m_stackAmount)
1149 Unit *target = GetTarget();
1150 Unit *caster = GetCaster();
1151 if (!target || !caster)
1152 return;
1153 m_stackAmount = stackAmount;
1154 int32 amount = m_stackAmount * caster->CalculateSpellDamage(m_spellProto, m_effIndex, m_currentBasePoints, target);
1155 // Reapply if amount change
1156 if (amount!=m_modifier.m_amount)
1158 ApplyModifier(false, true);
1159 m_modifier.m_amount = amount;
1160 ApplyModifier(true, true);
1163 RefreshAura();
1166 bool Aura::modStackAmount(int32 num)
1168 // Can`t mod
1169 if (!m_spellProto->StackAmount)
1170 return true;
1172 // Modify stack but limit it
1173 int32 stackAmount = m_stackAmount + num;
1174 if (stackAmount > m_spellProto->StackAmount)
1175 stackAmount = m_spellProto->StackAmount;
1176 else if (stackAmount <=0) // Last aura from stack removed
1178 m_stackAmount = 0;
1179 return true; // need remove aura
1182 // Update stack amount
1183 SetStackAmount(stackAmount);
1184 return false;
1187 void Aura::RefreshAura()
1189 m_duration = m_maxduration;
1190 SendAuraUpdate(false);
1193 bool Aura::isAffectedOnSpell(SpellEntry const *spell) const
1195 // Check family name
1196 if (spell->SpellFamilyName != m_spellProto->SpellFamilyName)
1197 return false;
1198 // Check EffectClassMask
1199 uint32 const *ptr = getAuraSpellClassMask();
1200 if (((uint64*)ptr)[0] & spell->SpellFamilyFlags)
1201 return true;
1202 if (ptr[2] & spell->SpellFamilyFlags2)
1203 return true;
1204 return false;
1207 /*********************************************************/
1208 /*** BASIC AURA FUNCTION ***/
1209 /*********************************************************/
1210 void Aura::HandleAddModifier(bool apply, bool Real)
1212 if(m_target->GetTypeId() != TYPEID_PLAYER || !Real)
1213 return;
1215 if(m_modifier.m_miscvalue >= MAX_SPELLMOD)
1216 return;
1218 if (apply)
1220 // Add custom charges for some mod aura
1221 switch (m_spellProto->Id)
1223 case 17941: // Shadow Trance
1224 case 22008: // Netherwind Focus
1225 case 31834: // Light's Grace
1226 case 34754: // Clearcasting
1227 case 34936: // Backlash
1228 case 48108: // Hot Streak
1229 case 54741: // Firestarter
1230 case 57761: // Fireball!
1231 SetAuraCharges(1);
1232 break;
1235 SpellModifier *mod = new SpellModifier;
1236 mod->op = SpellModOp(m_modifier.m_miscvalue);
1237 mod->value = m_modifier.m_amount;
1238 mod->type = SpellModType(m_modifier.m_auraname); // SpellModType value == spell aura types
1239 mod->spellId = GetId();
1241 uint32 const *ptr;
1242 SpellAffectEntry const *spellAffect = spellmgr.GetSpellAffect(GetId(), m_effIndex);
1243 if (spellAffect)
1244 ptr = &spellAffect->SpellClassMask[0];
1245 else
1247 switch (m_effIndex)
1249 case 0: ptr = &m_spellProto->EffectSpellClassMaskA[0]; break;
1250 case 1: ptr = &m_spellProto->EffectSpellClassMaskB[0]; break;
1251 case 2: ptr = &m_spellProto->EffectSpellClassMaskC[0]; break;
1252 default:
1253 return;
1257 mod->mask = (uint64)ptr[0] | (uint64)ptr[1]<<32;
1258 mod->mask2= (uint64)ptr[2];
1259 mod->charges = m_procCharges;
1261 m_spellmod = mod;
1264 uint64 spellFamilyMask = m_spellmod->mask;
1266 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
1268 // reapply some passive spells after add/remove related spellmods
1269 if(m_spellProto->SpellFamilyName==SPELLFAMILY_WARRIOR && (spellFamilyMask & 0x0000100000000000LL))
1271 m_target->RemoveAurasDueToSpell(45471);
1273 if(apply)
1274 m_target->CastSpell(m_target,45471,true);
1277 void Aura::HandleAddTargetTrigger(bool apply, bool Real)
1279 // Use SpellModifier structure for check
1280 // used only fields:
1281 // spellId, mask, mask2
1282 if (apply)
1284 SpellModifier *mod = new SpellModifier;
1285 mod->spellId = GetId();
1287 uint32 const *ptr;
1288 SpellAffectEntry const *spellAffect = spellmgr.GetSpellAffect(GetId(), m_effIndex);
1289 if (spellAffect)
1290 ptr = &spellAffect->SpellClassMask[0];
1291 else
1293 switch (m_effIndex)
1295 case 0: ptr = &m_spellProto->EffectSpellClassMaskA[0]; break;
1296 case 1: ptr = &m_spellProto->EffectSpellClassMaskB[0]; break;
1297 case 2: ptr = &m_spellProto->EffectSpellClassMaskC[0]; break;
1298 default:
1299 return;
1303 mod->mask = (uint64)ptr[0] | (uint64)ptr[1]<<32;
1304 mod->mask2= (uint64)ptr[2];
1305 m_spellmod = mod;
1307 else
1309 delete m_spellmod;
1310 m_spellmod = NULL;
1314 void Aura::TriggerSpell()
1316 Unit* caster = GetCaster();
1317 Unit* target = GetTriggerTarget();
1319 if(!caster || !target)
1320 return;
1322 // generic casting code with custom spells and target/caster customs
1323 uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex];
1325 SpellEntry const *triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id);
1326 SpellEntry const *auraSpellInfo = GetSpellProto();
1327 uint32 auraId = auraSpellInfo->Id;
1329 // specific code for cases with no trigger spell provided in field
1330 if (triggeredSpellInfo == NULL)
1332 switch(auraSpellInfo->SpellFamilyName)
1334 case SPELLFAMILY_GENERIC:
1336 switch(auraId)
1338 // Firestone Passive (1-5 ranks)
1339 case 758:
1340 case 17945:
1341 case 17947:
1342 case 17949:
1343 case 27252:
1345 if (caster->GetTypeId()!=TYPEID_PLAYER)
1346 return;
1347 Item* item = ((Player*)caster)->GetWeaponForAttack(BASE_ATTACK);
1348 if (!item)
1349 return;
1350 uint32 enchant_id = 0;
1351 switch (GetId())
1353 case 758: enchant_id = 1803; break; // Rank 1
1354 case 17945: enchant_id = 1823; break; // Rank 2
1355 case 17947: enchant_id = 1824; break; // Rank 3
1356 case 17949: enchant_id = 1825; break; // Rank 4
1357 case 27252: enchant_id = 2645; break; // Rank 5
1358 default:
1359 return;
1361 // remove old enchanting before applying new
1362 ((Player*)caster)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,false);
1363 item->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, m_modifier.periodictime+1000, 0);
1364 // add new enchanting
1365 ((Player*)caster)->ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,true);
1366 return;
1368 // // Periodic Mana Burn
1369 // case 812: break;
1370 // // Polymorphic Ray
1371 // case 6965: break;
1372 // // Fire Nova (1-7 ranks)
1373 // case 8350:
1374 // case 8508:
1375 // case 8509:
1376 // case 11312:
1377 // case 11313:
1378 // case 25540:
1379 // case 25544:
1380 // break;
1381 // Thaumaturgy Channel
1382 case 9712: trigger_spell_id = 21029; break;
1383 // // Egan's Blaster
1384 // case 17368: break;
1385 // // Haunted
1386 // case 18347: break;
1387 // // Ranshalla Waiting
1388 // case 18953: break;
1389 // // Inferno
1390 // case 19695: break;
1391 // // Frostwolf Muzzle DND
1392 // case 21794: break;
1393 // // Alterac Ram Collar DND
1394 // case 21866: break;
1395 // // Celebras Waiting
1396 // case 21916: break;
1397 // Brood Affliction: Bronze
1398 case 23170:
1400 m_target->CastSpell(m_target, 23171, true, 0, this);
1401 return;
1403 // // Mark of Frost
1404 // case 23184: break;
1405 // Restoration
1406 case 23493:
1408 int32 heal = caster->GetMaxHealth() / 10;
1409 caster->ModifyHealth( heal );
1410 caster->SendHealSpellLog(caster, 23493, heal);
1412 int32 mana = caster->GetMaxPower(POWER_MANA);
1413 if (mana)
1415 mana /= 10;
1416 caster->ModifyPower( POWER_MANA, mana );
1417 caster->SendEnergizeSpellLog(caster, 23493, mana, POWER_MANA);
1419 break;
1421 // // Stoneclaw Totem Passive TEST
1422 // case 23792: break;
1423 // // Axe Flurry
1424 // case 24018: break;
1425 // // Mark of Arlokk
1426 // case 24210: break;
1427 // // Restoration
1428 // case 24379: break;
1429 // // Happy Pet
1430 // case 24716: break;
1431 // // Dream Fog
1432 // case 24780: break;
1433 // // Cannon Prep
1434 // case 24832: break;
1435 // // Shadow Bolt Whirl
1436 // case 24834: break;
1437 // // Stink Trap
1438 // case 24918: break;
1439 // // Mark of Nature
1440 // case 25041: break;
1441 // // Agro Drones
1442 // case 25152: break;
1443 // // Consume
1444 // case 25371: break;
1445 // // Pain Spike
1446 // case 25572: break;
1447 // // Rotate 360
1448 // case 26009: break;
1449 // // Rotate -360
1450 // case 26136: break;
1451 // // Consume
1452 // case 26196: break;
1453 // // Berserk
1454 // case 26615: break;
1455 // // Defile
1456 // case 27177: break;
1457 // // Teleport: IF/UC
1458 // case 27601: break;
1459 // // Five Fat Finger Exploding Heart Technique
1460 // case 27673: break;
1461 // // Nitrous Boost
1462 // case 27746: break;
1463 // // Steam Tank Passive
1464 // case 27747: break;
1465 // // Frost Blast
1466 // case 27808: break;
1467 // // Detonate Mana
1468 // case 27819: break;
1469 // // Controller Timer
1470 // case 28095: break;
1471 // // Stalagg Chain
1472 // case 28096: break;
1473 // // Stalagg Tesla Passive
1474 // case 28097: break;
1475 // // Feugen Tesla Passive
1476 // case 28109: break;
1477 // // Feugen Chain
1478 // case 28111: break;
1479 // // Mark of Didier
1480 // case 28114: break;
1481 // // Communique Timer, camp
1482 // case 28346: break;
1483 // // Icebolt
1484 // case 28522: break;
1485 // // Silithyst
1486 // case 29519: break;
1487 // // Inoculate Nestlewood Owlkin
1488 case 29528: trigger_spell_id = 28713; break;
1489 // // Overload
1490 // case 29768: break;
1491 // // Return Fire
1492 // case 29788: break;
1493 // // Return Fire
1494 // case 29793: break;
1495 // // Return Fire
1496 // case 29794: break;
1497 // // Guardian of Icecrown Passive
1498 // case 29897: break;
1499 // Feed Captured Animal
1500 case 29917: trigger_spell_id = 29916; break;
1501 // // Flame Wreath
1502 // case 29946: break;
1503 // // Flame Wreath
1504 // case 29947: break;
1505 // // Mind Exhaustion Passive
1506 // case 30025: break;
1507 // // Nether Beam - Serenity
1508 // case 30401: break;
1509 // Extract Gas
1510 case 30427:
1512 // move loot to player inventory and despawn target
1513 if(caster->GetTypeId() ==TYPEID_PLAYER &&
1514 target->GetTypeId() == TYPEID_UNIT &&
1515 ((Creature*)target)->GetCreatureInfo()->type == CREATURE_TYPE_GAS_CLOUD)
1517 Player* player = (Player*)caster;
1518 Creature* creature = (Creature*)target;
1519 // missing lootid has been reported on startup - just return
1520 if (!creature->GetCreatureInfo()->SkinLootId)
1521 return;
1523 player->AutoStoreLoot(creature->GetCreatureInfo()->SkinLootId,LootTemplates_Skinning,true);
1525 creature->setDeathState(JUST_DIED);
1526 creature->RemoveCorpse();
1527 creature->SetHealth(0); // just for nice GM-mode view
1529 return;
1530 break;
1532 // Quake
1533 case 30576: trigger_spell_id = 30571; break;
1534 // // Burning Maul
1535 // case 30598: break;
1536 // // Regeneration
1537 // case 30799:
1538 // case 30800:
1539 // case 30801:
1540 // break;
1541 // // Despawn Self - Smoke cloud
1542 // case 31269: break;
1543 // // Time Rift Periodic
1544 // case 31320: break;
1545 // // Corrupt Medivh
1546 // case 31326: break;
1547 // Doom
1548 case 31347:
1550 m_target->CastSpell(m_target,31350,true);
1551 m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
1552 return;
1554 // Spellcloth
1555 case 31373:
1557 // Summon Elemental after create item
1558 caster->SummonCreature(17870, 0, 0, 0, caster->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0);
1559 return;
1561 // // Bloodmyst Tesla
1562 // case 31611: break;
1563 // // Doomfire
1564 // case 31944: break;
1565 // // Teleport Test
1566 // case 32236: break;
1567 // // Earthquake
1568 // case 32686: break;
1569 // // Possess
1570 // case 33401: break;
1571 // // Draw Shadows
1572 // case 33563: break;
1573 // // Murmur's Touch
1574 // case 33711: break;
1575 // Flame Quills
1576 case 34229:
1578 // cast 24 spells 34269-34289, 34314-34316
1579 for(uint32 spell_id = 34269; spell_id != 34290; ++spell_id)
1580 caster->CastSpell(m_target,spell_id,true);
1581 for(uint32 spell_id = 34314; spell_id != 34317; ++spell_id)
1582 caster->CastSpell(m_target,spell_id,true);
1583 return;
1585 // // Gravity Lapse
1586 // case 34480: break;
1587 // // Tornado
1588 // case 34683: break;
1589 // // Frostbite Rotate
1590 // case 34748: break;
1591 // // Arcane Flurry
1592 // case 34821: break;
1593 // // Interrupt Shutdown
1594 // case 35016: break;
1595 // // Interrupt Shutdown
1596 // case 35176: break;
1597 // // Inferno
1598 // case 35268: break;
1599 // // Salaadin's Tesla
1600 // case 35515: break;
1601 // // Ethereal Channel (Red)
1602 // case 35518: break;
1603 // // Nether Vapor
1604 // case 35879: break;
1605 // // Dark Portal Storm
1606 // case 36018: break;
1607 // // Burning Maul
1608 // case 36056: break;
1609 // // Living Grove Defender Lifespan
1610 // case 36061: break;
1611 // // Professor Dabiri Talks
1612 // case 36064: break;
1613 // // Kael Gaining Power
1614 // case 36091: break;
1615 // // They Must Burn Bomb Aura
1616 // case 36344: break;
1617 // // They Must Burn Bomb Aura (self)
1618 // case 36350: break;
1619 // // Stolen Ravenous Ravager Egg
1620 // case 36401: break;
1621 // // Activated Cannon
1622 // case 36410: break;
1623 // // Stolen Ravenous Ravager Egg
1624 // case 36418: break;
1625 // // Enchanted Weapons
1626 // case 36510: break;
1627 // // Cursed Scarab Periodic
1628 // case 36556: break;
1629 // // Cursed Scarab Despawn Periodic
1630 // case 36561: break;
1631 // // Vision Guide
1632 // case 36573: break;
1633 // // Cannon Charging (platform)
1634 // case 36785: break;
1635 // // Cannon Charging (self)
1636 // case 36860: break;
1637 // Remote Toy
1638 case 37027: trigger_spell_id = 37029; break;
1639 // // Mark of Death
1640 // case 37125: break;
1641 // // Arcane Flurry
1642 // case 37268: break;
1643 // // Spout
1644 // case 37429: break;
1645 // // Spout
1646 // case 37430: break;
1647 // // Karazhan - Chess NPC AI, Snapshot timer
1648 // case 37440: break;
1649 // // Karazhan - Chess NPC AI, action timer
1650 // case 37504: break;
1651 // // Karazhan - Chess: Is Square OCCUPIED aura (DND)
1652 // case 39400: break;
1653 // // Banish
1654 // case 37546: break;
1655 // // Shriveling Gaze
1656 // case 37589: break;
1657 // // Fake Aggro Radius (2 yd)
1658 // case 37815: break;
1659 // // Corrupt Medivh
1660 // case 37853: break;
1661 // Eye of Grillok
1662 case 38495:
1664 m_target->CastSpell(m_target, 38530, true);
1665 return;
1667 // Absorb Eye of Grillok (Zezzak's Shard)
1668 case 38554:
1670 if(m_target->GetTypeId() != TYPEID_UNIT)
1671 return;
1673 caster->CastSpell(caster, 38495, true);
1675 Creature* creatureTarget = (Creature*)m_target;
1677 creatureTarget->setDeathState(JUST_DIED);
1678 creatureTarget->RemoveCorpse();
1679 creatureTarget->SetHealth(0); // just for nice GM-mode view
1680 return;
1682 // // Magic Sucker Device timer
1683 // case 38672: break;
1684 // // Tomb Guarding Charging
1685 // case 38751: break;
1686 // // Murmur's Touch
1687 // case 38794: break;
1688 // // Activate Nether-wraith Beacon (31742 Nether-wraith Beacon item)
1689 // case 39105: break;
1690 // // Drain World Tree Visual
1691 // case 39140: break;
1692 // // Quest - Dustin's Undead Dragon Visual aura
1693 // case 39259: break;
1694 // // Hellfire - The Exorcism, Jules releases darkness, aura
1695 // case 39306: break;
1696 // // Inferno
1697 // case 39346: break;
1698 // // Enchanted Weapons
1699 // case 39489: break;
1700 // // Shadow Bolt Whirl
1701 // case 39630: break;
1702 // // Shadow Bolt Whirl
1703 // case 39634: break;
1704 // // Shadow Inferno
1705 // case 39645: break;
1706 // Tear of Azzinoth Summon Channel - it's not really supposed to do anything,and this only prevents the console spam
1707 case 39857: trigger_spell_id = 39856; break;
1708 // // Soulgrinder Ritual Visual (Smashed)
1709 // case 39974: break;
1710 // // Simon Game Pre-game timer
1711 // case 40041: break;
1712 // // Knockdown Fel Cannon: The Aggro Check Aura
1713 // case 40113: break;
1714 // // Spirit Lance
1715 // case 40157: break;
1716 // // Demon Transform 2
1717 // case 40398: break;
1718 // // Demon Transform 1
1719 // case 40511: break;
1720 // // Ancient Flames
1721 // case 40657: break;
1722 // // Ethereal Ring Cannon: Cannon Aura
1723 // case 40734: break;
1724 // // Cage Trap
1725 // case 40760: break;
1726 // // Random Periodic
1727 // case 40867: break;
1728 // // Prismatic Shield
1729 // case 40879: break;
1730 // // Aura of Desire
1731 // case 41350: break;
1732 // // Dementia
1733 // case 41404: break;
1734 // // Chaos Form
1735 // case 41629: break;
1736 // // Alert Drums
1737 // case 42177: break;
1738 // // Spout
1739 // case 42581: break;
1740 // // Spout
1741 // case 42582: break;
1742 // // Return to the Spirit Realm
1743 // case 44035: break;
1744 // // Curse of Boundless Agony
1745 // case 45050: break;
1746 // // Earthquake
1747 // case 46240: break;
1748 // Personalized Weather
1749 case 46736: trigger_spell_id = 46737; break;
1750 // // Stay Submerged
1751 // case 46981: break;
1752 // // Dragonblight Ram
1753 // case 47015: break;
1754 // // Party G.R.E.N.A.D.E.
1755 // case 51510: break;
1756 default:
1757 break;
1759 break;
1761 case SPELLFAMILY_MAGE:
1763 switch(auraId)
1765 // Invisibility
1766 case 66:
1768 if(!m_duration)
1769 m_target->CastSpell(m_target, 32612, true, NULL, this);
1770 return;
1772 default:
1773 break;
1775 break;
1777 // case SPELLFAMILY_WARRIOR:
1778 // {
1779 // switch(auraId)
1780 // {
1781 // // Wild Magic
1782 // case 23410: break;
1783 // // Corrupted Totems
1784 // case 23425: break;
1785 // default:
1786 // break;
1787 // }
1788 // break;
1789 // }
1790 // case SPELLFAMILY_PRIEST:
1791 // {
1792 // switch(auraId)
1793 // {
1794 // // Blue Beam
1795 // case 32930: break;
1796 // // Fury of the Dreghood Elders
1797 // case 35460: break;
1798 // default:
1799 // break;
1800 // }
1801 // break;
1802 // }
1803 case SPELLFAMILY_DRUID:
1805 switch(auraId)
1807 // Cat Form
1808 // trigger_spell_id not set and unknown effect triggered in this case, ignoring for while
1809 case 768:
1810 return;
1811 // Frenzied Regeneration
1812 case 22842:
1813 case 22895:
1814 case 22896:
1815 case 26999:
1817 int32 LifePerRage = GetModifier()->m_amount;
1819 int32 lRage = m_target->GetPower(POWER_RAGE);
1820 if(lRage > 100) // rage stored as rage*10
1821 lRage = 100;
1822 m_target->ModifyPower(POWER_RAGE, -lRage);
1823 int32 FRTriggerBasePoints = int32(lRage*LifePerRage/10);
1824 m_target->CastCustomSpell(m_target,22845,&FRTriggerBasePoints,NULL,NULL,true,NULL,this);
1825 return;
1827 default:
1828 break;
1830 break;
1833 // case SPELLFAMILY_HUNTER:
1834 // {
1835 // switch(auraId)
1836 // {
1837 // //Frost Trap Aura
1838 // case 13810:
1839 // return;
1840 // //Rizzle's Frost Trap
1841 // case 39900:
1842 // return;
1843 // // Tame spells
1844 // case 19597: // Tame Ice Claw Bear
1845 // case 19676: // Tame Snow Leopard
1846 // case 19677: // Tame Large Crag Boar
1847 // case 19678: // Tame Adult Plainstrider
1848 // case 19679: // Tame Prairie Stalker
1849 // case 19680: // Tame Swoop
1850 // case 19681: // Tame Dire Mottled Boar
1851 // case 19682: // Tame Surf Crawler
1852 // case 19683: // Tame Armored Scorpid
1853 // case 19684: // Tame Webwood Lurker
1854 // case 19685: // Tame Nightsaber Stalker
1855 // case 19686: // Tame Strigid Screecher
1856 // case 30100: // Tame Crazed Dragonhawk
1857 // case 30103: // Tame Elder Springpaw
1858 // case 30104: // Tame Mistbat
1859 // case 30647: // Tame Barbed Crawler
1860 // case 30648: // Tame Greater Timberstrider
1861 // case 30652: // Tame Nightstalker
1862 // return;
1863 // default:
1864 // break;
1865 // }
1866 // break;
1867 // }
1868 case SPELLFAMILY_SHAMAN:
1870 switch(auraId)
1872 // Lightning Shield (The Earthshatterer set trigger after cast Lighting Shield)
1873 case 28820:
1875 // Need remove self if Lightning Shield not active
1876 Unit::AuraMap const& auras = target->GetAuras();
1877 for(Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
1879 SpellEntry const* spell = itr->second->GetSpellProto();
1880 if( spell->SpellFamilyName == SPELLFAMILY_SHAMAN &&
1881 spell->SpellFamilyFlags & 0x0000000000000400L)
1882 return;
1884 target->RemoveAurasDueToSpell(28820);
1885 return;
1887 // Totemic Mastery (Skyshatter Regalia (Shaman Tier 6) - bonus)
1888 case 38443:
1890 bool all = true;
1891 for(int i = 0; i < MAX_TOTEM; ++i)
1893 if(!caster->m_TotemSlot[i])
1895 all = false;
1896 break;
1900 if(all)
1901 caster->CastSpell(caster,38437,true);
1902 else
1903 caster->RemoveAurasDueToSpell(38437);
1904 return;
1906 default:
1907 break;
1909 break;
1911 default:
1912 break;
1914 // Reget trigger spell proto
1915 triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id);
1916 if(triggeredSpellInfo == NULL)
1918 sLog.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?",GetId(),GetEffIndex());
1919 return;
1922 else
1924 // Spell exist but require custom code
1925 switch(auraId)
1927 // Curse of Idiocy
1928 case 1010:
1930 // TODO: spell casted by result in correct way mostly
1931 // BUT:
1932 // 1) target show casting at each triggered cast: target don't must show casting animation for any triggered spell
1933 // but must show affect apply like item casting
1934 // 2) maybe aura must be replace by new with accumulative stat mods instead stacking
1936 // prevent cast by triggered auras
1937 if(m_caster_guid == m_target->GetGUID())
1938 return;
1940 // stop triggering after each affected stats lost > 90
1941 int32 intelectLoss = 0;
1942 int32 spiritLoss = 0;
1944 Unit::AuraList const& mModStat = m_target->GetAurasByType(SPELL_AURA_MOD_STAT);
1945 for(Unit::AuraList::const_iterator i = mModStat.begin(); i != mModStat.end(); ++i)
1947 if ((*i)->GetId() == 1010)
1949 switch((*i)->GetModifier()->m_miscvalue)
1951 case STAT_INTELLECT: intelectLoss += (*i)->GetModifier()->m_amount; break;
1952 case STAT_SPIRIT: spiritLoss += (*i)->GetModifier()->m_amount; break;
1953 default: break;
1958 if(intelectLoss <= -90 && spiritLoss <= -90)
1959 return;
1961 caster = target;
1962 break;
1964 // Mana Tide
1965 case 16191:
1967 caster->CastCustomSpell(target, trigger_spell_id, &m_modifier.m_amount, NULL, NULL, true, NULL, this);
1968 return;
1972 // All ok cast by default case
1973 caster->CastSpell(target, triggeredSpellInfo, true, 0, this);
1976 void Aura::TriggerSpellWithValue()
1978 Unit* caster = GetCaster();
1979 Unit* target = GetTriggerTarget();
1981 if(!caster || !target)
1982 return;
1984 // generic casting code with custom spells and target/caster customs
1985 uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex];
1986 int32 basepoints0 = this->GetModifier()->m_amount;
1988 caster->CastCustomSpell(target, trigger_spell_id, &basepoints0, 0, 0, true, 0, this);
1991 /*********************************************************/
1992 /*** AURA EFFECTS ***/
1993 /*********************************************************/
1995 void Aura::HandleAuraDummy(bool apply, bool Real)
1997 // spells required only Real aura add/remove
1998 if(!Real)
1999 return;
2001 Unit* caster = GetCaster();
2003 // AT APPLY
2004 if(apply)
2006 switch(GetId())
2008 case 1515: // Tame beast
2009 // FIX_ME: this is 2.0.12 threat effect replaced in 2.1.x by dummy aura, must be checked for correctness
2010 if( caster && m_target->CanHaveThreatList())
2011 m_target->AddThreat(caster, 10.0f);
2012 return;
2013 case 13139: // net-o-matic
2014 // root to self part of (root_target->charge->root_self sequence
2015 if(caster)
2016 caster->CastSpell(caster,13138,true,NULL,this);
2017 return;
2018 case 39850: // Rocket Blast
2019 if(roll_chance_i(20)) // backfire stun
2020 m_target->CastSpell(m_target, 51581, true, NULL, this);
2021 return;
2022 case 43873: // Headless Horseman Laugh
2023 if(caster->GetTypeId() == TYPEID_PLAYER)
2024 ((Player*)caster)->PlaySound(11965, false);
2025 return;
2026 case 46354: // Blood Elf Illusion
2027 if(caster)
2029 switch(caster->getGender())
2031 case GENDER_FEMALE:
2032 caster->CastSpell(m_target,46356,true,NULL,this);
2033 break;
2034 case GENDER_MALE:
2035 caster->CastSpell(m_target,46355,true,NULL,this);
2036 break;
2037 default:
2038 break;
2041 return;
2042 case 46699: // Requires No Ammo
2043 if(m_target->GetTypeId()==TYPEID_PLAYER)
2044 ((Player*)m_target)->RemoveAmmo(); // not use ammo and not allow use
2045 return;
2048 // Earth Shield
2049 if ( caster && GetSpellProto()->SpellFamilyName == SPELLFAMILY_SHAMAN && (GetSpellProto()->SpellFamilyFlags & 0x40000000000LL))
2051 // prevent double apply bonuses
2052 if(m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())
2053 m_modifier.m_amount = caster->SpellHealingBonus(m_target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE);
2054 return;
2057 // AT REMOVE
2058 else
2060 if( m_target->GetTypeId() == TYPEID_PLAYER &&
2061 ( GetSpellProto()->Effect[0]==72 || GetSpellProto()->Effect[0]==6 &&
2062 ( GetSpellProto()->EffectApplyAuraName[0]==1 || GetSpellProto()->EffectApplyAuraName[0]==128 ) ) )
2064 // spells with SpellEffect=72 and aura=4: 6196, 6197, 21171, 21425
2065 ((Player*)m_target)->SetFarSightGUID(0);
2066 WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0);
2067 ((Player*)m_target)->GetSession()->SendPacket(&data);
2068 return;
2071 if( (IsQuestTameSpell(GetId())) && caster && caster->isAlive() && m_target->isAlive())
2073 uint32 finalSpelId = 0;
2074 switch(GetId())
2076 case 19548: finalSpelId = 19597; break;
2077 case 19674: finalSpelId = 19677; break;
2078 case 19687: finalSpelId = 19676; break;
2079 case 19688: finalSpelId = 19678; break;
2080 case 19689: finalSpelId = 19679; break;
2081 case 19692: finalSpelId = 19680; break;
2082 case 19693: finalSpelId = 19684; break;
2083 case 19694: finalSpelId = 19681; break;
2084 case 19696: finalSpelId = 19682; break;
2085 case 19697: finalSpelId = 19683; break;
2086 case 19699: finalSpelId = 19685; break;
2087 case 19700: finalSpelId = 19686; break;
2088 case 30646: finalSpelId = 30647; break;
2089 case 30653: finalSpelId = 30648; break;
2090 case 30654: finalSpelId = 30652; break;
2091 case 30099: finalSpelId = 30100; break;
2092 case 30102: finalSpelId = 30103; break;
2093 case 30105: finalSpelId = 30104; break;
2096 if(finalSpelId)
2097 caster->CastSpell(m_target,finalSpelId,true,NULL,this);
2098 return;
2101 // Waiting to Resurrect
2102 if(GetId()==2584)
2104 // Waiting to resurrect spell cancel, we must remove player from resurrect queue
2105 if(m_target->GetTypeId() == TYPEID_PLAYER)
2106 if(BattleGround *bg = ((Player*)m_target)->GetBattleGround())
2107 bg->RemovePlayerFromResurrectQueue(m_target->GetGUID());
2108 return;
2111 // Dark Fiend
2112 if(GetId()==45934)
2114 // Kill target if dispelled
2115 if (m_removeMode==AURA_REMOVE_BY_DISPEL)
2116 m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
2117 return;
2120 // Burning Winds
2121 if(GetId()==46308) // casted only at creatures at spawn
2123 m_target->CastSpell(m_target,47287,true,NULL,this);
2124 return;
2127 if (caster && m_removeMode == AURA_REMOVE_BY_DEATH)
2129 // Stop caster Arcane Missle chanelling on death
2130 if (m_spellProto->SpellFamilyName == SPELLFAMILY_MAGE &&
2131 m_spellProto->SpellFamilyFlags&0x0000000000000800LL)
2133 caster->InterruptSpell(CURRENT_CHANNELED_SPELL);
2134 return;
2136 // Stop caster Penance chanelling on death
2137 if (m_spellProto->SpellFamilyName == SPELLFAMILY_PRIEST &&
2138 m_spellProto->SpellFamilyFlags2 & 0x00000080)
2140 caster->InterruptSpell(CURRENT_CHANNELED_SPELL);
2141 return;
2147 // AT APPLY & REMOVE
2149 switch(m_spellProto->SpellFamilyName)
2151 case SPELLFAMILY_GENERIC:
2153 // Unstable Power
2154 if( GetId()==24658 )
2156 uint32 spellId = 24659;
2157 if (apply)
2159 const SpellEntry *spell = sSpellStore.LookupEntry(spellId);
2160 if (!spell)
2161 return;
2162 for (int i=0; i < spell->StackAmount; ++i)
2163 caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID());
2164 return;
2166 m_target->RemoveAurasDueToSpell(spellId);
2167 return;
2169 // Restless Strength
2170 if( GetId()==24661 )
2172 uint32 spellId = 24662;
2173 if (apply)
2175 const SpellEntry *spell = sSpellStore.LookupEntry(spellId);
2176 if (!spell)
2177 return;
2178 for (int i=0; i < spell->StackAmount; ++i)
2179 caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID());
2180 return;
2182 m_target->RemoveAurasDueToSpell(spellId);
2183 return;
2185 //Summon Fire Elemental
2186 if (GetId() == 40133 && caster)
2188 Unit *owner = caster->GetOwner();
2189 if (owner && owner->GetTypeId() == TYPEID_PLAYER)
2191 if(apply)
2192 owner->CastSpell(owner,8985,true);
2193 else
2194 ((Player*)owner)->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true);
2196 return;
2199 //Summon Earth Elemental
2200 if (GetId() == 40132 && caster)
2202 Unit *owner = caster->GetOwner();
2203 if (owner && owner->GetTypeId() == TYPEID_PLAYER)
2205 if(apply)
2206 owner->CastSpell(owner,19704,true);
2207 else
2208 ((Player*)owner)->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true);
2210 return;
2212 break;
2214 case SPELLFAMILY_MAGE:
2216 break;
2218 case SPELLFAMILY_PRIEST:
2220 // Pain and Suffering
2221 if( m_spellProto->SpellIconID == 2874 && m_target->GetTypeId()==TYPEID_PLAYER )
2223 if(apply)
2225 // Reduce backfire damage (dot damage) from Shadow Word: Death
2226 SpellModifier *mod = new SpellModifier;
2227 mod->op = SPELLMOD_DOT;
2228 mod->value = m_modifier.m_amount;
2229 mod->type = SPELLMOD_PCT;
2230 mod->spellId = GetId();
2231 mod->mask = 0x0000000200000000LL;
2232 mod->mask2= 0LL;
2233 m_spellmod = mod;
2235 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
2236 return;
2238 break;
2240 case SPELLFAMILY_DRUID:
2242 // Lifebloom
2243 if ( GetSpellProto()->SpellFamilyFlags & 0x1000000000LL )
2245 if ( apply )
2247 if ( caster )
2248 // prevent double apply bonuses
2249 if(m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading())
2250 m_modifier.m_amount = caster->SpellHealingBonus(m_target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE);
2252 else
2254 // Final heal only on dispelled or duration end
2255 if ( !(GetAuraDuration() <= 0 || m_removeMode==AURA_REMOVE_BY_DISPEL) )
2256 return;
2258 // have a look if there is still some other Lifebloom dummy aura
2259 Unit::AuraList auras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
2260 for(Unit::AuraList::iterator itr = auras.begin(); itr!=auras.end(); ++itr)
2261 if((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID &&
2262 (*itr)->GetSpellProto()->SpellFamilyFlags & 0x1000000000LL)
2263 return;
2265 // final heal
2266 if(m_target->IsInWorld() && m_stackAmount > 0)
2268 int32 amount = m_modifier.m_amount / m_stackAmount;
2269 m_target->CastCustomSpell(m_target,33778,&amount,NULL,NULL,true,NULL,this,GetCasterGUID());
2272 return;
2275 // Predatory Strikes
2276 if(m_target->GetTypeId()==TYPEID_PLAYER && GetSpellProto()->SpellIconID == 1563)
2278 ((Player*)m_target)->UpdateAttackPowerAndDamage();
2279 return;
2281 // Idol of the Emerald Queen
2282 if ( GetId() == 34246 && m_target->GetTypeId()==TYPEID_PLAYER )
2284 if(apply)
2286 SpellModifier *mod = new SpellModifier;
2287 mod->op = SPELLMOD_DOT;
2288 mod->value = m_modifier.m_amount/7;
2289 mod->type = SPELLMOD_FLAT;
2290 mod->spellId = GetId();
2291 mod->mask = 0x001000000000LL;
2292 mod->mask2= 0LL;
2294 m_spellmod = mod;
2297 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
2298 return;
2300 break;
2302 case SPELLFAMILY_HUNTER:
2304 // Improved Aspect of the Viper
2305 if( GetId()==38390 && m_target->GetTypeId()==TYPEID_PLAYER )
2307 if(apply)
2309 // + effect value for Aspect of the Viper
2310 SpellModifier *mod = new SpellModifier;
2311 mod->op = SPELLMOD_EFFECT1;
2312 mod->value = m_modifier.m_amount;
2313 mod->type = SPELLMOD_FLAT;
2314 mod->spellId = GetId();
2315 mod->mask = 0x4000000000000LL;
2316 mod->mask2= 0LL;
2318 m_spellmod = mod;
2321 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
2322 return;
2324 break;
2326 case SPELLFAMILY_SHAMAN:
2328 // Improved Weapon Totems
2329 if( GetSpellProto()->SpellIconID == 57 && m_target->GetTypeId()==TYPEID_PLAYER )
2331 if(apply)
2333 SpellModifier *mod = new SpellModifier;
2334 mod->op = SPELLMOD_EFFECT1;
2335 mod->value = m_modifier.m_amount;
2336 mod->type = SPELLMOD_PCT;
2337 mod->spellId = GetId();
2338 switch (m_effIndex)
2340 case 0:
2341 mod->mask = 0x00200000000LL; // Windfury Totem
2342 mod->mask2= 0LL;
2343 break;
2344 case 1:
2345 mod->mask = 0x00400000000LL; // Flametongue Totem
2346 mod->mask2= 0LL;
2347 break;
2350 m_spellmod = mod;
2353 ((Player*)m_target)->AddSpellMod(m_spellmod, apply);
2354 return;
2356 break;
2360 // pet auras
2361 if(PetAura const* petSpell = spellmgr.GetPetAura(GetId()))
2363 if(apply)
2364 m_target->AddPetAura(petSpell);
2365 else
2366 m_target->RemovePetAura(petSpell);
2367 return;
2371 void Aura::HandleAuraMounted(bool apply, bool Real)
2373 // only at real add/remove aura
2374 if(!Real)
2375 return;
2377 if(apply)
2379 CreatureInfo const* ci = objmgr.GetCreatureTemplate(m_modifier.m_miscvalue);
2380 if(!ci)
2382 sLog.outErrorDb("AuraMounted: `creature_template`='%u' not found in database (only need it modelid)", m_modifier.m_miscvalue);
2383 return;
2386 uint32 team = 0;
2387 if (m_target->GetTypeId()==TYPEID_PLAYER)
2388 team = ((Player*)m_target)->GetTeam();
2390 uint32 display_id = objmgr.ChooseDisplayId(team,ci);
2391 CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id);
2392 if (minfo)
2393 display_id = minfo->modelid;
2395 m_target->Mount(display_id);
2397 else
2399 m_target->Unmount();
2403 void Aura::HandleAuraWaterWalk(bool apply, bool Real)
2405 // only at real add/remove aura
2406 if(!Real)
2407 return;
2409 WorldPacket data;
2410 if(apply)
2411 data.Initialize(SMSG_MOVE_WATER_WALK, 8+4);
2412 else
2413 data.Initialize(SMSG_MOVE_LAND_WALK, 8+4);
2414 data.append(m_target->GetPackGUID());
2415 data << uint32(0);
2416 m_target->SendMessageToSet(&data,true);
2419 void Aura::HandleAuraFeatherFall(bool apply, bool Real)
2421 // only at real add/remove aura
2422 if(!Real)
2423 return;
2425 WorldPacket data;
2426 if(apply)
2427 data.Initialize(SMSG_MOVE_FEATHER_FALL, 8+4);
2428 else
2429 data.Initialize(SMSG_MOVE_NORMAL_FALL, 8+4);
2430 data.append(m_target->GetPackGUID());
2431 data << (uint32)0;
2432 m_target->SendMessageToSet(&data,true);
2435 void Aura::HandleAuraHover(bool apply, bool Real)
2437 // only at real add/remove aura
2438 if(!Real)
2439 return;
2441 WorldPacket data;
2442 if(apply)
2443 data.Initialize(SMSG_MOVE_SET_HOVER, 8+4);
2444 else
2445 data.Initialize(SMSG_MOVE_UNSET_HOVER, 8+4);
2446 data.append(m_target->GetPackGUID());
2447 data << uint32(0);
2448 m_target->SendMessageToSet(&data,true);
2451 void Aura::HandleWaterBreathing(bool apply, bool Real)
2453 if(!apply && !m_target->HasAuraType(SPELL_AURA_WATER_BREATHING))
2455 // update for enable timer in case not moving target
2456 if(m_target->GetTypeId()==TYPEID_PLAYER && m_target->IsInWorld())
2458 ((Player*)m_target)->UpdateUnderwaterState(m_target->GetMap(),m_target->GetPositionX(),m_target->GetPositionY(),m_target->GetPositionZ());
2459 ((Player*)m_target)->HandleDrowning();
2464 void Aura::HandleAuraModShapeshift(bool apply, bool Real)
2466 if(!Real)
2467 return;
2469 uint32 modelid = 0;
2470 Powers PowerType = POWER_MANA;
2471 ShapeshiftForm form = ShapeshiftForm(m_modifier.m_miscvalue);
2472 switch(form)
2474 case FORM_CAT:
2475 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2476 modelid = 892;
2477 else
2478 modelid = 8571;
2479 PowerType = POWER_ENERGY;
2480 break;
2481 case FORM_TRAVEL:
2482 modelid = 632;
2483 break;
2484 case FORM_AQUA:
2485 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2486 modelid = 2428;
2487 else
2488 modelid = 2428;
2489 break;
2490 case FORM_BEAR:
2491 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2492 modelid = 2281;
2493 else
2494 modelid = 2289;
2495 PowerType = POWER_RAGE;
2496 break;
2497 case FORM_GHOUL:
2498 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2499 modelid = 10045;
2500 break;
2501 case FORM_DIREBEAR:
2502 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2503 modelid = 2281;
2504 else
2505 modelid = 2289;
2506 PowerType = POWER_RAGE;
2507 break;
2508 case FORM_CREATUREBEAR:
2509 modelid = 902;
2510 break;
2511 case FORM_GHOSTWOLF:
2512 modelid = 4613;
2513 break;
2514 case FORM_FLIGHT:
2515 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2516 modelid = 20857;
2517 else
2518 modelid = 20872;
2519 break;
2520 case FORM_MOONKIN:
2521 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2522 modelid = 15374;
2523 else
2524 modelid = 15375;
2525 break;
2526 case FORM_FLIGHT_EPIC:
2527 if(Player::TeamForRace(m_target->getRace())==ALLIANCE)
2528 modelid = 21243;
2529 else
2530 modelid = 21244;
2531 break;
2532 case FORM_METAMORPHOSIS:
2533 modelid = 25277;
2534 break;
2535 case FORM_AMBIENT:
2536 case FORM_SHADOW:
2537 case FORM_STEALTH:
2538 break;
2539 case FORM_TREE:
2540 modelid = 864;
2541 break;
2542 case FORM_BATTLESTANCE:
2543 case FORM_BERSERKERSTANCE:
2544 case FORM_DEFENSIVESTANCE:
2545 PowerType = POWER_RAGE;
2546 break;
2547 case FORM_SPIRITOFREDEMPTION:
2548 modelid = 16031;
2549 break;
2550 default:
2551 sLog.outError("Auras: Unknown Shapeshift Type: %u", m_modifier.m_miscvalue);
2554 // remove polymorph before changing display id to keep new display id
2555 switch ( form )
2557 case FORM_CAT:
2558 case FORM_TREE:
2559 case FORM_TRAVEL:
2560 case FORM_AQUA:
2561 case FORM_BEAR:
2562 case FORM_DIREBEAR:
2563 case FORM_FLIGHT_EPIC:
2564 case FORM_FLIGHT:
2565 case FORM_MOONKIN:
2566 // remove movement affects
2567 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT);
2568 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED);
2570 // and polymorphic affects
2571 if(m_target->IsPolymorphed())
2572 m_target->RemoveAurasDueToSpell(m_target->getTransForm());
2573 break;
2574 default:
2575 break;
2578 if(apply)
2580 // remove other shapeshift before applying a new one
2581 if(m_target->m_ShapeShiftFormSpellId)
2582 m_target->RemoveAurasDueToSpell(m_target->m_ShapeShiftFormSpellId,this);
2584 m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, form);
2586 if(modelid > 0)
2587 m_target->SetDisplayId(modelid);
2589 if(PowerType != POWER_MANA)
2591 // reset power to default values only at power change
2592 if(m_target->getPowerType()!=PowerType)
2593 m_target->setPowerType(PowerType);
2595 switch(form)
2597 case FORM_CAT:
2598 case FORM_BEAR:
2599 case FORM_DIREBEAR:
2601 // get furor proc chance
2602 uint32 FurorChance = 0;
2603 Unit::AuraList const& mDummy = m_target->GetAurasByType(SPELL_AURA_DUMMY);
2604 for(Unit::AuraList::const_iterator i = mDummy.begin(); i != mDummy.end(); ++i)
2606 if ((*i)->GetSpellProto()->SpellIconID == 238)
2608 FurorChance = (*i)->GetModifier()->m_amount;
2609 break;
2613 if (m_modifier.m_miscvalue == FORM_CAT)
2615 m_target->SetPower(POWER_ENERGY,0);
2616 if(urand(1,100) <= FurorChance)
2617 m_target->CastSpell(m_target,17099,true,NULL,this);
2619 else
2621 m_target->SetPower(POWER_RAGE,0);
2622 if(urand(1,100) <= FurorChance)
2623 m_target->CastSpell(m_target,17057,true,NULL,this);
2625 break;
2627 case FORM_BATTLESTANCE:
2628 case FORM_DEFENSIVESTANCE:
2629 case FORM_BERSERKERSTANCE:
2631 uint32 Rage_val = 0;
2632 // Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch)
2633 if(m_target->GetTypeId() == TYPEID_PLAYER)
2635 PlayerSpellMap const& sp_list = ((Player *)m_target)->GetSpellMap();
2636 for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
2638 if(itr->second->state == PLAYERSPELL_REMOVED) continue;
2639 SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
2640 if (spellInfo && spellInfo->SpellFamilyName == SPELLFAMILY_WARRIOR && spellInfo->SpellIconID == 139)
2641 Rage_val += m_target->CalculateSpellDamage(spellInfo,0,spellInfo->EffectBasePoints[0],m_target) * 10;
2645 if (m_target->GetPower(POWER_RAGE) > Rage_val)
2646 m_target->SetPower(POWER_RAGE,Rage_val);
2647 break;
2649 default:
2650 break;
2654 m_target->m_ShapeShiftFormSpellId = GetId();
2655 m_target->m_form = form;
2657 else
2659 if(modelid > 0)
2660 m_target->SetDisplayId(m_target->GetNativeDisplayId());
2661 m_target->SetByteValue(UNIT_FIELD_BYTES_2, 3, FORM_NONE);
2662 if(m_target->getClass() == CLASS_DRUID)
2663 m_target->setPowerType(POWER_MANA);
2664 m_target->m_ShapeShiftFormSpellId = 0;
2665 m_target->m_form = FORM_NONE;
2667 switch(form)
2669 // Nordrassil Harness - bonus
2670 case FORM_BEAR:
2671 case FORM_DIREBEAR:
2672 case FORM_CAT:
2674 if(Aura* dummy = m_target->GetDummyAura(37315) )
2675 m_target->CastSpell(m_target,37316,true,NULL,dummy);
2676 break;
2678 // Nordrassil Regalia - bonus
2679 case FORM_MOONKIN:
2681 if(Aura* dummy = m_target->GetDummyAura(37324) )
2682 m_target->CastSpell(m_target,37325,true,NULL,dummy);
2683 break;
2688 // adding/removing linked auras
2689 // add/remove the shapeshift aura's boosts
2690 HandleShapeshiftBoosts(apply);
2692 if(m_target->GetTypeId()==TYPEID_PLAYER)
2693 ((Player*)m_target)->InitDataForForm();
2696 void Aura::HandleAuraTransform(bool apply, bool Real)
2698 if (apply)
2700 // special case (spell specific functionality)
2701 if(m_modifier.m_miscvalue==0)
2703 // player applied only
2704 if(m_target->GetTypeId()!=TYPEID_PLAYER)
2705 return;
2707 switch(GetId())
2709 // Orb of Deception
2710 case 16739:
2712 uint32 orb_model = m_target->GetNativeDisplayId();
2713 switch(orb_model)
2715 // Troll Female
2716 case 1479: m_target->SetDisplayId(10134); break;
2717 // Troll Male
2718 case 1478: m_target->SetDisplayId(10135); break;
2719 // Tauren Male
2720 case 59: m_target->SetDisplayId(10136); break;
2721 // Human Male
2722 case 49: m_target->SetDisplayId(10137); break;
2723 // Human Female
2724 case 50: m_target->SetDisplayId(10138); break;
2725 // Orc Male
2726 case 51: m_target->SetDisplayId(10139); break;
2727 // Orc Female
2728 case 52: m_target->SetDisplayId(10140); break;
2729 // Dwarf Male
2730 case 53: m_target->SetDisplayId(10141); break;
2731 // Dwarf Female
2732 case 54: m_target->SetDisplayId(10142); break;
2733 // NightElf Male
2734 case 55: m_target->SetDisplayId(10143); break;
2735 // NightElf Female
2736 case 56: m_target->SetDisplayId(10144); break;
2737 // Undead Female
2738 case 58: m_target->SetDisplayId(10145); break;
2739 // Undead Male
2740 case 57: m_target->SetDisplayId(10146); break;
2741 // Tauren Female
2742 case 60: m_target->SetDisplayId(10147); break;
2743 // Gnome Male
2744 case 1563: m_target->SetDisplayId(10148); break;
2745 // Gnome Female
2746 case 1564: m_target->SetDisplayId(10149); break;
2747 // BloodElf Female
2748 case 15475: m_target->SetDisplayId(17830); break;
2749 // BloodElf Male
2750 case 15476: m_target->SetDisplayId(17829); break;
2751 // Dranei Female
2752 case 16126: m_target->SetDisplayId(17828); break;
2753 // Dranei Male
2754 case 16125: m_target->SetDisplayId(17827); break;
2755 default: break;
2757 break;
2759 // Murloc costume
2760 case 42365: m_target->SetDisplayId(21723); break;
2761 default: break;
2764 else
2766 CreatureInfo const * ci = objmgr.GetCreatureTemplate(m_modifier.m_miscvalue);
2767 if(!ci)
2769 //pig pink ^_^
2770 m_target->SetDisplayId(16358);
2771 sLog.outError("Auras: unknown creature id = %d (only need its modelid) Form Spell Aura Transform in Spell ID = %d", m_modifier.m_miscvalue, GetId());
2773 else
2775 // Will use the default model here
2776 m_target->SetDisplayId(ci->DisplayID_A);
2778 // Dragonmaw Illusion (set mount model also)
2779 if(GetId()==42016 && m_target->GetMountID() && !m_target->GetAurasByType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED).empty())
2780 m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314);
2782 m_target->setTransForm(GetId());
2785 // polymorph case
2786 if( Real && m_target->GetTypeId() == TYPEID_PLAYER && m_target->IsPolymorphed())
2788 // for players, start regeneration after 1s (in polymorph fast regeneration case)
2789 // only if caster is Player (after patch 2.4.2)
2790 if(IS_PLAYER_GUID(GetCasterGUID()) )
2791 ((Player*)m_target)->setRegenTimer(1000);
2793 //dismount polymorphed target (after patch 2.4.2)
2794 if (m_target->IsMounted())
2795 m_target->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
2798 else
2800 Unit::AuraList const& otherTransforms = m_target->GetAurasByType(SPELL_AURA_TRANSFORM);
2801 if(otherTransforms.empty())
2803 m_target->SetDisplayId(m_target->GetNativeDisplayId());
2804 m_target->setTransForm(0);
2806 else
2808 // look for other transform auras
2809 Aura* handledAura = *otherTransforms.begin();
2810 for(Unit::AuraList::const_iterator i = otherTransforms.begin();i != otherTransforms.end(); ++i)
2812 // negative auras are preferred
2813 if(!IsPositiveSpell((*i)->GetSpellProto()->Id))
2815 handledAura = *i;
2816 break;
2819 handledAura->ApplyModifier(true);
2822 // Dragonmaw Illusion (restore mount model)
2823 if(GetId()==42016 && m_target->GetMountID()==16314)
2825 if(!m_target->GetAurasByType(SPELL_AURA_MOUNTED).empty())
2827 uint32 cr_id = m_target->GetAurasByType(SPELL_AURA_MOUNTED).front()->GetModifier()->m_miscvalue;
2828 if(CreatureInfo const* ci = objmgr.GetCreatureTemplate(cr_id))
2830 uint32 team = 0;
2831 if (m_target->GetTypeId()==TYPEID_PLAYER)
2832 team = ((Player*)m_target)->GetTeam();
2834 uint32 display_id = objmgr.ChooseDisplayId(team,ci);
2835 CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id);
2836 if (minfo)
2837 display_id = minfo->modelid;
2839 m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,display_id);
2846 void Aura::HandleForceReaction(bool apply, bool Real)
2848 if(m_target->GetTypeId() != TYPEID_PLAYER)
2849 return;
2851 if(!Real)
2852 return;
2854 Player* player = (Player*)m_target;
2856 uint32 faction_id = m_modifier.m_miscvalue;
2857 uint32 faction_rank = m_modifier.m_amount;
2859 if(apply)
2860 player->m_forcedReactions[faction_id] = ReputationRank(faction_rank);
2861 else
2862 player->m_forcedReactions.erase(faction_id);
2864 WorldPacket data;
2865 data.Initialize(SMSG_SET_FORCED_REACTIONS, 4+player->m_forcedReactions.size()*(4+4));
2866 data << uint32(player->m_forcedReactions.size());
2867 for(ForcedReactions::const_iterator itr = player->m_forcedReactions.begin(); itr != player->m_forcedReactions.end(); ++itr)
2869 data << uint32(itr->first); // faction_id (Faction.dbc)
2870 data << uint32(itr->second); // reputation rank
2872 player->SendDirectMessage(&data);
2875 void Aura::HandleAuraModSkill(bool apply, bool Real)
2877 if(m_target->GetTypeId() != TYPEID_PLAYER)
2878 return;
2880 uint32 prot=GetSpellProto()->EffectMiscValue[m_effIndex];
2881 int32 points = GetModifier()->m_amount;
2883 ((Player*)m_target)->ModifySkillBonus(prot,(apply ? points: -points),m_modifier.m_auraname==SPELL_AURA_MOD_SKILL_TALENT);
2884 if(prot == SKILL_DEFENSE)
2885 ((Player*)m_target)->UpdateDefenseBonusesMod();
2888 void Aura::HandleChannelDeathItem(bool apply, bool Real)
2890 if(Real && !apply)
2892 Unit* caster = GetCaster();
2893 Unit* victim = GetTarget();
2894 if(!caster || caster->GetTypeId() != TYPEID_PLAYER || !victim || m_removeMode!=AURA_REMOVE_BY_DEATH)
2895 return;
2896 // Item amount
2897 if (m_modifier.m_amount <= 0)
2898 return;
2900 SpellEntry const *spellInfo = GetSpellProto();
2901 if(spellInfo->EffectItemType[m_effIndex] == 0)
2902 return;
2904 // Soul Shard only from non-grey units
2905 if( spellInfo->EffectItemType[m_effIndex] == 6265 &&
2906 (victim->getLevel() <= MaNGOS::XP::GetGrayLevel(caster->getLevel()) ||
2907 victim->GetTypeId()==TYPEID_UNIT && !((Player*)caster)->isAllowedToLoot((Creature*)victim)) )
2908 return;
2909 //Adding items
2910 uint32 noSpaceForCount = 0;
2911 uint32 count = m_modifier.m_amount;
2913 ItemPosCountVec dest;
2914 uint8 msg = ((Player*)caster)->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, spellInfo->EffectItemType[m_effIndex], count, &noSpaceForCount);
2915 if( msg != EQUIP_ERR_OK )
2917 count-=noSpaceForCount;
2918 ((Player*)caster)->SendEquipError( msg, NULL, NULL );
2919 if (count==0)
2920 return;
2923 Item* newitem = ((Player*)caster)->StoreNewItem(dest, spellInfo->EffectItemType[m_effIndex], true);
2924 ((Player*)caster)->SendNewItem(newitem, count, true, false);
2928 void Aura::HandleBindSight(bool apply, bool Real)
2930 Unit* caster = GetCaster();
2931 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
2932 return;
2934 ((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);
2937 void Aura::HandleFarSight(bool apply, bool Real)
2939 Unit* caster = GetCaster();
2940 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
2941 return;
2943 ((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);
2946 void Aura::HandleAuraTrackCreatures(bool apply, bool Real)
2948 if(m_target->GetTypeId()!=TYPEID_PLAYER)
2949 return;
2951 if(apply)
2952 m_target->RemoveNoStackAurasDueToAura(this);
2953 m_target->SetUInt32Value(PLAYER_TRACK_CREATURES, apply ? ((uint32)1)<<(m_modifier.m_miscvalue-1) : 0 );
2956 void Aura::HandleAuraTrackResources(bool apply, bool Real)
2958 if(m_target->GetTypeId()!=TYPEID_PLAYER)
2959 return;
2961 if(apply)
2962 m_target->RemoveNoStackAurasDueToAura(this);
2963 m_target->SetUInt32Value(PLAYER_TRACK_RESOURCES, apply ? ((uint32)1)<<(m_modifier.m_miscvalue-1): 0 );
2966 void Aura::HandleAuraTrackStealthed(bool apply, bool Real)
2968 if(m_target->GetTypeId()!=TYPEID_PLAYER)
2969 return;
2971 if(apply)
2972 m_target->RemoveNoStackAurasDueToAura(this);
2974 m_target->ApplyModFlag(PLAYER_FIELD_BYTES,PLAYER_FIELD_BYTE_TRACK_STEALTHED,apply);
2977 void Aura::HandleAuraModScale(bool apply, bool Real)
2979 m_target->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X,m_modifier.m_amount,apply);
2982 void Aura::HandleModPossess(bool apply, bool Real)
2984 if(!Real)
2985 return;
2987 if(m_target->getLevel() > m_modifier.m_amount)
2988 return;
2990 // not possess yourself
2991 if(GetCasterGUID() == m_target->GetGUID())
2992 return;
2994 Unit* caster = GetCaster();
2995 if(!caster)
2996 return;
2998 if( apply )
3000 m_target->SetCharmerGUID(GetCasterGUID());
3001 m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,caster->getFaction());
3002 caster->SetCharm(m_target);
3004 m_target->CombatStop();
3005 m_target->DeleteThreatList();
3006 if(m_target->GetTypeId() == TYPEID_UNIT)
3008 m_target->StopMoving();
3009 m_target->GetMotionMaster()->Clear();
3010 m_target->GetMotionMaster()->MoveIdle();
3011 CharmInfo *charmInfo = ((Creature*)m_target)->InitCharmInfo(m_target);
3012 charmInfo->InitPossessCreateSpells();
3015 if(caster->GetTypeId() == TYPEID_PLAYER)
3017 ((Player*)caster)->PossessSpellInitialize();
3020 else
3022 m_target->SetCharmerGUID(0);
3024 if(m_target->GetTypeId() == TYPEID_PLAYER)
3025 ((Player*)m_target)->setFactionForRace(m_target->getRace());
3026 else if(m_target->GetTypeId() == TYPEID_UNIT)
3028 CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
3029 m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,cinfo->faction_A);
3032 caster->SetCharm(0);
3034 if(caster->GetTypeId() == TYPEID_PLAYER)
3036 WorldPacket data(SMSG_PET_SPELLS, 8);
3037 data << uint64(0);
3038 data << uint32(0);
3039 ((Player*)caster)->GetSession()->SendPacket(&data);
3041 if(m_target->GetTypeId() == TYPEID_UNIT)
3043 ((Creature*)m_target)->AIM_Initialize();
3045 if (((Creature*)m_target)->AI())
3046 ((Creature*)m_target)->AI()->AttackStart(caster);
3049 if(caster->GetTypeId() == TYPEID_PLAYER)
3050 ((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);
3053 void Aura::HandleModPossessPet(bool apply, bool Real)
3055 if(!Real)
3056 return;
3058 Unit* caster = GetCaster();
3059 if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
3060 return;
3062 Pet *pet = caster->GetPet();
3063 if(!pet || pet != m_target)
3064 return;
3066 if(apply)
3067 pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_24);
3068 else
3069 pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_24);
3071 ((Player*)caster)->SetFarSightGUID(apply ? pet->GetGUID() : NULL);
3072 ((Player*)caster)->SetCharm(apply ? pet : NULL);
3073 ((Player*)caster)->SetClientControl(pet, apply ? 1 : 0);
3075 if(apply)
3077 pet->StopMoving();
3078 pet->GetMotionMaster()->Clear();
3079 pet->GetMotionMaster()->MoveIdle();
3081 else
3083 pet->AttackStop();
3084 pet->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
3085 pet->SetUnitMovementFlags(MOVEMENTFLAG_NONE);
3089 void Aura::HandleAuraModPetTalentsPoints(bool Apply, bool Real)
3091 if(!Real)
3092 return;
3094 // Recalculate pet tlaent points
3095 if (Pet *pet=m_target->GetPet())
3096 pet->InitTalentForLevel();
3099 void Aura::HandleModCharm(bool apply, bool Real)
3101 if(!Real)
3102 return;
3104 // not charm yourself
3105 if(GetCasterGUID() == m_target->GetGUID())
3106 return;
3108 Unit* caster = GetCaster();
3109 if(!caster)
3110 return;
3112 if(int32(m_target->getLevel()) <= m_modifier.m_amount)
3114 if( apply )
3116 m_target->SetCharmerGUID(GetCasterGUID());
3117 m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,caster->getFaction());
3118 m_target->CastStop(m_target==caster ? GetId() : 0);
3119 caster->SetCharm(m_target);
3121 m_target->CombatStop();
3122 m_target->DeleteThreatList();
3124 if(m_target->GetTypeId() == TYPEID_UNIT)
3126 ((Creature*)m_target)->AIM_Initialize();
3127 CharmInfo *charmInfo = ((Creature*)m_target)->InitCharmInfo(m_target);
3128 charmInfo->InitCharmCreateSpells();
3129 charmInfo->SetReactState( REACT_DEFENSIVE );
3131 if(caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK)
3133 CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
3134 if(cinfo && cinfo->type == CREATURE_TYPE_DEMON)
3136 //to prevent client crash
3137 m_target->SetFlag(UNIT_FIELD_BYTES_0, 2048);
3138 //just to enable stat window
3139 charmInfo->SetPetNumber(objmgr.GeneratePetNumber(), true);
3140 //if charmed two demons the same session, the 2nd gets the 1st one's name
3141 m_target->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL));
3146 if(caster->GetTypeId() == TYPEID_PLAYER)
3148 ((Player*)caster)->CharmSpellInitialize();
3151 else
3153 m_target->SetCharmerGUID(0);
3155 if(m_target->GetTypeId() == TYPEID_PLAYER)
3156 ((Player*)m_target)->setFactionForRace(m_target->getRace());
3157 else
3159 CreatureInfo const *cinfo = ((Creature*)m_target)->GetCreatureInfo();
3161 // restore faction
3162 if(((Creature*)m_target)->isPet())
3164 if(Unit* owner = m_target->GetOwner())
3165 m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,owner->getFaction());
3166 else if(cinfo)
3167 m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,cinfo->faction_A);
3169 else if(cinfo) // normal creature
3170 m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,cinfo->faction_A);
3172 // restore UNIT_FIELD_BYTES_0
3173 if(cinfo && caster->GetTypeId() == TYPEID_PLAYER && caster->getClass() == CLASS_WARLOCK && cinfo->type == CREATURE_TYPE_DEMON)
3175 CreatureDataAddon const *cainfo = ((Creature*)m_target)->GetCreatureAddon();
3176 if(cainfo && cainfo->bytes0 != 0)
3177 m_target->SetUInt32Value(UNIT_FIELD_BYTES_0, cainfo->bytes0);
3178 else
3179 m_target->RemoveFlag(UNIT_FIELD_BYTES_0, 2048);
3181 if(m_target->GetCharmInfo())
3182 m_target->GetCharmInfo()->SetPetNumber(0, true);
3183 else
3184 sLog.outError("Aura::HandleModCharm: target="I64FMTD" with typeid=%d has a charm aura but no charm info!", m_target->GetGUID(), m_target->GetTypeId());
3188 caster->SetCharm(0);
3190 if(caster->GetTypeId() == TYPEID_PLAYER)
3192 WorldPacket data(SMSG_PET_SPELLS, 8);
3193 data << uint64(0);
3194 data << uint32(0);
3195 ((Player*)caster)->GetSession()->SendPacket(&data);
3197 if(m_target->GetTypeId() == TYPEID_UNIT)
3199 ((Creature*)m_target)->AIM_Initialize();
3200 if (((Creature*)m_target)->AI())
3201 ((Creature*)m_target)->AI()->AttackStart(caster);
3207 void Aura::HandleModConfuse(bool apply, bool Real)
3209 if(!Real)
3210 return;
3212 m_target->SetConfused(apply, GetCasterGUID(), GetId());
3215 void Aura::HandleModFear(bool apply, bool Real)
3217 if (!Real)
3218 return;
3220 m_target->SetFeared(apply, GetCasterGUID(), GetId());
3223 void Aura::HandleFeignDeath(bool apply, bool Real)
3225 if(!Real)
3226 return;
3228 if(m_target->GetTypeId() != TYPEID_PLAYER)
3229 return;
3231 if( apply )
3234 WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9);
3235 data<<m_target->GetGUID();
3236 data<<uint8(0);
3237 m_target->SendMessageToSet(&data,true);
3239 // blizz like 2.0.x
3240 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29);
3241 // blizz like 2.0.x
3242 m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
3243 // blizz like 2.0.x
3244 m_target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
3246 m_target->addUnitState(UNIT_STAT_DIED);
3247 m_target->CombatStop();
3249 // prevent interrupt message
3250 if(m_caster_guid==m_target->GetGUID() && m_target->m_currentSpells[CURRENT_GENERIC_SPELL])
3251 m_target->m_currentSpells[CURRENT_GENERIC_SPELL]->finish();
3252 m_target->InterruptNonMeleeSpells(true);
3253 m_target->getHostilRefManager().deleteReferences();
3255 else
3258 WorldPacket data(SMSG_FEIGN_DEATH_RESISTED, 9);
3259 data<<m_target->GetGUID();
3260 data<<uint8(1);
3261 m_target->SendMessageToSet(&data,true);
3263 // blizz like 2.0.x
3264 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_29);
3265 // blizz like 2.0.x
3266 m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH);
3267 // blizz like 2.0.x
3268 m_target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD);
3270 m_target->clearUnitState(UNIT_STAT_DIED);
3274 void Aura::HandleAuraModDisarm(bool apply, bool Real)
3276 if(!Real)
3277 return;
3279 if(!apply && m_target->HasAuraType(SPELL_AURA_MOD_DISARM))
3280 return;
3282 // not sure for it's correctness
3283 if(apply)
3284 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
3285 else
3286 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
3288 // only at real add/remove aura
3289 if (m_target->GetTypeId() != TYPEID_PLAYER)
3290 return;
3292 // main-hand attack speed already set to special value for feral form already and don't must change and reset at remove.
3293 if (((Player *)m_target)->IsInFeralForm())
3294 return;
3296 if (apply)
3297 m_target->SetAttackTime(BASE_ATTACK,BASE_ATTACK_TIME);
3298 else
3299 ((Player *)m_target)->SetRegularAttackTime();
3301 m_target->UpdateDamagePhysical(BASE_ATTACK);
3304 void Aura::HandleAuraModStun(bool apply, bool Real)
3306 if(!Real)
3307 return;
3309 if (apply)
3311 m_target->addUnitState(UNIT_STAT_STUNNED);
3312 m_target->SetUInt64Value(UNIT_FIELD_TARGET, 0);
3314 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
3315 m_target->CastStop(m_target->GetGUID() == GetCasterGUID() ? GetId() : 0);
3317 // Creature specific
3318 if(m_target->GetTypeId() != TYPEID_PLAYER)
3319 ((Creature*)m_target)->StopMoving();
3320 else
3321 m_target->SetUnitMovementFlags(0); //Clear movement flags
3323 WorldPacket data(SMSG_FORCE_MOVE_ROOT, 8);
3325 data.append(m_target->GetPackGUID());
3326 data << uint32(0);
3327 m_target->SendMessageToSet(&data,true);
3329 else
3331 // Real remove called after current aura remove from lists, check if other similar auras active
3332 if(m_target->HasAuraType(SPELL_AURA_MOD_STUN))
3333 return;
3335 m_target->clearUnitState(UNIT_STAT_STUNNED);
3336 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
3338 if(!m_target->hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect
3340 if(m_target->getVictim() && m_target->isAlive())
3341 m_target->SetUInt64Value(UNIT_FIELD_TARGET,m_target->getVictim()->GetGUID() );
3343 WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 8+4);
3344 data.append(m_target->GetPackGUID());
3345 data << uint32(0);
3346 m_target->SendMessageToSet(&data,true);
3349 // Wyvern Sting
3350 if (m_spellProto->SpellFamilyName == SPELLFAMILY_HUNTER && m_spellProto->SpellFamilyFlags & 0x0000100000000000LL)
3352 Unit* caster = GetCaster();
3353 if( !caster || caster->GetTypeId()!=TYPEID_PLAYER )
3354 return;
3356 uint32 spell_id = 0;
3358 switch(GetId())
3360 case 19386: spell_id = 24131; break;
3361 case 24132: spell_id = 24134; break;
3362 case 24133: spell_id = 24135; break;
3363 case 27068: spell_id = 27069; break;
3364 case 49011: spell_id = 49009; break;
3365 case 49012: spell_id = 49010; break;
3366 default:
3367 sLog.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?",GetId());
3368 return;
3371 SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id);
3373 if(!spellInfo)
3374 return;
3376 caster->CastSpell(m_target,spellInfo,true,NULL,this);
3377 return;
3382 void Aura::HandleModStealth(bool apply, bool Real)
3384 if(apply)
3386 // drop flag at stealth in bg
3387 if(Real && m_target->GetTypeId()==TYPEID_PLAYER && ((Player*)m_target)->InBattleGround())
3388 if(BattleGround *bg = ((Player*)m_target)->GetBattleGround())
3389 bg->EventPlayerDroppedFlag((Player*)m_target);
3391 // only at real aura add
3392 if(Real)
3394 m_target->SetStandFlags(UNIT_STAND_FLAGS_CREEP);
3395 if(m_target->GetTypeId()==TYPEID_PLAYER)
3396 m_target->SetFlag(PLAYER_FIELD_BYTES2, 0x2000);
3398 // apply only if not in GM invisibility (and overwrite invisibility state)
3399 if(m_target->GetVisibility()!=VISIBILITY_OFF)
3401 m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
3402 m_target->SetVisibility(VISIBILITY_GROUP_STEALTH);
3406 else
3408 // only at real aura remove
3409 if(Real)
3411 // if last SPELL_AURA_MOD_STEALTH and no GM invisibility
3412 if(!m_target->HasAuraType(SPELL_AURA_MOD_STEALTH) && m_target->GetVisibility()!=VISIBILITY_OFF)
3414 m_target->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP);
3415 if(m_target->GetTypeId()==TYPEID_PLAYER)
3416 m_target->RemoveFlag(PLAYER_FIELD_BYTES2, 0x2000);
3418 // restore invisibility if any
3419 if(m_target->HasAuraType(SPELL_AURA_MOD_INVISIBILITY))
3421 m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
3422 m_target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY);
3424 else
3425 m_target->SetVisibility(VISIBILITY_ON);
3430 // Master of Subtlety
3431 Unit::AuraList const& mDummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY);
3432 for(Unit::AuraList::const_iterator i = mDummyAuras.begin();i != mDummyAuras.end(); ++i)
3434 if ((*i)->GetSpellProto()->SpellIconID == 2114)
3436 if (apply)
3438 int32 bp = (*i)->GetModifier()->m_amount;
3439 m_target->CastCustomSpell(m_target,31665,&bp,NULL,NULL,true);
3441 else
3442 m_target->CastSpell(m_target,31666,true);
3443 break;
3448 void Aura::HandleInvisibility(bool apply, bool Real)
3450 if(apply)
3452 m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue);
3454 if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
3456 // apply glow vision
3457 m_target->SetFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
3459 // drop flag at invisible in bg
3460 if(((Player*)m_target)->InBattleGround())
3461 if(BattleGround *bg = ((Player*)m_target)->GetBattleGround())
3462 bg->EventPlayerDroppedFlag((Player*)m_target);
3465 // apply only if not in GM invisibility and not stealth
3466 if(m_target->GetVisibility()==VISIBILITY_ON)
3468 // Aura not added yet but visibility code expect temporary add aura
3469 m_target->SetVisibility(VISIBILITY_GROUP_NO_DETECT);
3470 m_target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY);
3473 else
3475 // recalculate value at modifier remove (current aura already removed)
3476 m_target->m_invisibilityMask = 0;
3477 Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY);
3478 for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
3479 m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue);
3481 // only at real aura remove and if not have different invisibility auras.
3482 if(Real && m_target->m_invisibilityMask==0)
3484 // remove glow vision
3485 if(m_target->GetTypeId() == TYPEID_PLAYER)
3486 m_target->RemoveFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
3488 // apply only if not in GM invisibility & not stealthed while invisible
3489 if(m_target->GetVisibility()!=VISIBILITY_OFF)
3491 // if have stealth aura then already have stealth visibility
3492 if(!m_target->HasAuraType(SPELL_AURA_MOD_STEALTH))
3493 m_target->SetVisibility(VISIBILITY_ON);
3499 void Aura::HandleInvisibilityDetect(bool apply, bool Real)
3501 if(apply)
3503 m_target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue);
3505 else
3507 // recalculate value at modifier remove (current aura already removed)
3508 m_target->m_detectInvisibilityMask = 0;
3509 Unit::AuraList const& auras = m_target->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION);
3510 for(Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
3511 m_target->m_detectInvisibilityMask |= (1 << m_modifier.m_miscvalue);
3513 if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
3514 ObjectAccessor::UpdateVisibilityForPlayer((Player*)m_target);
3517 void Aura::HandleAuraModRoot(bool apply, bool Real)
3519 // only at real add/remove aura
3520 if(!Real)
3521 return;
3523 // Frost root aura -> freeze/unfreeze target
3524 if (GetSpellSchoolMask(m_spellProto) & SPELL_SCHOOL_MASK_FROST)
3525 m_target->ModifyAuraState(AURA_STATE_FROZEN, apply);
3527 uint32 apply_stat = UNIT_STAT_ROOT;
3528 if (apply)
3530 m_target->addUnitState(UNIT_STAT_ROOT);
3531 m_target->SetUInt64Value (UNIT_FIELD_TARGET, 0);
3532 // probably wrong (this add skinable flag)
3533 // TODO: find correct flag
3534 // m_target->SetFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
3536 //Save last orientation
3537 if( m_target->getVictim() )
3538 m_target->SetOrientation(m_target->GetAngle(m_target->getVictim()));
3540 if(m_target->GetTypeId() == TYPEID_PLAYER)
3542 WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10);
3543 data.append(m_target->GetPackGUID());
3544 data << (uint32)2;
3545 m_target->SendMessageToSet(&data,true);
3547 //Clear unit movement flags
3548 m_target->SetUnitMovementFlags(0);
3550 else
3551 ((Creature *)m_target)->StopMoving();
3553 else
3555 // Real remove called after current aura remove from lists, check if other similar auras active
3556 if(m_target->HasAuraType(SPELL_AURA_MOD_ROOT))
3557 return;
3559 m_target->clearUnitState(UNIT_STAT_ROOT);
3560 // probably wrong (this add skinable flag)
3561 // TODO: find correct flag
3562 // m_target->RemoveFlag(UNIT_FIELD_FLAGS,(apply_stat<<16));
3564 if(!m_target->hasUnitState(UNIT_STAT_STUNNED)) // prevent allow move if have also stun effect
3566 if(m_target->getVictim() && m_target->isAlive())
3567 m_target->SetUInt64Value (UNIT_FIELD_TARGET,m_target->getVictim()->GetGUID() );
3569 if(m_target->GetTypeId() == TYPEID_PLAYER)
3571 WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 10);
3572 data.append(m_target->GetPackGUID());
3573 data << (uint32)2;
3574 m_target->SendMessageToSet(&data,true);
3580 void Aura::HandleAuraModSilence(bool apply, bool Real)
3582 // only at real add/remove aura
3583 if(!Real)
3584 return;
3586 if(apply)
3588 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED);
3589 // Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE
3590 for (uint32 i = CURRENT_MELEE_SPELL; i < CURRENT_MAX_SPELL;i++)
3592 Spell* currentSpell = m_target->m_currentSpells[i];
3593 if (currentSpell && currentSpell->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
3595 uint32 state = currentSpell->getState();
3596 // Stop spells on prepare or casting state
3597 if ( state == SPELL_STATE_PREPARING || state == SPELL_STATE_CASTING )
3599 currentSpell->cancel();
3600 currentSpell->SetReferencedFromCurrent(false);
3601 m_target->m_currentSpells[i] = NULL;
3606 switch (GetId())
3608 // Arcane Torrent (Energy)
3609 case 25046:
3611 Unit * caster = GetCaster();
3612 if (!caster)
3613 return;
3615 // Search Mana Tap auras on caster
3616 Aura * dummy = caster->GetDummyAura(28734);
3617 if (dummy)
3619 int32 bp = dummy->GetStackAmount() * 10;
3620 caster->CastCustomSpell(caster, 25048, &bp, NULL, NULL, true);
3621 caster->RemoveAurasDueToSpell(28734);
3626 else
3628 // Real remove called after current aura remove from lists, check if other similar auras active
3629 if(m_target->HasAuraType(SPELL_AURA_MOD_SILENCE))
3630 return;
3632 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED);
3636 void Aura::HandleModThreat(bool apply, bool Real)
3638 // only at real add/remove aura
3639 if(!Real)
3640 return;
3642 if(!m_target->isAlive())
3643 return;
3645 Unit* caster = GetCaster();
3647 if(!caster || !caster->isAlive())
3648 return;
3650 int level_diff = 0;
3651 int multiplier = 0;
3652 switch (GetId())
3654 // Arcane Shroud
3655 case 26400:
3656 level_diff = m_target->getLevel() - 60;
3657 multiplier = 2;
3658 break;
3659 // The Eye of Diminution
3660 case 28862:
3661 level_diff = m_target->getLevel() - 60;
3662 multiplier = 1;
3663 break;
3665 if (level_diff > 0)
3666 m_modifier.m_amount += multiplier * level_diff;
3668 for(int8 x=0;x < MAX_SPELL_SCHOOL;x++)
3670 if(m_modifier.m_miscvalue & int32(1<<x))
3672 if(m_target->GetTypeId() == TYPEID_PLAYER)
3673 ApplyPercentModFloatVar(m_target->m_threatModifier[x], m_positive ? m_modifier.m_amount : -m_modifier.m_amount, apply);
3678 void Aura::HandleAuraModTotalThreat(bool apply, bool Real)
3680 // only at real add/remove aura
3681 if(!Real)
3682 return;
3684 if(!m_target->isAlive() || m_target->GetTypeId()!= TYPEID_PLAYER)
3685 return;
3687 Unit* caster = GetCaster();
3689 if(!caster || !caster->isAlive())
3690 return;
3692 float threatMod = 0.0f;
3693 if(apply)
3694 threatMod = float(m_modifier.m_amount);
3695 else
3696 threatMod = float(-m_modifier.m_amount);
3698 m_target->getHostilRefManager().threatAssist(caster, threatMod);
3701 void Aura::HandleModTaunt(bool apply, bool Real)
3703 // only at real add/remove aura
3704 if(!Real)
3705 return;
3707 if(!m_target->isAlive() || !m_target->CanHaveThreatList())
3708 return;
3710 Unit* caster = GetCaster();
3712 if(!caster || !caster->isAlive() || caster->GetTypeId() != TYPEID_PLAYER)
3713 return;
3715 if(apply)
3716 m_target->TauntApply(caster);
3717 else
3719 // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat
3720 m_target->TauntFadeOut(caster);
3724 /*********************************************************/
3725 /*** MODIFY SPEED ***/
3726 /*********************************************************/
3727 void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real)
3729 // all applied/removed only at real aura add/remove
3730 if(!Real)
3731 return;
3733 m_target->UpdateSpeed(MOVE_RUN, true);
3736 void Aura::HandleAuraModIncreaseMountedSpeed(bool /*apply*/, bool Real)
3738 // all applied/removed only at real aura add/remove
3739 if(!Real)
3740 return;
3742 m_target->UpdateSpeed(MOVE_RUN, true);
3745 void Aura::HandleAuraModIncreaseFlightSpeed(bool apply, bool Real)
3747 // all applied/removed only at real aura add/remove
3748 if(!Real)
3749 return;
3751 // Enable Fly mode for flying mounts
3752 if (m_modifier.m_auraname == SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED)
3754 WorldPacket data;
3755 if(apply)
3756 data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
3757 else
3758 data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
3759 data.append(m_target->GetPackGUID());
3760 data << uint32(0); // unknown
3761 m_target->SendMessageToSet(&data, true);
3763 //Players on flying mounts must be immune to polymorph
3764 if (m_target->GetTypeId()==TYPEID_PLAYER)
3765 m_target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,MECHANIC_POLYMORPH,apply);
3767 // Dragonmaw Illusion (overwrite mount model, mounted aura already applied)
3768 if( apply && m_target->HasAura(42016,0) && m_target->GetMountID())
3769 m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314);
3772 m_target->UpdateSpeed(MOVE_FLIGHT, true);
3775 void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real)
3777 // all applied/removed only at real aura add/remove
3778 if(!Real)
3779 return;
3781 m_target->UpdateSpeed(MOVE_SWIM, true);
3784 void Aura::HandleAuraModDecreaseSpeed(bool /*apply*/, bool Real)
3786 // all applied/removed only at real aura add/remove
3787 if(!Real)
3788 return;
3790 m_target->UpdateSpeed(MOVE_RUN, true);
3791 m_target->UpdateSpeed(MOVE_SWIM, true);
3792 m_target->UpdateSpeed(MOVE_FLIGHT, true);
3795 void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real)
3797 // all applied/removed only at real aura add/remove
3798 if(!Real)
3799 return;
3801 m_target->UpdateSpeed(MOVE_RUN, true);
3802 m_target->UpdateSpeed(MOVE_SWIM, true);
3803 m_target->UpdateSpeed(MOVE_FLIGHT, true);
3806 /*********************************************************/
3807 /*** IMMUNITY ***/
3808 /*********************************************************/
3810 void Aura::HandleModMechanicImmunity(bool apply, bool Real)
3812 uint32 mechanic = 1 << m_modifier.m_miscvalue;
3814 //immune movement impairment and loss of control
3815 if(GetId()==42292)
3816 mechanic=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK;
3818 if(apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
3820 Unit::AuraMap& Auras = m_target->GetAuras();
3821 for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next)
3823 next = iter;
3824 ++next;
3825 SpellEntry const *spell = iter->second->GetSpellProto();
3826 if (!( spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) && // spells unaffected by invulnerability
3827 spell->Id != GetId())
3829 //check for mechanic mask
3830 if(GetSpellMechanicMask(spell, iter->second->GetEffIndex()) & mechanic)
3832 m_target->RemoveAurasDueToSpell(spell->Id);
3833 if(Auras.empty())
3834 break;
3835 else
3836 next = Auras.begin();
3842 m_target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,m_modifier.m_miscvalue,apply);
3844 // Bestial Wrath
3845 if ( GetSpellProto()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellProto()->SpellIconID == 1680)
3847 // The Beast Within cast on owner if talent present
3848 if ( Unit* owner = m_target->GetOwner() )
3850 // Search talent
3851 Unit::AuraList const& m_dummyAuras = owner->GetAurasByType(SPELL_AURA_DUMMY);
3852 for(Unit::AuraList::const_iterator i = m_dummyAuras.begin(); i != m_dummyAuras.end(); ++i)
3854 if ( (*i)->GetSpellProto()->SpellIconID == 2229 )
3856 if (apply)
3857 owner->CastSpell(owner, 34471, true, 0, this);
3858 else
3859 owner->RemoveAurasDueToSpell(34471);
3860 break;
3866 // The Beast Within and Bestial Wrath - immunity
3867 if(GetId() == 19574 || GetId() == 34471)
3869 if(apply)
3871 m_target->CastSpell(m_target,24395,true);
3872 m_target->CastSpell(m_target,24396,true);
3873 m_target->CastSpell(m_target,24397,true);
3874 m_target->CastSpell(m_target,26592,true);
3876 else
3878 m_target->RemoveAurasDueToSpell(24395);
3879 m_target->RemoveAurasDueToSpell(24396);
3880 m_target->RemoveAurasDueToSpell(24397);
3881 m_target->RemoveAurasDueToSpell(26592);
3886 void Aura::HandleAuraModEffectImmunity(bool apply, bool Real)
3888 if(!apply)
3890 if(m_target->GetTypeId() == TYPEID_PLAYER)
3892 if(((Player*)m_target)->InBattleGround())
3894 BattleGround *bg = ((Player*)m_target)->GetBattleGround();
3895 if(bg)
3897 switch(bg->GetTypeID())
3899 case BATTLEGROUND_AV:
3901 break;
3903 case BATTLEGROUND_WS:
3905 // Warsong Flag, horde // Silverwing Flag, alliance
3906 if(GetId() == 23333 || GetId() == 23335)
3907 bg->EventPlayerDroppedFlag(((Player*)m_target));
3908 break;
3910 case BATTLEGROUND_AB:
3912 break;
3914 case BATTLEGROUND_EY:
3916 if(GetId() == 34976)
3917 bg->EventPlayerDroppedFlag(((Player*)m_target));
3918 break;
3926 m_target->ApplySpellImmune(GetId(),IMMUNITY_EFFECT,m_modifier.m_miscvalue,apply);
3929 void Aura::HandleAuraModStateImmunity(bool apply, bool Real)
3931 if(apply && Real && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
3933 Unit::AuraList const& auraList = m_target->GetAurasByType(AuraType(m_modifier.m_miscvalue));
3934 for(Unit::AuraList::const_iterator itr = auraList.begin(); itr != auraList.end();)
3936 if (auraList.front() != this) // skip itself aura (it already added)
3938 m_target->RemoveAurasDueToSpell(auraList.front()->GetId());
3939 itr = auraList.begin();
3941 else
3942 ++itr;
3946 m_target->ApplySpellImmune(GetId(),IMMUNITY_STATE,m_modifier.m_miscvalue,apply);
3949 void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real)
3951 m_target->ApplySpellImmune(GetId(),IMMUNITY_SCHOOL,m_modifier.m_miscvalue,apply);
3953 if(Real && apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
3955 if(IsPositiveSpell(GetId())) //Only positive immunity removes auras
3957 uint32 school_mask = m_modifier.m_miscvalue;
3958 Unit::AuraMap& Auras = m_target->GetAuras();
3959 for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next)
3961 next = iter;
3962 ++next;
3963 SpellEntry const *spell = iter->second->GetSpellProto();
3964 if((GetSpellSchoolMask(spell) & school_mask)//Check for school mask
3965 && !( spell->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY) //Spells unaffected by invulnerability
3966 && !iter->second->IsPositive() //Don't remove positive spells
3967 && spell->Id != GetId() ) //Don't remove self
3969 m_target->RemoveAurasDueToSpell(spell->Id);
3970 if(Auras.empty())
3971 break;
3972 else
3973 next = Auras.begin();
3978 if( Real && GetSpellProto()->Mechanic == MECHANIC_BANISH )
3980 if( apply )
3981 m_target->addUnitState(UNIT_STAT_ISOLATED);
3982 else
3983 m_target->clearUnitState(UNIT_STAT_ISOLATED);
3987 void Aura::HandleAuraModDmgImmunity(bool apply, bool Real)
3989 m_target->ApplySpellImmune(GetId(),IMMUNITY_DAMAGE,m_modifier.m_miscvalue,apply);
3992 void Aura::HandleAuraModDispelImmunity(bool apply, bool Real)
3994 // all applied/removed only at real aura add/remove
3995 if(!Real)
3996 return;
3998 m_target->ApplySpellDispelImmunity(m_spellProto, DispelType(m_modifier.m_miscvalue), apply);
4001 void Aura::HandleAuraProcTriggerSpell(bool apply, bool Real)
4003 if(!Real)
4004 return;
4006 if(apply)
4008 // some spell have charges by functionality not have its in spell data
4009 switch (GetId())
4011 case 28200: // Ascendance (Talisman of Ascendance trinket)
4012 SetAuraCharges(6);
4013 break;
4014 default: break;
4019 void Aura::HandleAuraModStalked(bool apply, bool Real)
4021 // used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND
4022 if(apply)
4023 m_target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT);
4024 else
4025 m_target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT);
4028 /*********************************************************/
4029 /*** PERIODIC ***/
4030 /*********************************************************/
4032 void Aura::HandlePeriodicTriggerSpell(bool apply, bool Real)
4034 m_isPeriodic = apply;
4037 void Aura::HandlePeriodicTriggerSpellWithValue(bool apply, bool Real)
4039 m_isPeriodic = apply;
4042 void Aura::HandlePeriodicEnergize(bool apply, bool Real)
4044 if (!Real)
4045 return;
4047 m_isPeriodic = apply;
4049 // Replenishment (0.25% from max)
4050 // Infinite Replenishment
4051 if (GetId() == 57669 ||
4052 GetId() == 61782)
4053 m_modifier.m_amount = m_target->GetMaxPower(POWER_MANA) * 25 / 10000;
4056 void Aura::HandleAuraPowerBurn(bool apply, bool Real)
4058 m_isPeriodic = apply;
4061 void Aura::HandleAuraPeriodicDummy(bool apply, bool Real)
4063 // spells required only Real aura add/remove
4064 if(!Real)
4065 return;
4067 // For prevent double apply bonuses
4068 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
4070 Unit* caster = GetCaster();
4072 SpellEntry const*spell = GetSpellProto();
4073 switch( spell->SpellFamilyName)
4075 case SPELLFAMILY_ROGUE:
4077 // Master of Subtlety
4078 if (spell->Id==31666 && !apply)
4080 m_target->RemoveAurasDueToSpell(31665);
4081 break;
4083 break;
4085 case SPELLFAMILY_HUNTER:
4087 // Explosive Shot
4088 if (apply && !loading && caster)
4089 m_modifier.m_amount +=caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 8 / 100;
4090 break;
4094 m_isPeriodic = apply;
4097 void Aura::HandlePeriodicHeal(bool apply, bool Real)
4099 m_isPeriodic = apply;
4102 void Aura::HandlePeriodicDamage(bool apply, bool Real)
4104 // spells required only Real aura add/remove
4105 if(!Real)
4106 return;
4108 m_isPeriodic = apply;
4110 // For prevent double apply bonuses
4111 bool loading = (m_target->GetTypeId() == TYPEID_PLAYER && ((Player*)m_target)->GetSession()->PlayerLoading());
4113 // Custom damage calculation after
4114 if (!apply || loading)
4115 return;
4117 Unit *caster = GetCaster();
4118 if (!caster)
4119 return;
4121 switch (m_spellProto->SpellFamilyName)
4123 case SPELLFAMILY_GENERIC:
4125 // Pounce Bleed
4126 if ( m_spellProto->SpellIconID == 147 && m_spellProto->SpellVisual[0] == 0 )
4128 // $AP*0.18/6 bonus per tick
4129 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 3 / 100);
4130 return;
4132 break;
4134 case SPELLFAMILY_WARRIOR:
4136 // Rend
4137 if (m_spellProto->SpellFamilyFlags & 0x0000000000000020LL)
4139 // $0.2*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick
4140 float ap = caster->GetTotalAttackPowerValue(BASE_ATTACK);
4141 int32 mws = caster->GetAttackTime(BASE_ATTACK);
4142 float mwb_min = caster->GetWeaponDamageRange(BASE_ATTACK,MINDAMAGE);
4143 float mwb_max = caster->GetWeaponDamageRange(BASE_ATTACK,MAXDAMAGE);
4144 m_modifier.m_amount+=int32(((mwb_min+mwb_max)/2+ap*mws/14000)*0.2f);
4145 return;
4147 break;
4149 case SPELLFAMILY_DRUID:
4151 // Rake
4152 if (m_spellProto->SpellFamilyFlags & 0x0000000000001000LL)
4154 // $AP*0.06 bonus per tick
4155 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 6 / 100);
4156 return;
4158 // Lacerate
4159 if (m_spellProto->SpellFamilyFlags & 0x000000010000000000LL)
4161 // $AP*0.05/5 bonus per tick
4162 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100);
4163 return;
4165 // Rip
4166 if (m_spellProto->SpellFamilyFlags & 0x000000000000800000LL)
4168 // 0.01*$AP*cp
4169 if (caster->GetTypeId() != TYPEID_PLAYER)
4170 return;
4172 uint8 cp = ((Player*)caster)->GetComboPoints();
4174 // Idol of Feral Shadows. Cant be handled as SpellMod in SpellAura:Dummy due its dependency from CPs
4175 Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY);
4176 for(Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr)
4178 if((*itr)->GetId()==34241)
4180 m_modifier.m_amount += cp * (*itr)->GetModifier()->m_amount;
4181 break;
4184 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * cp / 100);
4185 return;
4187 // Lock Jaw
4188 if (m_spellProto->SpellFamilyFlags & 0x1000000000000000LL)
4190 // 0.15*$AP
4191 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 15 / 100);
4192 return;
4194 break;
4196 case SPELLFAMILY_ROGUE:
4198 // Rupture
4199 if (m_spellProto->SpellFamilyFlags & 0x000000000000100000LL)
4201 if (caster->GetTypeId() != TYPEID_PLAYER)
4202 return;
4203 //1 point : ${($m1+$b1*1+0.015*$AP)*4} damage over 8 secs
4204 //2 points: ${($m1+$b1*2+0.024*$AP)*5} damage over 10 secs
4205 //3 points: ${($m1+$b1*3+0.03*$AP)*6} damage over 12 secs
4206 //4 points: ${($m1+$b1*4+0.03428571*$AP)*7} damage over 14 secs
4207 //5 points: ${($m1+$b1*5+0.0375*$AP)*8} damage over 16 secs
4208 float AP_per_combo[] = {0, 0.015f, 0.024, 0.03, 0.03428571, 0.0375};
4209 uint8 cp = ((Player*)caster)->GetComboPoints();
4210 if (cp > 5) cp = 5;
4211 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * AP_per_combo[cp]);
4212 return;
4214 // Garrote
4215 if (m_spellProto->SpellFamilyFlags & 0x000000000000000100LL)
4217 // $AP*0.07 bonus per tick
4218 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 7 / 100);
4219 return;
4221 // Deadly Poison
4222 if (m_spellProto->SpellFamilyFlags & 0x0000000000010000)
4224 // 0.08*$AP / 4 * amount of stack
4225 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(BASE_ATTACK) * 2 * GetStackAmount() / 100);
4226 return;
4228 break;
4230 case SPELLFAMILY_HUNTER:
4232 // Serpent Sting
4233 if (m_spellProto->SpellFamilyFlags & 0x0000000000004000LL)
4235 // $RAP*0.1/5 bonus per tick
4236 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 10 / 500);
4237 return;
4239 // Immolation Trap
4240 if (m_spellProto->SpellFamilyFlags & 0x0000000000000004LL && m_spellProto->SpellIconID == 678)
4242 // $RAP*0.1/5 bonus per tick
4243 m_modifier.m_amount += int32(caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 10 / 500);
4244 return;
4246 break;
4248 default:
4249 break;
4253 void Aura::HandlePeriodicDamagePCT(bool apply, bool Real)
4255 m_isPeriodic = apply;
4258 void Aura::HandlePeriodicLeech(bool apply, bool Real)
4260 m_isPeriodic = apply;
4263 void Aura::HandlePeriodicManaLeech(bool apply, bool Real)
4265 m_isPeriodic = apply;
4268 void Aura::HandlePeriodicHealthFunnel(bool apply, bool Real)
4270 m_isPeriodic = apply;
4273 /*********************************************************/
4274 /*** MODIFY STATS ***/
4275 /*********************************************************/
4277 /********************************/
4278 /*** RESISTANCE ***/
4279 /********************************/
4281 void Aura::HandleAuraModResistanceExclusive(bool apply, bool Real)
4283 for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++)
4285 if(m_modifier.m_miscvalue & int32(1<<x))
4287 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_VALUE, float(m_modifier.m_amount), apply);
4288 if(m_target->GetTypeId() == TYPEID_PLAYER)
4289 m_target->ApplyResistanceBuffModsMod(SpellSchools(x),m_positive,m_modifier.m_amount, apply);
4294 void Aura::HandleAuraModResistance(bool apply, bool Real)
4296 for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++)
4298 if(m_modifier.m_miscvalue & int32(1<<x))
4300 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), TOTAL_VALUE, float(m_modifier.m_amount), apply);
4301 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
4302 m_target->ApplyResistanceBuffModsMod(SpellSchools(x),m_positive,m_modifier.m_amount, apply);
4307 void Aura::HandleAuraModBaseResistancePCT(bool apply, bool Real)
4309 // only players have base stats
4310 if(m_target->GetTypeId() != TYPEID_PLAYER)
4312 //pets only have base armor
4313 if(((Creature*)m_target)->isPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL))
4314 m_target->HandleStatModifier(UNIT_MOD_ARMOR, BASE_PCT, float(m_modifier.m_amount), apply);
4316 else
4318 for(int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL;x++)
4320 if(m_modifier.m_miscvalue & int32(1<<x))
4321 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_PCT, float(m_modifier.m_amount), apply);
4326 void Aura::HandleModResistancePercent(bool apply, bool Real)
4328 for(int8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++)
4330 if(m_modifier.m_miscvalue & int32(1<<i))
4332 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply);
4333 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
4335 m_target->ApplyResistanceBuffModsPercentMod(SpellSchools(i),true,m_modifier.m_amount, apply);
4336 m_target->ApplyResistanceBuffModsPercentMod(SpellSchools(i),false,m_modifier.m_amount, apply);
4342 void Aura::HandleModBaseResistance(bool apply, bool Real)
4344 // only players have base stats
4345 if(m_target->GetTypeId() != TYPEID_PLAYER)
4347 //only pets have base stats
4348 if(((Creature*)m_target)->isPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL))
4349 m_target->HandleStatModifier(UNIT_MOD_ARMOR, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4351 else
4353 for(int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++)
4354 if(m_modifier.m_miscvalue & (1<<i))
4355 m_target->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply);
4359 /********************************/
4360 /*** STAT ***/
4361 /********************************/
4363 void Aura::HandleAuraModStat(bool apply, bool Real)
4365 if (m_modifier.m_miscvalue < -2 || m_modifier.m_miscvalue > 4)
4367 sLog.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ",GetId(),GetEffIndex(),m_modifier.m_miscvalue);
4368 return;
4371 for(int32 i = STAT_STRENGTH; i < MAX_STATS; i++)
4373 // -1 or -2 is all stats ( misc < -2 checked in function beginning )
4374 if (m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue == i)
4376 //m_target->ApplyStatMod(Stats(i), m_modifier.m_amount,apply);
4377 m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply);
4378 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
4379 m_target->ApplyStatBuffMod(Stats(i),m_modifier.m_amount,apply);
4384 void Aura::HandleModPercentStat(bool apply, bool Real)
4386 if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4)
4388 sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
4389 return;
4392 // only players have base stats
4393 if (m_target->GetTypeId() != TYPEID_PLAYER)
4394 return;
4396 for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i)
4398 if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1)
4399 m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), BASE_PCT, float(m_modifier.m_amount), apply);
4403 void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool Real)
4405 if(m_target->GetTypeId() != TYPEID_PLAYER)
4406 return;
4408 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4409 // This information for client side use only
4410 // Recalculate bonus
4411 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4414 void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool Real)
4416 if(m_target->GetTypeId() != TYPEID_PLAYER)
4417 return;
4419 // Recalculate bonus
4420 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4423 void Aura::HandleAuraModDispelResist(bool apply, bool Real)
4425 if(!Real || !apply)
4426 return;
4428 if(GetId()==33206)
4429 m_target->CastSpell(m_target,44416,true,NULL,this,GetCasterGUID());
4432 void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool Real)
4434 if(m_target->GetTypeId() != TYPEID_PLAYER)
4435 return;
4437 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4438 // This information for client side use only
4439 // Recalculate bonus
4440 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4443 void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool Real)
4445 if(m_target->GetTypeId() != TYPEID_PLAYER)
4446 return;
4448 // Recalculate bonus
4449 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4452 void Aura::HandleModHealingDone(bool /*apply*/, bool Real)
4454 if(m_target->GetTypeId() != TYPEID_PLAYER)
4455 return;
4456 // implemented in Unit::SpellHealingBonus
4457 // this information is for client side only
4458 ((Player*)m_target)->UpdateSpellDamageAndHealingBonus();
4461 void Aura::HandleModTotalPercentStat(bool apply, bool Real)
4463 if (m_modifier.m_miscvalue < -1 || m_modifier.m_miscvalue > 4)
4465 sLog.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
4466 return;
4469 //save current and max HP before applying aura
4470 uint32 curHPValue = m_target->GetHealth();
4471 uint32 maxHPValue = m_target->GetMaxHealth();
4473 for (int32 i = STAT_STRENGTH; i < MAX_STATS; i++)
4475 if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1)
4477 m_target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply);
4478 if(m_target->GetTypeId() == TYPEID_PLAYER || ((Creature*)m_target)->isPet())
4479 m_target->ApplyStatPercentBuffMod(Stats(i), m_modifier.m_amount, apply );
4483 //recalculate current HP/MP after applying aura modifications (only for spells with 0x10 flag)
4484 if ((m_modifier.m_miscvalue == STAT_STAMINA) && (maxHPValue > 0) && (m_spellProto->Attributes & 0x10))
4486 // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed
4487 uint32 newHPValue = (m_target->GetMaxHealth() * curHPValue) / maxHPValue;
4488 m_target->SetHealth(newHPValue);
4492 void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool Real)
4494 if(m_target->GetTypeId() != TYPEID_PLAYER)
4495 return;
4497 if(m_modifier.m_miscvalue != SPELL_SCHOOL_MASK_NORMAL)
4499 // support required adding replace UpdateArmor by loop by UpdateResistence at intellect update
4500 // and include in UpdateResistence same code as in UpdateArmor for aura mod apply.
4501 sLog.outError("Aura SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT(182) need adding support for non-armor resistances!");
4502 return;
4505 // Recalculate Armor
4506 m_target->UpdateArmor();
4509 /********************************/
4510 /*** HEAL & ENERGIZE ***/
4511 /********************************/
4512 void Aura::HandleAuraModTotalHealthPercentRegen(bool apply, bool Real)
4514 m_isPeriodic = apply;
4517 void Aura::HandleAuraModTotalManaPercentRegen(bool apply, bool Real)
4519 if(m_modifier.periodictime == 0)
4520 m_modifier.periodictime = 1000;
4522 m_periodicTimer = m_modifier.periodictime;
4523 m_isPeriodic = apply;
4526 void Aura::HandleModRegen(bool apply, bool Real) // eating
4528 if(m_modifier.periodictime == 0)
4529 m_modifier.periodictime = 5000;
4531 m_periodicTimer = 5000;
4532 m_isPeriodic = apply;
4535 void Aura::HandleModPowerRegen(bool apply, bool Real) // drinking
4537 if (!Real)
4538 return;
4540 Powers pt = m_target->getPowerType();
4541 if(m_modifier.periodictime == 0)
4543 if (pt == POWER_RAGE)
4544 m_modifier.periodictime = 1000;
4545 else
4546 m_modifier.periodictime = 2000;
4549 m_periodicTimer = 5000;
4551 if (m_target->GetTypeId() == TYPEID_PLAYER && m_modifier.m_miscvalue == POWER_MANA)
4552 ((Player*)m_target)->UpdateManaRegen();
4554 m_isPeriodic = apply;
4557 void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real)
4559 // spells required only Real aura add/remove
4560 if(!Real)
4561 return;
4563 if (m_target->GetTypeId() != TYPEID_PLAYER)
4564 return;
4566 // Update manaregen value
4567 if (m_modifier.m_miscvalue == POWER_MANA)
4568 ((Player*)m_target)->UpdateManaRegen();
4571 void Aura::HandleModManaRegen(bool /*apply*/, bool Real)
4573 // spells required only Real aura add/remove
4574 if(!Real)
4575 return;
4577 if (m_target->GetTypeId() != TYPEID_PLAYER)
4578 return;
4580 //Note: an increase in regen does NOT cause threat.
4581 ((Player*)m_target)->UpdateManaRegen();
4584 void Aura::HandleComprehendLanguage(bool apply, bool Real)
4586 if(apply)
4587 m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG);
4588 else
4589 m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG);
4592 void Aura::HandleAuraModIncreaseHealth(bool apply, bool Real)
4594 // Special case with temporary increase max/current health
4595 switch(GetId())
4597 case 12976: // Warrior Last Stand triggered spell
4598 case 28726: // Nightmare Seed ( Nightmare Seed )
4599 case 34511: // Valor (Bulwark of Kings, Bulwark of the Ancient Kings)
4600 case 44055: // Tremendous Fortitude (Battlemaster's Alacrity)
4602 if(Real)
4604 if(apply)
4606 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4607 m_target->ModifyHealth(m_modifier.m_amount);
4609 else
4611 if (int32(m_target->GetHealth()) > m_modifier.m_amount)
4612 m_target->ModifyHealth(-m_modifier.m_amount);
4613 else
4614 m_target->SetHealth(1);
4615 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4618 return;
4622 // generic case
4623 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4626 void Aura::HandleAuraModIncreaseMaxHealth(bool apply, bool Real)
4628 uint32 oldhealth = m_target->GetHealth();
4629 double healthPercentage = (double)oldhealth / (double)m_target->GetMaxHealth();
4631 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4633 // refresh percentage
4634 if(oldhealth > 0)
4636 uint32 newhealth = uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage));
4637 if(newhealth==0)
4638 newhealth = 1;
4640 m_target->SetHealth(newhealth);
4644 void Aura::HandleAuraModIncreaseEnergy(bool apply, bool Real)
4646 Powers powerType = m_target->getPowerType();
4647 if(int32(powerType) != m_modifier.m_miscvalue)
4648 return;
4650 UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType);
4652 m_target->HandleStatModifier(unitMod, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4655 void Aura::HandleAuraModIncreaseEnergyPercent(bool apply, bool /*Real*/)
4657 Powers powerType = m_target->getPowerType();
4658 if(int32(powerType) != m_modifier.m_miscvalue)
4659 return;
4661 UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType);
4663 m_target->HandleStatModifier(unitMod, TOTAL_PCT, float(m_modifier.m_amount), apply);
4666 void Aura::HandleAuraModIncreaseHealthPercent(bool apply, bool /*Real*/)
4668 m_target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_PCT, float(m_modifier.m_amount), apply);
4671 void Aura::HandleAuraIncreaseBaseHealthPercent(bool apply, bool /*Real*/)
4673 m_target->HandleStatModifier(UNIT_MOD_HEALTH, BASE_PCT, float(m_modifier.m_amount), apply);
4676 /********************************/
4677 /*** FIGHT ***/
4678 /********************************/
4680 void Aura::HandleAuraModParryPercent(bool /*apply*/, bool Real)
4682 if(m_target->GetTypeId()!=TYPEID_PLAYER)
4683 return;
4685 ((Player*)m_target)->UpdateParryPercentage();
4688 void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool Real)
4690 if(m_target->GetTypeId()!=TYPEID_PLAYER)
4691 return;
4693 ((Player*)m_target)->UpdateDodgePercentage();
4694 //sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount));
4697 void Aura::HandleAuraModBlockPercent(bool /*apply*/, bool Real)
4699 if(m_target->GetTypeId()!=TYPEID_PLAYER)
4700 return;
4702 ((Player*)m_target)->UpdateBlockPercentage();
4703 //sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount));
4706 void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real)
4708 // spells required only Real aura add/remove
4709 if(!Real)
4710 return;
4712 if(m_target->GetTypeId()!=TYPEID_PLAYER)
4713 return;
4715 ((Player*)m_target)->UpdateManaRegen();
4718 void Aura::HandleAuraModCritPercent(bool apply, bool Real)
4720 if(m_target->GetTypeId()!=TYPEID_PLAYER)
4721 return;
4723 // apply item specific bonuses for already equipped weapon
4724 if(Real)
4726 for(int i = 0; i < MAX_ATTACK; ++i)
4727 if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i)))
4728 ((Player*)m_target)->_ApplyWeaponDependentAuraCritMod(pItem,WeaponAttackType(i),this,apply);
4731 // mods must be applied base at equipped weapon class and subclass comparison
4732 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
4733 // m_modifier.m_miscvalue comparison with item generated damage types
4735 if (GetSpellProto()->EquippedItemClass == -1)
4737 ((Player*)m_target)->HandleBaseModValue(CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
4738 ((Player*)m_target)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
4739 ((Player*)m_target)->HandleBaseModValue(RANGED_CRIT_PERCENTAGE, FLAT_MOD, float (m_modifier.m_amount), apply);
4741 else
4743 // done in Player::_ApplyWeaponDependentAuraMods
4747 void Aura::HandleModHitChance(bool apply, bool Real)
4749 if(m_target->GetTypeId() == TYPEID_PLAYER)
4751 ((Player*)m_target)->UpdateMeleeHitChances();
4752 ((Player*)m_target)->UpdateRangedHitChances();
4754 else
4756 m_target->m_modMeleeHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount);
4757 m_target->m_modRangedHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount);
4761 void Aura::HandleModSpellHitChance(bool apply, bool Real)
4763 if(m_target->GetTypeId() == TYPEID_PLAYER)
4765 ((Player*)m_target)->UpdateSpellHitChances();
4767 else
4769 m_target->m_modSpellHitChance += apply ? m_modifier.m_amount: (-m_modifier.m_amount);
4773 void Aura::HandleModSpellCritChance(bool apply, bool Real)
4775 // spells required only Real aura add/remove
4776 if(!Real)
4777 return;
4779 if(m_target->GetTypeId() == TYPEID_PLAYER)
4781 ((Player*)m_target)->UpdateAllSpellCritChances();
4783 else
4785 m_target->m_baseSpellCritChance += apply ? m_modifier.m_amount:(-m_modifier.m_amount);
4789 void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real)
4791 // spells required only Real aura add/remove
4792 if(!Real)
4793 return;
4795 if(m_target->GetTypeId() != TYPEID_PLAYER)
4796 return;
4798 for(int school = SPELL_SCHOOL_NORMAL; school < MAX_SPELL_SCHOOL; ++school)
4799 if (m_modifier.m_miscvalue & (1<<school))
4800 ((Player*)m_target)->UpdateSpellCritChance(school);
4803 /********************************/
4804 /*** ATTACK SPEED ***/
4805 /********************************/
4807 void Aura::HandleModCastingSpeed(bool apply, bool Real)
4809 m_target->ApplyCastTimePercentMod(m_modifier.m_amount,apply);
4812 void Aura::HandleModMeleeRangedSpeedPct(bool apply, bool Real)
4814 m_target->ApplyAttackTimePercentMod(BASE_ATTACK,m_modifier.m_amount,apply);
4815 m_target->ApplyAttackTimePercentMod(OFF_ATTACK,m_modifier.m_amount,apply);
4816 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply);
4819 void Aura::HandleModCombatSpeedPct(bool apply, bool Real)
4821 m_target->ApplyCastTimePercentMod(m_modifier.m_amount,apply);
4822 m_target->ApplyAttackTimePercentMod(BASE_ATTACK,m_modifier.m_amount,apply);
4823 m_target->ApplyAttackTimePercentMod(OFF_ATTACK,m_modifier.m_amount,apply);
4824 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply);
4827 void Aura::HandleModAttackSpeed(bool apply, bool Real)
4829 if(!m_target->isAlive() )
4830 return;
4832 m_target->ApplyAttackTimePercentMod(BASE_ATTACK,m_modifier.m_amount,apply);
4835 void Aura::HandleHaste(bool apply, bool Real)
4837 m_target->ApplyAttackTimePercentMod(BASE_ATTACK, m_modifier.m_amount,apply);
4838 m_target->ApplyAttackTimePercentMod(OFF_ATTACK, m_modifier.m_amount,apply);
4839 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK,m_modifier.m_amount,apply);
4842 void Aura::HandleAuraModRangedHaste(bool apply, bool Real)
4844 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK, m_modifier.m_amount, apply);
4847 void Aura::HandleRangedAmmoHaste(bool apply, bool Real)
4849 if(m_target->GetTypeId() != TYPEID_PLAYER)
4850 return;
4851 m_target->ApplyAttackTimePercentMod(RANGED_ATTACK,m_modifier.m_amount, apply);
4854 /********************************/
4855 /*** ATTACK POWER ***/
4856 /********************************/
4858 void Aura::HandleAuraModAttackPower(bool apply, bool Real)
4860 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4863 void Aura::HandleAuraModRangedAttackPower(bool apply, bool Real)
4865 if((m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0)
4866 return;
4868 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4871 void Aura::HandleAuraModAttackPowerPercent(bool apply, bool Real)
4873 //UNIT_FIELD_ATTACK_POWER_MULTIPLIER = multiplier - 1
4874 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_PCT, float(m_modifier.m_amount), apply);
4877 void Aura::HandleAuraModRangedAttackPowerPercent(bool apply, bool Real)
4879 if((m_target->getClassMask() & CLASSMASK_WAND_USERS)!=0)
4880 return;
4882 //UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1
4883 m_target->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply);
4886 void Aura::HandleAuraModRangedAttackPowerOfStatPercent(bool apply, bool Real)
4888 // spells required only Real aura add/remove
4889 if(!Real)
4890 return;
4892 // Recalculate bonus
4893 if(m_target->GetTypeId() == TYPEID_PLAYER && !(m_target->getClassMask() & CLASSMASK_WAND_USERS))
4894 ((Player*)m_target)->UpdateAttackPowerAndDamage(true);
4897 void Aura::HandleAuraModAttackPowerOfStatPercent(bool apply, bool Real)
4899 // spells required only Real aura add/remove
4900 if(!Real)
4901 return;
4903 // Recalculate bonus
4904 if(m_target->GetTypeId() == TYPEID_PLAYER)
4905 ((Player*)m_target)->UpdateAttackPowerAndDamage(false);
4908 /********************************/
4909 /*** DAMAGE BONUS ***/
4910 /********************************/
4911 void Aura::HandleModDamageDone(bool apply, bool Real)
4913 // apply item specific bonuses for already equipped weapon
4914 if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
4916 for(int i = 0; i < MAX_ATTACK; ++i)
4917 if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i)))
4918 ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem,WeaponAttackType(i),this,apply);
4921 // m_modifier.m_miscvalue is bitmask of spell schools
4922 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
4923 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wands
4924 // 127 - full bitmask any damages
4926 // mods must be applied base at equipped weapon class and subclass comparison
4927 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
4928 // m_modifier.m_miscvalue comparison with item generated damage types
4930 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0)
4932 // apply generic physical damage bonuses including wand case
4933 if (GetSpellProto()->EquippedItemClass == -1 || m_target->GetTypeId() != TYPEID_PLAYER)
4935 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4936 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4937 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply);
4939 else
4941 // done in Player::_ApplyWeaponDependentAuraMods
4944 if(m_target->GetTypeId() == TYPEID_PLAYER)
4946 if(m_positive)
4947 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS,m_modifier.m_amount,apply);
4948 else
4949 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG,m_modifier.m_amount,apply);
4953 // Skip non magic case for speedup
4954 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0)
4955 return;
4957 if( GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0 )
4959 // wand magic case (skip generic to all item spell bonuses)
4960 // done in Player::_ApplyWeaponDependentAuraMods
4962 // Skip item specific requirements for not wand magic damage
4963 return;
4966 // Magic damage modifiers implemented in Unit::SpellDamageBonus
4967 // This information for client side use only
4968 if(m_target->GetTypeId() == TYPEID_PLAYER)
4970 if(m_positive)
4972 for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; i++)
4974 if((m_modifier.m_miscvalue & (1<<i)) != 0)
4975 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i,m_modifier.m_amount,apply);
4978 else
4980 for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; i++)
4982 if((m_modifier.m_miscvalue & (1<<i)) != 0)
4983 m_target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG+i,m_modifier.m_amount,apply);
4986 Pet* pet = m_target->GetPet();
4987 if(pet)
4988 pet->UpdateAttackPowerAndDamage();
4992 void Aura::HandleModDamagePercentDone(bool apply, bool Real)
4994 sLog.outDebug("AURA MOD DAMAGE type:%u negative:%u", m_modifier.m_miscvalue, m_positive ? 0 : 1);
4996 // apply item specific bonuses for already equipped weapon
4997 if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
4999 for(int i = 0; i < MAX_ATTACK; ++i)
5000 if(Item* pItem = ((Player*)m_target)->GetWeaponForAttack(WeaponAttackType(i)))
5001 ((Player*)m_target)->_ApplyWeaponDependentAuraDamageMod(pItem,WeaponAttackType(i),this,apply);
5004 // m_modifier.m_miscvalue is bitmask of spell schools
5005 // 1 ( 0-bit ) - normal school damage (SPELL_SCHOOL_MASK_NORMAL)
5006 // 126 - full bitmask all magic damages (SPELL_SCHOOL_MASK_MAGIC) including wand
5007 // 127 - full bitmask any damages
5009 // mods must be applied base at equipped weapon class and subclass comparison
5010 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
5011 // m_modifier.m_miscvalue comparison with item generated damage types
5013 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) != 0)
5015 // apply generic physical damage bonuses including wand case
5016 if (GetSpellProto()->EquippedItemClass == -1 || m_target->GetTypeId() != TYPEID_PLAYER)
5018 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT, float(m_modifier.m_amount), apply);
5019 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply);
5020 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply);
5022 else
5024 // done in Player::_ApplyWeaponDependentAuraMods
5026 // For show in client
5027 if(m_target->GetTypeId() == TYPEID_PLAYER)
5028 m_target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT,m_modifier.m_amount/100.0f,apply);
5031 // Skip non magic case for speedup
5032 if((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0)
5033 return;
5035 if( GetSpellProto()->EquippedItemClass != -1 || GetSpellProto()->EquippedItemInventoryTypeMask != 0 )
5037 // wand magic case (skip generic to all item spell bonuses)
5038 // done in Player::_ApplyWeaponDependentAuraMods
5040 // Skip item specific requirements for not wand magic damage
5041 return;
5044 // Magic damage percent modifiers implemented in Unit::SpellDamageBonus
5045 // Send info to client
5046 if(m_target->GetTypeId() == TYPEID_PLAYER)
5047 for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
5048 m_target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT+i,m_modifier.m_amount/100.0f,apply);
5051 void Aura::HandleModOffhandDamagePercent(bool apply, bool Real)
5053 // spells required only Real aura add/remove
5054 if(!Real)
5055 return;
5057 sLog.outDebug("AURA MOD OFFHAND DAMAGE");
5059 m_target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(m_modifier.m_amount), apply);
5062 /********************************/
5063 /*** POWER COST ***/
5064 /********************************/
5066 void Aura::HandleModPowerCostPCT(bool apply, bool Real)
5068 // spells required only Real aura add/remove
5069 if(!Real)
5070 return;
5072 float amount = m_modifier.m_amount/100.0f;
5073 for(int i = 0; i < MAX_SPELL_SCHOOL; ++i)
5074 if(m_modifier.m_miscvalue & (1<<i))
5075 m_target->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+i,amount,apply);
5078 void Aura::HandleModPowerCost(bool apply, bool Real)
5080 // spells required only Real aura add/remove
5081 if(!Real)
5082 return;
5084 for(int i = 0; i < MAX_SPELL_SCHOOL; ++i)
5085 if(m_modifier.m_miscvalue & (1<<i))
5086 m_target->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER+i,m_modifier.m_amount,apply);
5089 void Aura::HandleNoReagentUseAura(bool Apply, bool Real)
5091 // spells required only Real aura add/remove
5092 if(!Real)
5093 return;
5094 if(m_target->GetTypeId() != TYPEID_PLAYER)
5095 return;
5096 uint32 mask[3] = {0, 0, 0};
5097 Unit::AuraList const& noReagent = m_target->GetAurasByType(SPELL_AURA_NO_REAGENT_USE);
5098 for(Unit::AuraList::const_iterator i = noReagent.begin(); i != noReagent.end(); ++i)
5100 uint32 const *ptr = (*i)->getAuraSpellClassMask();
5101 mask[0]|=ptr[0];
5102 mask[1]|=ptr[1];
5103 mask[2]|=ptr[2];
5106 m_target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1 , mask[0]);
5107 m_target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1+1, mask[1]);
5108 m_target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1+2, mask[2]);
5111 /*********************************************************/
5112 /*** OTHERS ***/
5113 /*********************************************************/
5115 void Aura::HandleShapeshiftBoosts(bool apply)
5117 uint32 spellId = 0;
5118 uint32 spellId2 = 0;
5119 uint32 HotWSpellId = 0;
5121 switch(GetModifier()->m_miscvalue)
5123 case FORM_CAT:
5124 spellId = 3025;
5125 HotWSpellId = 24900;
5126 break;
5127 case FORM_TREE:
5128 spellId = 5420;
5129 spellId2 = 34123;
5130 break;
5131 case FORM_TRAVEL:
5132 spellId = 5419;
5133 break;
5134 case FORM_AQUA:
5135 spellId = 5421;
5136 break;
5137 case FORM_BEAR:
5138 spellId = 1178;
5139 spellId2 = 21178;
5140 HotWSpellId = 24899;
5141 break;
5142 case FORM_DIREBEAR:
5143 spellId = 9635;
5144 spellId2 = 21178;
5145 HotWSpellId = 24899;
5146 break;
5147 case FORM_BATTLESTANCE:
5148 spellId = 21156;
5149 break;
5150 case FORM_DEFENSIVESTANCE:
5151 spellId = 7376;
5152 break;
5153 case FORM_BERSERKERSTANCE:
5154 spellId = 7381;
5155 break;
5156 case FORM_MOONKIN:
5157 spellId = 24905;
5158 // aura from effect trigger spell
5159 spellId2 = 24907;
5160 break;
5161 case FORM_FLIGHT:
5162 spellId = 33948;
5163 spellId2 = 34764;
5164 break;
5165 case FORM_FLIGHT_EPIC:
5166 spellId = 40122;
5167 spellId2 = 40121;
5168 break;
5169 case FORM_METAMORPHOSIS:
5170 spellId = 54817;
5171 spellId2 = 54879;
5172 break;
5173 case FORM_SPIRITOFREDEMPTION:
5174 spellId = 27792;
5175 spellId2 = 27795; // must be second, this important at aura remove to prevent to early iterator invalidation.
5176 break;
5177 case FORM_GHOSTWOLF:
5178 case FORM_AMBIENT:
5179 case FORM_GHOUL:
5180 case FORM_SHADOW:
5181 case FORM_STEALTH:
5182 case FORM_CREATURECAT:
5183 case FORM_CREATUREBEAR:
5184 spellId = 0;
5185 break;
5188 uint32 form = GetModifier()->m_miscvalue-1;
5190 if(apply)
5192 if (spellId) m_target->CastSpell(m_target, spellId, true, NULL, this );
5193 if (spellId2) m_target->CastSpell(m_target, spellId2, true, NULL, this);
5195 if(m_target->GetTypeId() == TYPEID_PLAYER)
5197 const PlayerSpellMap& sp_list = ((Player *)m_target)->GetSpellMap();
5198 for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
5200 if(itr->second->state == PLAYERSPELL_REMOVED) continue;
5201 if(itr->first==spellId || itr->first==spellId2) continue;
5202 SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
5203 if (!spellInfo || !(spellInfo->Attributes & (SPELL_ATTR_PASSIVE | (1<<7)))) continue;
5204 if (spellInfo->Stances & (1<<form))
5205 m_target->CastSpell(m_target, itr->first, true, NULL, this);
5207 //LotP
5208 if (((Player*)m_target)->HasSpell(17007))
5210 SpellEntry const *spellInfo = sSpellStore.LookupEntry(24932);
5211 if (spellInfo && spellInfo->Stances & (1<<form))
5212 m_target->CastSpell(m_target, 24932, true, NULL, this);
5214 // HotW
5215 if (HotWSpellId)
5217 Unit::AuraList const& mModTotalStatPct = m_target->GetAurasByType(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE);
5218 for(Unit::AuraList::const_iterator i = mModTotalStatPct.begin(); i != mModTotalStatPct.end(); ++i)
5220 if ((*i)->GetSpellProto()->SpellIconID == 240 && (*i)->GetModifier()->m_miscvalue == 3)
5222 int32 HotWMod = (*i)->GetModifier()->m_amount;
5223 if(GetModifier()->m_miscvalue == FORM_CAT)
5224 HotWMod /= 2;
5226 m_target->CastCustomSpell(m_target, HotWSpellId, &HotWMod, NULL, NULL, true, NULL, this);
5227 break;
5233 else
5235 m_target->RemoveAurasDueToSpell(spellId);
5236 m_target->RemoveAurasDueToSpell(spellId2);
5238 Unit::AuraMap& tAuras = m_target->GetAuras();
5239 for (Unit::AuraMap::iterator itr = tAuras.begin(); itr != tAuras.end();)
5241 if (itr->second->IsRemovedOnShapeLost())
5243 m_target->RemoveAurasDueToSpell(itr->second->GetId());
5244 itr = tAuras.begin();
5246 else
5248 ++itr;
5253 /*double healthPercentage = (double)m_target->GetHealth() / (double)m_target->GetMaxHealth();
5254 m_target->SetHealth(uint32(ceil((double)m_target->GetMaxHealth() * healthPercentage)));*/
5257 void Aura::HandleAuraEmpathy(bool apply, bool Real)
5259 if(m_target->GetTypeId() != TYPEID_UNIT)
5260 return;
5262 CreatureInfo const * ci = objmgr.GetCreatureTemplate(m_target->GetEntry());
5263 if(ci && ci->type == CREATURE_TYPE_BEAST)
5264 m_target->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO, apply);
5267 void Aura::HandleAuraUntrackable(bool apply, bool Real)
5269 if(apply)
5270 m_target->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE);
5271 else
5272 m_target->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE);
5275 void Aura::HandleAuraModPacify(bool apply, bool Real)
5277 if(m_target->GetTypeId() != TYPEID_PLAYER)
5278 return;
5280 if(apply)
5281 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
5282 else
5283 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
5286 void Aura::HandleAuraModPacifyAndSilence(bool apply, bool Real)
5288 HandleAuraModPacify(apply,Real);
5289 HandleAuraModSilence(apply,Real);
5292 void Aura::HandleAuraGhost(bool apply, bool Real)
5294 if(m_target->GetTypeId() != TYPEID_PLAYER)
5295 return;
5297 if(apply)
5299 m_target->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST);
5301 else
5303 m_target->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST);
5307 void Aura::HandleAuraAllowFlight(bool apply, bool Real)
5309 // all applied/removed only at real aura add/remove
5310 if(!Real)
5311 return;
5313 // allow fly
5314 WorldPacket data;
5315 if(apply)
5316 data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
5317 else
5318 data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
5319 data.append(m_target->GetPackGUID());
5320 data << uint32(0); // unk
5321 m_target->SendMessageToSet(&data, true);
5324 void Aura::HandleModRating(bool apply, bool Real)
5326 // spells required only Real aura add/remove
5327 if(!Real)
5328 return;
5330 if(m_target->GetTypeId() != TYPEID_PLAYER)
5331 return;
5333 for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating)
5334 if (m_modifier.m_miscvalue & (1 << rating))
5335 ((Player*)m_target)->ApplyRatingMod(CombatRating(rating), m_modifier.m_amount, apply);
5338 void Aura::HandleModRatingFromStat(bool apply, bool Real)
5340 // spells required only Real aura add/remove
5341 if(!Real)
5342 return;
5344 if(m_target->GetTypeId() != TYPEID_PLAYER)
5345 return;
5346 // Just recalculate ratings
5347 for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating)
5348 if (m_modifier.m_miscvalue & (1 << rating))
5349 ((Player*)m_target)->ApplyRatingMod(CombatRating(rating), 0, apply);
5352 void Aura::HandleForceMoveForward(bool apply, bool Real)
5354 if(!Real || m_target->GetTypeId() != TYPEID_PLAYER)
5355 return;
5356 if(apply)
5357 m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE);
5358 else
5359 m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE);
5362 void Aura::HandleAuraModExpertise(bool /*apply*/, bool Real)
5364 if(m_target->GetTypeId() != TYPEID_PLAYER)
5365 return;
5367 ((Player*)m_target)->UpdateExpertise(BASE_ATTACK);
5368 ((Player*)m_target)->UpdateExpertise(OFF_ATTACK);
5371 void Aura::HandleModTargetResistance(bool apply, bool Real)
5373 // spells required only Real aura add/remove
5374 if(!Real)
5375 return;
5376 // applied to damage as HandleNoImmediateEffect in Unit::CalcAbsorbResist and Unit::CalcArmorReducedDamage
5378 // show armor penetration
5379 if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL))
5380 m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE,m_modifier.m_amount, apply);
5382 // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy
5383 if (m_target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_SPELL)==SPELL_SCHOOL_MASK_SPELL)
5384 m_target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE,m_modifier.m_amount, apply);
5387 void Aura::HandleShieldBlockValue(bool apply, bool Real)
5389 BaseModType modType = FLAT_MOD;
5390 if(m_modifier.m_auraname == SPELL_AURA_MOD_SHIELD_BLOCKVALUE_PCT)
5391 modType = PCT_MOD;
5393 if(m_target->GetTypeId() == TYPEID_PLAYER)
5394 ((Player*)m_target)->HandleBaseModValue(SHIELD_BLOCK_VALUE, modType, float(m_modifier.m_amount), apply);
5397 void Aura::HandleAuraRetainComboPoints(bool apply, bool Real)
5399 // spells required only Real aura add/remove
5400 if(!Real)
5401 return;
5403 if(m_target->GetTypeId() != TYPEID_PLAYER)
5404 return;
5406 Player *target = (Player*)m_target;
5408 // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler
5409 // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost)
5410 if( !apply && m_duration==0 && target->GetComboTarget())
5411 if(Unit* unit = ObjectAccessor::GetUnit(*m_target,target->GetComboTarget()))
5412 target->AddComboPoints(unit, -m_modifier.m_amount);
5415 void Aura::HandleModUnattackable( bool Apply, bool Real )
5417 if(Real && Apply)
5418 m_target->CombatStop();
5420 m_target->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE,Apply);
5423 void Aura::HandleSpiritOfRedemption( bool apply, bool Real )
5425 // spells required only Real aura add/remove
5426 if(!Real)
5427 return;
5429 // prepare spirit state
5430 if(apply)
5432 if(m_target->GetTypeId()==TYPEID_PLAYER)
5434 // disable breath/etc timers
5435 ((Player*)m_target)->StopMirrorTimers();
5437 // set stand state (expected in this form)
5438 if(!m_target->IsStandState())
5439 m_target->SetStandState(UNIT_STAND_STATE_STAND);
5442 m_target->SetHealth(1);
5444 // die at aura end
5445 else
5446 m_target->DealDamage(m_target, m_target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, GetSpellProto(), false);
5449 void Aura::CleanupTriggeredSpells()
5451 if (m_spellProto->SpellFamilyName == SPELLFAMILY_WARRIOR && m_spellProto->SpellFamilyFlags & 0x0000001000000020LL)
5453 // Blood Frenzy remove
5454 m_target->RemoveAurasDueToSpell(30069);
5455 m_target->RemoveAurasDueToSpell(30070);
5456 return;
5459 uint32 tSpellId = m_spellProto->EffectTriggerSpell[GetEffIndex()];
5460 if(!tSpellId)
5461 return;
5463 SpellEntry const* tProto = sSpellStore.LookupEntry(tSpellId);
5464 if(!tProto)
5465 return;
5467 if(GetSpellDuration(tProto) != -1)
5468 return;
5470 // needed for spell 43680, maybe others
5471 // TODO: is there a spell flag, which can solve this in a more sophisticated way?
5472 if(m_spellProto->EffectApplyAuraName[GetEffIndex()] == SPELL_AURA_PERIODIC_TRIGGER_SPELL &&
5473 GetSpellDuration(m_spellProto) == m_spellProto->EffectAmplitude[GetEffIndex()])
5474 return;
5475 m_target->RemoveAurasDueToSpell(tSpellId);
5478 void Aura::HandleSchoolAbsorb(bool apply, bool Real)
5480 if(!Real)
5481 return;
5483 // prevent double apply bonuses
5484 if(apply && (m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading()))
5486 if(Unit* caster = GetCaster())
5488 float DoneActualBenefit = 0.0f;
5489 switch(m_spellProto->SpellFamilyName)
5491 case SPELLFAMILY_PRIEST:
5492 if(m_spellProto->SpellFamilyFlags == 0x1) //PW:S
5494 //+30% from +healing bonus
5495 DoneActualBenefit = caster->SpellBaseHealingBonus(GetSpellSchoolMask(m_spellProto)) * 0.3f;
5496 break;
5498 break;
5499 case SPELLFAMILY_MAGE:
5500 if(m_spellProto->SpellFamilyFlags == 0x80100 || m_spellProto->SpellFamilyFlags == 0x8 || m_spellProto->SpellFamilyFlags == 0x100000000LL)
5502 //frost ward, fire ward, ice barrier
5503 //+10% from +spd bonus
5504 DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.1f;
5505 break;
5507 break;
5508 case SPELLFAMILY_WARLOCK:
5509 if(m_spellProto->SpellFamilyFlags == 0x00)
5511 //shadow ward
5512 //+10% from +spd bonus
5513 DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.1f;
5514 break;
5516 break;
5517 default:
5518 break;
5521 DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto());
5523 m_modifier.m_amount += (int32)DoneActualBenefit;
5528 void Aura::PeriodicTick()
5530 if(!m_target->isAlive())
5531 return;
5533 switch(m_modifier.m_auraname)
5535 case SPELL_AURA_PERIODIC_DAMAGE:
5536 case SPELL_AURA_PERIODIC_DAMAGE_PERCENT:
5538 Unit *pCaster = GetCaster();
5539 if(!pCaster)
5540 return;
5542 if( GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA &&
5543 pCaster->SpellHitResult(m_target,GetSpellProto(),false)!=SPELL_MISS_NONE)
5544 return;
5546 // Check for immune (not use charges)
5547 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5548 return;
5550 // some auras remove at specific health level or more
5551 if(m_modifier.m_auraname==SPELL_AURA_PERIODIC_DAMAGE)
5553 switch(GetId())
5555 case 43093: case 31956: case 38801:
5556 case 35321: case 38363: case 39215:
5557 if(m_target->GetHealth() == m_target->GetMaxHealth() )
5559 m_target->RemoveAurasDueToSpell(GetId());
5560 return;
5562 break;
5563 case 38772:
5565 uint32 percent =
5566 GetEffIndex() < 2 && GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_DUMMY ?
5567 pCaster->CalculateSpellDamage(GetSpellProto(),GetEffIndex()+1,GetSpellProto()->EffectBasePoints[GetEffIndex()+1],m_target) :
5568 100;
5569 if(m_target->GetHealth()*100 >= m_target->GetMaxHealth()*percent )
5571 m_target->RemoveAurasDueToSpell(GetId());
5572 return;
5574 break;
5576 default:
5577 break;
5581 uint32 absorb=0;
5582 uint32 resist=0;
5583 CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
5585 // ignore non positive values (can be result apply spellmods to aura damage
5586 uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
5588 uint32 pdamage;
5590 if(m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE)
5592 pdamage = amount;
5594 // Calculate armor mitigation if it is a physical spell
5595 // But not for bleed mechanic spells
5596 if ( GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL &&
5597 GetEffectMechanic(GetSpellProto(), m_effIndex) != MECHANIC_BLEED)
5599 uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage);
5600 cleanDamage.damage += pdamage - pdamageReductedArmor;
5601 pdamage = pdamageReductedArmor;
5604 pdamage = pCaster->SpellDamageBonus(m_target, GetSpellProto(), pdamage, DOT, GetStackAmount());
5606 // Curse of Agony damage-per-tick calculation
5607 if (GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARLOCK && (GetSpellProto()->SpellFamilyFlags & 0x0000000000000400LL) && GetSpellProto()->SpellIconID==544)
5609 // 1..4 ticks, 1/2 from normal tick damage
5610 if (m_duration>=((m_maxduration-m_modifier.periodictime)*2/3))
5611 pdamage = pdamage/2;
5612 // 9..12 ticks, 3/2 from normal tick damage
5613 else if(m_duration<((m_maxduration-m_modifier.periodictime)/3))
5614 pdamage += (pdamage+1)/2; // +1 prevent 0.5 damage possible lost at 1..4 ticks
5615 // 5..8 ticks have normal tick damage
5618 else
5619 pdamage = uint32(m_target->GetMaxHealth()*amount/100);
5621 //As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit
5622 // Reduce dot damage from resilience for players
5623 if (m_target->GetTypeId()==TYPEID_PLAYER)
5624 pdamage-=((Player*)m_target)->GetDotDamageReduction(pdamage);
5626 pCaster->CalcAbsorbResist(m_target, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist);
5628 sLog.outDetail("PeriodicTick: %u (TypeId: %u) attacked %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
5629 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb);
5631 WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size
5632 data.append(m_target->GetPackGUID());
5633 data.appendPackGUID(GetCasterGUID());
5634 data << uint32(GetId());
5635 data << uint32(1);
5636 data << uint32(m_modifier.m_auraname);
5637 data << (uint32)pdamage;
5638 data << uint32(0); // overkill
5639 data << (uint32)GetSpellSchoolMask(GetSpellProto()); // will be mask in 2.4.x
5640 data << (uint32)absorb;
5641 data << (uint32)resist;
5642 m_target->SendMessageToSet(&data,true);
5644 Unit* target = m_target; // aura can be deleted in DealDamage
5645 SpellEntry const* spellProto = GetSpellProto();
5647 // Set trigger flag
5648 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;// | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
5649 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
5650 pdamage = (pdamage <= absorb+resist) ? 0 : (pdamage-absorb-resist);
5651 if (pdamage)
5652 procVictim|=PROC_FLAG_TAKEN_ANY_DAMAGE;
5653 pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto);
5655 pCaster->DealDamage(target, pdamage, &cleanDamage, DOT, GetSpellSchoolMask(spellProto), spellProto, true);
5656 break;
5658 case SPELL_AURA_PERIODIC_LEECH:
5659 case SPELL_AURA_PERIODIC_HEALTH_FUNNEL:
5661 Unit *pCaster = GetCaster();
5662 if(!pCaster)
5663 return;
5665 if(!pCaster->isAlive())
5666 return;
5668 if( GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA &&
5669 pCaster->SpellHitResult(m_target,GetSpellProto(),false)!=SPELL_MISS_NONE)
5670 return;
5672 // Check for immune
5673 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5674 return;
5676 uint32 absorb=0;
5677 uint32 resist=0;
5678 CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
5680 uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
5682 //Calculate armor mitigation if it is a physical spell
5683 if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL)
5685 uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage);
5686 cleanDamage.damage += pdamage - pdamageReductedArmor;
5687 pdamage = pdamageReductedArmor;
5690 pdamage = pCaster->SpellDamageBonus(m_target, GetSpellProto(), pdamage, DOT, GetStackAmount());
5692 //As of 2.2 resilience reduces damage from DoT ticks as much as the chance to not be critically hit
5693 // Reduce dot damage from resilience for players
5694 if (m_target->GetTypeId()==TYPEID_PLAYER)
5695 pdamage-=((Player*)m_target)->GetDotDamageReduction(pdamage);
5697 pCaster->CalcAbsorbResist(m_target, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist);
5699 if(m_target->GetHealth() < pdamage)
5700 pdamage = uint32(m_target->GetHealth());
5702 sLog.outDetail("PeriodicTick: %u (TypeId: %u) health leech of %u (TypeId: %u) for %u dmg inflicted by %u abs is %u",
5703 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId(),absorb);
5705 pCaster->SendSpellNonMeleeDamageLog(m_target, GetId(), pdamage, GetSpellSchoolMask(GetSpellProto()), absorb, resist, false, 0);
5708 Unit* target = m_target; // aura can be deleted in DealDamage
5709 SpellEntry const* spellProto = GetSpellProto();
5710 float multiplier = spellProto->EffectMultipleValue[GetEffIndex()] > 0 ? spellProto->EffectMultipleValue[GetEffIndex()] : 1;
5711 int32 stackAmount = GetStackAmount();
5713 // Set trigger flag
5714 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;// | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
5715 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
5716 pdamage = (pdamage <= absorb+resist) ? 0 : (pdamage-absorb-resist);
5717 if (pdamage)
5718 procVictim|=PROC_FLAG_TAKEN_ANY_DAMAGE;
5719 pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto);
5720 int32 new_damage = pCaster->DealDamage(target, pdamage, &cleanDamage, DOT, GetSpellSchoolMask(spellProto), spellProto, false);
5722 if (!target->isAlive() && pCaster->IsNonMeleeSpellCasted(false))
5724 for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++)
5726 if (pCaster->m_currentSpells[i] && pCaster->m_currentSpells[i]->m_spellInfo->Id == spellProto->Id)
5727 pCaster->m_currentSpells[i]->cancel();
5732 if(Player *modOwner = pCaster->GetSpellModOwner())
5733 modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_MULTIPLE_VALUE, multiplier);
5735 uint32 heal = pCaster->SpellHealingBonus(pCaster, spellProto, uint32(new_damage * multiplier), DOT, stackAmount);
5737 int32 gain = pCaster->ModifyHealth(heal);
5738 pCaster->getHostilRefManager().threatAssist(pCaster, gain * 0.5f, spellProto);
5740 pCaster->SendHealSpellLog(pCaster, spellProto->Id, heal);
5741 break;
5743 case SPELL_AURA_PERIODIC_HEAL:
5744 case SPELL_AURA_OBS_MOD_HEALTH:
5746 Unit *pCaster = GetCaster();
5747 if(!pCaster)
5748 return;
5750 // heal for caster damage (must be alive)
5751 if(m_target != pCaster && GetSpellProto()->SpellVisual[0]==163 && !pCaster->isAlive())
5752 return;
5754 // ignore non positive values (can be result apply spellmods to aura damage
5755 uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
5757 uint32 pdamage;
5759 if(m_modifier.m_auraname==SPELL_AURA_OBS_MOD_HEALTH)
5760 pdamage = uint32(m_target->GetMaxHealth() * amount/100);
5761 else
5762 pdamage = amount;
5764 pdamage = pCaster->SpellHealingBonus(m_target, GetSpellProto(), pdamage, DOT, GetStackAmount());
5766 sLog.outDetail("PeriodicTick: %u (TypeId: %u) heal of %u (TypeId: %u) for %u health inflicted by %u",
5767 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
5769 WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size
5770 data.append(m_target->GetPackGUID());
5771 data.appendPackGUID(GetCasterGUID());
5772 data << uint32(GetId());
5773 data << uint32(1);
5774 data << uint32(m_modifier.m_auraname);
5775 data << (uint32)pdamage;
5776 data << uint32(0); // wotlk
5777 m_target->SendMessageToSet(&data,true);
5779 int32 gain = m_target->ModifyHealth(pdamage);
5781 // add HoTs to amount healed in bgs
5782 if( pCaster->GetTypeId() == TYPEID_PLAYER )
5783 if( BattleGround *bg = ((Player*)pCaster)->GetBattleGround() )
5784 bg->UpdatePlayerScore(((Player*)pCaster), SCORE_HEALING_DONE, gain);
5786 //Do check before because m_modifier.auraName can be invalidate by DealDamage.
5787 bool procSpell = (m_modifier.m_auraname == SPELL_AURA_PERIODIC_HEAL && m_target != pCaster);
5789 m_target->getHostilRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto());
5791 Unit* target = m_target; // aura can be deleted in DealDamage
5792 SpellEntry const* spellProto = GetSpellProto();
5793 bool haveCastItem = GetCastItemGUID()!=0;
5795 // heal for caster damage
5796 if(m_target!=pCaster && spellProto->SpellVisual[0]==163)
5798 uint32 dmg = spellProto->manaPerSecond;
5799 if(pCaster->GetHealth() <= dmg && pCaster->GetTypeId()==TYPEID_PLAYER)
5801 pCaster->RemoveAurasDueToSpell(GetId());
5803 // finish current generic/channeling spells, don't affect autorepeat
5804 if(pCaster->m_currentSpells[CURRENT_GENERIC_SPELL])
5806 pCaster->m_currentSpells[CURRENT_GENERIC_SPELL]->finish();
5808 if(pCaster->m_currentSpells[CURRENT_CHANNELED_SPELL])
5810 pCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]->SendChannelUpdate(0);
5811 pCaster->m_currentSpells[CURRENT_CHANNELED_SPELL]->finish();
5814 else
5816 pCaster->SendSpellNonMeleeDamageLog(pCaster, GetId(), gain, GetSpellSchoolMask(GetSpellProto()), 0, 0, false, 0, false);
5818 CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
5819 pCaster->DealDamage(pCaster, gain, &cleanDamage, NODAMAGE, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
5823 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;// | PROC_FLAG_SUCCESSFUL_HEAL;
5824 uint32 procVictim = 0;//ROC_FLAG_ON_TAKE_PERIODIC | PROC_FLAG_TAKEN_HEAL;
5825 // ignore item heals
5826 // if(procSpell && !haveCastItem)
5827 // pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, PROC_EX_NORMAL_HIT, pdamage, BASE_ATTACK, spellProto);
5828 break;
5830 case SPELL_AURA_PERIODIC_MANA_LEECH:
5832 Unit *pCaster = GetCaster();
5833 if(!pCaster)
5834 return;
5836 if(!pCaster->isAlive())
5837 return;
5839 if( GetSpellProto()->Effect[GetEffIndex()]==SPELL_EFFECT_PERSISTENT_AREA_AURA &&
5840 pCaster->SpellHitResult(m_target,GetSpellProto(),false)!=SPELL_MISS_NONE)
5841 return;
5843 // Check for immune (not use charges)
5844 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5845 return;
5847 // ignore non positive values (can be result apply spellmods to aura damage
5848 uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
5850 sLog.outDetail("PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u",
5851 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
5853 if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS)
5854 break;
5856 Powers power = Powers(m_modifier.m_miscvalue);
5858 // power type might have changed between aura applying and tick (druid's shapeshift)
5859 if(m_target->getPowerType() != power)
5860 break;
5862 int32 drain_amount = m_target->GetPower(power) > pdamage ? pdamage : m_target->GetPower(power);
5864 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
5865 if (power == POWER_MANA && m_target->GetTypeId() == TYPEID_PLAYER)
5866 drain_amount -= ((Player*)m_target)->GetSpellCritDamageReduction(drain_amount);
5868 m_target->ModifyPower(power, -drain_amount);
5870 float gain_multiplier = 0;
5872 if(pCaster->GetMaxPower(power) > 0)
5874 gain_multiplier = GetSpellProto()->EffectMultipleValue[GetEffIndex()];
5876 if(Player *modOwner = pCaster->GetSpellModOwner())
5877 modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, gain_multiplier);
5880 WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size
5881 data.append(m_target->GetPackGUID());
5882 data.appendPackGUID(GetCasterGUID());
5883 data << uint32(GetId());
5884 data << uint32(1);
5885 data << uint32(m_modifier.m_auraname);
5886 data << (uint32)power; // power type
5887 data << (uint32)drain_amount;
5888 data << (float)gain_multiplier;
5889 m_target->SendMessageToSet(&data,true);
5891 int32 gain_amount = int32(drain_amount*gain_multiplier);
5893 if(gain_amount)
5895 int32 gain = pCaster->ModifyPower(power,gain_amount);
5896 m_target->AddThreat(pCaster, float(gain) * 0.5f, GetSpellSchoolMask(GetSpellProto()), GetSpellProto());
5898 break;
5900 case SPELL_AURA_PERIODIC_ENERGIZE:
5902 // ignore non positive values (can be result apply spellmods to aura damage
5903 uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
5905 sLog.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u dmg inflicted by %u",
5906 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
5908 if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS)
5909 break;
5911 Powers power = Powers(m_modifier.m_miscvalue);
5913 if(m_target->GetMaxPower(power) == 0)
5914 break;
5916 WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size
5917 data.append(m_target->GetPackGUID());
5918 data.appendPackGUID(GetCasterGUID());
5919 data << uint32(GetId());
5920 data << uint32(1);
5921 data << uint32(m_modifier.m_auraname);
5922 data << (uint32)power; // power type
5923 data << (uint32)pdamage;
5924 m_target->SendMessageToSet(&data,true);
5926 int32 gain = m_target->ModifyPower(power,pdamage);
5928 if(Unit* pCaster = GetCaster())
5929 m_target->getHostilRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto());
5930 break;
5932 case SPELL_AURA_OBS_MOD_MANA:
5934 // ignore non positive values (can be result apply spellmods to aura damage
5935 uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
5937 uint32 pdamage = uint32(m_target->GetMaxPower(POWER_MANA) * amount/100);
5939 sLog.outDetail("PeriodicTick: %u (TypeId: %u) energize %u (TypeId: %u) for %u mana inflicted by %u",
5940 GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
5942 if(m_target->GetMaxPower(POWER_MANA) == 0)
5943 break;
5945 WorldPacket data(SMSG_PERIODICAURALOG, (21+16));// we guess size
5946 data.append(m_target->GetPackGUID());
5947 data.appendPackGUID(GetCasterGUID());
5948 data << uint32(GetId());
5949 data << uint32(1);
5950 data << uint32(m_modifier.m_auraname);
5951 data << (uint32)0; // ?
5952 data << (uint32)pdamage;
5953 m_target->SendMessageToSet(&data,true);
5955 int32 gain = m_target->ModifyPower(POWER_MANA, pdamage);
5957 if(Unit* pCaster = GetCaster())
5958 m_target->getHostilRefManager().threatAssist(pCaster, float(gain) * 0.5f, GetSpellProto());
5959 break;
5961 case SPELL_AURA_POWER_BURN_MANA:
5963 Unit *pCaster = GetCaster();
5964 if(!pCaster)
5965 return;
5967 // Check for immune (not use charges)
5968 if(m_target->IsImmunedToDamage(GetSpellSchoolMask(GetSpellProto())))
5969 return;
5971 int32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
5973 Powers powerType = Powers(m_modifier.m_miscvalue);
5975 if(!m_target->isAlive() || m_target->getPowerType() != powerType)
5976 return;
5978 // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
5979 if (powerType == POWER_MANA && m_target->GetTypeId() == TYPEID_PLAYER)
5980 pdamage -= ((Player*)m_target)->GetSpellCritDamageReduction(pdamage);
5982 uint32 gain = uint32(-m_target->ModifyPower(powerType, -pdamage));
5984 gain = uint32(gain * GetSpellProto()->EffectMultipleValue[GetEffIndex()]);
5986 SpellEntry const* spellProto = GetSpellProto();
5987 //maybe has to be sent different to client, but not by SMSG_PERIODICAURALOG
5988 SpellNonMeleeDamage damageInfo(pCaster, m_target, spellProto->Id, spellProto->SchoolMask);
5989 pCaster->CalculateSpellDamage(&damageInfo, gain, spellProto);
5990 pCaster->SendSpellNonMeleeDamageLog(&damageInfo);
5992 // Set trigger flag
5993 uint32 procAttacker = PROC_FLAG_ON_DO_PERIODIC;// | PROC_FLAG_SUCCESSFUL_HARMFUL_SPELL_HIT;
5994 uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT;
5995 uint32 procEx = createProcExtendMask(&damageInfo, SPELL_MISS_NONE);
5996 if (damageInfo.damage)
5997 procVictim|=PROC_FLAG_TAKEN_ANY_DAMAGE;
5999 pCaster->ProcDamageAndSpell(damageInfo.target, procAttacker, procVictim, procEx, damageInfo.damage, BASE_ATTACK, spellProto);
6001 pCaster->DealSpellDamage(&damageInfo, true);
6002 break;
6004 case SPELL_AURA_MOD_REGEN:
6006 int32 gain = m_target->ModifyHealth(m_modifier.m_amount);
6007 if (Unit *caster = GetCaster())
6008 m_target->getHostilRefManager().threatAssist(caster, float(gain) * 0.5f, GetSpellProto());
6009 break;
6011 case SPELL_AURA_MOD_POWER_REGEN:
6013 Powers pt = m_target->getPowerType();
6014 if(int32(pt) != m_modifier.m_miscvalue)
6015 return;
6017 if ( GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED )
6019 // eating anim
6020 m_target->HandleEmoteCommand(EMOTE_ONESHOT_EAT);
6022 else if( GetId() == 20577 )
6024 // cannibalize anim
6025 m_target->HandleEmoteCommand(EMOTE_STATE_CANNIBALIZE);
6028 // Warrior talent, gain 1 rage every 3 seconds while in combat
6029 if(pt == POWER_RAGE && m_target->isInCombat())
6030 m_target->ModifyPower(pt, m_modifier.m_amount*10/17);
6031 break;
6033 // Here tick dummy auras
6034 case SPELL_AURA_PERIODIC_DUMMY:
6036 PeriodicDummyTick();
6037 break;
6039 case SPELL_AURA_PERIODIC_TRIGGER_SPELL:
6041 TriggerSpell();
6042 break;
6044 case SPELL_AURA_PERIODIC_TRIGGER_SPELL_WITH_VALUE:
6046 TriggerSpellWithValue();
6047 break;
6049 default:
6050 break;
6054 void Aura::PeriodicDummyTick()
6056 Unit *caster = GetCaster();
6057 SpellEntry const* spell = GetSpellProto();
6058 switch (spell->SpellFamilyName)
6060 case SPELLFAMILY_GENERIC:
6061 switch (spell->Id)
6063 // Drink
6064 case 430:
6065 case 431:
6066 case 432:
6067 case 1133:
6068 case 1135:
6069 case 1137:
6070 case 10250:
6071 case 22734:
6072 case 27089:
6073 case 34291:
6074 case 43706:
6075 case 46755:
6076 case 49472: // Drink Coffee
6077 case 61830:
6079 if (m_target->GetTypeId() != TYPEID_PLAYER)
6080 return;
6081 // Search SPELL_AURA_MOD_POWER_REGEN aura for this spell and add bonus
6082 Unit::AuraList const& aura = m_target->GetAurasByType(SPELL_AURA_MOD_POWER_REGEN);
6083 for(Unit::AuraList::const_iterator i = aura.begin(); i != aura.end(); ++i)
6085 if ((*i)->GetId() == GetId())
6087 (*i)->GetModifier()->m_amount = m_modifier.m_amount;
6088 ((Player*)m_target)->UpdateManaRegen();
6089 // Disable continue
6090 m_isPeriodic = false;
6091 return;
6094 return;
6096 // Forsaken Skills
6097 case 7054:
6099 // Possibly need cast one of them (but
6100 // 7038 Forsaken Skill: Swords
6101 // 7039 Forsaken Skill: Axes
6102 // 7040 Forsaken Skill: Daggers
6103 // 7041 Forsaken Skill: Maces
6104 // 7042 Forsaken Skill: Staves
6105 // 7043 Forsaken Skill: Bows
6106 // 7044 Forsaken Skill: Guns
6107 // 7045 Forsaken Skill: 2H Axes
6108 // 7046 Forsaken Skill: 2H Maces
6109 // 7047 Forsaken Skill: 2H Swords
6110 // 7048 Forsaken Skill: Defense
6111 // 7049 Forsaken Skill: Fire
6112 // 7050 Forsaken Skill: Frost
6113 // 7051 Forsaken Skill: Holy
6114 // 7053 Forsaken Skill: Shadow
6115 return;
6117 // // Panda
6118 // case 19230: break;
6119 // // Gossip NPC Periodic - Talk
6120 // case 33208: break;
6121 // // Gossip NPC Periodic - Despawn
6122 // case 33209: break;
6123 // // Steal Weapon
6124 // case 36207: break;
6125 // // Simon Game START timer, (DND)
6126 // case 39993: break;
6127 // // Knockdown Fel Cannon: break; The Aggro Burst
6128 // case 40119: break;
6129 // // Old Mount Spell
6130 // case 40154: break;
6131 // // Magnetic Pull
6132 // case 40581: break;
6133 // // Ethereal Ring: break; The Bolt Burst
6134 // case 40801: break;
6135 // // Crystal Prison
6136 // case 40846: break;
6137 // // Copy Weapon
6138 // case 41054: break;
6139 // // Dementia
6140 // case 41404: break;
6141 // // Ethereal Ring Visual, Lightning Aura
6142 // case 41477: break;
6143 // // Ethereal Ring Visual, Lightning Aura (Fork)
6144 // case 41525: break;
6145 // // Ethereal Ring Visual, Lightning Jumper Aura
6146 // case 41567: break;
6147 // // No Man's Land
6148 // case 41955: break;
6149 // // Headless Horseman - Fire
6150 // case 42074: break;
6151 // // Headless Horseman - Visual - Large Fire
6152 // case 42075: break;
6153 // // Headless Horseman - Start Fire, Periodic Aura
6154 // case 42140: break;
6155 // // Ram Speed Boost
6156 // case 42152: break;
6157 // // Headless Horseman - Fires Out Victory Aura
6158 // case 42235: break;
6159 // // Pumpkin Life Cycle
6160 // case 42280: break;
6161 // // Brewfest Request Chick Chuck Mug Aura
6162 // case 42537: break;
6163 // // Squashling
6164 // case 42596: break;
6165 // // Headless Horseman Climax, Head: Periodic
6166 // case 42603: break;
6167 // // Fire Bomb
6168 // case 42621: break;
6169 // // Headless Horseman - Conflagrate, Periodic Aura
6170 // case 42637: break;
6171 // // Headless Horseman - Create Pumpkin Treats Aura
6172 // case 42774: break;
6173 // // Headless Horseman Climax - Summoning Rhyme Aura
6174 // case 42879: break;
6175 // // Tricky Treat
6176 // case 42919: break;
6177 // // Giddyup!
6178 // case 42924: break;
6179 // // Ram - Trot
6180 // case 42992: break;
6181 // // Ram - Canter
6182 // case 42993: break;
6183 // // Ram - Gallop
6184 // case 42994: break;
6185 // // Ram Level - Neutral
6186 // case 43310: break;
6187 // // Headless Horseman - Maniacal Laugh, Maniacal, Delayed 17
6188 // case 43884: break;
6189 // // Wretched!
6190 // case 43963: break;
6191 // // Headless Horseman - Maniacal Laugh, Maniacal, other, Delayed 17
6192 // case 44000: break;
6193 // // Energy Feedback
6194 // case 44328: break;
6195 // // Romantic Picnic
6196 // case 45102: break;
6197 // // Romantic Picnic
6198 // case 45123: break;
6199 // // Looking for Love
6200 // case 45124: break;
6201 // // Kite - Lightning Strike Kite Aura
6202 // case 45197: break;
6203 // // Rocket Chicken
6204 // case 45202: break;
6205 // // Copy Offhand Weapon
6206 // case 45205: break;
6207 // // Upper Deck - Kite - Lightning Periodic Aura
6208 // case 45207: break;
6209 // // Kite -Sky Lightning Strike Kite Aura
6210 // case 45251: break;
6211 // // Ribbon Pole Dancer Check Aura
6212 // case 45390: break;
6213 // // Holiday - Midsummer, Ribbon Pole Periodic Visual
6214 // case 45406: break;
6215 // // Parachute
6216 // case 45472: break;
6217 // // Alliance Flag, Extra Damage Debuff
6218 // case 45898: break;
6219 // // Horde Flag, Extra Damage Debuff
6220 // case 45899: break;
6221 // // Ahune - Summoning Rhyme Aura
6222 // case 45926: break;
6223 // // Ahune - Slippery Floor
6224 // case 45945: break;
6225 // // Ahune's Shield
6226 // case 45954: break;
6227 // // Nether Vapor Lightning
6228 // case 45960: break;
6229 // // Darkness
6230 // case 45996: break;
6231 // // Summon Blood Elves Periodic
6232 // case 46041: break;
6233 // // Transform Visual Missile Periodic
6234 // case 46205: break;
6235 // // Find Opening Beam End
6236 // case 46333: break;
6237 // // Ice Spear Control Aura
6238 // case 46371: break;
6239 // // Hailstone Chill
6240 // case 46458: break;
6241 // // Hailstone Chill, Internal
6242 // case 46465: break;
6243 // // Chill, Internal Shifter
6244 // case 46549: break;
6245 // // Summon Ice Spear Knockback Delayer
6246 // case 46878: break;
6247 // // Burninate Effect
6248 // case 47214: break;
6249 // // Fizzcrank Practice Parachute
6250 // case 47228: break;
6251 // // Send Mug Control Aura
6252 // case 47369: break;
6253 // // Direbrew's Disarm (precast)
6254 // case 47407: break;
6255 // // Mole Machine Port Schedule
6256 // case 47489: break;
6257 // case 47941: break; // Crystal Spike
6258 // case 48200: break; // Healer Aura
6259 // case 48630: break; // Summon Gauntlet Mobs Periodic
6260 // case 49313: break; // Proximity Mine Area Aura
6261 // // Mole Machine Portal Schedule
6262 // case 49466: break;
6263 // case 49555: break; // Corpse Explode
6264 // case 49592: break; // Temporal Rift
6265 // case 49957: break; // Cutting Laser
6266 // case 50085: break; // Slow Fall
6267 // // Listening to Music
6268 // case 50493: break;
6269 // // Love Rocket Barrage
6270 // case 50530: break;
6271 // Exist more after, need add later
6272 default:
6273 break;
6275 break;
6276 case SPELLFAMILY_MAGE:
6278 // Mirror Image
6279 // if (spell->Id == 55342)
6280 // return;
6281 break;
6283 case SPELLFAMILY_WARRIOR:
6285 // Armored to the Teeth
6286 if (spell->SpellIconID == 3516)
6288 // Increases your attack power by $s1 for every $s2 armor value you have.
6289 // Calculate AP bonus (from 1 efect of this spell)
6290 int32 apBonus = m_modifier.m_amount * m_target->GetArmor() / m_target->CalculateSpellDamage(spell, 1, spell->EffectBasePoints[1], m_target);
6291 m_target->CastCustomSpell(m_target, 61217, &apBonus, &apBonus, 0, true, 0, this);
6292 return;
6294 break;
6296 case SPELLFAMILY_DRUID:
6298 switch (spell->Id)
6300 // Frenzied Regeneration
6301 case 22842:
6303 // Converts up to 10 rage per second into health for $d. Each point of rage is converted into ${$m2/10}.1% of max health.
6304 // Should be manauser
6305 if (m_target->getPowerType()!=POWER_RAGE)
6306 return;
6307 uint32 rage = m_target->GetPower(POWER_RAGE);
6308 // Nothing todo
6309 if (rage == 0)
6310 return;
6311 int32 mod = (rage < 100) ? rage : 100;
6312 int32 points = m_target->CalculateSpellDamage(spell, 1, spell->EffectBasePoints[1], m_target);
6313 int32 regen = m_target->GetMaxHealth() * (mod * points / 10) / 1000;
6314 m_target->CastCustomSpell(m_target, 22845, &regen, 0, 0, true, 0, this);
6315 m_target->SetPower(POWER_RAGE, rage-mod);
6316 return;
6318 // Force of Nature
6319 case 33831:
6320 return;
6321 default:
6322 break;
6324 break;
6326 case SPELLFAMILY_ROGUE:
6328 // switch (spell->Id)
6329 // {
6330 // Master of Subtlety
6331 // case 31666: break;
6332 // Killing Spree
6333 // case 51690: break;
6334 // Overkill
6335 // case 58428: break;
6336 // default:
6337 // break;
6338 // }
6339 break;
6341 case SPELLFAMILY_HUNTER:
6343 // Explosive Shot
6344 if (spell->SpellFamilyFlags & 0x8000000000000000LL)
6346 if (!caster)
6347 return;
6348 int32 damage = m_modifier.m_amount;
6349 // Full damage to target at 0 tick
6350 if (m_duration > m_modifier.periodictime)
6352 caster->CastCustomSpell(m_target, 53352, &damage, 0, 0, true, 0, this);
6353 return;
6355 damage/=4;
6356 caster->CastCustomSpell(m_target, 56298, &damage, 0, 0, true, 0, this);
6357 return;
6359 switch (spell->Id)
6361 // Harpooner's Mark
6362 // case 40084:
6363 // return;
6364 // Feeding Frenzy Rank 1
6365 case 53511:
6366 if ( m_target->GetHealth() * 100 < m_target->GetMaxHealth() * 35 )
6367 m_target->CastSpell(m_target, 60096, true, 0, this);
6368 return;
6369 // Feeding Frenzy Rank 2
6370 case 53512:
6371 if ( m_target->GetHealth() * 100 < m_target->GetMaxHealth() * 35 )
6372 m_target->CastSpell(m_target, 60097, true, 0, this);
6373 return;
6374 default:
6375 break;
6377 break;
6379 case SPELLFAMILY_SHAMAN:
6381 // Astral Shift
6382 if (spell->Id == 52179)
6384 // Periodic need for remove visual on stun/fear/silence lost
6385 if (!(m_target->GetUInt32Value(UNIT_FIELD_FLAGS)&(UNIT_FLAG_STUNNED|UNIT_FLAG_FLEEING|UNIT_FLAG_SILENCED)))
6386 m_target->RemoveAurasDueToSpell(52179);
6387 return;
6389 break;
6391 case SPELLFAMILY_DEATHKNIGHT:
6393 // Death and Decay
6394 if (spell->SpellFamilyFlags & 0x0000000000000020LL)
6396 if (caster)
6397 caster->CastCustomSpell(m_target, 52212, &m_modifier.m_amount, NULL, NULL, true, 0, this);
6398 return;
6400 // Raise Dead
6401 // if (spell->SpellFamilyFlags & 0x0000000000001000LL)
6402 // return;
6403 // Chains of Ice
6404 if (spell->SpellFamilyFlags & 0x0000400000000000LL)
6406 // Get 0 effect aura
6407 Aura *slow = m_target->GetAura(GetId(), 0);
6408 if (slow)
6410 slow->ApplyModifier(false, true);
6411 Modifier *mod = slow->GetModifier();
6412 mod->m_amount+= m_modifier.m_amount;
6413 if (mod->m_amount > 0) mod->m_amount = 0;
6414 slow->ApplyModifier(true, true);
6416 return;
6418 // Summon Gargoyle
6419 // if (spell->SpellFamilyFlags & 0x0000008000000000LL)
6420 // return;
6421 // Death Rune Mastery
6422 // if (spell->SpellFamilyFlags & 0x0000000000004000LL)
6423 // return;
6424 // Bladed Armor
6425 if (spell->SpellIconID == 2653)
6427 // Increases your attack power by $s1 for every $s2 armor value you have.
6428 // Calculate AP bonus (from 1 efect of this spell)
6429 int32 apBonus = m_modifier.m_amount * m_target->GetArmor() / m_target->CalculateSpellDamage(spell, 1, spell->EffectBasePoints[1], m_target);
6430 m_target->CastCustomSpell(m_target, 61217, &apBonus, &apBonus, 0, true, 0, this);
6431 return;
6433 // Reaping
6434 // if (spell->SpellIconID == 22)
6435 // return;
6436 // Blood of the North
6437 // if (spell->SpellIconID == 30412)
6438 // return;
6439 break;
6441 default:
6442 break;
6446 void Aura::HandlePreventFleeing(bool apply, bool Real)
6448 if(!Real)
6449 return;
6451 Unit::AuraList const& fearAuras = m_target->GetAurasByType(SPELL_AURA_MOD_FEAR);
6452 if( !fearAuras.empty() )
6454 if (apply)
6455 m_target->SetFeared(false, fearAuras.front()->GetCasterGUID());
6456 else
6457 m_target->SetFeared(true);
6461 void Aura::HandleManaShield(bool apply, bool Real)
6463 if(!Real)
6464 return;
6466 // prevent double apply bonuses
6467 if(apply && (m_target->GetTypeId()!=TYPEID_PLAYER || !((Player*)m_target)->GetSession()->PlayerLoading()))
6469 if(Unit* caster = GetCaster())
6471 float DoneActualBenefit = 0.0f;
6472 switch(m_spellProto->SpellFamilyName)
6474 case SPELLFAMILY_MAGE:
6475 if(m_spellProto->SpellFamilyFlags & 0x8000)
6477 // Mana Shield
6478 // +50% from +spd bonus
6479 DoneActualBenefit = caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellProto)) * 0.5f;
6480 break;
6482 break;
6483 default:
6484 break;
6487 DoneActualBenefit *= caster->CalculateLevelPenalty(GetSpellProto());
6489 m_modifier.m_amount += (int32)DoneActualBenefit;
6494 void Aura::HandleArenaPreparation(bool apply, bool Real)
6496 if(!Real)
6497 return;
6499 if(apply)
6500 m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION);
6501 else
6502 m_target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION);
6505 void Aura::HandleAuraControlVehicle(bool apply, bool Real)
6507 if(!Real)
6508 return;
6510 if(m_target->GetTypeId() != TYPEID_PLAYER)
6511 return;
6513 if(Pet *pet = m_target->GetPet())
6514 pet->Remove(PET_SAVE_AS_CURRENT);
6516 WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0);
6517 ((Player*)m_target)->GetSession()->SendPacket(&data);
6520 void Aura::HandleAuraConvertRune(bool apply, bool Real)
6522 if(!Real)
6523 return;
6525 if(m_target->GetTypeId() != TYPEID_PLAYER)
6526 return;
6528 Player *plr = (Player*)m_target;
6530 if(plr->getClass() != CLASS_DEATH_KNIGHT)
6531 return;
6533 // how to determine what rune need to be converted?
6534 for(uint32 i = 0; i < MAX_RUNES; ++i)
6536 if(apply)
6538 if(!plr->GetRuneCooldown(i))
6540 plr->ConvertRune(i, GetSpellProto()->EffectMiscValueB[m_effIndex]);
6541 break;
6544 else
6546 if(plr->GetCurrentRune(i) == GetSpellProto()->EffectMiscValueB[m_effIndex])
6548 plr->ConvertRune(i, plr->GetBaseRune(i));
6549 break;
6555 void Aura::HandlePhase(bool apply, bool Real)
6557 if(!Real)
6558 return;
6560 // always non stackable
6561 if(apply)
6563 Unit::AuraList const& phases = m_target->GetAurasByType(SPELL_AURA_PHASE);
6564 if(!phases.empty())
6565 m_target->RemoveAurasDueToSpell(phases.front()->GetId(),this);
6568 // no-phase is also phase state so same code for apply and remove
6570 // phase auras normally not expected at BG but anyway better check
6571 if(m_target->GetTypeId()==TYPEID_PLAYER)
6573 // drop flag at invisible in bg
6574 if(((Player*)m_target)->InBattleGround())
6575 if(BattleGround *bg = ((Player*)m_target)->GetBattleGround())
6576 bg->EventPlayerDroppedFlag((Player*)m_target);
6578 // GM-mode have mask 0xFFFFFFFF
6579 if(!((Player*)m_target)->isGameMaster())
6580 m_target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL,false);
6582 else
6583 m_target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL,false);
6585 // need triggering visibility update base at phase update of not GM invisible (other GMs anyway see in any phases)
6586 if(m_target->GetVisibility()!=VISIBILITY_OFF)
6587 m_target->SetVisibility(m_target->GetVisibility());