Inside global_player.pl
Signals the players pet on level up to re-scale them...
Code:
sub EVENT_LEVEL_UP {
$client->Message(15, "Auto Skill Activating");
foreach my $skill ( 0 .. 42, 48 .. 54, 56, 62, 66, 67, 70 .. 74 ) {
next unless $client->CanHaveSkill($skill);
my $max = $client->MaxSkill( $skill, $client->GetClass(), $client->GetLevel() );
next unless $max > $client->GetRawSkill($skill);
$client->SetSkill( $skill, $max );
}
if($ulevel < 70) {
quest::traindiscs($ulevel);
quest::scribespells($ulevel);
}
my $PETID = $client->GetPetID();
if($PETID > 0) {
my $PET = $entity_list->GetNPCByID($PETID);
$PET->SignalNPC(42);
}
}
global_npc.pl
On spawn of an NPC.. checks if its a pet... and calls ScalePet()
The signal code is here for when a player levels it will receive the signal and re-scale to the players new level.
I can't find my original code that did this for me... but this is a rough idea of what I used to use
Code:
sub EVENT_SPAWN {
#Pet Code only below here
my $ownerid = $npc->GetOwnerID();
if($ownerid <= 0) { return; }
my $owner = $entity_list->GetMobByID($ownerid);
if($owner->IsClient()) {
$npc->SetLevel($owner->GetLevel());
ScalePet($npc, $owner->CastToClient(), $owner->GetCHA());
}
}
sub EVENT_SIGNAL {
if ($signal == 42) {
my $ownerid = $npc->GetOwnerID();
if($ownerid <= 0) { return; }
my $owner = $entity_list->GetMobByID($ownerid);
if($owner->IsClient()) {
$npc->SetLevel($owner->GetLevel());
ScalePet($npc, $owner->CastToClient(), $owner->GetCHA());
}
}
}
sub ScalePet {
my $pet = $_[0];
my $owner = $_[1];
my $cha = $_[2];
#Add more code under here to modify them ect...
$pet->ModifyNPCStat("max_hp", $owner->GetMaxHP() + ($cha * 0.25));
}