From 950db60435e7e513633ff5b22ad7f0ed8b1147e4 Mon Sep 17 00:00:00 2001 From: Shauren Date: Wed, 2 Feb 2022 00:08:37 +0100 Subject: Core/Pets: Updated pet summoning for latest client version (5 Call Pet spells and stable size 200) --- src/server/scripts/Spells/spell_hunter.cpp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/server/scripts/Spells') diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index ef3197d7119..29cd6f890b8 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -615,6 +615,15 @@ class spell_hun_tame_beast : public SpellScriptLoader { PrepareSpellScript(spell_hun_tame_beast_SpellScript); + static constexpr uint32 CallPetSpellIds[MAX_ACTIVE_PETS] = + { + 883, + 83242, + 83243, + 83244, + 83245, + }; + SpellCastResult CheckCast() { Player* caster = GetCaster()->ToPlayer(); @@ -633,13 +642,25 @@ class spell_hun_tame_beast : public SpellScriptLoader if (!target->GetCreatureTemplate()->IsTameable(caster->CanTameExoticPets())) return SPELL_FAILED_BAD_TARGETS; - PetStable const* petStable = caster->GetPetStable(); - if (petStable) + if (PetStable const* petStable = caster->GetPetStable()) { - if (petStable->CurrentPet) + if (petStable->CurrentPetIndex) return SPELL_FAILED_ALREADY_HAVE_SUMMON; - if (petStable->GetUnslottedHunterPet()) + auto freeSlotItr = std::find_if(petStable->ActivePets.begin(), petStable->ActivePets.end(), [](Optional const& petInfo) + { + return !petInfo.has_value(); + }); + + if (freeSlotItr == petStable->ActivePets.end()) + { + caster->SendTameFailure(PetTameResult::TooMany); + return SPELL_FAILED_DONT_REPORT; + } + + // Check for known Call Pet X spells + std::size_t freeSlotIndex = std::distance(petStable->ActivePets.begin(), freeSlotItr); + if (!caster->HasSpell(CallPetSpellIds[freeSlotIndex])) { caster->SendTameFailure(PetTameResult::TooMany); return SPELL_FAILED_DONT_REPORT; -- cgit v1.2.3