I think one of Earth-Fury's old tools used to be able to read values from .slk files, but honestly who knows if any of that code still runs. WereElf could made a struct that stores the current RGB values for a model and then write wrappers to change them that writes the data to the appropriate struct (linked to the unit with a storage system, hash, or looked up using brute force search on a bigass array) before they get altered . If you only have a few units with colors pre-set in the object editor this is probably the quickest solution, but it will disallow you from setting unit colors in the object editor (you have to change the RGB values to whatever color you want when the unit enters the map, for example).This is where SC2 is so good. One can just create a named actor to do the recolour and then remove that actor when you want to restore the colour and the colour then restores to whatever it should correctly be.
In WC3 you will need some tool to read all the tint values from the slk and object editor files and store them in data structures like arrays or hashtables. You then need to simulate all your colouration stacking mechanics with JASS triggers.
globals
RGBA array UnitColors
integer TotalUnits //How many different unit types there are in your game whose RGB values are stored by the system
endglobals
struct RGBA
integer uid //The rawcode of the unit this RGBA profile corresponds to
integer R
integer G
integer B
integer A
method create takes integer UID, integer R, integer G, integer B, integer A
//whatever is necessary
endmethod
endstruct
...
//Init function looks something like this:
function Init takes nothing returns nothing
UnitColors[1] = RGBA.create('Hpea',0,0,255,255)
UnitColors[2] = RGBA.create('Hfoo',130,193,255,200)
//etc....
//This could be automated into a loop or with textmacos
endfunction
...
function GetOriginalRGBA takes integer UnitID returns RGBA
local integer i = 0
loop
exitwhen i >= TotalUnits
if UnitColors[i].uid == UnitID then
return UnitColors[i]
end
set i = i+1
endloop
//If we get here we didn't find a match in our stored array
return RGBA.createNew() //or some method
endfunction
You could also save it represented by a hexadecimal, it is easier in my opinion. Example: Save integer, 0xFFF060 then extraction of each color would just be the same method, but just a different denominator.Thanks for all the answers.
I think I will save the unit's RGB value(s) into a hashtable, but instead of a struct - I will just save them as single integer. For example 255200100 would be 255 R 200 G 100 B.
And I will use the following formulas to get each value: R = RGB/1000000; G = RGB/1000 - (RBG/1000000)*1000; B = RGB - (RGB/1000)*1000
function toInt takes integer red, integer green, integer blue returns integer
return red + green*256 + blue*256*256
endfunction
function getRed takes integer data returns integer
return ModuloInteger(data, 256)
endfunction
function getGreen takes integer data returns integer
return ModuloInteger(data/256, 256)
endfunction
function getBlue takes integer data returns integer
return ModuloInteger(data/(256*256), 256)
endfunction