S
Soco
Guest
I'm making a jrpg game and I have an enemy that chases me when I get into his sight or aggro range. However, when I leave his sight, he stops chasing me. I'd prefer him to chase me for some time before giving up. I'm thinking about 5 seconds, maybe less, I dunno, that part is unimportant right now. Here's my logic so far, and maybe someone can tell me what I'm doing wrong.
This is my enemy searching for my player.
[
Then the alarm event which should just go off, un-aggro the enemy and make him choose his next state.
From what I've gathered, the alarm is being set, but isn't counting down. So that code never executes. Why isn't it working!?!?!?!?!?!?!?! I am slightly frustrated lol.
This is my enemy searching for my player.
[
Code:
//if player exists
if (instance_exists(obj_soco)){
dist = point_distance(x,y,obj_soco.x,obj_soco.y);
//if in aggro range
if (dist < sight){
aggro = true;
state = scr_e_chase;
show_debug_message(string("dist < sight, aggro"));
var dir = point_direction(x,y,obj_soco.x, obj_soco.y);
xaxis = lengthdir_x(1, dir);
yaxis = lengthdir_y(1, dir);
//if out of aggro range
}else if (dist >= sight){
//if aggro'd
if (aggro == true){
show_debug_message(string("dist >= sight, aggro"));
alarm[2] = room_speed * 3;
//state = scr_e_chase;
}else{ //if not aggro'd
show_debug_message(string("dist >= sight, no aggro"))
scr_e_choose_next_state();
}
}
//if player does not exist
}else{
scr_e_choose_next_state();
}
Code:
///Aggro alarm
aggro = false;
scr_e_choose_next_state(); //wander or idle