To create enemy bullet when player is come close enough :
Code:
var shoot_speed = 5;
var pushValue;
function shoot_you()
{
pushValue += 0.1; // prevent bullet hit each other
my.push = pushValue; // reset it if reached certain value
my.skill1 = 100; // bullet life
while(my.skill1 > 0)
{
c_move(my,vector(shoot_speed*time_step,0,0),nullvector,Ignore_Push);
my.skill1 -= 1 * time_step;
wait(1);
}
ent_remove(my);
}
Action Spawn2 // enemy action
{
c_setminmax(my);
while(player==NULL) {wait(1);}
while(my)
{
if (vec_dist(player.x,my.x) < 50)
{
you = ent_create(bullet,vector(my.x-40,my.y,my.z),shoot_you);
you.pan = my.pan;
}
wait(-0.5);
}
}
Just an example.