mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-26 03:42:37 +01:00
Core/Spells: Improved spell value calculation - variance will not be applied to spells with forced basepoints from CastCustomSpell
This commit is contained in:
@@ -461,10 +461,57 @@ 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;
|
||||
@@ -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;
|
||||
int32 level = caster ? int32(caster->getLevel()) : 1;
|
||||
value = sDB2Manager.EvaluateExpectedStat(stat, level, -2, 0, CLASS_NONE) * BasePoints / 100.0f;
|
||||
}
|
||||
|
||||
if (Scaling.Variance)
|
||||
{
|
||||
float delta = fabs(Scaling.Variance * 0.5f);
|
||||
float valueVariance = frand(-delta, delta);
|
||||
value += value * valueVariance;
|
||||
|
||||
if (variance)
|
||||
*variance = valueVariance;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user