diff --git a/Source/Framework/Constants/UnitConst.cs b/Source/Framework/Constants/UnitConst.cs index d7df14be9..981b9e5dd 100644 --- a/Source/Framework/Constants/UnitConst.cs +++ b/Source/Framework/Constants/UnitConst.cs @@ -401,15 +401,21 @@ namespace Framework.Constants BasePoint29, BasePoint30, BasePoint31, - End, - RadiusMod, - MaxTargets, + BasePointEnd, + + MaxTargets = BasePointEnd, AuraStack, - CritChance, - DurationPct, Duration, ParentSpellTargetCount, - ParentSpellTargetIndex + ParentSpellTargetIndex, + IntEnd, + } + + public enum SpellValueModFloat + { + RadiusMod = SpellValueMod.IntEnd, + CritChance, + DurationPct, } public enum CombatRating diff --git a/Source/Game/Entities/Object/WorldObject.cs b/Source/Game/Entities/Object/WorldObject.cs index ea09e676f..892a55309 100644 --- a/Source/Game/Entities/Object/WorldObject.cs +++ b/Source/Game/Entities/Object/WorldObject.cs @@ -2486,8 +2486,13 @@ namespace Game.Entities } Spell spell = new(this, info, args.TriggerFlags, args.OriginalCaster, args.OriginalCastId); - foreach (var pair in args.SpellValueOverrides) - spell.SetSpellValue(pair.Key, pair.Value); + 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); + } spell.m_CastItem = args.CastItem; if (args.OriginalCastItemLevel.HasValue) diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 60be3864f..dd6e26509 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -7805,7 +7805,7 @@ namespace Game.Spells public void SetSpellValue(SpellValueMod mod, int value) { - if (mod < SpellValueMod.End) + if (mod < SpellValueMod.IntEnd) { m_spellValue.EffectBasePoints[(int)mod] = value; m_spellValue.CustomBasePointsMask |= 1u << (int)mod; @@ -7814,21 +7814,12 @@ namespace Game.Spells switch (mod) { - case SpellValueMod.RadiusMod: - m_spellValue.RadiusMod = (float)value / 10000; - break; case SpellValueMod.MaxTargets: m_spellValue.MaxAffectedTargets = (uint)value; break; case SpellValueMod.AuraStack: m_spellValue.AuraStackAmount = value; break; - case SpellValueMod.CritChance: - m_spellValue.CriticalChance = value / 100.0f; // @todo ugly /100 remove when basepoints are double - break; - case SpellValueMod.DurationPct: - m_spellValue.DurationMul = (float)value / 100.0f; - break; case SpellValueMod.Duration: m_spellValue.Duration = value; break; @@ -7841,6 +7832,24 @@ namespace Game.Spells } } + public void SetSpellValue(SpellValueModFloat mod, float value) + { + switch (mod) + { + case SpellValueModFloat.RadiusMod: + m_spellValue.RadiusMod = value; + break; + case SpellValueModFloat.CritChance: + m_spellValue.CriticalChance = value; + break; + case SpellValueModFloat.DurationPct: + m_spellValue.DurationMul = value / 100.0f; + break; + default: + break; + } + } + void PrepareTargetProcessing() { } @@ -9804,22 +9813,44 @@ namespace Game.Spells } } - public class CastSpellExtraArgs + public class CastSpellExtraArgsInit { public TriggerCastFlags TriggerFlags; public Item CastItem; public Spell TriggeringSpell; public AuraEffect TriggeringAura; - public ObjectGuid OriginalCaster = ObjectGuid.Empty; + public ObjectGuid OriginalCaster; public Difficulty CastDifficulty; - public ObjectGuid OriginalCastId = ObjectGuid.Empty; + public ObjectGuid OriginalCastId; public int? OriginalCastItemLevel; - public Dictionary SpellValueOverrides = new(); - public object CustomArg; + public SpellValueOverride Value; + public List SpellValueOverrides = new(); + public object CustomArg; public ActionResultSetter ScriptResult; public bool ScriptWaitsForSpellHit; + public struct SpellValueOverride + { + public SpellValueOverride(SpellValueMod mod, int val) + { + Type = (int)mod; + IntValue = val; + } + public SpellValueOverride(SpellValueModFloat mod, float val) + { + Type = (int)mod; + FloatValue = val; + } + + public int Type; + public float FloatValue; + public int IntValue; + } + } + + public class CastSpellExtraArgs : CastSpellExtraArgsInit + { public CastSpellExtraArgs() { } public CastSpellExtraArgs(bool triggered) @@ -9857,7 +9888,12 @@ namespace Game.Spells public CastSpellExtraArgs(SpellValueMod mod, int val) { - SpellValueOverrides.Add(mod, val); + SpellValueOverrides.Add(new SpellValueOverride(mod, val)); + } + + public CastSpellExtraArgs(SpellValueModFloat mod, float val) + { + SpellValueOverrides.Add(new SpellValueOverride(mod, val)); } public CastSpellExtraArgs SetTriggerFlags(TriggerCastFlags flag) @@ -9877,8 +9913,10 @@ namespace Game.Spells TriggeringSpell = triggeringSpell; if (triggeringSpell != null) { - OriginalCastItemLevel = triggeringSpell.m_castItemLevel; - OriginalCastId = triggeringSpell.m_castId; + if (!OriginalCastItemLevel.HasValue) + OriginalCastItemLevel = triggeringSpell.m_castItemLevel; + if (!OriginalCastItemLevel.HasValue) + OriginalCastId = triggeringSpell.m_castId; } return this; } @@ -9909,7 +9947,13 @@ namespace Game.Spells public CastSpellExtraArgs AddSpellMod(SpellValueMod mod, int val) { - SpellValueOverrides.Add(mod, val); + SpellValueOverrides.Add(new SpellValueOverride(mod, val)); + return this; + } + + public CastSpellExtraArgs AddSpellMod(SpellValueModFloat mod, float val) + { + SpellValueOverrides.Add(new SpellValueOverride(mod, val)); return this; }