Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 06-23-2015, 07:03 PM
redshoes3
Fire Beetle
 
Join Date: Oct 2014
Posts: 4
Default 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?
Reply With Quote
  #2  
Old 06-23-2015, 07:23 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

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

http://wiki.eqemulator.org/p?Entity_...ow_to_Use_Them
Reply With Quote
  #3  
Old 06-23-2015, 08:43 PM
Kingly_Krab
Administrator
 
Join Date: May 2013
Location: United States
Posts: 1,594
Default

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);
        }
    }
}

Last edited by Kingly_Krab; 06-23-2015 at 08:51 PM..
Reply With Quote
  #4  
Old 06-25-2015, 07:25 PM
redshoes3
Fire Beetle
 
Join Date: Oct 2014
Posts: 4
Default

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.
Reply With Quote
  #5  
Old 06-25-2015, 07:31 PM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

You want 1 mob running around killing multiple mobs?
Reply With Quote
  #6  
Old 06-25-2015, 09:51 PM
redshoes3
Fire Beetle
 
Join Date: Oct 2014
Posts: 4
Default

yes.

I want to play around with AI, and I need a fake PC.
Reply With Quote
  #7  
Old 06-26-2015, 12:37 PM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

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
    }
}
Reply With Quote
  #8  
Old 06-26-2015, 01:09 PM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

That looks like it could be a lot of fun for testing. Especially if you make the aggressor mob NoHarm.
Reply With Quote
  #9  
Old 06-26-2015, 01:53 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

I love you Natedog
Reply With Quote
  #10  
Old 07-02-2015, 01:15 AM
redshoes3
Fire Beetle
 
Join Date: Oct 2014
Posts: 4
Default

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


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

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


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3