aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Unit
diff options
context:
space:
mode:
authorGiuseppe Montesanto <montesanto.giuseppe@live.it>2012-02-04 13:32:40 +0100
committerGiuseppe Montesanto <montesanto.giuseppe@live.it>2012-02-04 13:32:40 +0100
commit271feb587f2ef0940e1af3309bb3c679b8ad76d2 (patch)
tree340b08fc48b884ce5339075d2d68988d15bc42df /src/server/game/Entities/Unit
parent894c27af520eb550764d4cacd2b43e87fd100597 (diff)
Add hook on AuraScript called when an aura is dispelled
Diffstat (limited to 'src/server/game/Entities/Unit')
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp16
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.h21
2 files changed, 32 insertions, 5 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 63aa7771063..63a56516e8b 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -3492,17 +3492,25 @@ void Unit::RemoveAuraFromStack(uint32 spellId, uint64 casterGUID, AuraRemoveMode
}
}
-void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit* dispeller, uint8 chargesRemoved/*= 1*/)
+void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId, uint64 casterGUID, Unit* dispeller, uint8 chargesRemoved/*= 1*/)
{
for (AuraMap::iterator iter = m_ownedAuras.lower_bound(spellId); iter != m_ownedAuras.upper_bound(spellId);)
{
Aura* aura = iter->second;
if (aura->GetCasterGUID() == casterGUID)
{
+ DispelInfo dispelInfo(dispeller, dispellerSpellId, chargesRemoved);
+
+ // Call OnDispel hook on AuraScript
+ aura->CallScriptDispel(&dispelInfo);
+
if (aura->GetSpellInfo()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES)
- aura->ModCharges(-chargesRemoved, AURA_REMOVE_BY_ENEMY_SPELL);
+ aura->ModCharges(-dispelInfo.GetRemovedCharges(), AURA_REMOVE_BY_ENEMY_SPELL);
else
- aura->ModStackAmount(-chargesRemoved, AURA_REMOVE_BY_ENEMY_SPELL);
+ aura->ModStackAmount(-dispelInfo.GetRemovedCharges(), AURA_REMOVE_BY_ENEMY_SPELL);
+
+ // Call AfterDispel hook on AuraScript
+ aura->CallScriptAfterDispel(&dispelInfo);
switch (aura->GetSpellInfo()->SpellFamilyName)
{
@@ -3532,7 +3540,7 @@ void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit
{
// final heal
int32 healAmount = aurEff->GetAmount();
- int32 stack = chargesRemoved;
+ int32 stack = dispelInfo.GetRemovedCharges();
CastCustomSpell(this, 33778, &healAmount, &stack, NULL, true, NULL, NULL, aura->GetCasterGUID());
// mana
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index b64a2e210bc..1808018d865 100755
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -788,6 +788,25 @@ enum MeleeHitOutcome
MELEE_HIT_GLANCING, MELEE_HIT_CRIT, MELEE_HIT_CRUSHING, MELEE_HIT_NORMAL
};
+class DispelInfo
+{
+private:
+ Unit* const m_dispeller;
+ uint32 const m_dispellerSpellId;
+ uint8 m_chargesRemoved;
+public:
+ explicit DispelInfo(Unit* _dispeller, uint32 _dispellerSpellId, uint8 _chargesRemoved) :
+ m_dispeller(_dispeller), m_dispellerSpellId(_dispellerSpellId), m_chargesRemoved(_chargesRemoved) {}
+
+ Unit* GetDispeller() { return m_dispeller; }
+ uint32 GetDispellerSpellId() { return m_dispellerSpellId; }
+ uint8 GetRemovedCharges() { return m_chargesRemoved; }
+ void SetRemovedCharges(uint8 amount)
+ {
+ m_chargesRemoved = amount;
+ }
+};
+
struct CleanDamage
{
CleanDamage(uint32 mitigated, uint32 absorbed, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome) :
@@ -1744,7 +1763,7 @@ class Unit : public WorldObject
void RemoveAurasDueToSpell(uint32 spellId, uint64 casterGUID = 0, uint8 reqEffMask = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
void RemoveAuraFromStack(uint32 spellId, uint64 casterGUID = 0, AuraRemoveMode removeMode = AURA_REMOVE_BY_DEFAULT);
- void RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit* dispeller, uint8 chargesRemoved = 1);
+ void RemoveAurasDueToSpellByDispel(uint32 spellId, uint32 dispellerSpellId, uint64 casterGUID, Unit* dispeller, uint8 chargesRemoved = 1);
void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit* stealer);
void RemoveAurasDueToItemSpell(Item* castItem, uint32 spellId);
void RemoveAurasByType(AuraType auraType, uint64 casterGUID = 0, Aura* except = NULL, bool negative = true, bool positive = true);