Function called by Entity is terminated after Entity is removed?

Posted By: garv3

Function called by Entity is terminated after Entity is removed? - 04/03/09 22:40

Hi all!

I am calling a function from within an entity's action.
In this function is a while loop that seems to be terminated, when the entity is being removed. Is this standard and if - how can I work around this problem?

Thx in advance!
derGarv
Posted By: Ottawa

Re: Function called by Entity is terminated after Entity is removed? - 04/03/09 22:50

Hi!

Can you make your entity invisible for the duration of the action.
and
Keep the entity until all of the action is done

then
you can remove it.

Ottawa smile
Posted By: GamerX

Re: Function called by Entity is terminated after Entity is removed? - 04/03/09 23:17

Yea it is standard when the entity is removed he is removed from his action. why not just call that function once from the action and put all the statements in the function in a while loop?
Posted By: garv3

Re: Function called by Entity is terminated after Entity is removed? - 04/04/09 13:13

Originally Posted By: GamerX
why not just call that function once from the action and put all the statements in the function in a while loop?

That's what I did!
Posted By: EvilSOB

Re: Function called by Entity is terminated after Entity is removed? - 04/04/09 13:35

Inside the action, the ME pointer will empty, but unless your loop is
something like while(me) it should stay running.

Can you post the action?
Posted By: garv3

Re: Function called by Entity is terminated after Entity is removed? - 04/04/09 13:52

I am currently at work and for that do not have the code right here.

But the function is something like...
Code:
function doSomeStuff(ENTITY* ent){
   while(ent){
      // do something as logn as the entity exists
      wait(1);
   }
   // do something else -> this is not performed!!!
}


The action is very complex. But it just calls "doSomeStuff(me)" at the beginning!
Posted By: garv3

Re: Function called by Entity is terminated after Entity is removed? - 04/04/09 20:14

So this should work, right? But it definitely does not!

I hope someone can help me!

Thx in davance!
Posted By: Quad

Re: Function called by Entity is terminated after Entity is removed? - 04/04/09 20:49

that doesnt help, you need to post where exactly you call the function and function itself.
Posted By: EvilSOB

Re: Function called by Entity is terminated after Entity is removed? - 04/04/09 20:54

Umm, I dunno how to answer this but, TO ME, this should work but it dont.
It seems that as soon as "ent" is removed, the entire action just aborts.

Ive even tried rolling back to 7.50 and it does the same, BUT ONLY WITH ENTITY
related actions.... Hell they're not even actions, they are just functions.

Hopefully SOMEONE can answer this cause it doesnt make sense to me, but it would
explain some odd behavious my actions sometimes give.
Posted By: garv3

Re: Function called by Entity is terminated after Entity is removed? - 04/04/09 21:03

Originally Posted By: Quadraxas
that doesnt help, you need to post where exactly you call the function and function itself.
Well, that does not make any sense! From where within the action I call the function does not have ANY effect at all!

And to be precise: Even if I call it in the first line of the action, the behaviour is the same.

And if you want the function - here it is:
Code:
function bodentextur_fuer_turm_steuern(PARTICLE* bodentextur, ENTITY* turm){
	set(bodentextur, TRANSLUCENT);
	bodentextur.alpha = 100;
	while (turm){
		bodentextur.lifespan = 16000;
		wait(1);
	}
	debug1 = 1;
	while(bodentextur.alpha > 0){
		bodentextur.lifespan = 16000;
		bodentextur.alpha -= time_step;
		wait(1);
	}
	bodentextur.lifespan = 0;
}
debug1 is never set to 1 !!!

I am really frustrated...
Posted By: Quad

Re: Function called by Entity is terminated after Entity is removed? - 04/04/09 21:04

Code:
void print_lol(){
	while(1){
		printf("lol\n");
		wait(-.1);//print lol every 0.1 sec.
	}
}

action remove_me(){
	printf("ent_created");
	
	print_lol();//-> you mean this stops too?
	
	my.skill1=1000;
	while(me){
		my.skill1--;
		if(my.skill1==0){ 
			ent_remove(me);
			printf("ent removed");
		}
		wait(1);
	}
}

void main(){
	video_screen = 0;//dont open video device
	wait(1);
	level_load("");
	ent_create("cube.mdl",nullvector,remove_me);
}


yeah it stops... i demand explanation too.
Posted By: garv3

Re: Function called by Entity is terminated after Entity is removed? - 04/04/09 21:06

Originally Posted By: EvilSOB
Hopefully SOMEONE can answer this cause it doesnt make sense to me, but it would
explain some odd behavious my actions sometimes give.
Yeah, it makes absolutely no sense! I wonder why I've never been stuck with this before. And maybe this is kind of a bug. Anyway - this behaviour is not correct not to mention logical.
Posted By: garv3

Re: Function called by Entity is terminated after Entity is removed? - 04/06/09 13:32

Ok, here is some of the original code...

The Action:
Code:
action EoR_aktion(){
	c_trace(vector(my.x+bauoptionen_gegner_scan_ausgangspunkt_gewaehlt[0],my.y+bauoptionen_gegner_scan_ausgangspunkt_gewaehlt[1],my.z+bauoptionen_gegner_scan_ausgangspunkt_gewaehlt[2]), vector(my.x+bauoptionen_gegner_scan_ausgangspunkt_gewaehlt[0],my.y+bauoptionen_gegner_scan_ausgangspunkt_gewaehlt[1],my.z-100), IGNORE_PUSH|IGNORE_ME|IGNORE_PASSABLE|IGNORE_SPRITES|IGNORE_CONTENT|USE_POLYGON);
	PARTICLE* bodentextur = ent_decal (spielfeld, baustellen_boden_tga, my.einheiten_reichweite*2, 0);
	my.einheiten_status = im_bau;
	[...]
	bodentextur_fuer_turm_steuern(bodentextur, me); //this line calls the function
	[...]
	EoR_mainFunktion(auge, balken1, balken2, balken3, balken4, balken5, balken6);
}
And the function:
Code:
function bodentextur_fuer_turm_steuern(PARTICLE* bodentextur, ENTITY* turm){
	set(bodentextur, TRANSLUCENT);
	bodentextur.alpha = 100;
	while (turm){
		bodentextur.lifespan = 16000;
		wait(1);
	}
	// The code below this line will never be executed. The function is terminated if the entity is removed
	debug1 = 1;
	while(bodentextur.alpha > 0){
		bodentextur.lifespan = 16000;
		bodentextur.alpha -= time_step;
		wait(1);
	}
	bodentextur.lifespan = 0;
}

So may someone please tell me why?!
Posted By: EvilSOB

Re: Function called by Entity is terminated after Entity is removed? - 04/06/09 13:51

Hey garv, I reckon this needs bumping to bugs IMHO.
Posted By: garv3

Re: Function called by Entity is terminated after Entity is removed? - 04/06/09 14:08

I agree and will open a thread in the bug hunt section.
© 2024 lite-C Forums