HUD_DOC_HANDLE = -1
Hud_process_thread = -1
--Globals
MP_enabled = false
Challenge_tracker_enabled = false
Curr_tracked_challenge_id = -1
Curr_tracked_challenge = { }
INVALID_HANDLE = -1
HUD_KILL_ICON = 0
HUD_DEFEND_ICON = 1
HUD_USE_ICON = 2
HUD_REVIVE_ICON = 3
HUD_LOCATION_ICON = 4
HUD_COOP_ICON = 4
Hud_powers_are_disabled = false
Store_weapon_is_loaded = false ----Global store weapon is loaded...
local HUD_SPRINT_COLOR = { R = 220/255, G = 220/255, B = 220/255}
local HUD_MAP_OBJECTIVE_ICONS = {
[HUD_KILL_ICON] = "ui_hud_map_obj_kill",
[HUD_DEFEND_ICON] = "ui_hud_map_obj_protect",
[HUD_USE_ICON] = "ui_hud_map_obj_use",
[HUD_LOCATION_ICON] = "ui_hud_map_obj_goto",
}
local HUD_INTERACT_USE = 0
local HUD_INTERACT_VEHICLE = 1
local HUD_INTERACT_EQUIP = 2
local HUD_INTERACT_PICKUP = 2
HUD_DIVERSION_METER = 0
HUD_DIVERSION_METER = 1
HUD_DIVERSION_METER = 2
local Input_tracker = -1
local INTERACT_TYPE_STRINGS = {
[HUD_INTERACT_USE] = "Use",
[HUD_INTERACT_VEHICLE] = "Hijack",
[HUD_INTERACT_EQUIP] = "Equip",
[HUD_INTERACT_PICKUP] = "Pickup",
}
Hud_notoriety = {
is_expanded = true,
}
Hud_player_status = {
cash = 0,
bleed_out_health_pct = 1.0,
is_in_satellite_mode = false,
is_controlling_missile = false,
health_recovering = false,
respect_pct = -1,
total_respect = -1,
respect_level = -1,
respect_show_upgrades = false,
respect_is_hidden = false,
orientation = 0,
inventory_disabled = false,
cruise_control_active = -1,
cruise_control_h = -1,
cruise_control_anim = -1,
health_screen_is_fading = false,
}
Hud_cruise_control_hint_data = {
{CTRL_BUTTON_DPAD_DOWN, "HUD_CRUISE_CONTROL_NO_BUTTON", game_get_key_name_for_action("CBA_VDC_CRUISE_CONTROL_B")},
}
--Bar for health around the minimap
local Hud_health_bar = {
percent = -1,
bg_h = 0, fill_h = 0, fill_1_h = 0,
health_decay_anim_h = 0,
health_flash_anim_h = 0,
health_bg_angle_twn_h = 0,
health_fill_angle_twn_h = 0,
level_angles = {
[0] = {fill_start_angle = 6.3, fill_end_angle = 3.142, angle_offset = 0.035}, --180
[1] = {fill_start_angle = 6.3, fill_end_angle = 2.6774, angle_offset = 0.035},
[2] = {fill_start_angle = 6.3, fill_end_angle = 2.2128, angle_offset = 0.035},
[3] = {fill_start_angle = 6.3, fill_end_angle = 1.2836, angle_offset = 0.035},
[4] = {fill_start_angle = 6.3, fill_end_angle = 0.819, angle_offset = 0.035}, --360
},
level = -1,
is_flashing = false,
is_decaying = false,
is_expanded = true, --Whether the meter is expanded or not
timer_fade_out_anim_h = 0, --Animation for waiting for the timer to retract...
}
--Bar for sprint around the minimap
local Hud_sprint_bar = {
percent = -1,
sprint_enabled = true,
is_sprinting = -1,
bg_h = 0, fill_h = 0,
level_angles = {
[0] = {fill_start_angle = 6.3, fill_end_angle = 3.142, angle_offset = 0.035}, --180
[1] = {fill_start_angle = 6.3, fill_end_angle = 2.6774, angle_offset = 0.035},
[2] = {fill_start_angle = 6.3, fill_end_angle = 2.2128, angle_offset = 0.035},
[3] = {fill_start_angle = 6.3, fill_end_angle = 1.2836, angle_offset = 0.035},
[4] = {fill_start_angle = 6.3, fill_end_angle = 0.819, angle_offset = 0.035}, --360
},
level = -1,
is_flashing = false,
is_expanded = true,
timer_fade_out_anim_h = 0, --Animation for waiting for the meter to retract...
}
--Bar for super power charge around the minimap
local Hud_super_bar = {
pulse_anim_h = -1,
pulse_is_playing = false,
percent = -1,
bg_h = 0, fill_h = 0,
super_disabled = false,
super_suppressed = -1,
fill_start_angle = 0,
fill_end_angle = 4.15,
angle_offset = 0.07,
super_strength_h = -1,
super_swap_icon_h = -1,
element_swap_icon_h = -1,
super_swap_anim_h = -1,
super_swap_end_twn_h = -1,
super_swap_start_twn_h = -1,
swap_is_playing = false,
pressure_fill = 0,
pressure_fill_end_angle = 3.147,
pressure_grp = -1,
is_mech = false,
is_ship = false,
current_element = -1
}
local Hud_num_flaps = 0
--Homie call positions for HD and SD
local HUD_HOMIE_CALL_ON_SCREEN_X = 96
local HUD_HOMIE_CALL_OFF_SCREEN_X = -225
local HUD_HOMIE_CALL_Y = 340
local HUD_HOMIE_CALL_ON_SCREEN_X_SD = 48
local HUD_HOMIE_CALL_OFF_SCREEN_X_SD = -225
local HUD_HOMIE_CALL_Y_SD = 240
--Mech hud
local Mech_health_width, Mech_health_height = -1, -1
local Mech_weapon_width, Mech_weapon_height = -1, -1
local Mech_health_is_playing = false
local Mech_weapon_is_playing = false
local Mech_health_meter_img_h = -1
local Mech_health_mask_img_h = -1
local Mech_weapon_meter_img_h = -1
local Mech_weapon_mask_img_h = -1
local Mech_health_anim_h = -1
local Mech_weapon_anim_h = -1
local Mech_grp_h = -1
--Ship Health Hud
local Ship_health_width, Ship_health_height = -1, -1
local Ship_health_is_player = false
local Ship_health_meter_img_h = -1
local Ship_health_mask_img_h = -1
local Ship_health_grp_h = -1;
--Lookup table to match homie names with their images
--Script only gets the images from code
local Hud_homie_call_names = {
["ui_homie_asha"] = "HOMIES_ASHA",
["ui_homie_35_ben"] = "HOMIES_BENKING",
["ui_homie_35_cid"] = "HOMIES_CID",
["ui_homie_35_cyrus"] = "HOMIES_CYRUS",
["ui_homie_35_dane"] = "HOMIES_DANEVOGEL",
["ui_homie_35_dj"] = "HOMIES_DJVETCHILD",
["ui_homie_35_donnie"] = "HOMIES_DONNIE",
["ui_homie_gat"] = "HOMIES_GAT",
["ui_homie_keith"] = "HOMIES_VP",
["ui_homie_kinzie"] = "HOMIES_KINZIE",
["ui_homie_35_lin"] = "HOMIES_LIN",
["ui_homie_35_maero"] = "HOMIES_MAERO",
["ui_homie_matt"] = "HOMIES_MATT",
["ui_homie_josh"] = "HOMIES_NYTEBLAYDE",
["ui_homie_pierce"] = "HOMIES_PIERCE",
["ui_homie_shaundi"] = "HOMIES_SHAUNDI",
["ui_homie_35_shaundi"] = "HOMIES_OLDSHAUNDI",
["ui_homie_35_tanya"] = "HOMIES_TANYA",
["ui_homie_viola"] = "HOMIES_VIOLA",
["ui_homie_35_william"] = "HOMIES_WILLIAMSHARP",
["ui_homie_zinyak"] = "HUD_CALL_ZINYAK",
["ui_homie_35_julius"] = "HOMIES_JULIUS",
--xmas
["ui_homie_santa"] = "DLC2_HOMIE_SANTA_NAME",
["ui_homie_shaundi_future"] = "DLC2_HOMIE_FSHAUNDI_NAME",
["ui_homie_claws"] = "DLC2_HOMIE_CLAWZ_NAME",
["ui_homie_mrs_claus"] = "DLC2_HOMIE_MSCLAUS_NAME",
["ui_homie_gingerbread"] = "DLC2_HOMIE_GINGER_NAME",
--hey ash
["ui_homie_anthony"] = "DLC5_HOMIES_ANTHONY",
["ui_homie_ashly"] = "DLC5_HOMIES_ASH",
["ui_homie_papa"] = "DLC5_HOMIES_PAPA",
--GAT
["ui_homie_dane"] = "HOMIES_DANEVOGEL",
["ui_homie_blackbeard"] = "HOMIES_BLACKBEARD",
["ui_homie_vlad"] = "HOMIES_VLAD",
["ui_homie_shakespeare"] = "HOMIES_SHAKESPEARE",
["ui_homie_jezebel"] = "HOMIES_JEZEBEL",
["ui_homie_kiki"] = "HOMIES_KIKI",
}
local Hud_homie_call = {
grp_h = -1,
homie_img_h = -1,
homie_name_txt = -1,
waveform_images = {},
anim_h = -1,
alpha_twn_h = -1,
waveform_thread_h = -1,
}
local Hud_homie_call_listener = -1
local Cur_audio_id = -1
local Darken_h = -1
local Hud_inventory_hud_state_h = -1
local Hud_scope_state_h = -1
local Is_health_pickup_active = false
local Hud_super_powers = {
[0] = {label = "SUPER_TELEKINESIS_LABEL", bitmap = "ui_hud_inv_power_tele", sfx = "Telekinesis", slot = 8, tint = COLOR_POWER_TELE}, --TELEKINESIS
[1] = {label = "SUPER_GROUNDPOUND_LABEL", bitmap = "ui_hud_inv_power_pound", sfx = "SuperStomp", slot = 9, tint = COLOR_POWER_POUND}, --GROUNDPOUND
[2] = {label = "SUPER_BUFF_LABEL", bitmap = "ui_hud_inv_power_buff", sfx = "SuperStomp", slot = 10, tint = COLOR_POWER_BUFF}, --BUFF
[3] = {label = "SUPER_BLAST_LABEL", bitmap = "ui_hud_inv_power_blast", sfx = "Hadouken", slot = 11, tint = COLOR_POWER_BLAST}, --BLAST
[4] = {label = "SUPER_FORCE_SHIELD_LABEL", bitmap = "ui_hud_inv_power_shield", sfx = "SuperShield", slot = 11, tint = COLOR_POWER_MOVE}, --FORCE_SHIELD
[5] = {label = "SUPER_SPRINT_LABEL", bitmap = "ui_hud_inv_power_move", sfx = "Hadouken", slot = 11, tint = COLOR_POWER_MOVE}, --SPRINT
[6] = {label = "SUPER_JUMP_LABEL", bitmap = "ui_hud_inv_power_jump", sfx = "Hadouken", slot = 11, tint = COLOR_POWER_MOVE}, --JUMP
[7] = {label = "SUPER_DFA_LABEL", bitmap = "ui_hud_inv_power_dfa", sfx = "Hadouken", slot = 11, tint = COLOR_POWER_MOVE}, --DFA
}
Hud_super_reward = {
move_grp = -1,
icon = -1,
txt = -1,
txt2 = -1,
words_anim = -1,
top_anim = -1,
top_twn = -1,
bot_anim = -1,
bot_twn = -1,
in_anim = -1,
in_twn = -1,
out_anim = -1,
out_twn = -1,
circle_bg = -1,
icon_grp = -1,
counter = 0,
is_active = false,
}
--Respect VDO Object
Hud_respect = {}
Hud_enemy_status = {
respect = -1,
respect_needed = -1,
respect_bar = { bg_h = 0, fill_0_h = 0, fill_1_h = 0, txt_grp = 0, txt = 0,
start_angle = 0, end_angle = 3.14
}
}
Hud_weapon_status = {
wpn_ready = true,
wpn_bmp_name = -1,
super_bmp_name = -1,
element = -1,
recharging_txt_h = -1,
recharging_anim_h = -1,
is_recharging = false,
ammo_combined = -1,
fine_aim_transition = 0,
sniper_visible = -1,
show_reticule = false,
weapon_ammo_string = -1,
super_charge = -1,
weapon_is_hidden = false,
categories = {
["WPNCAT_MELEE"] = "",
["WPNCAT_PISTOL"] = "ui_menu_ammo_pistol",
["WPNCAT_SHOTGUN"] = "ui_menu_ammo_shtgn",
["WPNCAT_SUB_MACHINE_GUN"] = "ui_menu_ammo_smg",
["WPNCAT_RIFLE"] = "ui_menu_ammo_rifle",
["WPNCAT_SPECIAL"] = "ui_hud_ammo_sniper",
["WPNCAT_THROWN"] = "",
["WPNCAT_HAVOK"] = "ui_hud_ammo_missile",
}
}
Hud_followers = {
fade_in = -1,
fade_out = -1,
is_hidden = true,
slot_arrange = {1, 2, 3},
slot_objects = { {}, {}, {} },
follower_data = {
[1] = { head_img_name = "" },
[2] = { head_img_name = "" },
[3] = { head_img_name = "" },
},
}
Hud_balance_status = {
active = -1,
position = 0,
balance_grp_h = 0,
base_image_h = 0,
arrow_image_h = 0,
min_angle = -0.466,
max_angle = 0.466,
color_base = {43/255, 208/255, 0/255},
color_alarm = {220/255, 40/255, 0/255},
ls_btn = 0
}
Hud_vignettes = {
health = {
grp_h = -1,
pulse_grp_h = -1,
blue_anim_h = -1,
fade_anim_h = -1,
fade_twn_h = -1,
tint_anim_h = -1,
tint_twn_h = -1
},
fine_aim_dim = {
grp_h = -1,
},
tunnel_vision = {
grp_h = -1,
amount = 0
}
}
Reticule_hits = {}
Hud_camera = {}
Hud_hit_elements = {
main = -1,
minor = -1,
major = -1,
anim = -1,
}
Hud_mp_snatch_elements = {
main_grp_h = -1,
head_img_bg_h = -1,
recruitment_fill_h = -1,
}
Hud_smoked_busted = {}
local Hud_camera_screenshot_enabled = -1 --screenshot mode enabled?
Hud_current_veh_logo = 0
Hud_current_radio_station = 0
Hud_radio_has_updated = false
Hud_radio_show = false
Hud_map = {}
Hud_lockon = {
color_locked = {r=.7,g=0,b=0},
color_unlocked = {r=0,g=.8,b=0},
base_pixel_size_hor = 94,
base_pixel_size_vert = 94
}
local Hud_weapon_radial
Hud_gsi = -1
Hud_inventory = {
stick_mag = 0,
is_pressed = false,
}
Hud_radio_elements = {
radio_grp_h = -1,
image_h = -1,
arrow_left_h = -1,
arrow_right_h = -1,
anim = -1,
anim_in = -1,
radial_is_active = false,
station_is_selected = false,
}
HUD_RADIO_GRP_HUD_X = 644
HUD_RADIO_GRP_HUD_Y = 70
HUD_RADIO_GRP_RADIAL_X = 500
HUD_RADIO_GRP_RADIAL_Y = 357
HUD_RADIO_GRP_RADIAL_SD_X = 225
HUD_RADIO_GRP_RADIAL_SD_Y = 244
HUD_RADIO_GRP_RADIAL_POWERS_X = 640
HUD_RADIO_GRP_RADIAL_POWERS_SD_X = 300
local Hud_cheat_elements = {
image_grp_h = -1,
image_h = -1,
image_2_h = -1,
image_anim_h = -1,
images = {
[1] = "ui_hud_icon_cheat_swap",
[2] = "ui_hud_icon_cheat_shrink",
[3] = "ui_hud_icon_cheat_lag",
[4] = "ui_hud_icon_cheat_gimpy",
[5] = "ui_hud_icon_cheat_slow",
}
}
local Hud_sniper_hint_bar = -1
local Hud_sniper_button_hints = {
{CTRL_BUTTON_Y, "HUD_SNIPER_ZOOM_IN", game_get_key_name_for_action("CBA_OFC_ZOOM_IN")},
{CTRL_GAMEPLAY_BUTTON_A, "HUD_SNIPER_ZOOM_OUT", game_get_key_name_for_action("CBA_OFC_ZOOM_OUT")},
}
local Hud_vtol_button_hints = {
{CTRL_GAMEPLAY_BUTTON_B, "SWITCH_MODE", game_get_key_name_for_action("CBA_VDC_VTOL_TRANSITION")},
}
local INV_WEAPON_SLOT_LAST_EQUIPPED = 12
local HUD_INVENTORY_DELAY = 0.15
--enums for genki
HUD_GENKI_ETHICAL = 1
HUD_GENKI_UNETHICAL = 2
HUD_GENKI_NONE = 3
Hud_genki_anims = {}
Hud_genki_images = {}
--Ammo pickup
local Hud_ammo_pickup = {
grp = -1,
anim = -1,
twn = -1,
icon = -1,
amount = -1,
is_playing = -1,
queue = {},
amount_x = -1,
amount_y = -1,
}
Hud_gsi_supress_popout = false
local Hud_gsi_supress_popout_event_handle = -1
local Hud_damage_multiplier = {}
-- Hud flap data.
--
Hud_flap_data = {
-- needs to be the same amount as MAX_FLAPS
icons = {
[1] = {state = -1 },
[2] = {state = -1 },
[3] = {state = -1 },
[4] = {state = -1 },
[5] = {state = -1 },
},
backgrounds = {
[1] = {state = -1 },
[2] = {state = -1 },
[3] = {state = -1 },
[4] = {state = -1 },
[5] = {state = -1 },
}
}
-- change these according to design changes
local MAX_FLAPS = 5
local UNLOCKED_FLAPS = 5
function hud_init()
--Store document handle
HUD_DOC_HANDLE = vint_document_find("hud")
MP_enabled = mp_is_enabled()
--Pause all animations
vint_set_property(vint_object_find("vehicle_logo_anim_1"), "is_paused", true)
vint_set_property(vint_object_find("map_objective_anim"), "is_paused", true)
Hud_sniper_hint_bar = Vdo_hint_bar:new("sniper_btn_hints")
hud_sniper_set_hints()
--paused?
vint_dataitem_add_subscription( "game_paused_item", "update", "hud_game_is_paused" )
vint_dataitem_add_subscription( "game_chal_tracker_item", "update", "hud_chal_track_progress" )
--Ammo pickup
Hud_ammo_pickup.grp = vint_object_find("base_ammo_pickup", 0, HUD_DOC_HANDLE)
Hud_ammo_pickup.anim = vint_object_find("ammo_fade_anim")
Hud_ammo_pickup.icon = vint_object_find("ammo_bmp", 0, HUD_DOC_HANDLE)
Hud_ammo_pickup.amount = vint_object_find("ammo_txt", 0, HUD_DOC_HANDLE)
Hud_ammo_pickup.twn = Vdo_tween_object:new("end_event_twn", Hud_ammo_pickup.anim)
Hud_ammo_pickup.is_playing = false
Hud_ammo_pickup.queue = {}
--Get inital anchor for text
Hud_ammo_pickup.amount_x, Hud_ammo_pickup.amount_y = vint_get_property(Hud_ammo_pickup.amount, "anchor")
--vint_apply_start_values(Hud_ammo_pickup.anim)
vint_set_property(Hud_ammo_pickup.grp, "alpha", 0.0)
--Map
Hud_map.base_grp_h = vint_object_find("map_grp")
--Respect
Hud_respect = Vdo_respect_meter:new("respect_obj", 0, 0, "hud.lua", "Hud_respect")
--Health Meter Setup
local bar = Hud_health_bar
bar.bg_h = vint_object_find("health_bar_bg")
bar.fill_h = vint_object_find("health_bar")
bar.fill_1_h = vint_object_find("health_bar_2")
bar.health_decay_anim_h = vint_object_find("health_decay_anim")
bar.health_flash_anim_h = vint_object_find("health_flash_anim")
bar.health_bg_angle_twn_h = vint_object_find("health_bg_angle_twn")
bar.health_fill_angle_twn_h = vint_object_find("health_fill_angle_twn")
local challenges_bar_h = vint_object_find("challenges_bar", 0, HUD_DOC_HANDLE)
if Challenge_tracker_enabled then
vint_set_property(challenges_bar_h, "visible", true)
else
vint_set_property(challenges_bar_h, "visible", false)
end
local fill_start_angle = bar.level_angles[0].fill_start_angle
local fill_end_angle = bar.level_angles[0].fill_end_angle
local angle_offset = bar.level_angles[0].angle_offset
vint_set_property(bar.bg_h, "start_angle", fill_start_angle + angle_offset)
vint_set_property(bar.bg_h, "end_angle", fill_end_angle - angle_offset)
vint_set_property(bar.fill_h, "start_angle", fill_start_angle)
vint_set_property(bar.fill_h, "end_angle", fill_end_angle)
vint_set_property(bar.fill_1_h, "start_angle", fill_start_angle)
vint_set_property(bar.fill_1_h, "end_angle", fill_end_angle)
--set callbacks for tweens...
--Flash event callback...
local health_flash_tween_complete_h = vint_object_find("health_flash_tween_complete")
vint_set_property(health_flash_tween_complete_h, "end_event", "hud_health_flash_complete")
--Start event for decay and end event for decay...
vint_set_property(bar.health_bg_angle_twn_h, "start_event", "hud_health_decay_start")
vint_set_property(bar.health_bg_angle_twn_h, "end_event", "hud_health_decay_end")
--Meter retraction animation and callbacks
bar.timer_fade_out_anim_h = vint_object_find("map_health_timer_anim")
local timer_twn_h = vint_object_find("health_timer_twn")
vint_set_property(timer_twn_h, "end_event", "hud_player_health_hide")
--Mech HUD
Mech_health_meter_img_h = vint_object_find("health_meter_img", 0, HUD_DOC_HANDLE)
Mech_health_mask_img_h = vint_object_find("health_mask_img", 0, HUD_DOC_HANDLE)
Mech_weapon_meter_img_h = vint_object_find("weapon_meter_img", 0, HUD_DOC_HANDLE)
Mech_weapon_mask_img_h = vint_object_find("weapon_mask_img", 0, HUD_DOC_HANDLE)
Mech_health_anim_h = vint_object_find("mech_health_anim", 0, HUD_DOC_HANDLE)
local mech_health_twn_h = vint_object_find("end_event_twn", Mech_health_anim_h)
Mech_weapon_anim_h = vint_object_find("mech_weapon_anim", 0, HUD_DOC_HANDLE)
Mech_grp_h = vint_object_find("mech_grp", 0, HUD_DOC_HANDLE)
Mech_health_width, Mech_health_height = element_get_actual_size(Mech_health_mask_img_h)
Mech_weapon_width, Mech_weapon_height = element_get_actual_size(Mech_weapon_mask_img_h)
vint_set_property(Mech_grp_h, "visible", false)
vint_set_property(Mech_grp_h, "visible", false)
vint_set_property(mech_health_twn_h, "end_event", "hud_mech_health_anim_is_done")
-- Pirate Ship HUD
Ship_health_meter_img_h = vint_object_find("meter_base", 0, HUD_DOC_HANDLE)
Ship_health_mask_img_h = vint_object_find("vehicle_meter_mask", 0, HUD_DOC_HANDLE)
Ship_health_grp_h = vint_object_find("base_vehicle_health", 0, HUD_DOC_HANDLE)
Ship_health_width, Ship_health_height = element_get_actual_size(Ship_health_mask_img_h)
vint_set_property(Ship_health_grp_h, "visible", false)
--Sprint Meter Setup
bar = Hud_sprint_bar
bar.bg_h = vint_object_find("sprint_bar_bg")
bar.fill_h = vint_object_find("sprint_bar")
local fill_start_angle = bar.level_angles[0].fill_start_angle
local fill_end_angle = bar.level_angles[0].fill_end_angle
local angle_offset = bar.level_angles[0].angle_offset
vint_set_property(bar.bg_h, "start_angle", fill_start_angle + angle_offset)
vint_set_property(bar.bg_h, "end_angle", fill_end_angle - angle_offset)
vint_set_property(bar.fill_h, "start_angle", fill_start_angle)
vint_set_property(bar.fill_h, "end_angle", fill_end_angle)
Darken_h = vint_object_find("darken")
--Meter retraction animation and callbacks
bar.timer_fade_out_anim_h = vint_object_find("map_sprint_timer_anim")
local timer_twn_h = vint_object_find("sprint_timer_twn")
vint_set_property(timer_twn_h, "end_event", "hud_player_sprint_hide")
--Respect Timeout
Hud_player_status.respect_timer_h = vint_object_find("respect_timer_anim")
local timer_twn_h = vint_object_find("respect_timer_twn")
vint_set_property(timer_twn_h, "end_event", "hud_player_respect_hide")
--Weapon Timeout timer...
local h = vint_object_find("weapon_timer_twn")
vint_set_property(h, "end_event", "hud_weapon_fade_out")
--Cash and hide it
Hud_player_status.cash_h = vint_object_find("cash")
vint_set_property(Hud_player_status.cash_h, "alpha", 0)
--Ammo/Weapons
Hud_weapon_status.weapon_base_h = vint_object_find("weapons_grp") --Group containing weapon/super icons and count
Hud_weapon_status.weapon_grp_h = vint_object_find("weapon_icons_grp") --Group containing weapon/super icons and count
Hud_weapon_status.weapon_ammo_txt_h = vint_object_find("weapon_ammo_txt")
Hud_weapon_status.single_wpn_icon_h = vint_object_find("weapon_icon")
Hud_weapon_status.dual_wpn_icon_1_h = vint_object_find("dual_weapon_1")
Hud_weapon_status.dual_wpn_icon_2_h = vint_object_find("dual_weapon_2")
Hud_weapon_status.sniper_ammo_txt_h = vint_object_find("sniper_ammo_txt")
Hud_weapon_status.sniper_reload_txt_h = vint_object_find("sniper_reload_text")
Hud_weapon_status.sniper_ammo_anim = vint_object_find("sniper_reload_anim", 0, HUD_DOC_HANDLE)
Hud_weapon_status.recharging_txt_h = vint_object_find("recharging_txt")
Hud_weapon_status.recharging_anim_h = vint_object_find("recharging_anim")
lua_play_anim(Hud_weapon_status.recharging_anim_h)
-- Damage Multiplier Text
Hud_damage_multiplier.grp = vint_object_find("base_damage_multiplier")
Hud_damage_multiplier.multiplier_txt= vint_object_find("damage_multiplier_txt")
--Super Bar
Hud_weapon_status.super_icon_h = vint_object_find("super_icon")
Hud_weapon_status.element_icon_h = vint_object_find("element_icon")
Hud_super_bar.fill_h = vint_object_find("super_fill")
Hud_super_bar.bg_h = vint_object_find("super_bg")
Hud_super_bar.pulse_anim_h = vint_object_find("super_pulse_anim")
Hud_super_bar.super_strength_h = vint_object_find("super_strength")
Hud_super_bar.super_swap_icon_h = vint_object_find("super_swap_icon")
Hud_super_bar.element_swap_icon_h = vint_object_find("element_swap_icon")
Hud_super_bar.super_swap_anim_h = vint_object_find("super_swap_anim")
Hud_super_bar.super_swap_end_twn_h = vint_object_find("end_event_twn", Hud_super_bar.super_swap_anim_h)
Hud_super_bar.super_swap_start_twn_h = vint_object_find("start_twn", Hud_super_bar.super_swap_anim_h)
vint_set_property(Hud_super_bar.super_swap_end_twn_h, "end_event", "hud_super_swap_is_done")
Hud_super_bar.pressure_fill = vint_object_find("super_pressure_fill")
Hud_super_bar.pressure_grp = vint_object_find("super_pressure_grp")
--Super Reward
Hud_super_reward.move_grp = vint_object_find("super_reward_move_grp")
Hud_super_reward.icon = vint_object_find("super_reward_icon")
Hud_super_reward.txt = vint_object_find("super_reward_txt")
Hud_super_reward.txt2 = vint_object_find("super_reward_unlock_txt")
Hud_super_reward.words_anim = Vdo_anim_object:new("super_reward_words", 0, HUD_DOC_HANDLE)
Hud_super_reward.top_anim = Vdo_anim_object:new("super_reward_top", 0, HUD_DOC_HANDLE)
Hud_super_reward.top_twn = Vdo_tween_object:new("end_event_twn", Hud_super_reward.top_anim.handle)
Hud_super_reward.bot_anim = Vdo_anim_object:new("super_reward_bot", 0, HUD_DOC_HANDLE)
Hud_super_reward.bot_twn = Vdo_tween_object:new("end_event_twn", Hud_super_reward.bot_anim.handle)
Hud_super_reward.in_anim = Vdo_anim_object:new("super_reward_in", 0, HUD_DOC_HANDLE)
Hud_super_reward.in_twn = Vdo_tween_object:new("end_event_twn", Hud_super_reward.in_anim.handle)
Hud_super_reward.out_anim = Vdo_anim_object:new("super_reward_out", 0, HUD_DOC_HANDLE)
Hud_super_reward.out_twn = Vdo_tween_object:new("end_event_twn", Hud_super_reward.out_anim.handle)
Hud_super_reward.circle_bg = vint_object_find("super_circle_bg")
Hud_super_reward.icon_grp = vint_object_find("super_icon_grp")
Hud_super_reward.counter = 0
Hud_super_reward.is_active = false
--Balance Meter
local balance_meter = vint_object_find("balance_meter")
Hud_balance_status.balance_grp_h = balance_meter
Hud_balance_status.base_grp_h = vint_object_find("base_grp", balance_meter)
Hud_balance_status.arrow_image_h = vint_object_find("arrow_grp", balance_meter)
Hud_balance_status.fade_out_anim_h = vint_object_find("balance_ls_fade_out") -- Animation fades out left stick button
Hud_balance_status.ls_btn = Vdo_hint_button:new("ls_btn", 0, HUD_DOC_HANDLE)
--cheat icons
Hud_cheat_elements.image_grp_h = vint_object_find("cheats_grp")
Hud_cheat_elements.image_h = vint_object_find("cheat_icon")
Hud_cheat_elements.image_2_h = vint_object_find("cheat_icon_2")
Hud_cheat_elements.image_anim_h = vint_object_find("cheat_in_anim")
--Vignette
local h = vint_object_find("vignettes")
Hud_vignettes.health.grp_h = vint_object_find("vignette_health", h )
Hud_vignettes.health.pulse_grp_h = vint_object_find("vignette_health_pulse", h )
Hud_vignettes.health.blue_anim_h = vint_object_find("vignette_blue_anim")
Hud_vignettes.health.fade_anim_h = vint_object_find("vignette_fade_anim")
Hud_vignettes.health.fade_twn_h = vint_object_find("vignette_alpha_twn")
Hud_vignettes.tunnel_vision.grp_h = vint_object_find("tunnel_vision", h)
vint_set_property(Hud_vignettes.health.fade_twn_h, "end_event", "hud_health_screen_fade_complete")
--Followers
Hud_followers.fade_in = vint_object_find("follow_fade_in_anim")
Hud_followers.fade_out = vint_object_find("follow_fade_out_anim")
local master_follower_anim_0 = vint_object_find("follow_anim_0")
local master_follower_anim_1 = vint_object_find("follow_anim_1")
local master_count_tween_alpha = vint_object_find("follow_rev_count_alpha_0")
for i = 1, 3 do
local slot_object = Hud_followers.slot_objects[i]
local grp = vint_object_find("follower_grp_" .. i)
slot_object.name = i
slot_object.head_img_h = vint_object_find("follower_head", grp)
slot_object.frame_img_h = vint_object_find("follower_frame", grp)
slot_object.revive_timer_h = vint_object_find("follower_count", grp)
slot_object.visible = -1
slot_object.group_h = grp
--clone animations into slots
local anim_0 = vint_object_clone(master_follower_anim_0)
local anim_1 = vint_object_clone(master_follower_anim_1)
slot_object.anim_0 = anim_0
slot_object.anim_1 = anim_1
vint_set_property(anim_0, "target_handle", grp)
vint_set_property(anim_1, "target_handle", grp)
--Duplicate Tweens for Counting Anim
local count_tween_alpha_h = vint_object_clone(master_count_tween_alpha)
vint_set_property(count_tween_alpha_h, "target_handle", slot_object.revive_timer_h)
end
--Hit Indicator
Hud_hit_elements.main_h = vint_object_find("hits")
h = Hud_hit_elements.main_h
Hud_hit_elements.minor_h = vint_object_find("major", h)
Hud_hit_elements.major_h = vint_object_find("major", h)
Hud_hit_elements.anim_h = vint_object_find("hit_anim")
--Cruise Control
Hud_player_status.cruise_control_h = vint_object_find("cruise_control_grp")
Hud_player_status.cruise_control_obj = Vdo_hint_bar:new("cruise_control_hint_bar", 0, HUD_DOC_HANDLE)
Hud_player_status.cruise_control_anim = vint_object_find("cruise_control_fade_anim")
--Hud Lockon
Hud_lockon.lock_h = vint_object_find("lockon")
Hud_lockon.lock1_h = vint_object_find("lockon_1", Hud_lockon.lockon_h )
Hud_lockon.lock2_h = vint_object_find("lockon_2", Hud_lockon.lockon_h )
Hud_lockon.lock3_h = vint_object_find("lockon_3", Hud_lockon.lockon_h )
Hud_lockon.lock4_h = vint_object_find("lockon_4", Hud_lockon.lockon_h )
Hud_lockon.lock_txt_grp_h = vint_object_find("lockon_txt_grp")
Hud_lockon.lock_text_h = vint_object_find("lockon_txt", Hud_lockon.lock_txt_grp_h)
Hud_lockon.lock_lock_h = vint_object_find("scan_lock", Hud_lockon.lock_txt_grp_h)
Hud_lockon.lock_spinner_h = vint_object_find("scan_spinner", Hud_lockon.lock_txt_grp_h)
Hud_lockon.lock_anim_h = vint_object_find("lockon_anim")
lua_play_anim(Hud_lockon.lock_anim_h, 0, HUD_DOC_HANDLE)
--lockon base screensize
Hud_lockon.lock_base_hor_width, Hud_lockon.lock_base_hor_height = vint_get_property(Hud_lockon.lock2_h, "scale")
Hud_lockon.lock_base_vert_width, Hud_lockon.lock_base_vert_height = vint_get_property(Hud_lockon.lock1_h, "scale")
--initialize the radio elements
Hud_radio_elements.radio_grp_h = vint_object_find("radio_grp")
Hud_radio_elements.radio_title_grp_h = vint_object_find("radio_title_grp")
Hud_radio_elements.image_h = vint_object_find("radio_station_image")
Hud_radio_elements.arrow_left_h = vint_object_find("radio_left_arrow")
Hud_radio_elements.arrow_right_h = vint_object_find("radio_right_arrow")
Hud_radio_elements.hint_left_h = Vdo_hint_button:new("radio_hint_left", 0, HUD_DOC_HANDLE)
Hud_radio_elements.hint_right_h = Vdo_hint_button:new("radio_hint_right", 0, HUD_DOC_HANDLE)
Hud_radio_elements.anim = vint_object_find("radio_station_anim_1")
Hud_radio_elements.anim_in = vint_object_find("radio_in_anim")
--Find homie call elements
Hud_homie_call.grp_h = vint_object_find("base_homie_call")
Hud_homie_call.box_grp_h = vint_object_find("box_grp", Hud_homie_call.grp_h, HUD_DOC_HANDLE)
Hud_homie_call.homie_img_h = vint_object_find("homie_img")
Hud_homie_call.homie_name_txt_h = vint_object_find("homie_name_txt")
Hud_homie_call.anim_h = vint_object_find("homie_call_anim")
Hud_homie_call.alpha_twn_h = vint_object_find("homie_call_alpha_twn")
for i = 1, 11 do
Hud_homie_call.waveform_images[i] = vint_object_find("bar_img_"..i)
end
vint_set_property(Hud_homie_call.grp_h, "visible", false)
vint_set_property(Hud_homie_call.grp_h, "alpha", 0)
--Listen for hud homie call updates
Hud_homie_call_listener = vint_scriptevent_listen( "hud_voice", "hud_homie_call_update" )
--Initialize controls for Radio Selection
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("black", "hud_inventory_input", 50, nil, nil, false)
Input_tracker:add_input("white", "hud_inventory_input", 50, nil, nil, false)
Input_tracker:subscribe(false)
--Initialize Gameplay Status Indicator
Hud_gsi = Vdo_gsi:new("gsi", 0, 0, "hud.lua", "Hud_gsi")
vint_datagroup_add_subscription("sr2_local_player_gameplay_indicator_status", "insert", "hud_gsi_vdo_update")
vint_datagroup_add_subscription("sr2_local_player_gameplay_indicator_status", "update", "hud_gsi_vdo_update")
--Find Genki anims and images
Hud_genki_anims = {
[HUD_GENKI_ETHICAL] = vint_object_find("genki_ethical_anim"),
[HUD_GENKI_UNETHICAL] = vint_object_find("genki_unethical_anim"),
[HUD_GENKI_NONE] = -1,
}
Hud_genki_images = {
[HUD_GENKI_ETHICAL] = vint_object_find("ethical_img"),
[HUD_GENKI_UNETHICAL] = vint_object_find("unethical_img"),
}
--Setup Camera hint for taking screenshots.
-- Set Control Image...
Hud_camera.hint_icon = Vdo_hint_button:new("camera_hint_button")
Hud_camera.hint_button = CTRL_MENU_BUTTON_BACK
Hud_camera.hint_text = vint_object_find("camera_hint_txt", 0, HUD_DOC_HANDLE)
Hud_camera.hint_key = game_get_key_name_for_action( "CBA_GAC_TAKE_SCREENSHOT" )
--vint_set_property(camera_hint_icon_bmp_h, "image", get_dpad_down_image())
--Initialize Mayhem Hud
hud_mayhem_init()
--Initialize Object Indicators
--object_indicators_init()
--Initialize Floating Healthbars (sewage version)
hud_healthbars_init()
--Initialize reticule related stuff,
hud_reticules_init()
hud_busted_init()
--DISABLE Vehicle logo...
local h = vint_object_find("vehicle_logo")
vint_set_property(h, "visible", false)
--Init VDO Objects
--Weapon Radial VDO Initialize and Hide
Hud_weapon_radial = Vdo_weapon_radial:new("radial_grp")
Hud_weapon_radial:show(false)
vint_set_property(Darken_h, "visible", false)
--Radial Menu Subscriptions
vint_datagroup_add_subscription("sr2_local_player_inventory", "insert", "hud_radial_menu_update")
vint_datagroup_add_subscription("sr2_local_player_inventory", "update", "hud_radial_menu_update")
--Subscribe to datagroups and dataitems
--Respect
vint_dataitem_add_subscription("sr2_local_player_respect", "update", "hud_player_respect_change")
--Initialize notoriety...
hud_noto_init()
--Flap Icons Setup--
--find reference base icons (amount of flaps may change)
for i = 1, MAX_FLAPS do
-- icons
local flap_icon_h = vint_object_find("flap_icon_0" .. i)
Hud_flap_data.icons[i].icon_h = flap_icon_h
vint_set_property(Hud_flap_data.icons[i].icon_h, "visible", false)
-- icon backgrounds
local flap_bg_h = vint_object_find("flap_icon_bg_0" .. i)
Hud_flap_data.backgrounds[i].bg_h = flap_bg_h
vint_set_property(Hud_flap_data.backgrounds[i].bg_h, "visible", false)
end
--Hood
vint_dataitem_add_subscription("sr2_local_player_hood", "update", "hud_player_hood_change")
vint_dataitem_add_subscription("sr2_local_player_status", "update", "hud_player_status_change")
--Followers
vint_datagroup_add_subscription("sr2_local_player_followers", "insert", "hud_player_followers_change")
vint_datagroup_add_subscription("sr2_local_player_followers", "update", "hud_player_followers_change")
--Infrequent
--..moving below followers, hopefully solves homie update issues (Derik)
vint_dataitem_add_subscription("sr2_local_player_status_infrequent", "update", "hud_player_status_inf_change")
--Weapons
vint_dataitem_add_subscription("sr2_local_player_weapons", "update", "hud_player_weapon_change")
vint_dataitem_add_subscription("sr2_local_player_frequent_weapon", "update", "hud_player_weapon_freq_change")
vint_dataitem_add_subscription("sr2_local_player_satellite_weapon", "update", "hud_player_satellite_weapon")
--Lockon
vint_dataitem_add_subscription("sr2_local_player_lockon", "update", "hud_player_lockon_update")
--Balance Meter
vint_dataitem_add_subscription("sr2_balance_meter", "update", "hud_balance_meter_change")
--Cheat icons
vint_dataitem_add_subscription("hud_cheat_icons", "update", "hud_cheat_icon_update")
--HUD Process Thread
Hud_process_thread = thread_new("hud_process")
--Giant Minimap Icon
vint_dataitem_add_subscription("minimap_giant_icon", "update", "hud_map_objective_icon")
--Ammo pickup
vint_dataitem_add_subscription("hud_ammo_pickup", "update", "hud_ammo_pickup_update")
--Hud collection init... (Flashpoint, Chopshop, Hitman, etc...)
hud_collection_init()
Hud_gsi_supress_popout_event_handle = vint_scriptevent_listen( "gsi_supress_popout", "hud_gsi_supress_popout_update" )
--Setup animation to fade in the hud
local safe_frame_h = vint_object_find("safe_frame", 0, HUD_DOC_HANDLE)
local hud_fade_in_anim_h = vint_object_find("hud_fade_in_anim")
local hud_fade_in_twn_h = vint_object_find("hud_fade_in_twn", hud_fade_in_anim_h, safe_frame_h)
--Hide HUD via safe frame
vint_set_property(safe_frame_h, "alpha", 0)
--Retarget tween to the safe frame...
vint_set_property(hud_fade_in_twn_h, "target_handle", safe_frame_h)
--Fade in the hud
lua_play_anim(hud_fade_in_anim_h, 1)
if game_get_platform() == "PC" then
eyefinity_force_blackout( false )
end
end
function hud_cleanup()
--kill threads
--VDOWEAPON
hud_inventory_hide()
--unload vehicle logo
game_peg_unload(Hud_current_veh_logo)
if Hud_weapon_status.hud_state_h ~= nil then
ui_hud_display_remove_state(Hud_weapon_status.hud_state_h, false)
Hud_weapon_status.hud_state_h = nil
end
if Hud_inventory_hud_state_h ~= -1 then
ui_hud_display_remove_state(Hud_inventory_hud_state_h, false)
Hud_inventory_hud_state_h = -1
end
vint_scriptevent_stop_listening( Hud_gsi_supress_popout_event_handle )
vint_scriptevent_stop_listening( Hud_homie_call_listener )
if game_get_platform() == "PC" then
eyefinity_force_blackout( false )
end
end
function hud_chal_track_progress(di_h)
local progress, collected, total = vint_dataitem_get(di_h)
if progress == 1 and collected == 0 and total == 0 then
Curr_tracked_challenge.equipped = false
Curr_tracked_challenge = { }
Curr_tracked_challenge_id = -1
local challenges_bar_h = vint_object_find("challenges_bar", 0, HUD_DOC_HANDLE)
vint_set_property(challenges_bar_h, "visible", false)
elseif progress == 0 and collected == 0 and total == 0 then
local challenges_bar_h = vint_object_find("challenges_bar", 0, HUD_DOC_HANDLE)
vint_set_property(challenges_bar_h, "visible", false)
else
Curr_tracked_challenge.complete_pct = progress
local METER_FULL_PCT = 140
local challenges_bar_h = vint_object_find("challenges_bar", 0, HUD_DOC_HANDLE)
vint_set_property(challenges_bar_h, "visible", true)
local chal_meter_clip_h = vint_object_find("chal_meter_bar_clip", 0, HUD_DOC_HANDLE)
local chal_meter_width, chal_meter_height = vint_get_property(chal_meter_clip_h, "clip_size")
local new_width = METER_FULL_PCT * Curr_tracked_challenge.complete_pct
if Curr_tracked_challenge.complete_pct ~= 1 then --if 1 then set it to full
local increment = METER_FULL_PCT/20
for i = 0, METER_FULL_PCT, increment do
if new_width >= i and new_width < (i + increment) then
new_width = i
end
end
end
vint_set_property(chal_meter_clip_h, "clip_size", new_width, chal_meter_height)
local chal_meter_unit_type = vint_object_find("chal_unit_txt", 0, HUD_DOC_HANDLE)
local base_units_string = "{0}/{1}"
local values = {[0] = collected, [1] = total}
local units_tag = vint_insert_values_in_string(base_units_string, values)
vint_set_property(chal_meter_unit_type, "text_tag", units_tag)
end
end
function hud_hide_map()
vint_set_property(Hud_map.base_grp_h, "visible", false)
end
function hud_show_map()
vint_set_property(Hud_map.base_grp_h, "visible", true)
end
--Updates the Hud Radial Menu VDO
function hud_radial_menu_update(di_h)
Hud_weapon_radial:slots_update(di_h)
--Make sure we have the right slot selected...
if Hud_weapon_radial.equipped_grenade_slot > 0 then
Hud_weapon_radial:weapon_highlight(Hud_weapon_radial.equipped_grenade_slot, true)
end
--Make sure we have the right slot selected...
if Hud_weapon_radial.equipped_weapon_slot ~= -1 and Hud_weapon_radial.selected_weapon_slot == -1 then
Hud_weapon_radial:weapon_highlight(Hud_weapon_radial.equipped_weapon_slot, true)
end
end
function hud_inventory_change_power_slot(slot)
if Hud_weapon_radial.selected_grenade_slot ~= slot then
Hud_weapon_radial:weapon_highlight(slot)
else
local element = player_super_power_get_next_unlocked_element(Hud_weapon_radial.slots[slot].element)
Hud_weapon_radial.slots[slot]:update_element(element)
Hud_weapon_radial:weapon_highlight(slot)
end
end
--Inventory Control Mapping
function hud_inventory_input(event, value)
if event == "inventory_x" then
--Move Analog Stick X
Hud_inventory.x = value
Hud_inventory.stale = true
elseif event == "inventory_y" then
--Move Analog Stick Y
Hud_inventory.y = value
Hud_inventory.stale = true
elseif event == "dpad_up" then
hud_inventory_change_power_slot(8)
elseif event == "dpad_right" then
hud_inventory_change_power_slot(9)
elseif event == "dpad_down" then
hud_inventory_change_power_slot(10)
elseif event == "dpad_left" then
hud_inventory_change_power_slot(11)
elseif event == "black" then
debug_print("vint", "scroll_left\n\n")
hud_on_foot_radio_prev_station()
Hud_radio_elements.station_is_selected = true
elseif event == "white" then
debug_print("vint", "scroll_right\n\n")
hud_on_foot_radio_next_station()
Hud_radio_elements.station_is_selected = true
end
end
--Show Hud Inventory!!
function hud_inventory_show()
game_hud_update_inventory()
if Hud_inventory.thread == nil then
if game_get_platform() == "PC" then
eyefinity_force_blackout( true )
end
--Determine if we need to show or hide the dpad menu based on powers
--Reposition the raidal based on the dpad
if (Hud_powers_are_disabled == true) or (Hud_weapon_radial:slot_is_empty(8) == true and Hud_weapon_radial:slot_is_empty(9) == true and Hud_weapon_radial:slot_is_empty(10) == true and Hud_weapon_radial:slot_is_empty(11) == true) then
Hud_weapon_radial:show_dpad_menu(false)
--Reposition for SD
if vint_is_std_res() then
Hud_weapon_radial:set_anchor(HUD_RADIO_GRP_RADIAL_SD_X, HUD_RADIO_GRP_RADIAL_SD_Y)
--Center bg grp
vint_set_property(Hud_weapon_radial.bg_grp_h, "anchor", 0, 0)
else
Hud_weapon_radial:set_anchor(HUD_RADIO_GRP_RADIAL_X, HUD_RADIO_GRP_RADIAL_Y)
end
else
Hud_weapon_radial:show_dpad_menu(true)
--Reposition for SD
if vint_is_std_res() then
Hud_weapon_radial:set_anchor(HUD_RADIO_GRP_RADIAL_POWERS_SD_X, HUD_RADIO_GRP_RADIAL_SD_Y)
--Center bg grp
vint_set_property(Hud_weapon_radial.bg_grp_h, "anchor", 40, 0)
else
Hud_weapon_radial:set_anchor(HUD_RADIO_GRP_RADIAL_POWERS_X, HUD_RADIO_GRP_RADIAL_Y)
end
end
Hud_weapon_radial:show(true)
--Set flag that radial is up
Hud_radio_elements.radial_is_active = true
--If radio is not disabled then show the radio controls
if radio_tuner_is_enabled() then
Hud_radio_elements.radio_is_visible = true
hud_radio_station_update(Hud_current_radio_station)
if Hud_inventory.thread == nil then --Double checking in hopes to fix a bug where the radio stays open after inventory closes -Rossi 5-23-13
vint_set_property(Hud_radio_elements.radio_grp_h, "tint", .9, .9, .9)
local platform = game_get_platform()
if platform == "PS3" then
Hud_radio_elements.hint_right_h:set_button("ui_ctrl_ps3_btn_r1")
Hud_radio_elements.hint_left_h:set_button("ui_ctrl_ps3_btn_l1")
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
Hud_radio_elements.hint_right_h:set_button("ui_ctrl_ps4_btn_r1")
Hud_radio_elements.hint_left_h:set_button("ui_ctrl_ps4_btn_l1")
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
Hud_radio_elements.hint_right_h:set_button(CTRL_BUTTON_RB)
Hud_radio_elements.hint_left_h:set_button(CTRL_BUTTON_LB)
elseif game_is_active_input_gamepad() == false then
Hud_radio_elements.hint_right_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_NEXT_RADIO" ), false, true)
Hud_radio_elements.hint_left_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_PREV_RADIO" ) , false, true)
else
Hud_radio_elements.hint_right_h:set_button(CTRL_BUTTON_RB)
Hud_radio_elements.hint_left_h:set_button(CTRL_BUTTON_LB)
end
Hud_radio_elements.hint_right_h:set_visible( true )
Hud_radio_elements.hint_left_h:set_visible( true )
vint_set_property(Hud_radio_elements.anim, "is_paused", true)
vint_set_property(Hud_radio_elements.radio_grp_h, "visible", true)
vint_set_property(Hud_radio_elements.radio_title_grp_h, "visible", true)
lua_play_anim(Hud_radio_elements.anim_in, 0)
end
end
Input_tracker:subscribe(true)
if coop_is_active() == false then
ui_audio_post_event("UI_Weapon_Radial_Pause")
else
game_UI_audio_play("UI_HUD_Open_Weapon_Radial")
end
--Show darken scrim when radial is visible
vint_set_property(Darken_h, "visible", true)
--fade bg if not paused
Hud_weapon_radial:transparent_bg(not pause_on_weapon_inv())
--Animated radial in
Hud_weapon_radial:play_show_anim()
--Hide all HUD except radial
Hud_inventory_hud_state_h = ui_hud_display_create_state()
ui_hud_display_set_element(Hud_inventory_hud_state_h, HUD_ALL_ELEM, HUD_FADE_HIDDEN)
ui_hud_display_set_element(Hud_inventory_hud_state_h, HUD_ELEM_RADIO_STATION, HUD_FADE_VISIBLE)
--Commit state without fades (second param)
ui_hud_display_commit_state(Hud_inventory_hud_state_h, true)
--Subscribe to input
Hud_inventory.extra_buttons = {
-- RCS 3/3/2014: I removed commented out lines. You can diff in source control to see what was removed. Comments are loaded into memory too.
vint_subscribe_to_input_event("map", "hud_inventory_input"),
vint_subscribe_to_input_event("pause", "hud_inventory_input"),
}
Hud_inventory.subs_x = vint_subscribe_to_raw_input("inventory_x", "hud_inventory_input")
Hud_inventory.subs_y = vint_subscribe_to_raw_input("inventory_y", "hud_inventory_input")
Hud_inventory.subs_up = vint_subscribe_to_input_event("dpad_up", "hud_inventory_input")
Hud_inventory.subs_right = vint_subscribe_to_input_event("dpad_right", "hud_inventory_input")
Hud_inventory.subs_down = vint_subscribe_to_input_event("dpad_down", "hud_inventory_input")
Hud_inventory.subs_left = vint_subscribe_to_input_event("dpad_left", "hud_inventory_input")
--Reset visual analog stick and get the proper text tag on it.
Hud_inventory.x = 0
Hud_inventory.y = 0
--Highlight Currently equipped slots
Hud_weapon_radial:weapon_highlight(Hud_weapon_radial.equipped_weapon_slot, true)
if Hud_weapon_radial.equipped_grenade_slot > 0 then
Hud_weapon_radial:weapon_highlight(Hud_weapon_radial.equipped_grenade_slot, true)
end
Hud_weapon_radial:stick_update_position(0, 0)
Hud_weapon_radial:stick_update_tag()
Hud_weapon_radial:stick_arrow_reset()
Hud_inventory.thread = thread_new("hud_inventory_process")
end
end
function hud_inventory_hide(aborted)
if game_get_platform() == "PC" then
eyefinity_force_blackout( false )
end
if Hud_inventory.thread ~= nil then
thread_kill(Hud_inventory.thread)
Hud_inventory.thread = nil
if aborted == false then
Hud_weapon_radial:game_equip_selected_slots()
end
--Hide Radial Menu
Hud_weapon_radial:show(false)
--Radial is not active
Hud_radio_elements.radial_is_active = false
--If the radio is visible (and active) then hide it
if Hud_radio_elements.radio_is_visible == true then
vint_set_property(Hud_radio_elements.radio_grp_h, "tint", 1, 1, 1)
--Bring arrows back
vint_set_property(Hud_radio_elements.arrow_right_h, "visible", true)
vint_set_property(Hud_radio_elements.arrow_left_h, "visible", true)
--Move and hide radio grp
vint_set_property(Hud_radio_elements.radio_grp_h, "alpha", 0)
vint_set_property(Hud_radio_elements.radio_grp_h, "visible", false)
vint_set_property(Hud_radio_elements.radio_title_grp_h, "visible", false)
vint_set_property(Hud_radio_elements.radio_grp_h, "anchor", HUD_RADIO_GRP_HUD_X, HUD_RADIO_GRP_HUD_Y)
Hud_radio_elements.radio_is_visible = false
end
--Release controls
Input_tracker:subscribe(false)
--Radial is hidden, pop HUD back on (second param controls fade vs pop)
ui_hud_display_remove_state(Hud_inventory_hud_state_h, false)
Hud_inventory_hud_state_h = -1
vint_set_property(Darken_h, "visible", false)
if coop_is_active() == false then
ui_audio_post_event("UI_Weapon_Radial_Unpause")
end
vint_unsubscribe_to_raw_input(Hud_inventory.subs_x)
vint_unsubscribe_to_raw_input(Hud_inventory.subs_y)
vint_unsubscribe_to_input_event(Hud_inventory.subs_up)
vint_unsubscribe_to_input_event(Hud_inventory.subs_right)
vint_unsubscribe_to_input_event(Hud_inventory.subs_down)
vint_unsubscribe_to_input_event(Hud_inventory.subs_left)
for idx, val in pairs(Hud_inventory.extra_buttons) do
vint_unsubscribe_to_input_event(val)
end
Hud_inventory.extra_buttons = nil
end
end
function hud_inventory_process()
while true do
if Hud_inventory.stale == true then
local x = Hud_inventory.x
local y = Hud_inventory.y
local selected_weapon_index = 0
local mag = sqrt((x * x) + (y * y))
local pi = 3.14159
if mag > 0.5 then
-- Y resolves out so don't bother with it
x = x/mag
local radians = acos(x)
if y < 0.0 then
radians = pi + (pi - radians)
end
local eighth = pi / 8
local fourth = pi / 4
local selected_weapon_index = 0
if radians < eighth then
selected_weapon_index = 2;
elseif radians < (fourth + eighth) then
selected_weapon_index = 1
elseif radians < (2.0 * fourth + eighth) then
selected_weapon_index = 0
elseif radians < (3.0 * fourth + eighth) then
selected_weapon_index = 7
elseif radians < (4.0 * fourth + eighth) then
selected_weapon_index = 6
elseif radians < (5.0 * fourth + eighth) then
selected_weapon_index = 5
elseif radians < (6.0 * fourth + eighth) then
selected_weapon_index = 4;
elseif radians < (7.0 * fourth + eighth) then
selected_weapon_index = 3;
else
selected_weapon_index = 2;
end
--Change selected item in the menu
--Hud_radial_menu_change_select(selected_weapon_index)
Hud_weapon_radial:weapon_highlight(selected_weapon_index)
Hud_weapon_radial:stick_update_arrow(radians)
end
--Update Stick location on radial menu
Hud_weapon_radial:stick_update_position(Hud_inventory.x, Hud_inventory.y)
Hud_inventory.stick_mag = mag
Hud_inventory.stale = false
end
thread_yield()
end
end
function hud_inventory_set_selected_weapon(selected_weapon_index)
Hud_weapon_radial:weapon_highlight(selected_weapon_index)
end
function hud_inventory_set_selected_grenade(selected_grenade_index)
Hud_weapon_radial:weapon_highlight(selected_grenade_index + 8)
end
-- call from C to notify that all GSI elements have been updated
function hud_gsi_update_complete()
Hud_gsi:update_complete()
end
function hud_gsi_vdo_update(di_h)
if Hud_gsi ~= -1 then
Hud_gsi:update(di_h)
end
end
function exp_approach(source, dest, pct_per_sec, step_time)
pct_per_sec = max(min(pct_per_sec, 1), 0)
local pct_this_frame = 1 - pow(1-pct_per_sec, step_time)
local lerp_result = lerp(source, dest, pct_this_frame)
--debug_print("vint_exp", source .. " -> " .. dest .. ", " .. pct_per_sec .. "%%/s, " .. step_time .. "s, " .. pct_this_frame .. "%%/f ==> " .. lerp_result .. "\n")
return lerp_result
end
function hud_process()
local display_cash = Hud_player_status.cash - 1 --Subtract one so it gets formatted in the loop.
local hud_had_focus = nil
while true do
thread_yield()
-- Animate Cash
if display_cash ~= Hud_player_status.cash then
local step_time = get_frame_time()
local diff_cash = Hud_player_status.cash - display_cash
local linear_cash = step_time * 1000
if abs(diff_cash) > linear_cash then
-- approach the player's cash value by whichever rate is greater: linear slope or exponential approach
linear_cash = linear_cash * (diff_cash / abs(diff_cash))
local exp_cash = exp_approach(display_cash, Hud_player_status.cash, 0.99995, step_time) - display_cash
if diff_cash > 0 then
diff_cash = max(linear_cash, exp_cash)
else
diff_cash = min(linear_cash, exp_cash)
end
end
display_cash = display_cash + diff_cash
vint_set_property(Hud_player_status.cash_h, "text_tag", "{GAME_CASH}" .. format_cash(display_cash))
--color red if going down
if diff_cash >= 0 then
vint_set_property(Hud_player_status.cash_h, "tint", 220/255, 220/255, 220/255)
else
vint_set_property(Hud_player_status.cash_h, "tint", 220/255, 0/255, 0/255)
end
else
vint_set_property(Hud_player_status.cash_h, "tint", 220/255, 220/255, 220/255)
end
-- check to see if the hud has lost focus
if hud_had_focus ~= Hud_has_focus then
hud_had_focus = Hud_has_focus
end
local hud_msg_doc_h = vint_document_find("hud_msg")
if hud_msg_doc_h ~= 0 then
hud_msg_process()
end
end
end
function hud_player_hood_change(data_item_handle, event_name)
local hood_name, cur_hood_owner, orig_hood_owner, is_contested = vint_dataitem_get(data_item_handle)
-- this will become relevant for pushbacks and display of notoriety since we always will show
-- gang noto for mission/activity gang or hood owner if hood is contested
end
function hud_player_status_inf_change(di_h, event_name)
local cash, max_followers, inventory_disabled, vehicle_logo, radio_station, cruise_control_active, camera_screenshot_enabled, force_show_cash, show_vtol_hints, vehicle_scanned = vint_dataitem_get(di_h)
local floored_cash = floor(cash)
if cash ~= Hud_player_status.cash or force_show_cash then
--Start up the cash display animation if the players cash updates
local cash_anim_h = vint_object_find("cash_anim")
--set first frame of animation to current alpha value of cash
local cash_alpha = vint_get_property(Hud_player_status.cash_h, "alpha")
local cash_anim_first_tween_h = vint_object_find("cash_anim_first_tween", cash_anim_h)
vint_set_property(cash_anim_first_tween_h, "start_value", cash_alpha)
lua_play_anim(cash_anim_h)
end
--Update cash (this gets read through hud_process() so it counts up nicely)
Hud_player_status.cash = floored_cash
if vehicle_logo == nil then
vehicle_logo = 0
end
if radio_station == nil then
radio_station = 0
end
-- Display a new vehicle logo
if Hud_current_veh_logo ~= vehicle_logo then
if Hud_current_veh_logo ~= "__unloaded" and Hud_current_veh_logo ~= 0 then
game_peg_unload(Hud_current_veh_logo)
end
Hud_current_veh_logo = vehicle_logo
if vehicle_logo == "__unloaded" or vehicle_logo == 0 then
local o = vint_object_find("vehicle_logo")
vint_set_property(o, "visible", false)
else
-- Load vehicle logo peg
game_peg_load_with_cb("hud_set_vehicle_logo", 1, vehicle_logo)
end
end
if vehicle_scanned == true then
local vehicle_scan_anim_h = vint_object_find("vehicle_scan_anim")
vint_apply_start_values(vehicle_scan_anim_h)
lua_play_anim(vehicle_scan_anim_h)
end
if radio_tuner_is_enabled() then
-- Display a new radio station
if game_is_active_input_gamepad() == false or Hud_inventory.thread == nil then
if Hud_inventory.thread == nil then
vint_set_property(Hud_radio_elements.radio_grp_h, "anchor", HUD_RADIO_GRP_HUD_X, HUD_RADIO_GRP_HUD_Y)
vint_set_property(Hud_radio_elements.radio_title_grp_h, "visible", false)
else
vint_set_property(Hud_radio_elements.radio_title_grp_h, "visible", true)
end
if game_get_platform() == "PS3" then
Hud_radio_elements.hint_right_h:set_button("ui_ctrl_ps3_btn_r1")
Hud_radio_elements.hint_left_h:set_button("ui_ctrl_ps3_btn_l1")
elseif game_is_active_input_gamepad() == false then
Hud_radio_elements.hint_right_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_NEXT_RADIO" ), false, true)
Hud_radio_elements.hint_left_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_PREV_RADIO" ) , false, true)
else
Hud_radio_elements.hint_right_h:set_button(CTRL_BUTTON_RB)
Hud_radio_elements.hint_left_h:set_button(CTRL_BUTTON_LB)
end
vint_set_property(Hud_radio_elements.radio_grp_h, "visible", true)
end
hud_radio_station_update(radio_station, false)
end
hud_cruise_control_update(cruise_control_active)
if show_vtol_hints then
hud_vtol_set_hints()
Hud_sniper_hint_bar:set_visible(true)
else
Hud_sniper_hint_bar:set_visible(false)
end
if camera_screenshot_enabled ~= Hud_camera_screenshot_enabled then
--show or hide screenshot hint... this is always on.
local h = vint_object_find("screenshot_camera_hint_grp")
vint_set_property(h, "visible", camera_screenshot_enabled)
Hud_camera.hint_key = game_get_key_name_for_action( "CBA_GAC_TAKE_SCREENSHOT" )
Hud_camera.hint_icon:set_button( Hud_camera.hint_button, Hud_camera.hint_key, false, false)
Hud_camera_screenshot_enabled = camera_screenshot_enabled
end
if game_get_platform() == "PC" and game_is_active_input_gamepad() ~= true then
local hint_icon_w,hint_icon_h = Hud_camera.hint_icon:get_size()
local adjusted_hint_x = hint_icon_w * 0.5
Hud_camera.hint_icon:set_property( "anchor", adjusted_hint_x, 0 )
local camera_hint_icon_bmp_h = vint_object_find( "camera_hint_icon_bmp" )
vint_set_property( camera_hint_icon_bmp_h, "anchor", hint_icon_w + 15, 0 )
vint_set_property(Hud_camera.hint_text, "visible", false)
else
local hint_text_w, hint_text_h = element_get_actual_size(Hud_camera.hint_text)
local hint_icon_w,hint_icon_h = Hud_camera.hint_icon:get_actual_size()
local adjusted_hint_x = hint_icon_w * 0.5
Hud_camera.hint_icon:set_property( "anchor", hint_text_w + 20 + adjusted_hint_x, 0 )
local camera_hint_icon_bmp_h = vint_object_find( "camera_hint_icon_bmp" )
vint_set_property( camera_hint_icon_bmp_h, "anchor", hint_text_w + 20 + hint_icon_w + 20, 0 )
vint_set_property(Hud_camera.hint_text, "visible", true)
end
end
-- Display a new radio station
function hud_radio_station_update(radio_station, force_update)
if Hud_current_radio_station ~= radio_station or force_update == true then
if radio_station ~= 0 then
local radio_station_small
if radio_station ~= "" then
--build the radio image name
radio_station_small = radio_station.."_sm"
vint_set_property(Hud_radio_elements.image_h, "scale", 1.25, 1.25)
vint_set_property(Hud_radio_elements.image_h, "tint", COLOR_HUD_RADIO_NAME.R, COLOR_HUD_RADIO_NAME.G, COLOR_HUD_RADIO_NAME.B)
else
radio_station_small = "ui_cell_icon_music"
vint_set_property(Hud_radio_elements.image_h, "scale", 0.6, 0.6)
vint_set_property(Hud_radio_elements.image_h, "tint", COLOR_HUD_RADIO_ICON.R, COLOR_HUD_RADIO_ICON.G , COLOR_HUD_RADIO_ICON.B)
end
vint_set_property(Hud_radio_elements.image_h, "image", radio_station_small)
if force_update == false and Hud_current_radio_station ~= 0 then
ui_audio_post_event("ui_radio_switch")
end
local arrow_pad = 20
local radio_w,radio_h = element_get_actual_size( Hud_radio_elements.image_h )
local radio_x,radio_y = vint_get_property( Hud_radio_elements.image_h, "anchor" )
local arrow_x,arrow_y = vint_get_property( Hud_radio_elements.arrow_left_h, "anchor" )
vint_set_property(Hud_radio_elements.arrow_right_h, "visible", true)
vint_set_property(Hud_radio_elements.arrow_left_h, "visible", true)
local left_arrow_adjusted_x = radio_x - ((radio_w * 0.5) + arrow_pad)
vint_set_property(Hud_radio_elements.arrow_left_h, "anchor", left_arrow_adjusted_x, arrow_y)
local right_arrow_adjusted_x = radio_x + ((radio_w * 0.5) + arrow_pad)
vint_set_property(Hud_radio_elements.arrow_right_h, "anchor", right_arrow_adjusted_x, arrow_y)
if Hud_inventory.thread == nil then -- Allow radio selection if we are not in the inventory radial
Hud_radio_elements.hint_right_h:set_visible( true )
Hud_radio_elements.hint_left_h:set_visible( true )
if game_is_active_input_gamepad() == false then -- Display keyboard command if not using gamepad
Hud_radio_elements.hint_right_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_NEXT_RADIO" ), false, true)
Hud_radio_elements.hint_left_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_PREV_RADIO" ) , false, true)
else -- Display d-pad controls if using gamepad
Hud_radio_elements.hint_right_h:set_button(CTRL_BUTTON_DPAD_RIGHT)
Hud_radio_elements.hint_left_h:set_button(CTRL_BUTTON_DPAD_LEFT)
end
local hint_right_x,hint_right_y = Hud_radio_elements.hint_right_h:get_property( "anchor" )
local hint_left_x,hint_left_y = Hud_radio_elements.hint_left_h:get_property( "anchor" )
local hint_right_w,hint_right_h = Hud_radio_elements.hint_right_h:get_property( "screen_size" )
local hint_left_w,hint_left_h = Hud_radio_elements.hint_left_h:get_property( "screen_size" )
local new_hint_right_x = right_arrow_adjusted_x + (hint_right_w * 0.5)
local new_hint_left_x = left_arrow_adjusted_x - (hint_left_w * 0.5)
Hud_radio_elements.hint_right_h:set_property( "anchor", new_hint_right_x, hint_right_y )
Hud_radio_elements.hint_left_h:set_property( "anchor", new_hint_left_x, hint_left_y )
local radio_station_alpha_twn_1_h = vint_object_find( "radio_station_alpha_twn_1", Hud_radio_elements.anim, HUD_DOC_HANDLE )
local radio_grp_alpha = vint_get_property( Hud_radio_elements.radio_grp_h, "alpha" )
-- Start the animation with what the current alpha is so as not to always fade in when switching radio stations
vint_set_property( radio_station_alpha_twn_1_h, "start_value", radio_grp_alpha )
-- Hide the first time the radio updates when the hud is loaded
if Hud_radio_has_updated then
lua_play_anim( Hud_radio_elements.anim )
else
vint_set_property(Hud_radio_elements.radio_grp_h, "alpha", 0)
vint_set_property(Hud_radio_elements.radio_grp_h, "visible", false)
end
Hud_radio_has_updated = true
else -- Show the LB/RB hints since we are in the radial inventory
local platform = game_get_platform()
if platform == "PS3" then
Hud_radio_elements.hint_right_h:set_button("ui_ctrl_ps3_btn_r1")
Hud_radio_elements.hint_left_h:set_button("ui_ctrl_ps3_btn_l1")
elseif platform == "PS4" then -- HVS_JRP[PRINCE] 3/18/2014
Hud_radio_elements.hint_right_h:set_button("ui_ctrl_ps4_btn_r1")
Hud_radio_elements.hint_left_h:set_button("ui_ctrl_ps4_btn_l1")
elseif platform == "XBOX3" then -- HVS_JRP[PRINCE] 3/18/2014
Hud_radio_elements.hint_right_h:set_button(CTRL_BUTTON_RB)
Hud_radio_elements.hint_left_h:set_button(CTRL_BUTTON_LB)
elseif game_is_active_input_gamepad() == false then
Hud_radio_elements.hint_right_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_NEXT_RADIO" ), false, true)
Hud_radio_elements.hint_left_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_PREV_RADIO" ) , false, true)
else
Hud_radio_elements.hint_right_h:set_button(CTRL_BUTTON_RB)
Hud_radio_elements.hint_left_h:set_button(CTRL_BUTTON_LB)
end
end
end
else
vint_set_property(Hud_radio_elements.radio_grp_h, "alpha", 0)
vint_set_property(Hud_radio_elements.radio_grp_h, "visible", false)
end
Hud_current_radio_station = radio_station
end
function hud_set_vehicle_logo()
local o = vint_object_find("vehicle_logo")
vint_set_property(o, "image", Hud_current_veh_logo)
lua_play_anim(vint_object_find("vehicle_logo_anim_1"), 0)
vint_set_property(o, "visible", true)
end
function hud_player_status_change(di_h, event_name)
--HUD dataitem is special and doesn't need any comments. FML. :/
local sprint_enabled, health_pct, health_level, is_dbno, bleed_out_health_pct, sprint_pct, sprint_level, is_sprinting, orientation, is_mp_invulnerable, tunnel_vision_amount, is_in_satellite_mode, is_controlling_missile, is_health_pickup, vignette_pct, num_unlocked_flaps, num_used_flaps, objective_health_pct = vint_dataitem_get(di_h)
--Blink health blue for pickup
if is_health_pickup == true and Is_health_pickup_active ~= true then
local health_pickup_anim_h = vint_object_find("health_pickup", 0, HUD_DOC_HANDLE)
local health_pickup_twn_h = vint_object_find("end_event_twn", health_pickup_anim_h)
vint_set_property(health_pickup_twn_h, "end_event", "hud_health_pickup_is_done")
lua_play_anim(health_pickup_anim_h)
Is_health_pickup_active = true
end
if Hud_super_bar.is_mech == true then
--Update health meter
element_set_actual_size(Mech_health_mask_img_h, Mech_health_width * objective_health_pct, Mech_health_height)
if (objective_health_pct < Hud_health_bar.percent) and (Mech_health_is_playing == false) then
lua_play_anim(Mech_health_anim_h)
Mech_health_is_playing = true
end
--Update weapon meter
element_set_actual_size(Mech_weapon_mask_img_h, Mech_weapon_width * sprint_pct, Mech_weapon_height)
if sprint_pct < Hud_sprint_bar.percent then
if Mech_weapon_is_playing == false then
lua_play_anim(Mech_weapon_anim_h)
Mech_weapon_is_playing = true
end
else
vint_set_property(Mech_weapon_meter_img_h, "alpha", .5)
vint_set_property(Mech_weapon_anim_h, "is_paused", true)
Mech_weapon_is_playing = false
end
vint_set_property(Mech_grp_h, "visible", true)
else
vint_set_property(Mech_grp_h, "visible", false)
end
if Hud_super_bar.is_ship == true then
--Update health meter
element_set_actual_size(Ship_health_mask_img_h, Ship_health_width * objective_health_pct, Ship_health_height)
vint_set_property(Ship_health_grp_h, "visible", true)
else
vint_set_property(Ship_health_grp_h, "visible", false)
end
local unhide_weapons = false
-- Get health difference...
local health_pct_diff = abs(Hud_health_bar.percent - health_pct)
--Since we don't have regen health, the vignette should match the health pct
vint_set_property(Hud_vignettes.health.grp_h, "alpha", vignette_pct)
if health_pct_diff > .001 or health_level ~= Hud_health_bar.level then
local bar = Hud_health_bar
local level = health_level
--get start/end angles depending on level...
local start_angle_static = bar.level_angles[level].fill_start_angle
local end_angle_static = bar.level_angles[level].fill_end_angle
local angle_offset_static = bar.level_angles[level].angle_offset
--Calculate current angles...
local fill_end_angle = (end_angle_static - start_angle_static) * health_pct + start_angle_static
local bg_end_angle = fill_end_angle - angle_offset_static
--if new health pct is less than current then do the animation of it dropping
if health_pct < Hud_health_bar.percent then
if bar.is_expanded == false then
hud_player_health_show()
end
--Decrease the health meter
hud_player_health_decrease_anim(bar, fill_end_angle, bg_end_angle)
if health_pct < .3 then
--Full screen health effect gets even heavier if it drops below .3
local vignette_alpha = .70 - health_pct
--hud_health_screen_fade(vignette_alpha)
elseif health_pct < .5 then
--Full screen health effect if drops below .5
local vignette_alpha = .5 - health_pct
--hud_health_screen_fade(vignette_alpha)
end
Hud_player_status.health_recovering = false
elseif health_pct >= Hud_health_bar.percent then
--Increase the health meter
hud_player_health_increase_anim(bar, fill_end_angle, bg_end_angle)
if Hud_player_status.health_recovering == false then
--hud_health_screen_fade(0)
Hud_player_status.health_recovering = true
end
end
if health_pct == 1 and bar.is_expanded == true then
--Start to hide the bar.
lua_play_anim(bar.timer_fade_out_anim_h)
else
vint_set_property(bar.timer_fade_out_anim_h, "is_paused", true)
end
--Make sure we can see the healthbar...
unhide_weapons = true
Hud_health_bar.percent = health_pct
Hud_health_bar.level = health_level
end
Hud_player_status.bleed_out_health_pct = bleed_out_health_pct
Hud_player_status.is_in_satellite_mode = is_in_satellite_mode
Hud_player_status.is_controlling_missile = is_controlling_missile
local unhide_sprint = false
--Sprint
-- Get Sprint difference...
local sprint_pct_diff = abs(Hud_sprint_bar.percent - sprint_pct)
if sprint_enabled == true and (sprint_pct_diff > .001 or sprint_level ~= Hud_sprint_bar.level) then
local bar = Hud_sprint_bar
local level = sprint_level
--get start/end angles depending on level...
local start_angle_static = bar.level_angles[level].fill_start_angle
local end_angle_static = bar.level_angles[level].fill_end_angle
local angle_offset_static = bar.level_angles[level].angle_offset
--Calculate current angles...
local fill_end_angle = (end_angle_static - start_angle_static) * sprint_pct + start_angle_static
local bg_end_angle = fill_end_angle - angle_offset_static
unhide_sprint = true
--Update angles for the sprint meter
vint_set_property(bar.bg_h, "end_angle", bg_end_angle)
--Hide bg of meter if sprint is empty.
if sprint_pct == 0 then
vint_set_property(bar.bg_h, "visible", false)
else
vint_set_property(bar.bg_h, "visible", true)
end
vint_set_property(bar.fill_h, "end_angle", fill_end_angle)
--Make sure we can see the sprintbar...
unhide_weapons = true
Hud_sprint_bar.percent = sprint_pct
Hud_sprint_bar.level = sprint_level
end
if is_sprinting ~= Hud_player_status.is_sprinting then
local sprint_anim_h = vint_object_find("sprint_pulse_anim")
if is_sprinting == false then
--Stop pulse animation and reset...
vint_set_property(sprint_anim_h, "is_paused", true)
vint_set_property(Hud_sprint_bar.fill_h, "tint", HUD_SPRINT_COLOR.R, HUD_SPRINT_COLOR.G, HUD_SPRINT_COLOR.B)
else
lua_play_anim(sprint_anim_h)
end
unhide_sprint = true
--Store to global...
Hud_player_status.is_sprinting = is_sprinting
end
if unhide_sprint == true then
--Should we hide the sprint bar...
local bar = Hud_sprint_bar
if (sprint_pct == 1) and (bar.is_expanded == true) and (Hud_health_bar.is_expanded == false) then
--Start to hide the bar.
lua_play_anim(bar.timer_fade_out_anim_h)
else
vint_set_property(bar.timer_fade_out_anim_h, "is_paused", true)
end
--Attempt to show the sprint bar...
hud_player_sprint_show()
--Make sure we can see the sprintbar...
unhide_weapons = true
end
if mission_is_active("mIntro") == true then
num_unlocked_flaps = 0
end
if num_unlocked_flaps == nil then
num_unlocked_flaps = 0
end
if num_unlocked_flaps > MAX_FLAPS then
num_unlocked_flaps = MAX_FLAPS
end
if num_unlocked_flaps < 0 then
num_unlocked_flaps = 0
end
if num_used_flaps == nil then
num_used_flaps = 0
end
if num_used_flaps > MAX_FLAPS then
num_used_flaps = MAX_FLAPS
end
if num_used_flaps < 0 then
num_used_flaps = 0
end
for i = 1, MAX_FLAPS do
local num_flap_used = num_unlocked_flaps - num_used_flaps + 1;
-- icons
if i < num_flap_used then
vint_set_property(Hud_flap_data.icons[i].icon_h, "visible", true)
vint_set_property(Hud_flap_data.icons[i].icon_h, "alpha", 1)
else
vint_set_property(Hud_flap_data.icons[i].icon_h, "visible", false)
end
-- icon backgrounds
if i <= num_unlocked_flaps then
vint_set_property(Hud_flap_data.backgrounds[i].bg_h, "visible", true)
vint_set_property(Hud_flap_data.backgrounds[i].bg_h, "alpha", 1)
else
vint_set_property(Hud_flap_data.backgrounds[i].bg_h, "visible", false)
vint_set_property(Hud_flap_data.icons[i].icon_h, "visible", false)
end
end
if num_used_flaps > 0 then
unhide_weapons = true
end
--If we updated the health or sprint... we unhide the weapons...
if unhide_weapons == true then
--fade in...
hud_weapon_fade_in()
end
if orientation ~= Hud_player_status.orientation then
--Rotate Hit Indicators to player rotation
orientation = 3.14 - orientation
vint_set_property(Hud_hit_elements.main_h, "rotation", orientation)
Hud_player_status.orientation = orientation
end
--Sets the amount of tunnel vision for the player
if tunnel_vision_amount ~= Hud_vignettes.tunnel_vision then--and
vint_set_property(Hud_vignettes.tunnel_vision.grp_h, "alpha", tunnel_vision_amount)
end
end
function hud_player_sprint_show()
if Hud_sprint_bar.is_expanded == false then
vint_set_property(vint_object_find("map_sprint_contract"), "is_paused", true)
lua_play_anim(vint_object_find("map_sprint_expand"))
Hud_sprint_bar.is_expanded = true
end
end
--Plays the animation which retracts the sprint bar.
--This is triggered by a callback setup in the init()
function hud_player_sprint_hide()
--Always show sprint if health is up
if (Hud_health_bar.is_expanded == false) then
vint_set_property(vint_object_find("map_sprint_expand"), "is_paused", true)
lua_play_anim(vint_object_find("map_sprint_contract"))
Hud_sprint_bar.is_expanded = false
end
end
function hud_player_health_show()
vint_set_property(vint_object_find("map_health_contract"), "is_paused", true)
lua_play_anim(vint_object_find("map_health_expand"))
Hud_health_bar.is_expanded = true
hud_player_sprint_show()
end
--Plays the animation which retracts the health bar.
--This is triggered by a callback setup in the init()
function hud_player_health_hide()
vint_set_property(vint_object_find("map_health_expand"), "is_paused", true)
lua_play_anim(vint_object_find("map_health_contract"))
Hud_health_bar.is_expanded = false
end
function hud_player_health_decrease_anim(bar, fill_end_angle, bg_end_angle)
--Flash the bar if we are not already flashing.
if Hud_health_bar.is_flashing == false then
lua_play_anim(bar.health_flash_anim_h, 0)
Hud_health_bar.is_flashing = true
end
--Decay animation...
if Hud_health_bar.is_decaying == false then
--We aren't already decaying so its safe to replay the animation...
--update the start values if we aren't decaying...
local current_start_value = vint_get_property(bar.fill_1_h, "end_angle")
local bg_start_angle = vint_get_property(bar.bg_h, "end_angle")
vint_set_property(bar.health_bg_angle_twn_h, "start_value", bg_start_angle)
vint_set_property(bar.health_fill_angle_twn_h, "start_value", current_start_value)
lua_play_anim(bar.health_decay_anim_h, 0)
-- The decaying flag will get set to true when the tween actually starts. until then we won't update that.
end
--change the state of the end tweens regardless if we are decaying or not...
--Pop start of second bar to first
vint_set_property(bar.fill_h, "end_angle", fill_end_angle)
vint_set_property(bar.fill_1_h, "start_angle", fill_end_angle)
--Set values for fill angle
vint_set_property(bar.health_fill_angle_twn_h, "end_value", fill_end_angle)
--set values for bg end angle...
vint_set_property(bar.health_bg_angle_twn_h, "end_value", bg_end_angle)
end
function hud_player_health_increase_anim(bar, fill_end_angle, bg_end_angle)
--stop decrease anims
vint_set_property(bar.health_flash_anim_h, "is_paused", true)
vint_set_property(bar.health_decay_anim_h, "is_paused", true)
Hud_health_bar.is_decaying = false
Hud_health_bar.is_flashing = false
--update the values directly...
vint_set_property(bar.fill_h, "end_angle", fill_end_angle)
vint_set_property(bar.fill_1_h, "end_angle", fill_end_angle)
vint_set_property(bar.bg_h, "end_angle", bg_end_angle)
end
--Callbacks for health animations...
function hud_health_decay_start(twn_h)
--set our decaying status to true
Hud_health_bar.is_decaying = true
end
function hud_health_decay_end(twn_h)
--set our decaying status to false...
Hud_health_bar.is_decaying = false
end
function hud_health_flash_complete(twn_h)
Hud_health_bar.is_flashing = false
end
--#####################################################
--Weapon Changes
--#####################################################
function hud_player_weapon_change(di_h, event_name)
local wpn_bmp_name, rdy_ammo, rsv_ammo, wpn_rdy, dual_wield, no_ammo, inf_ammo, cont_fire, no_mag, sniper_visible, wpn_name, wpn_category, reticule_highlight, wpn_spread, wpn_slot, cur_super_name, super_charge, super_suppressed, super_disabled, super_disabled_by_script, show_reticule, overheat_pct, is_overheated, bullet_hit, genki_target, reloading, is_recharging, is_pct, is_mech, element, power_changed, is_power_recharging = vint_dataitem_get(di_h)
Hud_super_bar.is_ship = is_mech
--set flag to hide or show the dpad menu
if super_disabled_by_script == true then
Hud_powers_are_disabled = true
else
Hud_powers_are_disabled = false
end
--Set flag to determine if we should attemp to unhide the weapons...
local unhide_weapons = false
--Update weapon area...
if wpn_bmp_name == nil then
wpn_bmp_name = "ui_hud_inv_fist"
end
--Do not show mech icon as dual
if wpn_bmp_name == "ui_hud_inv_veh_mgun_missle" then
dual_wield = false
end
if dual_wield ~= Hud_weapon_status.dual_wield or wpn_bmp_name ~= Hud_weapon_status.wpn_bmp_name then
if dual_wield == true then
vint_set_property(Hud_weapon_status.dual_wpn_icon_1_h, "image", wpn_bmp_name)
vint_set_property(Hud_weapon_status.dual_wpn_icon_2_h, "image", wpn_bmp_name)
else
vint_set_property(Hud_weapon_status.single_wpn_icon_h, "image", wpn_bmp_name)
end
unhide_weapons = true
Hud_weapon_status.wpn_bmp_name = wpn_bmp_name
end
if dual_wield ~= Hud_weapon_status.dual_wield then
vint_set_property(Hud_weapon_status.dual_wpn_icon_1_h, "visible", dual_wield)
vint_set_property(Hud_weapon_status.dual_wpn_icon_2_h, "visible", dual_wield)
vint_set_property(Hud_weapon_status.single_wpn_icon_h, "visible", not dual_wield)
unhide_weapons = true
Hud_weapon_status.dual_wield = dual_wield
end
--Update Super Power area
local super_bmp_name = -1
local grenade_slot = -1
if cur_super_name ~= -1 and cur_super_name ~= 255 and cur_super_name ~= nil then
super_bmp_name = Hud_super_powers[cur_super_name].bitmap
grenade_slot = Hud_super_powers[cur_super_name].slot
else
super_bmp_name = nil
grenade_slot = 8
end
--check if turned off
if super_disabled_by_script == false then
--Suppressed
if super_suppressed >= .33 and cur_super_name ~= -1 and cur_super_name ~= nil then
local super_strength_level = -1
if super_suppressed >= .33 and super_suppressed < .67 then
super_strength_level = 2
elseif super_suppressed >= .67 and super_suppressed < 1 then
super_strength_level = 3
else
super_strength_level = 4
end
local insert_values = {[0] = super_strength_level}
local super_strength_string = vint_insert_values_in_string("HUD_SUPER_LEVEL", insert_values)
vint_set_property(Hud_super_bar.super_strength_h, "text_tag", super_strength_string)
--vint_set_property(Hud_super_bar.super_strength_h, "visible", true)
else
--vint_set_property(Hud_super_bar.super_strength_h, "visible", false)
end
--Disabled
if super_disabled == true or is_power_recharging == true then
if Hud_super_bar.pulse_is_playing == false then
lua_play_anim(Hud_super_bar.pulse_anim_h)
Hud_super_bar.pulse_is_playing = true
end
vint_set_property(Hud_weapon_status.super_icon_h, "alpha", .5)
vint_set_property(Hud_super_bar.super_strength_h, "alpha", .5)
vint_set_property(Hud_weapon_status.element_icon_h, "alpha", .5)
else
vint_set_property(Hud_super_bar.pulse_anim_h, "is_paused", true)
Hud_super_bar.pulse_is_playing = false
vint_set_property(Hud_weapon_status.super_icon_h, "alpha", 1)
vint_set_property(Hud_super_bar.super_strength_h, "alpha", 1)
vint_set_property(Hud_weapon_status.element_icon_h, "alpha", 1)
end
vint_set_property(Hud_super_bar.fill_h, "alpha", 1)
vint_set_property(Hud_super_bar.bg_h, "alpha", 1)
vint_set_property(Hud_super_bar.pressure_fill, "alpha", .5)
else
--turned off
vint_set_property(Hud_weapon_status.super_icon_h, "alpha", 0)
vint_set_property(Hud_super_bar.fill_h, "alpha", 0)
vint_set_property(Hud_super_bar.bg_h, "alpha", 0)
vint_set_property(Hud_super_bar.super_strength_h, "alpha", 0)
vint_set_property(Hud_weapon_status.element_icon_h, "alpha", 0)
end
--super power charge meter
--adjust bg so it doesnt stick out over weapon bg edge
if super_charge == 1 or super_charge == 0 then
Hud_super_bar.angle_offset = 0
--vint_set_property(Hud_super_bar.bg_h, "visible", false)
else
Hud_super_bar.angle_offset = .07
--vint_set_property(Hud_super_bar.bg_h, "visible", true)
end
Hud_super_bar.fill_end_angle = (1 - super_charge) * 4.15
local super_fill_angle = Hud_super_bar.fill_end_angle
local super_bg_angle = Hud_super_bar.fill_end_angle - Hud_super_bar.angle_offset
vint_set_property(Hud_super_bar.fill_h, "start_angle", super_fill_angle)
vint_set_property(Hud_super_bar.bg_h, "start_angle", super_bg_angle)
--super reticule meter
Hud_super_bar.pressure_fill_end_angle = super_charge * 3.147
vint_set_property(Hud_super_bar.pressure_fill, "end_angle", Hud_super_bar.pressure_fill_end_angle)
if super_charge == 1 then
vint_set_property(Hud_super_bar.pressure_grp, "visible", false)
else
if super_bmp_name ~= -1 and super_bmp_name ~= nil then
--match meter color to icon
local super_colors = Hud_super_powers[cur_super_name].tint
vint_set_property(Hud_super_bar.pressure_fill, "tint", super_colors.R, super_colors.G, super_colors.B)
vint_set_property(Hud_super_bar.pressure_grp, "visible", true)
end
end
-- Set\Hide\Show Super Power icon
if super_bmp_name ~= Hud_weapon_status.super_bmp_name or power_changed == true or element ~= Hud_super_bar.current_element then
if super_bmp_name ~= -1 and super_bmp_name ~= nil then
--match meter color to icon
local super_colors = Hud_super_powers[cur_super_name].tint
vint_set_property(Hud_super_bar.fill_h, "visible", true)
vint_set_property(Hud_super_bar.bg_h, "visible", true)
vint_set_property(Hud_super_bar.fill_h, "tint", super_colors.R, super_colors.G, super_colors.B)
vint_set_property(Hud_super_bar.super_strength_h, "tint", super_colors.R, super_colors.G, super_colors.B)
--Set weapon bitmap...
vint_set_property(Hud_weapon_status.super_icon_h, "image", super_bmp_name) --Weapon Bitmap
--Show objects...
vint_set_property(Hud_weapon_status.super_icon_h, "visible", true) --Weapon Bitmap
--flash new super power in center of screen
vint_set_property(Hud_super_bar.element_swap_icon_h, "image", POWERS_ELEMENTS_ENUMS[element].bitmap)
vint_set_property(Hud_super_bar.super_swap_icon_h, "image", super_bmp_name)
if Hud_super_bar.swap_is_playing == false then
--start anim from faded out
vint_set_property(Hud_super_bar.super_swap_start_twn_h, "start_value", 0)
else
--already playing, start anim from faded in
vint_set_property(Hud_super_bar.super_swap_start_twn_h, "start_value", 1)
end
lua_play_anim(Hud_super_bar.super_swap_anim_h)
Hud_super_bar.swap_is_playing = true
--play super power audio on swap
audio_stop(Cur_audio_id)
Cur_audio_id = audio_object_post_event("UI_Select_SuperPower", "Super_Power_Select", Hud_super_powers[cur_super_name].sfx, nil, false)
else
--Hide objects...
--vint_set_property(Hud_super_bar.super_strength_h, "visible", false)
vint_set_property(Hud_super_bar.fill_h, "visible", false)
vint_set_property(Hud_super_bar.bg_h, "visible", false)
vint_set_property(Hud_weapon_status.super_icon_h, "visible", false)
end
unhide_weapons = true
Hud_weapon_status.super_bmp_name = super_bmp_name
Hud_super_bar.current_element = element
end
--element, we currently don't show this on the hud
if element ~= nil and element ~= -1 then
if element ~= Hud_weapon_status.element then
vint_set_property(Hud_weapon_status.element_icon_h, "image", POWERS_ELEMENTS_ENUMS[element].bitmap)
vint_set_property(Hud_weapon_status.element_icon_h, "visible", false) --set this to true to show element on hud
end
else
vint_set_property(Hud_weapon_status.element_icon_h, "visible", false)
end
Hud_weapon_status.element = element
--Show recharging info
if is_recharging == true and inf_ammo ~= true then
vint_set_property(Hud_weapon_status.single_wpn_icon_h, "alpha", .5)
vint_set_property(Hud_weapon_status.dual_wpn_icon_1_h, "alpha", .5)
vint_set_property(Hud_weapon_status.dual_wpn_icon_2_h, "alpha", .5)
vint_set_property(Hud_weapon_status.weapon_ammo_txt_h, "tint", COLOR_HUD_WEAPON_RECHARGE_TEXT.R, COLOR_HUD_WEAPON_RECHARGE_TEXT.G, COLOR_HUD_WEAPON_RECHARGE_TEXT.B)
hud_resize_text_element(Hud_weapon_status.recharging_txt_h, 80)
vint_set_property(Hud_weapon_status.recharging_txt_h, "visible", true)
else
vint_set_property(Hud_weapon_status.single_wpn_icon_h, "alpha", 1)
vint_set_property(Hud_weapon_status.dual_wpn_icon_1_h, "alpha", 1)
vint_set_property(Hud_weapon_status.dual_wpn_icon_2_h, "alpha", 1)
vint_set_property(Hud_weapon_status.weapon_ammo_txt_h, "tint", COLOR_HUD_WEAPON_DESCRIPT_TEXT.R, COLOR_HUD_WEAPON_DESCRIPT_TEXT.G, COLOR_HUD_WEAPON_DESCRIPT_TEXT.B)
vint_set_property(Hud_weapon_status.recharging_txt_h, "visible", false)
end
--Update Ammo Count
local ammo_combined = rdy_ammo + rsv_ammo
local ammo_string = ""
if is_pct == true then
if no_ammo == false then
if inf_ammo == false then
ammo_string = "" .. ammo_combined .. "%%"
else
ammo_string = "[image:ui_hud_base_smcirc_infinite]"
end
end
else
if no_ammo == false then
if no_mag == true then
if inf_ammo == false then
if cont_fire == false then
ammo_string = "" .. ammo_combined
else
ammo_string = "" .. ammo_combined
end
else
ammo_string = "[image:ui_hud_base_smcirc_infinite]"
end
else
if inf_ammo == false then
if cont_fire == false then
ammo_string = rdy_ammo .. "/" .. rsv_ammo
else
ammo_string = floor(rdy_ammo / 100) .. "/" .. floor(rsv_ammo / 100)
end
else
if cont_fire == false then
ammo_string = rdy_ammo .. "/[image:ui_hud_base_smcirc_infinite]"
else
ammo_string = floor(rdy_ammo / 100) .. "/[image:ui_hud_base_smcirc_infinite]"
end
end
end
end
end
vint_set_property(Hud_weapon_status.weapon_ammo_txt_h, "text_tag", ammo_string)
vint_set_property(Hud_weapon_status.sniper_ammo_txt_h, "text_tag", ammo_string)
Hud_weapon_status.show_reticule = show_reticule
if reloading then
vint_set_property(Hud_weapon_status.sniper_reload_txt_h, "visible", true)
lua_play_anim(Hud_weapon_status.sniper_ammo_anim, 0, HUD_DOC_HANDLE)
else
vint_set_property(Hud_weapon_status.sniper_reload_txt_h, "visible", false)
end
--Unhide weapons if the ammo string has changed, for recharge weapons only if recharging status has changed....
if is_pct then
if is_recharging or Hud_weapon_status.is_recharging ~= is_recharging or ammo_combined < Hud_weapon_status.ammo_combined then
unhide_weapons = true
end
else
if ammo_string ~= Hud_weapon_status.ammo_string then
unhide_weapons = true
Hud_weapon_status.ammo_string = ammo_string
end
end
if super_charge ~= Hud_weapon_status.super_charge then
unhide_weapons = true
Hud_weapon_status.super_charge = super_charge
end
Hud_weapon_status.is_recharging = is_recharging
Hud_weapon_status.ammo_combined = ammo_combined
--Dim Weapon if not ready
if wpn_rdy ~= Hud_weapon_status.wpn_rdy then
if wpn_rdy == true then
--Show Weapon
vint_set_property(Hud_weapon_status.weapon_grp_h, "alpha", 1)
--TODO: Show and hide reticule need to be pulled out of here and moved into a function that stacks the reticule visibility.
if Hud_weapon_status.sniper_visible == false and Hud_weapon_status.show_reticule == true then
--Show reticule
vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", true)
else
vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", false)
end
else
--Dim Weapon
vint_set_property(Hud_weapon_status.weapon_grp_h, "alpha", 0.67)
--Hide reticule
vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", false)
end
-- do not un hide weapons on weapon ready change... (JMH 10/14/2010)
-- unhide_weapons = true
Hud_weapon_status.wpn_rdy = wpn_rdy
else
-- Make sure we hide the reticule if it changes but weapon ready doesn't.
vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", show_reticule)
end
--If sniper rifle is on then show the sniper rifle and not the standard reticule
if sniper_visible ~= Hud_weapon_status.sniper_visible then
if sniper_visible == true then
vint_set_property(Hud_reticules.elements.sniper_h, "visible", true)
vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", false)
hud_sniper_set_hints()
Hud_sniper_hint_bar:set_visible(true)
else
vint_set_property(Hud_reticules.elements.sniper_h, "visible", false)
vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", true)
Hud_sniper_hint_bar:set_visible(false)
end
Hud_weapon_status.sniper_visible = sniper_visible
end
--Change reticules if we have a different weapon
if wpn_name ~= Hud_reticules.status.wpn_name or reticule_highlight ~= Hud_reticules.status.highlight then
Hud_reticule_update(wpn_name, wpn_category, reticule_highlight)
end
--Process a hit every frame
Hud_reticule_process_hit(bullet_hit)
--Do Weapon Spread
if wpn_spread ~= Hud_reticules.status.wpn_spread then
hud_reticule_spread_update(wpn_spread, Hud_reticules.configs[Hud_reticules.status.config].spread)
end
--Update current selections in the radial menu
if wpn_slot ~= Hud_weapon_radial.equipped_weapon_slot then
Hud_weapon_radial:weapon_highlight(wpn_slot, true)
--unhide_weapons = true
end
if grenade_slot ~= Hud_weapon_radial.equipped_grenade_slot then
Hud_weapon_radial:weapon_highlight(grenade_slot, true)
--unhide_weapons = true
end
if grenade_slot == 0 then
Hud_weapon_radial.equipped_grenade_slot = 0
end
hud_reticule_overheat_update(overheat_pct, is_overheated)
if unhide_weapons == true then
--fade in...
hud_weapon_fade_in()
end
if genki_target ~= HUD_GENKI_NONE then
vint_set_property(Hud_genki_images[HUD_GENKI_ETHICAL], "visible", true)
vint_set_property(Hud_genki_images[HUD_GENKI_UNETHICAL], "visible", true)
if genki_target == HUD_GENKI_ETHICAL then
vint_set_property(Hud_genki_images[HUD_GENKI_UNETHICAL], "visible", false)
vint_set_property(Hud_genki_anims[HUD_GENKI_UNETHICAL], "is_paused", true)
elseif genki_target == HUD_GENKI_UNETHICAL then
vint_set_property(Hud_genki_images[HUD_GENKI_ETHICAL], "visible", false)
vint_set_property(Hud_genki_anims[HUD_GENKI_ETHICAL], "is_paused", true)
end
lua_play_anim(Hud_genki_anims[genki_target])
end
end
function hud_resize_text_element(element_h, max_width)
vint_set_property(element_h, "scale", 1, 1)
local text_width, text_height = element_get_actual_size(element_h)
if text_width > max_width then
local text_scale = max_width/text_width
vint_set_property(element_h, "scale", text_scale, text_scale)
end
end
function hud_sniper_set_hints()
local Hud_sniper_button_hints = {
{CTRL_BUTTON_Y, "HUD_SNIPER_ZOOM_IN", game_get_key_name_for_action("CBA_OFC_ZOOM_IN")},
{CTRL_GAMEPLAY_BUTTON_A, "HUD_SNIPER_ZOOM_OUT", game_get_key_name_for_action("CBA_OFC_ZOOM_OUT")},
}
Hud_sniper_hint_bar:set_hints(Hud_sniper_button_hints)
local width, height = Hud_sniper_hint_bar:get_size()
local Hud_sniper_hint_bar_x,Hud_sniper_hint_bar_y = Hud_sniper_hint_bar:get_property("anchor")
local x = -1*(width*0.5)
vint_set_property(Hud_sniper_hint_bar.handle, "anchor", x, Hud_sniper_hint_bar_y)
vint_set_property(Hud_sniper_hint_bar.handle, "alpha", 1.0)
Hud_sniper_hint_bar:enable_text_shadow(false)
end
function hud_vtol_set_hints()
Hud_vtol_button_hints = {
{CTRL_GAMEPLAY_BUTTON_B, "SWITCH_MODE", game_get_key_name_for_action("CBA_VDC_VTOL_TRANSITION")},
}
Hud_sniper_hint_bar:set_hints(Hud_vtol_button_hints)
local width, height = Hud_sniper_hint_bar:get_size()
local Hud_sniper_hint_bar_x,Hud_sniper_hint_bar_y = Hud_sniper_hint_bar:get_property("anchor")
local x = -1*(width*0.5)
vint_set_property(Hud_sniper_hint_bar.handle, "anchor", x, Hud_sniper_hint_bar_y)
vint_set_property(Hud_sniper_hint_bar.handle, "alpha", 0.67)
Hud_sniper_hint_bar:enable_text_shadow(true)
end
function hud_weapon_fade_in()
--Fade in only if we aren't hidden...
if Hud_weapon_status.weapon_is_hidden == true and Hud_weapon_status.hud_state_h ~= nil then
ui_hud_display_remove_state(Hud_weapon_status.hud_state_h, false)
Hud_weapon_status.hud_state_h = nil
end
Hud_weapon_status.weapon_is_hidden = false
-- this fades the weapon after a time
lua_play_anim(vint_object_find("weapon_timer_anim"))
end
function hud_weapon_fade_out()
if Hud_weapon_status.weapon_is_hidden == false then
if Hud_weapon_status.hud_state_h ~= nil then
ui_hud_display_remove_state(Hud_weapon_status.hud_state_h, false)
Hud_weapon_status.hud_state_h = nil
end
local hud_state_h = ui_hud_display_create_state()
ui_hud_display_set_element(hud_state_h, HUD_ALL_ELEM, HUD_FADE_NO_CHANGE)
ui_hud_display_set_element(hud_state_h, HUD_ELEM_WEAPONS, HUD_FADE_HIDDEN)
ui_hud_display_commit_state(hud_state_h, false)
Hud_weapon_status.hud_state_h = hud_state_h
Hud_weapon_status.weapon_is_hidden = false
end
Hud_weapon_status.weapon_is_hidden = true
end
function hud_weapon_show()
Hud_weapon_status.weapon_is_hidden = false
hud_weapon_fade_in()
end
function hud_weapon_hide()
Hud_weapon_status.weapon_is_hidden = true
end
function hud_player_weapon_freq_change(di_h)
local ammo_ready, reticle_highlight, cur_wpn_spread, fine_aim_transition, water_pressure, x_screen_coord, y_screen_coord, reticule_opacity, is_player_flying, damage_multiplier, num_unlocked_flaps, num_used_flaps = vint_dataitem_get(di_h)
if fine_aim_transition ~= Hud_weapon_status.fine_aim_transition then
hud_reticule_spread_update(cur_wpn_spread, Hud_reticules.configs[Hud_reticules.status.config].spread)
if fine_aim_transition == nil then
fine_aim_transition = 0
end
--Fine aim minimap off...
local tranny = 1.2 - fine_aim_transition
tranny = limit(tranny, 0, 1)
vint_set_property(Hud_map.base_grp_h, "alpha", tranny)
Hud_weapon_status.fine_aim_transition = fine_aim_transition
end
--Update pressure
hud_reticule_update_pressure(water_pressure)
--Change x y screen coords of reticule
hud_reticule_change_position(x_screen_coord, y_screen_coord)
--Update Reticle Opacity
hud_reticule_opacity_update(reticule_opacity)
if is_player_flying then
vint_set_property(Hud_weapon_status.single_wpn_icon_h, "alpha", 0)
vint_set_property(Hud_weapon_status.dual_wpn_icon_1_h, "alpha", 0)
vint_set_property(Hud_weapon_status.dual_wpn_icon_2_h, "alpha", 0)
vint_set_property(Hud_weapon_status.weapon_ammo_txt_h, "alpha", 0)
else
vint_set_property(Hud_weapon_status.single_wpn_icon_h, "alpha", 1)
vint_set_property(Hud_weapon_status.dual_wpn_icon_1_h, "alpha", 1)
vint_set_property(Hud_weapon_status.dual_wpn_icon_2_h, "alpha", 1)
vint_set_property(Hud_weapon_status.weapon_ammo_txt_h, "alpha", 1)
end
if is_player_flying then
if Hud_reticules.status.wpn_name ~= nil then
Hud_reticule_update(nil, "WPNCAT_DOT", Hud_reticules.status.highlight)
end
end
--Update Ammo Count
local damage_multiplier_string = ""
if damage_multiplier > 100 then
vint_set_property(Hud_damage_multiplier.grp, "visible", true)
damage_multiplier_string = "X" .. damage_multiplier .. "%%"
else
vint_set_property(Hud_damage_multiplier.grp, "visible", false)
damage_multiplier_string = ""
end
vint_set_property(Hud_damage_multiplier.multiplier_txt, "text_tag", damage_multiplier_string)
-- HVS_JPM - scale damage multiplier banner so it fits localized string
local bonus_dmg_txt_h = Vdo_base_object:new("bonus_damage_txt", Hud_damage_multiplier.grp)
local bonus_dmg_bg_h = Vdo_base_object:new("frame_fill01", Hud_damage_multiplier.grp) -- background
local bonus_dmg_l_cap_h = Vdo_base_object:new("frame_cap_l01", Hud_damage_multiplier.grp) -- l cap
local bonus_dmg_r_cap_h = Vdo_base_object:new("frame_cap_r01", Hud_damage_multiplier.grp) -- r cap
local bonus_dmg_bg_anchor_x, bonus_dmg_bg_anchor_y = bonus_dmg_bg_h:get_anchor()
local bonus_dmg_bg_size_x, bonus_dmg_bg_size_y = bonus_dmg_bg_h:get_actual_size()
-- find text size
bonus_dmg_txt_h:set_text_crc(get_localized_crc_for_tag("HUD_DAMAGE_BONUS"))
local text_size_x, text_size_y = bonus_dmg_txt_h:get_actual_size()
local BONUS_DAMAGE_TEXT_PADDING = 20
local new_bg_size = text_size_x + BONUS_DAMAGE_TEXT_PADDING
-- only change if its bigger than the current size
if new_bg_size < bonus_dmg_bg_size_x then
new_bg_size = bonus_dmg_bg_size_x
end
-- set size
bonus_dmg_bg_h:set_actual_size(new_bg_size, bonus_dmg_bg_size_y)
-- reposition endcaps
bonus_dmg_l_cap_h:set_anchor(bonus_dmg_bg_anchor_x - new_bg_size/2, bonus_dmg_bg_anchor_y)
bonus_dmg_r_cap_h:set_anchor(bonus_dmg_bg_anchor_x + new_bg_size/2, bonus_dmg_bg_anchor_y)
end
function hud_player_satellite_weapon(di_h)
-- TODO: finish
end
function hud_player_respect_change(di_h)
local total_respect, respect_pct, respect_level, show_upgrades, force_show_respect = vint_dataitem_get(di_h)
local respect_meter_show_upgrade = false --Flag to determine if we want to actually show upgrades...
if Hud_player_status.respect_show_upgrades ~= show_upgrades then
-- Upgrade flag changed... so we need to do something...
--We are done showing upgrades...
if show_upgrades == false then
--Have respect animate back to normal...
Hud_respect:game_is_finished_showing_upgrades()
--Reset Fade out timer. :)
lua_play_anim(Hud_player_status.respect_timer_h)
else
--We actually need to show upgrades on for this update...
respect_meter_show_upgrade = true
end
Hud_player_status.respect_show_upgrades = show_upgrades
end
if Hud_player_status.total_respect ~= total_respect or Hud_player_status.respect_pct ~= respect_pct or respect_level ~= Hud_player_status.respect_level then
Hud_respect:update_respect(total_respect, respect_pct, respect_level, respect_meter_show_upgrade)
Hud_player_status.total_respect = total_respect
Hud_player_status.respect_pct = respect_pct
Hud_player_status.respect_level = respect_level
end
-- force_show_respect causes respect to be shown. no condition check is needed.
if Hud_player_status.respect_is_hidden == true then
lua_play_anim(vint_object_find("respect_fade_in_anim"))
Hud_player_status.respect_is_hidden = false
end
lua_play_anim(Hud_player_status.respect_timer_h)
end
--Plays the animation which hides the respect bar...
--This is triggered by a callback setup in the init()
function hud_player_respect_hide()
if Hud_player_status.respect_is_hidden ~= true then
if Hud_respect:can_hide() then
--Check if we can hide first...
lua_play_anim(vint_object_find("respect_fade_out_anim"))
Hud_player_status.respect_is_hidden = true
else
--If we can't hide then restart start the timer tween...
lua_play_anim(Hud_player_status.respect_timer_h)
end
end
end
-- Plays the animation which hides the respect bar...
-- Hides the respect but immediatly... triggered by flashpoint complete..
function hud_player_respect_force_hide()
if Hud_respect:can_hide() then
--Check if we can hide first...
Hud_respect:set_alpha(0)
Hud_player_status.respect_is_hidden = true
else
--If we can't hide then restart start the timer tween...
lua_play_anim(Hud_player_status.respect_timer_h)
end
end
function hud_player_followers_change(di_h)
local slot, head_img_name, hlth_pct, revive_time, slot_visible = vint_dataitem_get(di_h)
--No slots other than 1 to 3 allowed.
if slot < 1 or slot > 3 then
return
end
--Turn on whole followers section for a few seconds - or prolong if already on.
hud_player_followers_show()
--Show or hide slot
if slot_visible ~= Hud_followers.slot_objects[slot].visible then
vint_set_property(Hud_followers.slot_objects[slot].group_h, "visible", slot_visible)
Hud_followers.slot_objects[slot].visible = slot_visible
end
local data = Hud_followers.follower_data[slot]
local objects = Hud_followers.slot_objects[slot]
if head_img_name ~= data.head_img_name then
if head_img_name == nil then
--No homie head
--hide the icon in the homie slot by playing the close animation
vint_set_property(objects.anim_0, "is_paused", true)
--match alpha level of our tween to current value.
local alpha_level = vint_get_property(objects.head_img_h, "alpha")
local twn_h = vint_object_find("follow_head_alpha_tween_1", objects.anim_1)
vint_set_property(twn_h, "start_value", alpha_level)
--Play fade out anim...
lua_play_anim(objects.anim_1, 0)
--Be sure the timer is hidden too
vint_set_property(objects.revive_timer_h, "visible", false)
else
if data.head_img_name == nil then
vint_set_property(objects.anim_1, "is_paused", true)
lua_play_anim(objects.anim_0, 0)
end
--Reset the head image
vint_set_property(objects.head_img_h, "image", head_img_name)
end
data.head_img_name = head_img_name
end
--take damage only if health changed..
if hlth_pct ~= data.hlth_pct then
--make sure we've inited already...
if data.hlth_pct ~= nil then
local target_alpha = 1
if hlth_pct < .33 then
target_alpha = hlth_pct + .33
if hlth_pct == 0 then
target_alpha = 0.5
end
end
vint_set_property(objects.head_img_h, "alpha", target_alpha )
end
--Store data...
data.hlth_pct = hlth_pct
end
--Revives (This is the counter that shows up over the homie heads)
revive_time = floor(revive_time)
if revive_time ~= data.revive_time then
if revive_time == 0 and data.revive_time ~= 0 then
vint_set_property(objects.revive_timer_h, "visible", false)
vint_set_property(vint_object_find("follow_rev_anim"),"is_paused", true)
elseif revive_time ~= 0 and data.revive_time == 0 then
vint_set_property(objects.revive_timer_h, "visible", true)
--vint_set_property(vint_object_find("follow_rev_anim"),"is_paused", false)
lua_play_anim(vint_object_find("follow_rev_anim"))
end
if revive_time ~= 0 then
lua_play_anim(vint_object_find("follow_rev_anim"))
end
--Update Revive Time
vint_set_property(objects.revive_timer_h, "text_tag", revive_time)
data.revive_time = revive_time
end
end
function hud_player_followers_show()
if Hud_followers.is_hidden == true then
local end_event_twn_h = vint_object_find("end_event_twn", Hud_followers.fade_in)
vint_set_property(end_event_twn_h, "end_event", "hud_player_followers_prolong")
lua_play_anim(Hud_followers.fade_in)
else
hud_player_followers_prolong()
end
Hud_followers.is_hidden = false
end
function hud_player_followers_prolong()
local end_event_twn_h = vint_object_find("end_event_twn", Hud_followers.fade_out)
vint_set_property(end_event_twn_h, "end_event", "hud_player_followers_is_hidden")
vint_set_property(Hud_followers.fade_out, "is_paused", true)
lua_play_anim(Hud_followers.fade_out)
end
function hud_player_followers_is_hidden()
Hud_followers.is_hidden = true
end
function hud_balance_meter_change(di_h)
-- active bool is the meter active?
-- position float -1 to 1 indicating the position on the meter
local active, position = vint_dataitem_get(di_h)
local force_update = false
--Update visibility
if Hud_balance_status.active ~= active then
if active == true then
vint_set_property(Hud_balance_status.balance_grp_h, "visible", true)
Hud_balance_status.ls_btn:set_button(CTRL_BUTTON_LS)
if game_is_active_input_gamepad() == false then
Hud_balance_status.ls_btn:set_button(CTRL_BUTTON_LS, game_get_key_name_for_action("CAA_WALK_TURN_LEFT_RIGHT"))
end
--Fade out left stick after a little while...
lua_play_anim(Hud_balance_status.fade_out_anim_h)
else
vint_set_property(Hud_balance_status.balance_grp_h, "visible", false)
end
force_update = true
Hud_balance_status.active = active
end
--Update Position and Color
if Hud_balance_status.position ~= position or force_update == true then
--Calculate Angle
local angle = position * Hud_balance_status.max_angle
--Calculate Color
local color_r, color_g, color_b
local p_val = abs(position)
color_r = Hud_balance_status.color_base[1] - p_val * (Hud_balance_status.color_base[1] - Hud_balance_status.color_alarm[1])
color_g = Hud_balance_status.color_base[2] - p_val * (Hud_balance_status.color_base[2] - Hud_balance_status.color_alarm[2])
color_b = Hud_balance_status.color_base[3] - p_val * (Hud_balance_status.color_base[3] - Hud_balance_status.color_alarm[3])
--Set Props
vint_set_property(Hud_balance_status.arrow_image_h, "rotation", angle)
vint_set_property(Hud_balance_status.base_grp_h, "tint", color_r, color_g, color_b)
Hud_balance_status.position = position
end
end
--Health Vignette
function hud_health_screen_fade(target_alpha)
if Hud_player_status.health_screen_is_fading == true then
--screen is already fading... just update the end alpha...
vint_set_property(Hud_vignettes.health.fade_twn_h, "end_value", target_alpha)
else
--screen isnot fading so we need to restart the animation...
local current_alpha = vint_get_property(Hud_vignettes.health.grp_h, "alpha")
vint_set_property(Hud_vignettes.health.fade_twn_h, "start_value", current_alpha)
vint_set_property(Hud_vignettes.health.fade_twn_h, "end_value", target_alpha)
lua_play_anim(Hud_vignettes.health.fade_anim_h, 0)
Hud_player_status.health_screen_is_fading = true
end
end
function hud_health_screen_fade_complete()
Hud_player_status.health_screen_is_fading = false
end
--========================================================
--HUD Hits
--Things around the reticule
--========================================================
function Hud_hit_add(di_h)
local hit_index = di_h
-- distance is relative distance to target, 0 - 1
local direction, strength, distance = vint_dataitem_get(di_h)
local hit_bmp_h, hit_anim_h, hit_twn_h, fade_time, stick_time
--Check if major/minor hit
if strength > .3 then
hit_bmp_h = vint_object_clone(Hud_hit_elements.major_h)
stick_time = 1
fade_time = .5
else
hit_bmp_h = vint_object_clone(Hud_hit_elements.minor_h)
stick_time = .5
fade_time = .5
end
local hit_behind = direction
if hit_behind < 0 then
hit_behind = hit_behind + PI2
end
hit_behind = abs(hit_behind - ( PI2 - Hud_player_status.orientation ) )
if hit_behind > 1.57 and hit_behind < 4.7 then
stick_time = stick_time + 1
end
vint_set_property(hit_bmp_h, "visible", true)
vint_set_property(hit_bmp_h, "rotation", direction)
--Tween Fade out, Set Callback
hit_anim_h = vint_object_clone(Hud_hit_elements.anim_h)
hit_twn_h = vint_object_find("hit_twn", hit_anim_h)
vint_set_property(hit_twn_h, "target_handle", hit_bmp_h)
vint_set_property(hit_twn_h, "duration", fade_time)
--vint_set_property(hit_twn_h, "start_value", distance_alpha)
vint_set_property(hit_twn_h, "end_event", "hud_hit_fade_end")
lua_play_anim(hit_anim_h, stick_time)
--Store Reticule Information for further processing
Reticule_hits[hit_index] = {
hit_bmp_h = hit_bmp_h,
hit_twn_h = hit_twn_h,
hit_anim_h = hit_anim_h,
direction = direction,
strength = strength,
}
end
function hud_hit_fade_end(twn_h, event_name)
--Clean up reticule hits
for index, value in pairs(Reticule_hits) do
if value.hit_twn_h == twn_h then
vint_object_destroy(value.hit_anim_h)
vint_object_destroy(value.hit_twn_h)
vint_object_destroy(value.hit_bmp_h)
Reticule_hits[index] = nil
end
end
end
function hud_hits_updates_pos(x_screen_coord, y_screen_coord)
--y screen coordinate
local x, y = vint_get_property(Hud_hit_elements.main_h, "anchor")
vint_set_property(Hud_hit_elements.main_h, "anchor", x_screen_coord, y_screen_coord)
end
--Clears all indicators if called, designed to be called via C++
function hud_hit_clear_all()
for index, value in pairs(Reticule_hits) do
vint_object_destroy(value.hit_anim_h)
vint_object_destroy(value.hit_twn_h)
vint_object_destroy(value.hit_bmp_h)
end
Reticule_hits = {}
end
--#####################################################################
--Showing/Hiding the hud
--#####################################################################
Hud_elements = {
[HUD_ELEM_GSI] = {
target_doc = nil,
grp_name = "base_gsi",
},
[HUD_ELEM_MINIMAP] = {
target_doc = nil,
grp_name = "base_mini_map",
},
[HUD_ELEM_RETICLE] = {
target_doc = nil,
grp_name = "base_reticle",
},
[HUD_ELEM_HIT_INDICATORS] = {
target_doc = nil,
grp_name = "base_reticle_hits",
},
[HUD_ELEM_WEAPONS] = {
target_doc = nil,
grp_name = "weapons_grp",
},
[HUD_ELEM_CASH_RESPECT_HOMEY] = {
target_doc = nil,
grp_name = "base_cash_respect_homey",
},
[HUD_ELEM_WEAPON_SWAP_MESSAGE] = {
target_doc = nil,
grp_name = "base_weapon_swap_message",
},
[HUD_ELEM_RADIO_STATION] = {
target_doc = nil,
grp_name = "base_radio_station",
},
[HUD_ELEM_VEHICLE_NAME] = {
target_doc = nil,
grp_name = "base_vehicle_name",
},
[HUD_ELEM_DIVERSIONS] = {
target_doc = "hud_diversion",
grp_name = nil,
},
[HUD_ELEM_MESSAGES] = {
target_doc = "hud_msg",
grp_name = "messages_grp",
},
[HUD_ELEM_TUTORIAL_HELP] = {
target_doc = "tutorial",
grp_name = "tutorial_base_grp",
},
[HUD_ELEM_RADIAL] = {
target_doc = nil,
grp_name = "base_weapons",
},
[HUD_ELEM_AMMO_PICKUP] = {
target_doc = nil,
grp_name = "base_ammo_pickup",
},
[HUD_ELEM_COLLECTION] = {
target_doc = nil,
grp_name = "base_collection",
},
[HUD_ELEM_SUPER_REWARD] = {
target_doc = nil,
grp_name = "base_super_reward",
},
[HUD_ELEM_SCREEN_FX] = {
target_doc = nil,
grp_name = "base_full_screen_effect",
},
[HUD_ELEM_SUBTITLES] = {
target_doc = "hud_msg",
grp_name = "subtitles_grp",
},
[HUD_ELEM_OI] = {
target_doc = "object_indicator",
grp_name = "oi_base_grp",
},
[HUD_ELEM_MECH] = {
target_doc = "msn_spaceship",
grp_name = "screen_grp",
},
}
Hud_element_tweens = {}
-- hud fade parameters
-- transparency
local HUD_FADE_HIDDEN = 0
local HUD_FADE_TRANSPARENT = 1
local HUD_FADE_VISIBLE = 2
-- fade duration
local HUD_FADE_DURATION_FADE = 0
local HUD_FADE_DURATION_IMMEDIATE = 1
local Hud_tween_fade_duration = 0.25
--Fades a particular element
function hud_element_fade(element_id, fade, duration)
if duration == nil then
duration = HUD_FADE_DURATION_FADE
end
--fade: 0 = hidden, 1 = transparent, 2 = visible
local element_group
local target_document_name
local grp_name
target_document_name = Hud_elements[element_id].target_doc
grp_name = Hud_elements[element_id].grp_name
--Set alpha based on fade
local target_alpha
if fade == HUD_FADE_HIDDEN then
target_alpha = 0
elseif fade == HUD_FADE_TRANSPARENT then
target_alpha = .35
else
target_alpha = 1
end
-- Set the actual duration
local actual_duration
if (duration == HUD_FADE_DURATION_FADE) then
actual_duration = Hud_tween_fade_duration
else
actual_duration = 0
end
local grp_h, current_alpha, twn_h
--Figure out which document the elements exist in
local target_doc_h = HUD_DOC_HANDLE
if target_document_name ~= nil then
target_doc_h = vint_document_find(target_document_name)
if target_doc_h == 0 then
--This document is not loaded for whatever reason exit
return
end
end
if grp_name ~= nil then
--get the group object to fade
grp_h = vint_object_find(grp_name, nil, target_doc_h)
else
grp_h = vint_object_find("safe_frame", nil, target_doc_h)
end
--Verify that we aren't already fading something
for idx, val in pairs(Hud_element_tweens) do
if grp_h == val.grp_h then
--tween exist so delete the tween
vint_object_destroy(idx)
Hud_element_tweens[idx] = nil
end
end
--Get Current Alpha of object
current_alpha = vint_get_property(grp_h, "alpha")
local hud_root_animation = vint_object_find("root_animation", nil, target_doc_h)
--Create Tween and set values
twn_h = vint_object_create("hud_fade_tweens", "tween", hud_root_animation, target_doc_h)
vint_set_property(twn_h, "duration", actual_duration) --Fade time
vint_set_property(twn_h, "target_handle", grp_h)
vint_set_property(twn_h, "target_property", "alpha")
vint_set_property(twn_h, "start_value", current_alpha)
vint_set_property(twn_h, "end_value", target_alpha)
vint_set_property(twn_h, "start_time", vint_get_time_index(target_doc_h))
vint_set_property(twn_h, "is_paused", false)
--Set callback
vint_set_property(twn_h, "end_event", "hud_element_fade_end")
--Store for cleanup
Hud_element_tweens[twn_h] = {
grp_h = grp_h
}
-- flag this element as disabled by game
if fade == HUD_FADE_HIDDEN then
Hud_elements[ element_id ].disabled_by_game = true
else
Hud_elements[ element_id ].disabled_by_game = false
--Show/prolong the follwers section
if element_id == 5 then
hud_player_followers_show()
end
end
end
function hud_element_fade_end(tween_h, event_name)
--Delete all fade tweens and references
vint_object_destroy(tween_h)
Hud_element_tweens[tween_h] = nil
end
---------[ BUSTED/SMOKED ]---------
function hud_busted_init()
Hud_smoked_busted.handles = {}
Hud_smoked_busted.handles.grp = vint_object_find("smoked_busted")
vint_set_property(Hud_smoked_busted.handles.grp, "visible", false)
--Fade In animations
Hud_smoked_busted.handles.fade_in_anim = vint_object_find("sb_fade_in")
vint_set_property(Hud_smoked_busted.handles.fade_in_anim , "is_paused", true)
end
function hud_busted_complete()
end
function hud_busted_fade_in(smoked, delay, fade_time)
local msg, effect, color
if smoked == true then
msg = "GAMEPLAY_SMOKED"
effect = "smoked"
color = {r = .9, g = .9, b = .9}
else
msg = "GAMEPLAY_BUSTED"
effect = "busted"
color = {r = .9, g = .9, b = .9}
end
--Show Smoked busted text
vint_set_property(Hud_smoked_busted.handles.grp, "visible", true)
vint_set_property(Hud_smoked_busted.handles.grp, "alpha", 0)
vint_set_property(Hud_smoked_busted.handles.grp, "tint", color.r, color.g, color.b)
--Busted/Smoked text fade in
--JM: Removing "You're Smoked" and "Busted" text.
vint_set_property(vint_object_find("sb_text"), "text_tag", " ") --msg)
lua_play_anim(Hud_smoked_busted.handles.fade_in_anim)
--Start Interface effect, use blue version for matrix
if effect == "smoked" then
game_interface_effect_begin(effect, 1, .5, true)
--lua_play_anim(Hud_vignettes.health.blue_anim_h)
game_set_refraction_situation("screen_death")
end
end
function hud_effect_smoked()
game_interface_effect_begin("smoked", 1, 1, true)
end
function hud_effect_busted()
game_interface_effect_begin("busted", 1, 1, true)
end
function hud_effect_pause()
game_interface_effect_begin("pause", 1, 1)
end
function hud_effect_end()
game_interface_effect_end()
end
function hud_player_reset_complete()
--Reset the busted state
game_interface_effect_end(0)
--Hide Smoked busted text
vint_set_property(Hud_smoked_busted.handles.grp, "visible", false)
--vint_set_property(Hud_vignettes.health.pulse_grp_h, "tint", 36/255, 5/255, 0/255)
game_clear_refraction_situation()
end
--===================================================
--Cruise Control
--===================================================
function hud_cruise_control_update(is_active)
if is_active ~= Hud_player_status.cruise_control_active then
if is_active == true then
--Show Cruise Control Status and let it fade with the animation.
vint_set_property(Hud_player_status.cruise_control_h, "visible", true)
vint_set_property(Hud_player_status.cruise_control_h, "alpha", .8)
lua_play_anim(Hud_player_status.cruise_control_anim, 0)
Hud_cruise_control_hint_data = {
{CTRL_BUTTON_DPAD_DOWN, "HUD_CRUISE_CONTROL_NO_BUTTON", game_get_key_name_for_action("CBA_VDC_CRUISE_CONTROL_B")},
}
Hud_player_status.cruise_control_obj:set_hints(Hud_cruise_control_hint_data)
local width, height = Hud_player_status.cruise_control_obj:get_size()
local x, y = vint_get_property(Hud_player_status.cruise_control_obj.handle, "anchor")
vint_set_property(Hud_player_status.cruise_control_obj.handle, "anchor", - (width * 0.5), y)
else
--Hide status
vint_set_property(Hud_player_status.cruise_control_h, "visible", false)
end
Hud_player_status.cruise_control_active = is_active
end
end
function hud_cruise_control_update_pos(x_pos, y_pos)
local x, y = vint_get_property(Hud_player_status.cruise_control_h, "anchor")
vint_set_property(Hud_player_status.cruise_control_h, "anchor", x_pos, y_pos)
end
--===================================================
--Player Lockon
--===================================================
function hud_player_lockon_update(di_h)
local x, y, width, rotation, is_locked, is_visible = vint_dataitem_get(di_h)
vint_set_property(Hud_lockon.lock_h, "anchor", x, y)
vint_set_property(Hud_lockon.lock_txt_grp_h, "anchor", x, y)
if is_visible == true then
--Scale
local scale = width/100
local scale_hor = width/100--Hud_lockon.base_pixel_size_hor
local scale_vert = width/100--Hud_lockon.base_pixel_size_vert
vint_set_property(Hud_lockon.lock_h, "anchor", x, y)
vint_set_property(Hud_lockon.lock_h, "scale", scale, scale)
vint_set_property(Hud_lockon.lock_h, "rotation", rotation)
vint_set_property(Hud_lockon.lock_txt_grp_h, "scale", scale, scale)
local lock_vert_height = Hud_lockon.lock_base_vert_height / scale_vert
local lock_hor_height = Hud_lockon.lock_base_hor_height / scale_hor
--Rescale Innards
vint_set_property(Hud_lockon.lock1_h, "scale",Hud_lockon.lock_base_vert_width, lock_vert_height)
vint_set_property(Hud_lockon.lock2_h, "scale", Hud_lockon.lock_base_hor_width, lock_hor_height)
vint_set_property(Hud_lockon.lock3_h, "scale", Hud_lockon.lock_base_hor_width, lock_hor_height)
vint_set_property(Hud_lockon.lock4_h, "scale", Hud_lockon.lock_base_vert_width, lock_vert_height)
if is_locked then
vint_set_property(Hud_lockon.lock_lock_h,"visible",true)
vint_set_property(Hud_lockon.lock_spinner_h,"visible",false)
vint_set_property(Hud_lockon.lock_text_h,"text_tag","HUD_LOCKON_TARGET_LOCKED")
else
vint_set_property(Hud_lockon.lock_lock_h,"visible",false)
vint_set_property(Hud_lockon.lock_spinner_h,"visible",true)
vint_set_property(Hud_lockon.lock_text_h,"text_tag","HUD_LOCKON_SCANNING")
end
--Tint lockon
local color
if is_locked == true then
color = Hud_lockon.color_locked
else
color = Hud_lockon.color_unlocked
end
vint_set_property(Hud_lockon.lock_h, "tint", color.r, color.g, color.b)
vint_set_property(Hud_lockon.lock_txt_grp_h, "tint", color.r, color.g, color.b)
--Show lockon
vint_set_property(Hud_lockon.lock_h, "visible", true)
vint_set_property(Hud_lockon.lock_txt_grp_h, "visible", true)
else
vint_set_property(Hud_lockon.lock_h, "visible", false)
vint_set_property(Hud_lockon.lock_txt_grp_h, "visible", false)
end
end
function hud_cheat_icon_update(di_h)
-- active bool is the cheat active?
-- icon int 0: INVALID, 1: Inverted controls, 2: Size reduction, 3: Lag, 4: Lame weapon, 5: Slow
local active, icon = vint_dataitem_get(di_h)
vint_set_property(Hud_cheat_elements.image_grp_h, "visible", active)
vint_set_property(Hud_cheat_elements.image_h, "image", Hud_cheat_elements.images[icon])
vint_set_property(Hud_cheat_elements.image_2_h, "image", Hud_cheat_elements.images[icon])
if active then
lua_play_anim(Hud_cheat_elements.image_anim_h, 0, HUD_DOC_HANDLE)
end
end
--------------------------
--Ammo pickup notification
--------------------------
function hud_ammo_pickup_update(di_h)
local icon, amount = vint_dataitem_get(di_h)
debug_print("vint", "image: " .. var_to_string(icon) .. "\n")
debug_print("vint", "amount: " .. var_to_string(amount) .. "\n")
if Hud_ammo_pickup.is_playing == false then
hud_ammo_pickup_play(icon,amount)
else
Hud_ammo_pickup.queue[#Hud_ammo_pickup.queue] = {icon = icon, amount = amount}
end
end
--queues it up, plays each anim in order once previous is finished
function hud_ammo_pickup_next()
Hud_ammo_pickup.is_playing = false
if #Hud_ammo_pickup.queue >0 then
hud_ammo_pickup_play(Hud_ammo_pickup.queue[1].icon, Hud_ammo_pickup.queue[1].amount)
for i,entry in pairs(Hud_ammo_pickup.queue) do
if i >= #Hud_ammo_pickup.queue then
break
end
Hud_ammo_pickup.queue[i] = Hud_ammo_pickup.queue[i+1]
end
Hud_ammo_pickup.queue[#Hud_ammo_pickup.queue] = nil
end
end
-------------------------------------------------------------------------------
-- Function hud_ammo_pickup_play()
--
-- Displays how much ammo you picked up for which weapon in the bottom right
-- of the hud
--
-- @param icon - icon for the weapon that recieved ammo
-- @param amount - how much ammo was picked up
--
-------------------------------------------------------------------------------
function hud_ammo_pickup_play(icon,amount)
-- This shouldn't be called if the player didn't recieve ammo
if amount == 0 then
return
end
Hud_ammo_pickup.is_playing = true
vint_set_property(Hud_ammo_pickup.icon, "image", icon)
local width, height = element_get_actual_size(Hud_ammo_pickup.icon)
--keep the text outside the circle
if width < 60 then
width = 60
end
--position text adjacent to icon
local move_x = Hud_ammo_pickup.amount_x + (width/2)
vint_set_property(Hud_ammo_pickup.amount, "text_tag", "+ " .. amount)
vint_set_property(Hud_ammo_pickup.amount, "anchor", move_x, Hud_ammo_pickup.amount_y)
Hud_ammo_pickup.twn:set_end_event("hud_ammo_pickup_next")
lua_play_anim(Hud_ammo_pickup.anim)
end
function hud_super_reward_update(power, style) --use 0-6 for power, for style (1=Unlocked, 2=Increased), pass in nothing for generic
if Hud_super_reward.is_active == false then
Hud_super_reward.bot_twn:set_end_event("hud_super_reward_play_top")
Hud_super_reward.top_twn:set_end_event("hud_super_reward_play_bot")
Hud_super_reward.in_twn:set_end_event("hud_super_reward_play_bot")
Hud_super_reward.out_twn:set_end_event("hud_super_reward_is_done")
if power == nil or style == nil then
vint_set_property(Hud_super_reward.txt, "text_tag", "SUPER_POWERS_GENERIC")
vint_set_property(Hud_super_reward.txt2, "text_tag", "SUPER_POWERS_INCREASED")
vint_set_property(Hud_super_reward.icon_grp, "visible", false)
vint_set_property(Hud_super_reward.txt, "tint", COLOR_HUD_WEAPON_DESCRIPT_TEXT.R, COLOR_HUD_WEAPON_DESCRIPT_TEXT.G, COLOR_HUD_WEAPON_DESCRIPT_TEXT.B)
else
vint_set_property(Hud_super_reward.txt, "text_tag", Hud_super_powers[power].label)
vint_set_property(Hud_super_reward.txt, "tint", Hud_super_powers[power].tint.R, Hud_super_powers[power].tint.G, Hud_super_powers[power].tint.B)
vint_set_property(Hud_super_reward.circle_bg, "tint", Hud_super_powers[power].tint.R, Hud_super_powers[power].tint.G, Hud_super_powers[power].tint.B)
vint_set_property(Hud_super_reward.icon, "image", Hud_super_powers[power].bitmap)
vint_set_property(Hud_super_reward.icon_grp, "visible", true)
if style == 1 then
vint_set_property(Hud_super_reward.txt2, "text_tag", "SUPER_POWERS_UNLOCKED")
else
vint_set_property(Hud_super_reward.txt2, "text_tag", "SUPER_POWERS_INCREASED")
end
end
--Move down if the banner is active
if Hud_collection_is_active ~= nil and Hud_collection_is_active == true then
vint_set_property(Hud_super_reward.move_grp, "anchor", 0, 110)
else
vint_set_property(Hud_super_reward.move_grp, "anchor", 0,0)
end
Hud_super_reward.in_anim:play(0)
Hud_super_reward.words_anim:play(0)
Hud_super_reward.is_active = true
--game_set_refraction_situation("screen_collection")
end
end
function hud_super_reward_play_top()
vint_set_property(Hud_super_reward.icon_grp, "depth", -10)
Hud_super_reward.counter = Hud_super_reward.counter + 1
if Hud_super_reward.counter > 2 then
Hud_super_reward.out_anim:play(0)
Hud_super_reward.counter = 0
else
Hud_super_reward.top_anim:play(0)
end
end
function hud_super_reward_play_bot()
vint_set_property(Hud_super_reward.icon_grp, "depth", 10)
Hud_super_reward.bot_anim:play(0)
end
function hud_super_reward_is_done()
Hud_super_reward.is_active = false
end
function hud_super_swap_is_done()
Hud_super_bar.swap_is_playing = false
end
function hud_health_pickup_is_done()
Is_health_pickup_active = false
end
-------------------------------------------------------------------------------
-- Updates and Plays the Icon Objective Over the minimap.
-------------------------------------------------------------------------------
function hud_map_objective_icon(di_h)
end
function hud_gsi_supress_popout_update( supress )
Hud_gsi_supress_popout = supress
end
---------------------------------------------------------------------------------------------------
-- Function hud_homie_call_update()
--
-- Displays a homie call widget that shows the name and homie head
-- for voice lines deemed "voice in the sky"
--
-- This system currently does not support queuing. Each new call takes priority and kills any
-- existing calls.
--
-- @param action -- "start"/"stop" determines whether to play or stop a call
-- @param id -- unique identifier for call
-- @param conv -- unique id for the conversation
-- @param homie_img -- homie head icon image name
-- @param intro_delay -- amount of seconds to delay before showing the call
-- @param homie_name -- name of homie calling
--
---------------------------------------------------------------------------------------------------
function hud_homie_call_update(action, id, conv, homie_img, intro_delay, homie_name)
debug_print("vint", "----------------------- \n")
vint_debug_print("action", action)
vint_debug_print("id", id)
vint_debug_print("conv", conv)
vint_debug_print("intro_delay", intro_delay)
debug_print("vint", "----------------------- \n\n")
-- Start a new call
if action == "start" then
-- This will bash over an existing head. This is okay as it will update the id and conv, which we want
hud_homie_call_show(homie_img, intro_delay, homie_name)
-- Only update this data on a start. We do this in case we receive these out of order (ie start then stop instead of stop then start)
Hud_homie_call.prev_id = id
Hud_homie_call.prev_conv = conv
elseif action == "stop" then
-- Check to make sure we are the proper id
if id == Hud_homie_call.prev_id then
-- Check to see if the conversation is over
if conv >= 0 then
-- We need to grey out the head
hud_homie_call_greyout()
Hud_homie_call.prev_id = nil
else
-- Hide the head
hud_homie_call_hide()
Hud_homie_call.prev_id = nil
Hud_homie_call.prev_conv = nil
end
end
else
-- Make sure we are reseting the current conv
if conv == Hud_homie_call.prev_conv then
-- Hide the head
hud_homie_call_hide()
Hud_homie_call.prev_id = nil
Hud_homie_call.prev_conv = nil
end
end
end
-----------------------------------------------------------------------------------------------------------
-- Shows the homie head
--
function hud_homie_call_show(homie_img, intro_delay)
--Loop through lookup table to find loc tag for homie based on homie head image.
--JAM 4/15/13: For the record, lookup tables suck.
local homie_name = ""
if homie_img ~= nil then
for bmp, name in pairs(Hud_homie_call_names) do
if homie_img == bmp then
homie_name = name
break
end
end
end
-- Set homie info
vint_set_property(Hud_homie_call.homie_img_h, "image", homie_img)
vint_set_property(Hud_homie_call.homie_name_txt_h, "text_tag", homie_name)
-- Shrink homie name to fit
resize_text_element(Hud_homie_call.homie_name_txt_h, 135)
vint_set_property(Hud_homie_call.box_grp_h, "tint", COLOR_SAINTS_PURPLE.R, COLOR_SAINTS_PURPLE.G, COLOR_SAINTS_PURPLE.B )
vint_set_property(Hud_homie_call.grp_h, "visible", true)
--Kill the waveform
thread_kill(Hud_homie_call.waveform_thread_h)
Hud_homie_call.waveform_thread_h = -1
-- Start waveform animation
Hud_homie_call.waveform_thread_h = thread_new("hud_homie_call_simulate_waveform")
-- Adjust position for HD and SD
if vint_is_std_res() == true then
vint_set_property(Hud_homie_call.grp_h, "anchor", HUD_HOMIE_CALL_ON_SCREEN_X_SD, HUD_HOMIE_CALL_Y_SD)
else
vint_set_property(Hud_homie_call.grp_h, "anchor", HUD_HOMIE_CALL_ON_SCREEN_X, HUD_HOMIE_CALL_Y)
end
vint_set_property(Hud_homie_call.box_grp_h, "alpha", 1)
vint_set_property(Hud_homie_call.homie_img_h, "saturation", 1)
-- If we're a new call alpha in, else pop in between greyed out states
if (Hud_homie_call.call_is_greyed_out == true) or (Hud_homie_call.prev_id ~= nil) then
-- Make sure we are not greyed out!!
Hud_homie_call.call_is_greyed_out = false
return
end
-- Make sure we are not greyed out!!
Hud_homie_call.call_is_greyed_out = false
--Setup twn to alpha in
vint_set_property(Hud_homie_call.alpha_twn_h, "start_value", 0)
vint_set_property(Hud_homie_call.alpha_twn_h, "end_value", 1)
vint_set_property(Hud_homie_call.alpha_twn_h, "end_event", nil)
-- Play call slide in anim
lua_play_anim(Hud_homie_call.anim_h, 0)
end
-----------------------------------------------------------------------------------------------------------
-- Hides the homie head
--
function hud_homie_call_greyout()
vint_set_property(Hud_homie_call.box_grp_h, "alpha", 0.65)
vint_set_property(Hud_homie_call.homie_img_h, "saturation", 0.5)
-- Tells the waveform to flatten out
Hud_homie_call.call_is_greyed_out = true
end
-----------------------------------------------------------------------------------------------------------
-- Animates call out then turns visible to false after anim is done
--
function hud_homie_call_hide()
-- Make sure we are not greyed out!!
Hud_homie_call.call_is_greyed_out = false
--Kill the waveform
thread_kill(Hud_homie_call.waveform_thread_h)
Hud_homie_call.waveform_thread_h = -1
-- Alpha out to 0 from whatever the alpha currently is (could be 0.85 or 1)
local call_alpha = vint_get_property(Hud_homie_call.grp_h, "alpha")
--Setup twn to alpha out
vint_set_property(Hud_homie_call.alpha_twn_h, "start_value", call_alpha)
vint_set_property(Hud_homie_call.alpha_twn_h, "end_value", 0)
vint_set_property(Hud_homie_call.alpha_twn_h, "end_event", "hud_homie_call_hide_cb")
-- Play call slide in anim
lua_play_anim(Hud_homie_call.anim_h, 0)
end
-----------------------------------------------------------------------------------------------------------
-- Hide the homie call
--
function hud_homie_call_hide_cb()
vint_set_property(Hud_homie_call.grp_h, "visible", false)
end
-----------------------------------------------------------------------------------------------------------
-- Simulates a random waveform pattern
--
function hud_homie_call_simulate_waveform()
--Get a random number to determine frequency and which breaks (flat lines) appear
local wave_counter = rand_int(0, 50)
local flat_line_frames = 0
local new_scale_y
local last_scale_y
while true do
if wave_counter == 0 then
--Random number to determine duration of break
flat_line_frames = rand_int(1, 2)
wave_counter = -1
end
delay(1/20)
--Loop through the lines and move new scale value from left to right
for i = 11, 2, -1 do
local prev_scale_x, prev_scale_y = vint_get_property(Hud_homie_call.waveform_images[i-1], "scale")
vint_set_property(Hud_homie_call.waveform_images[i], "scale", prev_scale_x, prev_scale_y)
end
--Create a break or a random new scale
if Hud_homie_call.call_is_greyed_out ~= true then
if flat_line_frames > 0 then
new_scale_y = 0.5
flat_line_frames = flat_line_frames - 1
if flat_line_frames == 0 then
wave_counter = rand_int(0, 100)
end
else
new_scale_y = rand_float(0.5, 2)
wave_counter = wave_counter - 1
end
else
new_scale_y = 0.5
end
--Start the first line in the waveform
vint_set_property(Hud_homie_call.waveform_images[1], "scale", 0.3, new_scale_y)
end
end
function hud_mech_health_anim_is_done()
Mech_health_is_playing = false
end
function play_flap_icon_callout()
hud_weapon_fade_in()
local flap_callout_anim = vint_object_find("flap_callout_anim")
lua_play_anim(flap_callout_anim, 0)
end