./hud.lua

  1. HUD_DOC_HANDLE = -1 
  2.  
  3.  
  4. Hud_process_thread = -1 
  5.  
  6. --Globals 
  7. MP_enabled = false 
  8.  
  9. INVALID_HANDLE = -1 
  10. HUD_KILL_ICON = 0 
  11. HUD_DEFEND_ICON = 1 
  12. HUD_USE_ICON = 2 
  13. HUD_REVIVE_ICON = 3 
  14. HUD_LOCATION_ICON = 4   
  15. HUD_COOP_ICON = 4  
  16.  
  17. local HUD_SPRINT_COLOR = { R = 246/255, G = 187/255, B = 79/255} 
  18.  
  19. local HUD_MAP_OBJECTIVE_ICONS = { 
  20. 	[HUD_KILL_ICON] = "ui_hud_map_obj_kill", 
  21. 	[HUD_DEFEND_ICON] = "ui_hud_map_obj_protect", 
  22. 	[HUD_USE_ICON] = "ui_hud_map_obj_use", 
  23. 	[HUD_LOCATION_ICON] = "ui_hud_map_obj_goto", 
  24. } 
  25.  
  26. local HUD_INTERACT_USE 			= 0 
  27. local HUD_INTERACT_VEHICLE 	= 1 
  28. local HUD_INTERACT_EQUIP		= 2 
  29. local HUD_INTERACT_PICKUP		= 2 
  30.  
  31. HUD_DIVERSION_METER = 0 
  32. HUD_DIVERSION_METER = 1 
  33. HUD_DIVERSION_METER = 2 
  34.  
  35.  
  36.  
  37.  
  38. local INTERACT_TYPE_STRINGS = { 
  39. 	[HUD_INTERACT_USE] = "Use", 
  40. 	[HUD_INTERACT_VEHICLE] = "Hijack", 
  41. 	[HUD_INTERACT_EQUIP] = "Equip", 
  42. 	[HUD_INTERACT_PICKUP] = "Pickup", 
  43. } 
  44.  
  45. Hud_notoriety = { 
  46. 	is_expanded = true, 
  47. } 
  48.  
  49. Hud_player_status = { 
  50. 	cash = 0, 
  51. 	bleed_out_health_pct = 1.0, 
  52. 	is_in_satellite_mode = false, 
  53. 	is_controlling_missile = false, 
  54. 	health_recovering = false, 
  55. 	respect_pct = -1, 
  56. 	total_respect = -1, 
  57. 	respect_level = -1, 
  58. 	respect_show_upgrades = false, 
  59. 	respect_is_hidden = false, 
  60. 	orientation = 0, 
  61. 	inventory_disabled = false, 
  62. 	cruise_control_active = -1, 
  63. 	cruise_control_h = -1, 
  64. 	cruise_control_anim = -1, 
  65. 	health_screen_is_fading = false, 
  66. } 
  67.  
  68. 			 
  69. Hud_cruise_control_hint_data = { 
  70. 	{CTRL_BUTTON_DPAD_DOWN, "HUD_CRUISE_CONTROL_NO_BUTTON", game_get_key_name_for_action("CBA_VDC_CRUISE_CONTROL_B")}, 
  71. } 
  72.  
  73. --Bar for health around the minimap 
  74. local Hud_health_bar = { 
  75. 	percent = -1, 
  76. 	bg_h = 0, fill_h = 0, fill_1_h = 0, 
  77. 	health_decay_anim_h 		= 0, 
  78. 	health_flash_anim_h 		= 0, 
  79. 	health_bg_angle_twn_h 	= 0, 
  80. 	health_fill_angle_twn_h = 0, 
  81. 	level_angles = { 
  82. 		[0] = {fill_start_angle = 6.3, fill_end_angle = 3.142, angle_offset = 0.035}, --180 
  83. 		[1] = {fill_start_angle = 6.3, fill_end_angle = 2.6774, angle_offset = 0.035},  
  84. 		[2] = {fill_start_angle = 6.3, fill_end_angle = 2.2128, angle_offset = 0.035},  
  85. 		[3] = {fill_start_angle = 6.3, fill_end_angle = 1.2836, angle_offset = 0.035}, 
  86. 		[4] = {fill_start_angle = 6.3, fill_end_angle = 0.819, angle_offset = 0.035}, --360 
  87. 	}, 
  88. 	level = -1, 
  89. 	is_flashing = false, 
  90. 	is_decaying = false, 
  91. 	is_expanded = true,			--Whether the meter is expanded or not 
  92. 	timer_fade_out_anim_h = 0,	--Animation for waiting for the timer to retract... 
  93. } 
  94.  
  95. --Bar for sprint around the minimap 
  96. local Hud_sprint_bar = { 
  97. 	percent = -1, 
  98. 	sprint_enabled = true, 
  99. 	is_sprinting = -1,	 
  100. 	bg_h = 0, fill_h = 0, 
  101. 	level_angles = { 
  102. 		[0] = {fill_start_angle = 6.3, fill_end_angle = 3.142, angle_offset = 0.035}, --180 
  103. 		[1] = {fill_start_angle = 6.3, fill_end_angle = 2.6774, angle_offset = 0.035},  
  104. 		[2] = {fill_start_angle = 6.3, fill_end_angle = 2.2128, angle_offset = 0.035},  
  105. 		[3] = {fill_start_angle = 6.3, fill_end_angle = 1.2836, angle_offset = 0.035}, 
  106. 		[4] = {fill_start_angle = 6.3, fill_end_angle = 0.819, angle_offset = 0.035}, --360 
  107. 	}, 
  108. 	level = -1, 
  109. 	is_flashing = false, 
  110. 	is_expanded = true, 
  111. 	timer_fade_out_anim_h = 0, --Animation for waiting for the meter to retract... 
  112. } 
  113.  
  114. --Respect VDO Object 
  115. Hud_respect = {} 
  116.  
  117. Hud_enemy_status = { 
  118. 	respect = -1, 
  119. 	respect_needed = -1, 
  120. 	respect_bar =	{ bg_h = 0, fill_0_h = 0, fill_1_h = 0, txt_grp = 0, txt = 0, 
  121. 							start_angle = 0, end_angle = 3.14						 
  122. 						} 
  123. } 
  124.  
  125. Hud_weapon_status = { 
  126. 	wpn_ready = true, 
  127. 	wpn_bmp_name = -1, 
  128. 	grenade_bmp_name = -1, 
  129. 	fine_aim_transition = 0, 
  130. 	sniper_visible = -1, 
  131. 	show_reticule = false, 
  132. 	weapon_ammo_string = -1, 
  133. 	grenade_ammo_string = -1, 
  134. 	weapon_is_hidden = -1, 
  135. 	categories = { 
  136. 		["WPNCAT_MELEE"] = "", 
  137. 		["WPNCAT_PISTOL"] = "ui_menu_ammo_pistol", 
  138. 		["WPNCAT_SHOTGUN"] = "ui_menu_ammo_shtgn", 
  139. 		["WPNCAT_SUB_MACHINE_GUN"] = "ui_menu_ammo_smg", 
  140. 		["WPNCAT_RIFLE"] = "ui_menu_ammo_rifle", 
  141. 		["WPNCAT_SPECIAL"] = "ui_hud_ammo_sniper", 
  142. 		["WPNCAT_THROWN"] = "", 
  143. 		["WPNCAT_HAVOK"] = "ui_hud_ammo_missile", 
  144. 	} 
  145. } 
  146.  
  147. Hud_followers = { 
  148. 	slot_arrange = {1, 2, 3}, 
  149. 	slot_objects = { {}, {}, {} }, 
  150. 	follower_data = { 
  151. 		[1] = { head_img_name = "" }, 
  152. 		[2] = { head_img_name = "" }, 
  153. 		[3] = { head_img_name = "" }, 
  154. 	}, 
  155. } 
  156.  
  157. Hud_balance_status = { 
  158. 	active = -1,  
  159. 	position = 0, 
  160. 	balance_grp_h = 0, 
  161. 	base_image_h = 0, 
  162. 	arrow_image_h = 0, 
  163. 	min_angle = -0.466, 
  164. 	max_angle = 0.466, 
  165. 	color_base = {43/255, 208/255, 0/255}, 
  166. 	color_alarm = {220/255, 40/255, 0/255}, 
  167. 	ls_btn = 0 
  168. } 
  169.  
  170. Hud_vignettes = { 
  171. 	health = { 
  172. 		grp_h = -1, 
  173. 		fade_anim_h = -1, 
  174. 		fade_twn_h = -1, 
  175. 		tint_anim_h = -1, 
  176. 		tint_twn_h = -1 
  177. 	}, 
  178. 	fine_aim_dim = { 
  179. 		grp_h = -1, 
  180. 	}, 
  181. 	tunnel_vision = { 
  182. 		grp_h = -1, 
  183. 		amount = 0 
  184. 	} 
  185. } 
  186.  
  187. Reticule_hits = {} 
  188.  
  189. Hud_camera = {} 
  190.  
  191. Hud_hit_elements = { 
  192. 	main = -1, 
  193. 	minor = -1, 
  194. 	major = -1, 
  195. 	anim = -1, 
  196. } 
  197.  
  198. Hud_mp_snatch_elements = { 
  199. 	main_grp_h = -1, 
  200. 	head_img_bg_h = -1, 
  201. 	recruitment_fill_h = -1, 
  202. } 
  203.  
  204.  
  205. Hud_smoked_busted = {} 
  206.  
  207. local Hud_camera_screenshot_enabled = -1		--screenshot mode enabled? 
  208.  
  209. Hud_current_veh_logo = 0 
  210. Hud_current_radio_station = 0 
  211. Hud_radio_show = false 
  212. Hud_map = {} 
  213.  
  214. Hud_lockon = { 
  215. 	color_locked = {r=.7,g=0,b=0}, 
  216. 	color_unlocked = {r=0,g=.8,b=0}, 
  217. 	base_pixel_size_hor = 94, 
  218. 	base_pixel_size_vert = 94 
  219. } 
  220.  
  221. local Hud_weapon_radial 
  222. Hud_gsi = -1 
  223. Hud_inventory = { 
  224. 	stick_mag = 0, 
  225. 	is_pressed = false, 
  226. } 
  227.  
  228. Hud_radio_elements = { 
  229. 	image_h = -1, 
  230. 	arrow_left_h = -1, 
  231. 	arrow_right_h = -1, 
  232. 	anim = -1, 
  233. } 
  234.  
  235. local Hud_cheat_elements = { 
  236. 	image_grp_h = -1, 
  237. 	image_h = -1, 
  238. 	image_2_h = -1, 
  239. 	image_anim_h = -1, 
  240. 	images = { 
  241. 		[1] = "ui_hud_icon_cheat_swap", 
  242. 		[2] = "ui_hud_icon_cheat_shrink", 
  243. 		[3] = "ui_hud_icon_cheat_lag", 
  244. 		[4] = "ui_hud_icon_cheat_gimpy", 
  245. 		[5] = "ui_hud_icon_cheat_slow", 
  246. 	} 
  247. } 
  248.  
  249. local Hud_sniper_hint_bar = -1 
  250. local Hud_sniper_button_hints = { 
  251. 	{CTRL_BUTTON_Y, "HUD_SNIPER_ZOOM_IN", game_get_key_name_for_action("CBA_OFC_ZOOM_IN")}, 
  252. 	{CTRL_GAMEPLAY_BUTTON_A, "HUD_SNIPER_ZOOM_OUT", game_get_key_name_for_action("CBA_OFC_ZOOM_OUT")}, 
  253. } 
  254.  
  255. local Hud_vtol_button_hints = { 
  256. 	{CTRL_GAMEPLAY_BUTTON_B, "SWITCH_MODE", game_get_key_name_for_action("CBA_VDC_VTOL_TRANSITION")}, 
  257. } 
  258.  
  259. local INV_WEAPON_SLOT_LAST_EQUIPPED = 12 
  260. local HUD_INVENTORY_DELAY = 0.15 
  261. 	 
  262. --enums for genki 
  263. HUD_GENKI_ETHICAL = 1 
  264. HUD_GENKI_UNETHICAL = 2 
  265. HUD_GENKI_NONE = 3 
  266.  
  267. Hud_genki_anims = {} 
  268. Hud_genki_images = {} 
  269.  
  270. function hud_init() 
  271. 		 
  272. 	--Store document handle 
  273. 	HUD_DOC_HANDLE = vint_document_find("hud") 
  274. 	 
  275. 	MP_enabled = mp_is_enabled() 
  276. 	 
  277. 	--Pause all animations 
  278. 	vint_set_property(vint_object_find("vehicle_logo_anim_1"), "is_paused", true) 
  279. 		 
  280. 	vint_set_property(vint_object_find("map_objective_anim"), "is_paused", true) 
  281. 	 
  282. 	Hud_sniper_hint_bar = Vdo_hint_bar:new("sniper_btn_hints") 
  283. 	hud_sniper_set_hints() 
  284. 	 
  285. 	--Map 
  286. 	Hud_map.base_grp_h = vint_object_find("map_grp") 
  287. 	 
  288. 	--Respect 
  289. 	Hud_respect = Vdo_respect_meter:new("respect_obj", 0, 0, "hud.lua", "Hud_respect") 
  290.  
  291. 	--Health Meter Setup 
  292. 	local bar = Hud_health_bar 
  293. 	bar.bg_h = vint_object_find("health_bar_bg") 
  294. 	bar.fill_h = vint_object_find("health_bar") 
  295. 	bar.fill_1_h = vint_object_find("health_bar_2") 
  296.  
  297. 	bar.health_decay_anim_h 		= vint_object_find("health_decay_anim") 
  298. 	bar.health_flash_anim_h 		= vint_object_find("health_flash_anim") 
  299. 	bar.health_bg_angle_twn_h 		= vint_object_find("health_bg_angle_twn") 
  300. 	bar.health_fill_angle_twn_h 	= vint_object_find("health_fill_angle_twn") 
  301.  
  302. 	 
  303. 	local fill_start_angle =  bar.level_angles[0].fill_start_angle 
  304. 	local fill_end_angle =  bar.level_angles[0].fill_end_angle 
  305. 	local angle_offset =  bar.level_angles[0].angle_offset 
  306. 	 
  307. 	vint_set_property(bar.bg_h, 		"start_angle", fill_start_angle + angle_offset) 
  308. 	vint_set_property(bar.bg_h, 		"end_angle", 	fill_end_angle - angle_offset) 
  309. 	vint_set_property(bar.fill_h,		"start_angle",	fill_start_angle) 
  310. 	vint_set_property(bar.fill_h, 	"end_angle", 	fill_end_angle) 
  311. 	vint_set_property(bar.fill_1_h,	"start_angle",	fill_start_angle) 
  312. 	vint_set_property(bar.fill_1_h, 	"end_angle", 	fill_end_angle) 
  313.  
  314. 	--set callbacks for tweens... 
  315. 	--Flash event callback... 
  316. 	local health_flash_tween_complete_h = vint_object_find("health_flash_tween_complete") 
  317. 	vint_set_property(health_flash_tween_complete_h, "end_event", "hud_health_flash_complete") 
  318. 	 
  319. 	--Start event for decay and end event for decay... 
  320. 	vint_set_property(bar.health_bg_angle_twn_h, "start_event", "hud_health_decay_start") 
  321. 	vint_set_property(bar.health_bg_angle_twn_h,	"end_event", 	"hud_health_decay_end") 
  322.  
  323. 	--Meter retraction animation and callbacks 
  324. 	bar.timer_fade_out_anim_h = vint_object_find("map_health_timer_anim") 
  325. 	local timer_twn_h = vint_object_find("health_timer_twn") 
  326. 	vint_set_property(timer_twn_h, "end_event", "hud_player_health_hide") 
  327. 	 
  328. 	--Sprint Meter Setup  
  329. 	bar = Hud_sprint_bar 
  330. 	bar.bg_h = vint_object_find("sprint_bar_bg") 
  331. 	bar.fill_h = vint_object_find("sprint_bar") 
  332. 	 
  333. 	local fill_start_angle =  bar.level_angles[0].fill_start_angle 
  334. 	local fill_end_angle =  bar.level_angles[0].fill_end_angle 
  335. 	local angle_offset =  bar.level_angles[0].angle_offset 
  336. 	 
  337. 	vint_set_property(bar.bg_h, 		"start_angle", fill_start_angle + angle_offset) 
  338. 	vint_set_property(bar.bg_h, 		"end_angle", 	fill_end_angle - angle_offset) 
  339. 	vint_set_property(bar.fill_h,		"start_angle",	fill_start_angle) 
  340. 	vint_set_property(bar.fill_h, 	"end_angle", 	fill_end_angle) 
  341. 	 
  342. 	--Meter retraction animation and callbacks 
  343. 	bar.timer_fade_out_anim_h = vint_object_find("map_sprint_timer_anim") 
  344. 	local timer_twn_h = vint_object_find("sprint_timer_twn") 
  345. 	vint_set_property(timer_twn_h, "end_event", "hud_player_sprint_hide") 
  346. 	 
  347. 	--Respect Timeout 
  348. 	Hud_player_status.respect_timer_h = vint_object_find("respect_timer_anim") 
  349. 	local timer_twn_h = vint_object_find("respect_timer_twn") 
  350. 	vint_set_property(timer_twn_h, "end_event", "hud_player_respect_hide") 
  351.  
  352. 	--Weapon Timeout timer... 
  353. 	local h = vint_object_find("weapon_timer_twn") 
  354. 	vint_set_property(h, "end_event", "hud_weapon_fade_out") 
  355. 	 
  356. 	--Cash and hide it 
  357. 	Hud_player_status.cash_h = vint_object_find("cash") 
  358. 	vint_set_property(Hud_player_status.cash_h, "alpha", 0) 
  359. 	 
  360. 	--Ammo/Weapons 
  361. 	Hud_weapon_status.weapon_base_h = vint_object_find("weapons_grp")								--Group containing weapon/grenade icons and count 
  362. 	Hud_weapon_status.weapon_grp_h = vint_object_find("weapon_icons_grp")								--Group containing weapon/grenade icons and count 
  363. 	 
  364. 	Hud_weapon_status.weapon_ammo_txt_h = vint_object_find("weapon_ammo_txt") 
  365. 	Hud_weapon_status.single_wpn_icon_h = vint_object_find("weapon_icon") 
  366. 	Hud_weapon_status.dual_wpn_icon_1_h = vint_object_find("dual_weapon_1") 
  367. 	Hud_weapon_status.dual_wpn_icon_2_h = vint_object_find("dual_weapon_2") 
  368. 	 
  369. 	Hud_weapon_status.sniper_ammo_txt_h = vint_object_find("sniper_ammo_txt") 
  370. 	Hud_weapon_status.sniper_reload_txt_h = vint_object_find("sniper_reload_text") 
  371. 	Hud_weapon_status.sniper_ammo_anim = vint_object_find("sniper_reload_anim", 0, HUD_DOC_HANDLE) 
  372. 	 
  373. 	Hud_weapon_status.grenade_ammo_txt_h = vint_object_find("grenade_ammo_txt") 
  374. 	Hud_weapon_status.grenade_icon_h = vint_object_find("grenade_icon") 
  375.  
  376. 	Hud_weapon_status.grenade_holster_h = vint_object_find("grenade_holster")						--Bitmap for behind the grenade ammo text 
  377. 	Hud_weapon_status.grenade_holster_extra_h = vint_object_find("grenade_holster_extra")		--Bitmap for extra holster extenstion (goes behind the grenade ammo text) 
  378. 	 
  379. 	--Balance Meter 
  380. 	local balance_meter = vint_object_find("balance_meter") 
  381. 	Hud_balance_status.balance_grp_h = balance_meter 
  382. 	Hud_balance_status.base_grp_h = vint_object_find("base_grp", balance_meter) 
  383. 	Hud_balance_status.arrow_image_h = vint_object_find("arrow_grp", balance_meter) 
  384. 	Hud_balance_status.fade_out_anim_h = vint_object_find("balance_ls_fade_out")		-- Animation fades out left stick button 
  385. 	 
  386. 	Hud_balance_status.ls_btn = Vdo_hint_button:new("ls_btn", 0, HUD_DOC_HANDLE) 
  387. 	Hud_balance_status.ls_btn:set_button(CTRL_BUTTON_LS) 
  388. 	if game_is_active_input_gamepad() == false then 
  389. 		Hud_balance_status.ls_btn:set_button(CTRL_BUTTON_LS, game_get_key_name_for_action("CAA_WALK_TURN_LEFT_RIGHT")) 
  390. 	end 
  391. 	 
  392. 	--cheat icons 
  393. 	Hud_cheat_elements.image_grp_h = vint_object_find("cheats_grp") 
  394. 	Hud_cheat_elements.image_h = vint_object_find("cheat_icon") 
  395. 	Hud_cheat_elements.image_2_h = vint_object_find("cheat_icon_2") 
  396. 	Hud_cheat_elements.image_anim_h = vint_object_find("cheat_in_anim") 
  397. 	 
  398. 	--Vignette 
  399. 	local h = vint_object_find("vignettes") 
  400. 	Hud_vignettes.health.grp_h = vint_object_find("vignette_health", h ) 
  401. 	Hud_vignettes.health.fade_anim_h = vint_object_find("vignette_fade_anim") 
  402. 	Hud_vignettes.health.fade_twn_h = vint_object_find("vignette_alpha_twn") 
  403. 	Hud_vignettes.tunnel_vision.grp_h = vint_object_find("tunnel_vision", h) 
  404. 	 
  405. 	vint_set_property(Hud_vignettes.health.fade_twn_h, "end_event", "hud_health_screen_fade_complete") 
  406.  
  407. 	--Followers 
  408. 	local master_follower_anim_0 = vint_object_find("follow_anim_0") 
  409. 	local master_follower_anim_1 = vint_object_find("follow_anim_1") 
  410. 	local master_count_tween_alpha = vint_object_find("follow_rev_count_alpha_0") 
  411.  
  412. 	for i = 1, 3 do 
  413. 		local slot_object = Hud_followers.slot_objects[i] 
  414. 		local grp = vint_object_find("follower_grp_" .. i) 
  415. 		slot_object.name = i 
  416. 		slot_object.head_img_h = vint_object_find("follower_head", grp) 
  417. 		slot_object.frame_img_h = vint_object_find("follower_frame", grp) 
  418. 		slot_object.revive_timer_h = vint_object_find("follower_count", grp) 
  419. 		slot_object.visible = -1 
  420. 		slot_object.group_h = grp 
  421.  
  422. 		--clone animations into slots 
  423. 		local anim_0 = vint_object_clone(master_follower_anim_0) 
  424. 		local anim_1 = vint_object_clone(master_follower_anim_1) 
  425. 		slot_object.anim_0 = anim_0 
  426. 		slot_object.anim_1 = anim_1 
  427. 		vint_set_property(anim_0, "target_handle", grp) 
  428. 		vint_set_property(anim_1, "target_handle", grp) 
  429.  
  430. 		--Duplicate Tweens for Counting Anim 
  431. 		local count_tween_alpha_h = vint_object_clone(master_count_tween_alpha) 
  432. 		vint_set_property(count_tween_alpha_h, "target_handle", slot_object.revive_timer_h) 
  433. 	end 
  434. 	 
  435. 	--Hit Indicator  
  436. 	Hud_hit_elements.main_h = vint_object_find("hits") 
  437. 	h = Hud_hit_elements.main_h  
  438. 	Hud_hit_elements.minor_h = vint_object_find("major", h) 
  439. 	Hud_hit_elements.major_h = vint_object_find("major", h) 
  440. 	Hud_hit_elements.anim_h = vint_object_find("hit_anim") 
  441.  
  442. 	--Cruise Control 
  443. 	Hud_player_status.cruise_control_h = vint_object_find("cruise_control_grp") 
  444. 	Hud_player_status.cruise_control_obj = Vdo_hint_bar:new("cruise_control_hint_bar", 0, HUD_DOC_HANDLE) 
  445. 	Hud_player_status.cruise_control_anim = vint_object_find("cruise_control_fade_anim") 
  446.  
  447. 	--Hud Lockon 
  448. 	 
  449. 	Hud_lockon.lock_h = vint_object_find("lockon") 
  450. 	Hud_lockon.lock1_h = vint_object_find("lockon_1", Hud_lockon.lockon_h ) 
  451. 	Hud_lockon.lock2_h = vint_object_find("lockon_2", Hud_lockon.lockon_h ) 
  452. 	Hud_lockon.lock3_h = vint_object_find("lockon_3", Hud_lockon.lockon_h ) 
  453. 	Hud_lockon.lock4_h = vint_object_find("lockon_4", Hud_lockon.lockon_h ) 
  454. 	 
  455. 	Hud_lockon.lock_txt_grp_h = vint_object_find("lockon_txt_grp") 
  456. 	Hud_lockon.lock_text_h = vint_object_find("lockon_txt", Hud_lockon.lock_txt_grp_h) 
  457. 	Hud_lockon.lock_lock_h = vint_object_find("scan_lock", Hud_lockon.lock_txt_grp_h) 
  458. 	Hud_lockon.lock_spinner_h = vint_object_find("scan_spinner", Hud_lockon.lock_txt_grp_h) 
  459. 	Hud_lockon.lock_anim_h = vint_object_find("lockon_anim") 
  460. 	 
  461. 	lua_play_anim(Hud_lockon.lock_anim_h, 0, HUD_DOC_HANDLE) 
  462. 	 
  463. 	--lockon base screensize 
  464. 	Hud_lockon.lock_base_hor_width, Hud_lockon.lock_base_hor_height = vint_get_property(Hud_lockon.lock2_h, "scale") 
  465. 	Hud_lockon.lock_base_vert_width, Hud_lockon.lock_base_vert_height = vint_get_property(Hud_lockon.lock1_h, "scale") 
  466. 	 
  467. 	 
  468. 	--initialize the radio elements 
  469. 	Hud_radio_elements.image_h = vint_object_find("radio_station_image") 
  470. 	Hud_radio_elements.arrow_left_h = vint_object_find("radio_left_arrow") 
  471. 	Hud_radio_elements.arrow_right_h = vint_object_find("radio_right_arrow") 
  472. 	Hud_radio_elements.hint_left_h = Vdo_hint_button:new("radio_hint_left", 0, HUD_DOC_HANDLE) 
  473. 	Hud_radio_elements.hint_right_h = Vdo_hint_button:new("radio_hint_right", 0, HUD_DOC_HANDLE) 
  474. 	Hud_radio_elements.anim = vint_object_find("radio_station_anim_1") 
  475. 	 
  476. 	--Initialize Gameplay Status Indicator 
  477. 	Hud_gsi = Vdo_gsi:new("gsi") 
  478. 	vint_datagroup_add_subscription("sr2_local_player_gameplay_indicator_status", "insert", "hud_gsi_vdo_update") 
  479. 	vint_datagroup_add_subscription("sr2_local_player_gameplay_indicator_status", "update", "hud_gsi_vdo_update") 
  480. 	 
  481. 	--Find Genki anims and images 
  482. 	Hud_genki_anims = { 
  483. 		[HUD_GENKI_ETHICAL] = vint_object_find("genki_ethical_anim"), 
  484. 		[HUD_GENKI_UNETHICAL] = vint_object_find("genki_unethical_anim"), 
  485. 		[HUD_GENKI_NONE] = -1, 
  486. 	} 
  487. 	 
  488. 	Hud_genki_images = { 
  489. 		[HUD_GENKI_ETHICAL] = vint_object_find("ethical_img"), 
  490. 		[HUD_GENKI_UNETHICAL] = vint_object_find("unethical_img"), 
  491. 	} 
  492. 	 
  493. 	--Setup Camera hint for taking screenshots. 
  494. 	-- Set Control Image... 
  495. 	Hud_camera.hint_icon = Vdo_hint_button:new("camera_hint_button") 
  496. 	Hud_camera.hint_button = CTRL_BUTTON_DPAD_DOWN 
  497. 	Hud_camera.hint_key = game_get_key_name_for_action( "CBA_GAC_TAKE_SCREENSHOT" ) 
  498.  
  499. 	--vint_set_property(camera_hint_icon_bmp_h, "image", get_dpad_down_image()) 
  500. 	 
  501. 	--Initialize Mayhem Hud 
  502. 	hud_mayhem_init() 
  503. 	 
  504. 	--Initialize Object Indicators 
  505. 	--object_indicators_init() 
  506. 	 
  507. 	--Initialize Floating Healthbars (sewage version) 
  508. 	hud_healthbars_init() 
  509. 	 
  510. 	--Initialize reticule related stuff, 
  511. 	hud_reticules_init() 
  512. 	 
  513. 	hud_busted_init() 
  514. 	 
  515. 	--DISABLE Vehicle logo... 
  516. 	local h = vint_object_find("vehicle_logo") 
  517. 	vint_set_property(h, "visible", false) 
  518.  
  519. 	--Init VDO Objects 
  520. 	--Weapon Radial VDO Initialize and Hide 
  521. 	Hud_weapon_radial = Vdo_weapon_radial:new("radial_grp") 
  522. 	Hud_weapon_radial:show(false) 
  523. 		 
  524. 	--Radial Menu Subscriptions 
  525. 	vint_datagroup_add_subscription("sr2_local_player_inventory", "insert", "hud_radial_menu_update") 
  526. 	vint_datagroup_add_subscription("sr2_local_player_inventory", "update", "hud_radial_menu_update") 
  527. 	 
  528. 	--Subscribe to datagroups and dataitems 
  529. 	 
  530. 	--Respect 
  531. 	vint_dataitem_add_subscription("sr2_local_player_respect", "update", "hud_player_respect_change") 
  532. 	 
  533. 	--Initialize notoriety... 
  534. 	hud_noto_init() 
  535. 	--Hood 
  536. 	vint_dataitem_add_subscription("sr2_local_player_hood", "update", "hud_player_hood_change") 
  537. 	vint_dataitem_add_subscription("sr2_local_player_status", "update", "hud_player_status_change") 
  538.  
  539. 	--Followers 
  540. 	vint_datagroup_add_subscription("sr2_local_player_followers", "insert", "hud_player_followers_change") 
  541. 	vint_datagroup_add_subscription("sr2_local_player_followers", "update", "hud_player_followers_change") 
  542.  
  543. 	--Infrequent 
  544. 	--..moving below followers, hopefully solves homie update issues (Derik) 
  545. 	vint_dataitem_add_subscription("sr2_local_player_status_infrequent", "update", "hud_player_status_inf_change") 
  546. 	 
  547. 	--Weapons 
  548. 	vint_dataitem_add_subscription("sr2_local_player_weapons", "update", "hud_player_weapon_change") 
  549. 	vint_dataitem_add_subscription("sr2_local_player_frequent_weapon", "update", "hud_player_weapon_freq_change") 
  550. 	vint_dataitem_add_subscription("sr2_local_player_satellite_weapon", "update", "hud_player_satellite_weapon") 
  551. 	 
  552. 	--Lockon 
  553. 	vint_dataitem_add_subscription("sr2_local_player_lockon", "update", "hud_player_lockon_update") 
  554. 	 
  555. 	--Balance Meter 
  556. 	vint_dataitem_add_subscription("sr2_balance_meter", "update", "hud_balance_meter_change") 
  557. 	 
  558. 	--Cheat icons 
  559. 	vint_dataitem_add_subscription("hud_cheat_icons", "update", "hud_cheat_icon_update") 
  560.  
  561. 	--HUD Process Thread 
  562. 	Hud_process_thread = thread_new("hud_process") 
  563. 	 
  564. 	--Giant Minimap Icon 
  565. 	vint_dataitem_add_subscription("minimap_giant_icon", "update", "hud_map_objective_icon") 
  566. 	 
  567. 	--Hud collection init... (Flashpoint, Chopshop, Hitman, etc...) 
  568. 	hud_collection_init() 
  569. end 
  570.  
  571. function hud_cleanup() 
  572. 	--kill threads 
  573.  
  574. 	--VDOWEAPON 
  575. 	hud_inventory_hide() 
  576. 	 
  577. 	--unload vehicle logo 
  578. 	game_peg_unload(Hud_current_veh_logo) 
  579. 	 
  580. end 
  581.  
  582. function hud_hide_map() 
  583. 	vint_set_property(Hud_map.base_grp_h, "visible", false) 
  584. end 
  585.  
  586. function hud_show_map() 
  587. 	vint_set_property(Hud_map.base_grp_h, "visible", true) 
  588. end 
  589.  
  590. --Updates the Hud Radial Menu VDO 
  591. function hud_radial_menu_update(di_h) 
  592. 	Hud_weapon_radial:slots_update(di_h) 
  593. 	 
  594. 	--Make sure we have the right slot selected... 
  595. 	if Hud_weapon_radial.equipped_grenade_slot > 0 then 
  596. 		Hud_weapon_radial:weapon_highlight(Hud_weapon_radial.equipped_grenade_slot, true) 
  597. 	end 
  598. 	 
  599. 	--Make sure we have the right slot selected... 
  600. 	if Hud_weapon_radial.equipped_weapon_slot ~= -1 and Hud_weapon_radial.selected_weapon_slot == -1 then 
  601. 		Hud_weapon_radial:weapon_highlight(Hud_weapon_radial.equipped_weapon_slot, true) 
  602. 	end 
  603. end 
  604.  
  605. --Inventory Control Mapping 
  606. function hud_inventory_input(event, value) 
  607. 	if event == "inventory" then 
  608. --[[		if value > 0.4 then 
  609. 			-- We're doing a fast weapon switch if you tap the button 
  610. 			if Hud_inventory.is_pressed == false then 
  611. 				if Hud_inventory.tap_thread == nil then 
  612. 					Hud_inventory.tap_thread = thread_new( "hud_inventory_delayed_show" ) 
  613. 				end	 
  614. 			end 
  615. 		else 
  616. 			if Hud_inventory.tap_thread == nil then 
  617. 				--Normal inventory select... 
  618. 				--Select Weapon 
  619. 				Hud_weapon_radial:game_equip_selected_slots() 
  620. 			 
  621. 				--Hide Inventory 
  622. 				hud_inventory_hide() 
  623. 				Hud_inventory.is_pressed = false 
  624. 			else 
  625. 				--Tap thread style select. 
  626. 				 
  627. 				--only switch if the inventory is enabled 
  628. 				if Hud_player_status.inventory_disabled == false then 
  629. 					--Equip last equipped weapon... 
  630. 					local success = game_use_radial_menu_item(INV_WEAPON_SLOT_LAST_EQUIPPED) 
  631. 					if success then 
  632. 						Hud_weapon_radial.equipped_weapon_slot = Hud_weapon_radial.selected_weapon_slot  
  633. 					end 
  634. 				end 
  635. 		 
  636. 				thread_kill( Hud_inventory.tap_thread ) 
  637. 				Hud_inventory.tap_thread = nil 
  638. 			end 
  639. 		end--]] 
  640. 	elseif event == "inventory_x" then 
  641. 		--Move Analog Stick X 
  642. 		Hud_inventory.x = value 
  643. 		Hud_inventory.stale = true 
  644. 		 
  645. 	elseif event == "inventory_y" then 
  646. 		--Move Analog Stick Y 
  647. 		Hud_inventory.y = value 
  648. 		Hud_inventory.stale = true 
  649.  
  650. 	elseif event == "inventory_up" and value > INVENTORY_DPAD_THRESHOLD then 
  651. 		Hud_weapon_radial:weapon_highlight(8) 
  652. 	elseif event == "inventory_right" and value > INVENTORY_DPAD_THRESHOLD then 
  653. 		Hud_weapon_radial:weapon_highlight(9) 
  654. 	elseif event == "inventory_down" and value > INVENTORY_DPAD_THRESHOLD then 
  655. 		Hud_weapon_radial:weapon_highlight(10) 
  656. 	elseif event == "inventory_left" and value > INVENTORY_DPAD_THRESHOLD then	 
  657. 		Hud_weapon_radial:weapon_highlight(11) 
  658. 	end 
  659. end 
  660.  
  661. --Show Hud Inventory!! 
  662. function hud_inventory_show() 
  663.  
  664. 	game_hud_update_inventory() 
  665. 	 
  666. 	hud_weapon_hide() 
  667.  
  668. 	if Hud_inventory.thread == nil then 
  669. 		game_UI_audio_play("UI_HUD_Open_Weapon_Radial") 
  670. 		 
  671. 		--TODO: Show Inventory 
  672. 		Hud_weapon_radial:show(true) 
  673. 		 
  674. 		--Subscribe to input 
  675. 		Hud_inventory.extra_buttons = { 
  676. 		--	vint_subscribe_to_input_event("alt_select", "hud_inventory_input"), 
  677. 		--	vint_subscribe_to_input_event("select", "hud_inventory_input"), 
  678. 		--	vint_subscribe_to_input_event("exit", "hud_inventory_input"), 
  679. 		--	vint_subscribe_to_input_event("back", "hud_inventory_input"), 
  680. 		--	vint_subscribe_to_input_event("white", "hud_inventory_input"), 
  681. 		--	vint_subscribe_to_input_event("black", "hud_inventory_input"), 
  682. 			vint_subscribe_to_input_event("map", "hud_inventory_input"), 
  683. 			vint_subscribe_to_input_event("pause", "hud_inventory_input"), 
  684. 		--	vint_subscribe_to_input_event("scroll_up", "hud_inventory_input"), 
  685. 		--	vint_subscribe_to_input_event("scroll_down", "hud_inventory_input"), 
  686. 		--	vint_subscribe_to_input_event("scroll_left", "hud_inventory_input"), 
  687. 		--	vint_subscribe_to_input_event("scroll_right", "hud_inventory_input"), 
  688. 		} 
  689.  
  690. 		Hud_inventory.subs_x = vint_subscribe_to_raw_input("inventory_x", "hud_inventory_input") 
  691. 		Hud_inventory.subs_y = vint_subscribe_to_raw_input("inventory_y", "hud_inventory_input") 
  692. 		Hud_inventory.subs_up = vint_subscribe_to_raw_input("inventory_up", "hud_inventory_input") 
  693. 		Hud_inventory.subs_right = vint_subscribe_to_raw_input("inventory_right", "hud_inventory_input") 
  694. 		Hud_inventory.subs_down = vint_subscribe_to_raw_input("inventory_down", "hud_inventory_input") 
  695. 		Hud_inventory.subs_left = vint_subscribe_to_raw_input("inventory_left", "hud_inventory_input") 
  696.  
  697. 		--Reset visual analog stick and get the proper text tag on it. 
  698. 		Hud_inventory.x = 0 
  699. 		Hud_inventory.y = 0 
  700. 		 
  701. 		--Highlight Currently equipped slots 
  702. 		Hud_weapon_radial:weapon_highlight(Hud_weapon_radial.equipped_weapon_slot, true) 
  703. 		if Hud_weapon_radial.equipped_grenade_slot > 0 then 
  704. 			Hud_weapon_radial:weapon_highlight(Hud_weapon_radial.equipped_grenade_slot, true) 
  705. 		end 
  706. 		 
  707. 		Hud_weapon_radial:stick_update_position(0, 0) 
  708. 		Hud_weapon_radial:stick_update_tag()	 
  709. 		Hud_weapon_radial:stick_arrow_reset()	 
  710.  
  711. 		Hud_inventory.thread = thread_new("hud_inventory_process")			 
  712. 	end 
  713. end 
  714.  
  715. function hud_inventory_hide(aborted) 
  716. 	if Hud_inventory.thread ~= nil then 
  717. 	 
  718. 		if aborted == false then 
  719. 			Hud_weapon_radial:game_equip_selected_slots() 
  720. 		end 
  721. 		 
  722. 		--Hide Radial Menu 
  723. 		Hud_weapon_radial:show(false) 
  724. 		 
  725. 		--Show weapon 
  726. 		hud_weapon_show() 
  727. 		 
  728. 		vint_unsubscribe_to_raw_input(Hud_inventory.subs_x) 
  729. 		vint_unsubscribe_to_raw_input(Hud_inventory.subs_y) 
  730. 		vint_unsubscribe_to_raw_input(Hud_inventory.subs_up) 
  731. 		vint_unsubscribe_to_raw_input(Hud_inventory.subs_right) 
  732. 		vint_unsubscribe_to_raw_input(Hud_inventory.subs_down) 
  733. 		vint_unsubscribe_to_raw_input(Hud_inventory.subs_left) 
  734. 		 
  735. 		for idx, val in pairs(Hud_inventory.extra_buttons) do  
  736. 			vint_unsubscribe_to_input_event(val) 
  737. 		end 
  738. 		 
  739. 		Hud_inventory.extra_buttons = nil				 
  740. 		thread_kill(Hud_inventory.thread) 
  741. 		Hud_inventory.thread = nil 
  742. 		 
  743. 	end 
  744. end 
  745.  
  746.  
  747. function hud_inventory_process() 
  748. 	while true do  
  749. 		if Hud_inventory.stale == true then 
  750. 		 
  751. 			local x = Hud_inventory.x 
  752. 			local y = Hud_inventory.y 
  753. 			local selected_weapon_index = 0 
  754. 			local mag = sqrt((x * x) + (y * y)) 
  755. 			local pi = 3.14159 
  756. 			 
  757. 			if mag > 0.5 then 
  758. 				 
  759. 				-- Y resolves out so don't bother with it 
  760. 				x = x/mag 
  761. 				local radians = acos(x) 
  762. 				 
  763. 				if y < 0.0 then 
  764. 					radians = pi + (pi - radians) 
  765. 				end 
  766. 	 
  767. 				local eighth = pi / 8 
  768. 				local fourth = pi / 4 
  769. 				local selected_weapon_index = 0 
  770. 				 
  771. 				if radians < eighth then 
  772. 					selected_weapon_index = 2; 
  773. 				elseif radians < (fourth + eighth) then 
  774. 					selected_weapon_index = 1 
  775. 				elseif radians < (2.0 * fourth + eighth) then 
  776. 					selected_weapon_index = 0 
  777. 				elseif radians < (3.0 * fourth + eighth) then 
  778. 					selected_weapon_index = 7 
  779. 				elseif radians < (4.0 * fourth + eighth) then 
  780. 					selected_weapon_index = 6 
  781. 				elseif radians < (5.0 * fourth + eighth) then 
  782. 					selected_weapon_index = 5 
  783. 				elseif radians < (6.0 * fourth + eighth) then 
  784. 					selected_weapon_index = 4; 
  785. 				elseif radians < (7.0 * fourth + eighth) then				 
  786. 					selected_weapon_index = 3; 
  787. 				else 
  788. 					selected_weapon_index = 2; 
  789. 				end 
  790.  
  791. 				--Change selected item in the menu 
  792. 				--Hud_radial_menu_change_select(selected_weapon_index)	 
  793. 				Hud_weapon_radial:weapon_highlight(selected_weapon_index) 
  794. 				Hud_weapon_radial:stick_update_arrow(radians) 
  795. 				 
  796. 			end 
  797. 	 
  798. 			--Update Stick location on radial menu 
  799. 			Hud_weapon_radial:stick_update_position(Hud_inventory.x, Hud_inventory.y) 
  800. 			Hud_inventory.stick_mag = mag 
  801. 			Hud_inventory.stale = false 
  802. 		end 
  803. 		thread_yield() 
  804. 	end 
  805. end 
  806.  
  807. function hud_gsi_vdo_update(di_h) 
  808. 	if Hud_gsi ~= -1 then 
  809. 		Hud_gsi:update(di_h) 
  810. 	end 
  811. end 
  812. 	 
  813. function hud_process() 
  814.  
  815. 	local display_cash = Hud_player_status.cash - 1 --Subtract one so it gets formatted in the loop. 
  816. 	local hud_had_focus = nil 
  817. 	 
  818. 	while true do 
  819. 		thread_yield() 
  820. 		 
  821. 		-- Animate Cash 
  822. 		if display_cash ~= Hud_player_status.cash then 
  823. 			local diff_cash = Hud_player_status.cash - display_cash 
  824. 			 
  825. 			if diff_cash > 5 or diff_cash < -5 then 
  826. 				diff_cash = floor(diff_cash * 0.5) 
  827. 			end 
  828. 			 
  829. 			display_cash = display_cash + diff_cash 
  830. 			vint_set_property(Hud_player_status.cash_h, "text_tag", "$" .. format_cash(display_cash)) 
  831. 		end 
  832. 		 
  833. 		-- check to see if the hud has lost focus 
  834. 		if hud_had_focus ~= Hud_has_focus then 
  835. 			hud_had_focus = Hud_has_focus 
  836. 		end 
  837. 		 
  838. 		local hud_msg_doc_h = vint_document_find("hud_msg") 
  839. 		if hud_msg_doc_h ~= 0 then 
  840. 			hud_msg_process() 
  841. 		end 
  842. 	end 
  843. end 
  844.  
  845. function hud_player_hood_change(data_item_handle, event_name) 
  846. 	local hood_name, cur_hood_owner, orig_hood_owner, is_contested = vint_dataitem_get(data_item_handle) 
  847.  
  848. 	-- this will become relevant for pushbacks and display of notoriety since we always will show 
  849. 	-- gang noto for mission/activity gang or hood owner if hood is contested 
  850. end 
  851.  
  852. function hud_player_status_inf_change(di_h, event_name) 
  853. 	 
  854. 	local cash, max_followers, inventory_disabled, vehicle_logo, radio_station, cruise_control_active, camera_screenshot_enabled, force_show_cash, show_vtol_hints	= vint_dataitem_get(di_h) 
  855. 		 
  856. 	local floored_cash = floor(cash) 
  857. 	if cash ~= Hud_player_status.cash or force_show_cash then 
  858. 		--Start up the cash display animation if the players cash updates 
  859. 		local cash_anim_h = vint_object_find("cash_anim") 
  860.  
  861. 		--set first frame of animation to current alpha value of cash 
  862. 		local cash_alpha = vint_get_property(Hud_player_status.cash_h, "alpha") 
  863. 		local cash_anim_first_tween_h = vint_object_find("cash_anim_first_tween", cash_anim_h) 
  864. 		vint_set_property(cash_anim_first_tween_h, "start_value", cash_alpha) 
  865. 		 
  866. 		lua_play_anim(cash_anim_h) 
  867. 	end 
  868. 	 
  869. 	--Update cash (this gets read through hud_process() so it counts up nicely) 
  870. 	Hud_player_status.cash = floored_cash 
  871. 	 
  872. 	if vehicle_logo == nil then 
  873. 		vehicle_logo = 0 
  874. 	end 
  875. 	 
  876. 	if radio_station == nil then 
  877. 		radio_station = 0 
  878. 	end 
  879. 	 
  880. 	-- Display a new vehicle logo 
  881. 	if Hud_current_veh_logo ~= vehicle_logo then 
  882. 	 
  883. 		if Hud_current_veh_logo ~= "__unloaded" and Hud_current_veh_logo ~= 0 then 
  884. 			game_peg_unload(Hud_current_veh_logo) 
  885. 		end 
  886.  
  887. 		Hud_current_veh_logo = vehicle_logo		 
  888. 		 
  889. 		if vehicle_logo == "__unloaded" or vehicle_logo == 0 then				 
  890. 			local o = vint_object_find("vehicle_logo") 
  891. 			vint_set_property(o, "visible", false)			 
  892. 		else		 
  893. 			-- Load vehicle logo peg 
  894. 			game_peg_load_with_cb("hud_set_vehicle_logo", 1, vehicle_logo) 
  895. 		end 
  896. 	end 
  897. 		 
  898. 	-- Display a new radio station 
  899. 	if Hud_current_radio_station ~= radio_station then 
  900. 		if radio_station ~= 0 then 
  901. 			local radio_station_small 
  902. 			if radio_station ~= "" then 
  903. 				--build the radio image name 
  904. 				radio_station_small = radio_station.."_sm" 
  905. 				vint_set_property(Hud_radio_elements.image_h, "scale", 1.25, 1.25) 
  906. 			else 
  907. 				radio_station_small = "ui_menu_none" 
  908. 				vint_set_property(Hud_radio_elements.image_h, "scale", 0.8, 0.8) 
  909. 			end 
  910. 			vint_set_property(Hud_radio_elements.image_h, "image", radio_station_small) 
  911. 			local arrow_pad = 20 
  912. 			local radio_w,radio_h = element_get_actual_size( Hud_radio_elements.image_h ) 
  913. 			local radio_x,radio_y = vint_get_property( Hud_radio_elements.image_h, "anchor" ) 
  914. 			local arrow_x,arrow_y = vint_get_property( Hud_radio_elements.arrow_left_h, "anchor" ) 
  915. 			 
  916. 			local left_arrow_adjusted_x = radio_x - ((radio_w * 0.5) + arrow_pad) 
  917. 			vint_set_property(Hud_radio_elements.arrow_left_h, "anchor", left_arrow_adjusted_x, arrow_y) 
  918. 			 
  919. 			local right_arrow_adjusted_x = radio_x + ((radio_w * 0.5) + arrow_pad) 
  920. 			vint_set_property(Hud_radio_elements.arrow_right_h, "anchor", right_arrow_adjusted_x, arrow_y) 
  921. 			 
  922. 			if game_is_active_input_gamepad() == false then 
  923. 				Hud_radio_elements.hint_right_h:set_visible( true ) 
  924. 				Hud_radio_elements.hint_left_h:set_visible( true ) 
  925. 				 
  926. 				Hud_radio_elements.hint_right_h:set_button( nil, game_get_key_name_for_action( "CBA_VDC_NEXT_RADIO" ), false, true) 
  927. 				Hud_radio_elements.hint_left_h:set_button( nil, game_get_key_name_for_action( "CBA_VDC_PREV_RADIO" ) , false, true) 
  928. 				 
  929. 				local hint_right_x,hint_right_y = 	Hud_radio_elements.hint_right_h:get_property( "anchor" ) 
  930. 				local hint_left_x,hint_left_y = 		Hud_radio_elements.hint_left_h:get_property( "anchor" ) 
  931. 				local hint_right_w,hint_right_h = 	Hud_radio_elements.hint_right_h:get_property( "screen_size" ) 
  932. 				local hint_left_w,hint_left_h = 		Hud_radio_elements.hint_left_h:get_property( "screen_size" ) 
  933. 				 
  934. 				local new_hint_right_x = right_arrow_adjusted_x + (hint_right_w * 0.5) 
  935. 				local new_hint_left_x = left_arrow_adjusted_x - (hint_left_w * 0.5) 
  936. 				 
  937. 				Hud_radio_elements.hint_right_h:set_property( "anchor", new_hint_right_x, hint_right_y ) 
  938. 				Hud_radio_elements.hint_left_h:set_property( "anchor", new_hint_left_x, hint_left_y ) 
  939. 			else 
  940. 				Hud_radio_elements.hint_right_h:set_visible( false ) 
  941. 				Hud_radio_elements.hint_left_h:set_visible( false ) 
  942. 			end 
  943. 			 
  944. 			lua_play_anim( Hud_radio_elements.anim ) 
  945. 		end 
  946. 	end 
  947. 	 
  948. 	Hud_current_radio_station = radio_station 
  949. 	 
  950. 	hud_cruise_control_update(cruise_control_active) 
  951. 	 
  952. 	if show_vtol_hints then 
  953. 		hud_vtol_set_hints() 
  954. 		Hud_sniper_hint_bar:set_visible(true) 
  955. 	else 
  956. 		Hud_sniper_hint_bar:set_visible(false) 
  957. 	end 
  958. 	 
  959. 	if camera_screenshot_enabled ~= Hud_camera_screenshot_enabled then 
  960. 		--show or hide screenshot hint... this is always on. 
  961. 		local h = vint_object_find("screenshot_camera_hint_grp") 
  962. 		vint_set_property(h, "visible", camera_screenshot_enabled) 
  963. 		 
  964. 		Hud_camera.hint_key = game_get_key_name_for_action( "CBA_GAC_TAKE_SCREENSHOT" ) 
  965. 		Hud_camera.hint_icon:set_button( Hud_camera.hint_button, Hud_camera.hint_key, false, false) 
  966. 		 
  967. 		Hud_camera_screenshot_enabled = camera_screenshot_enabled 
  968. 	end 
  969. 	 
  970. 	local hint_icon_w,hint_icon_h = Hud_camera.hint_icon:get_size() 
  971. 	local adjusted_hint_x = hint_icon_w * 0.5 
  972. 	 
  973. 	Hud_camera.hint_icon:set_property( "anchor", adjusted_hint_x, 0 ) 
  974. 	 
  975. 	local camera_hint_icon_bmp_h = vint_object_find( "camera_hint_icon_bmp" ) 
  976. 	vint_set_property( camera_hint_icon_bmp_h, "anchor", hint_icon_w + 15, 0 ) 
  977.  
  978. end 
  979.  
  980. function hud_set_vehicle_logo() 
  981. 	local o = vint_object_find("vehicle_logo") 
  982. 	vint_set_property(o, "image", Hud_current_veh_logo) 
  983. 	lua_play_anim(vint_object_find("vehicle_logo_anim_1"), 0) 
  984. 	vint_set_property(o, "visible", true) 
  985. end 
  986.  
  987. function hud_player_status_change(di_h, event_name) 
  988. 	--HUD dataitem is special and doesn't need any comments. FML. :/ 
  989. 	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 = vint_dataitem_get(di_h) 
  990. 	 
  991. 	local unhide_weapons = false 
  992.  
  993. 	-- Get health difference... 
  994. 	local health_pct_diff = abs(Hud_health_bar.percent - health_pct) 
  995. 	 
  996. 	if health_pct_diff > .001 or health_level ~= Hud_health_bar.level then 
  997.  
  998. 		local bar = Hud_health_bar 
  999. 		local level = health_level 
  1000. 	 
  1001. 		--get start/end angles depending on level... 
  1002. 		local start_angle_static	 = bar.level_angles[level].fill_start_angle 
  1003. 		local end_angle_static		 = bar.level_angles[level].fill_end_angle 
  1004. 		local angle_offset_static	 = bar.level_angles[level].angle_offset 
  1005. 		 
  1006. 		--Calculate current angles... 
  1007. 		local fill_end_angle =  (end_angle_static - start_angle_static) * health_pct + start_angle_static 
  1008. 		local bg_end_angle = fill_end_angle - angle_offset_static 
  1009. 		 
  1010. 		--if new health pct is less than current then do the animation of it dropping 
  1011. 		if health_pct < Hud_health_bar.percent then 
  1012. 			if bar.is_expanded == false then 
  1013. 				hud_player_health_show() 
  1014. 			end 
  1015. 			 
  1016. 			--Decrease the health meter 
  1017. 			hud_player_health_decrease_anim(bar, fill_end_angle, bg_end_angle) 
  1018.  
  1019. 			if health_pct < .3 then 
  1020. 				--Full screen health effect gets even heavier if it drops below .3 
  1021. 				local vignette_alpha = .70 - health_pct 
  1022. 				hud_health_screen_fade(vignette_alpha) 
  1023.  
  1024. 			elseif health_pct < .5 then 
  1025. 				--Full screen health effect if drops below .5 
  1026. 				local vignette_alpha = .5 - health_pct 
  1027. 				hud_health_screen_fade(vignette_alpha) 
  1028. 			end 
  1029. 			Hud_player_status.health_recovering = false 
  1030. 		elseif health_pct >= Hud_health_bar.percent then 
  1031. 			--Increase the health meter 
  1032. 			hud_player_health_increase_anim(bar, fill_end_angle, bg_end_angle) 
  1033. 			 
  1034. 			if Hud_player_status.health_recovering == false then 
  1035. 				hud_health_screen_fade(0) 
  1036. 				Hud_player_status.health_recovering = true 
  1037. 			end 
  1038. 		end 
  1039. 			 
  1040. 		if health_pct == 1 and bar.is_expanded == true then 
  1041. 			--Start to hide the bar. 
  1042. 			lua_play_anim(bar.timer_fade_out_anim_h) 
  1043. 		else 
  1044. 			vint_set_property(bar.timer_fade_out_anim_h, "is_paused", true) 
  1045. 		end 
  1046.  
  1047. 		--Make sure we can see the healthbar...  
  1048. 		unhide_weapons = true 
  1049. 		 
  1050. 		Hud_health_bar.percent = health_pct 
  1051. 		Hud_health_bar.level = health_level 
  1052. 	end 
  1053.  
  1054. 	Hud_player_status.bleed_out_health_pct = bleed_out_health_pct 
  1055. 	Hud_player_status.is_in_satellite_mode = is_in_satellite_mode 
  1056. 	Hud_player_status.is_controlling_missile = is_controlling_missile 
  1057.  
  1058. 	local unhide_sprint = false  
  1059. 	 
  1060. 	--Sprint 
  1061. 	-- Get Sprint difference... 
  1062. 	local sprint_pct_diff = abs(Hud_sprint_bar.percent - sprint_pct) 
  1063.  
  1064. 	if sprint_enabled == true and (sprint_pct_diff > .001 or sprint_level ~= Hud_sprint_bar.level) then 
  1065. 		local bar = Hud_sprint_bar 
  1066. 		local level = sprint_level 
  1067. 		 
  1068. 		--get start/end angles depending on level... 
  1069. 		local start_angle_static	 = bar.level_angles[level].fill_start_angle 
  1070. 		local end_angle_static		 = bar.level_angles[level].fill_end_angle 
  1071. 		local angle_offset_static	 = bar.level_angles[level].angle_offset 
  1072. 		 
  1073. 		--Calculate current angles... 
  1074. 		local fill_end_angle =  (end_angle_static - start_angle_static) * sprint_pct + start_angle_static 
  1075. 		local bg_end_angle = fill_end_angle - angle_offset_static 
  1076. 		 
  1077. 		 
  1078. 		unhide_sprint = true 
  1079. 		 
  1080. 		--Update angles for the sprint meter 
  1081. 		vint_set_property(bar.bg_h, "end_angle", bg_end_angle) 
  1082. 		 
  1083. 		--Hide bg of meter if sprint is empty. 
  1084. 		if sprint_pct == 0 then 
  1085. 			vint_set_property(bar.bg_h, "visible", false) 
  1086. 		else 
  1087. 			vint_set_property(bar.bg_h, "visible", true) 
  1088. 		end 
  1089. 		 
  1090. 		vint_set_property(bar.fill_h, "end_angle", fill_end_angle) 
  1091.  
  1092. 		--Make sure we can see the sprintbar...  
  1093. 		unhide_weapons = true 
  1094. 		 
  1095. 		Hud_sprint_bar.sprint_percent = sprint_pct 
  1096. 		Hud_sprint_bar.level = sprint_level 
  1097. 	end 
  1098. 	 
  1099. 	if is_sprinting ~= Hud_player_status.is_sprinting then 
  1100. 		local sprint_anim_h = vint_object_find("sprint_pulse_anim") 
  1101. 		if is_sprinting == false then 
  1102. 			--Stop pulse animation and reset... 
  1103. 			vint_set_property(sprint_anim_h, "is_paused", true) 
  1104. 			vint_set_property(Hud_sprint_bar.fill_h, "tint", HUD_SPRINT_COLOR.R, HUD_SPRINT_COLOR.G, HUD_SPRINT_COLOR.B) 
  1105. 		else  
  1106. 			lua_play_anim(sprint_anim_h)		 
  1107. 		end 
  1108. 	 
  1109. 		unhide_sprint = true 
  1110. 		 
  1111. 		--Store to global... 
  1112. 		Hud_player_status.is_sprinting = is_sprinting 
  1113. 	end 
  1114.  
  1115. 	 
  1116. 	if unhide_sprint == true then 
  1117. 		--Should we hide the sprint bar... 
  1118. 		local bar = Hud_sprint_bar 
  1119. 		 
  1120. 		if sprint_pct == 1 and bar.is_expanded == true then 
  1121. 			--Start to hide the bar. 
  1122. 			lua_play_anim(bar.timer_fade_out_anim_h) 
  1123. 		else 
  1124. 			vint_set_property(bar.timer_fade_out_anim_h, "is_paused", true) 
  1125. 		end 
  1126. 		 
  1127. 		--Attempt to show the sprint bar... 
  1128. 		hud_player_sprint_show() 
  1129. 		 
  1130. 		--Make sure we can see the sprintbar...  
  1131. 		unhide_weapons = true 
  1132. 	end 
  1133. 	 
  1134. 	--If we updated the health or sprint... we unhide the weapons... 
  1135. 	if unhide_weapons == true then 
  1136. 		--fade in... 
  1137. 		hud_weapon_fade_in() 
  1138. 	end 
  1139. 	 
  1140. 	if orientation ~= Hud_player_status.orientation then 
  1141. 		--Rotate Hit Indicators to player rotation 
  1142. 		orientation = 3.14 - orientation 
  1143. 		vint_set_property(Hud_hit_elements.main_h, "rotation", orientation) 
  1144. 		Hud_player_status.orientation = orientation 
  1145. 	end 
  1146. 	 
  1147. 	--Sets the amount of tunnel vision for the player 
  1148. 	if tunnel_vision_amount ~= Hud_vignettes.tunnel_vision then--and 
  1149. 		vint_set_property(Hud_vignettes.tunnel_vision.grp_h, "alpha", tunnel_vision_amount) 
  1150. 	end 
  1151. end 
  1152.  
  1153. function hud_player_sprint_show() 
  1154. 	if Hud_sprint_bar.is_expanded == false then 
  1155. 		vint_set_property(vint_object_find("map_sprint_contract"), "is_paused", true) 
  1156. 		lua_play_anim(vint_object_find("map_sprint_expand")) 
  1157. 		Hud_sprint_bar.is_expanded = true 
  1158. 	end 
  1159. end 
  1160.  
  1161. --Plays the animation which retracts the sprint bar. 
  1162. --This is triggered by a callback setup in the init() 
  1163. function hud_player_sprint_hide() 
  1164. 	vint_set_property(vint_object_find("map_sprint_expand"), "is_paused", true) 
  1165. 	lua_play_anim(vint_object_find("map_sprint_contract")) 
  1166. 	Hud_sprint_bar.is_expanded = false 
  1167. end 
  1168.  
  1169. function hud_player_health_show() 
  1170. 	vint_set_property(vint_object_find("map_health_contract"), "is_paused", true) 
  1171. 	lua_play_anim(vint_object_find("map_health_expand")) 
  1172. 	Hud_health_bar.is_expanded = true 
  1173. end 
  1174.  
  1175. --Plays the animation which retracts the health bar. 
  1176. --This is triggered by a callback setup in the init() 
  1177. function hud_player_health_hide() 
  1178. 	vint_set_property(vint_object_find("map_health_expand"), "is_paused", true) 
  1179. 	lua_play_anim(vint_object_find("map_health_contract")) 
  1180. 	Hud_health_bar.is_expanded = false 
  1181. end 
  1182.  
  1183. function hud_player_health_decrease_anim(bar, fill_end_angle, bg_end_angle) 
  1184.  
  1185.  
  1186. 	--Flash the bar if we are not already flashing. 
  1187. 	if Hud_health_bar.is_flashing == false then 
  1188. 		lua_play_anim(bar.health_flash_anim_h, 0) 
  1189. 		Hud_health_bar.is_flashing = true 
  1190. 	end 
  1191.  
  1192.  
  1193. 	--Decay animation... 
  1194. 	if Hud_health_bar.is_decaying == false then 
  1195. 		--We aren't already decaying so its safe to replay the animation... 
  1196. 	 
  1197. 		--update the start values if we aren't decaying... 
  1198. 		local current_start_value = vint_get_property(bar.fill_1_h, "end_angle") 
  1199. 		local bg_start_angle = vint_get_property(bar.bg_h, "end_angle") 
  1200. 		 
  1201. 		vint_set_property(bar.health_bg_angle_twn_h, "start_value", bg_start_angle) 
  1202. 		vint_set_property(bar.health_fill_angle_twn_h, "start_value", current_start_value) 
  1203. 		 
  1204. 		lua_play_anim(bar.health_decay_anim_h, 0) 
  1205. 		-- The decaying flag will get set to true when the tween actually starts. until then we won't update that. 
  1206. 	end 
  1207.  
  1208. 	--change the state of the end tweens regardless if we are decaying or not... 
  1209. 	--Pop start of second bar to first 
  1210. 	vint_set_property(bar.fill_h, "end_angle", fill_end_angle) 
  1211. 	vint_set_property(bar.fill_1_h, "start_angle", fill_end_angle) 
  1212.  
  1213. 	--Set values for fill angle	 
  1214. 	vint_set_property(bar.health_fill_angle_twn_h, "end_value", fill_end_angle) 
  1215. 	 
  1216. 	--set values for bg end angle... 
  1217. 	vint_set_property(bar.health_bg_angle_twn_h, "end_value", bg_end_angle) 
  1218. end 
  1219.  
  1220. function hud_player_health_increase_anim(bar, fill_end_angle, bg_end_angle) 
  1221. 	--update the values directly... 
  1222. 	vint_set_property(bar.fill_h, "end_angle", fill_end_angle) 
  1223. 	vint_set_property(bar.fill_1_h, "end_angle", fill_end_angle) 
  1224. 	vint_set_property(bar.bg_h, "end_angle", bg_end_angle) 
  1225. end 
  1226.  
  1227. --Callbacks for health animations... 
  1228. function hud_health_decay_start(twn_h) 
  1229. 	--set our decaying status to true 
  1230. 	Hud_health_bar.is_decaying = true 
  1231. end 
  1232.  
  1233. function hud_health_decay_end(twn_h) 
  1234. 	--set our decaying status to false... 
  1235. 	Hud_health_bar.is_decaying = false 
  1236. end 
  1237.  
  1238. function hud_health_flash_complete(twn_h) 
  1239. 	Hud_health_bar.is_flashing = false 
  1240. end 
  1241.  
  1242.  
  1243. --##################################################### 
  1244. --Weapon Changes 
  1245. --##################################################### 
  1246.  
  1247. function hud_player_weapon_change(di_h, event_name) 
  1248. --[[ 
  1249. 		di->set_element(0, wpn_bmp_name);						// weapon image name 
  1250. 		di->set_element(1, ammo_ready);							// current ammo or < 0 if ammoless weapon 
  1251. 		di->set_element(2, ammo_reserve);						// ammo capacity 
  1252. 		di->set_element(3, grenade_bmp_name);					// greande image name 
  1253. 		di->set_element(4, grenade_ammo);						// current grenade ammo 
  1254. 		di->set_element(5, wpn_ready);							// weapon ready 
  1255. 		di->set_element(6, dual_wield);							// secondary weapon 
  1256. 		di->set_element(7, ammoless_wpn);						// infinite ammo 
  1257. 		di->set_element(8, ammo_infinite);						// infinite ammo 
  1258. 		di->set_element(9, grenade_ammo_infinite);			// infinite ammo 
  1259. 		di->set_element(10, continuous_fire);					// infinite ammo 
  1260. 		di->set_element(11, no_magazine);						// continuous fire (like water gun or flame thrower) 
  1261. 		di->set_element(12, pp->pflags.is_zoomed != 0);		// is the player vp zoomed (ala sniper rifle) 
  1262. 		di->set_element(13, cur_wpn_name);						// name of weapon 
  1263. 		di->set_element(14, cur_wpn_category_name);			// weapon category name 
  1264. 		di->set_element(15, reticle_highlight);				// enemy / friendly / none  
  1265. 		di->set_element(16, cur_wpn_spread);					// weapon spread 
  1266. 		di->set_element(17, slot);									// slot the current weapon is in. 
  1267. 		di->set_element(18, grenade_slot);						// slot the current grenade is in. 
  1268. 		di->set_element(19, show_reticle);						// Show the reticle when in cover and aiming or in fine aim. 
  1269. 		di->set_element(20, overheat_pct);						// Overheat percentage 
  1270. 		di->set_element(21, is_overheated);						// Is overheated... (is the reticule overheated?) 
  1271. 		heat_pct, is_overheated  
  1272. 		di->set_element(22, bullet_hit);							// bool did the shot hit something valid 
  1273. 		di->set_element(23, genki_target);						// genki target type (HUD_GENKI_NONE, HUD_GENKI_ETHICAL, HUD_GENKI_UNETHICAL) 
  1274. 		di->set_element(24, reloading);							// player is reloading 
  1275. 		 
  1276. ]]-- 
  1277. 	local wpn_bmp_name, rdy_ammo, rsv_ammo, grenade_bmp_name, grenade_ammo, wpn_rdy, dual_wield, no_ammo, inf_ammo, gnd_inf_ammo, cont_fire, no_mag, sniper_visible, wpn_name, wpn_category, reticule_highlight, wpn_spread, wpn_slot, grenade_slot, show_reticule, overheat_pct, is_overheated, bullet_hit, genki_target, reloading  = vint_dataitem_get(di_h)	 
  1278.  
  1279. 	--Debug Ammo Dataitem... 
  1280. 	--dataitem_to_debug(di_h, "wpn_bmp_name", "rdy_ammo", "rsv_ammo", "grenade_bmp_name", "grenade_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", "grenade_slot", "show_reticule", "overheat_pct", "is_overheated") 
  1281. 	 
  1282. 	--Set flag to determine if we should attemp to unhide the weapons... 
  1283. 	local unhide_weapons = false 
  1284. 	 
  1285. 	--Update weapon area... 
  1286. 	if wpn_bmp_name == nil then 
  1287. 		wpn_bmp_name = "ui_hud_inv_fist" 
  1288. 	end 
  1289.  
  1290. 	if dual_wield ~= Hud_weapon_status.dual_wield or wpn_bmp_name ~= Hud_weapon_status.wpn_bmp_name then 
  1291. 		if dual_wield == true then 
  1292. 			vint_set_property(Hud_weapon_status.dual_wpn_icon_1_h, "image", wpn_bmp_name) 
  1293. 			vint_set_property(Hud_weapon_status.dual_wpn_icon_2_h, "image", wpn_bmp_name) 
  1294. 		else 
  1295. 			vint_set_property(Hud_weapon_status.single_wpn_icon_h, "image", wpn_bmp_name) 
  1296. 		end 
  1297. 		unhide_weapons = true 
  1298. 		Hud_weapon_status.wpn_bmp_name = wpn_bmp_name 
  1299. 	end 
  1300.  
  1301. 	if dual_wield ~= Hud_weapon_status.dual_wield then 
  1302. 		vint_set_property(Hud_weapon_status.dual_wpn_icon_1_h, "visible", dual_wield) 
  1303. 		vint_set_property(Hud_weapon_status.dual_wpn_icon_2_h, "visible", dual_wield) 
  1304. 		vint_set_property(Hud_weapon_status.single_wpn_icon_h, "visible", not dual_wield) 
  1305. 		 
  1306. 		unhide_weapons = true 
  1307. 		Hud_weapon_status.dual_wield = dual_wield 
  1308. 	end 
  1309. 	 
  1310. 	-- Hide\Show grenade holster 
  1311. 	if grenade_bmp_name ~= Hud_weapon_status.grenade_bmp_name then 
  1312. 		if grenade_bmp_name ~= nil then 
  1313. 			--Set weapon bitmap... 
  1314. 			vint_set_property(Hud_weapon_status.grenade_icon_h, "image", grenade_bmp_name)		--Weapon Bitmap 
  1315. 			 
  1316. 			--Show objects... 
  1317. 			vint_set_property(Hud_weapon_status.grenade_icon_h, "visible", true)						--Weapon Bitmap 
  1318. 			vint_set_property(Hud_weapon_status.grenade_holster_h, "visible", true)					--Area for ammo... 
  1319. 			vint_set_property(Hud_weapon_status.grenade_holster_extra_h, "visible", true)			--Extra area for ammo 
  1320. 			vint_set_property(Hud_weapon_status.grenade_ammo_h, "visible", true)						--Ammo text 
  1321. 			 
  1322. 		else 
  1323. 			--Hide objects... 
  1324. 			vint_set_property(Hud_weapon_status.grenade_icon_h, "visible", false)					--Weapon Bitmap 
  1325. 			vint_set_property(Hud_weapon_status.grenade_holster_h, "visible", false)      		--Area for ammo... 
  1326. 			vint_set_property(Hud_weapon_status.grenade_holster_extra_h, "visible", false)		--Extra area for ammo 
  1327. 			vint_set_property(Hud_weapon_status.grenade_ammo_h, "visible", false)         		--Ammo text 
  1328. 		end 
  1329. 		 
  1330. 		unhide_weapons = true 
  1331. 		Hud_weapon_status.grenade_bmp_name = grenade_bmp_name 
  1332. 	end 
  1333. 	 
  1334. 	--Update Ammo Count 
  1335. 	local ammo_string = "" 
  1336. 	if no_ammo == false then 
  1337. 		if no_mag == true then 
  1338. 			if inf_ammo == false then 
  1339. 				if cont_fire == false then 
  1340. 					ammo_string = "" .. rdy_ammo + rsv_ammo 
  1341. 				else 
  1342. 					ammo_string = "" .. rdy_ammo + rsv_ammo 
  1343. 				end 
  1344. 			else 
  1345. 				ammo_string = "[image:ui_hud_base_smcirc_infinite]" 
  1346. 			end 
  1347. 		else 
  1348. 			if inf_ammo == false then 
  1349. 				if cont_fire == false then 
  1350. 					ammo_string = rdy_ammo .. "/" .. rsv_ammo 
  1351. 				else 
  1352. 					--debug_print("vint", "this should fire for grenade") 
  1353. 					ammo_string = floor(rdy_ammo / 100) .. "/" .. floor(rsv_ammo / 100) 
  1354. 				end 
  1355. 			else 
  1356. 				if cont_fire == false then 
  1357. 					ammo_string = rdy_ammo .. "/[image:ui_hud_base_smcirc_infinite]" 
  1358. 				else 
  1359. 					ammo_string = floor(rdy_ammo / 100) .. "/[image:ui_hud_base_smcirc_infinite]" 
  1360. 				end 
  1361. 			end 
  1362. 		end 
  1363. 	end 
  1364.  
  1365. 	-- 
  1366. 	local grenade_ammo_string = "" 
  1367. 	if grenade_ammo > 0 then 
  1368. 		if gnd_inf_ammo == false then 
  1369. 			grenade_ammo_string = grenade_ammo 
  1370. 		else 
  1371. 			grenade_ammo_string = "[format][scale:1.0][image:ui_hud_base_smcirc_infinite][/format]" 
  1372. 		end 
  1373. 	end	 
  1374. 	 
  1375. 	vint_set_property(Hud_weapon_status.weapon_ammo_txt_h, "text_tag", ammo_string) 
  1376. 	vint_set_property(Hud_weapon_status.sniper_ammo_txt_h, "text_tag", ammo_string) 
  1377. 	vint_set_property(Hud_weapon_status.grenade_ammo_txt_h, "text_tag", grenade_ammo_string) 
  1378. 	Hud_weapon_status.show_reticule = show_reticule 
  1379. 	 
  1380. 	if reloading then 
  1381. 		vint_set_property(Hud_weapon_status.sniper_reload_txt_h, "visible", true) 
  1382. 		lua_play_anim(Hud_weapon_status.sniper_ammo_anim, 0, HUD_DOC_HANDLE) 
  1383. 	else 
  1384. 		vint_set_property(Hud_weapon_status.sniper_reload_txt_h, "visible", false) 
  1385. 	end 
  1386.  
  1387. 	--Unhide weapons if the ammo string has changed... 
  1388. 	if ammo_string ~= Hud_weapon_status.ammo_string then 
  1389. 		unhide_weapons = true 
  1390. 		Hud_weapon_status.ammo_string = ammo_string 
  1391. 	end 
  1392.  
  1393. 	if grenade_ammo_string ~= Hud_weapon_status.grenade_ammo_string then 
  1394. 		unhide_weapons = true 
  1395. 		Hud_weapon_status.grenade_ammo_string = grenade_ammo_string 
  1396. 	end 
  1397. 		 
  1398. 	--Dim Weapon if not ready 
  1399. 	if wpn_rdy ~= Hud_weapon_status.wpn_rdy then 
  1400. 		if wpn_rdy == true then 
  1401. 			--Show Weapon 
  1402. 			vint_set_property(Hud_weapon_status.weapon_grp_h, "alpha", 1) 
  1403. 						 
  1404. 			--TODO: Show and hide reticule need to be pulled out of here and moved into a function that stacks the reticule visibility. 
  1405. 			 
  1406. 			if Hud_weapon_status.sniper_visible == false and Hud_weapon_status.show_reticule == true then 
  1407. 				--Show reticule 
  1408. 				vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", true) 
  1409. 			else 
  1410. 				vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", false) 
  1411. 			end 
  1412. 		else 
  1413. 			--Dim Weapon 
  1414. 			vint_set_property(Hud_weapon_status.weapon_grp_h, "alpha", 0.67) 
  1415. 			 
  1416. 			--Hide reticule 
  1417. 			vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", false) 
  1418. 		end 
  1419. 		 
  1420. 		-- do not un hide weapons on weapon ready change... (JMH 10/14/2010) 
  1421. 		-- unhide_weapons = true 
  1422. 		Hud_weapon_status.wpn_rdy = wpn_rdy 
  1423. 	else 
  1424. 		-- Make sure we hide the reticule if it changes but weapon ready doesn't. 
  1425. 		vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", show_reticule) 
  1426. 	end 
  1427. 	 
  1428. 	--If sniper rifle is on then show the sniper rifle and not the standard reticule 
  1429. 	if sniper_visible ~= Hud_weapon_status.sniper_visible then 
  1430. 		if sniper_visible == true then 
  1431. 			vint_set_property(Hud_reticules.elements.sniper_h, "visible", true) 
  1432. 			vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", false) 
  1433. 			hud_sniper_set_hints() 
  1434. 			Hud_sniper_hint_bar:set_visible(true) 
  1435. 		else 
  1436. 			vint_set_property(Hud_reticules.elements.sniper_h, "visible", false) 
  1437. 			vint_set_property(Hud_reticules.elements.reticule_base_h, "visible", true) 
  1438. 			Hud_sniper_hint_bar:set_visible(false) 
  1439. 		end 
  1440. 		Hud_weapon_status.sniper_visible = sniper_visible 
  1441. 	end	 
  1442.  
  1443. 	--Change reticules if we have a different weapon 
  1444. 	if wpn_name ~= Hud_reticules.status.wpn_name or reticule_highlight ~= Hud_reticules.status.highlight  then 
  1445. 		Hud_reticule_update(wpn_name, wpn_category, reticule_highlight) 
  1446. 	end 
  1447. 	 
  1448. 	--Process a hit every frame 
  1449. 	Hud_reticule_process_hit(bullet_hit) 
  1450.  
  1451. 	--Do Weapon Spread 
  1452. 	if wpn_spread ~= Hud_reticules.status.wpn_spread then 
  1453. 		hud_reticule_spread_update(wpn_spread, Hud_reticules.configs[Hud_reticules.status.config].spread) 
  1454. 	end 
  1455. 	 
  1456. 	--Update current selections in the radial menu 
  1457. 	if wpn_slot ~= Hud_weapon_radial.equipped_weapon_slot then 
  1458. 		Hud_weapon_radial:weapon_highlight(wpn_slot, true) 
  1459. 		--unhide_weapons = true 
  1460. 	end 
  1461. 	if grenade_slot ~= Hud_weapon_radial.equipped_grenade_slot then 
  1462. 		Hud_weapon_radial:weapon_highlight(grenade_slot, true) 
  1463. 		--unhide_weapons = true 
  1464. 	end 
  1465. 	 
  1466. 	if grenade_slot == 0 then 
  1467. 		Hud_weapon_radial.equipped_grenade_slot = 0 
  1468. 	end 
  1469. 	 
  1470. 	hud_reticule_overheat_update(overheat_pct, is_overheated) 
  1471. 	 
  1472. 	if unhide_weapons == true then 
  1473. 		--fade in... 
  1474. 		hud_weapon_fade_in() 
  1475. 	end	 
  1476.  
  1477. 	-- Genki Ethical weapon stuff... 
  1478. 	-- ( Moved 7/28/2011 JMH ) - (This was setup as a Duplicate dataitem ignoring all  
  1479. 	-- previous values except for this one not good considering this one gets called every time there is an ammo update) 
  1480.  
  1481. 	if genki_target ~= HUD_GENKI_NONE then 
  1482. 		vint_set_property(Hud_genki_images[HUD_GENKI_ETHICAL], "visible", true) 
  1483. 		vint_set_property(Hud_genki_images[HUD_GENKI_UNETHICAL], "visible", true) 
  1484. 		if genki_target == HUD_GENKI_ETHICAL then 
  1485. 			vint_set_property(Hud_genki_images[HUD_GENKI_UNETHICAL], "visible", false) 
  1486. 			vint_set_property(Hud_genki_anims[HUD_GENKI_UNETHICAL], "is_paused", true) 
  1487. 		elseif genki_target == HUD_GENKI_UNETHICAL then 
  1488. 			vint_set_property(Hud_genki_images[HUD_GENKI_ETHICAL], "visible", false) 
  1489. 			vint_set_property(Hud_genki_anims[HUD_GENKI_ETHICAL], "is_paused", true) 
  1490. 		end 
  1491. 		lua_play_anim(Hud_genki_anims[genki_target]) 
  1492. 	end 
  1493. end 
  1494.  
  1495. function hud_sniper_set_hints() 
  1496. 	local Hud_sniper_button_hints = { 
  1497. 		{CTRL_BUTTON_Y, "HUD_SNIPER_ZOOM_IN", game_get_key_name_for_action("CBA_OFC_ZOOM_IN")}, 
  1498. 		{CTRL_GAMEPLAY_BUTTON_A, "HUD_SNIPER_ZOOM_OUT", game_get_key_name_for_action("CBA_OFC_ZOOM_OUT")}, 
  1499. 	} 
  1500. 	Hud_sniper_hint_bar:set_hints(Hud_sniper_button_hints) 
  1501. 	local width, height = Hud_sniper_hint_bar:get_size() 
  1502. 	local Hud_sniper_hint_bar_x,Hud_sniper_hint_bar_y = Hud_sniper_hint_bar:get_property("anchor") 
  1503. 	local x = -1*(width*0.5) 
  1504. 	vint_set_property(Hud_sniper_hint_bar.handle, "anchor", x, Hud_sniper_hint_bar_y) 
  1505. 	vint_set_property(Hud_sniper_hint_bar.handle, "alpha", 1.0) 
  1506. 	Hud_sniper_hint_bar:enable_text_shadow(false) 
  1507. end 
  1508.  
  1509. function hud_vtol_set_hints() 
  1510.  
  1511. 	Hud_vtol_button_hints = { 
  1512. 		{CTRL_GAMEPLAY_BUTTON_B, "SWITCH_MODE", game_get_key_name_for_action("CBA_VDC_VTOL_TRANSITION")}, 
  1513. 	} 
  1514. 	Hud_sniper_hint_bar:set_hints(Hud_vtol_button_hints) 
  1515. 	local width, height = Hud_sniper_hint_bar:get_size() 
  1516. 	local Hud_sniper_hint_bar_x,Hud_sniper_hint_bar_y = Hud_sniper_hint_bar:get_property("anchor") 
  1517. 	local x = -1*(width*0.5) 
  1518. 	vint_set_property(Hud_sniper_hint_bar.handle, "anchor", x, Hud_sniper_hint_bar_y) 
  1519. 	vint_set_property(Hud_sniper_hint_bar.handle, "alpha", 0.67) 
  1520. 	Hud_sniper_hint_bar:enable_text_shadow(true) 
  1521. end 
  1522.  
  1523. function hud_weapon_fade_in() 
  1524. 	--Fade in only if we aren't hidden... 
  1525. 	if Hud_weapon_status.weapon_is_hidden == true then 
  1526. 		--Get alpha of weapon group so we don't fade in from nothing... if it is partially shown... 
  1527. 		local weapon_base_alpha = vint_get_property(Hud_weapon_status.weapon_base_h, "alpha") 
  1528. 		local weapon_fade_in_anim_h = vint_object_find("weapon_fade_in_anim") 
  1529. 		local weapon_fade_in_twn_h = vint_object_find("weapon_fade_in_twn", weapon_fade_in_anim_h) 
  1530. 		vint_set_property(weapon_fade_in_twn_h, "start_value", weapon_base_alpha) 
  1531.  
  1532. 		--Play the fade in anim... 
  1533. 		lua_play_anim(weapon_fade_in_anim_h) 
  1534. 		Hud_weapon_status.weapon_is_hidden = false 
  1535. 		 
  1536. 		 
  1537. 		local h = vint_object_find("weapon_fade_out_anim") 
  1538. 		vint_set_property(h, "is_paused", true) 
  1539. 	end 
  1540. 	 
  1541. 	lua_play_anim(vint_object_find("weapon_timer_anim")) 
  1542. end 
  1543. 	 
  1544.  
  1545. function hud_weapon_fade_out() 
  1546. 	lua_play_anim(vint_object_find("weapon_fade_out_anim")) 
  1547. 	Hud_weapon_status.weapon_is_hidden = true 
  1548. end 
  1549.  
  1550. function hud_weapon_show() 
  1551. 	--vint_set_property(Hud_weapon_status.weapon_base_h,"visible",true)	 
  1552. end 
  1553.  
  1554. function hud_weapon_hide() 
  1555. 	--vint_set_property(Hud_weapon_status.weapon_base_h,"visible",false)	 
  1556. end 
  1557.  
  1558. function hud_player_weapon_freq_change(di_h) 
  1559. 	local ammo_ready, reticle_highlight, cur_wpn_spread, fine_aim_transition, water_pressure, x_screen_coord, y_screen_coord, reticule_opacity = vint_dataitem_get(di_h) 
  1560. 	if fine_aim_transition ~= Hud_weapon_status.fine_aim_transition then 
  1561. 		hud_reticule_spread_update(cur_wpn_spread, Hud_reticules.configs[Hud_reticules.status.config].spread) 
  1562. 		if fine_aim_transition == nil then 
  1563. 			fine_aim_transition  = 0 
  1564. 		end 
  1565. 		 
  1566. 		--Fine aim minimap off... 
  1567. 		local tranny = 1.2 - fine_aim_transition 
  1568. 		tranny = limit(tranny, 0, 1) 
  1569. 		vint_set_property(Hud_map.base_grp_h, "alpha", tranny) 
  1570. 		Hud_weapon_status.fine_aim_transition = fine_aim_transition 
  1571. 	end 
  1572. 	 
  1573. 	--Update pressure 
  1574. 	hud_reticule_update_pressure(water_pressure) 
  1575. 		 
  1576. 	--Change x y screen coords of reticule 
  1577. 	hud_reticule_change_position(x_screen_coord, y_screen_coord) 
  1578. 	 
  1579. 	--Update x y coords of predator reticule... 
  1580. 	hud_predator_change_position(x_screen_coord, y_screen_coord) 
  1581. 	 
  1582. 	--Update Reticle Opacity 
  1583. 	hud_reticule_opacity_update(reticule_opacity) 
  1584. end 
  1585.  
  1586. function hud_player_satellite_weapon(di_h) 
  1587. 	-- TODO: finish 
  1588. end 
  1589.  
  1590.  
  1591. function hud_player_respect_change(di_h) 
  1592. 	--[[ 
  1593. 		respect_total		= total respect earned 
  1594. 		respect_needed		= respect % to reach next level 
  1595. 		respect_level		= current respect level 
  1596. 		show_upgrades		= should we show the "upgrade ready" indication 
  1597. 	]]-- 
  1598. 	local total_respect, respect_pct, respect_level, show_upgrades, force_show_respect = vint_dataitem_get(di_h) 
  1599. 	 
  1600. --	debug_print("vint", "total_respect" .. var_to_string(total_respect) .. "\n") 
  1601. --	debug_print("vint", "respect_pct" .. 	var_to_string(respect_pct) .. "\n") 
  1602. --	debug_print("vint", "respect_level" .. var_to_string(respect_level) .. "\n") 
  1603. --	debug_print("vint", "show_upgrades" .. var_to_string(show_upgrades) .. "\n") 
  1604. 	 
  1605. 	local respect_meter_show_upgrade = false	--Flag to determine if we want to actually show upgrades... 
  1606. 	if Hud_player_status.respect_show_upgrades ~= show_upgrades then 
  1607. 		-- Upgrade flag changed... so we need to do something... 
  1608. 		 
  1609. 		--We are done showing upgrades... 
  1610. 		if show_upgrades == false then 
  1611. 			--Have respect animate back to normal... 
  1612. 			Hud_respect:game_is_finished_showing_upgrades() 
  1613. 			--Reset Fade out timer. :) 
  1614. 			lua_play_anim(Hud_player_status.respect_timer_h) 
  1615. 		else 
  1616. 			--We actually need to show upgrades on for this update... 
  1617. 			respect_meter_show_upgrade = true 
  1618. 		end 
  1619. 		Hud_player_status.respect_show_upgrades = show_upgrades 
  1620. 	end 
  1621. 	 
  1622. 	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 
  1623. 		Hud_respect:update_respect(total_respect, respect_pct, respect_level, respect_meter_show_upgrade) 
  1624. 		Hud_player_status.total_respect = total_respect 
  1625. 		Hud_player_status.respect_pct = respect_pct 
  1626. 		Hud_player_status.respect_level = respect_level 
  1627. 	end 
  1628. 	 
  1629. 	-- force_show_respect causes respect to be shown.  no condition check is needed. 
  1630. 	if Hud_player_status.respect_is_hidden == true then 
  1631. 		lua_play_anim(vint_object_find("respect_fade_in_anim")) 
  1632. 		Hud_player_status.respect_is_hidden = false 
  1633. 	end 
  1634. 	 
  1635. 	lua_play_anim(Hud_player_status.respect_timer_h) 
  1636. end 
  1637.  
  1638. --Plays the animation which hides the respect bar... 
  1639. --This is triggered by a callback setup in the init() 
  1640. function hud_player_respect_hide() 
  1641. 	if Hud_player_status.respect_is_hidden ~= true then 
  1642. 		if Hud_respect:can_hide() then 
  1643. 			--Check if we can hide first... 
  1644. 			lua_play_anim(vint_object_find("respect_fade_out_anim")) 
  1645. 			Hud_player_status.respect_is_hidden = true 
  1646. 		else 
  1647. 			--If we can't hide then restart start the timer tween... 
  1648. 			lua_play_anim(Hud_player_status.respect_timer_h) 
  1649. 		end 
  1650. 	end 
  1651. end 
  1652.  
  1653. -- Plays the animation which hides the respect bar... 
  1654. -- Hides the respect but immediatly... triggered by flashpoint complete.. 
  1655. function hud_player_respect_force_hide() 
  1656. 	if Hud_respect:can_hide() then 
  1657. 		--Check if we can hide first... 
  1658. 		Hud_respect:set_alpha(0) 
  1659. 		Hud_player_status.respect_is_hidden = true 
  1660. 	else 
  1661. 		--If we can't hide then restart start the timer tween... 
  1662. 		lua_play_anim(Hud_player_status.respect_timer_h) 
  1663. 	end 
  1664. end 
  1665.  
  1666. function hud_player_followers_change(di_h) 
  1667. 	local slot, head_img_name, hlth_pct, revive_time, slot_visible = vint_dataitem_get(di_h) 
  1668.  
  1669. 	--No slots other than 1 to 3 allowed. 
  1670. 	if slot < 1 or slot > 3 then 
  1671. 		return 
  1672. 	end 
  1673. 	 
  1674. 	--Show or hide slot 
  1675. 	if slot_visible ~= Hud_followers.slot_objects[slot].visible then 
  1676. 		vint_set_property(Hud_followers.slot_objects[slot].group_h, "visible", slot_visible) 
  1677. 		Hud_followers.slot_objects[slot].visible = slot_visible 
  1678. 	end 
  1679. 	 
  1680. 	local data = Hud_followers.follower_data[slot] 
  1681. 	local objects = Hud_followers.slot_objects[slot] 
  1682. 	 
  1683. 	if head_img_name ~= data.head_img_name then 
  1684. 		if head_img_name == nil then 
  1685. 			--No homie head 
  1686. 			--hide the icon in the homie slot by playing the close animation 
  1687. 			vint_set_property(objects.anim_0, "is_paused", true) 
  1688. 			 
  1689. 			--match alpha level of our tween to current value. 
  1690. 			local alpha_level = vint_get_property(objects.head_img_h, "alpha") 
  1691. 			local twn_h = vint_object_find("follow_head_alpha_tween_1", objects.anim_1) 
  1692. 			vint_set_property(twn_h, "start_value", alpha_level) 
  1693. 			 
  1694. 			--Play fade out anim... 
  1695. 			lua_play_anim(objects.anim_1, 0) 
  1696. 			 
  1697. 			--Be sure the timer is hidden too 
  1698. 			vint_set_property(objects.revive_timer_h, "visible", false) 
  1699. 		else 
  1700. 			if data.head_img_name == nil then 
  1701. 				vint_set_property(objects.anim_1, "is_paused", true) 
  1702. 				lua_play_anim(objects.anim_0, 0) 
  1703. 			end 
  1704. 			 
  1705. 			--Reset the head image  
  1706. 			vint_set_property(objects.head_img_h, "image", head_img_name) 
  1707. 			 
  1708. 			end 
  1709. 		data.head_img_name = head_img_name 
  1710. 	end 
  1711.  
  1712. 	--take damage only if health changed.. 
  1713. 	if hlth_pct ~= data.hlth_pct then 
  1714. 		--make sure we've inited already... 
  1715. 		if data.hlth_pct ~= nil then 
  1716. 			local target_alpha = 1 
  1717. 			if hlth_pct < .33 then 
  1718. 				target_alpha = hlth_pct + .33 
  1719. 				if hlth_pct == 0 then 
  1720. 					target_alpha = 0.5 
  1721. 				end 
  1722. 			end	 
  1723. 			vint_set_property(objects.head_img_h, "alpha", target_alpha ) 
  1724. 		end 
  1725. 		--Store data... 
  1726. 		data.hlth_pct = hlth_pct 
  1727. 	end 
  1728. 	 
  1729. 	--Revives (This is the counter that shows up over the homie heads) 
  1730. 	revive_time = floor(revive_time) 
  1731. 	if revive_time ~= data.revive_time then 
  1732. 		if revive_time == 0 and data.revive_time ~= 0 then 
  1733. 			vint_set_property(objects.revive_timer_h, "visible", false) 
  1734. 			vint_set_property(vint_object_find("follow_rev_anim"),"is_paused", true) 
  1735. 		elseif revive_time ~= 0 and data.revive_time == 0 then 
  1736. 			vint_set_property(objects.revive_timer_h, "visible", true) 
  1737. 			--vint_set_property(vint_object_find("follow_rev_anim"),"is_paused", false) 
  1738. 			lua_play_anim(vint_object_find("follow_rev_anim")) 
  1739. 		end 
  1740. 		if revive_time ~= 0 then 
  1741. 			lua_play_anim(vint_object_find("follow_rev_anim")) 
  1742. 		end 
  1743. 		--Update Revive Time 
  1744. 		vint_set_property(objects.revive_timer_h, "text_tag", revive_time) 
  1745. 		data.revive_time = revive_time 
  1746. 	end 
  1747. end 
  1748.  
  1749. function hud_balance_meter_change(di_h) 
  1750.  
  1751. 	--	active		bool		is the meter active? 
  1752. 	--	position		float		-1 to 1 indicating the position on the meter	 
  1753. 	local active, position = vint_dataitem_get(di_h) 
  1754. 	local force_update = false 
  1755. 	 
  1756.  
  1757. 	 
  1758. --	debug_print("vint", "active: " .. var_to_string(active) .. "| position: " .. position .. "\n") 
  1759. 	 
  1760. 	--Update visibility 
  1761. 	if Hud_balance_status.active ~= active then 
  1762. 		if active == true then 
  1763. 			vint_set_property(Hud_balance_status.balance_grp_h, "visible", true) 
  1764. 			 
  1765. 			--Fade out left stick after a little while... 
  1766. 			lua_play_anim(Hud_balance_status.fade_out_anim_h) 
  1767. 		else 
  1768. 			vint_set_property(Hud_balance_status.balance_grp_h, "visible", false) 
  1769. 		end 
  1770. 		force_update = true 
  1771. 		Hud_balance_status.active = active 
  1772. 	end 
  1773. 	 
  1774. 	--Update Position and Color 
  1775. 	if Hud_balance_status.position ~= position or force_update == true then 
  1776. 		 
  1777. 		--Calculate Angle 
  1778. 		local angle = position * Hud_balance_status.max_angle 
  1779. 		 
  1780. 		--Calculate Color 
  1781. 		local color_r, color_g, color_b 
  1782. 		local p_val = abs(position) 
  1783. 		 
  1784. 		 
  1785. 		 
  1786. 		color_r = Hud_balance_status.color_base[1] - p_val * (Hud_balance_status.color_base[1] - Hud_balance_status.color_alarm[1]) 
  1787. 		color_g = Hud_balance_status.color_base[2] - p_val * (Hud_balance_status.color_base[2] - Hud_balance_status.color_alarm[2]) 
  1788. 		color_b = Hud_balance_status.color_base[3] - p_val * (Hud_balance_status.color_base[3] - Hud_balance_status.color_alarm[3]) 
  1789. 			 
  1790. 		--Set Props 
  1791. 		vint_set_property(Hud_balance_status.arrow_image_h, "rotation", angle) 
  1792. 		vint_set_property(Hud_balance_status.base_grp_h, "tint", color_r, color_g, color_b) 
  1793. 		 
  1794. 		Hud_balance_status.position = position  
  1795. 	end 
  1796. end 
  1797.  
  1798. --Health Vignette 
  1799. function hud_health_screen_fade(target_alpha) 
  1800. 	if Hud_player_status.health_screen_is_fading == true then 
  1801. 		--screen is already fading... just update the end alpha... 
  1802. 		vint_set_property(Hud_vignettes.health.fade_twn_h, "end_value", target_alpha) 
  1803. 	else 
  1804. 		--screen isnot fading so we need to restart the animation... 
  1805. 		local current_alpha = vint_get_property(Hud_vignettes.health.grp_h, "alpha") 
  1806. 		vint_set_property(Hud_vignettes.health.fade_twn_h, "start_value", current_alpha) 
  1807. 		vint_set_property(Hud_vignettes.health.fade_twn_h, "end_value", target_alpha) 
  1808. 		lua_play_anim(Hud_vignettes.health.fade_anim_h, 0) 
  1809. 		Hud_player_status.health_screen_is_fading = true 
  1810. 	end 
  1811. end 
  1812.  
  1813. function hud_health_screen_fade_complete() 
  1814. 	Hud_player_status.health_screen_is_fading = false 
  1815. end 
  1816.  
  1817.  
  1818. --======================================================== 
  1819. --HUD Hits 
  1820. --Things around the reticule 
  1821. --======================================================== 
  1822. function Hud_hit_add(di_h) 
  1823. 	local hit_index = di_h 
  1824. 	local direction, strength = vint_dataitem_get(di_h) 
  1825. 	local hit_bmp_h, hit_anim_h, hit_twn_h, fade_time, stick_time 
  1826.  
  1827. 	--Check if major/minor hit 
  1828. 	if strength > .3 then 
  1829. 		hit_bmp_h = vint_object_clone(Hud_hit_elements.major_h) 
  1830. 		stick_time = .5 
  1831. 		fade_time = .5 
  1832. 	else 
  1833. 		hit_bmp_h = vint_object_clone(Hud_hit_elements.minor_h) 
  1834. 		stick_time = .25 
  1835. 		fade_time = .25 
  1836. 	end 
  1837. 	 
  1838. 	vint_set_property(hit_bmp_h, "visible", true) 
  1839. 	vint_set_property(hit_bmp_h, "rotation", direction) 
  1840. 	 
  1841. 	--Tween Fade out, Set Callback 
  1842. 	hit_anim_h = vint_object_clone(Hud_hit_elements.anim_h)	 
  1843. 	hit_twn_h =  vint_object_find("hit_twn", hit_anim_h) 
  1844. 	vint_set_property(hit_twn_h, "target_handle", hit_bmp_h) 
  1845. 	vint_set_property(hit_twn_h, "duration", fade_time) 
  1846. 	vint_set_property(hit_twn_h, "end_event", "hud_hit_fade_end") 
  1847. 	 
  1848. 	lua_play_anim(hit_anim_h, stick_time) 
  1849. 	 
  1850. 	--Store Reticule Information for further processing 
  1851. 	Reticule_hits[hit_index] = { 
  1852. 		hit_bmp_h = hit_bmp_h, 
  1853. 		hit_twn_h = hit_twn_h, 
  1854. 		hit_anim_h = hit_anim_h, 
  1855. 		direction = direction, 
  1856. 		strength = strength, 
  1857. 	} 
  1858. end 
  1859.  
  1860. function hud_hit_fade_end(twn_h, event_name) 
  1861. 	--Clean up reticule hits 
  1862. 	for index, value in pairs(Reticule_hits) do 
  1863. 		if value.hit_twn_h == twn_h then 
  1864. 			vint_object_destroy(value.hit_anim_h) 
  1865. 			vint_object_destroy(value.hit_twn_h) 
  1866. 			vint_object_destroy(value.hit_bmp_h) 
  1867. 			Reticule_hits[index] = nil 
  1868. 		end 
  1869. 	end 
  1870. end 
  1871.  
  1872. function hud_hits_updates_pos(x_screen_coord, y_screen_coord) 
  1873. 	--y screen coordinate 
  1874. 	local x, y = vint_get_property(Hud_hit_elements.main_h, "anchor") 
  1875. 	vint_set_property(Hud_hit_elements.main_h, "anchor", x_screen_coord, y_screen_coord) 
  1876. end 
  1877.  
  1878. --Clears all indicators if called, designed to be called via C++ 
  1879. function hud_hit_clear_all() 
  1880. 	for index, value in pairs(Reticule_hits) do 
  1881. 		vint_object_destroy(value.hit_anim_h) 
  1882. 		vint_object_destroy(value.hit_twn_h) 
  1883. 		vint_object_destroy(value.hit_bmp_h) 
  1884. 	end 
  1885. 	Reticule_hits = {} 
  1886. end 
  1887.  
  1888.  
  1889. --#####################################################################  
  1890. --Showing/Hiding the hud 
  1891. --##################################################################### 
  1892.  
  1893. local HUD_ELEM_GSI = 0 
  1894.  
  1895. Hud_elements = { 
  1896. 	[0] = { 	-- HUD_ELEM_GSI 
  1897. 		target_doc = nil, 
  1898. 		grp_name = "base_gsi",				 
  1899. 	}, 
  1900. 	[1] = { 	-- HUD_ELEM_MINIMAP 
  1901. 		target_doc = nil, 
  1902. 		grp_name = "base_mini_map",	 
  1903. 	}, 
  1904. 	[2] = {	-- HUD_ELEM_RETICLE 
  1905. 		target_doc = nil, 
  1906. 		grp_name = "base_reticle",				 
  1907. 	}, 
  1908. 	[3] = {	-- HUD_ELEM_HIT_INDICATORS 
  1909. 		target_doc = nil, 
  1910. 		grp_name = "base_reticle_hits", 
  1911. 	}, 
  1912. 	[4] = {	-- HUD_ELEM_WEAPONS 
  1913. 		target_doc = nil, 
  1914. 		grp_name = "base_weapons", 
  1915. 	}, 
  1916. 	[5] = {	-- HUD_ELEM_CASH_RESPECT_HOMEY 
  1917. 		target_doc = nil, 
  1918. 		grp_name = "base_cash_respect_homey",  
  1919. 	}, 
  1920. 	[6] = {	--	HUD_ELEM_WEAPON_SWAP_MESSAGE 
  1921. 		target_doc = nil, 
  1922. 		grp_name = "base_weapon_swap_message", 
  1923. 	}, 
  1924. 	[7] = {	-- HUD_ELEM_RADIO_STATION 
  1925. 		target_doc = nil, 
  1926. 		grp_name = "base_radio_station",		 
  1927. 	}, 
  1928. 	[8] = {	-- HUD_ELEM_VEHICLE_NAME 
  1929. 		target_doc = nil, 
  1930. 		grp_name = "base_vehicle_name", 
  1931. 	}, 
  1932. 	[9] = { -- HUD_ELEM_DIVERSIONS 
  1933. 		target_doc = "hud_diversion", 
  1934. 		grp_name = nil, 
  1935. 	}, 
  1936. 	[10] = { -- HUD_ELEM_MESSAGES, 
  1937. 		target_doc = "hud_msg", 
  1938. 		grp_name = "messages_grp", 
  1939. 	}, 
  1940. 	[11] = { -- HUD_ELEM_TUTORIAL_HELP, 
  1941. 		target_doc = "tutorial", 
  1942. 		grp_name = "tutorial_base_grp", 
  1943. 	}, 
  1944. 	[12] = { -- HUD_ELEM_FULL_SCREEN_EFFECT 
  1945. 		target_doc = nil, 
  1946. 		grp_name = "base_full_screen_effect", 
  1947. 	}, 
  1948. 	[13] = { -- HUD_ELEM_SUBTITLES 
  1949. 		target_doc = "hud_msg", 
  1950. 		grp_name = "subtitles_grp", 
  1951. 	}, 
  1952. 	[14] = { -- HUD_ELEM_OI 
  1953. 		target_doc = "object_indicator", 
  1954. 		grp_name = "oi_base_grp",		 
  1955. 	}, 
  1956. } 
  1957.  
  1958. Hud_element_tweens = {} 
  1959.  
  1960. -- hud fade parameters 
  1961. -- transparency 
  1962. local HUD_FADE_HIDDEN 		= 0 
  1963. local HUD_FADE_TRANSPARENT = 1 
  1964. local HUD_FADE_VISIBLE 		= 2 
  1965. -- fade duration 
  1966. local HUD_FADE_DURATION_FADE 			= 0 
  1967. local HUD_FADE_DURATION_IMMEDIATE 	= 1 
  1968.  
  1969. local Hud_tween_fade_duration = 0.25 
  1970.  
  1971. --Fades a particular element 
  1972. function hud_element_fade(element_id, fade, duration) 
  1973. 	if duration == nil then 
  1974. 		duration = HUD_FADE_DURATION_FADE 
  1975. 	end 
  1976. 	--fade: 0 = hidden,	1 = transparent, 2 = visible 
  1977. 	local element_group 
  1978. 	local target_document_name 
  1979. 	local grp_name 
  1980. 	 
  1981. 	if element_id == HUD_ELEM_GSI and horde_mode_is_active() then 
  1982. 		target_document_name = "hud_whored" 
  1983. 		grp_name = "base_gsi" 
  1984. 	else  
  1985. 		target_document_name = Hud_elements[element_id].target_doc 
  1986. 		grp_name = Hud_elements[element_id].grp_name 
  1987. 	end 
  1988. 	 
  1989. 	--Set alpha based on fade 
  1990. 	local target_alpha 
  1991. 	if fade == HUD_FADE_HIDDEN then 
  1992. 		target_alpha = 0 
  1993. 	elseif fade == HUD_FADE_TRANSPARENT then 
  1994. 		target_alpha = .35 
  1995. 	else 
  1996. 		target_alpha = 1 
  1997. 	end 
  1998.  
  1999. 	-- Set the actual duration 
  2000. 	local actual_duration 
  2001. 	if (duration == HUD_FADE_DURATION_FADE) then 
  2002. 		actual_duration = Hud_tween_fade_duration 
  2003. 	else  
  2004. 		actual_duration = 0 
  2005. 	end 
  2006. 	 
  2007. 	local grp_h, current_alpha, twn_h 
  2008. 	 
  2009. 	--Figure out which document the elements exist in 
  2010. 	local target_doc_h = HUD_DOC_HANDLE 
  2011. 	if target_document_name ~= nil then 
  2012. 		target_doc_h = vint_document_find(target_document_name) 
  2013. 		if target_doc_h == 0 then 
  2014. 			--This document is not loaded for whatever reason exit 
  2015. 			return 
  2016. 		end 
  2017. 	end 
  2018.  
  2019. 	if grp_name ~= nil then 
  2020. 		--get the group object to fade 
  2021. 		grp_h = vint_object_find(grp_name, nil, target_doc_h) 
  2022. 	else  
  2023. 		grp_h = vint_object_find("safe_frame", nil, target_doc_h) 
  2024. 	end 
  2025. 			 
  2026. 	--Verify that we aren't already fading something 
  2027. 	for idx, val in pairs(Hud_element_tweens) do 
  2028. 		if grp_h == val.grp_h then 
  2029. 			--tween exist so delete the tween 
  2030. 			vint_object_destroy(idx) 
  2031. 			Hud_element_tweens[idx] = nil 
  2032. 		end 
  2033. 	end 
  2034. 			 
  2035. 	--Get Current Alpha of object 
  2036. 	current_alpha = vint_get_property(grp_h, "alpha") 
  2037. 			 
  2038. 	local hud_root_animation =  vint_object_find("root_animation", nil, target_doc_h) 
  2039. 			 
  2040. 	--Create Tween and set values 
  2041. 	twn_h = vint_object_create("hud_fade_tweens", "tween", hud_root_animation, target_doc_h) 
  2042.  
  2043. 	vint_set_property(twn_h, "duration", actual_duration)	--Fade time 
  2044. 	vint_set_property(twn_h, "target_handle", grp_h) 
  2045. 	vint_set_property(twn_h, "target_property", "alpha") 
  2046. 	vint_set_property(twn_h, "start_value", current_alpha) 
  2047. 	vint_set_property(twn_h, "end_value", target_alpha) 
  2048. 	vint_set_property(twn_h, "start_time",	vint_get_time_index(target_doc_h)) 
  2049. 	vint_set_property(twn_h, "is_paused", false) 
  2050. 			 
  2051. 	--Set callback 
  2052. 	vint_set_property(twn_h, "end_event", "hud_element_fade_end") 
  2053. 		 
  2054. 	--Store for cleanup 
  2055. 	Hud_element_tweens[twn_h] = { 
  2056. 		grp_h = grp_h 
  2057. 	} 
  2058. end 
  2059.  
  2060. function hud_element_fade_end(tween_h, event_name) 
  2061. 	--Delete all fade tweens and references 
  2062. 	vint_object_destroy(tween_h) 
  2063. 	Hud_element_tweens[tween_h] = nil 
  2064. end 
  2065.  
  2066. ---------[ BUSTED/SMOKED ]--------- 
  2067.  
  2068. function hud_busted_init() 
  2069. 	Hud_smoked_busted.handles = {} 
  2070. 	 
  2071. 	Hud_smoked_busted.handles.grp = vint_object_find("smoked_busted") 
  2072. 	vint_set_property(Hud_smoked_busted.handles.grp, "visible", false) 
  2073. 	 
  2074. 	--Fade In animations 
  2075. 	Hud_smoked_busted.handles.fade_in_anim = vint_object_find("sb_fade_in") 
  2076. 	vint_set_property(Hud_smoked_busted.handles.fade_in_anim , "is_paused", true) 
  2077. end 
  2078.  
  2079. function hud_busted_complete() 
  2080. end 
  2081.  
  2082. function hud_busted_fade_in(smoked, delay, fade_time) 
  2083. 	local msg, effect, color 
  2084. 	if smoked == true then 
  2085. 		msg = "GAMEPLAY_SMOKED" 
  2086. 		effect = "smoked" 
  2087. 		color = {r = .9, g = .9, b = .9} 
  2088. 	else 
  2089. 		msg = "GAMEPLAY_BUSTED" 
  2090. 		effect = "busted" 
  2091. 		color = {r = .9, g = .9, b = .9} 
  2092. 	end 
  2093. 	 
  2094. 	--Show Smoked busted text 
  2095. 	vint_set_property(Hud_smoked_busted.handles.grp, "visible", true) 
  2096. 	vint_set_property(Hud_smoked_busted.handles.grp, "alpha", 0) 
  2097. 	vint_set_property(Hud_smoked_busted.handles.grp, "tint", color.r, color.g, color.b) 
  2098. 	 
  2099. 	--Busted/Smoked text fade in 
  2100. 	--JM: Removing "You're Smoked" and "Busted" text. 
  2101. 	vint_set_property(vint_object_find("sb_text"), "text_tag", " ") --msg) 
  2102. 	lua_play_anim(Hud_smoked_busted.handles.fade_in_anim) 
  2103. 	 
  2104. 	--Start Interface effect 
  2105. 	game_interface_effect_begin(effect, 1, .5, true) 
  2106. end 
  2107.  
  2108. function hud_effect_smoked() 
  2109. 	game_interface_effect_begin("smoked", 1, 1, true) 
  2110. end 
  2111.  
  2112. function hud_effect_busted() 
  2113. 	game_interface_effect_begin("busted", 1, 1, true) 
  2114. end 
  2115.  
  2116. function hud_effect_pause() 
  2117. 	game_interface_effect_begin("pause", 1, 1) 
  2118. end 
  2119.  
  2120. function hud_effect_end() 
  2121. 	game_interface_effect_end() 
  2122. end 
  2123.  
  2124. function hud_player_reset_complete() 
  2125. 	--Reset the busted state 
  2126. 	game_interface_effect_end(0) 
  2127. 	--Hide Smoked busted text 
  2128. 	vint_set_property(Hud_smoked_busted.handles.grp, "visible", false) 
  2129. end 
  2130.  
  2131. ---------[ COLLECTION MESSAGES ]--------- 
  2132.  
  2133. --Hud_collection_msgs = { num_msgs = 0 } 
  2134.  
  2135. -- you can also call this to clear any existing messages 
  2136. function hud_collection_msg_init() 
  2137. --[[ 
  2138. 	Hud_collection_msgs = { num_msgs = 0 } 
  2139. 	vint_set_property(vint_object_find("collection_msg"), "alpha", 0) 
  2140. 	vint_set_property(vint_object_find("collection_msg"), "visible", true) 
  2141. 	vint_set_property(vint_object_find("collection_anim"), "is_paused", true) 
  2142. 	vint_set_property(vint_object_find("collection_msg_alpha_twn_2"), "end_event", "hud_collection_msg_end") 
  2143. 	]] 
  2144. end 
  2145.  
  2146. function hud_collection_msg_show(m) 
  2147. --[[ 
  2148. 	local header_text_h = vint_object_find("collection_header_text") 
  2149. 	local body_text_h = vint_object_find("collection_body_text") 
  2150. 	 
  2151. 	vint_set_property(header_text_h , "text_tag", m.header) 
  2152. 	 
  2153. 	local y_ornate_offset = 0 
  2154. 	if m.body ~= nil then 
  2155. 		vint_set_property(body_text_h, "text_tag", m.body) 
  2156. 		vint_set_property(body_text_h, "visible", true) 
  2157. 	else 
  2158. 		vint_set_property(body_text_h, "visible", false)	 
  2159. 		--No body text so adjust the ornate 
  2160. 		y_ornate_offset = -10 
  2161. 	end 
  2162.  
  2163. 	-- Hide the stuff about getting smoked like Thanksgiving turkey 
  2164. 	vint_set_property(Hud_smoked_busted.handles.fade_in_anim , "is_paused", true) 
  2165. 	vint_set_property(Hud_smoked_busted.handles.grp, "visible", false) 
  2166. 	vint_set_property(Hud_smoked_busted.handles.grp, "alpha", 0) 
  2167. 	 
  2168. 	lua_play_anim(vint_object_find("collection_anim")) 
  2169.  
  2170. 	if m.audio >= 0 then 
  2171. 		game_UI_audio_play(m.audio) 
  2172. 	end 
  2173. 	]] 
  2174. end 
  2175.  
  2176. function hud_collection_msg_end() 
  2177. --[[ 
  2178. 	if Hud_collection_msgs.num_msgs > 0 then 
  2179. 		-- remove element 0 and push others up 
  2180. 		for i = 0, Hud_collection_msgs.num_msgs - 2 do 
  2181. 			Hud_collection_msgs[i] = Hud_collection_msgs[i + 1] 
  2182. 		end 
  2183. 		 
  2184. 		Hud_collection_msgs[Hud_collection_msgs.num_msgs - 1] = nil 
  2185. 		Hud_collection_msgs.num_msgs = Hud_collection_msgs.num_msgs - 1 
  2186. 		 
  2187. 		if Hud_collection_msgs.num_msgs > 0 then 
  2188. 			hud_collection_msg_show(Hud_collection_msgs[0]) 
  2189. 		end 
  2190. 	end 
  2191. 	]] 
  2192. end 
  2193.  
  2194. function hud_collection_msg_new(header, body, audio, win_status) 
  2195. --[[ 
  2196. 	--TODO: ADD Header/Body/Win Status support (the body can be nil) 
  2197.  
  2198. 	local m = { header = header, body = body, win_status = win_status, audio = audio } 
  2199. 	Hud_collection_msgs[Hud_collection_msgs.num_msgs] = m 
  2200. 	Hud_collection_msgs.num_msgs = Hud_collection_msgs.num_msgs + 1 
  2201.  
  2202. 	if Hud_collection_msgs.num_msgs == 1 then 
  2203. 		hud_collection_msg_show(m) 
  2204. 	end 
  2205. 	]] 
  2206. end 
  2207.  
  2208.  
  2209. --=================================================== 
  2210. --Cruise Control 
  2211. --=================================================== 
  2212. function hud_cruise_control_update(is_active) 
  2213. 	if is_active ~= Hud_player_status.cruise_control_active then 
  2214. 		if is_active == true then 
  2215. 			--Show Cruise Control Status and let it fade with the animation. 
  2216. 			vint_set_property(Hud_player_status.cruise_control_h, "visible", true) 
  2217. 			vint_set_property(Hud_player_status.cruise_control_h, "alpha", .8) 
  2218. 			lua_play_anim(Hud_player_status.cruise_control_anim, 0) 
  2219.  
  2220. 			Hud_cruise_control_hint_data = { 
  2221. 				{CTRL_BUTTON_DPAD_DOWN, "HUD_CRUISE_CONTROL_NO_BUTTON", game_get_key_name_for_action("CBA_VDC_CRUISE_CONTROL_B")}, 
  2222. 			} 
  2223. 			Hud_player_status.cruise_control_obj:set_hints(Hud_cruise_control_hint_data) 
  2224. 			local width, height = Hud_player_status.cruise_control_obj:get_size() 
  2225. 			local x, y = vint_get_property(Hud_player_status.cruise_control_obj.handle, "anchor") 
  2226. 			vint_set_property(Hud_player_status.cruise_control_obj.handle, "anchor",  - (width * 0.5), y) 
  2227. 		else 
  2228. 			--Hide status 
  2229. 			vint_set_property(Hud_player_status.cruise_control_h, "visible", false) 
  2230. 		end 
  2231. 	Hud_player_status.cruise_control_active = is_active 
  2232. 	end 
  2233. end 
  2234.  
  2235. function hud_cruise_control_update_pos(x_pos, y_pos) 
  2236. 	local x, y = vint_get_property(Hud_player_status.cruise_control_h, "anchor") 
  2237. 	vint_set_property(Hud_player_status.cruise_control_h, "anchor", x_pos, y_pos) 
  2238. end 
  2239.  
  2240.  
  2241. --=================================================== 
  2242. --Player Lockon 
  2243. --=================================================== 
  2244. function hud_player_lockon_update(di_h) 
  2245. 	local x, y, width, rotation, is_locked, is_visible = vint_dataitem_get(di_h) 
  2246.  
  2247. 	vint_set_property(Hud_lockon.lock_h, "anchor", x, y) 
  2248. 	vint_set_property(Hud_lockon.lock_txt_grp_h, "anchor", x, y) 
  2249. 	 
  2250. 	if is_visible == true then 
  2251. 		--Scale 
  2252. 		local scale = width/100 
  2253. 		local scale_hor = width/100--Hud_lockon.base_pixel_size_hor 
  2254. 		local scale_vert = width/100--Hud_lockon.base_pixel_size_vert 
  2255. 		 
  2256. 		vint_set_property(Hud_lockon.lock_h, "anchor", x, y) 
  2257. 		vint_set_property(Hud_lockon.lock_h, "scale", scale, scale) 
  2258. 		vint_set_property(Hud_lockon.lock_h, "rotation", rotation) 
  2259. 		 
  2260. 		vint_set_property(Hud_lockon.lock_txt_grp_h, "scale", scale, scale) 
  2261. 			 
  2262. 		local lock_vert_height = Hud_lockon.lock_base_vert_height / scale_vert 
  2263. 		local lock_hor_height = Hud_lockon.lock_base_hor_height / scale_hor 
  2264. 		 
  2265. 		--Rescale Innards 
  2266. 		vint_set_property(Hud_lockon.lock1_h, "scale",Hud_lockon.lock_base_vert_width, lock_vert_height) 
  2267. 		vint_set_property(Hud_lockon.lock2_h, "scale", Hud_lockon.lock_base_hor_width, lock_hor_height) 
  2268. 		vint_set_property(Hud_lockon.lock3_h, "scale", Hud_lockon.lock_base_hor_width, lock_hor_height) 
  2269. 		vint_set_property(Hud_lockon.lock4_h, "scale", Hud_lockon.lock_base_vert_width, lock_vert_height) 
  2270. 		 
  2271. 		if is_locked then 
  2272. 			vint_set_property(Hud_lockon.lock_lock_h,"visible",true) 
  2273. 			vint_set_property(Hud_lockon.lock_spinner_h,"visible",false) 
  2274. 			vint_set_property(Hud_lockon.lock_text_h,"text_tag","HUD_LOCKON_TARGET_LOCKED") 
  2275. 		else 
  2276. 			vint_set_property(Hud_lockon.lock_lock_h,"visible",false) 
  2277. 			vint_set_property(Hud_lockon.lock_spinner_h,"visible",true) 
  2278. 			vint_set_property(Hud_lockon.lock_text_h,"text_tag","HUD_LOCKON_SCANNING") 
  2279. 		end 
  2280. 		--Tint lockon 
  2281. 		local color 
  2282. 		if is_locked == true then 
  2283. 			color = Hud_lockon.color_locked 
  2284. 		else 
  2285. 			color = Hud_lockon.color_unlocked	 
  2286. 		end 
  2287. 		vint_set_property(Hud_lockon.lock_h, "tint", color.r, color.g, color.b) 
  2288. 		vint_set_property(Hud_lockon.lock_txt_grp_h, "tint", color.r, color.g, color.b) 
  2289. 		 
  2290. 		--Show lockon 
  2291. 		vint_set_property(Hud_lockon.lock_h, "visible", true) 
  2292. 		vint_set_property(Hud_lockon.lock_txt_grp_h, "visible", true) 
  2293. 	else 
  2294. 		vint_set_property(Hud_lockon.lock_h, "visible", false) 
  2295. 		vint_set_property(Hud_lockon.lock_txt_grp_h, "visible", false) 
  2296. 	end 
  2297. end 
  2298.  
  2299. function hud_cheat_icon_update(di_h) 
  2300. 	--	active	bool	is the cheat active? 
  2301. 	--	icon		int	0: INVALID, 1: Inverted controls, 2: Size reduction, 3: Lag, 4: Lame weapon, 5: Slow 
  2302. 	local active, icon = vint_dataitem_get(di_h) 
  2303. 	 
  2304. 	vint_set_property(Hud_cheat_elements.image_grp_h, "visible", active) 
  2305. 	vint_set_property(Hud_cheat_elements.image_h, "image", Hud_cheat_elements.images[icon]) 
  2306. 	vint_set_property(Hud_cheat_elements.image_2_h, "image", Hud_cheat_elements.images[icon]) 
  2307. 	if active then 
  2308. 		lua_play_anim(Hud_cheat_elements.image_anim_h, 0, HUD_DOC_HANDLE) 
  2309. 	end 
  2310. end 
  2311.  
  2312. ------------------------------------------------------------------------------- 
  2313. -- Updates and Plays the Icon Objective Over the minimap. 
  2314. ------------------------------------------------------------------------------- 
  2315. function hud_map_objective_icon(di_h) 
  2316. 	 
  2317. 	--[[ 
  2318. 			Making it a data vacuum. Be advised. 
  2319. 	 
  2320. 	local objective_enum, count = vint_dataitem_get(di_h) 
  2321. 	local icon_name 
  2322.  
  2323. 	if objective_enum == INVALID_HANDLE then 
  2324. 		return 
  2325. 	end 
  2326. 	 
  2327. 	if HUD_MAP_OBJECTIVE_ICONS[objective_enum] ~= nil then 
  2328. 		icon_name = HUD_MAP_OBJECTIVE_ICONS[objective_enum] 
  2329. 	else 
  2330. 		icon_name = HUD_MAP_OBJECTIVE_ICONS[HUD_KILL_ICON] 
  2331. 	end 
  2332. 	 
  2333. 	local map_bmp = vint_object_find("map_objective_icon") 
  2334. 	vint_set_property(map_bmp, "image", icon_name) 
  2335. 	vint_set_property(map_bmp, "visible", true) 
  2336. 	 
  2337. 	local anim_h = vint_object_find("map_objective_anim") 
  2338. 	lua_play_anim(anim_h) 
  2339. 	 
  2340. 	]] 
  2341. end 
  2342.  
  2343. --[[ 
  2344. ------------------------------------------------------------------------------- 
  2345. -- Displays on the HUD that the player can interact with objects 
  2346. -- (Y) ENTER VEHICLE 
  2347. ------------------------------------------------------------------------------- 
  2348. function hud_game_interact_update(di_h) 
  2349. 	-- button_is_visible		is the button visible? determined by game_audio_play 
  2350. 	-- interact_type			an enum based on the type of player interaction  [INTERACT_TYPE_STRINGS] 
  2351. 	local button_is_visible, interact_type = vint_dataitem_get(di_h) 
  2352. 	local interact_grp = vint_object_find("interact_grp") 
  2353. 	 
  2354. 	if button_is_visible == true then 
  2355. 		vint_set_property(interact_grp, "visible", true) 
  2356. 		 
  2357. 		--Set Text 
  2358. 		local interact_button_bmp = vint_object_find("interact_button") 
  2359. 		local interact_text = vint_object_find("interact_text") 
  2360. 		local interact_string = INTERACT_TYPE_STRINGS[interact_type] 
  2361. 		vint_set_property(interact_text, "text_tag", interact_string) 
  2362. 		 
  2363. 		--Set Size of Background 
  2364. 		local bg = vint_object_find("bg", interact_grp) 
  2365. 		local x, y = vint_get_property(interact_text, "anchor") 
  2366. 		local width, height = element_get_actual_size(interact_text) 
  2367. 		 
  2368. 		--Resize teh background 
  2369. 		local bg_width, bg_height = element_get_actual_size(bg) 
  2370. 		element_set_actual_size(bg, (width + x + 30), height) 
  2371. 	else 
  2372. 		vint_set_property(interact_grp, "visible", false) 
  2373. 	end 
  2374. end 
  2375. ]]-- 
  2376.