So, the first issue is randomly selecting a map that isn't owned by the player? Here's how I would go about doing it:
The basic idea is to create an integer variable for each map. This variable will hold the number of the player that controls it. Once you beat the current map, you can easily import them from game cache and compare to the number of the player that won the current map. If they are the same, it means that both areas are controlled by the same player, i.e. the map is not eligible for loading.
1. Create these variables:
- MapOwnerNumber[Index] = Integer Variable Array, with "Index" ranging from 0 to X, where X is the total number of available zones. The initial values should be set to player numbers of players that start with the corresponding zone controlled.
- IndexInteger = Integer Variable
2. Once a map is started, granted it isn't the first map to be played, I would load the values from Game Cache:
-
For each (Integer IndexInteger) from 1 to X, do (Actions)
-
Loop - Actions
-
Set MapOwnerNumber[IndexInteger] = (Load (MON + (String(IndexInteger))) of MapOwnerNumbers from GameCacheVariable)
Where:
- X (in "from 1 to X" part) = total amount of rows in the multiboard = total amount of zones available.
- MON = just a string I used as a first part of a Label's name, you can set it to whatever as long as it corresponds to an appropriate Label in Game Cache.
- MapOwnerNumbers = just a string I used as a Category's name, you can set it to whatever as long as it corresponds to an appropriate Category in Game Cache.
- GameCacheVariable = your Game Cache Variable
Functions within "Set Variable" action:
- "Game Cache - Load Integer Value"
- "Concatenate Strings" - used to create an equation with strings.
- "Conversion - Convert Integer to String" with IndexInteger set as the integer to be converted.
How it should work:
- Functions should add MON and the converted integer together, creating strings like MON1, MON2, MON3, etc.
- This is how what the saved integer values should be labeled as in your Game Cache.
- I haven't tested this - if it doesn't work, load each integer manually.
3. I don't know how you want to determine whether a player has gained control over the map/area, so I cannot write you a trigger for that, but once you do determine that, put this at the end of that trigger:
-
Set PlayerVariable = Player Y (Color)
-
Set MapOwnerNumber[Z] = (Player number of PlayerVariable)
-
For each (Integer IndexInteger) from 1 to X, do (Actions)
-
Loop - Actions
-
Game Cache - Store MapOwnerNumber[IndexInteger] as (MON + (String(IndexInteger)) of MapOwnerNumbers in GameCacheVariable
-
Trigger - Run Next Chapter Selection <gen> (checking conditions)
Where:
- Z (as MapOwnerNumber index) = the number corresponding to a currently played map.
- PlayerVariable = Player Variable, set its value to the player that has gained control over the currently played map/area [i.e. Player X (Color)].
- Next Chapter Selection = next trigger that I'm about to post, that's the one that selects a chapter to play next.
4. Run something like this - i.e. Next Chapter Selection trigger:
-
Set PlayerVictorious = True
-
For each (Integer IndexInteger) from 1 to X, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MapOwnerNumber[IndexInteger] Not Equal to MapOwnerNumber[Z]
-
Then - Actions
-
Set PlayerVictorious = False
-
Else - Actions
-
-------- do nothing --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Then - Actions
-
-------- do nothing --------
-
Else - Actions
-
-------- any other actionss you want to happen before giving the victory to the player that won curent map --------
-
Game - Victory (Player(MapOwnerNumber[Z])) (Show dialogs, Show scores)
-
Skip remaining actions
-
Set CheckingOrder = (Random integer number between 1 and IndexInteger)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MapOwnerNumber[CheckingOrder] Equal to MapOwnerNumber[Z]
-
Then - Actions
-
Trigger - Run (This trigger) (checking conditions)
-
Else - Actions
-
Game - Set the next level to (Maps\Map + ((String(CheckingOrder)) + .w3x))
-
-------- any other functions you want to happen before loading the next map --------
-
Game - Victory (Player(MapOwnerNumber[Z])) (Show dialogs, Show scores)
Where:
- "PlayerVictorious" - Boolean Variable
- "CheckingOrder" - Integer Variable
Functions:
- "Conversion - Convert Player Index to Player" - used in this part: "(Player(MapOwnerNumber[Z]))" with MapOwnerNumber[Z] as the index.
Things to note:
- In the example above, the map path will look like this: "Maps\Map2.w3x", "Maps\Map3.w3x" as it should be generated by this code: "(Maps\Map + ((String(CheckingOrder)) + .w3x))". This is actually the addition of three separate strings.
How this should work:
- First it sets "PlayerVictorious" as True
- If all maps are controlled by the same player as the one who won the currently played one, this player will get the victory.
- If at least one other map is not controlled by the same player, it will randomly select a map to check.
- If that map is also controlled by the same player, the trigger will run itself again.
- If not, it will set the next map to the corresponding map.
Honestly, it's a bit late here and I have to go to bed, so I really don't have any idea if this will even work. You might want to try it out, though.
If it doesn't work and you don't care about a random map being selected, you might just want to run through the maps individually through the "If/Then/Else" cascade with "Skip Remaining Actions". Something like this basically:
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MapOwnerNumber[1] Equal to MapOwnerNumber[Z]
-
Then - Actions
-
-------- do nothing --------
-
Else - Actions
-
Game - Set the next level to (Maps\Map1.w3x))
-
-------- any other functions you want to happen before loading the next map --------
-
Game - Victory (Player(MapOwnerNumber[Z])) (Show dialogs, Show scores)
-
Skip remaining actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MapOwnerNumber[2] Equal to MapOwnerNumber[Z]
-
Then - Actions
-
-------- do nothing --------
-
Else - Actions
-
Game - Set the next level to (Maps\Map2.w3x))
-
-------- any other functions you want to happen before loading the next map --------
-
Game - Victory (Player(MapOwnerNumber[Z])) (Show dialogs, Show scores)
-
Skip remaining actions
-
etc.
---
As for the Multiboard thing.
I'd create a multiboard that in Column 1 lists all the available zones and in column 2 displays the name of the player that has control over that zone. Column 1 doesn't change, but all string values have to be manually inserted. Column 2 values change and are directly determined by this set of actions:
-
For each (Integer IndexInteger) from 1 to X, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MapOwnerNumber[IndexInteger] Equal to 0
-
Then - Actions
-
Multiboard - Set the text for MultiboardVariable item in column 2, row IndexInteger to No Owner
-
Else - Actions
-
Multiboard - Set the text for MultiboardVariable item in column 2, row IndexInteger to (Name of (Player(MapOwnerNumber[IndexInteger])))
Explanations:
- X (in "from 1 to X" part) = total amount of rows in the multiboard = total amount of zones available
- MapOwnerNumber[IndexInteger] = Integer Variable Array, the values for each variable in the array have to be imported from the Game Cache as in the example above.
- IndexInteger = Integer Variable
- MultiboardVariable = Multiboard Variable
To get to the last part of the final action, use functions:
- "Player - Player Name" and then
- "Conversion - Convert Player Index to Player" and then
- set "MapOwnerNumber[IndexInteger] as the index number for that function
On the contrary to the map selection triggers, I've tested this one and it works.