{$CLEO}

{
    Mod Name:   GTA VCS HUD v1.5
    Author:     Henrique Nunes - h3nr1qu3
    Credits:    Wesser for Windshield GUI
                Demarest
                Silent
}

03A4: name_thread 'hud' 

const
   SX                = 0@ 
   MAX_BREATH_LVL    = 1@  
   BREATH_LVL        = 2@ 
   MAX_PL_HEALTH     = 3@ 
   CURRENT_WEAP      = 4@ 
   WEAP_AMMO         = 5@ 
   CURRENT_SLOT      = 6@ 
   AMMO_CLIP         = 7@ 
   AMMO_OTH          = 8@ 
   WEAP_SEL          = 9@ 
   WEAP_MODEL        = 10@ 
   WANTED_LVL        = 11@ 
   CUR_HOURS         = 12@ 
   CUR_MINS          = 13@ 
   MAX_AMMO_CLIP     = 14@ 
   BOOL_BITS         = 15@ // Saved MUCH memory space for that 'true' 'false' variables
   PL_VEHICLE        = 16@
   TIMER             = 17@
   CURRENT_ZONE_CRC  = 18@
   LAST_ZONE_CRC     = 19@
   ZONE_ALPHA        = 20@
   ZONE_TIMER        = 21@
   CARNAME_ALPHA     = 22@
   CARNAME_TIMER     = 23@
   CURRENT_RADIO_STA = 24@
   LAST_RADIO_STA    = 25@
   RADIO_ALPHA       = 26@
   RADIO_TIMER       = 27@
   CURRENT_MONEY     = 28@
   PL_HEALTH         = 29@
   PL_ARMOUR         = 30@
   MAX_PL_ARMOUR     = 31@
   
   // -----------
   
   IS_IN_WIDESCREEN  = 0 // Bit IDs - easier to understand using constants than raw integers
   IS_IN_CUTSCENE    = 1
   IS_HUD_ENABLED    = 2
   IS_WEAP_FOUND     = 3 
   CARNAME_SHOWN     = 4
   
   // -----------
   
   REQUESTED_ZONE_DELAY_TIME    = 10000 // in ms
   REQUESTED_CARNAME_DELAY_TIME = 10000
   REQUESTED_RADIO_DELAY_TIME   = 3000
   REQUESTED_MONEY_DELAY_TIME   = 3000
   REQUESTED_FADEOUT_SPEED      = 15   // not in ms
end

if
    8AAB: not file_exists "MODELS\TXD\VCSHUD.TXD" 
then 
    0ACA: show_text_box "VCS HUD MOD: vcshud.txd wasn't found in models/txd folder, this mod won't work without this file." 
    0A93: end_custom_thread 
end
   
0ADF: add_dynamic_GXT_entry "HUD_AM"  text "~1~-~1~"
0ADF: add_dynamic_GXT_entry "FEA_R0"  text ""
0ADF: add_dynamic_GXT_entry "FEA_R1"  text ""
0ADF: add_dynamic_GXT_entry "FEA_R2"  text ""
0ADF: add_dynamic_GXT_entry "FEA_R3"  text ""
0ADF: add_dynamic_GXT_entry "FEA_R4"  text ""
0ADF: add_dynamic_GXT_entry "FEA_R5"  text ""
0ADF: add_dynamic_GXT_entry "FEA_R6"  text ""
0ADF: add_dynamic_GXT_entry "FEA_R7"  text ""
0ADF: add_dynamic_GXT_entry "FEA_R8"  text ""
0ADF: add_dynamic_GXT_entry "FEA_R9"  text ""
0ADF: add_dynamic_GXT_entry "FEA_R10" text ""
0ADF: add_dynamic_GXT_entry "FEA_MP3" text ""
0ADF: add_dynamic_GXT_entry "FEA_NON" text ""
0ADF: add_dynamic_GXT_entry "PLAY"    text "Playback FM"
0ADF: add_dynamic_GXT_entry "KROS"    text "K Rose"
0ADF: add_dynamic_GXT_entry "WCTR"    text "WCTR"
0ADF: add_dynamic_GXT_entry "KDST"    text "K-DST"
0ADF: add_dynamic_GXT_entry "BOUN"    text "Bounce FM"
0ADF: add_dynamic_GXT_entry "SFUR"    text "SF-UR"
0ADF: add_dynamic_GXT_entry "RLS"     text "Radio Los Santos"
0ADF: add_dynamic_GXT_entry "RADX"    text "Radio X"
0ADF: add_dynamic_GXT_entry "CSR"     text "CSR 103.9"
0ADF: add_dynamic_GXT_entry "KJAH"    text "K-Jah West"
0ADF: add_dynamic_GXT_entry "MSOU"    text "Master Sounds 98.3"
0ADF: add_dynamic_GXT_entry "USTP"    text "User Track Player"
0ADF: add_dynamic_GXT_entry "ROFF"    text "Radio Off"
0ADF: add_dynamic_GXT_entry "PICON"   text "+"
0ADF: add_dynamic_GXT_entry "CASH7"   text "$0000000~1~"
0ADF: add_dynamic_GXT_entry "CASH6"   text "$000000~1~"
0ADF: add_dynamic_GXT_entry "CASH5"   text "$00000~1~"
0ADF: add_dynamic_GXT_entry "CASH4"   text "$0000~1~"
0ADF: add_dynamic_GXT_entry "CASH3"   text "$000~1~"
0ADF: add_dynamic_GXT_entry "CASH2"   text "$00~1~"
0ADF: add_dynamic_GXT_entry "CASH1"   text "$0~1~"
0ADF: add_dynamic_GXT_entry "CASH0"   text "$~1~"
0ADF: add_dynamic_GXT_entry "DEAD"    text ""
0ADF: add_dynamic_GXT_entry "WAST"    text "WASTED!"
0ADF: add_dynamic_GXT_entry "BUSTED"  text ""
0ADF: add_dynamic_GXT_entry "BUST"    text "BUSTED!"
0ADF: add_dynamic_GXT_entry "TIME_1"  text "0~1~:0~1~"
0ADF: add_dynamic_GXT_entry "TIME_2"  text "0~1~:~1~"

0A8C: write_memory 0xBAB258 size 4 value 0xFFB181E9 virtual_protect 0 // value is the RGBA backwards
0A8C: write_memory 0xBAB234 size 4 value 0xFFCF984B virtual_protect 0 // value is the RGBA backwards
0A8C: write_memory 0xBAB260 size 4 value 0xFF7E2624 virtual_protect 0 // value is the RGBA backwards
0A8C: write_memory 0xBAB22C size 4 value 0xFF0000A6 virtual_protect 0 // value is the RGBA backwards
0A8C: write_memory 0xBAB23C size 4 value 0xFFFFFFFF virtual_protect 0 // value is the RGBA backwards
0A8C: write_memory 0xBAB248 size 4 value 0xFFFCFC1E virtual_protect 0 // value is the RGBA backwards

01BD: ZONE_TIMER = current_time_in_ms    

gosub @LoadTxdDictionary 

while true
    wait 0 
    gosub @RemoveOnScreenTexts 
    gosub @WideScreenCheck 
    gosub @CutsceneCheck 
    gosub @HudEnabledCheck 
    
    if or
        08B7:   test BOOL_BITS bit IS_IN_WIDESCREEN 
        08B7:   test BOOL_BITS bit IS_IN_CUTSCENE 
        88B7:   not test BOOL_BITS bit IS_HUD_ENABLED 
    then
        03F0: enable_text_draw 0      
    else
        03F0: enable_text_draw 1 
        
        gosub @HealthBarDisplay
        gosub @ArmourBarDisplay        
        gosub @BreathBarDisplay 
        gosub @WeapAmmoDisplay 
        gosub @WeapIconDisplay 
        gosub @WantedStarDisplay 
        gosub @MoneyTextDisplay 
        gosub @TimeTextDisplay 
        gosub @DrawRadioText
        gosub @VehicleTextDisplay 
        gosub @DrawTownText
        gosub @DrawWastedText
        gosub @DrawBustedText    
    end 
end

:WideScreenCheck
0A8D: 0@ = read_memory 0xB6F065 size 1 virtual_protect 0 
if 
    0039:   0@ == 1 
then
    08BD: set BOOL_BITS bit IS_IN_WIDESCREEN
else
    08C3: clear BOOL_BITS bit IS_IN_WIDESCREEN
end
return 

:CutsceneCheck
if 
    06B9:   cutscene_data_loaded 
then
    if 
        82E9:   not cutscene_reached_end
    then
        08BD: set BOOL_BITS bit IS_IN_CUTSCENE 
    end
else
    08C3: clear BOOL_BITS bit IS_IN_CUTSCENE
end
return 

:HudEnabledCheck
0A8D: 0@ = read_memory 0xBA6769 size 1 virtual_protect 0 // Was 'size 4' earlier == could cause bugs :/
if 
    0039:   0@ == 0
then
    08C3: clear BOOL_BITS bit IS_HUD_ENABLED
else
    08BD: set BOOL_BITS bit IS_HUD_ENABLED
end
return 

:HealthBarDisplay
gosub @GetPlayerHealth 
gosub @DrawHealthBar 
return 

:GetPlayerHealth
PL_HEALTH = Actor.Health($PLAYER_ACTOR)
0093: PL_HEALTH  = integer PL_HEALTH to_float 
0653: MAX_PL_HEALTH = float_stat 24 
0017: MAX_PL_HEALTH /= 5.69
0073: PL_HEALTH /= MAX_PL_HEALTH
0013: PL_HEALTH *= 100.0
0092: PL_HEALTH = float PL_HEALTH to_integer
0092: MAX_PL_HEALTH = float MAX_PL_HEALTH to_integer
return 

:DrawHealthBar
if
    0019: MAX_PL_HEALTH > 100
then
    03E0: draw_text_behind_textures 1
    0349: set_text_draw_font 3
    033F: set_text_draw_letter_size 0.8 4.2
    0340: set_text_draw_RGBA 255 255 255 255
    081C: draw_text_outline 1 RGBA 0 0 0 255 
    033E: set_draw_text_position 495.0 52.0 GXT "PICON"
end
if
    0019: PL_HEALTH > 100
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 49 position 515.5 74.5 size 72.5 16.7 RGBA 255 255 255 255
end
if and
   002B: 100 >= PL_HEALTH
   0029: PL_HEALTH >= 91 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 49 position 515.5 74.5 size 72.5 16.7 RGBA 255 255 255 255  
end
if and
   002B: 90 >= PL_HEALTH 
   0029: PL_HEALTH >= 81  
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 50 position 515.5 74.5 size 72.0 16.7 RGBA 255 255 255 255  
end
if and
   002B: 80 >= PL_HEALTH 
   0029: PL_HEALTH >= 71
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 51 position 515.5 74.5 size 72.0 16.7 RGBA 255 255 255 255  
end
if and
   002B: 70 >= PL_HEALTH
   0029: PL_HEALTH >= 61 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 52 position 515.5 74.5 size 72.0 16.7 RGBA 255 255 255 255  
end
if and
   002B: 60 >= PL_HEALTH 
   0029: PL_HEALTH >= 51 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 53 position 515.5 74.5 size 72.0 16.7 RGBA 255 255 255 255  
end
if and
   002B: 50 >= PL_HEALTH 
   0029: PL_HEALTH >= 41 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 54 position 515.5 74.5 size 72.0 16.7 RGBA 255 255 255 255  
end
if and
   002B: 40 >= PL_HEALTH 
   0029: PL_HEALTH >= 31 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 55 position 515.5 74.5 size 72.0 16.7 RGBA 255 255 255 255  
end
if and
   002B: 30 >= PL_HEALTH 
   0029: PL_HEALTH >= 21 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 56 position 515.5 74.5 size 72.0 16.7 RGBA 255 255 255 255  
end
if and
   002B: 20 >= PL_HEALTH 
   0029: PL_HEALTH >= 11
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 57 position 515.5 74.5 size 72.0 16.7 RGBA 255 255 255 255  
end
if and
   002B: 10 >= PL_HEALTH
   0029: PL_HEALTH >= 6 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 58 position 515.5 74.5 size 72.0 16.7 RGBA 255 255 255 255  
end
if and
   002B: 5 >= PL_HEALTH
   0029: PL_HEALTH >= 1 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 59 position 515.5 74.5 size 72.0 16.7 RGBA 255 255 255 255  
end
if
    0039: PL_HEALTH == 0 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 60 position 515.5 74.5 size 72.0 16.7 RGBA 255 255 255 255
end 
return 

:ArmourBarDisplay
gosub @GetPlayerArmour 
gosub @DrawArmourBar 
return 

:GetPlayerArmour
04DD: PL_ARMOUR = actor $PLAYER_ACTOR armour 
0945: get_player 0 max_armour_to MAX_PL_ARMOUR
0093: PL_ARMOUR = integer PL_ARMOUR to_float 
0093: MAX_PL_ARMOUR = integer MAX_PL_ARMOUR to_float
0073: PL_ARMOUR /= MAX_PL_ARMOUR
0013: PL_ARMOUR *= 100.0
0092: PL_ARMOUR = float PL_ARMOUR to_integer
0092: MAX_PL_ARMOUR = float MAX_PL_ARMOUR to_integer
return 

:DrawArmourBar
if
    8965: not actor $PLAYER_ACTOR swimming 
then
if and
    0019: MAX_PL_ARMOUR > 100
    0019: PL_ARMOUR > 0
then
    03E0: draw_text_behind_textures 1
    0349: set_text_draw_font 3
    033F: set_text_draw_letter_size 0.8 4.2 
    0340: set_text_draw_RGBA 255 255 255 255
    081C: draw_text_outline 1 RGBA 0 0 0 255 
    033E: set_draw_text_position 495.0 32.7 GXT "PICON"
end
if
    0019: PL_ARMOUR > 100
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 61 position 515.5 55.0 size 72.5 16.7 RGBA 255 255 255 255
end
if and
   002B: 100 >= PL_ARMOUR
   0029: PL_ARMOUR >= 91 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 61 position 515.5 55.0 size 72.5 16.7 RGBA 255 255 255 255
end
if and
   002B: 90 >= PL_ARMOUR
   0029: PL_ARMOUR >= 81 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 62 position 515.5 55.0 size 72.0 16.7 RGBA 255 255 255 255
end
if and
   002B: 80 >= PL_ARMOUR
   0029: PL_ARMOUR >= 71 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 63 position 515.5 55.0 size 72.0 16.7 RGBA 255 255 255 255
end
if and
   002B: 70 >= PL_ARMOUR
   0029: PL_ARMOUR >= 61 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 64 position 515.5 55.0 size 72.0 16.7 RGBA 255 255 255 255
end
if and
   002B: 60 >= PL_ARMOUR
   0029: PL_ARMOUR >= 51 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 65 position 515.5 55.0 size 72.0 16.7 RGBA 255 255 255 255
end
if and
   002B: 50 >= PL_ARMOUR
   0029: PL_ARMOUR >= 41 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 66 position 515.5 55.0 size 72.0 16.7 RGBA 255 255 255 255
end
if and
   002B: 40 >= PL_ARMOUR
   0029: PL_ARMOUR >= 31 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 67 position 515.5 55.0 size 72.0 16.7 RGBA 255 255 255 255
end
if and
   002B: 30 >= PL_ARMOUR
   0029: PL_ARMOUR >= 21 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 68 position 515.5 55.0 size 72.0 16.7 RGBA 255 255 255 255
end
if and
   002B: 20 >= PL_ARMOUR
   0029: PL_ARMOUR >= 11 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 69 position 515.5 55.0 size 72.0 16.7 RGBA 255 255 255 255
end
if and
   002B: 10 >= PL_ARMOUR
   0029: PL_ARMOUR >= 6
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 70 position 515.5 55.0 size 72.0 16.7 RGBA 255 255 255 255
end
if and
   002B: 5 >= PL_ARMOUR
   0029: PL_ARMOUR >= 1 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 71 position 515.5 55.0 size 72.0 16.7 RGBA 255 255 255 255
end
end
return 

:BreathBarDisplay
gosub @GetPlayerBreath 

if  and
    BREATH_LVL > 0 
    0965:   actor $PLAYER_ACTOR swimming 
then
    gosub @GetPlayerMaxBreath 
    gosub @GetBreathMath 
    gosub @DrawBreathBar 
end
return 

:GetPlayerBreath
0652: BREATH_LVL = integer_stat 4080 

:GetPlayerMaxBreath
0653: MAX_BREATH_LVL = float_stat 225 
MAX_BREATH_LVL *= 1.5 
MAX_BREATH_LVL += 1150.0 
return 

:GetBreathMath
SX = 100.0 
if 
    0025:   MAX_BREATH_LVL > BREATH_LVL // (float) 
then
    0073: MAX_BREATH_LVL /= BREATH_LVL // (float) 
    0073: SX /= MAX_BREATH_LVL // (float) 
    0087: BREATH_LVL = SX // (float) 
    0017: BREATH_LVL /= 2.0 
end
0092: SX = float SX to_integer 
return 

:DrawBreathBar
if
    0965: actor $PLAYER_ACTOR swimming 
then
if and
     100 >= SX
     SX >= 91
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 61 position 515.5 55.0 size 72.5 16.7 RGBA 5 30 110 255
end
if and
     90 >= SX
     SX >= 81 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 62 position 515.5 55.0 size 72.0 16.7 RGBA 5 30 110 255
end
if and
    80 >= SX
    SX >= 71 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 63 position 515.5 55.0 size 72.0 16.7 RGBA 5 30 110 255
end
if and
    70 >= SX
    SX >= 61 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 64 position 515.5 55.0 size 72.0 16.7 RGBA 5 30 110 255
end
if and
    60 >= SX
    SX >= 51 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 65 position 515.5 55.0 size 72.0 16.7 RGBA 5 30 110 255
end
if and
    50 >= SX
    SX >= 41 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 66 position 515.5 55.0 size 72.0 16.7 RGBA 5 30 110 255
end
if and
    40 >= SX
    SX >= 31 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 67 position 515.5 55.0 size 72.0 16.7 RGBA 5 30 110 255
end
if and
    30 >= SX
    SX >= 21 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 68 position 515.5 55.0 size 72.0 16.7 RGBA 5 30 110 255
end
if and
    20 >= SX
    SX >= 11 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 69 position 515.5 55.0 size 72.0 16.7 RGBA 5 30 110 255
end
if and
    10 >= SX
    SX >= 6
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 70 position 515.5 55.0 size 72.0 16.7 RGBA 5 30 110 255
end
if and
    5 >= SX
    SX >= 1 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 71 position 515.5 55.0 size 72.0 16.7 RGBA 5 30 110 255
end
end
return  

:WeapAmmoDisplay
gosub @GetCurrentWeap 

if and
    0019:   CURRENT_WEAP > 15 
    8039:   not CURRENT_WEAP == 40 
    8019:   not CURRENT_WEAP > 43 
then
    gosub @GetCurrentWeapAmmo 
    
    if or
        0039:   CURRENT_WEAP == 16
        0039:   CURRENT_WEAP == 17
        0039:   CURRENT_WEAP == 18
        0039:   CURRENT_WEAP == 25
        0039:   CURRENT_WEAP == 35
        0039:   CURRENT_WEAP == 36
        0039:   CURRENT_WEAP == 39
    then
        gosub @DrawWeapAmmoOne 

    else
        gosub @GetCurrentSlot 
        
        0A96: 0@ = actor $PLAYER_ACTOR struct 
        000A: 0@ += 0x5A0 
        0012: CURRENT_SLOT *= 0x1C 
        005A: 0@ += CURRENT_SLOT // (int) 
        000A: 0@ += 0x8 
        0A8D: AMMO_CLIP = read_memory 0@ size 4 virtual_protect 0 // GetAmmoClip
        0062: WEAP_AMMO -= AMMO_CLIP // (int) 
        0085: AMMO_OTH = WEAP_AMMO // (int) 
        gosub @DrawWeapAmmoTwo 
        
    end
end
return 

:DrawWeapAmmoOne
0341: set_text_draw_align_justify 0 
03E4: enable_text_draw_align_right 1
03E0: draw_text_behind_textures 1
0340: set_text_draw_RGBA 255 255 255 255 
033F: set_text_draw_letter_size 0.2 1.5 
045A: draw_text_1number 603.0 66.0 GXT "NUMBER" number WEAP_AMMO  // ~1~
return 

:DrawWeapAmmoTwo
0341: set_text_draw_align_justify 0 
03E4: enable_text_draw_align_right 1
03E0: draw_text_behind_textures 1
0340: set_text_draw_RGBA 255 255 255 255 
033F: set_text_draw_letter_size 0.2 1.5 
045B: draw_text_2numbers 603.0 66.0 GXT "HUD_AM" numbers AMMO_OTH AMMO_CLIP  // ~1~-~1~
return 

:WeapIconDisplay
gosub @GetCurrentWeap 
gosub @RemoveWeap 
gosub @WeapFoundCheck 
gosub @DrawWeapIcon 
return 

:DrawWeapIcon
000A: CURRENT_WEAP += 1
03E3: set_texture_to_be_drawn_antialiased 1 
038D: draw_texture CURRENT_WEAP position 590.0 60.7 size 72.0 72.0 RGBA 255 255 255 230 

:GetAllWeapData
04B8: get_weapon_data_from_actor $PLAYER_ACTOR weapon_group CURRENT_SLOT weapon WEAP_SEL ammo WEAP_AMMO model WEAP_MODEL 
return 

:RemoveWeap
gosub @GetCurrentWeap 

0085: 0@ = CURRENT_WEAP // (int) 
0012: 0@ *= 0x70 
000A: 0@ += 0xC8AAB8 
000A: 0@ += 0x20 
0A8D: MAX_AMMO_CLIP = read_memory 0@ size 4 virtual_protect 0 
return 

:WeapFoundCheck
if 
    803B:   not CURRENT_WEAP == WEAP_SEL // (int) 
then
    08BD: set BOOL_BITS bit IS_WEAP_FOUND
else
    08C3: clear BOOL_BITS bit IS_WEAP_FOUND
end
return 

:GetCurrentWeap
0470: CURRENT_WEAP = actor $PLAYER_ACTOR current_weapon 
return 

:GetCurrentWeapAmmo
041A: WEAP_AMMO = actor $PLAYER_ACTOR weapon CURRENT_WEAP ammo 
return 

:GetCurrentSlot
0A96: 0@ = actor $PLAYER_ACTOR struct 
000A: 0@ += 0x718 
0A8D: CURRENT_SLOT = read_memory 0@ size 1 virtual_protect 0 
return 

:WantedStarDisplay
gosub @GetCurrentWantedlvl 
gosub @DrawWantedStar 
return 

:GetCurrentWantedlvl
01C0: WANTED_LVL = player 0 wanted_level 
return 

:DrawWantedStar
if 
    0019:   WANTED_LVL > 0 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 48 position 596.5 110.0 size 17.25 16.0 RGBA 255 255 255 255
end
if 
    0019:   WANTED_LVL > 1 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 48 position 579.25 110.0 size 17.25 16.0 RGBA 255 255 255 255  
end
if 
    0019:   WANTED_LVL > 2 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 48 position 562.0 110.0 size 17.25 16.0 RGBA 255 255 255 255  
end
if 
    0019:   WANTED_LVL > 3 
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 48 position 544.75 110.0 size 17.25 16.0 RGBA 255 255 255 255  
end
if 
    0019:   WANTED_LVL > 4
then
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 48 position 527.5 110.0 size 17.25 16.0 RGBA 255 255 255 255  
end
if 
    0019:   WANTED_LVL > 5 
then 
    03E3: set_texture_to_be_drawn_antialiased 1 
    038D: draw_texture 48 position 510.25 110.0 size 17.25 16.0 RGBA 255 255 255 255  
end
return 

:MoneyTextDisplay
010B: CURRENT_MONEY = player 0 money 
if 
    0019:   CURRENT_MONEY > -1
then
    0340: set_text_draw_RGBA 32 110 32 255 
else

    0340: set_text_draw_RGBA 171 139 140 255 
    0012: CURRENT_MONEY *= -1
end
gosub @DrawMoneyText 
return 

:DrawMoneyText
03E0: draw_text_behind_textures 1
033F: set_text_draw_letter_size 0.55 2.3 
0349: set_text_draw_font 3
03E4: set_text_draw_align_right 1 
081C: draw_text_outline 2 RGBA 0 0 0 255
if and
    0029:   CURRENT_MONEY >= 0
    002B:   9 >= CURRENT_MONEY
then
    045A: draw_text_1number 606.0 82.0 GXT "CASH7" number CURRENT_MONEY 
end
if and
    0029:   CURRENT_MONEY >= 9
    002B:   99 >= CURRENT_MONEY
then
    045A: draw_text_1number 606.0 82.0 GXT "CASH6" number CURRENT_MONEY 
end
if and
    0029:   CURRENT_MONEY >= 99
    002B:   999 >= CURRENT_MONEY
then
    045A: draw_text_1number 606.0 82.0 GXT "CASH5" number CURRENT_MONEY 
end
if and
    0029:   CURRENT_MONEY >= 999
    002B:   9999 >= CURRENT_MONEY
then
    045A: draw_text_1number 606.0 82.0 GXT "CASH4" number CURRENT_MONEY 
end
if and
    0029:   CURRENT_MONEY >= 9999
    002B:   99999 >= CURRENT_MONEY
then
    045A: draw_text_1number 606.0 82.0 GXT "CASH3" number CURRENT_MONEY 
end
if and
    0029:   CURRENT_MONEY >= 99999
    002B:   999999 >= CURRENT_MONEY
then
    045A: draw_text_1number 606.0 82.0 GXT "CASH2" number CURRENT_MONEY 
end
if and
    0029:   CURRENT_MONEY >= 999999
    002B:   9999999 >= CURRENT_MONEY
then
    045A: draw_text_1number 606.0 82.0 GXT "CASH1" number CURRENT_MONEY 
end
if 
    0029:   CURRENT_MONEY >= 9999999
then
    045A: draw_text_1number 606.0 82.0 GXT "CASH0" number CURRENT_MONEY 
end
return 

:TimeTextDisplay
00BF: CUR_HOURS = current_time_hours, CUR_MINS = current_time_minutes 
if and
    0029:   CUR_HOURS >= 10   
    001B:   10 > CUR_MINS 
then
    gosub @DrawTimeTextOne 
end
if and
    0029:   CUR_MINS >= 10
    0029:   CUR_HOURS >= 10
then  
    gosub @DrawTimeTextTwo 
end
if and 
    001B:   10 > CUR_MINS
    001B:   10 > CUR_HOURS
then
    gosub @DrawTimeTextThree
end
if and
    001B:   10 > CUR_HOURS
    0029:   CUR_MINS >= 10 
then
    gosub @DrawTimeTextFour
end        
return 

:DrawTimeTextOne
03E0: draw_text_behind_textures 1
033F: set_text_draw_letter_size 0.55 2.25 
0342: set_text_draw_centered 1 
081C: draw_text_outline 2 RGBA 0 0 0 255
0349: set_text_draw_font 3
0340: set_text_draw_RGBA 193 140 44 255
045B: draw_text_2numbers 525.0 23.0 GXT "TIME_0" numbers CUR_HOURS CUR_MINS  // ~1~:0~1~
return 

:DrawTimeTextTwo
03E0: draw_text_behind_textures 1 
033F: set_text_draw_letter_size 0.55 2.25  
0342: set_text_draw_centered 1
081C: draw_text_outline 2 RGBA 0 0 0 255
0349: set_text_draw_font 3
0340: set_text_draw_RGBA 193 140 44 255
045B: draw_text_2numbers 525.0 23.0 GXT "TIME" numbers CUR_HOURS CUR_MINS  // ~1~:~1~
return 

:DrawTimeTextThree
03E0: draw_text_behind_textures 1
033F: set_text_draw_letter_size 0.55 2.25 
0342: set_text_draw_centered 1 
081C: draw_text_outline 2 RGBA 0 0 0 255
0349: set_text_draw_font 3
0340: set_text_draw_RGBA 193 140 44 255
045B: draw_text_2numbers 525.0 23.0 GXT "TIME_1" numbers CUR_HOURS CUR_MINS  // 0~1~:0~1~
return

:DrawTimeTextFour
03E0: draw_text_behind_textures 1 
033F: set_text_draw_letter_size 0.55 2.25  
0342: set_text_draw_centered 1
081C: draw_text_outline 2 RGBA 0 0 0 255
0349: set_text_draw_font 3
0340: set_text_draw_RGBA 193 140 44 255
045B: draw_text_2numbers 525.0 23.0 GXT "TIME_2" numbers CUR_HOURS CUR_MINS  // 0~1~:~1~
return 

:DrawRadioText
if and 
    00DF:   actor $PLAYER_ACTOR driving 
    856C:   not actor $PLAYER_ACTOR driving_police_car 
    89AE:   not actor $PLAYER_ACTOR driving_train 
    80DD:   not actor $PLAYER_ACTOR driving_car_with_model #AMBULAN 
    80DD:   not actor $PLAYER_ACTOR driving_car_with_model #BIKE 
    80DD:   not actor $PLAYER_ACTOR driving_car_with_model #MTBIKE
    80DD:   not actor $PLAYER_ACTOR driving_car_with_model #BMX
then
    051E: CURRENT_RADIO_STA = get_current_radio_station
    if
        803B:   not LAST_RADIO_STA == CURRENT_RADIO_STA // (int)
    then
        01BD: RADIO_TIMER = current_time_in_ms  
        0085: LAST_RADIO_STA = CURRENT_RADIO_STA // (int)  
    end      
    01BD: $CURRENT_TIME_IN_MS = current_time_in_ms 
    0A8F: TIMER = $CURRENT_TIME_IN_MS - RADIO_TIMER // (int)
    if   0019:   TIMER > REQUESTED_RADIO_DELAY_TIME 
    then 0006: RADIO_ALPHA = 0
    else 0006: RADIO_ALPHA = 255
    end
    if
        88FE:   not text_box_displayed
    then
        03E0: draw_text_behind_textures 1 
        033F: set_text_draw_letter_size 1.1 4.9
        060D: draw_text_shadow 3 color_RGBA 0 0 0 RADIO_ALPHA
        0340: set_text_draw_RGBA 70 140 190 RADIO_ALPHA
        0342: set_text_draw_centered 1 
        0349: set_text_draw_font 0
        0871: init_jump_table CURRENT_RADIO_STA total_jumps 13 default_jump 0 @RadioStationEnd jumps 0 @PLAY 1 @KROS 2 @KDST 3 @BOUN 4 @SFUR 5 @RLS 6 @RADX  
        0872: jump_table_jumps 7 @CSR 8 @KJAH 9 @MSOU 10 @WCTR 11 @USTP 12 @ROFF -1 @RadioStationEnd -1 @RadioStationEnd -1 @RadioStationEnd
        
        :PLAY
        033E: set_draw_text_position 320.0 5.0 GXT "PLAY" // Playback FM  
        jump @RadioStationEnd
        
        :KROS
        033E: set_draw_text_position 320.0 5.0 GXT "KROS" // K Rose 
        jump @RadioStationEnd
        
        :KDST
        033E: set_draw_text_position 320.0 5.0 GXT "KDST" // K-DST
        jump @RadioStationEnd
        
        :BOUN
        033E: set_draw_text_position 320.0 5.0 GXT "BOUN" // Bounce FM 
        jump @RadioStationEnd
    
        :SFUR
        033E: set_draw_text_position 320.0 5.0 GXT "SFUR" // SF-UR
        jump @RadioStationEnd
      
        :RLS
        033E: set_draw_text_position 320.0 5.0 GXT "RLS" // Radio Los Santos 
        jump @RadioStationEnd
        
        :RADX
        033E: set_draw_text_position 320.0 5.0 GXT "RADX" // Radio X 
        jump @RadioStationEnd
        
        :CSR
        033E: set_draw_text_position 320.0 5.0 GXT "CSR" // CSR 103.9 
        jump @RadioStationEnd
        
        :KJAH
        033E: set_draw_text_position 320.0 5.0 GXT "KJAH" // K-Jah West
        jump @RadioStationEnd
        
        :MSOU
        033E: set_draw_text_position 320.0 5.0 GXT "MSOU" // Master Sounds 98.3 
        jump @RadioStationEnd
        
        :WCTR
        033E: set_draw_text_position 320.0 5.0 GXT "WCTR" // WCTR
        jump @RadioStationEnd
        
        :USTP
        033E: set_draw_text_position 320.0 5.0 GXT "USTP" // User Track Player 
        jump @RadioStationEnd
        
        :ROFF
        033E: set_draw_text_position 320.0 5.0 GXT "ROFF" // Radio Off 
        
    end
    
    :RadioStationEnd
end    
return

:VehicleTextDisplay
if 
    00DF:   actor $PLAYER_ACTOR driving
then
    if
        88B7:   not test BOOL_BITS bit CARNAME_SHOWN   
    then
        01BD: CARNAME_TIMER = current_time_in_ms 
        08BD: set BOOL_BITS bit CARNAME_SHOWN 
    end
    01BD: $CURRENT_TIME_IN_MS = current_time_in_ms 
    0A8F: TIMER = $CURRENT_TIME_IN_MS - CARNAME_TIMER // (int)
    if   0019:   TIMER > REQUESTED_CARNAME_DELAY_TIME
    then 0006: CARNAME_ALPHA = 0
    else 0006: CARNAME_ALPHA = 255
    end
    0811: PL_VEHICLE = actor $PLAYER_ACTOR car_nosave
    0441: 0@ = car PL_VEHICLE model
    0ADB: 1@v = car_model 0@ name
    if
        876F: not text_priority_displayed 
    then
        03E0: draw_text_behind_textures 0 
        033F: set_text_draw_letter_size 1.1 4.9
        060D: draw_text_shadow 3 color_RGBA 0 0 0 CARNAME_ALPHA
        0340: set_text_draw_RGBA 255 255 255 CARNAME_ALPHA
        0349: set_text_draw_font 0
        03E4: enable_text_draw_align_right 1
        033E: set_draw_text_position 605.0 340.0 GXT 1@s
    end
else
    08C3: clear BOOL_BITS bit CARNAME_SHOWN
end
return 

:DrawTownText
00A0: store_actor $PLAYER_ACTOR position_to 1@ 2@ 3@
0843: get_zone_at 1@ 2@ 3@ nameA_to 1@s // 8-byte string
09A9: get_string 1@v CRC32_to CURRENT_ZONE_CRC // 16-byte strings
if
    803B:   not LAST_ZONE_CRC == CURRENT_ZONE_CRC // (int)
then
    01BD: ZONE_TIMER = current_time_in_ms  
    0085: LAST_ZONE_CRC = CURRENT_ZONE_CRC // (int)  
end 
01BD: $CURRENT_TIME_IN_MS = current_time_in_ms 
0A8F: TIMER = $CURRENT_TIME_IN_MS - ZONE_TIMER // (int)
if 0019:   TIMER > REQUESTED_ZONE_DELAY_TIME
then 000E: ZONE_ALPHA -= REQUESTED_FADEOUT_SPEED
else 0006: ZONE_ALPHA = 255
end
if 
    001B:   0 > ZONE_ALPHA 
then
    0006: ZONE_ALPHA = 0
end        
if 
    05AD:   1@s == "SAN_AND"  // San Andreas
then
    094B: 1@v = get_active_interior_name_from_actor $PLAYER_ACTOR // 16-byte string 
end
if
    876F: not text_priority_displayed 
then
    03E0: draw_text_behind_textures 1 
    033F: set_text_draw_letter_size 1.1 4.9
    060D: draw_text_shadow 3 color_RGBA 0 0 0 ZONE_ALPHA
    0340: set_text_draw_RGBA 255 255 255 ZONE_ALPHA
    03E4: enable_text_draw_align_right 1
    0349: set_text_draw_font 0
    033E: set_draw_text_position 605.0 385.0 GXT 1@s
end
return  

:DrawWastedText
if
    0117: player 0 wasted
then
    03E0: draw_text_behind_textures 1
    033F: set_text_draw_letter_size 1.3 6.3
    060D: draw_text_shadow 3 color_RGBA 0 0 0 255
    0340: set_text_draw_RGBA 10 185 115 230
    0342: set_text_draw_centered 1 
    0349: set_text_draw_font 3
    033E: set_draw_text_position 330.0 125.0 GXT "WAST" // WASTED!
end
return

:DrawBustedText
if
    0741:   actor $PLAYER_ACTOR busted 
then
    03E0: draw_text_behind_textures 1 
    033F: set_text_draw_letter_size 1.3 6.3
    060D: draw_text_shadow 3 color_RGBA 0 0 0 255
    0340: set_text_draw_RGBA 10 185 115 230
    0342: set_text_draw_centered 1 
    0349: set_text_draw_font 3
    033E: set_draw_text_position 330.0 125.0 GXT "BUST" // BUSTED!
end
return

:LoadTxdDictionary
0391: release_textures
0390: load_txd_dictionary "VCSHUD" 
038F: load_texture "FIST" as 1 // Load dictionary with 0390 first 
038F: load_texture "BRASSKNUCKLE" as 2 // Load dictionary with 0390 first 
038F: load_texture "GOLFCLUB" as 3 // Load dictionary with 0390 first 
038F: load_texture "NITESTICK" as 4 // Load dictionary with 0390 first 
038F: load_texture "KNIFECUR" as 5 // Load dictionary with 0390 first 
038F: load_texture "BAT" as 6 // Load dictionary with 0390 first 
038F: load_texture "SHOVEL" as 7 // Load dictionary with 0390 first 
038F: load_texture "POOLCUE" as 8 // Load dictionary with 0390 first 
038F: load_texture "KATANA" as 9 // Load dictionary with 0390 first 
038F: load_texture "CHNSAW" as 10 // Load dictionary with 0390 first 
038F: load_texture "DILDO" as 11 // Load dictionary with 0390 first 
038F: load_texture "DILDO2" as 12 // Load dictionary with 0390 first 
038F: load_texture "VIBE" as 13 // Load dictionary with 0390 first 
038F: load_texture "VIBE2" as 14 // Load dictionary with 0390 first 
038F: load_texture "FLOWERS" as 15 // Load dictionary with 0390 first 
038F: load_texture "CANE" as 16 // Load dictionary with 0390 first 
038F: load_texture "GRENADE" as 17 // Load dictionary with 0390 first 
038F: load_texture "TEARGAS" as 18 // Load dictionary with 0390 first 
038F: load_texture "MOLOTOV" as 19 // Load dictionary with 0390 first 
038F: load_texture "BERETTA" as 23 // Load dictionary with 0390 first 
038F: load_texture "SILENCD" as 24 // Load dictionary with 0390 first 
038F: load_texture "PYTHON" as 25 // Load dictionary with 0390 first 
038F: load_texture "CHROMEGUN" as 26 // Load dictionary with 0390 first 
038F: load_texture "BUDDYSHOT" as 27 // Load dictionary with 0390 first 
038F: load_texture "SHOTGSPA" as 28 // Load dictionary with 0390 first 
038F: load_texture "UZI" as 29 // Load dictionary with 0390 first 
038F: load_texture "MPLNG" as 30 // Load dictionary with 0390 first 
038F: load_texture "AK47" as 31 // Load dictionary with 0390 first 
038F: load_texture "M16" as 32 // Load dictionary with 0390 first 
038F: load_texture "SKORPION" as 33 // Load dictionary with 0390 first 
038F: load_texture "LASER" as 34 // Load dictionary with 0390 first 
038F: load_texture "SNIPER" as 35 // Load dictionary with 0390 first 
038F: load_texture "ROCKETLA" as 36 // Load dictionary with 0390 first 
038F: load_texture "HSEEKER" as 37 // Load dictionary with 0390 first 
038F: load_texture "FLAME" as 38 // Load dictionary with 0390 first 
038F: load_texture "MINIGUN" as 39 // Load dictionary with 0390 first 
038F: load_texture "SATCHEL" as 40 // Load dictionary with 0390 first 
038F: load_texture "BOMB" as 41 // Load dictionary with 0390 first 
038F: load_texture "SPRAYC" as 42 // Load dictionary with 0390 first 
038F: load_texture "FXTING" as 43 // Load dictionary with 0390 first 
038F: load_texture "CAMERA" as 44 // Load dictionary with 0390 first 
038F: load_texture "NVGOGLS" as 45 // Load dictionary with 0390 first 
038F: load_texture "IRGOGLS" as 46 // Load dictionary with 0390 first 
038F: load_texture "PARCHUT" as 47 // Load dictionary with 0390 first 
038F: load_texture "WSTAR" as 48 // Load dictionary with 0390 first 
038F: load_texture "BAR2_10" as 49 // Load dictionary with 0390 first 
038F: load_texture "BAR2_9" as 50 // Load dictionary with 0390 first 
038F: load_texture "BAR2_8" as 51 // Load dictionary with 0390 first 
038F: load_texture "BAR2_7" as 52 // Load dictionary with 0390 first 
038F: load_texture "BAR2_6" as 53 // Load dictionary with 0390 first 
038F: load_texture "BAR2_5" as 54 // Load dictionary with 0390 first 
038F: load_texture "BAR2_4" as 55 // Load dictionary with 0390 first 
038F: load_texture "BAR2_3" as 56 // Load dictionary with 0390 first 
038F: load_texture "BAR2_2" as 57 // Load dictionary with 0390 first 
038F: load_texture "BAR2_1" as 58 // Load dictionary with 0390 first 
038F: load_texture "BAR2_0" as 59 // Load dictionary with 0390 first 
038F: load_texture "BAR2_EMPTY" as 60 // Load dictionary with 0390 first
038F: load_texture "BAR1_10" as 61 // Load dictionary with 0390 first 
038F: load_texture "BAR1_9" as 62 // Load dictionary with 0390 first 
038F: load_texture "BAR1_8" as 63 // Load dictionary with 0390 first 
038F: load_texture "BAR1_7" as 64 // Load dictionary with 0390 first 
038F: load_texture "BAR1_6" as 65 // Load dictionary with 0390 first 
038F: load_texture "BAR1_5" as 66 // Load dictionary with 0390 first 
038F: load_texture "BAR1_4" as 67 // Load dictionary with 0390 first 
038F: load_texture "BAR1_3" as 68 // Load dictionary with 0390 first 
038F: load_texture "BAR1_2" as 69 // Load dictionary with 0390 first 
038F: load_texture "BAR1_1" as 70 // Load dictionary with 0390 first 
038F: load_texture "BAR1_0" as 71 // Load dictionary with 0390 first 
038F: load_texture "BAR1_EMPTY" as 72 // Load dictionary with 0390 first}  
return 

:RemoveOnScreenTexts
09BA: show_entered_zone_name 0 
09B9: show_entered_car_name 0 
0826: enable_hud 0
return