WizzardMaker / S4GFX

A tool to extract Settlers 4 assets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unit team color support

WizzardMaker opened this issue · comments

Units are colored in according to their team color - Red team has red units

The game uses probably reserved palette offsets to control which pixel gets what shade of the team color

image
45
There are multiple palette offsets probably, as there appear to be more than 1 team color shade. The exporter currently interprets it as a solid black. Importing the file like its exported, results in missing team colors.

Upon testing with upscaled textures, I noticed random team colors being added to the character. The most likely cause is, that the new files used the full 253 possible colors, that the importer is willing to give. The team colors are maybe in the high range of that limit.
image
12659

commented

There appears to be 32 shades per team color. Each color is rgb565. Here are the palettes for each team color:

red (0)
0000 0000 0000 0800 1000 1800 2000 2800
3000 3800 4000 4800 5000 5800 6000 6800
7000 7800 8000 8800 9000 9800 A000 A800
B000 B800 C000 C800 D000 D820 E061 E8A2

blue (1)
0000 0000 0000 0000 0000 0000 0001 0002
0003 0004 0005 0006 0007 0008 0008 0009
000A 000B 000C 000D 000E 000F 0010 0011
0832 1073 18B4 20F5 2936 3177 39B8 41F9

green (2)
0000 0000 0000 0000 0000 0000 0000 0020
0060 00A0 00E0 0120 0160 01A0 01E0 0220
0260 02A0 02E0 0320 0360 03A0 03E0 0420
0460 04A0 04E1 0522 0563 05A4 05E5 0626

yellow (3)
0000 0800 1020 1860 20A0 28E0 3120 3960
41A0 41E0 4A20 5260 5AA0 62E0 6B20 7360
7BA0 83E0 8C20 9460 9CA0 A4E0 AD20 B540
BD80 C5C0 CE00 D640 DE80 E6C0 EF00 F740

purple (4)
0000 0001 0002 0003 0004 0005 0006 0007
0008 0809 100A 180B 200C 280D 300E 380F
4010 4811 5012 5813 6014 6815 7016 7857
8098 88D9 911A 995B A19C A9DD B21E BA5F

orange (5)
0000 0800 1000 1800 2000 2800 3000 3800
4000 4800 5000 5800 6020 6860 70A0 78E0
8120 8960 91A0 99E0 A220 AA60 B2A0 B2E0
BB20 C360 CBA0 D3E0 DC21 E462 ECA3 F4E4

cyan (6)
0000 0000 0000 0000 0000 0000 0000 0020
0060 00A0 00E1 0122 0163 01A4 01E5 0226
0267 02A8 02C9 030A 034B 038C 03CD 040E
044F 0490 04D1 0512 0D53 1594 1DD5 2616

white (7)
0020 0061 00A2 00E3 0924 1165 19A6 21E7
2A28 3269 3AAA 42EB 4B2C 536D 5BAE 63EF
6C30 7471 7CB2 84F3 8D34 9575 9DB6 A5F7
AE38 B679 BEBA C6FB CF3C D77D D7BE DFFF

Here is a demo that rotates the colors every 100 ms for each team:

image

Looks like the palettes you gave me aren't 100% right, or at least not long enough. I don't know the exact starting point of the team color palette, but it looks like its at 192. Problem is, the image still has some missing colors, as there are palette references beyond 224 (192+32). I've seen values like 244 or 248

Red value is the palette index:
image

The resulting image, when using your provided palette swap
image

commented

There are no more than these 32 colors. Swapping them while being ingame seems to be enough to correctly change the team of a unit (see the gif above). Maybe the game can somehow "stretch" a palette. I will have to do more research on that though.

commented

It actually does not look like it is a palette problem. It looks more like the game does some interpolation that we are missing. The problematic pixels are only at edges. Maybe the pixels with values 244, 248 etc are "blended pixels" that blend with the upper, left, right or bottom pixel (or a combination of them).
interp

Edit: Can you do one for the blue colored settler? I think it will be more obvious with that color if that is the case.

commented

Yes you were totally right. There is a second set of 32 team colors that are combined to the palette. However this second set is different for every object. These object specific team color palettes are stored in the files of the gfx directory. I've seen some of them come from 20.p26.

6

The color information for the team seems to be after the normal color information in the palette file.

After the 256 colors of the normale image, there are 32 colors for each team in a palette file.