removing entity

Posted By: seecah

removing entity - 11/13/09 04:25

Hello Guys,

I need your ideas to help me solve my problem. I have an entity action that is making another entity inside..

Code:
void act_shellpearl()
{
	you = ent_create("pearl28.dds", vector(my.x, my.y, my.z + 2), NULL); 
	you.tilt = 90;
	you.ambient = 100;
	you.scale_x = 0.8;
	you.scale_y = you.scale_x;
	set(you, PASSABLE | INVISIBLE);
	my.emask |= (ENABLE_IMPACT | ENABLE_ENTITY | ENABLE_SCAN | ENABLE_DETECT);
	my.event = shellpearl_event;
	while(1)
	{
		//action of the my entity..
		// I have to toggle here the visibility of the you entity
	}
	ent_remove(me);
}



Indeed, you entity is a Pearl while my entity is a Shell..

I can't use a single global ENTITY* declaration since I'll be making variable number of Shell entities with action "act_shellpearl"

Now my problem is how to remove the you entity (Pearl) inside the "shellpearl_event" function.. during that event, the Shell will be removed and so as the Pearl must be.. but I can't use you pointer to remove the Pearl entity since it's already on another function..

Please advise..

Thanks,
Sedrix
Posted By: EvilSOB

Re: removing entity - 11/13/09 06:20

Code:
void act_shellpearl()
{
	you = ent_create("pearl28.dds", vector(my.x, my.y, my.z + 2), NULL); 
	you.tilt = 90;
	you.ambient = 100;
	you.scale_x = 0.8;
	you.scale_y = you.scale_x;
	set(you, PASSABLE | INVISIBLE);
//
	you.parent = me;
//
	my.emask |= (ENABLE_IMPACT | ENABLE_ENTITY | ENABLE_SCAN | ENABLE_DETECT);
	my.event = shellpearl_event;
	while(1)
	{
		//action of the my entity..
		// I have to toggle here the visibility of the you entity
	}
	ent_remove(me);
}


and in the pearls action, put something like
if(my.parent==NULL) ent_remove(me)
Posted By: seecah

Re: removing entity - 11/13/09 09:13

thanks EvilSOB, this is really what I needed.. waaaaaaaahhh.. I never know there is this parent pointer..

Super thank you!!!
Posted By: EvilSOB

Re: removing entity - 11/13/09 13:55

Hardly surprising, its undocumented... my area of expertise. grin
Posted By: Joey

Re: removing entity - 11/13/09 14:10

parent is not undocumented wink
Posted By: EvilSOB

Re: removing entity - 11/13/09 15:14

OK Joey, after a bit of a dig through the manual, I stand corrected.

I'll call it "almost" undocumented then....

I just that Ive never come across it in the manual in nearly 2 years.
© 2024 lite-C Forums