PDA

View Full Version : NPC's finding other NPC's $x,$y,$z


nightsta69
10-23-2009, 07:56 PM
i'd like to request somethin to the effect of $npc->$GetNpcX(NPCID); i'm wantin to use it to update npc positions based on the discussion here (http://www.eqemulator.net/forums/showthread.php?t=29844). think it would be a viable addition, and could be used for other purposes as well.

KLS
10-23-2009, 08:28 PM
There are already a couple ways to accomplish this, we don't need another.

nightsta69
10-23-2009, 08:37 PM
could you please explain how? i've been trying everything, and apparently noone else knows of a way to do so, based on the answers provided on the forums, and IRC.

KLS
10-23-2009, 09:10 PM
The first step is to get the npc, the second step is to get the locations.

I can think of two ways to do this, the first with $entity_list and the second with $entity_list and list iteration:

my $x_loc = 0;
my $y_loc = 0;
my $z_loc = 0;
my $target_to_follow = $entity_list->GetMobByNpcTypeID(12345);
if($target_to_follow)
{
$x_loc = $target_to_follow->GetX();
$y_loc = $target_to_follow->GetY();
$z_loc = $target_to_follow->GetZ();
}



my $x_loc = 0;
my $y_loc = 0;
my $z_loc = 0;
my @npclist = $entity_list->GetNPCList();
foreach $ent (@npclist)
{
if($ent->GetNPCTypeID() == 12345)
{
$x_loc = $ent->GetX();
$y_loc = $ent->GetY();
$z_loc = $ent->GetZ();
last;
}
}


I suggest the first one in this case because it's less complicated and a little faster code wise, the second is more for if there's more than one target you want to track easily.

nightsta69
10-23-2009, 09:43 PM
thank you KLS, i've been at this all day, and noone knew this lol. another learning experience.