removing entities

Posted By: ery

removing entities - 01/13/11 17:52

I want to know how to remove already collected subjects from the level at its repeated visiting, not using game_save.
Tried to use level_mark()/level_free(), but they give me only errors.
Please add any code if you can.
Posted By: Logan

Re: removing entities - 01/14/11 18:30

It's possible with a couple solutions. My first question is, how are these subjects being "collected"? You could keep an internal list of everything that has already been collected, and then upon loading the level, each entity checks if it is on that list, and if so, it removes itself.
Posted By: ery

Re: removing entities - 01/14/11 19:29

You mean to use vars? It's not the way, because there are a lot of subjects of the same type (like lives) and it'll be very hard to have so many variables to put them into the list. I use event_impact and one action for them all.
Posted By: wdlmaster

Re: removing entities - 01/14/11 21:35

you just need one (1) array for every item type.
Code:
char coins[1000];
char lives[40];
char OtherCoolItemHere[7];
...


But every item must hold a unique identifier - use a skill for that. When an item is collected the first time, it simply sets the corresponding variable (in the array) to 1.
Code:
if (vec_dist(my.x,player.x) < 32) {coins[my.skill8] = 1;ent_remove (me);}


When the level is loaded, the item checks everytime, if the variable is 1 or 0.
Code:
void coin() {
   if coins[my.skill8] ent_remove (me);
   ...
   ... }


Again: You must make sure, that every item has a unique ID.
Posted By: ery

Re: removing entities - 01/15/11 17:06

Void gives me errors. Probably it's used in Lite-C, but I work in C-Script. Must I use only void()?
Posted By: Superku

Re: removing entities - 01/15/11 17:34

For C-Script, replace
void coin() {
with
function coin() {
Posted By: ery

Re: removing entities - 01/15/11 18:31

Thanks you, guys!!
© 2024 lite-C Forums