*Always remove aura when charge becomes 0 in dropcharge.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-04-19 12:10:53 -05:00
parent 2a875fb5e0
commit e6868e73f1
4 changed files with 27 additions and 24 deletions
+9 -7
View File
@@ -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
+1 -1
View File
@@ -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; }
+15 -15
View File
@@ -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();
}
}
}
+2 -1
View File
@@ -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);