./hud_noto.lua

  1. ------------------------------------------------------------------------------- 
  2. -- This deals with the notoriety icons around the minimap. 
  3. --------------------------------------------------------------------------------- 
  4.  
  5. --Notoriety States 
  6. local NOTO_STATE_INITIALIZE	= -1 
  7. local NOTO_STATE_HIDDEN 		= 0 
  8. local NOTO_STATE_VISIBLE 		= 1 
  9. local NOTO_STATE_ADD				= 2 
  10. local NOTO_STATE_REMOVE			= 3 
  11. local NOTO_STATE_DECAYING		= 4 
  12. local NOTO_STATE_INCREASING	= 5 
  13.  
  14. ------------------------------------------------------------------------------- 
  15. -- Hud notoriety data. 
  16. --   
  17. Hud_noto_data = { 
  18. 	--[[gangs = { 
  19. 		cur_team = 0, 
  20. 		cur_level = -1, 
  21. 		teams = { 
  22. 			["brotherhood"]	= 	{icon_image = "ui_hud_not_syndicate",	noto_level = -1, meter = -1}, 
  23. 			["ronin"]	= 			{icon_image = "ui_hud_not_syndicate",	noto_level = -1, meter = -1}, 
  24. 			["samedi"]	= 			{icon_image = "ui_hud_not_syndicate",	noto_level = -1, meter = -1}, 
  25. 		}, 
  26. 		icons = { 
  27. 			[1] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  28. 			[2] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  29. 			[3] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  30. 			[4] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  31. 			[5] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0} 
  32. 		}, 
  33. 		meter = { meter_fill_h = 0, meter_bg_h = 0, start_angle = 3.141592654, end_angle = 6.283185307, cw = true, tween = 0 }, 
  34. 	},]]-- 
  35.  
  36. 	police = { 
  37. 		cur_team = 0, 
  38. 		cur_level = -1, 
  39. 		teams = { 
  40. 			["police"]	= {icon_image = "ui_hud_not_police", noto_level = -1, meter = -1}, 
  41. 		}, 
  42. 		icons = { 
  43. 			[1] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  44. 			[2] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  45. 			[3] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  46. 			[4] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  47. 			[5] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  48. 			[6] = {state = -1, state_prev = -1, tween_end = 0, anim_0 = 0, anim_1 = 0, anim_2 = 0, anim_3 = 0, bmp_clone_0 = 0, bmp_clone_1 = 0}, 
  49. 		}, 
  50. 		meter = { meter_fill_h = 0, meter_bg_h = 0, start_angle = 5.327, end_angle = 6.18, cw = false, tween = 0 }, --3.141592654 --6.28318 
  51. 	}, 
  52. } 
  53.  
  54. ------------------------------------------------------------------------- 
  55. -- Initialize and subscribe to data. 
  56. --  
  57. function hud_noto_init() 
  58.  
  59. 	--Notoriety Meters 
  60. 	--Hud_noto_data.gangs.meter.meter_fill_h = vint_object_find("noto_bar_gang") 
  61. 	Hud_noto_data.police.meter.meter_fill_h = vint_object_find("noto_bar_police") 
  62. 	--Hud_noto_data.gangs.meter.meter_bg_h = vint_object_find("noto_bar_gang_bg") 
  63. 	--Hud_noto_data.police.meter.meter_bg_h = vint_object_find("noto_bar_police_bg") 
  64. 	 
  65. 	--vint_set_property(Hud_noto_data.gangs.meter.meter_fill_h, "visible", false) 
  66. 	vint_set_property(Hud_noto_data.police.meter.meter_fill_h, "visible", false) 
  67. 	--vint_set_property(Hud_noto_data.gangs.meter.meter_bg_h, "visible", false) 
  68. 	--vint_set_property(Hud_noto_data.police.meter.meter_bg_h, "visible", false) 
  69. 	 
  70. 	--the top of the map barely peaks out on pc for some reason 
  71. 	local map_pc_move_grp_h = vint_object_find("map_pc_move_grp") 
  72. 	if game_get_platform() == "PC" then 
  73. 		vint_set_property(map_pc_move_grp_h, "anchor", 0, -1) 
  74. 	else 
  75. 		vint_set_property(map_pc_move_grp_h, "anchor", 0, 0) 
  76. 	end 
  77. 	 
  78. 	------ 
  79. 	 
  80. 	--find reference base icons 
  81. 	for i = 1, 6 do 
  82. 		local police_icon_h = vint_object_find("police_noto_icon_" .. i) 
  83. 		--Hud_noto_data.gangs.icons[i].icon_h = gang_icon_h 
  84. 		Hud_noto_data.police.icons[i].icon_h = police_icon_h 
  85. 	end 
  86.  
  87. 	--decay tweens must play at the same time. so we start the animation but disable the tweens and enable them as we go. 
  88. 	local decaying_anim_h = vint_object_find("noto_decaying_anim") 
  89. 	local noto_decaying_twn_h = vint_object_find("noto_decaying_twn", decaying_anim_h)  
  90. 	vint_set_property(noto_decaying_twn_h, "state", VINT_TWEEN_STATE_DISABLED) 
  91. 	lua_play_anim(decaying_anim_h) 
  92. 	 
  93. 	--Notoriety 
  94. 	vint_datagroup_add_subscription("sr2_notoriety", "update", "hud_noto_change") 
  95. 	vint_datagroup_add_subscription("sr2_notoriety", "insert", "hud_noto_change") 
  96.  
  97. end 
  98.  
  99. ------------------------------------------------------------------------------- 
  100. -- Datagroup callback 
  101. --  
  102. function hud_noto_change(data_item_h, event_name) 
  103. 	local team_name, noto_level, noto_icon = vint_dataitem_get(data_item_h) 
  104. 	local noto_data, display_data, icon_data, meter_data, team_data 
  105. 	-- find the interesting data for team 
  106. 	for key, noto_type in pairs(Hud_noto_data) do 
  107. 		if noto_type.teams[team_name] ~= nil then 
  108. 			noto_data = noto_type 
  109. 			display_data = noto_type.teams[team_name] 
  110. 			icon_data = noto_type.icons 
  111. 			meter_data = noto_type.meter 
  112. 			break 
  113. 		end 
  114. 	end 
  115. 	 
  116. 	 
  117.  
  118. 	if noto_data == nil then 
  119. 		-- not an interesting team so outta here 
  120. 		return 
  121. 	end 
  122.  
  123. 	-- update the notoriety table 
  124. 	display_data.noto_level = noto_level 
  125.  
  126. 	-- find the team in this group with highest notoriety 
  127. 	noto_level = -1 
  128. 	team_name = nil 
  129. 	for key, value in pairs(noto_data.teams) do 
  130. 		if value.noto_level > noto_level then 
  131. 			team_name = key 
  132. 			noto_level = value.noto_level 
  133. 			team_data = value 
  134. 		end 
  135. 	end 
  136.  
  137. 	-- better safe then sorry 
  138. 	if team_name == nil then 
  139. 		return 
  140. 	end 
  141.  
  142. 	local base_new_noto = floor(noto_level) 
  143. 	local base_old_noto = floor(noto_data.cur_level) 
  144. 	local icon_h = 0 
  145.  
  146. 	-- new team, animate in all icons 
  147. 	if team_name ~= noto_data.cur_team then 
  148. 		--update current image 
  149. 		for i = 1, 6 do 
  150. 			--Set image of icon... 
  151. 			vint_set_property(noto_data.icons[i], "image", team_data.icon_image) 
  152. 		 
  153. 			--set the proper state for the icon... 
  154. 			if base_new_noto >= i then 
  155. 				hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_ADD) 
  156. 			else 
  157. 				hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_REMOVE) 
  158. 			end 
  159. 		end 
  160.  
  161. 		noto_data.cur_team = team_name 
  162. 		 
  163. 		--Make sure we are visible... 
  164. 		hud_player_notoriety_show() 
  165.  
  166. 	-- noto on the rise, animate in all new icons 
  167. 	elseif base_new_noto > base_old_noto then 
  168. 		for i = 1, 6 do 
  169. 			icon_h = noto_data.icons[i].icon_h 
  170. 			if base_new_noto >= i and base_old_noto < i then 
  171. 				hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_ADD) 
  172. 			elseif base_new_noto < i then 
  173. 				hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_REMOVE) 
  174. 			else 
  175. 				hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_VISIBLE) 
  176. 			end 
  177. 		end 
  178. 		 
  179. 		--Make sure we are visible... 
  180. 		hud_player_notoriety_show() 
  181.  
  182. 	-- noto falling, animate the highest active icon 
  183. 	elseif base_new_noto < base_old_noto then 
  184. 		for i = 1, 6 do 
  185. 			if base_new_noto == i then 
  186. 				hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_ADD) 
  187. 			elseif base_new_noto < i then 
  188. 				hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_REMOVE) 
  189. 			end 
  190. 		end 
  191. 	end 
  192.  
  193. 	-- update meter 
  194. 	local part_new_noto = noto_level - base_new_noto 
  195. 	 
  196. 	if meter_data.cw == false then 
  197. 		-- Lower Bar Update 
  198. 		local start_angle = meter_data.end_angle + ((meter_data.start_angle - meter_data.end_angle) * part_new_noto) 
  199. 		vint_set_property(meter_data.meter_fill_h, "start_angle", start_angle) 
  200. 		--vint_set_property(meter_data.meter_bg_h, "start_angle", start_angle - 0.02) 
  201. 		 
  202. 	else 
  203. 		-- Upper Bar Update 
  204. 		local end_angle = meter_data.start_angle + ((meter_data.end_angle - meter_data.start_angle) * part_new_noto) 
  205. 		vint_set_property(meter_data.meter_fill_h, "end_angle", end_angle) 
  206. 		--vint_set_property(meter_data.meter_bg_h, "end_angle", end_angle + 0.02) 
  207. 		debug_print("vint","NOTO end_angle = "..var_to_string(end_angle).."\n") 
  208. 	end 
  209. 	 
  210. 	if part_new_noto == 0 then 
  211. 		-- If the meter is at 0 then we should hide it 
  212. 		vint_set_property(meter_data.meter_fill_h, "visible", false) 
  213. 		--vint_set_property(meter_data.meter_bg_h, "visible", false) 
  214. 	else 
  215. 		--If the meter isn't at zero then make it visible 
  216. 		vint_set_property(meter_data.meter_fill_h, "visible", true) 
  217. 		--vint_set_property(meter_data.meter_bg_h, "visible", true) 
  218. 	end 
  219. 	 
  220. 	if base_new_noto >= 1 then 
  221. 		vint_set_property(meter_data.meter_fill_h, "rotation", (base_new_noto - 1) * (60 * DEG_TO_RAD)) 
  222. 		vint_set_property(meter_data.meter_fill_h, "visible", true) 
  223. 	else 
  224. 		vint_set_property(meter_data.meter_fill_h, "visible", false) 
  225. 	end 
  226. 	 
  227. 	--determine if we are still, decaying or increasing 
  228. 	local noto_diff = noto_level - noto_data.cur_level 
  229. 	if base_new_noto == base_old_noto then 
  230.  
  231. 		if noto_diff < -0.001 then 
  232. 			--decaying... 
  233. 			for i = 1, 6 do 
  234. 				icon_h = noto_data.icons[i].icon_h 
  235. 				if base_new_noto == i then 
  236. 					hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_DECAYING) 
  237. 				end 
  238. 			end 
  239. 		elseif noto_diff > 0.001 then 
  240. 			--Increase... 
  241. 			for i = 1, 6 do 
  242. 				icon_h = noto_data.icons[i].icon_h 
  243. 				if base_new_noto == i then 
  244. 					hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_INCREASING) 
  245. 				end 
  246. 			end 
  247. 		elseif abs(noto_level) > 0.0001 then 
  248. 			--probably the same level again just make sure we are visible... 
  249. 			for i = 1, 6 do 
  250. 				icon_h = noto_data.icons[i].icon_h 
  251. 				if base_new_noto == i then 
  252. 					hud_noto_icon_set_state(noto_data.icons[i], NOTO_STATE_VISIBLE) 
  253. 				end 
  254. 			end 
  255. 		end 
  256. 	end 
  257.  
  258. 	--store the current level to the notoriety type(gang or police) 
  259. 	noto_data.cur_level = noto_level 
  260. 	noto_data.base_new_noto = base_new_noto 
  261. 	 
  262. 	--Process the states... 
  263. 	hud_noto_icon_process_state(noto_data) 
  264. 	 
  265. 	-- find lowest notoriety value 
  266. 	local lowest_noto_level = 0 
  267. 	local x_data = Hud_noto_data 
  268. 	for key, noto_type in pairs(Hud_noto_data) do 
  269. 		if noto_type.cur_level ~= -1 then 
  270. 			if noto_type.cur_level > lowest_noto_level then 
  271. 				lowest_noto_level = noto_type.cur_level 
  272. 			end		 
  273. 		end 
  274. 	end 
  275. 	 
  276. 	--hide notoriety if we are less than 1. 
  277. 	if lowest_noto_level < 1 then 
  278. 		hud_player_notoriety_hide() 
  279. 	end 
  280. end 
  281.  
  282. ------------------------------------------------------------------------------- 
  283. -- Icon set state 
  284. -- 
  285. function hud_noto_icon_set_state(icon, state) 
  286. 	if state == NOTO_STATE_ADD then 
  287. 		if icon.state == NOTO_STATE_VISIBLE then 
  288. 			--Don't try to re-add an icon. 
  289. 			icon.state = NOTO_STATE_VISIBLE 
  290. 		else 
  291. 			icon.state = NOTO_STATE_ADD 
  292. 		end 
  293. 	elseif state == NOTO_STATE_REMOVE then 
  294. 		if icon.state == NOTO_STATE_HIDDEN then 
  295. 			--Don't try to re-hide an icon 
  296. 			icon.state = NOTO_STATE_HIDDEN 
  297. 		else 
  298. 			icon.state = NOTO_STATE_REMOVE 
  299. 		end 
  300. 	elseif state == NOTO_STATE_VISIBLE then 
  301. 		if icon.state == NOTO_STATE_ADD then 
  302. 			--If the state is already adding, we just keep it that way instead of trying to force visible. 
  303. 			icon.state = NOTO_STATE_ADD 
  304. 		else 
  305. 			icon.state = NOTO_STATE_VISIBLE 
  306. 		end 
  307. 	elseif state == NOTO_STATE_INCREASING then 
  308. 		if icon.state == NOTO_STATE_ADD then 
  309. 			--can't change to increasing if we are currently adding. 
  310. 			icon.state = NOTO_STATE_ADD 
  311. 		else 
  312. 			icon.state = NOTO_STATE_INCREASING 
  313. 		end		 
  314. 	else 
  315. 		icon.state = state 
  316. 	end 
  317. end 
  318.  
  319. ------------------------------------------------------------------------------- 
  320. -- Silenetly resets the state. This happens after our ADD, REMOVE and PULSE 
  321. -- callbacks. This way we don't reprocess a hidden state. 
  322. -- 
  323. function hud_noto_icon_set_state_silent(icon, state) 
  324. 	icon.state = state 
  325. 	icon.state_prev = state 
  326. end 
  327.  
  328. ------------------------------------------------------------------------------- 
  329. -- Processes the state for the specific noto type. 
  330. -- noto_type			(gang or police) Hud_noto_data.gang or Hud_noto_data.police 
  331. -- process_icon_id 	if icon# is specified, we will only process that icon. 
  332. -- 
  333. function hud_noto_icon_process_state(noto_type) 
  334. 	-- Loop through our icons and change state... 
  335. 	for icon_id = 1, 6 do 
  336. 		local level = noto_type.base_new_noto 
  337. 		local icon = noto_type.icons[icon_id] 
  338. 		local icon_h = icon.icon_h 
  339. 		 
  340. 		if (icon_id < level) or (icon_id == level and level == 6) then 
  341. 			vint_set_property(icon_h, "tint", COLOR_HUD_NOTO_FULL_SECTION.R, COLOR_HUD_NOTO_FULL_SECTION.G, COLOR_HUD_NOTO_FULL_SECTION.B) 
  342. 		elseif icon_id == level then 
  343. 			vint_set_property(icon_h, "tint", COLOR_HUB_NOTO_RISING_SECTION.R, COLOR_HUD_NOTO_FULL_SECTION.G, COLOR_HUD_NOTO_FULL_SECTION.B) 
  344. 		end 
  345. 		 
  346. 		if icon.state ~= icon.state_prev then 
  347. 			-- We need to change states now... 
  348. 			if icon.state == NOTO_STATE_ADD then 
  349. 				hud_noto_icon_add(icon_h, icon, icon_id, level) 
  350. 			elseif icon.state == NOTO_STATE_DECAYING then 
  351. 				hud_noto_icon_decay(icon_h, icon) 
  352. 			elseif icon.state == NOTO_STATE_INCREASING then 
  353. 				hud_noto_icon_pulse(icon_h, icon) 
  354. 			elseif icon.state == NOTO_STATE_REMOVE then 
  355. 				hud_noto_icon_remove(icon_h, icon) 
  356. 			elseif icon.state == NOTO_STATE_VISIBLE then 
  357. 				hud_noto_icon_visible(icon_h, icon, icon_id, level)	 
  358. 			elseif icon.state == NOTO_STATE_HIDDEN then 
  359. 				hud_noto_icon_hide(icon_h, icon) 
  360. 			end 
  361. 			icon.state_prev = icon.state 
  362. 		end 
  363. 	end 
  364. end 
  365.  
  366. ------------------------------------------------------------------------------- 
  367. -- Hides icons with animation... 
  368. --  
  369. function hud_noto_icon_remove(icon_h, icon) 
  370. 	vint_object_destroy(icon.bmp_clone_0) 
  371. 	vint_object_destroy(icon.bmp_clone_1) 
  372. 	vint_object_destroy(icon.anim_0) 
  373. 	vint_object_destroy(icon.anim_1) 
  374. 	vint_object_destroy(icon.anim_2) 
  375. 	vint_object_destroy(icon.anim_3) 
  376.  
  377. 	--ANIMATE: Fade Icon Away 
  378. 	local anim_3 = vint_object_find("noto_fade_out_anim") 
  379. 	local anim_clone_3 = vint_object_clone(anim_3) 
  380.  
  381. 	--Targets 
  382. 	local anim_3_alpha_tween = vint_object_find("noto_alpha_3", anim_clone_3) 
  383. 	vint_set_property(anim_3_alpha_tween, "target_handle", icon_h) 
  384. 	local anim_3_alpha_b_tween = vint_object_find("noto_alpha_3b", anim_clone_3) 
  385. 	vint_set_property(anim_3_alpha_b_tween, "target_handle", icon_h) 
  386.  
  387. 	--Reset Tween value 
  388. 	local tint_r, tint_g, tint_b = vint_get_property(icon_h, "tint") 
  389. 	vint_set_property(anim_3_alpha_tween, "start_value", tint_r, tint_g, tint_b) 
  390.  
  391. 	--Callback 
  392. 	vint_set_property(anim_3_alpha_tween, "end_event",		"hud_noto_icon_hide_end") 
  393.  
  394. 	lua_play_anim(anim_clone_3, 0); 
  395.  
  396. 	icon.bmp_clone_0 = 0 
  397. 	icon.bmp_clone_1 = 0 
  398. 	icon.anim_0 = 0 
  399. 	icon.anim_1 = 0 
  400. 	icon.anim_2 = 0 
  401. 	icon.anim_3 = anim_clone_3 
  402. 	icon.tween_end = anim_3_alpha_tween 
  403. end 
  404.  
  405. function hud_noto_icon_hide_end(tween_h, event_name) 
  406. 	-- search for indicated tween and clean up 
  407. 	for k, noto_data in pairs(Hud_noto_data) do 
  408. 		for key, icon in pairs(noto_data.icons) do 
  409. 			if icon.tween_alpha_out == tween_h then 
  410. 				vint_object_destroy(icon.bmp_clone_0) 
  411. 				vint_object_destroy(icon.bmp_clone_1) 
  412. 				vint_object_destroy(icon.anim_0) 
  413. 				vint_object_destroy(icon.anim_1) 
  414. 				vint_object_destroy(icon.anim_2) 
  415. 				vint_object_destroy(icon.anim_3) 
  416. 				icon.bmp_clone_0 = 0 
  417. 				icon.bmp_clone_1 = 0 
  418. 				icon.anim_0 = 0 
  419. 				icon.anim_1 = 0 
  420. 				icon.anim_2 = 0 
  421. 				icon.anim_3 = 0 
  422. 				icon.tween_show = 0 
  423. 				 
  424. 				hud_noto_icon_set_state_silent(icon, NOTO_STATE_HIDDEN) 
  425. 				return 
  426. 			end 
  427. 		end 
  428. 	end 
  429. end 
  430.  
  431. ------------------------------------------------------------------------------- 
  432. -- Shows icons with animation... 
  433. --  
  434. function hud_noto_icon_add(icon_h, icon, icon_id, level) 
  435. 	vint_set_property(icon_h, "visible", true) 
  436. 	--vint_set_property(Hud_noto_data.police.meter.meter_fill_h, "visible", false) 
  437. 	 
  438. 	--Destroy all objects if there are any currently being animated 
  439. 	vint_object_destroy(icon.bmp_clone_0) 
  440. 	vint_object_destroy(icon.bmp_clone_1) 
  441. 	vint_object_destroy(icon.anim_0) 
  442. 	vint_object_destroy(icon.anim_1) 
  443. 	vint_object_destroy(icon.anim_2) 
  444. 	vint_object_destroy(icon.anim_3) 
  445.  
  446. 	--Create bitmap clones for animation 
  447. 	local bmp_clone_0 = vint_object_clone(icon_h) 
  448. 	vint_set_property(bmp_clone_0, "depth",	-1) 
  449.  
  450. 	--Clone the notoriety anim and adjust the childs targets 
  451. 	 
  452. 	--ANIMATION: Blink white 
  453. 	local anim_0 = vint_object_find("noto_pulse_anim") 
  454. 	local anim_clone_0 = vint_object_clone(anim_0) 
  455. 	 
  456. 	--Target Tweens 
  457. 	local noto_pulse_1 = vint_object_find("noto_pulse_1", anim_clone_0) 
  458. 	local noto_pulse_2 = vint_object_find("noto_pulse_2", anim_clone_0) 
  459. 	local noto_pulse_3 = vint_object_find("noto_pulse_3", anim_clone_0) 
  460. 	local noto_pulse_4 = vint_object_find("noto_pulse_4", anim_clone_0) 
  461. 	local noto_pulse_end = vint_object_find("noto_pulse_end", anim_clone_0) 
  462. 	 
  463. 	vint_set_property(noto_pulse_1, "target_handle",	bmp_clone_0) 
  464. 	vint_set_property(noto_pulse_2, "target_handle",	bmp_clone_0) 
  465. 	vint_set_property(noto_pulse_3, "target_handle",	bmp_clone_0) 
  466. 	vint_set_property(noto_pulse_4, "target_handle",	bmp_clone_0) 
  467. 	vint_set_property(noto_pulse_end, "target_handle",	bmp_clone_0) 
  468. 	 
  469. 	--ANIMATION: Small To Large 
  470. 	local anim_1 = vint_object_find("noto_add_up_anim"); 
  471. 	local anim_clone_1 = vint_object_clone(anim_1) 
  472. 	 
  473. 	--[[ 
  474. 	--ANIMATION: BASIC FADE IN 
  475. 	local anim_2 = vint_object_find("noto_fade_in_anim") 
  476. 	local anim_clone_2 = vint_object_clone(anim_2)  
  477. 		 
  478. 	--Target Tweens 
  479. 	local anim_2_alpha_tween = vint_object_find("noto_alpha_2", anim_clone_2) 
  480. 	vint_set_property(anim_2_alpha_tween, "target_handle",	icon_h) 
  481. 	local anim_2_alpha_b_tween = vint_object_find("noto_alpha_2b", anim_clone_2) 
  482. 	vint_set_property(anim_2_alpha_b_tween, "target_handle",	icon_h) 
  483. 	 
  484. 	--Reset Properties to current value 
  485. 	local tint_r, tint_g, tint_b = vint_get_property(icon_h, "tint") 
  486. 	vint_set_property(anim_2_alpha_tween, "start_value", tint_r, tint_g, tint_b) 
  487. 	]] 
  488. 	if (icon_id == level and level == 6) then 
  489. 		vint_set_property(icon_h, "tint", 220/255, 0, 0) 
  490. 	elseif icon_id == level then 
  491. 		vint_set_property(icon_h, "tint", 100/255, 0, 0) 
  492. 	end 
  493. 	vint_set_property(icon_h, "alpha", 1) 
  494. 	 
  495. 	--Setup callback 
  496. 	vint_set_property(noto_pulse_end, "end_event",		"hud_noto_icon_add_end") 
  497. 	--vint_set_property(anim_1, "end_event",	"hud_noto_clear_map_fill") 
  498. 	--vint_set_property(anim_clone_1, "end_event",	"hud_noto_clear_map_fill") 
  499. 	 
  500. 	--play anims 
  501. 	lua_play_anim(anim_clone_0, 0); 
  502. 	lua_play_anim(anim_clone_1, 0); 
  503. 	--lua_play_anim(anim_clone_2, 0); 
  504.  
  505. 	icon.bmp_clone_0 = bmp_clone_0 
  506. 	icon.bmp_clone_1 = 0 
  507. 	icon.anim_0 = anim_clone_0 
  508. 	icon.anim_1 = anim_clone_1 
  509. 	icon.anim_2 = 0 
  510. 	icon.anim_3 = 0 
  511. 	icon.tween_end = noto_pulse_end 
  512. 	 
  513. end 
  514.  
  515. function hud_noto_icon_add_end(tween_h, event_name) 
  516. 	-- search for indicated tween and clean up 
  517.  
  518. 	for k, noto_data in pairs(Hud_noto_data) do 
  519. 		for key, icon in pairs(noto_data.icons) do 
  520. 			if icon.tween_end == tween_h then 
  521.  
  522. 				vint_object_destroy(icon.bmp_clone_0) 
  523. 				vint_object_destroy(icon.bmp_clone_1) 
  524. 				vint_object_destroy(icon.anim_0) 
  525. 				vint_object_destroy(icon.anim_1) 
  526. 				vint_object_destroy(icon.anim_2) 
  527.  
  528. 				icon.bmp_clone_0 = 0 
  529. 				icon.bmp_clone_1 = 0 
  530. 				icon.anim_0 = 0 
  531. 				icon.anim_1 = 0 
  532. 				icon.anim_2 = 0 
  533. 				icon.tween_show = 0 
  534. 				icon.tween_end = 0 
  535. 				 
  536. 				hud_noto_icon_set_state_silent(icon, NOTO_STATE_VISIBLE) 
  537.  
  538. 				return 
  539. 			end 
  540. 		end 
  541. 	end 
  542. end 
  543.  
  544. function hud_noto_clear_map_fill(tween_h, event_name) 
  545. 	-- HVS_JPM HS 7354 - manually set the alpha of this obejct back to zero so we dont get the grayed out minimap 
  546. 	local map_fill_h = vint_object_find("map_fill") 
  547. 	vint_set_property(map_fill_h, "alpha", 0) 
  548. end 
  549.  
  550.  
  551. ------------------------------------------------------------------------------- 
  552. -- Starts decaying looping animation on specific icon. 
  553. -- 
  554. function hud_noto_icon_decay(icon_h, icon) 
  555.  
  556. 	--vint_set_property(Hud_noto_data.police.meter.meter_fill_h, "visible", true) 
  557. 	 
  558. 	--make sure we aren't already playing an animation... 
  559. 	vint_object_destroy(icon.bmp_clone_0) 
  560. 	vint_object_destroy(icon.bmp_clone_1) 
  561. 	vint_object_destroy(icon.anim_0) 
  562. 	vint_object_destroy(icon.anim_1) 
  563. 	vint_object_destroy(icon.anim_2) 
  564. 	vint_object_destroy(icon.anim_3) 
  565.  
  566. 	vint_set_property(icon_h, "visible", true) 
  567.  
  568. 	--This one is a little bit different because we want the tweens to stay in sync... so we just clone the tween. 
  569. 	--Animation is already playing, cloning the tweens will keep them in sync. 
  570. 	local decaying_anim_h = vint_object_find("noto_decaying_anim") 
  571. 	local decay_twn_h = vint_object_find("noto_decaying_twn", decaying_anim_h) 
  572. 	local decay_clone_twn_h = vint_object_clone(decay_twn_h) 
  573. 	vint_set_property(decay_clone_twn_h, "state", VINT_TWEEN_STATE_RUNNING) 
  574. 	vint_set_property(decay_clone_twn_h, "target_handle",	icon_h) 
  575. 	 
  576. 	--Store options to globals... 
  577. 	icon.bmp_clone_0 = 0 
  578. 	icon.bmp_clone_1 = 0 
  579. 	icon.anim_0 = decay_clone_twn_h 
  580. 	icon.anim_1 = 0 
  581. 	icon.anim_2 = 0 
  582. 	icon.anim_3 = 0 
  583. 	icon.tween_end = 0 
  584. end 
  585.  
  586. ------------------------------------------------------------------------------- 
  587. -- Pleys pulse up animation on icon 
  588. -- 
  589. function hud_noto_icon_pulse(icon_h, icon) 
  590.  
  591. 	--vint_set_property(Hud_noto_data.police.meter.meter_fill_h, "visible", false) 
  592.  
  593. 	--make sure we aren't already playing an animation, nuke it... 
  594. 	vint_object_destroy(icon.bmp_clone_0) 
  595. 	vint_object_destroy(icon.bmp_clone_1) 
  596. 	vint_object_destroy(icon.anim_0) 
  597. 	vint_object_destroy(icon.anim_1) 
  598. 	vint_object_destroy(icon.anim_2) 
  599. 	vint_object_destroy(icon.anim_3) 
  600. 	 
  601. 	--make sure our notoriety icon is visible. 
  602. 	vint_set_property(icon_h, "visible", true) 
  603. 	--vint_set_property(icon_h, "tint", 100/255, 0, 0) 
  604.  
  605. 	--Create bitmap clones for animation 
  606. 	local bmp_clone_0 = vint_object_clone(icon_h) 
  607. 	vint_set_property(bmp_clone_0, "depth",	-1) 
  608.  
  609. 	--Clone the notoriety anim and adjust the childs targets 
  610.  
  611. 	--ANIMATION: Blink white 
  612. 	local anim_0 = vint_object_find("noto_pulse_anim") 
  613. 	local anim_clone_0 = vint_object_clone(anim_0) 
  614.  
  615. 	--Target Tweens 
  616. 	local noto_pulse_1 = vint_object_find("noto_pulse_1", anim_clone_0) 
  617. 	local noto_pulse_2 = vint_object_find("noto_pulse_2", anim_clone_0) 
  618. 	local noto_pulse_3 = vint_object_find("noto_pulse_3", anim_clone_0) 
  619. 	local noto_pulse_4 = vint_object_find("noto_pulse_4", anim_clone_0) 
  620. 	local noto_pulse_end = vint_object_find("noto_pulse_end", anim_clone_0) 
  621. 	 
  622. 	vint_set_property(noto_pulse_1, "target_handle",	bmp_clone_0) 
  623. 	vint_set_property(noto_pulse_2, "target_handle",	bmp_clone_0) 
  624. 	vint_set_property(noto_pulse_3, "target_handle",	bmp_clone_0) 
  625. 	vint_set_property(noto_pulse_4, "target_handle",	bmp_clone_0) 
  626. 	vint_set_property(noto_pulse_end, "target_handle",	bmp_clone_0) 
  627.  
  628. 	--Setup callback 
  629. 	vint_set_property(noto_pulse_end, "end_event",		"hud_noto_icon_pulse_end") 
  630. 	 
  631. 	--play anims 
  632. 	lua_play_anim(anim_clone_0, 0) 
  633.  
  634. 	icon.bmp_clone_0 = bmp_clone_0 
  635. 	icon.anim_0 = anim_clone_0 
  636. 	icon.tween_end = noto_pulse_end 
  637. end 
  638.  
  639. function hud_noto_icon_pulse_end(tween_h, event) 
  640. 	-- search for indicated tween and clean up 
  641. 	for k, noto_data in pairs(Hud_noto_data) do 
  642. 		for key, icon in pairs(noto_data.icons) do 
  643. 			if icon.tween_end == tween_h then 
  644. 				vint_object_destroy(icon.bmp_clone_0) 
  645. 				vint_object_destroy(icon.bmp_clone_1) 
  646. 				vint_object_destroy(icon.anim_0) 
  647. 				vint_object_destroy(icon.anim_1) 
  648. 				vint_object_destroy(icon.anim_2) 
  649.  
  650. 				icon.bmp_clone_0 = 0 
  651. 				icon.bmp_clone_1 = 0 
  652. 				icon.anim_0 = 0 
  653. 				icon.anim_1 = 0 
  654. 				icon.anim_2 = 0 
  655. 				icon.tween_show = 0 
  656. 				 
  657. 				hud_noto_icon_set_state_silent(icon, NOTO_STATE_VISIBLE) 
  658. 				return 
  659. 			end 
  660. 		end 
  661. 	end 
  662. end 
  663.  
  664. ------------------------------------------------------------------------------- 
  665. -- Force show icon... 
  666. -- 
  667. function hud_noto_icon_visible(icon_h, icon, icon_id, level) 
  668. 	--make sure we aren't already playing an animation... 
  669. 	vint_object_destroy(icon.bmp_clone_0) 
  670. 	vint_object_destroy(icon.bmp_clone_1) 
  671. 	vint_object_destroy(icon.anim_0) 
  672. 	vint_object_destroy(icon.anim_1) 
  673. 	vint_object_destroy(icon.anim_2) 
  674. 	vint_object_destroy(icon.anim_3) 
  675.  
  676. 	vint_set_property(icon_h, "visible", true) 
  677. 	if (icon_id < level) or (icon_id == level and level == 6) then 
  678. 		vint_set_property(icon_h, "tint", 220/255, 0, 0) 
  679. 	end 
  680. end 
  681.  
  682. ------------------------------------------------------------------------------- 
  683. -- Force hide icon. 
  684. -- 
  685. function hud_noto_icon_hide(icon_h, icon) 
  686. 	--make sure we aren't already playing an animation... 
  687. 	vint_object_destroy(icon.bmp_clone_0) 
  688. 	vint_object_destroy(icon.bmp_clone_1) 
  689. 	vint_object_destroy(icon.anim_0) 
  690. 	vint_object_destroy(icon.anim_1) 
  691. 	vint_object_destroy(icon.anim_2) 
  692. 	vint_object_destroy(icon.anim_3) 
  693.  
  694. 	vint_set_property(icon_h, "visible", false) 
  695. 	vint_set_property(icon_h, "tint", 0, 0, 0) 
  696. end 
  697.  
  698.  
  699.  
  700. ------------------------------------------------------------------------------- 
  701. -- Expand notoriety bars... 
  702. --  
  703. function hud_player_notoriety_show() 
  704. 	if Hud_notoriety.is_expanded ~= true then 
  705. 		vint_set_property(vint_object_find("map_noteriety_contract"), "is_paused", true) 
  706. 		lua_play_anim(vint_object_find("map_noteriety_expand")) 
  707. 		local mask = vint_object_find("map_mask") 
  708. 		--vint_set_property(mask, "visible", true) 
  709. 		Hud_notoriety.is_expanded = true 
  710. 	end 
  711. end 
  712.  
  713.  
  714. ------------------------------------------------------------------------------- 
  715. -- Retract notoriety bars... 
  716. --  
  717. function hud_player_notoriety_hide() 
  718. 	if Hud_notoriety.is_expanded ~= false then 
  719. 		vint_set_property(vint_object_find("map_noteriety_expand"), "is_paused", true) 
  720. 		lua_play_anim(vint_object_find("map_noteriety_contract")) 
  721. 		local mask = vint_object_find("map_mask") 
  722. 		--vint_set_property(mask, "visible", false) 
  723. 		Hud_notoriety.is_expanded = false 
  724. 	end 
  725. end