Core/Spells: relocated DieSides handling - fall back to DieSides when Variance is not provided

This commit is contained in:
Ovahlord
2024-05-31 22:00:37 +02:00
parent 98f5c121d2
commit b23ebaa00c

View File

@@ -504,7 +504,7 @@ int32 SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, int32
if (caster)
casterUnit = caster->ToUnit();
if (Scaling.Variance)
if (Scaling.Variance != 0.0f)
{
float delta = fabs(Scaling.Variance * 0.5f);
double valueVariance = frand(-delta, delta);
@@ -513,6 +513,17 @@ int32 SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, int32
if (variance)
*variance = valueVariance;
}
else
{
if (DieSides)
{
// roll in a range <1;EffectDieSides> as of patch 3.3.3
if (DieSides == 1)
value += DieSides;
else
value += (DieSides >= 1) ? irand(1, DieSides) : irand(DieSides, 1);
}
}
// base amount modification based on spell lvl vs caster lvl
if (Scaling.Coefficient != 0.0f)
@@ -534,15 +545,6 @@ int32 SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, int32
level = 0;
value += level * basePointsPerLevel;
}
if (DieSides)
{
// roll in a range <1;EffectDieSides> as of patch 3.3.3
if (DieSides == 1)
value += DieSides;
else
value += (DieSides >= 1) ? irand(1, DieSides) : irand(DieSides, 1);
}
}
// random damage