mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 01:37:37 +01:00
Core/Spells: Implemented multiple spell power costs
This commit is contained in:
@@ -539,8 +539,13 @@ class spell_dru_lifebloom : public SpellScriptLoader
|
||||
GetTarget()->CastCustomSpell(GetTarget(), SPELL_DRUID_LIFEBLOOM_FINAL_HEAL, &healAmount, NULL, NULL, true, NULL, aurEff, GetCasterGUID());
|
||||
|
||||
// restore mana
|
||||
int32 returnMana = CalculatePct(caster->GetCreateMana(), GetSpellInfo()->ManaCostPercentage) * stack / 2;
|
||||
caster->CastCustomSpell(caster, SPELL_DRUID_LIFEBLOOM_ENERGIZE, &returnMana, NULL, NULL, true, NULL, aurEff, GetCasterGUID());
|
||||
std::vector<SpellInfo::CostData> costs = GetSpellInfo()->CalcPowerCost(caster, GetSpellInfo()->GetSchoolMask());
|
||||
auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_MANA; });
|
||||
if (m != costs.end())
|
||||
{
|
||||
int32 returnMana = m->Amount * stack / 2;
|
||||
caster->CastCustomSpell(caster, SPELL_DRUID_LIFEBLOOM_ENERGIZE, &returnMana, NULL, NULL, true, NULL, aurEff, GetCasterGUID());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -562,8 +567,13 @@ class spell_dru_lifebloom : public SpellScriptLoader
|
||||
target->CastCustomSpell(target, SPELL_DRUID_LIFEBLOOM_FINAL_HEAL, &healAmount, NULL, NULL, true, NULL, NULL, GetCasterGUID());
|
||||
|
||||
// restore mana
|
||||
int32 returnMana = CalculatePct(caster->GetCreateMana(), GetSpellInfo()->ManaCostPercentage) * dispelInfo->GetRemovedCharges() / 2;
|
||||
caster->CastCustomSpell(caster, SPELL_DRUID_LIFEBLOOM_ENERGIZE, &returnMana, NULL, NULL, true, NULL, NULL, GetCasterGUID());
|
||||
std::vector<SpellInfo::CostData> costs = GetSpellInfo()->CalcPowerCost(caster, GetSpellInfo()->GetSchoolMask());
|
||||
auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_MANA; });
|
||||
if (m != costs.end())
|
||||
{
|
||||
int32 returnMana = m->Amount * dispelInfo->GetRemovedCharges() / 2;
|
||||
caster->CastCustomSpell(caster, SPELL_DRUID_LIFEBLOOM_ENERGIZE, &returnMana, NULL, NULL, true, NULL, NULL, GetCasterGUID());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -947,10 +947,14 @@ class spell_hun_thrill_of_the_hunt : public SpellScriptLoader
|
||||
void HandleEffectProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
|
||||
{
|
||||
PreventDefaultAction();
|
||||
int32 focus = eventInfo.GetDamageInfo()->GetSpellInfo()->CalcPowerCost(GetTarget(), SpellSchoolMask(eventInfo.GetDamageInfo()->GetSchoolMask()));
|
||||
focus = CalculatePct(focus, aurEff->GetAmount());
|
||||
|
||||
GetTarget()->CastCustomSpell(GetTarget(), SPELL_HUNTER_THRILL_OF_THE_HUNT, &focus, NULL, NULL, true, NULL, aurEff);
|
||||
std::vector<SpellInfo::CostData> costs = eventInfo.GetDamageInfo()->GetSpellInfo()->CalcPowerCost(GetTarget(), SpellSchoolMask(eventInfo.GetDamageInfo()->GetSchoolMask()));
|
||||
auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_FOCUS; });
|
||||
if (m != costs.end())
|
||||
{
|
||||
int32 focus = CalculatePct(m->Amount, aurEff->GetAmount());
|
||||
if (focus > 0)
|
||||
GetTarget()->CastCustomSpell(GetTarget(), SPELL_HUNTER_THRILL_OF_THE_HUNT, &focus, NULL, NULL, true, NULL, aurEff);
|
||||
}
|
||||
}
|
||||
|
||||
void Register() override
|
||||
|
||||
@@ -1004,11 +1004,14 @@ class spell_mage_master_of_elements : public SpellScriptLoader
|
||||
{
|
||||
PreventDefaultAction();
|
||||
|
||||
int32 mana = int32(eventInfo.GetDamageInfo()->GetSpellInfo()->CalcPowerCost(GetTarget(), eventInfo.GetDamageInfo()->GetSchoolMask()));
|
||||
mana = CalculatePct(mana, aurEff->GetAmount());
|
||||
|
||||
if (mana > 0)
|
||||
GetTarget()->CastCustomSpell(SPELL_MAGE_MASTER_OF_ELEMENTS_ENERGIZE, SPELLVALUE_BASE_POINT0, mana, GetTarget(), true, NULL, aurEff);
|
||||
std::vector<SpellInfo::CostData> costs = eventInfo.GetDamageInfo()->GetSpellInfo()->CalcPowerCost(GetTarget(), eventInfo.GetDamageInfo()->GetSchoolMask());
|
||||
auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_MANA; });
|
||||
if (m != costs.end())
|
||||
{
|
||||
int32 mana = CalculatePct(m->Amount, aurEff->GetAmount());
|
||||
if (mana > 0)
|
||||
GetTarget()->CastCustomSpell(SPELL_MAGE_MASTER_OF_ELEMENTS_ENERGIZE, SPELLVALUE_BASE_POINT0, mana, GetTarget(), true, NULL, aurEff);
|
||||
}
|
||||
}
|
||||
|
||||
void Register() override
|
||||
|
||||
@@ -794,10 +794,14 @@ class spell_sha_item_mana_surge : public SpellScriptLoader
|
||||
void OnProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
|
||||
{
|
||||
PreventDefaultAction();
|
||||
int32 mana = eventInfo.GetDamageInfo()->GetSpellInfo()->CalcPowerCost(GetTarget(), SpellSchoolMask(eventInfo.GetDamageInfo()->GetSchoolMask()));
|
||||
mana = int32(CalculatePct(mana, 35));
|
||||
|
||||
GetTarget()->CastCustomSpell(SPELL_SHAMAN_ITEM_MANA_SURGE, SPELLVALUE_BASE_POINT0, mana, GetTarget(), true, NULL, aurEff);
|
||||
std::vector<SpellInfo::CostData> costs = eventInfo.GetDamageInfo()->GetSpellInfo()->CalcPowerCost(GetTarget(), eventInfo.GetDamageInfo()->GetSchoolMask());
|
||||
auto m = std::find_if(costs.begin(), costs.end(), [](SpellInfo::CostData const& cost) { return cost.Power == POWER_MANA; });
|
||||
if (m != costs.end())
|
||||
{
|
||||
int32 mana = CalculatePct(m->Amount, 35);
|
||||
if (mana > 0)
|
||||
GetTarget()->CastCustomSpell(SPELL_SHAMAN_ITEM_MANA_SURGE, SPELLVALUE_BASE_POINT0, mana, GetTarget(), true, NULL, aurEff);
|
||||
}
|
||||
}
|
||||
|
||||
void Register() override
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
if (buffTimer <= diff)
|
||||
{
|
||||
//Find a spell that targets friendly and applies an aura (these are generally buffs)
|
||||
SpellInfo const* info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_AURA);
|
||||
SpellInfo const* info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, SELECT_EFFECT_AURA);
|
||||
|
||||
if (info && !globalCooldown)
|
||||
{
|
||||
@@ -124,13 +124,13 @@ public:
|
||||
|
||||
//Select a healing spell if less than 30% hp
|
||||
if (me->HealthBelowPct(30))
|
||||
info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING);
|
||||
info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, SELECT_EFFECT_HEALING);
|
||||
|
||||
//No healing spell available, select a hostile spell
|
||||
if (info)
|
||||
healing = true;
|
||||
else
|
||||
info = SelectSpell(me->GetVictim(), 0, 0, SELECT_TARGET_ANY_ENEMY, 0, 0, 0, 0, SELECT_EFFECT_DONTCARE);
|
||||
info = SelectSpell(me->GetVictim(), 0, 0, SELECT_TARGET_ANY_ENEMY, 0, 0, SELECT_EFFECT_DONTCARE);
|
||||
|
||||
//20% chance to replace our white hit with a spell
|
||||
if (info && urand(0, 99) < 20 && !globalCooldown)
|
||||
@@ -160,13 +160,13 @@ public:
|
||||
|
||||
//Select a healing spell if less than 30% hp ONLY 33% of the time
|
||||
if (me->HealthBelowPct(30) && 33 > urand(0, 99))
|
||||
info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING);
|
||||
info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, SELECT_EFFECT_HEALING);
|
||||
|
||||
//No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE)
|
||||
if (info)
|
||||
healing = true;
|
||||
else
|
||||
info = SelectSpell(me->GetVictim(), 0, 0, SELECT_TARGET_ANY_ENEMY, 0, 0, NOMINAL_MELEE_RANGE, 0, SELECT_EFFECT_DONTCARE);
|
||||
info = SelectSpell(me->GetVictim(), 0, 0, SELECT_TARGET_ANY_ENEMY, NOMINAL_MELEE_RANGE, 0, SELECT_EFFECT_DONTCARE);
|
||||
|
||||
//Found a spell, check if we arn't on cooldown
|
||||
if (info && !globalCooldown)
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
if (BuffTimer <= diff)
|
||||
{
|
||||
//Find a spell that targets friendly and applies an aura (these are generally buffs)
|
||||
SpellInfo const* info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_AURA);
|
||||
SpellInfo const* info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, SELECT_EFFECT_AURA);
|
||||
|
||||
if (info && !GlobalCooldown)
|
||||
{
|
||||
@@ -108,11 +108,11 @@ public:
|
||||
|
||||
//Select a healing spell if less than 30% hp
|
||||
if (HealthBelowPct(30))
|
||||
info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING);
|
||||
info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, SELECT_EFFECT_HEALING);
|
||||
|
||||
//No healing spell available, select a hostile spell
|
||||
if (info) Healing = true;
|
||||
else info = SelectSpell(me->GetVictim(), 0, 0, SELECT_TARGET_ANY_ENEMY, 0, 0, 0, 0, SELECT_EFFECT_DONTCARE);
|
||||
else info = SelectSpell(me->GetVictim(), 0, 0, SELECT_TARGET_ANY_ENEMY, 0, 0, SELECT_EFFECT_DONTCARE);
|
||||
|
||||
//50% chance if elite or higher, 20% chance if not, to replace our white hit with a spell
|
||||
if (info && (rand32() % (me->GetCreatureTemplate()->rank > 1 ? 2 : 5) == 0) && !GlobalCooldown)
|
||||
@@ -139,11 +139,11 @@ public:
|
||||
|
||||
//Select a healing spell if less than 30% hp ONLY 33% of the time
|
||||
if (HealthBelowPct(30) && rand32() % 3 == 0)
|
||||
info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, 0, 0, SELECT_EFFECT_HEALING);
|
||||
info = SelectSpell(me, 0, 0, SELECT_TARGET_ANY_FRIEND, 0, 0, SELECT_EFFECT_HEALING);
|
||||
|
||||
//No healing spell available, See if we can cast a ranged spell (Range must be greater than ATTACK_DISTANCE)
|
||||
if (info) Healing = true;
|
||||
else info = SelectSpell(me->GetVictim(), 0, 0, SELECT_TARGET_ANY_ENEMY, 0, 0, NOMINAL_MELEE_RANGE, 0, SELECT_EFFECT_DONTCARE);
|
||||
else info = SelectSpell(me->GetVictim(), 0, 0, SELECT_TARGET_ANY_ENEMY, NOMINAL_MELEE_RANGE, 0, SELECT_EFFECT_DONTCARE);
|
||||
|
||||
//Found a spell, check if we arn't on cooldown
|
||||
if (info && !GlobalCooldown)
|
||||
|
||||
Reference in New Issue
Block a user