mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 03:32:28 -04:00
Core/Auras: Split SpellModifierByClassMask into separate flat/pct types
This commit is contained in:
@@ -22734,7 +22734,7 @@ void Player::GetSpellModValues(SpellInfo const* spellInfo, SpellModOp op, Spell*
|
||||
if (!IsAffectedBySpellmod(spellInfo, mod, spell))
|
||||
continue;
|
||||
|
||||
if (base < 10000.0 && static_cast<SpellModifierByClassMask*>(mod)->value <= -100)
|
||||
if (base < 10000.0 && static_cast<SpellPctModifierByClassMask*>(mod)->value <= -100)
|
||||
{
|
||||
modInstantSpell = mod;
|
||||
break;
|
||||
@@ -22773,7 +22773,7 @@ void Player::GetSpellModValues(SpellInfo const* spellInfo, SpellModOp op, Spell*
|
||||
if (!IsAffectedBySpellmod(spellInfo, mod, spell))
|
||||
continue;
|
||||
|
||||
if (static_cast<SpellModifierByClassMask*>(mod)->value >= 100)
|
||||
if (static_cast<SpellFlatModifierByClassMask*>(mod)->value >= 100)
|
||||
{
|
||||
modCritical = mod;
|
||||
break;
|
||||
@@ -22813,7 +22813,7 @@ void Player::GetSpellModValues(SpellInfo const* spellInfo, SpellModOp op, Spell*
|
||||
if (!applyCount)
|
||||
continue;
|
||||
|
||||
int32 value = static_cast<SpellModifierByClassMask*>(mod)->value;
|
||||
int32 value = static_cast<SpellFlatModifierByClassMask*>(mod)->value;
|
||||
if (value == 0)
|
||||
continue;
|
||||
|
||||
@@ -22845,7 +22845,7 @@ void Player::GetSpellModValues(SpellInfo const* spellInfo, SpellModOp op, Spell*
|
||||
if (base + *flat == 0)
|
||||
continue;
|
||||
|
||||
int32 value = static_cast<SpellModifierByClassMask*>(mod)->value;
|
||||
int32 value = static_cast<SpellPctModifierByClassMask*>(mod)->value;
|
||||
if (value == 0)
|
||||
continue;
|
||||
|
||||
@@ -22946,7 +22946,7 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply)
|
||||
auto itr = std::ranges::lower_bound(m_spellMods, std::make_pair(mod->op, SPELLMOD_FLAT), std::ranges::less(), [](SpellModifier const* sm) { return std::make_pair(sm->op, sm->type); });
|
||||
while (itr != m_spellMods.end() && (*itr)->op == mod->op && (*itr)->type == SPELLMOD_FLAT)
|
||||
{
|
||||
SpellModifierByClassMask const* spellMod = static_cast<SpellModifierByClassMask const*>(*itr++);
|
||||
SpellFlatModifierByClassMask const* spellMod = static_cast<SpellFlatModifierByClassMask const*>(*itr++);
|
||||
if (spellMod->mask[classIndex / 32] & (1u << (classIndex % 32)))
|
||||
modData.ModifierValue += spellMod->value;
|
||||
}
|
||||
@@ -22957,7 +22957,7 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply)
|
||||
auto itr = std::ranges::lower_bound(m_spellMods, std::make_pair(mod->op, SPELLMOD_PCT), std::ranges::less(), [](SpellModifier const* sm) { return std::make_pair(sm->op, sm->type); });
|
||||
while (itr != m_spellMods.end() && (*itr)->op == mod->op && (*itr)->type == SPELLMOD_PCT)
|
||||
{
|
||||
SpellModifierByClassMask const* spellMod = static_cast<SpellModifierByClassMask const*>(*itr++);
|
||||
SpellPctModifierByClassMask const* spellMod = static_cast<SpellPctModifierByClassMask const*>(*itr++);
|
||||
if (spellMod->mask[classIndex / 32] & (1u << (classIndex % 32)))
|
||||
modData.ModifierValue *= 1.0f + CalculatePct(1.0f, spellMod->value);
|
||||
}
|
||||
@@ -23051,9 +23051,6 @@ void Player::SendSpellModifiers() const
|
||||
|
||||
for (SpellModifier const* mod : m_spellMods)
|
||||
{
|
||||
if (mod->type != SPELLMOD_FLAT && mod->type != SPELLMOD_PCT)
|
||||
continue;
|
||||
|
||||
switch (mod->type)
|
||||
{
|
||||
case SPELLMOD_FLAT:
|
||||
@@ -23066,7 +23063,7 @@ void Player::SendSpellModifiers() const
|
||||
for (std::size_t classIndex = mask.find_first(); classIndex != decltype(mask)::npos; classIndex = mask.find_next(classIndex))
|
||||
{
|
||||
float& modifierValue = getOrCreateModifierData(flatModifier->ModifierData, classIndex, 0.0f);
|
||||
modifierValue += static_cast<SpellModifierByClassMask const*>(mod)->value;
|
||||
modifierValue += static_cast<SpellFlatModifierByClassMask const*>(mod)->value;
|
||||
}
|
||||
break;
|
||||
case SPELLMOD_PCT:
|
||||
@@ -23079,7 +23076,7 @@ void Player::SendSpellModifiers() const
|
||||
for (std::size_t classIndex = mask.find_first(); classIndex != decltype(mask)::npos; classIndex = mask.find_next(classIndex))
|
||||
{
|
||||
float& modifierValue = getOrCreateModifierData(pctModifier->ModifierData, classIndex, 1.0f);
|
||||
modifierValue *= 1.0f + CalculatePct(1.0f, static_cast<SpellModifierByClassMask const*>(mod)->value);
|
||||
modifierValue *= 1.0f + CalculatePct(1.0f, static_cast<SpellPctModifierByClassMask const*>(mod)->value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -251,7 +251,8 @@ enum SpecResetType
|
||||
// Spell modifier (used for modify other spells)
|
||||
struct SpellModifier
|
||||
{
|
||||
SpellModifier(Aura* _ownerAura) : op(SpellModOp::HealingAndDamage), type(SPELLMOD_FLAT), spellId(0), ownerAura(_ownerAura) { }
|
||||
SpellModifier(SpellModOp _op, SpellModType _type, uint32 _spellId, Aura* _ownerAura)
|
||||
: op(_op), type(_type), spellId(_spellId), ownerAura(_ownerAura) { }
|
||||
virtual ~SpellModifier() = default;
|
||||
|
||||
SpellModOp op;
|
||||
@@ -263,22 +264,53 @@ struct SpellModifier
|
||||
|
||||
struct SpellModifierByClassMask : SpellModifier
|
||||
{
|
||||
SpellModifierByClassMask(Aura* _ownerAura) : SpellModifier(_ownerAura), value(0), mask() { }
|
||||
SpellModifierByClassMask(SpellModOp _op, SpellModType _type, uint32 _spellId, Aura* _ownerAura, flag128 const& _mask)
|
||||
: SpellModifier(_op, _type, _spellId, _ownerAura), mask(_mask) { }
|
||||
|
||||
int32 value;
|
||||
flag128 mask;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct SpellModifierByLabel : SpellModifier
|
||||
struct SpellFlatModifierByClassMask : SpellModifierByClassMask
|
||||
{
|
||||
SpellModifierByLabel(Aura* _ownerAura) : SpellModifier(_ownerAura) { }
|
||||
SpellFlatModifierByClassMask(SpellModOp _op, uint32 _spellId, Aura* _ownerAura, flag128 _mask)
|
||||
: SpellModifierByClassMask(_op, SPELLMOD_FLAT, _spellId, _ownerAura, _mask) { }
|
||||
|
||||
T value;
|
||||
int32 value = { };
|
||||
};
|
||||
|
||||
using SpellFlatModifierByLabel = SpellModifierByLabel<UF::SpellFlatModByLabel>;
|
||||
using SpellPctModifierByLabel = SpellModifierByLabel<UF::SpellPctModByLabel>;
|
||||
struct SpellPctModifierByClassMask : SpellModifierByClassMask
|
||||
{
|
||||
SpellPctModifierByClassMask(SpellModOp _op, uint32 _spellId, Aura* _ownerAura, flag128 _mask)
|
||||
: SpellModifierByClassMask(_op, SPELLMOD_PCT, _spellId, _ownerAura, _mask) { }
|
||||
|
||||
int32 value = { };
|
||||
};
|
||||
|
||||
struct SpellFlatModifierByLabel : SpellModifier
|
||||
{
|
||||
SpellFlatModifierByLabel(SpellModOp _op, uint32 _spellId, Aura* _ownerAura, uint32 _label)
|
||||
: SpellModifier(_op, SPELLMOD_LABEL_FLAT, _spellId, _ownerAura)
|
||||
{
|
||||
value.ModIndex = int32(_op);
|
||||
value.ModifierValue = 0;
|
||||
value.LabelID = _label;
|
||||
}
|
||||
|
||||
UF::SpellFlatModByLabel value = { };
|
||||
};
|
||||
|
||||
struct SpellPctModifierByLabel : SpellModifier
|
||||
{
|
||||
SpellPctModifierByLabel(SpellModOp _op, uint32 _spellId, Aura* _ownerAura, int32 _label)
|
||||
: SpellModifier(_op, SPELLMOD_LABEL_PCT, _spellId, _ownerAura)
|
||||
{
|
||||
value.ModIndex = int32(_op);
|
||||
value.ModifierValue = 0.0f;
|
||||
value.LabelID = _label;
|
||||
}
|
||||
|
||||
UF::SpellPctModByLabel value;
|
||||
};
|
||||
|
||||
struct SpellModifierCompare
|
||||
{
|
||||
|
||||
@@ -1006,45 +1006,23 @@ void AuraEffect::CalculateSpellMod()
|
||||
switch (GetAuraType())
|
||||
{
|
||||
case SPELL_AURA_ADD_FLAT_MODIFIER:
|
||||
if (!m_spellmod)
|
||||
m_spellmod = new SpellFlatModifierByClassMask(SpellModOp(GetMiscValue()), GetId(), GetBase(), GetSpellEffectInfo().SpellClassMask);
|
||||
static_cast<SpellFlatModifierByClassMask*>(m_spellmod)->value = GetAmount();
|
||||
break;
|
||||
case SPELL_AURA_ADD_PCT_MODIFIER:
|
||||
if (!m_spellmod)
|
||||
{
|
||||
SpellModifierByClassMask* spellmod = new SpellModifierByClassMask(GetBase());
|
||||
spellmod->op = SpellModOp(GetMiscValue());
|
||||
|
||||
spellmod->type = GetAuraType() == SPELL_AURA_ADD_PCT_MODIFIER ? SPELLMOD_PCT : SPELLMOD_FLAT;
|
||||
spellmod->spellId = GetId();
|
||||
spellmod->mask = GetSpellEffectInfo().SpellClassMask;
|
||||
m_spellmod = spellmod;
|
||||
}
|
||||
static_cast<SpellModifierByClassMask*>(m_spellmod)->value = GetAmount();
|
||||
m_spellmod = new SpellPctModifierByClassMask(SpellModOp(GetMiscValue()), GetId(), GetBase(), GetSpellEffectInfo().SpellClassMask);
|
||||
static_cast<SpellPctModifierByClassMask*>(m_spellmod)->value = GetAmount();
|
||||
break;
|
||||
case SPELL_AURA_ADD_FLAT_MODIFIER_BY_SPELL_LABEL:
|
||||
if (!m_spellmod)
|
||||
{
|
||||
SpellFlatModifierByLabel* spellmod = new SpellFlatModifierByLabel(GetBase());
|
||||
spellmod->op = SpellModOp(GetMiscValue());
|
||||
|
||||
spellmod->type = SPELLMOD_LABEL_FLAT;
|
||||
spellmod->spellId = GetId();
|
||||
spellmod->value.ModIndex = GetMiscValue();
|
||||
spellmod->value.LabelID = GetMiscValueB();
|
||||
m_spellmod = spellmod;
|
||||
}
|
||||
m_spellmod = new SpellFlatModifierByLabel(SpellModOp(GetMiscValue()), GetId(), GetBase(), GetMiscValueB());
|
||||
static_cast<SpellFlatModifierByLabel*>(m_spellmod)->value.ModifierValue = GetAmount();
|
||||
break;
|
||||
case SPELL_AURA_ADD_PCT_MODIFIER_BY_SPELL_LABEL:
|
||||
if (!m_spellmod)
|
||||
{
|
||||
SpellPctModifierByLabel* spellmod = new SpellPctModifierByLabel(GetBase());
|
||||
spellmod->op = SpellModOp(GetMiscValue());
|
||||
|
||||
spellmod->type = SPELLMOD_LABEL_PCT;
|
||||
spellmod->spellId = GetId();
|
||||
spellmod->value.ModIndex = GetMiscValue();
|
||||
spellmod->value.LabelID = GetMiscValueB();
|
||||
m_spellmod = spellmod;
|
||||
}
|
||||
m_spellmod = new SpellPctModifierByLabel(SpellModOp(GetMiscValue()), GetId(), GetBase(), GetMiscValueB());
|
||||
static_cast<SpellPctModifierByLabel*>(m_spellmod)->value.ModifierValue = 1.0f + CalculatePct(1.0f, GetAmount());
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -2311,12 +2311,8 @@ class spell_dh_soul_furnace_conduit : public AuraScript
|
||||
{
|
||||
if (!spellMod)
|
||||
{
|
||||
spellMod = new SpellModifierByClassMask(GetAura());
|
||||
spellMod->op = SpellModOp::HealingAndDamage;
|
||||
spellMod->type = SPELLMOD_PCT;
|
||||
spellMod->spellId = GetId();
|
||||
static_cast<SpellModifierByClassMask*>(spellMod)->mask = flag128(0x80000000);
|
||||
static_cast<SpellModifierByClassMask*>(spellMod)->value = GetEffect(EFFECT_1)->GetAmount() + 1;
|
||||
spellMod = new SpellPctModifierByClassMask(SpellModOp::HealingAndDamage, GetId(), GetAura(), flag128(0x80000000));
|
||||
static_cast<SpellPctModifierByClassMask*>(spellMod)->value = GetEffect(EFFECT_1)->GetAmount() + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1322,20 +1322,12 @@ class spell_sha_hailstorm : public AuraScript
|
||||
void CalcCleaveMod(AuraEffect const* aurEff, SpellModifier*& spellMod) const
|
||||
{
|
||||
if (!spellMod)
|
||||
{
|
||||
SpellModifierByClassMask* mod = new SpellModifierByClassMask(GetAura());
|
||||
mod->op = SpellModOp::ChainTargets;
|
||||
mod->type = SPELLMOD_FLAT;
|
||||
mod->spellId = GetId();
|
||||
mod->mask = { 0x80000000, 0x00000000, 0x00000000, 0x00000000 };
|
||||
|
||||
spellMod = mod;
|
||||
}
|
||||
spellMod = new SpellFlatModifierByClassMask(SpellModOp::ChainTargets, GetId(), GetAura(), { 0x80000000, 0x00000000, 0x00000000, 0x00000000 });
|
||||
|
||||
if (AuraEffect const* hailstormPassive = GetUnitOwner()->GetAuraEffect(SPELL_SHAMAN_HAILSTORM_TALENT, EFFECT_0))
|
||||
{
|
||||
int32 targetCap = hailstormPassive->GetAmount() / aurEff->GetBaseAmount();
|
||||
static_cast<SpellModifierByClassMask*>(spellMod)->value = std::min<int32>(targetCap, GetStackAmount()) + 1;
|
||||
static_cast<SpellFlatModifierByClassMask*>(spellMod)->value = std::min<int32>(targetCap, GetStackAmount()) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user