sr2lua/mp_hud.lua

  1. ---------- 
  2. -- Globals 
  3. ---------- 
  4. Mp_hud_debug_mode = false 
  5.  
  6. Mp_hud_teamscore = { 
  7. 	init = false 
  8. } 
  9. Mp_hud_activity = { 
  10. 	init = false 
  11. } 
  12. Mp_hud_perks = { 
  13. 	init = false 
  14. } 
  15.  
  16. Tagging_progress_info = {} 
  17.  
  18.  
  19. FOF_NEUTRAL 		= -1 
  20. FOF_FRIEND			= 0 
  21. FOF_FOE				= 1 
  22.  
  23.  
  24. GAMETYPE_BRAWL = 0 
  25. GAMETYPE_TEAM_BRAWL = 1 
  26. GAMETYPE_STRONGARM = 2 
  27.  
  28. STATUSTYPE_NO_LIMIT		= 0 
  29. STATUSTYPE_TIMER			= 1 
  30. STATUSTYPE_ROUNDS			= 2 
  31. STATUSTYPE_SUDDEN_DEATH	= 3 
  32.  
  33. -- Colors need to be specified from 0 to 1 
  34. Mp_hud_colors = { 
  35. 	[FOF_NEUTRAL] 	= 	{ r = 1, g = 1, b = 1 }, 
  36. 	[FOF_FRIEND] 	= 	{ r =  68/255, g = 129/255, b = 213/255 }, 
  37. 	[FOF_FOE] 		=	{ r = 175/255, g =  0/255, b =  0/255 } 
  38. } 
  39.  
  40. Mp_perk_enum_bitmaps = { 
  41. 	[-1] 	= "ui_blank"	,					--"none", 
  42. 	[0] 	= "ui_mp_tag_cash",				--"PERK_TYPE_SCORE", 
  43. 	[1] 	= "ui_mp_tag_police",			--"PERK_TYPE_POLICE", 
  44. 	[2] 	= "ui_mp_tag_sprint",			--"PERK_TYPE_SPRINT", 
  45. 	[3] 	= "ui_mp_tag_kill_bonus",		--"PERK_TYPE_KILL_BONUS", 
  46. 	[4] 	= "ui_mp_tag_nitro",				--"PERK_TYPE_NITRO", 
  47. 	[5] 	= "ui_mp_tag_slap",				--"PERK_TYPE_SLAP", 
  48. 	[6] 	= "ui_mp_tag_stealth",			--"PERK_TYPE_STEALTH", 
  49. 	[7] 	= "ui_mp_tag_ammo",				--"PERK_TYPE_AMMO",!!!!! 
  50. 	[8] 	= "ui_mp_tag_health",			--"PERK_TYPE_HEALTH", 
  51. 	[9] 	= "ui_mp_tag_accuracy",			--"PERK_TYPE_ACCURACY", 
  52. 	[10]	= "ui_mp_tag_smokescreen",		--"PERK_TYPE_SMOKESCREEN", 
  53. } 
  54.  
  55. function create_tween(name, target_h, target_prop, duration) 
  56. 	local tween_h = vint_object_create(name, "tween", vint_object_find("root_animation")) 
  57. 	vint_set_property(tween_h, "duration", duration) 
  58. 	vint_set_property(tween_h, "target_handle", target_h) 
  59. 	vint_set_property(tween_h, "target_property", target_prop) 
  60. 	vint_set_property(tween_h, "start_time",	vint_get_time_index()) 
  61. 	vint_set_property(tween_h, "state", "disabled") 
  62. 	return tween_h 
  63. end 
  64.  
  65. -- Given a score and the score limit, finds a percentage between 0 and 1 
  66. -- 
  67. function mp_hud_percent_from_score(score, score_limit) 
  68. 	if score_limit <= 0 then 
  69. 		return 0 
  70. 	end 
  71. 	 
  72. 	local percent = score / score_limit 
  73. 	if percent > 1 then 
  74. 		percent = 1 
  75. 	elseif percent < 0 then 
  76. 		percent = 0 
  77. 	end 
  78. 	 
  79. 	return percent 
  80. end 
  81.  
  82. -- Given a boolean value, returns TRUE or FALSE as text (for debugging) 
  83. -- 
  84. function bool_to_text(bool_var) 
  85. 	if bool_var then 
  86. 		return "TRUE" 
  87. 	else 
  88. 		return "FALSE" 
  89. 	end 
  90. end 
  91.  
  92. --------------- 
  93. -- Scoreboard 
  94. --------------- 
  95. function mp_hud_teamscore_init() 
  96. 	Mp_hud_teamscore.init = true 
  97.  
  98. 	--Find objects and store handles 
  99. 	Mp_hud_teamscore.handles = {} 
  100. 	Mp_hud_teamscore.handles.teamscore_grp = vint_object_find("teamscore_grp") 
  101. 	 
  102. 	-- Match status items 
  103. 	local h = Mp_hud_teamscore.handles.teamscore_grp  
  104. 	Mp_hud_teamscore.handles.game_status_txt = vint_object_find("game_status_txt", h) 
  105. 	Mp_hud_teamscore.handles.unlimited_bm = vint_object_find("unlimited_bm", h) 
  106. 	Mp_hud_teamscore.handles.sudden_death_bm = vint_object_find("sudden_death_bm", h) 
  107. 	 
  108. 	--Blue meter 
  109. 	Mp_hud_teamscore.handles.blue_meter_label = vint_object_find("label_blue_txt", h) 
  110. 	Mp_hud_teamscore.handles.blue_meter = vint_object_find("meter_blue", h) 
  111. 	Mp_hud_teamscore.handles.blue_meter_bg = vint_object_find("bg", Mp_hud_teamscore.handles.blue_meter) 
  112. 	Mp_hud_teamscore.handles.blue_meter_fill = vint_object_find("fill", Mp_hud_teamscore.handles.blue_meter) 
  113. 	 
  114. 	--Red meter 
  115. 	Mp_hud_teamscore.handles.red_meter_label = vint_object_find("label_red_txt", h) 
  116. 	Mp_hud_teamscore.handles.red_meter = vint_object_find("meter_red", h) 
  117. 	Mp_hud_teamscore.handles.red_meter_bg = vint_object_find("bg", Mp_hud_teamscore.handles.red_meter) 
  118. 	Mp_hud_teamscore.handles.red_meter_fill = vint_object_find("fill", Mp_hud_teamscore.handles.red_meter) 
  119. 	 
  120. 	--Frame 
  121. 	Mp_hud_teamscore.frame = mp_hud_teamscore_frame_find(vint_object_find("standard_box", Mp_hud_teamscore.handles.teamscore_grp)) 
  122.  
  123. 	Mp_hud_teamscore.score_limit = 0				--Total Amount of score to win the game 
  124. 	Mp_hud_teamscore.game_type = -1				--Game Type 
  125. 	Mp_hud_teamscore.status_type = 0				--Status type 0 = No Limit, 1 = Timer, 2 = Rounds 
  126. 	Mp_hud_teamscore.cur_round = -1				--Current Round 
  127. 	Mp_hud_teamscore.max_rounds = -1				--Maximum Rounds 
  128. 	Mp_hud_teamscore.cur_time = -1				--Current Game Time 
  129. 	 
  130. 	--Max size of bar 
  131. 	Mp_hud_teamscore.meter_fill_width, Mp_hud_teamscore.meter_fill_height = vint_get_property(Mp_hud_teamscore.handles.blue_meter_fill, "source_se") 
  132.  
  133. 	-- Make 'em all visible 
  134. 	vint_set_property(Mp_hud_teamscore.handles.teamscore_grp, "visible", true) 
  135. 	 
  136. 	-- ... except the Unlimited and Sudden Death images 
  137. 	vint_set_property(Mp_hud_teamscore.handles.unlimited_bm, "visible", false) 
  138. 	vint_set_property(Mp_hud_teamscore.handles.sudden_death_bm, "visible", false) 
  139.  
  140. 	--mp_game_gsi 
  141. 	vint_dataitem_add_subscription("mp_game_gsi", "update", "mp_hud_teamscore_status_update") 
  142. 	 
  143. 	-- Add a subscription to the score limit data item 
  144. 	vint_dataitem_add_subscription("sr2_score_limit_item", "update", "mp_hud_teamscore_limit_update") 
  145. 	 
  146. 	-- Add a subscription to the fof scores data item 
  147. 	vint_dataitem_add_subscription("sr2_fof_scores_item", "update", "mp_hud_teamscore_score_update") 
  148. 	 
  149. 	vint_dataitem_add_subscription("sr2_sa_game_timer_item", "update", "mp_hud_teamscore_timer_update")	 
  150. end 
  151.  
  152. -- Callback to set the score limit 
  153. function mp_hud_teamscore_limit_update(di_h, event_name) 
  154. 	debug_print("vint", "Mp_hud_teamscore.score_limit: " .. Mp_hud_teamscore.score_limit .. "\n") 
  155. 	Mp_hud_teamscore.score_limit = vint_dataitem_get(di_h) 
  156. end 
  157.  
  158. -- Callback for an update to the respect bar scores 
  159. function mp_hud_teamscore_score_update(di_h, event_name) 
  160. --function mp_hud_teamscore_score_test(friend_score, enemy_score, friend_score_text, enemy_score_text) 
  161. 	local friend_score, enemy_score, friend_score_text, enemy_score_text = vint_dataitem_get(di_h) 
  162. 	local score_limit = Mp_hud_teamscore.score_limit 
  163. 	 
  164. 	if Mp_hud_debug_mode == true then 
  165. 	end 
  166. 						 
  167. 	--Update Bars and Labels 
  168. 	local friend_percent 
  169. 	local enemy_percent	 
  170. 	 
  171. 	if score_limit > 0 then 
  172. 		friend_percent = mp_hud_percent_from_score(friend_score, score_limit) 
  173. 		enemy_percent = mp_hud_percent_from_score(enemy_score, score_limit) 
  174. 	else 
  175. 		-- Show the bars as a percentage of the highest score 
  176. 		local highest_score = friend_score 
  177. 		if enemy_score > friend_score then 
  178. 			highest_score = enemy_score 
  179. 		end 
  180.  
  181. 		friend_percent = mp_hud_percent_from_score(friend_score, highest_score) 
  182. 		enemy_percent = mp_hud_percent_from_score(enemy_score, highest_score) 
  183. 	end 
  184. 	 
  185. 	--Set Bars 
  186. 	local friend_fill_width = friend_percent * Mp_hud_teamscore.meter_fill_width 
  187. 	local enemy_fill_width = enemy_percent * Mp_hud_teamscore.meter_fill_width 
  188.  
  189. 	vint_set_property(Mp_hud_teamscore.handles.blue_meter_fill, "source_se", friend_fill_width, Mp_hud_teamscore.meter_fill_height) 
  190. 	vint_set_property(Mp_hud_teamscore.handles.red_meter_fill, "source_se", enemy_fill_width, Mp_hud_teamscore.meter_fill_height) 
  191. 	 
  192. 	--Set Score Text 
  193. 	if Mp_hud_teamscore.game_type == GAMETYPE_STRONGARM then 
  194. 		--Strong arm (Format Cash) 
  195. 		vint_set_property(Mp_hud_teamscore.handles.blue_meter_label, "text_tag", "$" .. format_cash(friend_score)) 
  196. 		vint_set_property(Mp_hud_teamscore.handles.red_meter_label, "text_tag", "$" .. format_cash(enemy_score)) 
  197. 	else 
  198. 		--Normal 
  199. 		vint_set_property(Mp_hud_teamscore.handles.blue_meter_label, "text_tag", friend_score) 
  200. 		vint_set_property(Mp_hud_teamscore.handles.red_meter_label, "text_tag", enemy_score) 
  201. 	end 
  202. 		 
  203. 	Mp_hud_teamscore.score_limit = score_limit 
  204. end 
  205.  
  206. function show_teamscore_status_by_type( status_type ) 
  207. 	if status_type == STATUSTYPE_NO_LIMIT then 
  208. 		-- Show the unlimited bitmap 
  209. 		vint_set_property(Mp_hud_teamscore.handles.game_status_txt, "visible", false) 
  210. 		vint_set_property(Mp_hud_teamscore.handles.unlimited_bm, "visible", true) 
  211. 		vint_set_property(Mp_hud_teamscore.handles.sudden_death_bm, "visible", false) 
  212. 		 
  213. 	elseif status_type == STATUSTYPE_SUDDEN_DEATH then 
  214. 		-- Show the sudden death bitmap 
  215. 		vint_set_property(Mp_hud_teamscore.handles.game_status_txt, "visible", false) 
  216. 		vint_set_property(Mp_hud_teamscore.handles.unlimited_bm, "visible", false) 
  217. 		vint_set_property(Mp_hud_teamscore.handles.sudden_death_bm, "visible", true) 
  218. 		 
  219. 	else 
  220. 		-- Timer and rounds use the game status text 
  221. 		vint_set_property(Mp_hud_teamscore.handles.game_status_txt, "visible", true) 
  222. 		vint_set_property(Mp_hud_teamscore.handles.unlimited_bm, "visible", false) 
  223. 		vint_set_property(Mp_hud_teamscore.handles.sudden_death_bm, "visible", false) 
  224. 	end 
  225. end 
  226.  
  227. --function mp_hud_teamscore_status_test(game_type, status_type, cur_round, max_rounds) 
  228. function mp_hud_teamscore_status_update(di_h) 
  229. 	local game_type, status_type, cur_round, max_rounds = vint_dataitem_get(di_h) 
  230. 	 
  231. 	--[[ 
  232. 		element 0 - game_type - int, 0 = Brawl, 1 = Team Brawl, 2 = StrongArm 
  233. 		element 1 - Status type - int, 0 = No Limit, 1 = Timer, 2 = Rounds, 3 = Sudden Death 
  234. 		element 2 - Current Round 
  235. 		element 3 - Round Max 
  236. 	]] 
  237.  
  238. 	--Ignore game_type 
  239. 	Mp_hud_teamscore.game_type = game_type 
  240. 	 
  241. 	-- Only visible if we have some sort of time limit 
  242. 	show_teamscore_status_by_type(status_type) 
  243. 	 
  244. 	-- If rounds, set the current round 
  245. 	if status_type == STATUSTYPE_ROUNDS then 
  246. 		local status_str = cur_round .. "/" .. max_rounds 
  247. 		status_str = {[0] = status_str} 
  248. 		status_str = vint_insert_values_in_string("MP_HUD_ROUND", status_str) 
  249. 		vint_set_property(Mp_hud_teamscore.handles.game_status_txt, "text_tag", status_str) 
  250. 		Mp_hud_teamscore.status_cur_roundpart_1 = cur_round 
  251. 		Mp_hud_teamscore.max_rounds = max_rounds 
  252. 	end 
  253. 	 
  254. 	Mp_hud_teamscore.status_type = status_type 
  255. end 
  256.  
  257. function mp_hud_teamscore_timer_update(data_item_h, event_name) 
  258. 	--Game Timer 
  259. 	if Mp_hud_teamscore.status_type == STATUSTYPE_TIMER then 
  260. 		--only do this is we are in timer mode 
  261. 		local status_str = vint_dataitem_get(data_item_h) 
  262. 		Mp_hud_teamscore.cur_time = status_str 
  263. 		status_str = {[0] = status_str} 
  264. 		status_str = vint_insert_values_in_string("MP_HUD_TIME", status_str) 
  265. 		vint_set_property(Mp_hud_teamscore.handles.game_status_txt, "text_tag", status_str) 
  266. 	end 
  267. end 
  268.  
  269. --------------------- 
  270. -- Activity Display 
  271. --------------------- 
  272. function mp_hud_activity_init() 
  273. 	 
  274. 	Mp_hud_teamscore.init = true 
  275.  
  276. 	Mp_hud_activity.handles = {} 
  277. 	Mp_hud_activity.handles.activity_grp = vint_object_find("activity_score_grp") 
  278. 	 
  279. 	local h = Mp_hud_activity.handles.activity_grp 
  280. 	Mp_hud_activity.handles.icon = vint_object_find("icon", h) 
  281. 	Mp_hud_activity.handles.title_txt = vint_object_find("title_txt", h) 
  282. 	Mp_hud_activity.handles.time_txt = vint_object_find("time_txt", h) 
  283. 	Mp_hud_activity.handles.box = vint_object_find("standard_box", h) 
  284. 	 
  285. 	Mp_hud_activity.handles.combo_grp = vint_object_find("combo_grp", h) 
  286. 	Mp_hud_activity.handles.race_pos_grp = vint_object_find("race_pos_grp", h) 
  287. 	Mp_hud_activity.handles.score_grp = vint_object_find("score_grp", h) 
  288. 	 
  289. 	--Score 
  290. 	h = Mp_hud_activity.handles.score_grp 
  291. 	Mp_hud_activity.handles.fill_blue = vint_object_find("fill_blue", h) 
  292. 	Mp_hud_activity.handles.fill_blue_2 = vint_object_find("fill_blue_2", h) 
  293. 	Mp_hud_activity.handles.fill_red = vint_object_find("fill_red", h) 
  294. 	Mp_hud_activity.handles.text_blue = vint_object_find("txt_blue", h) 
  295. 	Mp_hud_activity.handles.text_blue_2 = vint_object_find("txt_blue_2", h) 
  296. 	Mp_hud_activity.handles.text_red = vint_object_find("txt_red", h) 
  297. 	Mp_hud_activity.handles.line = vint_object_find("line", h) 
  298. 	 
  299. 	--Combo 
  300. 	h = Mp_hud_activity.handles.combo_grp  
  301. 	Mp_hud_activity.handles.combo_label_txt = vint_object_find("label_txt", h) 
  302. 	Mp_hud_activity.handles.combo_info_txt = vint_object_find("info_txt", h) 
  303. 	Mp_hud_activity.handles.combo_meter_grp = vint_object_find("meter_grp", h) 
  304. 	Mp_hud_activity.handles.combo_meter_fill = vint_object_find("fill", h) 
  305. 	 
  306. 	--Race position 
  307. 	h = Mp_hud_activity.handles.race_pos_grp 
  308. 	Mp_hud_activity.handles.race_place_bm = vint_object_find("race_place_bm", h) 
  309. 	Mp_hud_activity.handles.race_total_bm = vint_object_find("race_total_bm", h) 
  310. 	 
  311. 	--Animations 
  312. 	Mp_hud_activity.handles.blue_score_pulse = vint_object_find("fill_blue_anim_1") 
  313. 	Mp_hud_activity.handles.blue_scale_twn = vint_object_find("fill_blue_scale_twn_1", Mp_hud_activity.handles.blue_score_pulse) 
  314. 	vint_set_property(Mp_hud_activity.handles.blue_score_pulse, "is_paused", true) 
  315. 	 
  316. 	--Constants for display purposes 
  317. 	Mp_hud_activity.BAR_WIDTH_MAX = 172 
  318. 	Mp_hud_activity.BAR_WIDTH_MIN = 10 
  319. 	Mp_hud_activity.BAR_HEIGHT = 12 
  320. 	Mp_hud_activity.COMBO_BAR_WIDTH, Mp_hud_activity.COMBO_BAR_HEIGHT = vint_get_property(Mp_hud_activity.handles.combo_meter_fill, "source_se") 
  321. 	 
  322. 	--Variables for display 
  323. 	Mp_hud_activity.timer_width = element_get_actual_size(Mp_hud_activity.handles.time_txt) 
  324. 	 
  325. 	--Initialize Values 
  326. 	Mp_hud_activity.is_active = -1 
  327. 	Mp_hud_activity.time = -1 
  328. 	Mp_hud_activity.title_str = -1 
  329. 	Mp_hud_activity.icon_bmp_name = -1 
  330. 	Mp_hud_activity.score_blue = -1 
  331. 	Mp_hud_activity.score_red = -1 
  332. 	Mp_hud_activity.has_combo_bar = -1 
  333. 	Mp_hud_activity.combo_meter_value = -1 
  334. 	Mp_hud_activity.combo_count = -1 
  335. 	Mp_hud_activity.has_race_pos = -1 
  336. 	Mp_hud_activity.race_place = -1 
  337. 	Mp_hud_activity.race_total = -1 
  338. 	 
  339. 	--Subscribe to dataitem 
  340. 	vint_dataitem_add_subscription("sa_activity_gsi", "update", "mp_hud_activity_update") 
  341. end 
  342.  
  343. function mp_hud_activity_update(di_h) 
  344. 	local is_active, icon_bmp_name, title_str, activity_time, friendly_cash, opponent_cash, has_combo_bar, combo_count, combo_meter_value, want_race_pos, race_place, race_total, just_scored =  vint_dataitem_get(di_h) 
  345. --function mp_hud_activity_test(is_active, icon_bmp_name, title_str, activity_time, friendly_cash, opponent_cash, has_combo_bar, combo_meter_value, combo_count, just_scored) 
  346. 	 
  347. 	 
  348. 	if Mp_hud_debug_mode == true then 
  349. 		debug_print("vint", "is_active " .. var_to_string(is_active) .. "\n") 
  350. 		debug_print("vint", "icon_bmp_name: " .. var_to_string(icon_bmp_name) .. "\n") 
  351. 		debug_print("vint", "title_str: " .. var_to_string(title_str) .. "\n") 
  352. 		debug_print("vint", "activity_time: " .. var_to_string(activity_time) .. "\n") 
  353. 		debug_print("vint", "friendly_cash: " .. var_to_string(friendly_cash) .. "\n") 
  354. 		debug_print("vint", "opponent_cash: " .. var_to_string(opponent_cash) .. "\n") 
  355. 		debug_print("vint", "combo_count " .. var_to_string(combo_count) .. "\n") 
  356. 		debug_print("vint", "combo_meter_value " .. var_to_string(combo_meter_value) .. "\n") 
  357. 		debug_print("vint", "race_place" .. var_to_string(race_place) .. "\n") 
  358. 		debug_print("vint", "race_total" .. var_to_string(race_total) .. "\n\n\n") 
  359. 		debug_print("vint", "just_scored " .. var_to_string(just_scored) .. "\n\n\n") 
  360. 	end	 
  361. 	 
  362. 	--Is activity indicator active? 
  363. 	if is_active ~= Mp_hud_activity.is_active then 
  364. 		if is_active == true then 
  365. 			--Show indicator 
  366. 			vint_set_property(Mp_hud_activity.handles.activity_grp, "visible", true) 
  367. 		else  
  368. 			--Hide indicator 
  369. 			vint_set_property(Mp_hud_activity.handles.activity_grp, "visible", false) 
  370. 		end 
  371. 		Mp_hud_activity.is_active = is_active  
  372. 	end 
  373.  
  374. 	--Bitmap Name 
  375. 	if icon_bmp_name ~= Mp_hud_activity.icon_bmp_name then 
  376. 		vint_set_property(Mp_hud_activity.handles.icon, "image", icon_bmp_name) 
  377. 		Mp_hud_activity.icon_bmp_name = icon_bmp_name  
  378. 	end 
  379.  
  380. 	--Activity Name 
  381. 	if title_str ~= Mp_hud_activity.title_str then 
  382. 		vint_set_property(Mp_hud_activity.handles.title_txt, "text_tag", title_str) 
  383. 		Mp_hud_activity.title_str = title_str  
  384. 	end 
  385. 	 
  386. 	--Timer 
  387. 	if activity_time ~= Mp_hud_activity.time then 
  388. 		vint_set_property(Mp_hud_activity.handles.time_txt, "text_tag", format_clock(activity_time)) 
  389. 		Mp_hud_activity.time = activity_time 
  390. 	end 
  391. 	 
  392. 	--Scores 
  393. 	local update_meter = false 
  394. 	if friendly_cash ~= Mp_hud_activity.score_blue then 
  395. 		local cash_str = "$" .. format_cash(friendly_cash) 
  396. 		vint_set_property(Mp_hud_activity.handles.text_blue, "text_tag", cash_str) 
  397. 		vint_set_property(Mp_hud_activity.handles.text_blue_2, "text_tag", cash_str) 
  398. 		Mp_hud_activity.score_blue = friendly_cash  
  399. 		update_meter = true 
  400. 	end 
  401. 	 
  402. 	if opponent_cash ~= Mp_hud_activity.score_red then 
  403. 		local cash_str = "$" .. format_cash(opponent_cash) 
  404. 		vint_set_property(Mp_hud_activity.handles.text_red, "text_tag", cash_str) 
  405. 		Mp_hud_activity.score_red = opponent_cash  
  406. 		update_meter = true 
  407. 	end 
  408.  
  409. 	--Meter (Only update if scores have changed) 
  410. 	if update_meter == true then 
  411. 		local total_score = opponent_cash + friendly_cash 
  412. 		local friendly_width, opponent_width 
  413. 		 
  414. 		if total_score == 0 then 
  415. 			friendly_width = Mp_hud_activity.BAR_WIDTH_MAX * .5 
  416. 			opponent_width = Mp_hud_activity.BAR_WIDTH_MAX * .5 
  417. 		else 
  418. 			local scale_factor = Mp_hud_activity.BAR_WIDTH_MAX/total_score  
  419. 			friendly_width = friendly_cash * scale_factor 
  420. 			opponent_width = opponent_cash * scale_factor 
  421. 		end 
  422. 		 
  423. 		if friendly_width < Mp_hud_activity.BAR_WIDTH_MIN then 
  424. 			--Friendly Bar is smaller than our minimum so we just need to force it to display something 
  425. 			friendly_width = Mp_hud_activity.BAR_WIDTH_MIN 
  426. 			opponent_width = Mp_hud_activity.BAR_WIDTH_MAX - Mp_hud_activity.BAR_WIDTH_MIN 
  427. 		elseif opponent_width < Mp_hud_activity.BAR_WIDTH_MIN then 
  428. 			--Opponent Bar is smaller than our minimum so we just need to force it to display something 
  429. 			opponent_width = Mp_hud_activity.BAR_WIDTH_MIN 
  430. 			friendly_width = Mp_hud_activity.BAR_WIDTH_MAX - Mp_hud_activity.BAR_WIDTH_MIN 
  431. 		end 
  432. 		 
  433. 		vint_set_property(Mp_hud_activity.handles.fill_blue, "source_se", floor(friendly_width), Mp_hud_activity.BAR_HEIGHT) 
  434. 		vint_set_property(Mp_hud_activity.handles.fill_blue_2, "source_se", floor(friendly_width), Mp_hud_activity.BAR_HEIGHT) 
  435. 		vint_set_property(Mp_hud_activity.handles.fill_red, "source_se", floor(opponent_width), Mp_hud_activity.BAR_HEIGHT) 
  436. 		 
  437. 		--Update Line 
  438. 		local x, y = element_get_actual_size(Mp_hud_activity.handles.fill_blue) 
  439. 		local x_d = x/Mp_hud_activity.BAR_WIDTH_MAX 
  440. 		vint_set_property(Mp_hud_activity.handles.line, "anchor", floor(x_d * friendly_width), 5) 
  441. 	end 
  442. 	 
  443. 	--Combo Bar Updates 
  444. 	local combo_is_dirty 
  445. 	 
  446. 	--Combo meter fill update 
  447. 	if combo_meter_value ~= Mp_hud_activity.combo_meter_value then 
  448. 		local target_width = Mp_hud_activity.COMBO_BAR_WIDTH * combo_meter_value 
  449. 		vint_set_property(Mp_hud_activity.handles.combo_meter_fill, "source_se", target_width, Mp_hud_activity.COMBO_BAR_HEIGHT) 
  450. 		Mp_hud_activity.combo_meter_value = combo_meter_value  
  451. 	end 
  452. 	 
  453. 	--Combo Count Update 
  454. 	if combo_count ~= Mp_hud_activity.combo_count then 
  455. 		--Set value 
  456. 		vint_set_property(Mp_hud_activity.handles.combo_info_txt, "text_tag", combo_count) 
  457. 		combo_is_dirty = true 
  458. 		Mp_hud_activity.combo_count = combo_count 
  459. 	end 
  460. 	 
  461. 	--Is combo bar visible 
  462. 	if has_combo_bar ~= Mp_hud_activity.has_combo_bar then 
  463. 		if has_combo_bar == true then 
  464. 			--show combo bar 
  465. 			vint_set_property(Mp_hud_activity.handles.combo_grp, "visible", true)  
  466. 			combo_is_dirty = true 
  467. 		else 
  468. 			--hide combo bar 
  469. 			vint_set_property(Mp_hud_activity.handles.combo_grp, "visible", false)  
  470. 		end 
  471. 		Mp_hud_activity.has_combo_bar = has_combo_bar  
  472. 	end 
  473. 	 
  474. 	--Format Combo bar 
  475. 	if combo_is_dirty == true then 
  476. 		local new_width = element_get_actual_size(Mp_hud_activity.handles.combo_info_txt) 
  477. 	 
  478. 		--Scale\Align combo meter 
  479. 		local label_width, label_height = element_get_actual_size(Mp_hud_activity.handles.title_txt) 
  480. 		local label_x, label_y = vint_get_property(Mp_hud_activity.handles.title_txt, "anchor") 
  481. 		local combo_padding_left = 15 
  482. 		 
  483. 		local combo_grp_x, combo_grp_y = vint_get_property(Mp_hud_activity.handles.combo_grp, "anchor") 
  484. 		combo_grp_x = label_x + label_width + combo_padding_left + new_width 
  485. 		vint_set_property(Mp_hud_activity.handles.combo_grp, "anchor", combo_grp_x, combo_grp_y) 
  486. 		 
  487. 		local max_width = 302 
  488. 		 
  489. 		local bg_1 = vint_object_find("bg_1", Mp_hud_activity.handles.combo_grp) 
  490. 		local bg_2 = vint_object_find("bg_2", Mp_hud_activity.handles.combo_grp) 
  491. 		local fill = vint_object_find("fill", Mp_hud_activity.handles.combo_grp) 
  492. 		 
  493. 		local target_width = max_width - combo_grp_x + 8 
  494. 		 
  495. 		local bg_1_width, bg_1_height = element_get_actual_size(bg_1) 
  496. 		local bg_2_width, bg_2_height = element_get_actual_size(bg_2) 
  497. 		local fill_width, fill_height = element_get_actual_size(fill) 
  498. 		 
  499. 		element_set_actual_size(bg_1, target_width, bg_1_height) 
  500. 		element_set_actual_size(bg_2, target_width, bg_2_height) 
  501. 		element_set_actual_size(fill, target_width - 4, fill_height) 
  502. 	end 
  503. 	 
  504. 	-- Validate whether we have valid values before showing the race position 
  505. 	local has_race_pos = want_race_pos and race_place >= 1 and race_total >= 1 and race_place <= 8 and race_total <= 8 
  506. 	 
  507. 	if has_race_pos ~= Mp_hud_activity.has_race_pos then 
  508. 		vint_set_property( Mp_hud_activity.handles.race_pos_grp, "visible", has_race_pos ) 
  509. 		 
  510. 		Mp_hud_activity.has_race_pos = has_race_pos 
  511. 	end 
  512.  
  513. 	if has_race_pos then 
  514. 		-- Update the place and total bitmaps 
  515. 		local bitmap_prefix = "ingame_race_position_" 
  516. 		 
  517. 		if race_place ~= Mp_hud_activity.race_place then 
  518. 			vint_set_property( Mp_hud_activity.handles.race_place_bm, "image", bitmap_prefix .. race_place ) 
  519. 			Mp_hud_activity.race_place = race_place 
  520. 		end 
  521. 		 
  522. 		if race_total ~= Mp_hud_activity.race_total then 
  523. 			vint_set_property( Mp_hud_activity.handles.race_total_bm, "image", bitmap_prefix .. race_total ) 
  524. 			Mp_hud_activity.race_total = race_total 
  525. 		end 
  526. 	end 
  527. 	 
  528. 	if just_scored == true then 
  529. 		--Pulse Team score 
  530. 		--Center bar so when we scale it scales from center 
  531. 		local start_x, start_y = vint_get_property(Mp_hud_activity.handles.fill_blue, "anchor") 
  532. 		 
  533. 		local source_se_x, source_se_y = vint_get_property(Mp_hud_activity.handles.fill_blue, "source_se") 
  534. 		local width, height = element_get_actual_size(Mp_hud_activity.handles.fill_blue) 
  535. 		local real_width = width/Mp_hud_activity.BAR_WIDTH_MAX 
  536. 		 
  537. 		real_width = floor(real_width * source_se_x) 
  538. 	 
  539. 		local anchor_x = real_width 
  540. 		local anchor_y = height 
  541. 		local offset_x = 0 - anchor_x /2 
  542. 		local offset_y = 0 - anchor_y/2 
  543. 		 
  544. 		vint_set_property(Mp_hud_activity.handles.fill_blue_2, "anchor", anchor_x, anchor_y) 
  545. 		vint_set_property(Mp_hud_activity.handles.fill_blue_2, "offset", offset_x, offset_y) 
  546. 		 
  547. 		--TODO: Edit tween so scale is close to the original 
  548. 		local target_scale_x, target_scale_y = vint_get_property(Mp_hud_activity.handles.blue_scale_twn, "end_value") 
  549. 		local cur_scale_x, cur_scale_y = vint_get_property(Mp_hud_activity.handles.fill_blue, "scale") 
  550.  
  551. 		--Center Text 
  552. 		local width, height = element_get_actual_size(Mp_hud_activity.handles.text_blue) 
  553. 		local x, y = vint_get_property(Mp_hud_activity.handles.text_blue, "anchor") 
  554.  
  555. 		anchor_x = x + width/2 
  556. 		anchor_y = y + height/2 
  557. 		offset_x = 0 - width/2 
  558. 		offset_y = 0 - height/2 
  559. 		 
  560. 		vint_set_property(Mp_hud_activity.handles.text_blue_2, "anchor", anchor_x, anchor_y)  
  561. 		vint_set_property(Mp_hud_activity.handles.text_blue_2, "offset", offset_x, offset_y)  
  562. 		 
  563. 		local depth = vint_get_property(Mp_hud_activity.handles.text_blue_2, "depth") 
  564. 		depth = depth - 100 
  565. 		vint_set_property(Mp_hud_activity.handles.text_blue_2, "depth ", depth)  
  566. 		 
  567. 		vint_set_property(Mp_hud_activity.handles.blue_scale_twn, "end_value", target_scale_x, target_scale_y) 
  568. 		lua_play_anim(Mp_hud_activity.handles.blue_score_pulse) 
  569. 	end 
  570. end 
  571.  
  572. -------------------------------------------------------------------- 
  573.  
  574.  
  575. function mp_hud_teamscore_frame_find(frame_grp_h) 
  576. 	local frame = {} 
  577. 	frame.nw = vint_object_find("bg_nw",	frame_grp_h) 
  578. 	frame.n = vint_object_find("bg_n", 		frame_grp_h) 
  579. 	frame.ne = vint_object_find("bg_ne", 	frame_grp_h) 
  580. 	frame.e = vint_object_find("bg_e", 		frame_grp_h) 
  581. 	frame.se = vint_object_find("bg_se",	frame_grp_h) 
  582. 	frame.s = vint_object_find("bg_s", 		frame_grp_h) 
  583. 	frame.sw = vint_object_find("bg_sw", 	frame_grp_h) 
  584. 	frame.w = vint_object_find("bg_w", 		frame_grp_h) 
  585. 	frame.c = vint_object_find("bg_c", 		frame_grp_h) 
  586. 	return frame 
  587. end 
  588.  
  589. function mp_hud_frame_resize(active_frame, width, height) 
  590. 	width = floor(width) 
  591. 	height = floor(height) 
  592. 	 
  593. 	debug_print("vint", "width:   " .. width .. "\n") 
  594. 	debug_print("vint", "height:   " .. height .. "\n") 
  595. 	--setup limits	 
  596. 	local source_se_x, source_se_y, anchor_x, anchor_y, c_anchor_y, c_anchor_x, target_x, target_y 
  597.  
  598. 	--North 
  599. 	source_se_x, source_se_y = vint_get_property(active_frame.n,"source_se") 
  600. 	vint_set_property(active_frame.n, "source_se", width, source_se_y) 
  601. 	 
  602. 	--West 
  603. 	source_se_x, source_se_y = vint_get_property(active_frame.w,"source_se") 
  604. 	vint_set_property(active_frame.w, "source_se", source_se_x, height) 
  605. 	 
  606. 	--Center 
  607. 	vint_set_property(active_frame.c, "source_se", width, height) 
  608. 	c_anchor_y, c_anchor_x = vint_get_property(active_frame.c, "anchor") 
  609. 	 
  610. 	target_x = c_anchor_x + width - 1 
  611. 	target_y = c_anchor_y + height + 1 
  612. 	 
  613. 	--North East 
  614. 	anchor_x, anchor_y = vint_get_property(active_frame.ne, "anchor") 
  615. 	vint_set_property(active_frame.ne, "anchor", target_x , anchor_y) 
  616. 		 
  617. 	--East 
  618. 	anchor_x, anchor_y = vint_get_property(active_frame.e, "anchor") 
  619. 	source_se_x, source_se_y = vint_get_property(active_frame.e, "source_se") 
  620. 	vint_set_property(active_frame.e, "anchor", target_x , anchor_y) 
  621. 	vint_set_property(active_frame.e, "source_se", source_se_x, height) 
  622. 	 
  623. 	--South West 
  624. 	anchor_x, anchor_y = vint_get_property(active_frame.sw, "anchor") 
  625. 	vint_set_property(active_frame.sw, "anchor", anchor_x, target_y) 
  626. 	 
  627. 	--South  
  628. 	anchor_x, anchor_y = vint_get_property(active_frame.s, "anchor") 
  629. 	vint_set_property(active_frame.s, "anchor", anchor_x, target_y) 
  630. 	source_se_x, source_se_y = vint_get_property(active_frame.s, "source_se") 
  631. 	vint_set_property(active_frame.s, "source_se", width, source_se_y) 
  632. 	 
  633. 	--South East 
  634. 	vint_set_property(active_frame.se, "anchor", target_x, target_y)	 
  635. end 
  636.  
  637. ------------------- 
  638. -- Tagging Progress 
  639. ------------------- 
  640. Mp_hud_tagging_process = {} 
  641. function mp_hud_tagging_progress_init() 
  642. 	Mp_hud_tagging_process.handles = {} 
  643. 	Mp_hud_tagging_process.handles.meter = vint_object_find("tagging_progress_grp") 
  644. 	Mp_hud_tagging_process.handles.fill = vint_object_find( "tagging_progress_fill" ) 
  645. 	local x, y = vint_get_property(Mp_hud_tagging_process.handles.fill, "source_se" ) 
  646. 	 
  647. 	Tagging_progress_info.bar_length = x 
  648. 	Tagging_progress_info.bar_height = y 
  649. 	 
  650. 	-- Hide progress until we need it 
  651. 	vint_set_property(Mp_hud_tagging_process.handles.meter, "visible", false ) 
  652. 	vint_dataitem_add_subscription("sr2_sa_tagging_progress_item", "update", "mp_hud_tagging_progress_update" ) 
  653. end 
  654.  
  655. function mp_hud_tagging_progress_update(data_item_h, event_name) 
  656. 	local percent = vint_dataitem_get(data_item_h) 
  657. 	percent = min( percent, 1 ) 
  658. 	if percent > 0 then 
  659. 		vint_set_property(Mp_hud_tagging_process.handles.meter, "visible", true) 
  660. 		 
  661. 		local fill_position = percent * Tagging_progress_info.bar_length 
  662. 		 
  663. 		vint_set_property(Mp_hud_tagging_process.handles.fill, "source_se", fill_position, Tagging_progress_info.bar_height) 
  664. 	else 
  665. 		vint_set_property(Mp_hud_tagging_process.handles.meter, "visible", false) 
  666. 	end 
  667. end 
  668.  
  669. -------------------------------------------- 
  670. -- Tagging Perks 
  671. -------------------------------------------- 
  672. function mp_hud_perks_init() 
  673.  
  674. 	Mp_hud_teamscore.init = true 
  675.  
  676. 	--Find objects 
  677. 	Mp_hud_perks.handles = {} 
  678. 	Mp_hud_perks.handles.perks = vint_object_find("perk_grp") 
  679. 	vint_set_property(Mp_hud_perks.handles.perks, "visible", true) 
  680.  
  681. 	Mp_hud_perks.slots = {} 
  682. 	 
  683. 	Mp_hud_perks.twn_cb_data = {} 
  684. 	--Clone template object into slots 
  685. 	local perk_template_h = vint_object_find("perk_template") 
  686. 	local perk_anim_h = vint_object_find("perk_anim_2") 
  687. 	 
  688. 	local h, ico_pulse_h, ico_static_h, anim_h, twn_1_h, twn_2_h, x, y 
  689. 	local highlight_1_h, highlight_2_h 
  690. 	for i = 1, 4 do 
  691. 		--Find position of perk 
  692. 		h = vint_object_find("perk_" .. i, Mp_hud_perks.handles.perks) 
  693. 		x, y = vint_get_property(h, "anchor") 
  694. 		vint_object_destroy(h) 
  695. 		 
  696. 		--Clone Perk into destination 
  697. 		h = vint_object_clone(perk_template_h) 
  698. 		vint_object_set_parent(h, Mp_hud_perks.handles.perks) 
  699. 		vint_set_property(h, "anchor", x, y) 
  700. 		 
  701. 		--Icon 
  702. 		ico_pulse_h = vint_object_find("ico_pulse", h) 
  703. 		ico_static_h = vint_object_find("ico_static", h) 
  704. 		 
  705. 		--Highlights 
  706. 		highlight_1_h = vint_object_find("highlight_bmp", h) 
  707. 		highlight_2_h = vint_object_find("highlight_normal_bmp", h) 
  708. 		 
  709. 		--Clone and target animations 
  710. 		local anim_h = vint_object_clone(perk_anim_h) 
  711. 		vint_set_property(anim_h, "target_handle", h) 
  712. 		vint_set_property(anim_h, "is_paused", true) 
  713. 		lua_play_anim(anim_h) 
  714. 		 
  715. 		--Find Tweens 
  716. 		twn_1_h = vint_object_find("ico_tint_twn_1", anim_h) 
  717. 		twn_2_h = vint_object_find("highlight_bmp_alpha_twn_1", anim_h) 
  718. 		 
  719. 		--Set end event for end tween loopage 
  720. 		vint_set_property(twn_2_h, "end_event", "mp_hud_perks_anim_loop") 
  721. 		Mp_hud_perks.twn_cb_data[twn_2_h] = anim_h 
  722. 		 
  723. 		Mp_hud_perks.slots[i] = { 
  724. 			grp_h = h, 
  725. 			ico_pulse_h = ico_pulse_h, 
  726. 			ico_static_h = ico_static_h, 
  727. 			highlight_1_h = highlight_1_h, 
  728. 			highlight_2_h = highlight_2_h, 
  729. 			anim_h = anim_h, 
  730. 			twn_1_h = twn_1_h, 
  731. 			twn_2_h = twn_2_h, 
  732. 		} 
  733. 	end 
  734. 	 
  735. 	--Destroy template objects 
  736. 	vint_object_destroy(perk_template_h) 
  737. 	vint_object_destroy(perk_anim_h)	 
  738. 	 
  739. 	--Subscribe to events 
  740. 	vint_datagroup_add_subscription("sr2_sa_tagging_perk_listing_group", "insert", "mp_hud_perks_update") 
  741. 	vint_datagroup_add_subscription("sr2_sa_tagging_perk_listing_group", "update", "mp_hud_perks_update") 
  742. end 
  743.  
  744. function mp_hud_perks_anim_loop(twn_h) 
  745. 	lua_play_anim(Mp_hud_perks.twn_cb_data[twn_h], 0) 
  746. end 
  747.  
  748. function mp_hud_perks_update(di_h, event_name) 
  749.  
  750. 	local id, perk_name, owner_team, current_tagger_team, bmp_index = vint_dataitem_get(di_h) 
  751. --function mp_hud_perks_test(id, perk_name, owner_team, current_tagger_team, bmp_index)	 
  752.  -- Find the right perk info to edit 
  753. 	 
  754. 	debug_print("vint", "id: " .. var_to_string(id) .. "\n") 
  755. 	debug_print("vint", "perk_name: " .. var_to_string(perk_name) .. "\n") 
  756. 	debug_print("vint", "perk_name: " .. var_to_string(current_tagger_team) .. "\n") 
  757. 	debug_print("vint", "owner_team: " .. var_to_string(bmp_index) .. "\n") 
  758.   
  759. 	local slot = Mp_hud_perks.slots[id] 
  760. 	if slot == nil then 
  761. 		debug_print( "mpvint", "ERROR!  Tagging perk listing " .. id .. " not found\n" ) 
  762. 		return 
  763. 	end 
  764. 	 
  765. 	local visible = ( perk_name ~= "" ) 
  766. 	vint_set_property(slot.grp_h, "visible", visible) 
  767. 	 
  768. 	if visible then 
  769. 		--Set bitmap information 
  770. 		vint_set_property(slot.ico_static_h, "image", Mp_perk_enum_bitmaps[bmp_index]) 
  771. 		vint_set_property(slot.ico_pulse_h, "image", Mp_perk_enum_bitmaps[bmp_index]) 
  772. 	else 
  773. 		return 
  774. 	end 
  775.  
  776. 	-- The current tag is no longer being tagged. Return the perk text to the new owner. 
  777. 	if current_tagger_team == FOF_NEUTRAL then 
  778. 		local new_color = Mp_hud_colors[owner_team] 
  779. 		 
  780. 		--Stop any animations from going on 
  781. 		--vint_set_property(slot.anim_h, "is_paused", true) 
  782. 		 
  783. 		vint_set_property(slot.ico_static_h , "visible", true) 
  784. 		vint_set_property(slot.ico_pulse_h , "visible", false) 
  785. 		vint_set_property(slot.highlight_1_h , "visible", false) 
  786. 		vint_set_property(slot.highlight_2_h , "visible", false) 
  787. 		 
  788. 		--Tint and showBMP 
  789. 		vint_set_property(slot.ico_static_h, "tint", new_color.r, new_color.g, new_color.b) 
  790. 		vint_set_property(slot.ico_pulse_h, "tint", new_color.r, new_color.g, new_color.b)	 
  791. 		vint_set_property(slot.ico_static_h, "visible", true) 
  792. 		vint_set_property(slot.ico_pulse_h, "visible", false) 
  793. 		 
  794. 	else 
  795. 		local start_color = Mp_hud_colors[owner_team] 
  796. 		local end_color = Mp_hud_colors[current_tagger_team] 
  797.  
  798. 		vint_set_property(slot.ico_static_h , "visible", false) 
  799. 		vint_set_property(slot.ico_pulse_h , "visible", true) 
  800. 		 
  801. 		vint_set_property(slot.highlight_1_h , "visible", true) 
  802. 		vint_set_property(slot.highlight_2_h , "visible", true) 
  803. 		vint_set_property(slot.highlight_1_h , "tint", end_color.r, end_color.g, end_color.b) 
  804. 		vint_set_property(slot.highlight_2_h , "tint", end_color.r, end_color.g, end_color.b) 
  805. 		vint_set_property(slot.ico_pulse_h, "tint", start_color.r, start_color.g, start_color.b) 
  806. 		vint_set_property(slot.ico_static_h, "tint", start_color.r, start_color.g, start_color.b) 
  807. 		 
  808. 		--[[ 
  809. 		--1 is the color flashing thing... (start = og, end = new) 
  810. 		vint_set_property(slot.twn_1_h, "start_value", start_color.r, start_color.g, start_color.b) 
  811. 		vint_set_property(slot.twn_1_h, "end_value", end_color.r, end_color.g, end_color.b) 
  812. 		 
  813. 		--2 is the original color(start/end = og) 
  814. 		vint_set_property(slot.twn_2_h, "start_value", start_color.r, start_color.g, start_color.b) 
  815. 		vint_set_property(slot.twn_2_h, "end_value", start_color.r, start_color.g, start_color.b) 
  816. 		]] 
  817. 		--lua_play_anim(slot.anim_h, 0) 
  818. 	end	 
  819. end 
  820.  
  821.  
  822. Mp_hud_voip = {} 
  823.  
  824. function mp_hud_voip_init() 
  825. 	vint_set_property(vint_object_find("voip_grp"), "visible", true) 
  826. 	 
  827. 	Mp_hud_voip.slots = {} 
  828. 	local h = vint_object_find("voip_1") 
  829. 	Mp_hud_voip.slots[0] = { 
  830. 		grp_h = h, txt_h = vint_object_find("txt", h) 
  831. 	} 
  832. 	 
  833. 	local h = vint_object_find("voip_2") 
  834. 	Mp_hud_voip.slots[1] = { 
  835. 		grp_h = h, txt_h = vint_object_find("txt", h) 
  836. 	} 
  837. 	 
  838. 	local h = vint_object_find("voip_3") 
  839. 	Mp_hud_voip.slots[2] = { 
  840. 		grp_h = h, txt_h = vint_object_find("txt", h) 
  841. 	} 
  842. 	 
  843. 	vint_datagroup_add_subscription("mp_game_voip", "insert", "mp_hud_voip_update") 
  844. 	vint_datagroup_add_subscription("mp_game_voip", "update", "mp_hud_voip_update") 
  845. end 
  846.  
  847. function mp_hud_voip_update(di_h) 
  848. 	local index, player_name = vint_dataitem_get(di_h) 
  849. 	local grp_h = Mp_hud_voip.slots[index].grp_h 
  850. 	local txt_h = Mp_hud_voip.slots[index].txt_h 
  851. 	 
  852. 	vint_set_property(txt_h, "text_tag", player_name) 
  853. 	if player_name == "" then 
  854. 		--No name so hide the slot 
  855. 		vint_set_property(grp_h, "visible", false) 
  856. 	else 
  857. 		vint_set_property(grp_h, "visible", true) 
  858. 	end 
  859. end 
  860.  
  861. ------------------- 
  862. -- Init and Cleanup 
  863. ------------------- 
  864.  
  865. function mp_hud_init() 
  866. 	local gp_mode = get_game_play_mode() 
  867. 	 
  868. 	--Hide objects 
  869. 	vint_set_property(vint_object_find("teamscore_grp"), "visible", false) 
  870. 	vint_set_property(vint_object_find("activity_score_grp"), "visible", false) 
  871. 	vint_set_property(vint_object_find("tagging_progress_grp"), "visible", false ) 
  872. 	vint_set_property(vint_object_find("perk_grp"), "visible", false ) 
  873. 	vint_set_property(vint_object_find("voip_grp"), "visible", false ) 
  874. 	 
  875. 	--mp_hud_teamscore_init() 
  876. 	--mp_hud_activity_init() 
  877. 	 
  878. 	-- 
  879. 	 
  880. 	if gp_mode == "Braveheart" then 
  881. 		mp_hud_activity_init() 
  882. 		mp_hud_teamscore_init() 
  883. 		mp_hud_tagging_progress_init() 
  884. 		mp_hud_perks_init() 
  885. 		mp_hud_voip_init() 
  886.  
  887. 	elseif gp_mode == "Gangsta Brawl" or gp_mode == "Team Gangsta Brawl" then 
  888. 		mp_hud_teamscore_init() 
  889. 		mp_hud_voip_init() 
  890. 	end 
  891. end 
  892.  
  893. function mp_hud_clean_up() 
  894. end 
  895.  
  896. function mp_test1() 
  897.  
  898. --[[ 
  899. 	mp_hud_perks_test(1, "Perk1", FOF_NEUTRAL, FOF_FRIEND, 	5)	 
  900. 	mp_hud_perks_test(2, "Perk2", FOF_NEUTRAL, FOF_FOE, 		6)	 
  901. 	mp_hud_perks_test(3, "Perk4", FOF_FOE,		 FOF_NEUTRAL, 	7)	 
  902. 	mp_hud_perks_test(4, "Perk5", FOF_NEUTRAL, FOF_NEUTRAL, 	8)	 
  903. 	]] 
  904. 	Mp_hud_teamscore.score_limit  = 20000 
  905. 	mp_hud_teamscore_status_test(3, 1, 1, 2) 
  906.  
  907. 	mp_hud_teamscore_score_test(2000, 2000, "$22,000", "$2000") 
  908.  
  909. end 
  910.  
  911. function mp_test2() 
  912. --[[ 
  913.   	mp_hud_perks_test(1, "Perk1", FOF_FRIEND, FOF_NEUTRAL, 9)	 
  914. 	mp_hud_perks_test(2, "Perk2", FOF_NEUTRAL, FOF_NEUTRAL, 10)	 
  915. 	mp_hud_perks_test(3, "Perk1", FOF_FOE, FOF_FRIEND, 4)	 
  916. 	mp_hud_perks_test(4, "Perk1", FOF_FRIEND, FOF_NEUTRAL, 3)	 
  917. 	]] 
  918. 	--mp_hud_activity_test(true, "ui_hud_act_ico_crowdcontrol", "crowd control", 200, 0, 0, false, 0, 0, true) 
  919. 	--mp_hud_teamscore_test(0, 0, 412, 421, 52324, 32, 100000) 
  920. 	mp_hud_teamscore_status_test(1, 0, 1, 2) 
  921. 	mp_hud_activity_test(true, "ui_hud_act_ico_crowdcontrol", "crowd control", 200, 43784, 0, false, .2, 5, true) 
  922. end 
  923.  
  924. function mp_test3() 
  925. --[[ 
  926.   	mp_hud_perks_test(1, "Perk1", FOF_FRIEND, FOF_NEUTRAL, 1)	 
  927. 	mp_hud_perks_test(2, "Perk2", FOF_NEUTRAL, FOF_FRIEND, 2)	 
  928. 	mp_hud_perks_test(3, "Perk1", FOF_NEUTRAL, FOF_FRIEND, 3)	 
  929. 	mp_hud_perks_test(4, "Perk1", FOF_FRIEND, FOF_FOE, 4)	 
  930. ]] 
  931. 	mp_hud_teamscore_status_test(2, 0, 1, 2) 
  932. 	mp_hud_activity_test(true, "ui_hud_act_ico_crowdcontrol", "crowd control", 200, 43784, 0, false, .2, 5, true) 
  933. 	--mp_hud_teamscore_test(4000, 500, "$4,000", "$500") 
  934. end 
  935.  
  936. function mp_test4() 
  937. --	mp_hud_activity_test(true, "ui_hud_act_ico_crowdcontrol", "crowd control", 200, 0, 53432, true, .5, 19, true) 
  938. 	mp_hud_activity_test(true, "ui_hud_act_ico_mayhem", "Mayhem", 200, 43784, 0, true, .2, 5, true) 
  939. end 
  940.  
  941. function mp_test5() 
  942. 	mp_hud_activity_test(true, "ui_hud_act_ico_mayhem", "MayhemDESTRUC", 200, 43784, 0, true, 1, 25, true) 
  943. 	--mp_hud_activity_test(true, "ui_hud_act_ico_crowdcontrol", "crowd control", 10, 5500, 9300, true, .2, 0, true) 
  944. end 
  945.