diff --git a/data/sql/updates/pending_db_world/rev_1769046247414176200.sql b/data/sql/updates/pending_db_world/rev_1769046247414176200.sql new file mode 100644 index 000000000..fd0cd8c6a --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1769046247414176200.sql @@ -0,0 +1,4 @@ +-- +DELETE FROM `spell_script_names` WHERE `spell_id` = 28375; +INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES +(28375, 'spell_gluth_decimate_damage'); diff --git a/src/server/scripts/Northrend/Naxxramas/boss_gluth.cpp b/src/server/scripts/Northrend/Naxxramas/boss_gluth.cpp index 189b24880..7076ab750 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_gluth.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_gluth.cpp @@ -255,7 +255,8 @@ class spell_gluth_decimate : public SpellScript Unit::DealDamage(GetCaster(), cTarget, damage); return; } - GetCaster()->CastCustomSpell(SPELL_DECIMATE_DAMAGE, SPELLVALUE_BASE_POINT0, damage, unitTarget); + + GetCaster()->CastSpell(unitTarget, SPELL_DECIMATE_DAMAGE); } } @@ -265,8 +266,38 @@ class spell_gluth_decimate : public SpellScript } }; +// 28375 - Decimate +class spell_gluth_decimate_damage : public SpellScript +{ + PrepareSpellScript(spell_gluth_decimate_damage) + + void RecalculateDamage() + { + Unit* target = GetHitUnit(); + if (!target) + return; + + int32 targetHealth = int32(target->GetHealth()); + int32 fivePctHealth = int32(target->CountPctFromMaxHealth(5)); + + // Damage needed to leave the target at exactly 5% + int32 damage = targetHealth - fivePctHealth; + + if (damage <= 0) + damage = 0; + + SetHitDamage(damage); + } + + void Register() override + { + OnHit += SpellHitFn(spell_gluth_decimate_damage::RecalculateDamage); + } +}; + void AddSC_boss_gluth() { new boss_gluth(); RegisterSpellScript(spell_gluth_decimate); + RegisterSpellScript(spell_gluth_decimate_damage); }