spell_priest.cpp
// -17 - Power Word: Shield
class spell_pri_power_word_shield : public SpellScriptLoader
{
public:
spell_pri_power_word_shield() : SpellScriptLoader("spell_pri_power_word_shield") { }
class spell_pri_power_word_shield_AuraScript : public AuraScript
{
PrepareAuraScript(spell_pri_power_word_shield_AuraScript);
bool Validate(SpellInfo const* /*spellInfo*/)
{
if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_REFLECTIVE_SHIELD_TRIGGERED))
return false;
if (!sSpellMgr->GetSpellInfo(SPELL_PRIEST_REFLECTIVE_SHIELD_R1))
return false;
return true;
}
void CalculateAmount(AuraEffect const* aurEff, int32& amount, bool& canBeRecalculated)
{
canBeRecalculated = false;
if (Unit* caster = GetCaster())
{
// +80.68% from sp bonus
float bonus = 0.8068f;
// Borrowed Time
if (AuraEffect const* borrowedTime = caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, PRIEST_ICON_ID_BORROWED_TIME, EFFECT_1))
bonus += CalculatePct(1.0f, borrowedTime->GetAmount());
bonus *= caster->SpellBaseHealingBonusDone(GetSpellInfo()->GetSchoolMask());
// Improved PW: Shield: its weird having a SPELLMOD_ALL_EFFECTS here but its blizzards doing
// Improved PW: Shield is only applied at the spell healing bonus because it was already applied to the base value in CalculateSpellDamage
bonus = caster->ApplyEffectModifiers(GetSpellInfo(), aurEff->GetEffIndex(), bonus);
bonus *= caster->CalculateLevelPenalty(GetSpellInfo());
amount += int32(bonus);
// Twin Disciplines
if (AuraEffect const* twinDisciplines = caster->GetAuraEffect(SPELL_AURA_ADD_PCT_MODIFIER, SPELLFAMILY_PRIEST, 0x400000, 0, 0, GetCasterGUID()))
AddPct(amount, twinDisciplines->GetAmount());
// Focused Power
amount *= caster->GetTotalAuraMultiplier(SPELL_AURA_MOD_HEALING_DONE_PERCENT);
}
}
void ReflectDamage(AuraEffect* aurEff, DamageInfo& dmgInfo, uint32& absorbAmount)
{
Unit* target = GetTarget();
if (dmgInfo.GetAttacker() == target)
return;
if (Unit* caster = GetCaster())
if (AuraEffect* talentAurEff = caster->GetAuraEffectOfRankedSpell(SPELL_PRIEST_REFLECTIVE_SHIELD_R1, EFFECT_0))
{
int32 bp = CalculatePct(absorbAmount, talentAurEff->GetAmount());
target->CastCustomSpell(dmgInfo.GetAttacker(), SPELL_PRIEST_REFLECTIVE_SHIELD_TRIGGERED, &bp, NULL, NULL, true, NULL, aurEff);
}
}
void Register()
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_pri_power_word_shield_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_SCHOOL_ABSORB);
AfterEffectAbsorb += AuraEffectAbsorbFn(spell_pri_power_word_shield_AuraScript::ReflectDamage, EFFECT_0);
}
};
AuraScript* GetAuraScript() const
{
return new spell_pri_power_word_shield_AuraScript();
}
};