Scripts/Spells: Use Spell::GetPowerTypeCostAmount where possible instead of iterating Spell::GetPowerCost
Port From (https://github.com/TrinityCore/TrinityCore/commit/26376d89e165aece42e58213632ef43ecb0d81b3)
This commit is contained in:
@@ -1761,12 +1761,11 @@ namespace Scripts.Spells.Druid
|
||||
return;
|
||||
|
||||
Unit caster = eventInfo.GetActor();
|
||||
List<SpellPowerCost> costs = spell.GetPowerCost();
|
||||
var m = costs.Find(cost => cost.Power == PowerType.Mana);
|
||||
if (m == null)
|
||||
int? manaCost = spell.GetPowerTypeCostAmount(PowerType.Mana);
|
||||
if (!manaCost.HasValue)
|
||||
return;
|
||||
|
||||
int amount = MathFunctions.CalculatePct(m.Amount, aurEff.GetAmount());
|
||||
int amount = MathFunctions.CalculatePct(manaCost.Value, aurEff.GetAmount());
|
||||
CastSpellExtraArgs args = new(aurEff);
|
||||
args.AddSpellMod(SpellValueMod.BasePoint0, amount);
|
||||
caster.CastSpell(null, SpellIds.Exhilarate, args);
|
||||
|
||||
@@ -1472,13 +1472,8 @@ namespace Scripts.Spells.Azerite
|
||||
bool CheckProc(ProcEventInfo eventInfo)
|
||||
{
|
||||
Spell spell = eventInfo.GetProcSpell();
|
||||
if (spell != null)
|
||||
{
|
||||
var cost = spell.GetPowerCost();
|
||||
var m = cost.Find(cost => cost.Power == PowerType.Mana && cost.Amount > 0);
|
||||
if (m != null)
|
||||
return true;
|
||||
}
|
||||
if (spell != null && spell.GetPowerTypeCostAmount(PowerType.Mana) > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -782,10 +782,9 @@ namespace Scripts.Spells.Rogue
|
||||
damagePerCombo += t5.GetAmount();
|
||||
|
||||
int finalDamage = damagePerCombo;
|
||||
List<SpellPowerCost> cost = GetSpell().GetPowerCost();
|
||||
var c = cost.Find(cost => cost.Power == PowerType.ComboPoints);
|
||||
if (c != null)
|
||||
finalDamage *= c.Amount;
|
||||
int? comboPointCost = GetSpell().GetPowerTypeCostAmount(PowerType.ComboPoints);
|
||||
if (comboPointCost.HasValue)
|
||||
finalDamage *= comboPointCost.Value;
|
||||
|
||||
SetHitDamage(finalDamage);
|
||||
}
|
||||
|
||||
@@ -977,11 +977,10 @@ namespace Scripts.Spells.Shaman
|
||||
{
|
||||
PreventDefaultAction();
|
||||
|
||||
List<SpellPowerCost> costs = eventInfo.GetProcSpell().GetPowerCost();
|
||||
var m = costs.Find(cost => cost.Power == PowerType.Mana);
|
||||
if (m != null)
|
||||
int? manaCost = eventInfo.GetProcSpell().GetPowerTypeCostAmount(PowerType.Mana);
|
||||
if (manaCost.HasValue)
|
||||
{
|
||||
int mana = MathFunctions.CalculatePct(m.Amount, 35);
|
||||
int mana = MathFunctions.CalculatePct(manaCost.Value, 35);
|
||||
if (mana > 0)
|
||||
{
|
||||
CastSpellExtraArgs args = new(aurEff);
|
||||
|
||||
Reference in New Issue
Block a user