Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class spell_warr_execute : public SpellScriptLoader
- {
- public:
- spell_warr_execute() : SpellScriptLoader("spell_warr_execute") { }
- class spell_warr_execute_SpellScript : public SpellScript
- {
- PrepareSpellScript(spell_warr_execute_SpellScript);
- void HandleEffect(SpellEffIndex /*effIndex*/)
- {
- Unit* caster = GetCaster();
- if (GetHitUnit())
- {
- SpellInfo const* spellInfo = GetSpellInfo();
- int32 rageUsed = std::min<int32>(200 - spellInfo->CalcPowerCost(caster, SpellSchoolMask(spellInfo->SchoolMask)), caster->GetPower(POWER_RAGE));
- int32 newRage = std::max<int32>(0, caster->GetPower(POWER_RAGE) - rageUsed);
- // Sudden Death rage save
- if (AuraEffect* aurEff = caster->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_GENERIC, WARRIOR_ICON_ID_SUDDEN_DEATH, EFFECT_0))
- {
- int32 ragesave = aurEff->GetSpellInfo()->Effects[EFFECT_0].CalcValue() * 10;
- newRage = std::max(newRage, ragesave);
- }
- caster->SetPower(POWER_RAGE, uint32(newRage));
- /// Formula taken from the DBC: "${10+$AP*0.437*$m1/100}"
- int32 baseDamage = int32(10 + caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.437f * GetEffectValue() / 100.0f);
- /// Formula taken from the DBC: "${$ap*0.874*$m1/100-1} = 20 rage"
- int32 moreDamage = int32(rageUsed * (caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.874f * GetEffectValue() / 100.0f - 1) / 200);
- SetHitDamage(baseDamage + moreDamage);
- }
- }
- void Register() override
- {
- OnEffectHitTarget += SpellEffectFn(spell_warr_execute_SpellScript::HandleEffect, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
- }
- };
- SpellScript* GetSpellScript() const override
- {
- return new spell_warr_execute_SpellScript();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement