PDA

View Full Version : Checking pet owners in script files


Cottus
10-10-2010, 11:34 PM
I have a quest file which basically has the following:


sub EVENT_ATTACK {
quest::shout("$name is attacking me (level $ulevel)");
}

sub EVENT_AGGRO {
quest::shout("$name has aggroed me (level $ulevel)");
}


This NPC casts an aoe. Now I have my warrior and a mage with a pet, lets call him Larer.

When my warrior attacks I get

"Cottus has aggroed me (level 60)"
"Cottus is attacking me (level 60)"

Then the aoe goes off and I get:
"Larer000 is attacking me (level 49)".

The aggro event never fires for the mage, even though the mage makes it onto the hatelist. And the attack event only fires for the pet, which makes sense.

Is there any way in the perl script to check if the "client" is a pet in the attack portion and get its owner? Calling $mob->GetOwnerID() doesnt seem to work, nor does $mob->GetOwnerOrSelf().

Secrets
10-11-2010, 01:06 AM
Is there any way in the perl script to check if the "client" is a pet in the attack portion and get its owner? Calling $mob->GetOwnerID() doesnt seem to work, nor does $mob->GetOwnerOrSelf().


Something like this should work:



sub EVENT_ATTACK {

f( $mob->IsPet() && $mob->IsNPC() )
{
$mob = $mob->GetOwner();
}

quest::shout("$mob->GetCleanName() is attacking me (level $mob->GetLevel())");
}

sub EVENT_AGGRO {

f( $mob->IsPet() && $mob->IsNPC() )
{
$mob = $mob->GetOwner();
}

quest::shout("$mob->GetCleanName() has aggroed me (level $mob->GetLevel())");
}



You can even call other functions, because you now have a pointer to that client object. So if you want to do other things based on that client who aggroed, you can by using $mob->CastToClient()

Cottus
10-13-2010, 12:40 AM
Thanks much for the suggestions, Secrets.

The script still isnt working, so I need to dig into what version of eqemu I'm working with. I am nearly 100% its an issue with the $mob variable or some of its methods not being properly exposed to perl.