./hud_mayhem.lua

  1.  
  2. --Constants...	 
  3. local MAYHEM_DISPLAY_TYPE_CASH	 		= 0 
  4. local MAYHEM_DISPLAY_TYPE_POINTS 		= 1 
  5. local MAYHEM_DISPLAY_TYPE_SEC 			= 2 
  6. local MAYHEM_DISPLAY_TYPE_SEC_2 		= 3 
  7. local MAYHEM_DISPLAY_TYPE_CUSTOM 		= 4 
  8. local MAYHEM_DISPLAY_TYPE_FRAUD_UNITS	= 5 
  9.  
  10. Hud_mayhem_elements = { 
  11. 	in_game_grp_h = -1, 
  12. 	bonus_grp_h = -1, 
  13. 	bonus_item_grp_h = -1, 
  14. 	bonus_grp_start_x = -1, 
  15. 	bonus_grp_start_y = -1, 
  16. } 
  17.  
  18. Hud_mayhem_anims = { 
  19. 	rise_anim_h = -1, 
  20. 	bonus_item_grp_anim_h = -1 
  21. } 
  22.  
  23. Hud_mayhem_world_cash_status = { 
  24. 	depth = 0, 
  25. 	text_intensity = 0, 
  26. 	color_r = .89, 
  27. 	color_g = .749, 
  28. 	color_b = .05, 
  29. } 
  30. Hud_mayhem_world_cash = {} 
  31.  
  32. Hud_mayhem_bonus_mod_status = { 
  33. 	current_index = 0, 
  34. 	cleared_index = 0, 
  35. 	line_height = 25, 
  36. }  
  37.  
  38. Hud_mayhem_bonus_mods = {} 
  39.  
  40.  
  41. Hud_mayhem_world_cash_colors = { 
  42. 	["WHITE"] 		= { ["r"] = .898,			 ["g"] = .894,				 ["b"] = .874}, 	--White 
  43. 	["YELLOW"] 		= { ["r"] = 246/255, 	["g"] = 173/255,	 ["b"] = 40/255}, 	--Yellow 
  44. 	["ORANGE"]		= { ["r"] = 235/255, 	["g"] = 98/255, 	["b"] = 5/255}, 	--Orange 
  45. 	["RED"]			= { ["r"] = 220/255, 	["g"] = 47/255, 	["b"] = 9/255}, 	--Red 
  46. 	["BLUE"]			= { ["r"] = .26,	["g"] = .501, 	["b"] = .835},  
  47. 	["MID_BLUE"]	= { ["r"] = .145,	["g"] = .419, 	["b"] = .811},  
  48. 	["DARK_BLUE"]	= { ["r"] = .027,	["g"] = .341, 	["b"] = .788}, 
  49. } 
  50.  
  51. --object handles... 
  52. local Hud_mayhem_combo_total_item_h = 0 
  53.  
  54. -- Local player combo hud data 
  55. local HUD_COMBO_OFFESET_X = 100 
  56. local HUD_COMBO_OFFESET_Y = 0 
  57.  
  58. local HUD_PLAYER_INVALID_ID	= 0 
  59.  
  60. local HP_TEXT	= 0 
  61. local HP_VALUE	= 1 
  62.  
  63. -- Player combo hud data 
  64. -- NOTE: It is not local because this hud has been opened to LUA and these defines are shared. 
  65. HPT_NONE			= 0 
  66. HPT_POINTS			= 1 
  67. HPT_DISTANCE		= 2 
  68. HPT_TIME			= 3 
  69. HPT_MONEY			= 4 
  70. HPT_DEGREES			= 5 
  71. HPT_MULTIPLIER		= 6 
  72. HPT_MESSAGE_ONLY	= 7 
  73. HPT_SECONDS			= 8 
  74. HPT_PERCENT			= 9 
  75. HPT_FRAUD_UNITS		= 10 
  76.  
  77. HPS_NONE				= 0 
  78. HPS_MINUS			= 1 
  79. HPS_PLUS				= 2 
  80. HPS_MULTIPLIER		= 3 
  81.  
  82. -- Player combo hud skin types 
  83. HP_SKIN_DEFAULT 	= 0 
  84. HP_SKIN_YELLOW 	= 1 
  85.  
  86. -- Player combo hud skin data 
  87. local Hud_player_skins = { 
  88. 	[HP_SKIN_DEFAULT]	= { 
  89. 		[HP_TEXT]	= { 0.898, 0.894, 0.874 }, -- White 
  90. 		[HP_VALUE]	= { 0.898, 0.894, 0.874 }, -- White 
  91. 	}, 
  92. 	[HP_SKIN_YELLOW]	= { 
  93. 		[HP_TEXT]	= { 238/255, 174/255, 48/255}, -- Yellow 
  94. 		[HP_VALUE]	= { 238/255, 174/255, 48/255}, -- YEllow 
  95. 	}, 
  96. } 
  97.  
  98. function hud_mayhem_init() 
  99. 	--Find and store elements 
  100. 	local h = vint_object_find("mayhem_grp") 
  101. 	 
  102. 	--In world cash 
  103. 	Hud_mayhem_elements.in_game_grp_h = vint_object_find("mayhem_cash_grp")		-- in world cash 
  104. 	Hud_mayhem_anims.rise_anim_h = vint_object_find("mayhem_rise_anim")			-- in world cash 
  105. 	Hud_mayhem_combo_total_item_h = vint_object_find("combo_total_item")		--combo totals 
  106. 	 
  107. 	-- hide base elements 
  108. 	vint_set_property(Hud_mayhem_elements.in_game_grp_h, "visible", false) 
  109. 	vint_set_property(Hud_mayhem_combo_total_item_h, "visible", false) 
  110. 	 
  111. 	--Subscribe to data items 
  112. 	vint_dataitem_add_subscription("local_player_combohud", "update", "hud_mayhem_combo_total_update") 
  113. 	 
  114. 	autil_hud_mayhem_init( ) 
  115. end 
  116.  
  117. function hud_mayhem_world_cash_update(di_h) 
  118. 	--[[ 
  119. 		VINT_PROP_TYPE_FLOAT          - World position (x) 
  120. 		VINT_PROP_TYPE_FLOAT          - World position (y) 
  121. 		VINT_PROP_TYPE_FLOAT          - World position (z) 
  122. 		VINT_PROP_TYPE_VECTOR2F    	- Screen position 
  123. 		VINT_PROP_TYPE_INT            - Cash value 
  124. 		VINT_PROP_TYPE_FLOAT          - Text intensity 
  125. 		VINT_PROP_TYPE_INT        	- Multiplier value 
  126. 		VINT_PROP_TYPE_INT			- Type 0 = $$, 1 = Points, 2 = Seconds, 3 = Seconds added, 4 = Custom text 
  127. 		VINT_PROP_TYPE_ING	  		- Line offset 
  128. 		VINT_PROP_TYPE_FLOAT		- Text scale 
  129. 		VINT_PROP_TYPE_STRING		- Custom text string 
  130. 		 
  131. 	]] 
  132. 	local world_x, world_y, world_z, screen_pos_x, screen_pos_y, cash_value, text_intensity, multiplier, display_type, line_offset, scale, custom_text = vint_dataitem_get(di_h) 
  133. 								 
  134. 	--debug_print("vint", "hud_mayhem_world_cash_update: di_h " .. di_h .. "\n") 
  135. 	--debug_print("vint", "hud_mayhem_world_cash_update: cash_value $" .. cash_value .. "\n") 
  136.  
  137. 	if display_type == nil then 
  138. 		display_type = 0 
  139. 	end 
  140.  
  141. 	--Don't do anything else if this is a dummy object. 
  142. 	if cash_value == 0 then 
  143. 		--reset text color 
  144. 		hud_mayhem_text_color_change(text_intensity) 
  145. 		return 
  146. 	end 
  147.  
  148. 	--If this item has't been created, make a new one and set it up 
  149. 	if Hud_mayhem_world_cash[di_h] == nil then 
  150. 		--Reset text color 
  151. 		hud_mayhem_text_color_change(text_intensity) 
  152. 		 
  153. 		--Clone New item 
  154. 		local grp_h = vint_object_clone(Hud_mayhem_elements.in_game_grp_h) 
  155. 		local sub_grp_h = vint_object_find("cash_sub_grp", grp_h) 
  156. 		local cash_txt_h = vint_object_find("cash_txt", grp_h) 
  157. 		local multiplier_txt_h = vint_object_find("multiplier_txt", grp_h) 
  158. 		local anim_h = vint_object_clone(Hud_mayhem_anims.rise_anim_h) 
  159.  
  160. 		--show gombo cash... 
  161. 		vint_set_property(grp_h, "visible", true) 
  162. 		 
  163. 		--Set the scale 
  164. 		local base_scale_x, base_scale_y = vint_get_property(grp_h, "scale") 
  165. 		vint_set_property(grp_h, "scale", base_scale_x * scale, base_scale_y * scale) 
  166.  
  167. 		--Rotate and set depth 
  168. 		vint_set_property(grp_h, "rotation", rand_float(-0.249, 0.249)) 
  169. 		vint_set_property(grp_h, "depth", Hud_mayhem_world_cash_status.depth) 
  170. 	 
  171. 		--Hide the group for the first frame since it takes a frame for tweens to play. 
  172. 		vint_set_property(sub_grp_h, "alpha", 0) 
  173. 		 
  174. 		--Retarget Tweens 
  175. 		vint_set_property(anim_h, "target_handle", grp_h) 
  176. 		 
  177. 		--Randomize Tween Direction 
  178. 		local twn_h = vint_object_find("txt_anchor_twn_1", anim_h) 
  179. 		vint_set_property(twn_h, "end_value", rand_int(-20, 20), rand_int(-0,-30)) 
  180. 		 
  181. 		--Callback tween to kill objects and stuff 
  182. 		local callback_twn_h = vint_object_find("txt_anchor_twn_1", anim_h) 
  183. 		vint_set_property(callback_twn_h, "end_event", "hud_mayhem_cash_destroy") 
  184. 						 
  185. 		--Tint Cash Text 
  186. 		vint_set_property(cash_txt_h, "tint", Hud_mayhem_world_cash_status.color_r, Hud_mayhem_world_cash_status.color_g, Hud_mayhem_world_cash_status.color_b) 
  187. 		 
  188. 		-- +{0}sec   HUD_AMT_SECS 
  189. 		-- +{0}points   HUD_AMT_POINTS 
  190. 		 
  191. 		--HUD_AMT_POINTS 
  192. 		local insertion_text = { [0] = floor(cash_value) } 
  193. 		local amt = "" 
  194.  
  195. 		if display_type == MAYHEM_DISPLAY_TYPE_CASH then 
  196. 			--Cash 
  197. 			amt =  "{GAME_CASH}" .. cash_value 
  198. 		elseif display_type == MAYHEM_DISPLAY_TYPE_FRAUD_UNITS then 
  199. 			--Fraud Units 
  200. 			amt =  (cash_value) .. " {ACT_FRAUD_SCORE_UNIT}" 
  201. 		elseif display_type == MAYHEM_DISPLAY_TYPE_POINTS then 
  202. 			--Points 
  203. 			amt = vint_insert_values_in_string("HUD_AMT_POINTS", insertion_text) 
  204. 		elseif display_type == MAYHEM_DISPLAY_TYPE_SEC then 
  205. 			--Seconds 
  206. 			amt = vint_insert_values_in_string("HUD_AMT_SECS", insertion_text) 
  207. 		elseif display_type == MAYHEM_DISPLAY_TYPE_SEC_2 then 
  208. 			--seconds + green 
  209. 			amt = vint_insert_values_in_string("HUD_AMT_SECS", insertion_text) 
  210. 			--Force green text 
  211. 			vint_set_property(cash_txt_h, "tint", 0, 1, 0.25) 
  212. 		elseif display_type == MAYHEM_DISPLAY_TYPE_CUSTOM then 
  213. 			amt = custom_text 
  214.  
  215. 			--Override default tween end position and rotation 
  216. 			vint_set_property(twn_h, "end_value", rand_int(-25, 25), rand_int(0,10)) 
  217. 			vint_set_property(grp_h, "rotation", 0) 
  218. 		end 
  219. 		 
  220. 		vint_set_property(cash_txt_h, "text_tag", amt)	 
  221. 		 
  222.  
  223. 		--Format Text with or without multiplier 
  224. 		if multiplier ~= 0 then 
  225. 			--Show Multiplier and Align text 
  226. 			 
  227. 			--Set MultiplierText Value 
  228. 			vint_set_property(multiplier_txt_h, "text_tag", "X" .. multiplier) 
  229. 			 
  230. 			--Alignment 
  231. 			local spacing = 5 
  232. 			local c_w, c_h = vint_get_property(cash_txt_h, "screen_size") 
  233. 			local c_x, c_y = vint_get_property(cash_txt_h, "anchor") 
  234. 			local m_w, m_h = vint_get_property(multiplier_txt_h, "screen_size") 
  235. 			local m_x, m_y = vint_get_property(multiplier_txt_h, "anchor") 
  236. 			local half_w = (c_w + m_w + spacing) / 2 
  237. 			local c_x = 0 - half_w  
  238. 			local m_x = c_x + c_w + spacing 
  239. 			 
  240. 			--Set Properties 
  241. 			vint_set_property(cash_txt_h, "anchor", c_x, c_y) 
  242. 			vint_set_property(multiplier_txt_h, "anchor", m_x, m_y) 
  243. 		else 
  244. 			--Hide multiplier and center text 
  245. 			 
  246. 			vint_set_property(multiplier_txt_h, "visible", false) 
  247. 			 
  248. 			--Alignment 
  249. 			local c_w, c_h = vint_get_property(cash_txt_h, "screen_size") 
  250. 			local c_x, c_y = vint_get_property(cash_txt_h, "anchor") 
  251. 			local c_x = 0 - (c_w / 2) 
  252. 			 
  253. 			--Set Properties 
  254. 			vint_set_property(cash_txt_h, "anchor", c_x, c_y) 
  255. 		end 
  256.  
  257. 		--play tween in animation 
  258. 		lua_play_anim(anim_h, 0) 
  259. 		 
  260. 		--Decrement depth 
  261. 		Hud_mayhem_world_cash_status.depth = Hud_mayhem_world_cash_status.depth - 1 
  262. 		 
  263. 		--Store values and handles to process later 
  264. 		Hud_mayhem_world_cash[di_h] = { 
  265. 			di_h = di_h, 
  266. 			grp_h = grp_h, 
  267. 			sub_grp_h = sub_grp_h, 
  268. 			anim_h = anim_h, 
  269. 			twn_h = callback_twn_h 
  270. 		} 
  271. 		 
  272. 	end 
  273.  
  274. 	--Calculate and set the position 
  275. 	local size_x, size_y = vint_get_property(Hud_mayhem_world_cash[di_h].grp_h, "screen_size") 
  276. 	screen_pos_y = screen_pos_y + (line_offset * (size_y - 10)) 
  277. 	vint_set_property(Hud_mayhem_world_cash[di_h].grp_h, "anchor", screen_pos_x, screen_pos_y) 
  278.  
  279. end 
  280.  
  281. function hud_mayhem_text_color_change(text_intensity) 
  282. 	--Combo Color update 
  283. 	--Prepare color morphing based on intensity 
  284. 	local color1, color2, morph_value 
  285. 	if text_intensity < 0.5 then 
  286. 		if MP_enabled == true then 
  287. 			color1 = Hud_mayhem_world_cash_colors["BLUE"] 
  288. 			color2 = Hud_mayhem_world_cash_colors["MID_BLUE"] 
  289. 		else 
  290. 			color1 = Hud_mayhem_world_cash_colors["YELLOW"] 
  291. 			color2 = Hud_mayhem_world_cash_colors["ORANGE"] 
  292. 		end 
  293. 		morph_value = text_intensity / 0.5 
  294. 	else 
  295. 		if text_intensity > 1 then  
  296. 			morph_value = (text_intensity -1) -- 1..2 
  297. 			color1 = Hud_mayhem_world_cash_colors["MID_BLUE"] 
  298. 			color2 = Hud_mayhem_world_cash_colors["DARK_BLUE"] 
  299. 		elseif MP_enabled == true then 
  300. 			color1 = Hud_mayhem_world_cash_colors["MID_BLUE"] 
  301. 			color2 = Hud_mayhem_world_cash_colors["DARK_BLUE"] 
  302. 		else 
  303. 			color1 = Hud_mayhem_world_cash_colors["ORANGE"] 
  304. 			color2 = Hud_mayhem_world_cash_colors["RED"] 
  305. 		end 
  306. 		morph_value = (text_intensity - 0.5) / 0.5 
  307. 	end 
  308. 	 
  309. 	Hud_mayhem_world_cash_status.color_r = color1.r - ((color1.r - color2.r) * morph_value) 
  310. 	Hud_mayhem_world_cash_status.color_g = color1.g - ((color1.g - color2.g) * morph_value) 
  311. 	Hud_mayhem_world_cash_status.color_b = color1.b - ((color1.b - color2.b) * morph_value) 
  312. 	Hud_mayhem_world_cash_status.text_intensity = text_intensity 
  313. end 
  314.  
  315. function hud_mayhem_world_cash_remove(di_h) 
  316. 	--Destroy objects, animation and values 
  317. 	if Hud_mayhem_world_cash[di_h] ~= nil then 
  318. 		--Destroy animation 
  319. 		vint_object_destroy(Hud_mayhem_world_cash[di_h].anim_h) 
  320. 		--Destroy group object 
  321. 		vint_object_destroy(Hud_mayhem_world_cash[di_h].grp_h) 
  322. 		--Destroy stored values 
  323. 		Hud_mayhem_world_cash[di_h] = nil	 
  324. 	end 
  325. end 
  326.  
  327. --Destroys world cash text 
  328. function hud_mayhem_cash_destroy(twn_h, event) 
  329. 	for idx, val in pairs(Hud_mayhem_world_cash) do 
  330. 		if val.twn_h == twn_h then 
  331. 		 
  332. 			--Destroy animation, text object and Data item 
  333. 			vint_object_destroy(val.anim_h) 
  334. 			vint_object_destroy(val.grp_h) 
  335. 			if val.di_h ~= -1 then 
  336. 				vint_datagroup_remove_item("mayhem_local_player_world_cash", val.di_h) 
  337. 			end 
  338. 			 
  339. 			--Destroy stored values 
  340. 			Hud_mayhem_world_cash[idx] = nil	 
  341. 		end 
  342. 	end 
  343. 	 
  344. 	--reset values if this is the last cash item 
  345. 	local cash_item_count = 0 
  346. 	local is_last_item = true 
  347. 	for idx, val in pairs(Hud_mayhem_world_cash) do 
  348. 		cash_item_count = cash_item_count + 1 
  349. 		is_last_item = false 
  350. 		break 
  351. 	end 
  352. end 
  353.  
  354. local Combo_totals = {} 
  355. local Combo_totals_cleanup_data = {} 
  356. local Combo_total_last_update_id = -2 
  357.  
  358. function hud_mayhem_combo_total_update(di_h) 
  359. 	--[[ 
  360. 		VINT_PROP_TYPE_UINT  - Message ID 
  361. 		VINT_PROP_TYPE_FLOAT - World position (x) 
  362. 		VINT_PROP_TYPE_FLOAT - World position (y) 
  363. 		VINT_PROP_TYPE_UINT  - Message crc (can be nil/invalid crc) 
  364. 		VINT_PROP_TYPE_FLOAT - Message display value (can be nil) 
  365. 		VINT_PROP_TYPE_FLOAT - Message meter value (can be nil) 
  366. 		VINT_PROP_TYPE_FLOAT - Text intensity.  -1.0 is off.  Otherwise a 0.0 - 1.0 scale 
  367. 		VINT_PROP_TYPE_INT   - The message type id 
  368. 		VINT_PROP_TYPE_INT   - The symbol id 
  369. 		VINT_PROP_TYPE_INT   - The skin id 
  370. 		VINT_PROP_TYPE_BOOL  - Play animations 
  371. 		VINT_PROP_TYPE_BOOL  - Show the meter 
  372. 		VINT_PROP_TYPE_BOOL  - If the meter is flashing 
  373. 	]] 
  374. 	local id, x, y, desc_crc, display_value, meter_value, text_intensity, value_type, value_symbol, skin, do_animation, show_meter, meter_flashing = vint_dataitem_get(di_h) 
  375. 	 
  376. 	-- When the data item is first initialized, nil values are passed.  Catch this and exit. 
  377. 	if id == nil then 
  378. 		return 
  379. 	end 
  380. 	 
  381. 	if Combo_totals[id] == nil then 
  382. 		--New ID 
  383. 		 
  384. 		--Fade out anim... and set to cleanup... 
  385. 		local old_combo_total = Combo_totals[Combo_total_last_update_id] 
  386. 		if old_combo_total ~= nil then 
  387. 			--Play anim out, the callback will handle the rest of cleanup... 
  388. 			lua_play_anim(old_combo_total.anim_out_h) 
  389. 			Combo_total_last_update_id = HUD_PLAYER_INVALID_ID 
  390. 		end 
  391. 		 
  392. 		if id == HUD_PLAYER_INVALID_ID then 
  393. 			--just needed to destroy the old one 
  394. 			return 
  395. 		end 
  396. 		 
  397. 		local item_h = vint_object_clone(Hud_mayhem_combo_total_item_h) 
  398. 		 
  399. 		vint_set_property(item_h, "visible", true) 
  400. 		 
  401. 		--Play animation in, only if we need to... 
  402. 		local anim_in_h = vint_object_find("combo_total_in_anim") 
  403. 		 
  404. 		if do_animation ~= true then 
  405. 			--smooth fade in... 
  406. 			anim_in_h = vint_object_find("combo_total_smooth_in_anim") 
  407. 		end 
  408. 		 
  409. 		--Clone animation and target item... 
  410. 		anim_in_h = vint_object_clone(anim_in_h) 
  411. 		vint_set_property(anim_in_h, "target_handle", item_h) 
  412.  
  413. 		--Clone out animation and target item... 
  414. 		local anim_out_h = vint_object_find("combo_total_out_anim") 
  415. 		anim_out_h = vint_object_clone(anim_out_h) 
  416. 		vint_set_property(anim_out_h, "target_handle", item_h) 
  417. 		 
  418. 		--Set callback and data for animation to hide item and clean up the data... 
  419. 		local twn_h = vint_object_find("combot_total_out_twn", anim_out_h) 
  420. 		vint_set_property(twn_h, "end_event", "hud_mayhem_combo_total_cleanup") 
  421. 		Combo_totals_cleanup_data[twn_h] = id 
  422. 		 
  423. 		-- Set the skin and colors for the message 
  424. 		if skin == nil or skin < 0 then 
  425. 			skin = HP_SKIN_DEFAULT 
  426. 		end 
  427. 		 
  428. 		local title_color = Hud_player_skins[skin][HP_TEXT] 
  429. 		local val_color = Hud_player_skins[skin][HP_VALUE] 
  430. 			 
  431. 		local title_txt_h = vint_object_find("combo_title_txt", item_h) 
  432. 		local value_txt_h = vint_object_find("combo_value_txt", item_h) 
  433. 		vint_set_property(title_txt_h, "tint", title_color[1], title_color[2], title_color[3]) 
  434. 		vint_set_property(value_txt_h, "tint", val_color[1], val_color[2], val_color[3]) 
  435.  
  436. 		--Configure meter if needed 
  437. 		local meter = Vdo_gsi_meter:new("combo_total_meter", item_h) 
  438. 		local combo_total_meter_value_h = vint_object_find("combo_total_meter_value", item_h) 
  439. 		local meter_val_in_anim_h = vint_object_find("combo_total_meter_val_in_anim") 
  440. 		meter_val_in_anim_h = vint_object_clone(meter_val_in_anim_h) 
  441. 		 
  442. 		if show_meter == true then 
  443. 			--Show combo meter/hide value text... 
  444. 			meter:set_visible(true) 
  445. 			vint_set_property(value_txt_h, "visible", false) 
  446. 			vint_set_property(combo_total_meter_value_h, "visible", true) 
  447. 			 
  448. 			--Creates the meter(initializing values.. 
  449. 			meter:create() 
  450. 			 
  451. 			--target animation to combo meter value... 
  452. 			vint_set_property(meter_val_in_anim_h, "target_handle", combo_total_meter_value_h) 
  453. 			 
  454. 			-- Set the default color 
  455. 			vint_set_property(combo_total_meter_value_h, "tint", val_color[1], val_color[2], val_color[3]) 
  456. 		else 
  457. 			meter:set_visible(false) 
  458. 			vint_set_property(value_txt_h, "visible", true) 
  459. 			vint_set_property(combo_total_meter_value_h, "visible", false) 
  460. 		end 
  461. 		 
  462. 		--Fade in... 
  463. 		lua_play_anim(anim_in_h) 
  464.  
  465. 		--Store off for later... 
  466. 		Combo_totals[id] = { 
  467. 			item_h = item_h,  
  468. 			meter = meter, 
  469. 			meter_display_value = display_value - 2, -- Why do it this way?  -1 might be a valid value, but this will always work 
  470. 			text_intensity = -1, -- Default, means no text intensity is used 
  471. 			anim_in_h = anim_in_h, 
  472. 			anim_out_h = anim_out_h, 
  473. 			meter_val_in_anim_h = meter_val_in_anim_h, 
  474. 		} 
  475. 	end 
  476. 	 
  477. 	--update! 
  478. 	local combo_total = Combo_totals[id] 
  479. 	 
  480. 	vint_set_property(combo_total.item_h, "anchor", x + HUD_COMBO_OFFESET_X, y + HUD_COMBO_OFFESET_Y) 
  481. 	local title_txt_h = vint_object_find("combo_title_txt", combo_total.item_h) 
  482. 	local value_txt_h = vint_object_find("combo_value_txt", combo_total.item_h) 
  483. 	 
  484. 	--Set title description... 
  485. 	if desc_crc ~= nil and desc_crc ~= 0 then 
  486. 		vint_set_property(title_txt_h, "text_tag_crc", desc_crc) 
  487. 	end 
  488. 	 
  489. 	--Set symbol 
  490. 	local symbol = "" 
  491. 	if value_symbol == HPS_MINUS then 
  492. 		symbol = "-" 
  493. 	elseif value_symbol == HPS_PLUS then 
  494. 		symbol = "+" 
  495. 	elseif value_symbol == HPS_MULTIPLIER then 
  496. 		symbol = "X" 
  497. 	end 
  498. 	 
  499. 	--Handle the display value being nil 
  500. 	if display_value == nil then 
  501. 		display_value = 0 
  502. 	end 
  503. 	 
  504. 	--Set amount... 
  505. 	local insertion_text = { [0] = symbol .. floor(display_value) } 
  506. 	local amt = "" 
  507. 	 
  508. 	if value_type == HPT_NONE then 
  509. 		-- Standard integer 
  510. 		amt = symbol .. floor(display_value) 
  511. 	elseif value_type == HPT_POINTS then 
  512. 		-- Points 
  513. 		amt = vint_insert_values_in_string("HUD_AMT_POINTS", insertion_text) 
  514. 	elseif value_type == HPT_DISTANCE then 
  515. 		-- Distance 
  516. 		amt = symbol .. format_distance(display_value) 
  517. 	elseif value_type == HPT_TIME then 
  518. 		-- Seconds . Milliseconds 
  519. 		amt = symbol .. format_time(display_value, true, true) 
  520. 	elseif value_type == HPT_SECONDS then 
  521. 		-- Seconds without milliseconds 
  522. 		amt = symbol .. format_time(display_value, false, true) 
  523. 	elseif value_type == HPT_MONEY then 
  524. 		-- Cash 
  525. 		amt = symbol .. "{GAME_CASH}" .. format_cash(floor(display_value)) 
  526. 	elseif value_type == HPT_FRAUD_UNITS then 
  527. 		-- Fraud Units 
  528. 		amt = symbol .. format_cash(floor(display_value)) .. " {ACT_FRAUD_SCORE_UNIT}"		 
  529. 	elseif value_type == HPT_DEGREES then 
  530. 		-- Degrees 
  531. 		amt = vint_insert_values_in_string("HUD_AMT_DEGREES", insertion_text) 
  532. 	elseif value_type == HPT_MULTIPLIER then 
  533. 		-- Multiplier, A digit formatted as such: 1.5X 
  534. 		 
  535. 		-- Make it show one significant digit 
  536. 		display_value = display_value * 10 
  537. 		floor(display_value) 
  538. 		display_value = display_value / 10 
  539. 		 
  540. 		amt = symbol .. display_value .. "X" 
  541. 	elseif value_type == HPT_PERCENT then 
  542. 		display_value = floor( display_value * 100 ) 
  543. 		amt = symbol .. display_value .. "%%" 
  544. 	elseif value_type == HPT_MESSAGE_ONLY then 
  545. 		-- No display value at all 
  546. 		vint_set_property(value_txt_h, "visible", false) 
  547. 		vint_set_property(combo_total_meter_value_h, "visible", false) 
  548. 	end 
  549. 	 
  550. 	-- Set the value to the correct place depending on if the meter should show. 
  551. 	if show_meter == true then 
  552. 		local combo_total_meter_value_h = vint_object_find("combo_total_meter_value", combo_total.item_h) 
  553. 		local meter = combo_total.meter 
  554. 		 
  555. 		-- First we need to set the color based on if a text_intensity exists and has been changed 
  556. 		if combo_total.text_intensity ~= text_intensity then 
  557. 			if text_intensity < 0 then 
  558. 				local val_color = Hud_player_skins[skin][HP_VALUE] 
  559. 				vint_set_property(combo_total_meter_value_h, "tint", val_color[1], val_color[2], val_color[3]) 
  560. 			else 
  561. 				hud_mayhem_text_color_change(text_intensity) 
  562. 				vint_set_property(combo_total_meter_value_h, "tint", Hud_mayhem_world_cash_status.color_r, Hud_mayhem_world_cash_status.color_g, Hud_mayhem_world_cash_status.color_b) 
  563. 			end 
  564. 			 
  565. 			combo_total.text_intensity = text_intensity 
  566. 		end 
  567. 		 
  568. 		-- Next update the display value if it has changed 
  569. 		if combo_total.meter_display_value ~= display_value then 
  570. 			--Set value of bonus label... 
  571. 			vint_set_property(combo_total_meter_value_h, "text_tag", amt) 
  572. 			 
  573. 			--realign text to size of it so it stays centered for animation but left aligned to the title... 
  574. 			--Reset the text to be scaled at 1 to measure... 
  575. 			vint_set_property(combo_total_meter_value_h, "scale", 1, 1) 
  576. 			local width, height = element_get_actual_size(combo_total_meter_value_h) 
  577. 			local x, y = vint_get_property(combo_total_meter_value_h, "anchor") 
  578. 			x = width/2 
  579. 			vint_set_property(combo_total_meter_value_h, "anchor", x, y) 
  580.  
  581. 			x, y = vint_get_property(meter.handle, "anchor") 
  582. 			x = width + 8 -- half the width of our combo value and 5 for padding... 
  583. 			vint_set_property(meter.handle, "anchor", x, y) 
  584. 			 
  585. 			--trigger the scale down animation of the text. 
  586. 			lua_play_anim(combo_total.meter_val_in_anim_h) 
  587. 			 
  588. 			combo_total.meter_display_value = display_value 
  589. 		end 
  590. 		 
  591. 		--Make sure the meter range is valid 
  592. 		if meter_value < 0 then 
  593. 			meter_value = 0 
  594. 		elseif meter_value > 1 then 
  595. 			meter_value = 1 
  596. 		end 
  597.  
  598. 		--Always update the meter... 
  599. 		meter:update(true, "Mayhem", 0, meter_value, meter_flashing) 
  600. 		 
  601. 	-- No meter, just set it to the regular value text tag. 
  602. 	else 
  603. 		-- First we need to set the color based on if a text_intensity exists and has been changed 
  604. 		if combo_total.text_intensity ~= text_intensity then 
  605. 			if text_intensity < 0 then 
  606. 				local val_color = Hud_player_skins[skin][HP_VALUE] 
  607. 				vint_set_property(value_txt_h, "tint", val_color[1], val_color[2], val_color[3]) 
  608. 			else 
  609. 				hud_mayhem_text_color_change(text_intensity) 
  610. 				vint_set_property(value_txt_h, "tint", Hud_mayhem_world_cash_status.color_r, Hud_mayhem_world_cash_status.color_g, Hud_mayhem_world_cash_status.color_b) 
  611. 			end 
  612. 			 
  613. 			combo_total.text_intensity = text_intensity 
  614. 		end 
  615. 		 
  616. 		vint_set_property(value_txt_h, "text_tag", amt) 
  617. 	end 
  618. 	 
  619. 	if x == 0 and y == 0 then 
  620. 		vint_set_property(combo_total.item_h, "visible", false) 
  621. 	else 
  622. 		vint_set_property(combo_total.item_h, "visible", true) 
  623. 	end 
  624. 	 
  625. 	--Store off update id... 
  626. 	Combo_total_last_update_id = id 
  627. end 
  628.  
  629.  
  630. ------------------------------------------------------------------------------- 
  631. -- Cleans up the combo total after the out animation has played... 
  632. ------------------------------------------------------------------------------- 
  633. function hud_mayhem_combo_total_cleanup(twn_h) 
  634. 	local combo_destroy_data = Combo_totals_cleanup_data[twn_h]  
  635. 	if combo_destroy_data ~= nil then 
  636. 	 
  637. 		local combo_data = Combo_totals[combo_destroy_data] 
  638. 	 
  639. 		--Destroy Objects... 
  640. 		vint_object_destroy(combo_data.item_h) 
  641. 		vint_object_destroy(combo_data.anim_in_h) 
  642. 		vint_object_destroy(combo_data.anim_out_h) 
  643. 		vint_object_destroy(combo_data.meter_val_in_anim_h) 
  644. 		 
  645. 		--Destroy Data in cleanup table... 
  646. 		Combo_totals_cleanup_data[twn_h] = nil 
  647. 		 
  648. 		--Destroy data in  combo totals table... 
  649. 		Combo_totals[combo_destroy_data] = nil 
  650. 	end 
  651. end 
  652.