diff options
Diffstat (limited to 'src/server/scripts/Spells')
| -rw-r--r-- | src/server/scripts/Spells/spell_hunter.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
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<PetStable::PetInfo> 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; |
