When I try to shoot my enemies, I use ent_remove(you). But if I hit the target, I (players ship) got removed not the hidden target grin

Code:
function move_bomb() 
{
	c_setminmax(me); // bounding box setzten
	my.STATE = 1;
	my.pan = your.pan;
	my.tilt = your.tilt;
	my.roll = your.roll;
	
	while(1)
	{
		// Bombe flieg
		if (my.STATE == 1) 
		{
			c_move(me, vector(0, 50 * time_step, 0), vector(0, 0, 0), IGNORE_YOU);
			if(my.y >= 980 || my.z >= 580) 
        	{ // levelende erreicht?
        		my.STATE = 2;
        	}
        	if (HIT_TARGET) 
        	{
				//ent_create("explosion+4.bmp",vector(my.x,my.y,my.z+20),NULL); // particle effect planned
        		ent_remove(you);
        		my.STATE = 2;
        	}
		}
		// Bombe verschwinde
		if (my.STATE == 2) 
		{
        	ent_remove(me);
        	
        	bomb_anzahl --;
        	return; // !!! prevents further access to removed entity
			
		}
		wait(1);
	}
}



an this is the player action, from where function move_bomb is called:

Code:
action spieler_aktion()
{
	spieler = my;
	my.STATE = 1;
	
	while(1)
	{
		// auf und ab drehen
                ...
                 code for ship controll
		...



		// Schiessen - code for fireing
		if (my.STATE == 1) // kein Schuss
	   {
			if(mouse_left) my.STATE = 2;
		}
		if(my.STATE == 2) // Schuss  
		{
			if(last_bomb_x == 15) last_bomb_x = -15;
			else last_bomb_x = 15;
			if(bomb_anzahl < 4)
			{
				ent_create("bomb.mdl",vector(my.x+last_bomb_x,my.y+10,my.z),move_bomb);
				bomb_anzahl ++;
			}
			my.STATE = 3;
		}
		if (my.STATE == 3)
		{
			if (!mouse_left) my.STATE = 1;
		}
		wait(1);
	}
}



Cheers

Ditje

Last edited by Ditje; 08/02/10 14:39.