2 * Copyright (C) 2005,2006 MaNGOS <http://www.mangosproject.org/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "Database/DatabaseEnv.h"
21 #include "WorldPacket.h"
22 #include "WorldSession.h"
25 #include "UpdateMask.h"
27 #include "ObjectMgr.h"
31 #include "SpellAuras.h"
32 #include "EventSystem.h"
33 #include "DynamicObject.h"
35 #include "UpdateData.h"
36 #include "MapManager.h"
37 #include "ObjectAccessor.h"
38 #include "RedZoneDistrict.h"
40 #include "Policies/SingletonImp.h"
43 #include "ConfusedMovementGenerator.h"
46 pAuraHandler AuraHandler
[TOTAL_AURAS
]=
48 &Aura::HandleNULL
, //SPELL_AURA_NONE
49 &Aura::HandleBindSight
, //SPELL_AURA_BIND_SIGHT
50 &Aura::HandleModPossess
, //SPELL_AURA_MOD_POSSESS = 2,
51 &Aura::HandlePeriodicDamage
, //SPELL_AURA_PERIODIC_DAMAGE = 3,
52 &Aura::HandleAuraDummy
, //SPELL_AURA_DUMMY //missing 4
53 &Aura::HandleModConfuse
, //SPELL_AURA_MOD_CONFUSE = 5,
54 &Aura::HandleModCharm
, //SPELL_AURA_MOD_CHARM = 6,
55 &Aura::HandleModFear
, //SPELL_AURA_MOD_FEAR = 7,
56 &Aura::HandlePeriodicHeal
, //SPELL_AURA_PERIODIC_HEAL = 8,
57 &Aura::HandleModAttackSpeed
, //SPELL_AURA_MOD_ATTACKSPEED = 9,
58 &Aura::HandleModThreat
, //SPELL_AURA_MOD_THREAT = 10,
59 &Aura::HandleNULL
, //SPELL_AURA_MOD_TAUNT = 11,
60 &Aura::HandleAuraModStun
, //SPELL_AURA_MOD_STUN = 12,
61 &Aura::HandleModDamageDone
, //SPELL_AURA_MOD_DAMAGE_DONE = 13,
62 &Aura::HandleModDamageTaken
, //SPELL_AURA_MOD_DAMAGE_TAKEN = 14,
63 &Aura::HandleAuraDamageShield
, //SPELL_AURA_DAMAGE_SHIELD = 15,
64 &Aura::HandleModStealth
, //SPELL_AURA_MOD_STEALTH = 16,
65 &Aura::HandleModDetect
, //SPELL_AURA_MOD_DETECT = 17,
66 &Aura::HandleInvisibility
, //SPELL_AURA_MOD_INVISIBILITY = 18,
67 &Aura::HandleInvisibilityDetect
, //SPELL_AURA_MOD_INVISIBILITY_DETECTION = 19,
68 &Aura::HandleAuraModTotalHealthPercentRegen
, //SPELL_AURA_OBS_MOD_HEALTH = 20
69 &Aura::HandleAuraModTotalManaPercentRegen
, //SPELL_AURA_OBS_MOD_MANA = 21
70 &Aura::HandleAuraModResistance
, //SPELL_AURA_MOD_RESISTANCE = 22,
71 &Aura::HandlePeriodicTriggerSpell
, //SPELL_AURA_PERIODIC_TRIGGER_SPELL = 23,
72 &Aura::HandlePeriodicEnergize
, //SPELL_AURA_PERIODIC_ENERGIZE = 24,
73 &Aura::HandleNULL
, //SPELL_AURA_MOD_PACIFY = 25,
74 &Aura::HandleAuraModRoot
, //SPELL_AURA_MOD_ROOT = 26,
75 &Aura::HandleAuraModSilence
, //SPELL_AURA_MOD_SILENCE = 27,
76 &Aura::HandleReflectSpells
, //SPELL_AURA_REFLECT_SPELLS = 28,
77 &Aura::HandleAuraModStat
, //SPELL_AURA_MOD_STAT = 29,
78 &Aura::HandleAuraModSkill
, //SPELL_AURA_MOD_SKILL = 30,
79 &Aura::HandleAuraModIncreaseSpeed
, //SPELL_AURA_MOD_INCREASE_SPEED = 31,
80 &Aura::HandleAuraModIncreaseMountedSpeed
, //SPELL_AURA_MOD_INCREASE_MOUNTED_SPEED = 32,
81 &Aura::HandleAuraModDecreaseSpeed
, //SPELL_AURA_MOD_DECREASE_SPEED = 33,
82 &Aura::HandleAuraModIncreaseHealth
, //SPELL_AURA_MOD_INCREASE_HEALTH = 34,
83 &Aura::HandleAuraModIncreaseEnergy
, //SPELL_AURA_MOD_INCREASE_ENERGY = 35,
84 &Aura::HandleAuraModShapeshift
, //SPELL_AURA_MOD_SHAPESHIFT = 36,
85 &Aura::HandleAuraModEffectImmunity
, //SPELL_AURA_EFFECT_IMMUNITY = 37,
86 &Aura::HandleAuraModStateImmunity
, //SPELL_AURA_STATE_IMMUNITY = 38,
87 &Aura::HandleAuraModSchoolImmunity
, //SPELL_AURA_SCHOOL_IMMUNITY = 39,
88 &Aura::HandleAuraModDmgImmunity
, //SPELL_AURA_DAMAGE_IMMUNITY = 40,
89 &Aura::HandleAuraModDispelImmunity
, //SPELL_AURA_DISPEL_IMMUNITY = 41,
90 &Aura::HandleAuraProcTriggerSpell
, //SPELL_AURA_PROC_TRIGGER_SPELL = 42,
91 &Aura::HandleAuraProcTriggerDamage
, //SPELL_AURA_PROC_TRIGGER_DAMAGE = 43,
92 &Aura::HandleAuraTracCreatures
, //SPELL_AURA_TRACK_CREATURES = 44,
93 &Aura::HandleAuraTracResources
, //SPELL_AURA_TRACK_RESOURCES = 45,
94 &Aura::HandleNULL
, //SPELL_AURA_MOD_PARRY_SKILL = 46, obsolete?
95 &Aura::HandleAuraModParryPercent
, //SPELL_AURA_MOD_PARRY_PERCENT = 47,
96 &Aura::HandleNULL
, //SPELL_AURA_MOD_DODGE_SKILL = 48, obsolete?
97 &Aura::HandleAuraModDodgePercent
, //SPELL_AURA_MOD_DODGE_PERCENT = 49,
98 &Aura::HandleNULL
, //SPELL_AURA_MOD_BLOCK_SKILL = 50, obsolete?
99 &Aura::HandleAuraModBlockPercent
, //SPELL_AURA_MOD_BLOCK_PERCENT = 51,
100 &Aura::HandleAuraModCritPercent
, //SPELL_AURA_MOD_CRIT_PERCENT = 52,
101 &Aura::HandlePeriodicLeech
, //SPELL_AURA_PERIODIC_LEECH = 53,
102 &Aura::HandleModHitChance
, //SPELL_AURA_MOD_HIT_CHANCE = 54,
103 &Aura::HandleModSpellHitChance
, //SPELL_AURA_MOD_SPELL_HIT_CHANCE = 55,
104 &Aura::HandleAuraTransform
, //SPELL_AURA_TRANSFORM = 56,
105 &Aura::HandleModSpellCritChance
, //SPELL_AURA_MOD_SPELL_CRIT_CHANCE = 57,
106 &Aura::HandleAuraModIncreaseSwimSpeed
, //SPELL_AURA_MOD_INCREASE_SWIM_SPEED = 58,
107 &Aura::HandleModDamageDoneCreature
, //SPELL_AURA_MOD_DAMAGE_DONE_CREATURE = 59,
108 &Aura::HandleNULL
, //SPELL_AURA_MOD_PACIFY_SILENCE = 60,
109 &Aura::HandleAuraModScale
, //SPELL_AURA_MOD_SCALE = 61,
110 &Aura::HandleNULL
, //SPELL_AURA_PERIODIC_HEALTH_FUNNEL = 62,
111 &Aura::HandleNULL
, //SPELL_AURA_PERIODIC_MANA_FUNNEL = 63,
112 &Aura::HandlePeriodicManaLeech
, //SPELL_AURA_PERIODIC_MANA_LEECH = 64,
113 &Aura::HandleModCastingSpeed
, //SPELL_AURA_MOD_CASTING_SPEED = 65,
114 &Aura::HandleNULL
, //SPELL_AURA_FEIGN_DEATH = 66,
115 &Aura::HandleNULL
, //SPELL_AURA_MOD_DISARM = 67,
116 &Aura::HandleNULL
, //SPELL_AURA_MOD_STALKED = 68,
117 &Aura::HandleAuraSchoolAbsorb
, //SPELL_AURA_SCHOOL_ABSORB = 69,
118 &Aura::HandleNULL
, //SPELL_AURA_EXTRA_ATTACKS = 70,// Useless
119 &Aura::HandleModSpellCritChanceShool
, //SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL = 71,
120 &Aura::HandleModPowerCost
, //SPELL_AURA_MOD_POWER_COST = 72,
121 &Aura::HandleModPowerCostSchool
, //SPELL_AURA_MOD_POWER_COST_SCHOOL = 73,
122 &Aura::HandleReflectSpellsSchool
, //SPELL_AURA_REFLECT_SPELLS_SCHOOL = 74,
123 &Aura::HandleNULL
, //SPELL_AURA_MOD_LANGUAGE = 75,
124 &Aura::HandleFarSight
, //SPELL_AURA_FAR_SIGHT = 76,
125 &Aura::HandleModMechanicImmunity
, //SPELL_AURA_MECHANIC_IMMUNITY = 77,
126 &Aura::HandleAuraMounted
, //SPELL_AURA_MOUNTED = 78,
127 &Aura::HandleModDamagePercentDone
, //SPELL_AURA_MOD_DAMAGE_PERCENT_DONE = 79,
128 &Aura::HandleModPercentStat
, //SPELL_AURA_MOD_PERCENT_STAT = 80,
129 &Aura::HandleNULL
, //SPELL_AURA_SPLIT_DAMAGE = 81,
130 &Aura::HandleWaterBreathing
, //SPELL_AURA_WATER_BREATHING = 82,
131 &Aura::HandleModBaseResistance
, //SPELL_AURA_MOD_BASE_RESISTANCE = 83,
132 &Aura::HandleModRegen
, //SPELL_AURA_MOD_REGEN = 84,
133 &Aura::HandleModPowerRegen
, //SPELL_AURA_MOD_POWER_REGEN = 85,
134 &Aura::HandleChannelDeathItem
, //SPELL_AURA_CHANNEL_DEATH_ITEM = 86,
135 &Aura::HandleModDamagePCTTaken
, //SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN = 87,
136 &Aura::HandleModPCTRegen
, //SPELL_AURA_MOD_HEALTH_REGEN_PERCENT = 88,
137 &Aura::HandlePeriodicDamagePCT
, //SPELL_AURA_PERIODIC_DAMAGE_PERCENT = 89,
138 &Aura::HandleNULL
, //SPELL_AURA_MOD_RESIST_CHANCE = 90,// Useless
139 &Aura::HandleModDetectRange
, //SPELL_AURA_MOD_DETECT_RANGE = 91,
140 &Aura::HandleNULL
, //SPELL_AURA_PREVENTS_FLEEING = 92,
141 &Aura::HandleNULL
, //SPELL_AURA_MOD_UNATTACKABLE = 93,
142 &Aura::HandleNULL
, //SPELL_AURA_INTERRUPT_REGEN = 94,
143 &Aura::HandleNULL
, //SPELL_AURA_GHOST = 95,
144 &Aura::HandleNULL
, //SPELL_AURA_SPELL_MAGNET = 96,
145 &Aura::HandleAuraManaShield
, //SPELL_AURA_MANA_SHIELD = 97,
146 &Aura::HandleAuraModSkill
, //SPELL_AURA_MOD_SKILL_TALENT = 98,
147 &Aura::HandleAuraModAttackPower
, //SPELL_AURA_MOD_ATTACK_POWER = 99,
148 &Aura::HandleNULL
, //SPELL_AURA_AURAS_VISIBLE = 100,
149 &Aura::HandleModResistancePercent
, //SPELL_AURA_MOD_RESISTANCE_PCT = 101,
150 &Aura::HandleModCreatureAttackPower
, //SPELL_AURA_MOD_CREATURE_ATTACK_POWER = 102,
151 &Aura::HandleNULL
, //SPELL_AURA_MOD_TOTAL_THREAT = 103,
152 &Aura::HandleAuraWaterWalk
, //SPELL_AURA_WATER_WALK = 104,
153 &Aura::HandleAuraFeatherFall
, //SPELL_AURA_FEATHER_FALL = 105,
154 &Aura::HandleAuraHover
, //SPELL_AURA_HOVER = 106,
155 &Aura::HandleAddModifier
, //SPELL_AURA_ADD_FLAT_MODIFIER = 107,
156 &Aura::HandleAddModifier
, //SPELL_AURA_ADD_PCT_MODIFIER = 108,
157 &Aura::HandleNULL
, //SPELL_AURA_ADD_TARGET_TRIGGER = 109,
158 &Aura::HandleNULL
, //SPELL_AURA_MOD_POWER_REGEN_PERCENT = 110,
159 &Aura::HandleNULL
, //SPELL_AURA_ADD_CASTER_HIT_TRIGGER = 111,
160 &Aura::HandleNULL
, //SPELL_AURA_OVERRIDE_CLASS_SCRIPTS = 112,
161 &Aura::HandleNULL
, //SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN = 113,
162 &Aura::HandleNULL
, //SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN_PCT = 114,
163 &Aura::HandleNULL
, //SPELL_AURA_MOD_HEALING = 115,
164 &Aura::HandleNULL
, //SPELL_AURA_IGNORE_REGEN_INTERRUPT = 116,
165 &Aura::HandleNULL
, //SPELL_AURA_MOD_MECHANIC_RESISTANCE = 117,
166 &Aura::HandleNULL
, //SPELL_AURA_MOD_HEALING_PCT = 118,
167 &Aura::HandleNULL
, //SPELL_AURA_SHARE_PET_TRACKING = 119,
168 &Aura::HandleNULL
, //SPELL_AURA_UNTRACKABLE = 120,
169 &Aura::HandleAuraEmpathy
, //SPELL_AURA_EMPATHY = 121,
170 &Aura::HandleNULL
, //SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT = 122,
171 &Aura::HandleNULL
, //SPELL_AURA_MOD_POWER_COST_PCT = 123,
172 &Aura::HandleAuraModRangedAttackPower
, //SPELL_AURA_MOD_RANGED_ATTACK_POWER = 124,
173 &Aura::HandleNULL
, //SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN = 125,
174 &Aura::HandleNULL
, //SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT = 126,
175 &Aura::HandleNULL
, //SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS = 127,
176 &Aura::HandleNULL
, //SPELL_AURA_MOD_POSSESS_PET = 128,
177 &Aura::HandleAuraModIncreaseSpeedAlways
, //SPELL_AURA_MOD_INCREASE_SPEED_ALWAYS = 129,
178 &Aura::HandleNULL
, //SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS = 130,
179 &Aura::HandleNULL
, //SPELL_AURA_MOD_CREATURE_RANGED_ATTACK_POWER = 131,
180 &Aura::HandleAuraModIncreaseEnergyPercent
, //SPELL_AURA_MOD_INCREASE_ENERGY_PERCENT = 132,
181 &Aura::HandleAuraModIncreaseHealthPercent
, //SPELL_AURA_MOD_INCREASE_HEALTH_PERCENT = 133,
182 &Aura::HandleNULL
, //SPELL_AURA_MOD_MANA_REGEN_INTERRUPT = 134,
183 &Aura::HandleNULL
, //SPELL_AURA_MOD_HEALING_DONE = 135,
184 &Aura::HandleNULL
, //SPELL_AURA_MOD_HEALING_DONE_PERCENT = 136,
185 &Aura::HandleModTotalPercentStat
, //SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE = 137,
186 &Aura::HandleHaste
, //SPELL_AURA_MOD_HASTE = 138,
187 &Aura::HandleForceReaction
, //SPELL_AURA_FORCE_REACTION = 139,
188 &Aura::HandleAuraModRangedHaste
, //SPELL_AURA_MOD_RANGED_HASTE = 140,
189 &Aura::HandleRangedAmmoHaste
, //SPELL_AURA_MOD_RANGED_AMMO_HASTE = 141,
190 &Aura::HandleAuraModBaseResistancePCT
, //SPELL_AURA_MOD_BASE_RESISTANCE_PCT = 142,
191 &Aura::HandleAuraModResistanceExclusive
, //SPELL_AURA_MOD_RESISTANCE_EXCLUSIVE = 143,
192 &Aura::HandleAuraSafeFall
, //SPELL_AURA_SAFE_FALL = 144,
193 &Aura::HandleNULL
, //SPELL_AURA_CHARISMA = 145,
194 &Aura::HandleNULL
, //SPELL_AURA_PERSUADED = 146,
195 &Aura::HandleNULL
, //SPELL_AURA_ADD_CREATURE_IMMUNITY = 147,
196 &Aura::HandleNULL
, //SPELL_AURA_RETAIN_COMBO_POINTS = 148,
197 &Aura::HandleNULL
, //SPELL_AURA_RESIST_PUSHBACK = 149 ,// Resist Pushback
198 &Aura::HandleModShieldBlock
, //SPELL_AURA_MOD_SHIELD_BLOCK = 150 ,// Mod Shield Block %
199 &Aura::HandleNULL
, //SPELL_AURA_TRACK_STEALTHED = 151 ,// Track Stealthed
200 &Aura::HandleNULL
, //SPELL_AURA_MOD_DETECTED_RANGE = 152 ,// Mod Detected Range
201 &Aura::HandleNULL
, //SPELL_AURA_SPLIT_DAMAGE_FLAT = 153 ,// Split Damage Flat
202 &Aura::HandleNULL
, //SPELL_AURA_MOD_STEALTH_LEVEL = 154 ,// Stealth Level Modifier
203 &Aura::HandleNULL
, //SPELL_AURA_MOD_WATER_BREATHING = 155 ,// Mod Water Breathing
204 &Aura::HandleModReputationGain
, //SPELL_AURA_MOD_REPUTATION_GAIN = 156 ,// Mod Reputation Gain
205 &Aura::HandleNULL
, //SPELL_AURA_PET_DAMAGE_MULTI = 157 ,// Mod Pet Damage
206 &Aura::HandleNULL
, // = 158 ,//
207 &Aura::HandleNULL
, // = 159 ,//
208 &Aura::HandleNULL
, // = 160 ,//
209 &Aura::HandleNULL
, // = 161 ,//
210 &Aura::HandleNULL
// = 162 ,//
213 Aura::Aura(SpellEntry
const* spellproto
, uint32 eff
, Unit
*target
, Unit
*caster
, Item
* castItem
) :
214 m_spellId(spellproto
->Id
), m_effIndex(eff
), m_caster_guid(0), m_target(target
),
215 m_timeCla(1000), m_castItem(castItem
), m_auraSlot(0),m_positive(false), m_permanent(false),
216 m_isPeriodic(false), m_isTrigger(false), m_periodicTimer(0), m_PeriodicEventId(0),
217 m_procCharges(0), m_absorbDmg(0), m_isPersistent(false), m_removeOnDeath(false),
221 m_duration
= GetDuration(spellproto
);
222 int32 maxduration
= GetMaxDuration(spellproto
);
225 if( m_duration
!= maxduration
)
228 if(caster
->GetTypeId() == TYPEID_PLAYER
)
230 comboPoints
= (uint8
)((caster
->GetUInt32Value(PLAYER_FIELD_BYTES
) & 0xFF00) >> 8);
231 caster
->SetUInt32Value(PLAYER_FIELD_BYTES
,((caster
->GetUInt32Value(PLAYER_FIELD_BYTES
) & ~(0xFF << 8)) | (0x00 << 8)));
233 comboPoints
= comboPoints
< 5 ? comboPoints
: 5;
234 m_duration
+= int32((maxduration
- m_duration
) * comboPoints
/ 5);
236 m_isPassive
= IsPassiveSpell(m_spellId
);
237 m_positive
= IsPositiveEffect(m_spellId
, m_effIndex
);
238 m_applyTime
= time(NULL
);
240 sLog
.outDebug("Aura: construct Spellid : %u, Aura : %u Duration : %d Target : %d.", spellproto
->Id
, spellproto
->EffectApplyAuraName
[eff
], m_duration
, spellproto
->EffectImplicitTargetA
[eff
]);
248 m_caster_guid
= target
->GetGUID();
249 damage
= spellproto
->EffectBasePoints
[eff
]+1; // stored value-1
253 m_caster_guid
= caster
->GetGUID();
254 damage
= CalculateDamage();
258 SetModifier(spellproto
->EffectApplyAuraName
[eff
], damage
, spellproto
->EffectAmplitude
[eff
], spellproto
->EffectMiscValue
[eff
], type
);
265 AreaAura::AreaAura(SpellEntry
const* spellproto
, uint32 eff
, Unit
*target
,
266 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, target
, caster
, castItem
)
271 AreaAura::~AreaAura()
275 PersistentAreaAura::PersistentAreaAura(SpellEntry
const* spellproto
, uint32 eff
, Unit
*target
,
276 Unit
*caster
, Item
* castItem
) : Aura(spellproto
, eff
, target
, caster
, castItem
)
278 m_isPersistent
= true;
281 PersistentAreaAura::~PersistentAreaAura()
285 Unit
* Aura::GetCaster() const
287 if(m_caster_guid
==m_target
->GetGUID())
290 return ObjectAccessor::Instance().GetUnit(*m_target
,m_caster_guid
);
293 int32
Aura::CalculateDamage()
295 SpellEntry
const* spellproto
= GetSpellProto();
300 Unit
* caster
= GetCaster();
303 /*level= caster->getLevel();
304 if( level > spellproto->maxLevel && spellproto->maxLevel > 0)
305 level = spellproto->maxLevel;*/
307 float basePointsPerLevel
= spellproto
->EffectRealPointsPerLevel
[m_effIndex
];
308 float randomPointsPerLevel
= spellproto
->EffectDicePerLevel
[m_effIndex
];
309 int32 basePoints
= spellproto
->EffectBasePoints
[m_effIndex
] + level
* basePointsPerLevel
;
310 int32 randomPoints
= spellproto
->EffectDieSides
[m_effIndex
] + level
* randomPointsPerLevel
;
311 float comboDamage
= spellproto
->EffectPointsPerComboPoint
[m_effIndex
];
313 if(caster
->GetTypeId() == TYPEID_PLAYER
)
314 comboPoints
= (uint8
)((caster
->GetUInt32Value(PLAYER_FIELD_BYTES
) & 0xFF00) >> 8);
316 value
+= spellproto
->EffectBaseDice
[m_effIndex
];
317 if(randomPoints
<= 1)
318 value
= basePoints
+1;
320 value
= basePoints
+rand()%randomPoints
;
324 value
+= (int32
)(comboDamage
* comboPoints
);
325 if(caster
->GetTypeId() == TYPEID_PLAYER
)
326 caster
->SetUInt32Value(PLAYER_FIELD_BYTES
,((caster
->GetUInt32Value(PLAYER_FIELD_BYTES
) & ~(0xFF << 8)) | (0x00 << 8)));
332 void Aura::SetModifier(uint8 t
, int32 a
, uint32 pt
, int32 miscValue
, uint32 miscValue2
)
334 m_modifier
.m_auraname
= t
;
335 m_modifier
.m_amount
= a
;
336 m_modifier
.m_miscvalue
= miscValue
;
337 m_modifier
.m_miscvalue2
= miscValue2
;
338 m_modifier
.periodictime
= pt
;
340 Unit
* caster
= GetCaster();
341 if (caster
&& caster
->GetTypeId() == TYPEID_PLAYER
)
342 ((Player
*)caster
)->ApplySpellMod(m_spellId
,SPELLMOD_ALL_EFFECTS
, m_modifier
.m_amount
);
345 void Aura::Update(uint32 diff
)
354 Unit
* caster
= GetCaster();
355 if(caster
&& m_timeCla
<= 0)
357 Powers powertype
= caster
->getPowerType();
358 int32 manaPerSecond
= GetSpellProto()->manaPerSecond
;
359 int32 manaPerSecondPerLevel
= uint32(GetSpellProto()->manaPerSecondPerLevel
*caster
->getLevel());
361 caster
->ModifyPower(powertype
,-manaPerSecond
);
362 caster
->ModifyPower(powertype
,-manaPerSecondPerLevel
);
364 if(caster
&& m_target
->isAlive() && m_target
->HasFlag(UNIT_FIELD_FLAGS
,(UNIT_STAT_FLEEING
<<16)))
366 float x
,y
,z
,angle
,speed
,pos_x
,pos_y
,pos_z
;
367 angle
= m_target
->GetAngle( caster
->GetPositionX(), caster
->GetPositionY() );
368 // If the m_target is player,and if the speed is too slow,change it :P
369 speed
= m_target
->GetSpeed(MOVE_RUN
);
370 pos_x
= m_target
->GetPositionX();
371 pos_y
= m_target
->GetPositionY();
372 uint32 mapid
= m_target
->GetMapId();
373 pos_z
= MapManager::Instance().GetMap(mapid
)->GetHeight(pos_x
,pos_y
);
374 // Control the max Distance; 20 for temp.
375 if(m_target
->IsWithinDist(caster
, 20))
377 if( m_target
->GetPositionX() < caster
->GetPositionX() || m_target
->GetPositionY() > caster
->GetPositionY() )
378 x
= m_target
->GetPositionX() + speed
*diff
* sin(angle
)/1000;
380 x
= m_target
->GetPositionX() - speed
*diff
* sin(angle
)/1000;
381 y
= m_target
->GetPositionY() - speed
*diff
* cos(angle
)/1000;
382 mapid
= m_target
->GetMapId();
383 z
= MapManager::Instance().GetMap(mapid
)->GetHeight(x
,y
);
384 // Control the target to not climb or drop when dz > |x|,x = 1.3 for temp.
385 // fixed me if it needs checking when the position will be in water?
386 if(z
<=pos_z
+1.3 && z
>=pos_z
-1.3)
388 m_target
->SendMonsterMove(x
,y
,z
,false,true,diff
);
389 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
390 m_target
->Relocate(x
,y
,z
,m_target
->GetOrientation());
396 if(m_isPeriodic
&& (m_duration
>= 0 || m_isPassive
))
398 m_periodicTimer
-= diff
;
399 if(m_periodicTimer
< 0)
401 if( m_modifier
.m_auraname
== SPELL_AURA_MOD_REGEN
||
402 m_modifier
.m_auraname
== SPELL_AURA_MOD_POWER_REGEN
||
403 // Cannibalize, eating items and other spells
404 m_modifier
.m_auraname
== SPELL_AURA_OBS_MOD_HEALTH
||
405 // Eating items and other spells
406 m_modifier
.m_auraname
== SPELL_AURA_OBS_MOD_MANA
)
411 // update before applying (aura can be removed in TriggerSpell or PeriodicAuraLog calls)
412 m_periodicTimer
+= m_modifier
.periodictime
;
420 if(Unit
* caster
= GetCaster())
421 caster
->PeriodicAuraLog(m_target
, GetSpellProto(), &m_modifier
);
423 m_target
->PeriodicAuraLog(m_target
, GetSpellProto(), &m_modifier
);
429 void AreaAura::Update(uint32 diff
)
431 // update for the caster of the aura
432 if(m_caster_guid
== m_target
->GetGUID())
434 Unit
* caster
= m_target
;
436 Group
*pGroup
= NULL
;
437 if (caster
->GetTypeId() == TYPEID_PLAYER
)
438 pGroup
= ((Player
*)caster
)->groupInfo
.group
;
439 else if(((Creature
*)caster
)->isTotem())
441 Unit
*owner
= ((Totem
*)caster
)->GetOwner();
442 if (owner
&& owner
->GetTypeId() == TYPEID_PLAYER
)
443 pGroup
= ((Player
*)owner
)->groupInfo
.group
;
446 float radius
= GetRadius(sSpellRadiusStore
.LookupEntry(GetSpellProto()->EffectRadiusIndex
[m_effIndex
]));
449 for(uint32 p
=0;p
<pGroup
->GetMembersCount();p
++)
451 Unit
* Target
= objmgr
.GetPlayer(pGroup
->GetMemberGUID(p
));
452 if(!Target
|| Target
->GetGUID() == m_caster_guid
|| !Target
->isAlive() || pGroup
->SameSubGroup(m_caster_guid
, Target
->GetGUID()))
454 Aura
*t_aura
= Target
->GetAura(m_spellId
, m_effIndex
);
456 if(caster
->IsWithinDist(Target
, radius
) )
458 // apply aura to players in range that dont have it yet
461 Aura
*aur
= new Aura(GetSpellProto(), m_effIndex
, Target
, caster
);
462 Target
->AddAura(aur
);
467 // remove auras of the same caster from out of range players
469 if (t_aura
->GetCasterGUID() == m_caster_guid
)
470 Target
->RemoveAura(m_spellId
, m_effIndex
);
474 else if (caster
->GetTypeId() != TYPEID_PLAYER
&& ((Creature
*)caster
)->isTotem())
476 // add / remove auras from the totem's owner
477 Unit
*owner
= ((Totem
*)caster
)->GetOwner();
480 Aura
*o_aura
= owner
->GetAura(m_spellId
, m_effIndex
);
481 if(caster
->IsWithinDist(owner
, radius
))
485 Aura
*aur
= new Aura(GetSpellProto(), m_effIndex
, owner
, caster
);
492 if (o_aura
->GetCasterGUID() == m_caster_guid
)
493 owner
->RemoveAura(m_spellId
, m_effIndex
);
502 void PersistentAreaAura::Update(uint32 diff
)
506 // remove the aura if its caster or the dynamic object causing it was removed
507 // or if the target moves too far from the dynamic object
508 Unit
*caster
= GetCaster();
511 DynamicObject
*dynObj
= caster
->GetDynObject(GetId(), GetEffIndex());
514 if (!m_target
->IsWithinDist(dynObj
, dynObj
->GetRadius()))
526 m_target
->RemoveAura(GetId(), GetEffIndex());
529 void Aura::ApplyModifier(bool apply
, bool Real
)
532 aura
= m_modifier
.m_auraname
;
535 (*this.*AuraHandler
[aura
])(apply
,Real
);
538 void Aura::UpdateAuraDuration()
540 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
545 WorldPacket
data(SMSG_UPDATE_AURA_DURATION
, 5);
546 data
<< (uint8
)m_auraSlot
<< (uint32
)m_duration
;
547 //((Player*)m_target)->SendMessageToSet(&data, true); //GetSession()->SendPacket(&data);
548 ((Player
*)m_target
)->SendDirectMessage(&data
);
551 void Aura::DelayPeriodicTimer(int32 delaytime
)
553 m_periodicTimer
+= delaytime
;
556 void Aura::_AddAura()
563 bool samespell
= false;
564 uint8 slot
= 0xFF, i
;
567 for(i
= 0; i
< 3; i
++)
569 aura
= m_target
->GetAura(m_spellId
, i
);
572 //if (i != m_effIndex)
575 slot
= aura
->GetAuraSlot();
580 // not call total regen auras at adding
581 if( m_modifier
.m_auraname
==SPELL_AURA_OBS_MOD_HEALTH
|| m_modifier
.m_auraname
==SPELL_AURA_OBS_MOD_MANA
)
582 m_periodicTimer
= m_modifier
.periodictime
;
584 if( m_modifier
.m_auraname
==SPELL_AURA_MOD_REGEN
|| m_modifier
.m_auraname
==SPELL_AURA_MOD_POWER_REGEN
)
585 m_periodicTimer
= 5000;
587 m_target
->ApplyStats(false);
588 ApplyModifier(true,true);
589 m_target
->ApplyStats(true);
591 sLog
.outDebug("Aura %u now is in use", m_modifier
.m_auraname
);
593 Unit
* caster
= GetCaster();
595 // passive auras (except totem auras) do not get placed in the slots
596 if(!m_isPassive
|| (caster
&& caster
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)caster
)->isTotem()))
602 for (i
= 0; i
< MAX_POSITIVE_AURAS
; i
++)
604 if (m_target
->GetUInt32Value((uint16
)(UNIT_FIELD_AURA
+ i
)) == 0)
613 for (i
= MAX_POSITIVE_AURAS
; i
< MAX_AURAS
; i
++)
615 if (m_target
->GetUInt32Value((uint16
)(UNIT_FIELD_AURA
+ i
)) == 0)
623 m_target
->SetUInt32Value((uint16
)(UNIT_FIELD_AURA
+ slot
), GetId());
625 uint8 flagslot
= slot
>> 3;
626 uint32 value
= m_target
->GetUInt32Value((uint16
)(UNIT_FIELD_AURAFLAGS
+ flagslot
));
628 uint8 value1
= (slot
& 7) << 2;
629 value
|= ((uint32
)AFLAG_SET
<< value1
);
631 m_target
->SetUInt32Value((uint16
)(UNIT_FIELD_AURAFLAGS
+ flagslot
), value
);
635 /* TODO: increase count */
638 if(GetSpellProto()->SpellVisual
== 5622)
639 m_target
->SetFlag(UNIT_FIELD_AURASTATE
, uint32(1<<(AURA_STATE_JUDGEMENT
-1)));
641 if( m_target
->GetTypeId() == TYPEID_PLAYER
)
642 UpdateAuraDuration();
647 void Aura::_RemoveAura()
649 m_target
->ApplyStats(false);
650 sLog
.outDebug("Aura %u now is remove", m_modifier
.m_auraname
);
651 ApplyModifier(false,true);
652 m_target
->ApplyStats(true);
654 Unit
* caster
= GetCaster();
656 if(caster
&& IsPersistent())
658 DynamicObject
*dynObj
= caster
->GetDynObject(GetId(), GetEffIndex());
660 dynObj
->RemoveAffected(m_target
);
662 //passive auras do not get put in slots
663 if(m_isPassive
&& !(caster
&& caster
->GetTypeId() == TYPEID_UNIT
&& ((Creature
*)caster
)->isTotem()))
666 uint8 slot
= GetAuraSlot();
668 // Aura added always to m_target
669 //Aura* aura = m_target->GetAura(m_spellId, m_effIndex);
673 if(m_target
->GetUInt32Value((uint16
)(UNIT_FIELD_AURA
+ slot
)) == 0)
676 // count all auras from each effect of the spell
677 Unit::AuraMap
& t_Auras
= m_target
->GetAuras();
678 uint8 count
[3], totalcount
= 0;
679 for(uint8 i
= 0; i
< 3; i
++)
681 count
[i
] = t_Auras
.count(Unit::spellEffectPair(m_spellId
, i
));
682 totalcount
+= count
[i
];
687 // all counts should be the same after the last effect of a spell was taken out
688 for(uint8 i = 0; i < 3; i++)
689 if (count[i] > count[m_effIndex])
692 TODO: decrease count for spell
695 // only remove icon when the last aura of the spell is removed (current aura already removed from list)
699 m_target
->SetUInt32Value((uint16
)(UNIT_FIELD_AURA
+ slot
), 0);
701 uint8 flagslot
= slot
>> 3;
703 uint32 value
= m_target
->GetUInt32Value((uint16
)(UNIT_FIELD_AURAFLAGS
+ flagslot
));
705 uint8 aurapos
= (slot
& 7) << 2;
706 uint32 value1
= ~( AFLAG_SET
<< aurapos
);
709 m_target
->SetUInt32Value((uint16
)(UNIT_FIELD_AURAFLAGS
+ flagslot
), value
);
710 if(GetSpellProto()->SpellVisual
== 5622)
711 m_target
->RemoveFlag(UNIT_FIELD_AURASTATE
, uint32(1<<(AURA_STATE_JUDGEMENT
-1)));
714 /*********************************************************/
715 /*** BASIC AURA FUNCTION ***/
716 /*********************************************************/
718 void Aura::HandleNULL(bool apply
, bool Real
)
722 void Aura::HandleAddModifier(bool apply
, bool Real
)
724 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
727 Player
*p_target
= (Player
*)m_target
;
729 SpellEntry
const *spellInfo
= GetSpellProto();
730 if(!spellInfo
) return;
732 uint8 op
= spellInfo
->EffectMiscValue
[m_effIndex
];
733 int32 value
= spellInfo
->EffectBasePoints
[m_effIndex
]+1;
734 uint8 type
= spellInfo
->EffectApplyAuraName
[m_effIndex
];
735 uint32 mask
= spellInfo
->EffectItemType
[m_effIndex
];
737 SpellModList
*p_mods
= p_target
->getSpellModList(op
);
742 SpellModifier
*mod
= new SpellModifier
;
747 mod
->spellId
= m_spellId
;
748 mod
->charges
= spellInfo
->procCharges
;
749 p_mods
->push_back(mod
);
752 uint16 send_val
=0, send_mark
=0;
753 int16 tmpval
=spellInfo
->EffectBasePoints
[m_effIndex
];
754 uint32 shiftdata
=0x01, Opcode
=SMSG_SET_FLAT_SPELL_MODIFIER
;
765 send_val
= 0xFFFF + (tmpval
+2);
770 if (mod
->type
== SPELLMOD_FLAT
) Opcode
= SMSG_SET_FLAT_SPELL_MODIFIER
;
771 else if (mod
->type
== SPELLMOD_PCT
) Opcode
= SMSG_SET_PCT_SPELL_MODIFIER
;
773 for(int eff
=0;eff
<32;eff
++)
775 if ( mask
& shiftdata
)
777 WorldPacket
data(Opcode
, (1+1+2+2));
779 data
<< uint8(mod
->op
);
780 data
<< uint16(send_val
);
781 data
<< uint16(send_mark
);
782 p_target
->SendDirectMessage(&data
);
784 shiftdata
=shiftdata
<<1;
789 SpellModList
*p_mods
= p_target
->getSpellModList(spellInfo
->EffectMiscValue
[m_effIndex
]);
790 p_mods
->remove(this->m_spellmod
);
794 void Aura::TriggerSpell()
796 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry( GetSpellProto()->EffectTriggerSpell
[m_effIndex
] );
800 sLog
.outError("Auras: unknown TriggerSpell:%i From spell: %i", GetSpellProto()->EffectTriggerSpell
[m_effIndex
],GetSpellProto()->Id
);
803 if(GetSpellProto()->Id
== 1515)
804 spellInfo
= sSpellStore
.LookupEntry( 13481 );
806 Unit
* caster
= GetCaster();
808 Spell
spell(caster
, spellInfo
, true, this);
809 Unit
* target
= m_target
;
810 if(!target
&& caster
&& caster
->GetTypeId() == TYPEID_PLAYER
)
812 target
= ObjectAccessor::Instance().GetUnit(*caster
, ((Player
*)caster
)->GetSelection());
816 SpellCastTargets targets
;
817 targets
.setUnitTarget(target
);
818 spell
.prepare(&targets
);
821 /*********************************************************/
822 /*** AURA EFFECTS ***/
823 /*********************************************************/
825 void Aura::HandleAuraDummy(bool apply
, bool Real
)
827 Unit
* caster
= GetCaster();
829 if(GetSpellProto()->SpellVisual
== 5622 && caster
&& caster
->GetTypeId() == TYPEID_PLAYER
)
831 if(GetSpellProto()->SpellIconID
== 25 && GetEffIndex() == 0)
833 Unit::AuraList
& tAuraProcTriggerDamage
= m_target
->GetAurasByType(SPELL_AURA_PROC_TRIGGER_DAMAGE
);
835 tAuraProcTriggerDamage
.push_back(this);
837 tAuraProcTriggerDamage
.remove(this);
839 if(apply
&& !m_procCharges
)
841 m_procCharges
= GetSpellProto()->procCharges
;
847 if(GetSpellProto()->SpellVisual
== 7395 && GetSpellProto()->SpellIconID
== 278 && caster
->GetTypeId() == TYPEID_PLAYER
)
849 Unit::AuraList
& tAuraProcTriggerDamage
= m_target
->GetAurasByType(SPELL_AURA_PROC_TRIGGER_DAMAGE
);
851 tAuraProcTriggerDamage
.push_back(this);
853 tAuraProcTriggerDamage
.remove(this);
855 if(apply
&& !m_procCharges
)
857 m_procCharges
= GetSpellProto()->procCharges
;
862 if(GetSpellProto()->SpellVisual
== 99 && GetSpellProto()->SpellIconID
== 92 && caster
863 && caster
->GetTypeId() == TYPEID_PLAYER
&& m_castItem
)
865 if(m_target
&& m_target
->GetTypeId() == TYPEID_PLAYER
)
867 Player
* player
= (Player
*)m_target
;
869 uint32 itemflag
= m_castItem
->GetUInt32Value(ITEM_FIELD_FLAGS
);
872 // 1<<20 just a temp value to detect if any one has be stored,
873 // we should find out a field to correctly mask the target.
874 if(itemflag
& (1<<20))
878 case 20707:spellid
= 3026;break;
879 case 20762:spellid
= 20758;break;
880 case 20763:spellid
= 20759;break;
881 case 20764:spellid
= 20760;break;
882 case 20765:spellid
= 20761;break;
887 m_castItem
->ApplyModFlag(ITEM_FIELD_FLAGS
,(1<<20),true);
888 player
->SetSoulStone(m_castItem
);
889 player
->SetSoulStoneSpell(spellid
);
893 m_castItem
->ApplyModFlag(ITEM_FIELD_FLAGS
,(1<<20),false);
899 // only at real remove
902 if( IsQuestTameSpell(GetId()) && caster
&& caster
->isAlive() && m_target
&& m_target
->isAlive())
904 uint32 finalSpelId
= 0;
907 case 19548: finalSpelId
= 19597; break;
908 case 19674: finalSpelId
= 19677; break;
909 case 19687: finalSpelId
= 19676; break;
910 case 19688: finalSpelId
= 19678; break;
911 case 19689: finalSpelId
= 19679; break;
912 case 19692: finalSpelId
= 19680; break;
913 case 19693: finalSpelId
= 19684; break;
914 case 19694: finalSpelId
= 19681; break;
915 case 19696: finalSpelId
= 19682; break;
916 case 19697: finalSpelId
= 19683; break;
917 case 19699: finalSpelId
= 19685; break;
918 case 19700: finalSpelId
= 19686; break;
923 SpellEntry
const *spell_proto
= sSpellStore
.LookupEntry(finalSpelId
);
927 Spell
spell(caster
, spell_proto
, true, 0);
928 SpellCastTargets targets
;
929 targets
.setUnitTarget(m_target
);
930 // prevent double stat apply for triggered auras
931 m_target
->ApplyStats(true);
932 spell
.prepare(&targets
);
933 m_target
->ApplyStats(false);
940 void Aura::HandleAuraMounted(bool apply
, bool Real
)
944 CreatureInfo
const* ci
= objmgr
.GetCreatureTemplate(m_modifier
.m_miscvalue
);
946 uint32 displayId
= ci
->randomDisplayID();
948 m_target
->Mount(displayId
);
955 void Aura::HandleAuraWaterWalk(bool apply
, bool Real
)
957 // only at real add/remove aura
963 data
.Initialize(SMSG_MOVE_WATER_WALK
, 8);
965 data
.Initialize(SMSG_MOVE_LAND_WALK
, 8);
966 data
.append(m_target
->GetPackGUID());
967 m_target
->SendMessageToSet(&data
,true);
970 void Aura::HandleAuraFeatherFall(bool apply
, bool Real
)
972 // only at real add/remove aura
978 data
.Initialize(SMSG_MOVE_FEATHER_FALL
, 8);
980 data
.Initialize(SMSG_MOVE_NORMAL_FALL
, 8);
981 data
.append(m_target
->GetPackGUID());
982 m_target
->SendMessageToSet(&data
,true);
985 void Aura::HandleAuraHover(bool apply
, bool Real
)
987 // only at real add/remove aura
993 data
.Initialize(SMSG_MOVE_SET_HOVER
, 8);
995 data
.Initialize(SMSG_MOVE_UNSET_HOVER
, 8);
996 data
.append(m_target
->GetPackGUID());
997 m_target
->SendMessageToSet(&data
,true);
1000 void Aura::HandleWaterBreathing(bool apply
, bool Real
)
1002 m_target
->waterbreath
= apply
;
1005 void Aura::HandleAuraModShapeshift(bool apply
, bool Real
)
1009 Unit
*unit_target
= m_target
;
1011 Powers PowerType
= POWER_MANA
;
1012 uint32 new_bytes_1
= m_modifier
.m_miscvalue
;
1013 switch(m_modifier
.m_miscvalue
)
1016 if(unit_target
->getRace() == RACE_NIGHTELF
)
1018 else if(unit_target
->getRace() == RACE_TAUREN
)
1020 PowerType
= POWER_ENERGY
;
1026 if(unit_target
->getRace() == RACE_NIGHTELF
)
1028 else if(unit_target
->getRace() == RACE_TAUREN
)
1032 if(unit_target
->getRace() == RACE_NIGHTELF
)
1034 else if(unit_target
->getRace() == RACE_TAUREN
)
1036 PowerType
= POWER_RAGE
;
1039 if(unit_target
->getRace() == RACE_NIGHTELF
)
1043 if(unit_target
->getRace() == RACE_NIGHTELF
)
1045 else if(unit_target
->getRace() == RACE_TAUREN
)
1047 PowerType
= POWER_RAGE
;
1049 case FORM_CREATUREBEAR
:
1052 case FORM_GHOSTWOLF
:
1056 if(unit_target
->getRace() == RACE_NIGHTELF
)
1058 else if(unit_target
->getRace() == RACE_TAUREN
)
1062 case FORM_BATTLESTANCE
:
1063 case FORM_BERSERKERSTANCE
:
1064 case FORM_DEFENSIVESTANCE
:
1070 sLog
.outError("Auras: Unknown Shapeshift Type: %u", m_modifier
.m_miscvalue
);
1075 unit_target
->SetFlag(UNIT_FIELD_BYTES_1
, (new_bytes_1
<<16) );
1078 unit_target
->SetUInt32Value(UNIT_FIELD_DISPLAYID
,modelid
);
1081 if(PowerType
!= POWER_MANA
)
1082 unit_target
->setPowerType(PowerType
);
1084 unit_target
->m_ShapeShiftForm
= m_spellId
;
1085 unit_target
->m_form
= m_modifier
.m_miscvalue
;
1086 if(unit_target
->m_form
== FORM_DIREBEAR
)
1087 if (m_target
->getRace() == RACE_TAUREN
)
1089 m_target
->SetFloatValue(OBJECT_FIELD_SCALE_X
,1.35f
);
1092 m_target
->SetFloatValue(OBJECT_FIELD_SCALE_X
,1.0f
);
1096 if (m_target
->getRace() == RACE_TAUREN
)
1097 unit_target
->SetFloatValue(OBJECT_FIELD_SCALE_X
,1.35f
);
1099 unit_target
->SetFloatValue(OBJECT_FIELD_SCALE_X
,1.0f
);
1100 unit_target
->SetUInt32Value(UNIT_FIELD_DISPLAYID
,unit_target
->GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID
));
1101 unit_target
->RemoveFlag(UNIT_FIELD_BYTES_1
, (new_bytes_1
<<16) );
1102 if(unit_target
->getClass() == CLASS_DRUID
)
1103 unit_target
->setPowerType(POWER_MANA
);
1104 unit_target
->m_ShapeShiftForm
= 0;
1105 unit_target
->m_form
= 0;
1109 void Aura::HandleAuraTransform(bool apply
, bool Real
)
1116 CreatureInfo
const * ci
= objmgr
.GetCreatureTemplate(m_modifier
.m_miscvalue
);
1120 m_target
->SetUInt32Value (UNIT_FIELD_DISPLAYID
, 16358);
1121 sLog
.outError("Auras: unknown creature id = %d (only need its modelid) Form Spell Aura Transform in Spell ID = %d", m_modifier
.m_miscvalue
, GetSpellProto()->Id
);
1125 m_target
->SetUInt32Value (UNIT_FIELD_DISPLAYID
, ci
->randomDisplayID());
1127 m_target
->setTransForm(GetSpellProto()->Id
);
1131 m_target
->SetUInt32Value (UNIT_FIELD_DISPLAYID
, m_target
->GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID
));
1132 m_target
->setTransForm(0);
1135 Unit
* caster
= GetCaster();
1137 if(caster
&& caster
->GetTypeId() == TYPEID_PLAYER
)
1138 m_target
->SendUpdateToPlayer((Player
*)caster
);
1141 void Aura::HandleForceReaction(bool Apply
, bool Real
)
1143 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
1148 uint32 faction_id
= m_modifier
.m_miscvalue
;
1150 FactionTemplateEntry
const *factionTemplateEntry
= NULL
;
1152 for(uint32 i
= 0; i
< sFactionTemplateStore
.GetNumRows(); ++i
)
1154 factionTemplateEntry
= sFactionTemplateStore
.LookupEntry(i
);
1155 if(!factionTemplateEntry
)
1158 if(factionTemplateEntry
->faction
== faction_id
)
1162 if(!factionTemplateEntry
)
1165 m_target
->setFaction(factionTemplateEntry
->ID
);
1168 ((Player
*)m_target
)->setFactionForRace(((Player
*)m_target
)->getRace());
1171 void Aura::HandleAuraModSkill(bool apply
, bool Real
)
1173 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
1176 uint32 prot
=GetSpellProto()->EffectMiscValue
[m_effIndex
];
1177 int32 points
= GetSpellProto()->EffectBasePoints
[m_effIndex
]+1;
1179 ((Player
*)m_target
)->ModifySkillBonus(prot
,(apply
? points
: -points
));
1180 if(prot
== SKILL_DEFENSE
)
1181 ((Player
*)m_target
)->ApplyDefenseBonusesMod(points
, apply
);
1184 void Aura::HandleChannelDeathItem(bool apply
, bool Real
)
1188 Unit
* caster
= GetCaster();
1189 Unit
* victim
= GetTarget();
1190 if(!caster
|| caster
->GetTypeId() != TYPEID_PLAYER
|| !victim
|| !m_removeOnDeath
)
1193 SpellEntry
const *spellInfo
= GetSpellProto();
1194 if(spellInfo
->EffectItemType
[m_effIndex
] == 0)
1197 // Soul Shard only from non-grey units
1198 if( victim
->getLevel() <= MaNGOS::XP::GetGrayLevel(caster
->getLevel()) && spellInfo
->EffectItemType
[m_effIndex
] == 6265)
1202 uint8 msg
= ((Player
*)caster
)->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, spellInfo
->EffectItemType
[m_effIndex
], 1, false);
1203 if( msg
== EQUIP_ERR_OK
)
1204 ((Player
*)caster
)->StoreNewItem(dest
, spellInfo
->EffectItemType
[m_effIndex
], 1, true);
1206 ((Player
*)caster
)->SendEquipError( msg
, NULL
, NULL
);
1210 void Aura::HandleAuraSafeFall(bool apply
, bool Real
)
1212 // only at real add/remove aura
1218 data
.Initialize(SMSG_MOVE_FEATHER_FALL
, 8);
1220 data
.Initialize(SMSG_MOVE_NORMAL_FALL
, 8);
1221 data
.append(m_target
->GetPackGUID());
1222 m_target
->SendMessageToSet(&data
,true);
1225 void Aura::HandleBindSight(bool apply
, bool Real
)
1230 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
1233 m_target
->SetUInt64Value(PLAYER_FARSIGHT
,apply
? m_target
->GetGUID() : 0);
1236 void Aura::HandleFarSight(bool apply
, bool Real
)
1241 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
1244 m_target
->SetUInt64Value(PLAYER_FARSIGHT
,apply
? m_modifier
.m_miscvalue
: 0);
1247 void Aura::HandleAuraTracCreatures(bool apply
, bool Real
)
1249 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
1252 m_target
->SetUInt32Value(PLAYER_TRACK_CREATURES
, apply
? ((uint32
)1)<<(m_modifier
.m_miscvalue
-1) : 0 );
1255 void Aura::HandleAuraTracResources(bool apply
, bool Real
)
1257 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
1260 m_target
->SetUInt32Value(PLAYER_TRACK_RESOURCES
, apply
? ((uint32
)1)<<(m_modifier
.m_miscvalue
-1): 0 );
1263 void Aura::HandleAuraModScale(bool apply
, bool Real
)
1265 m_target
->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X
,m_modifier
.m_amount
,apply
);
1268 void Aura::HandleModPossess(bool apply
, bool Real
)
1273 if(m_target
->GetTypeId() != TYPEID_UNIT
)
1279 Creature
* creatureTarget
= (Creature
*)m_target
;
1281 if(int32(m_target
->getLevel()) <= m_modifier
.m_amount
)
1283 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
1286 Unit
* caster
= GetCaster();
1289 creatureTarget
->AttackStop();
1290 if(caster
->getVictim()==creatureTarget
)
1291 caster
->AttackStop();
1293 creatureTarget
->CombatStop();
1295 creatureTarget
->SetUInt64Value(UNIT_FIELD_CHARMEDBY
,caster
->GetGUID());
1296 creatureTarget
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,caster
->getFaction());
1297 caster
->SetCharm(creatureTarget
);
1298 creatureTarget
->AIM_Initialize();
1300 if(caster
->GetTypeId() == TYPEID_PLAYER
)
1302 ((Player
*)caster
)->PetSpellInitialize();
1308 creatureTarget
->SetUInt64Value(UNIT_FIELD_CHARMEDBY
,0);
1309 creatureTarget
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,cinfo
->faction
);
1311 if(Unit
* caster
= GetCaster())
1313 caster
->SetCharm(0);
1315 if(caster
->GetTypeId() == TYPEID_PLAYER
)
1317 WorldPacket
data(SMSG_PET_SPELLS
, 8);
1319 ((Player
*)caster
)->GetSession()->SendPacket(&data
);
1322 creatureTarget
->AIM_Initialize();
1327 void Aura::HandleModCharm(bool apply
, bool Real
)
1332 if(m_target
->GetTypeId() != TYPEID_UNIT
)
1338 Creature
* creatureTarget
= (Creature
*)m_target
;
1340 if(int32(m_target
->getLevel()) <= m_modifier
.m_amount
)
1342 CreatureInfo
const *cinfo
= ((Creature
*)m_target
)->GetCreatureInfo();
1345 Unit
* caster
= GetCaster();
1348 creatureTarget
->AttackStop();
1349 if(caster
->getVictim()==creatureTarget
)
1350 caster
->AttackStop();
1352 creatureTarget
->CombatStop();
1354 creatureTarget
->SetUInt64Value(UNIT_FIELD_CHARMEDBY
,caster
->GetGUID());
1355 creatureTarget
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,caster
->getFaction());
1356 caster
->SetCharm(creatureTarget
);
1357 creatureTarget
->AIM_Initialize();
1358 if(caster
->GetTypeId() == TYPEID_PLAYER
)
1360 ((Player
*)caster
)->PetSpellInitialize();
1366 creatureTarget
->SetUInt64Value(UNIT_FIELD_CHARMEDBY
,0);
1367 creatureTarget
->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE
,cinfo
->faction
);
1368 Unit
* caster
= GetCaster();
1371 caster
->SetCharm(0);
1372 if(caster
->GetTypeId() == TYPEID_PLAYER
)
1374 WorldPacket
data(SMSG_PET_SPELLS
);
1376 ((Player
*)caster
)->GetSession()->SendPacket(&data
);
1379 creatureTarget
->AIM_Initialize();
1384 void Aura::HandleModConfuse(bool apply
, bool Real
)
1386 uint32 apply_stat
= UNIT_STAT_CONFUSED
;
1389 m_target
->addUnitState(UNIT_STAT_CONFUSED
);
1390 m_target
->SetFlag(UNIT_FIELD_FLAGS
,(apply_stat
<<16));
1392 // only at real add aura
1395 if (m_target
->GetTypeId() == TYPEID_UNIT
)
1396 (*((Creature
*)m_target
))->Mutate(new ConfusedMovementGenerator(*((Creature
*)m_target
)));
1401 m_target
->clearUnitState(UNIT_STAT_CONFUSED
);
1402 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
,(apply_stat
<<16));
1404 // only at real remove aura
1407 if (m_target
->GetTypeId() == TYPEID_UNIT
)
1408 (*((Creature
*)m_target
))->MovementExpired();
1413 void Aura::HandleModFear(bool Apply
, bool Real
)
1415 uint32 apply_stat
= UNIT_STAT_FLEEING
;
1418 m_target
->addUnitState(UNIT_STAT_FLEEING
);
1419 // m_target->AttackStop();
1421 m_target
->SetFlag(UNIT_FIELD_FLAGS
,(apply_stat
<<16));
1423 // only at real add aura
1426 WorldPacket
data(SMSG_DEATH_NOTIFY_OBSOLETE
, 9);
1427 data
<<m_target
->GetGUID();
1429 m_target
->SendMessageToSet(&data
,true);
1434 m_target
->clearUnitState(UNIT_STAT_FLEEING
);
1435 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
,(apply_stat
<<16));
1437 // only at real remove aura
1440 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
1441 m_target
->Attack(GetCaster());
1442 WorldPacket
data(SMSG_DEATH_NOTIFY_OBSOLETE
, 9);
1443 data
<<m_target
->GetGUID();
1445 m_target
->SendMessageToSet(&data
,true);
1450 void Aura::HandleAuraModStun(bool apply
, bool Real
)
1454 m_target
->addUnitState(UNIT_STAT_STUNDED
);
1455 m_target
->SetUInt64Value (UNIT_FIELD_TARGET
, 0);
1456 m_target
->SetFlag(UNIT_FIELD_FLAGS
, 0x40000);
1458 // only at real add aura
1461 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
1462 ((Creature
*)m_target
)->StopMoving();
1464 WorldPacket
data(SMSG_FORCE_MOVE_ROOT
, 8);
1465 data
.append(m_target
->GetPackGUID());
1466 m_target
->SendMessageToSet(&data
,true);
1471 m_target
->clearUnitState(UNIT_STAT_STUNDED
);
1472 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
, 0x40000);
1474 // only at real remove aura
1477 WorldPacket
data(SMSG_FORCE_MOVE_UNROOT
, 8);
1478 data
.append(m_target
->GetPackGUID());
1479 m_target
->SendMessageToSet(&data
,true);
1484 void Aura::HandleModStealth(bool apply
, bool Real
)
1488 m_target
->m_stealthvalue
= CalculateDamage();
1489 m_target
->SetFlag(UNIT_FIELD_BYTES_1
, PLAYER_STATE_FLAG_STEALTH
);
1491 // only at real aura add
1494 m_target
->SetVisibility(VISIBILITY_GROUP
);
1495 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
1496 m_target
->SendUpdateToPlayer((Player
*)m_target
);
1501 m_target
->m_stealthvalue
= 0;
1502 m_target
->RemoveFlag(UNIT_FIELD_BYTES_1
, PLAYER_STATE_FLAG_STEALTH
);
1504 // only at real aura remove
1507 SendCoolDownEvent();
1508 m_target
->SetVisibility(VISIBILITY_ON
);
1509 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
1510 m_target
->SendUpdateToPlayer((Player
*)m_target
);
1515 void Aura::HandleModDetect(bool apply
, bool Real
)
1519 m_target
->m_detectStealth
= CalculateDamage();
1523 m_target
->m_detectStealth
= 0;
1527 void Aura::HandleInvisibility(bool Apply
, bool Real
)
1531 m_target
->m_stealthvalue
= CalculateDamage();
1532 m_target
->SetFlag(UNIT_FIELD_BYTES_1
, PLAYER_STATE_FLAG_STEALTH
);
1534 // only at real aura add
1537 m_target
->SetVisibility(VISIBILITY_GROUP
);
1538 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
1539 m_target
->SendUpdateToPlayer((Player
*)m_target
);
1544 m_target
->m_stealthvalue
= 0;
1545 m_target
->RemoveFlag(UNIT_FIELD_BYTES_1
, PLAYER_STATE_FLAG_STEALTH
);
1547 // only at real aura remove
1550 SendCoolDownEvent();
1551 m_target
->SetVisibility(VISIBILITY_ON
);
1552 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
1553 m_target
->SendUpdateToPlayer((Player
*)m_target
);
1558 void Aura::HandleInvisibilityDetect(bool Apply
, bool Real
)
1562 m_target
->m_detectStealth
= CalculateDamage();
1566 m_target
->m_detectStealth
= 0;
1570 void Aura::HandleAuraModRoot(bool apply
, bool Real
)
1572 uint32 apply_stat
= UNIT_STAT_ROOT
;
1575 m_target
->addUnitState(UNIT_STAT_ROOT
);
1576 m_target
->SetUInt64Value (UNIT_FIELD_TARGET
, 0);
1577 m_target
->SetFlag(UNIT_FIELD_FLAGS
,(apply_stat
<<16));
1579 // only at real add aura
1582 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
1584 WorldPacket
data(SMSG_FORCE_MOVE_ROOT
, 10);
1585 data
.append(m_target
->GetPackGUID());
1587 m_target
->SendMessageToSet(&data
,true);
1590 ((Creature
*)m_target
)->StopMoving();
1595 m_target
->clearUnitState(UNIT_STAT_ROOT
);
1596 m_target
->RemoveFlag(UNIT_FIELD_FLAGS
,(apply_stat
<<16));
1598 // only at real remove aura
1601 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
1603 WorldPacket
data(SMSG_FORCE_MOVE_UNROOT
, 10);
1604 data
.append(m_target
->GetPackGUID());
1606 m_target
->SendMessageToSet(&data
,true);
1612 void Aura::HandleAuraModSilence(bool apply
, bool Real
)
1614 apply
? m_target
->m_silenced
= true : m_target
->m_silenced
= false;
1617 void Aura::HandleModThreat(bool apply
, bool Real
)
1619 // only at real add/remove aura
1623 if(!m_target
|| !m_target
->isAlive())
1626 Unit
* caster
= GetCaster();
1628 if(!caster
|| !caster
->isAlive())
1631 m_target
->AddHostil(m_caster_guid
,apply
? float(m_modifier
.m_amount
) : -float(m_modifier
.m_amount
));
1634 /*********************************************************/
1635 /*** MODIDY SPEED ***/
1636 /*********************************************************/
1638 void Aura::HandleAuraModIncreaseSpeedAlways(bool apply
, bool Real
)
1640 // all applied/removed only at real aura add/remove
1644 sLog
.outDebug("HandleAuraModIncreaseSpeedAlways: Current Speed:%f \tmodify percent:%f", m_target
->GetSpeed(MOVE_RUN
),(float)m_modifier
.m_amount
);
1645 if(m_modifier
.m_amount
<=1)
1648 float rate
= (100.0f
+ m_modifier
.m_amount
)/100.0f
;
1650 m_target
->ApplySpeedMod(MOVE_RUN
, rate
, false, apply
);
1651 sLog
.outDebug("ChangeSpeedTo:%f", m_target
->GetSpeed(MOVE_RUN
));
1654 void Aura::HandleAuraModIncreaseSpeed(bool apply
, bool Real
)
1656 // all applied/removed only at real aura add/remove
1660 sLog
.outDebug("HandleAuraModIncreaseSpeed: Current Speed:%f \tmodify percent:%f", m_target
->GetSpeed(MOVE_RUN
),(float)m_modifier
.m_amount
);
1661 if(m_modifier
.m_amount
<=1)
1664 float rate
= (100.0f
+ m_modifier
.m_amount
)/100.0f
;
1666 m_target
->ApplySpeedMod(MOVE_RUN
, rate
, true, apply
);
1668 sLog
.outDebug("ChangeSpeedTo:%f", m_target
->GetSpeed(MOVE_RUN
));
1671 void Aura::HandleAuraModIncreaseMountedSpeed(bool apply
, bool Real
)
1673 // all applied/removed only at real aura add/remove
1677 sLog
.outDebug("HandleAuraModIncreaseMountedSpeed: Current Speed:%f \tmodify percent:%f", m_target
->GetSpeed(MOVE_RUN
),(float)m_modifier
.m_amount
);
1678 if(m_modifier
.m_amount
<=1)
1681 float rate
= (100.0f
+ m_modifier
.m_amount
)/100.0f
;
1683 m_target
->ApplySpeedMod(MOVE_RUN
, rate
, true, apply
);
1685 sLog
.outDebug("ChangeSpeedTo:%f", m_target
->GetSpeed(MOVE_RUN
));
1688 void Aura::HandleAuraModDecreaseSpeed(bool apply
, bool Real
)
1690 // all applied/removed only at real aura add/remove
1694 sLog
.outDebug("HandleAuraModDecreaseSpeed: Current Speed:%f \tmodify percent:%f", m_target
->GetSpeed(MOVE_RUN
),(float)m_modifier
.m_amount
);
1695 if(m_modifier
.m_amount
<= 0)
1696 { //for new spell dbc
1697 float rate
= (100.0f
+ m_modifier
.m_amount
)/100.0f
;
1699 m_target
->ApplySpeedMod(MOVE_RUN
, rate
, true, apply
);
1702 { //for old spell dbc
1703 float rate
= m_modifier
.m_amount
/ 100.0f
;
1705 m_target
->ApplySpeedMod(MOVE_RUN
, rate
, true, apply
);
1707 sLog
.outDebug("ChangeSpeedTo:%f", m_target
->GetSpeed(MOVE_RUN
));
1710 void Aura::HandleAuraModIncreaseSwimSpeed(bool apply
, bool Real
)
1712 // all applied/removed only at real aura add/remove
1716 sLog
.outDebug("HandleAuraModIncreaseSwimSpeed: Current Speed:%f \tmodify percent:%f", m_target
->GetSpeed(MOVE_SWIM
),(float)m_modifier
.m_amount
);
1717 if(m_modifier
.m_amount
<=1)
1720 float rate
= (100.0f
+ m_modifier
.m_amount
)/100.0f
;
1722 m_target
->ApplySpeedMod(MOVE_SWIM
, rate
, true, apply
);
1724 sLog
.outDebug("ChangeSpeedTo:%f", m_target
->GetSpeed(MOVE_SWIM
));
1727 /*********************************************************/
1729 /*********************************************************/
1731 void Aura::HandleModMechanicImmunity(bool apply
, bool Real
)
1733 m_target
->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC
,m_modifier
.m_miscvalue
,apply
);
1736 void Aura::HandleAuraModEffectImmunity(bool apply
, bool Real
)
1738 m_target
->ApplySpellImmune(GetId(),IMMUNITY_EFFECT
,m_modifier
.m_miscvalue
,apply
);
1741 void Aura::HandleAuraModStateImmunity(bool apply
, bool Real
)
1743 m_target
->ApplySpellImmune(GetId(),IMMUNITY_STATE
,m_modifier
.m_miscvalue
,apply
);
1746 void Aura::HandleAuraModSchoolImmunity(bool apply
, bool Real
)
1748 m_target
->ApplySpellImmune(GetId(),IMMUNITY_SCHOOL
,m_modifier
.m_miscvalue
,apply
);
1751 void Aura::HandleAuraModDmgImmunity(bool apply
, bool Real
)
1753 m_target
->ApplySpellImmune(GetId(),IMMUNITY_DAMAGE
,m_modifier
.m_miscvalue
,apply
);
1756 void Aura::HandleAuraModDispelImmunity(bool apply
, bool Real
)
1758 m_target
->ApplySpellImmune(GetId(),IMMUNITY_DISPEL
,m_modifier
.m_miscvalue
,apply
);
1761 /*********************************************************/
1762 /*** MANA SHIELD ***/
1763 /*********************************************************/
1765 void Aura::HandleAuraDamageShield(bool apply
, bool Real
)
1769 for(std::list<struct DamageShield>::iterator i = m_target->m_damageShields.begin();i != m_target->m_damageShields.end();i++)
1770 if(i->m_spellId == GetId() && i->m_caster_guid == m_caster_guid)
1772 m_target->m_damageShields.erase(i);
1775 DamageShield* ds = new DamageShield();
1776 ds->m_caster_guid = m_caster_guid;
1777 ds->m_damage = m_modifier.m_amount;
1778 ds->m_spellId = GetId();
1779 m_target->m_damageShields.push_back((*ds));
1783 for(std::list<struct DamageShield>::iterator i = m_target->m_damageShields.begin();i != m_target->m_damageShields.end();i++)
1784 if(i->m_spellId == GetId() && i->m_caster_guid == m_caster_guid)
1786 m_target->m_damageShields.erase(i);
1792 void Aura::HandleAuraManaShield(bool apply
, bool Real
)
1794 if (apply
&& !m_absorbDmg
)
1795 m_absorbDmg
= m_modifier
.m_amount
;
1800 for(std::list<struct DamageManaShield*>::iterator i = m_target->m_damageManaShield.begin();i != m_target->m_damageManaShield.end();i++)
1802 if(GetId() == (*i)->m_spellId)
1805 m_target->m_damageManaShield.erase(i);
1809 DamageManaShield *dms = new DamageManaShield();
1811 dms->m_spellId = GetId();
1812 dms->m_modType = m_modifier.m_auraname;
1813 dms->m_totalAbsorb = m_modifier.m_amount;
1814 dms->m_currAbsorb = 0;
1815 dms->m_schoolType = m_modifier.m_miscvalue;
1816 m_target->m_damageManaShield.push_back(dms);
1820 for(std::list<struct DamageManaShield*>::iterator i = m_target->m_damageManaShield.begin();i != m_target->m_damageManaShield.end();i++)
1822 if(GetId() == (*i)->m_spellId)
1825 m_target->m_damageManaShield.erase(i);
1832 void Aura::HandleAuraSchoolAbsorb(bool apply
, bool Real
)
1834 if (apply
&& !m_absorbDmg
)
1835 m_absorbDmg
= m_modifier
.m_amount
;
1839 for(std::list<struct DamageManaShield*>::iterator i = m_target->m_damageManaShield.begin();i != m_target->m_damageManaShield.end();i++)
1841 if(GetId() == (*i)->m_spellId)
1843 m_target->m_damageManaShield.erase(i);
1847 DamageManaShield *dms = new DamageManaShield();
1849 dms->m_spellId = GetId();
1850 dms->m_modType = m_modifier.m_auraname;
1851 dms->m_totalAbsorb = m_modifier.m_amount;
1852 dms->m_currAbsorb = 0;
1853 dms->m_schoolType = m_modifier.m_miscvalue;
1854 m_target->m_damageManaShield.push_back(dms);
1858 for(std::list<struct DamageManaShield*>::iterator i = m_target->m_damageManaShield.begin();i != m_target->m_damageManaShield.end();i++)
1860 if(GetId() == (*i)->m_spellId)
1862 m_target->m_damageManaShield.erase(i);
1869 /*********************************************************/
1870 /*** REFLECT SPELLS ***/
1871 /*********************************************************/
1873 void Aura::HandleReflectSpells(bool apply
, bool Real
)
1875 // has no immediate effect when adding / removing
1878 void Aura::HandleReflectSpellsSchool(bool apply
, bool Real
)
1880 // has no immediate effect when adding / removing
1883 /*********************************************************/
1884 /*** PROC TRIGGER ***/
1885 /*********************************************************/
1887 void Aura::HandleAuraProcTriggerSpell(bool apply
, bool Real
)
1889 if(apply
&& !m_procCharges
)
1891 m_procCharges
= GetSpellProto()->procCharges
;
1897 void Aura::HandleAuraProcTriggerDamage(bool apply
, bool Real
)
1899 if(apply
&& !m_procCharges
)
1901 m_procCharges
= GetSpellProto()->procCharges
;
1907 /*********************************************************/
1909 /*********************************************************/
1911 void Aura::HandlePeriodicTriggerSpell(bool apply
, bool Real
)
1913 if (m_periodicTimer
<= 0)
1914 m_periodicTimer
+= m_modifier
.periodictime
;
1916 m_isPeriodic
= apply
;
1917 m_isTrigger
= apply
;
1920 void Aura::HandlePeriodicEnergize(bool apply
, bool Real
)
1922 if (m_periodicTimer
<= 0)
1923 m_periodicTimer
+= m_modifier
.periodictime
;
1925 m_isPeriodic
= apply
;
1928 void Aura::HandlePeriodicHeal(bool apply
, bool Real
)
1930 if (m_periodicTimer
<= 0)
1931 m_periodicTimer
+= m_modifier
.periodictime
;
1933 m_isPeriodic
= apply
;
1936 void Aura::HandlePeriodicDamage(bool apply
, bool Real
)
1938 if (m_periodicTimer
<= 0)
1939 m_periodicTimer
+= m_modifier
.periodictime
;
1941 m_isPeriodic
= apply
;
1944 void Aura::HandlePeriodicDamagePCT(bool apply
, bool Real
)
1946 if (m_periodicTimer
<= 0)
1947 m_periodicTimer
+= m_modifier
.periodictime
;
1949 m_isPeriodic
= apply
;
1952 void Aura::HandleModDetectRange(bool apply
, bool Real
)
1954 // has no immediate effect when adding / removing
1957 void Aura::HandlePeriodicLeech(bool apply
, bool Real
)
1959 if (m_periodicTimer
<= 0)
1960 m_periodicTimer
+= m_modifier
.periodictime
;
1962 m_isPeriodic
= apply
;
1965 void Aura::HandlePeriodicManaLeech(bool apply
, bool Real
)
1967 if (m_periodicTimer
<= 0)
1968 m_periodicTimer
+= m_modifier
.periodictime
;
1970 m_isPeriodic
= apply
;
1973 /*********************************************************/
1974 /*** MODITY STATES ***/
1975 /*********************************************************/
1977 /********************************/
1978 /*** RESISTANCE ***/
1979 /********************************/
1981 void Aura::HandleAuraModResistanceExclusive(bool apply
, bool Real
)
1983 if(m_modifier
.m_miscvalue
< IMMUNE_SCHOOL_PHYSICAL
|| m_modifier
.m_miscvalue
> 127)
1985 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_BASE_RESISTANCE_PCT not valid");
1989 bool positive
= m_modifier
.m_miscvalue2
== 0;
1991 for(int8 x
=0;x
< MAX_SPELL_SCHOOOL
;x
++)
1993 if(m_modifier
.m_miscvalue
& int32(1<<x
))
1995 SpellSchools school
= SpellSchools(SPELL_SCHOOL_NORMAL
+ x
);
1997 m_target
->ApplyResistanceMod(school
,m_modifier
.m_amount
, apply
);
1998 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
1999 ((Player
*)m_target
)->ApplyResistanceBuffModsMod(school
,positive
,m_modifier
.m_amount
, apply
);
2004 void Aura::HandleAuraModResistance(bool apply
, bool Real
)
2006 if(m_modifier
.m_miscvalue
< IMMUNE_SCHOOL_PHYSICAL
|| m_modifier
.m_miscvalue
> 127)
2008 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_BASE_RESISTANCE_PCT not valid");
2012 bool positive
= m_modifier
.m_miscvalue2
== 0;
2014 for(int8 x
=0;x
< MAX_SPELL_SCHOOOL
;x
++)
2016 if(m_modifier
.m_miscvalue
& int32(1<<x
))
2018 SpellSchools school
= SpellSchools(SPELL_SCHOOL_NORMAL
+ x
);
2020 m_target
->ApplyResistanceMod(school
,m_modifier
.m_amount
, apply
);
2021 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2022 ((Player
*)m_target
)->ApplyResistanceBuffModsMod(school
,positive
,m_modifier
.m_amount
, apply
);
2027 void Aura::HandleAuraModBaseResistancePCT(bool apply
, bool Real
)
2029 if(m_modifier
.m_miscvalue
< IMMUNE_SCHOOL_PHYSICAL
|| m_modifier
.m_miscvalue
> 127)
2031 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_BASE_RESISTANCE_PCT not valid");
2035 // only players have base stats
2036 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
2038 Player
*p_target
= (Player
*)m_target
;
2040 for(int8 x
=0;x
< MAX_SPELL_SCHOOOL
;x
++)
2042 if(m_modifier
.m_miscvalue
& int32(1<<x
))
2044 SpellSchools school
= SpellSchools(SPELL_SCHOOL_NORMAL
+ x
);
2045 float curRes
= p_target
->GetResistance(school
);
2046 float baseRes
= curRes
+ p_target
->GetResistanceBuffMods(school
, false) - p_target
->GetResistanceBuffMods(school
, true);
2047 float baseRes_new
= baseRes
* (apply
?(100.0f
+m_modifier
.m_amount
)/100.0f
: 100.0f
/ (100.0f
+m_modifier
.m_amount
));
2048 p_target
->SetResistance(school
, curRes
+ baseRes_new
- baseRes
);
2053 void Aura::HandleModResistancePercent(bool apply
, bool Real
)
2055 for(int8 i
= 0; i
< MAX_SPELL_SCHOOOL
; i
++)
2057 if(m_modifier
.m_miscvalue
& int32(1<<i
))
2059 m_target
->ApplyResistancePercentMod(SpellSchools(i
), m_modifier
.m_amount
, apply
);
2060 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2062 ((Player
*)m_target
)->ApplyResistanceBuffModsPercentMod(SpellSchools(i
),true,m_modifier
.m_amount
, apply
);
2063 ((Player
*)m_target
)->ApplyResistanceBuffModsPercentMod(SpellSchools(i
),false,m_modifier
.m_amount
, apply
);
2069 void Aura::HandleModBaseResistance(bool apply
, bool Real
)
2071 // only players have base stats
2072 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
2074 Player
*p_target
= (Player
*)m_target
;
2076 for(int i
= 0; i
< MAX_SPELL_SCHOOOL
; i
++)
2077 if(m_modifier
.m_miscvalue
& (1<<i
))
2078 p_target
->ApplyResistanceMod(SpellSchools(SPELL_SCHOOL_NORMAL
+ i
),m_modifier
.m_amount
, apply
);
2081 /********************************/
2083 /********************************/
2085 void Aura::HandleAuraModStat(bool apply
, bool Real
)
2087 if (m_modifier
.m_miscvalue
< -1 || m_modifier
.m_miscvalue
> 4)
2089 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_STAT not valid");
2093 for(int32 i
= 0; i
< 5; i
++)
2095 if (m_modifier
.m_miscvalue
== -1 || m_modifier
.m_miscvalue
== i
)
2097 m_target
->ApplyStatMod(Stats(i
), m_modifier
.m_amount
,apply
);
2098 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2100 if (m_modifier
.m_miscvalue2
== 0)
2101 ((Player
*)m_target
)->ApplyPosStatMod(Stats(i
),m_modifier
.m_amount
,apply
);
2103 ((Player
*)m_target
)->ApplyNegStatMod(Stats(i
),m_modifier
.m_amount
,apply
);
2109 void Aura::HandleModPercentStat(bool apply
, bool Real
)
2111 if (m_modifier
.m_miscvalue
< -1 || m_modifier
.m_miscvalue
> 4)
2113 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
2117 // only players have base stats
2118 if (m_target
->GetTypeId() != TYPEID_PLAYER
)
2120 Player
*p_target
= (Player
*)m_target
;
2122 for (int32 i
= 0; i
< 5; i
++)
2124 if(m_modifier
.m_miscvalue
== i
|| m_modifier
.m_miscvalue
== -1)
2126 float curStat
= p_target
->GetStat(Stats(i
));
2127 float baseStat
= curStat
+ p_target
->GetNegStat(Stats(i
)) - p_target
->GetPosStat(Stats(i
));
2128 float baseStat_new
= baseStat
* (apply
?(100.0f
+m_modifier
.m_amount
)/100.0f
: 100.0f
/ (100.0f
+m_modifier
.m_amount
));
2129 p_target
->SetStat(Stats(i
), curStat
+ baseStat_new
- baseStat
);
2130 p_target
->ApplyCreateStatPercentMod(Stats(i
), m_modifier
.m_amount
, apply
);
2135 void Aura::HandleModTotalPercentStat(bool apply
, bool Real
)
2137 if (m_modifier
.m_miscvalue
< -1 || m_modifier
.m_miscvalue
> 4)
2139 sLog
.outError("WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
2143 for (int32 i
= 0; i
< 5; i
++)
2145 if(m_modifier
.m_miscvalue
== i
|| m_modifier
.m_miscvalue
== -1)
2147 m_target
->ApplyStatPercentMod(Stats(i
), m_modifier
.m_amount
, apply
);
2148 if (m_target
->GetTypeId() == TYPEID_PLAYER
)
2150 ((Player
*)m_target
)->ApplyPosStatPercentMod(Stats(i
), m_modifier
.m_amount
, apply
);
2151 ((Player
*)m_target
)->ApplyNegStatPercentMod(Stats(i
), m_modifier
.m_amount
, apply
);
2152 ((Player
*)m_target
)->ApplyCreateStatPercentMod(Stats(i
), m_modifier
.m_amount
, apply
);
2158 /********************************/
2159 /*** HEAL & ENERGIZE ***/
2160 /********************************/
2161 void Aura::HandleAuraModTotalHealthPercentRegen(bool apply
, bool Real
)
2164 Need additional checking for auras who reduce or increase healing, magic effect like Dumpen Magic,
2165 so this aura not fully working.
2167 if ((GetSpellProto()->AuraInterruptFlags
& (1 << 18)) != 0)
2169 m_target
->ApplyModFlag(UNIT_FIELD_BYTES_1
,PLAYER_STATE_SIT
,apply
);
2172 if(apply
&& m_periodicTimer
<= 0)
2174 m_periodicTimer
+= m_modifier
.periodictime
;
2175 float modifier
= GetSpellProto()->EffectBasePoints
[m_effIndex
]+1;
2176 m_modifier
.m_amount
= uint32(m_target
->GetMaxHealth() * modifier
/100);
2178 if(m_target
->GetHealth() < m_target
->GetMaxHealth())
2179 m_target
->PeriodicAuraLog(m_target
, GetSpellProto(), &m_modifier
);
2182 m_isPeriodic
= apply
;
2185 void Aura::HandleAuraModTotalManaPercentRegen(bool apply
, bool Real
)
2187 if ((GetSpellProto()->AuraInterruptFlags
& (1 << 18)) != 0)
2188 m_target
->ApplyModFlag(UNIT_FIELD_BYTES_1
,PLAYER_STATE_SIT
,apply
);
2190 if(apply
&& m_periodicTimer
<= 0 && m_target
->getPowerType() == POWER_MANA
)
2192 m_periodicTimer
+= m_modifier
.periodictime
;
2193 if (m_modifier
.m_amount
)
2195 float modifier
= GetSpellProto()->EffectBasePoints
[m_effIndex
]+1;
2196 // take percent (m_modifier.m_amount) max mana
2197 m_modifier
.m_amount
= uint32((m_target
->GetMaxPower(POWER_MANA
) * modifier
)/100);
2200 if(m_target
->GetPower(POWER_MANA
) < m_target
->GetMaxPower(POWER_MANA
))
2201 m_target
->PeriodicAuraLog(m_target
, GetSpellProto(), &m_modifier
);
2204 m_isPeriodic
= apply
;
2207 void Aura::HandleModRegen(bool apply
, bool Real
) // eating
2209 if ((GetSpellProto()->AuraInterruptFlags
& (1 << 18)) != 0)
2210 m_target
->ApplyModFlag(UNIT_FIELD_BYTES_1
,PLAYER_STATE_SIT
,apply
);
2212 if(apply
&& m_periodicTimer
<= 0)
2214 m_periodicTimer
+= 5000;
2215 m_target
->ModifyHealth(m_modifier
.m_amount
);
2218 m_isPeriodic
= apply
;
2221 void Aura::HandleModPowerRegen(bool apply
, bool Real
) // drinking
2223 if ((GetSpellProto()->AuraInterruptFlags
& (1 << 18)) != 0)
2224 m_target
->ApplyModFlag(UNIT_FIELD_BYTES_1
,PLAYER_STATE_SIT
,apply
);
2226 if(apply
&& m_periodicTimer
<= 0)
2228 m_periodicTimer
+= 5000;
2229 Powers pt
= m_target
->getPowerType();
2230 // Prevent rage regeneration in combat with rage loss slowdown warrior talant and 0<->1 switching range out combat.
2231 if( !(pt
== POWER_RAGE
&& (m_target
->isInCombat() || m_target
->GetPower(POWER_RAGE
) == 0)) )
2233 m_target
->ModifyPower(pt
, m_modifier
.m_amount
);
2237 m_isPeriodic
= apply
;
2240 void Aura::HandleAuraModIncreaseHealth(bool apply
, bool Real
)
2242 m_target
->ApplyMaxHealthMod(m_modifier
.m_amount
,apply
);
2245 void Aura::HandleAuraModIncreaseEnergy(bool apply
, bool Real
)
2247 Powers powerType
= m_target
->getPowerType();
2248 if(int32(powerType
) != m_modifier
.m_miscvalue
)
2251 m_target
->ApplyMaxPowerMod(powerType
, m_modifier
.m_amount
,apply
);
2254 void Aura::HandleAuraModIncreaseEnergyPercent(bool apply
, bool Real
)
2256 Powers powerType
= m_target
->getPowerType();
2257 if(int32(powerType
) != m_modifier
.m_miscvalue
)
2260 m_target
->ApplyMaxPowerPercentMod(powerType
,m_modifier
.m_amount
,apply
);
2261 sLog
.outDetail("MaxPowerPercentMod %s %d",(apply
? "+" : "-"), m_modifier
.m_amount
);
2264 void Aura::HandleAuraModIncreaseHealthPercent(bool apply
, bool Real
)
2266 m_target
->ApplyMaxHealthPercentMod(m_modifier
.m_amount
,apply
);
2269 /********************************/
2271 /********************************/
2273 void Aura::HandleAuraModParryPercent(bool apply
, bool Real
)
2275 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
2278 m_target
->ApplyModFloatValue(PLAYER_PARRY_PERCENTAGE
,m_modifier
.m_amount
,apply
);
2281 void Aura::HandleAuraModDodgePercent(bool apply
, bool Real
)
2283 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
2286 m_target
->ApplyModFloatValue(PLAYER_DODGE_PERCENTAGE
,m_modifier
.m_amount
,apply
);
2289 void Aura::HandleAuraModBlockPercent(bool apply
, bool Real
)
2291 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
2294 m_target
->ApplyModFloatValue(PLAYER_BLOCK_PERCENTAGE
,m_modifier
.m_amount
,apply
);
2297 void Aura::HandleAuraModCritPercent(bool apply
, bool Real
)
2299 if(m_target
->GetTypeId()!=TYPEID_PLAYER
)
2302 m_target
->ApplyModFloatValue(PLAYER_CRIT_PERCENTAGE
,m_modifier
.m_amount
,apply
);
2305 void Aura::HandleModShieldBlock(bool apply
, bool Real
)
2307 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
2310 ((Player
*)m_target
)->ApplyBlockValueMod(m_modifier
.m_amount
,apply
);
2313 void Aura::HandleModHitChance(bool Apply
, bool Real
)
2315 m_target
->m_modHitChance
= Apply
?m_modifier
.m_amount
:0;
2318 void Aura::HandleModSpellHitChance(bool Apply
, bool Real
)
2320 m_target
->m_modSpellHitChance
= Apply
?m_modifier
.m_amount
:0;
2323 void Aura::HandleModSpellCritChance(bool Apply
, bool Real
)
2325 m_target
->m_baseSpellCritChance
+= Apply
?m_modifier
.m_amount
:(-m_modifier
.m_amount
);
2328 void Aura::HandleModSpellCritChanceShool(bool apply
, bool Real
)
2330 // has no immediate effect when adding / removing
2333 /********************************/
2334 /*** ATTACK SPEED ***/
2335 /********************************/
2337 void Aura::HandleModCastingSpeed(bool apply
, bool Real
)
2339 m_target
->m_modCastSpeedPct
+= apply
? m_modifier
.m_amount
: (-m_modifier
.m_amount
);
2342 void Aura::HandleModAttackSpeed(bool apply
, bool Real
)
2344 if(!m_target
|| !m_target
->isAlive() )
2347 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
,m_modifier
.m_amount
,apply
);
2350 void Aura::HandleHaste(bool apply
, bool Real
)
2353 if(m_modifier
.m_amount
>= 0)
2355 // v*(1+percent/100)
2356 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
, m_modifier
.m_amount
,apply
);
2357 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
, m_modifier
.m_amount
,apply
);
2359 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
2360 ((Player
*)m_target
)->_ApplyAmmoBonuses(false);
2362 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
,m_modifier
.m_amount
,apply
);
2364 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
2365 ((Player
*)m_target
)->_ApplyAmmoBonuses(true);
2369 // v/(1+abs(percent)/100)
2370 m_target
->ApplyAttackTimePercentMod(BASE_ATTACK
, -m_modifier
.m_amount
,!apply
);
2371 m_target
->ApplyAttackTimePercentMod(OFF_ATTACK
, -m_modifier
.m_amount
,!apply
);
2373 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
2374 ((Player
*)m_target
)->_ApplyAmmoBonuses(false);
2376 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
,-m_modifier
.m_amount
,!apply
);
2378 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
2379 ((Player
*)m_target
)->_ApplyAmmoBonuses(true);
2383 void Aura::HandleAuraModRangedHaste(bool apply
, bool Real
)
2385 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
2386 ((Player
*)m_target
)->_ApplyAmmoBonuses(false);
2388 if(m_modifier
.m_amount
>= 0)
2389 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, m_modifier
.m_amount
, apply
);
2391 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
, -m_modifier
.m_amount
, !apply
);
2393 if(m_target
->GetTypeId()==TYPEID_PLAYER
)
2394 ((Player
*)m_target
)->_ApplyAmmoBonuses(true);
2397 void Aura::HandleRangedAmmoHaste(bool apply
, bool Real
)
2399 if(m_target
->GetTypeId() != TYPEID_PLAYER
)
2401 ((Player
*)m_target
)->_ApplyAmmoBonuses(false);
2402 m_target
->ApplyAttackTimePercentMod(RANGED_ATTACK
,m_modifier
.m_amount
, apply
);
2403 ((Player
*)m_target
)->_ApplyAmmoBonuses(true);
2406 /********************************/
2407 /*** ATTACK POWER ***/
2408 /********************************/
2410 void Aura::HandleAuraModAttackPower(bool apply
, bool Real
)
2412 m_target
->ApplyModUInt32Value(UNIT_FIELD_ATTACK_POWER_MODS
, m_modifier
.m_amount
, apply
);
2415 void Aura::HandleAuraModRangedAttackPower(bool apply
, bool Real
)
2417 m_target
->ApplyModUInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS
,m_modifier
.m_amount
,apply
);
2420 /********************************/
2421 /*** DAMAGE BONUS ***/
2422 /********************************/
2424 void Aura::HandleModDamagePCTTaken(bool apply
, bool Real
)
2426 m_target
->m_modDamagePCT
= apply
? m_modifier
.m_amount
: 0;
2429 void Aura::HandleModPCTRegen(bool apply
, bool Real
)
2431 // has no immediate effect when adding / removing
2434 void Aura::HandleModCreatureAttackPower(bool apply
, bool Real
)
2436 // has no immediate effect when adding / removing
2439 void Aura::HandleModDamageDoneCreature(bool apply
, bool Real
)
2441 // has no immediate effect when adding / removing
2444 void Aura::HandleModDamageDone(bool apply
, bool Real
)
2446 // physical damage modifier is applied to damage fields
2447 if(m_modifier
.m_miscvalue
& (int32
)(1<<SPELL_SCHOOL_NORMAL
))
2449 m_target
->ApplyModFloatValue(UNIT_FIELD_MINDAMAGE
,m_modifier
.m_amount
,apply
);
2450 m_target
->ApplyModFloatValue(UNIT_FIELD_MAXDAMAGE
,m_modifier
.m_amount
,apply
);
2451 // TODO: add ranged support and maybe offhand ?
2452 // not completely sure how this should work
2453 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2455 if(m_modifier
.m_miscvalue2
)
2456 m_target
->ApplyModFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG
,m_modifier
.m_amount
,apply
);
2458 m_target
->ApplyModFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_POS
,m_modifier
.m_amount
,apply
);
2463 void Aura::HandleModDamageTaken(bool apply
, bool Real
)
2465 // has no immediate effect when adding / removing
2468 void Aura::HandleModDamagePercentDone(bool apply
, bool Real
)
2470 sLog
.outDebug("AURA MOD DAMAGE type:%u type2:%u", m_modifier
.m_miscvalue
, m_modifier
.m_miscvalue2
);
2472 // FIX ME: This is wrong code.
2473 // It not work with 20218 18791 spells
2475 // m_modifier.m_miscvalue is bitmask of spell schools
2476 // 1 ( 0-bit ) - normal school damage
2477 // 126 - full bitmask all magic damages
2478 // 127 - full bitmask any damages
2480 // mods must be applied base at equiped weapon class and subclass comparison
2481 // with spell->EquippedItemClass and EquippedItemSubClassMask and EquippedItemInventoryTypeMask
2482 // m_modifier.m_miscvalue comparison with item generated damage types
2486 if((m_modifier
.m_miscvalue
& 1) != 0)
2488 if (GetSpellProto()->EquippedItemClass
== -1 || m_target
->GetTypeId() != TYPEID_PLAYER
)
2490 m_target
->ApplyPercentModFloatValue(UNIT_FIELD_MINRANGEDDAMAGE
, m_modifier
.m_amount
, apply
);
2491 m_target
->ApplyPercentModFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE
, m_modifier
.m_amount
, apply
);
2492 m_target
->ApplyPercentModFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE
, m_modifier
.m_amount
, apply
);
2493 m_target
->ApplyPercentModFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE
, m_modifier
.m_amount
, apply
);
2494 m_target
->ApplyPercentModFloatValue(UNIT_FIELD_MINDAMAGE
, m_modifier
.m_amount
, apply
);
2495 m_target
->ApplyPercentModFloatValue(UNIT_FIELD_MAXDAMAGE
, m_modifier
.m_amount
, apply
);
2499 Item
* pItem
= ((Player
*)m_target
)->GetItemByPos(INVENTORY_SLOT_BAG_0
, EQUIPMENT_SLOT_MAINHAND
);
2502 if (pItem
->IsFitToSpellRequirements(GetSpellProto()))
2504 m_target
->ApplyPercentModFloatValue(UNIT_FIELD_MINDAMAGE
, m_modifier
.m_amount
, apply
);
2505 m_target
->ApplyPercentModFloatValue(UNIT_FIELD_MAXDAMAGE
, m_modifier
.m_amount
, apply
);
2508 pItem
= ((Player
*)m_target
)->GetItemByPos(INVENTORY_SLOT_BAG_0
, EQUIPMENT_SLOT_OFFHAND
);
2511 if (pItem
->IsFitToSpellRequirements(GetSpellProto()))
2513 m_target
->ApplyPercentModFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE
, m_modifier
.m_amount
, apply
);
2514 m_target
->ApplyPercentModFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE
, m_modifier
.m_amount
, apply
);
2517 pItem
= ((Player
*)m_target
)->GetItemByPos(INVENTORY_SLOT_BAG_0
, EQUIPMENT_SLOT_RANGED
);
2520 if (pItem
->IsFitToSpellRequirements(GetSpellProto()))
2522 m_target
->ApplyPercentModFloatValue(UNIT_FIELD_MINRANGEDDAMAGE
, m_modifier
.m_amount
, apply
);
2523 m_target
->ApplyPercentModFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE
, m_modifier
.m_amount
, apply
);
2529 // Magic damage percent modifiers implemented in Unit::SpellDamageBonus
2532 /********************************/
2533 /*** POWER COST ***/
2534 /********************************/
2536 void Aura::HandleModPowerCost(bool apply
, bool Real
)
2538 m_target
->ApplyModUInt32Value(UNIT_FIELD_POWER_COST_MODIFIER
, m_modifier
.m_amount
, apply
);
2541 void Aura::HandleModPowerCostSchool(bool apply
, bool Real
)
2543 // has no immediate effect when adding / removing
2546 /*********************************************************/
2548 /*********************************************************/
2550 void Aura::HandleModReputationGain(bool apply
, bool Real
)
2552 // has no immediate effect when adding / removing
2555 void Aura::SendCoolDownEvent()
2557 Unit
* caster
= GetCaster();
2560 WorldPacket
data(SMSG_COOLDOWN_EVENT
, (4+8+4));
2561 data
<< uint32(m_spellId
) << m_caster_guid
;
2562 data
<< uint32(0); //CoolDown Time ?
2563 caster
->SendMessageToSet(&data
,true);
2568 void HandleTriggerSpellEvent(void *obj
)
2570 Aura
*Aur
= ((Aura
*)obj
);
2573 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(Aur
->GetSpellProto()->EffectTriggerSpell
[Aur
->GetEffIndex()]);
2577 sLog
.outError("WORLD: unknown spell id %i\n", Aur
->GetSpellProto()->EffectTriggerSpell
[Aur
->GetEffIndex()]);
2581 Spell
spell(Aur
->GetCaster(), spellInfo
, true, Aur
);
2582 SpellCastTargets targets
;
2583 targets
.setUnitTarget(Aur
->GetTarget());
2585 //dump.Initialize(0);
2586 //dump << uint16(2) << GetUInt32Value(UNIT_FIELD_CHANNEL_OBJECT) << GetUInt32Value(UNIT_FIELD_CHANNEL_OBJECT+1);
2587 //targets.read(&dump,this);
2588 spell
.prepare(&targets
);
2590 /*else if(m_spellProto->EffectApplyAuraName[i] == 23)
2592 unitTarget->tmpAura->SetPeriodicTriggerSpell(m_spellProto->EffectTriggerSpell[i],m_spellProto->EffectAmplitude[i]);
2596 void HandleDOTEvent(void *obj
)
2598 Aura
*Aur
= ((Aura
*)obj
);
2599 //Aur->GetCaster()->AddPeriodicAura(Aur);
2600 if(Unit
* caster
= Aur
->GetCaster())
2601 caster
->PeriodicAuraLog(Aur
->GetTarget(), Aur
->GetSpellProto(), Aur
->GetModifier());
2604 void HandleHealEvent(void *obj
)
2606 Aura
*Aur
= ((Aura
*)obj
);
2607 if(Unit
* caster
= Aur
->GetCaster())
2608 Aur
->GetTarget()->PeriodicAuraLog(caster
, Aur
->GetSpellProto(), Aur
->GetModifier());
2611 void Aura::HandleShapeshiftBoosts(bool apply
)
2617 uint32 spellId2
= 0;
2619 switch(GetModifier()->m_miscvalue
)
2639 case FORM_CREATUREBEAR
:
2642 case FORM_BATTLESTANCE
:
2645 case FORM_DEFENSIVESTANCE
:
2648 case FORM_BERSERKERSTANCE
:
2653 // aura from effect trigger spell
2656 case FORM_GHOSTWOLF
:
2665 uint32 form
= GetModifier()->m_miscvalue
-1;
2669 if(m_target
->m_ShapeShiftForm
)
2671 m_target
->RemoveAurasDueToSpell(m_target
->m_ShapeShiftForm
);
2674 if (spellId
) m_target
->CastSpell(m_target
, spellId
, true);
2675 if (spellId2
) m_target
->CastSpell(m_target
, spellId2
, true);
2677 if(m_target
->GetTypeId() == TYPEID_PLAYER
)
2679 const PlayerSpellMap
& sp_list
= ((Player
*)m_target
)->GetSpellMap();
2680 for (PlayerSpellMap::const_iterator itr
= sp_list
.begin(); itr
!= sp_list
.end(); ++itr
)
2682 if(itr
->second
->state
== PLAYERSPELL_REMOVED
) continue;
2683 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(itr
->first
);
2684 if (!spellInfo
|| !IsPassiveSpell(itr
->first
)) continue;
2685 if (spellInfo
->Stances
& (1<<form
))
2686 m_target
->CastSpell(m_target
, itr
->first
, true);
2692 m_target
->RemoveAurasDueToSpell(spellId
);
2693 m_target
->RemoveAurasDueToSpell(spellId2
);
2695 Unit::AuraMap
& tAuras
= m_target
->GetAuras();
2696 for (Unit::AuraMap::iterator itr
= tAuras
.begin(); itr
!= tAuras
.end();)
2698 if ((*itr
).second
->GetSpellProto()->Stances
& uint32(1<<form
))
2699 m_target
->RemoveAura(itr
);
2705 double healthPercentage
= (double)m_target
->GetHealth() / (double)m_target
->GetMaxHealth();
2706 m_target
->SetHealth(uint32(ceil((double)m_target
->GetMaxHealth() * healthPercentage
)));
2709 void Aura::HandleAuraEmpathy(bool apply
, bool Real
)
2711 if(m_target
->GetTypeId()!=TYPEID_UNIT
)
2714 CreatureInfo
const * ci
= objmgr
.GetCreatureTemplate(m_target
->GetEntry());
2715 if(ci
&& ci
->type
== CREATURE_TYPE_BEAST
)
2717 m_target
->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS
, UNIT_DYNFLAG_SPECIALINFO
, apply
);