mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/BattlePets: Fixes when adding pets (#27076)
* Add pet when learning it for the first time (summon spell not known). * Removed code that adds battle pet if its summon spell is known (Learn cageable pet -> Cage pet -> Log out -> Log in -> Pet is added). * When uncaging check that the species has a summon spell before trying to learn it.
This commit is contained in:
@@ -402,6 +402,7 @@ void BattlePetMgr::AddPet(uint32 species, uint32 display, uint16 breed, BattlePe
|
||||
updates.push_back(std::ref(pet));
|
||||
SendUpdates(std::move(updates), true);
|
||||
|
||||
_owner->GetPlayer()->UpdateCriteria(CriteriaType::UniquePetsOwned);
|
||||
_owner->GetPlayer()->UpdateCriteria(CriteriaType::LearnedNewPet, species);
|
||||
}
|
||||
|
||||
|
||||
@@ -3115,17 +3115,6 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent
|
||||
if (sDB2Manager.GetMount(spellId))
|
||||
GetSession()->GetCollectionMgr()->AddMount(spellId, MOUNT_STATUS_NONE, false, IsInWorld() ? false : true);
|
||||
|
||||
// need to add Battle pets automatically into pet journal
|
||||
for (BattlePetSpeciesEntry const* entry : sBattlePetSpeciesStore)
|
||||
{
|
||||
if (entry->SummonSpellID == int32(spellId) && GetSession()->GetBattlePetMgr()->GetPetCount(entry->ID) == 0)
|
||||
{
|
||||
GetSession()->GetBattlePetMgr()->AddPet(entry->ID, BattlePetMgr::SelectPetDisplay(entry), BattlePetMgr::RollPetBreed(entry->ID), BattlePetMgr::GetDefaultPetQuality(entry->ID));
|
||||
UpdateCriteria(CriteriaType::UniquePetsOwned);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// return true (for send learn packet) only if spell active (in case ranked spells) and not replace old spell
|
||||
return active && !disabled && !superceded_old;
|
||||
}
|
||||
|
||||
@@ -1206,11 +1206,8 @@ void WorldSession::HandleUseCritterItem(WorldPackets::Item::UseCritterItem& useC
|
||||
if (itemEffect->TriggerType != ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
|
||||
continue;
|
||||
|
||||
if (BattlePetSpeciesEntry const* entry = sSpellMgr->GetBattlePetSpecies(uint32(itemEffect->SpellID)))
|
||||
{
|
||||
GetBattlePetMgr()->AddPet(entry->ID, BattlePetMgr::SelectPetDisplay(entry), BattlePetMgr::RollPetBreed(entry->ID), BattlePetMgr::GetDefaultPetQuality(entry->ID));
|
||||
_player->UpdateCriteria(CriteriaType::UniquePetsOwned);
|
||||
}
|
||||
if (BattlePetSpeciesEntry const* speciesEntry = sSpellMgr->GetBattlePetSpecies(uint32(itemEffect->SpellID)))
|
||||
GetBattlePetMgr()->AddPet(speciesEntry->ID, BattlePetMgr::SelectPetDisplay(speciesEntry), BattlePetMgr::RollPetBreed(speciesEntry->ID), BattlePetMgr::GetDefaultPetQuality(speciesEntry->ID));
|
||||
}
|
||||
|
||||
_player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
|
||||
|
||||
@@ -2146,6 +2146,9 @@ void Spell::EffectLearnSpell()
|
||||
continue;
|
||||
|
||||
player->LearnSpell(itemEffect->SpellID, false);
|
||||
|
||||
if (BattlePetSpeciesEntry const* speciesEntry = sSpellMgr->GetBattlePetSpecies(uint32(itemEffect->SpellID)))
|
||||
player->GetSession()->GetBattlePetMgr()->AddPet(speciesEntry->ID, BattlePetMgr::SelectPetDisplay(speciesEntry), BattlePetMgr::RollPetBreed(speciesEntry->ID), BattlePetMgr::GetDefaultPetQuality(speciesEntry->ID));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5713,8 +5716,9 @@ void Spell::EffectUncageBattlePet()
|
||||
|
||||
battlePetMgr->AddPet(speciesId, displayId, breed, BattlePetBreedQuality(quality), level);
|
||||
|
||||
if (!plr->HasSpell(speciesEntry->SummonSpellID))
|
||||
plr->LearnSpell(speciesEntry->SummonSpellID, false);
|
||||
if (speciesEntry->SummonSpellID)
|
||||
if (!plr->HasSpell(speciesEntry->SummonSpellID))
|
||||
plr->LearnSpell(speciesEntry->SummonSpellID, false);
|
||||
|
||||
plr->SendPlaySpellVisual(plr, SPELL_VISUAL_UNCAGE_PET, 0, 0, 0.f, false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user