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
+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
{