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
+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();
}