diff options
Diffstat (limited to 'src/server/game/Spells/SpellInfo.cpp')
| -rw-r--r-- | src/server/game/Spells/SpellInfo.cpp | 112 |
1 files changed, 53 insertions, 59 deletions
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index cc39622cc41..d1ae93cd318 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -461,12 +461,59 @@ bool SpellEffectInfo::IsUnitOwnedAuraEffect() const int32 SpellEffectInfo::CalcValue(Unit const* caster /*= nullptr*/, int32 const* bp /*= nullptr*/, Unit const* target /*= nullptr*/, float* variance /*= nullptr*/, int32 itemLevel /*= -1*/) const { float basePointsPerLevel = RealPointsPerLevel; - int32 basePoints = bp ? *bp : BasePoints; + // TODO: this needs to be a float, not rounded + int32 basePoints = CalcBaseValue(caster, target, itemLevel); + float value = bp ? *bp : basePoints; float comboDamage = PointsPerResource; + if (Scaling.Variance) + { + float delta = fabs(Scaling.Variance * 0.5f); + float valueVariance = frand(-delta, delta); + value += basePoints * valueVariance; + + if (variance) + *variance = valueVariance; + } + // base amount modification based on spell lvl vs caster lvl if (Scaling.Coefficient != 0.0f) { + if (Scaling.ResourceCoefficient) + comboDamage = Scaling.ResourceCoefficient * value; + } + else + { + if (GetScalingExpectedStat() == ExpectedStatType::None) + { + int32 level = caster ? int32(caster->getLevel()) : 0; + if (level > int32(_spellInfo->MaxLevel) && _spellInfo->MaxLevel > 0) + level = int32(_spellInfo->MaxLevel); + level -= int32(_spellInfo->BaseLevel); + if (level < 0) + level = 0; + value += level * basePointsPerLevel; + } + } + + // random damage + if (caster) + { + // bonus amount from combo points + if (caster->m_playerMovingMe && comboDamage) + if (uint32 comboPoints = caster->m_playerMovingMe->GetComboPoints()) + value += comboDamage * comboPoints; + + value = caster->ApplyEffectModifiers(_spellInfo, EffectIndex, value); + } + + return int32(round(value)); +} + +int32 SpellEffectInfo::CalcBaseValue(Unit const* caster, Unit const* target, int32 itemLevel) const +{ + if (Scaling.Coefficient != 0.0f) + { uint32 level = _spellInfo->SpellLevel; if (target && _spellInfo->IsPositiveEffect(EffectIndex) && (Effect == SPELL_EFFECT_APPLY_AURA)) level = target->getLevel(); @@ -520,25 +567,11 @@ int32 SpellEffectInfo::CalcValue(Unit const* caster /*= nullptr*/, int32 const* if (value != 0.0f && value < 1.0f) value = 1.0f; - if (Scaling.Variance) - { - float delta = fabs(Scaling.Variance * 0.5f); - float valueVariance = frand(-delta, delta); - value += value * valueVariance; - - if (variance) - *variance = valueVariance; - } - - basePoints = int32(round(value)); - - if (Scaling.ResourceCoefficient) - comboDamage = Scaling.ResourceCoefficient * value; + return int32(round(value)); } else { - int32 level = caster ? int32(caster->getLevel()) : 0; - float value = basePoints; + float value = BasePoints; ExpectedStatType stat = GetScalingExpectedStat(); if (stat != ExpectedStatType::None) { @@ -546,51 +579,12 @@ int32 SpellEffectInfo::CalcValue(Unit const* caster /*= nullptr*/, int32 const* stat = ExpectedStatType::CreatureAutoAttackDps; // TODO - add expansion and content tuning id args? - value = sDB2Manager.EvaluateExpectedStat(stat, level, -2, 0, CLASS_NONE) * value / 100.0f; - } - - if (Scaling.Variance) - { - float delta = fabs(Scaling.Variance * 0.5f); - float valueVariance = frand(-delta, delta); - value += value * valueVariance; - - if (variance) - *variance = valueVariance; + int32 level = caster ? int32(caster->getLevel()) : 1; + value = sDB2Manager.EvaluateExpectedStat(stat, level, -2, 0, CLASS_NONE) * BasePoints / 100.0f; } - if (stat == ExpectedStatType::None) - { - if (level > int32(_spellInfo->MaxLevel) && _spellInfo->MaxLevel > 0) - level = int32(_spellInfo->MaxLevel); - level -= int32(_spellInfo->BaseLevel); - if (level < 0) - level = 0; - value += level * basePointsPerLevel; - } - - basePoints = int32(round(value)); + return int32(round(value)); } - - float value = float(basePoints); - - // random damage - if (caster) - { - // bonus amount from combo points - if (caster->m_playerMovingMe && comboDamage) - if (uint32 comboPoints = caster->m_playerMovingMe->GetComboPoints()) - value += comboDamage * comboPoints; - - value = caster->ApplyEffectModifiers(_spellInfo, EffectIndex, value); - } - - return int32(value); -} - -int32 SpellEffectInfo::CalcBaseValue(int32 value) const -{ - return value; } float SpellEffectInfo::CalcValueMultiplier(Unit* caster, Spell* spell) const |
