diff --git a/Source/Game/AI/CoreAI/PassiveAI.cs b/Source/Game/AI/CoreAI/PassiveAI.cs index c3862360b..b014808aa 100644 --- a/Source/Game/AI/CoreAI/PassiveAI.cs +++ b/Source/Game/AI/CoreAI/PassiveAI.cs @@ -17,6 +17,7 @@ using Framework.Constants; using Game.Entities; +using Game.Spells; using System.Collections.Generic; namespace Game.AI @@ -128,7 +129,11 @@ namespace Game.AI public override void IsSummonedBy(Unit summoner) { if (me.m_spells[0] != 0) - me.CastSpell(me, me.m_spells[0], false, null, null, summoner.GetGUID()); + { + CastSpellExtraArgs extra = new(); + extra.OriginalCaster = summoner.GetGUID(); + me.CastSpell(me, me.m_spells[0], extra); + } } } } diff --git a/Source/Game/AI/CoreAI/UnitAI.cs b/Source/Game/AI/CoreAI/UnitAI.cs index 0e881c93f..0b6a0c689 100644 --- a/Source/Game/AI/CoreAI/UnitAI.cs +++ b/Source/Game/AI/CoreAI/UnitAI.cs @@ -98,17 +98,17 @@ namespace Game.AI } } - public bool DoSpellAttackIfReady(uint spell) + public bool DoSpellAttackIfReady(uint spellId) { if (me.HasUnitState(UnitState.Casting) || !me.IsAttackReady()) return true; - var spellInfo = Global.SpellMgr.GetSpellInfo(spell, me.GetMap().GetDifficultyID()); + var spellInfo = Global.SpellMgr.GetSpellInfo(spellId, me.GetMap().GetDifficultyID()); if (spellInfo != null) { if (me.IsWithinCombatRange(me.GetVictim(), spellInfo.GetMaxRange(false))) { - me.CastSpell(me.GetVictim(), spellInfo, TriggerCastFlags.None); + me.CastSpell(me.GetVictim(), spellId, new CastSpellExtraArgs(me.GetMap().GetDifficultyID())); me.ResetAttackTimer(); return true; } @@ -300,32 +300,25 @@ namespace Game.AI me.CastSpell(target, spellId, false); } - public void DoCast(Unit victim, uint spellId, bool triggered = false) + public void DoCast(Unit victim, uint spellId, CastSpellExtraArgs args = null) { - if (victim == null || (me.HasUnitState(UnitState.Casting) && !triggered)) + if (me.HasUnitState(UnitState.Casting) && !args.TriggerFlags.HasAnyFlag(TriggerCastFlags.IgnoreCastInProgress)) return; - me.CastSpell(victim, spellId, triggered); + me.CastSpell(victim, spellId, args); } - public void DoCastSelf(uint spellId, bool triggered = false) { DoCast(me, spellId, triggered); } + public void DoCastSelf(uint spellId, CastSpellExtraArgs args = null) { DoCast(me, spellId, args); } - public void DoCastVictim(uint spellId, bool triggered = false) + public void DoCastVictim(uint spellId, CastSpellExtraArgs args = null) { - if (me.GetVictim() == null || (me.HasUnitState(UnitState.Casting) && !triggered)) - return; - - me.CastSpell(me.GetVictim(), spellId, triggered); - } - - public void DoCastAOE(uint spellId, bool triggered = false) - { - if (!triggered && me.HasUnitState(UnitState.Casting)) - return; - - me.CastSpell((Unit)null, spellId, triggered); + Unit victim = me.GetVictim(); + if (victim != null) + DoCast(victim, spellId, args); } + public void DoCastAOE(uint spellId, CastSpellExtraArgs args = null) { DoCast(null, spellId, args); } + public static void FillAISpellInfo() { //AISpellInfo = new AISpellInfoType[spellStorage.Keys.Max() + 1]; diff --git a/Source/Game/AI/PlayerAI/PlayerAI.cs b/Source/Game/AI/PlayerAI/PlayerAI.cs index 008d71c05..e0910d204 100644 --- a/Source/Game/AI/PlayerAI/PlayerAI.cs +++ b/Source/Game/AI/PlayerAI/PlayerAI.cs @@ -602,7 +602,7 @@ namespace Game.AI if (rangedAttackSpell == 0) return; - me.CastSpell(victim, rangedAttackSpell, TriggerCastFlags.CastDirectly); + me.CastSpell(victim, rangedAttackSpell, new CastSpellExtraArgs(TriggerCastFlags.CastDirectly)); me.ResetAttackTimer(WeaponAttackType.RangedAttack); } diff --git a/Source/Game/AI/ScriptedAI/ScriptedAI.cs b/Source/Game/AI/ScriptedAI/ScriptedAI.cs index be01637c8..0bc9e3094 100644 --- a/Source/Game/AI/ScriptedAI/ScriptedAI.cs +++ b/Source/Game/AI/ScriptedAI/ScriptedAI.cs @@ -97,7 +97,7 @@ namespace Game.AI return; me.StopMoving(); - me.CastSpell(target, spellInfo, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None); + me.CastSpell(target, spellInfo.Id, triggered); } //Plays a sound to all nearby players diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 8e149a79b..07a887d5c 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -486,12 +486,10 @@ namespace Game.AI ((SmartAI)_me.GetAI()).SetCombatMove(allowMove); } - _me.CastSpell(target.ToUnit(), e.Action.cast.spell, triggerFlag); + _me.CastSpell(target.ToUnit(), e.Action.cast.spell, new CastSpellExtraArgs(triggerFlag)); } else if (_go) _go.CastSpell(target.ToUnit(), e.Action.cast.spell, triggerFlag); - else if (target != null) - target.ToUnit().CastSpell(target.ToUnit(), e.Action.cast.spell); } else Log.outDebug(LogFilter.ScriptsAi, "Spell {0} not casted because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (Guid: {1} Entry: {2} Type: {3}) already has the aura", @@ -531,7 +529,7 @@ namespace Game.AI triggerFlag = TriggerCastFlags.FullMask; } - tempLastInvoker.CastSpell(target.ToUnit(), e.Action.cast.spell, triggerFlag); + tempLastInvoker.CastSpell(target.ToUnit(), e.Action.cast.spell, new CastSpellExtraArgs(triggerFlag)); Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction. SMART_ACTION_INVOKER_CAST: Invoker {0} casts spell {1} on target {2} with castflags {3}", tempLastInvoker.GetGUID().ToString(), e.Action.cast.spell, target.GetGUID().ToString(), e.Action.cast.castFlags); diff --git a/Source/Game/Chat/Commands/CastCommands.cs b/Source/Game/Chat/Commands/CastCommands.cs index d580fbed6..69bf9cbb5 100644 --- a/Source/Game/Chat/Commands/CastCommands.cs +++ b/Source/Game/Chat/Commands/CastCommands.cs @@ -118,7 +118,7 @@ namespace Game.Chat float x, y, z; handler.GetSession().GetPlayer().GetClosePoint(out x, out y, out z, dist); - handler.GetSession().GetPlayer().CastSpell(x, y, z, spellId, triggered); + handler.GetSession().GetPlayer().CastSpell(new Position(x, y, z), spellId, new CastSpellExtraArgs(triggered)); return true; } @@ -221,7 +221,7 @@ namespace Game.Chat bool triggered = (triggeredStr != null); - caster.CastSpell(x, y, z, spellId, triggered); + caster.CastSpell(new Position(x, y, z), spellId, new CastSpellExtraArgs(triggered)); return true; } diff --git a/Source/Game/Entities/GameObject/GameObject.cs b/Source/Game/Entities/GameObject/GameObject.cs index 81c321a33..1104ce9dd 100644 --- a/Source/Game/Entities/GameObject/GameObject.cs +++ b/Source/Game/Entities/GameObject/GameObject.cs @@ -2001,8 +2001,7 @@ namespace Game.Entities if (spellId == 0) return; - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID()); - if (spellInfo == null) + if (!Global.SpellMgr.HasSpellInfo(spellId, GetMap().GetDifficultyID())) { if (!user.IsTypeId(TypeId.Player) || !Global.OutdoorPvPMgr.HandleCustomSpell(user.ToPlayer(), spellId, this)) Log.outError(LogFilter.Server, "WORLD: unknown spell id {0} at use action for gameobject (Entry: {1} GoType: {2})", spellId, GetEntry(), GetGoType()); @@ -2016,7 +2015,7 @@ namespace Game.Entities Global.OutdoorPvPMgr.HandleCustomSpell(player1, spellId, this); if (spellCaster != null) - spellCaster.CastSpell(user, spellInfo, triggered); + spellCaster.CastSpell(user, spellId, triggered); else CastSpell(user, spellId); } @@ -2045,7 +2044,7 @@ namespace Game.Entities if (self) { if (target != null) - target.CastSpell(target, spellInfo, triggered); + target.CastSpell(target, spellInfo.Id, new CastSpellExtraArgs(triggered)); return; } @@ -2059,6 +2058,7 @@ namespace Game.Entities PhasingHandler.InheritPhaseShift(trigger, this); + CastSpellExtraArgs args = new CastSpellExtraArgs(triggered); Unit owner = GetOwner(); if (owner) { @@ -2069,14 +2069,17 @@ namespace Game.Entities trigger.SetPvpFlags(owner.GetPvpFlags()); // needed for GO casts for proper target validation checks trigger.SetOwnerGUID(owner.GetGUID()); - trigger.CastSpell(target != null ? target : trigger, spellInfo, triggered, null, null, owner.GetGUID()); + + args.OriginalCaster = owner.GetGUID(); + trigger.CastSpell(target ?? trigger, spellInfo.Id, args); } else { trigger.SetFaction(spellInfo.IsPositive() ? 35 : 14u); // Set owner guid for target if no owner available - needed by trigger auras // - trigger gets despawned and there's no caster avalible (see AuraEffect.TriggerSpell()) - trigger.CastSpell(target != null ? target : trigger, spellInfo, triggered, null, null, target ? target.GetGUID() : ObjectGuid.Empty); + args.OriginalCaster = target ? target.GetGUID() : ObjectGuid.Empty; + trigger.CastSpell(target ?? trigger, spellInfo.Id, args); } } diff --git a/Source/Game/Entities/Pet.cs b/Source/Game/Entities/Pet.cs index 074452b15..ea498249a 100644 --- a/Source/Game/Entities/Pet.cs +++ b/Source/Game/Entities/Pet.cs @@ -1412,13 +1412,12 @@ namespace Game.Entities if (auraId == 0) return; + CastSpellExtraArgs args = new CastSpellExtraArgs(TriggerCastFlags.FullMask); + if (auraId == 35696) // Demonic Knowledge - { - int basePoints = MathFunctions.CalculatePct(aura.GetDamage(), GetStat(Stats.Stamina) + GetStat(Stats.Intellect)); - CastCustomSpell(this, auraId, basePoints, 0, 0, true); - } - else - CastSpell(this, auraId, true); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, MathFunctions.CalculatePct(aura.GetDamage(), GetStat(Stats.Stamina) + GetStat(Stats.Intellect))); + + CastSpell(this, auraId, args); } bool IsPetAura(Aura aura) diff --git a/Source/Game/Entities/Player/Player.Items.cs b/Source/Game/Entities/Player/Player.Items.cs index 99ebad175..05af493ba 100644 --- a/Source/Game/Entities/Player/Player.Items.cs +++ b/Source/Game/Entities/Player/Player.Items.cs @@ -3888,7 +3888,7 @@ namespace Game.Entities Log.outDebug(LogFilter.Player, "WORLD: cast {0} Equip spellId - {1}", (item != null ? "item" : "itemset"), spellInfo.Id); - CastSpell(this, spellInfo, true, item); + CastSpell(this, spellInfo.Id, new CastSpellExtraArgs(item)); } else { @@ -5083,13 +5083,14 @@ namespace Game.Entities } else if (apply) { - Dictionary csv = new(); + CastSpellExtraArgs args = new CastSpellExtraArgs(TriggerCastFlags.FullMask); + args.CastItem = artifact; if (artifactPowerRank.AuraPointsOverride != 0) for (int i = 0; i < SpellConst.MaxEffects; ++i) if (spellInfo.GetEffect((uint)i) != null) - csv.Add(SpellValueMod.BasePoint0 + i, (int)artifactPowerRank.AuraPointsOverride); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, (int)artifactPowerRank.AuraPointsOverride); - CastCustomSpell(artifactPowerRank.SpellID, csv, this, TriggerCastFlags.FullMask, artifact); + CastSpell(this, artifactPowerRank.SpellID, args); } } else @@ -5159,7 +5160,7 @@ namespace Game.Entities if (azeritePower != null) { if (apply) - CastSpell(this, azeritePower.SpellID, true, item); + CastSpell(this, azeritePower.SpellID, item); else RemoveAurasDueToItemSpell(azeritePower.SpellID, item.GetGUID()); } @@ -5177,7 +5178,7 @@ namespace Game.Entities if (major && currentRank == 1) { if (apply) - CastCustomSpell(PlayerConst.SpellIdHeartEssenceActionBarOverride, SpellValueMod.BasePoint0, (int)azeriteEssencePower.MajorPowerDescription, this, TriggerCastFlags.FullMask); + CastSpell(this, PlayerConst.SpellIdHeartEssenceActionBarOverride, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, (int)azeriteEssencePower.MajorPowerDescription)); else RemoveAurasDueToSpell(PlayerConst.SpellIdHeartEssenceActionBarOverride); } @@ -5191,7 +5192,7 @@ namespace Game.Entities if (powerSpell != null) { if (apply) - CastSpell(this, powerSpell, true, item); + CastSpell(this, powerSpell.Id, item); else RemoveAurasDueToItemSpell(powerSpell.Id, item.GetGUID()); } @@ -5204,7 +5205,7 @@ namespace Game.Entities if (powerSpell.IsPassive()) { if (apply) - CastSpell(this, powerSpell, true, item); + CastSpell(this, powerSpell.Id, item); else RemoveAurasDueToItemSpell(powerSpell.Id, item.GetGUID()); } @@ -5224,7 +5225,7 @@ namespace Game.Entities if (apply) { if (azeritePower.SpecSetID == 0 || Global.DB2Mgr.IsSpecSetMember(azeritePower.SpecSetID, GetPrimarySpecialization())) - CastSpell(this, azeritePower.SpellID, true, item); + CastSpell(this, azeritePower.SpellID, item); } else RemoveAurasDueToItemSpell(azeritePower.SpellID, item.GetGUID()); diff --git a/Source/Game/Entities/Player/Player.Quest.cs b/Source/Game/Entities/Player/Player.Quest.cs index 7f52acecd..284125e17 100644 --- a/Source/Game/Entities/Player/Player.Quest.cs +++ b/Source/Game/Entities/Player/Player.Quest.cs @@ -800,7 +800,7 @@ namespace Game.Entities caster = unit; } - caster.CastSpell(this, spellInfo, true); + caster.CastSpell(this, spellInfo.Id, new CastSpellExtraArgs(TriggerCastFlags.FullMask).SetCastDifficulty(spellInfo.Difficulty)); } SetQuestSlot(log_slot, quest_id, qtime); @@ -1124,7 +1124,7 @@ namespace Game.Entities caster = unit; } - caster.CastSpell(this, spellInfo, true); + caster.CastSpell(this, spellInfo.Id, new CastSpellExtraArgs(TriggerCastFlags.FullMask).SetCastDifficulty(spellInfo.Difficulty)); } else { @@ -1144,7 +1144,7 @@ namespace Game.Entities caster = unit; } - caster.CastSpell(this, spellInfo, true); + caster.CastSpell(this, spellInfo.Id, new CastSpellExtraArgs(TriggerCastFlags.FullMask).SetCastDifficulty(spellInfo.Difficulty)); } } diff --git a/Source/Game/Entities/Player/Player.Spells.cs b/Source/Game/Entities/Player/Player.Spells.cs index 38f30af1a..52a9a5623 100644 --- a/Source/Game/Entities/Player/Player.Spells.cs +++ b/Source/Game/Entities/Player/Player.Spells.cs @@ -587,7 +587,7 @@ namespace Game.Entities if (enchant_spell_id != 0) { if (apply) - CastSpell(this, enchant_spell_id, true, item); + CastSpell(this, enchant_spell_id, item); else RemoveAurasDueToItemSpell(enchant_spell_id, item.GetGUID()); } @@ -1779,7 +1779,7 @@ namespace Game.Entities if (apply) { if (!HasAura((uint)spellId)) - CastSpell(this, (uint)spellId, true, item); + CastSpell(this, (uint)spellId, item); } else RemoveAurasDueToSpell((uint)spellId); @@ -3183,7 +3183,7 @@ namespace Game.Entities chance = GetWeaponProcChance(); if (RandomHelper.randChance(chance) && Global.ScriptMgr.OnCastItemCombatSpell(this, damageInfo.GetVictim(), spellInfo, item)) - CastSpell(damageInfo.GetVictim(), spellInfo.Id, true, item); + CastSpell(damageInfo.GetVictim(), spellInfo.Id, item); } } @@ -3205,7 +3205,7 @@ namespace Game.Entities if (entry != null && entry.HitMask != 0) { // Check hit/crit/dodge/parry requirement - if (((uint)entry.HitMask & (uint)damageInfo.GetHitMask()) == 0) + if ((entry.HitMask & (uint)damageInfo.GetHitMask()) == 0) continue; } else @@ -3247,17 +3247,17 @@ namespace Game.Entities if (RandomHelper.randChance(chance)) { if (spellInfo.IsPositive()) - CastSpell(this, spellInfo, true, item); + CastSpell(this, spellInfo.Id, item); else - CastSpell(damageInfo.GetVictim(), spellInfo, true, item); + CastSpell(damageInfo.GetVictim(), spellInfo.Id, item); } if (RandomHelper.randChance(chance)) { Unit target = spellInfo.IsPositive() ? this : damageInfo.GetVictim(); + CastSpellExtraArgs args = new(item); // reduce effect values if enchant is limited - Dictionary values = new(); if (entry != null && entry.AttributesMask.HasAnyFlag(EnchantProcAttributes.Limit60) && target.GetLevelForTarget(this) > 60) { int lvlDifference = (int)target.GetLevelForTarget(this) - 60; @@ -3268,11 +3268,11 @@ namespace Game.Entities for (byte i = 0; i < SpellConst.MaxEffects; ++i) { if (spellInfo.GetEffect(i).IsEffect()) - values.Add(SpellValueMod.BasePoint0 + i, MathFunctions.CalculatePct(spellInfo.GetEffect(i).CalcValue(this), effectPct)); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, MathFunctions.CalculatePct(spellInfo.GetEffect(i).CalcValue(this), effectPct)); } } - CastCustomSpell(spellInfo.Id, values, target, TriggerCastFlags.FullMask, item); + CastSpell(target, spellInfo.Id, args); } } } diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index 1b4365446..8c681111c 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -1073,7 +1073,7 @@ namespace Game.Entities } if (spellInfo.IsPassive()) - vehicle.CastSpell(vehicle, spellInfo, true); + vehicle.CastSpell(vehicle, spellInfo.Id, true); petSpells.ActionButtons[i] = UnitActionBarEntry.MAKE_UNIT_ACTION_BUTTON(spellId, i + 8); } @@ -2466,7 +2466,7 @@ namespace Game.Entities break; case GossipOption.Spirithealer: if (IsDead()) - source.ToCreature().CastSpell(source.ToCreature(), 17251, true, null, null, GetGUID()); + source.ToCreature().CastSpell(source.ToCreature(), 17251, new CastSpellExtraArgs(GetGUID())); break; case GossipOption.Questgiver: PrepareQuestMenu(guid); @@ -3538,7 +3538,7 @@ namespace Game.Entities SetPower(PowerType.LunarPower, 0); if (resurrectAura != 0) - CastSpell(this, resurrectAura, true, null, null, resurrectGUID); + CastSpell(this, resurrectAura, new CastSpellExtraArgs(resurrectGUID)); SpawnCorpseBones(); } diff --git a/Source/Game/Entities/StatSystem.cs b/Source/Game/Entities/StatSystem.cs index 5843886e3..e4a77bf8b 100644 --- a/Source/Game/Entities/StatSystem.cs +++ b/Source/Game/Entities/StatSystem.cs @@ -706,7 +706,9 @@ namespace Game.Entities break; } - CastSpell(this, triggerSpell, true, null, effect); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.TriggeringAura = effect; + CastSpell(this, triggerSpell, args); } } } diff --git a/Source/Game/Entities/Unit/CharmInfo.cs b/Source/Game/Entities/Unit/CharmInfo.cs index 7267bd88a..33826e897 100644 --- a/Source/Game/Entities/Unit/CharmInfo.cs +++ b/Source/Game/Entities/Unit/CharmInfo.cs @@ -110,7 +110,7 @@ namespace Game.Entities if (spellInfo != null) { if (spellInfo.IsPassive()) - _unit.CastSpell(_unit, spellInfo, true); + _unit.CastSpell(_unit, spellInfo.Id, new CastSpellExtraArgs(true)); else AddSpellToActionBar(spellInfo, ActiveStates.Passive, i % SharedConst.ActionBarIndexMax); } @@ -143,7 +143,7 @@ namespace Game.Entities if (spellInfo.IsPassive()) { - _unit.CastSpell(_unit, spellInfo, true); + _unit.CastSpell(_unit, spellInfo.Id, new CastSpellExtraArgs(true)); _charmspells[x].SetActionAndType(spellId, ActiveStates.Passive); } else diff --git a/Source/Game/Entities/Unit/Unit.Combat.cs b/Source/Game/Entities/Unit/Unit.Combat.cs index bc2939628..0250bb075 100644 --- a/Source/Game/Entities/Unit/Unit.Combat.cs +++ b/Source/Game/Entities/Unit/Unit.Combat.cs @@ -698,7 +698,9 @@ namespace Game.Entities } else { - CastSpell(victim, meleeAttackSpellId, true, null, meleeAttackAuraEffect); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.TriggeringAura = meleeAttackAuraEffect; + CastSpell(victim, meleeAttackSpellId, args); HitInfo hitInfo = HitInfo.AffectsVictim | HitInfo.NoAnimation; if (attType == WeaponAttackType.OffAttack) diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index 9267ed362..a87776235 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -1066,124 +1066,58 @@ namespace Game.Entities return SpellMissInfo.None; } - public void CastSpell(SpellCastTargets targets, SpellInfo spellInfo, Dictionary values, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default) + public void CastSpell(SpellCastTargets targets, uint spellId, CastSpellExtraArgs args) { + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, args.CastDifficulty != Difficulty.None ? args.CastDifficulty : GetMap().GetDifficultyID()); if (spellInfo == null) { - Log.outError(LogFilter.Spells, "CastSpell: unknown spell by caster: {0}", GetGUID().ToString()); + Log.outError(LogFilter.Unit, $"CastSpell: unknown spell {spellId} by caster: {GetGUID()}"); return; } - Spell spell = new(this, spellInfo, triggerFlags, originalCaster); + if (args == null) + args = new CastSpellExtraArgs(); - if (values != null) - foreach (var pair in values) - spell.SetSpellValue(pair.Key, pair.Value); + Spell spell = new(this, spellInfo, args.TriggerFlags, args.OriginalCaster); + foreach (var pair in args.SpellValueOverrides) + spell.SetSpellValue(pair.Key, pair.Value); - spell.m_CastItem = castItem; - spell.Prepare(targets, triggeredByAura); + spell.m_CastItem = args.CastItem; + spell.Prepare(targets, args.TriggeringAura); } - public void CastSpell(Unit victim, uint spellId, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default) - { - CastSpell(victim, spellId, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster); - } - public void CastSpell(Unit victim, uint spellId, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default) - { - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID()); - if (spellInfo == null) - { - Log.outError(LogFilter.Spells, "CastSpell: unknown spell id {0} by caster: {1}", spellId, GetGUID().ToString()); - return; - } - CastSpell(victim, spellInfo, triggerFlags, castItem, triggeredByAura, originalCaster); - } - public void CastSpell(Unit victim, SpellInfo spellInfo, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default) + public void CastSpell(WorldObject target, uint spellId, bool triggered) { - CastSpell(victim, spellInfo, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster); + CastSpell(target, spellId, new CastSpellExtraArgs(triggered)); } - public void CastSpell(Unit victim, SpellInfo spellInfo, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default) + + public void CastSpell(WorldObject target, uint spellId, CastSpellExtraArgs args = null) { SpellCastTargets targets = new(); - targets.SetUnitTarget(victim); - CastSpell(targets, spellInfo, null, triggerFlags, castItem, triggeredByAura, originalCaster); - } - public void CastSpell(float x, float y, float z, uint spellId, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default) - { - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID()); - if (spellInfo == null) + if (target) { - Log.outError(LogFilter.Unit, "CastSpell: unknown spell id {0} by caster: {1}", spellId, GetGUID().ToString()); - return; + Unit unitTarget = target.ToUnit(); + GameObject goTarget = target.ToGameObject(); + if (unitTarget != null) + targets.SetUnitTarget(unitTarget); + else if (goTarget != null) + targets.SetGOTarget(goTarget); + else + { + Log.outError(LogFilter.Unit, $"CastSpell: Invalid target {target.GetGUID()} passed to spell cast by {GetGUID()}"); + return; + } } + + CastSpell(targets, spellId, args); + } + + public void CastSpell(Position dest, uint spellId, CastSpellExtraArgs args = null) + { SpellCastTargets targets = new(); - targets.SetDst(x, y, z, GetOrientation()); + targets.SetDst(dest); - CastSpell(targets, spellInfo, null, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster); - } - public void CastSpell(GameObject go, uint spellId, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default) - { - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID()); - if (spellInfo == null) - { - Log.outError(LogFilter.Unit, "CastSpell: unknown spell id {0} by caster: {1}", spellId, GetGUID().ToString()); - return; - } - SpellCastTargets targets = new(); - targets.SetGOTarget(go); - - CastSpell(targets, spellInfo, null, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster); - } - public void CastSpell(Item item, uint spellId, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default) - { - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID()); - if (spellInfo == null) - { - Log.outError(LogFilter.Unit, "CastSpell: unknown spell id {0} by caster: {1}", spellId, GetGUID().ToString()); - return; - } - SpellCastTargets targets = new(); - targets.SetItemTarget(item); - - CastSpell(targets, spellInfo, null, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster); - } - - - public void CastCustomSpell(Unit target, uint spellId, int bp0, int bp1, int bp2, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default) - { - Dictionary values = new(); - if (bp0 != 0) - values.Add(SpellValueMod.BasePoint0, bp0); - if (bp1 != 0) - values.Add(SpellValueMod.BasePoint1, bp1); - if (bp2 != 0) - values.Add(SpellValueMod.BasePoint2, bp2); - CastCustomSpell(spellId, values, target, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster); - } - public void CastCustomSpell(uint spellId, SpellValueMod mod, int value, Unit target, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default) - { - Dictionary values = new(); - values.Add(mod, value); - CastCustomSpell(spellId, values, target, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster); - } - public void CastCustomSpell(uint spellId, SpellValueMod mod, int value, Unit target = null, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default) - { - Dictionary values = new(); - values.Add(mod, value); - CastCustomSpell(spellId, values, target, triggerFlags, castItem, triggeredByAura, originalCaster); - } - public void CastCustomSpell(uint spellId, Dictionary values, Unit victim = null, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default) - { - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID()); - if (spellInfo == null) - { - Log.outError(LogFilter.Unit, "CastSpell: unknown spell id {0} by caster: {1}", spellId, GetGUID().ToString()); - return; - } - SpellCastTargets targets = new(); - targets.SetUnitTarget(victim); - - CastSpell(targets, spellInfo, values, triggerFlags, castItem, triggeredByAura, originalCaster); + CastSpell(targets, spellId, args); } public void FinishSpell(CurrentSpellTypes spellType, bool ok = true) @@ -3038,7 +2972,12 @@ namespace Game.Entities } if (IsInMap(caster)) - caster.CastCustomSpell(clickInfo.spellId, SpellValueMod.BasePoint0 + i, seatId + 1, target, flags, null, null, origCasterGUID); + { + CastSpellExtraArgs args = new(flags); + args.OriginalCaster = origCasterGUID; + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, seatId + 1); + caster.CastSpell(target, clickInfo.spellId, args); + } else // This can happen during Player._LoadAuras { int[] bp0 = new int[SpellConst.MaxEffects]; @@ -3055,7 +2994,7 @@ namespace Game.Entities else { if (IsInMap(caster)) - caster.CastSpell(target, spellEntry, flags, null, null, origCasterGUID); + caster.CastSpell(target, spellEntry.Id, new CastSpellExtraArgs().SetOriginalCaster(origCasterGUID)); else Aura.TryRefreshStackOrCreate(spellEntry, ObjectGuid.Create(HighGuid.Cast, SpellCastSource.Normal, GetMapId(), spellEntry.Id, GetMap().GenerateLowGuid(HighGuid.Cast)), SpellConst.MaxEffectMask, this, clicker, GetMap().GetDifficultyID(), null, null, origCasterGUID); } @@ -3893,7 +3832,7 @@ namespace Game.Entities continue; if (spellInfo.CasterAuraState == flag) - CastSpell(this, spell.Key, true, null); + CastSpell(this, spell.Key, true); } } else if (IsPet()) @@ -3907,7 +3846,7 @@ namespace Game.Entities if (spellInfo == null || !spellInfo.IsPassive()) continue; if (spellInfo.CasterAuraState == flag) - CastSpell(this, spell.Key, true, null); + CastSpell(this, spell.Key, true); } } } diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index c770d1359..30c747a57 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -886,7 +886,9 @@ namespace Game.Entities public void EnterVehicle(Unit Base, sbyte seatId = -1) { - CastCustomSpell(SharedConst.VehicleSpellRideHardcoded, SpellValueMod.BasePoint0, seatId + 1, Base, TriggerCastFlags.IgnoreCasterMountedOrOnVehicle); + CastSpellExtraArgs args = new(TriggerCastFlags.IgnoreCasterMountedOrOnVehicle); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, seatId + 1); + CastSpell(this, SharedConst.VehicleSpellRideHardcoded, args); } public void _EnterVehicle(Vehicle vehicle, sbyte seatId, AuraApplication aurApp) diff --git a/Source/Game/Handlers/CharacterHandler.cs b/Source/Game/Handlers/CharacterHandler.cs index ff324ad80..daa1be894 100644 --- a/Source/Game/Handlers/CharacterHandler.cs +++ b/Source/Game/Handlers/CharacterHandler.cs @@ -26,6 +26,7 @@ using Game.Guilds; using Game.Maps; using Game.Networking; using Game.Networking.Packets; +using Game.Spells; using System; using System.Collections.Generic; using System.Linq; @@ -882,10 +883,10 @@ namespace Game { // not blizz like, we must correctly save and load player instead... if (pCurrChar.GetRace() == Race.NightElf && !pCurrChar.HasAura(20584)) - pCurrChar.CastSpell(pCurrChar, 20584, true);// auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form) + pCurrChar.CastSpell(pCurrChar, 20584, new CastSpellExtraArgs(true));// auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form) if (!pCurrChar.HasAura(8326)) - pCurrChar.CastSpell(pCurrChar, 8326, true, null); // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?) + pCurrChar.CastSpell(pCurrChar, 8326, new CastSpellExtraArgs(true)); // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?) pCurrChar.SetWaterWalking(true); } @@ -937,7 +938,7 @@ namespace Game PlayerInfo info = Global.ObjectMgr.GetPlayerInfo(pCurrChar.GetRace(), pCurrChar.GetClass()); foreach (var spellId in info.castSpells) - pCurrChar.CastSpell(pCurrChar, spellId, true); + pCurrChar.CastSpell(pCurrChar, spellId, new CastSpellExtraArgs(true)); // start with every map explored if (WorldConfig.GetBoolValue(WorldCfg.StartAllExplored)) diff --git a/Source/Game/Handlers/SpellHandler.cs b/Source/Game/Handlers/SpellHandler.cs index 65a55d47b..b810a0367 100644 --- a/Source/Game/Handlers/SpellHandler.cs +++ b/Source/Game/Handlers/SpellHandler.cs @@ -480,11 +480,8 @@ namespace Game List selfResSpells = _player.m_activePlayerData.SelfResSpells; if (!selfResSpells.Contains(selfRes.SpellId)) return; - - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(selfRes.SpellId, _player.GetMap().GetDifficultyID()); - if (spellInfo != null) - _player.CastSpell(_player, spellInfo, false, null); - + + _player.CastSpell(_player, selfRes.SpellId, new CastSpellExtraArgs(_player.GetMap().GetDifficultyID())); _player.RemoveSelfResSpell(selfRes.SpellId); } diff --git a/Source/Game/Spells/Auras/Aura.cs b/Source/Game/Spells/Auras/Aura.cs index bed384404..c623e5ace 100644 --- a/Source/Game/Spells/Auras/Aura.cs +++ b/Source/Game/Spells/Auras/Aura.cs @@ -1155,7 +1155,7 @@ namespace Game.Spells else if (spellArea.flags.HasAnyFlag(SpellAreaFlag.AutoCast)) { if (!target.HasAura(spellArea.spellId)) - target.CastSpell(target, spellArea.spellId, true); + target.CastSpell(target, spellArea.spellId, new CastSpellExtraArgs(true)); } } } @@ -1189,7 +1189,7 @@ namespace Game.Spells if (spell < 0) target.RemoveAurasDueToSpell((uint)-spell); else if (removeMode != AuraRemoveMode.Death) - target.CastSpell(target, (uint)spell, true, null, null, GetCasterGUID()); + target.CastSpell(target, (uint)spell, new CastSpellExtraArgs(GetCasterGUID())); } } spellTriggered = Global.SpellMgr.GetSpellLinked((int)GetId() + (int)SpellLinkedType.Aura); @@ -1237,11 +1237,11 @@ namespace Game.Spells break; case 33572: // Gronn Lord's Grasp, becomes stoned if (GetStackAmount() >= 5 && !target.HasAura(33652)) - target.CastSpell(target, 33652, true); + target.CastSpell(target, 33652, new CastSpellExtraArgs(true)); break; case 50836: //Petrifying Grip, becomes stoned if (GetStackAmount() >= 5 && !target.HasAura(50812)) - target.CastSpell(target, 50812, true); + target.CastSpell(target, 50812, new CastSpellExtraArgs(true)); break; case 60970: // Heroic Fury (remove Intercept cooldown) if (target.IsTypeId(TypeId.Player)) @@ -1258,8 +1258,9 @@ namespace Game.Spells // Druid T8 Restoration 4P Bonus if (caster.HasAura(64760)) { - int heal = GetEffect(0).GetAmount(); - caster.CastCustomSpell(target, 64801, heal, 0, 0, true, null, GetEffect(0)); + CastSpellExtraArgs args = new(GetEffect(0)); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, GetEffect(0).GetAmount()); + caster.CastSpell(target, 64801, args); } } break; @@ -1276,7 +1277,7 @@ namespace Game.Spells case 66: // Invisibility if (removeMode != AuraRemoveMode.Expire) break; - target.CastSpell(target, 32612, true, null, GetEffect(1)); + target.CastSpell(target, 32612, new CastSpellExtraArgs(GetEffect(1))); target.CombatStop(); break; default: @@ -1312,8 +1313,9 @@ namespace Game.Spells if (aurEff != null) { float multiplier = aurEff.GetAmount(); - int basepoints0 = MathFunctions.CalculatePct(caster.GetMaxPower(PowerType.Mana), multiplier); - caster.CastCustomSpell(caster, 47755, basepoints0, 0, 0, true); + CastSpellExtraArgs args = new CastSpellExtraArgs(TriggerCastFlags.FullMask); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, MathFunctions.CalculatePct(caster.GetMaxPower(PowerType.Mana), multiplier)); + caster.CastSpell(caster, 47755, args); } } } @@ -1329,25 +1331,6 @@ namespace Game.Spells // mods at aura apply or remove switch (GetSpellInfo().SpellFamilyName) { - case SpellFamilyNames.Rogue: - // Stealth - if (GetSpellInfo().SpellFamilyFlags[0].HasAnyFlag(0x00400000u)) - { - // Master of subtlety - AuraEffect aurEff = target.GetAuraEffect(31223, 0); - if (aurEff != null) - { - if (!apply) - target.CastSpell(target, 31666, true); - else - { - int basepoints0 = aurEff.GetAmount(); - target.CastCustomSpell(target, 31665, basepoints0, 0, 0, true); - } - } - break; - } - break; case SpellFamilyNames.Hunter: switch (GetId()) { @@ -1360,7 +1343,7 @@ namespace Game.Spells if (owner.HasAura(34692)) { if (apply) - owner.CastSpell(owner, 34471, true, null, GetEffect(0)); + owner.CastSpell(owner, 34471, new CastSpellExtraArgs(GetEffect(0))); else owner.RemoveAurasDueToSpell(34471); } @@ -1383,7 +1366,7 @@ namespace Game.Spells if (apply) { if ((GetSpellInfo().Id == 31821 && target.HasAura(19746, GetCasterGUID())) || (GetSpellInfo().Id == 19746 && target.HasAura(31821))) - target.CastSpell(target, 64364, true); + target.CastSpell(target, 64364, new CastSpellExtraArgs(true)); } else target.RemoveAurasDueToSpell(64364, GetCasterGUID()); @@ -1393,7 +1376,7 @@ namespace Game.Spells if (target.HasAura(70755)) { if (apply) - target.CastSpell(target, 71166, true); + target.CastSpell(target, 71166, new CastSpellExtraArgs(true)); else target.RemoveAurasDueToSpell(71166); } @@ -1409,7 +1392,7 @@ namespace Game.Spells if (apply) { if (target != caster && !target.HealthAbovePct(25)) - caster.CastSpell(caster, 100001, true); + caster.CastSpell(caster, 100001, new CastSpellExtraArgs(true)); } else { diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index e4c162d4a..90fa648f3 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -678,16 +678,16 @@ namespace Game.Spells if (apply) { if (spellId != 0) - target.CastSpell(target, spellId, true, null, this); + target.CastSpell(target, spellId, new CastSpellExtraArgs(this)); if (spellId2 != 0) - target.CastSpell(target, spellId2, true, null, this); + target.CastSpell(target, spellId2, new CastSpellExtraArgs(this)); if (spellId3 != 0) - target.CastSpell(target, spellId3, true, null, this); + target.CastSpell(target, spellId3, new CastSpellExtraArgs(this)); if (spellId4 != 0) - target.CastSpell(target, spellId4, true, null, this); + target.CastSpell(target, spellId4, new CastSpellExtraArgs(this)); if (target.IsTypeId(TypeId.Player)) { @@ -711,7 +711,7 @@ namespace Game.Spells continue; if (Convert.ToBoolean(spellInfo.Stances & (1ul << (GetMiscValue() - 1)))) - target.CastSpell(target, pair.Key, true, null, this); + target.CastSpell(target, pair.Key, new CastSpellExtraArgs(this)); } } } @@ -1246,13 +1246,13 @@ namespace Game.Spells case ShapeShiftForm.CatForm: AuraEffect dummy = target.GetAuraEffect(37315, 0); if (dummy != null) - target.CastSpell(target, 37316, true, null, dummy); + target.CastSpell(target, 37316, new CastSpellExtraArgs(dummy)); break; // Nordrassil Regalia - bonus case ShapeShiftForm.MoonkinForm: dummy = target.GetAuraEffect(37324, 0); if (dummy != null) - target.CastSpell(target, 37325, true, null, dummy); + target.CastSpell(target, 37325, new CastSpellExtraArgs(dummy)); break; default: break; @@ -2062,7 +2062,7 @@ namespace Game.Spells { var mountCapability = CliDB.MountCapabilityStorage.LookupByKey(GetAmount()); if (mountCapability != null) - target.CastSpell(target, mountCapability.ModSpellAuraID, true); + target.CastSpell(target, mountCapability.ModSpellAuraID, new CastSpellExtraArgs(true)); } } else @@ -4064,7 +4064,7 @@ namespace Game.Spells case 13139: // net-o-matic // root to self part of (root_target.charge.root_self sequence if (caster != null) - caster.CastSpell(caster, 13138, true, null, this); + caster.CastSpell(caster, 13138, new CastSpellExtraArgs(this)); break; case 34026: // kill command { @@ -4072,7 +4072,7 @@ namespace Game.Spells if (pet == null) break; - target.CastSpell(target, 34027, true, null, this); + target.CastSpell(target, 34027, new CastSpellExtraArgs(this)); // set 3 stacks and 3 charges (to make all auras not disappear at once) Aura owner_aura = target.GetAura(34027, GetCasterGUID()); @@ -4093,15 +4093,15 @@ namespace Game.Spells if (caster != null) { if (caster.GetGender() == Gender.Female) - caster.CastSpell(target, 37095, true, null, this); // Blood Elf Disguise + caster.CastSpell(target, 37095, new CastSpellExtraArgs(this)); // Blood Elf Disguise else - caster.CastSpell(target, 37093, true, null, this); + caster.CastSpell(target, 37093, new CastSpellExtraArgs(this)); } break; } case 39850: // Rocket Blast if (RandomHelper.randChance(20)) // backfire stun - target.CastSpell(target, 51581, true, null, this); + target.CastSpell(target, 51581, new CastSpellExtraArgs(this)); break; case 43873: // Headless Horseman Laugh target.PlayDistanceSound(11965); @@ -4110,9 +4110,9 @@ namespace Game.Spells if (caster != null) { if (caster.GetGender() == Gender.Female) - caster.CastSpell(target, 46356, true, null, this); + caster.CastSpell(target, 46356, new CastSpellExtraArgs(this)); else - caster.CastSpell(target, 46355, true, null, this); + caster.CastSpell(target, 46355, new CastSpellExtraArgs(this)); } break; case 46361: // Reinforced Net @@ -4186,7 +4186,7 @@ namespace Game.Spells } if (finalSpelId != 0) - caster.CastSpell(target, finalSpelId, true, null, this); + caster.CastSpell(target, finalSpelId, new CastSpellExtraArgs(this)); } switch (m_spellInfo.SpellFamilyName) @@ -4208,7 +4208,7 @@ namespace Game.Spells break; case 36730: // Flame Strike { - target.CastSpell(target, 36731, true, null, this); + target.CastSpell(target, 36731, new CastSpellExtraArgs(this)); break; } case 44191: // Flame Strike @@ -4217,7 +4217,7 @@ namespace Game.Spells { uint spellId = (uint)(target.GetMap().IsHeroic() ? 46163 : 44190); - target.CastSpell(target, spellId, true, null, this); + target.CastSpell(target, spellId, new CastSpellExtraArgs(this)); } break; } @@ -4231,25 +4231,25 @@ namespace Game.Spells break; } case 42783: // Wrath of the Astromancer - target.CastSpell(target, (uint)GetAmount(), true, null, this); + target.CastSpell(target, (uint)GetAmount(), new CastSpellExtraArgs(this)); break; case 46308: // Burning Winds casted only at creatures at spawn - target.CastSpell(target, 47287, true, null, this); + target.CastSpell(target, 47287, new CastSpellExtraArgs(this)); break; case 52172: // Coyote Spirit Despawn Aura case 60244: // Blood Parrot Despawn Aura - target.CastSpell((Unit)null, (uint)GetAmount(), true, null, this); + target.CastSpell((Unit)null, (uint)GetAmount(), new CastSpellExtraArgs(this)); break; case 91604: // Restricted Flight Area if (aurApp.GetRemoveMode() == AuraRemoveMode.Expire) - target.CastSpell(target, 58601, true); + target.CastSpell(target, 58601, new CastSpellExtraArgs(true)); break; } break; case SpellFamilyNames.Deathknight: // Summon Gargoyle (Dismiss Gargoyle at remove) if (GetId() == 61777) - target.CastSpell(target, (uint)GetAmount(), true); + target.CastSpell(target, (uint)GetAmount(), new CastSpellExtraArgs(true)); break; default: break; @@ -4278,9 +4278,13 @@ namespace Game.Spells if (apply && caster != null) { SpellInfo spell = Global.SpellMgr.GetSpellInfo(spellId, GetBase().GetCastDifficulty()); + CastSpellExtraArgs args = new(); + args.TriggerFlags = TriggerCastFlags.FullMask; + args.OriginalCaster = GetCasterGUID(); + args.CastDifficulty = spell.Difficulty; for (uint i = 0; i < spell.StackAmount; ++i) - caster.CastSpell(target, spell, true, null, null, GetCasterGUID()); + caster.CastSpell(target, spell.Id, args); break; } target.RemoveAurasDueToSpell(spellId); @@ -4293,8 +4297,12 @@ namespace Game.Spells if (apply && caster != null) { SpellInfo spell = Global.SpellMgr.GetSpellInfo(spellId, GetBase().GetCastDifficulty()); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.OriginalCaster = GetCasterGUID(); + args.CastDifficulty = spell.Difficulty; + for (uint i = 0; i < spell.StackAmount; ++i) - caster.CastSpell(target, spell, true, null, null, GetCasterGUID()); + caster.CastSpell(target, spell.Id, args); break; } target.RemoveAurasDueToSpell(spellId); @@ -4347,7 +4355,7 @@ namespace Game.Spells target.PlayDirectSound(14970, target.ToPlayer()); // continue in 58205 else - target.CastSpell(target, 58205, true); + target.CastSpell(target, 58205, new CastSpellExtraArgs(true)); } break; // LK Intro VO (2) @@ -4561,11 +4569,12 @@ namespace Game.Spells { if (apply) { - // If amount avalible cast with basepoints (Crypt Fever for example) - if (GetAmount() != 0) - caster.CastCustomSpell(target, triggeredSpellId, m_amount, 0, 0, true, null, this); - else - caster.CastSpell(target, triggeredSpellId, true, null, this); + CastSpellExtraArgs args = new(this); + + if (GetAmount() != 0) // If amount avalible cast with basepoints (Crypt Fever for example) + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, GetAmount()); + + caster.CastSpell(target, triggeredSpellId, args); } else { @@ -4609,7 +4618,7 @@ namespace Game.Spells break; } - target.CastSpell(target, triggerSpell, true); + target.CastSpell(target, triggerSpell, new CastSpellExtraArgs(true)); } [AuraEffectHandler(AuraType.TriggerSpellOnPowerAmount)] @@ -4638,7 +4647,7 @@ namespace Game.Spells break; } - target.CastSpell(target, triggerSpell, true); + target.CastSpell(target, triggerSpell, new CastSpellExtraArgs(true)); } [AuraEffectHandler(AuraType.OpenStable)] @@ -4808,12 +4817,12 @@ namespace Game.Spells Unit triggerCaster = triggeredSpellInfo.NeedsToBeTriggeredByCaster(m_spellInfo) ? caster : target; if (triggerCaster != null) { - triggerCaster.CastSpell(target, triggeredSpellInfo, true, null, this); + triggerCaster.CastSpell(target, triggerSpellId, new CastSpellExtraArgs(this)); Log.outDebug(LogFilter.Spells, "AuraEffect.HandlePeriodicTriggerSpellAuraTick: Spell {0} Trigger {1}", GetId(), triggeredSpellInfo.Id); } } else - Log.outDebug(LogFilter.Spells, "AuraEffect.HandlePeriodicTriggerSpellAuraTick: Spell {0} has non-existent spell {1} in EffectTriggered[{2}] and is therefor not triggered.", GetId(), triggerSpellId, GetEffIndex()); + Log.outWarn(LogFilter.Spells, "AuraEffect.HandlePeriodicTriggerSpellAuraTick: Spell {0} has non-existent spell {1} in EffectTriggered[{2}] and is therefor not triggered.", GetId(), triggerSpellId, GetEffIndex()); } void HandlePeriodicTriggerSpellWithValueAuraTick(Unit target, Unit caster) @@ -4825,13 +4834,16 @@ namespace Game.Spells Unit triggerCaster = triggeredSpellInfo.NeedsToBeTriggeredByCaster(m_spellInfo) ? caster : target; if (triggerCaster != null) { - int basepoints = GetAmount(); - triggerCaster.CastCustomSpell(target, triggerSpellId, basepoints, basepoints, basepoints, true, null, this); + CastSpellExtraArgs args = new(this); + for (int i = 0; i < SpellConst.MaxEffects; ++i) + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, GetAmount()); + + triggerCaster.CastSpell(target, triggerSpellId, args); Log.outDebug(LogFilter.Spells, "AuraEffect.HandlePeriodicTriggerSpellWithValueAuraTick: Spell {0} Trigger {1}", GetId(), triggeredSpellInfo.Id); } } else - Log.outDebug(LogFilter.Spells, "AuraEffect.HandlePeriodicTriggerSpellWithValueAuraTick: Spell {0} has non-existent spell {1} in EffectTriggered[{2}] and is therefor not triggered.", GetId(), triggerSpellId, GetEffIndex()); + Log.outWarn(LogFilter.Spells, "AuraEffect.HandlePeriodicTriggerSpellWithValueAuraTick: Spell {0} has non-existent spell {1} in EffectTriggered[{2}] and is therefor not triggered.", GetId(), triggerSpellId, GetEffIndex()); } void HandlePeriodicDamageAurasTick(Unit target, Unit caster) @@ -4880,7 +4892,7 @@ namespace Game.Spells if (GetSpellInfo().SpellFamilyName == SpellFamilyNames.Warlock && GetSpellInfo().SpellFamilyFlags[0].HasAnyFlag(0x00004000u)) { if (caster.IsTypeId(TypeId.Player) && caster.ToPlayer().IsHonorOrXPTarget(target)) - caster.CastSpell(caster, 95810, true, null, this); + caster.CastSpell(caster, 95810, new CastSpellExtraArgs(this)); } if (GetSpellInfo().SpellFamilyName == SpellFamilyNames.Generic) @@ -5231,7 +5243,10 @@ namespace Game.Spells if (manaFeedVal > 0) { int feedAmount = MathFunctions.CalculatePct(gainedAmount, manaFeedVal); - caster.CastCustomSpell(caster, 32554, feedAmount, 0, 0, true, null, this); + + CastSpellExtraArgs args = new(this); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, feedAmount); + caster.CastSpell(caster, 32554, args); } } @@ -5367,7 +5382,7 @@ namespace Game.Spells if (triggeredSpellInfo != null) { Log.outDebug(LogFilter.Spells, $"AuraEffect.HandleProcTriggerSpellAuraProc: Triggering spell {triggeredSpellInfo.Id} from aura {GetId()} proc"); - triggerCaster.CastSpell(triggerTarget, triggeredSpellInfo, true, null, this); + triggerCaster.CastSpell(triggerTarget, triggeredSpellInfo.Id, new CastSpellExtraArgs(this)); } else if (triggerSpellId != 0 && GetAuraType() != AuraType.Dummy) Log.outError(LogFilter.Spells, $"AuraEffect.HandleProcTriggerSpellAuraProc: Could not trigger spell {triggerSpellId} from aura {GetId()} proc, because the spell does not have an entry in Spell.dbc."); @@ -5382,9 +5397,10 @@ namespace Game.Spells SpellInfo triggeredSpellInfo = Global.SpellMgr.GetSpellInfo(triggerSpellId, GetBase().GetCastDifficulty()); if (triggeredSpellInfo != null) { - int basepoints0 = GetAmount(); - Log.outDebug(LogFilter.Spells, "AuraEffect.HandleProcTriggerSpellWithValueAuraProc: Triggering spell {0} with value {1} from aura {2} proc", triggeredSpellInfo.Id, basepoints0, GetId()); - triggerCaster.CastCustomSpell(triggerTarget, triggerSpellId, basepoints0, 0, 0, true, null, this); + CastSpellExtraArgs args = new(this); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, GetAmount()); + triggerCaster.CastSpell(triggerTarget, triggerSpellId, args); + Log.outDebug(LogFilter.Spells, "AuraEffect.HandleProcTriggerSpellWithValueAuraProc: Triggering spell {0} with value {1} from aura {2} proc", triggeredSpellInfo.Id, GetAmount(), GetId()); } else Log.outError(LogFilter.Spells, "AuraEffect.HandleProcTriggerSpellWithValueAuraProc: Could not trigger spell {0} from aura {1} proc, because the spell does not have an entry in Spell.dbc.", triggerSpellId, GetId()); @@ -5580,7 +5596,12 @@ namespace Game.Spells // on apply cast summon spell if (apply) - target.CastSpell(target, triggerSpellInfo, true, null, this); + { + CastSpellExtraArgs args = new CastSpellExtraArgs(TriggerCastFlags.FullMask); + args.TriggeringAura = this; + args.CastDifficulty = triggerSpellInfo.Difficulty; + target.CastSpell(target, triggerSpellInfo.Id, args); + } // on unapply we need to search for and remove the summoned creature else { diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 15e12a96e..40605a580 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -2026,7 +2026,7 @@ namespace Game.Spells // Check for SPELL_ATTR7_INTERRUPT_ONLY_NONPLAYER if (missInfo == SpellMissInfo.None && m_spellInfo.HasAttribute(SpellAttr7.InterruptOnlyNonplayer) && !unit.IsTypeId(TypeId.Player)) - caster.CastSpell(unit, 32747, true); + caster.CastSpell(unit, 32747, new CastSpellExtraArgs(true)); if (spellHitTarget != null) { @@ -2149,7 +2149,7 @@ namespace Game.Spells int[] basePoints = new int[SpellConst.MaxEffects]; foreach (SpellEffectInfo auraSpellEffect in m_spellInfo.GetEffects()) if (auraSpellEffect != null) - basePoints[auraSpellEffect.EffectIndex] = (m_spellValue.CustomBasePointsMask & (1 << (int)auraSpellEffect.EffectIndex)) != 0 ? + basePoints[auraSpellEffect.EffectIndex] = (m_spellValue.CustomBasePointsMask & (1 << (int)auraSpellEffect.EffectIndex)) != 0 ? m_spellValue.EffectBasePoints[auraSpellEffect.EffectIndex] : auraSpellEffect.CalcBaseValue(m_originalCaster, unit, m_castItemEntry, m_castItemLevel); bool refresh = false; @@ -2260,7 +2260,7 @@ namespace Game.Spells { if (CanExecuteTriggersOnHit(effMask, hit.triggeredByAura) && RandomHelper.randChance(hit.chance)) { - m_caster.CastSpell(unit, hit.triggeredSpell, TriggerCastFlags.FullMask); + m_caster.CastSpell(unit, hit.triggeredSpell.Id, new CastSpellExtraArgs(TriggerCastFlags.FullMask).SetCastDifficulty(hit.triggeredSpell.Difficulty)); Log.outDebug(LogFilter.Spells, "Spell {0} triggered spell {1} by SPELL_AURA_ADD_TARGET_TRIGGER aura", m_spellInfo.Id, hit.triggeredSpell.Id); // SPELL_AURA_ADD_TARGET_TRIGGER auras shouldn't trigger auras without duration @@ -2291,9 +2291,9 @@ namespace Game.Spells foreach (var id in spellTriggered) { if (id < 0) - unit.RemoveAurasDueToSpell((uint)-(id)); + unit.RemoveAurasDueToSpell((uint)-id); else - unit.CastSpell(unit, (uint)id, true, null, null, m_caster.GetGUID()); + unit.CastSpell(unit, (uint)id, new CastSpellExtraArgs(m_caster.GetGUID())); } } } @@ -2702,7 +2702,7 @@ namespace Game.Spells // Should this be done for original caster? Player modOwner = m_caster.GetSpellModOwner(); - if (modOwner !=null) + if (modOwner != null) { // Set spell which will drop charges for triggered cast spells // if not successfully casted, will be remove in finish(false) @@ -2904,7 +2904,7 @@ namespace Game.Spells if (spellId < 0) m_caster.RemoveAurasDueToSpell((uint)-spellId); else - m_caster.CastSpell(m_targets.GetUnitTarget() ?? m_caster, (uint)spellId, true); + m_caster.CastSpell(m_targets.GetUnitTarget() ?? m_caster, (uint)spellId, new CastSpellExtraArgs(true)); } } @@ -4470,7 +4470,7 @@ namespace Game.Spells return null; } - + public SpellCastResult CheckCast(bool strict) { uint param1 = 0, param2 = 0; @@ -5167,7 +5167,7 @@ namespace Game.Spells { Pet pet = m_caster.ToPlayer().GetPet(); if (pet != null) - pet.CastSpell(pet, 32752, true, null, null, pet.GetGUID()); + pet.CastSpell(pet, 32752, new CastSpellExtraArgs(pet.GetGUID())); } } else if (!m_spellInfo.HasAttribute(SpellAttr1.DismissPet)) @@ -6169,7 +6169,7 @@ namespace Game.Spells return SpellCastResult.DontReport; } else if ((efi = m_spellInfo.GetEffect(1)) != null) - player.CastSpell(m_caster, (uint)efi.CalcValue(), false); // move this to anywhere + player.CastSpell(m_caster, (uint)efi.CalcValue(), new CastSpellExtraArgs(false)); // move this to anywhere return SpellCastResult.DontReport; } } @@ -6545,7 +6545,7 @@ namespace Game.Spells { return m_powerCost.Any(cost => cost.Power == power); } - + bool UpdatePointers() { if (m_originalCasterGUID == m_caster.GetGUID()) @@ -6620,7 +6620,7 @@ namespace Game.Spells { return m_caster.GetMap().GetDifficultyID(); } - + bool CheckEffectTarget(Unit target, SpellEffectInfo effect, Position losPosition) { if (!effect.IsEffect()) @@ -6750,7 +6750,7 @@ namespace Game.Spells { return m_spellInfo.IsPositive() && (m_triggeredByAuraSpell == null || m_triggeredByAuraSpell.IsPositive()); } - + bool IsNeedSendToClient() { return m_SpellVisual.SpellXSpellVisualID != 0 || m_SpellVisual.ScriptVisualID != 0 || m_spellInfo.IsChanneled() || @@ -7152,7 +7152,7 @@ namespace Game.Spells loadedScript._FinishScriptCall(); } } - + void CallScriptObjectAreaTargetSelectHandlers(List targets, uint effIndex, SpellImplicitTargetInfo targetType) { foreach (var script in m_loadedScripts) @@ -8141,4 +8141,91 @@ namespace Game.Spells Unit _victim; ObjectGuid _casterGuid; } + + public class CastSpellExtraArgs + { + public TriggerCastFlags TriggerFlags; + public Item CastItem; + public AuraEffect TriggeringAura; + public ObjectGuid OriginalCaster = ObjectGuid.Empty; + public Difficulty CastDifficulty; + public Dictionary SpellValueOverrides = new(); + + public CastSpellExtraArgs() { } + public CastSpellExtraArgs(bool triggered) + { + TriggerFlags = triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None; + } + + public CastSpellExtraArgs(TriggerCastFlags trigger) + { + TriggerFlags = trigger; + } + + public CastSpellExtraArgs(Item item) + { + TriggerFlags = TriggerCastFlags.FullMask; + CastItem = item; + } + + public CastSpellExtraArgs(AuraEffect eff) + { + TriggerFlags = TriggerCastFlags.FullMask; + TriggeringAura = eff; + } + + public CastSpellExtraArgs(ObjectGuid origCaster) + { + TriggerFlags = TriggerCastFlags.FullMask; + OriginalCaster = origCaster; + } + + public CastSpellExtraArgs(AuraEffect eff, ObjectGuid origCaster) + { + TriggerFlags = TriggerCastFlags.FullMask; + TriggeringAura = eff; + OriginalCaster = origCaster; + } + + public CastSpellExtraArgs(Difficulty castDifficulty) + { + CastDifficulty = castDifficulty; + } + + public CastSpellExtraArgs(SpellValueMod mod, int val) + { + SpellValueOverrides.Add(mod, val); + } + + public CastSpellExtraArgs SetTriggerFlags(TriggerCastFlags flag) + { + TriggerFlags = flag; + return this; + } + public CastSpellExtraArgs SetCastItem(Item item) + { + CastItem = item; + return this; + } + public CastSpellExtraArgs SetTriggeringAura(AuraEffect triggeringAura) + { + TriggeringAura = triggeringAura; + return this; + } + public CastSpellExtraArgs SetOriginalCaster(ObjectGuid guid) + { + OriginalCaster = guid; + return this; + } + public CastSpellExtraArgs SetCastDifficulty(Difficulty castDifficulty) + { + CastDifficulty = castDifficulty; + return this; + } + public CastSpellExtraArgs AddSpellMod(SpellValueMod mod, int val) + { + SpellValueOverrides.Add(mod, val); + return this; + } + } } diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index 22584fdfc..714aa56fe 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -385,17 +385,14 @@ namespace Game.Spells targets.SetUnitTarget(m_caster); } - Dictionary values = new(); + CastSpellExtraArgs args = new(m_originalCasterGUID); // set basepoints for trigger with value effect if (effectInfo.Effect == SpellEffectName.TriggerSpellWithValue) - { - values.Add(SpellValueMod.BasePoint0, damage); - values.Add(SpellValueMod.BasePoint1, damage); - values.Add(SpellValueMod.BasePoint2, damage); - } + for (int i = 0; i < SpellConst.MaxEffects; ++i) + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, damage); // original caster guid only for GO cast - m_caster.CastSpell(targets, spellInfo, values, TriggerCastFlags.FullMask, null, null, m_originalCasterGUID); + m_caster.CastSpell(targets, spellInfo.Id, args); } [SpellEffectHandler(SpellEffectName.TriggerMissile)] @@ -434,18 +431,14 @@ namespace Game.Spells targets.SetUnitTarget(m_caster); } - Dictionary values = new(); + CastSpellExtraArgs args = new(m_originalCasterGUID); // set basepoints for trigger with value effect if (effectInfo.Effect == SpellEffectName.TriggerMissileSpellWithValue) - { - // maybe need to set value only when basepoints == 0? - values.Add(SpellValueMod.BasePoint0, damage); - values.Add(SpellValueMod.BasePoint1, damage); - values.Add(SpellValueMod.BasePoint2, damage); - } + for (int i = 0; i < SpellConst.MaxEffects; ++i) + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, damage); // original caster guid only for GO cast - m_caster.CastSpell(targets, spellInfo, values, TriggerCastFlags.FullMask, null, null, m_originalCasterGUID); + m_caster.CastSpell(targets, spellInfo.Id, args); } [SpellEffectHandler(SpellEffectName.ForceCast)] @@ -479,25 +472,29 @@ namespace Game.Spells break; case 52463: // Hide In Mine Car case 52349: // Overtake - unitTarget.CastCustomSpell(unitTarget, spellInfo.Id, damage, 0, 0, true, null, null, m_originalCasterGUID); - return; + { + CastSpellExtraArgs args1 = new(m_originalCasterGUID); + args1.SpellValueOverrides.Add(SpellValueMod.BasePoint0, damage); + unitTarget.CastSpell(unitTarget, spellInfo.Id, args1); + return; + } } } - Dictionary values = new(); - // set basepoints for trigger with value effect - if (effectInfo.Effect == SpellEffectName.ForceCastWithValue) + switch (spellInfo.Id) { - // maybe need to set value only when basepoints == 0? - values.Add(SpellValueMod.BasePoint0, damage); - values.Add(SpellValueMod.BasePoint1, damage); - values.Add(SpellValueMod.BasePoint2, damage); + case 72298: // Malleable Goo Summon + unitTarget.CastSpell(unitTarget, spellInfo.Id, new CastSpellExtraArgs(m_originalCasterGUID)); + return; } - SpellCastTargets targets = new(); - targets.SetUnitTarget(m_caster); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + // set basepoints for trigger with value effect + if (effectInfo.Effect == SpellEffectName.ForceCastWithValue) + for (int i = 0; i < SpellConst.MaxEffects; ++i) + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, damage); - unitTarget.CastSpell(targets, spellInfo, values, TriggerCastFlags.FullMask); + unitTarget.CastSpell(m_caster, spellInfo.Id, args); } [SpellEffectHandler(SpellEffectName.TriggerSpell2)] @@ -516,7 +513,7 @@ namespace Game.Spells Finish(); - m_caster.CastSpell(null, spellInfo, false); + m_caster.CastSpell((Unit)null, spellInfo.Id, new CastSpellExtraArgs(false)); } [SpellEffectHandler(SpellEffectName.Jump)] @@ -1748,11 +1745,13 @@ namespace Game.Spells spellId = spellInfo.Id; } + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + // if we have small value, it indicates seat position if (basePoints > 0 && basePoints < SharedConst.MaxVehicleSeats) - m_originalCaster.CastCustomSpell(spellId, SpellValueMod.BasePoint0, basePoints, summon, true); - else - m_originalCaster.CastSpell(summon, spellId, true); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, basePoints); + + m_originalCaster.CastSpell(summon, spellId, args); uint faction = properties.Faction; if (faction == 0) @@ -2519,7 +2518,7 @@ namespace Game.Spells // Stormstrike AuraEffect aurEff = m_caster.IsScriptOverriden(m_spellInfo, 5634); if (aurEff != null) - m_caster.CastSpell(m_caster, 38430, true, null, aurEff); + m_caster.CastSpell(m_caster, 38430, new CastSpellExtraArgs(aurEff)); break; } case SpellFamilyNames.Druid: @@ -2796,7 +2795,7 @@ namespace Game.Spells switch (m_spellInfo.Id) { case 45204: // Clone Me! - m_caster.CastSpell(unitTarget, (uint)damage, true); + m_caster.CastSpell(unitTarget, (uint)damage, new CastSpellExtraArgs(true)); break; case 55693: // Remove Collapsing Cave Aura if (unitTarget == null) @@ -2811,7 +2810,7 @@ namespace Game.Spells uint spell_id = RandomHelper.Rand32(20) != 0 ? 8854u : 8855u; - m_caster.CastSpell(m_caster, spell_id, true, null); + m_caster.CastSpell(m_caster, spell_id, new CastSpellExtraArgs(true)); return; } // Brittle Armor - need remove one 24575 Brittle Armor aura @@ -2845,7 +2844,7 @@ namespace Game.Spells return; // Shadow Flame - m_caster.CastSpell(unitTarget, 22682, true); + m_caster.CastSpell(unitTarget, 22682, new CastSpellExtraArgs(true)); return; } // Mirren's Drinking Hat @@ -2917,7 +2916,7 @@ namespace Game.Spells if (m_caster.ToPlayer().GetItemByPos(bag, slot).GetCount() == 1) m_caster.ToPlayer().RemoveItem(bag, slot, true); else m_caster.ToPlayer().GetItemByPos(bag, slot).SetCount(m_caster.ToPlayer().GetItemByPos(bag, slot).GetCount() - 1); // Spell 42518 (Braufest - Gratisprobe des Braufest herstellen) - m_caster.CastSpell(m_caster, 42518, true); + m_caster.CastSpell(m_caster, 42518, new CastSpellExtraArgs(true)); return; } break; @@ -2929,7 +2928,7 @@ namespace Game.Spells //Workaround for Range ... should be global for every ScriptEffect float radius = effectInfo.CalcRadius(); if (unitTarget != null && unitTarget.IsTypeId(TypeId.Player) && unitTarget.GetDistance(m_caster) >= radius && !unitTarget.HasAura(46394) && unitTarget != m_caster) - unitTarget.CastSpell(unitTarget, 46394, true); + unitTarget.CastSpell(unitTarget, 46394, new CastSpellExtraArgs(true)); break; } @@ -2947,7 +2946,7 @@ namespace Game.Spells case 2: spellId = 46738; break; case 3: spellId = 46736; break; } - unitTarget.CastSpell(unitTarget, spellId, true); + unitTarget.CastSpell(unitTarget, spellId, new CastSpellExtraArgs(true)); break; } // 5, 000 Gold @@ -2992,7 +2991,7 @@ namespace Game.Spells default: return; } - unitTarget.CastSpell(unitTarget, iTmpSpellId, true); + unitTarget.CastSpell(unitTarget, iTmpSpellId, new CastSpellExtraArgs(true)); Creature npc = unitTarget.ToCreature(); npc.LoadEquipment(); return; @@ -3003,7 +3002,7 @@ namespace Game.Spells if (m_originalCaster == null) return; - m_originalCaster.CastSpell(m_originalCaster, (uint)damage, false); + m_originalCaster.CastSpell(m_originalCaster, (uint)damage, new CastSpellExtraArgs(false)); break; } // Deathbolt from Thalgran Blightbringer @@ -3014,9 +3013,9 @@ namespace Game.Spells if (unitTarget == null) return; if (unitTarget.HasAura(51845)) - unitTarget.CastSpell(m_caster, 51856, true); + unitTarget.CastSpell(m_caster, 51856, new CastSpellExtraArgs(true)); else - m_caster.CastSpell(unitTarget, 51855, true); + m_caster.CastSpell(unitTarget, 51855, new CastSpellExtraArgs(true)); break; } // Summon Ghouls On Scarlet Crusade @@ -3030,7 +3029,7 @@ namespace Game.Spells for (byte i = 0; i < 15; ++i) { m_caster.GetRandomPoint(destTarget, radius, out x, out y, out z); - m_caster.CastSpell(x, y, z, 54522, true); + m_caster.CastSpell(new Position(x, y, z), 54522, new CastSpellExtraArgs(true)); } break; } @@ -3041,11 +3040,11 @@ namespace Game.Spells return; case 52479: // Gift of the Harvester if (unitTarget != null && m_originalCaster != null) - m_originalCaster.CastSpell(unitTarget, Convert.ToBoolean(RandomHelper.IRand(0, 1)) ? (uint)damage : 52505, true); + m_originalCaster.CastSpell(unitTarget, Convert.ToBoolean(RandomHelper.IRand(0, 1)) ? (uint)damage : 52505, new CastSpellExtraArgs(true)); return; case 53110: // Devour Humanoid if (unitTarget != null) - unitTarget.CastSpell(m_caster, (uint)damage, true); + unitTarget.CastSpell(m_caster, (uint)damage, new CastSpellExtraArgs(true)); return; case 57347: // Retrieving (Wintergrasp RP-GG pickup spell) { @@ -3076,7 +3075,7 @@ namespace Game.Spells uint questID = (uint)m_spellInfo.GetEffect(1).CalcValue(); if (unitTarget.ToPlayer().GetQuestStatus(questID) == QuestStatus.Complete) - unitTarget.CastSpell(unitTarget, spellID, true); + unitTarget.CastSpell(unitTarget, spellID, new CastSpellExtraArgs(true)); return; } @@ -3085,18 +3084,18 @@ namespace Game.Spells { for (uint i = 0; i < 3; ++i) { - m_originalCaster.CastSpell(unitTarget, 58689, true); - m_originalCaster.CastSpell(unitTarget, 58692, true); + m_originalCaster.CastSpell(unitTarget, 58689, new CastSpellExtraArgs(true)); + m_originalCaster.CastSpell(unitTarget, 58692, new CastSpellExtraArgs(true)); } if (m_originalCaster.GetMap().GetDifficultyID() == Difficulty.None) { - m_originalCaster.CastSpell(unitTarget, 58695, true); - m_originalCaster.CastSpell(unitTarget, 58696, true); + m_originalCaster.CastSpell(unitTarget, 58695, new CastSpellExtraArgs(true)); + m_originalCaster.CastSpell(unitTarget, 58696, new CastSpellExtraArgs(true)); } else { - m_originalCaster.CastSpell(unitTarget, 60883, true); - m_originalCaster.CastSpell(unitTarget, 60884, true); + m_originalCaster.CastSpell(unitTarget, 60883, new CastSpellExtraArgs(true)); + m_originalCaster.CastSpell(unitTarget, 60884, new CastSpellExtraArgs(true)); } } return; @@ -3108,10 +3107,10 @@ namespace Game.Spells // return from top if (unitTarget.ToPlayer().GetAreaId() == 4637) - unitTarget.CastSpell(unitTarget, 59316, true); + unitTarget.CastSpell(unitTarget, 59316, new CastSpellExtraArgs(true)); // teleport atop else - unitTarget.CastSpell(unitTarget, 59314, true); + unitTarget.CastSpell(unitTarget, 59314, new CastSpellExtraArgs(true)); return; } @@ -3126,7 +3125,7 @@ namespace Game.Spells if (parent != null) { // @todo a hack, range = 11, should after some time cast, otherwise too far - m_caster.CastSpell(parent, 62496, true); + m_caster.CastSpell(parent, 62496, new CastSpellExtraArgs(true)); unitTarget.CastSpell(parent, (uint)m_spellInfo.GetEffect(0).CalcValue()); } } @@ -3157,7 +3156,7 @@ namespace Game.Spells Aura chargesAura = m_caster.GetAura(59907); if (chargesAura != null) { - m_caster.CastSpell(unitTarget, spell_heal, true, null, null, m_caster.ToTempSummon().GetSummonerGUID()); + m_caster.CastSpell(unitTarget, spell_heal, new CastSpellExtraArgs(m_caster.ToTempSummon().GetSummonerGUID())); if (chargesAura.ModCharges(-1)) m_caster.ToTempSummon().UnSummon(); } @@ -3176,7 +3175,6 @@ namespace Game.Spells case 58590: // Rank 9 case 58591: // Rank 10 { - int basepoints0 = damage; // Cast Absorb on totems for (byte slot = (int)SummonSlot.Totem; slot < SharedConst.MaxTotemSlot; ++slot) { @@ -3186,7 +3184,9 @@ namespace Game.Spells Creature totem = unitTarget.GetMap().GetCreature(unitTarget.m_SummonSlot[slot]); if (totem != null && totem.IsTotem()) { - m_caster.CastCustomSpell(totem, 55277, basepoints0, 0, 0, true); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, damage); + m_caster.CastSpell(totem, 55277, args); } } break; @@ -3588,7 +3588,9 @@ namespace Game.Spells player.DestroyItemCount(foodItem, ref count, true); // @todo fix crash when a spell has two effects, both pointed at the same item target - m_caster.CastCustomSpell(pet, effectInfo.TriggerSpell, benefit, 0, 0, true); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, benefit); + m_caster.CastSpell(pet, effectInfo.TriggerSpell, args); } [SpellEffectHandler(SpellEffectName.DismissPet)] @@ -3962,7 +3964,7 @@ namespace Game.Spells m_caster.Attack(unitTarget, true); if (effectInfo.TriggerSpell != 0) - m_caster.CastSpell(unitTarget, effectInfo.TriggerSpell, true, null, null, m_originalCasterGUID); + m_caster.CastSpell(unitTarget, effectInfo.TriggerSpell, new CastSpellExtraArgs(m_originalCasterGUID)); } } @@ -3987,7 +3989,7 @@ namespace Game.Spells else if (effectHandleMode == SpellEffectHandleMode.Hit) { if (effectInfo.TriggerSpell != 0) - m_caster.CastSpell(destTarget.GetPositionX(), destTarget.GetPositionY(), destTarget.GetPositionZ(), effectInfo.TriggerSpell, true, null, null, m_originalCasterGUID); + m_caster.CastSpell(destTarget, effectInfo.TriggerSpell, new CastSpellExtraArgs(m_originalCasterGUID)); } } @@ -4269,7 +4271,11 @@ namespace Game.Spells } MathFunctions.ApplyPct(ref mana, damage); if (mana != 0) - m_caster.CastCustomSpell(m_caster, 39104, mana, 0, 0, true); + { + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, mana); + m_caster.CastSpell(m_caster, 39104, args); + } } [SpellEffectHandler(SpellEffectName.DurabilityDamage)] @@ -5073,8 +5079,9 @@ namespace Game.Spells if (!spellInfo.HasAttribute(SpellAttr9.SummonPlayerTotem)) continue; - TriggerCastFlags triggerFlags = (TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreCastInProgress | TriggerCastFlags.CastDirectly | TriggerCastFlags.DontReportCastError); - m_caster.CastSpell(m_caster, spellInfo, triggerFlags); + CastSpellExtraArgs args = new(TriggerCastFlags.IgnoreGCD | TriggerCastFlags.IgnoreCastInProgress | TriggerCastFlags.CastDirectly | TriggerCastFlags.DontReportCastError); + args.CastDifficulty = GetCastDifficulty(); + m_caster.CastSpell(m_caster, spellInfo.Id, args); } } diff --git a/Source/Game/Spells/SpellManager.cs b/Source/Game/Spells/SpellManager.cs index 87294d92e..11240a5ee 100644 --- a/Source/Game/Spells/SpellManager.cs +++ b/Source/Game/Spells/SpellManager.cs @@ -3053,6 +3053,7 @@ namespace Game.Entities case 52449: // Summon Skittering Infector (Force Cast) case 53609: // Summon Anub'ar Assassin (Force Cast) case 53457: // Summon Impale Trigger (AoE) + case 45907: // Torch Target Picker spellInfo.MaxAffectedTargets = 1; break; case 36384: // Skartax Purple Beam diff --git a/Source/Scripts/Pets/Generic.cs b/Source/Scripts/Pets/Generic.cs index 82d30fb76..403451642 100644 --- a/Source/Scripts/Pets/Generic.cs +++ b/Source/Scripts/Pets/Generic.cs @@ -74,8 +74,8 @@ namespace Scripts.Pets _victimGUID = player.GetGUID(); - DoCast(player, SpellIds.FeelingFroggy, true); - DoCast(me, SpellIds.SeductionVisual, true); + DoCast(player, SpellIds.FeelingFroggy, new Game.Spells.CastSpellExtraArgs(true)); + DoCast(me, SpellIds.SeductionVisual, new Game.Spells.CastSpellExtraArgs(true)); me.GetMotionMaster().MoveFollow(player, 0.0f, 0.0f); } diff --git a/Source/Scripts/Pets/Hunter.cs b/Source/Scripts/Pets/Hunter.cs index 433bc7697..c7ecf318b 100644 --- a/Source/Scripts/Pets/Hunter.cs +++ b/Source/Scripts/Pets/Hunter.cs @@ -19,6 +19,7 @@ using Framework.Constants; using Game.AI; using Game.Entities; using Game.Scripting; +using Game.Spells; namespace Scripts.Pets { @@ -68,7 +69,7 @@ namespace Scripts.Pets } if (!_isViper) - DoCast(me, SpellIds.DeadlyPoisonPassive, true); + DoCast(me, SpellIds.DeadlyPoisonPassive, new CastSpellExtraArgs(true)); } // Redefined for random target selection: diff --git a/Source/Scripts/Pets/Priest.cs b/Source/Scripts/Pets/Priest.cs index d0baf33e6..8bea44d4b 100644 --- a/Source/Scripts/Pets/Priest.cs +++ b/Source/Scripts/Pets/Priest.cs @@ -36,7 +36,7 @@ namespace Scripts.Pets { public npc_pet_pri_lightwell(Creature creature) : base(creature) { - DoCast(creature, SpellIds.LightWellCharges, false); + DoCast(creature, SpellIds.LightWellCharges, new Game.Spells.CastSpellExtraArgs(false)); } public override void EnterEvadeMode(EvadeReason why) diff --git a/Source/Scripts/Spells/DeathKnight.cs b/Source/Scripts/Spells/DeathKnight.cs index 961680e15..0448eb8c8 100644 --- a/Source/Scripts/Spells/DeathKnight.cs +++ b/Source/Scripts/Spells/DeathKnight.cs @@ -150,7 +150,9 @@ namespace Scripts.Spells.DeathKnight if (!GetTarget().HasAura(SpellIds.VolatileShielding)) { int bp = (int)(2 * absorbAmount * 100 / maxHealth); - GetTarget().CastCustomSpell(SpellIds.RunicPowerEnergize, SpellValueMod.BasePoint0, bp, GetTarget(), true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(absorbAmount, 2 * absorbAmount * 100 / maxHealth)); + GetTarget().CastSpell(GetTarget(), SpellIds.RunicPowerEnergize, args); } } @@ -159,8 +161,9 @@ namespace Scripts.Spells.DeathKnight AuraEffect volatileShielding = GetTarget().GetAuraEffect(SpellIds.VolatileShielding, 1); if (volatileShielding != null) { - int damage = (int)MathFunctions.CalculatePct(absorbedAmount, volatileShielding.GetAmount()); - GetTarget().CastCustomSpell(SpellIds.VolatileShieldingDamage, SpellValueMod.BasePoint0, damage, null, TriggerCastFlags.FullMask, null, volatileShielding); + CastSpellExtraArgs args = new(volatileShielding); + args.AddSpellMod(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(absorbedAmount, volatileShielding.GetAmount())); + GetTarget().CastSpell((Unit)null, SpellIds.VolatileShieldingDamage, args); } } @@ -292,7 +295,7 @@ namespace Scripts.Spells.DeathKnight { WorldLocation pos = GetExplTargetDest(); if (pos != null) - GetCaster().CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), SpellIds.TighteningGraspSlow, true); + GetCaster().CastSpell(pos, SpellIds.TighteningGraspSlow, new CastSpellExtraArgs(true)); } } @@ -301,6 +304,7 @@ namespace Scripts.Spells.DeathKnight OnCast.Add(new CastHandler(HandleDummy)); } } + [Script] // 43265 - Death and Decay class spell_dk_death_and_decay_AuraScript : AuraScript { @@ -308,7 +312,7 @@ namespace Scripts.Spells.DeathKnight { Unit caster = GetCaster(); if (caster) - caster.CastSpell(GetTarget(), SpellIds.DeathAndDecayDamage, true, null, aurEff); + caster.CastSpell(GetTarget(), SpellIds.DeathAndDecayDamage, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -331,7 +335,7 @@ namespace Scripts.Spells.DeathKnight caster.CastSpell(GetHitUnit(), SpellIds.DeathCoilDamage, true); AuraEffect unholyAura = caster.GetAuraEffect(SpellIds.Unholy, 6); if (unholyAura != null) // can be any effect, just here to send SpellFailedDontReport on failure - caster.CastSpell(caster, SpellIds.UnholyVigor, true, null, unholyAura); + caster.CastSpell(caster, SpellIds.UnholyVigor, new CastSpellExtraArgs(unholyAura)); } public override void Register() @@ -442,11 +446,11 @@ namespace Scripts.Spells.DeathKnight int pctOfMaxHealth = MathFunctions.CalculatePct(spellInfo.GetEffect(2).CalcValue(GetCaster()), caster.GetMaxHealth()); heal = Math.Max(heal, pctOfMaxHealth); - caster.CastCustomSpell(SpellIds.DeathStrikeHeal, SpellValueMod.BasePoint0, heal, caster, true); + caster.CastSpell(caster, SpellIds.DeathStrikeHeal, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, heal)); AuraEffect aurEff = caster.GetAuraEffect(SpellIds.BloodShieldMastery, 0); if (aurEff != null) - caster.CastCustomSpell(SpellIds.BloodShieldAbsorb, SpellValueMod.BasePoint0, MathFunctions.CalculatePct(heal, aurEff.GetAmount()), caster); + caster.CastSpell(caster, SpellIds.BloodShieldAbsorb, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, MathFunctions.CalculatePct(heal, aurEff.GetAmount()))); if (caster.HasAura(SpellIds.Frost)) caster.CastSpell(GetHitUnit(), SpellIds.DeathStrikeOffhand, true); @@ -513,7 +517,7 @@ namespace Scripts.Spells.DeathKnight void HandleScriptEffect(uint effIndex) { - GetCaster().CastCustomSpell(SpellIds.FesteringWound, SpellValueMod.AuraStack, GetEffectValue(), GetHitUnit(), TriggerCastFlags.FullMask); + GetCaster().CastSpell(GetHitUnit(), SpellIds.FesteringWound, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.AuraStack, GetEffectValue())); } public override void Register() diff --git a/Source/Scripts/Spells/DemonHunter.cs b/Source/Scripts/Spells/DemonHunter.cs index 77cbfd7d2..80c7f1862 100644 --- a/Source/Scripts/Spells/DemonHunter.cs +++ b/Source/Scripts/Spells/DemonHunter.cs @@ -38,7 +38,7 @@ namespace Scripts.Spells.DemonHunter void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastCustomSpell(SpellIds.ChaosStrikeEnergize, SpellValueMod.BasePoint0, aurEff.GetAmount(), GetTarget(), true, null, aurEff); + GetTarget().CastSpell(GetTarget(), SpellIds.ChaosStrikeEnergize, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, aurEff.GetAmount()).SetTriggeringAura(aurEff)); } public override void Register() diff --git a/Source/Scripts/Spells/Druid.cs b/Source/Scripts/Spells/Druid.cs index 47e544bda..1f608aadb 100644 --- a/Source/Scripts/Spells/Druid.cs +++ b/Source/Scripts/Spells/Druid.cs @@ -154,7 +154,7 @@ namespace Scripts.Spells.Druid Unit target = GetTarget(); Unit attacker = dmgInfo.GetAttacker(); if (attacker != null) - target.CastCustomSpell(SpellIds.BramblesRelect, SpellValueMod.BasePoint0, (int)absorbAmount, attacker, TriggerCastFlags.FullMask); + target.CastSpell(attacker, SpellIds.BramblesRelect, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, (int)absorbAmount)); } public override void Register() @@ -181,7 +181,7 @@ namespace Scripts.Spells.Druid Unit target = GetTarget(); uint rage = (uint)(target.GetMaxPower(PowerType.Rage) * (float)damageInfo.GetDamage() / (float)target.GetMaxHealth()); if (rage > 0) - target.CastCustomSpell(SpellIds.BristlingFurGainRage, SpellValueMod.BasePoint0, (int)rage, target, TriggerCastFlags.FullMask); + target.CastSpell(target, SpellIds.BristlingFurGainRage, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, (int)rage)); } } @@ -232,7 +232,7 @@ namespace Scripts.Spells.Druid { Aura aura = unitOwner.GetAura(spellId); if (aura == null) - unitOwner.CastCustomSpell(spellId, SpellValueMod.AuraStack, (int)amount, null, TriggerCastFlags.FullMask); + unitOwner.CastSpell(unitOwner, spellId, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.AuraStack, (int)amount)); else aura.SetStackAmount((byte)amount); } @@ -316,7 +316,7 @@ namespace Scripts.Spells.Druid void OnOwnerOutOfCombat(bool isNowInCombat) { if (!isNowInCombat) - GetTarget().CastSpell(GetTarget(), SpellIds.EclipseOoc, TriggerCastFlags.FullMask); + GetTarget().CastSpell(GetTarget(), SpellIds.EclipseOoc, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); } public override void Register() @@ -342,7 +342,7 @@ namespace Scripts.Spells.Druid else { // cast eclipse - target.CastSpell(target, eclipseAuraSpellId, TriggerCastFlags.FullMask); + target.CastSpell(target, eclipseAuraSpellId, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); // Remove stacks from other one as well // reset remaining power on other spellId @@ -524,7 +524,7 @@ namespace Scripts.Spells.Druid return; } - target.CastSpell(target, triggerspell, true, null, aurEff); + target.CastSpell(target, triggerspell, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -698,7 +698,7 @@ namespace Scripts.Spells.Druid return; if (RandomHelper.randChance(chance)) - eventInfo.GetActor().CastSpell((Unit)null, spellId, true, null, aurEff); + eventInfo.GetActor().CastSpell((Unit)null, spellId, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -715,14 +715,8 @@ namespace Scripts.Spells.Druid return ValidateSpellInfo(SpellIds.LifebloomFinalHeal, SpellIds.LifebloomEnergize); } - void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + void OnRemoveEffect(Unit target, AuraEffect aurEff, uint stack) { - // Final heal only on duration end - if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) - return; - - // final heal - uint stack = GetStackAmount(); uint healAmount = (uint)aurEff.GetAmount(); Unit caster = GetCaster(); if (caster != null) @@ -730,22 +724,34 @@ namespace Scripts.Spells.Druid healAmount = caster.SpellHealingBonusDone(GetTarget(), GetSpellInfo(), healAmount, DamageEffectType.Heal, aurEff.GetSpellEffectInfo(), stack); healAmount = GetTarget().SpellHealingBonusTaken(caster, GetSpellInfo(), healAmount, DamageEffectType.Heal, aurEff.GetSpellEffectInfo(), stack); - GetTarget().CastCustomSpell(GetTarget(), SpellIds.LifebloomFinalHeal, (int)healAmount, 0, 0, true, null, aurEff, GetCasterGUID()); - // restore mana var spellPowerCostList = GetSpellInfo().CalcPowerCost(caster, GetSpellInfo().GetSchoolMask()); var spellPowerCost = spellPowerCostList.Find(cost => cost.Power == PowerType.Mana); if (spellPowerCost != null) { - int returnMana = spellPowerCost.Amount * (int)stack / 2; - caster.CastCustomSpell(caster, SpellIds.LifebloomEnergize, returnMana, 0, 0, true, null, aurEff, GetCasterGUID()); + CastSpellExtraArgs args1 = new(aurEff); + args1.OriginalCaster = GetCasterGUID(); + args1.AddSpellMod(SpellValueMod.BasePoint0, (int)(spellPowerCost.Amount * stack / 2)); + caster.CastSpell(caster, SpellIds.LifebloomEnergize, args1); } - return; } - GetTarget().CastCustomSpell(GetTarget(), SpellIds.LifebloomFinalHeal, (int)healAmount, 0, 0, true, null, aurEff, GetCasterGUID()); + CastSpellExtraArgs args = new(aurEff); + args.OriginalCaster = GetCasterGUID(); + args.AddSpellMod(SpellValueMod.BasePoint0, (int)healAmount); + target.CastSpell(target, SpellIds.LifebloomFinalHeal, args); } + void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + // Final heal only on duration end + if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) + return; + + // final heal + OnRemoveEffect(GetTarget(), aurEff, GetStackAmount()); + } + void HandleDispel(DispelInfo dispelInfo) { Unit target = GetUnitOwner(); @@ -753,29 +759,7 @@ namespace Scripts.Spells.Druid { AuraEffect aurEff = GetEffect(1); if (aurEff != null) - { - // final heal - uint healAmount = (uint)aurEff.GetAmount(); - Unit caster = GetCaster(); - if (caster != null) - { - healAmount = caster.SpellHealingBonusDone(target, GetSpellInfo(), healAmount, DamageEffectType.Heal, aurEff.GetSpellEffectInfo(), dispelInfo.GetRemovedCharges()); - healAmount = target.SpellHealingBonusTaken(caster, GetSpellInfo(), healAmount, DamageEffectType.Heal, aurEff.GetSpellEffectInfo(), dispelInfo.GetRemovedCharges()); - target.CastCustomSpell(target, SpellIds.LifebloomFinalHeal, (int)healAmount, 0, 0, true, null, null, GetCasterGUID()); - - // restore mana - var spellPowerCostList = GetSpellInfo().CalcPowerCost(caster, GetSpellInfo().GetSchoolMask()); - var spellPowerCost = spellPowerCostList.Find(cost => cost.Power == PowerType.Mana); - if (spellPowerCost != null) - { - int returnMana = spellPowerCost.Amount * dispelInfo.GetRemovedCharges() / 2; - caster.CastCustomSpell(caster, SpellIds.LifebloomEnergize, returnMana, 0, 0, true, null, null, GetCasterGUID()); - } - return; - } - - target.CastCustomSpell(target, SpellIds.LifebloomFinalHeal, (int)healAmount, 0, 0, true, null, null, GetCasterGUID()); - } + OnRemoveEffect(target, aurEff, dispelInfo.GetRemovedCharges()); // final heal } } @@ -797,8 +781,13 @@ namespace Scripts.Spells.Druid void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - int amount = (int)MathFunctions.CalculatePct(eventInfo.GetHealInfo().GetHeal(), aurEff.GetAmount()); - GetTarget().CastCustomSpell(SpellIds.LivingSeedProc, SpellValueMod.BasePoint0, amount, eventInfo.GetProcTarget(), true, null, aurEff); + HealInfo healInfo = eventInfo.GetHealInfo(); + if (healInfo == null || healInfo.GetHeal() == 0) + return; + + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount())); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.LivingSeedProc, args); } public override void Register() @@ -818,7 +807,9 @@ namespace Scripts.Spells.Druid void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastCustomSpell(SpellIds.LivingSeedHeal, SpellValueMod.BasePoint0, aurEff.GetAmount(), GetTarget(), true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, aurEff.GetAmount()); + GetTarget().CastSpell(GetTarget(), SpellIds.LivingSeedHeal, args); } public override void Register() @@ -858,7 +849,7 @@ namespace Scripts.Spells.Druid { Unit target = GetTarget(); if (target.HasAura(SpellIds.BalanceT10Bonus)) - target.CastSpell((Unit)null, SpellIds.BalanceT10BonusProc, true, null); + target.CastSpell(null, SpellIds.BalanceT10BonusProc, true); } public override void Register() @@ -971,7 +962,7 @@ namespace Scripts.Spells.Druid void AfterApply(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit target = GetTarget(); - target.CastSpell(target, SpellIds.SavageRoar, true, null, aurEff, GetCasterGUID()); + target.CastSpell(target, SpellIds.SavageRoar, new CastSpellExtraArgs(aurEff, GetCasterGUID())); } void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) @@ -1020,8 +1011,8 @@ namespace Scripts.Spells.Druid if (GetTarget().GetShapeshiftForm() != ShapeShiftForm.CatForm || eventInfo.GetDamageInfo().GetSpellInfo().Id != SpellIds.FeralChargeCat) return; - GetTarget().CastSpell(GetTarget(), Global.SpellMgr.GetSpellWithRank(SpellIds.StampedeCatRank1, GetSpellInfo().GetRank()), true, null, aurEff); - GetTarget().CastSpell(GetTarget(), SpellIds.StampedeCatState, true, null, aurEff); + GetTarget().CastSpell(GetTarget(), Global.SpellMgr.GetSpellWithRank(SpellIds.StampedeCatRank1, GetSpellInfo().GetRank()), new CastSpellExtraArgs(aurEff)); + GetTarget().CastSpell(GetTarget(), SpellIds.StampedeCatState, new CastSpellExtraArgs(aurEff)); } void HandleEffectBearProc(AuraEffect aurEff, ProcEventInfo eventInfo) @@ -1030,7 +1021,7 @@ namespace Scripts.Spells.Druid if (GetTarget().GetShapeshiftForm() != ShapeShiftForm.BearForm || eventInfo.GetDamageInfo().GetSpellInfo().Id != SpellIds.FeralChargeBear) return; - GetTarget().CastSpell(GetTarget(), Global.SpellMgr.GetSpellWithRank(SpellIds.StampedeBearRank1, GetSpellInfo().GetRank()), true, null, aurEff); + GetTarget().CastSpell(GetTarget(), Global.SpellMgr.GetSpellWithRank(SpellIds.StampedeBearRank1, GetSpellInfo().GetRank()), new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -1120,7 +1111,9 @@ namespace Scripts.Spells.Druid void AfterApply(AuraEffect aurEff, AuraEffectHandleModes mode) { Unit target = GetTarget(); - target.CastSpell(target, SpellIds.SurvivalInstincts, true); + CastSpellExtraArgs args = new(aurEff); + args.AddSpellMod(SpellValueMod.BasePoint0, (int)target.CountPctFromMaxHealth(aurEff.GetAmount())); + target.CastSpell(target, SpellIds.SurvivalInstincts, args); } public override void Register() @@ -1162,7 +1155,7 @@ namespace Scripts.Spells.Druid void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.BlessingOfTheClaw, true, null, aurEff); + eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.BlessingOfTheClaw, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -1193,7 +1186,9 @@ namespace Scripts.Spells.Druid return; int amount = MathFunctions.CalculatePct(spellPowerCost.Amount, aurEff.GetAmount()); - caster.CastCustomSpell(SpellIds.Exhilarate, SpellValueMod.BasePoint0, amount, null, true, null, aurEff); + CastSpellExtraArgs args = new (aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, amount); + caster.CastSpell((Unit)null, SpellIds.Exhilarate, args); } public override void Register() @@ -1214,7 +1209,7 @@ namespace Scripts.Spells.Druid void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - eventInfo.GetActor().CastSpell((Unit)null, SpellIds.Infusion, true, null, aurEff); + eventInfo.GetActor().CastSpell((Unit)null, SpellIds.Infusion, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -1248,7 +1243,9 @@ namespace Scripts.Spells.Druid // Add remaining ticks to damage done amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.Languish, AuraType.PeriodicDamage); - caster.CastCustomSpell(SpellIds.Languish, SpellValueMod.BasePoint0, amount, target, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, amount); + caster.CastSpell(target, SpellIds.Languish, args); } public override void Register() @@ -1329,7 +1326,9 @@ namespace Scripts.Spells.Druid PreventDefaultAction(); int amount = (int)eventInfo.GetHealInfo().GetHeal(); - eventInfo.GetActor().CastCustomSpell(SpellIds.RejuvenationT10Proc, SpellValueMod.BasePoint0, amount, null, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, (int)eventInfo.GetHealInfo().GetHeal()); + eventInfo.GetActor().CastSpell((Unit)null, SpellIds.RejuvenationT10Proc, args); } public override void Register() @@ -1354,7 +1353,7 @@ namespace Scripts.Spells.Druid { Unit caster = GetCaster(); - caster.CastSpell(hitUnit, SpellIds.ThrashBearAura, TriggerCastFlags.FullMask); + caster.CastSpell(hitUnit, SpellIds.ThrashBearAura, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); } } @@ -1429,7 +1428,7 @@ namespace Scripts.Spells.Druid Player player = GetTarget().ToPlayer(); if (triggeredSpellId != 0) // Apply new form - player.CastSpell(player, triggeredSpellId, true, null, aurEff); + player.CastSpell(player, triggeredSpellId, new CastSpellExtraArgs(aurEff)); else // If not set, simply remove Travel Form dummy player.RemoveAura(SpellIds.TravelForm); } @@ -1512,7 +1511,7 @@ namespace Scripts.Spells.Druid // Outdoor check already passed - Travel Form (dummy) has SPELL_ATTR0_OUTDOORS_ONLY attribute. uint triggeredSpellId = spell_dru_travel_form_AuraScript.GetFormSpellId(player, GetCastDifficulty(), false); - player.CastSpell(player, triggeredSpellId, true, null, aurEff); + player.CastSpell(player, triggeredSpellId, new CastSpellExtraArgs(aurEff)); } void AfterRemove(AuraEffect aurEff, AuraEffectHandleModes mode) diff --git a/Source/Scripts/Spells/Generic.cs b/Source/Scripts/Spells/Generic.cs index cb0bed859..19b5b4de9 100644 --- a/Source/Scripts/Spells/Generic.cs +++ b/Source/Scripts/Spells/Generic.cs @@ -440,7 +440,7 @@ namespace Scripts.Spells.Generic default: return; } - GetTarget().CastSpell(GetTarget(), spellId, true, null, aurEff); + GetTarget().CastSpell(GetTarget(), spellId, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -752,7 +752,9 @@ namespace Scripts.Spells.Generic PreventDefaultAction(); Unit caster = eventInfo.GetActionTarget(); - caster.CastCustomSpell(SpellIds.BloodReserveHeal, SpellValueMod.BasePoint0, aurEff.GetAmount(), caster, TriggerCastFlags.FullMask, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, aurEff.GetAmount()); + caster.CastSpell(caster, SpellIds.BloodReserveHeal, args); caster.RemoveAura(SpellIds.BloodReserveAura); } @@ -979,7 +981,11 @@ namespace Scripts.Spells.Generic Unit caster = GetCaster(); Unit target = GetHitUnit(); if (target) - caster.CastCustomSpell(target, SpellIds.ChaosBlast, basepoints0, 0, 0, true); + { + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, basepoints0); + caster.CastSpell(target, SpellIds.ChaosBlast, args); + } } public override void Register() @@ -1393,7 +1399,7 @@ namespace Scripts.Spells.Generic else spellId = SpellIds.Normal; - GetCaster().CastSpell(GetHitUnit(), spellId, true, null); + GetCaster().CastSpell(GetHitUnit(), spellId, true); } public override void Register() @@ -1514,7 +1520,7 @@ namespace Scripts.Spells.Generic void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.GenThrowInterrupt, true, null, aurEff); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.GenThrowInterrupt, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -1570,7 +1576,7 @@ namespace Scripts.Spells.Generic return; // final heal - GetTarget().CastSpell(GetTarget(), _spellId, true, null, aurEff, GetCasterGUID()); + GetTarget().CastSpell(GetTarget(), _spellId, new CastSpellExtraArgs(aurEff, GetCasterGUID())); } public override void Register() @@ -1700,7 +1706,7 @@ namespace Scripts.Spells.Generic void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - eventInfo.GetActionTarget().CastSpell((Unit)null, SpellIds.FallDown, true, null, aurEff); + eventInfo.GetActionTarget().CastSpell((Unit)null, SpellIds.FallDown, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -1721,7 +1727,9 @@ namespace Scripts.Spells.Generic { PreventDefaultAction(); - GetTarget().CastCustomSpell(GetSpellInfo().GetEffect(aurEff.GetEffIndex()).TriggerSpell, SpellValueMod.MaxTargets, (int)(aurEff.GetTickNumber() / 10 + 1), null, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.MaxTargets, (int)aurEff.GetTickNumber() / 10 + 1); + GetTarget().CastSpell((Unit)null, GetSpellInfo().GetEffect(aurEff.GetEffIndex()).TriggerSpell, args); } public override void Register() @@ -1863,7 +1871,7 @@ namespace Scripts.Spells.Generic default: return; } - GetTarget().CastSpell(GetTarget(), spellId, true, null, aurEff); + GetTarget().CastSpell(GetTarget(), spellId, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -1947,7 +1955,7 @@ namespace Scripts.Spells.Generic if (GetTargetApplication().GetRemoveMode() != AuraRemoveMode.Expire) return; - GetTarget().CastSpell((Unit)null, SpellIds.Paralysis, true, null, aurEff); + GetTarget().CastSpell((Unit)null, SpellIds.Paralysis, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -2117,10 +2125,10 @@ namespace Scripts.Spells.Generic switch (caster.GetTeam()) { case Team.Alliance: - caster.CastSpell(caster, SpellIds.PvpTrinketAlliance, TriggerCastFlags.FullMask); + caster.CastSpell(caster, SpellIds.PvpTrinketAlliance, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); break; case Team.Horde: - caster.CastSpell(caster, SpellIds.PvpTrinketHorde, TriggerCastFlags.FullMask); + caster.CastSpell(caster, SpellIds.PvpTrinketHorde, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); break; } } @@ -2334,7 +2342,7 @@ namespace Scripts.Spells.Generic { // Definitely not a good thing, but currently the only way to do something at cast start // Should be replaced as soon as possible with a new hook: BeforeCastStart - GetCaster().CastSpell(GetCaster(), SpellIds.AlteredForm, TriggerCastFlags.FullMask); + GetCaster().CastSpell(GetCaster(), SpellIds.AlteredForm, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); return false; } @@ -2363,7 +2371,7 @@ namespace Scripts.Spells.Generic // cast speed aura MountCapabilityRecord mountCapability = CliDB.MountCapabilityStorage.LookupByKey(aurEff.GetAmount()); if (mountCapability != null) - target.CastSpell(target, mountCapability.ModSpellAuraID, TriggerCastFlags.FullMask); + target.CastSpell(target, mountCapability.ModSpellAuraID, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); } public override void Register() @@ -2400,7 +2408,7 @@ namespace Scripts.Spells.Generic if (target.HasAuraType(AuraType.WorgenAlteredForm)) target.RemoveAurasByType(AuraType.WorgenAlteredForm); else // Basepoints 1 for this aura control whether to trigger transform transition animation or not. - target.CastCustomSpell(SpellIds.AlteredForm, SpellValueMod.BasePoint0, 1, target, TriggerCastFlags.FullMask); + target.CastSpell(target, SpellIds.AlteredForm, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, 1)); } public override void Register() @@ -2415,7 +2423,7 @@ namespace Scripts.Spells.Generic { void TriggerTransform() { - GetCaster().CastSpell(GetCaster(), SpellIds.AlteredForm, TriggerCastFlags.FullMask); + GetCaster().CastSpell(GetCaster(), SpellIds.AlteredForm, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); } public override void Register() @@ -2746,7 +2754,7 @@ namespace Scripts.Spells.Generic // on stack 15 cast the achievement crediting spell if (GetStackAmount() >= 15) - target.CastSpell(target, SpellIds.TurkeyVengeance, true, null, aurEff, GetCasterGUID()); + target.CastSpell(target, SpellIds.TurkeyVengeance, new CastSpellExtraArgs(aurEff, GetCasterGUID())); } void OnPeriodic(AuraEffect aurEff) @@ -2811,8 +2819,9 @@ namespace Scripts.Spells.Generic return; Unit caster = eventInfo.GetActor(); - int bp = (int)(damageInfo.GetDamage() / 2); - caster.CastCustomSpell(SpellIds.VampiricTouchHeal, SpellValueMod.BasePoint0, bp, caster, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, (int)damageInfo.GetDamage() / 2); + caster.CastSpell(caster, SpellIds.VampiricTouchHeal, args); } public override void Register() @@ -3462,7 +3471,7 @@ namespace Scripts.Spells.Generic if (target.GetPower(PowerType.Mana) == 0) { - target.CastSpell(target, SpellIds.MarkOfKazrogalDamageHellfire, true, null, aurEff); + target.CastSpell(target, SpellIds.MarkOfKazrogalDamageHellfire, new CastSpellExtraArgs(aurEff)); // Remove aura SetDuration(0); } diff --git a/Source/Scripts/Spells/Holiday.cs b/Source/Scripts/Spells/Holiday.cs index 462ac2289..1c6453a72 100644 --- a/Source/Scripts/Spells/Holiday.cs +++ b/Source/Scripts/Spells/Holiday.cs @@ -540,19 +540,26 @@ namespace Scripts.Spells.Holiday } break; case SpellIds.RamCanter: - target.CastCustomSpell(SpellIds.RamFatigue, SpellValueMod.AuraStack, 1, target, TriggerCastFlags.FullMask); - if (aurEff.GetTickNumber() == 8) - target.CastSpell(target, QuestIds.BrewfestSpeedBunnyYellow, true); - break; + { + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.SpellValueOverrides.Add(SpellValueMod.AuraStack, 1); + target.CastSpell(target, SpellIds.RamFatigue, args); + if (aurEff.GetTickNumber() == 8) + target.CastSpell(target, QuestIds.BrewfestSpeedBunnyYellow, true); + break; + } case SpellIds.RamGallop: - target.CastCustomSpell(SpellIds.RamFatigue, SpellValueMod.AuraStack, target.HasAura(SpellIds.RamFatigue) ? 4 : 5 /*Hack*/, target, TriggerCastFlags.FullMask); - if (aurEff.GetTickNumber() == 8) - target.CastSpell(target, QuestIds.BrewfestSpeedBunnyRed, true); - break; + { + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.SpellValueOverrides.Add(SpellValueMod.AuraStack, target.HasAura(SpellIds.RamFatigue) ? 4 : 5 /*Hack*/); + target.CastSpell(target, SpellIds.RamFatigue, args); + if (aurEff.GetTickNumber() == 8) + target.CastSpell(target, QuestIds.BrewfestSpeedBunnyRed, true); + break; + } default: break; } - } public override void Register() @@ -623,7 +630,7 @@ namespace Scripts.Spells.Holiday PreventHitDefaultEffect(effIndex); // All this spells trigger a spell that requires reagents; if the // triggered spell is cast as "triggered", reagents are not consumed - GetHitUnit().CastSpell(null, GetEffectInfo().TriggerSpell, TriggerCastFlags.FullMask & ~TriggerCastFlags.IgnorePowerAndReagentCost); + GetHitUnit().CastSpell((Unit)null, GetEffectInfo().TriggerSpell, new CastSpellExtraArgs(TriggerCastFlags.FullMask & ~TriggerCastFlags.IgnorePowerAndReagentCost)); } public override void Register() @@ -643,7 +650,7 @@ namespace Scripts.Spells.Holiday if (aura != null) { aura.SetDuration(aura.GetDuration() + 30 * Time.InMilliseconds); - GetCaster().CastSpell(GetHitUnit(), SpellIds.RelayRaceTurnIn, TriggerCastFlags.FullMask); + GetCaster().CastSpell(GetHitUnit(), SpellIds.RelayRaceTurnIn, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); } } diff --git a/Source/Scripts/Spells/Hunter.cs b/Source/Scripts/Spells/Hunter.cs index 168e778eb..af79c92ab 100644 --- a/Source/Scripts/Spells/Hunter.cs +++ b/Source/Scripts/Spells/Hunter.cs @@ -116,8 +116,9 @@ namespace Scripts.Spells.Hunter void HandleDummy(uint effIndex) { Unit caster = GetCaster(); - int healthModSpellBasePoints0 = (int)caster.CountPctFromMaxHealth(30); - caster.CastCustomSpell(caster, SpellIds.PetLastStandTriggered, healthModSpellBasePoints0, 0, 0, true, null); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, (int)caster.CountPctFromMaxHealth(30)); + caster.CastSpell(caster, SpellIds.PetLastStandTriggered, args); } public override void Register() @@ -215,7 +216,7 @@ namespace Scripts.Spells.Hunter void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.MisdirectionProc, true, null, aurEff); + GetTarget().CastSpell(GetTarget(), SpellIds.MisdirectionProc, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -265,7 +266,9 @@ namespace Scripts.Spells.Hunter { if (!caster.HasAura(SpellIds.PetHeartOfThePhoenixDebuff)) { - owner.CastCustomSpell(SpellIds.PetHeartOfThePhoenixTriggered, SpellValueMod.BasePoint0, 100, caster, true); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, 100); + owner.CastSpell(caster, SpellIds.PetHeartOfThePhoenixTriggered, args); caster.CastSpell(caster, SpellIds.PetHeartOfThePhoenixDebuff, true); } } @@ -301,8 +304,9 @@ namespace Scripts.Spells.Hunter { PreventDefaultAction(); - int damage = (int)MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()); - eventInfo.GetActor().CastCustomSpell(SpellIds.RoarOfSacrificeTriggered, SpellValueMod.BasePoint0, damage, GetCaster(), TriggerCastFlags.FullMask, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount())); + eventInfo.GetActor().CastSpell(GetCaster(), SpellIds.RoarOfSacrificeTriggered, args); } public override void Register() @@ -422,7 +426,7 @@ namespace Scripts.Spells.Hunter PreventDefaultAction(); Unit caster = eventInfo.GetActor(); - caster.CastSpell(caster.ToPlayer().GetPet(), SpellIds.T94PGreatness, true, null, aurEff); + caster.CastSpell(caster.ToPlayer().GetPet(), SpellIds.T94PGreatness, new CastSpellExtraArgs(aurEff)); } public override void Register() diff --git a/Source/Scripts/Spells/Items.cs b/Source/Scripts/Spells/Items.cs index 89d501a30..ef9cd618b 100644 --- a/Source/Scripts/Spells/Items.cs +++ b/Source/Scripts/Spells/Items.cs @@ -500,7 +500,7 @@ namespace Scripts.Spells.Items Unit caster = GetCaster(); Item item = GetCastItem(); if (item) - caster.CastSpell(caster, _triggeredSpellId, true, item); + caster.CastSpell(caster, _triggeredSpellId, new CastSpellExtraArgs(item)); } public override void Register() @@ -522,7 +522,7 @@ namespace Scripts.Spells.Items void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.AegisHeal, true, null, aurEff); + GetTarget().CastSpell(GetTarget(), SpellIds.AegisHeal, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -546,7 +546,7 @@ namespace Scripts.Spells.Items if (!GetCaster() || !GetTarget().IsTypeId(TypeId.Unit)) return; - GetCaster().CastSpell(GetCaster(), SpellIds.EyeOfGrillok, true, null, aurEff); + GetCaster().CastSpell(GetCaster(), SpellIds.EyeOfGrillok, new CastSpellExtraArgs(aurEff)); GetTarget().ToCreature().DespawnOrUnsummon(); } @@ -592,7 +592,10 @@ namespace Scripts.Spells.Items if (spellId == 0) return; - GetTarget().CastCustomSpell(spellId, SpellValueMod.BasePoint0, amount, GetTarget(), true, null, aurEff); + Unit caster = eventInfo.GetActionTarget(); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, amount); + caster.CastSpell((Unit)null, spellId, args); } public override void Register() @@ -638,7 +641,7 @@ namespace Scripts.Spells.Items if (player.GetWeaponForAttack(WeaponAttackType.OffAttack, true) && RandomHelper.URand(0, 1) != 0) spellId = SpellIds.ManifestAngerOffHand; - caster.CastSpell(target, spellId, true, null, aurEff); + caster.CastSpell(target, spellId, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -708,7 +711,7 @@ namespace Scripts.Spells.Items PreventDefaultAction(); Unit caster = eventInfo.GetActor(); uint spellId = triggeredSpells[(int)caster.GetClass()].SelectRandom(); - caster.CastSpell(caster, spellId, true, null, aurEff); + caster.CastSpell(caster, spellId, new CastSpellExtraArgs(aurEff)); if (RandomHelper.randChance(10)) caster.Say(TextIds.SayMadness); @@ -731,7 +734,7 @@ namespace Scripts.Spells.Items void HandlePeriodicDummy(AuraEffect aurEff) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), RandomHelper.RAND(SpellIds.DementiaPos, SpellIds.DementiaNeg), true, null, aurEff); + GetTarget().CastSpell(GetTarget(), RandomHelper.RAND(SpellIds.DementiaPos, SpellIds.DementiaNeg), new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -772,7 +775,11 @@ namespace Scripts.Spells.Items protEff.GetBase().RefreshDuration(); } else - GetTarget().CastCustomSpell(SpellIds.ProtectionOfAncientKings, SpellValueMod.BasePoint0, absorb, eventInfo.GetProcTarget(), true, null, aurEff); + { + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, absorb); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.ProtectionOfAncientKings, args); + } } public override void Register() @@ -822,7 +829,9 @@ namespace Scripts.Spells.Items void HandleDummy(uint effIndex) { SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(SpellIds.DeadlyPrecision, GetCastDifficulty()); - GetCaster().CastCustomSpell(spellInfo.Id, SpellValueMod.AuraStack, (int)spellInfo.StackAmount, GetCaster(), true); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.SpellValueOverrides.Add(SpellValueMod.AuraStack, (int)spellInfo.StackAmount); + GetCaster().CastSpell(GetCaster(), spellInfo.Id, args); } public override void Register() @@ -891,7 +900,7 @@ namespace Scripts.Spells.Items return; uint spellId = randomSpells.SelectRandom(); - caster.CastSpell(caster, spellId, true, null, aurEff); + caster.CastSpell(caster, spellId, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -964,7 +973,7 @@ namespace Scripts.Spells.Items { PreventHitDefaultEffect(effIndex); if (_failSpell != 0) - GetCaster().CastSpell(GetCaster(), _failSpell, true, GetCastItem()); + GetCaster().CastSpell(GetCaster(), _failSpell, new CastSpellExtraArgs(GetCastItem())); } } @@ -988,7 +997,7 @@ namespace Scripts.Spells.Items void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.DesperateRage, true, null, aurEff); + GetTarget().CastSpell(GetTarget(), SpellIds.DesperateRage, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -1015,7 +1024,7 @@ namespace Scripts.Spells.Items { Unit caster = GetCaster(); uint spellId = RandomHelper.URand(SpellIds.Sleepy, SpellIds.HealthySpirit); - caster.CastSpell(caster, spellId, true, null); + caster.CastSpell(caster, spellId, true); } public override void Register() @@ -1035,7 +1044,7 @@ namespace Scripts.Spells.Items void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - eventInfo.GetActor().CastSpell((Unit)null, SpellIds.DiscerningEyeBeast, true, null, aurEff); + eventInfo.GetActor().CastSpell((Unit)null, SpellIds.DiscerningEyeBeast, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -1184,9 +1193,10 @@ namespace Scripts.Spells.Items if (damageInfo == null || damageInfo.GetDamage() == 0) return; - int amount = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); Unit caster = eventInfo.GetActor(); - caster.CastCustomSpell(SpellIds.Shadowmend, SpellValueMod.BasePoint0, amount, null, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount())); + caster.CastSpell((Unit)null, SpellIds.Shadowmend, args); } public override void Register() @@ -1270,7 +1280,7 @@ namespace Scripts.Spells.Items return; } - caster.CastSpell((Unit)null, spellId, true, null, aurEff); + caster.CastSpell((Unit)null, spellId, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -1346,7 +1356,7 @@ namespace Scripts.Spells.Items spellId = SpellIds.TinyMagicalCrawdad; break; } - caster.CastSpell(caster, spellId, true, null); + caster.CastSpell(caster, spellId, true); } public override void Register() @@ -1372,7 +1382,7 @@ namespace Scripts.Spells.Items // in that case, do not cast heal spell PreventDefaultAction(); // but mana instead - eventInfo.GetActor().CastSpell((Unit)null, SpellIds.MarkOfConquestEnergize, true, null, aurEff); + eventInfo.GetActor().CastSpell((Unit)null, SpellIds.MarkOfConquestEnergize, new CastSpellExtraArgs(aurEff)); } } @@ -1445,8 +1455,9 @@ namespace Scripts.Spells.Items if (damageInfo == null || damageInfo.GetDamage() == 0) return; - int bp = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); - GetTarget().CastCustomSpell(SpellIds.ItemNecroticTouchProc, SpellValueMod.BasePoint0, bp, eventInfo.GetProcTarget(), true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount())); + GetTarget().CastSpell((Unit)null, SpellIds.ItemNecroticTouchProc, args); } public override void Register() @@ -1477,7 +1488,7 @@ namespace Scripts.Spells.Items else if (roll < 4) // 2% for 20 sec root, charge to target (off-like chance unknown) spellId = SpellIds.NetOMaticTriggered2; - GetCaster().CastSpell(target, spellId, true, null); + GetCaster().CastSpell(target, spellId, true); } } @@ -1515,7 +1526,7 @@ namespace Scripts.Spells.Items break; } - caster.CastSpell(caster, spellId, true, null); + caster.CastSpell(caster, spellId, true); } public override void Register() @@ -1572,7 +1583,9 @@ namespace Scripts.Spells.Items if (shield.GetAmount() > bp0) return; - caster.CastCustomSpell(SpellIds.PersistentShieldTriggered, SpellValueMod.BasePoint0, bp0, target, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, bp0); + caster.CastSpell(target, SpellIds.PersistentShieldTriggered, args); } public override void Register() @@ -1599,9 +1612,9 @@ namespace Scripts.Spells.Items if (damageInfo == null || damageInfo.GetDamage() == 0) return; - int bp = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); - Unit caster = eventInfo.GetActor(); - caster.CastCustomSpell(SpellIds.HealthLink, SpellValueMod.BasePoint0, bp, null, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount())); + eventInfo.GetActor().CastSpell((Unit)null, SpellIds.HealthLink, args); } public override void Register() @@ -1652,7 +1665,7 @@ namespace Scripts.Spells.Items // Yaaarrrr - pirate case 2: spellId = (caster.GetGender() == Gender.Male ? SpellIds.YaaarrrrMale : SpellIds.YaaarrrrFemale); break; } - caster.CastSpell(caster, spellId, true, null); + caster.CastSpell(caster, spellId, true); } public override void Register() @@ -1745,7 +1758,7 @@ namespace Scripts.Spells.Items if (!caster || !target) return; - caster.CastSpell(target, SpellIds.SoulFeast, TriggerCastFlags.FullMask); + caster.CastSpell(target, SpellIds.SoulFeast, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); } public override void Register() @@ -1772,7 +1785,7 @@ namespace Scripts.Spells.Items void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.ShadowmourneSoulFragment, true, null, aurEff); + GetTarget().CastSpell(GetTarget(), SpellIds.ShadowmourneSoulFragment, new CastSpellExtraArgs(aurEff)); // this can't be handled in AuraScript of SoulFragments because we need to know victim Aura soulFragments = GetTarget().GetAura(SpellIds.ShadowmourneSoulFragment); @@ -1780,7 +1793,7 @@ namespace Scripts.Spells.Items { if (soulFragments.GetStackAmount() >= 10) { - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.ShadowmourneChaosBaneDamage, true, null, aurEff); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.ShadowmourneChaosBaneDamage, new CastSpellExtraArgs(aurEff)); soulFragments.Remove(); } } @@ -1873,7 +1886,7 @@ namespace Scripts.Spells.Items target = caster; } - caster.CastSpell(target, spellId, true, GetCastItem()); + caster.CastSpell(target, spellId, new CastSpellExtraArgs(GetCastItem())); } } @@ -1896,8 +1909,9 @@ namespace Scripts.Spells.Items PreventDefaultAction(); Unit caster = eventInfo.GetActor(); - int amount = (int)caster.CountPctFromMaxHealth(aurEff.GetAmount()); - caster.CastCustomSpell(SpellIds.SwiftHandOfJusticeHeal, SpellValueMod.BasePoint0, amount, null, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, (int)caster.CountPctFromMaxHealth(aurEff.GetAmount())); + caster.CastSpell((Unit)null, SpellIds.SwiftHandOfJusticeHeal, args); } public override void Register() @@ -1949,7 +1963,7 @@ namespace Scripts.Spells.Items spellId = SpellIds.UnderbellyElixirTriggered2; break; } - caster.CastSpell(caster, spellId, true, null); + caster.CastSpell(caster, spellId, true); } public override void Register() @@ -2261,7 +2275,7 @@ namespace Scripts.Spells.Items void HandleDummy(uint effIndex) { Unit caster = GetCaster(); - caster.CastSpell(caster, RandomHelper.randChance(50) ? SpellIds.SummonPurifiedHelboarMeat : SpellIds.SummonToxicHelboarMeat, true, null); + caster.CastSpell(caster, RandomHelper.randChance(50) ? SpellIds.SummonPurifiedHelboarMeat : SpellIds.SummonToxicHelboarMeat, true); } public override void Register() @@ -2357,9 +2371,9 @@ namespace Scripts.Spells.Items if (castItem) { if (RandomHelper.randChance(86)) // Nigh-Invulnerability - success - caster.CastSpell(caster, SpellIds.NighInvulnerability, true, castItem); + caster.CastSpell(caster, SpellIds.NighInvulnerability, new CastSpellExtraArgs(castItem)); else // Complete Vulnerability - backfire in 14% casts - caster.CastSpell(caster, SpellIds.CompleteVulnerability, true, castItem); + caster.CastSpell(caster, SpellIds.CompleteVulnerability, new CastSpellExtraArgs(castItem)); } } @@ -2380,7 +2394,7 @@ namespace Scripts.Spells.Items void HandleDummy(uint effIndex) { if (GetCastItem() && GetHitUnit()) - GetCaster().CastSpell(GetHitUnit(), RandomHelper.randChance(80) ? SpellIds.PoultryizerSuccess : SpellIds.PoultryizerBackfire, true, GetCastItem()); + GetCaster().CastSpell(GetHitUnit(), RandomHelper.randChance(80) ? SpellIds.PoultryizerSuccess : SpellIds.PoultryizerBackfire, new CastSpellExtraArgs(GetCastItem())); } public override void Register() @@ -2481,7 +2495,7 @@ namespace Scripts.Spells.Items GetHitCreature().DespawnOrUnsummon(); //cast spell Raptor Capture Credit - caster.CastSpell(caster, SpellIds.RaptorCaptureCredit, true, null); + caster.CastSpell(caster, SpellIds.RaptorCaptureCredit, true); } } @@ -2583,7 +2597,7 @@ namespace Scripts.Spells.Items bool success = true; if (areaEntry != null && areaEntry.IsFlyable() && !caster.GetMap().IsDungeon()) success = RandomHelper.randChance(95); - caster.CastSpell(caster, success ? SpellIds.NitroBoostsSuccess : SpellIds.NitroBoostsBackfire, true, GetCastItem()); + caster.CastSpell(caster, success ? SpellIds.NitroBoostsSuccess : SpellIds.NitroBoostsBackfire, new CastSpellExtraArgs(GetCastItem())); } public override void Register() @@ -2612,7 +2626,7 @@ namespace Scripts.Spells.Items if (curZ < lastZ) { if (RandomHelper.randChance(80)) // we don't have enough sniffs to verify this, guesstimate - GetTarget().CastSpell(GetTarget(), SpellIds.NitroBoostsParachute, true, null, effect); + GetTarget().CastSpell(GetTarget(), SpellIds.NitroBoostsParachute, new CastSpellExtraArgs(effect)); GetAura().Remove(); } else @@ -2677,7 +2691,7 @@ namespace Scripts.Spells.Items bg.EventPlayerDroppedFlag(caster); caster.GetSpellHistory().ResetCooldown(SpellIds.RocketBootsProc); - caster.CastSpell(caster, SpellIds.RocketBootsProc, true, null); + caster.CastSpell(caster, SpellIds.RocketBootsProc, true); } SpellCastResult CheckCast() @@ -2836,10 +2850,10 @@ namespace Scripts.Spells.Items Unit target = eventInfo.GetProcTarget(); if (eventInfo.GetTypeMask().HasAnyFlag(ProcFlags.DoneSpellMagicDmgClassPos)) - caster.CastSpell(target, _healProcSpellId, true, null, aurEff); + caster.CastSpell(target, _healProcSpellId, new CastSpellExtraArgs(aurEff)); if (eventInfo.GetTypeMask().HasAnyFlag(ProcFlags.DoneSpellMagicDmgClassNeg)) - caster.CastSpell(target, _damageProcSpellId, true, null, aurEff); + caster.CastSpell(target, _damageProcSpellId, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -2868,16 +2882,16 @@ namespace Scripts.Spells.Items switch (caster.GetClass()) { case Class.Druid: - caster.CastSpell(caster, SpellIds.SoulPreserverDruid, true, null, aurEff); + caster.CastSpell(caster, SpellIds.SoulPreserverDruid, new CastSpellExtraArgs(aurEff)); break; case Class.Paladin: - caster.CastSpell(caster, SpellIds.SoulPreserverPaladin, true, null, aurEff); + caster.CastSpell(caster, SpellIds.SoulPreserverPaladin, new CastSpellExtraArgs(aurEff)); break; case Class.Priest: - caster.CastSpell(caster, SpellIds.SoulPreserverPriest, true, null, aurEff); + caster.CastSpell(caster, SpellIds.SoulPreserverPriest, new CastSpellExtraArgs(aurEff)); break; case Class.Shaman: - caster.CastSpell(caster, SpellIds.SoulPreserverShaman, true, null, aurEff); + caster.CastSpell(caster, SpellIds.SoulPreserverShaman, new CastSpellExtraArgs(aurEff)); break; default: break; @@ -2923,10 +2937,10 @@ namespace Scripts.Spells.Items // Aggression checks are in the spell system... just cast and forget if (player.GetReputationRank(FactionIds.Aldor) == ReputationRank.Exalted) - player.CastSpell(target, _aldorSpellId, true, null, aurEff); + player.CastSpell(target, _aldorSpellId, new CastSpellExtraArgs(aurEff)); if (player.GetReputationRank(FactionIds.Scryers) == ReputationRank.Exalted) - player.CastSpell(target, _scryersSpellId, true, null, aurEff); + player.CastSpell(target, _scryersSpellId, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -2987,17 +3001,17 @@ namespace Scripts.Spells.Items case SpellIds.DeathChoiceNormalAura: { if (str > agi) - caster.CastSpell(caster, SpellIds.DeathChoiceNormalStrength, true, null, aurEff); + caster.CastSpell(caster, SpellIds.DeathChoiceNormalStrength, new CastSpellExtraArgs(aurEff)); else - caster.CastSpell(caster, SpellIds.DeathChoiceNormalAgility, true, null, aurEff); + caster.CastSpell(caster, SpellIds.DeathChoiceNormalAgility, new CastSpellExtraArgs(aurEff)); break; } case SpellIds.DeathChoiceHeroicAura: { if (str > agi) - caster.CastSpell(caster, SpellIds.DeathChoiceHeroicStrength, true, null, aurEff); + caster.CastSpell(caster, SpellIds.DeathChoiceHeroicStrength, new CastSpellExtraArgs(aurEff)); else - caster.CastSpell(caster, SpellIds.DeathChoiceHeroicAgility, true, null, aurEff); + caster.CastSpell(caster, SpellIds.DeathChoiceHeroicAgility, new CastSpellExtraArgs(aurEff)); break; } default: @@ -3034,7 +3048,7 @@ namespace Scripts.Spells.Items Unit caster = eventInfo.GetActor(); - caster.CastSpell(caster, _stackSpell, true, null, aurEff); // cast the stack + caster.CastSpell(caster, _stackSpell, new CastSpellExtraArgs(aurEff)); // cast the stack Aura dummy = caster.GetAura(_stackSpell); // retrieve aura @@ -3046,7 +3060,7 @@ namespace Scripts.Spells.Items caster.RemoveAurasDueToSpell(_stackSpell); Unit target = eventInfo.GetActionTarget(); if (target) - caster.CastSpell(target, _triggerSpell, true, null, aurEff); + caster.CastSpell(target, _triggerSpell, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -3103,7 +3117,7 @@ namespace Scripts.Spells.Items stat = vers; } - caster.CastSpell(caster, spellTrigger, true, null, aurEff); + caster.CastSpell(caster, spellTrigger, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -3128,10 +3142,10 @@ namespace Scripts.Spells.Items Unit target = eventInfo.GetActionTarget(); if (caster.IsAlive()) - caster.CastSpell(caster, SpellIds.ManaDrainEnergize, true, null, aurEff); + caster.CastSpell(caster, SpellIds.ManaDrainEnergize, new CastSpellExtraArgs(aurEff)); if (target && target.IsAlive()) - caster.CastSpell(target, SpellIds.ManaDrainLeech, true, null, aurEff); + caster.CastSpell(target, SpellIds.ManaDrainLeech, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -3199,7 +3213,7 @@ namespace Scripts.Spells.Items if (target) { if (RandomHelper.randChance(95)) - caster.CastSpell(target, RandomHelper.randChance(32) ? SpellIds.Dullard : SpellIds.GnomishMindControlCap, true, GetCastItem()); + caster.CastSpell(target, RandomHelper.randChance(32) ? SpellIds.Dullard : SpellIds.GnomishMindControlCap, new CastSpellExtraArgs(GetCastItem())); else target.CastSpell(caster, SpellIds.GnomishMindControlCap, true); // backfire - 5% chance } @@ -3233,11 +3247,11 @@ namespace Scripts.Spells.Items { uint chance = RandomHelper.URand(0, 99); if (chance < 15) - GetCaster().CastSpell(target, SpellIds.TargetLock, true, GetCastItem()); + GetCaster().CastSpell(target, SpellIds.TargetLock, new CastSpellExtraArgs(GetCastItem())); else if (chance < 25) - GetCaster().CastSpell(target, SpellIds.MobilityMalfunction, true, GetCastItem()); + GetCaster().CastSpell(target, SpellIds.MobilityMalfunction, new CastSpellExtraArgs(GetCastItem())); else - GetCaster().CastSpell(target, SpellIds.ControlMachine, true, GetCastItem()); + GetCaster().CastSpell(target, SpellIds.ControlMachine, new CastSpellExtraArgs(GetCastItem())); } } @@ -3521,7 +3535,7 @@ namespace Scripts.Spells.Items } if (useElixir) - target.CastSpell(target, chosenElixir, true, GetCastItem()); + target.CastSpell(target, chosenElixir, new CastSpellExtraArgs(GetCastItem())); } public override void Register() @@ -3559,7 +3573,7 @@ namespace Scripts.Spells.Items uint chosenElixir = availableElixirs.SelectRandom(); - target.CastSpell(target, chosenElixir, true, GetCastItem()); + target.CastSpell(target, chosenElixir, new CastSpellExtraArgs(GetCastItem())); } public override void Register() diff --git a/Source/Scripts/Spells/Mage.cs b/Source/Scripts/Spells/Mage.cs index f3aa50ce9..c866ca48e 100644 --- a/Source/Scripts/Spells/Mage.cs +++ b/Source/Scripts/Spells/Mage.cs @@ -157,9 +157,9 @@ namespace Scripts.Spells.Mage } GetTarget().SetHealth(GetTarget().CountPctFromMaxHealth(effectInfo.GetAmount())); - GetTarget().CastSpell(GetTarget(), GetSpellInfo().GetEffect(2).TriggerSpell, TriggerCastFlags.FullMask); - GetTarget().CastSpell(GetTarget(), SpellIds.CauterizeDot, TriggerCastFlags.FullMask); - GetTarget().CastSpell(GetTarget(), SpellIds.Cauterized, TriggerCastFlags.FullMask); + GetTarget().CastSpell(GetTarget(), GetSpellInfo().GetEffect(2).TriggerSpell, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + GetTarget().CastSpell(GetTarget(), SpellIds.CauterizeDot, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + GetTarget().CastSpell(GetTarget(), SpellIds.Cauterized, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); } public override void Register() @@ -268,7 +268,7 @@ namespace Scripts.Spells.Mage void Trigger(AuraEffect aurEff, ProcEventInfo eventInfo) { - eventInfo.GetActor().CastSpell(GetTarget(), SpellIds.FingersOfFrost, true, null, aurEff); + eventInfo.GetActor().CastSpell(GetTarget(), SpellIds.FingersOfFrost, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -356,7 +356,9 @@ namespace Scripts.Spells.Mage } // put target index for chain value multiplier into EFFECT_1 base points, otherwise triggered spell doesn't know which damage multiplier to apply - caster.CastCustomSpell(SpellIds.IceLanceTrigger, SpellValueMod.BasePoint1, index, target, true); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.AddSpellMod(SpellValueMod.BasePoint1, index); + caster.CastSpell(target, SpellIds.IceLanceTrigger, args); } public override void Register() @@ -409,7 +411,10 @@ namespace Scripts.Spells.Mage int amount = (int)(MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), pct) / igniteDot.GetMaxTicks()); amount += (int)eventInfo.GetProcTarget().GetRemainingPeriodicAmount(eventInfo.GetActor().GetGUID(), SpellIds.Ignite, AuraType.PeriodicDamage); - GetTarget().CastCustomSpell(SpellIds.Ignite, SpellValueMod.BasePoint0, amount, eventInfo.GetProcTarget(), true, null, aurEff); + + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, amount); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.Ignite, args); } public override void Register() @@ -451,7 +456,7 @@ namespace Scripts.Spells.Mage void HandleDummy(uint effIndex) { PreventHitDefaultEffect(effIndex); - GetCaster().CastCustomSpell(SpellIds.LivingBombPeriodic, SpellValueMod.BasePoint2, 1, GetHitUnit(), TriggerCastFlags.FullMask); + GetCaster().CastSpell(GetHitUnit(), SpellIds.LivingBombPeriodic, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint2, 1)); } public override void Register() @@ -476,7 +481,7 @@ namespace Scripts.Spells.Mage void HandleSpread(uint effIndex) { if (GetSpellValue().EffectBasePoints[0] > 0) - GetCaster().CastCustomSpell(SpellIds.LivingBombPeriodic, SpellValueMod.BasePoint2, 0, GetHitUnit(), TriggerCastFlags.FullMask); + GetCaster().CastSpell(GetHitUnit(), SpellIds.LivingBombPeriodic, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint2, 0)); } public override void Register() @@ -501,7 +506,7 @@ namespace Scripts.Spells.Mage Unit caster = GetCaster(); if (caster) - caster.CastCustomSpell(SpellIds.LivingBombExplosion, SpellValueMod.BasePoint0, aurEff.GetAmount(), GetTarget(), TriggerCastFlags.FullMask); + caster.CastSpell(GetTarget(), SpellIds.LivingBombExplosion, new CastSpellExtraArgs (TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, aurEff.GetAmount())); } public override void Register() @@ -574,7 +579,7 @@ namespace Scripts.Spells.Mage { TempSummon ringOfFrost = GetRingOfFrostMinion(); if (ringOfFrost) - GetTarget().CastSpell(ringOfFrost.GetPositionX(), ringOfFrost.GetPositionY(), ringOfFrost.GetPositionZ(), SpellIds.RingOfFrostFreeze, true); + GetTarget().CastSpell(ringOfFrost.GetPosition(), SpellIds.RingOfFrostFreeze, new CastSpellExtraArgs(true)); } void Apply(AuraEffect aurEff, AuraEffectHandleModes mode) @@ -729,7 +734,7 @@ namespace Scripts.Spells.Mage Unit caster = GetCaster(); if (caster != null) - caster.CastCustomSpell(SpellIds.TouchOfTheMagiExplode, SpellValueMod.BasePoint0, amount, GetTarget(), TriggerCastFlags.FullMask); + caster.CastSpell(GetTarget(), SpellIds.TouchOfTheMagiExplode, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, amount)); } public override void Register() diff --git a/Source/Scripts/Spells/Monk.cs b/Source/Scripts/Spells/Monk.cs index 7daddc0a7..7ee6bb5c0 100644 --- a/Source/Scripts/Spells/Monk.cs +++ b/Source/Scripts/Spells/Monk.cs @@ -49,7 +49,7 @@ namespace Scripts.Spells.Monk Unit caster = GetCaster(); if (caster) if (caster.HasAura(SpellIds.StanceOfTheSpiritedCrane)) - caster.CastSpell(caster, SpellIds.CracklingJadeLightningChiProc, TriggerCastFlags.FullMask); + caster.CastSpell(caster, SpellIds.CracklingJadeLightningChiProc, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); } public override void Register() @@ -83,8 +83,8 @@ namespace Scripts.Spells.Monk void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { - GetTarget().CastSpell(eventInfo.GetActor(), SpellIds.CracklingJadeLightningKnockback, TriggerCastFlags.FullMask); - GetTarget().CastSpell(GetTarget(), SpellIds.CracklingJadeLightningKnockbackCd, TriggerCastFlags.FullMask); + GetTarget().CastSpell(eventInfo.GetActor(), SpellIds.CracklingJadeLightningKnockback, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); + GetTarget().CastSpell(GetTarget(), SpellIds.CracklingJadeLightningKnockbackCd, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); } public override void Register() diff --git a/Source/Scripts/Spells/Paladin.cs b/Source/Scripts/Spells/Paladin.cs index bb7581df5..730d0ba53 100644 --- a/Source/Scripts/Spells/Paladin.cs +++ b/Source/Scripts/Spells/Paladin.cs @@ -434,7 +434,7 @@ namespace Scripts.Spells.Paladin { Unit caster = GetCaster(); if (caster.HasSpell(SpellIds.JudgementProtRetR3)) - caster.CastSpell(caster, SpellIds.JudementGainHolyPower, TriggerCastFlags.FullMask); + caster.CastSpell(caster, SpellIds.JudementGainHolyPower, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); } public override void Register() @@ -517,7 +517,7 @@ namespace Scripts.Spells.Paladin void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.ItemHealingTrance, true, null, aurEff); + GetTarget().CastSpell(GetTarget(), SpellIds.ItemHealingTrance, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -560,7 +560,7 @@ namespace Scripts.Spells.Paladin return; if (RandomHelper.randChance(chance)) - eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), spellId, true, null, aurEff); + eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), spellId, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -640,7 +640,11 @@ namespace Scripts.Spells.Paladin { List applications = eff.GetApplicationList(); if (!applications.Empty()) - eventInfo.GetActor().CastCustomSpell(SpellIds.BeaconOfLightHeal, SpellValueMod.BasePoint0, (int)heal, applications.First().GetTarget(), true); + { + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, (int)heal); + eventInfo.GetActor().CastSpell(applications[0].GetTarget(), SpellIds.BeaconOfLightHeal, args); + } return; } } @@ -784,7 +788,7 @@ namespace Scripts.Spells.Paladin return; } - caster.CastSpell(target, spellId, true, null, aurEff); + caster.CastSpell(target, spellId, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -818,7 +822,9 @@ namespace Scripts.Spells.Paladin // Add remaining ticks to damage done amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.HolyMending, AuraType.PeriodicHeal); - caster.CastCustomSpell(SpellIds.HolyMending, SpellValueMod.BasePoint0, amount, target, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, amount); + caster.CastSpell(target, SpellIds.HolyMending, args); } public override void Register() @@ -838,7 +844,7 @@ namespace Scripts.Spells.Paladin void HandleEffectProc(AuraEffect aurEff, ProcEventInfo procInfo) { Unit target = GetTarget(); - target.CastCustomSpell(SpellIds.ZealAura, SpellValueMod.AuraStack, aurEff.GetAmount(), target, true); + target.CastSpell(target, SpellIds.ZealAura, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.AuraStack, aurEff.GetAmount())); PreventDefaultAction(); } diff --git a/Source/Scripts/Spells/Priest.cs b/Source/Scripts/Spells/Priest.cs index 9a0beedea..543dd2001 100644 --- a/Source/Scripts/Spells/Priest.cs +++ b/Source/Scripts/Spells/Priest.cs @@ -87,8 +87,9 @@ namespace Scripts.Spells.Priest if (healInfo == null || healInfo.GetHeal() == 0) return; - int amount = (int)MathFunctions.CalculatePct(healInfo.GetHeal(), 10); - caster.CastCustomSpell(SpellIds.OracularHeal, SpellValueMod.BasePoint0, amount, caster, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(healInfo.GetHeal(), 10)); + caster.CastSpell(caster, SpellIds.OracularHeal, args); } public override void Register() @@ -115,14 +116,15 @@ namespace Scripts.Spells.Priest void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { DamageInfo damageInfo = eventInfo.GetDamageInfo(); - int heal = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); + CastSpellExtraArgs args = new(aurEff); + args.AddSpellMod(SpellValueMod.BasePoint0, (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount())); _appliedAtonements.RemoveAll(targetGuid => { Unit target = Global.ObjAccessor.GetUnit(GetTarget(), targetGuid); if (target) { if (target.GetExactDist(GetTarget()) < GetSpellInfo().GetEffect(1).CalcValue()) - GetTarget().CastCustomSpell(SpellIds.AtonementHeal, SpellValueMod.BasePoint0, heal, target, true); + GetTarget().CastSpell(target, SpellIds.AtonementHeal, args); return false; } @@ -254,7 +256,9 @@ namespace Scripts.Spells.Priest int healAmount = (int)target.CountPctFromMaxHealth((int)healPct); // Remove the aura now, we don't want 40% healing bonus Remove(AuraRemoveMode.EnemySpell); - target.CastCustomSpell(target, SpellIds.GuardianSpiritHeal, healAmount, 0, 0, true); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, healAmount); + target.CastSpell(target, SpellIds.GuardianSpiritHeal, args); absorbAmount = dmgInfo.GetDamage(); } @@ -306,7 +310,7 @@ namespace Scripts.Spells.Priest SpellCastTargets targets = new SpellCastTargets(); targets.SetDst(destPos); targets.SetUnitTarget(GetCaster()); - GetHitUnit().CastSpell(targets, Global.SpellMgr.GetSpellInfo((uint)GetEffectValue(), GetCastDifficulty()), null); + GetHitUnit().CastSpell(targets, (uint)GetEffectValue(), new CastSpellExtraArgs(GetCastDifficulty())); } public override void Register() @@ -482,10 +486,10 @@ namespace Scripts.Spells.Priest void HandleEffectDummy(uint effIndex) { uint basePoints = GetCaster().SpellHealingBonusDone(GetHitUnit(), _spellInfoHeal, (uint)_healEffectDummy.CalcValue(GetCaster()), DamageEffectType.Heal, _healEffectDummy); - Dictionary values = new Dictionary(); - values.Add(SpellValueMod.AuraStack, (byte)GetEffectValue()); - values.Add(SpellValueMod.BasePoint0, (int)basePoints); - GetCaster().CastCustomSpell(SpellIds.PrayerOfMendingAura, values, GetHitUnit(), TriggerCastFlags.FullMask); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.AddSpellMod(SpellValueMod.AuraStack, GetEffectValue()); + args.AddSpellMod(SpellValueMod.BasePoint0, (int)basePoints); + GetCaster().CastSpell(GetHitUnit(), SpellIds.PrayerOfMendingAura, args); } public override void Register() @@ -511,12 +515,18 @@ namespace Scripts.Spells.Priest if (caster != null) { // Cast the spell to heal the owner - caster.CastSpell(target, SpellIds.PrayerOfMendingHeal, true, null, aurEff); + caster.CastSpell(target, SpellIds.PrayerOfMendingHeal, new CastSpellExtraArgs(aurEff)); // Only cast jump if stack is higher than 0 int stackAmount = GetStackAmount(); if (stackAmount > 1) - target.CastCustomSpell(SpellIds.PrayerOfMendingJump, SpellValueMod.BasePoint0, stackAmount - 1, target, true, null, aurEff, caster.GetGUID()); + { + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.TriggeringAura = aurEff; + args.OriginalCaster = caster.GetGUID(); + args.AddSpellMod(SpellValueMod.BasePoint0, stackAmount - 1); + target.CastSpell(target, SpellIds.PrayerOfMendingJump, args); + } Remove(); } @@ -580,10 +590,10 @@ namespace Scripts.Spells.Priest if (origCaster) { uint basePoints = origCaster.SpellHealingBonusDone(target, _spellInfoHeal, (uint)_healEffectDummy.CalcValue(origCaster), DamageEffectType.Heal, _healEffectDummy); - Dictionary values = new Dictionary(); - values.Add(SpellValueMod.AuraStack, (byte)GetEffectValue()); - values.Add(SpellValueMod.BasePoint0, (int)basePoints); - origCaster.CastCustomSpell(SpellIds.PrayerOfMendingAura, values, target, TriggerCastFlags.FullMask); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.AddSpellMod(SpellValueMod.AuraStack, GetEffectValue()); + args.AddSpellMod(SpellValueMod.BasePoint0, (int)basePoints); + origCaster.CastSpell(target, SpellIds.PrayerOfMendingAura, args); } } @@ -607,7 +617,7 @@ namespace Scripts.Spells.Priest Unit target = GetTarget(); if (dmgInfo.GetDamage() >= target.GetHealth()) { - target.CastSpell(target, SpellIds.SpiritOfRedemption, TriggerCastFlags.FullMask, null, aurEff); + target.CastSpell(target, SpellIds.SpiritOfRedemption, new CastSpellExtraArgs(aurEff)); target.SetFullHealth(); return; } @@ -632,7 +642,7 @@ namespace Scripts.Spells.Priest void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.ArmorOfFaith, true, null, aurEff); + eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.ArmorOfFaith, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -667,7 +677,7 @@ namespace Scripts.Spells.Priest void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.ItemEfficiency, true, null, aurEff); + GetTarget().CastSpell(GetTarget(), SpellIds.ItemEfficiency, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -702,7 +712,9 @@ namespace Scripts.Spells.Priest Unit target = eventInfo.GetProcTarget(); amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.BlessedHealing, AuraType.PeriodicHeal); - caster.CastCustomSpell(SpellIds.BlessedHealing, SpellValueMod.BasePoint0, amount, target, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, amount); + caster.CastSpell(target, SpellIds.BlessedHealing, args); } public override void Register() @@ -736,7 +748,10 @@ namespace Scripts.Spells.Priest int selfHeal = (int)MathFunctions.CalculatePct(damageInfo.GetDamage(), aurEff.GetAmount()); int teamHeal = selfHeal / 2; - GetTarget().CastCustomSpell(null, SpellIds.VampiricEmbraceHeal, teamHeal, selfHeal, 0, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, teamHeal); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint1, selfHeal); + GetTarget().CastSpell((Unit)null, SpellIds.VampiricEmbraceHeal, args); } public override void Register() @@ -781,9 +796,10 @@ namespace Scripts.Spells.Priest AuraEffect aurEff = GetEffect(1); if (aurEff != null) { - int damage = aurEff.GetAmount() * 8; // backfire damage - caster.CastCustomSpell(target, SpellIds.VampiricTouchDispel, damage, 0, 0, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, aurEff.GetAmount() * 8); + caster.CastSpell(target, SpellIds.VampiricTouchDispel, args); } } } @@ -797,7 +813,7 @@ namespace Scripts.Spells.Priest void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - eventInfo.GetProcTarget().CastSpell((Unit)null, SpellIds.GenReplenishment, true, null, aurEff); + eventInfo.GetProcTarget().CastSpell((Unit)null, SpellIds.GenReplenishment, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -830,7 +846,9 @@ namespace Scripts.Spells.Priest { SpellCastTargets targets = new SpellCastTargets(); targets.SetDst(destPos); - GetCaster().CastSpell(targets, Global.SpellMgr.GetSpellInfo(SpellIds.AngelicFeatherAreatrigger, GetCastDifficulty()), null); + CastSpellExtraArgs args = new CastSpellExtraArgs(TriggerCastFlags.FullMask); + args.CastDifficulty = GetCastDifficulty(); + GetCaster().CastSpell(targets, SpellIds.AngelicFeatherAreatrigger, args); } } diff --git a/Source/Scripts/Spells/Quest.cs b/Source/Scripts/Spells/Quest.cs index 665b941b9..0bfceebc4 100644 --- a/Source/Scripts/Spells/Quest.cs +++ b/Source/Scripts/Spells/Quest.cs @@ -371,7 +371,7 @@ namespace Scripts.Spells.Quest { Unit caster = GetCaster(); uint spellId = RandomHelper.randChance(50) ? SpellIds.CreateResonatingSkull : SpellIds.CreateBoneDust; - caster.CastSpell(caster, spellId, true, null); + caster.CastSpell(caster, spellId, true); } public override void Register() @@ -466,7 +466,7 @@ namespace Scripts.Spells.Quest if (target.IsTypeId(TypeId.Unit) && target.HasAura(SpellIds.ForceShieldArcanePurpleX3)) // Make sure nobody else is channeling the same target if (!target.HasAura(SpellIds.ScourgingCrystalController)) - GetCaster().CastSpell(target, SpellIds.ScourgingCrystalController, true, GetCastItem()); + GetCaster().CastSpell(target, SpellIds.ScourgingCrystalController, new CastSpellExtraArgs(GetCastItem())); } public override void Register() @@ -574,7 +574,7 @@ namespace Scripts.Spells.Quest default: return; } - caster.CastSpell(caster, spellId, true, castItem); + caster.CastSpell(caster, spellId, new CastSpellExtraArgs(castItem)); caster.CastSpell(caster, SpellIds.RobotKillCredit, true); target.DespawnOrUnsummon(); } @@ -645,7 +645,7 @@ namespace Scripts.Spells.Quest // sometimes, if you're lucky, you get a dwarf if (RandomHelper.randChance(5)) spellId = SpellIds.SummonAdventurousDwarf; - GetCaster().CastSpell(GetCaster(), spellId, true, null); + GetCaster().CastSpell(GetCaster(), spellId, true); } public override void Register() @@ -667,7 +667,7 @@ namespace Scripts.Spells.Quest if (caster.HasAuraEffect(reqAuraId, 0)) { uint spellId = (uint)GetSpellInfo().GetEffect(0).CalcValue(); - caster.CastSpell(caster, spellId, true, null); + caster.CastSpell(caster, spellId, true); } } @@ -739,7 +739,7 @@ namespace Scripts.Spells.Quest Creature target = GetHitCreature(); if (target) { - caster.CastSpell(caster, SpellIds.TriggerAidOfTheEarthen, true, null); + caster.CastSpell(caster, SpellIds.TriggerAidOfTheEarthen, true); caster.KilledMonsterCredit(CreatureIds.FallenEarthenDefender); target.DespawnOrUnsummon(); } @@ -1204,7 +1204,7 @@ namespace Scripts.Spells.Quest if (playerTarget) // Check if found player target is on fly mount or using flying form if (playerTarget.HasAuraType(AuraType.Fly) || playerTarget.HasAuraType(AuraType.ModIncreaseMountedFlightSpeed)) - playerTarget.CastSpell(playerTarget, SpellIds.FlakCannonTrigger, TriggerCastFlags.IgnoreCasterMountedOrOnVehicle); + playerTarget.CastSpell(playerTarget, SpellIds.FlakCannonTrigger, new CastSpellExtraArgs(TriggerCastFlags.IgnoreCasterMountedOrOnVehicle)); } public override void Register() @@ -1444,7 +1444,7 @@ namespace Scripts.Spells.Quest { WorldLocation pos = GetExplTargetDest(); if (pos != null) - GetCaster().CastSpell(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), (uint)GetEffectValue(), true); + GetCaster().CastSpell(pos.GetPosition(), (uint)GetEffectValue(), new CastSpellExtraArgs(true)); } public override void Register() @@ -1617,7 +1617,7 @@ namespace Scripts.Spells.Quest PreventDefaultAction(); Unit caster = GetCaster(); if (caster) - caster.CastSpell(caster, aurEff.GetSpellEffectInfo().TriggerSpell, true, null, aurEff); + caster.CastSpell(caster, aurEff.GetSpellEffectInfo().TriggerSpell, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -1651,10 +1651,12 @@ namespace Scripts.Spells.Quest void HandleScript(uint effIndex) { - sbyte seatId = 2; if (!GetHitCreature()) return; - GetHitCreature().CastCustomSpell(SpellIds.RideGymer, SpellValueMod.BasePoint0, seatId, GetCaster(), true); + + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, 2); + GetHitCreature().CastSpell(GetCaster(), SpellIds.RideGymer, args); GetHitCreature().CastSpell(GetHitCreature(), SpellIds.Grabbed, true); } @@ -1725,7 +1727,7 @@ namespace Scripts.Spells.Quest { Player player = GetHitPlayer(); if (player) - player.CastSpell(player, SpellIds.TotemOfTheEarthenRing, TriggerCastFlags.FullMask); // ignore reagent cost, consumed by quest + player.CastSpell(player, SpellIds.TotemOfTheEarthenRing, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); // ignore reagent cost, consumed by quest } public override void Register() diff --git a/Source/Scripts/Spells/Shaman.cs b/Source/Scripts/Spells/Shaman.cs index 2d7c0279b..9e7b311b8 100644 --- a/Source/Scripts/Spells/Shaman.cs +++ b/Source/Scripts/Spells/Shaman.cs @@ -101,7 +101,11 @@ namespace Scripts.Spells.Shaman PreventDefaultAction(); int bp0 = MathFunctions.CalculatePct((int)eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()); if (bp0 != 0) - eventInfo.GetActor().CastCustomSpell(SpellIds.AncestralGuidanceHeal, SpellValueMod.BasePoint0, bp0, eventInfo.GetActor(), true, null, aurEff); + { + CastSpellExtraArgs args = new(aurEff); + args.AddSpellMod(SpellValueMod.BasePoint0, bp0); + eventInfo.GetActor().CastSpell(eventInfo.GetActor(), SpellIds.AncestralGuidanceHeal, args); + } } public override void Register() @@ -180,7 +184,11 @@ namespace Scripts.Spells.Shaman AuraEffect gatheringStorms = GetCaster().GetAuraEffect(SpellIds.GatheringStorms, 0); if (gatheringStorms != null) - GetCaster().CastCustomSpell(SpellIds.GatheringStormsBuff, SpellValueMod.BasePoint0, (int)(gatheringStorms.GetAmount() * _targetsHit), GetCaster(), true); + { + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.AddSpellMod(SpellValueMod.BasePoint0, (int)(gatheringStorms.GetAmount() * _targetsHit)); + GetCaster().CastSpell(GetCaster(), SpellIds.GatheringStormsBuff, args); + } } public override void Register() @@ -211,7 +219,7 @@ namespace Scripts.Spells.Shaman { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.EarthShieldHeal, true, null, aurEff, GetCasterGUID()); + GetTarget().CastSpell(GetTarget(), SpellIds.EarthShieldHeal, new CastSpellExtraArgs(aurEff, GetCasterGUID())); } public override void Register() @@ -298,7 +306,7 @@ namespace Scripts.Spells.Shaman Player caster = GetCaster().ToPlayer(); uint spellId = RandomHelper.RAND(SpellIds.ElementalBlastCrit, SpellIds.ElementalBlastHaste, SpellIds.ElementalBlastMastery); - caster.CastSpell(caster, spellId, TriggerCastFlags.FullMask); + caster.CastSpell(caster, spellId, new CastSpellExtraArgs(TriggerCastFlags.FullMask)); } public override void Register() @@ -354,8 +362,9 @@ namespace Scripts.Spells.Shaman PreventDefaultAction(); Unit attacker = eventInfo.GetActor(); - int damage = Math.Max(1, (int)(attacker.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.0264f)); - attacker.CastCustomSpell(SpellIds.FlametongueAttack, SpellValueMod.BasePoint0, damage, eventInfo.GetActionTarget(), TriggerCastFlags.FullMask, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.AddSpellMod(SpellValueMod.BasePoint0, Math.Max(1, (int)(attacker.GetTotalAttackPowerValue(WeaponAttackType.BaseAttack) * 0.0264f))); + attacker.CastSpell(eventInfo.GetActionTarget(), SpellIds.FlametongueAttack, args); } public override void Register() @@ -411,7 +420,7 @@ namespace Scripts.Spells.Shaman void HandleEffectPeriodic(AuraEffect aurEff) { - GetTarget().CastSpell(_x, _y, _z, SpellIds.HealingRainHeal, true, null, aurEff); + GetTarget().CastSpell(new Position(_x, _y, _z), SpellIds.HealingRainHeal, new CastSpellExtraArgs(aurEff)); } void HandleEffecRemoved(AuraEffect aurEff, AuraEffectHandleModes mode) @@ -488,7 +497,7 @@ namespace Scripts.Spells.Shaman void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.ItemLightningShield, true, null, aurEff); + GetTarget().CastSpell(eventInfo.GetProcTarget(), SpellIds.ItemLightningShield, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -508,7 +517,7 @@ namespace Scripts.Spells.Shaman void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - GetTarget().CastSpell(GetTarget(), SpellIds.ItemLightningShieldDamage, true, null, aurEff); + GetTarget().CastSpell(GetTarget(), SpellIds.ItemLightningShieldDamage, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -540,7 +549,11 @@ namespace Scripts.Spells.Shaman { int mana = MathFunctions.CalculatePct(m.Amount, 35); if (mana > 0) - GetTarget().CastCustomSpell(SpellIds.ItemManaSurge, SpellValueMod.BasePoint0, mana, GetTarget(), true, null, aurEff); + { + CastSpellExtraArgs args = new(aurEff); + args.AddSpellMod(SpellValueMod.BasePoint0, mana); + GetTarget().CastSpell(GetTarget(), SpellIds.ItemManaSurge, args); + } } } @@ -792,10 +805,11 @@ namespace Scripts.Spells.Shaman void HandleEffectProc(AuraEffect aurEff, ProcEventInfo eventInfo) { PreventDefaultAction(); - int basePoints0 = -aurEff.GetAmount(); - int basePoints1 = aurEff.GetAmount(); + CastSpellExtraArgs args = new(aurEff); + args.AddSpellMod(SpellValueMod.BasePoint0, -aurEff.GetAmount()); + args.AddSpellMod(SpellValueMod.BasePoint1, aurEff.GetAmount()); - GetTarget().CastCustomSpell(GetTarget(), SpellIds.TidalWaves, basePoints0, basePoints1, 0, true, null, aurEff); + GetTarget().CastSpell(GetTarget(), SpellIds.TidalWaves, args); } public override void Register() @@ -843,7 +857,7 @@ namespace Scripts.Spells.Shaman return; } - caster.CastSpell(target, spellId, true, null, aurEff); + caster.CastSpell(target, spellId, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -895,7 +909,9 @@ namespace Scripts.Spells.Shaman Unit target = eventInfo.GetProcTarget(); amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.Electrified, AuraType.PeriodicDamage); - caster.CastCustomSpell(SpellIds.Electrified, SpellValueMod.BasePoint0, amount, target, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, amount); + caster.CastSpell(target, SpellIds.Electrified, args); } public override void Register() @@ -929,7 +945,9 @@ namespace Scripts.Spells.Shaman Unit target = eventInfo.GetProcTarget(); amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.LavaBurstBonusDamage, AuraType.PeriodicDamage); - caster.CastCustomSpell(SpellIds.LavaBurstBonusDamage, SpellValueMod.BasePoint0, amount, target, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, amount); + caster.CastSpell(target, SpellIds.LavaBurstBonusDamage, args); } public override void Register() @@ -995,7 +1013,9 @@ namespace Scripts.Spells.Shaman Unit target = eventInfo.GetProcTarget(); amount += (int)target.GetRemainingPeriodicAmount(caster.GetGUID(), SpellIds.ChainedHeal, AuraType.PeriodicHeal); - caster.CastCustomSpell(SpellIds.ChainedHeal, SpellValueMod.BasePoint0, amount, target, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, amount); + caster.CastSpell(target, SpellIds.ChainedHeal, args); } public override void Register() @@ -1017,7 +1037,7 @@ namespace Scripts.Spells.Shaman PreventDefaultAction(); for (uint i = 0; i < 2; ++i) - eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.WindfuryAttack, true, null, aurEff); + eventInfo.GetActor().CastSpell(eventInfo.GetProcTarget(), SpellIds.WindfuryAttack, new CastSpellExtraArgs(aurEff)); } public override void Register() diff --git a/Source/Scripts/Spells/Warlock.cs b/Source/Scripts/Spells/Warlock.cs index 0f55b8660..13bf1c741 100644 --- a/Source/Scripts/Spells/Warlock.cs +++ b/Source/Scripts/Spells/Warlock.cs @@ -208,15 +208,16 @@ namespace Scripts.Spells.Warlock if (effect != null) { Unit caster = GetCaster(); - int heal_amount = effect.CalcValue(caster); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.AddSpellMod(SpellValueMod.BasePoint0, effect.CalcValue(caster)); - caster.CastCustomSpell(caster, SpellIds.DevourMagicHeal, heal_amount, 0, 0, true); + caster.CastSpell(caster, SpellIds.DevourMagicHeal, args); // Glyph of Felhunter Unit owner = caster.GetOwner(); if (owner) if (owner.GetAura(SpellIds.GlyphOfDemonTraining) != null) - owner.CastCustomSpell(owner, SpellIds.DevourMagicHeal, heal_amount, 0, 0, true); + owner.CastSpell(owner, SpellIds.DevourMagicHeal, args); } } @@ -427,7 +428,7 @@ namespace Scripts.Spells.Warlock if (!caster) return; - caster.CastSpell(eventInfo.GetActionTarget(), SpellIds.SeedOfCorruptionGeneric, true, null, aurEff); + caster.CastSpell(eventInfo.GetActionTarget(), SpellIds.SeedOfCorruptionGeneric, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -617,7 +618,7 @@ namespace Scripts.Spells.Warlock { PreventDefaultAction(); Unit caster = eventInfo.GetActor(); - caster.CastSpell(caster, _triggerSpell, true, null, aurEff); + caster.CastSpell(caster, _triggerSpell, new CastSpellExtraArgs(aurEff)); } public override void Register() @@ -644,9 +645,10 @@ namespace Scripts.Spells.Warlock AuraEffect aurEff = GetEffect(1); if (aurEff != null) { - int damage = aurEff.GetAmount() * 9; // backfire damage and silence - caster.CastCustomSpell(dispelInfo.GetDispeller(), SpellIds.UnstableAfflictionDispel, damage, 0, 0, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.AddSpellMod(SpellValueMod.BasePoint0, aurEff.GetAmount() * 9); + caster.CastSpell(dispelInfo.GetDispeller(), SpellIds.UnstableAfflictionDispel, args); } } } diff --git a/Source/Scripts/Spells/Warrior.cs b/Source/Scripts/Spells/Warrior.cs index da03b37d8..2fb09d82c 100644 --- a/Source/Scripts/Spells/Warrior.cs +++ b/Source/Scripts/Spells/Warrior.cs @@ -144,7 +144,7 @@ namespace Scripts.Spells.Warrior { Unit caster = GetCaster(); Unit target = GetHitUnit(); - caster.CastCustomSpell(SpellIds.ChargePauseRageDecay, SpellValueMod.BasePoint0, 0, caster, true); + caster.CastSpell(caster, SpellIds.ChargePauseRageDecay, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, 0)); caster.CastSpell(target, SpellIds.ChargeRootEffect, true); caster.CastSpell(target, SpellIds.ChargeSlowEffect, true); } @@ -224,7 +224,7 @@ namespace Scripts.Spells.Warrior { WorldLocation dest = GetHitDest(); if (dest != null) - GetCaster().CastSpell(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), SpellIds.HeroicLeapJump, true); + GetCaster().CastSpell(dest.GetPosition(), SpellIds.HeroicLeapJump, new CastSpellExtraArgs(true)); } public override void Register() @@ -311,7 +311,9 @@ namespace Scripts.Spells.Warrior Unit target = eventInfo.GetActionTarget(); int bp0 = (int)MathFunctions.CalculatePct(target.GetMaxHealth(), GetSpellInfo().GetEffect(1).CalcValue()); - target.CastCustomSpell(SpellIds.Stoicism, SpellValueMod.BasePoint0, bp0, (Unit)null, true); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, bp0); + target.CastSpell((Unit)null, SpellIds.Stoicism, args); } public override void Register() @@ -356,9 +358,10 @@ namespace Scripts.Spells.Warrior void HandleScript(uint effIndex) { - int basePoints0 = (int)(GetHitUnit().CountPctFromMaxHealth(GetEffectValue())); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.AddSpellMod(SpellValueMod.BasePoint0, (int)GetHitUnit().CountPctFromMaxHealth(GetEffectValue())); - GetCaster().CastCustomSpell(GetHitUnit(), SpellIds.RallyingCry, basePoints0, 0, 0, true); + GetCaster().CastSpell(GetHitUnit(), SpellIds.RallyingCry, args); } public override void Register() @@ -472,12 +475,13 @@ namespace Scripts.Spells.Warrior if (spellInfo != null && (spellInfo.Id == SpellIds.BladestormPeriodicWhirlwind || (spellInfo.Id == SpellIds.Execute && !_procTarget.HasAuraState(AuraStateType.Wounded20Percent)))) { // If triggered by Execute (while target is not under 20% hp) or Bladestorm deals normalized weapon damage - GetTarget().CastSpell(_procTarget, SpellIds.SweepingStrikesExtraAttack2, true, null, aurEff); + GetTarget().CastSpell(_procTarget, SpellIds.SweepingStrikesExtraAttack2, new CastSpellExtraArgs(aurEff)); } else { - int damage = (int)damageInfo.GetDamage(); - GetTarget().CastCustomSpell(SpellIds.SweepingStrikesExtraAttack1, SpellValueMod.BasePoint0, damage, _procTarget, true, null, aurEff); + CastSpellExtraArgs args = new(aurEff); + args.AddSpellMod(SpellValueMod.BasePoint0, (int)damageInfo.GetDamage()); + GetTarget().CastSpell(_procTarget, SpellIds.SweepingStrikesExtraAttack1, args); } } } @@ -506,7 +510,9 @@ namespace Scripts.Spells.Warrior int remainingDamage = (int)target.GetRemainingPeriodicAmount(target.GetGUID(), SpellIds.TraumaEffect, AuraType.PeriodicDamage); //Get 25% of damage from the spell casted (Slam & Whirlwind) plus Remaining Damage from Aura int damage = (int)(MathFunctions.CalculatePct(eventInfo.GetDamageInfo().GetDamage(), aurEff.GetAmount()) / Global.SpellMgr.GetSpellInfo(SpellIds.TraumaEffect, GetCastDifficulty()).GetMaxTicks()) + remainingDamage; - GetCaster().CastCustomSpell(SpellIds.TraumaEffect, SpellValueMod.BasePoint0, damage, target, true); + CastSpellExtraArgs args = new(TriggerCastFlags.FullMask); + args.AddSpellMod(SpellValueMod.BasePoint0, damage); + GetCaster().CastSpell(target, SpellIds.TraumaEffect, args); } public override void Register() diff --git a/Source/Scripts/World/EmeraldDragons.cs b/Source/Scripts/World/EmeraldDragons.cs index 579b59322..919413bee 100644 --- a/Source/Scripts/World/EmeraldDragons.cs +++ b/Source/Scripts/World/EmeraldDragons.cs @@ -103,7 +103,7 @@ namespace Scripts.World.EmeraldDragons base.Reset(); me.RemoveUnitFlag(UnitFlags.NotSelectable | UnitFlags.NonAttackable); me.SetReactState(ReactStates.Aggressive); - DoCast(me, SpellIds.MarkOfNatureAura, true); + DoCast(me, SpellIds.MarkOfNatureAura, new CastSpellExtraArgs(true)); _scheduler.Schedule(TimeSpan.FromSeconds(4), task => { @@ -123,8 +123,8 @@ namespace Scripts.World.EmeraldDragons { // Seeping Fog appears only as "pairs", and only ONE pair at any given time! // Despawntime is 2 minutes, so reschedule it for new cast after 2 minutes + a minor "random time" (30 seconds at max) - DoCast(me, SpellIds.SeepingFogLeft, true); - DoCast(me, SpellIds.SeepingFogRight, true); + DoCast(me, SpellIds.SeepingFogLeft, new CastSpellExtraArgs(true)); + DoCast(me, SpellIds.SeepingFogRight, new CastSpellExtraArgs(true)); task.Repeat(TimeSpan.FromMinutes(2), TimeSpan.FromMinutes(2.5)); }); } @@ -245,7 +245,7 @@ namespace Scripts.World.EmeraldDragons Talk(TextIds.SayYsondreSummonDruids); for (byte i = 0; i < 10; ++i) - DoCast(me, SpellIds.SummonDruidSpirits, true); + DoCast(me, SpellIds.SummonDruidSpirits, new CastSpellExtraArgs(true)); ++_stage; } } @@ -357,7 +357,7 @@ namespace Scripts.World.EmeraldDragons public override void KilledUnit(Unit who) { if (who.IsTypeId(TypeId.Player)) - DoCast(who, SpellIds.PutridMushroom, true); + DoCast(who, SpellIds.PutridMushroom, new CastSpellExtraArgs(true)); base.KilledUnit(who); } @@ -372,7 +372,7 @@ namespace Scripts.World.EmeraldDragons if (!HealthAbovePct(100 - 25 * _stage)) { Talk(TextIds.SayEmerissCastCorruption); - DoCast(me, SpellIds.CorruptionOfEarth, true); + DoCast(me, SpellIds.CorruptionOfEarth, new CastSpellExtraArgs(true)); ++_stage; } } @@ -445,7 +445,7 @@ namespace Scripts.World.EmeraldDragons Talk(TextIds.SayTaerarSummonShades); foreach (var spell in SpellIds.TaerarShadeSpells) - DoCastVictim(spell, true); + DoCastVictim(spell, new CastSpellExtraArgs(true)); _shades += (byte)SpellIds.TaerarShadeSpells.Length; DoCast(SpellIds.Shade); diff --git a/Source/Scripts/World/MobGenericCreature.cs b/Source/Scripts/World/MobGenericCreature.cs index b17e1c1b7..a7bf973b9 100644 --- a/Source/Scripts/World/MobGenericCreature.cs +++ b/Source/Scripts/World/MobGenericCreature.cs @@ -15,9 +15,11 @@ * along with this program. If not, see . */ +using Framework.Constants; using Game.AI; using Game.Entities; using Game.Scripting; +using Game.Spells; using System; namespace Scripts.World @@ -27,10 +29,13 @@ namespace Scripts.World { public trigger_periodic(Creature creature) : base(creature) { - var interval = me.GetBaseAttackTime(Framework.Constants.WeaponAttackType.BaseAttack); + var interval = me.GetBaseAttackTime(WeaponAttackType.BaseAttack); + var spell = me.m_spells[0] != 0 ? Global.SpellMgr.GetSpellInfo(me.m_spells[0], me.GetMap().GetDifficultyID()) : null; + _scheduler.Schedule(TimeSpan.FromMilliseconds(interval), task => { - me.CastSpell(me, me.m_spells[0], true); + if (spell != null) + me.CastSpell(me, spell.Id, new CastSpellExtraArgs(TriggerCastFlags.FullMask).SetCastDifficulty(spell.Difficulty)); task.Repeat(TimeSpan.FromMilliseconds(interval)); }); } diff --git a/Source/Scripts/World/NpcSpecial.cs b/Source/Scripts/World/NpcSpecial.cs index dd77ab05f..aef60e8a9 100644 --- a/Source/Scripts/World/NpcSpecial.cs +++ b/Source/Scripts/World/NpcSpecial.cs @@ -695,8 +695,8 @@ namespace Scripts.World.NpcSpecial public override void Reset() { Initialize(); - DoCast(me, SpellIds.Brazier, true); - DoCast(me, SpellIds.FieryAura, false); + DoCast(me, SpellIds.Brazier, new CastSpellExtraArgs(true)); + DoCast(me, SpellIds.FieryAura, new CastSpellExtraArgs(false)); float x, y, z; me.GetPosition(out x, out y, out z); me.Relocate(x, y, z + 0.94f); @@ -744,7 +744,7 @@ namespace Scripts.World.NpcSpecial break; case TextEmotes.Dance: if (!player.HasAura(SpellIds.Seduction)) - DoCast(player, SpellIds.Seduction, true); + DoCast(player, SpellIds.Seduction, new CastSpellExtraArgs(true)); break; } } @@ -1330,7 +1330,7 @@ namespace Scripts.World.NpcSpecial if (me.IsAttackReady()) { - DoCastVictim(SpellIds.Deathtouch, true); + DoCastVictim(SpellIds.Deathtouch, new CastSpellExtraArgs(true)); me.ResetAttackTimer(); } } @@ -1404,7 +1404,7 @@ namespace Scripts.World.NpcSpecial player.SendGossipMenu(GossipMenus.YourFortuneIsCast, me.GetGUID()); break; case eTradeskill.GossipActionInfoDef + 6: - DoCast(player, SpellIds.Fortune, false); + DoCast(player, SpellIds.Fortune, new CastSpellExtraArgs(false)); player.SendGossipMenu(GossipMenus.HereIsYourFortune, me.GetGUID()); break; } @@ -1449,7 +1449,7 @@ namespace Scripts.World.NpcSpecial if (spellId != 0) { - DoCast(player, spellId, false); + DoCast(player, spellId, new CastSpellExtraArgs(false)); player.GetSpellHistory().AddCooldown(spellId, 0, TimeSpan.FromHours(2)); SendAction(player, action); } @@ -1509,7 +1509,7 @@ namespace Scripts.World.NpcSpecial { if (ExplosionTimer <= diff) { - DoCast(me, SpellIds.TonkMineDetonate, true); + DoCast(me, SpellIds.TonkMineDetonate, new CastSpellExtraArgs(true)); me.SetDeathState(DeathState.Dead); // unsummon it } else @@ -1654,27 +1654,27 @@ namespace Scripts.World.NpcSpecial { case eTradeskill.GossipActionInfoDef + 1: // Borean Tundra player.CloseGossipMenu(); - DoCast(player, SpellIds.BoreanTundra, false); + DoCast(player, SpellIds.BoreanTundra, new CastSpellExtraArgs(false)); break; case eTradeskill.GossipActionInfoDef + 2: // Howling Fjord player.CloseGossipMenu(); - DoCast(player, SpellIds.HowlingFjord, false); + DoCast(player, SpellIds.HowlingFjord, new CastSpellExtraArgs(false)); break; case eTradeskill.GossipActionInfoDef + 3: // Sholazar Basin player.CloseGossipMenu(); - DoCast(player, SpellIds.SholazarBasin, false); + DoCast(player, SpellIds.SholazarBasin, new CastSpellExtraArgs(false)); break; case eTradeskill.GossipActionInfoDef + 4: // Icecrown player.CloseGossipMenu(); - DoCast(player, SpellIds.Icecrown, false); + DoCast(player, SpellIds.Icecrown, new CastSpellExtraArgs(false)); break; case eTradeskill.GossipActionInfoDef + 5: // Storm peaks player.CloseGossipMenu(); - DoCast(player, SpellIds.StormPeaks, false); + DoCast(player, SpellIds.StormPeaks, new CastSpellExtraArgs(false)); break; case eTradeskill.GossipActionInfoDef + 6: // Underground player.CloseGossipMenu(); - DoCast(player, SpellIds.Underground, false); + DoCast(player, SpellIds.Underground, new CastSpellExtraArgs(false)); break; } @@ -1931,7 +1931,7 @@ namespace Scripts.World.NpcSpecial } else //me.CastSpell(me, GetFireworkSpell(me.GetEntry()), true); - me.CastSpell(me.GetPositionX(), me.GetPositionY(), me.GetPositionZ(), GetFireworkSpell(me.GetEntry()), true); + me.CastSpell(me.GetPosition(), GetFireworkSpell(me.GetEntry()), new CastSpellExtraArgs(true)); } } @@ -2253,9 +2253,9 @@ namespace Scripts.World.NpcSpecial case GossipMenus.OptionIdIronforgeSilvermoonPennant: case GossipMenus.OptionIdStormwindThunderbluffPennant: if (IsArgentSquire()) - DoCastSelf(Misc.bannerSpells[gossipListId - 3].Item1, true); + DoCastSelf(Misc.bannerSpells[gossipListId - 3].Item1, new CastSpellExtraArgs(true)); else - DoCastSelf(Misc.bannerSpells[gossipListId - 3].Item2, true); + DoCastSelf(Misc.bannerSpells[gossipListId - 3].Item2, new CastSpellExtraArgs(true)); break; } player.PlayerTalkClass.SendCloseGossip();