mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-24 10:56:38 +01:00
Scripts/Spells: Use Spell::GetPowerTypeCostAmount where possible instead of iterating Spell::GetPowerCost
This commit is contained in:
@@ -1846,12 +1846,11 @@ class spell_dru_t3_8p_bonus : public AuraScript
|
||||
return;
|
||||
|
||||
Unit* caster = eventInfo.GetActor();
|
||||
std::vector<SpellPowerCost> const& costs = spell->GetPowerCost();
|
||||
auto m = std::find_if(costs.begin(), costs.end(), [](SpellPowerCost const& cost) { return cost.Power == POWER_MANA; });
|
||||
if (m == costs.end())
|
||||
Optional<int32> manaCost = spell->GetPowerTypeCostAmount(POWER_MANA);
|
||||
if (!manaCost)
|
||||
return;
|
||||
|
||||
int32 amount = CalculatePct(m->Amount, aurEff->GetAmount());
|
||||
int32 amount = CalculatePct(*manaCost, aurEff->GetAmount());
|
||||
CastSpellExtraArgs args(aurEff);
|
||||
args.AddSpellBP0(amount);
|
||||
caster->CastSpell(nullptr, SPELL_DRUID_EXHILARATE, args);
|
||||
|
||||
@@ -1658,12 +1658,8 @@ class spell_item_pendant_of_the_violet_eye : public AuraScript
|
||||
bool CheckProc(ProcEventInfo& eventInfo)
|
||||
{
|
||||
if (Spell const* spell = eventInfo.GetProcSpell())
|
||||
{
|
||||
std::vector<SpellPowerCost> const& costs = spell->GetPowerCost();
|
||||
auto m = std::find_if(costs.begin(), costs.end(), [](SpellPowerCost const& cost) { return cost.Power == POWER_MANA && cost.Amount > 0; });
|
||||
if (m != costs.end())
|
||||
if (spell->GetPowerTypeCostAmount(POWER_MANA) > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1031,10 +1031,8 @@ class spell_rog_sinister_strike : public SpellScript
|
||||
damagePerCombo += t5->GetAmount();
|
||||
|
||||
int32 finalDamage = damagePerCombo;
|
||||
std::vector<SpellPowerCost> const& costs = GetSpell()->GetPowerCost();
|
||||
auto c = std::find_if(costs.begin(), costs.end(), [](SpellPowerCost const& cost) { return cost.Power == POWER_COMBO_POINTS; });
|
||||
if (c != costs.end())
|
||||
finalDamage *= c->Amount;
|
||||
if (Optional<int32> comboPointCost = GetSpell()->GetPowerTypeCostAmount(POWER_COMBO_POINTS))
|
||||
finalDamage *= *comboPointCost;
|
||||
|
||||
SetHitDamage(finalDamage);
|
||||
}
|
||||
|
||||
@@ -1012,11 +1012,9 @@ class spell_sha_item_mana_surge : public AuraScript
|
||||
{
|
||||
PreventDefaultAction();
|
||||
|
||||
std::vector<SpellPowerCost> const& costs = eventInfo.GetProcSpell()->GetPowerCost();
|
||||
auto m = std::find_if(costs.begin(), costs.end(), [](SpellPowerCost const& cost) { return cost.Power == POWER_MANA; });
|
||||
if (m != costs.end())
|
||||
if (Optional<int32> manaCost = eventInfo.GetProcSpell()->GetPowerTypeCostAmount(POWER_MANA))
|
||||
{
|
||||
int32 mana = CalculatePct(m->Amount, 35);
|
||||
int32 mana = CalculatePct(*manaCost, 35);
|
||||
if (mana > 0)
|
||||
{
|
||||
CastSpellExtraArgs args(aurEff);
|
||||
|
||||
Reference in New Issue
Block a user