Core/Spells: Refactor CastSpellExtraArgs
Port From (https://github.com/TrinityCore/TrinityCore/commit/975e7cc0723d3136822f6190de8742eef17a2539)
This commit is contained in:
@@ -401,15 +401,21 @@ namespace Framework.Constants
|
|||||||
BasePoint29,
|
BasePoint29,
|
||||||
BasePoint30,
|
BasePoint30,
|
||||||
BasePoint31,
|
BasePoint31,
|
||||||
End,
|
BasePointEnd,
|
||||||
RadiusMod,
|
|
||||||
MaxTargets,
|
MaxTargets = BasePointEnd,
|
||||||
AuraStack,
|
AuraStack,
|
||||||
CritChance,
|
|
||||||
DurationPct,
|
|
||||||
Duration,
|
Duration,
|
||||||
ParentSpellTargetCount,
|
ParentSpellTargetCount,
|
||||||
ParentSpellTargetIndex
|
ParentSpellTargetIndex,
|
||||||
|
IntEnd,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SpellValueModFloat
|
||||||
|
{
|
||||||
|
RadiusMod = SpellValueMod.IntEnd,
|
||||||
|
CritChance,
|
||||||
|
DurationPct,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum CombatRating
|
public enum CombatRating
|
||||||
|
|||||||
@@ -2486,8 +2486,13 @@ 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 pair in args.SpellValueOverrides)
|
foreach (var spellOverride in args.SpellValueOverrides)
|
||||||
spell.SetSpellValue(pair.Key, pair.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)
|
||||||
|
|||||||
+63
-19
@@ -7805,7 +7805,7 @@ namespace Game.Spells
|
|||||||
|
|
||||||
public void SetSpellValue(SpellValueMod mod, int value)
|
public void SetSpellValue(SpellValueMod mod, int value)
|
||||||
{
|
{
|
||||||
if (mod < SpellValueMod.End)
|
if (mod < SpellValueMod.IntEnd)
|
||||||
{
|
{
|
||||||
m_spellValue.EffectBasePoints[(int)mod] = value;
|
m_spellValue.EffectBasePoints[(int)mod] = value;
|
||||||
m_spellValue.CustomBasePointsMask |= 1u << (int)mod;
|
m_spellValue.CustomBasePointsMask |= 1u << (int)mod;
|
||||||
@@ -7814,21 +7814,12 @@ namespace Game.Spells
|
|||||||
|
|
||||||
switch (mod)
|
switch (mod)
|
||||||
{
|
{
|
||||||
case SpellValueMod.RadiusMod:
|
|
||||||
m_spellValue.RadiusMod = (float)value / 10000;
|
|
||||||
break;
|
|
||||||
case SpellValueMod.MaxTargets:
|
case SpellValueMod.MaxTargets:
|
||||||
m_spellValue.MaxAffectedTargets = (uint)value;
|
m_spellValue.MaxAffectedTargets = (uint)value;
|
||||||
break;
|
break;
|
||||||
case SpellValueMod.AuraStack:
|
case SpellValueMod.AuraStack:
|
||||||
m_spellValue.AuraStackAmount = value;
|
m_spellValue.AuraStackAmount = value;
|
||||||
break;
|
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:
|
case SpellValueMod.Duration:
|
||||||
m_spellValue.Duration = value;
|
m_spellValue.Duration = value;
|
||||||
break;
|
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()
|
void PrepareTargetProcessing()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -9804,22 +9813,44 @@ namespace Game.Spells
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CastSpellExtraArgs
|
public class CastSpellExtraArgsInit
|
||||||
{
|
{
|
||||||
public TriggerCastFlags TriggerFlags;
|
public TriggerCastFlags TriggerFlags;
|
||||||
public Item CastItem;
|
public Item CastItem;
|
||||||
public Spell TriggeringSpell;
|
public Spell TriggeringSpell;
|
||||||
public AuraEffect TriggeringAura;
|
public AuraEffect TriggeringAura;
|
||||||
public ObjectGuid OriginalCaster = ObjectGuid.Empty;
|
public ObjectGuid OriginalCaster;
|
||||||
public Difficulty CastDifficulty;
|
public Difficulty CastDifficulty;
|
||||||
public ObjectGuid OriginalCastId = ObjectGuid.Empty;
|
public ObjectGuid OriginalCastId;
|
||||||
public int? OriginalCastItemLevel;
|
public int? OriginalCastItemLevel;
|
||||||
public Dictionary<SpellValueMod, int> SpellValueOverrides = new();
|
public SpellValueOverride Value;
|
||||||
public object CustomArg;
|
|
||||||
|
|
||||||
|
public List<SpellValueOverride> SpellValueOverrides = new();
|
||||||
|
public object CustomArg;
|
||||||
public ActionResultSetter<SpellCastResult> ScriptResult;
|
public ActionResultSetter<SpellCastResult> ScriptResult;
|
||||||
public bool ScriptWaitsForSpellHit;
|
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() { }
|
||||||
|
|
||||||
public CastSpellExtraArgs(bool triggered)
|
public CastSpellExtraArgs(bool triggered)
|
||||||
@@ -9857,7 +9888,12 @@ namespace Game.Spells
|
|||||||
|
|
||||||
public CastSpellExtraArgs(SpellValueMod mod, int val)
|
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)
|
public CastSpellExtraArgs SetTriggerFlags(TriggerCastFlags flag)
|
||||||
@@ -9877,8 +9913,10 @@ namespace Game.Spells
|
|||||||
TriggeringSpell = triggeringSpell;
|
TriggeringSpell = triggeringSpell;
|
||||||
if (triggeringSpell != null)
|
if (triggeringSpell != null)
|
||||||
{
|
{
|
||||||
OriginalCastItemLevel = triggeringSpell.m_castItemLevel;
|
if (!OriginalCastItemLevel.HasValue)
|
||||||
OriginalCastId = triggeringSpell.m_castId;
|
OriginalCastItemLevel = triggeringSpell.m_castItemLevel;
|
||||||
|
if (!OriginalCastItemLevel.HasValue)
|
||||||
|
OriginalCastId = triggeringSpell.m_castId;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -9909,7 +9947,13 @@ namespace Game.Spells
|
|||||||
|
|
||||||
public CastSpellExtraArgs AddSpellMod(SpellValueMod mod, int val)
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user