very basic question about ent_create and funcitons

Posted By: Ditje

very basic question about ent_create and funcitons - 08/06/10 15:40

I am rewriting some functions, to have a cleaner code and a faster game. I`ve got adviced, to preload my entities and instead of ent_remove, I should just hide the entities. Ok - enties got loaded and here are my first problems laugh

Code:
var epos[40][3];
var enemy[80];
...
	// Positionen Welle 3
	epos[16][0] = -165;   epos[16][1] = 800;  epos[16][2] = 270;
...
// Welle 3
	for(i=16; i<24; i++)
	{
		enemy[i] = ent_create("bee2.mdl", vector(epos[i][0], -epos[i][1], epos[i][2]), enemy_attack); 
	}
...



1.) I can`t call ENTITY like enemy[16].y=800; - error
2.) Instead of "enemy_attack" I want to create ENTITY without a function(NULL), because I don`t want the engine run through functions, if it`s not nessesary. But how can I point to my entities?

I need something with "me" laugh

THX

Ditje
Posted By: FlorianP

Re: very basic question about ent_create and funcitons - 08/06/10 16:00

This would be the correct syntax.
Code:
ENTITY* enemy[80];



Anyway, not removing the entities is inadvisable in most cases.
Either they are just not visible or they can be removed. Just hiding them would be only in very special cases more efficent as its renders the Objectoriented-Programming model useless.

Use ent_preload() to store the models in memory. Any other approach would most likely cause more cpu-time and way more hustle.
Posted By: Ditje

Re: very basic question about ent_create and funcitons - 08/06/10 16:26

Ah yes I forgot the ENITY*

Hmm and now I am not sure any more laugh There will be several different bonus stages later. If I hide them (behind the player) there will be about 200 unused entities. That`s why I don`t wanted to call them with a function.

I thought only the .mdl file gets loaded. That happens already in the startscreen.

Ditje
© 2024 lite-C Forums