diff --git a/sql/updates/world/custom/custom_2019_11_15_00_world.sql b/sql/updates/world/custom/custom_2019_11_15_00_world.sql new file mode 100644 index 00000000000..9552b8d0eb2 --- /dev/null +++ b/sql/updates/world/custom/custom_2019_11_15_00_world.sql @@ -0,0 +1 @@ +UPDATE `spell_script_names` SET `ScriptName`= 'spell_item_hearts_judgement' WHERE `ScriptName`= 'spell_item_hearts_judgement_heroic'; diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 41f8f8dd7f7..8fb5a9d6fe8 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -4764,8 +4764,6 @@ class spell_item_crescendo_of_suffering : public AuraScript enum ConsumeCharges { - SPELL_HEARTS_REVELATION = 91027, - SPELL_HEARTS_REVELATION_HEROIC = 92325, SPELL_RAW_FURY = 91832 }; @@ -4819,6 +4817,81 @@ class spell_item_consume_charges : public SpellScriptLoader uint32 _spellId; }; +enum HeartsJudgement +{ + SPELL_HEARTS_JUDGEMENT_HEROIC = 92328, + SPELL_HEARTS_REVELATION = 91027, + SPELL_HEARTS_REVELATION_HEROIC = 92325 +}; + +class spell_item_hearts_judgement : public SpellScript +{ + PrepareSpellScript(spell_item_hearts_judgement); + + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo( + { + SPELL_HEARTS_JUDGEMENT_HEROIC, + SPELL_HEARTS_REVELATION, + SPELL_HEARTS_REVELATION_HEROIC + }); + } + + bool Load() override + { + _auraId = GetSpellInfo()->Id == SPELL_HEARTS_JUDGEMENT_HEROIC ? SPELL_HEARTS_REVELATION_HEROIC : SPELL_HEARTS_REVELATION; + return true; + } + + SpellCastResult CheckCast() + { + if (Aura* aura = GetCaster()->GetAura(_auraId, GetCaster()->GetGUID())) + if (aura->GetStackAmount()) + return SPELL_CAST_OK; + + return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; + } + + void Register() override + { + OnCheckCast += SpellCheckCastFn(spell_item_hearts_judgement::CheckCast); + } +private: + uint32 _auraId = 0; +}; + +class spell_item_hearts_judgement_AuraScript : public AuraScript +{ + PrepareAuraScript(spell_item_hearts_judgement_AuraScript); + + bool Load() override + { + _auraId = GetSpellInfo()->Id == SPELL_HEARTS_JUDGEMENT_HEROIC ? SPELL_HEARTS_REVELATION_HEROIC : SPELL_HEARTS_REVELATION; + return true; + } + + void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) + { + Unit* target = GetUnitOwner(); + uint8 stacks = 0; + if (Aura* revelation = target->GetAura(_auraId, target->GetGUID())) + { + stacks = revelation->GetStackAmount(); + revelation->Remove(); + } + + amount *= stacks; + } + + void Register() override + { + DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_item_hearts_judgement_AuraScript::CalculateAmount, EFFECT_0, SPELL_AURA_MOD_RATING); + } +private: + uint32 _auraId; +}; + void AddSC_item_spell_scripts() { // 23074 Arcanite Dragonling @@ -4941,7 +5014,7 @@ void AddSC_item_spell_scripts() RegisterAuraScript(spell_item_egg_shell); RegisterAuraScript(spell_item_song_of_sorrow); RegisterAuraScript(spell_item_crescendo_of_suffering); - new spell_item_consume_charges("spell_item_hearts_judgement", SPELL_HEARTS_REVELATION); - new spell_item_consume_charges("spell_item_hearts_judgement_heroic", SPELL_HEARTS_REVELATION_HEROIC); new spell_item_consume_charges("spell_item_forged_fury", SPELL_RAW_FURY); + RegisterSpellAndAuraScriptPair(spell_item_hearts_judgement, spell_item_hearts_judgement_AuraScript); + }