View Single Post
  #4  
Old 10-23-2009, 09:10 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

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:
Code:
    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();
    }
Code:
    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.
Reply With Quote