diff options
author | faq <ainarsh@gmail.com> | 2012-09-24 18:05:00 +0300 |
---|---|---|
committer | faq <ainarsh@gmail.com> | 2012-09-24 18:18:30 +0300 |
commit | da4067cb30f3bf45f1456dd1411cf9f4c1df8c5c (patch) | |
tree | fc309de3b44b2463658c9d221a9b52e2687079ca /src | |
parent | a4e3709dd3a1554ca01544bac365aea1629d7ed5 (diff) |
Implementing split dmg cap to Divine Sacrifice. Author Tibbi
+correcting previos sql
Closes #6024
Diffstat (limited to 'src')
-rw-r--r-- | src/server/scripts/Spells/spell_paladin.cpp | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index 43c4dc139a3..ad0ed6a7e20 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -24,6 +24,7 @@ #include "ScriptMgr.h" #include "SpellScript.h" #include "SpellAuraEffects.h" +#include "Group.h" enum PaladinSpells @@ -49,6 +50,7 @@ enum PaladinSpells SPELL_IMMUNE_SHIELD_MARKER = 61988, SPELL_HAND_OF_SACRIFICE = 6940, + SPELL_DIVINE_SACRIFICE = 64205, }; // 31850 - Ardent Defender @@ -577,7 +579,6 @@ class spell_pal_hand_of_sacrifice : public SpellScriptLoader { PrepareAuraScript(spell_pal_hand_of_sacrifice_AuraScript); - uint32 splitPct; int32 remainingAmount; Unit* caster; @@ -587,7 +588,6 @@ class spell_pal_hand_of_sacrifice : public SpellScriptLoader if (!caster) return false; remainingAmount = caster->GetMaxHealth(); - splitPct = GetSpellInfo()->Effects[EFFECT_0].CalcValue(GetCaster()); return true; } @@ -614,6 +614,59 @@ class spell_pal_hand_of_sacrifice : public SpellScriptLoader } }; +class spell_pal_divine_sacrifice : public SpellScriptLoader +{ + public: + spell_pal_divine_sacrifice() : SpellScriptLoader("spell_pal_divine_sacrifice") { } + + class spell_pal_divine_sacrifice_AuraScript : public AuraScript + { + PrepareAuraScript(spell_pal_divine_sacrifice_AuraScript); + + uint32 splitPct, groupSize, minHpPct; + int32 remainingAmount; + Unit* caster; + + bool Load() + { + caster = GetCaster(); + if (!caster) + return false; + + if (caster->ToPlayer()->GetGroup()) + groupSize = caster->ToPlayer()->GetGroup()->GetMembersCount(); + else + groupSize = 1; + + remainingAmount = (caster->CountPctFromMaxHealth(GetSpellInfo()->Effects[EFFECT_2].CalcValue(caster)) * groupSize); + splitPct = GetSpellInfo()->Effects[EFFECT_0].CalcValue(caster); + minHpPct = GetSpellInfo()->Effects[EFFECT_1].CalcValue(caster); + + return true; + } + + void Split(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & splitAmount) + { + splitAmount = CalculatePctN(dmgInfo.GetDamage(), splitPct); + remainingAmount -= splitAmount; + + // break when absorbed everything it could, or if the casters hp drops below 20% + if (remainingAmount <= 0 || (GetCaster()->GetHealthPct() < minHpPct)) + GetCaster()->RemoveAura(SPELL_DIVINE_SACRIFICE); + } + + void Register() + { + OnEffectSplit += AuraEffectSplitFn(spell_pal_divine_sacrifice_AuraScript::Split, EFFECT_0); + } + }; + + AuraScript* GetAuraScript() const + { + return new spell_pal_divine_sacrifice_AuraScript(); + } +}; + void AddSC_paladin_spell_scripts() { new spell_pal_ardent_defender(); @@ -628,4 +681,5 @@ void AddSC_paladin_spell_scripts() new spell_pal_righteous_defense(); new spell_pal_exorcism_and_holy_wrath_damage(); new spell_pal_hand_of_sacrifice(); + new spell_pal_divine_sacrifice(); } |