If I follow your prerequisites, you don't have to do that.
You can set player's color with action "Player - Set Player Color" .
You randomize the color at the start of your game.
If you reaaaaally want to use that actor message (It sure is opens some possibilities), you need :
- Global <Integer> "MAX_PLAYERS" set as a constant the maximum number of players.
- Global array of <Integer> "Players_ColorId" with as size "MAX_PLAYERS". It will save the color Id for each player.
- New action definition "Set Color to Players".
- New action definition "Set Team Color To Player Actors".
- Trigger "Initialization" where to set actions at the beginning of the game. Or equivalent.
- Trigger "Unit Creation" with as event "Unit is Created" if you create units from in-game abilities.
OR Action "Unit Creation" where you create units from the script.
[X] Instructions for action "Set ColorId to Players" :
> You must want a non repetitive random integer, and for that you need a local array of <Integer> "colors" with as size "MAX_PLAYERS".
> In a "For" loop with local variable "i" from 1 to "MAX_PLAYERS", set "colors" to "i".
> End "For" loop.
> In a "For" loop with local variable "p" from 1 to "MAX_PLAYERS".
> Set a local variable "randInt" from 1 to "MAX_PLAYERS".
> In a "If Then Else" :
> If :
> Comparison like variable "colors[randInt]" is greater than 0.
> Then :
> Set "Players_ColorId[p]" to "colors[randInt]".
> Set value "colors[randInt]" to value "-1" (I recommend to use "0" as a default/neutral value).
> Else :
> Modify "p" with value -1.
> End "If Then Else".
> End "For" loop.
[X] Instructions for action "Set Team Color To Player Actors" :
> Parameter of <Integer> "Player".
> Parameter of <Actor> "SourceActor".
> Switch on variable "Players_Color[Player]" from 1 to "MAX_PLAYERS".
> Equals to 1 : Call function : "Send Actor Message" with message "SetTeamColorBlend" to "SourceActor".
> ...
> Equals to "MAX_PLAYERS" : Call function : "Send Actor Message" with message "SetTeamColorBlend" to "SourceActor".
> End "Switch".
[X] Instructions for trigger "Initialization" :
> Call action : "Set ColorId to Players".
[X] Instructions for trigger or action "Unit Creation" :
> Call action "Set Team Color To Player Actors" with parameters : "Player" = "Owner of (Last created unit)" ; "SourceActor" = "Actor of unit (Last created unit)".
Definition of action "Set ColorId to Players" is not optimal but since we don't have dynamic array, we cannot remove "-1" values in "colors".
Plus, the array is small, it should not go over few seconds in worst cases.
I wrote this from my head and tried to detail instructions.
I'm trying to create a trigger that randomizes Team colors for each player using the "Send Actor Message's" "SetTeamColorBlend" function
What I want to do:
- Have each Player a random team color using the above mentioned function
- No random colors BETWEEN that player's units
- Assigned at the beginning of the match
Hello.
If I follow your prerequisites, you don't have to do that.
You can set player's color with action "Player - Set Player Color" .
You randomize the color at the start of your game.
If you reaaaaally want to use that actor message (It sure is opens some possibilities), you need :
- Global <Integer> "MAX_PLAYERS" set as a constant the maximum number of players.
- Global array of <Integer> "Players_ColorId" with as size "MAX_PLAYERS". It will save the color Id for each player.
- New action definition "Set Color to Players".
- New action definition "Set Team Color To Player Actors".
- Trigger "Initialization" where to set actions at the beginning of the game. Or equivalent.
- Trigger "Unit Creation" with as event "Unit is Created" if you create units from in-game abilities.
OR Action "Unit Creation" where you create units from the script.
[X] Instructions for action "Set ColorId to Players" :
> You must want a non repetitive random integer, and for that you need a local array of <Integer> "colors" with as size "MAX_PLAYERS".
> In a "For" loop with local variable "i" from 1 to "MAX_PLAYERS", set "colors" to "i".
> End "For" loop.
> In a "For" loop with local variable "p" from 1 to "MAX_PLAYERS".
> Set a local variable "randInt" from 1 to "MAX_PLAYERS".
> In a "If Then Else" :
> If :
> Comparison like variable "colors[randInt]" is greater than 0.
> Then :
> Set "Players_ColorId[p]" to "colors[randInt]".
> Set value "colors[randInt]" to value "-1" (I recommend to use "0" as a default/neutral value).
> Else :
> Modify "p" with value -1.
> End "If Then Else".
> End "For" loop.
[X] Instructions for action "Set Team Color To Player Actors" :
> Parameter of <Integer> "Player".
> Parameter of <Actor> "SourceActor".
> Switch on variable "Players_Color[Player]" from 1 to "MAX_PLAYERS".
> Equals to 1 : Call function : "Send Actor Message" with message "SetTeamColorBlend" to "SourceActor".
> ...
> Equals to "MAX_PLAYERS" : Call function : "Send Actor Message" with message "SetTeamColorBlend" to "SourceActor".
> End "Switch".
[X] Instructions for trigger "Initialization" :
> Call action : "Set ColorId to Players".
[X] Instructions for trigger or action "Unit Creation" :
> Call action "Set Team Color To Player Actors" with parameters : "Player" = "Owner of (Last created unit)" ; "SourceActor" = "Actor of unit (Last created unit)".
Definition of action "Set ColorId to Players" is not optimal but since we don't have dynamic array, we cannot remove "-1" values in "colors".
Plus, the array is small, it should not go over few seconds in worst cases.
I wrote this from my head and tried to detail instructions.
Hope you can achieve your goal.
Have a nice day.
Cool, thanks man.