Core/Spells: Merge Spell::SetSpellValue overloads

Port From (https://github.com/TrinityCore/TrinityCore/commit/e57b0296d65446e358ead632750c4ae0c5249631)
This commit is contained in:
Hondacrx
2025-08-10 12:40:04 -04:00
parent 70f313866f
commit b43849a605
3 changed files with 18 additions and 26 deletions
+2 -7
View File
@@ -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)
+14 -17
View File
@@ -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;
+1 -1
View File
@@ -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()