mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 09:44:45 +01:00
Core/Unit: added GetTotalAuraXXX overloads taking a predicate
This commit is contained in:
@@ -4559,261 +4559,230 @@ uint32 Unit::GetDoTsByCaster(ObjectGuid casterGUID) const
|
||||
return dots;
|
||||
}
|
||||
|
||||
int32 Unit::GetTotalAuraModifier(AuraType auratype) const
|
||||
int32 Unit::GetTotalAuraModifier(AuraType auratype, std::function<bool(AuraEffect const*)> const& predicate) const
|
||||
{
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
if (mTotalAuraList.empty())
|
||||
return 0;
|
||||
|
||||
std::map<SpellGroup, int32> SameEffectSpellGroup;
|
||||
std::map<SpellGroup, int32> sameEffectSpellGroup;
|
||||
int32 modifier = 0;
|
||||
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup))
|
||||
modifier += (*i)->GetAmount();
|
||||
for (AuraEffect const* aurEff : mTotalAuraList)
|
||||
{
|
||||
if (predicate(aurEff))
|
||||
{
|
||||
// Check if the Aura Effect has a the Same Effect Stack Rule and if so, use the highest amount of that SpellGroup
|
||||
// If the Aura Effect does not have this Stack Rule, it returns false so we can add to the multiplier as usual
|
||||
if (!sSpellMgr->AddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), aurEff->GetAmount(), sameEffectSpellGroup))
|
||||
modifier += aurEff->GetAmount();
|
||||
}
|
||||
}
|
||||
|
||||
for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr)
|
||||
// Add the highest of the Same Effect Stack Rule SpellGroups to the accumulator
|
||||
for (auto itr = sameEffectSpellGroup.begin(); itr != sameEffectSpellGroup.end(); ++itr)
|
||||
modifier += itr->second;
|
||||
|
||||
return modifier;
|
||||
}
|
||||
|
||||
float Unit::GetTotalAuraMultiplier(AuraType auratype, std::function<bool(AuraEffect const*)> const& predicate) const
|
||||
{
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
if (mTotalAuraList.empty())
|
||||
return 1.0f;
|
||||
|
||||
std::map<SpellGroup, int32> sameEffectSpellGroup;
|
||||
float multiplier = 1.0f;
|
||||
|
||||
for (AuraEffect const* aurEff : mTotalAuraList)
|
||||
{
|
||||
if (predicate(aurEff))
|
||||
{
|
||||
// Check if the Aura Effect has a the Same Effect Stack Rule and if so, use the highest amount of that SpellGroup
|
||||
// If the Aura Effect does not have this Stack Rule, it returns false so we can add to the multiplier as usual
|
||||
if (!sSpellMgr->AddSameEffectStackRuleSpellGroups(aurEff->GetSpellInfo(), aurEff->GetAmount(), sameEffectSpellGroup))
|
||||
AddPct(multiplier, aurEff->GetAmount());
|
||||
}
|
||||
}
|
||||
|
||||
// Add the highest of the Same Effect Stack Rule SpellGroups to the multiplier
|
||||
for (auto itr = sameEffectSpellGroup.begin(); itr != sameEffectSpellGroup.end(); ++itr)
|
||||
AddPct(multiplier, itr->second);
|
||||
|
||||
return multiplier;
|
||||
}
|
||||
|
||||
int32 Unit::GetMaxPositiveAuraModifier(AuraType auratype, std::function<bool(AuraEffect const*)> const& predicate) const
|
||||
{
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
if (mTotalAuraList.empty())
|
||||
return 0;
|
||||
|
||||
int32 modifier = 0;
|
||||
for (AuraEffect const* aurEff : mTotalAuraList)
|
||||
{
|
||||
if (predicate(aurEff))
|
||||
modifier = std::max(modifier, aurEff->GetAmount());
|
||||
}
|
||||
|
||||
return modifier;
|
||||
}
|
||||
|
||||
int32 Unit::GetMaxNegativeAuraModifier(AuraType auratype, std::function<bool(AuraEffect const*)> const& predicate) const
|
||||
{
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
if (mTotalAuraList.empty())
|
||||
return 0;
|
||||
|
||||
int32 modifier = 0;
|
||||
for (AuraEffect const* aurEff : mTotalAuraList)
|
||||
{
|
||||
if (predicate(aurEff))
|
||||
modifier = std::min(modifier, aurEff->GetAmount());
|
||||
}
|
||||
|
||||
return modifier;
|
||||
}
|
||||
|
||||
int32 Unit::GetTotalAuraModifier(AuraType auratype) const
|
||||
{
|
||||
return GetTotalAuraModifier(auratype, [](AuraEffect const* /*aurEff*/) { return true; });
|
||||
}
|
||||
|
||||
float Unit::GetTotalAuraMultiplier(AuraType auratype) const
|
||||
{
|
||||
float multiplier = 1.0f;
|
||||
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
AddPct(multiplier, (*i)->GetAmount());
|
||||
|
||||
return multiplier;
|
||||
return GetTotalAuraMultiplier(auratype, [](AuraEffect const* /*aurEff*/) { return true; });
|
||||
}
|
||||
|
||||
int32 Unit::GetMaxPositiveAuraModifier(AuraType auratype) const
|
||||
{
|
||||
int32 modifier = 0;
|
||||
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
{
|
||||
if ((*i)->GetAmount() > modifier)
|
||||
modifier = (*i)->GetAmount();
|
||||
}
|
||||
|
||||
return modifier;
|
||||
return GetMaxPositiveAuraModifier(auratype, [](AuraEffect const* /*aurEff*/) { return true; });
|
||||
}
|
||||
|
||||
int32 Unit::GetMaxNegativeAuraModifier(AuraType auratype) const
|
||||
{
|
||||
int32 modifier = 0;
|
||||
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
if ((*i)->GetAmount() < modifier)
|
||||
modifier = (*i)->GetAmount();
|
||||
|
||||
return modifier;
|
||||
return GetMaxNegativeAuraModifier(auratype, [](AuraEffect const* /*aurEff*/) { return true; });
|
||||
}
|
||||
|
||||
int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 miscMask) const
|
||||
{
|
||||
std::map<SpellGroup, int32> SameEffectSpellGroup;
|
||||
int32 modifier = 0;
|
||||
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
if ((*i)->GetMiscValue() & miscMask)
|
||||
if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup))
|
||||
modifier += (*i)->GetAmount();
|
||||
|
||||
for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr)
|
||||
modifier += itr->second;
|
||||
|
||||
return modifier;
|
||||
return GetTotalAuraModifier(auratype, [miscMask](AuraEffect const* aurEff) -> bool
|
||||
{
|
||||
if ((aurEff->GetMiscValue() & miscMask) != 0)
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 miscMask) const
|
||||
{
|
||||
std::map<SpellGroup, int32> SameEffectSpellGroup;
|
||||
float multiplier = 1.0f;
|
||||
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
return GetTotalAuraMultiplier(auratype, [miscMask](AuraEffect const* aurEff) -> bool
|
||||
{
|
||||
if (((*i)->GetMiscValue() & miscMask))
|
||||
{
|
||||
// Check if the Aura Effect has a the Same Effect Stack Rule and if so, use the highest amount of that SpellGroup
|
||||
// If the Aura Effect does not have this Stack Rule, it returns false so we can add to the multiplier as usual
|
||||
if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup))
|
||||
AddPct(multiplier, (*i)->GetAmount());
|
||||
}
|
||||
}
|
||||
// Add the highest of the Same Effect Stack Rule SpellGroups to the multiplier
|
||||
for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr)
|
||||
AddPct(multiplier, itr->second);
|
||||
|
||||
return multiplier;
|
||||
if ((aurEff->GetMiscValue() & miscMask) != 0)
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
int32 Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 miscMask, const AuraEffect* except) const
|
||||
int32 Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 miscMask, AuraEffect const* except /*= nullptr*/) const
|
||||
{
|
||||
int32 modifier = 0;
|
||||
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
return GetMaxPositiveAuraModifier(auratype, [miscMask, except](AuraEffect const* aurEff) -> bool
|
||||
{
|
||||
if (except != (*i) && (*i)->GetMiscValue()& miscMask && (*i)->GetAmount() > modifier)
|
||||
modifier = (*i)->GetAmount();
|
||||
}
|
||||
|
||||
return modifier;
|
||||
if (except != aurEff && (aurEff->GetMiscValue() & miscMask) != 0)
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
int32 Unit::GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 miscMask) const
|
||||
{
|
||||
int32 modifier = 0;
|
||||
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
return GetMaxNegativeAuraModifier(auratype, [miscMask](AuraEffect const* aurEff) -> bool
|
||||
{
|
||||
if ((*i)->GetMiscValue()& miscMask && (*i)->GetAmount() < modifier)
|
||||
modifier = (*i)->GetAmount();
|
||||
}
|
||||
|
||||
return modifier;
|
||||
if ((aurEff->GetMiscValue() & miscMask) != 0)
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
int32 Unit::GetTotalAuraModifierByMiscValue(AuraType auratype, int32 miscValue) const
|
||||
{
|
||||
std::map<SpellGroup, int32> SameEffectSpellGroup;
|
||||
int32 modifier = 0;
|
||||
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
return GetTotalAuraModifier(auratype, [miscValue](AuraEffect const* aurEff) -> bool
|
||||
{
|
||||
if ((*i)->GetMiscValue() == miscValue)
|
||||
if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup))
|
||||
modifier += (*i)->GetAmount();
|
||||
}
|
||||
|
||||
for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr)
|
||||
modifier += itr->second;
|
||||
|
||||
return modifier;
|
||||
if (aurEff->GetMiscValue() == miscValue)
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
float Unit::GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 miscValue) const
|
||||
{
|
||||
std::map<SpellGroup, int32> SameEffectSpellGroup;
|
||||
float multiplier = 1.0f;
|
||||
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
return GetTotalAuraMultiplier(auratype, [miscValue](AuraEffect const* aurEff) -> bool
|
||||
{
|
||||
if ((*i)->GetMiscValue() == miscValue)
|
||||
if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup))
|
||||
AddPct(multiplier, (*i)->GetAmount());
|
||||
}
|
||||
|
||||
for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr)
|
||||
AddPct(multiplier, itr->second);
|
||||
|
||||
return multiplier;
|
||||
if (aurEff->GetMiscValue() == miscValue)
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
int32 Unit::GetMaxPositiveAuraModifierByMiscValue(AuraType auratype, int32 miscValue) const
|
||||
{
|
||||
int32 modifier = 0;
|
||||
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
return GetMaxPositiveAuraModifier(auratype, [miscValue](AuraEffect const* aurEff) -> bool
|
||||
{
|
||||
if ((*i)->GetMiscValue() == miscValue && (*i)->GetAmount() > modifier)
|
||||
modifier = (*i)->GetAmount();
|
||||
}
|
||||
|
||||
return modifier;
|
||||
if (aurEff->GetMiscValue() == miscValue)
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
int32 Unit::GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 miscValue) const
|
||||
{
|
||||
int32 modifier = 0;
|
||||
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
return GetMaxNegativeAuraModifier(auratype, [miscValue](AuraEffect const* aurEff) -> bool
|
||||
{
|
||||
if ((*i)->GetMiscValue() == miscValue && (*i)->GetAmount() < modifier)
|
||||
modifier = (*i)->GetAmount();
|
||||
}
|
||||
|
||||
return modifier;
|
||||
if (aurEff->GetMiscValue() == miscValue)
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
int32 Unit::GetTotalAuraModifierByAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const
|
||||
{
|
||||
std::map<SpellGroup, int32> SameEffectSpellGroup;
|
||||
int32 modifier = 0;
|
||||
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
return GetTotalAuraModifier(auratype, [affectedSpell](AuraEffect const* aurEff) -> bool
|
||||
{
|
||||
if ((*i)->IsAffectingSpell(affectedSpell))
|
||||
if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup))
|
||||
modifier += (*i)->GetAmount();
|
||||
}
|
||||
|
||||
for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr)
|
||||
modifier += itr->second;
|
||||
|
||||
return modifier;
|
||||
if (aurEff->IsAffectingSpell(affectedSpell))
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
float Unit::GetTotalAuraMultiplierByAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const
|
||||
{
|
||||
std::map<SpellGroup, int32> SameEffectSpellGroup;
|
||||
float multiplier = 1.0f;
|
||||
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
return GetTotalAuraMultiplier(auratype, [affectedSpell](AuraEffect const* aurEff) -> bool
|
||||
{
|
||||
if ((*i)->IsAffectingSpell(affectedSpell))
|
||||
if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup))
|
||||
AddPct(multiplier, (*i)->GetAmount());
|
||||
}
|
||||
|
||||
for (std::map<SpellGroup, int32>::const_iterator itr = SameEffectSpellGroup.begin(); itr != SameEffectSpellGroup.end(); ++itr)
|
||||
AddPct(multiplier, itr->second);
|
||||
|
||||
return multiplier;
|
||||
if (aurEff->IsAffectingSpell(affectedSpell))
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
int32 Unit::GetMaxPositiveAuraModifierByAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const
|
||||
{
|
||||
int32 modifier = 0;
|
||||
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
return GetMaxPositiveAuraModifier(auratype, [affectedSpell](AuraEffect const* aurEff) -> bool
|
||||
{
|
||||
if ((*i)->IsAffectingSpell(affectedSpell) && (*i)->GetAmount() > modifier)
|
||||
modifier = (*i)->GetAmount();
|
||||
}
|
||||
|
||||
return modifier;
|
||||
if (aurEff->IsAffectingSpell(affectedSpell))
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
int32 Unit::GetMaxNegativeAuraModifierByAffectMask(AuraType auratype, SpellInfo const* affectedSpell) const
|
||||
{
|
||||
int32 modifier = 0;
|
||||
|
||||
AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype);
|
||||
for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i)
|
||||
return GetMaxNegativeAuraModifier(auratype, [affectedSpell](AuraEffect const* aurEff) -> bool
|
||||
{
|
||||
if ((*i)->IsAffectingSpell(affectedSpell) && (*i)->GetAmount() < modifier)
|
||||
modifier = (*i)->GetAmount();
|
||||
}
|
||||
|
||||
return modifier;
|
||||
if (aurEff->IsAffectingSpell(affectedSpell))
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
float Unit::GetResistanceBuffMods(SpellSchools school, bool positive) const
|
||||
|
||||
@@ -1850,9 +1850,14 @@ class TC_GAME_API Unit : public WorldObject
|
||||
int32 GetMaxPositiveAuraModifier(AuraType auratype) const;
|
||||
int32 GetMaxNegativeAuraModifier(AuraType auratype) const;
|
||||
|
||||
int32 GetTotalAuraModifier(AuraType auratype, std::function<bool(AuraEffect const*)> const& predicate) const;
|
||||
float GetTotalAuraMultiplier(AuraType auratype, std::function<bool(AuraEffect const*)> const& predicate) const;
|
||||
int32 GetMaxPositiveAuraModifier(AuraType auratype, std::function<bool(AuraEffect const*)> const& predicate) const;
|
||||
int32 GetMaxNegativeAuraModifier(AuraType auratype, std::function<bool(AuraEffect const*)> const& predicate) const;
|
||||
|
||||
int32 GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const;
|
||||
float GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const;
|
||||
int32 GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask, const AuraEffect* except = NULL) const;
|
||||
int32 GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask, AuraEffect const* except = nullptr) const;
|
||||
int32 GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const;
|
||||
|
||||
int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const;
|
||||
|
||||
Reference in New Issue
Block a user