Core/Spell: SpellValueOverrides encapsulation

Port From (https://github.com/TrinityCore/TrinityCore/commit/5fbddef85f48f6b9140d025d7f2e14faae0af178)
This commit is contained in:
hondacrx
2021-06-22 18:43:40 -04:00
parent 046cd9f917
commit c51c4d443f
21 changed files with 74 additions and 66 deletions
+1 -1
View File
@@ -1401,7 +1401,7 @@ namespace Game.Entities
CastSpellExtraArgs args = new(TriggerCastFlags.FullMask);
if (auraId == 35696) // Demonic Knowledge
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, MathFunctions.CalculatePct(aura.GetDamage(), GetStat(Stats.Stamina) + GetStat(Stats.Intellect)));
args.AddSpellMod(SpellValueMod.BasePoint0, MathFunctions.CalculatePct(aura.GetDamage(), GetStat(Stats.Stamina) + GetStat(Stats.Intellect)));
CastSpell(this, auraId, args);
}
+6 -2
View File
@@ -5138,7 +5138,7 @@ namespace Game.Entities
if (artifactPowerRank.AuraPointsOverride != 0)
for (int i = 0; i < SpellConst.MaxEffects; ++i)
if (spellInfo.GetEffect((uint)i) != null)
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, (int)artifactPowerRank.AuraPointsOverride);
args.AddSpellMod(SpellValueMod.BasePoint0 + i, (int)artifactPowerRank.AuraPointsOverride);
CastSpell(this, artifactPowerRank.SpellID, args);
}
@@ -5228,7 +5228,11 @@ namespace Game.Entities
if (major && currentRank == 1)
{
if (apply)
CastSpell(this, PlayerConst.SpellIdHeartEssenceActionBarOverride, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, (int)azeriteEssencePower.MajorPowerDescription));
{
CastSpellExtraArgs args = new(TriggerCastFlags.FullMask);
args.AddSpellMod(SpellValueMod.BasePoint0, (int)azeriteEssencePower.MajorPowerDescription);
CastSpell(this, PlayerConst.SpellIdHeartEssenceActionBarOverride, args);
}
else
RemoveAurasDueToSpell(PlayerConst.SpellIdHeartEssenceActionBarOverride);
}
+1 -1
View File
@@ -3268,7 +3268,7 @@ namespace Game.Entities
for (byte i = 0; i < SpellConst.MaxEffects; ++i)
{
if (spellInfo.GetEffect(i).IsEffect())
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, MathFunctions.CalculatePct(spellInfo.GetEffect(i).CalcValue(this), effectPct));
args.AddSpellMod(SpellValueMod.BasePoint0 + i, MathFunctions.CalculatePct(spellInfo.GetEffect(i).CalcValue(this), effectPct));
}
}
+1 -1
View File
@@ -3009,7 +3009,7 @@ namespace Game.Entities
{
CastSpellExtraArgs args = new(flags);
args.OriginalCaster = origCasterGUID;
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, seatId + 1);
args.AddSpellMod(SpellValueMod.BasePoint0 + i, seatId + 1);
caster.CastSpell(target, clickInfo.spellId, args);
}
else // This can happen during Player._LoadAuras
+3 -3
View File
@@ -862,11 +862,11 @@ namespace Game.Entities
return targets.SelectRandom();
}
public void EnterVehicle(Unit Base, sbyte seatId = -1)
public void EnterVehicle(Unit baseUnit, sbyte seatId = -1)
{
CastSpellExtraArgs args = new(TriggerCastFlags.IgnoreCasterMountedOrOnVehicle);
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, seatId + 1);
CastSpell(this, SharedConst.VehicleSpellRideHardcoded, args);
args.AddSpellMod(SpellValueMod.BasePoint0, seatId + 1);
CastSpell(baseUnit, SharedConst.VehicleSpellRideHardcoded, args);
}
public void _EnterVehicle(Vehicle vehicle, sbyte seatId, AuraApplication aurApp)
+2 -2
View File
@@ -1276,7 +1276,7 @@ namespace Game.Spells
if (caster.HasAura(64760))
{
CastSpellExtraArgs args = new(GetEffect(0));
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, GetEffect(0).GetAmount());
args.AddSpellMod(SpellValueMod.BasePoint0, GetEffect(0).GetAmount());
caster.CastSpell(target, 64801, args);
}
}
@@ -1331,7 +1331,7 @@ namespace Game.Spells
{
float multiplier = aurEff.GetAmount();
CastSpellExtraArgs args = new(TriggerCastFlags.FullMask);
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, MathFunctions.CalculatePct(caster.GetMaxPower(PowerType.Mana), multiplier));
args.AddSpellMod(SpellValueMod.BasePoint0, MathFunctions.CalculatePct(caster.GetMaxPower(PowerType.Mana), multiplier));
caster.CastSpell(caster, 47755, args);
}
}
+4 -4
View File
@@ -4619,7 +4619,7 @@ namespace Game.Spells
CastSpellExtraArgs args = new(this);
if (GetAmount() != 0) // If amount avalible cast with basepoints (Crypt Fever for example)
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, GetAmount());
args.AddSpellMod(SpellValueMod.BasePoint0, GetAmount());
caster.CastSpell(target, triggeredSpellId, args);
}
@@ -4883,7 +4883,7 @@ namespace Game.Spells
{
CastSpellExtraArgs args = new(this);
for (int i = 0; i < SpellConst.MaxEffects; ++i)
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, GetAmount());
args.AddSpellMod(SpellValueMod.BasePoint0 + i, GetAmount());
triggerCaster.CastSpell(target, triggerSpellId, args);
Log.outDebug(LogFilter.Spells, "AuraEffect.HandlePeriodicTriggerSpellWithValueAuraTick: Spell {0} Trigger {1}", GetId(), triggeredSpellInfo.Id);
@@ -5272,7 +5272,7 @@ namespace Game.Spells
int feedAmount = MathFunctions.CalculatePct(gainedAmount, manaFeedVal);
CastSpellExtraArgs args = new(this);
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, feedAmount);
args.AddSpellMod(SpellValueMod.BasePoint0, feedAmount);
caster.CastSpell(caster, 32554, args);
}
}
@@ -5425,7 +5425,7 @@ namespace Game.Spells
if (triggeredSpellInfo != null)
{
CastSpellExtraArgs args = new(this);
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, GetAmount());
args.AddSpellMod(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());
}
+15 -13
View File
@@ -389,7 +389,7 @@ namespace Game.Spells
// set basepoints for trigger with value effect
if (effectInfo.Effect == SpellEffectName.TriggerSpellWithValue)
for (int i = 0; i < SpellConst.MaxEffects; ++i)
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, damage);
args.AddSpellMod(SpellValueMod.BasePoint0 + i, damage);
// original caster guid only for GO cast
m_caster.CastSpell(targets, spellInfo.Id, args);
@@ -435,7 +435,7 @@ namespace Game.Spells
// set basepoints for trigger with value effect
if (effectInfo.Effect == SpellEffectName.TriggerMissileSpellWithValue)
for (int i = 0; i < SpellConst.MaxEffects; ++i)
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, damage);
args.AddSpellMod(SpellValueMod.BasePoint0 + i, damage);
// original caster guid only for GO cast
m_caster.CastSpell(targets, spellInfo.Id, args);
@@ -474,7 +474,7 @@ namespace Game.Spells
case 52349: // Overtake
{
CastSpellExtraArgs args1 = new(m_originalCasterGUID);
args1.SpellValueOverrides.Add(SpellValueMod.BasePoint0, damage);
args1.AddSpellMod(SpellValueMod.BasePoint0, damage);
unitTarget.CastSpell(unitTarget, spellInfo.Id, args1);
return;
}
@@ -492,7 +492,7 @@ namespace Game.Spells
// 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);
args.AddSpellMod(SpellValueMod.BasePoint0 + i, damage);
unitTarget.CastSpell(m_caster, spellInfo.Id, args);
}
@@ -1746,7 +1746,7 @@ namespace Game.Spells
// if we have small value, it indicates seat position
if (basePoints > 0 && basePoints < SharedConst.MaxVehicleSeats)
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, basePoints);
args.AddSpellMod(SpellValueMod.BasePoint0, basePoints);
m_originalCaster.CastSpell(summon, spellId, args);
@@ -3176,7 +3176,7 @@ namespace Game.Spells
if (totem != null && totem.IsTotem())
{
CastSpellExtraArgs args = new(TriggerCastFlags.FullMask);
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, damage);
args.AddSpellMod(SpellValueMod.BasePoint0, damage);
m_caster.CastSpell(totem, 55277, args);
}
}
@@ -3571,12 +3571,8 @@ namespace Game.Spells
ExecuteLogEffectDestroyItem(effIndex, foodItem.GetEntry());
uint count = 1;
player.DestroyItemCount(foodItem, ref count, true);
// @todo fix crash when a spell has two effects, both pointed at the same item target
int pct;
int levelDiff = (int)(pet.GetLevel() - foodItem.GetTemplate().GetBaseItemLevel());
int levelDiff = (int)pet.GetLevel() - (int)foodItem.GetTemplate().GetBaseItemLevel();
if (levelDiff >= 30)
return;
else if (levelDiff >= 20)
@@ -3586,7 +3582,13 @@ namespace Game.Spells
else
pct = 50;
m_caster.CastSpell(pet, effectInfo.TriggerSpell, new CastSpellExtraArgs(SpellValueMod.BasePoint0, pct).SetTriggerFlags(TriggerCastFlags.FullMask));
uint count = 1;
player.DestroyItemCount(foodItem, ref count, true);
// @todo fix crash when a spell has two effects, both pointed at the same item target
CastSpellExtraArgs args = new(TriggerCastFlags.FullMask);
args.AddSpellMod(SpellValueMod.BasePoint0, pct);
m_caster.CastSpell(pet, effectInfo.TriggerSpell, args);
}
[SpellEffectHandler(SpellEffectName.DismissPet)]
@@ -4272,7 +4274,7 @@ namespace Game.Spells
if (mana != 0)
{
CastSpellExtraArgs args = new(TriggerCastFlags.FullMask);
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, mana);
args.AddSpellMod(SpellValueMod.BasePoint0, mana);
m_caster.CastSpell(m_caster, 39104, args);
}
}