Core/Spells: CastSpell Cleanup

Port From (https://github.com/TrinityCore/TrinityCore/commit/)
This commit is contained in:
hondacrx
2021-04-18 18:42:11 -04:00
parent b1ea7212f3
commit d0faa12ef6
45 changed files with 775 additions and 632 deletions
+6 -1
View File
@@ -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);
}
}
}
}
+13 -20
View File
@@ -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];
+1 -1
View File
@@ -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);
}
+1 -1
View File
@@ -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
+2 -4
View File
@@ -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);
+2 -2
View File
@@ -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;
}
@@ -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);
}
}
+5 -6
View File
@@ -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)
+10 -9
View File
@@ -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<SpellValueMod, int> 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());
+3 -3
View File
@@ -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));
}
}
+9 -9
View File
@@ -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<SpellValueMod, int> 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);
}
}
}
+3 -3
View File
@@ -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();
}
+3 -1
View File
@@ -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);
}
}
}
+2 -2
View File
@@ -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
+3 -1
View File
@@ -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)
+43 -104
View File
@@ -1066,124 +1066,58 @@ namespace Game.Entities
return SpellMissInfo.None;
}
public void CastSpell(SpellCastTargets targets, SpellInfo spellInfo, Dictionary<SpellValueMod, int> 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<SpellValueMod, int> 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<SpellValueMod, int> 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<SpellValueMod, int> values = new();
values.Add(mod, value);
CastCustomSpell(spellId, values, target, triggerFlags, castItem, triggeredByAura, originalCaster);
}
public void CastCustomSpell(uint spellId, Dictionary<SpellValueMod, int> 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);
}
}
}
+3 -1
View File
@@ -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)
+4 -3
View File
@@ -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))
+2 -5
View File
@@ -480,11 +480,8 @@ namespace Game
List<uint> 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);
}
+15 -32
View File
@@ -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
{
+66 -45
View File
@@ -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
{
+101 -14
View File
@@ -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<WorldObject> 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<SpellValueMod, int> 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;
}
}
}
+71 -64
View File
@@ -385,17 +385,14 @@ namespace Game.Spells
targets.SetUnitTarget(m_caster);
}
Dictionary<SpellValueMod, int> 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<SpellValueMod, int> 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<SpellValueMod, int> 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);
}
}
+1
View File
@@ -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