Alright, I think I mostly understand this, and have something that works better now. That said, Not sure how I would go about adjusting things before the initial function run, or override it. As is, I at least recover the small amount of remaining detail now, but obviously would prefer keeping all of it if possible.
I'm probably still doing this wrong anyway, and am unsure how to not have the green color get brighter the darker the tile is. I understand why it happens, shade caps at 15, so the darker the tile is, the more I increase the brightness. Which is suboptimal, but unsure how to fix that.
Also, if I try and brighten unit's it invariably seems to make them kinda glow, even if I just add a small amount, when the target is only slightly shaded. Always ends up washed out. I thought each point of shade offset all colors by 1, and reversing that, unless you fall off the 1-15 range, would undo the effect.
Also, is there a way to print to screen instead of log, or chose a specific pixel to log, and only once per "Change"? This is worse that Wc3 debugging. Or just debug message best practice?
extended:
scripts:
recolorUnitSprite:
- offset: 1
code: |
var int tileShade;
var int oldShade;
var int newShade;
unit.getTileShade tileShade;
unit.getRecolor new_pixel;
get_shade oldShade new_pixel;
if le tileShade 9;
# Fully Lit. Not on border.
if ge tileShade 6;
## Reduce shade.
#set newShade oldShade;
#sub newShade tileShade;
#add newShade 4;
#limit newShade 1 15;
#set_shade new_pixel newShade;
end;
else eq tileShade 10;
# dark, on border. Leave as is.
set newShade oldShade;
sub newShade tileShade;
add newShade 4;
limit newShade 1 15;
set_shade new_pixel newShade;
else gt tileShade 10;
# Dark, and not on border. Greenlight it, but keep it dark-ish
set_color new_pixel 4;
set newShade oldShade;
sub newShade tileShade;
add newShade 6;
limit newShade 1 15;
set_shade new_pixel newShade;
end;
return new_pixel;