./hud_running_man.lua

  1. --Enums for events 
  2. RM_FIRE_TRAP 				= 1 
  3. RM_ELECTRIC_TRAP 			= 2 
  4. RM_FIRE_TRAP_KILL 		= 3 
  5. RM_ELECTRIC_TRAP_KILL 	= 4 
  6. RM_PRESENT_AWARDED		= 5 
  7. RM_PRESENT_SPAWN			= 6 
  8. RM_PRESENT_EXPLODED		= 7 
  9. RM_PRESENT_WARNING 		= 8 
  10. RM_MULTI_5X					= 9 
  11. RM_HUNTER_SPAWN			= 10 
  12. RM_HUNTER_KILLED			= 11 
  13. RM_HUNTER_KILL_PLAYER	= 12 
  14. RM_ENEMY_TRAP				= 13 
  15. RM_HUMAN_SHIELD			= 14 
  16. RM_TARGET_ETHICAL			= 15 
  17. RM_TARGET_UNETHICAL		= 16 
  18. RM_TARGET_MONEY			= 17 
  19. RM_TARGET_TIME_BONUS		= 18 
  20. RM_TARGET_HEALTH			= 19 
  21. RM_HEAD_SHOT				= 20 
  22. RM_NUT_SHOT					= 21 
  23. RM_TIME_LOW					= 22 
  24. RM_EXIT_SPAWN				= 23 
  25. RM_START_MATCH				= 24 
  26. RM_GENKI_TARGET_CORRECT	= 25 
  27. RM_GENKI_TARGET_INCORRECT = 26 
  28. RM_TARGET_ETHICAL_CLASSIC			= 27 
  29. RM_TARGET_UNETHICAL_CLASSIC		= 28 
  30. RM_SHARK						= 29 
  31. RM_TARGET_ETHICAL_XMAS			= 30 
  32. RM_TARGET_UNETHICAL_XMAS		= 31 
  33. RM_TARGET_COMBO 					= 32 
  34. RM_TARGET_COMBO_SUPER 			= 33 
  35.  
  36. Data = { 
  37. 	[RM_FIRE_TRAP] = {  
  38. 			animation = "fire_anim",  
  39. 			tween = "end_event_twn", 
  40. 			grps = {"fire_grp"}, 
  41. 			sfx = "RM_HUD_Fire_Trap" 
  42. 	}, 
  43. 	[RM_ELECTRIC_TRAP] = {  
  44. 			animation = "trap_electric_anim",  
  45. 			tween = "end_event_twn", 
  46. 			grps = { "trap_electric_grp" }, 
  47. 			sfx = "RM_HUD_Electricity_Trap", 
  48. 	}, 
  49. 	[RM_FIRE_TRAP_KILL] = {  
  50. 			animation = "do_nothing_anim", 
  51. 			tween = "end_event_twn", 
  52. 			grps = { "do_nothing_grp" }, 
  53. 			sfx = "RM_Player_Killed_by_Fire_Trap", 
  54. 	}, 
  55. 	[RM_ELECTRIC_TRAP_KILL] = {  
  56. 			animation = "do_nothing_anim", 
  57. 			tween = "end_event_twn", 
  58. 			grps = { "do_nothing_grp" }, 
  59. 			sfx = "RM_Player_Killed_by_Fire_Trap", 
  60. 	}, 
  61. 	[RM_PRESENT_AWARDED] = {  
  62. 			animation = "do_nothing_anim",  
  63. 			tween = "end_event_twn", 
  64. 			grps = { "do_nothing_grp" }, 
  65. 			sfx = "RM_Player_Gets_Present", 
  66. 	}, 
  67. 	[RM_PRESENT_SPAWN] = {  
  68. 			animation = "present_anim",  
  69. 			tween = "end_event_twn", 
  70. 			grps = { "present_grp" }, 
  71. 			sfx = "RM_Present_Spawned", 
  72. 	}, 
  73. 	[RM_PRESENT_EXPLODED] = {  
  74. 			animation = "do_nothing_anim", 
  75. 			tween = "end_event_twn", 
  76. 			grps = { "do_nothing_grp" }, 
  77. 			sfx = "RM_Player_Damaged_by_Present", 
  78. 	}, 
  79. 	[RM_PRESENT_WARNING] = {  
  80. 			animation = "do_nothing_anim", 
  81. 			tween = "end_event_twn", 
  82. 			grps = { "do_nothing_grp" }, 
  83. 			sfx = "RM_Present_About_to_Explode", 
  84. 	}, 
  85. 	[RM_MULTI_5X] = {  
  86. 			animation = "5x_anim",  
  87. 			tween = "end_event_twn", 
  88. 			grps = { "fan_grp", "multiplier_grp" }, 
  89. 			sfx = "RM_5X_Multiplier", 
  90. 	}, 
  91. 	[RM_HUNTER_SPAWN] = {  
  92. 			animation = "hunter_anim",  
  93. 			tween = "end_event_twn", 
  94. 			grps = { "hunter_grp" }, 
  95. 			sfx = "RM_Hunters_Spawned", 
  96. 	}, 
  97. 	[RM_HUNTER_KILLED] = {  
  98. 			animation = "do_nothing_anim",  
  99. 			tween = "end_event_twn", 
  100. 			grps = { "do_nothing_grp" }, 
  101. 			sfx = "RM_Kills_Hunter", 
  102. 	}, 
  103. 	[RM_HUNTER_KILL_PLAYER] = {  
  104. 			animation = "do_nothing_anim",  
  105. 			tween = "end_event_twn", 
  106. 			grps = { "do_nothing_grp" }, 
  107. 			sfx = "RM_Killed_by_Hunter", 
  108. 	}, 
  109. 	[RM_ENEMY_TRAP] = {  
  110. 			animation = "do_nothing_anim",  
  111. 			tween = "end_event_twn", 
  112. 			grps = { "do_nothing_grp" }, 
  113. 			sfx = "RM_Kill_Enemy_With_Trap", 
  114. 	}, 
  115. 	[RM_HUMAN_SHIELD] = {  
  116. 			animation = "do_nothing_anim",  
  117. 			tween = "end_event_twn", 
  118. 			grps = { "do_nothing_grp" }, 
  119. 			sfx = "RM_Take_Human_Shield", 
  120. 	}, 
  121. 	[RM_TARGET_ETHICAL] = {  
  122. 			animation = "ethical_anim",  
  123. 			tween = "end_event_twn", 
  124. 			grps = { "ethical_grp" }, 
  125. 			sfx = "RM_HUD_Ethical", 
  126. 	},	 
  127. 	[RM_TARGET_UNETHICAL] = {  
  128. 			animation = "unethical_anim",  
  129. 			tween = "end_event_twn", 
  130. 			grps = { "unethical_grp" }, 
  131. 			sfx = "RM_HUD_Unethical", 
  132. 	}, 
  133. 	[RM_TARGET_MONEY] = {  
  134. 			animation = "money_shot_anim",  
  135. 			tween = "end_event_twn", 
  136. 			grps = { "money_shot_grp" }, 
  137. 			sfx = "RM_Shoot_Money_Target", 
  138. 	}, 
  139. 	[RM_TARGET_TIME_BONUS] = {  
  140. 			animation = "time_bonus_anim",  
  141. 			tween = "end_event_twn", 
  142. 			grps = { "time_bonus_grp", "genki_head_grp" }, 
  143. 			sfx = "RM_HUD_Time_Bonus", 
  144. 	}, 
  145. 	[RM_TARGET_HEALTH] = {  
  146. 			animation = "health_anim",  
  147. 			tween = "end_event_twn", 
  148. 			grps = { "health_grp" }, 
  149. 			sfx = "RM_HUD_Health", 
  150. 	},	 
  151. 	[RM_HEAD_SHOT] = {  
  152. 			animation = "do_nothing_anim", 
  153. 			tween = "end_event_twn", 
  154. 			grps = { "do_nothing_grp" }, 
  155. 			sfx = "RM_Headshot", 
  156. 	}, 
  157. 	[RM_NUT_SHOT] = {  
  158. 			animation = "do_nothing_anim",  
  159. 			tween = "end_event_twn", 
  160. 			grps = { "do_nothing_grp" }, 
  161. 			sfx = "RM_Nutshot", 
  162. 	}, 
  163. 	[RM_TIME_LOW] = {  
  164. 			animation = "time_low_anim",  
  165. 			tween = "end_event_twn", 
  166. 			grps = { "timer_grp", "fan_grp", "genki_head_grp" }, 
  167. 			sfx = "RM_HUD_Timer", 
  168. 	}, 
  169. 	[RM_EXIT_SPAWN] = {  
  170. 			animation = "exit_spawn_anim",  
  171. 			tween = "end_event_twn", 
  172. 			grps = { "exit_spawned_grp" }, 
  173. 			sfx = "RM_Exiting", 
  174. 	},	 
  175. 	[RM_START_MATCH] = {  
  176. 			animation = "do_nothing_anim",  
  177. 			tween = "end_event_twn", 
  178. 			grps = { "do_nothing_grp" }, 
  179. 			sfx = "RM_Start_Match", 
  180. 	},	 
  181. 	[RM_GENKI_TARGET_CORRECT] = {  
  182. 			animation = "ethical_anim",  
  183. 			tween = "end_event_twn", 
  184. 			grps = { "ethical_grp" }, 
  185. 			sfx = "RM_HUD_Ethical", 
  186. 	},	 
  187. 	[RM_GENKI_TARGET_INCORRECT] = {  
  188. 			animation = "unethical_anim",  
  189. 			tween = "end_event_twn", 
  190. 			grps = { "unethical_grp" }, 
  191. 			sfx = "RM_HUD_Unethical", 
  192. 	},	 
  193. 	[RM_TARGET_ETHICAL_CLASSIC] = {  
  194. 			animation = "ethical_classic_anim",  
  195. 			tween = "end_event_twn", 
  196. 			grps = { "ethical_classic_grp" }, 
  197. 			sfx = "RM_HUD_Ethical", 
  198. 	},	 
  199. 	[RM_TARGET_UNETHICAL_CLASSIC] = {  
  200. 			animation = "unethical_classic_anim",  
  201. 			tween = "end_event_twn", 
  202. 			grps = { "unethical_classic_grp" }, 
  203. 			sfx = "RM_HUD_Unethical", 
  204. 	}, 
  205. 	[RM_SHARK] = {  
  206. 			animation = "shark_anim",  
  207. 			tween = "end_event_twn", 
  208. 			grps = { "shark_grp" }, 
  209. 			sfx = "Jungle_HUD_Water_Bear", 
  210. 			no_switch_sfx = true, 
  211. 	},	 
  212. 	[RM_TARGET_ETHICAL_XMAS] = {  
  213. 			animation = "ethical_xmas_anim",  
  214. 			tween = "end_event_twn", 
  215. 			grps = { "ethical_xmas_grp" }, 
  216. 			sfx = "Genki_Holiday_Orthodox", 
  217. 			 
  218. 	},	 
  219. 	[RM_TARGET_UNETHICAL_XMAS] = {  
  220. 			animation = "unethical_xmas_anim",  
  221. 			tween = "end_event_twn", 
  222. 			grps = { "unethical_xmas_grp" }, 
  223. 			sfx = "Genki_Holiday_Unorthodox", 
  224. 			 
  225. 	},	 
  226. 	[RM_TARGET_COMBO] = {  
  227. 			animation = "combo_anim",  
  228. 			tween = "end_event_twn", 
  229. 			grps = { "combo_grp" }, 
  230. 			sfx = "Genki_Holiday_Combo_01", 
  231. 	 
  232. 	},	 
  233. 	[RM_TARGET_COMBO_SUPER] = {  
  234. 			animation = "combo_super_anim",  
  235. 			tween = "end_event_twn", 
  236. 			grps = { "combo_super_grp" }, 
  237. 			sfx = "Genki_Holiday_Combo_2x", 
  238. 	 
  239. 	},	 
  240. } 
  241.  
  242. Hud_running_man_doc_handle = -1 
  243.  
  244. local Event_played = -1 
  245. local Timer_audio = 0 
  246. local Event_is_playing = false 
  247. local Running_man_peg_loaded = false 
  248. local Panda_is_sad = false 
  249. local Rm_hud_event_audio_id = -1 
  250.  
  251.  
  252. function hud_running_man_init() 
  253. 	Hud_running_man_doc_handle = vint_document_find("hud_running_man") 
  254. 		 
  255. 	for key, event in pairs(Data) do 
  256. 		local anim_h = vint_object_find(event.animation) 
  257. 		local tween_h = vint_object_find(event.tween, anim_h) 
  258. 		vint_set_property(tween_h, "end_event", "end_event_anim") 
  259. 		vint_apply_start_values(anim_h) 
  260. 		 
  261. 		for key2, group_name in pairs (event.grps) do 
  262. 			local group_h = vint_object_find(group_name) 
  263. 			vint_set_property(group_h, "visible", false) 
  264. 		end			 
  265. 	end 
  266. 	 
  267. 	-- Set up looping tweens 
  268. 	local unethical_classic_anim = Vdo_anim_object:new("unethical_classic_anim", 0, Hud_running_man_doc_handle) 
  269. 	local trap_electric_anim = Vdo_anim_object:new("trap_eletric_anim", 0, Hud_running_man_doc_handle) 
  270. 	local health_anim = Vdo_anim_object:new("health_anim", 0, Hud_running_man_doc_handle) 
  271. 	local money_shot_anim = Vdo_anim_object:new("money_shot_anim", 0, Hud_running_man_doc_handle) 
  272. 	 
  273. 	local panda_shock_twn = Vdo_tween_object:new("panda_shock_twn", trap_electric_anim.handle) 
  274. 	panda_shock_twn:set_end_event("hud_running_man_switch_panda")	 
  275. 	 
  276. 	local panda_twn = Vdo_tween_object:new("panda_twn", unethical_classic_anim.handle) 
  277. 	panda_twn:set_end_event("hud_running_man_switch_panda") 
  278. 	 
  279. 	thread_new( "hud_running_man_load_complete" ) 
  280. end 
  281.  
  282. function hud_running_man_load_complete() 
  283. 	 
  284. 	 
  285. 	if (mission_is_active("mol_jg_01") == true) then 
  286. 		pause_map_dump( true ) 
  287. 		game_peg_load_with_cb("hud_running_man_peg_loaded", 2, "ui_bms_rm", "ui_bms_genki_run") 
  288. 	elseif(mission_is_active("DLC2_A_GH_NE_01") == true) or (mission_is_active("DLC2_A_GH_NW_01") == true) or (mission_is_active("DLC2_A_GH_DT_01") == true) then 
  289. 		game_peg_load_with_cb("hud_running_man_peg_loaded", 1, "ui_bms_genki_fly") 
  290. 	else 
  291. 		game_peg_load_with_cb("hud_running_man_peg_loaded", 1, "ui_bms_genki_escort") 
  292. 	end 
  293. end 
  294.  
  295. function hud_running_man_peg_loaded() 
  296. 	Running_man_peg_loaded = true 
  297. 	hud_running_man_event_update(RM_START_MATCH) 
  298. end 
  299.  
  300. function hud_running_man_event_update(event_idx, timer) 
  301. 	-- check if we're using the time low event 
  302. 	if event_idx == RM_TIME_LOW then 
  303. 		hud_running_man_play_time_low(event_idx, timer) 
  304. 		return 
  305. 	end 
  306. 	 
  307. 	if Running_man_peg_loaded == false then 
  308. 		return 
  309. 	end 
  310. 	 
  311. 	--Always interrupt an existing event to play something newer 
  312. 	if Event_is_playing then 
  313. 		end_event_anim() 
  314. 	end 
  315. 	 
  316. 	-- DEBUG TEXT MESSAGE 
  317. 	-- local do_nothing_txt = Vdo_base_object:new("do_nothing_txt", 0, Hud_running_man_doc_handle) 
  318. 	-- do_nothing_txt:set_text("Event "..event_idx.." fired") 
  319. 	 
  320. 	for key, group_name in pairs(Data[event_idx].grps) do 
  321. 		local group_h = vint_object_find(group_name) 
  322. 		vint_set_property(group_h, "visible", true) 
  323. 	end 
  324. 		 
  325. 	local anim_h = vint_object_find(Data[event_idx].animation) 
  326. 	lua_play_anim(anim_h) 
  327. 	 
  328. 	if Data[event_idx].sfx ~= nil then 
  329. 		if Data[event_idx].no_switch_sfx then 
  330. 			Rm_hud_event_audio_id = audio_object_post_event(Data[event_idx].sfx)		 
  331. 		else 
  332. 			Rm_hud_event_audio_id = audio_object_post_event("Activity", {"Activity_Type","Running_Man"}, {"Running_Man",Data[event_idx].sfx}) 
  333. 		end 
  334. 	end 
  335. 	 
  336. 	Event_is_playing = true 
  337. 	Event_played = event_idx 
  338. end 
  339.  
  340. function end_event_anim() 
  341. 	-- hide grps that were used and stop animation 
  342. 	for key, group_name in pairs(Data[Event_played].grps) do 
  343. 		local group_h = vint_object_find(group_name) 
  344. 		vint_set_property(group_h, "visible", false) 
  345. 	end 
  346. 	 
  347. 	-- stop animation 
  348. 	vint_set_property(vint_object_find(Data[Event_played].animation),"is_paused", true) 
  349. 	 
  350. 	-- Mark it ended 
  351. 	Event_is_playing = false 
  352. end 
  353.  
  354. function hud_running_man_unload()	 
  355. 	 
  356. 	if (mission_is_active("mol_jg_01") == true) then 
  357. 		game_peg_unload_wait("ui_bms_rm") 
  358. 		game_peg_unload_wait("ui_bms_genki_run") 
  359. 		pause_map_restore() 
  360. 	elseif(mission_is_active("DLC2_A_GH_NE_01") == true) or (mission_is_active("DLC2_A_GH_NW_01") == true) or (mission_is_active("DLC2_A_GH_DT_01") == true) then 
  361. 		game_peg_unload_wait("ui_bms_genki_fly") 
  362. 	else 
  363. 		game_peg_unload_wait("ui_bms_genki_escort") 
  364. 	end 
  365. 	 
  366. 	--pop_screen( "running_man_hud" ) 
  367. end 
  368.  
  369. function hud_running_man_cleanup()	 
  370. end 
  371.  
  372. function hud_running_man_switch_panda(twn_handle) 
  373. 	 
  374. 	local anim_h = vint_object_parent(twn_handle) 
  375. 	 
  376. 	local unethical_classic_anim_h = vint_object_find("unethical_classic_anim") 
  377. 	local trap_electric_anim_h = vint_object_find("trap_electric_anim") 
  378. 		 
  379. 	local panda_img 
  380. 	 
  381. 	if anim_h == unethical_classic_anim_h then 
  382. 		 
  383. 		panda_img = Vdo_base_object:new("panda_img", 0, Hud_running_man_doc_handle)	 
  384. 	 
  385. 		if Panda_is_sad then 
  386. 			panda_img:set_image("ui_rm_nuetral_panda")				 
  387. 			Panda_is_sad = false		 
  388. 		else 
  389. 			panda_img:set_image("ui_rm_sad_panda")	 
  390. 			Panda_is_sad = true 
  391. 		end 
  392. 		 
  393. 	elseif anim_h == trap_electric_anim_h then 
  394. 		 
  395. 		panda_img = Vdo_base_object:new("panda_shocked", 0, Hud_running_man_doc_handle) 
  396. 				 
  397. 		if Panda_is_sad then 
  398. 			panda_img:set_image("ui_rm_panda_shocked")				 
  399. 			Panda_is_sad = false		 
  400. 		else 
  401. 			panda_img:set_image("ui_rm_panda_skeleton")	 
  402. 			Panda_is_sad = true 
  403. 		end 
  404. 	 
  405. 	end	 
  406. end 
  407.  
  408.  
  409. function hud_running_man_play_time_low(event_idx, timer) 
  410.  
  411. 	local timer_grp = Vdo_base_object:new("timer_grp", 0, Hud_running_man_doc_handle) 
  412. 	local genki_head_grp = Vdo_base_object:new("genki_head_grp", 0, Hud_running_man_doc_handle) 
  413. 	local anim_h = vint_object_find("time_low_anim") 
  414. 	local timer_txt = Vdo_base_object:new("timer_txt", 0, Hud_running_man_doc_handle) 
  415. 	 
  416. 	if Event_is_playing == false and timer > -1 then 
  417. 		timer_txt:set_text(format_time(timer/1000, false, false)) 
  418. 		lua_play_anim(anim_h) 
  419. 		Timer_audio = audio_object_post_event("Activity", {"Activity_Type","Running_Man"}, {"Running_Man","RM_HUD_Timer"}) 
  420. 		 
  421. 		timer_grp:set_visible(true) 
  422. 		genki_head_grp:set_visible(true) 
  423. 		Event_is_playing = true 
  424. 	elseif timer > -1 then 
  425. 		timer_txt:set_text(format_time(timer/1000, false, false)) 
  426. 		if timer <= 0 then 
  427. 			if Timer_audio > 0 then 
  428. 				audio_stop(Timer_audio) 
  429. 				Timer_audio = 0 
  430. 			end 
  431. 		end 
  432. 	elseif timer == -1 then 
  433. 		timer_grp:set_visible(false) 
  434. 		genki_head_grp:set_visible(true) 
  435. 		vint_set_property(anim_h, "is_paused", true) 
  436. 		 
  437. 		if Timer_audio > 0 then 
  438. 			audio_stop(Timer_audio) 
  439. 			Timer_audio = 0 
  440. 		end 
  441. 		 
  442. 		Event_is_playing = false 
  443. 	end 
  444.  
  445. end