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 04-27-2014, 03:20 PM
Hateborne
Hill Giant
 
Join Date: May 2010
Posts: 125
Question Get All NPCs by NPCTypeID

Hilariously stupid quest, maybe I'm just hungry.

Is there any easy way to pull all the NPCs by npc_type id?

I thought the below bit would work, but it seems to only pull one. I have 11 of npc_type id 12345 in the zone, but it seems to only select one of them.
Code:
my @creatures = $entity_list->GetNPCByNPCTypeID(12345);
I am using this in the default.pl for the zone and I'm trying to select three of them to start on a grid.

Pre-emptive thank you!
-Hate
Reply With Quote
  #2  
Old 04-27-2014, 03:55 PM
sorvani
Dragon
 
Join Date: May 2010
Posts: 966
Default

It is returning once it finds the first one. So it is working as intended.


entity.cpp line 856
Code:
NPC *EntityList::GetNPCByNPCTypeID(uint32 npc_id)
{
	if (npc_id == 0 || npc_list.empty())
		return nullptr;

	auto it = npc_list.begin();
	while (it != npc_list.end()) {
		if (it->second->GetNPCTypeID() == npc_id)
			return it->second;
		++it;
	}

	return nullptr;
}
Reply With Quote
  #3  
Old 04-27-2014, 03:57 PM
sorvani
Dragon
 
Join Date: May 2010
Posts: 966
Default

As much as I hate signals, that is the only thing that would work here

Code:
quest::signal(npc_id, wait=0 ) # cause an EVENT_SIGNAL on all mobs in the zone with this NPC type, with $signalid = 0. wait is an optional time to wait in ms before sending signal.
quest::signalwith(npc_id,signal_id, wait=0) # same as signal(), except it sets $signal to the supplied signal_id. wait is an optional time to wait in ms before sending signal.
Reply With Quote
  #4  
Old 04-27-2014, 04:42 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Can do it via signals or very simply:

Code:
my @nlist $entity_list->GetNPCList();
foreach my $n (@nlist){
	if($n->GetNPCTypeID() == ID){
		DoStuff();
	}
}
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 06:43 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