./hud.lua

  1. HUD_DOC_HANDLE = -1 
  2. Hud_process_thread = -1 
  3.  
  4. --Globals 
  5. MP_enabled = false 
  6.  
  7. Challenge_tracker_enabled = false 
  8. Curr_tracked_challenge_id = -1 
  9. Curr_tracked_challenge = { } 
  10. INVALID_HANDLE = -1 
  11. HUD_KILL_ICON = 0 
  12. HUD_DEFEND_ICON = 1 
  13. HUD_USE_ICON = 2 
  14. HUD_REVIVE_ICON = 3 
  15. HUD_LOCATION_ICON = 4   
  16. HUD_COOP_ICON = 4  
  17.  
  18. Hud_powers_are_disabled = false 
  19.  
  20. Store_weapon_is_loaded = false	----Global store weapon is loaded... 
  21.  
  22. local HUD_SPRINT_COLOR = { R = 220/255, G = 220/255, B = 220/255} 
  23.  
  24. local HUD_MAP_OBJECTIVE_ICONS = { 
  25. 	[HUD_KILL_ICON] = "ui_hud_map_obj_kill", 
  26. 	[HUD_DEFEND_ICON] = "ui_hud_map_obj_protect", 
  27. 	[HUD_USE_ICON] = "ui_hud_map_obj_use", 
  28. 	[HUD_LOCATION_ICON] = "ui_hud_map_obj_goto", 
  29. } 
  30.  
  31. local HUD_INTERACT_USE 			= 0 
  32. local HUD_INTERACT_VEHICLE 	= 1 
  33. local HUD_INTERACT_EQUIP		= 2 
  34. local HUD_INTERACT_PICKUP		= 2 
  35.  
  36. HUD_DIVERSION_METER = 0 
  37. HUD_DIVERSION_METER = 1 
  38. HUD_DIVERSION_METER = 2 
  39.  
  40. local Input_tracker = -1 
  41.  
  42. local INTERACT_TYPE_STRINGS = { 
  43. 	[HUD_INTERACT_USE] = "Use", 
  44. 	[HUD_INTERACT_VEHICLE] = "Hijack", 
  45. 	[HUD_INTERACT_EQUIP] = "Equip", 
  46. 	[HUD_INTERACT_PICKUP] = "Pickup", 
  47. } 
  48.  
  49. Hud_notoriety = { 
  50. 	is_expanded = true, 
  51. } 
  52.  
  53. Hud_player_status = { 
  54. 	cash = 0, 
  55. 	bleed_out_health_pct = 1.0, 
  56. 	is_in_satellite_mode = false, 
  57. 	is_controlling_missile = false, 
  58. 	health_recovering = false, 
  59. 	respect_pct = -1, 
  60. 	total_respect = -1, 
  61. 	respect_level = -1, 
  62. 	respect_show_upgrades = false, 
  63. 	respect_is_hidden = false, 
  64. 	orientation = 0, 
  65. 	inventory_disabled = false, 
  66. 	cruise_control_active = -1, 
  67. 	cruise_control_h = -1, 
  68. 	cruise_control_anim = -1, 
  69. 	health_screen_is_fading = false, 
  70. } 
  71.  
  72. 			 
  73. Hud_cruise_control_hint_data = { 
  74. 	{CTRL_BUTTON_DPAD_DOWN, "HUD_CRUISE_CONTROL_NO_BUTTON", game_get_key_name_for_action("CBA_VDC_CRUISE_CONTROL_B")}, 
  75. } 
  76.  
  77. --Bar for health around the minimap 
  78. local Hud_health_bar = { 
  79. 	percent = -1, 
  80. 	bg_h = 0, fill_h = 0, fill_1_h = 0, 
  81. 	health_decay_anim_h 		= 0, 
  82. 	health_flash_anim_h 		= 0, 
  83. 	health_bg_angle_twn_h 	= 0, 
  84. 	health_fill_angle_twn_h = 0, 
  85. 	level_angles = { 
  86. 		[0] = {fill_start_angle = 6.3, fill_end_angle = 3.142, angle_offset = 0.035}, --180 
  87. 		[1] = {fill_start_angle = 6.3, fill_end_angle = 2.6774, angle_offset = 0.035},  
  88. 		[2] = {fill_start_angle = 6.3, fill_end_angle = 2.2128, angle_offset = 0.035},  
  89. 		[3] = {fill_start_angle = 6.3, fill_end_angle = 1.2836, angle_offset = 0.035}, 
  90. 		[4] = {fill_start_angle = 6.3, fill_end_angle = 0.819, angle_offset = 0.035}, --360 
  91. 	}, 
  92. 	level = -1, 
  93. 	is_flashing = false, 
  94. 	is_decaying = false, 
  95. 	is_expanded = true,			--Whether the meter is expanded or not 
  96. 	timer_fade_out_anim_h = 0,	--Animation for waiting for the timer to retract... 
  97. } 
  98.  
  99. --Bar for sprint around the minimap 
  100. local Hud_sprint_bar = { 
  101. 	percent = -1, 
  102. 	sprint_enabled = true, 
  103. 	is_sprinting = -1,	 
  104. 	bg_h = 0, fill_h = 0, 
  105. 	level_angles = { 
  106. 		[0] = {fill_start_angle = 6.3, fill_end_angle = 3.142, angle_offset = 0.035}, --180 
  107. 		[1] = {fill_start_angle = 6.3, fill_end_angle = 2.6774, angle_offset = 0.035},  
  108. 		[2] = {fill_start_angle = 6.3, fill_end_angle = 2.2128, angle_offset = 0.035},  
  109. 		[3] = {fill_start_angle = 6.3, fill_end_angle = 1.2836, angle_offset = 0.035}, 
  110. 		[4] = {fill_start_angle = 6.3, fill_end_angle = 0.819, angle_offset = 0.035}, --360 
  111. 	}, 
  112. 	level = -1, 
  113. 	is_flashing = false, 
  114. 	is_expanded = true, 
  115. 	timer_fade_out_anim_h = 0, --Animation for waiting for the meter to retract... 
  116. } 
  117.  
  118. --Bar for super power charge around the minimap 
  119. local Hud_super_bar = { 
  120. 	pulse_anim_h = -1, 
  121. 	pulse_is_playing = false, 
  122. 	percent = -1, 
  123. 	bg_h = 0, fill_h = 0, 
  124. 	super_disabled = false, 
  125. 	super_suppressed = -1, 
  126. 	fill_start_angle = 0,  
  127. 	fill_end_angle = 4.15, 
  128. 	angle_offset = 0.07, 
  129. 	super_strength_h = -1, 
  130. 	super_swap_icon_h = -1, 
  131. 	element_swap_icon_h = -1, 
  132. 	super_swap_anim_h = -1, 
  133. 	super_swap_end_twn_h = -1, 
  134. 	super_swap_start_twn_h = -1, 
  135. 	swap_is_playing = false, 
  136. 	pressure_fill = 0, 
  137. 	pressure_fill_end_angle = 3.147, 
  138. 	pressure_grp = -1, 
  139. 	is_mech = false, 
  140. 	is_ship = false, 
  141. 	current_element = -1 
  142. } 
  143.  
  144. local Hud_num_flaps = 0 
  145.  
  146. --Homie call positions for HD and SD 
  147. local HUD_HOMIE_CALL_ON_SCREEN_X = 96 
  148. local HUD_HOMIE_CALL_OFF_SCREEN_X = -225 
  149. local HUD_HOMIE_CALL_Y = 340 
  150.  
  151. local HUD_HOMIE_CALL_ON_SCREEN_X_SD = 48 
  152. local HUD_HOMIE_CALL_OFF_SCREEN_X_SD = -225 
  153. local HUD_HOMIE_CALL_Y_SD = 240 
  154.  
  155. --Mech hud 
  156. local Mech_health_width, Mech_health_height = -1, -1 
  157. local Mech_weapon_width, Mech_weapon_height = -1, -1 
  158.  
  159. local Mech_health_is_playing = false 
  160. local Mech_weapon_is_playing = false 
  161.  
  162. local Mech_health_meter_img_h = -1 
  163. local Mech_health_mask_img_h = -1 
  164. local Mech_weapon_meter_img_h = -1 
  165. local Mech_weapon_mask_img_h = -1 
  166. local Mech_health_anim_h = -1 
  167. local Mech_weapon_anim_h = -1 
  168. local Mech_grp_h = -1 
  169.  
  170. --Ship Health Hud 
  171. local Ship_health_width, Ship_health_height = -1, -1 
  172.  
  173. local Ship_health_is_player = false 
  174.  
  175. local Ship_health_meter_img_h = -1 
  176. local Ship_health_mask_img_h = -1 
  177. local Ship_health_grp_h = -1; 
  178.  
  179. --Lookup table to match homie names with their images 
  180. --Script only gets the images from code 
  181. local Hud_homie_call_names = { 
  182. 	["ui_homie_asha"] = "HOMIES_ASHA", 
  183. 	["ui_homie_35_ben"] = "HOMIES_BENKING", 
  184. 	["ui_homie_35_cid"] = "HOMIES_CID", 
  185. 	["ui_homie_35_cyrus"] = "HOMIES_CYRUS", 
  186. 	["ui_homie_35_dane"] = "HOMIES_DANEVOGEL", 
  187. 	["ui_homie_35_dj"] = "HOMIES_DJVETCHILD", 
  188. 	["ui_homie_35_donnie"] = "HOMIES_DONNIE", 
  189. 	["ui_homie_gat"] = "HOMIES_GAT", 
  190. 	["ui_homie_keith"] = "HOMIES_VP", 
  191. 	["ui_homie_kinzie"] = "HOMIES_KINZIE", 
  192. 	["ui_homie_35_lin"] = "HOMIES_LIN", 
  193. 	["ui_homie_35_maero"] = "HOMIES_MAERO", 
  194. 	["ui_homie_matt"] = "HOMIES_MATT", 
  195. 	["ui_homie_josh"] = "HOMIES_NYTEBLAYDE", 
  196. 	["ui_homie_pierce"] = "HOMIES_PIERCE", 
  197. 	["ui_homie_shaundi"] = "HOMIES_SHAUNDI", 
  198. 	["ui_homie_35_shaundi"] = "HOMIES_OLDSHAUNDI", 
  199. 	["ui_homie_35_tanya"] = "HOMIES_TANYA", 
  200. 	["ui_homie_viola"] = "HOMIES_VIOLA", 
  201. 	["ui_homie_35_william"] = "HOMIES_WILLIAMSHARP", 
  202. 	["ui_homie_zinyak"] = "HUD_CALL_ZINYAK", 
  203. 	["ui_homie_35_julius"] = "HOMIES_JULIUS", 
  204. 	 
  205. 	--xmas 
  206. 	["ui_homie_santa"] = "DLC2_HOMIE_SANTA_NAME", 
  207. 	["ui_homie_shaundi_future"] = "DLC2_HOMIE_FSHAUNDI_NAME", 
  208. 	["ui_homie_claws"] = "DLC2_HOMIE_CLAWZ_NAME", 
  209. 	["ui_homie_mrs_claus"] = "DLC2_HOMIE_MSCLAUS_NAME", 
  210. 	["ui_homie_gingerbread"] = "DLC2_HOMIE_GINGER_NAME", 
  211. 	 
  212. 	--hey ash 
  213. 	["ui_homie_anthony"] = "DLC5_HOMIES_ANTHONY", 
  214. 	["ui_homie_ashly"] = "DLC5_HOMIES_ASH", 
  215. 	["ui_homie_papa"] = "DLC5_HOMIES_PAPA", 
  216.  
  217. 	--GAT 
  218. 	["ui_homie_dane"] = "HOMIES_DANEVOGEL", 
  219. 	["ui_homie_blackbeard"] = "HOMIES_BLACKBEARD", 
  220. 	["ui_homie_vlad"] = "HOMIES_VLAD", 
  221. 	["ui_homie_shakespeare"] = "HOMIES_SHAKESPEARE", 
  222. 	["ui_homie_jezebel"] = "HOMIES_JEZEBEL", 
  223. 	["ui_homie_kiki"] = "HOMIES_KIKI", 
  224. } 
  225.  
  226. local Hud_homie_call = { 
  227. 	grp_h = -1, 
  228. 	homie_img_h = -1, 
  229. 	homie_name_txt = -1, 
  230. 	waveform_images = {},	 
  231. 	anim_h = -1, 
  232. 	alpha_twn_h = -1, 
  233. 	waveform_thread_h = -1, 
  234. } 
  235.  
  236. local Hud_homie_call_listener = -1 
  237.  
  238. local Cur_audio_id = -1 
  239. local Darken_h = -1 
  240. local Hud_inventory_hud_state_h = -1 
  241. local Hud_scope_state_h = -1 
  242. local Is_health_pickup_active = false 
  243.  
  244. local Hud_super_powers = { 
  245. 	[0] = {label = "SUPER_TELEKINESIS_LABEL", bitmap = "ui_hud_inv_power_tele", sfx = "Telekinesis", slot = 8, tint = COLOR_POWER_TELE}, --TELEKINESIS 
  246. 	[1] = {label = "SUPER_GROUNDPOUND_LABEL", bitmap = "ui_hud_inv_power_pound", sfx = "SuperStomp", slot = 9, tint = COLOR_POWER_POUND}, --GROUNDPOUND 
  247. 	[2] = {label = "SUPER_BUFF_LABEL", bitmap = "ui_hud_inv_power_buff", sfx = "SuperStomp", slot = 10, tint = COLOR_POWER_BUFF}, --BUFF 
  248. 	[3] = {label = "SUPER_BLAST_LABEL", bitmap = "ui_hud_inv_power_blast", sfx = "Hadouken", slot = 11, tint = COLOR_POWER_BLAST}, --BLAST 
  249. 	 
  250. 	[4] = {label = "SUPER_FORCE_SHIELD_LABEL", bitmap = "ui_hud_inv_power_shield", sfx = "SuperShield", slot = 11, tint = COLOR_POWER_MOVE}, --FORCE_SHIELD 
  251. 	[5] = {label = "SUPER_SPRINT_LABEL", bitmap = "ui_hud_inv_power_move", sfx = "Hadouken", slot = 11, tint = COLOR_POWER_MOVE}, --SPRINT 
  252. 	[6] = {label = "SUPER_JUMP_LABEL", bitmap = "ui_hud_inv_power_jump", sfx = "Hadouken", slot = 11, tint = COLOR_POWER_MOVE}, --JUMP 
  253. 	[7] = {label = "SUPER_DFA_LABEL", bitmap = "ui_hud_inv_power_dfa", sfx = "Hadouken", slot = 11, tint = COLOR_POWER_MOVE}, --DFA 
  254. } 
  255.  
  256. Hud_super_reward = { 
  257. 	move_grp = -1, 
  258. 	icon = -1, 
  259. 	txt = -1, 
  260. 	txt2 = -1, 
  261. 	words_anim = -1, 
  262. 	top_anim = -1, 
  263. 	top_twn = -1, 
  264. 	bot_anim = -1, 
  265. 	bot_twn = -1, 
  266. 	in_anim = -1, 
  267. 	in_twn = -1, 
  268. 	out_anim = -1, 
  269. 	out_twn = -1, 
  270. 	circle_bg = -1, 
  271. 	icon_grp = -1, 
  272. 	counter = 0, 
  273. 	is_active = false, 
  274. } 
  275.  
  276. --Respect VDO Object 
  277. Hud_respect = {} 
  278.  
  279. Hud_enemy_status = { 
  280. 	respect = -1, 
  281. 	respect_needed = -1, 
  282. 	respect_bar =	{ bg_h = 0, fill_0_h = 0, fill_1_h = 0, txt_grp = 0, txt = 0, 
  283. 							start_angle = 0, end_angle = 3.14						 
  284. 						} 
  285. } 
  286.  
  287. Hud_weapon_status = { 
  288. 	wpn_ready = true, 
  289. 	wpn_bmp_name = -1, 
  290. 	super_bmp_name = -1, 
  291. 	element = -1, 
  292. 	recharging_txt_h = -1, 
  293. 	recharging_anim_h = -1, 
  294. 	is_recharging = false, 
  295. 	ammo_combined = -1, 
  296. 	fine_aim_transition = 0, 
  297. 	sniper_visible = -1, 
  298. 	show_reticule = false, 
  299. 	weapon_ammo_string = -1, 
  300. 	super_charge = -1, 
  301. 	weapon_is_hidden = false, 
  302. 	categories = { 
  303. 		["WPNCAT_MELEE"] = "", 
  304. 		["WPNCAT_PISTOL"] = "ui_menu_ammo_pistol", 
  305. 		["WPNCAT_SHOTGUN"] = "ui_menu_ammo_shtgn", 
  306. 		["WPNCAT_SUB_MACHINE_GUN"] = "ui_menu_ammo_smg", 
  307. 		["WPNCAT_RIFLE"] = "ui_menu_ammo_rifle", 
  308. 		["WPNCAT_SPECIAL"] = "ui_hud_ammo_sniper", 
  309. 		["WPNCAT_THROWN"] = "", 
  310. 		["WPNCAT_HAVOK"] = "ui_hud_ammo_missile", 
  311. 	} 
  312. } 
  313.  
  314. Hud_followers = { 
  315. 	fade_in = -1, 
  316. 	fade_out = -1, 
  317. 	is_hidden = true, 
  318. 	slot_arrange = {1, 2, 3}, 
  319. 	slot_objects = { {}, {}, {} }, 
  320. 	follower_data = { 
  321. 		[1] = { head_img_name = "" }, 
  322. 		[2] = { head_img_name = "" }, 
  323. 		[3] = { head_img_name = "" }, 
  324. 	}, 
  325. } 
  326.  
  327. Hud_balance_status = { 
  328. 	active = -1,  
  329. 	position = 0, 
  330. 	balance_grp_h = 0, 
  331. 	base_image_h = 0, 
  332. 	arrow_image_h = 0, 
  333. 	min_angle = -0.466, 
  334. 	max_angle = 0.466, 
  335. 	color_base = {43/255, 208/255, 0/255}, 
  336. 	color_alarm = {220/255, 40/255, 0/255}, 
  337. 	ls_btn = 0 
  338. } 
  339.  
  340. Hud_vignettes = { 
  341. 	health = { 
  342. 		grp_h = -1, 
  343. 		pulse_grp_h = -1, 
  344. 		blue_anim_h = -1, 
  345. 		fade_anim_h = -1, 
  346. 		fade_twn_h = -1, 
  347. 		tint_anim_h = -1, 
  348. 		tint_twn_h = -1 
  349. 	}, 
  350. 	fine_aim_dim = { 
  351. 		grp_h = -1, 
  352. 	}, 
  353. 	tunnel_vision = { 
  354. 		grp_h = -1, 
  355. 		amount = 0 
  356. 	} 
  357. } 
  358.  
  359. Reticule_hits = {} 
  360.  
  361. Hud_camera = {} 
  362.  
  363. Hud_hit_elements = { 
  364. 	main = -1, 
  365. 	minor = -1, 
  366. 	major = -1, 
  367. 	anim = -1, 
  368. } 
  369.  
  370. Hud_mp_snatch_elements = { 
  371. 	main_grp_h = -1, 
  372. 	head_img_bg_h = -1, 
  373. 	recruitment_fill_h = -1, 
  374. } 
  375.  
  376.  
  377. Hud_smoked_busted = {} 
  378.  
  379. local Hud_camera_screenshot_enabled = -1		--screenshot mode enabled? 
  380.  
  381. Hud_current_veh_logo = 0 
  382. Hud_current_radio_station = 0 
  383. Hud_radio_has_updated = false 
  384. Hud_radio_show = false 
  385. Hud_map = {} 
  386.  
  387. Hud_lockon = { 
  388. 	color_locked = {r=.7,g=0,b=0}, 
  389. 	color_unlocked = {r=0,g=.8,b=0}, 
  390. 	base_pixel_size_hor = 94, 
  391. 	base_pixel_size_vert = 94 
  392. } 
  393.  
  394. local Hud_weapon_radial 
  395. Hud_gsi = -1 
  396. Hud_inventory = { 
  397. 	stick_mag = 0, 
  398. 	is_pressed = false, 
  399. } 
  400.  
  401. Hud_radio_elements = { 
  402. 	radio_grp_h = -1, 
  403. 	image_h = -1, 
  404. 	arrow_left_h = -1, 
  405. 	arrow_right_h = -1, 
  406. 	anim = -1,	 
  407. 	anim_in = -1, 
  408. 	radial_is_active = false, 
  409. 	station_is_selected = false, 
  410. } 
  411.  
  412. HUD_RADIO_GRP_HUD_X 					= 644 
  413. HUD_RADIO_GRP_HUD_Y 					= 70 
  414. HUD_RADIO_GRP_RADIAL_X 				= 500 
  415. HUD_RADIO_GRP_RADIAL_Y 				= 357 
  416. HUD_RADIO_GRP_RADIAL_SD_X			= 225 
  417. HUD_RADIO_GRP_RADIAL_SD_Y			= 244 
  418. HUD_RADIO_GRP_RADIAL_POWERS_X 	= 640 
  419. HUD_RADIO_GRP_RADIAL_POWERS_SD_X = 300 
  420.  
  421.  
  422. local Hud_cheat_elements = { 
  423. 	image_grp_h = -1, 
  424. 	image_h = -1, 
  425. 	image_2_h = -1, 
  426. 	image_anim_h = -1, 
  427. 	images = { 
  428. 		[1] = "ui_hud_icon_cheat_swap", 
  429. 		[2] = "ui_hud_icon_cheat_shrink", 
  430. 		[3] = "ui_hud_icon_cheat_lag", 
  431. 		[4] = "ui_hud_icon_cheat_gimpy", 
  432. 		[5] = "ui_hud_icon_cheat_slow", 
  433. 	} 
  434. } 
  435.  
  436. local Hud_sniper_hint_bar = -1 
  437. local Hud_sniper_button_hints = { 
  438. 	{CTRL_BUTTON_Y, "HUD_SNIPER_ZOOM_IN", game_get_key_name_for_action("CBA_OFC_ZOOM_IN")}, 
  439. 	{CTRL_GAMEPLAY_BUTTON_A, "HUD_SNIPER_ZOOM_OUT", game_get_key_name_for_action("CBA_OFC_ZOOM_OUT")}, 
  440. } 
  441.  
  442. local Hud_vtol_button_hints = { 
  443. 	{CTRL_GAMEPLAY_BUTTON_B, "SWITCH_MODE", game_get_key_name_for_action("CBA_VDC_VTOL_TRANSITION")}, 
  444. } 
  445.  
  446. local INV_WEAPON_SLOT_LAST_EQUIPPED = 12 
  447. local HUD_INVENTORY_DELAY = 0.15 
  448. 	 
  449. --enums for genki 
  450. HUD_GENKI_ETHICAL = 1 
  451. HUD_GENKI_UNETHICAL = 2 
  452. HUD_GENKI_NONE = 3 
  453.  
  454. Hud_genki_anims = {} 
  455. Hud_genki_images = {} 
  456.  
  457. --Ammo pickup 
  458. local Hud_ammo_pickup = { 
  459. 	grp = -1, 
  460. 	anim = -1, 
  461. 	twn = -1, 
  462. 	icon = -1, 
  463. 	amount = -1, 
  464. 	is_playing = -1, 
  465. 	queue = {}, 
  466. 	amount_x = -1, 
  467. 	amount_y = -1, 
  468. } 
  469.  
  470. Hud_gsi_supress_popout = false 
  471. local Hud_gsi_supress_popout_event_handle = -1 
  472.  
  473. local Hud_damage_multiplier = {} 
  474.  
  475. -- Hud flap data. 
  476. --   
  477. Hud_flap_data = { 
  478. 		 
  479. 		-- needs to be the same amount as MAX_FLAPS  
  480. 		icons = { 
  481. 			[1] = {state = -1 }, 
  482. 			[2] = {state = -1 }, 
  483. 			[3] = {state = -1 }, 
  484. 			[4] = {state = -1 }, 
  485. 			[5] = {state = -1 }, 
  486. 		}, 
  487.  
  488. 		backgrounds = { 
  489. 			[1] = {state = -1 }, 
  490. 			[2] = {state = -1 }, 
  491. 			[3] = {state = -1 }, 
  492. 			[4] = {state = -1 }, 
  493. 			[5] = {state = -1 }, 
  494. 		} 
  495. } 
  496.  
  497. -- change these according to design changes 
  498. local MAX_FLAPS				= 5 
  499. local UNLOCKED_FLAPS		= 5 
  500.  
  501. function hud_init() 
  502. 	 
  503. 	--Store document handle 
  504. 	HUD_DOC_HANDLE = vint_document_find("hud") 
  505. 	 
  506. 	MP_enabled = mp_is_enabled() 
  507. 	 
  508. 	--Pause all animations 
  509. 	vint_set_property(vint_object_find("vehicle_logo_anim_1"), "is_paused", true) 
  510. 		 
  511. 	vint_set_property(vint_object_find("map_objective_anim"), "is_paused", true) 
  512. 	 
  513. 	Hud_sniper_hint_bar = Vdo_hint_bar:new("sniper_btn_hints") 
  514. 	hud_sniper_set_hints() 
  515. 	 
  516. 	--paused? 
  517. 	vint_dataitem_add_subscription( "game_paused_item", "update", "hud_game_is_paused" ) 
  518. 	vint_dataitem_add_subscription( "game_chal_tracker_item", "update", "hud_chal_track_progress" ) 
  519. 	 
  520. 	--Ammo pickup 
  521. 	Hud_ammo_pickup.grp = vint_object_find("base_ammo_pickup", 0, HUD_DOC_HANDLE) 
  522. 	Hud_ammo_pickup.anim = vint_object_find("ammo_fade_anim") 
  523. 	Hud_ammo_pickup.icon = vint_object_find("ammo_bmp", 0, HUD_DOC_HANDLE) 
  524. 	 
  525. 	Hud_ammo_pickup.amount = vint_object_find("ammo_txt", 0, HUD_DOC_HANDLE) 
  526. 	Hud_ammo_pickup.twn = Vdo_tween_object:new("end_event_twn", Hud_ammo_pickup.anim) 
  527. 	Hud_ammo_pickup.is_playing = false 
  528. 	Hud_ammo_pickup.queue = {} 
  529. 	--Get inital anchor for text 
  530. 	Hud_ammo_pickup.amount_x, Hud_ammo_pickup.amount_y = vint_get_property(Hud_ammo_pickup.amount, "anchor") 
  531. 	 
  532. 	--vint_apply_start_values(Hud_ammo_pickup.anim) 
  533. 	vint_set_property(Hud_ammo_pickup.grp, "alpha", 0.0) 
  534. 		 
  535. 	--Map 
  536. 	Hud_map.base_grp_h = vint_object_find("map_grp") 
  537. 	 
  538. 	--Respect 
  539. 	Hud_respect = Vdo_respect_meter:new("respect_obj", 0, 0, "hud.lua", "Hud_respect") 
  540.  
  541. 	--Health Meter Setup 
  542. 	local bar = Hud_health_bar 
  543. 	bar.bg_h = vint_object_find("health_bar_bg") 
  544. 	bar.fill_h = vint_object_find("health_bar") 
  545. 	bar.fill_1_h = vint_object_find("health_bar_2") 
  546.  
  547. 	bar.health_decay_anim_h 		= vint_object_find("health_decay_anim") 
  548. 	bar.health_flash_anim_h 		= vint_object_find("health_flash_anim") 
  549. 	bar.health_bg_angle_twn_h 		= vint_object_find("health_bg_angle_twn") 
  550. 	bar.health_fill_angle_twn_h 	= vint_object_find("health_fill_angle_twn") 
  551.  
  552. 	local challenges_bar_h = vint_object_find("challenges_bar", 0, HUD_DOC_HANDLE) 
  553. 	if Challenge_tracker_enabled then 
  554. 		vint_set_property(challenges_bar_h, "visible", true) 
  555. 	else 
  556. 		vint_set_property(challenges_bar_h, "visible", false) 
  557. 	end 
  558. 	 
  559. 	local fill_start_angle =  bar.level_angles[0].fill_start_angle 
  560. 	local fill_end_angle =  bar.level_angles[0].fill_end_angle 
  561. 	local angle_offset =  bar.level_angles[0].angle_offset 
  562. 	 
  563. 	vint_set_property(bar.bg_h, 		"start_angle", fill_start_angle + angle_offset) 
  564. 	vint_set_property(bar.bg_h, 		"end_angle", 	fill_end_angle - angle_offset) 
  565. 	vint_set_property(bar.fill_h,		"start_angle",	fill_start_angle) 
  566. 	vint_set_property(bar.fill_h, 	"end_angle", 	fill_end_angle) 
  567. 	vint_set_property(bar.fill_1_h,	"start_angle",	fill_start_angle) 
  568. 	vint_set_property(bar.fill_1_h, 	"end_angle", 	fill_end_angle) 
  569.  
  570. 	--set callbacks for tweens... 
  571. 	--Flash event callback... 
  572. 	local health_flash_tween_complete_h = vint_object_find("health_flash_tween_complete") 
  573. 	vint_set_property(health_flash_tween_complete_h, "end_event", "hud_health_flash_complete") 
  574. 	 
  575. 	--Start event for decay and end event for decay... 
  576. 	vint_set_property(bar.health_bg_angle_twn_h, "start_event", "hud_health_decay_start") 
  577. 	vint_set_property(bar.health_bg_angle_twn_h,	"end_event", 	"hud_health_decay_end") 
  578.  
  579. 	--Meter retraction animation and callbacks 
  580. 	bar.timer_fade_out_anim_h = vint_object_find("map_health_timer_anim") 
  581. 	local timer_twn_h = vint_object_find("health_timer_twn") 
  582. 	vint_set_property(timer_twn_h, "end_event", "hud_player_health_hide") 
  583. 	 
  584. 	--Mech HUD 
  585. 	Mech_health_meter_img_h = vint_object_find("health_meter_img", 0, HUD_DOC_HANDLE) 
  586. 	Mech_health_mask_img_h = vint_object_find("health_mask_img", 0, HUD_DOC_HANDLE) 
  587. 	Mech_weapon_meter_img_h = vint_object_find("weapon_meter_img", 0, HUD_DOC_HANDLE) 
  588. 	Mech_weapon_mask_img_h = vint_object_find("weapon_mask_img", 0, HUD_DOC_HANDLE) 
  589. 	Mech_health_anim_h = vint_object_find("mech_health_anim", 0, HUD_DOC_HANDLE) 
  590. 	local mech_health_twn_h = vint_object_find("end_event_twn", Mech_health_anim_h) 
  591. 	Mech_weapon_anim_h = vint_object_find("mech_weapon_anim", 0, HUD_DOC_HANDLE) 
  592. 	Mech_grp_h = vint_object_find("mech_grp", 0, HUD_DOC_HANDLE) 
  593. 	Mech_health_width, Mech_health_height = element_get_actual_size(Mech_health_mask_img_h) 
  594. 	Mech_weapon_width, Mech_weapon_height = element_get_actual_size(Mech_weapon_mask_img_h) 
  595. 	vint_set_property(Mech_grp_h, "visible", false)		 
  596. 	vint_set_property(Mech_grp_h, "visible", false)	 
  597. 	vint_set_property(mech_health_twn_h, "end_event", "hud_mech_health_anim_is_done") 
  598. 	 
  599. 	-- Pirate Ship HUD 
  600. 	Ship_health_meter_img_h = vint_object_find("meter_base", 0, HUD_DOC_HANDLE) 
  601. 	Ship_health_mask_img_h = vint_object_find("vehicle_meter_mask", 0, HUD_DOC_HANDLE) 
  602. 	Ship_health_grp_h = vint_object_find("base_vehicle_health", 0, HUD_DOC_HANDLE)	 
  603.  
  604. 	Ship_health_width, Ship_health_height = element_get_actual_size(Ship_health_mask_img_h) 
  605. 	vint_set_property(Ship_health_grp_h, "visible", false)		 
  606. 	 
  607. 	--Sprint Meter Setup  
  608. 	bar = Hud_sprint_bar 
  609. 	bar.bg_h = vint_object_find("sprint_bar_bg") 
  610. 	bar.fill_h = vint_object_find("sprint_bar") 
  611. 	 
  612. 	local fill_start_angle =  bar.level_angles[0].fill_start_angle 
  613. 	local fill_end_angle =  bar.level_angles[0].fill_end_angle 
  614. 	local angle_offset =  bar.level_angles[0].angle_offset 
  615. 	 
  616. 	vint_set_property(bar.bg_h, 		"start_angle", fill_start_angle + angle_offset) 
  617. 	vint_set_property(bar.bg_h, 		"end_angle", 	fill_end_angle - angle_offset) 
  618. 	vint_set_property(bar.fill_h,		"start_angle",	fill_start_angle) 
  619. 	vint_set_property(bar.fill_h, 	"end_angle", 	fill_end_angle) 
  620. 	 
  621. 	Darken_h = vint_object_find("darken") 
  622. 	 
  623. 	--Meter retraction animation and callbacks 
  624. 	bar.timer_fade_out_anim_h = vint_object_find("map_sprint_timer_anim") 
  625. 	local timer_twn_h = vint_object_find("sprint_timer_twn") 
  626. 	vint_set_property(timer_twn_h, "end_event", "hud_player_sprint_hide") 
  627. 	 
  628. 	--Respect Timeout 
  629. 	Hud_player_status.respect_timer_h = vint_object_find("respect_timer_anim") 
  630. 	local timer_twn_h = vint_object_find("respect_timer_twn") 
  631. 	vint_set_property(timer_twn_h, "end_event", "hud_player_respect_hide") 
  632.  
  633. 	--Weapon Timeout timer... 
  634. 	local h = vint_object_find("weapon_timer_twn") 
  635. 	vint_set_property(h, "end_event", "hud_weapon_fade_out") 
  636. 	 
  637. 	--Cash and hide it 
  638. 	Hud_player_status.cash_h = vint_object_find("cash") 
  639. 	vint_set_property(Hud_player_status.cash_h, "alpha", 0) 
  640. 	 
  641. 	--Ammo/Weapons 
  642. 	Hud_weapon_status.weapon_base_h = vint_object_find("weapons_grp")								--Group containing weapon/super icons and count 
  643. 	Hud_weapon_status.weapon_grp_h = vint_object_find("weapon_icons_grp")						--Group containing weapon/super icons and count 
  644. 	 
  645. 	Hud_weapon_status.weapon_ammo_txt_h = vint_object_find("weapon_ammo_txt") 
  646. 	Hud_weapon_status.single_wpn_icon_h = vint_object_find("weapon_icon") 
  647. 	Hud_weapon_status.dual_wpn_icon_1_h = vint_object_find("dual_weapon_1") 
  648. 	Hud_weapon_status.dual_wpn_icon_2_h = vint_object_find("dual_weapon_2") 
  649. 	 
  650. 	Hud_weapon_status.sniper_ammo_txt_h = vint_object_find("sniper_ammo_txt") 
  651. 	Hud_weapon_status.sniper_reload_txt_h = vint_object_find("sniper_reload_text") 
  652. 	Hud_weapon_status.sniper_ammo_anim = vint_object_find("sniper_reload_anim", 0, HUD_DOC_HANDLE) 
  653. 	 
  654. 	Hud_weapon_status.recharging_txt_h = vint_object_find("recharging_txt") 
  655. 	Hud_weapon_status.recharging_anim_h = vint_object_find("recharging_anim") 
  656. 	lua_play_anim(Hud_weapon_status.recharging_anim_h) 
  657.  
  658. 	-- Damage Multiplier Text 
  659. 	Hud_damage_multiplier.grp = vint_object_find("base_damage_multiplier") 
  660. 	Hud_damage_multiplier.multiplier_txt= vint_object_find("damage_multiplier_txt") 
  661. 	 
  662. 	--Super Bar 
  663. 	Hud_weapon_status.super_icon_h = vint_object_find("super_icon") 
  664. 	Hud_weapon_status.element_icon_h = vint_object_find("element_icon") 
  665. 	 
  666. 	Hud_super_bar.fill_h = vint_object_find("super_fill") 
  667. 	Hud_super_bar.bg_h = vint_object_find("super_bg") 
  668. 	Hud_super_bar.pulse_anim_h = vint_object_find("super_pulse_anim") 
  669. 	Hud_super_bar.super_strength_h = vint_object_find("super_strength") 
  670. 	Hud_super_bar.super_swap_icon_h = vint_object_find("super_swap_icon") 
  671. 	Hud_super_bar.element_swap_icon_h = vint_object_find("element_swap_icon") 
  672. 	Hud_super_bar.super_swap_anim_h = vint_object_find("super_swap_anim") 
  673. 	Hud_super_bar.super_swap_end_twn_h = vint_object_find("end_event_twn", Hud_super_bar.super_swap_anim_h) 
  674. 	Hud_super_bar.super_swap_start_twn_h = vint_object_find("start_twn", Hud_super_bar.super_swap_anim_h) 
  675. 	vint_set_property(Hud_super_bar.super_swap_end_twn_h, "end_event", "hud_super_swap_is_done") 
  676. 	Hud_super_bar.pressure_fill = vint_object_find("super_pressure_fill") 
  677. 	Hud_super_bar.pressure_grp = vint_object_find("super_pressure_grp") 
  678. 	 
  679. 	--Super Reward 
  680. 	Hud_super_reward.move_grp = vint_object_find("super_reward_move_grp") 
  681. 	Hud_super_reward.icon = vint_object_find("super_reward_icon") 
  682. 	Hud_super_reward.txt = vint_object_find("super_reward_txt") 
  683. 	Hud_super_reward.txt2 = vint_object_find("super_reward_unlock_txt") 
  684. 	Hud_super_reward.words_anim = Vdo_anim_object:new("super_reward_words", 0, HUD_DOC_HANDLE) 
  685. 	Hud_super_reward.top_anim = Vdo_anim_object:new("super_reward_top", 0, HUD_DOC_HANDLE) 
  686. 	Hud_super_reward.top_twn = Vdo_tween_object:new("end_event_twn", Hud_super_reward.top_anim.handle) 
  687. 	Hud_super_reward.bot_anim = Vdo_anim_object:new("super_reward_bot", 0, HUD_DOC_HANDLE) 
  688. 	Hud_super_reward.bot_twn = Vdo_tween_object:new("end_event_twn", Hud_super_reward.bot_anim.handle) 
  689. 	Hud_super_reward.in_anim = Vdo_anim_object:new("super_reward_in", 0, HUD_DOC_HANDLE) 
  690. 	Hud_super_reward.in_twn = Vdo_tween_object:new("end_event_twn", Hud_super_reward.in_anim.handle) 
  691. 	Hud_super_reward.out_anim = Vdo_anim_object:new("super_reward_out", 0, HUD_DOC_HANDLE) 
  692. 	Hud_super_reward.out_twn = Vdo_tween_object:new("end_event_twn", Hud_super_reward.out_anim.handle) 
  693. 	Hud_super_reward.circle_bg = vint_object_find("super_circle_bg") 
  694. 	Hud_super_reward.icon_grp = vint_object_find("super_icon_grp") 
  695. 	Hud_super_reward.counter = 0 
  696. 	Hud_super_reward.is_active = false 
  697. 	 
  698. 	--Balance Meter 
  699. 	local balance_meter = vint_object_find("balance_meter") 
  700. 	Hud_balance_status.balance_grp_h = balance_meter 
  701. 	Hud_balance_status.base_grp_h = vint_object_find("base_grp", balance_meter) 
  702. 	Hud_balance_status.arrow_image_h = vint_object_find("arrow_grp", balance_meter) 
  703. 	Hud_balance_status.fade_out_anim_h = vint_object_find("balance_ls_fade_out")		-- Animation fades out left stick button 
  704. 	 
  705. 	Hud_balance_status.ls_btn = Vdo_hint_button:new("ls_btn", 0, HUD_DOC_HANDLE) 
  706. 	 
  707. 	 
  708. 	--cheat icons 
  709. 	Hud_cheat_elements.image_grp_h = vint_object_find("cheats_grp") 
  710. 	Hud_cheat_elements.image_h = vint_object_find("cheat_icon") 
  711. 	Hud_cheat_elements.image_2_h = vint_object_find("cheat_icon_2") 
  712. 	Hud_cheat_elements.image_anim_h = vint_object_find("cheat_in_anim") 
  713. 	 
  714. 	--Vignette 
  715. 	local h = vint_object_find("vignettes") 
  716. 	Hud_vignettes.health.grp_h = vint_object_find("vignette_health", h ) 
  717. 	Hud_vignettes.health.pulse_grp_h = vint_object_find("vignette_health_pulse", h ) 
  718. 	Hud_vignettes.health.blue_anim_h = vint_object_find("vignette_blue_anim") 
  719. 	Hud_vignettes.health.fade_anim_h = vint_object_find("vignette_fade_anim") 
  720. 	Hud_vignettes.health.fade_twn_h = vint_object_find("vignette_alpha_twn") 
  721. 	Hud_vignettes.tunnel_vision.grp_h = vint_object_find("tunnel_vision", h) 
  722. 	 
  723. 	vint_set_property(Hud_vignettes.health.fade_twn_h, "end_event", "hud_health_screen_fade_complete") 
  724.  
  725. 	--Followers 
  726. 	Hud_followers.fade_in = vint_object_find("follow_fade_in_anim") 
  727. 	Hud_followers.fade_out = vint_object_find("follow_fade_out_anim") 
  728. 	 
  729. 	 
  730. 	local master_follower_anim_0 = vint_object_find("follow_anim_0") 
  731. 	local master_follower_anim_1 = vint_object_find("follow_anim_1") 
  732. 	local master_count_tween_alpha = vint_object_find("follow_rev_count_alpha_0") 
  733.  
  734. 	for i = 1, 3 do 
  735. 		local slot_object = Hud_followers.slot_objects[i] 
  736. 		local grp = vint_object_find("follower_grp_" .. i) 
  737. 		slot_object.name = i 
  738. 		slot_object.head_img_h = vint_object_find("follower_head", grp) 
  739. 		slot_object.frame_img_h = vint_object_find("follower_frame", grp) 
  740. 		slot_object.revive_timer_h = vint_object_find("follower_count", grp) 
  741. 		slot_object.visible = -1 
  742. 		slot_object.group_h = grp 
  743.  
  744. 		--clone animations into slots 
  745. 		local anim_0 = vint_object_clone(master_follower_anim_0) 
  746. 		local anim_1 = vint_object_clone(master_follower_anim_1) 
  747. 		slot_object.anim_0 = anim_0 
  748. 		slot_object.anim_1 = anim_1 
  749. 		vint_set_property(anim_0, "target_handle", grp) 
  750. 		vint_set_property(anim_1, "target_handle", grp) 
  751.  
  752. 		--Duplicate Tweens for Counting Anim 
  753. 		local count_tween_alpha_h = vint_object_clone(master_count_tween_alpha) 
  754. 		vint_set_property(count_tween_alpha_h, "target_handle", slot_object.revive_timer_h) 
  755. 	end 
  756. 	 
  757. 	--Hit Indicator  
  758. 	Hud_hit_elements.main_h = vint_object_find("hits") 
  759. 	h = Hud_hit_elements.main_h  
  760. 	Hud_hit_elements.minor_h = vint_object_find("major", h) 
  761. 	Hud_hit_elements.major_h = vint_object_find("major", h) 
  762. 	Hud_hit_elements.anim_h = vint_object_find("hit_anim") 
  763.  
  764. 	--Cruise Control 
  765. 	Hud_player_status.cruise_control_h = vint_object_find("cruise_control_grp") 
  766. 	Hud_player_status.cruise_control_obj = Vdo_hint_bar:new("cruise_control_hint_bar", 0, HUD_DOC_HANDLE) 
  767. 	Hud_player_status.cruise_control_anim = vint_object_find("cruise_control_fade_anim") 
  768.  
  769. 	--Hud Lockon 
  770. 	 
  771. 	Hud_lockon.lock_h = vint_object_find("lockon") 
  772. 	Hud_lockon.lock1_h = vint_object_find("lockon_1", Hud_lockon.lockon_h ) 
  773. 	Hud_lockon.lock2_h = vint_object_find("lockon_2", Hud_lockon.lockon_h ) 
  774. 	Hud_lockon.lock3_h = vint_object_find("lockon_3", Hud_lockon.lockon_h ) 
  775. 	Hud_lockon.lock4_h = vint_object_find("lockon_4", Hud_lockon.lockon_h ) 
  776. 	 
  777. 	Hud_lockon.lock_txt_grp_h = vint_object_find("lockon_txt_grp") 
  778. 	Hud_lockon.lock_text_h = vint_object_find("lockon_txt", Hud_lockon.lock_txt_grp_h) 
  779. 	Hud_lockon.lock_lock_h = vint_object_find("scan_lock", Hud_lockon.lock_txt_grp_h) 
  780. 	Hud_lockon.lock_spinner_h = vint_object_find("scan_spinner", Hud_lockon.lock_txt_grp_h) 
  781. 	Hud_lockon.lock_anim_h = vint_object_find("lockon_anim") 
  782. 	 
  783. 	lua_play_anim(Hud_lockon.lock_anim_h, 0, HUD_DOC_HANDLE) 
  784. 	 
  785. 	--lockon base screensize 
  786. 	Hud_lockon.lock_base_hor_width, Hud_lockon.lock_base_hor_height = vint_get_property(Hud_lockon.lock2_h, "scale") 
  787. 	Hud_lockon.lock_base_vert_width, Hud_lockon.lock_base_vert_height = vint_get_property(Hud_lockon.lock1_h, "scale")	 
  788. 	 
  789. 	--initialize the radio elements 
  790. 	Hud_radio_elements.radio_grp_h = vint_object_find("radio_grp") 
  791. 	Hud_radio_elements.radio_title_grp_h = vint_object_find("radio_title_grp") 
  792. 	Hud_radio_elements.image_h = vint_object_find("radio_station_image") 
  793. 	Hud_radio_elements.arrow_left_h = vint_object_find("radio_left_arrow") 
  794. 	Hud_radio_elements.arrow_right_h = vint_object_find("radio_right_arrow") 
  795. 	Hud_radio_elements.hint_left_h = Vdo_hint_button:new("radio_hint_left", 0, HUD_DOC_HANDLE) 
  796. 	Hud_radio_elements.hint_right_h = Vdo_hint_button:new("radio_hint_right", 0, HUD_DOC_HANDLE) 
  797. 	Hud_radio_elements.anim = vint_object_find("radio_station_anim_1") 
  798. 	Hud_radio_elements.anim_in = vint_object_find("radio_in_anim") 
  799. 		 
  800. 	--Find homie call elements 
  801. 	Hud_homie_call.grp_h = vint_object_find("base_homie_call") 
  802. 	Hud_homie_call.box_grp_h = vint_object_find("box_grp", Hud_homie_call.grp_h, HUD_DOC_HANDLE) 
  803. 	Hud_homie_call.homie_img_h = vint_object_find("homie_img") 
  804. 	Hud_homie_call.homie_name_txt_h = vint_object_find("homie_name_txt") 
  805. 	Hud_homie_call.anim_h = vint_object_find("homie_call_anim")	 
  806. 	Hud_homie_call.alpha_twn_h = vint_object_find("homie_call_alpha_twn") 
  807. 		 
  808. 	for i = 1, 11 do 
  809. 		Hud_homie_call.waveform_images[i] = vint_object_find("bar_img_"..i) 
  810. 	end	 
  811. 	 
  812. 	vint_set_property(Hud_homie_call.grp_h, "visible", false) 
  813. 	vint_set_property(Hud_homie_call.grp_h, "alpha", 0) 
  814. 	 
  815. 	--Listen for hud homie call updates 
  816. 	Hud_homie_call_listener = vint_scriptevent_listen( "hud_voice", "hud_homie_call_update" ) 
  817. 	 
  818. 	--Initialize controls for Radio Selection 
  819. 	Input_tracker = Vdo_input_tracker:new() 
  820. 	Input_tracker:add_input("black", "hud_inventory_input", 50, nil, nil, false) 
  821. 	Input_tracker:add_input("white", "hud_inventory_input", 50, nil, nil, false) 
  822. 	Input_tracker:subscribe(false) 
  823. 	 
  824. 	--Initialize Gameplay Status Indicator 
  825. 	Hud_gsi = Vdo_gsi:new("gsi", 0, 0, "hud.lua", "Hud_gsi") 
  826. 	vint_datagroup_add_subscription("sr2_local_player_gameplay_indicator_status", "insert", "hud_gsi_vdo_update") 
  827. 	vint_datagroup_add_subscription("sr2_local_player_gameplay_indicator_status", "update", "hud_gsi_vdo_update") 
  828. 	 
  829. 	--Find Genki anims and images 
  830. 	Hud_genki_anims = { 
  831. 		[HUD_GENKI_ETHICAL] = vint_object_find("genki_ethical_anim"), 
  832. 		[HUD_GENKI_UNETHICAL] = vint_object_find("genki_unethical_anim"), 
  833. 		[HUD_GENKI_NONE] = -1, 
  834. 	} 
  835. 	 
  836. 	Hud_genki_images = { 
  837. 		[HUD_GENKI_ETHICAL] = vint_object_find("ethical_img"), 
  838. 		[HUD_GENKI_UNETHICAL] = vint_object_find("unethical_img"), 
  839. 	} 
  840. 	 
  841. 	--Setup Camera hint for taking screenshots. 
  842. 	-- Set Control Image... 
  843. 	Hud_camera.hint_icon = Vdo_hint_button:new("camera_hint_button") 
  844. 	Hud_camera.hint_button = CTRL_MENU_BUTTON_BACK 
  845. 	Hud_camera.hint_text = vint_object_find("camera_hint_txt", 0, HUD_DOC_HANDLE) 
  846. 	Hud_camera.hint_key = game_get_key_name_for_action( "CBA_GAC_TAKE_SCREENSHOT" ) 
  847.  
  848. 	--vint_set_property(camera_hint_icon_bmp_h, "image", get_dpad_down_image()) 
  849. 		 
  850. 	--Initialize Mayhem Hud 
  851. 	hud_mayhem_init() 
  852. 	 
  853. 	--Initialize Object Indicators 
  854. 	--object_indicators_init() 
  855. 	 
  856. 	--Initialize Floating Healthbars (sewage version) 
  857. 	hud_healthbars_init() 
  858. 	 
  859. 	--Initialize reticule related stuff, 
  860. 	hud_reticules_init() 
  861. 	 
  862. 	hud_busted_init() 
  863. 	 
  864. 	--DISABLE Vehicle logo... 
  865. 	local h = vint_object_find("vehicle_logo") 
  866. 	vint_set_property(h, "visible", false) 
  867.  
  868. 	--Init VDO Objects 
  869. 	--Weapon Radial VDO Initialize and Hide 
  870. 	Hud_weapon_radial = Vdo_weapon_radial:new("radial_grp") 
  871. 	Hud_weapon_radial:show(false) 
  872. 	vint_set_property(Darken_h, "visible", false) 
  873. 	 
  874. 	--Radial Menu Subscriptions 
  875. 	vint_datagroup_add_subscription("sr2_local_player_inventory", "insert", "hud_radial_menu_update") 
  876. 	vint_datagroup_add_subscription("sr2_local_player_inventory", "update", "hud_radial_menu_update") 
  877. 	 
  878. 	--Subscribe to datagroups and dataitems 
  879. 	 
  880. 	--Respect 
  881. 	vint_dataitem_add_subscription("sr2_local_player_respect", "update", "hud_player_respect_change") 
  882. 	 
  883. 	--Initialize notoriety... 
  884. 	hud_noto_init() 
  885. 	--Flap Icons Setup-- 
  886. 	--find reference base icons (amount of flaps may change) 
  887. 	for i = 1, MAX_FLAPS do 
  888. 		-- icons 
  889. 		local flap_icon_h = vint_object_find("flap_icon_0" .. i) 
  890. 		Hud_flap_data.icons[i].icon_h = flap_icon_h 
  891. 		vint_set_property(Hud_flap_data.icons[i].icon_h, "visible", false) 
  892.  
  893. 		-- icon backgrounds 
  894. 		local flap_bg_h = vint_object_find("flap_icon_bg_0" .. i) 
  895. 		Hud_flap_data.backgrounds[i].bg_h = flap_bg_h 
  896. 		vint_set_property(Hud_flap_data.backgrounds[i].bg_h, "visible", false) 
  897. 	end 
  898.  
  899. 	--Hood 
  900. 	vint_dataitem_add_subscription("sr2_local_player_hood", "update", "hud_player_hood_change") 
  901. 	vint_dataitem_add_subscription("sr2_local_player_status", "update", "hud_player_status_change") 
  902.  
  903. 	--Followers 
  904. 	vint_datagroup_add_subscription("sr2_local_player_followers", "insert", "hud_player_followers_change") 
  905. 	vint_datagroup_add_subscription("sr2_local_player_followers", "update", "hud_player_followers_change") 
  906.  
  907. 	--Infrequent 
  908. 	--..moving below followers, hopefully solves homie update issues (Derik) 
  909. 	vint_dataitem_add_subscription("sr2_local_player_status_infrequent", "update", "hud_player_status_inf_change") 
  910. 	 
  911. 	--Weapons 
  912. 	vint_dataitem_add_subscription("sr2_local_player_weapons", "update", "hud_player_weapon_change") 
  913. 	vint_dataitem_add_subscription("sr2_local_player_frequent_weapon", "update", "hud_player_weapon_freq_change") 
  914. 	vint_dataitem_add_subscription("sr2_local_player_satellite_weapon", "update", "hud_player_satellite_weapon") 
  915. 	 
  916. 	--Lockon 
  917. 	vint_dataitem_add_subscription("sr2_local_player_lockon", "update", "hud_player_lockon_update") 
  918. 	 
  919. 	--Balance Meter 
  920. 	vint_dataitem_add_subscription("sr2_balance_meter", "update", "hud_balance_meter_change") 
  921. 	 
  922. 	--Cheat icons 
  923. 	vint_dataitem_add_subscription("hud_cheat_icons", "update", "hud_cheat_icon_update") 
  924.  
  925. 	--HUD Process Thread 
  926. 	Hud_process_thread = thread_new("hud_process") 
  927. 	 
  928. 	--Giant Minimap Icon 
  929. 	vint_dataitem_add_subscription("minimap_giant_icon", "update", "hud_map_objective_icon") 
  930. 	 
  931. 	--Ammo pickup 
  932. 	vint_dataitem_add_subscription("hud_ammo_pickup", "update", "hud_ammo_pickup_update") 
  933. 	 
  934. 	--Hud collection init... (Flashpoint, Chopshop, Hitman, etc...) 
  935. 	hud_collection_init() 
  936. 	 
  937. 	Hud_gsi_supress_popout_event_handle = vint_scriptevent_listen( "gsi_supress_popout", "hud_gsi_supress_popout_update" ) 
  938. 			 
  939. 	--Setup animation to fade in the hud 
  940. 	local safe_frame_h = vint_object_find("safe_frame", 0, HUD_DOC_HANDLE) 
  941. 	local hud_fade_in_anim_h = vint_object_find("hud_fade_in_anim") 
  942. 	local hud_fade_in_twn_h = vint_object_find("hud_fade_in_twn", hud_fade_in_anim_h, safe_frame_h) 
  943. 	 
  944. 	--Hide HUD via safe frame 
  945. 	vint_set_property(safe_frame_h, "alpha", 0) 
  946. 	 
  947. 	--Retarget tween to the safe frame... 
  948. 	vint_set_property(hud_fade_in_twn_h, "target_handle", safe_frame_h) 
  949. 	 
  950. 	--Fade in the hud 
  951. 	lua_play_anim(hud_fade_in_anim_h, 1) 
  952. 	 
  953. 	if game_get_platform() == "PC" then 
  954. 		eyefinity_force_blackout( false )  
  955. 	end 
  956. end 
  957.  
  958. function hud_cleanup() 
  959. 	--kill threads 
  960.  
  961. 	--VDOWEAPON 
  962. 	hud_inventory_hide() 
  963. 	 
  964. 	--unload vehicle logo 
  965. 	game_peg_unload(Hud_current_veh_logo) 
  966. 	 
  967. 	if Hud_weapon_status.hud_state_h ~= nil then 
  968. 		ui_hud_display_remove_state(Hud_weapon_status.hud_state_h, false) 
  969. 		Hud_weapon_status.hud_state_h = nil 
  970. 	end 
  971. 	 
  972. 	if Hud_inventory_hud_state_h ~= -1 then 
  973. 		ui_hud_display_remove_state(Hud_inventory_hud_state_h, false) 
  974. 		Hud_inventory_hud_state_h = -1 
  975. 	end 
  976. 	 
  977. 	vint_scriptevent_stop_listening( Hud_gsi_supress_popout_event_handle ) 
  978. 	vint_scriptevent_stop_listening( Hud_homie_call_listener ) 
  979. 	 
  980. 	if game_get_platform() == "PC" then 
  981. 		eyefinity_force_blackout( false )  
  982. 	end 
  983. end 
  984.  
  985. function hud_chal_track_progress(di_h) 
  986. 	local progress, collected, total = vint_dataitem_get(di_h) 
  987.  
  988. 	if progress == 1 and collected == 0 and total == 0 then 
  989. 		Curr_tracked_challenge.equipped = false 
  990. 		Curr_tracked_challenge = { } 
  991. 		Curr_tracked_challenge_id = -1 
  992. 		local challenges_bar_h = vint_object_find("challenges_bar", 0, HUD_DOC_HANDLE) 
  993. 		vint_set_property(challenges_bar_h, "visible", false) 
  994. 	elseif progress == 0 and collected == 0 and total == 0 then 
  995. 		local challenges_bar_h = vint_object_find("challenges_bar", 0, HUD_DOC_HANDLE) 
  996. 		vint_set_property(challenges_bar_h, "visible", false) 
  997. 	else 
  998. 		Curr_tracked_challenge.complete_pct = progress 
  999. 		 
  1000. 		local METER_FULL_PCT = 140	 
  1001. 		local challenges_bar_h = vint_object_find("challenges_bar", 0, HUD_DOC_HANDLE) 
  1002. 		vint_set_property(challenges_bar_h, "visible", true) 
  1003. 		local chal_meter_clip_h = vint_object_find("chal_meter_bar_clip", 0, HUD_DOC_HANDLE) 
  1004. 		local chal_meter_width, chal_meter_height = vint_get_property(chal_meter_clip_h, "clip_size") 
  1005. 		local new_width = METER_FULL_PCT * Curr_tracked_challenge.complete_pct 
  1006. 		 
  1007. 		if Curr_tracked_challenge.complete_pct ~= 1 then --if 1 then set it to full 
  1008. 			local increment = METER_FULL_PCT/20 
  1009. 			for i = 0, METER_FULL_PCT, increment do 
  1010. 				if new_width >= i and new_width < (i + increment) then 
  1011. 					new_width = i 
  1012. 				end 
  1013. 			end 
  1014. 		end 
  1015. 		 
  1016. 		vint_set_property(chal_meter_clip_h, "clip_size", new_width, chal_meter_height)	 
  1017.  
  1018. 		local chal_meter_unit_type = vint_object_find("chal_unit_txt", 0, HUD_DOC_HANDLE) 
  1019.  
  1020. 		local base_units_string = "{0}/{1}" 
  1021. 		local values = {[0] = collected, [1] = total} 
  1022. 		local units_tag = vint_insert_values_in_string(base_units_string, values) 
  1023.  
  1024. 		vint_set_property(chal_meter_unit_type, "text_tag", units_tag) 
  1025. 	end 
  1026. end 
  1027. function hud_hide_map() 
  1028. 	vint_set_property(Hud_map.base_grp_h, "visible", false) 
  1029. end 
  1030.  
  1031. function hud_show_map() 
  1032. 	vint_set_property(Hud_map.base_grp_h, "visible", true) 
  1033. end 
  1034.  
  1035. --Updates the Hud Radial Menu VDO 
  1036. function hud_radial_menu_update(di_h) 
  1037. 	Hud_weapon_radial:slots_update(di_h) 
  1038. 	 
  1039. 	--Make sure we have the right slot selected... 
  1040. 	if Hud_weapon_radial.equipped_grenade_slot > 0 then 
  1041. 		Hud_weapon_radial:weapon_highlight(Hud_weapon_radial.equipped_grenade_slot, true) 
  1042. 	end 
  1043. 	 
  1044. 	--Make sure we have the right slot selected... 
  1045. 	if Hud_weapon_radial.equipped_weapon_slot ~= -1 and Hud_weapon_radial.selected_weapon_slot == -1 then 
  1046. 		Hud_weapon_radial:weapon_highlight(Hud_weapon_radial.equipped_weapon_slot, true) 
  1047. 	end 
  1048. end 
  1049.  
  1050. function hud_inventory_change_power_slot(slot) 
  1051. 	 
  1052. 	if Hud_weapon_radial.selected_grenade_slot ~= slot then 
  1053. 		Hud_weapon_radial:weapon_highlight(slot) 
  1054. 	else 
  1055. 		local element = player_super_power_get_next_unlocked_element(Hud_weapon_radial.slots[slot].element) 
  1056. 		Hud_weapon_radial.slots[slot]:update_element(element) 
  1057. 		Hud_weapon_radial:weapon_highlight(slot) 
  1058. 	end 
  1059. end 
  1060.  
  1061. --Inventory Control Mapping 
  1062. function hud_inventory_input(event, value) 
  1063. 	if event == "inventory_x" then 
  1064. 		--Move Analog Stick X 
  1065. 		Hud_inventory.x = value 
  1066. 		Hud_inventory.stale = true 
  1067. 		 
  1068. 	elseif event == "inventory_y" then 
  1069. 		--Move Analog Stick Y 
  1070. 		Hud_inventory.y = value 
  1071. 		Hud_inventory.stale = true 
  1072.  
  1073. 	elseif event == "dpad_up" then 
  1074. 		hud_inventory_change_power_slot(8) 
  1075. 	elseif event == "dpad_right" then 
  1076. 		hud_inventory_change_power_slot(9) 
  1077. 	elseif event == "dpad_down" then 
  1078. 		hud_inventory_change_power_slot(10) 
  1079. 	elseif event == "dpad_left" then	 
  1080. 		hud_inventory_change_power_slot(11) 
  1081. 	elseif event == "black" then 
  1082. 		debug_print("vint", "scroll_left\n\n") 
  1083. 		 
  1084. 		hud_on_foot_radio_prev_station() 
  1085. 		Hud_radio_elements.station_is_selected = true 
  1086. 	elseif event == "white" then 
  1087. 		debug_print("vint", "scroll_right\n\n") 
  1088. 		hud_on_foot_radio_next_station()		 
  1089. 		Hud_radio_elements.station_is_selected = true 
  1090. 	end 
  1091. end 
  1092.  
  1093. --Show Hud Inventory!! 
  1094. function hud_inventory_show() 
  1095. 	game_hud_update_inventory() 
  1096. 	 
  1097. 	if Hud_inventory.thread == nil then 
  1098. 		if game_get_platform() == "PC" then 
  1099. 			eyefinity_force_blackout( true ) 
  1100. 		end 
  1101. 		 
  1102. 		--Determine if we need to show or hide the dpad menu based on powers 
  1103. 		--Reposition the raidal based on the dpad 
  1104. 		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  
  1105. 			Hud_weapon_radial:show_dpad_menu(false) 
  1106. 			 
  1107. 			--Reposition for SD 
  1108. 			if vint_is_std_res() then 
  1109. 				Hud_weapon_radial:set_anchor(HUD_RADIO_GRP_RADIAL_SD_X, HUD_RADIO_GRP_RADIAL_SD_Y) 
  1110. 				 
  1111. 				--Center bg grp 
  1112. 				vint_set_property(Hud_weapon_radial.bg_grp_h, "anchor", 0, 0) 
  1113. 			else 
  1114. 				Hud_weapon_radial:set_anchor(HUD_RADIO_GRP_RADIAL_X, HUD_RADIO_GRP_RADIAL_Y) 
  1115. 			end 
  1116. 		else 
  1117. 			Hud_weapon_radial:show_dpad_menu(true) 
  1118. 			 
  1119. 			--Reposition for SD 
  1120. 			if vint_is_std_res() then 
  1121. 				Hud_weapon_radial:set_anchor(HUD_RADIO_GRP_RADIAL_POWERS_SD_X, HUD_RADIO_GRP_RADIAL_SD_Y) 
  1122. 				 
  1123. 				--Center bg grp 
  1124. 				vint_set_property(Hud_weapon_radial.bg_grp_h, "anchor", 40, 0) 
  1125. 			else 
  1126. 				Hud_weapon_radial:set_anchor(HUD_RADIO_GRP_RADIAL_POWERS_X, HUD_RADIO_GRP_RADIAL_Y) 
  1127. 			end			 
  1128. 		end 
  1129. 		 
  1130. 		Hud_weapon_radial:show(true) 
  1131. 		 
  1132. 		--Set flag that radial is up  
  1133. 		Hud_radio_elements.radial_is_active = true 
  1134. 		 
  1135. 		--If radio is not disabled then show the radio controls 
  1136. 		if radio_tuner_is_enabled() then		 
  1137. 			 
  1138. 			Hud_radio_elements.radio_is_visible = true 
  1139. 			 
  1140. 			hud_radio_station_update(Hud_current_radio_station) 
  1141. 			 
  1142. 			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 
  1143. 				vint_set_property(Hud_radio_elements.radio_grp_h, "tint", .9, .9, .9) 
  1144. 				 
  1145. 				local platform = game_get_platform() 
  1146. 				if platform == "PS3" then 
  1147. 					Hud_radio_elements.hint_right_h:set_button("ui_ctrl_ps3_btn_r1") 
  1148. 					Hud_radio_elements.hint_left_h:set_button("ui_ctrl_ps3_btn_l1") 
  1149.       	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1150. 					Hud_radio_elements.hint_right_h:set_button("ui_ctrl_ps4_btn_r1") 
  1151. 					Hud_radio_elements.hint_left_h:set_button("ui_ctrl_ps4_btn_l1") 
  1152. 				elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1153. 					Hud_radio_elements.hint_right_h:set_button(CTRL_BUTTON_RB) 
  1154. 					Hud_radio_elements.hint_left_h:set_button(CTRL_BUTTON_LB) 
  1155. 				elseif game_is_active_input_gamepad() == false then 
  1156. 					Hud_radio_elements.hint_right_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_NEXT_RADIO" ), false, true) 
  1157. 					Hud_radio_elements.hint_left_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_PREV_RADIO" ) , false, true) 
  1158. 				else 
  1159. 					Hud_radio_elements.hint_right_h:set_button(CTRL_BUTTON_RB) 
  1160. 					Hud_radio_elements.hint_left_h:set_button(CTRL_BUTTON_LB) 
  1161. 				end 
  1162. 				 
  1163. 				Hud_radio_elements.hint_right_h:set_visible( true ) 
  1164. 				Hud_radio_elements.hint_left_h:set_visible( true ) 
  1165. 				 
  1166. 				vint_set_property(Hud_radio_elements.anim, "is_paused", true) 
  1167. 						 
  1168. 				vint_set_property(Hud_radio_elements.radio_grp_h, "visible", true) 
  1169. 				vint_set_property(Hud_radio_elements.radio_title_grp_h, "visible", true) 
  1170. 				 
  1171. 				lua_play_anim(Hud_radio_elements.anim_in, 0)	 
  1172. 			end 
  1173. 		end 
  1174. 		 
  1175. 		 
  1176. 		Input_tracker:subscribe(true) 
  1177. 								 
  1178. 		if coop_is_active() == false then			 
  1179. 			ui_audio_post_event("UI_Weapon_Radial_Pause") 
  1180. 		else 
  1181. 			game_UI_audio_play("UI_HUD_Open_Weapon_Radial") 
  1182. 		end 
  1183. 		 
  1184. 		--Show darken scrim when radial is visible 
  1185. 		vint_set_property(Darken_h, "visible", true) 
  1186. 		 
  1187. 		--fade bg if not paused 
  1188. 		Hud_weapon_radial:transparent_bg(not pause_on_weapon_inv()) 
  1189. 		 
  1190. 		--Animated radial in 
  1191. 		Hud_weapon_radial:play_show_anim() 
  1192. 		 
  1193. 		--Hide all HUD except radial 
  1194. 		Hud_inventory_hud_state_h = ui_hud_display_create_state() 
  1195. 		 
  1196. 		ui_hud_display_set_element(Hud_inventory_hud_state_h, HUD_ALL_ELEM, HUD_FADE_HIDDEN) 
  1197. 		ui_hud_display_set_element(Hud_inventory_hud_state_h, HUD_ELEM_RADIO_STATION, HUD_FADE_VISIBLE) 
  1198.  
  1199. 		--Commit state without fades (second param) 
  1200. 		ui_hud_display_commit_state(Hud_inventory_hud_state_h, true) 
  1201. 		 
  1202. 		--Subscribe to input 
  1203. 		Hud_inventory.extra_buttons = { 
  1204. 		--	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. 
  1205. 			vint_subscribe_to_input_event("map", "hud_inventory_input"), 
  1206. 			vint_subscribe_to_input_event("pause", "hud_inventory_input"), 
  1207. 		} 
  1208.  
  1209. 		Hud_inventory.subs_x = vint_subscribe_to_raw_input("inventory_x", "hud_inventory_input") 
  1210. 		Hud_inventory.subs_y = vint_subscribe_to_raw_input("inventory_y", "hud_inventory_input") 
  1211. 		Hud_inventory.subs_up = vint_subscribe_to_input_event("dpad_up", "hud_inventory_input") 
  1212. 		Hud_inventory.subs_right = vint_subscribe_to_input_event("dpad_right", "hud_inventory_input") 
  1213. 		Hud_inventory.subs_down = vint_subscribe_to_input_event("dpad_down", "hud_inventory_input") 
  1214. 		Hud_inventory.subs_left = vint_subscribe_to_input_event("dpad_left", "hud_inventory_input") 
  1215.  
  1216. 		--Reset visual analog stick and get the proper text tag on it. 
  1217. 		Hud_inventory.x = 0 
  1218. 		Hud_inventory.y = 0 
  1219. 		 
  1220. 		--Highlight Currently equipped slots 
  1221. 		Hud_weapon_radial:weapon_highlight(Hud_weapon_radial.equipped_weapon_slot, true) 
  1222. 		if Hud_weapon_radial.equipped_grenade_slot > 0 then 
  1223. 			Hud_weapon_radial:weapon_highlight(Hud_weapon_radial.equipped_grenade_slot, true) 
  1224. 		end 
  1225. 		 
  1226. 		Hud_weapon_radial:stick_update_position(0, 0) 
  1227. 		Hud_weapon_radial:stick_update_tag()	 
  1228. 		Hud_weapon_radial:stick_arrow_reset()	 
  1229.  
  1230. 		Hud_inventory.thread = thread_new("hud_inventory_process")		 
  1231. 	end 
  1232. end 
  1233.  
  1234.  
  1235. function hud_inventory_hide(aborted) 
  1236. 	if game_get_platform() == "PC" then 
  1237. 		eyefinity_force_blackout( false )  
  1238. 	end 
  1239. 	 
  1240. 	if Hud_inventory.thread ~= nil then 
  1241. 		thread_kill(Hud_inventory.thread) 
  1242. 		Hud_inventory.thread = nil 
  1243. 		 
  1244. 		if aborted == false then 
  1245. 			Hud_weapon_radial:game_equip_selected_slots() 
  1246. 		end 
  1247. 		 
  1248. 		--Hide Radial Menu 
  1249. 		Hud_weapon_radial:show(false) 
  1250. 		 
  1251. 		--Radial is not active 
  1252. 		Hud_radio_elements.radial_is_active = false 
  1253. 		 
  1254. 		--If the radio is visible (and active) then hide it 
  1255. 		if Hud_radio_elements.radio_is_visible == true then				 
  1256. 			 
  1257. 			vint_set_property(Hud_radio_elements.radio_grp_h, "tint", 1, 1, 1) 
  1258. 					 
  1259. 			--Bring arrows back 
  1260. 			vint_set_property(Hud_radio_elements.arrow_right_h, "visible", true) 
  1261. 			vint_set_property(Hud_radio_elements.arrow_left_h, "visible", true) 
  1262. 			 
  1263. 			--Move and hide radio grp 
  1264. 			vint_set_property(Hud_radio_elements.radio_grp_h, "alpha", 0) 
  1265. 			vint_set_property(Hud_radio_elements.radio_grp_h, "visible", false) 
  1266. 			vint_set_property(Hud_radio_elements.radio_title_grp_h, "visible", false) 
  1267. 			vint_set_property(Hud_radio_elements.radio_grp_h, "anchor", HUD_RADIO_GRP_HUD_X, HUD_RADIO_GRP_HUD_Y) 
  1268. 			 
  1269. 			Hud_radio_elements.radio_is_visible  = false 
  1270. 		end 
  1271. 		 
  1272. 		--Release controls 
  1273. 		Input_tracker:subscribe(false) 
  1274. 		 
  1275. 		--Radial is hidden, pop HUD back on (second param controls fade vs pop) 
  1276. 		ui_hud_display_remove_state(Hud_inventory_hud_state_h, false) 
  1277. 		Hud_inventory_hud_state_h = -1 
  1278. 		 
  1279. 		vint_set_property(Darken_h, "visible", false) 
  1280. 		if coop_is_active() == false then 
  1281. 			ui_audio_post_event("UI_Weapon_Radial_Unpause") 
  1282. 		end		 
  1283. 		 
  1284. 		vint_unsubscribe_to_raw_input(Hud_inventory.subs_x) 
  1285. 		vint_unsubscribe_to_raw_input(Hud_inventory.subs_y) 
  1286. 		vint_unsubscribe_to_input_event(Hud_inventory.subs_up) 
  1287. 		vint_unsubscribe_to_input_event(Hud_inventory.subs_right) 
  1288. 		vint_unsubscribe_to_input_event(Hud_inventory.subs_down) 
  1289. 		vint_unsubscribe_to_input_event(Hud_inventory.subs_left) 
  1290. 		 
  1291. 		for idx, val in pairs(Hud_inventory.extra_buttons) do  
  1292. 			vint_unsubscribe_to_input_event(val) 
  1293. 		end 
  1294. 		 
  1295. 		Hud_inventory.extra_buttons = nil	 
  1296. 	end 
  1297. end 
  1298.  
  1299.  
  1300. function hud_inventory_process() 
  1301. 	while true do  
  1302. 		if Hud_inventory.stale == true then 
  1303. 		 
  1304. 			local x = Hud_inventory.x 
  1305. 			local y = Hud_inventory.y 
  1306. 			local selected_weapon_index = 0 
  1307. 			local mag = sqrt((x * x) + (y * y)) 
  1308. 			local pi = 3.14159 
  1309. 			 
  1310. 			if mag > 0.5 then 
  1311. 				 
  1312. 				-- Y resolves out so don't bother with it 
  1313. 				x = x/mag 
  1314. 				local radians = acos(x) 
  1315. 				 
  1316. 				if y < 0.0 then 
  1317. 					radians = pi + (pi - radians) 
  1318. 				end 
  1319. 	 
  1320. 				local eighth = pi / 8 
  1321. 				local fourth = pi / 4 
  1322. 				local selected_weapon_index = 0 
  1323. 				 
  1324. 				if radians < eighth then 
  1325. 					selected_weapon_index = 2; 
  1326. 				elseif radians < (fourth + eighth) then 
  1327. 					selected_weapon_index = 1 
  1328. 				elseif radians < (2.0 * fourth + eighth) then 
  1329. 					selected_weapon_index = 0 
  1330. 				elseif radians < (3.0 * fourth + eighth) then 
  1331. 					selected_weapon_index = 7 
  1332. 				elseif radians < (4.0 * fourth + eighth) then 
  1333. 					selected_weapon_index = 6 
  1334. 				elseif radians < (5.0 * fourth + eighth) then 
  1335. 					selected_weapon_index = 5 
  1336. 				elseif radians < (6.0 * fourth + eighth) then 
  1337. 					selected_weapon_index = 4; 
  1338. 				elseif radians < (7.0 * fourth + eighth) then				 
  1339. 					selected_weapon_index = 3; 
  1340. 				else 
  1341. 					selected_weapon_index = 2; 
  1342. 				end 
  1343.  
  1344. 				--Change selected item in the menu 
  1345. 				--Hud_radial_menu_change_select(selected_weapon_index)	 
  1346. 				Hud_weapon_radial:weapon_highlight(selected_weapon_index) 
  1347. 				Hud_weapon_radial:stick_update_arrow(radians) 
  1348. 				 
  1349. 			end 
  1350. 	 
  1351. 			--Update Stick location on radial menu 
  1352. 			Hud_weapon_radial:stick_update_position(Hud_inventory.x, Hud_inventory.y) 
  1353. 			Hud_inventory.stick_mag = mag 
  1354. 			Hud_inventory.stale = false 
  1355. 		end 
  1356. 		thread_yield() 
  1357. 	end 
  1358. end 
  1359.  
  1360. function hud_inventory_set_selected_weapon(selected_weapon_index) 
  1361. 	Hud_weapon_radial:weapon_highlight(selected_weapon_index) 
  1362. end 
  1363.  
  1364. function hud_inventory_set_selected_grenade(selected_grenade_index) 
  1365. 	Hud_weapon_radial:weapon_highlight(selected_grenade_index + 8) 
  1366. end 
  1367.  
  1368. -- call from C to notify that all GSI elements have been updated 
  1369. function hud_gsi_update_complete() 
  1370. 	Hud_gsi:update_complete() 
  1371. end 
  1372.  
  1373. function hud_gsi_vdo_update(di_h) 
  1374. 	if Hud_gsi ~= -1 then 
  1375. 		Hud_gsi:update(di_h) 
  1376. 	end 
  1377. end 
  1378.  
  1379. function exp_approach(source, dest, pct_per_sec, step_time) 
  1380. 	pct_per_sec = max(min(pct_per_sec, 1), 0) 
  1381. 	local pct_this_frame = 1 - pow(1-pct_per_sec, step_time) 
  1382. 	local lerp_result = lerp(source, dest, pct_this_frame) 
  1383. 	--debug_print("vint_exp", source .. " -> " .. dest .. ", " .. pct_per_sec .. "%%/s, " .. step_time .. "s, " .. pct_this_frame .. "%%/f ==> " .. lerp_result .. "\n") 
  1384. 	return lerp_result 
  1385. end 
  1386. 	 
  1387. function hud_process() 
  1388.  
  1389. 	local display_cash = Hud_player_status.cash - 1 --Subtract one so it gets formatted in the loop. 
  1390. 	local hud_had_focus = nil 
  1391. 	 
  1392. 	while true do 
  1393. 		thread_yield() 
  1394. 		 
  1395. 		-- Animate Cash 
  1396. 		if display_cash ~= Hud_player_status.cash then 
  1397. 			local step_time = get_frame_time() 
  1398. 			local diff_cash = Hud_player_status.cash - display_cash 
  1399. 			 
  1400. 			local linear_cash = step_time * 1000 
  1401. 			if	abs(diff_cash) > linear_cash then 
  1402. 				-- approach the player's cash value by whichever rate is greater: linear slope or exponential approach 
  1403. 				linear_cash = linear_cash * (diff_cash / abs(diff_cash)) 
  1404. 				local exp_cash = exp_approach(display_cash, Hud_player_status.cash, 0.99995, step_time) - display_cash 
  1405.  
  1406. 				if diff_cash > 0 then 
  1407. 					diff_cash = max(linear_cash, exp_cash) 
  1408. 				else  
  1409. 					diff_cash = min(linear_cash, exp_cash) 
  1410. 				end 
  1411. 			end 
  1412. 			 
  1413. 			display_cash = display_cash + diff_cash 
  1414. 			vint_set_property(Hud_player_status.cash_h, "text_tag", "{GAME_CASH}" .. format_cash(display_cash)) 
  1415. 			 
  1416. 			--color red if going down 
  1417. 			if diff_cash >= 0 then 
  1418. 				vint_set_property(Hud_player_status.cash_h, "tint", 220/255, 220/255, 220/255) 
  1419. 			else 
  1420. 				vint_set_property(Hud_player_status.cash_h, "tint", 220/255, 0/255, 0/255) 
  1421. 			end 
  1422. 		else 
  1423. 			vint_set_property(Hud_player_status.cash_h, "tint", 220/255, 220/255, 220/255) 
  1424. 		end 
  1425. 	 
  1426. 		-- check to see if the hud has lost focus 
  1427. 		if hud_had_focus ~= Hud_has_focus then 
  1428. 			hud_had_focus = Hud_has_focus 
  1429. 		end 
  1430. 		 
  1431. 		local hud_msg_doc_h = vint_document_find("hud_msg") 
  1432. 		if hud_msg_doc_h ~= 0 then 
  1433. 			hud_msg_process() 
  1434. 		end 
  1435. 	end 
  1436. end 
  1437.  
  1438. function hud_player_hood_change(data_item_handle, event_name) 
  1439. 	local hood_name, cur_hood_owner, orig_hood_owner, is_contested = vint_dataitem_get(data_item_handle) 
  1440.  
  1441. 	-- this will become relevant for pushbacks and display of notoriety since we always will show 
  1442. 	-- gang noto for mission/activity gang or hood owner if hood is contested 
  1443. end 
  1444.  
  1445. function hud_player_status_inf_change(di_h, event_name) 
  1446. 	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) 
  1447. 	 
  1448. 	local floored_cash = floor(cash) 
  1449. 	if cash ~= Hud_player_status.cash or force_show_cash then 
  1450. 		--Start up the cash display animation if the players cash updates 
  1451. 		local cash_anim_h = vint_object_find("cash_anim") 
  1452.  
  1453. 		--set first frame of animation to current alpha value of cash 
  1454. 		local cash_alpha = vint_get_property(Hud_player_status.cash_h, "alpha") 
  1455. 		local cash_anim_first_tween_h = vint_object_find("cash_anim_first_tween", cash_anim_h) 
  1456. 		vint_set_property(cash_anim_first_tween_h, "start_value", cash_alpha) 
  1457. 		 
  1458. 		lua_play_anim(cash_anim_h) 
  1459. 	end 
  1460. 	 
  1461. 	--Update cash (this gets read through hud_process() so it counts up nicely) 
  1462. 	Hud_player_status.cash = floored_cash 
  1463. 	 
  1464. 	if vehicle_logo == nil then 
  1465. 		vehicle_logo = 0 
  1466. 	end 
  1467. 	 
  1468. 	if radio_station == nil then 
  1469. 		radio_station = 0 
  1470. 	end 
  1471. 	 
  1472. 	-- Display a new vehicle logo 
  1473. 	if Hud_current_veh_logo ~= vehicle_logo then 
  1474. 	 
  1475. 		if Hud_current_veh_logo ~= "__unloaded" and Hud_current_veh_logo ~= 0 then 
  1476. 			game_peg_unload(Hud_current_veh_logo) 
  1477. 		end 
  1478.  
  1479. 		Hud_current_veh_logo = vehicle_logo		 
  1480. 		 
  1481. 		if vehicle_logo == "__unloaded" or vehicle_logo == 0 then				 
  1482. 			local o = vint_object_find("vehicle_logo") 
  1483. 			vint_set_property(o, "visible", false)			 
  1484. 		else		 
  1485. 			-- Load vehicle logo peg 
  1486. 			game_peg_load_with_cb("hud_set_vehicle_logo", 1, vehicle_logo) 
  1487. 		end 
  1488. 	end 
  1489. 		 
  1490. 	if vehicle_scanned == true then 
  1491. 		local vehicle_scan_anim_h = vint_object_find("vehicle_scan_anim") 
  1492. 		vint_apply_start_values(vehicle_scan_anim_h) 
  1493. 		lua_play_anim(vehicle_scan_anim_h) 
  1494. 	end 
  1495. 	 
  1496. 	if radio_tuner_is_enabled()  then 
  1497. 		-- Display a new radio station 
  1498. 		if game_is_active_input_gamepad() == false or Hud_inventory.thread == nil then 
  1499. 			if Hud_inventory.thread == nil then 
  1500. 				vint_set_property(Hud_radio_elements.radio_grp_h, "anchor", HUD_RADIO_GRP_HUD_X, HUD_RADIO_GRP_HUD_Y) 
  1501. 				vint_set_property(Hud_radio_elements.radio_title_grp_h, "visible", false) 
  1502. 			else 
  1503. 				vint_set_property(Hud_radio_elements.radio_title_grp_h, "visible", true) 
  1504. 			end 
  1505. 			 
  1506. 			if game_get_platform() == "PS3" then 
  1507. 				Hud_radio_elements.hint_right_h:set_button("ui_ctrl_ps3_btn_r1") 
  1508. 				Hud_radio_elements.hint_left_h:set_button("ui_ctrl_ps3_btn_l1") 
  1509. 			elseif game_is_active_input_gamepad() == false then 
  1510. 				Hud_radio_elements.hint_right_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_NEXT_RADIO" ), false, true) 
  1511. 				Hud_radio_elements.hint_left_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_PREV_RADIO" ) , false, true) 
  1512. 			else 
  1513. 				Hud_radio_elements.hint_right_h:set_button(CTRL_BUTTON_RB) 
  1514. 				Hud_radio_elements.hint_left_h:set_button(CTRL_BUTTON_LB) 
  1515. 			end 
  1516. 			 
  1517. 			vint_set_property(Hud_radio_elements.radio_grp_h, "visible", true) 
  1518. 		end	 
  1519. 	 
  1520. 		hud_radio_station_update(radio_station, false) 
  1521. 	end 
  1522. 	 
  1523. 	hud_cruise_control_update(cruise_control_active) 
  1524. 	 
  1525. 	if show_vtol_hints then 
  1526. 		hud_vtol_set_hints() 
  1527. 		Hud_sniper_hint_bar:set_visible(true) 
  1528. 	else 
  1529. 		Hud_sniper_hint_bar:set_visible(false) 
  1530. 	end 
  1531. 	 
  1532. 	if camera_screenshot_enabled ~= Hud_camera_screenshot_enabled then 
  1533. 		--show or hide screenshot hint... this is always on. 
  1534. 		local h = vint_object_find("screenshot_camera_hint_grp") 
  1535. 		vint_set_property(h, "visible", camera_screenshot_enabled) 
  1536. 		 
  1537. 		Hud_camera.hint_key = game_get_key_name_for_action( "CBA_GAC_TAKE_SCREENSHOT" ) 
  1538. 		Hud_camera.hint_icon:set_button( Hud_camera.hint_button, Hud_camera.hint_key, false, false) 
  1539. 		 
  1540. 		Hud_camera_screenshot_enabled = camera_screenshot_enabled 
  1541. 	end 
  1542. 	 
  1543. 	if game_get_platform() == "PC" and game_is_active_input_gamepad() ~= true then 
  1544. 		local hint_icon_w,hint_icon_h = Hud_camera.hint_icon:get_size() 
  1545. 		local adjusted_hint_x = hint_icon_w * 0.5 
  1546. 		 
  1547. 		Hud_camera.hint_icon:set_property( "anchor", adjusted_hint_x, 0 ) 
  1548. 		 
  1549. 		local camera_hint_icon_bmp_h = vint_object_find( "camera_hint_icon_bmp" ) 
  1550. 		vint_set_property( camera_hint_icon_bmp_h, "anchor", hint_icon_w + 15, 0 ) 
  1551. 		vint_set_property(Hud_camera.hint_text, "visible", false) 
  1552. 	else 
  1553. 		local hint_text_w, hint_text_h = element_get_actual_size(Hud_camera.hint_text) 
  1554. 		local hint_icon_w,hint_icon_h = Hud_camera.hint_icon:get_actual_size() 
  1555. 		local adjusted_hint_x = hint_icon_w * 0.5 
  1556. 		 
  1557. 		Hud_camera.hint_icon:set_property( "anchor", hint_text_w + 20 + adjusted_hint_x, 0 ) 
  1558. 		 
  1559. 		local camera_hint_icon_bmp_h = vint_object_find( "camera_hint_icon_bmp" ) 
  1560. 		vint_set_property( camera_hint_icon_bmp_h, "anchor", hint_text_w + 20 + hint_icon_w + 20, 0 ) 
  1561. 		vint_set_property(Hud_camera.hint_text, "visible", true) 
  1562. 	end 
  1563. 	 
  1564. 	 
  1565. end 
  1566.  
  1567.  
  1568. -- Display a new radio station	 
  1569. function hud_radio_station_update(radio_station, force_update) 
  1570. 	if Hud_current_radio_station ~= radio_station or force_update == true then 
  1571. 		if radio_station ~= 0 then 
  1572. 			local radio_station_small 
  1573. 			if radio_station ~= "" then 
  1574. 				--build the radio image name 
  1575. 				radio_station_small = radio_station.."_sm" 
  1576. 				vint_set_property(Hud_radio_elements.image_h, "scale", 1.25, 1.25) 
  1577. 				vint_set_property(Hud_radio_elements.image_h, "tint", COLOR_HUD_RADIO_NAME.R, COLOR_HUD_RADIO_NAME.G, COLOR_HUD_RADIO_NAME.B) 
  1578. 			else 
  1579. 				radio_station_small = "ui_cell_icon_music" 
  1580. 				vint_set_property(Hud_radio_elements.image_h, "scale", 0.6, 0.6) 
  1581. 				vint_set_property(Hud_radio_elements.image_h, "tint", COLOR_HUD_RADIO_ICON.R, COLOR_HUD_RADIO_ICON.G , COLOR_HUD_RADIO_ICON.B) 
  1582. 			end 
  1583. 			vint_set_property(Hud_radio_elements.image_h, "image", radio_station_small) 
  1584. 			 
  1585. 			if force_update == false and Hud_current_radio_station ~= 0 then 
  1586. 				ui_audio_post_event("ui_radio_switch") 
  1587. 			end 
  1588. 			 
  1589. 			local arrow_pad = 20 
  1590. 			local radio_w,radio_h = element_get_actual_size( Hud_radio_elements.image_h ) 
  1591. 			local radio_x,radio_y = vint_get_property( Hud_radio_elements.image_h, "anchor" ) 
  1592. 			local arrow_x,arrow_y = vint_get_property( Hud_radio_elements.arrow_left_h, "anchor" ) 
  1593. 			 
  1594. 			vint_set_property(Hud_radio_elements.arrow_right_h, "visible", true) 
  1595. 			vint_set_property(Hud_radio_elements.arrow_left_h, "visible", true) 
  1596. 			 
  1597. 			local left_arrow_adjusted_x = radio_x - ((radio_w * 0.5) + arrow_pad) 
  1598. 			vint_set_property(Hud_radio_elements.arrow_left_h, "anchor", left_arrow_adjusted_x, arrow_y) 
  1599. 			 
  1600. 			local right_arrow_adjusted_x = radio_x + ((radio_w * 0.5) + arrow_pad) 
  1601. 			vint_set_property(Hud_radio_elements.arrow_right_h, "anchor", right_arrow_adjusted_x, arrow_y) 
  1602. 			 
  1603. 			if Hud_inventory.thread == nil then -- Allow radio selection if we are not in the inventory radial 
  1604. 			 
  1605. 				Hud_radio_elements.hint_right_h:set_visible( true ) 
  1606. 				Hud_radio_elements.hint_left_h:set_visible( true ) 
  1607. 				 
  1608. 				if game_is_active_input_gamepad() == false then -- Display keyboard command if not using gamepad 
  1609. 					Hud_radio_elements.hint_right_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_NEXT_RADIO" ), false, true) 
  1610. 					Hud_radio_elements.hint_left_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_PREV_RADIO" ) , false, true) 
  1611. 				else -- Display d-pad controls if using gamepad 
  1612. 					Hud_radio_elements.hint_right_h:set_button(CTRL_BUTTON_DPAD_RIGHT) 
  1613. 					Hud_radio_elements.hint_left_h:set_button(CTRL_BUTTON_DPAD_LEFT) 
  1614. 				end 
  1615. 				 
  1616. 				local hint_right_x,hint_right_y = 	Hud_radio_elements.hint_right_h:get_property( "anchor" ) 
  1617. 				local hint_left_x,hint_left_y = 		Hud_radio_elements.hint_left_h:get_property( "anchor" ) 
  1618. 				local hint_right_w,hint_right_h = 	Hud_radio_elements.hint_right_h:get_property( "screen_size" ) 
  1619. 				local hint_left_w,hint_left_h = 		Hud_radio_elements.hint_left_h:get_property( "screen_size" ) 
  1620. 				 
  1621. 				local new_hint_right_x = right_arrow_adjusted_x + (hint_right_w * 0.5) 
  1622. 				local new_hint_left_x = left_arrow_adjusted_x - (hint_left_w * 0.5) 
  1623. 				 
  1624. 				Hud_radio_elements.hint_right_h:set_property( "anchor", new_hint_right_x, hint_right_y ) 
  1625. 				Hud_radio_elements.hint_left_h:set_property( "anchor", new_hint_left_x, hint_left_y ) 
  1626. 				 
  1627. 				local radio_station_alpha_twn_1_h = vint_object_find( "radio_station_alpha_twn_1", Hud_radio_elements.anim, HUD_DOC_HANDLE ) 
  1628. 				local radio_grp_alpha = vint_get_property( Hud_radio_elements.radio_grp_h, "alpha" ) 
  1629. 				 
  1630. 				-- Start the animation with what the current alpha is so as not to always fade in when switching radio stations 
  1631. 				vint_set_property( radio_station_alpha_twn_1_h, "start_value", radio_grp_alpha ) 
  1632. 				 
  1633. 				-- Hide the first time the radio updates when the hud is loaded 
  1634. 				if Hud_radio_has_updated then 
  1635. 					lua_play_anim( Hud_radio_elements.anim ) 
  1636. 				else 
  1637. 					vint_set_property(Hud_radio_elements.radio_grp_h, "alpha", 0)	 
  1638. 					vint_set_property(Hud_radio_elements.radio_grp_h, "visible", false) 
  1639. 				end 
  1640. 				 
  1641. 				Hud_radio_has_updated = true 
  1642. 				 
  1643. 			else -- Show the LB/RB hints since we are in the radial inventory 
  1644. 				local platform = game_get_platform() 
  1645. 				if platform == "PS3" then 
  1646. 					Hud_radio_elements.hint_right_h:set_button("ui_ctrl_ps3_btn_r1") 
  1647. 					Hud_radio_elements.hint_left_h:set_button("ui_ctrl_ps3_btn_l1") 
  1648.         elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1649. 					Hud_radio_elements.hint_right_h:set_button("ui_ctrl_ps4_btn_r1") 
  1650. 					Hud_radio_elements.hint_left_h:set_button("ui_ctrl_ps4_btn_l1") 
  1651. 				elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  1652. 					Hud_radio_elements.hint_right_h:set_button(CTRL_BUTTON_RB) 
  1653. 					Hud_radio_elements.hint_left_h:set_button(CTRL_BUTTON_LB) 
  1654. 				elseif game_is_active_input_gamepad() == false then 
  1655. 					Hud_radio_elements.hint_right_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_NEXT_RADIO" ), false, true) 
  1656. 					Hud_radio_elements.hint_left_h:set_button( nil, game_get_key_name_for_action( "CBA_GAC_PREV_RADIO" ) , false, true) 
  1657. 				else 
  1658. 					Hud_radio_elements.hint_right_h:set_button(CTRL_BUTTON_RB) 
  1659. 					Hud_radio_elements.hint_left_h:set_button(CTRL_BUTTON_LB) 
  1660. 				end 
  1661. 			end 
  1662. 		end 
  1663. 	else 
  1664. 		vint_set_property(Hud_radio_elements.radio_grp_h, "alpha", 0)	 
  1665. 		vint_set_property(Hud_radio_elements.radio_grp_h, "visible", false) 
  1666. 	end 
  1667. 	 
  1668. 	Hud_current_radio_station = radio_station 
  1669. end 
  1670.  
  1671.  
  1672. function hud_set_vehicle_logo() 
  1673. 	local o = vint_object_find("vehicle_logo") 
  1674. 	vint_set_property(o, "image", Hud_current_veh_logo) 
  1675. 	lua_play_anim(vint_object_find("vehicle_logo_anim_1"), 0) 
  1676. 	vint_set_property(o, "visible", true) 
  1677. end 
  1678.  
  1679. function hud_player_status_change(di_h, event_name) 
  1680. 	--HUD dataitem is special and doesn't need any comments. FML. :/ 
  1681. 	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) 
  1682. 	 
  1683. 	--Blink health blue for pickup 
  1684. 	if is_health_pickup == true and Is_health_pickup_active ~= true then 
  1685. 		local health_pickup_anim_h = vint_object_find("health_pickup", 0, HUD_DOC_HANDLE) 
  1686. 		local health_pickup_twn_h = vint_object_find("end_event_twn", health_pickup_anim_h) 
  1687. 		vint_set_property(health_pickup_twn_h, "end_event", "hud_health_pickup_is_done") 
  1688. 		lua_play_anim(health_pickup_anim_h) 
  1689. 		Is_health_pickup_active = true 
  1690. 	end 
  1691.  
  1692. 	 
  1693. 	if Hud_super_bar.is_mech == true then 
  1694. 		 
  1695. 		--Update health meter 
  1696. 		 
  1697. 		element_set_actual_size(Mech_health_mask_img_h, Mech_health_width * objective_health_pct, Mech_health_height) 
  1698. 		 
  1699. 		if (objective_health_pct < Hud_health_bar.percent) and (Mech_health_is_playing == false) then 
  1700. 			lua_play_anim(Mech_health_anim_h) 
  1701. 			Mech_health_is_playing = true 
  1702. 		end 
  1703. 		 
  1704. 		--Update weapon meter 
  1705. 		element_set_actual_size(Mech_weapon_mask_img_h, Mech_weapon_width * sprint_pct, Mech_weapon_height)	 
  1706. 		if sprint_pct < Hud_sprint_bar.percent then 
  1707. 			if Mech_weapon_is_playing == false then 
  1708. 				lua_play_anim(Mech_weapon_anim_h) 
  1709. 				Mech_weapon_is_playing = true 
  1710. 			end 
  1711. 		else 
  1712. 			vint_set_property(Mech_weapon_meter_img_h, "alpha", .5) 
  1713. 			vint_set_property(Mech_weapon_anim_h, "is_paused", true) 
  1714. 			Mech_weapon_is_playing = false 
  1715. 		end 
  1716. 		 
  1717. 		 
  1718. 		vint_set_property(Mech_grp_h, "visible", true) 
  1719. 	else 
  1720. 		vint_set_property(Mech_grp_h, "visible", false) 
  1721. 	end 
  1722.  
  1723. 	 
  1724. 	if Hud_super_bar.is_ship == true then 
  1725. 		--Update health meter 
  1726. 		 
  1727. 		element_set_actual_size(Ship_health_mask_img_h, Ship_health_width * objective_health_pct, Ship_health_height) 
  1728. 		 
  1729. 		vint_set_property(Ship_health_grp_h, "visible", true) 
  1730. 	else 
  1731. 		vint_set_property(Ship_health_grp_h, "visible", false) 
  1732. 	end 
  1733. 	 
  1734.  
  1735. 	local unhide_weapons = false 
  1736.  
  1737. 	-- Get health difference... 
  1738. 	local health_pct_diff = abs(Hud_health_bar.percent - health_pct) 
  1739. 	 
  1740. 	--Since we don't have regen health, the vignette should match the health pct 
  1741. 	vint_set_property(Hud_vignettes.health.grp_h, "alpha", vignette_pct) 
  1742. 	 
  1743. 	if health_pct_diff > .001 or health_level ~= Hud_health_bar.level then 
  1744.  
  1745. 		local bar = Hud_health_bar 
  1746. 		local level = health_level 
  1747. 	 
  1748. 		--get start/end angles depending on level... 
  1749. 		local start_angle_static	 = bar.level_angles[level].fill_start_angle 
  1750. 		local end_angle_static		 = bar.level_angles[level].fill_end_angle 
  1751. 		local angle_offset_static	 = bar.level_angles[level].angle_offset 
  1752. 		 
  1753. 		--Calculate current angles... 
  1754. 		local fill_end_angle =  (end_angle_static - start_angle_static) * health_pct + start_angle_static 
  1755. 		local bg_end_angle = fill_end_angle - angle_offset_static 
  1756. 		 
  1757. 		--if new health pct is less than current then do the animation of it dropping 
  1758. 		if health_pct < Hud_health_bar.percent then 
  1759. 			if bar.is_expanded == false then 
  1760. 				hud_player_health_show() 
  1761. 			end 
  1762. 			 
  1763. 			--Decrease the health meter 
  1764. 			hud_player_health_decrease_anim(bar, fill_end_angle, bg_end_angle) 
  1765.  
  1766. 			if health_pct < .3 then 
  1767. 				--Full screen health effect gets even heavier if it drops below .3 
  1768. 				local vignette_alpha = .70 - health_pct 
  1769. 				--hud_health_screen_fade(vignette_alpha) 
  1770.  
  1771. 			elseif health_pct < .5 then 
  1772. 				--Full screen health effect if drops below .5 
  1773. 				local vignette_alpha = .5 - health_pct 
  1774. 				--hud_health_screen_fade(vignette_alpha) 
  1775. 			end 
  1776. 			Hud_player_status.health_recovering = false 
  1777. 		elseif health_pct >= Hud_health_bar.percent then 
  1778. 			--Increase the health meter 
  1779. 			hud_player_health_increase_anim(bar, fill_end_angle, bg_end_angle) 
  1780. 			 
  1781. 			if Hud_player_status.health_recovering == false then 
  1782. 				--hud_health_screen_fade(0) 
  1783. 				Hud_player_status.health_recovering = true 
  1784. 			end 
  1785. 		end 
  1786. 			 
  1787. 		if health_pct == 1 and bar.is_expanded == true then 
  1788. 			--Start to hide the bar. 
  1789. 			lua_play_anim(bar.timer_fade_out_anim_h) 
  1790. 		else 
  1791. 			vint_set_property(bar.timer_fade_out_anim_h, "is_paused", true) 
  1792. 		end 
  1793.  
  1794. 		--Make sure we can see the healthbar...  
  1795. 		unhide_weapons = true 
  1796. 		 
  1797. 		Hud_health_bar.percent = health_pct 
  1798. 		Hud_health_bar.level = health_level 
  1799. 	end 
  1800.  
  1801. 	Hud_player_status.bleed_out_health_pct = bleed_out_health_pct 
  1802. 	Hud_player_status.is_in_satellite_mode = is_in_satellite_mode 
  1803. 	Hud_player_status.is_controlling_missile = is_controlling_missile 
  1804.  
  1805. 	local unhide_sprint = false  
  1806. 	 
  1807. 	--Sprint 
  1808. 	-- Get Sprint difference... 
  1809. 	local sprint_pct_diff = abs(Hud_sprint_bar.percent - sprint_pct) 
  1810.  
  1811. 	if sprint_enabled == true and (sprint_pct_diff > .001 or sprint_level ~= Hud_sprint_bar.level) then 
  1812. 		local bar = Hud_sprint_bar 
  1813. 		local level = sprint_level 
  1814. 		 
  1815. 		--get start/end angles depending on level... 
  1816. 		local start_angle_static	 = bar.level_angles[level].fill_start_angle 
  1817. 		local end_angle_static		 = bar.level_angles[level].fill_end_angle 
  1818. 		local angle_offset_static	 = bar.level_angles[level].angle_offset 
  1819. 		 
  1820. 		--Calculate current angles... 
  1821. 		local fill_end_angle =  (end_angle_static - start_angle_static) * sprint_pct + start_angle_static 
  1822. 		local bg_end_angle = fill_end_angle - angle_offset_static 
  1823. 		 
  1824. 		unhide_sprint = true 
  1825. 		 
  1826. 		--Update angles for the sprint meter 
  1827. 		vint_set_property(bar.bg_h, "end_angle", bg_end_angle) 
  1828. 		 
  1829. 		--Hide bg of meter if sprint is empty. 
  1830. 		if sprint_pct == 0 then 
  1831. 			vint_set_property(bar.bg_h, "visible", false) 
  1832. 		else 
  1833. 			vint_set_property(bar.bg_h, "visible", true) 
  1834. 		end 
  1835. 		 
  1836. 		vint_set_property(bar.fill_h, "end_angle", fill_end_angle) 
  1837.  
  1838. 		--Make sure we can see the sprintbar...  
  1839. 		unhide_weapons = true 
  1840. 		 
  1841. 		Hud_sprint_bar.percent = sprint_pct 
  1842. 		Hud_sprint_bar.level = sprint_level 
  1843. 	end 
  1844. 	 
  1845. 	if is_sprinting ~= Hud_player_status.is_sprinting then 
  1846. 		local sprint_anim_h = vint_object_find("sprint_pulse_anim") 
  1847. 		if is_sprinting == false then 
  1848. 			--Stop pulse animation and reset... 
  1849. 			vint_set_property(sprint_anim_h, "is_paused", true) 
  1850. 			vint_set_property(Hud_sprint_bar.fill_h, "tint", HUD_SPRINT_COLOR.R, HUD_SPRINT_COLOR.G, HUD_SPRINT_COLOR.B) 
  1851. 		else  
  1852. 			lua_play_anim(sprint_anim_h)		 
  1853. 		end 
  1854. 	 
  1855. 		unhide_sprint = true 
  1856. 		 
  1857. 		--Store to global... 
  1858. 		Hud_player_status.is_sprinting = is_sprinting 
  1859. 	end 
  1860. 	 
  1861. 	if unhide_sprint == true then 
  1862. 		--Should we hide the sprint bar... 
  1863. 		local bar = Hud_sprint_bar 
  1864. 		 
  1865. 		if (sprint_pct == 1) and (bar.is_expanded == true) and (Hud_health_bar.is_expanded == false) then 
  1866. 			--Start to hide the bar. 
  1867. 			lua_play_anim(bar.timer_fade_out_anim_h) 
  1868. 		else 
  1869. 			vint_set_property(bar.timer_fade_out_anim_h, "is_paused", true) 
  1870. 		end 
  1871. 		 
  1872. 		--Attempt to show the sprint bar... 
  1873. 		hud_player_sprint_show() 
  1874. 		 
  1875. 		--Make sure we can see the sprintbar...  
  1876. 		unhide_weapons = true 
  1877. 	end 
  1878.  
  1879. 	if mission_is_active("mIntro") == true then 
  1880. 		num_unlocked_flaps = 0 
  1881. 	end 
  1882.  
  1883. 	if num_unlocked_flaps == nil then 
  1884. 		num_unlocked_flaps = 0 
  1885. 	end 
  1886. 		 
  1887. 	if num_unlocked_flaps > MAX_FLAPS then 
  1888. 		num_unlocked_flaps = MAX_FLAPS 
  1889. 	end 
  1890.  
  1891. 	if num_unlocked_flaps < 0 then 
  1892. 		num_unlocked_flaps = 0 
  1893. 	end 
  1894.  
  1895. 	if num_used_flaps == nil then 
  1896. 		num_used_flaps = 0 
  1897. 	end 
  1898. 	 
  1899. 	if num_used_flaps > MAX_FLAPS then 
  1900. 		num_used_flaps = MAX_FLAPS 
  1901. 	end 
  1902.  
  1903. 	if num_used_flaps < 0 then 
  1904. 		num_used_flaps = 0 
  1905. 	end 
  1906.  
  1907. 	for i = 1, MAX_FLAPS do 
  1908. 		 
  1909. 		local num_flap_used = num_unlocked_flaps - num_used_flaps + 1; 
  1910.  
  1911. 		-- icons 
  1912. 		if i < num_flap_used then 
  1913. 			vint_set_property(Hud_flap_data.icons[i].icon_h, "visible", true) 
  1914. 			vint_set_property(Hud_flap_data.icons[i].icon_h, "alpha", 1) 
  1915. 		else 
  1916. 			vint_set_property(Hud_flap_data.icons[i].icon_h, "visible", false) 
  1917. 		end 
  1918.  
  1919. 		-- icon backgrounds 
  1920. 		if	i <= num_unlocked_flaps then 
  1921. 			vint_set_property(Hud_flap_data.backgrounds[i].bg_h, "visible", true) 
  1922. 			vint_set_property(Hud_flap_data.backgrounds[i].bg_h, "alpha", 1) 
  1923. 		else 
  1924. 			vint_set_property(Hud_flap_data.backgrounds[i].bg_h, "visible", false) 
  1925. 			vint_set_property(Hud_flap_data.icons[i].icon_h, "visible", false) 
  1926. 		end 
  1927.  
  1928. 	end 
  1929.  
  1930. 	if num_used_flaps > 0 then 
  1931. 		unhide_weapons = true 
  1932. 	end 
  1933.  
  1934. 	--If we updated the health or sprint... we unhide the weapons... 
  1935. 	if unhide_weapons == true then 
  1936. 		--fade in... 
  1937. 		hud_weapon_fade_in() 
  1938. 	end 
  1939. 	 
  1940. 	if orientation ~= Hud_player_status.orientation then 
  1941. 		--Rotate Hit Indicators to player rotation 
  1942. 		orientation = 3.14 - orientation 
  1943. 		vint_set_property(Hud_hit_elements.main_h, "rotation", orientation) 
  1944. 		Hud_player_status.orientation = orientation 
  1945. 	end 
  1946. 	 
  1947. 	--Sets the amount of tunnel vision for the player 
  1948. 	if tunnel_vision_amount ~= Hud_vignettes.tunnel_vision then--and 
  1949. 		vint_set_property(Hud_vignettes.tunnel_vision.grp_h, "alpha", tunnel_vision_amount) 
  1950. 	end 
  1951.  
  1952. 	 
  1953. end 
  1954.  
  1955. function hud_player_sprint_show() 
  1956. 	if Hud_sprint_bar.is_expanded == false then 
  1957. 		vint_set_property(vint_object_find("map_sprint_contract"), "is_paused", true) 
  1958. 		lua_play_anim(vint_object_find("map_sprint_expand")) 
  1959. 		Hud_sprint_bar.is_expanded = true 
  1960. 	end 
  1961. end 
  1962.  
  1963. --Plays the animation which retracts the sprint bar. 
  1964. --This is triggered by a callback setup in the init() 
  1965. function hud_player_sprint_hide() 
  1966. 	--Always show sprint if health is up 
  1967. 	if (Hud_health_bar.is_expanded == false) then 
  1968. 		vint_set_property(vint_object_find("map_sprint_expand"), "is_paused", true) 
  1969. 		lua_play_anim(vint_object_find("map_sprint_contract")) 
  1970. 		Hud_sprint_bar.is_expanded = false 
  1971. 	end 
  1972. end 
  1973.  
  1974. function hud_player_health_show() 
  1975. 	vint_set_property(vint_object_find("map_health_contract"), "is_paused", true) 
  1976. 	lua_play_anim(vint_object_find("map_health_expand")) 
  1977. 	Hud_health_bar.is_expanded = true 
  1978. 	hud_player_sprint_show() 
  1979. end 
  1980.  
  1981. --Plays the animation which retracts the health bar. 
  1982. --This is triggered by a callback setup in the init() 
  1983. function hud_player_health_hide() 
  1984. 	vint_set_property(vint_object_find("map_health_expand"), "is_paused", true) 
  1985. 	lua_play_anim(vint_object_find("map_health_contract")) 
  1986. 	Hud_health_bar.is_expanded = false 
  1987. end 
  1988.  
  1989. function hud_player_health_decrease_anim(bar, fill_end_angle, bg_end_angle) 
  1990.  
  1991.  
  1992. 	--Flash the bar if we are not already flashing. 
  1993. 	if Hud_health_bar.is_flashing == false then 
  1994. 		lua_play_anim(bar.health_flash_anim_h, 0) 
  1995. 		Hud_health_bar.is_flashing = true 
  1996. 	end 
  1997.  
  1998.  
  1999. 	--Decay animation... 
  2000. 	if Hud_health_bar.is_decaying == false then 
  2001. 		--We aren't already decaying so its safe to replay the animation... 
  2002. 	 
  2003. 		--update the start values if we aren't decaying... 
  2004. 		local current_start_value = vint_get_property(bar.fill_1_h, "end_angle") 
  2005. 		local bg_start_angle = vint_get_property(bar.bg_h, "end_angle") 
  2006. 		 
  2007. 		vint_set_property(bar.health_bg_angle_twn_h, "start_value", bg_start_angle) 
  2008. 		vint_set_property(bar.health_fill_angle_twn_h, "start_value", current_start_value) 
  2009. 		 
  2010. 		lua_play_anim(bar.health_decay_anim_h, 0) 
  2011. 		-- The decaying flag will get set to true when the tween actually starts. until then we won't update that. 
  2012. 	end 
  2013.  
  2014. 	--change the state of the end tweens regardless if we are decaying or not... 
  2015. 	--Pop start of second bar to first 
  2016. 	vint_set_property(bar.fill_h, "end_angle", fill_end_angle) 
  2017. 	vint_set_property(bar.fill_1_h, "start_angle", fill_end_angle) 
  2018.  
  2019. 	--Set values for fill angle	 
  2020. 	vint_set_property(bar.health_fill_angle_twn_h, "end_value", fill_end_angle) 
  2021. 	 
  2022. 	--set values for bg end angle... 
  2023. 	vint_set_property(bar.health_bg_angle_twn_h, "end_value", bg_end_angle) 
  2024. end 
  2025.  
  2026. function hud_player_health_increase_anim(bar, fill_end_angle, bg_end_angle) 
  2027. 	--stop decrease anims 
  2028. 	vint_set_property(bar.health_flash_anim_h, "is_paused", true) 
  2029. 	vint_set_property(bar.health_decay_anim_h, "is_paused", true) 
  2030. 	Hud_health_bar.is_decaying = false 
  2031. 	Hud_health_bar.is_flashing = false 
  2032. 	 
  2033. 	--update the values directly... 
  2034. 	vint_set_property(bar.fill_h, "end_angle", fill_end_angle) 
  2035. 	vint_set_property(bar.fill_1_h, "end_angle", fill_end_angle) 
  2036. 	vint_set_property(bar.bg_h, "end_angle", bg_end_angle) 
  2037. end 
  2038.  
  2039. --Callbacks for health animations... 
  2040. function hud_health_decay_start(twn_h) 
  2041. 	--set our decaying status to true 
  2042. 	Hud_health_bar.is_decaying = true 
  2043. end 
  2044.  
  2045. function hud_health_decay_end(twn_h) 
  2046. 	--set our decaying status to false... 
  2047. 	Hud_health_bar.is_decaying = false 
  2048. end 
  2049.  
  2050. function hud_health_flash_complete(twn_h) 
  2051. 	Hud_health_bar.is_flashing = false 
  2052. end 
  2053.  
  2054.  
  2055. --##################################################### 
  2056. --Weapon Changes 
  2057. --##################################################### 
  2058.  
  2059. function hud_player_weapon_change(di_h, event_name) 
  2060. 	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)	 
  2061.  
  2062. 	Hud_super_bar.is_ship = is_mech 
  2063. 	 
  2064. 	--set flag to hide or show the dpad menu 
  2065. 	if super_disabled_by_script == true then 
  2066. 		Hud_powers_are_disabled = true 
  2067. 	else 
  2068. 		Hud_powers_are_disabled = false 
  2069. 	end 
  2070. 	 
  2071. 	--Set flag to determine if we should attemp to unhide the weapons... 
  2072. 	local unhide_weapons = false 
  2073. 	 
  2074. 	--Update weapon area... 
  2075. 	if wpn_bmp_name == nil then 
  2076. 		wpn_bmp_name = "ui_hud_inv_fist" 
  2077. 	end 
  2078. 	 
  2079. 	--Do not show mech icon as dual 
  2080. 	if wpn_bmp_name == "ui_hud_inv_veh_mgun_missle" then 
  2081. 		dual_wield = false 
  2082. 	end 
  2083.  
  2084. 	if dual_wield ~= Hud_weapon_status.dual_wield or wpn_bmp_name ~= Hud_weapon_status.wpn_bmp_name then 
  2085. 		if dual_wield == true then 
  2086. 			vint_set_property(Hud_weapon_status.dual_wpn_icon_1_h, "image", wpn_bmp_name) 
  2087. 			vint_set_property(Hud_weapon_status.dual_wpn_icon_2_h, "image", wpn_bmp_name) 
  2088. 		else 
  2089. 			vint_set_property(Hud_weapon_status.single_wpn_icon_h, "image", wpn_bmp_name) 
  2090. 		end 
  2091. 		unhide_weapons = true 
  2092. 		Hud_weapon_status.wpn_bmp_name = wpn_bmp_name 
  2093. 	end 
  2094.  
  2095. 	if dual_wield ~= Hud_weapon_status.dual_wield then 
  2096. 		vint_set_property(Hud_weapon_status.dual_wpn_icon_1_h, "visible", dual_wield) 
  2097. 		vint_set_property(Hud_weapon_status.dual_wpn_icon_2_h, "visible", dual_wield) 
  2098. 		vint_set_property(Hud_weapon_status.single_wpn_icon_h, "visible", not dual_wield) 
  2099. 		 
  2100. 		unhide_weapons = true 
  2101. 		Hud_weapon_status.dual_wield = dual_wield 
  2102. 	end 
  2103. 	 
  2104. 	--Update Super Power area 
  2105. 	local super_bmp_name = -1 
  2106. 	local grenade_slot = -1 
  2107. 	 
  2108. 	if cur_super_name ~= -1 and cur_super_name ~= 255 and cur_super_name ~= nil then 
  2109. 		super_bmp_name = Hud_super_powers[cur_super_name].bitmap 
  2110. 		grenade_slot = Hud_super_powers[cur_super_name].slot 
  2111. 	else 
  2112. 		super_bmp_name = nil 
  2113. 		grenade_slot = 8 
  2114. 	end 
  2115. 	 
  2116. 	--check if turned off 
  2117. 	if super_disabled_by_script == false then 
  2118. 	 
  2119. 		--Suppressed 
  2120. 		if super_suppressed >= .33 and cur_super_name ~= -1 and cur_super_name ~= nil then 
  2121. 			 
  2122. 			local super_strength_level = -1 
  2123.  
  2124. 			if super_suppressed >= .33 and super_suppressed < .67 then 
  2125. 				super_strength_level = 2 
  2126. 			elseif super_suppressed >= .67 and super_suppressed < 1 then 
  2127. 				super_strength_level = 3 
  2128. 			else  
  2129. 				super_strength_level = 4 
  2130. 			end 
  2131.  
  2132. 			local insert_values = {[0] = super_strength_level} 
  2133. 			local super_strength_string = vint_insert_values_in_string("HUD_SUPER_LEVEL", insert_values) 
  2134. 			 
  2135. 			vint_set_property(Hud_super_bar.super_strength_h, "text_tag", super_strength_string) 
  2136. 			--vint_set_property(Hud_super_bar.super_strength_h, "visible", true) 
  2137. 		else 
  2138. 			--vint_set_property(Hud_super_bar.super_strength_h, "visible", false) 
  2139. 		end 
  2140. 		 
  2141. 		--Disabled 
  2142. 		if super_disabled == true or is_power_recharging == true then 
  2143. 			if Hud_super_bar.pulse_is_playing == false then 
  2144. 				lua_play_anim(Hud_super_bar.pulse_anim_h) 
  2145. 				Hud_super_bar.pulse_is_playing = true 
  2146. 			end 
  2147. 			vint_set_property(Hud_weapon_status.super_icon_h, "alpha", .5) 
  2148. 			vint_set_property(Hud_super_bar.super_strength_h, "alpha", .5) 
  2149. 			vint_set_property(Hud_weapon_status.element_icon_h, "alpha", .5) 
  2150. 		else 
  2151. 			vint_set_property(Hud_super_bar.pulse_anim_h, "is_paused", true) 
  2152. 			Hud_super_bar.pulse_is_playing = false 
  2153. 			vint_set_property(Hud_weapon_status.super_icon_h, "alpha", 1) 
  2154. 			vint_set_property(Hud_super_bar.super_strength_h, "alpha", 1) 
  2155. 			vint_set_property(Hud_weapon_status.element_icon_h, "alpha", 1) 
  2156. 		end 
  2157. 		 
  2158. 		vint_set_property(Hud_super_bar.fill_h, "alpha", 1) 
  2159. 		vint_set_property(Hud_super_bar.bg_h, "alpha", 1) 
  2160. 		vint_set_property(Hud_super_bar.pressure_fill, "alpha", .5) 
  2161. 		 
  2162. 	else 
  2163. 		--turned off 
  2164. 		vint_set_property(Hud_weapon_status.super_icon_h, "alpha", 0) 
  2165. 		vint_set_property(Hud_super_bar.fill_h, "alpha", 0) 
  2166. 		vint_set_property(Hud_super_bar.bg_h, "alpha", 0) 
  2167. 		vint_set_property(Hud_super_bar.super_strength_h, "alpha", 0) 
  2168. 		vint_set_property(Hud_weapon_status.element_icon_h, "alpha", 0) 
  2169. 	end 
  2170. 	 
  2171. 	--super power charge meter 
  2172. 	 
  2173. 	--adjust bg so it doesnt stick out over weapon bg edge 
  2174. 	if super_charge == 1 or super_charge == 0 then 
  2175. 		Hud_super_bar.angle_offset = 0 
  2176. 		--vint_set_property(Hud_super_bar.bg_h, "visible", false) 
  2177. 	else 
  2178. 		Hud_super_bar.angle_offset = .07 
  2179. 		--vint_set_property(Hud_super_bar.bg_h, "visible", true) 
  2180. 	end 
  2181. 	 
  2182. 	Hud_super_bar.fill_end_angle = (1 - super_charge) * 4.15 
  2183. 	local super_fill_angle = Hud_super_bar.fill_end_angle 
  2184. 	local super_bg_angle = Hud_super_bar.fill_end_angle - Hud_super_bar.angle_offset 
  2185. 	 
  2186. 	vint_set_property(Hud_super_bar.fill_h, "start_angle", super_fill_angle) 
  2187. 	vint_set_property(Hud_super_bar.bg_h, "start_angle", super_bg_angle) 
  2188. 	 
  2189. 	--super reticule meter 
  2190. 	 
  2191. 	Hud_super_bar.pressure_fill_end_angle = super_charge * 3.147 
  2192. 	vint_set_property(Hud_super_bar.pressure_fill, "end_angle", Hud_super_bar.pressure_fill_end_angle) 
  2193. 		 
  2194. 	if super_charge == 1 then 
  2195. 		vint_set_property(Hud_super_bar.pressure_grp, "visible", false) 
  2196. 	else 
  2197. 		if super_bmp_name ~= -1 and super_bmp_name ~= nil then 
  2198. 			--match meter color to icon 
  2199. 			local super_colors = Hud_super_powers[cur_super_name].tint 
  2200. 			vint_set_property(Hud_super_bar.pressure_fill, "tint", super_colors.R, super_colors.G, super_colors.B) 
  2201. 			vint_set_property(Hud_super_bar.pressure_grp, "visible", true) 
  2202. 		end 
  2203. 	end 
  2204. 	 
  2205. 	 
  2206. 	-- Set\Hide\Show Super Power icon 
  2207. 	if super_bmp_name ~= Hud_weapon_status.super_bmp_name or power_changed == true or element ~= Hud_super_bar.current_element then 
  2208. 		 
  2209. 		if super_bmp_name ~= -1 and super_bmp_name ~= nil then 
  2210. 			--match meter color to icon 
  2211. 			local super_colors = Hud_super_powers[cur_super_name].tint 
  2212. 			 
  2213. 			vint_set_property(Hud_super_bar.fill_h, "visible", true) 
  2214. 			vint_set_property(Hud_super_bar.bg_h, "visible", true) 
  2215. 			vint_set_property(Hud_super_bar.fill_h, "tint", super_colors.R, super_colors.G, super_colors.B) 
  2216. 			vint_set_property(Hud_super_bar.super_strength_h, "tint", super_colors.R, super_colors.G, super_colors.B) 
  2217. 			 
  2218. 			 
  2219. 			--Set weapon bitmap... 
  2220. 			vint_set_property(Hud_weapon_status.super_icon_h, "image", super_bmp_name)		--Weapon Bitmap 
  2221. 			--Show objects... 
  2222. 			vint_set_property(Hud_weapon_status.super_icon_h, "visible", true)						--Weapon Bitmap 
  2223. 			 
  2224. 			--flash new super power in center of screen 
  2225. 			vint_set_property(Hud_super_bar.element_swap_icon_h, "image", POWERS_ELEMENTS_ENUMS[element].bitmap) 
  2226. 			vint_set_property(Hud_super_bar.super_swap_icon_h, "image", super_bmp_name) 
  2227. 			if Hud_super_bar.swap_is_playing == false then 
  2228. 				--start anim from faded out 
  2229. 				vint_set_property(Hud_super_bar.super_swap_start_twn_h, "start_value", 0) 
  2230. 			else 
  2231. 				--already playing, start anim from faded in 
  2232. 				vint_set_property(Hud_super_bar.super_swap_start_twn_h, "start_value", 1) 
  2233. 			end 
  2234. 			lua_play_anim(Hud_super_bar.super_swap_anim_h) 
  2235. 			Hud_super_bar.swap_is_playing = true 
  2236. 			 
  2237. 			--play super power audio on swap 
  2238. 			audio_stop(Cur_audio_id) 
  2239. 			Cur_audio_id = audio_object_post_event("UI_Select_SuperPower", "Super_Power_Select", Hud_super_powers[cur_super_name].sfx, nil, false) 
  2240. 			 
  2241. 		else 
  2242. 			--Hide objects... 
  2243. 			--vint_set_property(Hud_super_bar.super_strength_h, "visible", false) 
  2244. 			vint_set_property(Hud_super_bar.fill_h, "visible", false) 
  2245. 			vint_set_property(Hud_super_bar.bg_h, "visible", false) 
  2246. 			vint_set_property(Hud_weapon_status.super_icon_h, "visible", false)	 
  2247. 		end 
  2248. 		 
  2249. 		unhide_weapons = true 
  2250. 		Hud_weapon_status.super_bmp_name = super_bmp_name 
  2251. 		Hud_super_bar.current_element = element 
  2252. 	end 
  2253. 	 
  2254. 	--element, we currently don't show this on the hud 
  2255. 	if element ~= nil and element ~= -1 then 
  2256. 		if element ~= Hud_weapon_status.element then 
  2257. 			vint_set_property(Hud_weapon_status.element_icon_h, "image", POWERS_ELEMENTS_ENUMS[element].bitmap) 
  2258. 			vint_set_property(Hud_weapon_status.element_icon_h, "visible", false) --set this to true to show element on hud 
  2259. 		end 
  2260. 	else 
  2261. 		vint_set_property(Hud_weapon_status.element_icon_h, "visible", false) 
  2262. 	end 
  2263. 	 
  2264. 	Hud_weapon_status.element = element 
  2265. 	 
  2266. 	--Show recharging info 
  2267. 	if is_recharging == true and inf_ammo ~= true then 
  2268. 		vint_set_property(Hud_weapon_status.single_wpn_icon_h, "alpha", .5) 
  2269. 		vint_set_property(Hud_weapon_status.dual_wpn_icon_1_h, "alpha", .5) 
  2270. 		vint_set_property(Hud_weapon_status.dual_wpn_icon_2_h, "alpha", .5) 
  2271. 		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) 
  2272. 		hud_resize_text_element(Hud_weapon_status.recharging_txt_h, 80) 
  2273. 		vint_set_property(Hud_weapon_status.recharging_txt_h, "visible", true) 
  2274. 		 
  2275. 	else 
  2276. 		vint_set_property(Hud_weapon_status.single_wpn_icon_h, "alpha", 1) 
  2277. 		vint_set_property(Hud_weapon_status.dual_wpn_icon_1_h, "alpha", 1) 
  2278. 		vint_set_property(Hud_weapon_status.dual_wpn_icon_2_h, "alpha", 1) 
  2279. 		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) 
  2280. 		vint_set_property(Hud_weapon_status.recharging_txt_h, "visible", false) 
  2281. 	end 
  2282. 	 
  2283. 	 
  2284. 	 
  2285. 	--Update Ammo Count 
  2286. 	local ammo_combined = rdy_ammo + rsv_ammo 
  2287. 	local ammo_string = "" 
  2288. 	if is_pct == true then 
  2289. 		if no_ammo == false then 
  2290. 			if inf_ammo == false then 
  2291. 				ammo_string = "" .. ammo_combined .. "%%" 
  2292. 			else 
  2293. 				ammo_string = "[image:ui_hud_base_smcirc_infinite]" 
  2294. 			end 
  2295. 		end 
  2296. 	else 
  2297. 		if no_ammo == false then 
  2298. 			if no_mag == true then 
  2299. 				if inf_ammo == false then 
  2300. 					if cont_fire == false then 
  2301. 						ammo_string = "" .. ammo_combined 
  2302. 					else 
  2303. 						ammo_string = "" .. ammo_combined 
  2304. 					end 
  2305. 				else 
  2306. 					ammo_string = "[image:ui_hud_base_smcirc_infinite]" 
  2307. 				end 
  2308. 			else 
  2309. 				if inf_ammo == false then 
  2310. 					if cont_fire == false then 
  2311. 						ammo_string = rdy_ammo .. "/" .. rsv_ammo 
  2312. 					else 
  2313. 						 
  2314. 						ammo_string = floor(rdy_ammo / 100) .. "/" .. floor(rsv_ammo / 100) 
  2315. 					end 
  2316. 				else 
  2317. 					if cont_fire == false then 
  2318. 						ammo_string = rdy_ammo .. "/[image:ui_hud_base_smcirc_infinite]" 
  2319. 					else 
  2320. 						ammo_string = floor(rdy_ammo / 100) .. "/[image:ui_hud_base_smcirc_infinite]" 
  2321. 					end 
  2322. 				end 
  2323. 			end 
  2324. 		end 
  2325. 	end 
  2326. 	 
  2327. 	vint_set_property(Hud_weapon_status.weapon_ammo_txt_h, "text_tag", ammo_string) 
  2328. 	vint_set_property(Hud_weapon_status.sniper_ammo_txt_h, "text_tag", ammo_string) 
  2329. 	 
  2330. 	Hud_weapon_status.show_reticule = show_reticule 
  2331. 	 
  2332. 	if reloading then 
  2333. 		vint_set_property(Hud_weapon_status.sniper_reload_txt_h, "visible", true) 
  2334. 		lua_play_anim(Hud_weapon_status.sniper_ammo_anim, 0, HUD_DOC_HANDLE) 
  2335. 	else 
  2336. 		vint_set_property(Hud_weapon_status.sniper_reload_txt_h, "visible", false) 
  2337. 	end 
  2338.  
  2339. 	--Unhide weapons if the ammo string has changed, for recharge weapons only if recharging status has changed.... 
  2340. 	if is_pct then 
  2341. 		if is_recharging or Hud_weapon_status.is_recharging ~= is_recharging or ammo_combined < Hud_weapon_status.ammo_combined then 
  2342. 			unhide_weapons = true 
  2343. 		end 
  2344. 	else 
  2345. 		if ammo_string ~= Hud_weapon_status.ammo_string then 
  2346. 			unhide_weapons = true 
  2347. 			Hud_weapon_status.ammo_string = ammo_string 
  2348. 		end 
  2349. 	end	 
  2350. 		 
  2351. 	if super_charge ~= Hud_weapon_status.super_charge then 
  2352. 		unhide_weapons = true 
  2353. 		Hud_weapon_status.super_charge = super_charge 
  2354. 	end 
  2355. 		 
  2356. 	Hud_weapon_status.is_recharging = is_recharging	 
  2357. 	Hud_weapon_status.ammo_combined = ammo_combined 
  2358. 	 
  2359. 	--Dim Weapon if not ready 
  2360. 	if wpn_rdy ~= Hud_weapon_status.wpn_rdy then 
  2361. 		if wpn_rdy == true then 
  2362. 			--Show Weapon 
  2363. 			vint_set_property(Hud_weapon_status.weapon_grp_h, "alpha", 1) 
  2364. 						 
  2365. 			--TODO: Show and hide reticule need to be pulled out of here and moved into a function that stacks the reticule visibility. 
  2366. 			 
  2367. 			if Hud_weapon_status.sniper_visible == false and Hud_weapon_status.show_reticule == true then 
  2368. 				--Show reticule 
  2369. 				vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", true) 
  2370. 			else 
  2371. 				vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", false) 
  2372. 			end 
  2373. 		else 
  2374. 			--Dim Weapon 
  2375. 			vint_set_property(Hud_weapon_status.weapon_grp_h, "alpha", 0.67) 
  2376. 			 
  2377. 			--Hide reticule 
  2378. 			vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", false) 
  2379. 		end 
  2380. 		 
  2381. 		-- do not un hide weapons on weapon ready change... (JMH 10/14/2010) 
  2382. 		-- unhide_weapons = true 
  2383. 		Hud_weapon_status.wpn_rdy = wpn_rdy 
  2384. 	else 
  2385. 		-- Make sure we hide the reticule if it changes but weapon ready doesn't. 
  2386. 		vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", show_reticule) 
  2387. 	end 
  2388. 	 
  2389. 	--If sniper rifle is on then show the sniper rifle and not the standard reticule	 
  2390. 	if sniper_visible ~= Hud_weapon_status.sniper_visible then 
  2391. 		if sniper_visible == true then 
  2392. 			vint_set_property(Hud_reticules.elements.sniper_h, "visible", true) 
  2393. 			vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", false) 
  2394. 			hud_sniper_set_hints() 
  2395. 			Hud_sniper_hint_bar:set_visible(true) 
  2396. 							 
  2397. 		else 
  2398. 			vint_set_property(Hud_reticules.elements.sniper_h, "visible", false) 
  2399. 			vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", true) 
  2400. 			Hud_sniper_hint_bar:set_visible(false) 
  2401. 			 
  2402. 		end 
  2403. 		Hud_weapon_status.sniper_visible = sniper_visible 
  2404. 	end	 
  2405.  
  2406. 	--Change reticules if we have a different weapon 
  2407. 	if wpn_name ~= Hud_reticules.status.wpn_name or reticule_highlight ~= Hud_reticules.status.highlight  then 
  2408. 		Hud_reticule_update(wpn_name, wpn_category, reticule_highlight) 
  2409. 	end 
  2410. 	 
  2411. 	--Process a hit every frame 
  2412. 	Hud_reticule_process_hit(bullet_hit) 
  2413.  
  2414. 	--Do Weapon Spread 
  2415. 	if wpn_spread ~= Hud_reticules.status.wpn_spread then 
  2416. 		hud_reticule_spread_update(wpn_spread, Hud_reticules.configs[Hud_reticules.status.config].spread) 
  2417. 	end 
  2418. 	 
  2419. 	--Update current selections in the radial menu 
  2420. 	if wpn_slot ~= Hud_weapon_radial.equipped_weapon_slot then 
  2421. 		Hud_weapon_radial:weapon_highlight(wpn_slot, true) 
  2422. 		--unhide_weapons = true 
  2423. 	end 
  2424. 	if grenade_slot ~= Hud_weapon_radial.equipped_grenade_slot then 
  2425. 		Hud_weapon_radial:weapon_highlight(grenade_slot, true) 
  2426. 		--unhide_weapons = true 
  2427. 	end 
  2428. 	 
  2429. 	if grenade_slot == 0 then 
  2430. 		Hud_weapon_radial.equipped_grenade_slot = 0 
  2431. 	end 
  2432. 	 
  2433. 	hud_reticule_overheat_update(overheat_pct, is_overheated) 
  2434.  
  2435. 	if unhide_weapons == true then 
  2436. 		--fade in... 
  2437. 		hud_weapon_fade_in() 
  2438. 	end	 
  2439.  
  2440. 	 
  2441. 	if genki_target ~= HUD_GENKI_NONE then 
  2442. 		vint_set_property(Hud_genki_images[HUD_GENKI_ETHICAL], "visible", true) 
  2443. 		vint_set_property(Hud_genki_images[HUD_GENKI_UNETHICAL], "visible", true) 
  2444. 		if genki_target == HUD_GENKI_ETHICAL then 
  2445. 			vint_set_property(Hud_genki_images[HUD_GENKI_UNETHICAL], "visible", false) 
  2446. 			vint_set_property(Hud_genki_anims[HUD_GENKI_UNETHICAL], "is_paused", true) 
  2447. 		elseif genki_target == HUD_GENKI_UNETHICAL then 
  2448. 			vint_set_property(Hud_genki_images[HUD_GENKI_ETHICAL], "visible", false) 
  2449. 			vint_set_property(Hud_genki_anims[HUD_GENKI_ETHICAL], "is_paused", true) 
  2450. 		end 
  2451. 		lua_play_anim(Hud_genki_anims[genki_target]) 
  2452. 	end 
  2453.  
  2454. end 
  2455.  
  2456. function hud_resize_text_element(element_h, max_width) 
  2457. 	vint_set_property(element_h, "scale", 1, 1) 
  2458. 	local text_width, text_height = element_get_actual_size(element_h)	 
  2459. 	if text_width > max_width then 
  2460. 		local text_scale = max_width/text_width 
  2461. 		vint_set_property(element_h, "scale", text_scale, text_scale) 
  2462. 	end 
  2463. end 
  2464.  
  2465.  
  2466. function hud_sniper_set_hints() 
  2467. 	local Hud_sniper_button_hints = { 
  2468. 		{CTRL_BUTTON_Y, "HUD_SNIPER_ZOOM_IN", game_get_key_name_for_action("CBA_OFC_ZOOM_IN")}, 
  2469. 		{CTRL_GAMEPLAY_BUTTON_A, "HUD_SNIPER_ZOOM_OUT", game_get_key_name_for_action("CBA_OFC_ZOOM_OUT")}, 
  2470. 	} 
  2471. 	Hud_sniper_hint_bar:set_hints(Hud_sniper_button_hints) 
  2472. 	local width, height = Hud_sniper_hint_bar:get_size() 
  2473. 	local Hud_sniper_hint_bar_x,Hud_sniper_hint_bar_y = Hud_sniper_hint_bar:get_property("anchor") 
  2474. 	local x = -1*(width*0.5) 
  2475. 	vint_set_property(Hud_sniper_hint_bar.handle, "anchor", x, Hud_sniper_hint_bar_y) 
  2476. 	vint_set_property(Hud_sniper_hint_bar.handle, "alpha", 1.0) 
  2477. 	Hud_sniper_hint_bar:enable_text_shadow(false) 
  2478. end 
  2479.  
  2480. function hud_vtol_set_hints() 
  2481.  
  2482. 	Hud_vtol_button_hints = { 
  2483. 		{CTRL_GAMEPLAY_BUTTON_B, "SWITCH_MODE", game_get_key_name_for_action("CBA_VDC_VTOL_TRANSITION")}, 
  2484. 	} 
  2485. 	Hud_sniper_hint_bar:set_hints(Hud_vtol_button_hints) 
  2486. 	local width, height = Hud_sniper_hint_bar:get_size() 
  2487. 	local Hud_sniper_hint_bar_x,Hud_sniper_hint_bar_y = Hud_sniper_hint_bar:get_property("anchor") 
  2488. 	local x = -1*(width*0.5) 
  2489. 	vint_set_property(Hud_sniper_hint_bar.handle, "anchor", x, Hud_sniper_hint_bar_y) 
  2490. 	vint_set_property(Hud_sniper_hint_bar.handle, "alpha", 0.67) 
  2491. 	Hud_sniper_hint_bar:enable_text_shadow(true) 
  2492. end 
  2493.  
  2494. function hud_weapon_fade_in() 
  2495. 	--Fade in only if we aren't hidden... 
  2496. 	if Hud_weapon_status.weapon_is_hidden == true and Hud_weapon_status.hud_state_h ~= nil then 
  2497. 		ui_hud_display_remove_state(Hud_weapon_status.hud_state_h, false) 
  2498. 		Hud_weapon_status.hud_state_h = nil 
  2499. 	end 
  2500. 	 
  2501. 	Hud_weapon_status.weapon_is_hidden = false 
  2502. 	 
  2503. 	-- this fades the weapon after a time 
  2504. 	lua_play_anim(vint_object_find("weapon_timer_anim")) 
  2505. end 
  2506. 	 
  2507.  
  2508. function hud_weapon_fade_out() 
  2509. 	if Hud_weapon_status.weapon_is_hidden == false then 
  2510. 		if Hud_weapon_status.hud_state_h ~= nil then 
  2511. 			ui_hud_display_remove_state(Hud_weapon_status.hud_state_h, false) 
  2512. 			Hud_weapon_status.hud_state_h = nil 
  2513. 		end 
  2514.  
  2515. 		local hud_state_h = ui_hud_display_create_state() 
  2516. 		ui_hud_display_set_element(hud_state_h, HUD_ALL_ELEM, HUD_FADE_NO_CHANGE) 
  2517. 		ui_hud_display_set_element(hud_state_h, HUD_ELEM_WEAPONS, HUD_FADE_HIDDEN) 
  2518. 		ui_hud_display_commit_state(hud_state_h, false) 
  2519. 		 
  2520. 		Hud_weapon_status.hud_state_h = hud_state_h 
  2521. 		Hud_weapon_status.weapon_is_hidden = false 
  2522. 	end 
  2523.  
  2524. 	Hud_weapon_status.weapon_is_hidden = true 
  2525. end 
  2526.  
  2527. function hud_weapon_show() 
  2528. 	Hud_weapon_status.weapon_is_hidden = false 
  2529. 	hud_weapon_fade_in() 
  2530. end 
  2531.  
  2532. function hud_weapon_hide() 
  2533. 	Hud_weapon_status.weapon_is_hidden = true 
  2534. end 
  2535.  
  2536. function hud_player_weapon_freq_change(di_h) 
  2537. 	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) 
  2538. 	if fine_aim_transition ~= Hud_weapon_status.fine_aim_transition then 
  2539. 		hud_reticule_spread_update(cur_wpn_spread, Hud_reticules.configs[Hud_reticules.status.config].spread) 
  2540. 		if fine_aim_transition == nil then 
  2541. 			fine_aim_transition  = 0 
  2542. 		end 
  2543. 		 
  2544. 		--Fine aim minimap off... 
  2545. 		local tranny = 1.2 - fine_aim_transition 
  2546. 		tranny = limit(tranny, 0, 1) 
  2547. 		vint_set_property(Hud_map.base_grp_h, "alpha", tranny) 
  2548. 		Hud_weapon_status.fine_aim_transition = fine_aim_transition 
  2549. 	end 
  2550. 	 
  2551. 	--Update pressure 
  2552. 	hud_reticule_update_pressure(water_pressure) 
  2553. 		 
  2554. 	--Change x y screen coords of reticule 
  2555. 	hud_reticule_change_position(x_screen_coord, y_screen_coord) 
  2556. 	 
  2557. 	--Update Reticle Opacity 
  2558. 	hud_reticule_opacity_update(reticule_opacity) 
  2559.  
  2560. 	if is_player_flying then 
  2561. 		vint_set_property(Hud_weapon_status.single_wpn_icon_h, "alpha", 0) 
  2562. 		vint_set_property(Hud_weapon_status.dual_wpn_icon_1_h, "alpha", 0) 
  2563. 		vint_set_property(Hud_weapon_status.dual_wpn_icon_2_h, "alpha", 0) 
  2564. 		vint_set_property(Hud_weapon_status.weapon_ammo_txt_h, "alpha", 0) 
  2565. 	else 
  2566. 		vint_set_property(Hud_weapon_status.single_wpn_icon_h, "alpha", 1) 
  2567. 		vint_set_property(Hud_weapon_status.dual_wpn_icon_1_h, "alpha", 1) 
  2568. 		vint_set_property(Hud_weapon_status.dual_wpn_icon_2_h, "alpha", 1) 
  2569. 		vint_set_property(Hud_weapon_status.weapon_ammo_txt_h, "alpha", 1) 
  2570. 	end 
  2571.  
  2572. 	if is_player_flying then 
  2573. 		if Hud_reticules.status.wpn_name ~= nil then 
  2574. 			Hud_reticule_update(nil, "WPNCAT_DOT", Hud_reticules.status.highlight) 
  2575. 		end 
  2576. 	end 
  2577.  
  2578. 	--Update Ammo Count 
  2579. 	 
  2580. 	local damage_multiplier_string = "" 
  2581. 	if damage_multiplier > 100 then 
  2582. 		vint_set_property(Hud_damage_multiplier.grp, "visible", true) 
  2583. 		damage_multiplier_string = "X" .. damage_multiplier .. "%%" 
  2584. 	else 
  2585. 		vint_set_property(Hud_damage_multiplier.grp, "visible", false) 
  2586. 		damage_multiplier_string = "" 
  2587. 	end	 
  2588. 	 
  2589. 	vint_set_property(Hud_damage_multiplier.multiplier_txt, "text_tag", damage_multiplier_string) 
  2590.  
  2591. 	-- HVS_JPM - scale damage multiplier banner so it fits localized string 
  2592. 	local bonus_dmg_txt_h = Vdo_base_object:new("bonus_damage_txt", Hud_damage_multiplier.grp) 
  2593. 	local bonus_dmg_bg_h = Vdo_base_object:new("frame_fill01", Hud_damage_multiplier.grp)  -- background 
  2594. 	local bonus_dmg_l_cap_h = Vdo_base_object:new("frame_cap_l01", Hud_damage_multiplier.grp)  -- l cap 
  2595. 	local bonus_dmg_r_cap_h = Vdo_base_object:new("frame_cap_r01", Hud_damage_multiplier.grp)  -- r cap 
  2596.  
  2597. 	local bonus_dmg_bg_anchor_x, bonus_dmg_bg_anchor_y = bonus_dmg_bg_h:get_anchor() 
  2598. 	local bonus_dmg_bg_size_x, bonus_dmg_bg_size_y = bonus_dmg_bg_h:get_actual_size() 
  2599.  
  2600. 	-- find text size 
  2601. 	bonus_dmg_txt_h:set_text_crc(get_localized_crc_for_tag("HUD_DAMAGE_BONUS")) 
  2602. 	local text_size_x, text_size_y = bonus_dmg_txt_h:get_actual_size() 
  2603.  
  2604. 	local BONUS_DAMAGE_TEXT_PADDING = 20 
  2605. 	local new_bg_size = text_size_x + BONUS_DAMAGE_TEXT_PADDING 
  2606.  
  2607. 	-- only change if its bigger than the current size 
  2608. 	if new_bg_size < bonus_dmg_bg_size_x then 
  2609. 		new_bg_size = bonus_dmg_bg_size_x 
  2610. 	end 
  2611.  
  2612. 	-- set size 
  2613. 	bonus_dmg_bg_h:set_actual_size(new_bg_size, bonus_dmg_bg_size_y) 
  2614.  
  2615. 	-- reposition endcaps 
  2616. 	bonus_dmg_l_cap_h:set_anchor(bonus_dmg_bg_anchor_x - new_bg_size/2, bonus_dmg_bg_anchor_y) 
  2617. 	bonus_dmg_r_cap_h:set_anchor(bonus_dmg_bg_anchor_x + new_bg_size/2, bonus_dmg_bg_anchor_y) 
  2618.  
  2619. end 
  2620.  
  2621. function hud_player_satellite_weapon(di_h) 
  2622. 	-- TODO: finish 
  2623. end 
  2624.  
  2625.  
  2626. function hud_player_respect_change(di_h) 
  2627. 	 
  2628. 	local total_respect, respect_pct, respect_level, show_upgrades, force_show_respect = vint_dataitem_get(di_h) 
  2629. 	 
  2630. 	local respect_meter_show_upgrade = false	--Flag to determine if we want to actually show upgrades... 
  2631. 	if Hud_player_status.respect_show_upgrades ~= show_upgrades then 
  2632. 		-- Upgrade flag changed... so we need to do something... 
  2633. 		 
  2634. 		--We are done showing upgrades... 
  2635. 		if show_upgrades == false then 
  2636. 			--Have respect animate back to normal... 
  2637. 			Hud_respect:game_is_finished_showing_upgrades() 
  2638. 			--Reset Fade out timer. :) 
  2639. 			lua_play_anim(Hud_player_status.respect_timer_h) 
  2640. 		else 
  2641. 			--We actually need to show upgrades on for this update... 
  2642. 			respect_meter_show_upgrade = true 
  2643. 		end 
  2644. 		Hud_player_status.respect_show_upgrades = show_upgrades 
  2645. 	end 
  2646. 	 
  2647. 	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 
  2648. 		Hud_respect:update_respect(total_respect, respect_pct, respect_level, respect_meter_show_upgrade) 
  2649. 		Hud_player_status.total_respect = total_respect 
  2650. 		Hud_player_status.respect_pct = respect_pct 
  2651. 		Hud_player_status.respect_level = respect_level 
  2652. 	end 
  2653. 	 
  2654. 	-- force_show_respect causes respect to be shown.  no condition check is needed. 
  2655. 	if Hud_player_status.respect_is_hidden == true then 
  2656. 		lua_play_anim(vint_object_find("respect_fade_in_anim")) 
  2657. 		Hud_player_status.respect_is_hidden = false 
  2658. 	end 
  2659. 	 
  2660. 	lua_play_anim(Hud_player_status.respect_timer_h) 
  2661. end 
  2662.  
  2663. --Plays the animation which hides the respect bar... 
  2664. --This is triggered by a callback setup in the init() 
  2665. function hud_player_respect_hide() 
  2666. 	if Hud_player_status.respect_is_hidden ~= true then 
  2667. 		if Hud_respect:can_hide() then 
  2668. 			--Check if we can hide first... 
  2669. 			lua_play_anim(vint_object_find("respect_fade_out_anim")) 
  2670. 			Hud_player_status.respect_is_hidden = true 
  2671. 		else 
  2672. 			--If we can't hide then restart start the timer tween... 
  2673. 			lua_play_anim(Hud_player_status.respect_timer_h) 
  2674. 		end 
  2675. 	end 
  2676. end 
  2677.  
  2678. -- Plays the animation which hides the respect bar... 
  2679. -- Hides the respect but immediatly... triggered by flashpoint complete.. 
  2680. function hud_player_respect_force_hide() 
  2681. 	if Hud_respect:can_hide() then 
  2682. 		--Check if we can hide first... 
  2683. 		Hud_respect:set_alpha(0) 
  2684. 		Hud_player_status.respect_is_hidden = true 
  2685. 	else 
  2686. 		--If we can't hide then restart start the timer tween... 
  2687. 		lua_play_anim(Hud_player_status.respect_timer_h) 
  2688. 	end 
  2689. end 
  2690.  
  2691. function hud_player_followers_change(di_h) 
  2692. 	local slot, head_img_name, hlth_pct, revive_time, slot_visible = vint_dataitem_get(di_h) 
  2693.  
  2694. 	--No slots other than 1 to 3 allowed. 
  2695. 	if slot < 1 or slot > 3 then 
  2696. 		return 
  2697. 	end 
  2698. 	 
  2699. 	--Turn on whole followers section for a few seconds - or prolong if already on. 
  2700. 	hud_player_followers_show()		 
  2701. 		 
  2702. 	--Show or hide slot 
  2703. 	if slot_visible ~= Hud_followers.slot_objects[slot].visible then 
  2704. 		vint_set_property(Hud_followers.slot_objects[slot].group_h, "visible", slot_visible) 
  2705. 		Hud_followers.slot_objects[slot].visible = slot_visible 
  2706. 	end 
  2707. 	 
  2708. 	local data = Hud_followers.follower_data[slot] 
  2709. 	local objects = Hud_followers.slot_objects[slot] 
  2710. 	 
  2711. 	if head_img_name ~= data.head_img_name then 
  2712. 		if head_img_name == nil then 
  2713. 			--No homie head 
  2714. 			--hide the icon in the homie slot by playing the close animation 
  2715. 			vint_set_property(objects.anim_0, "is_paused", true) 
  2716. 			 
  2717. 			--match alpha level of our tween to current value. 
  2718. 			local alpha_level = vint_get_property(objects.head_img_h, "alpha") 
  2719. 			local twn_h = vint_object_find("follow_head_alpha_tween_1", objects.anim_1) 
  2720. 			vint_set_property(twn_h, "start_value", alpha_level) 
  2721. 			 
  2722. 			--Play fade out anim... 
  2723. 			lua_play_anim(objects.anim_1, 0) 
  2724. 			 
  2725. 			--Be sure the timer is hidden too 
  2726. 			vint_set_property(objects.revive_timer_h, "visible", false) 
  2727. 		else 
  2728. 			if data.head_img_name == nil then 
  2729. 				vint_set_property(objects.anim_1, "is_paused", true) 
  2730. 				lua_play_anim(objects.anim_0, 0) 
  2731. 			end 
  2732. 			 
  2733. 			--Reset the head image  
  2734. 			vint_set_property(objects.head_img_h, "image", head_img_name) 
  2735. 			 
  2736. 			end 
  2737. 		data.head_img_name = head_img_name 
  2738. 	end 
  2739.  
  2740. 	--take damage only if health changed.. 
  2741. 	if hlth_pct ~= data.hlth_pct then 
  2742. 		--make sure we've inited already... 
  2743. 		if data.hlth_pct ~= nil then 
  2744. 			local target_alpha = 1 
  2745. 			if hlth_pct < .33 then 
  2746. 				target_alpha = hlth_pct + .33 
  2747. 				if hlth_pct == 0 then 
  2748. 					target_alpha = 0.5 
  2749. 				end 
  2750. 			end	 
  2751. 			vint_set_property(objects.head_img_h, "alpha", target_alpha ) 
  2752. 		end 
  2753. 		--Store data... 
  2754. 		data.hlth_pct = hlth_pct 
  2755. 	end 
  2756. 	 
  2757. 	--Revives (This is the counter that shows up over the homie heads) 
  2758. 	revive_time = floor(revive_time) 
  2759. 	if revive_time ~= data.revive_time then 
  2760. 		if revive_time == 0 and data.revive_time ~= 0 then 
  2761. 			vint_set_property(objects.revive_timer_h, "visible", false) 
  2762. 			vint_set_property(vint_object_find("follow_rev_anim"),"is_paused", true) 
  2763. 		elseif revive_time ~= 0 and data.revive_time == 0 then 
  2764. 			vint_set_property(objects.revive_timer_h, "visible", true) 
  2765. 			--vint_set_property(vint_object_find("follow_rev_anim"),"is_paused", false) 
  2766. 			lua_play_anim(vint_object_find("follow_rev_anim")) 
  2767. 		end 
  2768. 		if revive_time ~= 0 then 
  2769. 			lua_play_anim(vint_object_find("follow_rev_anim")) 
  2770. 		end 
  2771. 		--Update Revive Time 
  2772. 		vint_set_property(objects.revive_timer_h, "text_tag", revive_time) 
  2773. 		data.revive_time = revive_time 
  2774. 	end 
  2775. end 
  2776.  
  2777. function hud_player_followers_show() 
  2778. 	if Hud_followers.is_hidden == true then 
  2779. 		local end_event_twn_h = vint_object_find("end_event_twn", Hud_followers.fade_in) 
  2780. 		vint_set_property(end_event_twn_h, "end_event", "hud_player_followers_prolong") 
  2781. 		lua_play_anim(Hud_followers.fade_in) 
  2782. 	else 
  2783. 		hud_player_followers_prolong() 
  2784. 	end 
  2785. 	Hud_followers.is_hidden = false 
  2786. end 
  2787.  
  2788. function hud_player_followers_prolong() 
  2789. 	local end_event_twn_h = vint_object_find("end_event_twn", Hud_followers.fade_out) 
  2790. 	vint_set_property(end_event_twn_h, "end_event", "hud_player_followers_is_hidden") 
  2791. 	vint_set_property(Hud_followers.fade_out, "is_paused", true) 
  2792. 	lua_play_anim(Hud_followers.fade_out) 
  2793. end 
  2794.  
  2795. function hud_player_followers_is_hidden() 
  2796. 	Hud_followers.is_hidden = true 
  2797. end 
  2798.  
  2799. function hud_balance_meter_change(di_h) 
  2800.  
  2801. 	--	active		bool		is the meter active? 
  2802. 	--	position		float		-1 to 1 indicating the position on the meter	 
  2803. 	local active, position = vint_dataitem_get(di_h) 
  2804. 	local force_update = false 
  2805. 	 
  2806. 	--Update visibility 
  2807. 	if Hud_balance_status.active ~= active then 
  2808. 		if active == true then 
  2809. 			vint_set_property(Hud_balance_status.balance_grp_h, "visible", true) 
  2810. 			 
  2811. 			Hud_balance_status.ls_btn:set_button(CTRL_BUTTON_LS) 
  2812. 			if game_is_active_input_gamepad() == false then 
  2813. 				Hud_balance_status.ls_btn:set_button(CTRL_BUTTON_LS, game_get_key_name_for_action("CAA_WALK_TURN_LEFT_RIGHT")) 
  2814. 			end 
  2815. 			 
  2816. 			--Fade out left stick after a little while... 
  2817. 			lua_play_anim(Hud_balance_status.fade_out_anim_h) 
  2818. 		else 
  2819. 			vint_set_property(Hud_balance_status.balance_grp_h, "visible", false) 
  2820. 		end 
  2821. 		force_update = true 
  2822. 		Hud_balance_status.active = active 
  2823. 	end 
  2824. 	 
  2825. 	--Update Position and Color 
  2826. 	if Hud_balance_status.position ~= position or force_update == true then 
  2827. 		 
  2828. 		--Calculate Angle 
  2829. 		local angle = position * Hud_balance_status.max_angle 
  2830. 		 
  2831. 		--Calculate Color 
  2832. 		local color_r, color_g, color_b 
  2833. 		local p_val = abs(position) 
  2834. 				 
  2835. 		color_r = Hud_balance_status.color_base[1] - p_val * (Hud_balance_status.color_base[1] - Hud_balance_status.color_alarm[1]) 
  2836. 		color_g = Hud_balance_status.color_base[2] - p_val * (Hud_balance_status.color_base[2] - Hud_balance_status.color_alarm[2]) 
  2837. 		color_b = Hud_balance_status.color_base[3] - p_val * (Hud_balance_status.color_base[3] - Hud_balance_status.color_alarm[3]) 
  2838. 			 
  2839. 		--Set Props 
  2840. 		vint_set_property(Hud_balance_status.arrow_image_h, "rotation", angle) 
  2841. 		vint_set_property(Hud_balance_status.base_grp_h, "tint", color_r, color_g, color_b) 
  2842. 		 
  2843. 		Hud_balance_status.position = position  
  2844. 	end 
  2845. end 
  2846.  
  2847. --Health Vignette 
  2848. function hud_health_screen_fade(target_alpha) 
  2849. 	if Hud_player_status.health_screen_is_fading == true then 
  2850. 		--screen is already fading... just update the end alpha... 
  2851. 		vint_set_property(Hud_vignettes.health.fade_twn_h, "end_value", target_alpha) 
  2852. 	else 
  2853. 		--screen isnot fading so we need to restart the animation... 
  2854. 		local current_alpha = vint_get_property(Hud_vignettes.health.grp_h, "alpha") 
  2855. 		vint_set_property(Hud_vignettes.health.fade_twn_h, "start_value", current_alpha) 
  2856. 		vint_set_property(Hud_vignettes.health.fade_twn_h, "end_value", target_alpha) 
  2857. 		lua_play_anim(Hud_vignettes.health.fade_anim_h, 0) 
  2858. 		Hud_player_status.health_screen_is_fading = true 
  2859. 	end 
  2860. end 
  2861.  
  2862. function hud_health_screen_fade_complete() 
  2863. 	Hud_player_status.health_screen_is_fading = false 
  2864. end 
  2865.  
  2866.  
  2867. --======================================================== 
  2868. --HUD Hits 
  2869. --Things around the reticule 
  2870. --======================================================== 
  2871. function Hud_hit_add(di_h) 
  2872. 	local hit_index = di_h 
  2873. 	-- distance is relative distance to target, 0 - 1 
  2874. 	local direction, strength, distance = vint_dataitem_get(di_h) 
  2875. 	local hit_bmp_h, hit_anim_h, hit_twn_h, fade_time, stick_time 
  2876. 	 
  2877. 	--Check if major/minor hit 
  2878. 	if strength > .3 then 
  2879. 		hit_bmp_h = vint_object_clone(Hud_hit_elements.major_h) 
  2880. 		stick_time = 1 
  2881. 		fade_time = .5 
  2882. 	else 
  2883. 		hit_bmp_h = vint_object_clone(Hud_hit_elements.minor_h) 
  2884. 		stick_time = .5 
  2885. 		fade_time = .5 
  2886. 	end 
  2887. 		 
  2888. 	local hit_behind = direction 
  2889. 	 
  2890. 	if hit_behind < 0 then 
  2891. 		hit_behind = hit_behind + PI2 
  2892. 	end 
  2893. 	 
  2894. 	hit_behind = abs(hit_behind - ( PI2 - Hud_player_status.orientation ) ) 
  2895. 		 
  2896. 	if hit_behind > 1.57 and hit_behind < 4.7 then 
  2897. 		stick_time = stick_time + 1 
  2898. 	end 
  2899. 	 
  2900. 	vint_set_property(hit_bmp_h, "visible", true) 
  2901. 	vint_set_property(hit_bmp_h, "rotation", direction) 
  2902. 	 
  2903. 	--Tween Fade out, Set Callback 
  2904. 	hit_anim_h = vint_object_clone(Hud_hit_elements.anim_h)	 
  2905. 	hit_twn_h =  vint_object_find("hit_twn", hit_anim_h) 
  2906. 	vint_set_property(hit_twn_h, "target_handle", hit_bmp_h) 
  2907. 	vint_set_property(hit_twn_h, "duration", fade_time) 
  2908. 	--vint_set_property(hit_twn_h, "start_value", distance_alpha) 
  2909. 	vint_set_property(hit_twn_h, "end_event", "hud_hit_fade_end") 
  2910. 	 
  2911. 	lua_play_anim(hit_anim_h, stick_time) 
  2912. 	 
  2913. 	--Store Reticule Information for further processing 
  2914. 	Reticule_hits[hit_index] = { 
  2915. 		hit_bmp_h = hit_bmp_h, 
  2916. 		hit_twn_h = hit_twn_h, 
  2917. 		hit_anim_h = hit_anim_h, 
  2918. 		direction = direction, 
  2919. 		strength = strength, 
  2920. 	} 
  2921. end 
  2922.  
  2923. function hud_hit_fade_end(twn_h, event_name) 
  2924. 	--Clean up reticule hits 
  2925. 	for index, value in pairs(Reticule_hits) do 
  2926. 		if value.hit_twn_h == twn_h then 
  2927. 			vint_object_destroy(value.hit_anim_h) 
  2928. 			vint_object_destroy(value.hit_twn_h) 
  2929. 			vint_object_destroy(value.hit_bmp_h) 
  2930. 			Reticule_hits[index] = nil 
  2931. 		end 
  2932. 	end 
  2933. end 
  2934.  
  2935. function hud_hits_updates_pos(x_screen_coord, y_screen_coord) 
  2936. 	--y screen coordinate 
  2937. 	local x, y = vint_get_property(Hud_hit_elements.main_h, "anchor") 
  2938. 	vint_set_property(Hud_hit_elements.main_h, "anchor", x_screen_coord, y_screen_coord) 
  2939. end 
  2940.  
  2941. --Clears all indicators if called, designed to be called via C++ 
  2942. function hud_hit_clear_all() 
  2943. 	for index, value in pairs(Reticule_hits) do 
  2944. 		vint_object_destroy(value.hit_anim_h) 
  2945. 		vint_object_destroy(value.hit_twn_h) 
  2946. 		vint_object_destroy(value.hit_bmp_h) 
  2947. 	end 
  2948. 	Reticule_hits = {} 
  2949. end 
  2950.  
  2951.  
  2952. --#####################################################################  
  2953. --Showing/Hiding the hud 
  2954. --##################################################################### 
  2955.  
  2956. Hud_elements = { 
  2957. 	[HUD_ELEM_GSI] = { 
  2958. 		target_doc = nil, 
  2959. 		grp_name = "base_gsi",				 
  2960. 	}, 
  2961. 	[HUD_ELEM_MINIMAP] = { 
  2962. 		target_doc = nil, 
  2963. 		grp_name = "base_mini_map",	 
  2964. 	}, 
  2965. 	[HUD_ELEM_RETICLE] = { 
  2966. 		target_doc = nil, 
  2967. 		grp_name = "base_reticle",				 
  2968. 	}, 
  2969. 	[HUD_ELEM_HIT_INDICATORS] = { 
  2970. 		target_doc = nil, 
  2971. 		grp_name = "base_reticle_hits", 
  2972. 	}, 
  2973. 	[HUD_ELEM_WEAPONS] = { 
  2974. 		target_doc = nil, 
  2975. 		grp_name = "weapons_grp",	 
  2976. 	}, 
  2977. 	[HUD_ELEM_CASH_RESPECT_HOMEY] = { 
  2978. 		target_doc = nil, 
  2979. 		grp_name = "base_cash_respect_homey",  
  2980. 	}, 
  2981. 	[HUD_ELEM_WEAPON_SWAP_MESSAGE] = { 
  2982. 		target_doc = nil, 
  2983. 		grp_name = "base_weapon_swap_message", 
  2984. 	}, 
  2985. 	[HUD_ELEM_RADIO_STATION] = { 
  2986. 		target_doc = nil, 
  2987. 		grp_name = "base_radio_station",		 
  2988. 	}, 
  2989. 	[HUD_ELEM_VEHICLE_NAME] = { 
  2990. 		target_doc = nil, 
  2991. 		grp_name = "base_vehicle_name", 
  2992. 	}, 
  2993. 	[HUD_ELEM_DIVERSIONS] = { 
  2994. 		target_doc = "hud_diversion", 
  2995. 		grp_name = nil, 
  2996. 	}, 
  2997. 	[HUD_ELEM_MESSAGES] = { 
  2998. 		target_doc = "hud_msg", 
  2999. 		grp_name = "messages_grp", 
  3000. 	}, 
  3001. 	[HUD_ELEM_TUTORIAL_HELP] = { 
  3002. 		target_doc = "tutorial", 
  3003. 		grp_name = "tutorial_base_grp", 
  3004. 	}, 
  3005. 	[HUD_ELEM_RADIAL] = { 
  3006. 		target_doc = nil, 
  3007. 		grp_name = "base_weapons", 
  3008. 	}, 
  3009. 	[HUD_ELEM_AMMO_PICKUP] = { 
  3010. 		target_doc = nil, 
  3011. 		grp_name = "base_ammo_pickup", 
  3012. 	}, 
  3013. 	[HUD_ELEM_COLLECTION] = { 
  3014. 		target_doc = nil, 
  3015. 		grp_name = "base_collection", 
  3016. 	}, 
  3017. 	[HUD_ELEM_SUPER_REWARD] = { 
  3018. 		target_doc = nil, 
  3019. 		grp_name = "base_super_reward",		 
  3020. 	}, 
  3021. 	[HUD_ELEM_SCREEN_FX] = { 
  3022. 		target_doc = nil, 
  3023. 		grp_name = "base_full_screen_effect", 
  3024. 	}, 
  3025. 	[HUD_ELEM_SUBTITLES] = { 
  3026. 		target_doc = "hud_msg", 
  3027. 		grp_name = "subtitles_grp", 
  3028. 	}, 
  3029. 	[HUD_ELEM_OI] = { 
  3030. 		target_doc = "object_indicator", 
  3031. 		grp_name = "oi_base_grp",		 
  3032. 	}, 
  3033. 	[HUD_ELEM_MECH] = { 
  3034. 		target_doc = "msn_spaceship", 
  3035. 		grp_name = "screen_grp",		 
  3036. 	}, 
  3037. } 
  3038.  
  3039. Hud_element_tweens = {} 
  3040.  
  3041. -- hud fade parameters 
  3042. -- transparency 
  3043. local HUD_FADE_HIDDEN 		= 0 
  3044. local HUD_FADE_TRANSPARENT = 1 
  3045. local HUD_FADE_VISIBLE 		= 2 
  3046. -- fade duration 
  3047. local HUD_FADE_DURATION_FADE 			= 0 
  3048. local HUD_FADE_DURATION_IMMEDIATE 	= 1 
  3049.  
  3050. local Hud_tween_fade_duration = 0.25 
  3051.  
  3052. --Fades a particular element 
  3053. function hud_element_fade(element_id, fade, duration) 
  3054. 	if duration == nil then 
  3055. 		duration = HUD_FADE_DURATION_FADE 
  3056. 	end 
  3057. 	--fade: 0 = hidden,	1 = transparent, 2 = visible 
  3058. 	local element_group 
  3059. 	local target_document_name 
  3060. 	local grp_name 
  3061. 	 
  3062. 	target_document_name = Hud_elements[element_id].target_doc 
  3063. 	grp_name = Hud_elements[element_id].grp_name 
  3064. 	 
  3065. 	--Set alpha based on fade 
  3066. 	local target_alpha 
  3067. 	if fade == HUD_FADE_HIDDEN then 
  3068. 		target_alpha = 0 
  3069. 	elseif fade == HUD_FADE_TRANSPARENT then 
  3070. 		target_alpha = .35 
  3071. 	else 
  3072. 		target_alpha = 1 
  3073. 	end 
  3074.  
  3075. 	-- Set the actual duration 
  3076. 	local actual_duration 
  3077. 	if (duration == HUD_FADE_DURATION_FADE) then 
  3078. 		actual_duration = Hud_tween_fade_duration 
  3079. 	else  
  3080. 		actual_duration = 0 
  3081. 	end 
  3082. 	 
  3083. 	local grp_h, current_alpha, twn_h 
  3084. 	 
  3085. 	--Figure out which document the elements exist in 
  3086. 	local target_doc_h = HUD_DOC_HANDLE 
  3087. 	if target_document_name ~= nil then 
  3088. 		target_doc_h = vint_document_find(target_document_name) 
  3089. 		if target_doc_h == 0 then 
  3090. 			--This document is not loaded for whatever reason exit 
  3091. 			return 
  3092. 		end 
  3093. 	end 
  3094.  
  3095. 	if grp_name ~= nil then 
  3096. 		--get the group object to fade 
  3097. 		grp_h = vint_object_find(grp_name, nil, target_doc_h) 
  3098. 	else  
  3099. 		grp_h = vint_object_find("safe_frame", nil, target_doc_h) 
  3100. 	end 
  3101. 			 
  3102. 	--Verify that we aren't already fading something 
  3103. 	for idx, val in pairs(Hud_element_tweens) do 
  3104. 		if grp_h == val.grp_h then 
  3105. 			--tween exist so delete the tween 
  3106. 			vint_object_destroy(idx) 
  3107. 			Hud_element_tweens[idx] = nil 
  3108. 		end 
  3109. 	end 
  3110. 			 
  3111. 	--Get Current Alpha of object 
  3112. 	current_alpha = vint_get_property(grp_h, "alpha") 
  3113. 			 
  3114. 	local hud_root_animation =  vint_object_find("root_animation", nil, target_doc_h) 
  3115. 			 
  3116. 	--Create Tween and set values 
  3117. 	twn_h = vint_object_create("hud_fade_tweens", "tween", hud_root_animation, target_doc_h) 
  3118.  
  3119. 	vint_set_property(twn_h, "duration", actual_duration)	--Fade time 
  3120. 	vint_set_property(twn_h, "target_handle", grp_h) 
  3121. 	vint_set_property(twn_h, "target_property", "alpha") 
  3122. 	vint_set_property(twn_h, "start_value", current_alpha) 
  3123. 	vint_set_property(twn_h, "end_value", target_alpha) 
  3124. 	vint_set_property(twn_h, "start_time",	vint_get_time_index(target_doc_h)) 
  3125. 	vint_set_property(twn_h, "is_paused", false) 
  3126. 			 
  3127. 	--Set callback 
  3128. 	vint_set_property(twn_h, "end_event", "hud_element_fade_end") 
  3129. 		 
  3130. 	--Store for cleanup 
  3131. 	Hud_element_tweens[twn_h] = { 
  3132. 		grp_h = grp_h 
  3133. 	} 
  3134. 	 
  3135. 	-- flag this element as disabled by game 
  3136. 	if fade == HUD_FADE_HIDDEN then 
  3137. 		Hud_elements[ element_id ].disabled_by_game = true 
  3138. 	else 
  3139. 		Hud_elements[ element_id ].disabled_by_game = false 
  3140. 		 
  3141. 		--Show/prolong the follwers section 
  3142. 		if element_id == 5 then 
  3143. 			hud_player_followers_show() 
  3144. 		end 
  3145. 	end 
  3146. end 
  3147.  
  3148. function hud_element_fade_end(tween_h, event_name) 
  3149. 	--Delete all fade tweens and references 
  3150. 	vint_object_destroy(tween_h) 
  3151. 	Hud_element_tweens[tween_h] = nil 
  3152. end 
  3153.  
  3154. ---------[ BUSTED/SMOKED ]--------- 
  3155.  
  3156. function hud_busted_init() 
  3157. 	Hud_smoked_busted.handles = {} 
  3158. 	 
  3159. 	Hud_smoked_busted.handles.grp = vint_object_find("smoked_busted") 
  3160. 	vint_set_property(Hud_smoked_busted.handles.grp, "visible", false) 
  3161. 	--Fade In animations 
  3162. 	Hud_smoked_busted.handles.fade_in_anim = vint_object_find("sb_fade_in") 
  3163. 	vint_set_property(Hud_smoked_busted.handles.fade_in_anim , "is_paused", true) 
  3164. end 
  3165.  
  3166. function hud_busted_complete() 
  3167. end 
  3168.  
  3169. function hud_busted_fade_in(smoked, delay, fade_time) 
  3170. 	local msg, effect, color 
  3171. 	if smoked == true then 
  3172. 		msg = "GAMEPLAY_SMOKED" 
  3173. 		effect = "smoked" 
  3174. 		color = {r = .9, g = .9, b = .9} 
  3175. 	else 
  3176. 		msg = "GAMEPLAY_BUSTED" 
  3177. 		effect = "busted" 
  3178. 		color = {r = .9, g = .9, b = .9} 
  3179. 	end 
  3180. 	 
  3181. 	--Show Smoked busted text 
  3182. 	vint_set_property(Hud_smoked_busted.handles.grp, "visible", true) 
  3183. 	vint_set_property(Hud_smoked_busted.handles.grp, "alpha", 0) 
  3184. 	vint_set_property(Hud_smoked_busted.handles.grp, "tint", color.r, color.g, color.b) 
  3185. 	 
  3186. 	--Busted/Smoked text fade in 
  3187. 	--JM: Removing "You're Smoked" and "Busted" text. 
  3188. 	vint_set_property(vint_object_find("sb_text"), "text_tag", " ") --msg) 
  3189. 	lua_play_anim(Hud_smoked_busted.handles.fade_in_anim) 
  3190. 	 
  3191. 	--Start Interface effect, use blue version for matrix 
  3192. 	if effect == "smoked" then 
  3193. 		game_interface_effect_begin(effect, 1, .5, true) 
  3194. 		--lua_play_anim(Hud_vignettes.health.blue_anim_h) 
  3195. 		game_set_refraction_situation("screen_death")  
  3196. 	end 
  3197. end 
  3198.  
  3199. function hud_effect_smoked() 
  3200. 	game_interface_effect_begin("smoked", 1, 1, true) 
  3201. end 
  3202.  
  3203. function hud_effect_busted() 
  3204. 	game_interface_effect_begin("busted", 1, 1, true) 
  3205. end 
  3206.  
  3207. function hud_effect_pause() 
  3208. 	game_interface_effect_begin("pause", 1, 1) 
  3209. end 
  3210.  
  3211. function hud_effect_end() 
  3212. 	game_interface_effect_end() 
  3213. end 
  3214.  
  3215. function hud_player_reset_complete() 
  3216. 	--Reset the busted state 
  3217. 	game_interface_effect_end(0) 
  3218. 	--Hide Smoked busted text 
  3219. 	vint_set_property(Hud_smoked_busted.handles.grp, "visible", false) 
  3220. 	--vint_set_property(Hud_vignettes.health.pulse_grp_h, "tint", 36/255, 5/255, 0/255) 
  3221. 	game_clear_refraction_situation()  
  3222. end 
  3223.  
  3224. --=================================================== 
  3225. --Cruise Control 
  3226. --=================================================== 
  3227. function hud_cruise_control_update(is_active) 
  3228. 	if is_active ~= Hud_player_status.cruise_control_active then 
  3229. 		if is_active == true then 
  3230. 			--Show Cruise Control Status and let it fade with the animation. 
  3231. 			vint_set_property(Hud_player_status.cruise_control_h, "visible", true) 
  3232. 			vint_set_property(Hud_player_status.cruise_control_h, "alpha", .8) 
  3233. 			lua_play_anim(Hud_player_status.cruise_control_anim, 0) 
  3234.  
  3235. 			Hud_cruise_control_hint_data = { 
  3236. 				{CTRL_BUTTON_DPAD_DOWN, "HUD_CRUISE_CONTROL_NO_BUTTON", game_get_key_name_for_action("CBA_VDC_CRUISE_CONTROL_B")}, 
  3237. 			} 
  3238. 			Hud_player_status.cruise_control_obj:set_hints(Hud_cruise_control_hint_data) 
  3239. 			local width, height = Hud_player_status.cruise_control_obj:get_size() 
  3240. 			local x, y = vint_get_property(Hud_player_status.cruise_control_obj.handle, "anchor") 
  3241. 			vint_set_property(Hud_player_status.cruise_control_obj.handle, "anchor",  - (width * 0.5), y) 
  3242. 		else 
  3243. 			--Hide status 
  3244. 			vint_set_property(Hud_player_status.cruise_control_h, "visible", false) 
  3245. 		end 
  3246. 	Hud_player_status.cruise_control_active = is_active 
  3247. 	end 
  3248. end 
  3249.  
  3250. function hud_cruise_control_update_pos(x_pos, y_pos) 
  3251. 	local x, y = vint_get_property(Hud_player_status.cruise_control_h, "anchor") 
  3252. 	vint_set_property(Hud_player_status.cruise_control_h, "anchor", x_pos, y_pos) 
  3253. end 
  3254.  
  3255.  
  3256. --=================================================== 
  3257. --Player Lockon 
  3258. --=================================================== 
  3259. function hud_player_lockon_update(di_h) 
  3260. 	local x, y, width, rotation, is_locked, is_visible = vint_dataitem_get(di_h) 
  3261.  
  3262. 	vint_set_property(Hud_lockon.lock_h, "anchor", x, y) 
  3263. 	vint_set_property(Hud_lockon.lock_txt_grp_h, "anchor", x, y) 
  3264. 	 
  3265. 	if is_visible == true then 
  3266. 		--Scale 
  3267. 		local scale = width/100 
  3268. 		local scale_hor = width/100--Hud_lockon.base_pixel_size_hor 
  3269. 		local scale_vert = width/100--Hud_lockon.base_pixel_size_vert 
  3270. 		 
  3271. 		vint_set_property(Hud_lockon.lock_h, "anchor", x, y) 
  3272. 		vint_set_property(Hud_lockon.lock_h, "scale", scale, scale) 
  3273. 		vint_set_property(Hud_lockon.lock_h, "rotation", rotation) 
  3274. 		 
  3275. 		vint_set_property(Hud_lockon.lock_txt_grp_h, "scale", scale, scale) 
  3276. 			 
  3277. 		local lock_vert_height = Hud_lockon.lock_base_vert_height / scale_vert 
  3278. 		local lock_hor_height = Hud_lockon.lock_base_hor_height / scale_hor 
  3279. 		 
  3280. 		--Rescale Innards 
  3281. 		vint_set_property(Hud_lockon.lock1_h, "scale",Hud_lockon.lock_base_vert_width, lock_vert_height) 
  3282. 		vint_set_property(Hud_lockon.lock2_h, "scale", Hud_lockon.lock_base_hor_width, lock_hor_height) 
  3283. 		vint_set_property(Hud_lockon.lock3_h, "scale", Hud_lockon.lock_base_hor_width, lock_hor_height) 
  3284. 		vint_set_property(Hud_lockon.lock4_h, "scale", Hud_lockon.lock_base_vert_width, lock_vert_height) 
  3285. 		 
  3286. 		if is_locked then 
  3287. 			vint_set_property(Hud_lockon.lock_lock_h,"visible",true) 
  3288. 			vint_set_property(Hud_lockon.lock_spinner_h,"visible",false) 
  3289. 			vint_set_property(Hud_lockon.lock_text_h,"text_tag","HUD_LOCKON_TARGET_LOCKED") 
  3290. 		else 
  3291. 			vint_set_property(Hud_lockon.lock_lock_h,"visible",false) 
  3292. 			vint_set_property(Hud_lockon.lock_spinner_h,"visible",true) 
  3293. 			vint_set_property(Hud_lockon.lock_text_h,"text_tag","HUD_LOCKON_SCANNING") 
  3294. 		end 
  3295. 		--Tint lockon 
  3296. 		local color 
  3297. 		if is_locked == true then 
  3298. 			color = Hud_lockon.color_locked 
  3299. 		else 
  3300. 			color = Hud_lockon.color_unlocked	 
  3301. 		end 
  3302. 		vint_set_property(Hud_lockon.lock_h, "tint", color.r, color.g, color.b) 
  3303. 		vint_set_property(Hud_lockon.lock_txt_grp_h, "tint", color.r, color.g, color.b) 
  3304. 		 
  3305. 		--Show lockon 
  3306. 		vint_set_property(Hud_lockon.lock_h, "visible", true) 
  3307. 		vint_set_property(Hud_lockon.lock_txt_grp_h, "visible", true) 
  3308. 	else 
  3309. 		vint_set_property(Hud_lockon.lock_h, "visible", false) 
  3310. 		vint_set_property(Hud_lockon.lock_txt_grp_h, "visible", false) 
  3311. 	end 
  3312. end 
  3313.  
  3314. function hud_cheat_icon_update(di_h) 
  3315. 	--	active	bool	is the cheat active? 
  3316. 	--	icon		int	0: INVALID, 1: Inverted controls, 2: Size reduction, 3: Lag, 4: Lame weapon, 5: Slow 
  3317. 	local active, icon = vint_dataitem_get(di_h) 
  3318. 	 
  3319. 	vint_set_property(Hud_cheat_elements.image_grp_h, "visible", active) 
  3320. 	vint_set_property(Hud_cheat_elements.image_h, "image", Hud_cheat_elements.images[icon]) 
  3321. 	vint_set_property(Hud_cheat_elements.image_2_h, "image", Hud_cheat_elements.images[icon]) 
  3322. 	if active then 
  3323. 		lua_play_anim(Hud_cheat_elements.image_anim_h, 0, HUD_DOC_HANDLE) 
  3324. 	end 
  3325. end 
  3326.  
  3327. -------------------------- 
  3328. --Ammo pickup notification 
  3329. -------------------------- 
  3330. function hud_ammo_pickup_update(di_h) 
  3331. 	local icon, amount = vint_dataitem_get(di_h) 
  3332. 	debug_print("vint", "image: " .. var_to_string(icon) .. "\n") 
  3333. 	debug_print("vint", "amount: " .. var_to_string(amount) .. "\n") 
  3334. 	 
  3335. 	if Hud_ammo_pickup.is_playing == false then 
  3336. 		hud_ammo_pickup_play(icon,amount) 
  3337. 	else 
  3338. 		Hud_ammo_pickup.queue[#Hud_ammo_pickup.queue] = {icon = icon, amount = amount} 
  3339. 	end 
  3340. 	 
  3341. end 
  3342.  
  3343. --queues it up, plays each anim in order once previous is finished 
  3344. function hud_ammo_pickup_next() 
  3345. 	Hud_ammo_pickup.is_playing = false 
  3346. 	if #Hud_ammo_pickup.queue >0 then 
  3347. 		hud_ammo_pickup_play(Hud_ammo_pickup.queue[1].icon, Hud_ammo_pickup.queue[1].amount) 
  3348. 		for i,entry in pairs(Hud_ammo_pickup.queue) do 
  3349. 			if i >= #Hud_ammo_pickup.queue then 
  3350. 				break 
  3351. 			end 
  3352. 			Hud_ammo_pickup.queue[i] = Hud_ammo_pickup.queue[i+1] 
  3353. 		end 
  3354. 		Hud_ammo_pickup.queue[#Hud_ammo_pickup.queue] = nil 
  3355. 	end 
  3356. end 
  3357.  
  3358.  
  3359. ------------------------------------------------------------------------------- 
  3360. -- Function hud_ammo_pickup_play() 
  3361. -- 
  3362. -- Displays how much ammo you picked up for which weapon in the bottom right 
  3363. -- of the hud 
  3364. -- 
  3365. -- @param icon		- icon for the weapon that recieved ammo 
  3366. -- @param amount	- how much ammo was picked up 
  3367. -- 
  3368. ------------------------------------------------------------------------------- 
  3369. function hud_ammo_pickup_play(icon,amount) 
  3370. 	 
  3371. 	-- This shouldn't be called if the player didn't recieve ammo	 
  3372. 	if amount == 0 then 
  3373. 		return 
  3374. 	end 
  3375. 	 
  3376. 	Hud_ammo_pickup.is_playing = true 
  3377. 	vint_set_property(Hud_ammo_pickup.icon, "image", icon) 
  3378. 	local width, height = element_get_actual_size(Hud_ammo_pickup.icon) 
  3379. 	--keep the text outside the circle 
  3380. 	if width < 60 then 
  3381. 		width = 60 
  3382. 	end 
  3383. 	--position text adjacent to icon 
  3384. 	local move_x = Hud_ammo_pickup.amount_x + (width/2) 
  3385. 	vint_set_property(Hud_ammo_pickup.amount, "text_tag", "+ " .. amount) 
  3386. 	vint_set_property(Hud_ammo_pickup.amount, "anchor", move_x, Hud_ammo_pickup.amount_y) 
  3387. 	 
  3388. 	Hud_ammo_pickup.twn:set_end_event("hud_ammo_pickup_next") 
  3389. 	lua_play_anim(Hud_ammo_pickup.anim) 
  3390. end 
  3391.  
  3392.  
  3393. function hud_super_reward_update(power, style) --use 0-6 for power, for style (1=Unlocked, 2=Increased), pass in nothing for generic 
  3394. 	 
  3395. 	if Hud_super_reward.is_active == false then 
  3396. 		Hud_super_reward.bot_twn:set_end_event("hud_super_reward_play_top") 
  3397. 		Hud_super_reward.top_twn:set_end_event("hud_super_reward_play_bot") 
  3398. 		Hud_super_reward.in_twn:set_end_event("hud_super_reward_play_bot") 
  3399. 		Hud_super_reward.out_twn:set_end_event("hud_super_reward_is_done") 
  3400.  
  3401. 		if power == nil or style == nil then 
  3402. 			vint_set_property(Hud_super_reward.txt, "text_tag", "SUPER_POWERS_GENERIC") 
  3403. 			vint_set_property(Hud_super_reward.txt2, "text_tag", "SUPER_POWERS_INCREASED") 
  3404. 			vint_set_property(Hud_super_reward.icon_grp, "visible", false) 
  3405. 			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) 
  3406. 		else 
  3407. 			vint_set_property(Hud_super_reward.txt, "text_tag", Hud_super_powers[power].label) 
  3408. 			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) 
  3409. 			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)	 
  3410. 			vint_set_property(Hud_super_reward.icon, "image", Hud_super_powers[power].bitmap) 
  3411. 			vint_set_property(Hud_super_reward.icon_grp, "visible", true) 
  3412. 			if style == 1 then 
  3413. 				vint_set_property(Hud_super_reward.txt2, "text_tag", "SUPER_POWERS_UNLOCKED") 
  3414. 			else 
  3415. 				vint_set_property(Hud_super_reward.txt2, "text_tag", "SUPER_POWERS_INCREASED") 
  3416. 			end 
  3417. 		end 
  3418.  
  3419. 		--Move down if the banner is active 
  3420. 		if Hud_collection_is_active ~= nil and Hud_collection_is_active == true then 
  3421. 			vint_set_property(Hud_super_reward.move_grp, "anchor", 0, 110) 
  3422. 		else 
  3423. 			vint_set_property(Hud_super_reward.move_grp, "anchor", 0,0) 
  3424. 		end 
  3425.  
  3426. 		Hud_super_reward.in_anim:play(0) 
  3427. 		Hud_super_reward.words_anim:play(0) 
  3428. 		Hud_super_reward.is_active = true 
  3429. 		--game_set_refraction_situation("screen_collection") 
  3430. 	end 
  3431. end 
  3432.  
  3433. function hud_super_reward_play_top() 
  3434. 	vint_set_property(Hud_super_reward.icon_grp, "depth", -10) 
  3435. 	Hud_super_reward.counter = Hud_super_reward.counter + 1 
  3436. 	if Hud_super_reward.counter > 2 then 
  3437. 		Hud_super_reward.out_anim:play(0) 
  3438. 		Hud_super_reward.counter = 0 
  3439. 	else 
  3440. 		Hud_super_reward.top_anim:play(0) 
  3441. 	end 
  3442. end 
  3443.  
  3444. function hud_super_reward_play_bot() 
  3445. 	vint_set_property(Hud_super_reward.icon_grp, "depth", 10) 
  3446. 	Hud_super_reward.bot_anim:play(0) 
  3447. 	 
  3448. end 
  3449.  
  3450. function hud_super_reward_is_done() 
  3451. 	Hud_super_reward.is_active = false 
  3452. end 
  3453.  
  3454. function hud_super_swap_is_done() 
  3455. 	Hud_super_bar.swap_is_playing = false 
  3456. end 
  3457.  
  3458. function hud_health_pickup_is_done() 
  3459. 	Is_health_pickup_active = false 
  3460. end 
  3461.  
  3462. ------------------------------------------------------------------------------- 
  3463. -- Updates and Plays the Icon Objective Over the minimap. 
  3464. ------------------------------------------------------------------------------- 
  3465. function hud_map_objective_icon(di_h) 
  3466. end 
  3467.  
  3468. function hud_gsi_supress_popout_update( supress ) 
  3469. 	Hud_gsi_supress_popout = supress 
  3470. end 
  3471.  
  3472. --------------------------------------------------------------------------------------------------- 
  3473. -- Function hud_homie_call_update() 
  3474. -- 
  3475. -- Displays a homie call widget that shows the name and homie head 
  3476. -- for voice lines deemed "voice in the sky" 
  3477. -- 
  3478. -- This system currently does not support queuing.  Each new call takes priority and kills any 
  3479. -- existing calls. 
  3480. -- 
  3481. -- @param action				-- "start"/"stop" determines whether to play or stop a call 
  3482. -- @param id					-- unique identifier for call 
  3483. -- @param conv					-- unique id for the conversation 
  3484. -- @param homie_img			-- homie head icon image name 
  3485. -- @param intro_delay		-- amount of seconds to delay before showing the call 
  3486. -- @param homie_name			-- name of homie calling 
  3487. -- 
  3488. --------------------------------------------------------------------------------------------------- 
  3489. function hud_homie_call_update(action, id, conv, homie_img, intro_delay, homie_name) 
  3490. 	 
  3491. 	debug_print("vint", "----------------------- \n") 
  3492. 	vint_debug_print("action", action) 
  3493. 	vint_debug_print("id", id) 
  3494. 	vint_debug_print("conv", conv) 
  3495. 	vint_debug_print("intro_delay", intro_delay) 
  3496. 	debug_print("vint", "----------------------- \n\n") 
  3497. 	 
  3498. 	-- Start a new call 
  3499. 	if action == "start" then 
  3500. 		-- This will bash over an existing head. This is okay as it will update the id and conv, which we want 
  3501. 		hud_homie_call_show(homie_img, intro_delay, homie_name) 
  3502.  
  3503. 		-- 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) 
  3504. 		Hud_homie_call.prev_id = id 
  3505. 		Hud_homie_call.prev_conv = conv 
  3506. 	elseif action == "stop" then 
  3507. 		-- Check to make sure we are the proper id 
  3508. 		if id == Hud_homie_call.prev_id then 
  3509. 			-- Check to see if the conversation is over 
  3510. 			if conv >= 0 then 
  3511. 				-- We need to grey out the head 
  3512. 				hud_homie_call_greyout() 
  3513.  
  3514. 				Hud_homie_call.prev_id = nil 
  3515. 			else 
  3516. 				-- Hide the head 
  3517. 				hud_homie_call_hide() 
  3518.  
  3519. 				Hud_homie_call.prev_id = nil 
  3520. 				Hud_homie_call.prev_conv = nil 
  3521. 			end 
  3522. 		end 
  3523. 	else 
  3524. 		-- Make sure we are reseting the current conv 
  3525. 		if conv == Hud_homie_call.prev_conv then 
  3526. 			-- Hide the head 
  3527. 			hud_homie_call_hide() 
  3528.  
  3529. 			Hud_homie_call.prev_id = nil 
  3530. 			Hud_homie_call.prev_conv = nil 
  3531. 		end 
  3532. 	end 
  3533. end 
  3534.  
  3535.  
  3536. ----------------------------------------------------------------------------------------------------------- 
  3537. -- Shows the homie head 
  3538. -- 
  3539. function hud_homie_call_show(homie_img, intro_delay) 
  3540.  
  3541. 	--Loop through lookup table to find loc tag for homie based on homie head image. 
  3542. 	--JAM 4/15/13:  For the record, lookup tables suck. 
  3543. 	local homie_name = ""	 
  3544. 	if homie_img ~= nil then 
  3545. 		for bmp, name in pairs(Hud_homie_call_names) do 
  3546. 			if homie_img == bmp then 
  3547. 				homie_name = name 
  3548. 				break 
  3549. 			end 
  3550. 		end 
  3551. 	end 
  3552. 	 
  3553. 	-- Set homie info 
  3554. 	vint_set_property(Hud_homie_call.homie_img_h, "image", homie_img) 
  3555. 	vint_set_property(Hud_homie_call.homie_name_txt_h, "text_tag", homie_name) 
  3556. 	 
  3557. 	-- Shrink homie name to fit 
  3558. 	resize_text_element(Hud_homie_call.homie_name_txt_h, 135)		 
  3559. 	 
  3560. 	vint_set_property(Hud_homie_call.box_grp_h, "tint", COLOR_SAINTS_PURPLE.R, COLOR_SAINTS_PURPLE.G, COLOR_SAINTS_PURPLE.B )	 
  3561. 	vint_set_property(Hud_homie_call.grp_h, "visible", true) 
  3562. 		 
  3563. 	--Kill the waveform 
  3564. 	thread_kill(Hud_homie_call.waveform_thread_h) 
  3565. 	Hud_homie_call.waveform_thread_h = -1 
  3566. 	 
  3567. 	-- Start waveform animation 
  3568. 	Hud_homie_call.waveform_thread_h = thread_new("hud_homie_call_simulate_waveform")	 
  3569. 		 
  3570. 	-- Adjust position for HD and SD 
  3571. 	if vint_is_std_res() == true then 
  3572. 		vint_set_property(Hud_homie_call.grp_h, "anchor", HUD_HOMIE_CALL_ON_SCREEN_X_SD, HUD_HOMIE_CALL_Y_SD)		 
  3573. 	else 
  3574. 		vint_set_property(Hud_homie_call.grp_h, "anchor", HUD_HOMIE_CALL_ON_SCREEN_X, HUD_HOMIE_CALL_Y)		 
  3575. 	end 
  3576.  
  3577. 	vint_set_property(Hud_homie_call.box_grp_h, "alpha", 1) 
  3578. 	vint_set_property(Hud_homie_call.homie_img_h, "saturation", 1) 
  3579. 	 
  3580. 	-- If we're a new call alpha in, else pop in between greyed out states 
  3581. 	if (Hud_homie_call.call_is_greyed_out == true) or (Hud_homie_call.prev_id ~= nil) then 
  3582. 		-- Make sure we are not greyed out!! 
  3583. 		Hud_homie_call.call_is_greyed_out = false 
  3584. 		return 
  3585. 	end	 
  3586. 	 
  3587. 	-- Make sure we are not greyed out!! 
  3588. 	Hud_homie_call.call_is_greyed_out = false 
  3589. 	 
  3590. 	--Setup twn to alpha in 
  3591. 	vint_set_property(Hud_homie_call.alpha_twn_h, "start_value", 0) 
  3592. 	vint_set_property(Hud_homie_call.alpha_twn_h, "end_value", 1) 
  3593. 	vint_set_property(Hud_homie_call.alpha_twn_h, "end_event", nil) 
  3594. 			 
  3595. 	-- Play call slide in anim 
  3596. 	lua_play_anim(Hud_homie_call.anim_h, 0) 
  3597. end 
  3598.  
  3599.  
  3600. ----------------------------------------------------------------------------------------------------------- 
  3601. -- Hides the homie head 
  3602. -- 
  3603. function hud_homie_call_greyout() 
  3604. 	vint_set_property(Hud_homie_call.box_grp_h, "alpha", 0.65) 
  3605. 	vint_set_property(Hud_homie_call.homie_img_h, "saturation", 0.5) 
  3606. 	 
  3607. 	-- Tells the waveform to flatten out 
  3608. 	Hud_homie_call.call_is_greyed_out = true 
  3609. end 
  3610.  
  3611.  
  3612. ----------------------------------------------------------------------------------------------------------- 
  3613. -- Animates call out then turns visible to false after anim is done 
  3614. -- 
  3615. function hud_homie_call_hide() 
  3616. 	-- Make sure we are not greyed out!! 
  3617. 	Hud_homie_call.call_is_greyed_out = false 
  3618. 	 
  3619. 	--Kill the waveform 
  3620. 	thread_kill(Hud_homie_call.waveform_thread_h) 
  3621. 	Hud_homie_call.waveform_thread_h = -1 
  3622. 	 
  3623. 	-- Alpha out to 0 from whatever the alpha currently is (could be 0.85 or 1) 
  3624. 	local call_alpha = vint_get_property(Hud_homie_call.grp_h, "alpha")	 
  3625. 	 
  3626. 	--Setup twn to alpha out 
  3627. 	vint_set_property(Hud_homie_call.alpha_twn_h, "start_value", call_alpha) 
  3628. 	vint_set_property(Hud_homie_call.alpha_twn_h, "end_value", 0) 
  3629. 	vint_set_property(Hud_homie_call.alpha_twn_h, "end_event", "hud_homie_call_hide_cb") 
  3630. 		 
  3631. 	-- Play call slide in anim 
  3632. 	lua_play_anim(Hud_homie_call.anim_h, 0) 
  3633. end 
  3634.  
  3635.  
  3636. ----------------------------------------------------------------------------------------------------------- 
  3637. -- Hide the homie call 
  3638. -- 
  3639. function hud_homie_call_hide_cb()	 
  3640. 	vint_set_property(Hud_homie_call.grp_h, "visible", false) 
  3641. end 
  3642.  
  3643.  
  3644. ----------------------------------------------------------------------------------------------------------- 
  3645. -- Simulates a random waveform pattern 
  3646. -- 
  3647. function hud_homie_call_simulate_waveform() 
  3648. 	--Get a random number to determine frequency and which breaks (flat lines) appear 
  3649. 	local wave_counter = rand_int(0, 50) 
  3650. 	local flat_line_frames = 0 
  3651. 	local new_scale_y  
  3652. 	local last_scale_y 
  3653. 	 
  3654. 	while true do 
  3655. 		if wave_counter == 0 then 
  3656. 			--Random number to determine duration of break 
  3657. 			flat_line_frames = rand_int(1, 2) 
  3658. 			wave_counter = -1 
  3659. 		end 
  3660. 		 
  3661. 		delay(1/20)	 
  3662. 				 
  3663. 		--Loop through the lines and move new scale value from left to right 
  3664. 		for i = 11, 2, -1 do 
  3665. 			local prev_scale_x, prev_scale_y = vint_get_property(Hud_homie_call.waveform_images[i-1], "scale") 
  3666. 			vint_set_property(Hud_homie_call.waveform_images[i], "scale", prev_scale_x, prev_scale_y) 
  3667. 		end 
  3668. 		 
  3669. 		--Create a break or a random new scale 
  3670. 		if Hud_homie_call.call_is_greyed_out ~= true	then 
  3671. 			if flat_line_frames > 0 then 
  3672. 				new_scale_y = 0.5 
  3673. 				flat_line_frames = flat_line_frames - 1 
  3674. 				 
  3675. 				if flat_line_frames == 0 then 
  3676. 					wave_counter = rand_int(0, 100) 
  3677. 				end 
  3678. 			else 
  3679. 				new_scale_y = rand_float(0.5, 2) 
  3680. 				 
  3681. 				wave_counter = wave_counter - 1 
  3682. 			end 
  3683. 		else 
  3684. 			new_scale_y = 0.5 
  3685. 		end 
  3686. 		 
  3687. 		--Start the first line in the waveform 
  3688. 		vint_set_property(Hud_homie_call.waveform_images[1], "scale", 0.3, new_scale_y) 
  3689. 	end	 
  3690. end 
  3691.  
  3692. function hud_mech_health_anim_is_done() 
  3693. 	Mech_health_is_playing = false 
  3694. end 
  3695.  
  3696. function play_flap_icon_callout() 
  3697. 	hud_weapon_fade_in() 
  3698. 	local flap_callout_anim = vint_object_find("flap_callout_anim") 
  3699. 	lua_play_anim(flap_callout_anim, 0) 
  3700. end