diff options
| author | Shauren <shauren.trinity@gmail.com> | 2022-02-02 00:08:37 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-02-02 00:08:37 +0100 |
| commit | 950db60435e7e513633ff5b22ad7f0ed8b1147e4 (patch) | |
| tree | cb5b9e47570528dea0374f804f829512c89a5410 /src/server/scripts/Spells | |
| parent | d6a2461fc77f156dfe9e62c1c2387815c27e43de (diff) | |
Core/Pets: Updated pet summoning for latest client version (5 Call Pet spells and stable size 200)
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; |
