From 213aaee42c338abbca975f919db33d1feb8177aa Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Wed, 29 Mar 2023 05:31:36 +0200 Subject: [PATCH] =?UTF-8?q?fix(Scripts/Spells):=20Fixed=20Improved=20Healt?= =?UTF-8?q?hstone=20not=20affecting=20Ritual=20=E2=80=A6=20(#15588)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix(Scripts/Spells): Fixed Improved Healthstone not affecting Ritual of Souls. Fixes #15510 --- src/server/scripts/World/go_scripts.cpp | 112 ++++++++++++++---------- 1 file changed, 66 insertions(+), 46 deletions(-) diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index 0371072b1..ac53001b3 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -1450,39 +1450,6 @@ public: { go_soulwellAI(GameObject* go) : GameObjectAI(go) { - _stoneSpell = 0; - _stoneId = 0; - switch (go->GetEntry()) - { - case GO_SOUL_WELL_R1: - _stoneSpell = SPELL_CREATE_MASTER_HEALTH_STONE_R0; - if (Unit* owner = go->GetOwner()) - { - if (owner->HasAura(SPELL_IMPROVED_HEALTH_STONE_R1)) - _stoneSpell = SPELL_CREATE_MASTER_HEALTH_STONE_R1; - else if (owner->HasAura(SPELL_CREATE_MASTER_HEALTH_STONE_R2)) - _stoneSpell = SPELL_CREATE_MASTER_HEALTH_STONE_R2; - } - break; - case GO_SOUL_WELL_R2: - _stoneSpell = SPELL_CREATE_FEL_HEALTH_STONE_R0; - if (Unit* owner = go->GetOwner()) - { - if (owner->HasAura(SPELL_IMPROVED_HEALTH_STONE_R1)) - _stoneSpell = SPELL_CREATE_FEL_HEALTH_STONE_R1; - else if (owner->HasAura(SPELL_CREATE_MASTER_HEALTH_STONE_R2)) - _stoneSpell = SPELL_CREATE_FEL_HEALTH_STONE_R2; - } - break; - } - if (_stoneSpell == 0) // Should never happen - return; - - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(_stoneSpell); - if (!spellInfo) - return; - - _stoneId = spellInfo->Effects[EFFECT_0].ItemType; } /// Due to the fact that this GameObject triggers CMSG_GAMEOBJECT_USE @@ -1495,40 +1462,93 @@ public: return false; Unit* owner = me->GetOwner(); - if (_stoneSpell == 0 || _stoneId == 0) + if (!owner) + return true; + + uint32 stoneId = 0; + uint32 stoneSpell = 0; + switch (me->GetEntry()) + { + case GO_SOUL_WELL_R1: + stoneSpell = SPELL_CREATE_MASTER_HEALTH_STONE_R0; + if (Unit* owner = me->GetOwner()) + { + if (owner->HasAura(SPELL_IMPROVED_HEALTH_STONE_R1)) + { + stoneSpell = SPELL_CREATE_MASTER_HEALTH_STONE_R1; + } + else if (owner->HasAura(SPELL_CREATE_MASTER_HEALTH_STONE_R2)) + { + stoneSpell = SPELL_CREATE_MASTER_HEALTH_STONE_R2; + } + } + break; + case GO_SOUL_WELL_R2: + stoneSpell = SPELL_CREATE_FEL_HEALTH_STONE_R0; + if (Unit* owner = me->GetOwner()) + { + if (owner->HasAura(SPELL_IMPROVED_HEALTH_STONE_R1)) + { + stoneSpell = SPELL_CREATE_FEL_HEALTH_STONE_R1; + } + else if (owner->HasAura(SPELL_CREATE_MASTER_HEALTH_STONE_R2)) + { + stoneSpell = SPELL_CREATE_FEL_HEALTH_STONE_R2; + } + } + break; + } + + if (!stoneSpell) { - if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(_stoneSpell)) - Spell::SendCastResult(player, spell, 0, SPELL_FAILED_ERROR); return true; } - if (!owner || owner->GetTypeId() != TYPEID_PLAYER || !player->IsInSameRaidWith(owner->ToPlayer())) + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(stoneSpell); + if (!spellInfo) { - if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(_stoneSpell)) + return true; + } + + stoneId = spellInfo->Effects[EFFECT_0].ItemType; + if (!stoneId) + { + if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(stoneSpell)) + { + Spell::SendCastResult(player, spell, 0, SPELL_FAILED_ERROR); + } + return true; + } + + if (owner->GetTypeId() != TYPEID_PLAYER || !player->IsInSameRaidWith(owner->ToPlayer())) + { + if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(stoneSpell)) + { Spell::SendCastResult(player, spell, 0, SPELL_FAILED_TARGET_NOT_IN_RAID); + } return true; } // Don't try to add a stone if we already have one. - if (player->HasItemCount(_stoneId)) + if (player->HasItemCount(stoneId)) { - if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(_stoneSpell)) + if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(stoneSpell)) + { Spell::SendCastResult(player, spell, 0, SPELL_FAILED_TOO_MANY_OF_ITEM); + } return true; } - player->CastSpell(player, _stoneSpell, false); + player->CastSpell(player, stoneSpell, false); // Item has to actually be created to remove a charge on the well. - if (player->HasItemCount(_stoneId)) + if (player->HasItemCount(stoneId)) + { me->AddUse(); + } return true; } - - private: - uint32 _stoneSpell; - uint32 _stoneId; }; GameObjectAI* GetAI(GameObject* go) const override