EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   count of mobs by npc_id or clean name (https://www.eqemulator.org/forums/showthread.php?t=33838)

sorvani 07-09-2011 11:14 PM

count of mobs by npc_id or clean name
 
How can I get a count of the mobs in a zone by their NPC_id or their CleanName

have a quest that I need to reduce boss HP based on # of mobs of a certain name.

I would prefer not to have to make 9 different NPC's when i only need 1

lerxst2112 07-09-2011 11:22 PM

You can probably walk the NPC list and count them. http://www.eqemulator.net/wiki/wikka...ListIterations

sorvani 07-09-2011 11:38 PM

was trying to avoid that because this needs to be checked repeatedly.

let me restate, is there any current function that will let me get a count of mobs or even a list by npc_id or CleanName. because if you dump something into an array and then dump the array into a scalar you get the count of the array.
This example for clients will get all clients in zone and $size will have the count.
Code:

  @list = $entity_list->GetClientList();
  $size = @list;

Just felt I shouldn't have to walk the entire mob list in perl to count my mobs.

Tabasco 07-10-2011 09:35 AM

The current functions for getting npc's by type id return the first matching npc. One would need to write a similar function to the existing ones except instead of returning on the first result, you would populate a container and return it at the end. From there you would adapt the perl interface to return a perl array. Either way, you're iterating that list, it's just faster using C++ and STL containers.

Another option would be to set up spawn and death events for the applicable NPC type where they signal a quest manager NPC, or the boss directly.
If the number of target mobs to start is static, you could easily just reduce boss hp by a fixed amount per signal, otherwise you would want to use the management NPC so they could increment the current count with a spawn signal and decrement with a death signal.

sorvani 07-10-2011 01:40 PM

Signals suck. The reason this came up was because the event was originally using signals, and a player got stuck with all 9 mobs down but the bosses unchanged.

The event in question is the ikkinz group 2 trial. If you look at the current quest SVN you can see how it was waiting for counter == 18 that was incrementing on a signal from the Constained Servitors. Yeah it seemed to work most of the time, but it failed once. I added the GM to instance and checked on the player. yup all down, but the Malevolent Priests were not switched. Obviously a failed signal.

I've rewrote the event and it works fine getting this counter would only make it cosmetically look better, when the serivtors are killed to reduce HP by 10% each. There are 5 constrained servitors npc id's. 1 is spawned 4 times, 1 is spawned twice and the other three are all up once for a total of nine. The way i redid it if 294086 is found i add 4 so it will suddenly drop the boss by 40% once the last one goes down. since the boss is not attackable at that point anyway it is only cosmetic.

lerxst2112 07-10-2011 03:49 PM

If you don't want to walk the list or write C++ code to walk the list and return a count then signals with a backup check for existence using $entity_list->GetMobByNpcTypeID(...) would probably work ok.

Tabasco 07-10-2011 11:23 PM

That's actually a pretty simple and elegant fix.

Looking at the source, NPC AI is processed every 10ms and only a single signal can be handled per process, so two kills inside of that 10ms window (10 ms in the high end, could be 0-10 really) would trample each other. It would be a very rare case, but it could happen.

trevius 07-11-2011 12:23 AM

I would definitely recommend just iterating the list to do a count as needed. Even if that means 1 time per second, it isn't all that heavy on resources. If you can just start a timer with the start of the event, then iterating just while the event is going on is definitely fine IMO.


All times are GMT -4. The time now is 08:27 AM.

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