aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/SpellAuras.cpp16
-rw-r--r--src/game/SpellAuras.h2
-rw-r--r--src/game/Unit.cpp30
-rw-r--r--src/game/Unit.h3
4 files changed, 27 insertions, 24 deletions
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index e394f9a18ca..ddc1b9c59a4 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -1260,14 +1260,16 @@ void Aura::SetAuraCharges(uint8 charges)
SendAuraUpdate();
}
-bool Aura::DropAuraCharge()
+void Aura::DropAuraCharge()
{
- if (m_procCharges == 0)
- return false;
- m_procCharges--;
- SendAuraUpdate();
- // return true if last charge dropped
- return m_procCharges == 0;
+ if(m_procCharges) //auras without charges always have charge = 0
+ {
+ --m_procCharges;
+ if(m_procCharges) // Send charge change
+ SendAuraUpdate();
+ else // Last charge dropped
+ m_target->RemoveAura(this);
+ }
}
bool Aura::IsPersistent() const
diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h
index 698df1f9a30..bef0be0bdd9 100644
--- a/src/game/SpellAuras.h
+++ b/src/game/SpellAuras.h
@@ -73,7 +73,7 @@ class TRINITY_DLL_SPEC Aura
void SetAuraSlot(uint8 slot) { m_auraSlot = slot; }
uint8 GetAuraCharges() const { return m_procCharges; }
void SetAuraCharges(uint8 charges);
- bool DropAuraCharge();
+ void DropAuraCharge();
void SetProcDamage(uint32 val) { m_procDamage = val; }
uint32 GetProcDamage() const { return m_procDamage; }
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index f9c5d5c4d6f..f2ae30ffee6 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -6297,8 +6297,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
{
uint32 spell = (*itr)->GetSpellProto()->EffectTriggerSpell[(*itr)->GetEffIndex()];
CastSpell(this, spell, true, castItem, triggeredByAura);
- if ((*itr)->GetParentAura()->DropAuraCharge())
- RemoveAurasDueToSpell((*itr)->GetId());
+ (*itr)->GetParentAura()->DropAuraCharge();
return true;
}
}
@@ -6382,8 +6381,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
return false;
}
CastSpell(this, spell, true, castItem, triggeredByAura);
- if ((*itr)->GetParentAura()->DropAuraCharge())
- RemoveAurasDueToSpell((*itr)->GetId());
+ (*itr)->GetParentAura()->DropAuraCharge();
return true;
}
}
@@ -8190,23 +8188,27 @@ Unit* Unit::SelectMagnetTarget(Unit *victim, SpellEntry const *spellInfo)
if(spellInfo->DmgClass == SPELL_DAMAGE_CLASS_NONE)
return victim;
- //if((*itr)->GetParentAura()->DropAuraCharge())
-
- Unit::AuraList const& magnetAuras = victim->GetAurasByType(SPELL_AURA_SPELL_MAGNET);
- for(Unit::AuraList::const_iterator itr = magnetAuras.begin(); itr != magnetAuras.end(); ++itr)
+ Unit::AuraEffectList const& magnetAuras = victim->GetAurasByType(SPELL_AURA_SPELL_MAGNET);
+ for(Unit::AuraEffectList::const_iterator itr = magnetAuras.begin(); itr != magnetAuras.end(); ++itr)
if(Unit* magnet = (*itr)->GetCaster())
if(magnet->isAlive())
+ {
+ (*itr)->GetParentAura()->DropAuraCharge();
return magnet;
+ }
}
// Melee && ranged case
else
{
- AuraList const& hitTriggerAuras = victim->GetAurasByType(SPELL_AURA_ADD_CASTER_HIT_TRIGGER);
- for(AuraList::const_iterator i = hitTriggerAuras.begin(); i != hitTriggerAuras.end(); ++i)
+ AuraEffectList const& hitTriggerAuras = victim->GetAurasByType(SPELL_AURA_ADD_CASTER_HIT_TRIGGER);
+ for(AuraEffectList::const_iterator i = hitTriggerAuras.begin(); i != hitTriggerAuras.end(); ++i)
if(Unit* magnet = (*i)->GetCaster())
if(magnet->isAlive() && magnet->IsWithinLOSInMap(this))
- if(roll_chance_i((*i)->GetModifier()->m_amount))
+ if(roll_chance_i((*i)->GetAmount()))
+ {
+ (*i)->GetParentAura()->DropAuraCharge();
return magnet;
+ }
}
return victim;
@@ -8820,8 +8822,7 @@ bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM
// Fingers of Frost
// TODO: Change this code to less hacky
if (Aura * aur = GetAura(44544))
- if (aur->DropAuraCharge())
- RemoveAura(aur);
+ aur->DropAuraCharge();
break;
case 7917: // Glyph of Shadowburn
if (pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellProto, this))
@@ -11805,8 +11806,7 @@ void Unit::ProcDamageAndSpellFor( bool isVictim, Unit * pTarget, uint32 procFlag
// Remove charge (aura can be removed by triggers)
if(useCharges && takeCharges)
{
- if (i->aura->DropAuraCharge())
- RemoveAura(i->aura);
+ i->aura->DropAuraCharge();
}
}
}
diff --git a/src/game/Unit.h b/src/game/Unit.h
index c52090b97d1..4d328042f53 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1173,7 +1173,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void SendEnergizeSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage,Powers powertype);
uint32 SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage, bool isTriggeredSpell = false, bool useSpellDamage = true);
void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0);
- void CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem= NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0);
+ void CastSpell(Unit* Victim, SpellEntry const *spellInfo, bool triggered, Item *castItem= NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0);
+ void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0);
void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0);
void CastCustomSpell(uint32 spellId, SpellValueMod mod, uint32 value, Unit* Victim = NULL, bool triggered = true, Item *castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0);
void CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* Victim = NULL, bool triggered = true, Item *castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0);