I've been reading up on instance ids and ds_priority, but I'm not really sure how to tell my objects listed to make a move. For now I have it set up so that if the player's "move" variable is true then my enemy object can move. I added a speed stat to my objects as well (stat_spd). I'm not really sure if I'm using it properly.
I have an invisible controller object that creates the priority queue and assigns it to a global variable called
global.turn_order. I have both my player object and my enemy add to the priority queue during their step events when they are not moving. The player has a stat_speed of 2 while the enemies have it set to 1. I add them to the priority queue like this:
Code:
if move == false{
ds_priority_add(global.turn_order , self.id , self.stat_spd);
}
This should add their instance id as the value and their speed as the priority. But now how do I tell the game to move them in order? I was trying something out like this in the controller object's step event:
Code:
while (!ds_priority_empty(global.turn_order) and obj_player.move == true){
ds_priority_find_max(global.turn_order);
}
Of course this does nothing since I'm just telling it to find the max value which should be my player object's speed, but what I have no idea what I should do after that. How do I pick my objects one at a time in order?
Thank you for the help so far.
EDIT: Literally after posting this I came up with the idea of using ds_priority_find_max() to check if the ds_priority is equal to the object's id.
Code:
if moving and ds_priority_find_max(global.turn_order) = id{
movement code
}
Now my problem is that not all the instances move. I added 9 instances of my enemy object to the room, but only 6 of them move. The three that don't move are also the last 3 that were added to the room. What could be causing this?