Scripts/Spells: Fix shaman Mastery: Elemental Overload + Stormkeeper and Unlimited Power talents

Port From (https://github.com/TrinityCore/TrinityCore/commit/bd19e225137377a0d6925960b715f58ea18652bc)
This commit is contained in:
hondacrx
2022-02-25 14:18:39 -05:00
parent 163e22c308
commit 6f0b8760e2
4 changed files with 264 additions and 61 deletions
+22 -32
View File
@@ -2229,6 +2229,21 @@ namespace Game.Entities
}
public SpellCastResult CastSpell(SpellCastTargets targets, uint spellId, CastSpellExtraArgs args)
{
return CastSpell(new CastSpellTargetArg(targets), spellId, args);
}
public SpellCastResult CastSpell(WorldObject target, uint spellId, CastSpellExtraArgs args)
{
return CastSpell(new CastSpellTargetArg(target), spellId, args);
}
public SpellCastResult CastSpell(Position dest, uint spellId, CastSpellExtraArgs args)
{
return CastSpell(new CastSpellTargetArg(dest), spellId, args);
}
public SpellCastResult CastSpell(CastSpellTargetArg targets, uint spellId, CastSpellExtraArgs args)
{
SpellInfo info = Global.SpellMgr.GetSpellInfo(spellId, args.CastDifficulty != Difficulty.None ? args.CastDifficulty : GetMap().GetDifficultyID());
if (info == null)
@@ -2237,43 +2252,18 @@ namespace Game.Entities
return SpellCastResult.SpellUnavailable;
}
if (targets.Targets == null)
{
Log.outError(LogFilter.Unit, $"CastSpell: Invalid target passed to spell cast {spellId} by {GetGUID()}");
return SpellCastResult.BadTargets;
}
Spell spell = new(this, info, args.TriggerFlags, args.OriginalCaster, args.OriginalCastId);
foreach (var pair in args.SpellValueOverrides)
spell.SetSpellValue(pair.Key, pair.Value);
spell.m_CastItem = args.CastItem;
return spell.Prepare(targets, args.TriggeringAura);
}
public SpellCastResult CastSpell(WorldObject target, uint spellId, CastSpellExtraArgs args)
{
SpellCastTargets targets = new();
if (target)
{
Unit unitTarget = target.ToUnit();
if (unitTarget != null)
targets.SetUnitTarget(unitTarget);
else
{
GameObject goTarget = target.ToGameObject();
if (goTarget != null)
targets.SetGOTarget(goTarget);
else
{
Log.outError(LogFilter.Unit, $"CastSpell: Invalid target {target.GetGUID()} passed to spell cast by {GetGUID()}");
return SpellCastResult.BadTargets;
}
}
}
return CastSpell(targets, spellId, args);
}
public void CastSpell(Position dest, uint spellId, CastSpellExtraArgs args)
{
SpellCastTargets targets = new();
targets.SetDst(dest);
CastSpell(targets, spellId, args);
return spell.Prepare(targets.Targets, args.TriggeringAura);
}
public void SendPlaySpellVisual(WorldObject target, uint spellVisualId, ushort missReason, ushort reflectStatus, float travelSpeed, bool speedAsTime = false)