Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (AndrewAMD, Ayumi, NewbieZorro), 14,141 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Array of entities #252076
02/16/09 10:36
02/16/09 10:36
Joined: Jan 2009
Posts: 57
Slovakia
wolodo87 Offline OP
Junior Member
wolodo87  Offline OP
Junior Member

Joined: Jan 2009
Posts: 57
Slovakia
Hi,
is it possible to create and save entities into an array? I need to create unknown number of entities and name them like name1, name2 etc...for further referencing. I also need to attach to each one an action. (flocking/boid algorithm)

Re: Array of entities [Re: wolodo87] #252078
02/16/09 10:51
02/16/09 10:51
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline
User
delinkx  Offline
User

Joined: Jul 2008
Posts: 553
Singapore
yes its possible.. u working on simulation ?

use something like this:
------------------------------

typedef struct
{
ENTITY* entAgent;
int ID;
var variable1;
var variable2;
var variable3;

} structAgent;

structAgent TestAgent[1000];

.......................................

to access each agent.. u can access TestAgent[0].variable1, etc...


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: Array of entities [Re: wolodo87] #252082
02/16/09 11:07
02/16/09 11:07
Joined: Jan 2009
Posts: 57
Slovakia
wolodo87 Offline OP
Junior Member
wolodo87  Offline OP
Junior Member

Joined: Jan 2009
Posts: 57
Slovakia
Thanks, this looks promising. Yes, I am trying to create bird flock simulation for AI. But how can I use this struct with ent_create function. I need something like: when key pressed, create agent, when another key pressed, delete agent with name abc.

Re: Array of entities [Re: wolodo87] #252085
02/16/09 11:18
02/16/09 11:18
Joined: Feb 2009
Posts: 84
Deutschland/Niedersachsen
GorNaKosh Offline
Junior Member
GorNaKosh  Offline
Junior Member

Joined: Feb 2009
Posts: 84
Deutschland/Niedersachsen
try someting like this way:
Code:
typede struct AGENT {
INT ID;
ENTITY *p_agentEnt;
STRING *agentName;
} AGENT;

AGENT pAgents[999];
var countAgents = 0;

AGENT* agent_create(STRING *name,) {
   if(name == NULL) {return;} //if no name is given return

   countAgents ++;

   AGENT *p_agent = malloc(sizeof(AGENT)); //create a new agent
   p_agent.ID = countAgents; //set agent-ID
   p_agent.p_agentEnt = ent_create("mdlFileName.mdl", vector(0,0,0), actionName); //create entity
   p_agent.agentName = str_create(name); //set agent-name

   return p_agent;
}

void main() {

   level_load("yourLevel.wmb");
   wait(1);
   pAgents[countAgents] = agent_create("max");
   pAgents[countAgents] = agent_create("john");
   pAgents[countAgents] = agent_create("lisa");
   [...]
}


Re: Array of entities [Re: wolodo87] #252151
02/16/09 20:25
02/16/09 20:25
Joined: Jan 2009
Posts: 57
Slovakia
wolodo87 Offline OP
Junior Member
wolodo87  Offline OP
Junior Member

Joined: Jan 2009
Posts: 57
Slovakia
Thanx to both of you. It is exactly what i wanted.

Thank god for this forum...there is always someone who knows the answer on my endless questions... laugh

Last edited by wolodo87; 02/17/09 13:39.

Gamestudio download | 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