I'm being lazy with this by pasting a few year old example from one of my archives:
Reference the
yellow text below pertaining to grabbing an entity based on it's NPC Type ID. You could do this from NPC B and check the distance between it and NPC A inside of a timer loop. Right now it is checking for x and y being within 50 units of each other, you can manipulate this example to your liking.
You may have to do this a bit different if you have several NPC's in the zone with the same type ID, you would have to iterate through an array to do the checking, I don't know your exact scenario.
Code:
sub EVENT_SAY{
if($text=~/hail/i){
plugin::UpdateTaskActivity("group", 157, 6, 1);
my $Akkazia = $entity_list->GetNPCByNPCTypeID(3034686);
my $AkkaziaX = $Akkazia->GetX();
my $AkkaziaY = $Akkazia->GetY();
my $AkkaziaZ = $Akkazia->GetZ();
my $myX = $npc->GetX();
my $myY = $npc->GetY();
my $myZ = $npc->GetZ();
if (abs($AkkaziaX - $myX) < 50 && abs($AkkaziaY - $myY) < 50 && !$Found) {
plugin::ClientSay("You found my darling Akkazia! Thank you $name, you have made me so happy!");
plugin::UpdateTaskActivity("group", 157, 7, 1);
plugin::DoAnim("plead");
quest::signalwith(3034686, 1);
$Found = 1;
}
elsif($Found == 1){
plugin::ClientSay("You found my darling Akkazia! Thank you $name, you have made me so happy!");
plugin::DoAnim("plead");
}
else{
plugin::ClientSay("Please find my baby! I haven't been able to find her!");
plugin::DoAnim("plead");
}
}
}