./dlc2_m02.lua

  1. --[[ 
  2. 	dlc2_m02.lua 
  3. 	SR3 Mission Script 
  4. 	DATE: 9/27/2011 
  5. 	AUTHOR:	Sean Rose 
  6. ]]-- 
  7.  
  8. -- Characters -- 
  9. Dlc2_m02_characters = { 
  10. 	alien_homie = "npc_alien_homie", 
  11. 	brutina = "npc_brutina", 
  12. } 
  13. -- Groups -- 
  14. Dlc2_m02_groups = { 
  15. 	homies = { 
  16. 		name = "grp_homies", 
  17. 		npcs = { Dlc2_m02_characters.alien_homie }, 
  18. 	}, 
  19. 	 
  20. 	machines = { 
  21. 		name = "grp_machines", 
  22. 	}, 
  23. 	 
  24. 	amazon_01 = { name = "grp_amazon_01", sleep = true, amazon = true, } , 
  25. 	amazon_02 = { name = "grp_amazon_02", sleep = true, amazon = true, } , 
  26. 	amazon_03 = { name = "grp_amazon_03", sleep = true , amazon = true,} , 
  27. 	amazon_04 = { name = "grp_amazon_04", sleep = true, amazon = true, } , 
  28. 	amazon_05 = { name = "grp_amazon_05", amazon = true, } , 
  29. 	amazon_06 = { name = "grp_amazon_06", sleep = true, amazon = true, } , 
  30. 	amazon_07 = { name = "grp_amazon_07", sleep = true, amazon = true, } , 
  31. 	amazon_08 = { name = "grp_amazon_08", sleep = true, amazon = true, } , 
  32. 	amazon_09 = { name = "grp_amazon_09", sleep = true, amazon = true, } , 
  33. 	amazon_10 = { name = "grp_amazon_10", sleep = true, amazon = true, } , 
  34. 	amazon_11 = { name = "grp_amazon_11", amazon = true, } , 
  35. 	amazon_12 = { name = "grp_amazon_12", amazon = true, } , 
  36. 	amazon_13 = { name = "grp_amazon_13", amazon = true, } , 
  37. 	amazon_14 = { name = "grp_amazon_14", amazon = true, } , 
  38. 	amazon_15 = { name = "grp_amazon_15", amazon = true, } , 
  39. 	amazon_16 = { name = "grp_amazon_16", amazon = true, } , 
  40. 	 
  41. 	brutina = { name = "grp_brutina" }, 
  42. 	 
  43. 	saucer = { name = "grp_saucer" }, 
  44. 	 
  45. 	loadout1 = { name = "grp_loadout_01" }, 
  46. 	loadout2 = { name = "grp_loadout_02" }, 
  47. 	loadout3 = { name = "grp_loadout_03" }, 
  48. 	 
  49. 	clapboards = { name = "grp_clapboards" }, 
  50. 	 
  51. 	kiwiposters = { name = "grp_kiwiposters" }, 
  52. } 
  53.  
  54. -- Navpoints -- 
  55. Dlc2_m02_navpoints = { 
  56. 	local_mission_start = "nav_local_mission_start", 
  57. 	remote_mission_start = "nav_remote_mission_start", 
  58. 	local_mission_end = "nav_local_mission_end", 
  59. 	remote_mission_end = "nav_remote_mission_end", 
  60. 	 
  61. 	hanger_camera = "nav_hanger_camera", 
  62. } 
  63.  
  64. -- Triggers -- 
  65. Dlc2_m02_triggers = { 
  66. 	machine_2 = "trg_machine_2", 
  67. 	saucer = "trg_saucer", 
  68. 	 
  69. 	machine_4a = "trg_machine4a_local", 
  70. 	machine_4b = "trg_machine4b_local", 
  71. 	machine_4c = "trg_machine4c_local", 
  72. 	 
  73. 	-- door triggers 
  74. 	room1_enter_door = "trg_room1_enter_door", 
  75. 	hall2_enter_door = "trg_hall2_enter_door", 
  76. 	room2_enter_door = "trg_room2_enter_door", 
  77. 	room3_enter_door = "trg_room3_enter_door", 
  78. 	hall3_enter_door = "trg_hall3_enter_door", 
  79. 	room4_enter_door = "trg_room4_enter_door", 
  80. 	room4_exit_door = "trg_room4_exit_door", 
  81. 	hall4_enter_door = "trg_hall4_enter_door", 
  82. 	hanger_enter_door = "trg_hanger_enter_door", 
  83. 	 
  84. 	-- backstage areas 
  85. 	backstage1 = "trg_backstage_enter_1", 
  86. 	backstage2 = "trg_backstage_enter_2", 
  87. 	backstage3 = "trg_backstage_enter_3", 
  88. 	 
  89. 	-- clapboards 
  90. 	clapboard_01 = "trg_clapboard_01", 
  91. 	clapboard_02 = "trg_clapboard_02", 
  92. 	clapboard_03 = "trg_clapboard_03", 
  93. 	clapboard_04 = "trg_clapboard_04", 
  94. 	clapboard_05 = "trg_clapboard_05", 
  95. 	clapboard_06 = "trg_clapboard_06", 
  96. 	 
  97. 	-- npc activation triggers 
  98. 	activate_hall_1 = "trg_activate_hall1", 
  99. 	activate_hall_2 = "trg_activate_hall2", 
  100. 	activate_hall_3 = "trg_activate_hall3", 
  101. 	activate_room_2 = "trg_activate_room2", 
  102. 	 
  103. 	-- convo triggers 
  104. 	backstage_01_roof = "trg_backstage_01_roof", 
  105. 	backstage_02_borc = "trg_backstage_02_borc", 
  106. 	hall_01_first_action_2 = "trg_convo_first_action_2", 
  107. 	hall_03_find_key_area = "trg_convo_find_key_area", 
  108. 	backstage_03_mars = "trg_convo_mars", 
  109. 	backstage_03_walker = "trg_convo_walker", 
  110. 	backstage_03_exit = "trg_convo_bs3_exit", 
  111. 	action_02 = "trg_convo_action_02", 
  112. 	 
  113. 	-- traps 
  114. 	electric_trap_1 = "trg_electric_1", 
  115. 	electric_trap_2 = "trg_electric_2", 
  116. 	fire_trap = "trg_fire_trap", 
  117. 	} 
  118.  
  119. -- Vehicles -- 
  120. Dlc2_m02_vehicles = { 
  121. 	saucer = "veh_saucer", 
  122. } 
  123.  
  124. -- Mesh Movers -- 
  125. Dlc2_m02_movers = { 
  126. } 
  127.  
  128. -- Text -- 
  129. Dlc2_m02_text = { 
  130. 	 
  131. 	-- backstage_01 -- 
  132. 	get_pistol = "DLC2_M02_GET_PISTOL", 
  133. 	go_to_set = "DLC2_M02_GO_TO_SET", 
  134. 		 
  135. 	-- hallway_01 -- 
  136. 	approach_machine_local = "DLC2_M02_APPROACH_MACHINE_LOCAL", 
  137. 	approach_machine_coop = "DLC2_M02_APPROACH_MACHINE_COOP",	 
  138. 	 
  139. 	-- room_01 -- 
  140. 	protect_homie = "DLC2_M02_PROTECT_HOMIE", 
  141. 	return_to_homie = "DLC2_M02_RETURN_TO_HOMIE", 
  142. 	progress_01 = "DLC2_M02_PROGRESS_01", -- replaces text below  
  143. 	progress = "DLC2_M02_PROGRESS_LABEL", 
  144. 	explosion_warning = "DLC2_M02_EXPLOSION_WARNING", 
  145. 	approach_machine_local = "DLC2_M02_APPROACH_MACHINE_LOCAL", 
  146. 	approach_machine_coop = "DLC2_M02_APPROACH_MACHINE_COOP",	 
  147.  
  148. 	-- room_02 -- 
  149. 	rewire_explosives = "DLC2_M02_REWIRE_EXPLOSIVES", 
  150. 	use_rewire = "DLC2_M02_USE_REWIRE", 
  151. 	progress_02 = "DLC2_M02_PROGRESS_02", -- replaces text below 
  152. 	progress = "DLC2_M02_PROGRESS_LABEL", 
  153. 	go_to_backstage = "DLC2_M02_GO_TO_BACKSTAGE", 
  154. 		 
  155. 	-- backstage_02 -- 
  156. 	get_smg = "DLC2_M02_GET_SMG", 
  157. 	go_to_set = "DLC2_M02_GO_TO_SET", 
  158. 		 
  159. 	-- room_03 -- 
  160. 	progress_02 = "DLC2_M02_PROGRESS_02", -- replaces text below 
  161. 	progress = "DLC2_M02_PROGRESS_LABEL", 
  162. 	explosion_warning = "DLC2_M02_EXPLOSION_WARNING", 
  163. 	go_to_servers = "DLC2_M02_GO_TO_SERVER_ROOM", 
  164. 	-- go_to_servers = "DLC2_MO2_GO_TO_SERVERS", replaces text below 
  165. 	approach_machine_local = "DLC2_M02_APPROACH_MACHINE_LOCAL", 
  166. 		 
  167. 	-- room_04 -- 
  168. 	go_to_server = "DLC2_M02_GO_TO_SERVER",  
  169. 	wait_for_homie = "DLC2_M02_WAIT_FOR_HOMIE", 
  170. 	search_code = "DLC2_M02_SEARCH_CODE",  
  171. 	progress = "DLC2_M02_PROGRESS_LABEL", 
  172. 	self_destruct = "DLC2_M02_SELF_DESTRUCT", -- replaces text below 
  173. 	security_activating = "DLC2_M02_SECURITY_ACTIVATING", 
  174. 	 
  175. 	-- backstage_03 -- 
  176. 	get_final_weapon = "DLC2_M02_GET_FINAL_WEAPON", 
  177. 	go_to_set = "DLC2_M02_GO_TO_SET", 
  178. 	 
  179. 	-- hangar --  
  180. 	go_to_hangar = "DLC2_M02_GO_TO_HANGAR", 
  181. 	approach_saucer = "DLC2_M02_APPROACH_SAUCER", 
  182. 	kill_brutina = "DLC2_M02_KILL_BRUTINA", 
  183. 	go_to_control_room = "DLC2_M02_GO_TO_CONTROL_ROOM", 
  184. 	destroy_console = "DLC2_M02_DESTROY_CONSOLE", -- replaces text below 
  185. 	generator_destroy = "DLC2_M02_DESTORY_GENERATOR", 
  186. 	board_saucer = "DLC2_M02_BOARD_SAUCER", 
  187. } 
  188.  
  189. -- Threads -- 
  190. Dlc2_m02_threads = { 
  191. } 
  192.  
  193. -- Checkpoints -- 
  194. Dlc2_m02_checkpoints = { 
  195. 	MISSION_START_CHECKPOINT, 
  196. 	"1", 
  197. 	"2", 
  198. 	"3", 
  199. 	"4", 
  200. } 
  201.  
  202. -- Continuous Spawn Groups -- 
  203. Dlc2_m02_spawn_groups = { 
  204. 	elites = { 
  205. 		"grp_cspawn_elite_01", 
  206. 		"grp_cspawn_elite_02", 
  207. 		"grp_cspawn_elite_03", 
  208. 		"grp_cspawn_elite_04", 
  209. 	}, 
  210. 	pistols = { 
  211. 		"grp_cspawn_pistol_01", 
  212. 		"grp_cspawn_pistol_02", 
  213. 		"grp_cspawn_pistol_03", 
  214. 		"grp_cspawn_pistol_04", 
  215. 	}, 
  216. 	smgs = { 
  217. 		"grp_cspawn_smg_01", 
  218. 		"grp_cspawn_smg_02", 
  219. 		"grp_cspawn_smg_03", 
  220. 		"grp_cspawn_smg_04", 
  221. 	}, 
  222. 	 
  223. 	-- not really spawn groups but put here so they shut down  
  224. 	-- when entering backstage 
  225. 	others = { 
  226. 		"grp_amazon_01", 
  227. 		"grp_amazon_02", 
  228. 		"grp_amazon_03", 
  229. 		"grp_amazon_04", 
  230. 		"grp_amazon_05", 
  231. 		"grp_amazon_06", 
  232. 		"grp_amazon_07", 
  233. 		"grp_amazon_08", 
  234. 		"grp_amazon_09", 
  235. 		"grp_amazon_10", 
  236. 		"grp_amazon_11", 
  237. 		"grp_amazon_12", 
  238. 		"grp_amazon_13", 
  239. 		"grp_amazon_14", 
  240. 		"grp_amazon_15", 
  241. 		"grp_amazon_16", 
  242. 	} 
  243. } 
  244.  
  245. -- Spawn Regions -- 
  246. Dlc2_m02_spawn_regions = { 
  247. 	hall_1 = { 
  248. 	}, 
  249.  
  250. 	machine_1 = { 
  251. 		{ name = "srgn_machine_1_1" }, 
  252. 		{ name = "srgn_machine_1_3" }, 
  253. 	}, 
  254. 	 
  255. 	hall_2 = { 
  256. 	}, 
  257.  
  258. 	machine_2 = { 
  259. 	}, 
  260.  
  261. 	machine_3 = { 
  262. 		{ name = "srgn_machine_1_9", filter = 2 }, 
  263. 		{ name = "srgn_machine_1_10", filter = 4 }, 
  264. 	}, 
  265.  
  266. 	hall_3 = { 
  267. 	}, 
  268.  
  269. 	machine_4a = { 
  270. 		{ name = "srgn_machine_1_15", filter = 2 }, 
  271. 		{ name = "srgn_machine_1_17", filter = 4 }, 
  272. 	}, 
  273. 	 
  274. 	machine_4b = { 
  275. 		{ name = "srgn_machine_1_16", filter = 2 }, 
  276. 		{ name = "srgn_machine_1_17", filter = 4 }, 
  277. 	}, 
  278.  
  279. 	machine_4 = { 
  280. 		{ name = "srgn_machine_1_13", filter = 2 }, 
  281. 		{ name = "srgn_machine_1_14", filter = 4 }, 
  282. 	}, 
  283.  
  284. 	hanger_1 = { 
  285. 		{ name = "srgn_machine_1_19" }, 
  286. 		{ name = "srgn_machine_1_20" }, 
  287. 	}, 
  288. } 
  289.  
  290. -- Cutscenes -- 
  291. Dlc2_m02_cutscenes = { 
  292. } 
  293.  
  294. -- Conversations -- 
  295. Dlc2_m02_convos = { 
  296. 	-- example_convo = { convo_name = "m14_drive_01", player_speaks = true }, 
  297. 	-- example_cell = { cell_name = "m14_reach_helicopter", speakers_2d = { "Kinzie" }, player_speaks = true, recieving = false }, 
  298. 	-- example_2d = { persona_2d_params = { "M14_Too_Far_Away_From_Van" }, speakers_2d = { "Kinzie" } }, 
  299. 	-- example_3d = { persona_3d_params = { LOCAL_PLAYER, "M20_Start_Running_Down_People" }, }, 
  300. 	 
  301. 	mission_start = { convo_name = "DLC2_M02_Mission_Start", player_speaks = true },  
  302. 	bs_1_first_convo = { convo_name = "DLC2_M02_BS_1_First_Convo", player_speaks = true }, 
  303. 	bs_1_walk_on_roof = { convo_name = "DLC2_M02_BS_1_Walk_On_Roof", player_speaks = true }, 
  304. 	first_action_1 = { convo_name = "DLC2_M02_1st_Action_1_Convo", player_speaks = true }, 
  305. 	first_action_see_mib = { convo_name = "DLC2_M02_1st_Action_See_MiB", player_speaks = true }, 
  306. 	find_1st_device = { convo_name = "DLC2_M02_Find_1st_Device", player_speaks = true }, 
  307. 	first_device_end = { convo_name = "DLC2_M02_1st_Device_End", player_speaks = true }, 
  308. 	first_action_2 = { convo_name = "DLC2_M02_1st_Action_2_Convo", player_speaks = true }, 
  309. 	arrive_locked_door = { convo_name = "DLC2_M02_Arrive_Locked_Door", player_speaks = true }, 
  310. 	blow_up_locked_door = { convo_name = "DLC2_M02_Blowup_Locked_Door", player_speaks = true }, 
  311. 	find_2nd_device = { convo_name = "DLC2_M02_Find_2nd_Device", player_speaks = true }, 
  312. 	second_device_end = { convo_name = "DLC2_M02_2nd_Device_End", player_speaks = true }, 
  313. 	bs_2_first = { convo_name = "DLC2_M02_BS_2_First_Convo", player_speaks = true }, 
  314. 	see_borc_set = { convo_name = "DLC2_M02_See_BorC_Set", player_speaks = true }, 
  315. 	see_rm_trap = { convo_name = "DLC2_M02_See_RM_Trap", player_speaks = true }, 
  316. 	see_genki_pyro = { convo_name = "DLC2_M02_See_Genki_Pyro", player_speaks = true }, 
  317. 	exit_bs_2 = { convo_name = "DLC2_M02_Exit_BS_2_Convo", player_speaks = true }, 
  318. 	second_action_1 = { convo_name = "DLC2_M02_2nd_Action_1_Convo", player_speaks = true }, 
  319. 	find_third_device = { convo_name = "DLC2_M02_Find_3rd_Device", player_speaks = true }, 
  320. 	third_device_end = { convo_name = "DLC2_M02_3rd_Device_End", player_speaks = true }, 
  321. 	find_key_area = { convo_name = "DLC2_M02_Find_Key_Area", player_speaks = true }, 
  322. 	after_first_tier = { convo_name = "DLC2_M02_After_First_Tier", player_speaks = true }, 
  323. 	trigger_destruct = { convo_name = "DLC2_M02_Trigger_Destruct", player_speaks = true }, 
  324. 	control_room = { convo_name = "DLC2_M02_Control_Room", player_speaks = true }, 
  325. 	unlock_door = { convo_name = "DLC2_M02_Unlock_Door", player_speaks = true }, 
  326. 	bs3_first_convo = { convo_name = "DLC2_M02_BS_3_First_Convo", player_speaks = true }, 
  327. 	after_massacre = { convo_name = "DLC2_M02_After_Massacre", player_speaks = true }, 
  328. 	see_zimos_crib = { convo_name = "DLC2_M02_See_Zimos_Crib", player_speaks = true }, 
  329. 	see_rfg_walker = { convo_name = "DLC2_M02_See_RFG_Walker", player_speaks = true }, 
  330. 	see_mars_set = { convo_name = "DLC2_M02_See_Mars_Set", player_speaks = true }, 
  331. 	exit_bs3 = { convo_name = "DLC2_M02_Exit_BS_3_Convo", player_speaks = true }, 
  332. 	third_action_1 = { convo_name = "DLC2_M02_3rd_Action_1_Convo", player_speaks = true }, 
  333. 	see_ship = { convo_name = "DLC2_M02_See_Ship", player_speaks = true }, 
  334. 	rambo_moment = { convo_name = "DLC2_M02_Rambo_Moment", player_speaks = true }, 
  335. 	see_brutina = { convo_name = "DLC2_M02_See_Brutina", player_speaks = true }, 
  336. 	force_field_start = { convo_name = "DLC2_M02_Force_Field_Start", player_speaks = true }, 
  337. 	disable_generator = { convo_name = "DLC2_M02_Disable_Generator", player_speaks = true }, 
  338. 	generator_blows_up = { convo_name = "DLC2_M02_Generator_Blows_Up", player_speaks = false }, 
  339. 	jumping_to_end = { convo_name = "DLC2_M02_Jumping_to_End", player_speaks = true }, 
  340. 	mission_end = { convo_name = "DLC2_M02_Mission_End", player_speaks = false }, 
  341. 	backstage_talking1 = { convo_name = "DLC2_M02_Backstage_Talking1", player_speaks = false }, 
  342. 	backstage_talking2 = { convo_name = "DLC2_M02_Backstage_Talking2", player_speaks = true }, 
  343. 	backstage_talking3 = { convo_name = "DLC2_M02_Backstage_Talking3", player_speaks = true }, 
  344. 	 
  345. 	 
  346. 	-- lines, not convos 
  347. 	first_device_finished_01 = { persona_2d_params = { "DLC2_m02_1st_device_finished_01" },  }, 
  348. 	work_on_trap_01 = { persona_2d_params = { "DLC2_m02_work_on_trap_01" }, }, 
  349. 	new_weapons_01 = { persona_2d_params = { "pak2_m02_new_weapons_01" }, speakers_2d = { "PAK2_Director" }, }, 
  350. 	new_weapons_02 = { persona_2d_params = { "pak2_m02_new_weapons_02" }, speakers_2d = { "PAK2_Director" }, }, 
  351. 	new_weapons_03 = { persona_2d_params = { "pak2_m02_new_weapons_03" }, speakers_2d = { "PAK2_Director" }, }, 
  352. 	action_01 = { persona_2d_params = { "pak2_m02_1st_action_start_01" }, speakers_2d = { "PAK2_Director" }, }, 
  353. 	action_02 = { persona_2d_params = { "pak2_m02_2nd_action_start_01" }, speakers_2d = { "PAK2_Director" }, }, 
  354. 	action_03 = { persona_2d_params = { "pak2_m02_3rd_action_start_01" }, speakers_2d = { "PAK2_Director" }, }, 
  355. 	approval_01 = { persona_2d_params = { "pak2_m02_2nd_device_approval_01" }, speakers_2d = { "PAK2_Director" }, }, 
  356. 	second_device_finished_01 = { persona_3d_params = { LOCAL_PLAYER, "pak2_m02_2nd_device_finished_01" }, }, 
  357. 	third_device_finished_01 = { persona_3d_params = { Dlc2_m02_characters.alien_homie, "pak2_m02_3rd_device_finished_01" }, }, 
  358. 	ready_4a = { persona_3d_params = { Dlc2_m02_characters.alien_homie, "PAK2_M02_Ready_Comp1_01" }, }, 
  359. 	berating_4a = { persona_3d_params = { Dlc2_m02_characters.alien_homie, "pak2_m02_first_tier_berating_01" }, }, 
  360. 	after_4b = { persona_3d_params = { LOCAL_PLAYER, "pak2_m02_after_bottom_tier_01" }, }, 
  361. 	ready_4b = { persona_3d_params = { Dlc2_m02_characters.alien_homie, "PAK2_M02_Ready_Comp2_01" }, }, 
  362. 	ready_4c = { persona_3d_params = { Dlc2_m02_characters.alien_homie, "PAK2_M02_Ready_Comp3_01" }, }, 
  363. 	fiding_key_01 = { persona_3d_params = { Dlc2_m02_characters.alien_homie, "pak2_m02_finding_key_01" }, }, 
  364. 	key_area_explodes_01 = { persona_3d_params = { LOCAL_PLAYER, "pak2_m02_key_area_explodes_01" }, }, 
  365. 	brutina_defeated_01 = { persona_3d_params = { LOCAL_PLAYER, "pak2_m02_brutina_defeated_01" }, }, 
  366. 	disable_generator_01 = { persona_3d_params = { Dlc2_m02_characters.alien_homie, "pak2_m02_disable_generator_01" }, }, 
  367. 	disable_generator_02 = { persona_3d_params = { Dlc2_m02_characters.alien_homie, "pak2_m02_disable_generator_02" }, }, 
  368. 	disable_generator_03  = { persona_3d_params = { LOCAL_PLAYER, "pak2_m02_disable_generator_03" }, }, 
  369. 	saving_player_01 = { persona_3d_params = { Dlc2_m02_characters.alien_homie, "pak2_m02_saving_player_01" }, }, 
  370. 	generic_actions = { persona_2d_params = { "pak2_generic_actions" }, speakers_2d = { "PAK2_Director" }, }, 
  371. } 
  372.  
  373. Dlc2_m02_loadouts = { 
  374. 	player = { 
  375. 		{ 
  376. 			weapons = { 
  377. 				[ WEAPON_SLOT_PISTOL ] = "DLC_LaserPistol", 
  378. 			}, 
  379. 			equip = WEAPON_SLOT_PISTOL, 
  380. 			trigger = "trg_loadout_1", 
  381. 			objective_text = Dlc2_m02_text.get_pistol, 
  382. 			convo = Dlc2_m02_convos.new_weapons_01, 
  383. 		}, 
  384. 		{ 
  385. 			weapons = { 
  386. 				[ WEAPON_SLOT_SMG ] = "DLC_LaserSMG", 
  387. 				[ WEAPON_SLOT_PISTOL ] = "DLC_LaserPistol", 
  388. 			}, 
  389. 			equip = WEAPON_SLOT_SMG, 
  390. 			trigger = "trg_loadout_2", 
  391. 			objective_text = Dlc2_m02_text.get_smg, 
  392. 			convo = Dlc2_m02_convos.new_weapons_02, 
  393. 		}, 
  394. 		{ 
  395. 			weapons = { 
  396. 				[ WEAPON_SLOT_EXPLOSIVE ] = "DLC_GrenadeLauncher", 
  397. 				[ WEAPON_SLOT_SMG ] = "DLC_LaserSMG", 
  398. 				[ WEAPON_SLOT_PISTOL ] = "DLC_LaserPistol", 
  399. 			}, 
  400. 			equip = WEAPON_SLOT_EXPLOSIVE, 
  401. 			trigger = "trg_loadout_3", 
  402. 			objective_text = Dlc2_m02_text.get_final_weapon, 
  403. 			convo = Dlc2_m02_convos.new_weapons_03, 
  404. 		}, 
  405. 	}, 
  406. 	homie = { 
  407. 		"DLC_LaserPistol",  
  408. 		"DLC_LaserSMG", 
  409. 		"DLC_GrenadeLauncher", 
  410. 	} 
  411. } 
  412.  
  413. Dlc2_m02_backstage_doors = { 
  414. 	{  
  415. 		exit = { "mov_door_backstage_exit_1a", "mov_door_backstage_exit_1b" }, 
  416. 	}, 
  417. 	{  
  418. 		enter = { "mov_door_backstage_enter_2a", }, 
  419. 		exit = { "mov_door_backstage_exit_2a", }, 
  420. 	}, 
  421. 	{  
  422. 		enter = { "mov_door_backstage_enter_3a", }, 
  423. 		exit = { "mov_door_backstage_exit_3a", }, 
  424. 	}, 
  425. } 
  426.  
  427. Dlc2_m02_trails = { 
  428. 	backstage1 = { 
  429. 		"nav_trail_backstage_1_1", 
  430. 		"nav_trail_backstage_1_2", 
  431. 		"nav_trail_backstage_1_3", 
  432. 		"nav_trail_backstage_1_4", 
  433. 	}, 
  434. 	room1 = { 
  435. 		"nav_trail_room_1_1", 
  436. 		"nav_machine_1", 
  437. 	}, 
  438. 	room2 = { 
  439. 		"nav_trail_room_2_1", 
  440. 		"nav_trail_room_2_2", 
  441. 		"nav_machine_2", 
  442. 	}, 
  443. 	backstage2 = { 
  444. 		"nav_trail_room_2_2", 
  445. 		"nav_trail_backstage_2_1", 
  446. 		"nav_trail_backstage_2_2", 
  447. 	}, 
  448. 	room3 = { 
  449. 		"nav_trail_room_3_1", 
  450. 		"nav_trail_room_3_2", 
  451. 		"nav_machine_3", 
  452. 	}, 
  453. 	room4a = { 
  454. 		"nav_trail_room_4_1", 
  455. 		"nav_trail_room_4_2", 
  456. 		"nav_trail_room_4_3", 
  457. 		"nav_trail_room_4_4", 
  458. 		"nav_machine4a_local", 
  459. 	}, 
  460. 	room4a_checkpoint = { 
  461. 		"nav_trail_room_4_3", 
  462. 		"nav_trail_room_4_4", 
  463. 		"nav_machine4a_local", 
  464. 	}, 
  465. 	room4b = { 
  466. 		"nav_trail_room_4_5", 
  467. 		"nav_trail_room_4_6", 
  468. 		"nav_machine4b_local", 
  469. 	}, 
  470. 	room4c = { 
  471. 		"nav_trail_room_4_7", 
  472. 		"nav_trail_room_4_8", 
  473. 		"nav_machine4c_local", 
  474. 	}, 
  475. 	room4 = { 
  476. 		"nav_trail_room_4_9", 
  477. 		"nav_machine_4", 
  478. 	}, 
  479. 	backstage3 = { 
  480. 		"nav_trail_backstage_3_1", 
  481. 		"nav_trail_backstage_3_2", 
  482. 	}, 
  483. 	hanger1 = { 
  484. 		"nav_trail_hanger_1", 
  485. 		"nav_trail_hanger_2", 
  486. 	}, 
  487. 	hanger2 = { 
  488. 		"nav_trail_hanger_3", 
  489. 		"nav_trail_hanger_4", 
  490. 		"nav_trail_hanger_5", 
  491. 		"nav_generator" 
  492. 	}, 
  493. } 
  494.  
  495. Dlc2_m02_convo_queue = { } 
  496.  
  497. Dlc2_m02_status = { } 
  498.  
  499. Dlc2_m02_gspawn_data = { 
  500. 	room_1 = {	-- both hall1 and room1 
  501. 		create_groups = { Dlc2_m02_groups.amazon_01, Dlc2_m02_groups.amazon_02 }, 
  502. 	}, 
  503. 	 
  504. 	hall_2 = { 
  505. 		create_groups = { Dlc2_m02_groups.amazon_03 }, 
  506. 	}, 
  507.  
  508. 	room_2 = { 
  509. 		create_groups = { Dlc2_m02_groups.amazon_04 }, 
  510. 	}, 
  511. 	 
  512. 	room_3 = { 
  513. 		delete_groups = { Dlc2_m02_groups.amazon_01, Dlc2_m02_groups.amazon_02, Dlc2_m02_groups.amazon_03, Dlc2_m02_groups.amazon_04 }, 
  514. 		create_groups = { Dlc2_m02_groups.amazon_05 }, 
  515. 	}, 
  516.  
  517. 	room_4 = {  -- hall3 and room4 
  518. 		create_groups = { Dlc2_m02_groups.amazon_06, Dlc2_m02_groups.amazon_07, Dlc2_m02_groups.amazon_08, Dlc2_m02_groups.amazon_09, Dlc2_m02_groups.amazon_10 }, 
  519. 	}, 
  520.  
  521. 	hanger_1 = {  -- on arrival at hanger - before mini cutscene 
  522. 		delete_groups = { Dlc2_m02_groups.amazon_05, Dlc2_m02_groups.amazon_06, Dlc2_m02_groups.amazon_07, Dlc2_m02_groups.amazon_08, Dlc2_m02_groups.amazon_09, Dlc2_m02_groups.amazon_10 }, 
  523. 	}, 
  524.  
  525. 	hanger_2 = {	-- after mini cutscene 
  526. 		create_groups = { Dlc2_m02_groups.amazon_15, Dlc2_m02_groups.amazon_14, Dlc2_m02_groups.amazon_16 }, 
  527. 	}, 
  528.  
  529. 	brutina = {	-- brutina trigger 
  530. 		create_groups = { Dlc2_m02_groups.brutina }, 
  531. 	}, 
  532. 	 
  533. 	kiwiposters = { 
  534. 		create_groups = { Dlc2_m02_groups.kiwiposters }, 
  535. 	} 
  536. } 
  537.  
  538. Dlc2_m02_cspawn_data = { 
  539. 	hall_1 = { 
  540. 		num_elites = 0, 
  541. 		num_pistols = 1, 
  542. 		num_smgs = 1, 
  543. 		cspawn_regions = Dlc2_m02_spawn_regions.hall_1, 
  544. 	}, 
  545. 	 
  546. 	machine_1 = { 
  547. 		num_elites = 0, 
  548. 		num_pistols = 2, 
  549. 		num_smgs = 1, 
  550. 		cspawn_regions = Dlc2_m02_spawn_regions.machine_1, 
  551. 	}, 
  552. 	 
  553. 	hall_2 = { 
  554. 		num_elites = 0, 
  555. 		num_pistols = 2, 
  556. 		num_smgs = 1, 
  557. 		cspawn_regions = Dlc2_m02_spawn_regions.hall_2, 
  558. 	}, 
  559.  
  560. 	machine_2 = { 
  561. 		num_elites = 0, 
  562. 		num_pistols = 1, 
  563. 		num_smgs = 1, 
  564. 		cspawn_regions = Dlc2_m02_spawn_regions.machine_2, 
  565. 	}, 
  566.  
  567. 	machine_3 = { 
  568. 		num_elites = 2, 
  569. 		num_pistols = 1, 
  570. 		num_smgs = 1, 
  571. 		cspawn_regions = Dlc2_m02_spawn_regions.machine_3, 
  572. 		respawn_delay = 1, 
  573. 		filters = { elites = { 2, 4 }, pistols = { 2 }, smgs = { 4 }, }, 
  574. 		tethers = { 
  575. 			[ Dlc2_m02_spawn_groups.elites[ 1 ] ] = { { nav = "nav_room_3_attack_from_l3", d = 1 } }, 
  576. 			[ Dlc2_m02_spawn_groups.elites[ 2 ] ] = { { nav = "nav_room_3_attack_from_r3", d = 1 } }, 
  577. 			[ Dlc2_m02_spawn_groups.pistols[ 1 ] ] = { { nav = "nav_room_3_attack_from_l2", d = 1 }, { nav = "nav_room_3_attack_from_r2", d = 1 }, }, 
  578. 			[ Dlc2_m02_spawn_groups.smgs[ 1 ] ] = { { nav = "nav_room_3_attack_from_l1", d = 1 }, { nav = "nav_room_3_attack_from_r1", d = 1 }, }, 
  579. 		}, 
  580. 	}, 
  581.  
  582. 	hall_3 = { 
  583. 		num_elites = 1, 
  584. 		num_pistols = 2, 
  585. 		num_smgs = 2, 
  586. 		cspawn_regions = Dlc2_m02_spawn_regions.hall_3, 
  587. 	}, 
  588.  
  589. 	machine_4a = { 
  590. 		num_elites = 0, 
  591. 		num_pistols = 1, 
  592. 		num_smgs = 1, 
  593. 		cspawn_regions = Dlc2_m02_spawn_regions.machine_4a, 
  594. 		filters = { elites = {  }, pistols = { 2 }, smgs = { 4 }, }, 
  595. 		tethers = { 
  596. 			[ Dlc2_m02_spawn_groups.pistols[ 1 ] ] = { { nav = "nav_room_4_attack_from_l1", d = 1 }, { nav = "nav_room_4_attack_from_l2", d = 1 }, }, 
  597. 			[ Dlc2_m02_spawn_groups.smgs[ 1 ] ] = { { nav = "nav_room_4_attack_from_l3", d = 1 }, { nav = "nav_room_4_attack_from_l4", d = 1 }, }, 
  598. 		}, 
  599. 	}, 
  600. 	 
  601. 	machine_4b = { 
  602. 		num_elites = 0, 
  603. 		num_pistols = 2, 
  604. 		num_smgs = 2, 
  605. 		cspawn_regions = Dlc2_m02_spawn_regions.machine_4b, 
  606. 		filters = { elites = {  }, pistols = { 4 }, smgs = { 2 }, }, 
  607. 		tethers = { 
  608. 			[ Dlc2_m02_spawn_groups.smgs[ 1 ] ] = { { nav = "nav_room_4_attack_from_r1", d = 1 }, { nav = "nav_room_4_attack_from_r2", d = 1 }, }, 
  609. 			[ Dlc2_m02_spawn_groups.pistols[ 1 ] ] = { { nav = "nav_room_4_attack_from_r3", d = 1 }, { nav = "nav_room_4_attack_from_r4", d = 1 }, }, 
  610. 		}, 
  611. 	}, 
  612.  
  613. 	machine_4 = { 
  614. 		num_elites = 2, 
  615. 		num_pistols = 2, 
  616. 		num_smgs = 0, 
  617. 		cspawn_regions = Dlc2_m02_spawn_regions.machine_4, 
  618. 		filters = { elites = { 4, 2 }, pistols = { 4, 2 }, smgs = {  }, }, 
  619. 		tethers = { 
  620. 			[ Dlc2_m02_spawn_groups.elites[ 1 ] ] = { { nav = "nav_room_4_attack_from_m1", d = 1 } }, 
  621. 			[ Dlc2_m02_spawn_groups.elites[ 2 ] ] = { { nav = "nav_room_4_attack_from_m8", d = 1 } }, 
  622. 			[ Dlc2_m02_spawn_groups.pistols[ 1 ] ] = { { nav = "nav_room_4_attack_from_m3", d = 1 }, { nav = "nav_room_4_attack_from_m4", d = 1 }, }, 
  623. 			[ Dlc2_m02_spawn_groups.pistols[ 2 ] ] = { { nav = "nav_room_4_attack_from_m5", d = 1 }, { nav = "nav_room_4_attack_from_m6", d = 1 }, }, 
  624. 		}, 
  625. 	}, 
  626.  
  627. 	brutina = {	-- brutina trigger 
  628. 		num_elites = 2, 
  629. 		num_pistols = 3, 
  630. 		num_smgs = 3, 
  631. 		cspawn_regions = Dlc2_m02_spawn_regions.hanger_1, 
  632. 	}, 
  633. } 
  634.  
  635. Dlc2_m02_trigger_doors = { 
  636. 	room1_entry = { 
  637. 		trigger = Dlc2_m02_triggers.room1_enter_door, 
  638. 		doors = { "mov_door_room1_enter_1a" }, 
  639. 		audio_event = "M02_Part1_Machine_Room_1", 
  640. 	}, 
  641. 	hall2_entry = { 
  642. 		trigger = Dlc2_m02_triggers.hall2_enter_door, 
  643. 		doors = { "mov_door_hall2_enter_1a",  }, 
  644. 	}, 
  645. 	room2_entry = { 
  646. 		trigger = Dlc2_m02_triggers.room2_enter_door, 
  647. 		doors = { "mov_door_room2_enter_1a" }, 
  648. 		audio_event = "M02_Part1_Machine_Room_2", 
  649. 	}, 
  650. 	room3_entry = { 
  651. 		trigger = Dlc2_m02_triggers.room3_enter_door, 
  652. 		doors = { "mov_door_room3_enter_1a", "mov_door_room3_enter_1b", }, 
  653. 	}, 
  654. 	hall3_entry = { 
  655. 		trigger = Dlc2_m02_triggers.hall3_enter_door, 
  656. 		doors = { "mov_door_hall3_enter_1a" }, 
  657. 		audio_event = "M02_Part2_Corridor_2", 
  658. 	}, 
  659. 	room4_entry = { 
  660. 		trigger = Dlc2_m02_triggers.room4_enter_door, 
  661. 		doors = { "mov_door_room4_enter_1a", }, 
  662. 	}, 
  663. 	room4_exit = { 
  664. 		trigger = Dlc2_m02_triggers.room4_exit_door, 
  665. 		doors = { "mov_door_room4_exit_1a" }, 
  666. 	}, 
  667. 	hall4_entry = { 
  668. 		trigger = Dlc2_m02_triggers.hall4_enter_door, 
  669. 		doors = { "mov_door_hall4_entry_1a" }, 
  670. 	}, 
  671. 	hanger_entry = { 
  672. 		trigger = Dlc2_m02_triggers.hanger_enter_door, 
  673. 		doors = { "mov_door_hanger_entry_1a" }, 
  674. 	}, 
  675. } 
  676.  
  677. Dlc2_m02_backstage_data = { 
  678. 	{ 
  679. 		exit_trigger = "trg_backstage_exit_1", 
  680. 		doors = Dlc2_m02_backstage_doors[ 1 ], 
  681. 		player_loadout = Dlc2_m02_loadouts.player[ 1 ], 
  682. 		homie_loadout = Dlc2_m02_loadouts.homie[ 1 ], 
  683. 		homie_personality = "gang defensive", 
  684. 		create_groups = { Dlc2_m02_groups.loadout1 }, 
  685. 		loadout_trail = Dlc2_m02_trails.backstage1, 
  686. 		convo_enter = Dlc2_m02_convos.bs_1_first_convo, 
  687. 		action_line = Dlc2_m02_convos.action_01, 
  688. 		convo_exit = Dlc2_m02_convos.first_action_1, 
  689. 	}, 
  690. 	{ 
  691. 		enter_trigger = "trg_backstage_enter_2", 
  692. 		exit_trigger = "trg_backstage_exit_2", 
  693. 		doors = Dlc2_m02_backstage_doors[ 2 ], 
  694. 		player_loadout = Dlc2_m02_loadouts.player[ 2 ], 
  695. 		homie_loadout = Dlc2_m02_loadouts.homie[ 2 ], 
  696. 		homie_personality = "gang normal", 
  697. 		trigger_doors_at_end = { Dlc2_m02_trigger_doors.room3_entry }, 
  698. 		create_groups = { Dlc2_m02_groups.loadout2 }, 
  699. 		trail = Dlc2_m02_trails.backstage2, 
  700. 		convo_enter = Dlc2_m02_convos.bs_2_first, 
  701. 		action_line = Dlc2_m02_convos.generic_actions, 
  702. 		convo_exit = Dlc2_m02_convos.second_action_1, 
  703. 		on_enter_backstage_audio_event = "M02_Part1_Music_Stop", 
  704. 	}, 
  705. 	{ 
  706. 		enter_trigger = "trg_backstage_enter_3", 
  707. 		exit_trigger = "trg_backstage_exit_3", 
  708. 		doors = Dlc2_m02_backstage_doors[ 3 ], 
  709. 		player_loadout = Dlc2_m02_loadouts.player[ 3 ], 
  710. 		homie_loadout = Dlc2_m02_loadouts.homie[ 3 ], 
  711. 		homie_personality = "gang offensive", 
  712. 		trigger_doors_at_end = { Dlc2_m02_trigger_doors.hall4_entry }, 
  713. 		create_groups = { Dlc2_m02_groups.loadout3 }, 
  714. 		action_line = Dlc2_m02_convos.action_03, 
  715. 		on_enter_backstage_audio_event = "M02_Part2_Music_Stop", 
  716. 		no_trail = true, 
  717. 	}, 
  718. } 
  719.  
  720. Dlc2_m02_machine_data = { 
  721. 	machine_1 = { 
  722. 		mover = "mov_machine_1", 
  723. 		navpoint = "nav_machine_1", 
  724. 		approach_trigger = "trg_machine_approach_1", 
  725. 		activation_time = 30, 
  726. 		homie_activates = true, 
  727. 		safe_nav = "nav_machine_safe_1", 
  728. 		gspawn_data = Dlc2_m02_gspawn_data.room_1, 
  729. 		cspawn_data = Dlc2_m02_cspawn_data.machine_1, 
  730. 		explosion_type = "alien_mindcontrol", 
  731. 		trigger_doors = { Dlc2_m02_trigger_doors.room1_entry }, 
  732. 		trail = Dlc2_m02_trails.room1, 
  733. 		convo_approach = Dlc2_m02_convos.find_1st_device, 
  734. 		convo_complete = Dlc2_m02_convos.first_device_end, 
  735. 		machine_mover = "mov_machine_1", 
  736. 		countdown_audio_event = "M02_Part1_Countdown_1", 
  737. 		homie_port = "nav_room1_homie_port", 
  738. 	}, 
  739. 	machine_2 = { 
  740. 		mover = "mov_machine_2", 
  741. 		trigger = Dlc2_m02_triggers.machine_2, 
  742. 		navpoint = "nav_machine_2", 
  743. 		approach_trigger = "trg_machine_approach_2", 
  744. 		safe_nav = "nav_machine_safe_2", 
  745. 		activation_time = 30, 
  746. 		player_activates = true, 
  747. 		gspawn_data = Dlc2_m02_gspawn_data.hall_2, 
  748. 		cspawn_data = Dlc2_m02_cspawn_data.machine_2, 
  749. 		explosion_type = "alien_mindcontrol", 
  750. 		trigger_doors = { Dlc2_m02_trigger_doors.room2_entry, Dlc2_m02_trigger_doors.hall2_entry }, 
  751. 		trail = Dlc2_m02_trails.room2, 
  752. 		convo_approach = {  Dlc2_m02_convos.find_2nd_device, Dlc2_m02_convos.approval_01 }, 
  753. 		convo_finish = Dlc2_m02_convos.second_device_finished_01, 
  754. 		convo_complete = Dlc2_m02_convos.second_device_end, 
  755. 		machine_mover = "mov_machine_2", 
  756. 		start_disable_audio_event = "M02_Part1_Countdown_2", 
  757. 		homie_port = "nav_room2_homie_port", 
  758. 	}, 
  759. 	machine_3 = { 
  760. 		mover = "mov_machine_3", 
  761. 		navpoint = "nav_machine_3", 
  762. 		safe_nav = "nav_machine_safe_3", 
  763. 		approach_trigger = "trg_machine_approach_3", 
  764. 		activation_time = 30, 
  765. 		homie_activates = true, 
  766. 		gspawn_data = Dlc2_m02_gspawn_data.room_3, 
  767. 		cspawn_data = Dlc2_m02_cspawn_data.machine_3, 
  768. 		explosion_type = "alien_mindcontrol", 
  769. 		trail = Dlc2_m02_trails.room3, 
  770. 		convo_approach = Dlc2_m02_convos.find_third_device, 
  771. 		convo_finish = Dlc2_m02_convos.third_device_finished_01, 
  772. 		convo_complete = Dlc2_m02_convos.third_device_end, 
  773. 		machine_mover = "mov_machine_3", 
  774. 		start_disable_audio_event = "M02_Part2_Kwilanna_1", 
  775. 		countdown_audio_event = "M02_Part2_Countdown_1", 
  776. 		homie_port = "nav_room3_homie_port", 
  777. 		explosions = { "nav_machine_3_explode_1", "nav_machine_3_explode_2", "nav_machine_3_explode_3",  }, 
  778. 		explosions_mov = { 
  779. 			{ "mov_barrell_01", "mov_barrell_02", "mov_barrell_03", "mov_barrell_09", "mov_barrell_10", "mov_barrell_11", }, 
  780. 			{ "mov_barrell_04", "mov_barrell_05", "mov_barrell_06", "mov_barrell_12", "mov_barrell_13", "mov_barrell_14", }, 
  781. 			{ "mov_barrell_07", "mov_barrell_08", "mov_barrell_15", "mov_barrell_16", }, 
  782. 		} 
  783. 	}, 
  784. 	machine_4a = { 
  785. 		navpoint = "nav_machine4a_local", 
  786. 		navpoint_homie = "nav_machine4a_homie", 
  787. 		trigger = Dlc2_m02_triggers.machine_4a, 
  788. 		approach_trigger = "trg_machine4a_approach", 
  789. 		activation_time = 30, 
  790. 		both_disable = true, 
  791. 		gspawn_data = Dlc2_m02_gspawn_data.room_4, 
  792. 		cspawn_data = Dlc2_m02_cspawn_data.machine_4a, 
  793. 		trigger_doors = { Dlc2_m02_trigger_doors.hall3_entry, Dlc2_m02_trigger_doors.room4_entry }, 
  794. 		trail = Dlc2_m02_trails.room4a, 
  795. 		convo_homie_ready = { Dlc2_m02_convos.ready_4a, Dlc2_m02_convos.berating_4a  }, 
  796. 		convo_complete = Dlc2_m02_convos.after_first_tier, 
  797. 		alt_approach_msg = Dlc2_m02_text.go_to_server, 
  798. 		start_disable_audio_event = "M02_Part2_Code_Search", 
  799. 		homie_port = "nav_room4_homie_port", 
  800. 	}, 
  801. 	machine_4b = { 
  802. 		navpoint = "nav_machine4b_local", 
  803. 		navpoint_homie = "nav_machine4b_homie", 
  804. 		trigger = Dlc2_m02_triggers.machine_4b, 
  805. 		approach_trigger = "trg_machine4b_approach", 
  806. 		activation_time = 30, 
  807. 		both_disable = true, 
  808. 		cspawn_data = Dlc2_m02_cspawn_data.machine_4b, 
  809. 		alt_approach_msg = Dlc2_m02_text.go_to_server, 
  810. 		trail = Dlc2_m02_trails.room4b, 
  811. 		convo_homie_ready = Dlc2_m02_convos.ready_4c, 
  812. 		convo_complete = Dlc2_m02_convos.after_4b, 
  813. 	}, 
  814. 	machine_4c = { 
  815. 		navpoint = "nav_machine4c_local", 
  816. 		navpoint_homie = "nav_machine4c_homie", 
  817. 		trigger = Dlc2_m02_triggers.machine_4c, 
  818. 		approach_trigger = "trg_machine4c_approach", 
  819. 		activation_time = 30, 
  820. 		both_disable = true,   
  821. 		convo_homie_ready = Dlc2_m02_convos.ready_4c, 
  822. 		convo_complete = { Dlc2_m02_convos.finding_key_01, Dlc2_m02_convos.trigger_destruct, }, 
  823. 		alt_approach_msg = Dlc2_m02_text.go_to_server, 
  824. 		trail = Dlc2_m02_trails.room4c, 
  825. 	}, 
  826. 	machine_4 = { 
  827. 		mover = "mov_machine_4", 
  828. 		navpoint = "nav_machine_4", 
  829. 		approach_trigger = "trg_machine_approach_4", 
  830. 		activation_time = 30, 
  831. 		homie_activates = true, 
  832. 		trail = Dlc2_m02_trails.room4b, 
  833. 		cspawn_data = Dlc2_m02_cspawn_data.machine_4, 
  834. 		convo_homie_ready = Dlc2_m02_convos.control_room, 
  835. 		convo_complete = Dlc2_m02_convos.unlock_door, 
  836. 		trail = Dlc2_m02_trails.room4, 
  837. 		start_disable_audio_event = "M02_Part2_Kwilanna_2", 
  838. 		proximity_check_waived = true, 
  839. 	}, 
  840. } 
  841.  
  842. Dlc2_m02_checkpoint_data = { 
  843. 	[ Dlc2_m02_checkpoints[ 1 ]  ] = {	-- mission start 
  844. 		local_start_nav = "nav_local_mission_start", 
  845. 		remote_start_nav = "nav_remote_mission_start", 
  846. 		homie_start_nav = "nav_homie_mission_start", 
  847. 	}, 
  848.  
  849. 	[ Dlc2_m02_checkpoints[ 2 ]  ] = {	-- room 1 
  850. 		local_start_nav = "nav_local_start_cp_m1", 
  851. 		remote_start_nav = "nav_remote_start_cp_m1", 
  852. 		homie_start_nav = "nav_homie_start_cp_m1", 
  853. 		backstage_data = Dlc2_m02_backstage_data[ 1 ] 
  854. 	}, 
  855.  
  856. 	[ Dlc2_m02_checkpoints[ 3 ]  ] = {	-- room 2 
  857. 		local_start_nav = "nav_local_start_cp_m2", 
  858. 		remote_start_nav = "nav_remote_start_cp_m2", 
  859. 		homie_start_nav = "nav_homie_start_cp_m2", 
  860. 		backstage_data = Dlc2_m02_backstage_data[ 2 ] 
  861. 	}, 
  862.  
  863. 	[ Dlc2_m02_checkpoints[ 4 ]  ] = {	-- room 3 
  864. 		local_start_nav = "nav_local_start_cp_m3", 
  865. 		remote_start_nav = "nav_remote_start_cp_m3", 
  866. 		homie_start_nav = "nav_homie_start_cp_m3", 
  867. 		backstage_data = Dlc2_m02_backstage_data[ 2 ] 
  868. 	}, 
  869. 	 
  870. 	[ Dlc2_m02_checkpoints[ 5 ]  ] = {	-- room 4 
  871. 		local_start_nav = "nav_local_start_cp_m4", 
  872. 		remote_start_nav = "nav_remote_start_cp_m4", 
  873. 		homie_start_nav = "nav_homie_start_cp_m4", 
  874. 		backstage_data = Dlc2_m02_backstage_data[ 3 ] 
  875. 	}, 
  876. } 
  877.  
  878. Dlc2_m02_clapboards = { 
  879. 	{ trigger = Dlc2_m02_triggers.clapboard_01, item = "item_clapboard_01", effect = "Vfx_clapboard_01", collected = false, }, 
  880. 	{ trigger = Dlc2_m02_triggers.clapboard_02, item = "item_clapboard_02", effect = "Vfx_clapboard_02", collected = false, }, 
  881. 	{ trigger = Dlc2_m02_triggers.clapboard_03, item = "item_clapboard_03", effect = "Vfx_clapboard_03", collected = false, }, 
  882. 	{ trigger = Dlc2_m02_triggers.clapboard_04, item = "item_clapboard_04", effect = "Vfx_clapboard_04", collected = false, }, 
  883. 	{ trigger = Dlc2_m02_triggers.clapboard_05, item = "item_clapboard_05", effect = "Vfx_clapboard_05", collected = false, }, 
  884. 	{ trigger = Dlc2_m02_triggers.clapboard_06, item = "item_clapboard_06", effect = "Vfx_clapboard_06", collected = false, }, 
  885. } 
  886.  
  887. -- Achievement data 
  888. 	Dlc2_m02_achievements = { 
  889. 		pew_pew_pew = { 
  890. 			name = "Pew Pew Pew!", 
  891. 			slot_idx = 0, 
  892. 			current_count = 0, 
  893. 			target_goal = 35, 
  894. 		}, 
  895. 		man_power = { 
  896. 			name = "Man Power!", 
  897. 			slot_idx = 1, 
  898. 			current_count = 0, 
  899. 			target_goal = 7, 
  900. 		}, 
  901. 		lights_camera_action = { 
  902. 			name = "Lights! Camera! Action!", 
  903. 			slot_idx = 1, 
  904. 			current_count = 0, 
  905. 			target_goal = #Dlc2_m02_clapboards, 
  906. 		}, 
  907. 	} 
  908.  
  909. 	-- ************************* 
  910. -- 
  911. -- Standard functions 
  912. -- 
  913. -- ************************* 
  914. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  915. -- at the specified checkpoint. 
  916. -- CALLED FROM CODE 
  917. -- 
  918. -- dlc2_m02_checkpoint:	The checkpoint the mission should begin at 
  919. -- is_restart:					TRUE if the mission is restarting, FALSE otherwise 
  920. -- 
  921. function dlc2_m02_start( checkpoint, is_restart ) 
  922.  
  923. 	-- Disable the ability to add crib weapons for this mission.  There wasn't room on consoles to store the meshes outside of the mission. 
  924. 	-- This fixes bug XXX where when the player did a brute kill with the pistol, the laser pistol weapon info was added to the crib 
  925. 	crib_weapon_add_disable() 
  926.  
  927. 	-- Make sure the screen is completly faded out 
  928. 	mission_start_fade_out( 0.0 ) 
  929. 	 
  930. 	if checkpoint == Dlc2_m02_checkpoints[ 1 ] then 
  931. 		-- Clear all of the acievement counters 
  932. 		for i, achievement in pairs(Dlc2_m02_achievements) do 
  933. 			dlc2_m02_helper_achievement_reset( achievement ) 
  934. 		end 
  935. 		 
  936. 		dlc2_m02_clapboards_reset( #Dlc2_m02_clapboards ) 
  937. 		 
  938. 		teleport_coop( Dlc2_m02_navpoints.local_mission_start, Dlc2_m02_navpoints.remote_mission_start, true  ) 
  939. 	end 
  940.  
  941. 	dlc2_m02_clapboard_setup() 
  942. 	 
  943. 	dlc2_m02_initialize_common() 
  944. 	dlc2_m02_initialize_checkpoint( checkpoint ) 
  945. 	 
  946. 	-- Start fading in  
  947. 	mission_start_fade_in() 
  948.  
  949. 	-- Run the mission from the current checkpoint 
  950. 	dlc2_m02_run( checkpoint, is_restart ) 
  951. end 
  952.  
  953. -- This is the primary function responsible for running the entire mission from start to finish. 
  954. -- 
  955. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  956. -- 
  957. function dlc2_m02_run( first_checkpoint, is_restart ) 
  958. 	local current_checkpoint = first_checkpoint 
  959. 	local homie = Dlc2_m02_characters.alien_homie 
  960.  
  961. 	-- make sure player personas are set to dlc2 
  962. 	persona_set_dlc_bundle(2) 
  963. 	 
  964. 	group_create( Dlc2_m02_groups.clapboards ) 
  965.  
  966. 	if current_checkpoint == Dlc2_m02_checkpoints[ 1 ] then 
  967. 		character_ragdoll_set_last_resort_position( Dlc2_m02_checkpoint_data[ current_checkpoint ].local_start_nav ) 
  968. 		 
  969. 		dlc2_m02_set_up_spawn_phase( Dlc2_m02_cspawn_data.hall_1 ) 
  970.  
  971. 		on_trigger( "dlc2_m02_backstage_01_roof", Dlc2_m02_triggers.backstage_01_roof ) 
  972. 		trigger_enable( Dlc2_m02_triggers.backstage_01_roof ) 
  973.  
  974. 		dlc2_m02_handle_backstage( Dlc2_m02_backstage_data[ 1 ], is_restart ) 
  975. 		 
  976. 		audio_object_post_event( "M02_Part1_Music_Start", nil, nil, LOCAL_PLAYER ) 
  977. 		 
  978. 		dlc2_m02_film_grain_load() 
  979. 		 
  980. 		-- destroy each machine in turn 
  981. 		dlc2_m02_handle_machine( Dlc2_m02_machine_data.machine_1 ) 
  982. 		 
  983. 		dlc2_m02_setup_convo_trigger( Dlc2_m02_triggers.hall_01_first_action_2, Dlc2_m02_convos.first_action_2 ) 
  984. 		 
  985. 		dlc2_m02_helper_achievements_write_checkpoint() 
  986. 		current_checkpoint = Dlc2_m02_checkpoints[ 2 ] 
  987. 		mission_set_checkpoint( current_checkpoint ) 
  988. 	end 
  989. 		 
  990. 	if current_checkpoint == Dlc2_m02_checkpoints[ 2 ] then 
  991. 	 
  992. 		dlc2_m02_film_grain_load() 
  993.  
  994. 		dlc2_m02_set_up_spawn_phase( Dlc2_m02_cspawn_data.hall_2 ) 
  995. 		 
  996. 		Dlc2_m02_status.spawn_on_wake = Dlc2_m02_gspawn_data.room_2 
  997. 	 
  998. 		dlc2_m02_handle_machine( Dlc2_m02_machine_data.machine_2 ) 
  999. 		 
  1000. 		dlc2_m02_setup_convo_trigger( Dlc2_m02_triggers.backstage_02_borc, Dlc2_m02_convos.see_borc_set ) 
  1001. 		 
  1002. 		dlc2_m02_setup_convo_trigger( Dlc2_m02_triggers.action_02, Dlc2_m02_convos.exit_bs_2 ) 
  1003.  
  1004. 		dlc2_m02_handle_backstage( Dlc2_m02_backstage_data[ 2 ] ) 
  1005.  
  1006. 		dlc2_m02_helper_achievements_write_checkpoint() 
  1007. 		current_checkpoint = Dlc2_m02_checkpoints[ 3 ] 
  1008. 		mission_set_checkpoint( current_checkpoint ) 
  1009. 	end 
  1010.  
  1011. 	if current_checkpoint == Dlc2_m02_checkpoints[ 3 ] then 
  1012. 		if first_checkpoint == Dlc2_m02_checkpoints[ 3 ] then 
  1013. 			-- since this checkpoint is starting us in the backstage we have to simulate that bit here 
  1014. 			 
  1015. 			-- objective 
  1016. 			objective_text( 0, Dlc2_m02_text.go_to_set, nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  1017. 			marker_add_trigger( "trg_backstage_exit_2", MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL, SYNC_ALL ) 
  1018. 			dlc2_m02_convo_play( Dlc2_m02_convos.exit_bs_2, false, true) 
  1019.  
  1020. 			dlc2_m02_wait_for_player_to_enter_trigger( "trg_backstage_exit_2", true ) 
  1021.  
  1022. 			objective_text_clear( 0 ) 
  1023. 			marker_remove( "trg_backstage_exit_2" ) 
  1024. 			dlc2_m02_convo_play( Dlc2_m02_convos.generic_actions, false, true ) 
  1025. 			dlc2_m02_convo_play( Dlc2_m02_convos.second_action_1, false, false) 
  1026. 			end 
  1027.  
  1028. 		dlc2_m02_film_grain_load() 
  1029.  
  1030. 		character_ragdoll_set_last_resort_position( Dlc2_m02_checkpoint_data[ current_checkpoint ].local_start_nav ) 
  1031. 		 
  1032. 		on_trigger( "dlc2_m02_room3_cue_music", "trg_room3_cue_music" ) 
  1033. 		trigger_enable( "trg_room3_cue_music", true ) 
  1034.  
  1035. 		dlc2_m02_handle_machine( Dlc2_m02_machine_data.machine_3 ) 
  1036. 		 
  1037. 		dlc2_m02_helper_achievements_write_checkpoint() 
  1038. 		current_checkpoint = Dlc2_m02_checkpoints[ 4 ] 
  1039. 		mission_set_checkpoint( current_checkpoint ) 
  1040. 	end 
  1041. 		 
  1042. 	if current_checkpoint == Dlc2_m02_checkpoints[ 4 ] then 
  1043. 		dlc2_m02_film_grain_load() 
  1044.  
  1045. 		dlc2_m02_set_up_spawn_phase( Dlc2_m02_cspawn_data.hall_3 ) 
  1046. 		 
  1047. 		-- use altered crumb trail on chekpoint 
  1048. 		if first_checkpoint == Dlc2_m02_checkpoints[ 4 ] then 
  1049. 			Dlc2_m02_machine_data.machine_4a.trail = Dlc2_m02_trails.room4a_checkpoint 
  1050. 		end 
  1051. 		 
  1052. 		dlc2_m02_setup_convo_trigger( Dlc2_m02_triggers.hall_03_find_key_area, Dlc2_m02_convos.find_key_area ) 
  1053.  
  1054. 		dlc2_m02_handle_machine( Dlc2_m02_machine_data.machine_4a ) 
  1055. 		dlc2_m02_handle_machine( Dlc2_m02_machine_data.machine_4b ) 
  1056. 		dlc2_m02_end_cspawning() 
  1057. 		dlc2_m02_handle_machine( Dlc2_m02_machine_data.machine_4c ) 
  1058. 		 
  1059. 		audio_object_post_event( "M02_Part2_Countdown_2", nil, nil, LOCAL_PLAYER ) 
  1060. 		audio_object_post_event( "M02_Security", nil, nil, LOCAL_PLAYER ) 
  1061. 		hud_critical_timer_set( 60 * 1000, Dlc2_m02_text.security_activating, "dlc2_m02_activate_security", SYNC_ALL ) 
  1062. 		dlc2_m02_handle_machine( Dlc2_m02_machine_data.machine_4 ) 
  1063. 		 
  1064. 		Dlc2_m02_threads.homie_kill_thread = thread_new( "dlc2_m02_homie_kills" ) 
  1065. 		 
  1066. 		dlc2_m02_setup_convo_trigger( Dlc2_m02_triggers.backstage_03_mars, Dlc2_m02_convos.see_mars_set ) 
  1067. 		dlc2_m02_setup_convo_trigger( Dlc2_m02_triggers.backstage_03_walker, Dlc2_m02_convos.see_rfg_walker ) 
  1068. 		dlc2_m02_setup_convo_trigger( Dlc2_m02_triggers.backstage_03_exit, Dlc2_m02_convos.exit_bs3 ) 
  1069. 		 
  1070. 		dlc2_m02_setup_door_trigger( Dlc2_m02_trigger_doors.room4_exit ) 
  1071.  
  1072. 		-- wait to detonate room 
  1073. 		dlc2_m02_trail_start( Dlc2_m02_trails.backstage3 ) 
  1074. 		objective_text( 0, Dlc2_m02_text.go_to_backstage, nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  1075.  
  1076. 		dlc2_m02_wait_for_player_to_enter_trigger( "trg_room4_escape" ) 
  1077. 		 
  1078. 		hud_critical_timer_stop() 
  1079. 		audio_object_post_event( "M02_Security_Stop", nil, nil, LOCAL_PLAYER ) 
  1080.  
  1081. 		local nav_explosions = { 
  1082. 			"self_destruct_explosion<001>", 
  1083. 			"self_destruct_explosion<002>", 
  1084. 			"self_destruct_explosion<003>", 
  1085. 			"self_destruct_explosion<004>", 
  1086. 			"self_destruct_explosion<005>", 
  1087. 			"self_destruct_explosion<006>", 
  1088. 			"self_destruct_explosion<007>", 
  1089. 		} 
  1090. 	 
  1091. 		for i, nav in pairs( nav_explosions ) do 
  1092. 			explosion_create( "alien_mindcontrol", nav, nil, nil, "vfx_mindcontrol_exp" ) 
  1093. 			camera_shake_play( "m24_marsquake", 6 ) 
  1094. 			delay( 1.0 ) 
  1095. 		end 
  1096. 		 
  1097. 		dlc2_m02_convo_play( Dlc2_m02_convos.key_area_explodes_01, false, true ) 
  1098.  
  1099. 		dlc2_m02_handle_backstage( Dlc2_m02_backstage_data[ 3 ] ) 
  1100.  
  1101. 		dlc2_m02_helper_achievements_write_checkpoint() 
  1102. 		current_checkpoint = Dlc2_m02_checkpoints[ 5 ] 
  1103. 		mission_set_checkpoint( current_checkpoint ) 
  1104. 	end 
  1105. 	 
  1106. 	character_ragdoll_set_last_resort_position( Dlc2_m02_checkpoint_data[ current_checkpoint ].local_start_nav ) 
  1107. 	 
  1108. 	-- audio: ACTION! 
  1109. 	-- TODO 
  1110. 	 
  1111. 	dlc2_m02_film_grain_load() 
  1112. 	 
  1113. 	dlc2_m02_saucer_camera_sequence() 
  1114. 	 
  1115. 	dlc2_m02_go_to_saucer() 
  1116. 	 
  1117. 	dlc2_m02_brutina() 
  1118. 	 
  1119. 	dlc2_m02_obj_shut_down_forcefield() 
  1120. 	 
  1121. 	dlc2_m02_escape_in_saucer() 
  1122. 	 
  1123. 	mission_end_success( "dlc2_m02" ) 
  1124. 	Dlc2_m02_status.mission_success = true 
  1125. end 
  1126.  
  1127. -- This is the primary function responsible for cleaning up the entire mission 
  1128. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  1129. -- 
  1130. function dlc2_m02_cleanup() 
  1131. 	dlc2_m02_trail_stop() 
  1132. 	hud_critical_timer_stop() 
  1133. 	cleanup_callbacks( Dlc2_m02_characters ) 
  1134. 	dlc2_m02_cleanup_group_members( Dlc2_m02_groups ) 
  1135. 	cleanup_groups( Dlc2_m02_groups ) 
  1136. 	dlc2_m02_cleanup_convos( Dlc2_m02_convos ) 
  1137. 	dlc2_m02_cleanup_triggers( Dlc2_m02_triggers ) 
  1138. 	dlc2_m02_cleanup_threads( Dlc2_m02_threads ) 
  1139. 	dlc2_m02_cleanup_movers( Dlc2_m02_movers ) 
  1140. 	dlc2_m02_cleanup_continuous_spawn_groups( Dlc2_m02_spawn_groups ) 
  1141. 	dlc2_m02_cleanup_continuous_spawn_regions( Dlc2_m02_spawn_regions ) 
  1142. 	qte_cleanup() 
  1143. 	character_ragdoll_clear_last_resort_position() 
  1144. 	spawning_vehicles( true ) 
  1145. 	spawning_pedestrians( true ) 
  1146. 	player_grenades_enable() 
  1147.    team_make_hostile( "Neutral Gang", "Playas" ) 
  1148. 	character_fake_revival_end( LOCAL_PLAYER ) 
  1149. 	customization_item_revert() 
  1150. 	player_force_vehicle_seat( LOCAL_PLAYER, -1 ) 
  1151. 	player_parachute_wear_backpack( LOCAL_PLAYER, false ) 
  1152. 	player_movement_enable( LOCAL_PLAYER ) 
  1153. 	player_can_sprint( true ) 
  1154. 	radio_global_block( false ) 
  1155. 	audio_object_post_event( "M02_Music_Kill", nil, nil, LOCAL_PLAYER ) 
  1156. 	dlc2_m02_enable_traps( false ) 
  1157. 	 
  1158. 	on_trigger( "", "trg_room3_cue_music" ) 
  1159.  
  1160. 	if coop_is_active() then 
  1161. 		player_force_vehicle_seat( REMOTE_PLAYER, -1 ) 
  1162. 	end 
  1163.  
  1164. 	notoriety_set_min_and_max( "police", 0, 5 ) 
  1165. 	notoriety_set_min_and_max( "stag", 0, 5 ) 
  1166. 	notoriety_set_min_and_max( "luchadores", 0, 5 ) 
  1167. 	notoriety_set_min_and_max( "deckers", 0, 5 ) 
  1168. 	notoriety_set_min_and_max( "morningstar", 0, 5 ) 
  1169. 	 
  1170. 	notoriety_force_no_spawn( "police", false ) 
  1171. 	notoriety_force_no_spawn( "stag", false ) 
  1172. 	notoriety_force_no_spawn( "luchadores", false ) 
  1173. 	notoriety_force_no_spawn( "deckers", false ) 
  1174. 	notoriety_force_no_spawn( "morningstar", false ) 
  1175. 	 
  1176. 	dlc2_m02_film_grain_unload( false ) 
  1177. 	dlc2_m02_remove_loadout() 
  1178. 	inv_weapon_disable_all_slots( false ) 
  1179. 	 
  1180. 	camera_end_look_through( true ) 
  1181. 	 
  1182. 	audio_persona_remove_2d( Dlc2_m02_status.personas[ "PAK2_Kwilanna" ]  ) 
  1183. 	audio_persona_remove_2d( Dlc2_m02_status.personas[ "PAK2_Director" ] ) 
  1184. 	 
  1185. 	Dlc2_m02_status.personas = { } 
  1186. 	 
  1187. 	action_nodes_shouldnt_flee( false ) 
  1188. 	 
  1189. 	if Dlc2_m02_status.mission_success == true then 
  1190. 		teleport( LOCAL_PLAYER, Dlc2_m02_navpoints.local_mission_end ) 
  1191. 		 
  1192. 		if coop_is_active() == true then 
  1193. 			teleport( REMOTE_PLAYER, Dlc2_m02_navpoints.remote_mission_end ) 
  1194. 		end 
  1195. 	end 
  1196. 	 
  1197. 	for i, d in  pairs( Dlc2_m02_clapboards ) do 
  1198. 		if d.effect_handle ~= nil then 
  1199. 			effect_stop( d.effect_handle ) 
  1200. 		end 
  1201. 	end 
  1202. 	 
  1203. 	-- Clear the global persona override 
  1204. 	persona_clear_global_situation_override()	 
  1205. 	 
  1206. 	-- Enable the addition of crib weapons 
  1207. 	crib_weapon_add_enable() 
  1208. end 
  1209.  
  1210. function dlc2_m02_cleanup_group_members( groups ) 
  1211. 	for i, grp in pairs( groups ) do 
  1212. 		local members = dlc2_m02_group_get_members( grp.name ) 
  1213. 		 
  1214. 		for j, member in pairs( members ) do 
  1215. 			if character_exists( member ) == true then 
  1216. 				clear_callbacks_for_obj( member ) 
  1217. 			end 
  1218. 		end 
  1219. 	end 
  1220. end 
  1221.  
  1222. -- Called when the mission has ended with success 
  1223. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  1224. -- 
  1225. function dlc2_m02_success() 
  1226. end 
  1227.  
  1228. -- ************************* 
  1229. -- 
  1230. -- Local functions 
  1231. -- 
  1232. -- ************************* 
  1233.  
  1234. -- Initialize the mission for the specified checkpoint 
  1235. -- 
  1236. -- checkpoint:		Checkpoint to initialize the mission to 
  1237. -- 
  1238. function dlc2_m02_initialize_checkpoint(checkpoint) 
  1239. 	local cp_data = Dlc2_m02_checkpoint_data[ checkpoint ] 
  1240. 	local homie = Dlc2_m02_characters.alien_homie 
  1241. 	 
  1242. 	dlc2_m02_helper_achievement_read_checkpoint( Dlc2_m02_achievements ) 
  1243. 	 
  1244. 	if checkpoint ~= MISSION_START_CHECKPOINT then 
  1245. 		teleport_coop( cp_data.local_start_nav, cp_data.remote_start_nav, true  ) 
  1246. 	end 
  1247.  
  1248. 	-- move homie into position 
  1249. 	teleport( Dlc2_m02_characters.alien_homie, cp_data.homie_start_nav ) 
  1250. 	 
  1251. 	-- backstage adjustments 
  1252. 	local backstage_data = cp_data.backstage_data 
  1253. 	 
  1254. 	if backstage_data ~= nil then 
  1255. 		if backstage_data.player_loadout ~= nil then 
  1256. 			dlc2_m02_switch_loadout( backstage_data.player_loadout ) 
  1257. 		end 
  1258.  
  1259. 		if backstage_data.homie_loadout ~= nil then 
  1260. 			inv_item_remove_all( homie ) 
  1261. 			inv_item_add( backstage_data.homie_loadout, 1, homie, true ) 
  1262. 		end 
  1263. 		 
  1264. 		if backstage_data.homie_personality ~= nil then 
  1265. 			ai_set_personality( homie, backstage_data.homie_personality ) 
  1266. 		end 
  1267. 	end 
  1268. 	 
  1269. 	if checkpoint == Dlc2_m02_checkpoints[ 2 ] then 
  1270. 		audio_object_post_event( "M02_Music_Checkpoint_1", nil, nil, LOCAL_PLAYER ) 
  1271. 	elseif checkpoint == Dlc2_m02_checkpoints[ 4 ] then 
  1272. 		audio_object_post_event( "M02_Music_Checkpoint_3", nil, nil, LOCAL_PLAYER ) 
  1273. 	end 
  1274. end 
  1275.  
  1276. -- *************************************************** 
  1277. -- dlc2_m02_run Helper Functions 
  1278. -- *************************************************** 
  1279.  
  1280. function dlc2_m02_handle_machine( machine_data ) 
  1281. 	local nav = machine_data.navpoint 
  1282. 	local homie = Dlc2_m02_characters.alien_homie 
  1283. 	 
  1284. 	if machine_data.gspawn_data ~= nil then 
  1285. 		dlc2_m02_create_groups( machine_data.gspawn_data ) 
  1286. 	end 
  1287. 	 
  1288. 	-- objective, local: approach machine 
  1289. 	local msg 
  1290. 	if machine_data.alt_approach_msg == nil then 
  1291. 		msg = Dlc2_m02_text.approach_machine_local 
  1292. 	else 
  1293. 		msg = machine_data.alt_approach_msg 
  1294. 	end 
  1295. 	 
  1296. 	objective_text( 0, msg, nil, nil, SYNC_LOCAL, OI_ASSET_LOCATION ) 
  1297. 	objective_text( 1, msg, nil, nil, SYNC_REMOTE, OI_ASSET_LOCATION ) 
  1298. 	 
  1299. 	if machine_data.trail ~= nil then 
  1300. 		dlc2_m02_trail_start( machine_data.trail ) 
  1301. 	else 
  1302. 		-- mark machine 
  1303. 		marker_add( nav, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL, SYNC_ALL ) 
  1304. 	end 
  1305. 	 
  1306. 	-- set up any triggered doors 
  1307. 	if machine_data.trigger_doors ~= nil then 
  1308. 		for i, door_data in pairs( machine_data.trigger_doors ) do 
  1309. 			dlc2_m02_setup_door_trigger( door_data ) 
  1310. 		end 
  1311. 	end 
  1312. 	 
  1313. 	-- wait for approach 
  1314. 	if machine_data.approach_trigger ~= nil then 
  1315. 		local coop_msg_displayed = coop_is_active() == false 
  1316. 		while object_is_in_trigger( machine_data.approach_trigger, LOCAL_PLAYER ) == false do 
  1317. 			if coop_msg_displayed == false and object_is_in_trigger( machine_data.approach_trigger, REMOTE_PLAYER ) == true then 
  1318. 				objective_text( 1, Dlc2_m02_text.wait_for_homie, nil, nil, SYNC_REMOTE, OI_ASSET_LOCATION ) 
  1319. 				coop_msg_displayed = true 
  1320. 			end 
  1321. 			thread_yield() 
  1322. 		end 
  1323. 	else 
  1324. 		while get_dist( LOCAL_PLAYER, nav ) > 15 do 
  1325. 			thread_yield() 
  1326. 		end 
  1327. 	end 
  1328. 	 
  1329. 	objective_text_clear( 0 ) 
  1330. 	objective_text_clear( 1 ) 
  1331. 	 
  1332. 	dlc2_m02_trail_stop() 
  1333. 	 
  1334. 	-- port homie to known good spot if she is too far 
  1335. 	local homie_port_nav = machine_data.homie_port 
  1336. 	if homie_port_nav ~= nil and get_dist( LOCAL_PLAYER, homie_port_nav ) < get_dist( LOCAL_PLAYER, homie ) then 
  1337. 		teleport( homie, homie_port_nav ) 
  1338. 	end 
  1339. 	 
  1340. 	-- approach convo 
  1341. 	if machine_data.convo_approach ~= nil then 
  1342. 		dlc2_m02_convo_play( machine_data.convo_approach, false, true ) 
  1343. 	end 
  1344.  
  1345. 	if machine_data.homie_activates == true then 
  1346. 		dlc2_m02_homie_disable_machine( machine_data ) 
  1347. 	elseif machine_data.player_activates == true then 
  1348. 		dlc2_m02_player_disable_machine( machine_data ) 
  1349. 	elseif machine_data.homie_destroys == true then 
  1350. 		dlc2_m02_homie_destroy_machine( machine_data ) 
  1351. 	elseif machine_data.both_disable == true then 
  1352. 		dlc2_m02_both_disable_machine( machine_data ) 
  1353. 	else  -- assume player_destroys == true 
  1354. 		dlc2_m02_player_destroy_machine( machine_data ) 
  1355. 	end 
  1356.  
  1357. 	if machine_data.convo_finish ~= nil then 
  1358. 		dlc2_m02_convo_play( machine_data.convo_finish, false, true ) 
  1359. 	end 
  1360.  
  1361. 	if machine_data.explosion_type ~= nil then 
  1362. 		audio_object_post_event( "M02_Self_Destruct", nil, nil, LOCAL_PLAYER ) 
  1363.  
  1364. 		if machine_data.countdown_audio_event ~= nil then 
  1365. 			audio_object_post_event( machine_data.countdown_audio_event, nil, nil, LOCAL_PLAYER ) 
  1366. 		end 
  1367.  
  1368. 		-- mark the unsafe area 
  1369. 		minimap_icon_add_radius( nav, 15, SYNC_ALL ) 
  1370. 		 
  1371. 		if machine_data.explosions ~= nil then 
  1372. 			for i, n in pairs( machine_data.explosions ) do 
  1373. 				minimap_icon_add_radius( n, 15, SYNC_ALL ) 
  1374. 			end 
  1375. 		end 
  1376. 		 
  1377. 		-- countdown to explosion 
  1378. 		Dlc2_m02_status.explosion_timer_complete = false 
  1379. 		hud_critical_timer_set( 10 * 1000, Dlc2_m02_text.explosion_warning, "dlc2_m02_machine_exploding_countdown", SYNC_ALL ) 
  1380.  
  1381. 		local homie_being_safe = false 
  1382. 		 
  1383. 		while true do 
  1384. 			local should_be_safe = Dlc2_m02_status.explosion_timer_complete == false and get_dist( nav, LOCAL_PLAYER ) < 10 
  1385. 			 
  1386. 			if homie_being_safe ~= should_be_safe then 
  1387. 				if should_be_safe then 
  1388. 						follower_make_independent( homie, true ) 
  1389. 						npc_leash_to_nav( homie, machine_data.safe_nav, 5 ) 
  1390. 				else 
  1391. 						follower_make_independent( homie, false ) 
  1392. 						npc_leash_remove( homie ) 
  1393. 				end 
  1394. 				 
  1395. 				homie_being_safe = should_be_safe 
  1396. 			end 
  1397. 			 
  1398. 			if Dlc2_m02_status.explosion_timer_complete then 
  1399. 				break 
  1400. 			end 
  1401.  
  1402. 			thread_yield() 
  1403. 		end 
  1404. 		 
  1405. 		hud_critical_timer_stop() 
  1406.  
  1407. 		-- explode with camera shake 
  1408. 		mesh_mover_set_invulnerable( machine_data.machine_mover, false ) 
  1409. 		mesh_mover_kill( machine_data.machine_mover ) 
  1410.  
  1411. 		minimap_icon_remove_radius( nav ) 
  1412. 		camera_shake_play( "m24_marsquake", 6 ) 
  1413. 		explosion_create( "alien_mindcontrol", nav, LOCAL_PLAYER, nil, "vfx_mindcontrol_exp" ) 
  1414. 		 
  1415. 		if machine_data.explosions ~= nil then 
  1416. 			for i, n in pairs( machine_data.explosions ) do 
  1417. 				delay( 1 ) 
  1418. 				minimap_icon_remove_radius( n ) 
  1419. 				for j, mov in pairs( machine_data.explosions_mov[ i ] ) do 
  1420. 					mesh_mover_set_invulnerable( mov, false ) 
  1421. 					mesh_mover_kill( mov ) 
  1422. 					camera_shake_play( "m24_marsquake", 6 ) 
  1423. 				end 
  1424. 			end 
  1425. 		end 
  1426. 	end 
  1427. 	 
  1428. 	if machine_data.convo_complete ~= nil then 
  1429. 		dlc2_m02_convo_play( machine_data.convo_complete, false, true ) 
  1430. 	end 
  1431. 	 
  1432. 	-- clear objective 
  1433. 	objective_text_clear( 0 ) 
  1434. end 
  1435.  
  1436. function dlc2_m02_go_to_saucer() 
  1437. 	-- objective 
  1438. 	objective_text( 0, Dlc2_m02_text.approach_saucer, nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  1439. 	dlc2_m02_create_groups( Dlc2_m02_gspawn_data.hanger_2 ) 
  1440.  
  1441. 	-- approach saucer 
  1442. 	Dlc2_m02_status.saucer_approached = false 
  1443. 	trigger_enable( Dlc2_m02_triggers.saucer, true ) 
  1444. 	on_trigger( "dlc2_m02_saucer_approach", Dlc2_m02_triggers.saucer ) 
  1445. 	 
  1446. 	dlc2_m02_trail_start( Dlc2_m02_trails.hanger1 ) 
  1447. 	 
  1448. 	while Dlc2_m02_status.saucer_approached == false do 
  1449. 		thread_yield() 
  1450. 	end 
  1451. 	 
  1452. 	dlc2_m02_trail_stop() 
  1453. 	 
  1454. 	mesh_mover_reset( "mov_forcefield" ) 
  1455. 	mesh_mover_show( "mov_forcefield" ) 
  1456. 	on_trigger( "", Dlc2_m02_triggers.saucer ) 
  1457. 	trigger_enable( Dlc2_m02_triggers.saucer, false ) 
  1458. 	 
  1459. 	dlc2_m02_convo_play( Dlc2_m02_convos.force_field_start, false, true )	 
  1460. 	 
  1461. 	-- clear objective 
  1462. 	objective_text_clear( 0 ) 
  1463. end 
  1464.  
  1465. function dlc2_m02_escape_in_saucer() 
  1466. 	local homie = Dlc2_m02_characters.alien_homie 
  1467. 	-- objective: get to saucer 
  1468. 	objective_text( 0, Dlc2_m02_text.approach_saucer, nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  1469. 	 
  1470. 	-- approach saucer 
  1471. 	Dlc2_m02_status.saucer_approached = false 
  1472. 	marker_add( Dlc2_m02_vehicles.saucer, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL, SYNC_ALL ) 
  1473. 	trigger_enable( Dlc2_m02_triggers.saucer, true ) 
  1474. 	on_trigger( "dlc2_m02_saucer_approach", Dlc2_m02_triggers.saucer ) 
  1475. 	 
  1476. 	while Dlc2_m02_status.saucer_approached == false do 
  1477. 		thread_yield() 
  1478. 	end 
  1479. 	 
  1480. 	on_trigger( "", Dlc2_m02_triggers.saucer ) 
  1481. 	marker_remove( Dlc2_m02_vehicles.saucer ) 
  1482. 	trigger_enable( Dlc2_m02_triggers.saucer, false ) 
  1483. 	 
  1484. 	-- objective: get in saucer 
  1485. 	objective_text( 0, Dlc2_m02_text.board_saucer, nil, nil, SYNC_ALL, OI_ASSET_USE ) 
  1486. 	marker_add( Dlc2_m02_vehicles.saucer, MINIMAP_ICON_USE, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL ) 
  1487. 	 
  1488. 	follower_make_independent( Dlc2_m02_characters.alien_homie, true ) 
  1489. 	vehicle_enter( homie, Dlc2_m02_vehicles.saucer, 0, true ) 
  1490. 	 
  1491. 	-- wait for players to get in saucer 
  1492. 	while true do 
  1493. 		if character_is_in_vehicle( homie, Dlc2_m02_vehicles.saucer ) then 
  1494. 			turn_invulnerable( homie ) 
  1495.  
  1496. 			if character_is_in_vehicle( LOCAL_PLAYER, Dlc2_m02_vehicles.saucer ) then 
  1497. 				if coop_is_active() then 
  1498. 					if character_is_in_vehicle( REMOTE_PLAYER, Dlc2_m02_vehicles.saucer ) then 
  1499. 						break 
  1500. 					end 
  1501. 				else 
  1502. 					break 
  1503. 				end 
  1504. 			end 
  1505. 		end 
  1506. 		 
  1507. 		thread_yield() 
  1508. 	end 
  1509. 	 
  1510. 	-- clear objective 
  1511. 	objective_text_clear( 0 ) 
  1512. 	marker_remove( Dlc2_m02_vehicles.saucer ) 
  1513.  
  1514. 	player_controls_disable( LOCAL_PLAYER ) 
  1515. 	 
  1516. 	if coop_is_active() == true then 
  1517. 		player_controls_disable( REMOTE_PLAYER ) 
  1518. 	end 
  1519. 	 
  1520. 	camera_look_through( Dlc2_m02_navpoints.hanger_camera, 2 ) 
  1521. 	 
  1522. 	Dlc2_m02_threads.saucer_away = thread_new( "dlc2_m02_saucer_away" ) 
  1523. 	 
  1524. 	delay( 5 ) 
  1525. 	 
  1526. 	audio_object_post_event( "M02_Part3_Music_Stop", nil, nil, LOCAL_PLAYER ) 
  1527. 	dlc2_m02_convo_play( Dlc2_m02_convos.mission_end, true, true )	 
  1528.  
  1529. 	delay( 3 ) 
  1530. end 
  1531.  
  1532. function dlc2_m02_saucer_away() 
  1533. 	helicopter_fly_to_direct( Dlc2_m02_vehicles.saucer, 2, "sp_saucer_away" ) 
  1534. end 
  1535.  
  1536. -- *************************************************** 
  1537. -- dlc2_m02_initialize_checkpoint Helper Functions 
  1538. -- *************************************************** 
  1539.  
  1540. -- Handle any common initialization 
  1541. -- 
  1542. function dlc2_m02_initialize_common() 
  1543. 	set_mission_author( "Sean Rose" ) 
  1544. 	 
  1545. 	notoriety_set_min_and_max( "police", 0, 0 ) 
  1546. 	notoriety_set_min_and_max( "stag", 0, 0 ) 
  1547. 	notoriety_set_min_and_max( "luchadores", 0, 0 ) 
  1548. 	notoriety_set_min_and_max( "deckers", 0, 0 ) 
  1549. 	notoriety_set_min_and_max( "morningstar", 0, 0 ) 
  1550. 	 
  1551. 	notoriety_force_no_spawn( "police", true ) 
  1552. 	notoriety_force_no_spawn( "stag", true ) 
  1553. 	notoriety_force_no_spawn( "luchadores", true ) 
  1554. 	notoriety_force_no_spawn( "deckers", true ) 
  1555. 	notoriety_force_no_spawn( "morningstar", true ) 
  1556. 	 
  1557. 	customization_outfit_wear("Lets Pretend Male A") 
  1558. 	radio_global_block( true ) 
  1559. 	action_nodes_shouldnt_flee( true ) 
  1560.  
  1561. 	mission_set_cancel_warp_location( Dlc2_m02_navpoints.local_mission_end, Dlc2_m02_navpoints.remote_mission_end ) 
  1562. 	spawning_vehicles( false ) 
  1563. 	spawning_pedestrians( false ) 
  1564.  
  1565. 	-- disable weapons, they get enabled based on the mission stage 
  1566. 	inv_weapon_disable_all_but_this_slot( WEAPON_SLOT_UNARMED ) 
  1567. 	 
  1568. 	-- create machines 
  1569. 	group_create( Dlc2_m02_groups.machines.name ) 
  1570. 	 
  1571. 	-- spawn homie 
  1572. 	group_create( Dlc2_m02_groups.homies.name ) 
  1573. 	party_add_ignore_limits( Dlc2_m02_groups.homies.npcs[ 1 ], LOCAL_PLAYER ) 
  1574. 	on_death( "dlc2_m02_on_death_alien_homie_fail", Dlc2_m02_groups.homies.npcs[ 1 ] ) 
  1575. 	 
  1576. 	Dlc2_m02_status.personas = {} 
  1577. 	Dlc2_m02_status.personas[ "PAK2_Kwilanna" ] = audio_persona_load_2d( "PAK2_Kwilanna" ) 
  1578. 	Dlc2_m02_status.personas[ "PAK2_Director" ] = audio_persona_load_2d( "PAK2_Director" ) 
  1579.  
  1580. 	-- set up activation triggers 
  1581. 	on_trigger( "dlc2_m02_wake_up_npcs", Dlc2_m02_triggers.activate_hall_1 ) 
  1582. 	trigger_enable( Dlc2_m02_triggers.activate_hall_1 ) 
  1583. 	on_trigger( "dlc2_m02_wake_up_npcs", Dlc2_m02_triggers.activate_hall_2 ) 
  1584. 	trigger_enable( Dlc2_m02_triggers.activate_hall_2 ) 
  1585. 	on_trigger( "dlc2_m02_wake_up_npcs", Dlc2_m02_triggers.activate_hall_3 ) 
  1586. 	trigger_enable( Dlc2_m02_triggers.activate_hall_3 ) 
  1587. 	on_trigger( "dlc2_m02_wake_up_npcs", Dlc2_m02_triggers.activate_room_2 ) 
  1588. 	trigger_enable( Dlc2_m02_triggers.activate_room_2 ) 
  1589. 	 
  1590. 	player_grenades_disable() 
  1591. 	 
  1592. 	dlc2_m02_enable_traps( true ) 
  1593. 	 
  1594. 	-- Setup a global persona situation override to disable some of Kwilanna's ambient persona lines 
  1595. 	persona_set_global_situation_override(9) 
  1596. end 
  1597.  
  1598. -- *************************************************** 
  1599. -- Miscellaneous m24 Helper Funcrtions 
  1600. -- *************************************************** 
  1601.  
  1602. -- Cleans up a table of trigger regions by reseting their on_trigger callback and disabling them 
  1603. -- 
  1604. -- trigger_group:		(string) table of trigger names 
  1605. function dlc2_m02_cleanup_triggers( trigger_group ) 
  1606. 	for i, trigger in pairs( trigger_group ) do 
  1607. 		if type( trigger ) == "table" then 
  1608. 			dlc2_m02_cleanup_triggers( trigger ) 
  1609. 		elseif trigger ~= "" then 
  1610. 			on_trigger( "", trigger ) 
  1611. 			on_trigger_exit( "", trigger ) 
  1612. 			trigger_enable( trigger, false ) 
  1613. 		end 
  1614. 	end 
  1615. end 
  1616.  
  1617. -- Cleans up a table of thread handles by killing them and resetting their thread handle 
  1618. -- 
  1619. -- thread_group:		(string) table of thread names 
  1620. function dlc2_m02_cleanup_threads( thread_group ) 
  1621. 	for i, thread in pairs( thread_group ) do 
  1622. 		if type( thread ) == "table" then 
  1623. 			dlc2_m02_cleanup_threads( thread ) 
  1624. 		else		 
  1625. 			if thread ~= INVALID_THREAD_HANDLE then 
  1626. 				thread_kill(thread) 
  1627. 				thread = INVALID_THREAD_HANDLE 
  1628. 			end 
  1629. 		end 
  1630. 	end 
  1631. end 
  1632.  
  1633. -- Cleans up a table of mover names by resetting their on_mover_destroyed callback and removing any HUD markers 
  1634. -- 
  1635. -- mover_group:		(string) table of mover names 
  1636. function dlc2_m02_cleanup_movers( mover_group ) 
  1637. 	for i, mover in pairs( mover_group ) do 
  1638. 		if type( mover ) == "table" then 
  1639. 			dlc2_m02_cleanup_movers( mover ) 
  1640. 		else		 
  1641. 			on_mover_destroyed( "", mover ) 
  1642. 			marker_remove( mover ) 
  1643. 		end 
  1644. 	end 
  1645. end 
  1646.  
  1647. -- Cleans up any active continuous spawn groups 
  1648. -- 
  1649. -- cs_group:	(string) table of spawn groups 
  1650. function dlc2_m02_cleanup_continuous_spawn_groups( cs_group ) 
  1651. 	for i, spawn_group in pairs( cs_group ) do 
  1652. 		if type( spawn_group ) == "table" then 
  1653. 			dlc2_m02_cleanup_continuous_spawn_groups( spawn_group ) 
  1654. 		else		 
  1655. 			continuous_spawn_stop( spawn_group, true ) 
  1656. 		end 
  1657. 	end 
  1658. end 
  1659.  
  1660. -- Disables any active spawn regions 
  1661. -- 
  1662. -- cs_region:	(string) table of spawn regions 
  1663. function dlc2_m02_cleanup_continuous_spawn_regions( cs_region ) 
  1664. 	for i, region in pairs( cs_region ) do 
  1665. 		if region.name == nil then 
  1666. 			dlc2_m02_cleanup_continuous_spawn_regions( region ) 
  1667. 		else 
  1668. 			spawn_region_enable( region.name, false ) 
  1669. 		end 
  1670. 	end 
  1671. end 
  1672.  
  1673. -- ************************* 
  1674. -- 
  1675. -- Conversations 
  1676. -- 
  1677. -- ************************* 
  1678.  
  1679. -- Play an audio conversation 
  1680. -- 
  1681. -- convo:	(table) the conversation to play - contains a name, handle, and table of non-player speakers 
  1682. -- wait:		(bool) don't return until convo has played 
  1683. -- clear:		(bool) clear any pending convos 
  1684. -- 
  1685. function dlc2_m02_convo_play( convo, wait, clear ) 
  1686. 	if convo == nil or type( convo ) ~= "table" then 
  1687. 		return 
  1688. 	end 
  1689. 	 
  1690. 	if convo.persona_3d_params == nil and convo.persona_2d_params == nil and convo.convo_name == nil then 
  1691. 		for i, c in pairs( convo ) do 
  1692. 			if i == 1 then 
  1693. 				dlc2_m02_convo_play( c, false, clear ) 
  1694. 			else 
  1695. 				dlc2_m02_convo_play( c, false, false ) 
  1696. 			end 
  1697. 		end 
  1698. 		 
  1699. 		if wait == true then 
  1700. 			while dlc2_m02_convo_is_playing( convo[ #convo ] ) == true do 
  1701. 				thread_yield() 
  1702. 			end 
  1703. 		end 
  1704. 		 
  1705. 		return 
  1706. 	end 
  1707. 	 
  1708. 	if clear == true then 
  1709. 		dlc2_m02_cleanup_convos( Dlc2_m02_convos ) 
  1710. 	end 
  1711.  
  1712. 	-- add to end of queue 
  1713. 	Dlc2_m02_convo_queue[ #Dlc2_m02_convo_queue + 1 ] = convo 
  1714.  
  1715. 	-- start a manager thread if needed 
  1716. 	if Dlc2_m02_threads.convo_manager == nil then 
  1717. 		Dlc2_m02_threads.convo_manager = thread_new( "dlc2_m02_convo_manager" ) 
  1718. 	end 
  1719.  
  1720. 	-- wait for convo to finish playing if requested 
  1721. 	if wait == true  then 
  1722. 		while dlc2_m02_convo_is_playing( convo ) == true do 
  1723. 			thread_yield() 
  1724. 		end 
  1725. 	end 
  1726. end 
  1727.  
  1728. function dlc2_m02_convo_is_playing( convo ) 
  1729. 	if convo == nil then 
  1730. 		return sizeof_table( Dlc2_m02_convo_queue ) > 0 
  1731. 	end 
  1732.  
  1733. 	for i, c in pairs( Dlc2_m02_convo_queue ) do 
  1734. 		if c == convo then 
  1735. 			return true 
  1736. 		end 
  1737. 	end 
  1738. 	 
  1739. 	return false 
  1740. end 
  1741.  
  1742. function dlc2_m02_convo_manager() 
  1743. 	local convo 
  1744.  
  1745. 	while #Dlc2_m02_convo_queue > 0 do 
  1746. 		convo = Dlc2_m02_convo_queue[ 1 ] 
  1747. 		convo.persona_handles = { } 
  1748.  
  1749. 		-- Load 2D personas when necessary 
  1750. 		if convo.speakers_2d ~= nil then 
  1751. 			for i, persona in pairs( convo.speakers_2d ) do 
  1752. 				if Dlc2_m02_status.personas[ persona ] ~= nil then 
  1753. 					convo.persona_handles[ i ] = Dlc2_m02_status.personas[ persona ] 
  1754. 				else 
  1755. 					convo.persona_handles[ i ] = audio_persona_load_2d( persona ) 
  1756. 				end 
  1757. 			end 
  1758. 		end 
  1759.  
  1760. 		-- Load the conversation 
  1761. 		if convo.persona_3d_params ~= nil then 
  1762. 			audio_play_persona_line( unpack( convo.persona_3d_params ) ) 
  1763. 			 
  1764. 			debug_print( "MAD", "playing 3d line " .. convo.persona_3d_params[ 2 ] .. "\n" ) 
  1765. 			 
  1766. 			while audio_persona_line_playing( convo.persona_3d_params[ 1 ] ) == true do 
  1767. 				thread_yield() 
  1768. 			end 
  1769. 		elseif convo.persona_2d_params ~= nil then 
  1770. 			-- a speakers_2d must have been specified 
  1771. 			if true or convo.persona_handles[ 1 ] ~= nil then 
  1772. 				convo.audio_id = audio_play_persona_line_2d( convo.persona_handles[ 1 ], convo.persona_2d_params[ 1 ] ) 
  1773. 				 
  1774. 				debug_print( "MAD", "playing 2d line " .. convo.persona_2d_params[ 1 ] .. "\n" ) 
  1775.  
  1776. 				while audio_is_playing( convo.audio_id ) == true do 
  1777. 					thread_yield() 
  1778. 				end 
  1779. 				 
  1780. 				convo.audio_id = nil 
  1781. 			end 
  1782. 		elseif convo.cell_name ~= nil then 
  1783. 			dlc2_m02_cellphone_call_wait( convo.cell_name, convo.recieving, convo.persona_handles[ 1 ] ) 
  1784. 		elseif convo.convo_name ~= nil then 
  1785. 			-- load convo 
  1786. 			if convo.coop_player ~= nil then 
  1787. 				convo.convo_handle = audio_conversation_load_player( convo.convo_name, convo.coop_player ) 
  1788. 			elseif convo.player_speaks then 
  1789. 				convo.convo_handle = audio_conversation_load( convo.convo_name ) 
  1790. 			else 
  1791. 				convo.convo_handle = audio_conversation_load_direct( convo.convo_name ) 
  1792. 			end 
  1793.  
  1794. 			-- play the conversation 
  1795. 			debug_print( "MAD", "Playing convo: " .. convo.convo_name .. "\n" ) 
  1796. 			audio_conversation_play( convo.convo_handle ) 
  1797. 			thread_yield() 
  1798.  
  1799. 			-- wait for the conversation to end 
  1800. 			audio_conversation_wait_for_end( convo.convo_handle ) 
  1801. 			convo.convo_handle = nil 
  1802. 		end 
  1803.  
  1804. 		-- clean up personas 
  1805. 		for i, handle in pairs( convo.persona_handles ) do 
  1806. 			if Dlc2_m02_status.personas[ convo.speakers_2d[ i ] ] == nil then 
  1807. 				audio_persona_remove_2d( handle ) 
  1808. 			end 
  1809. 		end 
  1810. 		convo.persona_handles = nil 
  1811.  
  1812. 		-- delay if needed 
  1813. 		if convo.delay_after ~= nil then 
  1814. 			delay( convo.delay_after ) 
  1815. 		end 
  1816.  
  1817. 		-- roll up the queue 
  1818. 		if #Dlc2_m02_convo_queue > 1 then 
  1819. 			for i = 2, #Dlc2_m02_convo_queue do 
  1820. 				Dlc2_m02_convo_queue[ i - 1 ] = Dlc2_m02_convo_queue[ i ] 
  1821. 			end 
  1822. 		end 
  1823.  
  1824. 		Dlc2_m02_convo_queue[ #Dlc2_m02_convo_queue ] = nil 
  1825. 	end 
  1826.  
  1827. 	-- if there's no convos to play just exit the thread 
  1828. 	Dlc2_m02_threads.convo_manager  = nil 
  1829. end 
  1830.  
  1831. function dlc2_m02_cleanup_convos( convos ) 
  1832. 	-- kill manager thread 
  1833. 	if Dlc2_m02_threads.convo_manager ~= nil then 
  1834. 		thread_kill( Dlc2_m02_threads.convo_manager ) 
  1835. 		Dlc2_m02_threads.convo_manager = nil 
  1836. 	end 
  1837. 	 
  1838. 	-- clear pending events 
  1839. 	Dlc2_m02_convo_queue = { } 
  1840.  
  1841. 	-- sweep all convo data and clean it up 
  1842. 	for i, convo in pairs( convos ) do 
  1843. 		dlc2_m02_cleanup_audio_item( convo ) 
  1844. 	end 
  1845. end 
  1846. 	 
  1847. function dlc2_m02_cleanup_audio_item( convo ) 
  1848. 	if convo.convo_handle ~= nil then 
  1849. 		audio_conversation_end( convo.convo_handle ) 
  1850. 		convo.convo_handle = nil 
  1851. 	end 
  1852. 	 
  1853. 	if convo.audio_id ~= nil then 
  1854. 		audio_stop( convo.audio_id ) 
  1855. 		convo.audio_id = nil 
  1856. 	end 
  1857. 	 
  1858. 	-- clean up loaded personas 
  1859. 	if convo.persona_handles ~= nil then 
  1860. 		for i, handle in pairs( convo.persona_handles ) do 
  1861. 			if Dlc2_m02_status.personas[ convo.speakers_2d[ i ] ] == nil then 
  1862. 				audio_persona_remove_2d( handle ) 
  1863. 			end 
  1864. 		end 
  1865. 		convo.persona_handles = nil 
  1866. 	end 
  1867. end 
  1868.  
  1869. function dlc2_m02_player_disable_machine( machine_data ) 
  1870. 	local nav = machine_data.navpoint 
  1871. 	local trigger = machine_data.trigger 
  1872. 	local mover = machine_data.mover 
  1873. 	local homie = Dlc2_m02_characters.alien_homie 
  1874.  
  1875. 	-- objective: disable machine 
  1876. 	marker_remove( nav ) 
  1877. 	marker_add_trigger( trigger, MINIMAP_ICON_USE, INGAME_EFFECT_LOCATION, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL ) 
  1878. 	objective_text( 0, Dlc2_m02_text.rewire_explosives, nil, nil, SYNC_ALL, OI_ASSET_USE ) 
  1879. 	 
  1880. 	-- set up trigger 
  1881. 	Dlc2_m02_status.activation_time = machine_data.activation_time 
  1882. 	Dlc2_m02_status.machine_disabled = false 
  1883. 	Dlc2_m02_status.activation_progress = 0 
  1884. 	Dlc2_m02_status.activation_nav = nav 
  1885. 	Dlc2_m02_status.trigger_audio_event = machine_data.start_disable_audio_event 
  1886. 	Dlc2_m02_status.trigger_cspawn_data = machine_data.cspawn_data 
  1887. 	trigger_enable( trigger ) 
  1888. 	trigger_set_hold_to_repeat( trigger, true ) 
  1889. 	on_trigger( "dlc2_m02_on_trigger_machine", trigger ) 
  1890.  
  1891. 	while Dlc2_m02_status.machine_disabled ~= true do 
  1892. 		thread_yield() 
  1893. 	end 
  1894.  
  1895. 	dlc2_m02_end_cspawning() 
  1896.  
  1897. 	-- remove marker from machine 
  1898. 	Dlc2_m02_status.trigger_cspawn_data = nil 
  1899. 	hud_bar_off( 1 ) 
  1900. 	marker_remove( trigger ) 
  1901. 	on_trigger( "", trigger ) 
  1902. 	objective_text_clear( 0 ) 
  1903. end 
  1904.  
  1905. -- homie moves to navpoint, plays animation for specified time 
  1906. -- if local player moves out of range then homie will cower and countdown will stop 
  1907. -- with appropriate messaging 
  1908. function dlc2_m02_homie_disable_machine( machine_data ) 
  1909. 	local nav = machine_data.navpoint 
  1910. 	local homie = Dlc2_m02_characters.alien_homie 
  1911. 	local mover = machine_data.mover 
  1912. 	 
  1913. 	if machine_data.cspawn_data ~= nil then 
  1914. 		dlc2_m02_set_up_spawn_phase( machine_data.cspawn_data ) 
  1915. 	end 
  1916. 	 
  1917. 	dlc2_m02_homie_disable( nav, machine_data.activation_time, machine_data.approach_trigger, machine_data.start_disable_audio_event, machine_data.convo_homie_ready, machine_data.proximity_check_waived ) 
  1918. 	 
  1919. 	dlc2_m02_end_cspawning() 
  1920. 	 
  1921. 	marker_remove( homie ) 
  1922. 	marker_remove( nav ) 
  1923. 	objective_text_clear( 0 ) 
  1924. end 
  1925.  
  1926. function dlc2_m02_homie_disable( nav, target_time, approach_trigger, start_disable_audio_event, start_disable_convo, proximity_check_waived ) 
  1927. 	local homie = Dlc2_m02_characters.alien_homie 
  1928.  
  1929. 	-- objective: protect homie 
  1930. 	marker_remove( nav ) 
  1931. 	marker_add( homie, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND, OI_FLAGS_FULL, SYNC_ALL ) 
  1932. 	objective_text( 0, Dlc2_m02_text.protect_homie, nil, nil, SYNC_ALL, OI_ASSET_DEFEND ) 
  1933. 	 
  1934. 	if start_disable_audio_event ~= nil then 
  1935. 		audio_object_post_event( start_disable_audio_event, nil, nil, LOCAL_PLAYER ) 
  1936. 	end 
  1937.  
  1938. 	-- set up progress bar 
  1939. 	hud_bar_on( 1, "health", Dlc2_m02_text.progress, target_time ) 
  1940. 	hud_bar_set_value(1, 0 ) 
  1941.  
  1942. 	-- move homie into place 
  1943. 	follower_make_independent( homie, true ) 
  1944. 	set_ignore_ai_flag( homie, true ) 
  1945. 	character_release_human_shield( homie ) 
  1946.  
  1947. 	-- now start timing the homie disabling the machine 
  1948. 	local accum_time = 0 
  1949. 	local disabling = false 
  1950. 	local min_dist = 20 
  1951. 	local msg_id = 0 
  1952. 	local started = false 
  1953. 	local critical_timer = false 
  1954. 	local start_disable_convo_played = false 
  1955. 	 
  1956. 	while accum_time < target_time do 
  1957. 		thread_yield() 
  1958. 		 
  1959. 		local protecting = true 
  1960. 		 
  1961. 		if object_is_in_trigger( approach_trigger, LOCAL_PLAYER ) == false then 
  1962. 			protecting = false 
  1963. 		elseif coop_is_active() == true and object_is_in_trigger( approach_trigger, REMOTE_PLAYER ) == false then 
  1964. 			protecting = false 
  1965. 		end 
  1966. 		 
  1967. 		if proximity_check_waived ~= true and critical_timer == false and started == true and protecting == false and disabling == true then 
  1968. 			minimap_icon_add_radius( nav, min_dist - 5, SYNC_ALL ) 
  1969. 			hud_critical_timer_set( 10 * 1000, Dlc2_m02_text.return_to_homie, "dlc2_m02_failed_to_protect" ) 
  1970. 			critical_timer = true 
  1971. 		elseif protecting == true and critical_timer == true then 
  1972. 			minimap_icon_remove_radius( nav ) 
  1973. 			hud_critical_timer_stop() 
  1974. 			critical_timer = false 
  1975. 		end 
  1976. 			 
  1977. 		if disabling == false then 
  1978. 			if human_is_downed( homie ) == false and character_is_ragdolled( homie ) == false then 
  1979. 				clear_animation_state( homie ) 
  1980. 				 
  1981. 				-- move into position 
  1982. 				if get_dist( homie, nav ) > 3 then 
  1983. 					ai_do_scripted_move( homie, nav, true, false ) 
  1984. 		 
  1985. 					while get_dist( homie, nav ) > 3 do 
  1986. 						thread_yield() 
  1987. 					end 
  1988. 				end 
  1989.  
  1990. 				-- animate disabling 
  1991. 				local anim_name = "m14 transmitter in" 
  1992. 				local force_play = false	 
  1993. 				local percentage = 1.0 
  1994. 				local stand_still = true 
  1995. 				local zero_movement = true 
  1996. 				set_animation_set( homie, "PLYM" ) 
  1997. 				set_animation_state( homie, "m14 transmitter idle", nav ) 
  1998. 				action_play( homie, anim_name, anim_name, force_play, percentage, stand_still, zero_movement, nav ) 
  1999. 				 
  2000. 				if start_disable_convo ~= nil and start_disable_convo_played == false then 
  2001. 					dlc2_m02_convo_play( start_disable_convo, false, true ) 
  2002. 				end 
  2003. 				 
  2004. 				disabling = true 
  2005. 				started = true 
  2006. 			end 
  2007. 		elseif human_is_downed( homie ) == true or get_dist( homie, nav ) > 1 then 
  2008. 			clear_animation_state( homie ) 
  2009. 			set_animation_set( homie, "COP" ) 
  2010. 			disabling = false 
  2011. 		end 
  2012.  
  2013. 		-- if we are not cowering then increment the timer 
  2014. 		if disabling == true and human_is_downed( homie ) == false then 
  2015. 			accum_time = accum_time + get_frame_time() 
  2016. 			hud_bar_set_value(1, accum_time ) 
  2017. 		end 
  2018. 	end 
  2019. 	 
  2020. 	marker_remove( homie ) 
  2021. 	set_ignore_ai_flag( homie, false ) 
  2022. 	set_animation_set( homie, "COP" ) 
  2023. 	clear_animation_state( homie ) 
  2024. 	 
  2025. 	if critical_timer == true then 
  2026. 		hud_critical_timer_stop() 
  2027. 	end 
  2028.  
  2029. 	-- clear the progress bar 
  2030. 	minimap_icon_remove_radius( nav ) 
  2031. 	hud_bar_off( 1 ) 
  2032. 	follower_make_independent( homie, false ) 
  2033. end 
  2034.  
  2035. function dlc2_m02_player_destroy_machine( machine_data ) 
  2036. 	local nav = machine_data.navpoint 
  2037. 	local mover = machine_data.mover 
  2038. 	local homie = Dlc2_m02_characters.alien_homie 
  2039. 	 
  2040. 	-- objective: destroy device 
  2041. 	marker_remove( nav ) 
  2042. 	marker_add( nav, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_FULL, SYNC_ALL ) 
  2043. 	 
  2044. 	local msg 
  2045. 	if machine_data.alt_destroy_msg == nil then 
  2046. 		msg = Dlc2_m02_text.player_destroy_machine 
  2047. 	else 
  2048. 		msg = machine_data.alt_destroy_msg 
  2049. 	end 
  2050. 	 
  2051. 	objective_text( 0, msg, nil, nil, SYNC_ALL, OI_ASSET_KILL ) 
  2052. 	 
  2053. 	turn_vulnerable( mover ) 
  2054.  
  2055. 	-- set up progress bar 
  2056. 	local prev_hit_points = get_current_hit_points( mover ) 
  2057. 	local max_hit_points = get_max_hit_points( mover ) 
  2058. 	local current_hit_points = prev_hit_points 
  2059.  
  2060. 	hud_bar_on( 1, "health", Dlc2_m02_text.progress, max_hit_points ) 
  2061. 	hud_bar_set_value( 1, 0 ) 
  2062. 	 
  2063. 	repeat 
  2064. 		thread_yield() 
  2065. 		current_hit_points = get_current_hit_points( mover ) 
  2066. 		if prev_hit_points ~= current_hit_points then 
  2067. 			hud_bar_set_value( 1, max_hit_points - current_hit_points ) 
  2068. 		end 
  2069. 	until current_hit_points <= 0 
  2070.  
  2071. 	-- clear the progress bar 
  2072. 	hud_bar_off( 1 ) 
  2073. 	 
  2074. 	marker_remove( nav ) 
  2075. 	 
  2076. 	objective_text_clear( 0 ) 
  2077. end 
  2078.  
  2079. function dlc2_m02_homie_destroy_machine( machine_data ) 
  2080. 	local nav = machine_data.navpoint 
  2081. 	local mover = machine_data.mover 
  2082. 	local homie = Dlc2_m02_characters.alien_homie 
  2083. 	 
  2084. 	-- objective: destroy device 
  2085. 	marker_remove( nav ) 
  2086. 	marker_add( homie, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND, OI_FLAGS_FULL, SYNC_ALL ) 
  2087. 	objective_text( 0, Dlc2_m02_text.protect_homie, nil, nil, SYNC_ALL, OI_ASSET_DEFEND ) 
  2088. 	 
  2089. 	-- set up progress bar 
  2090. 	local prev_hit_points = get_current_hit_points( mover ) 
  2091. 	local max_hit_points = get_max_hit_points( mover ) 
  2092. 	local current_hit_points = prev_hit_points 
  2093. 	local dmg_per_hit = max_hit_points / 10 
  2094. 	local target_hp = max_hit_points * 0.4 
  2095.  
  2096. 	hud_bar_on( 1, "health", Dlc2_m02_text.progress, max_hit_points ) 
  2097. 	hud_bar_set_value( 1, 0 ) 
  2098.  
  2099. 	-- move homie into firing position 
  2100. 	follower_make_independent( homie, true ) 
  2101. 	set_ignore_ai_flag( homie, true ) 
  2102. 	character_release_human_shield( homie ) 
  2103. 	 
  2104. 	repeat 
  2105. 		delay( rand_float( 0.5, 1.5 ) ) 
  2106. 		 
  2107. 		if get_dist( homie, machine_data.homie_fire_from ) > 1 then 
  2108. 			character_release_human_shield( homie ) 
  2109. 			ai_do_scripted_move( homie, machine_data.homie_fire_from, true, false ) 
  2110. 		elseif human_is_downed( homie ) == false then 
  2111. 			force_fire( homie, nav, true ) 
  2112. 			 
  2113. 			set_current_hit_points( mover, get_current_hit_points( mover ) - dmg_per_hit ) 
  2114. 			 
  2115. 			current_hit_points = get_current_hit_points( mover ) 
  2116. 			if prev_hit_points ~= current_hit_points then 
  2117. 				hud_bar_set_value( 1, max_hit_points - current_hit_points ) 
  2118. 			end 
  2119. 		end 
  2120. 	until current_hit_points <= target_hp 
  2121.  
  2122. 	set_ignore_ai_flag( homie, false ) 
  2123.  
  2124. 	-- clear the progress bar 
  2125. 	hud_bar_off( 1 ) 
  2126. 	 
  2127. 	marker_remove( homie ) 
  2128. 	follower_make_independent( homie, false ) 
  2129. 	 
  2130. 	objective_text_clear( 0 ) 
  2131. end 
  2132.  
  2133. function dlc2_m02_end_cspawning() 
  2134. 	-- deactivate all spawn regions 
  2135. 	if Dlc2_m02_status.active_spawn_regions ~= nil then 
  2136. 		for i, v in pairs( Dlc2_m02_status.active_spawn_regions ) do 
  2137. 			spawn_region_enable( v.name, false ) 
  2138. 		end 
  2139. 		 
  2140. 		Dlc2_m02_status.active_spawn_regions = nil 
  2141. 	end 
  2142. 	 
  2143. 	Dlc2_m02_status.cspawn_tethers = nil 
  2144. end 
  2145.  
  2146. function dlc2_m02_create_groups( group_data ) 
  2147. 	if group_data.delete_groups ~= nil then 
  2148. 		for i, v in pairs( group_data.delete_groups ) do 
  2149. 		 
  2150. 			-- set up the take dmg callback for achievements 
  2151. 			if v.amazon == true then 
  2152. 				local npcs = dlc2_m02_group_get_members( v.name ) 
  2153. 				for j, npc in pairs( npcs ) do 
  2154. 					on_take_damage( "", npc ) 
  2155. 				end 
  2156. 			end 
  2157. 			 
  2158. 			if group_is_loaded( v.name ) == true then 
  2159. 				group_destroy( v.name ) 
  2160. 			end 
  2161. 		end 
  2162.  
  2163. 		-- give the system a bit to clean up 
  2164. 		delay( 1 ) 
  2165. 	end 
  2166. 	 
  2167. 	-- create specified groups 
  2168. 	if Dlc2_m02_status.sleeping_npcs == nil then 
  2169. 		Dlc2_m02_status.sleeping_npcs = { } 
  2170. 	end 
  2171. 	 
  2172. 	if group_data.create_groups ~= nil then 
  2173. 		for i, grp in pairs( group_data.create_groups ) do 
  2174. 			if group_is_loaded( grp.name ) == false then 
  2175. 				group_create( grp.name, true ) 
  2176. 				 
  2177. 				local npcs = dlc2_m02_group_get_members( grp.name ) 
  2178. 				 
  2179. 				for j, npc in pairs( npcs ) do 
  2180. 					npc_dont_drop_weapon_on_death( npc, true ) 
  2181. 					 
  2182. 					if grp.sleep == true then 
  2183. 						set_ignore_ai_flag( npc, true ) 
  2184. 						Dlc2_m02_status.sleeping_npcs[ npc ] = true 
  2185. 					end 
  2186. 					 
  2187. 					if grp.amazon == true then 
  2188. 						on_take_damage( "dlc2_m02_amazon_damaged_cb", npc ) 
  2189. 					end 
  2190. 				end 
  2191. 			end 
  2192. 		end 
  2193. 	end 
  2194. end 
  2195.  
  2196. function dlc2_m02_wake_up_npcs( activator, trigger ) 
  2197. 	trigger_enable( trigger, false ) 
  2198. 	on_trigger( "", trigger ) 
  2199. 	 
  2200. 	if Dlc2_m02_status.sleeping_npcs == nil then 
  2201. 		return 
  2202. 	end 
  2203. 	 
  2204. 	for npc, d in pairs( Dlc2_m02_status.sleeping_npcs ) do 
  2205. 		if character_exists( npc ) == true and character_is_dead( npc )  == false then 
  2206. 			set_ignore_ai_flag( npc, false ) 
  2207. 		end 
  2208. 	end 
  2209.  
  2210. 	Dlc2_m02_status.sleeping_npcs = { } 
  2211. 	 
  2212. 	-- if anything needs spawning now, do it 
  2213. 	if Dlc2_m02_status.spawn_on_wake ~= nil then 
  2214. 		dlc2_m02_create_groups( Dlc2_m02_status.spawn_on_wake ) 
  2215. 		Dlc2_m02_status.spawn_on_wake = nil 
  2216. 	end 
  2217. end 
  2218.  
  2219. function dlc2_m02_set_up_spawn_groups( groups, count, filters, respawn_delay ) 
  2220. 	for i, group in pairs( groups ) do 
  2221. 		if i <= count then 
  2222. 			continuous_spawn_start( group, 0, respawn_delay, nil, filters[ i ], nil, nil, nil, "dlc2_m02_cspawn_group_created", "dlc2_m02_cspawn_group_released" ) 
  2223. 		else 
  2224. 			continuous_spawn_stop( group, false ) 
  2225. 		end 
  2226. 	end 
  2227. end 
  2228.  
  2229. function dlc2_m02_set_up_spawn_phase( spawn_data ) 
  2230. 	dlc2_m02_end_cspawning() 
  2231. 	 
  2232. 	Dlc2_m02_status.cspawn_tethers = spawn_data.tethers 
  2233. 	 
  2234. 	local f = spawn_data.filters 
  2235. 	if f == nil then 
  2236. 		f = { elites  = {}, pistols = {}, smgs = {} } 
  2237. 	end 
  2238. 	 
  2239. 	local respawn_delay = spawn_data.respawn_delay 
  2240. 	if respawn_delay == nil then 
  2241. 		respawn_delay = 5 
  2242. 	end 
  2243.  
  2244. 	dlc2_m02_set_up_spawn_groups( Dlc2_m02_spawn_groups.elites, spawn_data.num_elites, f.elites, respawn_delay ) 
  2245. 	dlc2_m02_set_up_spawn_groups( Dlc2_m02_spawn_groups.pistols, spawn_data.num_pistols, f.pistols, respawn_delay ) 
  2246. 	dlc2_m02_set_up_spawn_groups( Dlc2_m02_spawn_groups.smgs, spawn_data.num_smgs, f.smgs, respawn_delay ) 
  2247.  
  2248. 	-- activate new spawn regions 
  2249. 	if spawn_data.cspawn_regions ~= nil then 
  2250. 		Dlc2_m02_status.active_spawn_regions = spawn_data.cspawn_regions 
  2251.  
  2252. 		for i, v in pairs( Dlc2_m02_status.active_spawn_regions ) do 
  2253. 			spawn_region_enable( v.name, true ) 
  2254. 			 
  2255. 			if v.filter ~= nil then 
  2256. 				spawn_region_toggle_filter( v.name, v.filter ) 
  2257. 			end 
  2258. 		end 
  2259. 	end 
  2260. end 
  2261.  
  2262. function dlc2_m02_handle_backstage( backstage_data, skip_dialog ) 
  2263. 	local homie = Dlc2_m02_characters.alien_homie 
  2264. 	 
  2265. 	-- init 
  2266.  
  2267. 	-- init start trigger doors 
  2268. 	if backstage_data.trigger_doors_at_start ~= nil then 
  2269. 		for i, door_data in pairs( backstage_data.trigger_doors_at_start ) do 
  2270. 			dlc2_m02_setup_door_trigger( door_data ) 
  2271. 		end 
  2272. 	end 
  2273. 	 
  2274. 	-- open entry door 
  2275. 	if backstage_data.doors.enter ~= nil then 
  2276. 		for i, door in pairs( backstage_data.doors.enter ) do 
  2277. 			door_lock( door, false ) 
  2278. 		end 
  2279. 	end 
  2280. 	 
  2281. 	if backstage_data.create_groups ~= nil then 
  2282. 		for i, group in pairs( backstage_data.create_groups ) do 
  2283. 			if group_is_loaded( group.name ) == false then 
  2284. 				group_create( group.name ) 
  2285. 			end 
  2286. 		end 
  2287. 	end 
  2288. 	 
  2289. 	if backstage_data.no_trail ~= true then 
  2290. 		if backstage_data.trail ~= nil then 
  2291. 			dlc2_m02_trail_start( backstage_data.trail ) 
  2292. 		elseif backstage_data.enter_trigger ~= nil then 
  2293. 			marker_add_trigger( backstage_data.enter_trigger, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL ) 
  2294. 		end 
  2295. 	end 
  2296. 	 
  2297. 	-- wait for player to enter 
  2298. 	if skip_dialog ~= true and backstage_data.enter_trigger ~= nil then 
  2299. 		-- objective 
  2300. 		objective_text( 0, Dlc2_m02_text.go_to_backstage, nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  2301. 		dlc2_m02_wait_for_player_to_enter_trigger( backstage_data.enter_trigger ) 
  2302. 	end 
  2303. 	 
  2304. 	marker_remove( backstage_data.enter_trigger ) 
  2305. 	dlc2_m02_trail_stop() 
  2306. 	 
  2307. 	if backstage_data.on_enter_backstage_audio_event ~= nil then 
  2308. 		audio_object_post_event( backstage_data.on_enter_backstage_audio_event, nil, nil, LOCAL_PLAYER ) 
  2309. 	end 
  2310. 	 
  2311. 	inv_weapon_disable_all_but_this_slot( WEAPON_SLOT_UNARMED ) 
  2312. 	player_can_sprint( false ) 
  2313. 	 
  2314. 	-- actors stop attacking players 
  2315. 	for i, grp_set in pairs( Dlc2_m02_spawn_groups ) do 
  2316. 		for j, group in pairs( grp_set ) do 
  2317. 			local npcs = dlc2_m02_group_get_members( group ) 
  2318. 			 
  2319. 			for k, npc in pairs( npcs ) do 
  2320. 				if character_exists( npc ) == true and character_is_dead( npc ) == false then 
  2321. 					set_attack_player_flag( npc, false ) 
  2322. 				end 
  2323. 			end 
  2324. 		end 
  2325. 	end 
  2326. 	 
  2327. 	ai_force_team_idle( "None" ) 
  2328.    team_make_allies( "Neutral Gang", "Playas" ) 
  2329.  
  2330. 	for i, grp_set in pairs( Dlc2_m02_spawn_groups ) do 
  2331. 		for j, group in pairs( grp_set ) do 
  2332. 			local npcs = dlc2_m02_group_get_members( group ) 
  2333. 			 
  2334. 			for k, npc in pairs( npcs ) do 
  2335. 				if character_exists( npc ) == true and character_is_dead( npc ) == false then 
  2336. 					character_set_combat_ready( npc, false ) 
  2337. 					human_set_force_holster( npc, true ) 
  2338. 					-- TODO: move to action node 
  2339. 				end 
  2340. 			end 
  2341. 		end 
  2342. 	end 
  2343.  
  2344. 	-- stop film grain 
  2345. 	dlc2_m02_film_grain_unload() 
  2346. 	objective_text_clear( 0 ) 
  2347. 	delay( 3 ) 
  2348.  
  2349. 		-- dialog 
  2350. 	if skip_dialog ~= true and backstage_data.convo_enter ~= nil then 
  2351. 		dlc2_m02_convo_play( backstage_data.convo_enter , false, true ) 
  2352. 	end 
  2353. 	 
  2354. 	-- switch loadout 
  2355. 	if backstage_data.player_loadout ~= nil then 
  2356. 		dlc2_m02_loadout_sequence( backstage_data.player_loadout, backstage_data.loadout_trail ) 
  2357. 	end 
  2358.  
  2359. 	if backstage_data.homie_loadout ~= nil then 
  2360. 		inv_item_remove_all( homie ) 
  2361. 		inv_item_add( backstage_data.homie_loadout, 1, homie, true ) 
  2362. 	end 
  2363. 	 
  2364. 	if backstage_data.homie_personality ~= nil then 
  2365. 		ai_set_personality( homie, backstage_data.homie_personality ) 
  2366. 	end 
  2367.  
  2368. 	-- open exit door 
  2369. 	if backstage_data.doors.exit ~= nil then 
  2370. 		for i, door in pairs( backstage_data.doors.exit ) do 
  2371. 			door_lock( door, false ) 
  2372. --			door_open( door, true ) 
  2373. 		end 
  2374. 	end 
  2375. 	 
  2376. 	-- objective 
  2377. 	objective_text( 0, Dlc2_m02_text.go_to_set, nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  2378.  
  2379. 	if backstage_data.trigger_doors_at_end ~= nil then 
  2380. 		for i, door_data in pairs( backstage_data.trigger_doors_at_end ) do 
  2381. 			dlc2_m02_setup_door_trigger( door_data ) 
  2382. 		end 
  2383. 	end 
  2384.  
  2385. 	-- wait for player to exit 
  2386. 	if backstage_data.exit_trigger ~= nil then 
  2387. 		marker_add_trigger( backstage_data.exit_trigger, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL, SYNC_ALL ) 
  2388. 		dlc2_m02_wait_for_player_to_enter_trigger( backstage_data.exit_trigger, true ) 
  2389. 		marker_remove( backstage_data.exit_trigger ) 
  2390. 	end 
  2391. 	 
  2392. 	if backstage_data.action_line ~= nil then 
  2393. 		dlc2_m02_convo_play( backstage_data.action_line , false, true ) 
  2394. 	end 
  2395. 	 
  2396. 	if backstage_data.convo_exit ~= nil then 
  2397. 		local clear = backstage_data.action_line == nil 
  2398. 		dlc2_m02_convo_play( backstage_data.convo_exit , false, clear) 
  2399. 	end 
  2400. 	 
  2401. 	if backstage_data.on_leave_backstage_audio_event ~= nil then 
  2402. 		audio_object_post_event( backstage_data.on_leave_backstage_audio_event, nil, nil, LOCAL_PLAYER ) 
  2403. 	end 
  2404. 	 
  2405. 	-- despawn current 
  2406. 	dlc2_m02_cleanup_continuous_spawn_groups( Dlc2_m02_spawn_groups ) 
  2407. 	 
  2408.    team_make_hostile( "Neutral Gang", "Playas" ) 
  2409. 	player_can_sprint( true ) 
  2410. 	 
  2411. 	objective_text_clear( 0 ) 
  2412. 	 
  2413. 	-- new enemies will be spawned by the objective code 
  2414. end 
  2415.  
  2416. function dlc2_m02_dialog_placeholder_timer() 
  2417. 	Dlc2_m02_status.dialog_timer_elapsed = true 
  2418. 	hud_critical_timer_stop() 
  2419. end 
  2420.  
  2421. function dlc2_m02_wait_for_player_to_enter_trigger( trigger_name, coop ) 
  2422. 	trigger_enable( trigger_name, true ) 
  2423.  
  2424. 	while true do 
  2425. 		if object_is_in_trigger( trigger_name, LOCAL_PLAYER ) == true then 
  2426. 			break 
  2427. 		end 
  2428. 		 
  2429. 		if coop == true and coop_is_active() == true then 
  2430. 			if object_is_in_trigger( trigger_name, REMOTE_PLAYER ) == true then 
  2431. 				break 
  2432. 			end 
  2433. 		end 
  2434.  
  2435. 		thread_yield() 
  2436. 	end 
  2437. 	 
  2438. 	trigger_enable( trigger_name, false ) 
  2439. end 
  2440.  
  2441. -- ************************* 
  2442. -- 
  2443. -- Callback functions 
  2444. -- 
  2445. -- ************************* 
  2446.  
  2447. function dlc2_m02_on_death_alien_homie_fail() 
  2448. 	mission_end_failure( "dlc2_m02", "dlc2_m02_mission_fail_homie_died" ) 
  2449. end 
  2450.  
  2451. function dlc2_m02_on_trigger_machine( activator, trigger ) 
  2452. 	-- only one at a time please 
  2453. 	if Dlc2_m02_status.trigger_activator ~= nil and Dlc2_m02_status.trigger_activator ~= activator then 
  2454. 		return 
  2455. 	end 
  2456. 	 
  2457. 	player_movement_disable( activator ) 
  2458. 	 
  2459. 	local progress = Dlc2_m02_status.activation_progress 
  2460.  
  2461. 	if progress == 0 then 
  2462. 		hud_bar_on( 1, "health", Dlc2_m02_text.progress, Dlc2_m02_status.activation_time ) 
  2463. 	end 
  2464. 	 
  2465. 	if Dlc2_m02_status.trigger_activator == nil then 
  2466. 		Dlc2_m02_status.trigger_activator = activator 
  2467.  
  2468. 		-- wait until player is ready to play an animation 
  2469. 		while character_is_ready( activator ) == false do 
  2470. 			thread_yield() 
  2471. 		end 
  2472. 		 
  2473. 		set_animation_state( activator, "m14 transmitter idle", Dlc2_m02_status.placement_nav ) 
  2474. 		human_set_force_holster( activator, true ) 
  2475.  
  2476. 		if Dlc2_m02_status.trigger_audio_event ~= nil then 
  2477. 			audio_object_post_event( Dlc2_m02_status.trigger_audio_event, nil, nil, LOCAL_PLAYER ) 
  2478. 			Dlc2_m02_status.trigger_audio_event = nil 
  2479. 		end 
  2480.  
  2481. 		-- Play the intro animation 
  2482. 		action_play( activator, "m14 transmitter in", "m14 transmitter in", false, 0.8, true, true, Dlc2_m02_status.activation_nav ) 
  2483.  
  2484. 		if Dlc2_m02_status.trigger_cspawn_data ~= nil then 
  2485. 			dlc2_m02_set_up_spawn_phase( Dlc2_m02_status.trigger_cspawn_data ) 
  2486. 		end 
  2487. 	end 
  2488. 	 
  2489. 	if Dlc2_m02_threads.activation_monitor == nil then 
  2490. 		Dlc2_m02_threads.activation_monitor = thread_new( "dlc2_m02_maybe_cancel_activation_thread" ) 
  2491. 	end 
  2492. 	 
  2493. 	if Dlc2_m02_status.homie_disabling ~= false then 
  2494. 		progress = progress + 0.1 
  2495. 	end 
  2496.  
  2497. 	if progress >= Dlc2_m02_status.activation_time then 
  2498. 		player_movement_enable( activator ) 
  2499. 		human_set_force_holster( activator, false ) 
  2500. 		trigger_enable( trigger, false ) 
  2501.  
  2502. 		-- kill the monitor thread, not needed any more 
  2503. 		if Dlc2_m02_threads.transmitter_monitor ~= nil then 
  2504. 			thread_kill( Dlc2_m02_threads.activation_monitor ) 
  2505. 			Dlc2_m02_threads.transmitter_monitor = nil 
  2506. 		end 
  2507.  
  2508. 		-- Play the outro animation. 
  2509. 		clear_animation_state( activator ) 
  2510. 		action_play( activator, "m14 transmitter out",  "m14 transmitter out", false, 1, true, true ) 
  2511. 		Dlc2_m02_status.machine_disabled  = true 
  2512. 	else 
  2513. 		Dlc2_m02_status.activation_progress = progress 
  2514. 		hud_bar_set_value( 1, progress ) 
  2515. 	end 
  2516. end 
  2517.  
  2518. function dlc2_m02_maybe_cancel_activation_thread() 
  2519. 	local prev_progress = Dlc2_m02_status.activation_progress 
  2520. 	 
  2521. 	while true do 
  2522. 		delay( 1 ) 
  2523. 		 
  2524. 		if  Dlc2_m02_status.activation_progress <= prev_progress then 
  2525. 			-- no progress so break out and kill it 
  2526. 			break 
  2527. 		end 
  2528. 		 
  2529. 		prev_progress = Dlc2_m02_status.activation_progress 
  2530. 	end 
  2531. 	 
  2532. 	if Dlc2_m02_status.trigger_activator ~= nil then 
  2533. 		player_movement_enable( Dlc2_m02_status.trigger_activator ) 
  2534. 		 
  2535. 		-- remove the triangulator left behind by the anim 
  2536. 		character_remove_child_item_by_name( Dlc2_m02_status.trigger_activator, "Triangulator" ) 
  2537. 		 
  2538. 		-- Play the outro animation. 
  2539. 		clear_animation_state( Dlc2_m02_status.trigger_activator ) 
  2540. 		human_set_force_holster( Dlc2_m02_status.trigger_activator, false ) 
  2541. 	end 
  2542. 	 
  2543. 	if Dlc2_m02_status.trigger_cspawn_data ~= nil then 
  2544. 			dlc2_m02_end_cspawning() 
  2545. 	end 
  2546.  
  2547. 	Dlc2_m02_status.trigger_activator = nil 
  2548. 	Dlc2_m02_threads.activation_monitor = nil 
  2549. end 
  2550.  
  2551. function dlc2_m02_machine_exploding_countdown() 
  2552. 	Dlc2_m02_status.explosion_timer_complete = true 
  2553. end 
  2554.  
  2555. function dlc2_m02_saucer_approach() 
  2556. 	Dlc2_m02_status.saucer_approached = true 
  2557. end 
  2558.  
  2559. function dlc2_m02_group_get_members( group ) 
  2560. 	if type( group ) == "table" and type( group.name ) == "string" then 
  2561. 			group = group.name 
  2562. 	end 
  2563.  
  2564. 	local r = { } 
  2565. 	local npc = group_get_first_npc( group ) 
  2566. 	 
  2567. 	while npc do 
  2568. 		r[ #r + 1 ] = npc 
  2569. 		npc = group_get_next_npc( group, npc ) 
  2570. 	end 
  2571. 	 
  2572. 	return r 
  2573. end 
  2574.  
  2575. function dlc2_m02_cspawn_group_created( group ) 
  2576. 	local npcs = dlc2_m02_group_get_members( group ) 
  2577. 	 
  2578. 	for i, npc in pairs( npcs ) do 
  2579. 		npc_dont_drop_weapon_on_death( npc, true ) 
  2580. 		on_take_damage( "dlc2_m02_amazon_damaged_cb", npc ) 
  2581. 	end 
  2582. 	 
  2583. 	if Dlc2_m02_status.cspawn_tethers ~= nil then 
  2584. 		if Dlc2_m02_status.cspawn_tethers[ group ] ~= nil then 
  2585. 			local tethers = Dlc2_m02_status.cspawn_tethers[ group ] 
  2586. 			for i, npc in pairs( npcs ) do 
  2587. 				if tethers[ i ] ~= nil then 
  2588. 					ai_attack_region( npc, tethers[ i ].nav, tethers[ i ].d ) 
  2589. 					ai_do_scripted_move( npc, tethers[ i ].nav, true, false ) 
  2590. 				end 
  2591. 			end 
  2592. 		end 
  2593. 	end 
  2594. end 
  2595.  
  2596. function dlc2_m02_cspawn_group_released( group ) 
  2597. 	local npcs = dlc2_m02_group_get_members( group ) 
  2598. 	 
  2599. 	for i, npc in pairs( npcs ) do 
  2600. 		if character_exists( npc ) == true then 
  2601. 			on_take_damage( "", npc ) 
  2602. 		end 
  2603. 	end 
  2604. end 
  2605.  
  2606. function dlc2_m02_switch_loadout( loadout_data ) 
  2607. 	dlc2_m02_remove_loadout() 
  2608. 	 
  2609. 	Dlc2_m02_status.current_loadout = loadout_data 
  2610. 	 
  2611. 	for slot, weapon in pairs( loadout_data.weapons ) do 
  2612. 		inv_weapon_disable_slot( slot, false, SYNC_ALL ) 
  2613. 		inv_weapon_add_temporary( LOCAL_PLAYER, weapon, 1, true, loadout_data.equip == slot, true, true ) 
  2614. 		 
  2615. 		if coop_is_active() then 
  2616. 			inv_weapon_add_temporary( REMOTE_PLAYER, weapon, 1, true, loadout_data.equip == slot, true, true ) 
  2617. 		end 
  2618. 	end 
  2619. end 
  2620.  
  2621. -- adds temp weapons and disables other slots 
  2622. function dlc2_m02_loadout_sequence( loadout_data, trail ) 
  2623. 	trigger_enable( loadout_data.trigger, true ) 
  2624. 	objective_text( 0, loadout_data.objective_text, nil, nil, SYNC_ALL, OI_ASSET_USE ) 
  2625. 	 
  2626. 	if trail == nil then 
  2627. 		marker_add_trigger( loadout_data.trigger, MINIMAP_ICON_USE, INGAME_EFFECT_LOCATION, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL ) 
  2628. 	else 
  2629. 		dlc2_m02_trail_start( trail, "use" ) 
  2630. 	end 
  2631.  
  2632. 	dlc2_m02_wait_for_player_to_enter_trigger( loadout_data.trigger, true ) 
  2633. 	trigger_enable( loadout_data.trigger, false ) 
  2634.  
  2635. 	dlc2_m02_switch_loadout( loadout_data ) 
  2636.  
  2637. 	audio_object_post_event( "M02_Give_Player_Weapon", nil, nil, LOCAL_PLAYER ) 
  2638. 	dlc2_m02_convo_play( loadout_data.convo, false, true ) 
  2639.  
  2640. 	marker_remove( loadout_data.trigger ) 
  2641. 	dlc2_m02_trail_stop() 
  2642. end 
  2643.  
  2644. -- reverses dlc2_m02_loadout_sequence() 
  2645. function dlc2_m02_remove_loadout() 
  2646. 	if Dlc2_m02_status.current_loadout ~= nil then 
  2647. 		for slot, weapon in pairs( Dlc2_m02_status.current_loadout.weapons ) do 
  2648. 			inv_weapon_remove_temporary( LOCAL_PLAYER, weapon ) 
  2649. 			 
  2650. 			if coop_is_active() then 
  2651. 				inv_weapon_remove_temporary( REMOTE_PLAYER, weapon ) 
  2652. 			end 
  2653. 		end 
  2654. 		 
  2655. 		Dlc2_m02_status.current_loadout = nil 
  2656. 	end 
  2657. end 
  2658.  
  2659. function dlc2_m02_trigger_door_cb( char, trigger ) 
  2660. 	trigger_enable( trigger, false ) 
  2661. 	on_trigger( "", trigger ) 
  2662. 	 
  2663. 	local door_data = Dlc2_m02_status.trigger_doors[ trigger ] 
  2664. 	 
  2665. 	for i, door in pairs( door_data.doors ) do 
  2666. 		if i ~= "convo" then 
  2667. 			door_open( door ) 
  2668. 		end 
  2669. 	end 
  2670. 	 
  2671. 	if door_data.convo ~= nil then 
  2672. 		dlc2_m02_convo_play( door_data.convo, false, true ) 
  2673. 	end 
  2674. 	 
  2675. 	if door_data.gspawn_data ~= nil then 
  2676. 		dlc2_m02_create_groups( door_data.gspawn_data ) 
  2677. 	end 
  2678. 	 
  2679. 	if door_data.audio_event ~= nil then 
  2680. 		audio_object_post_event( door_data.audio_event, nil, nil, LOCAL_PLAYER ) 
  2681. 	end 
  2682. 	 
  2683. 	Dlc2_m02_status.trigger_doors[ trigger ] = nil 
  2684. end 
  2685.  
  2686. function dlc2_m02_setup_door_trigger( trigger_door ) 
  2687. 	if Dlc2_m02_status.trigger_doors == nil then 
  2688. 		Dlc2_m02_status.trigger_doors = { } 
  2689. 	end 
  2690. 	 
  2691. 	for j, door in pairs( trigger_door.doors ) do 
  2692. 		door_lock( door, false ) 
  2693. 	end 
  2694. 	 
  2695. 	Dlc2_m02_status.trigger_doors[ trigger_door.trigger ] = trigger_door 
  2696. 	 
  2697. 	trigger_enable( trigger_door.trigger, true ) 
  2698. 	on_trigger( "dlc2_m02_trigger_door_cb", trigger_door.trigger ) 
  2699. end 
  2700.  
  2701. function dlc2_m02_both_disable_machine( machine_data ) 
  2702. 	local local_nav = machine_data.navpoint 
  2703. 	local homie_nav = machine_data.navpoint_homie 
  2704. 	local trigger = machine_data.trigger 
  2705. 	local mover = machine_data.mover 
  2706. 	local homie = Dlc2_m02_characters.alien_homie 
  2707. 	local objective_switched = false 
  2708. 	 
  2709. 	Dlc2_m02_status.trigger_cspawn_data = machine_data.cspawn_data 
  2710.  
  2711. 	marker_remove( local_nav ) 
  2712. 	marker_add( local_nav, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL, SYNC_ALL ) 
  2713. 	objective_text( 0, Dlc2_m02_text.wait_for_homie, nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  2714. 	 
  2715. 	-- move homie into place 
  2716. 	follower_make_independent( homie, true ) 
  2717. 	set_ignore_ai_flag( homie, true ) 
  2718. 	character_release_human_shield( homie ) 
  2719.  
  2720. 	Dlc2_m02_status.homie_disabling = false 
  2721. 	Dlc2_m02_status.machine_disabled = false 
  2722.  
  2723. 	while Dlc2_m02_status.machine_disabled ~= true do 
  2724. 	 
  2725. 		if Dlc2_m02_status.homie_disabling == false then 
  2726. 			if human_is_downed( homie ) == false then 
  2727. 				clear_animation_state( homie ) 
  2728. 				 
  2729. 				-- move into position 
  2730. 				if get_dist( homie, homie_nav ) > 3 then 
  2731. 					ai_do_scripted_move( homie, homie_nav, true, false ) 
  2732. 		 
  2733. 					while get_dist( homie, homie_nav ) > 3 do 
  2734. 						thread_yield() 
  2735. 					end 
  2736. 				end 
  2737.  
  2738. 				-- animate disabling 
  2739. 				local anim_name = "m14 transmitter in" 
  2740. 				local force_play = false	 
  2741. 				local percentage = 1.0 
  2742. 				local stand_still = true 
  2743. 				local zero_movement = true 
  2744. 				set_animation_set( homie, "PLYM" ) 
  2745. 				set_animation_state( homie, "m14 transmitter idle", homie_nav ) 
  2746. 				action_play( homie, anim_name, anim_name, force_play, percentage, stand_still, zero_movement, homie_nav ) 
  2747. 				 
  2748. 				if objective_switched == false then 
  2749. 					-- objective: disable machine 
  2750. 					marker_remove( local_nav ) 
  2751. 					marker_add_trigger( trigger, MINIMAP_ICON_USE, INGAME_EFFECT_LOCATION, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL ) 
  2752. 					objective_text( 0, Dlc2_m02_text.search_code, nil, nil, SYNC_ALL, OI_ASSET_USE ) 
  2753. 					 
  2754. 					if machine_data.start_disable_audio_event ~= nil then 
  2755. 						audio_object_post_event( machine_data.start_disable_audio_event, nil, nil, LOCAL_PLAYER ) 
  2756. 					end 
  2757. 					 
  2758. 					-- set up trigger 
  2759. 					Dlc2_m02_status.activation_time = machine_data.activation_time 
  2760. 					Dlc2_m02_status.machine_disabled = false 
  2761. 					Dlc2_m02_status.activation_progress = 0 
  2762. 					Dlc2_m02_status.activation_nav = local_nav 
  2763. 					trigger_enable( trigger ) 
  2764. 					trigger_set_hold_to_repeat( trigger, true ) 
  2765. 					on_trigger( "dlc2_m02_on_trigger_machine", trigger ) 
  2766. 					 
  2767. 					if machine_data.convo_homie_ready ~= nil then 
  2768. 						dlc2_m02_convo_play( machine_data.convo_homie_ready, false, true ) 
  2769. 					end 
  2770. 					 
  2771. 					objective_switched = true 
  2772. 				end 
  2773. 			 
  2774. 				Dlc2_m02_status.homie_disabling = true 
  2775. 			end 
  2776. 		elseif human_is_downed( homie ) == true or get_dist( homie, homie_nav ) > 3 then 
  2777. 			set_animation_set( homie, "COP" ) 
  2778. 			clear_animation_state( homie ) 
  2779. 			Dlc2_m02_status.homie_disabling = false 
  2780. 		end 
  2781. 	 
  2782. 		thread_yield() 
  2783. 	end 
  2784. 	 
  2785. 	set_ignore_ai_flag( homie, false ) 
  2786. 	set_animation_set( homie, "COP" ) 
  2787. 	clear_animation_state( homie ) 
  2788. 	follower_make_independent( homie, false ) 
  2789. 	Dlc2_m02_status.homie_disabling = nil 
  2790. 	 
  2791. 	dlc2_m02_end_cspawning() 
  2792.  
  2793. 	-- remove marker from machine 
  2794. 	hud_bar_off( 1 ) 
  2795. 	marker_remove( trigger ) 
  2796. 	on_trigger( "", trigger ) 
  2797. 	objective_text_clear( 0 ) 
  2798. end 
  2799.  
  2800. function dlc2_m02_activate_security() 
  2801. 	mission_end_failure( "dlc2_m02", "DLC2_M02_MISSION_FAIL_OUT_OF_TIME" ) 
  2802. end 
  2803.  
  2804. function dlc2_m02_saucer_camera_sequence() 
  2805. 	local obj_nav = "nav_hanger_camera_objective" 
  2806. 	local trg_start = "trg_hanger_start_saucer_camera" 
  2807. 	local homie = Dlc2_m02_characters.alien_homie 
  2808. 	 
  2809. 	mesh_mover_reset( "mov_hanger_wall" ) 
  2810. 	mesh_mover_set_invulnerable( "mov_hanger_wall", true ) 
  2811. 	 
  2812. 	marker_add( obj_nav, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL, SYNC_ALL ) 
  2813. 	objective_text( 0, "DLC2_M02_GO_TO_HANGER", nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  2814. 	 
  2815. 	dlc2_m02_setup_door_trigger( Dlc2_m02_trigger_doors.hall4_entry ) 
  2816. --	dlc2_m02_setup_door_trigger( Dlc2_m02_trigger_doors.hanger_entry ) 
  2817. 	 
  2818. 	dlc2_m02_wait_for_trigger_hit( trg_start ) 
  2819. 	 
  2820. 	marker_remove( obj_nav ) 
  2821. 	objective_text_clear( 0 ) 
  2822. 	 
  2823. 	set_ignore_ai_flag( homie, true ) 
  2824. 	follower_make_independent( homie, true ) 
  2825.  
  2826. 	mission_start_fade_out() 
  2827. 	 
  2828. 	-- this just cleans up 
  2829. 	dlc2_m02_create_groups( Dlc2_m02_gspawn_data.hanger_1 ) 
  2830. 	 
  2831. 	group_create_hidden( Dlc2_m02_groups.saucer.name, true ) 
  2832. 	vehicle_allow_ownership_transfer( Dlc2_m02_vehicles.saucer, false ) 
  2833. 	vehicle_set_keyframed_physics( Dlc2_m02_vehicles.saucer, true ) 
  2834. 	player_force_vehicle_seat( LOCAL_PLAYER, 1, Dlc2_m02_vehicles.saucer ) 
  2835. 	 
  2836. 	if coop_is_active() then 
  2837. 		player_force_vehicle_seat( REMOTE_PLAYER, 2, Dlc2_m02_vehicles.saucer ) 
  2838. 	end 
  2839.  
  2840. 	 
  2841. 	teleport_coop( "nav_hanger_camera_local_start", "nav_hanger_camera_remote_start" ) 
  2842. 	teleport( homie, "nav_hanger_camera_homie_start" ) 
  2843.  
  2844. 	group_show( Dlc2_m02_groups.saucer.name ) 
  2845. 	 
  2846. 	mission_start_fade_in() 
  2847. 	audio_object_post_event( "M02_Part3_Music_Start", nil, nil, LOCAL_PLAYER ) 
  2848. 	audio_object_post_event( "M02_Spaceship_CTE", nil, nil, LOCAL_PLAYER ) 
  2849. 	fade_in_block() 
  2850. 	 
  2851. 	player_controls_disable( LOCAL_PLAYER ) 
  2852. 	player_movement_disable( LOCAL_PLAYER ) 
  2853. 	 
  2854. 	if coop_is_active() == true then 
  2855. 		player_controls_disable( REMOTE_PLAYER ) 
  2856. 		player_movement_disable( REMOTE_PLAYER ) 
  2857. 	end 
  2858.  
  2859. 	dlc2_m02_convo_play( Dlc2_m02_convos.see_ship, false, true )	 
  2860. 	 
  2861. 	ai_do_scripted_move( homie, "nav_hanger_camera_homie_end", true, false ) 
  2862. 	camera_look_through( "nav_hanger_camera_2", 7, true ) 
  2863. 	camera_look_through( "nav_hanger_camera_3", 1, true ) 
  2864. 	camera_look_through( "nav_hanger_camera_4", 3, true ) 
  2865. 	camera_look_through( "nav_hanger_camera_5", 1, true ) 
  2866. 	delay( 3 ) 
  2867. 	camera_end_look_through( true ) 
  2868. 	set_ignore_ai_flag( homie, false ) 
  2869. 	follower_make_independent( homie, false ) 
  2870. 	 
  2871. 	player_controls_enable( LOCAL_PLAYER ) 
  2872. 	player_movement_enable( LOCAL_PLAYER ) 
  2873. 	 
  2874. 	if coop_is_active() == true then 
  2875. 		player_controls_enable( REMOTE_PLAYER ) 
  2876. 		player_movement_enable( REMOTE_PLAYER ) 
  2877. 	end 
  2878.  
  2879. 	dlc2_m02_convo_play( Dlc2_m02_convos.third_action_1, false, true )	 
  2880. end 
  2881.  
  2882. function dlc2_m02_homie_kills() 
  2883. 	local homie = Dlc2_m02_characters.alien_homie 
  2884. 	local members = dlc2_m02_group_get_members( Dlc2_m02_groups.kiwiposters.name ) 
  2885. 	local flee_navs = { "nav_homie_kill_flee_1", "nav_homie_kill_flee_2", } 
  2886.  
  2887. 	dlc2_m02_create_groups( Dlc2_m02_gspawn_data.kiwiposters ) 
  2888. 	 
  2889. 	local members = dlc2_m02_group_get_members( Dlc2_m02_groups.kiwiposters.name ) 
  2890. 	 
  2891. 	for i, member in pairs( members ) do 
  2892. 		set_ignore_ai_flag( member, true ) 
  2893. 	end 
  2894.  
  2895. 	dlc2_m02_wait_for_trigger_hit( "trg_homie_kill_begin" ) 
  2896. 	 
  2897. 	set_ignore_ai_flag( homie, true ) 
  2898. 	turn_invulnerable( homie ) 
  2899. 	character_prevent_flinching( homie, true ) 
  2900. 	follower_make_independent( homie, true ) 
  2901. 	ai_do_scripted_move( homie, "nav_homie_kill_mark", true, false ) 
  2902. 	 
  2903. 	while get_dist( homie, "nav_homie_kill_mark" ) > 2 do 
  2904. 		thread_yield() 
  2905. 	end 
  2906. 	 
  2907. 	dlc2_m02_convo_play( Dlc2_m02_convos.bs3_first_convo, false, true ) 
  2908. 	 
  2909. 	ai_suggest_action( homie, "reload" ) 
  2910. 	delay( 7 ) 
  2911. 	 
  2912. 	for i, member in pairs( members ) do 
  2913. 		set_ignore_ai_flag( member, false ) 
  2914. 	end 
  2915. 	 
  2916. 	for i = 1, 2 do 
  2917. 		flee_to_navpoint( members[ i ], flee_navs[ i ], homie, true ) 
  2918. 	end 
  2919.  
  2920. 	for i = 3, 4 do 
  2921. 		local target_npc = members[ i ] 
  2922. 		 
  2923. 		-- force homie to fire 
  2924. --		ai_do_scripted_fire( homie, target_npc ) 
  2925. 		force_fire( homie, "nav_homie_kill_fire_at", true ) 
  2926. 		 
  2927. 		-- kill it 
  2928. 		turn_vulnerable( target_npc ) 
  2929. 		--effect_play_on_human( "Effect BloodHit", target_npc, "Head" ) 
  2930. 		character_kill( target_npc ) 
  2931. 		 
  2932. 		delay( 0.5 ) 
  2933. 	end 
  2934.  
  2935. 	turn_vulnerable( homie ) 
  2936. 	character_prevent_flinching( homie, false ) 
  2937. 	set_ignore_ai_flag( homie, false ) 
  2938. 	follower_make_independent( homie, false ) 
  2939. end 
  2940.  
  2941. function dlc2_m02_wait_for_trigger_hit( trigger_name ) 
  2942. 	while true do 
  2943. 		if object_is_in_trigger( trigger_name, LOCAL_PLAYER ) == true then 
  2944. 			break 
  2945. 		end 
  2946. 		 
  2947. 		if coop_is_active() == true and object_is_in_trigger( trigger_name, REMOTE_PLAYER ) == true then 
  2948. 			break 
  2949. 		end 
  2950. 		 
  2951. 		thread_yield() 
  2952. 	end 
  2953. end 
  2954.  
  2955. function dlc2_m02_brutina() 
  2956. 	local brutina = Dlc2_m02_characters.brutina 
  2957. 	local homie = Dlc2_m02_characters.alien_homie 
  2958.  
  2959. 	dlc2_m02_set_up_spawn_phase( Dlc2_m02_cspawn_data.brutina ) 
  2960. 	group_create( Dlc2_m02_groups.brutina.name, true ) 
  2961. 	 
  2962. 	ai_do_scripted_move( brutina, "nav_brutina_mark_1", true, false ) 
  2963. 	marker_add( brutina, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_FULL, SYNC_ALL ) 
  2964. 	objective_text( 0, Dlc2_m02_text.kill_brutina, nil, nil, SYNC_ALL, OI_ASSET_KILL ) 
  2965. 	 
  2966. 	while get_dist( brutina, "nav_brutina_mark_1" ) > 1 and character_is_dead( brutina ) == false do 
  2967. 		thread_yield() 
  2968. 	end 
  2969.  
  2970. 	dlc2_m02_convo_play( Dlc2_m02_convos.see_brutina, false, true )	 
  2971. 	ai_do_scripted_rush( brutina, homie ) 
  2972. 	ai_add_enemy_target( brutina, homie, ATTACK_NOW_NEVER_LOSE, true ) 
  2973. 	 
  2974. 	while  character_is_dead( brutina ) == false do 
  2975. 		thread_yield() 
  2976. 	end 
  2977.  
  2978. 	dlc2_m02_convo_play( Dlc2_m02_convos.brutina_defeated_01, false, true ) 
  2979. 	hud_achievement_show_progress( "Xenaphobe", 1, 1 ) 
  2980. 	 
  2981. 	objective_text_clear( 0 ) 
  2982. 	marker_remove( brutina ) 
  2983. end 
  2984.  
  2985. function dlc2_m02_obj_shut_down_forcefield() 
  2986. 	local generator_nav = "nav_generator" 
  2987. 	local console_nav = "nav_generator" 
  2988. 	local generator = "mov_generator" 
  2989. 	local wall = "mov_hanger_wall" 
  2990. 	local homie = Dlc2_m02_characters.alien_homie 
  2991. 	local approach_trigger = "trg_machine_approach_gen" 
  2992.  
  2993. 	-- obj: get to console 
  2994. 	objective_text( 0, "DLC2_M02_GO_TO_CONSOLE", nil, nil, SYNC_LOCAL, OI_ASSET_LOCATION ) 
  2995. 	objective_text( 1, "DLC2_M02_GO_TO_CONSOLE", nil, nil, SYNC_REMOTE, OI_ASSET_LOCATION ) 
  2996. 	dlc2_m02_trail_start( Dlc2_m02_trails.hanger2 ) 
  2997. 	audio_object_post_event( "M02_Part3_Security_Console", nil, nil, LOCAL_PLAYER ) 
  2998. 	 
  2999. 	dlc2_m02_wait_for_trigger_hit( approach_trigger ) 
  3000. 	local remote_arrived = coop_is_active() == false 
  3001. 	while object_is_in_trigger( approach_trigger, LOCAL_PLAYER ) == false do 
  3002. 		 
  3003. 		if remote_arrived == false and object_is_in_trigger( approach_trigger, REMOTE_PLAYER ) == true then 
  3004. 			objective_text( 1, Dlc2_m02_text.wait_for_homie, nil, nil, SYNC_REMOTE, OI_ASSET_LOCATION ) 
  3005. 			remote_arrived = true 
  3006. 		end 
  3007. 		 
  3008. 		thread_yield() 
  3009. 	end 
  3010. 	 
  3011. 	dlc2_m02_trail_stop() 
  3012.  
  3013. 	audio_object_post_event( "M02_Part3_Kwilanna_1", nil, nil, LOCAL_PLAYER ) 
  3014. 	dlc2_m02_convo_play( Dlc2_m02_convos.disable_generator_01, false, true)	 
  3015. 	 
  3016. 	objective_text_clear( 0 ) 
  3017. 	objective_text_clear( 1 ) 
  3018.  
  3019. 	-- obj: defend homie 
  3020. 	marker_remove( console_nav ) 
  3021. 	marker_add( homie, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND, OI_FLAGS_FULL, SYNC_ALL ) 
  3022. 	objective_text( 0, Dlc2_m02_text.protect_homie, nil, nil, SYNC_ALL, OI_ASSET_DEFEND ) 
  3023.  
  3024. 	-- homie activates console 
  3025. 	turn_invulnerable( homie ) 
  3026. 	follower_make_independent( homie, true ) 
  3027. 	set_ignore_ai_flag( homie, true ) 
  3028. 	character_release_human_shield( homie ) 
  3029. 	ai_do_scripted_move( homie, console_nav, true, false ) 
  3030.  
  3031. 	while get_dist( homie, console_nav ) > 3 do 
  3032. 		thread_yield() 
  3033. 	end 
  3034.  
  3035. 	-- animate disabling 
  3036. 	local anim_name = "m14 transmitter in" 
  3037. 	local force_play = false	 
  3038. 	local percentage = 1.0 
  3039. 	local stand_still = true 
  3040. 	local zero_movement = true 
  3041. 	character_allow_ragdoll( homie, false ) 
  3042. 	set_animation_set( homie, "PLYM" ) 
  3043. 	set_animation_state( homie, "m14 transmitter idle", console_nav ) 
  3044. 	action_play( homie, anim_name, anim_name, force_play, percentage, stand_still, zero_movement, console_nav ) 
  3045.  
  3046. 	delay( 5.25 ) 
  3047.  
  3048. 	-- homie is shocked 
  3049. 	clear_animation_state( homie ) 
  3050. 	set_animation_set( homie, "COP" ) 
  3051. 	character_prevent_flinching( homie, true ) 
  3052. 	local shock_effect_handle = effect_play_on_human( "vfx_electric_body", homie, "spine2", true ) 
  3053. 	audio_object_post_event( "M02_Part3_Kwilanna_2", nil, nil, LOCAL_PLAYER ) 
  3054. 	dlc2_m02_convo_play( Dlc2_m02_convos.disable_generator_02, false, true)	 
  3055. 	dlc2_m02_convo_play( Dlc2_m02_convos.disable_generator_03, false, false)	 
  3056. 	 
  3057. 	-- obj: destroy generator 
  3058. 	marker_remove( homie ) 
  3059. 	marker_add( generator, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_FULL, SYNC_ALL ) 
  3060. 	objective_text( 0, "DLC2_M02_DESTORY_GENERATOR", nil, nil, SYNC_ALL, OI_ASSET_KILL ) 
  3061. 	 
  3062. 	local mover = generator 
  3063. 	mesh_mover_set_invulnerable( mover, false ) 
  3064.  
  3065. 	-- set up progress bar 
  3066. 	local prev_hit_points = get_current_hit_points( mover ) 
  3067. 	local max_hit_points = get_max_hit_points( mover ) 
  3068. 	local current_hit_points = prev_hit_points 
  3069.  
  3070. 	hud_bar_on( 1, "health", Dlc2_m02_text.progress, max_hit_points ) 
  3071. 	hud_bar_set_value( 1, 0 ) 
  3072. 	 
  3073. 	repeat 
  3074. 		thread_yield() 
  3075. 		current_hit_points = get_current_hit_points( mover ) 
  3076. 		if prev_hit_points ~= current_hit_points then 
  3077. 			hud_bar_set_value( 1, max_hit_points - current_hit_points ) 
  3078. 		end 
  3079. 	until current_hit_points <= 0 
  3080. 	 
  3081. 	-- explode with camera shake 
  3082. 	character_allow_ragdoll( homie, true ) 
  3083. 	mesh_mover_set_invulnerable( wall, false ) 
  3084. 	mesh_mover_set_invulnerable( generator, false ) 
  3085. 	explosion_create( "alien_mindcontrol", "nav_generator_explosion", LOCAL_PLAYER, nil, "vfx_mindcontrol_exp" ) 
  3086. 	camera_shake_play( "m24_marsquake", 6 ) 
  3087. 	effect_stop( shock_effect_handle ) 
  3088. 	mesh_mover_hide( "mov_forcefield" ) 
  3089. 	set_unjackable_flag( Dlc2_m02_vehicles.saucer, false ) 
  3090. 	vehicle_set_keyframed_physics( Dlc2_m02_vehicles.saucer, false ) 
  3091.  
  3092. 	-- down local player 
  3093. 	player_movement_disable( LOCAL_PLAYER ) 
  3094. 	character_ragdoll( LOCAL_PLAYER, nil, nil, nil, nil, true ) 
  3095. 	audio_object_post_event( "M02_Forcefield_Disable", nil, nil, LOCAL_PLAYER )	 
  3096. 	dlc2_m02_convo_play( Dlc2_m02_convos.saving_player_01, false, true)	 
  3097.  
  3098. 	-- clear the progress bar 
  3099. 	marker_remove( generator ) 
  3100. 	objective_text_clear( 0 ) 
  3101. 	hud_bar_off( 1 ) 
  3102. 	 
  3103. 	while character_is_ragdolled( homie ) == true do 
  3104. 		thread_yield() 
  3105. 	end 
  3106. 	 
  3107. 	-- homie revives player 
  3108. 	ai_do_scripted_move( homie, LOCAL_PLAYER, true, false ) 
  3109. 	 
  3110. 	local elapsed_time = 0.0 
  3111.  
  3112. 	while get_dist( homie, LOCAL_PLAYER ) > 2 do 
  3113. 		thread_yield() 
  3114.  
  3115. 		elapsed_time = elapsed_time + get_frame_time() 
  3116. 		 
  3117. 		if elapsed_time > 5 then 
  3118. 			teleport_to_object( homie, LOCAL_PLAYER ) 
  3119. 			break 
  3120. 		end 
  3121. 	end 
  3122. 	 
  3123. 	dlc2_m02_convo_play( Dlc2_m02_convos.jumping_to_end, false, true)	 
  3124. 	 
  3125. 	character_fake_revival_start( LOCAL_PLAYER ) 
  3126. 	action_play_synced( LOCAL_PLAYER, homie, "DBNO revive" ) 
  3127. 	character_fake_revival_end( LOCAL_PLAYER ) 
  3128. 	 
  3129. 	player_movement_enable( LOCAL_PLAYER ) 
  3130. 	turn_vulnerable( homie ) 
  3131. 	character_prevent_flinching( homie, false ) 
  3132. 	set_ignore_ai_flag( homie, false ) 
  3133. 	follower_make_independent( homie, false ) 
  3134. end 
  3135.  
  3136. function dlc2_m02_trail_start( trail_data, end_point_mod ) 
  3137. 	dlc2_m02_trail_stop() 
  3138. 	 
  3139. 	Dlc2_m02_threads.trail = thread_new( "dlc2_m02_trail_thread", trail_data, end_point_mod ) 
  3140. end 
  3141.  
  3142. function dlc2_m02_trail_stop() 
  3143. 	if Dlc2_m02_threads.trail ~= nil then 
  3144. 		thread_kill( Dlc2_m02_threads.trail ) 
  3145. 		Dlc2_m02_threads.trail = nil 
  3146. 	end 
  3147. 	 
  3148. 	if Dlc2_m02_status.trail_current ~= nil then 
  3149. 		marker_remove( Dlc2_m02_status.trail_current ) 
  3150. 		Dlc2_m02_status.trail_current = nil 
  3151. 	end 
  3152. end 
  3153.  
  3154. function dlc2_m02_trail_thread( trail_data, end_point_mod ) 
  3155. 	local current_nav_index = 1 
  3156. 	local current_nav = trail_data[ 1 ] 
  3157. 	local new_nav_index = 1 
  3158. 	marker_add( current_nav, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL, SYNC_ALL ) 
  3159. 	Dlc2_m02_status.trail_current = current_nav 
  3160. 	 
  3161. 	while true do 
  3162. 		 
  3163. 		for i = current_nav_index, #trail_data do 
  3164. 			local nav = trail_data[ i ] 
  3165. 			local d = get_dist( nav, LOCAL_PLAYER ) 
  3166. 			 
  3167. 			if coop_is_active() == true then 
  3168. 				local d2 = get_dist( nav, REMOTE_PLAYER ) 
  3169. 				 
  3170. 				if d2 < d then 
  3171. 					d = d2 
  3172. 				end 
  3173. 			end 
  3174. 			 
  3175. 			if d < 2 then 
  3176. 				new_nav_index = i + 1 
  3177. 				break 
  3178. 			end 
  3179. 		end 
  3180. 		 
  3181. 		local new_nav = trail_data[ new_nav_index ] 
  3182. 		 
  3183. 		if new_nav_index ~= current_nav_index then 
  3184. 			if new_nav == nil then 
  3185. 				break 
  3186. 			end 
  3187.  
  3188. 			marker_remove( current_nav ) 
  3189.  
  3190. 			current_nav = new_nav 
  3191. 			current_nav_index = new_nav_index 
  3192. 			 
  3193. 			if trail_data[ current_nav_index + 1 ] == nil then 
  3194. 				-- last nav may require modification 
  3195. 				if end_point_mod == "use" then 
  3196. 					marker_add( current_nav, MINIMAP_ICON_USE, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL ) 
  3197. 				else 
  3198. 					marker_add( current_nav, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL, SYNC_ALL ) 
  3199. 				end 
  3200. 			else 
  3201. 				marker_add( current_nav, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL, SYNC_ALL ) 
  3202. 			end 
  3203. 			 
  3204. 			Dlc2_m02_status.trail_current = current_nav 
  3205. 		end 
  3206. 		 
  3207. 		thread_yield() 
  3208. 	end 
  3209. end 
  3210.  
  3211. function dlc2_m02_clapboard_setup() 
  3212. 	local count = 0 
  3213. 	 
  3214. 	for i, d in  pairs( Dlc2_m02_clapboards ) do 
  3215. 		if dlc2_m02_clapboards_get( i ) == false then 
  3216. 			trigger_enable( d.trigger, true ) 
  3217. 			on_trigger( "dlc2_m02_clapboard_cb", d.trigger ) 
  3218. 			item_show( d.item ) 
  3219. 			 
  3220. 			if d.effect_handle == nil then 
  3221. 				d.effect_handle = effect_play( d.effect, true ) 
  3222. 			end 
  3223. 		else 
  3224. 			item_hide( d.item ) 
  3225. 			d.collected = true 
  3226. 			count = count + 1 
  3227. 		end 
  3228. 	end 
  3229. 	 
  3230. 	Dlc2_m02_achievements.lights_camera_action.count = count 
  3231. end 
  3232.  
  3233. function dlc2_m02_clapboard_cb( char, trigger ) 
  3234. 	trigger_enable( trigger, false ) 
  3235. 	on_trigger( "", trigger ) 
  3236. 	 
  3237. 	-- find the index 
  3238. 	local index = -1 
  3239. 	for i, d in  pairs( Dlc2_m02_clapboards ) do 
  3240. 		if d.trigger == trigger then 
  3241. 			index = i 
  3242. 			break 
  3243. 		end 
  3244. 	end 
  3245. 	 
  3246. 	if index == -1 then 
  3247. 		return 
  3248. 	end 
  3249. 	 
  3250. 	-- set the flag 
  3251. 	Dlc2_m02_clapboards[ index ].collected = true 
  3252. 	dlc2_m02_helper_achievement_increment( Dlc2_m02_achievements.lights_camera_action ) 
  3253. 	audio_object_post_event( "M02_ClapBoard_Pickup", nil, nil, LOCAL_PLAYER ) 
  3254. 	 
  3255. 	-- dissappear the clapboard 
  3256. 	local c = Dlc2_m02_clapboards[ index ] 
  3257. 	item_hide( c.item ) 
  3258. 	 
  3259. 	if c.effect_handle ~= nil then 
  3260. 		effect_stop( c.effect_handle ) 
  3261. 		c.effect_handle = nil 
  3262. 	end 
  3263. end 
  3264.  
  3265. function dlc2_m02_backstage_01_roof( activator, trigger ) 
  3266. 	on_trigger( "", trigger ) 
  3267. 	trigger_enable( trigger, false ) 
  3268. 	 
  3269. 	dlc2_m02_convo_play( Dlc2_m02_convos.bs_1_walk_on_roof, false, true ) 
  3270. end 
  3271.  
  3272. function dlc2_m02_amazon_damaged_cb( npc, attacker, pct, explosion, melee ) 
  3273. 	if pct < 0.001 then 
  3274. 		if attacker == LOCAL_PLAYER or attacker == REMOTE_PLAYER then 
  3275. 			if melee == true then 
  3276. 				dlc2_m02_helper_achievement_increment( Dlc2_m02_achievements.man_power ) 
  3277. 				on_take_damage( "", npc ) 
  3278. 			elseif inv_item_is_equipped( "DLC_LaserPistol", attacker ) == true then 
  3279. 				dlc2_m02_helper_achievement_increment( Dlc2_m02_achievements.pew_pew_pew ) 
  3280. 				on_take_damage( "", npc ) 
  3281. 			end 
  3282. 		end 
  3283. 	end 
  3284. end 
  3285.  
  3286. function dlc2_m02_helper_achievements_write_checkpoint() 
  3287. 	-- Write the achievement data for the checkpoint 
  3288. 	for i, achievement in pairs( Dlc2_m02_achievements ) do 
  3289. 		dlc_achievement_counter_set( achievement.slot_idx, achievement.current_count ) 
  3290. 	end 
  3291. 	 
  3292. 	-- clapboards 
  3293. 	for i, clapboard in pairs( Dlc2_m02_clapboards ) do 
  3294. 		if clapboard.collected == true then 
  3295. 			dlc2_m02_clapboards_set( i ) 
  3296. 		end 
  3297. 	end 
  3298. end 
  3299.  
  3300. function dlc2_m02_helper_achievement_reset( achievement_table ) 
  3301. 	dlc_achievement_counter_set( achievement_table.slot_idx, 0 ) 
  3302. 	achievement_table.current_count = 0 
  3303. end 
  3304.  
  3305. -- Read the stored achievement counter from the previous checkpoint 
  3306. function dlc2_m02_helper_achievement_read_checkpoint( achievement_table ) 
  3307. 	for i, achievement in pairs( achievement_table ) do 
  3308. 		achievement.current_count = dlc_achievement_counter_get( achievement.slot_idx ) 
  3309. 	end	 
  3310. end 
  3311.  
  3312. -- Increment an achievement counter 
  3313. function dlc2_m02_helper_achievement_increment( achievement_table ) 
  3314. 	-- Check if the target goal has already been reached 
  3315. 	if ( achievement_table.current_count >= achievement_table.target_goal ) then 
  3316. 		return 
  3317. 	end 
  3318. 	 
  3319. 	-- Increment the counter 
  3320. 	achievement_table.current_count = achievement_table.current_count + 1 
  3321.  
  3322. 	-- Show the progress HUD 
  3323. 	hud_achievement_show_progress( achievement_table.name, achievement_table.current_count, achievement_table.target_goal ) 
  3324. end 
  3325.  
  3326. function dlc2_m02_failed_to_protect() 
  3327. 	mission_end_failure( "dlc2_m02", "dlc2_m02_mission_fail_didnt_protect_homie" ) 
  3328. end 
  3329.  
  3330. function 	dlc2_m02_room3_cue_music() 
  3331. 		trigger_enable( "trg_room3_cue_music", false ) 
  3332. 		on_trigger( "", "trg_room3_cue_music" ) 
  3333. 		audio_object_post_event( "M02_Part2_Music_Start", nil, nil, LOCAL_PLAYER ) 
  3334. end 
  3335.  
  3336. function dlc2_m02_setup_convo_trigger( trigger, convo ) 
  3337. 	if Dlc2_m02_status.convo_triggers == nil then 
  3338. 		Dlc2_m02_status.convo_triggers = { } 
  3339. 	end 
  3340. 	 
  3341. 	Dlc2_m02_status.convo_triggers[ trigger ] = convo 
  3342. 	trigger_enable( trigger, true ) 
  3343. 	on_trigger( "dlc2_m02_convo_trigger_cb", trigger ) 
  3344. end 
  3345.  
  3346. function dlc2_m02_convo_trigger_cb( char, trigger ) 
  3347. 	if Dlc2_m02_status.convo_triggers[ trigger ] ~= nil then 
  3348. 		if dlc2_m02_convo_is_playing() == false then 
  3349. 			dlc2_m02_convo_play( Dlc2_m02_status.convo_triggers[ trigger ], false, false ) 
  3350.  
  3351. 			trigger_enable( trigger, false ) 
  3352. 			on_trigger( "", trigger ) 
  3353. 		end 
  3354. 		 
  3355. 		Dlc2_m02_status.convo_triggers[ trigger ] = nil 
  3356. 	end 
  3357. end 
  3358.  
  3359. function dlc2_m02_enable_traps( enable ) 
  3360. 	local triggers = { 
  3361. 		Dlc2_m02_triggers.electric_trap_1, 
  3362. 		Dlc2_m02_triggers.electric_trap_2, 
  3363. 		Dlc2_m02_triggers.fire_trap, 
  3364. 	} 
  3365. 	 
  3366. 	for i, t in pairs( triggers ) do 
  3367. 		trigger_enable( t, enable ) 
  3368. 	end 
  3369. 	 
  3370. 	if enable then 
  3371. 		on_trigger( "dlc2_m02_trap_electric", Dlc2_m02_triggers.electric_trap_1 ) 
  3372. 		on_trigger( "dlc2_m02_trap_electric", Dlc2_m02_triggers.electric_trap_2 ) 
  3373. 		on_trigger( "dlc2_m02_trap_fire", Dlc2_m02_triggers.fire_trap ) 
  3374. 	else 
  3375. 		for i, t in pairs( triggers ) do 
  3376. 			on_trigger( "", t ) 
  3377. 		end 
  3378. 	end 
  3379. end 
  3380.  
  3381. function dlc2_m02_trap_electric( npc, trigger ) 
  3382. 	if npc == nil then 
  3383. 		return 
  3384. 	end 
  3385. 	 
  3386. 	local impulse_nav 
  3387. 	if trigger == Dlc2_m02_triggers.electric_trap_1 then 
  3388. 		impulse_nav = "nav_electric_1" 
  3389. 	else 
  3390. 		impulse_nav = "nav_electric_2" 
  3391. 	end 
  3392. 	 
  3393. 	character_ragdoll( npc, 3 * 1000, 10, impulse_nav ) 
  3394. 	 
  3395. 	local shock_effect_handle = effect_play_on_human( "vfx_electric_body", npc, "spine2", true ) 
  3396. 	delay( 3 ) 
  3397. 	effect_stop( shock_effect_handle ) 
  3398. end 
  3399.  
  3400. function dlc2_m02_trap_fire( npc ) 
  3401. 	if npc == nil then 
  3402. 		return 
  3403. 	end 
  3404. 	 
  3405. 	character_ignite( npc ) 
  3406. end 
  3407.  
  3408. function dlc2_m02_film_grain_unload( b ) 
  3409. 	if Dlc2_m02_status.film_grain == true then 
  3410. 		Dlc2_m02_status.film_grain = false 
  3411. 		dlc_gis_film_grain_unload( b ) 
  3412. 		audio_object_post_event( "M02_Cut", nil, nil, LOCAL_PLAYER ) 
  3413. 	end 
  3414. end 
  3415.  
  3416. function dlc2_m02_film_grain_load() 
  3417. 	if Dlc2_m02_status.film_grain ~= true then 
  3418. 		Dlc2_m02_status.film_grain = true 
  3419. 		dlc_gis_film_grain_load() 
  3420. 		audio_object_post_event( "M02_Action", nil, nil, LOCAL_PLAYER ) 
  3421. 	end 
  3422. end