/// @description Insert description here
// You can write your code in this editor
if hp<=0 then {if irandom(10)>7 then instance_create_depth(x,y,1,obj_heal) instance_create_depth(x,y,-1,obj_explosives) instance_destroy() }

if point_distance(x,y,player.x,player.y)>300 then mp_potential_step_object(player.x,player.y,sped,obj_wall) else 
{
	if place_meeting(x+lengthdir_x(sped,point_direction(x,y,player.x,player.y)+side*90),y,obj_wall)=0 then x+=lengthdir_x(sped,point_direction(x,y,player.x,player.y)+side*90) else side=-side
if place_meeting(x,y+lengthdir_y(sped,point_direction(x,y,player.x,player.y)+side*90),obj_wall)=0 then y+=lengthdir_y(sped,point_direction(x,y,player.x,player.y)+side*90) else side=-side
}

if reload>0 then reload-=1
if collision_line(x,y,player.x,player.y,obj_wall,0,1)=noone and reload=0 then 
{	
var a;
a=instance_create_depth(x,y,-1,obj_green_bullet)
a.direction=point_direction(x,y,player.x,player.y)
a.image_angle=a.direction
a.speed=8
reload=20
audio_play_sound(snd_cyborg,1,0)
}

