Core/Auras: Add functions for common actions on aura charges.
This commit is contained in:
@@ -19669,7 +19669,7 @@ void Player::RemoveSpellMods(Spell * spell)
|
||||
// remove from list
|
||||
spell->m_appliedMods.erase(iterMod);
|
||||
|
||||
if (mod->ownerAura->DropCharge())
|
||||
if (mod->ownerAura->DropCharge(AURA_REMOVE_BY_EXPIRE))
|
||||
itr = m_spellMods[i].begin();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3157,13 +3157,8 @@ Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellEntry const* newAura, uint
|
||||
*oldGUID = castItemGUID;
|
||||
}
|
||||
|
||||
uint8 charges = foundAura->GetSpellProto()->procCharges;
|
||||
if (caster)
|
||||
if (Player* modOwner = caster->GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(foundAura->GetId(), SPELLMOD_CHARGES, charges);
|
||||
|
||||
// refresh charges
|
||||
foundAura->SetCharges(charges);
|
||||
foundAura->SetCharges(foundAura->CalcMaxCharges(caster));
|
||||
|
||||
// try to increase stack amount
|
||||
foundAura->ModStackAmount(1);
|
||||
@@ -3675,10 +3670,7 @@ void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit
|
||||
if (aura->GetCasterGUID() == casterGUID)
|
||||
{
|
||||
if (aura->GetSpellProto()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES)
|
||||
{
|
||||
for (uint8 i = 0; i < chargesRemoved; i++)
|
||||
aura->DropCharge();
|
||||
}
|
||||
aura->ModCharges(-chargesRemoved, AURA_REMOVE_BY_ENEMY_SPELL);
|
||||
else
|
||||
aura->ModStackAmount(-chargesRemoved, AURA_REMOVE_BY_ENEMY_SPELL);
|
||||
|
||||
@@ -3793,21 +3785,12 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit
|
||||
}
|
||||
|
||||
bool stealCharge = aura->GetSpellProto()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES;
|
||||
bool stealStack = aura->GetSpellProto()->StackAmount > 1;
|
||||
int32 dur = (2*MINUTE*IN_MILLISECONDS < aura->GetDuration() || aura->GetDuration() < 0) ? 2*MINUTE*IN_MILLISECONDS : aura->GetDuration();
|
||||
int32 dur = std::min(2*MINUTE*IN_MILLISECONDS, aura->GetDuration());
|
||||
|
||||
if (Aura * newAura = (stealCharge || stealStack) ? stealer->GetAura(aura->GetId(), aura->GetCasterGUID()) : NULL)
|
||||
if (Aura * newAura = stealer->GetAura(aura->GetId(), aura->GetCasterGUID()))
|
||||
{
|
||||
if (stealCharge)
|
||||
{
|
||||
uint8 newCharges = newAura->GetCharges() + 1;
|
||||
uint8 maxCharges = newAura->GetSpellProto()->procCharges;
|
||||
// We must be able to steal as much charges as original caster can have
|
||||
if (caster)
|
||||
if (Player* modOwner = caster->GetSpellModOwner())
|
||||
modOwner->ApplySpellMod(aura->GetId(), SPELLMOD_CHARGES, maxCharges);
|
||||
newAura->SetCharges(maxCharges < newCharges ? maxCharges : newCharges);
|
||||
}
|
||||
newAura->ModCharges(1);
|
||||
else
|
||||
newAura->ModStackAmount(1);
|
||||
newAura->SetDuration(dur);
|
||||
@@ -3834,7 +3817,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit
|
||||
}
|
||||
|
||||
if (stealCharge)
|
||||
aura->DropCharge();
|
||||
aura->ModCharges(-1, AURA_REMOVE_BY_ENEMY_SPELL);
|
||||
else
|
||||
aura->ModStackAmount(-1, AURA_REMOVE_BY_ENEMY_SPELL);
|
||||
|
||||
@@ -10065,7 +10048,7 @@ Unit* Unit::SelectMagnetTarget(Unit *victim, SpellEntry const *spellInfo)
|
||||
if (Unit* magnet = (*itr)->GetBase()->GetUnitOwner())
|
||||
if (magnet->isAlive())
|
||||
{
|
||||
(*itr)->GetBase()->DropCharge();
|
||||
(*itr)->GetBase()->DropCharge(AURA_REMOVE_BY_EXPIRE);
|
||||
return magnet;
|
||||
}
|
||||
}
|
||||
@@ -10078,7 +10061,7 @@ Unit* Unit::SelectMagnetTarget(Unit *victim, SpellEntry const *spellInfo)
|
||||
if (magnet->isAlive() && magnet->IsWithinLOSInMap(this))
|
||||
if (roll_chance_i((*i)->GetAmount()))
|
||||
{
|
||||
(*i)->GetBase()->DropCharge();
|
||||
(*i)->GetBase()->DropCharge(AURA_REMOVE_BY_EXPIRE);
|
||||
return magnet;
|
||||
}
|
||||
}
|
||||
@@ -14417,7 +14400,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit * pTarget, uint32 procFlag,
|
||||
}
|
||||
// Remove charge (aura can be removed by triggers)
|
||||
if (useCharges && takeCharges)
|
||||
i->aura->DropCharge();
|
||||
i->aura->DropCharge(AURA_REMOVE_BY_EXPIRE);
|
||||
|
||||
if (spellInfo->AttributesEx3 & SPELL_ATTR3_DISABLE_PROC)
|
||||
SetCantProc(false);
|
||||
|
||||
Reference in New Issue
Block a user