Core/Pets: Updated pet summoning for latest client version (5 Call Pet spells and stable size 200)

This commit is contained in:
Shauren
2022-02-02 00:08:37 +01:00
parent d6a2461fc7
commit 950db60435
18 changed files with 395 additions and 458 deletions

View File

@@ -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;