Core/Spells: Changed SpellEffectInfo::CalcBaseValue return type to double
Signed-off-by: luis <[email protected]>
This commit is contained in:
@@ -1727,7 +1727,7 @@ float WorldObject::GetSpellMinRangeForTarget(Unit const* target, SpellInfo const
|
||||
return spellInfo->GetMinRange(!IsHostileTo(target));
|
||||
}
|
||||
|
||||
double WorldObject::ApplyEffectModifiers(SpellInfo const* spellInfo, uint8 effIndex, double value) const
|
||||
SpellEffectValue WorldObject::ApplyEffectModifiers(SpellInfo const* spellInfo, uint8 effIndex, SpellEffectValue value) const
|
||||
{
|
||||
if (Player* modOwner = GetSpellModOwner())
|
||||
{
|
||||
|
||||
@@ -471,7 +471,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
float GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const;
|
||||
float GetSpellMinRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const;
|
||||
|
||||
double ApplyEffectModifiers(SpellInfo const* spellInfo, uint8 effIndex, double value) const;
|
||||
SpellEffectValue ApplyEffectModifiers(SpellInfo const* spellInfo, uint8 effIndex, SpellEffectValue value) const;
|
||||
int32 CalcSpellDuration(SpellInfo const* spellInfo, std::vector<SpellPowerCost> const* powerCosts) const;
|
||||
int32 ModSpellDuration(SpellInfo const* spellInfo, WorldObject const* target, int32 duration, bool positive, uint32 effectMask) const;
|
||||
void ModSpellCastTime(SpellInfo const* spellInfo, int32& castTime, Spell* spell = nullptr) const;
|
||||
|
||||
@@ -6784,10 +6784,9 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32
|
||||
|
||||
if (spellEffectInfo.Effect == SPELL_EFFECT_CHANGE_BATTLEPET_QUALITY)
|
||||
{
|
||||
auto qualityItr = std::lower_bound(sBattlePetBreedQualityStore.begin(), sBattlePetBreedQualityStore.end(), spellEffectInfo.CalcBaseValue(m_caster, creature, m_castItemEntry, m_castItemLevel), [](BattlePetBreedQualityEntry const* a1, int32 selector)
|
||||
{
|
||||
return a1->MaxQualityRoll < selector;
|
||||
});
|
||||
auto qualityItr = std::ranges::lower_bound(sBattlePetBreedQualityStore,
|
||||
spellEffectInfo.CalcBaseValue(m_caster, creature, m_castItemEntry, m_castItemLevel), {},
|
||||
&BattlePetBreedQualityEntry::MaxQualityRoll);
|
||||
|
||||
BattlePets::BattlePetBreedQuality quality = BattlePets::BattlePetBreedQuality::Poor;
|
||||
if (qualityItr != sBattlePetBreedQualityStore.end())
|
||||
|
||||
@@ -480,6 +480,9 @@ struct TC_GAME_API CastSpellTargetArg
|
||||
Optional<SpellCastTargets> Targets; // empty optional used to signal error state
|
||||
};
|
||||
|
||||
//! Spell effect value calculation result type.
|
||||
using SpellEffectValue = double; //!< This is a double instead of float to be able to store full range of int32
|
||||
|
||||
struct CastSpellExtraArgsInit
|
||||
{
|
||||
TriggerCastFlags TriggerFlags = TRIGGERED_NONE;
|
||||
|
||||
@@ -514,11 +514,10 @@ uint32 SpellEffectInfo::GetPeriodicTickCount() const
|
||||
|
||||
int32 SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, int32 const* bp /*= nullptr*/, Unit const* target /*= nullptr*/, float* variance /*= nullptr*/, uint32 castItemId /*= 0*/, int32 itemLevel /*= -1*/) const
|
||||
{
|
||||
double basePointsPerLevel = RealPointsPerLevel;
|
||||
// TODO: this needs to be a float, not rounded
|
||||
int32 basePoints = CalcBaseValue(caster, target, castItemId, itemLevel);
|
||||
double value = bp ? *bp : basePoints;
|
||||
double comboDamage = PointsPerResource;
|
||||
SpellEffectValue basePoints = CalcBaseValue(caster, target, castItemId, itemLevel);
|
||||
SpellEffectValue value = bp ? *bp : basePoints;
|
||||
SpellEffectValue basePointsPerLevel = RealPointsPerLevel;
|
||||
SpellEffectValue comboDamage = PointsPerResource;
|
||||
|
||||
Unit const* casterUnit = nullptr;
|
||||
if (caster)
|
||||
@@ -555,8 +554,8 @@ int32 SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, int32
|
||||
if (Scaling.Variance)
|
||||
{
|
||||
float delta = fabs(Scaling.Variance * 0.5f);
|
||||
double valueVariance = frand(-delta, delta);
|
||||
value += double(basePoints) * valueVariance;
|
||||
float valueVariance = frand(-delta, delta);
|
||||
value += basePoints * valueVariance;
|
||||
|
||||
if (variance)
|
||||
*variance = valueVariance;
|
||||
@@ -566,7 +565,7 @@ int32 SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, int32
|
||||
if (Scaling.Coefficient != 0.0f)
|
||||
{
|
||||
if (Scaling.ResourceCoefficient)
|
||||
comboDamage = Scaling.ResourceCoefficient * value;
|
||||
comboDamage = value * Scaling.ResourceCoefficient;
|
||||
}
|
||||
else if (GetScalingExpectedStat() == ExpectedStatType::None)
|
||||
{
|
||||
@@ -578,8 +577,7 @@ int32 SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, int32
|
||||
|
||||
// if base level is greater than spell level, reduce by base level (eg. pilgrims foods)
|
||||
level -= int32(std::max(_spellInfo->BaseLevel, _spellInfo->SpellLevel));
|
||||
if (level < 0)
|
||||
level = 0;
|
||||
level = std::max(level, 0);
|
||||
value += level * basePointsPerLevel;
|
||||
}
|
||||
}
|
||||
@@ -603,7 +601,7 @@ int32 SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, int32
|
||||
return int32(round(value));
|
||||
}
|
||||
|
||||
int32 SpellEffectInfo::CalcBaseValue(WorldObject const* caster, Unit const* target, uint32 itemId, int32 itemLevel) const
|
||||
SpellEffectValue SpellEffectInfo::CalcBaseValue(WorldObject const* caster, Unit const* target, uint32 itemId, int32 itemLevel) const
|
||||
{
|
||||
if (Scaling.Coefficient != 0.0f)
|
||||
{
|
||||
@@ -660,7 +658,7 @@ int32 SpellEffectInfo::CalcBaseValue(WorldObject const* caster, Unit const* targ
|
||||
if (value > 0.0f && value < 1.0f)
|
||||
value = 1.0f;
|
||||
|
||||
return int32(round(value));
|
||||
return round(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -686,7 +684,7 @@ int32 SpellEffectInfo::CalcBaseValue(WorldObject const* caster, Unit const* targ
|
||||
value = sDB2Manager.EvaluateExpectedStat(stat, level, expansion, 0, CLASS_NONE, 0) * BasePoints / 100.0f;
|
||||
}
|
||||
|
||||
return int32(round(value));
|
||||
return round(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3625,7 +3623,7 @@ void SpellInfo::_LoadSqrtTargetLimit(int32 maxTargets, int32 numNonDiminishedTar
|
||||
else
|
||||
{
|
||||
SpellEffectInfo const& valueHolder = maxTargetValueHolder->GetEffect(*maxTargetsValueHolderEffect);
|
||||
int32 expectedValue = valueHolder.CalcBaseValue(nullptr, nullptr, 0, -1);
|
||||
int32 expectedValue = int32(valueHolder.CalcBaseValue(nullptr, nullptr, 0, -1));
|
||||
if (maxTargets != expectedValue)
|
||||
TC_LOG_ERROR("spells", "SpellInfo::_LoadSqrtTargetLimit(maxTargets): Spell {} has different value in effect {} than expected, recheck target caps (expected {}, got {})",
|
||||
maxTargetValueHolder->Id, AsUnderlyingType(*maxTargetsValueHolderEffect), maxTargets, expectedValue);
|
||||
@@ -3646,7 +3644,7 @@ void SpellInfo::_LoadSqrtTargetLimit(int32 maxTargets, int32 numNonDiminishedTar
|
||||
else
|
||||
{
|
||||
SpellEffectInfo const& valueHolder = numNonDiminishedTargetsValueHolder->GetEffect(*numNonDiminishedTargetsValueHolderEffect);
|
||||
int32 expectedValue = valueHolder.CalcBaseValue(nullptr, nullptr, 0, -1);
|
||||
int32 expectedValue = int32(valueHolder.CalcBaseValue(nullptr, nullptr, 0, -1));
|
||||
if (numNonDiminishedTargets != expectedValue)
|
||||
TC_LOG_ERROR("spells", "SpellInfo::_LoadSqrtTargetLimit(numNonDiminishedTargets): Spell {} has different value in effect {} than expected, recheck target caps (expected {}, got {})",
|
||||
numNonDiminishedTargetsValueHolder->Id, AsUnderlyingType(*numNonDiminishedTargetsValueHolderEffect), numNonDiminishedTargets, expectedValue);
|
||||
|
||||
@@ -264,7 +264,7 @@ public:
|
||||
uint32 GetPeriodicTickCount() const;
|
||||
|
||||
int32 CalcValue(WorldObject const* caster = nullptr, int32 const* basePoints = nullptr, Unit const* target = nullptr, float* variance = nullptr, uint32 castItemId = 0, int32 itemLevel = -1) const;
|
||||
int32 CalcBaseValue(WorldObject const* caster, Unit const* target, uint32 itemId, int32 itemLevel) const;
|
||||
SpellEffectValue CalcBaseValue(WorldObject const* caster, Unit const* target, uint32 itemId, int32 itemLevel) const;
|
||||
float CalcValueMultiplier(WorldObject* caster, Spell* spell = nullptr) const;
|
||||
float CalcDamageMultiplier(WorldObject* caster, Spell* spell = nullptr) const;
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ public:
|
||||
{
|
||||
return ValidateSpellInfo({ SPELL_DK_BONE_SHIELD })
|
||||
&& ValidateSpellEffect({ { spellInfo->Id, _effIndex } })
|
||||
&& spellInfo->GetEffect(_effIndex).CalcBaseValue(nullptr, nullptr, 0, 0) <= int32(sSpellMgr->AssertSpellInfo(SPELL_DK_BONE_SHIELD, DIFFICULTY_NONE)->StackAmount);
|
||||
&& spellInfo->GetEffect(_effIndex).CalcBaseValue(nullptr, nullptr, 0, 0) <= SpellEffectValue(sSpellMgr->AssertSpellInfo(SPELL_DK_BONE_SHIELD, DIFFICULTY_NONE)->StackAmount);
|
||||
}
|
||||
|
||||
void HandleHitTarget(SpellEffIndex /*effIndex*/) const
|
||||
|
||||
@@ -666,7 +666,7 @@ class spell_mage_ethereal_blink_triggered : public SpellScript
|
||||
if (AuraEffect const* effectivenessEffect = GetCaster()->GetAuraEffect(SPELL_MAGE_ETHEREAL_BLINK, EFFECT_1))
|
||||
effectivenessPct = effectivenessEffect->GetAmount();
|
||||
|
||||
int32 slowPct = sSpellMgr->AssertSpellInfo(SPELL_MAGE_SLOW, DIFFICULTY_NONE)->GetEffect(EFFECT_0).CalcBaseValue(GetCaster(), GetHitUnit(), 0, -1);
|
||||
SpellEffectValue slowPct = sSpellMgr->AssertSpellInfo(SPELL_MAGE_SLOW, DIFFICULTY_NONE)->GetEffect(EFFECT_0).CalcBaseValue(GetCaster(), GetHitUnit(), 0, -1);
|
||||
ApplyPct(slowPct, effectivenessPct);
|
||||
|
||||
GetCaster()->CastSpell(GetHitUnit(), SPELL_MAGE_SLOW, CastSpellExtraArgs(GetSpell())
|
||||
|
||||
Reference in New Issue
Block a user