Add hook on AuraScript called when an aura is dispelled
This commit is contained in:
1 parent
894c27af52
commit
271feb587f
7 files changed
+100
-6
No files matched your search
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user