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