(SOLVED) Can anyone figure out whats up with my alarm??

D

Den

Guest
My alarm only seems to end once I have took control of the enemy (which it shouldn't) it's set at a second (while i'm testing) but it won't run until the enemy goes into the control state. It's like the alarm only starts when the enemy enters the control state even tho I haven't told it to do that.
I'll show you my code below, if any of you guys could help that would be awesome.

This the enemies step for all my enemies (They just inherit vars from an enemy parent object)
Code:
///Player Takes Control
event_inherited();

if(instance_exists(obj_player)) controlled = false;

while(place_meeting(x, y, obj_player) && obj_player.image_alpha = 0) {
    controlled = true;
    break;
    
}

//Controlled cases
switch (controlled) {
    case true: state = controlled_state image_index = 1;
      break;
}
Then Wander state (random_dir just gets a random direction for the enemy to move in)
Code:
///wander_state()
alarm[WANDER] = .5*room_speed;
x+= random_dir;
At the end of the alarm I just have a show message at the min coz i'm trying to see when it finishes but as I said above it only seems to run the alarm once the enemy has switched stats.
The enemies also start in the wander state.
 

Conbeef

Member
Because you're resetting the alarm every time that code runs. Try this instead
Code:
///wander_state()
if alarm[WANDER] == -1{
alarm[WANDER] = .5*room_speed;
x+= random_dir;
}
 
D

Den

Guest
Because you're resetting the alarm every time that code runs. Try this instead
Code:
///wander_state()
if alarm[WANDER] == -1{
alarm[WANDER] = .5*room_speed;
x+= random_dir;
}
Thanks you so much man!, this had me stuck for ages :)
 
Top