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); Spell spell = new(this, info, args.TriggerFlags, args.OriginalCaster, args.OriginalCastId);
foreach (var spellOverride in args.SpellValueOverrides) foreach (var value in args.SpellValueOverrides)
{ spell.SetSpellValue(value);
if (spellOverride.Type < (int)SpellValueMod.IntEnd)
spell.SetSpellValue((SpellValueMod)spellOverride.Type, spellOverride.IntValue);
else
spell.SetSpellValue((SpellValueModFloat)spellOverride.Type, spellOverride.FloatValue);
}
spell.m_CastItem = args.CastItem; spell.m_CastItem = args.CastItem;
if (args.OriginalCastItemLevel.HasValue) if (args.OriginalCastItemLevel.HasValue)
+15 -18
View File
@@ -7827,47 +7827,44 @@ namespace Game.Spells
return SpellCastResult.SpellCastOk; 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.EffectBasePoints[value.Type - (int)SpellValueMod.BasePoint0] = value.IntValue;
m_spellValue.CustomBasePointsMask |= 1u << (int)mod; m_spellValue.CustomBasePointsMask |= 1u << (value.Type - (int)SpellValueMod.BasePoint0);
return; return;
} }
switch (mod) switch ((SpellValueMod)value.Type)
{ {
case SpellValueMod.MaxTargets: case SpellValueMod.MaxTargets:
m_spellValue.MaxAffectedTargets = (uint)value; m_spellValue.MaxAffectedTargets = (uint)value.IntValue;
break; break;
case SpellValueMod.AuraStack: case SpellValueMod.AuraStack:
m_spellValue.AuraStackAmount = value; m_spellValue.AuraStackAmount = value.IntValue;
break; break;
case SpellValueMod.Duration: case SpellValueMod.Duration:
m_spellValue.Duration = value; m_spellValue.Duration = value.IntValue;
break; break;
case SpellValueMod.ParentSpellTargetCount: case SpellValueMod.ParentSpellTargetCount:
m_spellValue.ParentSpellTargetCount = value; m_spellValue.ParentSpellTargetCount = value.IntValue;
break; break;
case SpellValueMod.ParentSpellTargetIndex: case SpellValueMod.ParentSpellTargetIndex:
m_spellValue.ParentSpellTargetIndex = value; m_spellValue.ParentSpellTargetIndex = value.IntValue;
break; break;
} }
}
public void SetSpellValue(SpellValueModFloat mod, float value) switch ((SpellValueModFloat)value.Type)
{ {
switch (mod)
{
case SpellValueModFloat.RadiusMod: case SpellValueModFloat.RadiusMod:
m_spellValue.RadiusMod = value; m_spellValue.RadiusMod = value.FloatValue;
break; break;
case SpellValueModFloat.CritChance: case SpellValueModFloat.CritChance:
m_spellValue.CriticalChance = value; m_spellValue.CriticalChance = value.FloatValue;
break; break;
case SpellValueModFloat.DurationPct: case SpellValueModFloat.DurationPct:
m_spellValue.DurationMul = value / 100.0f; m_spellValue.DurationMul = value.FloatValue / 100.0f;
break; break;
default: default:
break; break;
+1 -1
View File
@@ -136,7 +136,7 @@ namespace Scripts.Spells.Monk
calmingCoalescence.GetBase().Remove(); calmingCoalescence.GetBase().Remove();
} }
GetSpell().SetSpellValue(SpellValueMod.BasePoint0, absorb); GetSpell().SetSpellValue(new((int)SpellValueMod.BasePoint0, absorb));
} }
public override void Register() public override void Register()