aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Unit
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2016-12-11 15:04:25 -0300
committerjoschiwald <joschiwald.trinity@gmail.com>2018-04-21 13:52:37 +0200
commit76831d16bea0a4fdf7e11656c69949fd706971f9 (patch)
tree53530b5caee70d3e9d44b4fc167c907f660e1231 /src/server/game/Entities/Unit
parent4aaf4245646e4f117cb2de7855b5672ce2fff14f (diff)
Core/Spell: implemented dispel reflection
Closes #18323 (cherry picked from commit f0772eea98c66f7fd2e745c0cfb8599d6c21ef19) # Conflicts: # src/server/game/Spells/Spell.cpp # src/server/game/Spells/Spell.h # src/server/game/Spells/SpellEffects.cpp
Diffstat (limited to 'src/server/game/Entities/Unit')
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp25
-rw-r--r--src/server/game/Entities/Unit/Unit.h30
2 files changed, 46 insertions, 9 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 847a8e6f51e..f0af80b721e 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -105,6 +105,11 @@ float playerBaseMoveSpeed[MAX_MOVE_TYPE] =
3.14f // MOVE_PITCH_RATE
};
+bool DispelableAura::RollDispel() const
+{
+ return roll_chance_i(_chance);
+}
+
DamageInfo::DamageInfo(Unit* attacker, Unit* victim, uint32 damage, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, DamageEffectType damageType, WeaponAttackType attackType)
: m_attacker(attacker), m_victim(victim), m_damage(damage), m_spellInfo(spellInfo), m_schoolMask(schoolMask), m_damageType(damageType), m_attackType(attackType),
m_absorb(0), m_resist(0), m_block(0), m_hitMask(0)
@@ -4261,13 +4266,13 @@ 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
{
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;
@@ -4278,17 +4283,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);
}
}
}
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index b5a023620da..6d8f9c81cbd 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -228,7 +228,33 @@ namespace WorldPackets
}
typedef std::list<Unit*> UnitList;
-typedef std::list<std::pair<Aura*, uint8>> DispelChargesList;
+
+class DispelableAura
+{
+ public:
+ DispelableAura(Aura* aura, int32 dispelChance, uint8 dispelCharges) :
+ _aura(aura), _chance(dispelChance), _charges(dispelCharges) { }
+
+ Aura* GetAura() const { return _aura; }
+ bool RollDispel() const;
+ uint8 GetDispelCharges() const { return _charges; }
+
+ void IncrementCharges() { ++_charges; }
+ bool DecrementCharge()
+ {
+ if (!_charges)
+ return false;
+
+ --_charges;
+ return _charges > 0;
+ }
+
+ private:
+ Aura* _aura;
+ int32 _chance;
+ uint8 _charges;
+};
+typedef std::vector<DispelableAura> DispelChargesList;
typedef std::unordered_multimap<uint32 /*type*/, uint32 /*spellId*/> SpellImmuneContainer;
@@ -1471,7 +1497,7 @@ class TC_GAME_API Unit : public WorldObject
AuraApplication * GetAuraApplicationOfRankedSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint32 reqEffMask = 0, AuraApplication * except = NULL) const;
Aura* GetAuraOfRankedSpell(uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty, ObjectGuid itemCasterGUID = ObjectGuid::Empty, uint32 reqEffMask = 0) const;
- void GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelChargesList& dispelList);
+ void GetDispellableAuraList(Unit* caster, uint32 dispelMask, DispelChargesList& dispelList, bool isReflect = false) const;
bool HasAuraEffect(uint32 spellId, uint8 effIndex, ObjectGuid caster = ObjectGuid::Empty) const;
uint32 GetAuraCount(uint32 spellId) const;