• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Solved] Change player color(s) locally - desync or not?

Status
Not open for further replies.
Level 12
Joined
Nov 3, 2013
Messages
989
I've scrapped a map idea before because I was going to use neutral players as creeps à la Aeon of Strife but wc3 lacking the extra player colors just made it too confusing since either all neutrals would be black and you couldn't tell whose creeps were whose (especially on the minimap) or 3 players were bound to share their colors with the AI players which while less confusing over all isn't particularly good either.


However I'm thinking perhaps I can basically make my own version of the Ally Color Modes if changing player colors locally doesn't desync. (Which I'm guessing it's not since there already are "Ally Color Modes" after all, but who knows, it's Warcraft 3 :p)


Honestly I'd never play with any ally color mode myself but if I can add more player colors through local files then the map would still be playable normally without forcing local files, which I'm not considering otherwise.
 
Last edited by a moderator:
Level 24
Joined
Aug 1, 2013
Messages
4,657
native SetPlayerColor takes player whichPlayer, playercolor color returns nothing
Works quite fine when used publically or locally.
It changes the color of a player so that color will be used from now on...
However, it does not change the color of his units, so Blizzard was so kind to provide us with function SetPlayerColorBJ takes player whichPlayer, playercolor color, boolean changeExisting returns nothing which does exactly what you need.
It loop through all the units of the player and change their color as well... however,
1, It leaks.
2, It creates a new handle (group) which means you cannot use it locally or it will desync.

I also wanted to use local colors to make
Me: Yellow
Allies: Green
Enemies: Red
Neutrals: Blue
(could switch neutrals with self)
So I created a custom function to do this:
JASS:
function SetPlayerColorLocally takes player client, player affectedPlayer, playercolor pc, boolean changeUnits returns nothing
    local group g
    local unit FoG
    local player localPlayer = GetLocalPlayer()
    
    if localPlayer == client then
        call SetPlayerColor(affectedPlayer, pc)
    endif
    
    if changeUnits then
        set g = CreateGroup()
        
        call GroupEnumUnitsOfPlayer(g, affectedPlayer, null)
        loop
            set FoG = FirstOfGroup(g)
            exitwhen FoG == null
            call GroupRemoveUnit(g, FoG)
            
            if localPlayer == client then
                call SetUnitColor(FoG, pc)
            endif
        endloop
        call DestroyGroup(g)
        set g = null
    endif
    set localPlayer = null
endfunction
So you can use:
call SetPlayerColorLocally(Player(0), Player(1), PLAYER_COLOR_GREEN, true)
To make player(1) look green for player(0). All other players see player(1) still as the color he had before this function (blue by default).


About making custom colors...
"There are TC textures.
It is ReplaceableTextures\TeamColor\TeamColor(00-15).blp. In total, 16 colours, though the last 4 are just grey."
- GhostThruster
 
Status
Not open for further replies.
Top