Core/Spell: implemented dispel reflection

Closes #18323
This commit is contained in:
ariel- authored and Aokromes committed 2016-12-16 19:24:01 +01:00
1 parent 3c71fd2c3b
commit eb3a90a4e8
7 files changed
+150 -119

No files matched your search

+13 -7
View File
@@ -4258,17 +4258,17 @@ Aura* Unit::GetAuraOfRankedSpell(uint32 spellId, ObjectGuid casterGUID, ObjectGu
return aurApp ? aurApp->GetBase() : NULL;
}
void Unit::GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelChargesList& dispelList)
void Unit::GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelChargesList& dispelList, bool isReflect /*= false*/) const
{
// we should not be able to dispel diseases if the target is affected by unholy blight
if (dispelMask & (1 << DISPEL_DISEASE) && HasAura(50536))
dispelMask &= ~(1 << DISPEL_DISEASE);
AuraMap const& auras = GetOwnedAuras();
for (AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
for (auto itr = auras.begin(); itr != auras.end(); ++itr)
{
Aura* aura = itr->second;
AuraApplication * aurApp = aura->GetApplicationOfTarget(GetGUID());
AuraApplication const* aurApp = aura->GetApplicationOfTarget(GetGUID());
if (!aurApp)
continue;
@@ -4279,17 +4279,23 @@ void Unit::GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelCharges
if (aura->GetSpellInfo()->GetDispelMask() & dispelMask)
{
// do not remove positive auras if friendly target
// negative auras if non-friendly target
if (aurApp->IsPositive() == IsFriendlyTo(caster))
// negative auras if non-friendly
// unless we're reflecting (dispeller eliminates one of it's benefitial buffs)
if (isReflect != (aurApp->IsPositive() == IsFriendlyTo(caster)))
continue;
// 2.4.3 Patch Notes: "Dispel effects will no longer attempt to remove effects that have 100% dispel resistance."
int32 chance = aura->CalcDispelChance(this, !IsFriendlyTo(caster));
if (!chance)
continue;
// The charges / stack amounts don't count towards the total number of auras that can be dispelled.
// Ie: A dispel on a target with 5 stacks of Winters Chill and a Polymorph has 1 / (1 + 1) -> 50% chance to dispell
// Polymorph instead of 1 / (5 + 1) -> 16%.
bool dispelCharges = aura->GetSpellInfo()->HasAttribute(SPELL_ATTR7_DISPEL_CHARGES);
bool const dispelCharges = aura->GetSpellInfo()->HasAttribute(SPELL_ATTR7_DISPEL_CHARGES);
uint8 charges = dispelCharges ? aura->GetCharges() : aura->GetStackAmount();
if (charges > 0)
dispelList.push_back(std::make_pair(aura, charges));
dispelList.emplace_back(aura, chance, charges);
}
}
}