Core/Auras: Implement stacking interaction between SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE and SPELL_GROUP_STACK_RULE_EXCLUSIVE_SAME_EFFECT. Allows BoK/BoS to stack while maintaining the strongest buff
This commit is contained in:
@@ -17761,7 +17761,7 @@ void Unit::BuildCooldownPacket(WorldPacket& data, uint8 flags, PacketCooldowns c
|
||||
}
|
||||
}
|
||||
|
||||
int32 Unit::GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEff, AuraType auraType, bool sameMiscValue /*= false*/) const
|
||||
int32 Unit::GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEff, AuraType auraType, bool checkMiscValue /*= false*/, int32 miscValue /*= 0*/) const
|
||||
{
|
||||
int32 val = 0;
|
||||
SpellSpellGroupMapBounds spellGroup = sSpellMgr->GetSpellSpellGroupMapBounds(aurEff->GetSpellInfo()->GetFirstRankSpell()->Id);
|
||||
@@ -17772,7 +17772,7 @@ int32 Unit::GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEf
|
||||
AuraEffectList const& auraEffList = GetAuraEffectsByType(auraType);
|
||||
for (AuraEffectList::const_iterator auraItr = auraEffList.begin(); auraItr != auraEffList.end(); ++auraItr)
|
||||
{
|
||||
if (aurEff != (*auraItr) && (!sameMiscValue || aurEff->GetMiscValue() == (*auraItr)->GetMiscValue()) &&
|
||||
if (aurEff != (*auraItr) && (!checkMiscValue || (*auraItr)->GetMiscValue() == miscValue) &&
|
||||
sSpellMgr->IsSpellMemberOfSpellGroup((*auraItr)->GetSpellInfo()->Id, itr->second))
|
||||
{
|
||||
// absolute value only
|
||||
|
||||
@@ -2155,7 +2155,7 @@ class Unit : public WorldObject
|
||||
time_t GetLastDamagedTime() const { return _lastDamagedTime; }
|
||||
void SetLastDamagedTime(time_t val) { _lastDamagedTime = val; }
|
||||
|
||||
int32 GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEff, AuraType auraType, bool sameMiscValue = false) const;
|
||||
int32 GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEff, AuraType auraType, bool checkMiscValue = false, int32 miscValue = 0) const;
|
||||
bool IsHighestExclusiveAura(Aura const* aura, bool removeOtherAuraApplications = false);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -3577,7 +3577,7 @@ void AuraEffect::HandleAuraModStat(AuraApplication const* aurApp, uint8 mode, bo
|
||||
}
|
||||
|
||||
Unit* target = aurApp->GetTarget();
|
||||
int32 spellGroupVal = target->GetHighestExclusiveSameEffectSpellGroupValue(this, SPELL_AURA_MOD_STAT, true);
|
||||
int32 spellGroupVal = target->GetHighestExclusiveSameEffectSpellGroupValue(this, SPELL_AURA_MOD_STAT, true, GetMiscValue());
|
||||
if (abs(spellGroupVal) >= abs(GetAmount()))
|
||||
return;
|
||||
|
||||
@@ -3704,14 +3704,30 @@ void AuraEffect::HandleModTotalPercentStat(AuraApplication const* aurApp, uint8
|
||||
if (!(mode & (AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK | AURA_EFFECT_HANDLE_STAT)))
|
||||
return;
|
||||
|
||||
Unit* target = aurApp->GetTarget();
|
||||
|
||||
if (GetMiscValue() < -1 || GetMiscValue() > 4)
|
||||
{
|
||||
TC_LOG_ERROR("spells", "WARNING: Misc Value for SPELL_AURA_MOD_PERCENT_STAT not valid");
|
||||
return;
|
||||
}
|
||||
|
||||
Unit* target = aurApp->GetTarget();
|
||||
int32 spellGroupVal = target->GetHighestExclusiveSameEffectSpellGroupValue(this, SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, true, -1);
|
||||
if (abs(spellGroupVal) >= abs(GetAmount()))
|
||||
return;
|
||||
|
||||
if (spellGroupVal)
|
||||
{
|
||||
for (int32 i = STAT_STRENGTH; i < MAX_STATS; i++)
|
||||
{
|
||||
if (GetMiscValue() == i || GetMiscValue() == -1) // affect the same stats
|
||||
{
|
||||
target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(spellGroupVal), !apply);
|
||||
if (target->GetTypeId() == TYPEID_PLAYER || target->ToCreature()->IsPet())
|
||||
target->ApplyStatPercentBuffMod(Stats(i), float(spellGroupVal), !apply);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// save current health state
|
||||
float healthPct = target->GetHealthPct();
|
||||
bool alive = target->IsAlive();
|
||||
@@ -3720,6 +3736,17 @@ void AuraEffect::HandleModTotalPercentStat(AuraApplication const* aurApp, uint8
|
||||
{
|
||||
if (GetMiscValue() == i || GetMiscValue() == -1)
|
||||
{
|
||||
int32 spellGroupVal2 = target->GetHighestExclusiveSameEffectSpellGroupValue(this, SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, true, i);
|
||||
if (abs(spellGroupVal2) >= abs(GetAmount()))
|
||||
continue;
|
||||
|
||||
if (spellGroupVal2)
|
||||
{
|
||||
target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(spellGroupVal2), !apply);
|
||||
if (target->GetTypeId() == TYPEID_PLAYER || target->ToCreature()->IsPet())
|
||||
target->ApplyStatPercentBuffMod(Stats(i), float(spellGroupVal2), !apply);
|
||||
}
|
||||
|
||||
target->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, float(GetAmount()), apply);
|
||||
if (target->GetTypeId() == TYPEID_PLAYER || target->ToCreature()->IsPet())
|
||||
target->ApplyStatPercentBuffMod(Stats(i), float(GetAmount()), apply);
|
||||
|
||||
Reference in New Issue
Block a user