I'm going to explain the problem I'm trying to solve, my solution, and the problem I've run into with it. However, if there is a better way to solve the problem in the first place, then by all means, please let me know.
I'm making a map that has a hero/character selector. I want to know when all players have selected a hero. I've created a global var that is an array of booleans, and the trigger that sets the item to 'true' works fine.
Where I'm having the issue is in the next trigger, in that I want play to begin once everyone has selected. Do I have to set the Condition section to check each cell manually, or is there a shorter/better way to do it? I also want to avoid a manual check, as it will start leading to some kludgy situations if I don't have the max amount of players.
If the correct solution is Galaxy scripting, that's fine. Not afraid to jump into that, (I have a fair amount of programming experience) though I haven't touched it yet.
You could make a trigger which has a periodic event. lets say every 5 seconds.
This trigger will loop through all players in your player group which contains all activate players (If you don't have one, you should create one, since it will be very useful in a lot of cases).
Create a local boolean variable named "allSelectedHero" inside of the trigger and set it to true.
Inside the loop check for every player if he selected a hero (compare your array variable to whatever makes sense like Hero[PickedPlayer]==NoUnit). If one didn't select a hero then set your local "allSelectedHero" to false.
Then the variable will be false as long as at least one player hasn't selected a hero and true if all have one. This information can be used like you want. Maybe running the starting trigger in this case or doing whatever you want.
One word to the condition section: Conditions are mainly useful if you filter out "big" things like if you want the trigger only to run for a specific player, a specific unittype, ability, dialog, .... But since you can't make loops in there it's better to create your own conditions with loops, if-then-elses and comparisons.
Hello all.
I'm going to explain the problem I'm trying to solve, my solution, and the problem I've run into with it. However, if there is a better way to solve the problem in the first place, then by all means, please let me know.
I'm making a map that has a hero/character selector. I want to know when all players have selected a hero. I've created a global var that is an array of booleans, and the trigger that sets the item to 'true' works fine.
Where I'm having the issue is in the next trigger, in that I want play to begin once everyone has selected. Do I have to set the Condition section to check each cell manually, or is there a shorter/better way to do it? I also want to avoid a manual check, as it will start leading to some kludgy situations if I don't have the max amount of players.
If the correct solution is Galaxy scripting, that's fine. Not afraid to jump into that, (I have a fair amount of programming experience) though I haven't touched it yet.
Thanks. :)
You could make a trigger which has a periodic event. lets say every 5 seconds.
This trigger will loop through all players in your player group which contains all activate players (If you don't have one, you should create one, since it will be very useful in a lot of cases).
Create a local boolean variable named "allSelectedHero" inside of the trigger and set it to true.
Inside the loop check for every player if he selected a hero (compare your array variable to whatever makes sense like Hero[PickedPlayer]==NoUnit). If one didn't select a hero then set your local "allSelectedHero" to false.
Then the variable will be false as long as at least one player hasn't selected a hero and true if all have one. This information can be used like you want. Maybe running the starting trigger in this case or doing whatever you want.
One word to the condition section: Conditions are mainly useful if you filter out "big" things like if you want the trigger only to run for a specific player, a specific unittype, ability, dialog, .... But since you can't make loops in there it's better to create your own conditions with loops, if-then-elses and comparisons.
@Skystrider: Go
Run this function after every time a user confirms the selection on a hero
SelectionPhase Complete function
you can run this function after the button click to run it in a manner as to wait for it to finish... then do a compare on the global PlayerReady
you could just make this function return a boolean value of the "allready" internal variable as well.... how ever you prefer...
the wait... it to help it account for players pressing the button at the same time....
also with this its a good idea to have a hard capped time limit...... in the source trigger to prevent the game from locking due to afk people