{$CLEO .cs}
{$USE CLEO+}
{$USE INI}
script_name 'hbarclr'
0000: NOP
0AC6: 30@ = label @Colors pointer
//low
0AF0: 1@ = read_int_from_ini_file "cleo\health_bar_color.ini" section "Low" key "R"
0AF0: 2@ = read_int_from_ini_file "cleo\health_bar_color.ini" section "Low" key "G"
0AF0: 3@ = read_int_from_ini_file "cleo\health_bar_color.ini" section "Low" key "B"
0AF0: 4@ = read_int_from_ini_file "cleo\health_bar_color.ini" section "Low" key "A"
0E28: write_struct 30@ offset 0x0 size 1 value 1@
0E28: write_struct 30@ offset 0x1 size 1 value 2@
0E28: write_struct 30@ offset 0x2 size 1 value 3@       
0E28: write_struct 30@ offset 0x3 size 1 value 4@ 
//0AF0: 20@ = read_int_from_ini_file "cleo\health_bar_color.ini" section "Low" key "HealthPercentage"
//0093: 20@ = integer 20@ to_float
20@ = 0.0
//medium
0AF0: 1@ = read_int_from_ini_file "cleo\health_bar_color.ini" section "Medium" key "R"
0AF0: 2@ = read_int_from_ini_file "cleo\health_bar_color.ini" section "Medium" key "G"
0AF0: 3@ = read_int_from_ini_file "cleo\health_bar_color.ini" section "Medium" key "B"
0AF0: 4@ = read_int_from_ini_file "cleo\health_bar_color.ini" section "Medium" key "A"
0E28: write_struct 30@ offset 0x4 size 1 value 1@
0E28: write_struct 30@ offset 0x5 size 1 value 2@
0E28: write_struct 30@ offset 0x6 size 1 value 3@
0E28: write_struct 30@ offset 0x7 size 1 value 4@
0AF0: 21@ = read_int_from_ini_file "cleo\health_bar_color.ini" section "Medium" key "HealthPercentage"
0093: 21@ = integer 21@ to_float
//high
0AF0: 1@ = read_int_from_ini_file "cleo\health_bar_color.ini" section "High" key "R"
0AF0: 2@ = read_int_from_ini_file "cleo\health_bar_color.ini" section "High" key "G"
0AF0: 3@ = read_int_from_ini_file "cleo\health_bar_color.ini" section "High" key "B"
0AF0: 4@ = read_int_from_ini_file "cleo\health_bar_color.ini" section "High" key "A"
0E28: write_struct 30@ offset 0x8 size 1 value 1@
0E28: write_struct 30@ offset 0x9 size 1 value 2@
0E28: write_struct 30@ offset 0xA size 1 value 3@
0E28: write_struct 30@ offset 0xB size 1 value 4@
0AF0: 22@ = read_int_from_ini_file "cleo\health_bar_color.ini" section "High" key "HealthPercentage"
0093: 22@ = integer 22@ to_float

:Do                                                   
wait 0
0D4E: 1@ = struct 0xB7CD98 offset 0x14F size 1
0093: 1@ = integer 1@ to_float
0226: 2@ = actor $PLAYER_ACTOR health  //int
0093: 2@ = integer 2@ to_float
0073: 2@ /= 1@ // (float)
2@ *= 100.0
if and //low
    8045:   not 4@ == 2@  // (float)
    0035:   21@ >= 2@  // (float)       36>=h
    0025:   2@ > 20@  // (float)        h>0
then
    0085: 31@ = 30@ // (int)
    jump @Set
end
if and //medium
    8045:   not 4@ == 2@  // (float)
    0035: 22@ >= 2@
    0025: 2@ > 21@
then
    31@ = 30@ + 0x4  
    jump @Set
end
if and //high
    8045:   not 4@ == 2@  // (float)
    0025: 2@ > 22@
then
    31@ = 30@ + 0x8
    jump @Set
end
jump @Do
:Set
0A8C: write_memory 0x589331 size 4 value 31@ virtual_protect 0
0226: 4@ = actor $PLAYER_ACTOR health  //int
jump @Do
:Colors
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP