/// @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_destroy()}
if timer>=40 then
{
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
}
timer-=1
}
if timer<40 then
{
if place_meeting(x+lengthdir_x(sped/4,point_direction(x,y,player.x,player.y)+side*90),y,obj_wall)=0 then x+=lengthdir_x(sped/4,point_direction(x,y,player.x,player.y)+side*90) else side=-side
if place_meeting(x,y+lengthdir_y(sped/4,point_direction(x,y,player.x,player.y)+side*90),obj_wall)=0 then y+=lengthdir_y(sped/4,point_direction(x,y,player.x,player.y)+side*90) else side=-side
if timer>0 then timer-=1
if collision_line(x,y,player.x,player.y,obj_wall,0,1)=noone and timer=0 then 
{
timer=120+irandom_range(-30,120)	
var a;
a=instance_create_depth(x,y,-1,obj_axe)
a.direction=point_direction(x,y,player.x,player.y)
a.speed=6
}
}
