How to check if all npcs are done moving with turn-based movement <solved>

Problem info:

  1. I have an object group, called npcs.
  2. All objects of that group have an obnject variable called MaxNpcActions. There will likely be actions other than movement for some, such as enemies, but franktly, I haven’t gotten that far yet.
  3. Each npc moves to a random bordering square once over and over again until the object variable NpcActions equals MaxNpcActions.
  4. The Problem: Either the player turn resumes after the first NPC is out of moves or else, the thing I would like to know how make happen occurs, once the last npc in the current scene is out of moves, the player turn resumes. Unfortunately, I don’t know how to find the npc with the “fastest speed” (highest number of moves per turn) so that I can base the combined npc moves off of that. The only thing I can think of is to make the player and the npcs unequally waxed when it comes to speed and give the npcs a uniform 1-3 moves per turn.
1 Like

It seems like you are asking whether to know when all NPCs have moved.

You could have an array of remaining moves and npcs are done when that array is empty.

You could just iterate through the objects and when done with that, all npcs have moved.

What it sounds like you are saying is to sort npcs in to departments depending on their variable’s valuea nd have a turn for each department or to do something else. The first method, with the array, sounds like I would need an npc with the max number of moves on each scene for it to progress, but throughout my developing experience (which isn’t short but also isn’t that successful) I haven’t had much experience in any variables but booleans, number variables, and string variables, though those don’t seem quite as useful for more general purposes. I don’t know much about arrays, but I’ll try to look into that soon, I guess.

This is ingenious! Thankyou! Arrays are really cool! I considered using anumber variable to count the number of npcs who are finished and then check if the number of npcs who were finished was equal to the number of npcs in the scene but this would work so much better!

An explanation of how this would theoretically function: Extra groups which are for the specific number of moves for the npc objects inside the group. If the children of the array get a match in the number of moves used by an npc of one of those groups, then their turn will be over and the next bracket, so to speak, will not be done.

I watched further on into the video on advanced variables. Structure variables may be better because they can be named.

I’m having trouble with this method. I think it would be better to just make all the npcs walk around slowly instead, anyways. But this is how I would do it for enemies (whom I will make different from the npcs.)