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)
+49 -2
View File
@@ -7357,7 +7357,7 @@ namespace Game.Spells
script._FinishScriptCall();
}
}
bool CheckScriptEffectImplicitTargets(uint effIndex, uint effIndexToCheck)
{
// Skip if there are not any script
@@ -7512,7 +7512,7 @@ namespace Game.Spells
{
return $"Id: {GetSpellInfo().Id} Name: '{GetSpellInfo().SpellName[Global.WorldMgr.GetDefaultDbcLocale()]}' OriginalCaster: {m_originalCasterGUID} State: {GetState()}";
}
List<SpellScript> m_loadedScripts = new();
int CalculateDamage(SpellEffectInfo spellEffectInfo, Unit target)
@@ -8763,6 +8763,53 @@ namespace Game.Spells
ObjectGuid _casterGuid;
}
public class CastSpellTargetArg
{
public SpellCastTargets Targets;
public CastSpellTargetArg() { Targets = new(); }
public CastSpellTargetArg(WorldObject target)
{
if (target != null)
{
Unit unitTarget = target.ToUnit();
if (unitTarget != null)
{
Targets = new();
Targets.SetUnitTarget(unitTarget);
}
else
{
GameObject goTarget = target.ToGameObject();
if (goTarget != null)
{
Targets = new();
Targets.SetGOTarget(goTarget);
}
}
}
}
public CastSpellTargetArg(Item itemTarget)
{
Targets = new();
Targets.SetItemTarget(itemTarget);
}
public CastSpellTargetArg(Position dest)
{
Targets = new();
Targets.SetDst(dest);
}
public CastSpellTargetArg(SpellCastTargets targets)
{
Targets = new();
Targets = targets;
}
}
public class CastSpellExtraArgs
{
public TriggerCastFlags TriggerFlags;