From 4797ec31942dd821ae21fdc6963c04fca8d74120 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Thu, 16 Apr 2020 16:52:42 +0200 Subject: [PATCH] Scripts/Items: scripted Jar of Ancient Remedies, Scales of Life and Apparatus of Khaz'goroth --- .../world/4.3.4/2020_04_16_00_world.sql | 20 ++ src/server/scripts/Spells/spell_item.cpp | 197 +++++++++++++++++- 2 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 sql/updates/world/4.3.4/2020_04_16_00_world.sql diff --git a/sql/updates/world/4.3.4/2020_04_16_00_world.sql b/sql/updates/world/4.3.4/2020_04_16_00_world.sql new file mode 100644 index 0000000000..5fce8185f1 --- /dev/null +++ b/sql/updates/world/4.3.4/2020_04_16_00_world.sql @@ -0,0 +1,20 @@ +DELETE FROM `spell_proc` WHERE `SpellId` IN (96924, 96879, 97117); +INSERT INTO `spell_proc` (`SpellId`, `ProcFlags`, `SpellTypeMask`, `SpellPhaseMask`, `HitMask`, `AttributesMask`, `ProcsPerMinute`, `Charges`, `Cooldown`) VALUES +(96924, 0, 1, 2, 0x2, 0, 0, 0, 0), +(96879, 0, 2, 0, 0x0, 0, 0, 0, 0), +(97117, 0, 2, 0, 0x0, 0, 0, 0, 0); + +DELETE FROM `spell_script_names` WHERE `ScriptName` IN +('spell_item_blessing_of_khazgoroth', +'spell_item_weight_of_a_feather', +'spell_item_tipping_of_the_scales', +'spell_item_blind_spot'); + +INSERT INTO `spell_script_names` (`spell_Id`, `ScriptName`) VALUES +(96934, 'spell_item_blessing_of_khazgoroth'), +(97127, 'spell_item_blessing_of_khazgoroth'), +(96879, 'spell_item_weight_of_a_feather'), +(97117, 'spell_item_weight_of_a_feather'), +(96880, 'spell_item_tipping_of_the_scales'), +(91322, 'spell_item_blind_spot'), +(92331, 'spell_item_blind_spot'); diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 51d0c42356..2d4b194656 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -4892,6 +4892,198 @@ private: uint32 _auraId; }; +enum ApparatusOfKhazgoroth +{ + SPELL_TITANIC_POWER = 96923, + SPELL_BLESSING_OF_THE_SHAPER_HASTE = 96927, + SPELL_BLESSING_OF_THE_SHAPER_CRIT = 96928, + SPELL_BLESSING_OF_THE_SHAPER_MASTERY = 96929 +}; + +// 96934 - Blessing of Khaz'goroth +// 97127 - Blessing of Khaz'goroth +class spell_item_blessing_of_khazgoroth : public SpellScript +{ + PrepareSpellScript(spell_item_blessing_of_khazgoroth); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo( + { + SPELL_TITANIC_POWER, + SPELL_BLESSING_OF_THE_SHAPER_HASTE, + SPELL_BLESSING_OF_THE_SHAPER_CRIT, + SPELL_BLESSING_OF_THE_SHAPER_MASTERY + }); + } + + void HandleDummyEffect(SpellEffIndex /*effIndex*/) + { + Player* player = GetHitPlayer(); + if (!player) + return; + + uint8 stacks = 0; + Aura* aura = player->GetAura(SPELL_TITANIC_POWER, player->GetGUID()); + if (!aura) + return; + + stacks = aura->GetStackAmount(); + + int32 basePoints = GetEffectValue() * stacks; + if (!basePoints) + return; + + uint32 spellId = 0; + float haste = player->GetRatingBonusValue(CR_HASTE_MELEE); + float crit = player->GetRatingBonusValue(CR_CRIT_MELEE); + float mastery = player->GetRatingBonusValue(CR_MASTERY); + + if (haste >= crit && haste >= mastery) + spellId = SPELL_BLESSING_OF_THE_SHAPER_HASTE; + else if (crit >= haste && crit >= mastery) + spellId = SPELL_BLESSING_OF_THE_SHAPER_CRIT; + else if (mastery >= haste && mastery >= crit) + spellId = SPELL_BLESSING_OF_THE_SHAPER_MASTERY; + + if (spellId && basePoints) + { + player->CastCustomSpell(spellId, SPELLVALUE_BASE_POINT0, basePoints, player, true); + aura->Remove(); + } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_item_blessing_of_khazgoroth::HandleDummyEffect, EFFECT_0, SPELL_EFFECT_DUMMY); + } +}; + +enum ScalesOfLife +{ + SPELL_WEIGHT_OF_A_FEATHER = 96881 +}; + +// 96879 - Weight of a Feather +// 97117 - Weight of a Feather +class spell_item_weight_of_a_feather : public AuraScript +{ + PrepareAuraScript(spell_item_weight_of_a_feather); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_WEIGHT_OF_A_FEATHER }); + } + + bool CheckProc(ProcEventInfo& eventInfo) + { + HealInfo* heal = eventInfo.GetHealInfo(); + return heal && heal->GetHeal() > heal->GetEffectiveHeal(); + } + + void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + + Unit* target = GetTarget(); + int32 heal = eventInfo.GetHealInfo()->GetHeal() - eventInfo.GetHealInfo()->GetEffectiveHeal(); + + // Store overheal + int32 basePoints = heal; + if (AuraEffect const* effect = target->GetAuraEffect(SPELL_WEIGHT_OF_A_FEATHER, EFFECT_0, target->GetGUID())) + basePoints += effect->GetAmount(); + + basePoints = std::min(basePoints, aurEff->GetAmount()); + target->CastCustomSpell(SPELL_WEIGHT_OF_A_FEATHER, SPELLVALUE_BASE_POINT0, basePoints, target, true, nullptr, aurEff); + } + + void Register() override + { + DoCheckProc += AuraCheckProcFn(spell_item_weight_of_a_feather::CheckProc); + OnEffectProc += AuraEffectProcFn(spell_item_weight_of_a_feather::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); + } +}; + +// 96880 - Tipping of the Scales +class spell_item_tipping_of_the_scales : public SpellScript +{ + PrepareSpellScript(spell_item_tipping_of_the_scales); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo({ SPELL_WEIGHT_OF_A_FEATHER }); + } + + SpellCastResult CheckCast() + { + if (AuraEffect const* effect = GetCaster()->GetAuraEffect(SPELL_WEIGHT_OF_A_FEATHER, EFFECT_0, GetCaster()->GetGUID())) + return SPELL_CAST_OK; + + return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; + } + + void HandleHealValue(SpellEffIndex /*effIndex*/) + { + if (AuraEffect const* effect = GetCaster()->GetAuraEffect(SPELL_WEIGHT_OF_A_FEATHER, EFFECT_0, GetCaster()->GetGUID())) + { + SetEffectValue(effect->GetAmount()); + effect->GetBase()->Remove(); + } + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(spell_item_tipping_of_the_scales::CheckCast); + OnEffectLaunchTarget += SpellEffectFn(spell_item_tipping_of_the_scales::HandleHealValue, EFFECT_0, SPELL_EFFECT_HEAL); + } +}; + +enum JarOfAncientRemedies +{ + SPELL_INNER_EYE_N = 91320, + SPELL_INNER_EYE_HC = 92329, + SPELL_ITEM_PROC_STACKING_SPIRIT_N = 91321, + SPELL_ITEM_PROC_STACKING_SPIRIT_HC = 92330 + +}; + +// 91322 Blind Spot +// 92331 Blind Spot +class spell_item_blind_spot : public SpellScript +{ + PrepareSpellScript(spell_item_blind_spot); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo( + { + SPELL_INNER_EYE_N, + SPELL_INNER_EYE_HC, + SPELL_ITEM_PROC_STACKING_SPIRIT_N, + SPELL_ITEM_PROC_STACKING_SPIRIT_HC + }); + } + + void HandleHitEffect(SpellEffIndex /*effIndex*/) + { + Unit* target = GetHitUnit(); + target->RemoveAurasDueToSpell(SPELL_INNER_EYE_N, target->GetGUID()); + target->RemoveAurasDueToSpell(SPELL_INNER_EYE_HC, target->GetGUID()); + + uint32 spellId = target->HasAura(SPELL_ITEM_PROC_STACKING_SPIRIT_N, target->GetGUID()) ? SPELL_ITEM_PROC_STACKING_SPIRIT_N : SPELL_ITEM_PROC_STACKING_SPIRIT_HC; + if (AuraEffect const* effect = target->GetAuraEffect(spellId, EFFECT_0, target->GetGUID())) + { + std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now(); + effect->GetBase()->AddProcCooldown(now + 30s); + } + } + + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_item_blind_spot::HandleHitEffect, EFFECT_0, SPELL_EFFECT_ENERGIZE); + } +}; + void AddSC_item_spell_scripts() { // 23074 Arcanite Dragonling @@ -5016,5 +5208,8 @@ void AddSC_item_spell_scripts() RegisterAuraScript(spell_item_crescendo_of_suffering); new spell_item_consume_charges("spell_item_forged_fury", SPELL_RAW_FURY); RegisterSpellAndAuraScriptPair(spell_item_hearts_judgement, spell_item_hearts_judgement_AuraScript); - + RegisterSpellScript(spell_item_blessing_of_khazgoroth); + RegisterAuraScript(spell_item_weight_of_a_feather); + RegisterSpellScript(spell_item_tipping_of_the_scales); + RegisterSpellScript(spell_item_blind_spot); }