Best Way to Count Total Number of Entities

Posted By: 82RJZAE

Best Way to Count Total Number of Entities - 05/01/13 00:17

Hi, what is the best way to count the total number of the same entity present in a map?

I would like to count the number of my spawn entities (for clarity, they are named "spawn_cube.mdl") in my map, store pointers to the entities, and use the pointers so that I can randomly select a spawn location for my player.
Posted By: Superku

Re: Best Way to Count Total Number of Entities - 05/01/13 00:22

The easiest way would be something as follows:

#define _type skill100
#define type_misc 0
#define type_enemy 1
#define type_spawn 2

action act_spawn()
{
my._type = type_spawn;
}

...
for(you = NULL; you = ent_next(you); you)
{
if(your._type == type_spawn) ...
}

Alternatively, you can use the str_for_ent commands or how they are called to compare the file, and/ or run this loop once on level initialization and store them in an array/ a list.
Posted By: djfeeler

Re: Best Way to Count Total Number of Entities - 05/01/13 04:14

Hello,

To calculate the number of entities in the level there is the word ent. Just include default.c in your project and when you are in your level made F11. Next to ent to find the number of your entity level. In the Manual Engine -> Hot Keys.


Djfeeler
© 2024 lite-C Forums