Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. class spell_warr_execute : public SpellScriptLoader
  2. {
  3. public:
  4. spell_warr_execute() : SpellScriptLoader("spell_warr_execute") { }
  5.  
  6. class spell_warr_execute_SpellScript : public SpellScript
  7. {
  8. PrepareSpellScript(spell_warr_execute_SpellScript);
  9.  
  10. void HandleEffect(SpellEffIndex /*effIndex*/)
  11. {
  12. Unit* caster = GetCaster();
  13. if (GetHitUnit())
  14. {
  15. SpellInfo const* spellInfo = GetSpellInfo();
  16. int32 rageUsed = std::min<int32>(200 - spellInfo->CalcPowerCost(caster, SpellSchoolMask(spellInfo->SchoolMask)), caster->GetPower(POWER_RAGE));
  17. int32 newRage = std::max<int32>(0, caster->GetPower(POWER_RAGE) - rageUsed);
  18.  
  19. // Sudden Death rage save
  20. if (AuraEffect* aurEff = caster->GetAuraEffect(SPELL_AURA_PROC_TRIGGER_SPELL, SPELLFAMILY_GENERIC, WARRIOR_ICON_ID_SUDDEN_DEATH, EFFECT_0))
  21. {
  22. int32 ragesave = aurEff->GetSpellInfo()->Effects[EFFECT_0].CalcValue() * 10;
  23. newRage = std::max(newRage, ragesave);
  24. }
  25.  
  26. caster->SetPower(POWER_RAGE, uint32(newRage));
  27.  
  28. /// Formula taken from the DBC: "${10+$AP*0.437*$m1/100}"
  29. int32 baseDamage = int32(10 + caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.437f * GetEffectValue() / 100.0f);
  30. /// Formula taken from the DBC: "${$ap*0.874*$m1/100-1} = 20 rage"
  31. int32 moreDamage = int32(rageUsed * (caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.874f * GetEffectValue() / 100.0f - 1) / 200);
  32. SetHitDamage(baseDamage + moreDamage);
  33. }
  34. }
  35.  
  36. void Register() override
  37. {
  38. OnEffectHitTarget += SpellEffectFn(spell_warr_execute_SpellScript::HandleEffect, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
  39. }
  40. };
  41.  
  42. SpellScript* GetSpellScript() const override
  43. {
  44. return new spell_warr_execute_SpellScript();
  45. }
  46. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement