aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Spells
diff options
context:
space:
mode:
authorFrca <killerfrca@gmail.com>2012-04-22 19:19:32 +0200
committerFrca <killerfrca@gmail.com>2012-04-22 19:19:32 +0200
commitc7a70803b41bc9ce162a6aa1aa8cd0926353f9e3 (patch)
tree584f0d6f8f33fd97ad52b7094dfeada744515230 /src/server/scripts/Spells
parent284894b20b40af00951bdc25dd66dc759bc1d273 (diff)
parent57e937e171e632e37b4ee28da0cd4ed65ec733b7 (diff)
Merge branch 'master' of git://github.com/TrinityCore/TrinityCore
Diffstat (limited to 'src/server/scripts/Spells')
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp
index 035f9ec98b2..2d431331691 100644
--- a/src/server/scripts/Spells/spell_generic.cpp
+++ b/src/server/scripts/Spells/spell_generic.cpp
@@ -2618,6 +2618,44 @@ class spell_gen_wg_water : public SpellScriptLoader
}
};
+class spell_gen_count_pct_from_max_hp : public SpellScriptLoader
+{
+ public:
+ spell_gen_count_pct_from_max_hp(char const* name, int32 damagePct = 0) : SpellScriptLoader(name), _damagePct(damagePct) { }
+
+ class spell_gen_count_pct_from_max_hp_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_gen_count_pct_from_max_hp_SpellScript)
+
+ public:
+ spell_gen_count_pct_from_max_hp_SpellScript(int32 damagePct) : SpellScript(), _damagePct(damagePct) { }
+
+ void RecalculateDamage()
+ {
+ if (!_damagePct)
+ _damagePct = GetHitDamage();
+
+ SetHitDamage(GetHitUnit()->CountPctFromMaxHealth(_damagePct));
+ }
+
+ void Register()
+ {
+ OnHit += SpellHitFn(spell_gen_count_pct_from_max_hp_SpellScript::RecalculateDamage);
+ }
+
+ private:
+ int32 _damagePct;
+ };
+
+ SpellScript* GetSpellScript() const
+ {
+ return new spell_gen_count_pct_from_max_hp_SpellScript(_damagePct);
+ }
+
+ private:
+ int32 _damagePct;
+};
+
void AddSC_generic_spell_scripts()
{
new spell_gen_absorb0_hitlimit1();
@@ -2669,4 +2707,6 @@ void AddSC_generic_spell_scripts()
new spell_gen_chaos_blast();
new spell_gen_ds_flush_knockback();
new spell_gen_wg_water();
+ new spell_gen_count_pct_from_max_hp("spell_gen_default_count_pct_from_max_hp");
+ new spell_gen_count_pct_from_max_hp("spell_gen_50pct_count_pct_from_max_hp", 50);
}