From b43849a605e6c25fb31adacb10bf418793c4d778 Mon Sep 17 00:00:00 2001 From: Hondacrx Date: Sun, 10 Aug 2025 12:40:04 -0400 Subject: [PATCH] Core/Spells: Merge Spell::SetSpellValue overloads Port From (https://github.com/TrinityCore/TrinityCore/commit/e57b0296d65446e358ead632750c4ae0c5249631) --- Source/Game/Entities/Object/WorldObject.cs | 9 ++---- Source/Game/Spells/Spell.cs | 33 ++++++++++------------ Source/Scripts/Spells/Monk.cs | 2 +- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/Source/Game/Entities/Object/WorldObject.cs b/Source/Game/Entities/Object/WorldObject.cs index a63c6fc98..7946a30c7 100644 --- a/Source/Game/Entities/Object/WorldObject.cs +++ b/Source/Game/Entities/Object/WorldObject.cs @@ -2558,13 +2558,8 @@ namespace Game.Entities } Spell spell = new(this, info, args.TriggerFlags, args.OriginalCaster, args.OriginalCastId); - foreach (var spellOverride in args.SpellValueOverrides) - { - if (spellOverride.Type < (int)SpellValueMod.IntEnd) - spell.SetSpellValue((SpellValueMod)spellOverride.Type, spellOverride.IntValue); - else - spell.SetSpellValue((SpellValueModFloat)spellOverride.Type, spellOverride.FloatValue); - } + foreach (var value in args.SpellValueOverrides) + spell.SetSpellValue(value); spell.m_CastItem = args.CastItem; if (args.OriginalCastItemLevel.HasValue) diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 4d54e22e4..6b0f8b467 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -7827,47 +7827,44 @@ namespace Game.Spells return SpellCastResult.SpellCastOk; } - public void SetSpellValue(SpellValueMod mod, int value) + public void SetSpellValue(CastSpellExtraArgsInit.SpellValueOverride value) { - if (mod < SpellValueMod.IntEnd) + if (value.Type >= (int)SpellValueMod.BasePoint0 && value.Type < (int)SpellValueMod.BasePointEnd) { - m_spellValue.EffectBasePoints[(int)mod] = value; - m_spellValue.CustomBasePointsMask |= 1u << (int)mod; + m_spellValue.EffectBasePoints[value.Type - (int)SpellValueMod.BasePoint0] = value.IntValue; + m_spellValue.CustomBasePointsMask |= 1u << (value.Type - (int)SpellValueMod.BasePoint0); return; } - switch (mod) + switch ((SpellValueMod)value.Type) { case SpellValueMod.MaxTargets: - m_spellValue.MaxAffectedTargets = (uint)value; + m_spellValue.MaxAffectedTargets = (uint)value.IntValue; break; case SpellValueMod.AuraStack: - m_spellValue.AuraStackAmount = value; + m_spellValue.AuraStackAmount = value.IntValue; break; case SpellValueMod.Duration: - m_spellValue.Duration = value; + m_spellValue.Duration = value.IntValue; break; case SpellValueMod.ParentSpellTargetCount: - m_spellValue.ParentSpellTargetCount = value; + m_spellValue.ParentSpellTargetCount = value.IntValue; break; case SpellValueMod.ParentSpellTargetIndex: - m_spellValue.ParentSpellTargetIndex = value; + m_spellValue.ParentSpellTargetIndex = value.IntValue; break; } - } - public void SetSpellValue(SpellValueModFloat mod, float value) - { - switch (mod) - { + switch ((SpellValueModFloat)value.Type) + { case SpellValueModFloat.RadiusMod: - m_spellValue.RadiusMod = value; + m_spellValue.RadiusMod = value.FloatValue; break; case SpellValueModFloat.CritChance: - m_spellValue.CriticalChance = value; + m_spellValue.CriticalChance = value.FloatValue; break; case SpellValueModFloat.DurationPct: - m_spellValue.DurationMul = value / 100.0f; + m_spellValue.DurationMul = value.FloatValue / 100.0f; break; default: break; diff --git a/Source/Scripts/Spells/Monk.cs b/Source/Scripts/Spells/Monk.cs index 8e0c7d596..6b7e227f3 100644 --- a/Source/Scripts/Spells/Monk.cs +++ b/Source/Scripts/Spells/Monk.cs @@ -136,7 +136,7 @@ namespace Scripts.Spells.Monk calmingCoalescence.GetBase().Remove(); } - GetSpell().SetSpellValue(SpellValueMod.BasePoint0, absorb); + GetSpell().SetSpellValue(new((int)SpellValueMod.BasePoint0, absorb)); } public override void Register()