PDA

View Full Version : npc persistent pets


nilbog
08-25-2009, 02:21 PM
Per request of So_1337, here's the code necessary to make npc pets remain and fight after their master is slain.

This change brought to you by Ladoth, bringer of classic code. He is the lead source developer for project1999, and without him, we wouldn't have lots of cool stuff.

in zone/mob.cpp, change this

line 1420

void Mob::SetOwnerID(int16 NewOwnerID) {
if (NewOwnerID == GetID() && NewOwnerID != 0) // ok, no charming yourself now =p
return;
ownerid = NewOwnerID;
if (ownerid == 0 && this->IsNPC() && this->GetPetType() != petCharmed)
this->Depop();
}

to this

void Mob::SetOwnerID(int16 NewOwnerID) {
if (NewOwnerID == GetID() && NewOwnerID != 0) // ok, no charming yourself now =p
return;

// @LADOTH 07182009 don't depop a pet for NPC owners
Mob* oldowner = entity_list.GetMob(ownerid);

ownerid = NewOwnerID;
if (ownerid == 0 && this->IsNPC() && this->GetPetType() != petCharmed && oldowner && oldowner->IsClient())
this->Depop();
}

Dibalamin
08-25-2009, 09:32 PM
You may experience a slight bug in this. Sometimes for NPC's if you feign off the pet aggro they'll return to the point where they were summoned and go indifferent. Not sure if the fix for this was put into the code yet or not as I know zip all about source code.