Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Quad), 551 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Best Way to Count Total Number of Entities #422048
05/01/13 00:17
05/01/13 00:17
Joined: Jul 2008
Posts: 168
8
82RJZAE Offline OP
Member
82RJZAE  Offline OP
Member
8

Joined: Jul 2008
Posts: 168
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.

Re: Best Way to Count Total Number of Entities [Re: 82RJZAE] #422049
05/01/13 00:22
05/01/13 00:22
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
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.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Best Way to Count Total Number of Entities [Re: Superku] #422058
05/01/13 04:14
05/01/13 04:14
Joined: May 2008
Posts: 257
D
djfeeler Offline
Member
djfeeler  Offline
Member
D

Joined: May 2008
Posts: 257
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

Last edited by djfeeler; 05/01/13 04:18.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1