EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Feature Requests (https://www.eqemulator.org/forums/forumdisplay.php?f=612)
-   -   NPC's finding other NPC's $x,$y,$z (https://www.eqemulator.org/forums/showthread.php?t=29850)

nightsta69 10-23-2009 07:56 PM

NPC's finding other NPC's $x,$y,$z
 
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. 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:
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.

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.


All times are GMT -4. The time now is 01:03 PM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.