I'm trying to add the "A*" in the enemy script to improve movement, here is the function:
function scr_slime_perseguindo(){
image_speed=1.5;
dest_x=obj_player.x;
dest_y=obj_player.y;
if(mp_grid_path(obj_map.mp_grid,caminho,x,y,dest_x,dest_y,true)){
path_start(caminho,veloc_perseg,path_action_stop,false);
}
scr_slime_colisao();
if distance_to_object(obj_player)>=dist_desaggro{
estado=scr_slime_escolher_estado;
alarm[0]=irandom_range(120,240);
}
}
the original function was this:
function scr_slime_perseguindo(){
image_speed=1.5;
dest_x=obj_player.x;
dest_y=obj_player.y;
var _dir=point_direction(x,y,dest_x,dest_y);
hveloc=lengthdir_x(veloc_perseg,_dir);
vveloc=lengthdir_y(veloc_perseg,_dir);
scr_slime_colisao();
if distance_to_object(obj_player)>=dist_desaggro{
estado=scr_slime_escolher_estado;
alarm[0]=irandom_range(120,240);
}
}
but when attacking the enemy would receive a knockback with this function
function scr_slime_hit(){
alarm[2]=180;
empurrar_veloc=lerp(empurrar_veloc,0,0.05);
hveloc=lengthdir_x(empurrar_veloc,empurrar_dir);
vveloc=lengthdir_y(empurrar_veloc,empurrar_dir);
scr_slime_colisao();
}
stop working.
I would like to know if there is a way to fix this or if I would have to rewrite all two functions to work together, if I leave any information out, please let me know so I can clarify more, thx!