SetPetID after we assign the new NPC an ID (#1851)

This commit is contained in:
Natedog2012 2021-11-28 15:42:42 -06:00 committed by GitHub
parent 7cac2e2bc3
commit f70b4a79b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -689,6 +689,14 @@ void EntityList::AddNPC(NPC *npc, bool SendSpawnPacket, bool dontqueue)
{ {
npc->SetID(GetFreeID()); npc->SetID(GetFreeID());
//If this is not set here we will despawn pets from new AC changes
auto owner_id = npc->GetOwnerID();
if(owner_id) {
auto owner = entity_list.GetMob(owner_id);
if (owner) {
owner->SetPetID(npc->GetID());
}
}
parse->EventNPC(EVENT_SPAWN, npc, nullptr, "", 0); parse->EventNPC(EVENT_SPAWN, npc, nullptr, "", 0);
uint16 emoteid = npc->GetEmoteID(); uint16 emoteid = npc->GetEmoteID();