EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Entity_List->GetMobList() works on existing NPCs, not my custom NPC (https://www.eqemulator.org/forums/showthread.php?t=39791)

redshoes3 06-23-2015 07:03 PM

Entity_List->GetMobList() works on existing NPCs, not my custom NPC
 
I'm making a script that has a custom NPC completing other quests, so I am trying to make a script to find and attack other npcs.

I tested a simple script on my buddy Waradern_Skymoor in qeytoqrg:

Code:

sub killthings {

        my @nlist = $entity_list->GetMobList();
        quest::shout($nlist[0]->GetName());
        my $x = $nlist[0]->GetX();
        my $y = $nlist[0]->GetY();
        my $z = $nlist[0]->GetZ();
        quest::say($x);
        quest::SetRunning(1);
        quest::moveto($x,$y,$z,1.2);
        $nlist[1]->Attack($npc);
       
}

it works, and Waradern runs off towards a gnoll.

However, now that I've put this on my custom NPC, GetMobList() only has my PC character as a member. GetNPCList() is completely empty. If I look for $nlist[1], Perl throws an error for calling GetName() on undefined.

I've checked their database entries, and nothing looks too out of place. I inserted my custom NPC using the EOC platform, and the only difference I can see is that I've made my NPC unique by name. Both are the only members of their spawngroups, both have similar values, etc... I would guess that my NPC is on a different entity list than the rest for some reason.

Any thoughts?

Akkadius 06-23-2015 07:23 PM

Take a look at this extremely valuable/powerful write up:

http://wiki.eqemulator.org/p?Entity_...ow_to_Use_Them

Kingly_Krab 06-23-2015 08:43 PM

A better way of writing it would be this:
Code:

sub killthings {
    my @nlist = $entity_list->GetMobList();
    foreach my $npc (@nlist) {
        if ($npc->GetEnt()->CastToNPC()->GetNPCTypeID() == FIRSTID) {
            quest::SetRunning(1);
            my $at = $entity_list->GetNPCByNPCTypeID(SECONDID);
            quest::moveto($at->GetX(), $at->GetY(), $at->GetZ(), 1.2);
            $npc->GetEnt()->CastToNPC()->Attack($at);
        }
    }
}


redshoes3 06-25-2015 07:25 PM

thanks for responding so fast, guys. I'm clearly behind.

Akkadius, your writeup was very helpful.

Kingly, would you recommend always getting NPC by ID? I implemented it with NPCList so that I wouldn't have to specify other NPC types, and attacking would be determined by a survival function or sanity checks.

NatedogEZ 06-25-2015 07:31 PM

You want 1 mob running around killing multiple mobs?

redshoes3 06-25-2015 09:51 PM

yes.

I want to play around with AI, and I need a fake PC.

NatedogEZ 06-26-2015 12:37 PM

Heres an example of a quest where the mob just runs around killing stuff :p

Code:

sub EVENT_SPAWN {
        quest::settimer("fuck_shit_up", 5);
}

sub EVENT_TIMER {
        if($timer eq "fuck_shit_up" && !$npc->IsEngaged()) {
                KillMode();
        }
}

sub KillMode {
    my @npc_list = $entity_list->GetNPCList();
    foreach $npc_ent (@npc_list) {
                next if $npc_ent->GetID() == $npc->GetID(); #Lets not kill ourself
                next if $npc_ent->GetOwnerID(); #skip pets
                next if ($npc_ent->GetSpecialAbility(19) || $npc_ent->GetSpecialAbility(20) || $npc_ent->GetSpecialAbility(24) || $npc_ent->GetSpecialAbility(35)); #Immune to melee / magic / aggro / noharm SKIP
                next if $npc_ent->GetBodyType() == 11; #Skip untargetable NPCs
                next if $npc_ent->CalculateDistance($x, $y, $z) > 1000; #skip mobs over 1000 Distance
                quest::shout("I am coming for you, " . $npc_ent->GetCleanName() . "!");
                quest::SetRunning(1);
                $npc->AddToHateList($npc_ent, 1); #We now HATE HIM!
                last; #we found a valid target jump out of the loop
    }
}


Shendare 06-26-2015 01:09 PM

That looks like it could be a lot of fun for testing. Especially if you make the aggressor mob NoHarm.

Akkadius 06-26-2015 01:53 PM

I love you Natedog

redshoes3 07-02-2015 01:15 AM

Thanks, Nate. That's a lot cleaner than what I wrote.


All times are GMT -4. The time now is 10:15 PM.

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