This is mod tool (modified OpenXcom source) for recoloring unit sprites on runtime.
To use it you need compile exe using src from
https://github.com/Yankes/OpenXcom/tree/ColorScriptThen you can alter ruleset to add scripts.
Some example in action:
https://www.youtube.com/watch?v=_G34PHMiBv0https://www.youtube.com/watch?v=85A8eSGpO5QFeatures:
- Reuse same graphic for multiple armors with altered colors
- Alter look of unit based on stats (e.g. different color based on rank)
- Special effects (e.g. show blood or fatal wounds on unit arm or leg)
- Direct control on light shading
Syntax:
Every armor ruleset have new field "recolorScript" in "armors".
recolorScript: |
#this script is used to recolor solders hair/face colors based on nationality
get_color r0 in;
get_shade r1 in;
test r0 color_hair;
skip_eq hair;
test r0 color_face;
skip_eq face;
ret in;
hair:
add r1 soldier_hair;
ret r1;
face:
add r1 soldier_face;
ret r1;
Syntax based on assembler, every line contains
label: op arg0 arg1 arg2 arg3;
label is optional and number of args depends on op.
#"Reg" is one of: "r0", "r1", "r2", "r3", "in"
#"Data" can be Reg, const value (eg "-1", "0x1F"), data from unit
#"Label" is label defined somewhere in script
#"in" reg have value of current pixel
exit; #exit script, value retunded will be from reg "in"
ret Data; #exit with value
ret_gt Data; #exit with value if test is greater
ret_lt Data; #exit with value if test is less
ret_eq Data; #exit with value if test is equal
ret_neq Data; #exit with value if test is not equal
skip Label; #skip to label
skip_gt Label; #skip to label if test is greater
skip_lt Label; #skip to label if test is less
skip_eq Label; #skip to label if test is equal
skip_neq Label; #skip to label if test is not equal
set Reg Data; #set reg
set_gt Reg Data; #set reg if test is greater
set_lt Reg Data; #set reg if test is less
set_eq Reg Data; #set reg if test is equal
set_neq Reg Data; #set reg if test is not equal
Test Data Data; #test two values
swap Reg Reg; #swap value of two regs
add Reg Data; #add value to reg
sub Reg Data; #subtract value from reg
mul Reg Data; #multiple value of reg
muladd Reg Data Data; #multiple and add in one opeartion
muladdmod Reg Data Data Data; # Reg = (Reg * D1 + D2) % D3
wavegen_rect Reg Data Data Data; #create repeating sequence, args: x, period, rect width, rect height
wavegen_saw Reg Data Data Data; #create repeating sequence, args: x, period, sawtooth width, sawtooth cut out height
wavegen_tri Reg Data Data Data; #create repeating sequence, args: x, period, triangle width, triangle cut out height
div Reg Data; #division reg by value
mod Reg Data; #modulo reg by value
shl Reg Data; #left shift reg by value
shr Reg Data; #right shift reg by value
get_color Reg Data; #extract pixel color form value to reg
set_color Reg Data; #set pixel color in reg to value
get_shade Reg Data; #extract pixel shade form value to reg
set_shade Reg Data; #set pixel shade in reg to value
add_shade Reg Data; #add value to pixel shade in reg
All available data for script:
#enum
blit_part #what sprite part is now edited
#posible values:
blit_torso
blit_leftarm
blit_rightarm
blit_legs
blit_collapse #dying animation and corpse on ground
blit_inventory #corpse in inventory screen
anim_frame #number of current frame
shade #0 - light, 16 - dark
health
health_max
energy
energy_max
stun
stun_max
morale
morale_max
fatalwounds #sum of fatalwounds
fatalwounds_head
fatalwounds_torso
fatalwounds_leftarm
fatalwounds_rightarm
fatalwounds_leftleg
fatalwounds_rightleg
armor_front
armor_left
armor_right
armor_rear
armor_under
unit_id
unit_rank
unit_float #is floating
unit_kneel #is kneeling
soldier_hair #solder hair color based on soldier_look
soldier_face #solder face color based on soldier_look
#enum
soldier_look #current solder look
#posible values:
soldier_look_blonde
soldier_look_brownhair
soldier_look_oriental
soldier_look_african
#enum
soldier_grender #current solder grender
#posible values:
soldier_grender_male
soldier_grender_female
#const colors
color_hair #color group of hair color in solder sprite
color_face #color group of hair color in solder sprite
color_null
color_yellow
color_red
color_green0
color_green1
color_gray
color_brown0 #equal color_face
color_blue0
color_blue1
color_brown1 #equal color_face
color_brown2
color_purple0
color_purple1
color_blue2
color_silver
color_special
Possible future extensions:
Recolor scripts for weapons.
Recolor scripts for paperdoll in inventory.
Use script for selecting different sprite index e.g.:
spriteScript: |
test blit_part blit_torso;
ret_neq in;
test soldier_grender soldier_grender_female;
ret_neq in;
ret sprite_female_torso;