Code:
function player_scanning()
{
       while (1)
       {
               c_scan(my.x, my.pan, vector(360, 0, 500), SCAN_ENTS | SCAN_LIMIT | IGNORE_ME);
               if (you)
               {
                       ent_create ("slider.pcx", vector (you.x, you.y, you.z + 60), entity_marker);
               }
               wait (1);
       }
}

action my_enemy() // attach this action to your enemies
{
	player_scanning();	
	
	var idle_percentage = 0;
	var run_percentage = 0;
	var death_percentage = 0;
	var content_right[3]; // tracks the content in front of the player
	var content_left[3]; // tracks the content in front of the player
	var temp[3];
	

	
	
	set(my,POLYGON);// use accurate collision detection
	my.health = 100;
	my.emask |= ENABLE_IMPACT; // the enemy is sensitive to impact with player's bullets
	my.event = got_shot; // and runs this function when it is hit
	my.status = idle; // that's the same thing with my.skill1 = 1; (really!)
	while (my.status != dead) // this loop will run for as long as my.skill1 isn't equal to 3
	{




Hi,
IN this code notice that I call the player_scanning() function from within the player's action and it has a while(1) loop. However if I did NOT call that function, and instead simply placed that while loop at the beginning of my player action, then the player's next while (my.status != dead) would never activate. So can someone tell me the mechanics behind why this is? Why does this while loop work outside in a function, but not inside the action, like when and how does the engine run these?

Any insight you might be able to give me is appreciated

Thanks