So if I’m reading your post correctly it sounds like you would like to limit the heroes even further for the non-president players besides just ‘not Mercy’.
To do this we’ll take a look at our existing code in RULE: RESTRICT TO NON-MERCY HEROES -- NON-PRESIDENTS
. After our wait action is the
SET PLAYER ALLOWED HEROES(EVENT PLAYER, REMOVE FROM ARRAY(ALL HEROES, HERO(MERCY)))
This is how we our currently restricting the hero list for non president players. Lets take a look at the documentation for this action. We can view this by mousing over the action in the ‘EDIT ACTION’ popup window. (All documentation is also viewable in the workshop wiki at WIKI: Workshop Syntax & Script Database - #2 by Kaedi-11739)
Sets the list of heroes available to one or more players. If a player’s current hero becomes unavailable, the player is forced to choose a different hero and respawn at an appropriate spawn location.
Definitions:
- Player - The player or players whose hero list is being set. Can use most Player based Value Syntax for this value.
- Hero - The hero or heroes that will be available. If no heroes are provided, the action has no effect. Can use most Hero based Value Syntax for this value including compatible Arrays.
Neat! So the first thing we notice is that there are two bullet points for each value we can change for this Action. Programmers refer to these changeable values as either ‘arguments’ or ‘parameters’ (these terms may or may not be used interchangeably in other computer programming languages for any nit-pickers out there reading this post).
So what this action wants is a “player or players” to set a hero list for as the first ‘argument’ and a “Hero or heroes” the aforementioned player can pick from as the second. What this tells us is that the value both of these ‘arguments’ expects can either be a singular value or an array (a list of values).
Still with me? Alright! Now back to our case! Lets look at what we are currently ‘passing as’ (putting down as) the action’s arguments. For the player argument, we are passing the EVENT PLAYER
value that this rule has filtered out with our CONDITIONS
. This is a singular value of one player, in other words, not an array. If we wanted to though, we could put an array value like ALL LIVING PLAYERS
here which funnily enough is an array containing the names of all the players that are currently alive (shocker right?). We only want to set it for players with the ‘M
’ variable set to TRUE
which our rule is filtering for already, so let’s leave it be as EVENT PLAYER
.
The second argument expects a ‘hero or heroes’. We are currently passing an array value here!
REMOVE FROM ARRAY(ALL HEROES, HERO(MERCY))
What we are doing with this line is creating our own list of heroes from an already known array, ALL HEROES
. The ALL HEROES
array probably looks something like this…
["Tracer", "Winston", "Mercy", "Gengu", "Handsoap", ... , "Secret Hero #31 please do not release early"]
Another quick programming learning aside, square brackets ‘’ or sometimes curly brackets ‘{}’ are used by programmers to indicate that something is an array. All the quoted values inside are the ‘elements’ inside the array. Again, an array is a list, but I’m getting sidetracked!
What we wanted originally was the player to be able to chose any character except Mercy. So, we’ll need to give the second argument of the SET PLAYER ALLOWED HEROES
action an array containing all heroes BUT Mercy. The easiest way to create this is to take a list of all the heroes in the game and just remove the “Mercy” hero value. Which we can do with the previously mentioned line. (I won’t post it here since this is getting long but you can take a look at the documentation at WIKI: Workshop Syntax & Script Database - #2 by Kaedi-11739)
REMOVE FROM ARRAY(ALL HEROES, HERO(MERCY))
This will create an altered copy of the array from before that looks something like this.
["Tracer", "Winston", "Gengu", "Handsoap", ... , "Secret Hero #31 please do not release early"]
So one way we could further limit the list of allowed heroes is to continue on with our current method of removing heroes from the array. Let’s say another hero we did not want the player to be was tracer. We could accomplish that by ‘nesting’ (continuing on by putting actions inside each other) REMOVE FROM ARRAY
actions like so.
REMOVE FROM ARRAY(REMOVE FROM ARRAY(ALL HEROES, HERO(MERCY)), HERO(TRACER))
The resulting array would look like this…
["Winston", "Gengu", "Handsoap", ... , "Secret Hero #31 please do not release early"]
At some point though, nesting starts to affect the readability of your code so its better to break these actions out and chain them together by using a temporary global variable. I use ‘T
’ as the global variable in this example for temporary.
SET GLOBAL VARIABLE(T, ALL HEROES)
MODIFY GLOBAL VARIABLE(T, REMOVE FROM ARRAY BY VALUE, HERO(MERCY))
MODIFY GLOBAL VARIABLE(T, REMOVE FROM ARRAY BY VALUE, HERO(TRACER))
SET PLAYER ALLOWED HEROES(EVENT PLAYER, GLOBAL VARIABLE(T))
This code accomplishes the equivalent as the nested code from above, AND it’s way easier to read. I said earlier the global variable T
is temporary. That is, we don’t care about storing it’s value after we’re done using it in this rule, so it can be overwritten as a temporary variable for other rules. NEAT!
Now this is one way to accomplish the goal of creating an available list of desired heroes. Taking a full list of all 30 heroes in Overwatch and removing the ones we do not want one at a time. BUT! the key word you mentioned in your post is that you only wanted a handful of heroes. This is not the most efficient way to create your desired list if you only want to allow a few heroes.
Unfortunately it’s getting really late and I won’t be able to finish answering this question tonight. However, I’ll finish answering tomorrow night and I bet you can probably guess where I’m headed with this.
EDIT: I accidentally a word