./m14.lua

  1.  
  2. --[[ 
  3. 	m14.lua 
  4. 	SR3 Mission Script 
  5. 	DATE: 9/21/2010 
  6. 	AUTHOR:	Nick Heilmann 
  7. ]]-- 
  8.  
  9.  
  10. M14_TIMER_INDEX = 1 
  11. M14_PROGRESS_INDEX = 1 
  12. VEHICLE_SEAT_DRIVER = 0 
  13. VEHICLE_SEAT_PASSENGER = 1 
  14. VEHICLE_SEAT_HELI_BACK_DOOR = 2 
  15. HUD_BAR_MAX_VALUE = 100 
  16. HUD_BAR_STEP_TRANSMITTER = 2 
  17. HUD_BAR_STEP_VAN = 1 
  18. HUD_BAR_DELAY_TRANSMITTER = .5 
  19. HUD_BAR_DELAY_VAN = .25 
  20. HUD_FAKE_RETICLE_WEAPON_NAME = "sp_vtol01_w" 
  21. HUD_FAKE_RETICLE_WEAPON_CATEGORY_NAME = "WPNCAT_RIFLE" 
  22.  
  23. M14_DEBUG = { 
  24. 	infinity = 999999999, 
  25. 	message_handle = INVALID_MESSAGE_HANDLE, 
  26. } 
  27.  
  28. M14_status = { 
  29. 	do_timer_validation = false, 
  30. 	do_tower1_validation = false, 
  31. 	do_tower2_validation = false, 
  32. 	do_interview_validation = false, 
  33. 	transmitter_placed = false, 
  34. 	helipad_reached = false, 
  35. 	interview_stairs_reached = false, 
  36. 	helipad_left = false, 
  37. 	timer_active = false, 
  38. 	target_progress_displayed = false, 
  39. 	transmitter_bar_displayed = false, 
  40. 	deckers_alive = 0, 
  41. 	proxy_navpoint = nil, -- Navpoint that's being used as a proxy for placement of an icon when a trigger is set 
  42. 	play_radio_call_in = false,				-- we only want to play this on linear play through but not on checkpoint restart 
  43. } 
  44.  
  45. M14_objective_text = { 
  46. 	gsi_index = nil, 
  47. 	text = nil, 
  48. 	sub1 = nil, 
  49. 	sub2 = nil, 
  50. 	sync_type = nil, 
  51. 	oi_asset = nil, 
  52. } 
  53.  
  54. M14_char = { 
  55. 	-- M14_char.shaundi will be a reference to whichever version of Shaundi is currently active 
  56. 	shaundi = nil, 
  57. 	shaundi_sj = "NPC Shaundi SJ", 
  58. 	shaundi_heli = "NPC Shaundi Heli", 
  59. 	shaundi_t1 = "NPC Shaundi Tower 001", 
  60. 	shaundi_t2 = "NPC Shaundi Tower 002", 
  61. 	shaundi_studio = "NPC Shaundi Studio", 
  62.  
  63. 	t1_small = { "NPC T1 SG 001", "NPC T1 SG 002", "NPC T1 SG 003", "NPC T1 SG 004" }, 
  64. 	deckers_t1_1 = { "NPC T1 Decker 001", "NPC T1 Decker 002", "NPC T1 Decker 003" }, 
  65. 	t2_small = { "NPC T2 SG 001", "NPC T2 SG 002" }, 
  66.  
  67. 	helipad = { 
  68. 		"NPC Helipad 001", "NPC Helipad 002", "NPC Helipad 003", "NPC Helipad 004", 
  69. 		"NPC Helipad 005", "NPC Helipad 006", "NPC Helipad 007", "NPC Helipad 008",  
  70. 	}, 
  71. 	 
  72. 	deckers_studio = { 
  73. 		"NPC Decker Studio 001", "NPC Decker Studio 002", "NPC Decker Studio 003", "NPC Decker Studio 004", 
  74. 		"NPC Decker Studio 005", "NPC Decker Studio 006", "NPC Decker Studio 007", "NPC Decker Studio 008", 
  75. 	}, 
  76.  
  77. 	deckers_elevator_rb = { "NPC Decker Elevator RB 001", "NPC Decker Elevator RB 002" }, 
  78. 	deckers_elevator_fs = { "NPC Decker Elevator FS 001", "NPC Decker Elevator FS 002", "NPC Decker Elevator FS 003" }, 
  79. 	deckers_corner_rb = { "NPC Decker Corner RB 001" }, 
  80. 	deckers_corner_fs = { "NPC Decker Corner FS 001" }, 
  81. 	deckers_side_rb = { "NPC Decker Side RB 001" }, 
  82. 	deckers_side_fs = { "NPC Decker Side FS 001", "NPC Decker Side FS 002" }, 
  83. 	deckers_stairs_rb = { "NPC Decker Stairs RB 001", "NPC Decker Stairs RB 002", "NPC Decker Stairs RB 003" }, 
  84. 	deckers_stairs_fs = { "NPC Decker Stairs FS 001", "NPC Decker Stairs FS 002" }, 
  85. 	 
  86. 	broadcast_van = "NPC Broadcast Van Driver", 
  87. 	jane = "NPC Jane Valderama", 
  88. 	killbane = "NPC Killbane", 
  89. } 
  90.  
  91. M14_vehicle = { 
  92. 	cp_smiling_jacks = "Veh CP Smiling Jacks", 
  93.  
  94. 	-- M14_vehicle.spotlight_heli will be a reference to whichever version of the spotlight heli is currently active 
  95. 	spotlight_heli = "", 
  96. 	cp_sj_spotlight_heli = "Veh CP SJ Spotlight Heli", 
  97. 	cp_heli_spotlight_heli = "Veh CP Heli Spotlight Heli", 
  98. 	cp_t1_spotlight_heli = "Veh CP T1 Spotlight Heli", 
  99. 	cp_t2_spotlight_heli = "Veh CP T2 Spotlight Heli", 
  100. 	cp_studio_spotlight_heli = "Veh CP Studio Spotlight Heli", 
  101.  
  102. 	broadcast_van = "Veh Broadcast Van", 
  103. 	killbane_escape = "Veh Killbane Escape", 
  104. 	killbane_chase = "Veh Killbane Chase", 
  105. } 
  106.  
  107. M14_group = { 
  108. 	cp_smiling_jacks = { name = "GRP CP Smiling Jacks", chars = { M14_char.shaundi_sj }, vehicles = { M14_vehicle.cp_smiling_jacks, M14_vehicle.cp_sj_spotlight_heli } }, 
  109. 	cp_heli = { name = "GRP CP Heli", chars = { M14_char.shaundi_heli }, vehicles = { M14_vehicle.cp_heli_spotlight_heli } }, 
  110. 	cp_tower1 = { name = "GRP CP Tower 001", chars = { M14_char.shaundi_t1 }, vehicles = { M14_vehicle.cp_t1_spotlight_heli } }, 
  111. 	cp_tower2 = { name = "GRP CP Tower 002", chars = { M14_char.shaundi_t2 }, vehicles = { M14_vehicle.cp_t2_spotlight_heli } }, 
  112. 	cp_studio = { name = "GRP CP Studio", chars = { M14_char.shaundi_studio }, vehicles = { M14_vehicle.cp_studio_spotlight_heli } }, 
  113. 	--spotlight_heli = { name = "GRP Veh Spotlight Heli", vehicles = { M14_vehicle.cp_heli_spotlight_heli } }, 
  114. 	--shaundi = { name = "GRP Shaundi", chars = { M14_char.shaundi } }, 
  115. 	t1_small = { name = "GRP T1 Small", chars = M14_char.t1_small }, 
  116. 	t2_small = { name = "GRP T2 Small", chars = M14_char.t2_small }, 
  117. 	deckers_t1_1 = { name = "GRP Tower One Deckers 001", chars = M14_char.deckers_t1_1 }, 
  118. 	deckers_t1_2 = { name = "GRP Tower One Deckers 002" }, 
  119. 	deckers_t2_4 = { name = "GRP Tower Two Deckers 004" }, 
  120. 	broadcast_van = { name = "GRP Broadcast Van", chars = { M14_char.broadcast_van }, vehicles = { M14_vehicle.broadcast_van } }, 
  121. 	helipad = { name = "GRP Helipad", chars = M14_char.helipad }, 
  122. 	deckers_studio = { name = "GRP Studio Deckers", chars = M14_char.deckers_studio }, 
  123. 	deckers_elevator = { name = "GRP Deckers Elevator", chars = { M14_char.deckers_elevator_rb, M14_char.deckers_elevator_fs } }, 
  124. 	deckers_corner = { name = "GRP Deckers Corner", chars = { M14_char.deckers_corner_rb, M14_char.deckers_corner_fs } }, 
  125. 	deckers_side = { name = "GRP Deckers Side", chars = { M14_char.deckers_side_rb, M14_char.deckers_side_fs } }, 
  126. 	deckers_stairs = { name = "GRP Deckers Stairs", chars = { M14_char.deckers_stairs_rb, M14_char.deckers_stairs_fs } }, 
  127. 	jane = { name = "GRP Jane Valderama", chars = { M14_char.jane } }, 
  128. 	killbane = { name = "GRP Killbane", chars = { M14_char.killbane }, vehicles = { M14_vehicle.killbane_escape, M14_vehicle.killbane_chase } }, 
  129. } 
  130.  
  131. M14_spawn_group = { 
  132. 	deckers_t2 = {	"GRP Tower Two Deckers 001", "GRP Tower Two Deckers 002", "GRP Tower Two Deckers 003"   }, 
  133. } 
  134.  
  135. M14_spawn_region = { 
  136. 	deckers_t2 = { "Spawn Reg Ttwo 001", "Spawn Reg Ttwo 002", "Spawn Reg Ttwo 003" }, 
  137. } 
  138.  
  139. M14_navpoint = { 
  140. 	cp_sj_lp = "Nav CP SJ Local", 
  141. 	cp_sj_rp = "Nav CP SJ Remote", 
  142. 	cp_heli_lp = "Nav CP Heli Local", 
  143. 	cp_heli_rp = "Nav CP Heli Remote", 
  144. 	cp_tower1_lp = "Nav CP T1 Local", 
  145. 	cp_tower1_rp = "Nav CP T1 Remote", 
  146. 	cp_tower2_lp = "Nav CP T2 Local", 
  147. 	cp_tower2_rp = "Nav CP T2 Remote", 
  148. 	cp_van_complete_heli = "Nav CP Van Heli", 
  149. 	cp_studio_lp = "Nav CP Studio Local", 
  150. 	cp_studio_rp = "Nav CP Studio Remote", 
  151.  
  152. 	sj_spotlight_heli = "Nav CP SJ Spotlight Heli", 
  153.  
  154. 	t1_helipad = "Nav T1 Helipad", 
  155. 	t2_helipad = "Nav T2 Helipad", 
  156. 	interview_helipad = "Nav Interview Helipad", 
  157.  
  158. 	deckers_elevator = { "Nav Elevator 001", "Nav Elevator 002", "Nav Elevator 003" }, 
  159. 	deckers_corner = { "Nav Corner 001" }, 
  160. 	deckers_side = { "Nav Side 001", "Nav Side 002" }, 
  161. 	deckers_stairs = { "Nav Stairs 001", "Nav Stairs 002" }, 
  162.  
  163. 	elevator_rb = "Nav Elevator RB", 
  164. 	corner_rb = "Nav Corner RB", 
  165. 	side_rb = "Nav Side RB", 
  166. 	stairs_rb = "Nav Stairs RB", 
  167.  
  168. 	killbane_escape = "Nav Killbane Dest", 
  169.  
  170. 	end_local = "Nav Mission End Local", 
  171. 	end_remote = "Nav Mission End Remote", 
  172. 	 
  173. 	jane_tether = "Nav Jane Tether", 
  174. 	 
  175. 	tower_one_placement = "Nav Tower One Placement", 
  176. 	tower_two_placement = "Nav Tower Two Placement", 
  177. } 
  178.  
  179. M14_cam_nav = { 
  180. 	transmitters = { "Cam Nav Transmitter 001", "Cam Nav Transmitter 002" }, 
  181. 	helipads = { "Cam Nav Helipad 001", "Cam Nav Helipad 002" }, 
  182. 	jane = "Cam Nav Jane", 
  183. 	deckers = "Cam Nav Deckers", 
  184. 	elevator = { "Cam Nav Elevator 001", "Cam Nav Elevator 002" }, 
  185. 	doors = { "Cam Nav Doors 001", "Cam Nav Doors 002" }, 
  186. 	stairs = { "Cam Nav Stairs 001", "Cam Nav Stairs 002" }, 
  187. } 
  188.  
  189. M14_trigger = { 
  190. 	tower1_heli_validation = "Trigger Heli Validation 001", 
  191. 	--tower1_helipad = "Trigger T1 Helipad", 
  192. 	tower1 = "Trigger Tower 001", 
  193. 	tower2_heli_validation = "Trigger Heli Validation 002", 
  194. 	--tower2_helipad = "Trigger T2 Helipad", 
  195. 	tower2 = "Trigger Tower 002", 
  196. 	helipad = "Trigger Helipad", 
  197. 	studio_stairs1 = "Trigger Stairs1", 
  198. 	studio_stairs2 = "Trigger Stairs2", 
  199. 	interview_stairs = "Trigger Interview Stairs", 
  200. 	studio_massacre = "Trigger Studio Massacre", 
  201. 	t1_massacre = "Trigger T1 Massacre", 
  202. 	t2_massacre = "Trigger T2 Massacre", 
  203. } 
  204.  
  205. M14_scripted_path = { 
  206. 	killbane_escape = "Scripted Path Killbane Escape", 
  207. } 
  208.  
  209. M14_script_mover = { 
  210. 	elevator = "SM Elevator", 
  211. 	side_door = { "SM Side Door 001", "SM Side Door 002" }, 
  212. } 
  213.  
  214. M14_text = { 
  215. 	go_to_heli = "M14_OBJ_GO_TO_HELI", 
  216. 	get_in_heli = "M14_OBJ_GET_IN_HELI", 
  217. 	go_to_tower = "M14_OBJ_GO_TO_TOWER", 
  218. 	plant_transmitter = "M14_OBJ_PLANT_TRANSMITTER", 
  219. 	go_to_van = "M14_OBJ_GO_TO_VAN", 
  220. 	target_van = "M14_OBJ_TARGET_VAN", 
  221. 	go_to_interview = "M14_OBJ_GO_TO_INTERVIEW", 
  222. 	enter_building = "M14_OBJ_ENTER_BUILDING", 
  223. 	talk_to_jane = "M14_OBJ_TALK_TO_JANE", 
  224. 	clear_deckers = "M14_OBJ_CLEAR_DECKERS", 
  225. 	catch_killbane = "M14_OBJ_CATCH_KILLBANE", 
  226.  
  227. 	label_acquiring_target = "M14_LABEL_ACQUIRING_TARGET", 
  228. 	label_planting_transmitter = "M14_LABEL_PLANTING_TRANSMITTER", 
  229.  
  230. 	failure_van_destroyed = "m14_failure_van_destroyed", 
  231. 	failure_heli_destroyed = "m14_failure_heli_destroyed", 
  232. 	failure_shaundi_died = "m14_failure_shaundi_died", 
  233. 	failure_shaundi_abandoned = "m14_failure_shaundi_abandoned", 
  234. 	failure_heli_unreachable = "m14_failure_heli_unreachable", 
  235. 	failure_heli_abandoned = "m14_failure_heli_abandoned", 
  236. 	failure_jane_died = "m14_failure_jane_died", 
  237. 	failure_killbane_escaped = "m14_failure_killbane_escaped", 
  238. } 
  239.  
  240. M14_thread = { 
  241. 	that_was_easy = INVALID_THREAD_HANDLE, 
  242. 	get_out_place_transmitter = INVALID_THREAD_HANDLE, 
  243. 	surprise_for_you = INVALID_THREAD_HANDLE, 
  244. 	crazy_bitch = INVALID_THREAD_HANDLE, 
  245. 	killbane_escape = INVALID_THREAD_HANDLE, 
  246. 	failure_validation = INVALID_THREAD_HANDLE, 
  247. 	one_last_transmitter = INVALID_THREAD_HANDLE, 
  248. 	radio_call_in = INVALID_THREAD_HANDLE, 
  249. 	audio_failsafe = INVALID_THREAD_HANDLE, 
  250. } 
  251.  
  252. M14_2d_personas = { 
  253. 	anna = { 
  254. 		name = "Anna", 
  255. 		handle = -1, 
  256. 	}, 
  257. 	shaundi = { 
  258. 		name = "Shaundi", 
  259. 		handle = -1, 
  260. 	}, 
  261. 	kinzie = { 
  262. 		name = "Kinzie", 
  263. 		handle = -1, 
  264. 	}, 
  265. } 
  266.  
  267. M14_convo = { 
  268. 	-- Shaundi, Player 
  269. 	drive_01 = { convo_name = "m14_drive_01", handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { }, player_speaks = true }, 
  270.  
  271. 	-- Shaundi, Player 
  272. 	drive_02 = { convo_name = "m14_drive_02", handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { }, player_speaks = true }, 
  273.  
  274. 	-- Kinzie, Player 
  275. 	reach_helicopter = { cell_name = "m14_reach_helicopter", handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { M14_2d_personas.kinzie }, player_speaks = true, recieving = false }, 
  276.  
  277. 	-- Kinzie, Player 
  278. 	first_antenna = { cell_name = "m14_first_antenna", handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { M14_2d_personas.kinzie }, player_speaks = true, recieving = false }, 
  279. 	 
  280. 	-- Player, Shaundi  
  281. 	first_rooftop = { convo_name = "M14_First_Rooftop", handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { }, player_speaks = true }, 
  282. 	 
  283. 	-- Kinzie, Player 
  284. 	second_antenna = { cell_name = "m14_second_antenna", handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { M14_2d_personas.kinzie }, player_speaks = true, recieving = false }, 
  285. 	 
  286. 	-- Player, Shaundi 
  287. 	second_rooftop = { convo_name = "M14_Second_Rooftop", handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { }, player_speaks = true }, 
  288.  
  289. 	-- Kinzie, Player 
  290. 	target_van = { cell_name = "m14_target_van", handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { M14_2d_personas.kinzie }, player_speaks = true, recieving = true }, 
  291. 	 
  292. 	van_escaping = { persona_2d_params = { "M14_Too_Far_Away_From_Van" }, handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { M14_2d_personas.kinzie } }, 
  293. 	 
  294. 	spooked_van = { persona_2d_params = { "M14_Spooked_News_Van" }, handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { M14_2d_personas.shaundi } }, 
  295.  
  296. 	-- Kinzie, Player 
  297. 	got_location = { cell_name = "m14_got_location", handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { M14_2d_personas.kinzie }, player_speaks = true, recieving = true }, 
  298.  
  299. 	-- Shaundi, Player 
  300. 	land_on_office = { convo_name = "m14_land_on_office", handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { }, player_speaks = true }, 
  301.  
  302. 	-- Shaundi, Player 
  303. 	enter_office = { convo_name = "m14_enter_office", handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { M14_2d_personas.shaundi }, player_speaks = true }, 
  304. 	 
  305. 	-- Jane, Player 
  306. 	question_jane = { convo_name = "m14_question_jane", handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { M14_2d_personas.anna }, player_speaks = true }, 
  307.  
  308. 	-- Shaundi, Anna 
  309. 	anna_thanks = { convo_name = "m14_anna_thanks", handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { M14_2d_personas.anna, M14_2d_personas.shaundi }, player_speaks = false }, 
  310.  
  311. 	-- Shaundi, Player 
  312. 	go_after_killbane = { convo_name = "m14_go_after_killbane", handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { }, player_speaks = true }, 
  313. 	 
  314. 	-- player, shaundi 
  315. 	helecopter_end = { convo_name = "M14_End_Heli_Convo", handle = INVALID_CONVERSATION_HANDLE, speakers_2d = { }, player_speaks = true }, 
  316. } 
  317.  
  318. --M14_CHECKPOINT_MISSION_START = MISSION_START_CHECKPOINT, -- defined in ug_lib.lua 
  319. M14_CHECKPOINT_GET_TO_HELI = "heli" 
  320. M14_CHECKPOINT_TOWER1_COMPLETE = "t1" 
  321. M14_CHECKPOINT_TOWER2_COMPLETE = "t2" 
  322. M14_CHECKPOINT_TARGET_VAN_COMPLETE = "van" 
  323. M14_CHECKPOINT_GET_TO_STUDIO = "studio" 
  324.  
  325. -- the global timer for each checkpoint 
  326. M14_mission_start_time = 16 
  327. M14_checkpoint_time_get_to_heli = 15 
  328. M14_checkpoint_time_tower1_complete = 12 
  329. M14_checkpoint_time_tower2_complete = 8 
  330. M14_checkpoint_time_target_van_complete = 6 
  331. M14_checkpoint_time_get_to_studio = 5 
  332. 	 
  333. M14_cutscene = { 
  334. 	mission_intro = "14_in", 
  335. 	mission_outro = "14_out", 
  336. } 
  337.  
  338.  
  339. -- ************************* 
  340. -- 
  341. -- Standard functions 
  342. -- 
  343. -- *************************//sr3/main/sr3/data/levels/sr3_city/missions/m14.lua 
  344.  
  345.  
  346.  
  347.  
  348.  
  349. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  350. -- at the specified checkpoint. 
  351. -- CALLED FROM CODE 
  352. -- 
  353. -- m14_checkpoint:	The checkpoint the mission should begin at 
  354. -- is_restart:			TRUE if the mission is restarting, FALSE otherwise 
  355. -- 
  356. function m14_start(m14_checkpoint, is_restart) 
  357. 	-- Make sure the screen is completly faded out 
  358. 	mission_start_fade_out(0.0) 
  359.  
  360. 	-- Check if this mission starting from the beginning 
  361. 	if m14_checkpoint == MISSION_START_CHECKPOINT then 
  362. 		m14_initialize_smiling_jacks() 
  363. 		 
  364. 		if is_restart == false then 
  365. 			cutscene_play(M14_cutscene.mission_intro, nil, { M14_navpoint.cp_sj_lp, M14_navpoint.cp_sj_rp } ) 
  366. 		else 
  367. 			teleport_coop( M14_navpoint.cp_sj_lp, M14_navpoint.cp_sj_rp ) 
  368. 		end 
  369.  
  370. 		m14_initialize_smiling_jacks_post() 
  371. 	end 
  372.  
  373. 	-- Handle mission initialization for the current checkpoint 
  374. 	m14_initialize(m14_checkpoint) 
  375.  
  376. 	-- Run the mission from the current checkpoint 
  377. 	m14_run(m14_checkpoint) 
  378. 	 
  379. end 
  380.  
  381. -- This is the primary function responsible for running the entire mission from start to finish. 
  382. -- 
  383. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  384. -- 
  385. function m14_run(first_checkpoint) 
  386. 	local current_checkpoint = first_checkpoint 
  387.  
  388. 	local ignore_vehicles = true 
  389. 	local ignore_notoriety = true 
  390.  
  391. 	-- Start a thread that will do constant validation of failure conditions 
  392. --	M14_thread.failure_validation = thread_new("m14_failure_validation_thread") 
  393.  
  394. 	-- Run the mission from the beginning 
  395. 	if (current_checkpoint == MISSION_START_CHECKPOINT) then 
  396. 		hud_timer_set(M14_TIMER_INDEX, M14_mission_start_time * 60 * 1000, "m14_timer_validation_fail_cb") 
  397. 		 
  398. 		m14_objective_go_to_heli_smiling_jacks() 
  399.  
  400. 		current_checkpoint = M14_CHECKPOINT_GET_TO_HELI 
  401. 		mission_set_checkpoint(M14_CHECKPOINT_GET_TO_HELI, ignore_vehicles, ignore_notoriety) 
  402. 	end 
  403.  
  404. 	if (current_checkpoint == M14_CHECKPOINT_GET_TO_HELI) then 
  405. 		M14_thread.abandon_heli  = thread_new( "m14_abandon_heli_thread" ) 
  406. 		m14_objective_go_to_first_tower() 
  407. 		m14_objective_plant_first_transmitter() 
  408. 		m14_objective_get_in_heli_first_tower() 
  409. 		 
  410. 		current_checkpoint = M14_CHECKPOINT_TOWER1_COMPLETE 
  411. 		mission_set_checkpoint(M14_CHECKPOINT_TOWER1_COMPLETE, ignore_vehicles, ignore_notoriety) 
  412. 	end 
  413.  
  414. 	if (current_checkpoint == M14_CHECKPOINT_TOWER1_COMPLETE) then 
  415. 		m14_objective_go_to_second_tower() 
  416. 		m14_objective_plant_second_transmitter() 
  417. 		m14_objective_get_in_heli_second_tower() 
  418. 		 
  419. 		current_checkpoint = M14_CHECKPOINT_TOWER2_COMPLETE 
  420. 		mission_set_checkpoint(M14_CHECKPOINT_TOWER2_COMPLETE, ignore_vehicles, ignore_notoriety) 
  421. 	end 
  422. 	 
  423. 	if (current_checkpoint == M14_CHECKPOINT_TOWER2_COMPLETE) then 
  424. 		m14_objective_target_the_van() 
  425. 		 
  426. 		current_checkpoint = M14_CHECKPOINT_TARGET_VAN_COMPLETE 
  427. 		mission_set_checkpoint(M14_CHECKPOINT_TARGET_VAN_COMPLETE, ignore_vehicles, ignore_notoriety) 
  428. 	end 
  429. 		 
  430. 	if current_checkpoint == M14_CHECKPOINT_TARGET_VAN_COMPLETE then 
  431. 		m14_objective_go_to_interview() 
  432. 		M14_status.at_tower = true 
  433. 		m14_objective_enter_building() 
  434.  
  435. 		current_checkpoint = M14_CHECKPOINT_GET_TO_STUDIO 
  436. 		mission_set_checkpoint(M14_CHECKPOINT_GET_TO_STUDIO, ignore_vehicles, ignore_notoriety) 
  437. 	end 
  438.  
  439. 	if (current_checkpoint == M14_CHECKPOINT_GET_TO_STUDIO) then 
  440. 		M14_status.at_tower = true 
  441. 		m14_objective_clear_deckers() 
  442. 		m14_objective_talk_to_jane() 
  443. 		m14_objective_get_in_heli_chase_killbane() 
  444. 		M14_status.at_tower = false 
  445. 		m14_objective_catch_killbane() 
  446. 	end 
  447.  
  448. 	mission_end_success("m14", M14_cutscene.mission_outro) 
  449. end 
  450.  
  451. -- This is the primary function responsible for cleaning up the entire mission 
  452. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  453. -- 
  454. function m14_cleanup() 
  455. 	-- Make it early morning, so the sun will rise soon 
  456. 	--set_time_of_day(06, 00) 
  457. 	 
  458. 	radio_global_block( false ) 
  459.  
  460. 	spotlight_heli_laser_enable(false) 
  461.  
  462. 	vehicle_spotlight_cancel( LOCAL_PLAYER, true ) 
  463. 	 
  464. 	if coop_is_active() then 
  465. 		vehicle_spotlight_cancel( REMOTE_PLAYER, true ) 
  466. 	end 
  467.  
  468. 	notoriety_force_no_spawn("luchadores", false) 
  469. 	notoriety_force_no_spawn("deckers", false) 
  470. 	notoriety_force_no_spawn("morningstar", false) 
  471. 	notoriety_force_no_spawn("police", false) 
  472.  
  473. 	if (M14_navpoint.end_local ~= nil) then 
  474. 		teleport(LOCAL_PLAYER, M14_navpoint.end_local, true) 
  475. 		if (coop_is_active()) then 
  476. 			teleport(REMOTE_PLAYER, M14_navpoint.end_remote, true) 
  477. 		end 
  478. 	end 
  479.  
  480. 	-- Just in case these never got cleared 
  481. 	on_vehicle_enter("", LOCAL_PLAYER) 
  482. 	if (coop_is_active()) then 
  483. 		on_vehicle_enter("", REMOTE_PLAYER) 
  484. 	end 
  485. 	 
  486. 	mission_waypoint_remove() 
  487. 	cleanup_threads(M14_thread) 
  488. 	m14_radio_call_in_stop( false ) 
  489. 	m14_cleanup_audio(M14_convo) 
  490. 	hud_timer_stop(M14_TIMER_INDEX) 
  491. 	if (M14_status.target_progress_displayed or M14_status.transmitter_bar_displayed) then 
  492. 		hud_bar_off(M14_PROGRESS_INDEX) 
  493. 		M14_status.target_progress_displayed = false 
  494. 		M14_status.transmitter_bar_displayed = false 
  495. 	end 
  496. 	 
  497. 	m14_interview_kill() 
  498. 	cleanup_callbacks( { M14_char, M14_vehicle } ) 
  499. 	cleanup_groups(M14_group) 
  500. 	call_function_on_each_member(m14_clear_trigger, M14_trigger) 
  501. 	cleanup_spawn_regions(M14_spawn_region) 
  502. 	cleanup_spawn_groups(M14_spawn_group) 
  503. 	 
  504. 	if M14_status.cellphone_call_in_progress ~= nil then 
  505. 		audio_remove_mission_cellphone( M14_status.cellphone_call_in_progress ) 
  506. 	end 
  507. 	 
  508. 	-- clear any residual animation settings if the player 
  509. 	-- quits while planting a transmitter 
  510. 	clear_animation_state( LOCAL_PLAYER ) 
  511. 	player_movement_enable( LOCAL_PLAYER ) 
  512. 	if coop_is_active() then 
  513. 		clear_animation_state( REMOTE_PLAYER ) 
  514. 		player_movement_enable( REMOTE_PLAYER ) 
  515. 	end 
  516. 	 
  517. 	hud_critical_timer_stop() 
  518. 	 
  519. 	m14_cleanup_fake_laser_reticle() 
  520. 	 
  521. 	-- Clean up 2D personas. 
  522. 	for i, persona in pairs(M14_2d_personas) do 
  523. 		audio_persona_remove_2d(persona.handle) 
  524. 		persona.handle = -1 
  525. 	end 
  526. end 
  527.  
  528. -- Called when the mission has ended with success 
  529. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  530. -- 
  531. function m14_success() 
  532. 	m14_coop_skip( ) -- do the stuff we'd do in the skip case 
  533. end 
  534.  
  535.  
  536.  
  537.  
  538.  
  539. -- ************************* 
  540. -- 
  541. -- Local functions 
  542. -- 
  543. -- ************************* 
  544.  
  545.  
  546.  
  547.  
  548.  
  549. -- Initialize the mission for the specified checkpoint 
  550. -- 
  551. -- checkpoint:		Checkpoint to initialize the mission to 
  552. -- 
  553. function m14_initialize(checkpoint) 
  554. 	-- Set the mission author 
  555. 	set_mission_author("Nick Heilmann") 
  556.  
  557. 	-- Common initialization 
  558. 	m14_initialize_common() 
  559.  
  560. 	-- Checkpoint specific initialization 
  561. 	m14_initialize_checkpoint(checkpoint) 
  562.  
  563. 	-- Start fading in  
  564. 	mission_start_fade_in() 
  565.  
  566. end 
  567.  
  568.  
  569.  
  570.  
  571.  
  572. -- *************************************************** 
  573. -- 
  574. -- m14_run Helper Functions 
  575. -- 
  576. -- *************************************************** 
  577.  
  578.  
  579.  
  580.  
  581. --[[ MISSION START / SMILING JACKS ]]-- 
  582.  
  583. function m14_initialize_smiling_jacks() 
  584. 	group_create(M14_group.cp_smiling_jacks, true) 
  585. 	vehicle_car_alarm_enable(M14_vehicle.cp_smiling_jacks, false) 
  586. 	M14_char.shaundi = M14_char.shaundi_sj 
  587. 	M14_vehicle.spotlight_heli = M14_vehicle.cp_sj_spotlight_heli 
  588. end 
  589.  
  590. function m14_initialize_smiling_jacks_post() 
  591. 	party_add(M14_char.shaundi) 
  592. 	follower_set_can_abandon(M14_char.shaundi, true) 
  593. 	on_dismiss("m14_shaundi_dismissed_cb", M14_char.shaundi) 
  594. 	on_vehicle_destroyed("m14_spotlight_heli_destroyed_cb", M14_vehicle.spotlight_heli) 
  595. 	on_death("m14_shaundi_died_cb", M14_char.shaundi) 
  596. 	radio_block( M14_vehicle.spotlight_heli, true ) 
  597. 	group_show( M14_group.cp_smiling_jacks ) 
  598.  
  599. 	-- Intro animations 
  600. 	-- Player(s) look cool GO! 
  601. 	local anim_name = "M10 Player Mission Start" 
  602. 	local morph_name = "M10 Player Mission Start" 
  603. 	local force_play = false 
  604. 	local stand_still = false 
  605. 	local zero_movement = false 
  606. 	action_play_non_blocking(LOCAL_PLAYER, anim_name, morph_name, force_play, stand_still, zero_movement) 
  607. 	player_script_controlled_clear(LOCAL_PLAYER)	-- let player escape this animation 
  608. 	if (coop_is_active()) then 
  609. 		action_play_non_blocking(REMOTE_PLAYER, anim_name, morph_name, force_play, stand_still, zero_movement) 
  610. 		player_script_controlled_clear(REMOTE_PLAYER)	-- let player escape this animation 
  611. 	end 
  612. end 
  613.  
  614. function m14_objective_go_to_heli_smiling_jacks() 
  615. 	m14_objective_text(0, M14_text.go_to_heli, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  616.  
  617. 	M14_status.do_timer_validation = false 
  618. 	 
  619. 	-- Play Kinzie's mission start persona line 
  620. 	m14_cellphone_call_wait( "M14_Mission_Start", true, M14_2d_personas.kinzie.handle ) 
  621.  
  622. 	marker_add(M14_navpoint.sj_spotlight_heli, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL) 
  623. 	mission_waypoint_add(M14_navpoint.sj_spotlight_heli) 
  624. 	 
  625. 	-- if player gets into car before they arrive at the heli 
  626. 	-- they get to hear the first interview segment 
  627. 	local interview_1_played = false 
  628. 	while true do 
  629. 		local player_in_any_veh = character_is_in_vehicle( LOCAL_PLAYER )  
  630. 		-- if player is near heli and not in vehicle we are done 
  631. 		if player_in_any_veh == false and get_dist( LOCAL_PLAYER, M14_vehicle.spotlight_heli ) < 60 then 
  632. 			break 
  633. 		end 
  634. 		 
  635. 		-- if player enters vehicle the play interview 1 
  636. 		if interview_1_played == false and player_in_any_veh == true then 
  637. 			m14_convo_play( M14_convo.drive_01, true ) 
  638. 			delay( 1 ) 
  639. 			m14_interview_play( "m14_interview_part1", "#PLAYER1_VEHICLE#" ) 
  640. 			interview_1_played = true 
  641. 		end 
  642. 		 
  643. 		thread_yield() 
  644. 	end 
  645.  
  646. 	m14_cleanup_audio( M14_convo ) 
  647. 	m14_convo_play( M14_convo.drive_02 ) 
  648. 	 
  649. 	m14_objective_text_clear(0) 
  650.  
  651. 	m14_objective_text(0, M14_text.get_in_heli, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  652.  
  653. 	m14_wait_for_player_to_enter_vehicle() 
  654. 	 
  655. 	M14_status.do_timer_validation = true 
  656.  
  657. 	marker_remove( M14_navpoint.sj_spotlight_heli ) 
  658. 	mission_waypoint_remove() 
  659. 	m14_objective_text_clear(0) 
  660.  
  661. 	-- heli reached convo 
  662. 	m14_cleanup_audio( M14_convo ) 
  663. 	m14_convo_play( M14_convo.reach_helicopter, true ) 
  664. end 
  665.  
  666. --[[ HELI ]]-- 
  667.  
  668. function m14_initialize_heli() 
  669. 	teleport(LOCAL_PLAYER, M14_navpoint.cp_heli_lp, true) 
  670. 	if (coop_is_active()) then 
  671. 		teleport(REMOTE_PLAYER, M14_navpoint.cp_heli_rp, true) 
  672. 	end 
  673.  
  674. 	group_create(M14_group.cp_heli, true) 
  675. 	M14_char.shaundi = M14_char.shaundi_heli 
  676. 	M14_vehicle.spotlight_heli = M14_vehicle.cp_heli_spotlight_heli 
  677. 	party_add(M14_char.shaundi) 
  678. 	follower_set_can_abandon(M14_char.shaundi, true) 
  679. 	on_dismiss("m14_shaundi_dismissed_cb", M14_char.shaundi) 
  680. 	on_vehicle_destroyed("m14_spotlight_heli_destroyed_cb", M14_vehicle.spotlight_heli) 
  681. 	on_death("m14_shaundi_died_cb", M14_char.shaundi) 
  682.  
  683. 	-- Since the first objective ends after you enter the heli, we need to put you in it now 
  684. 	vehicle_enter_teleport(LOCAL_PLAYER, M14_vehicle.spotlight_heli, VEHICLE_SEAT_DRIVER, true) 
  685. 	vehicle_enter_teleport(M14_char.shaundi, M14_vehicle.spotlight_heli, VEHICLE_SEAT_PASSENGER, true) 
  686. 	if (coop_is_active()) then 
  687. 		vehicle_enter_teleport(REMOTE_PLAYER, M14_vehicle.spotlight_heli, VEHICLE_SEAT_HELI_BACK_DOOR, true) 
  688. 	end 
  689. 	 
  690. 	hud_timer_set(M14_TIMER_INDEX, M14_checkpoint_time_get_to_heli * 60 * 1000, "m14_timer_validation_fail_cb") 
  691. end 
  692.  
  693. function m14_objective_go_to_first_tower() 
  694. 	m14_objective_text(0, M14_text.go_to_tower, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  695.  
  696. 	m14_interview_play( "m14_interview_part2" ) 
  697.  
  698. 	M14_status.helipad_reached = false 
  699.  
  700. 	-- We'll set the whole validation trigger to go off if they get out of their vehicle while in it, but put the marker on the helipad 
  701. 	m14_set_helipad_trigger(M14_trigger.tower1_heli_validation, nil, M14_navpoint.t1_helipad, true, true, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION) 
  702.  
  703. 	-- Then spawn the Deckers defending the tower 
  704. 	group_create(M14_group.t1_small.name, true) 
  705. 	group_create(M14_group.deckers_t1_1.name, true) 
  706. 	 
  707. 	for i, n in pairs( M14_group.t1_small.chars ) do 
  708. 			on_attack_performed( "m14_on_attack_performed_cb", n ) 
  709. 	end 
  710.  
  711. 	for i, n in pairs( M14_group.deckers_t1_1.chars ) do 
  712. 			on_attack_performed( "m14_on_attack_performed_cb", n ) 
  713. 	end 
  714.  
  715. 	-- wait until the heli is in the trigger and one of the players gets out 
  716. 	local in_trigger = false 
  717. 	local has_been_in_trigger = false 
  718. 	local local_player_in_heli = true 
  719. 	local remote_player_in_heli = true 
  720. 	local kinzi_convo_played = false 
  721. 	while true do 
  722. 		in_trigger = object_is_in_trigger( M14_trigger.tower1_heli_validation, M14_vehicle.spotlight_heli ) 
  723. 		 
  724. 		if in_trigger then 
  725. 			if has_been_in_trigger == false then 
  726. 				-- guards... attack! 
  727. 				for i,npc in pairs(M14_char.t1_small) do 
  728. 					ai_add_enemy_target(npc, LOCAL_PLAYER, ATTACK_ON_SIGHT) 
  729. 					if (coop_is_active()) then 
  730. 						ai_add_enemy_target(npc, REMOTE_PLAYER, ATTACK_ON_SIGHT) 
  731. 					end 
  732. 				end 
  733. 				 
  734. 				-- if radio spot is over play kinzie convo 
  735. 				if audio_is_playing( M14_status.interview_audio_id ) == false then 
  736. 					m14_convo_play( M14_convo.first_antenna ) 
  737. 					m14_convo_play( M14_convo.first_rooftop ) 
  738. 					kinzi_convo_played = true 
  739. 				end 
  740.  
  741. 				has_been_in_trigger = true 
  742. 			end 
  743. 		 
  744. 			local_player_in_heli = character_is_in_vehicle( LOCAL_PLAYER, M14_vehicle.spotlight_heli  ) 
  745. 			 
  746. 			remote_player_in_heli = true 
  747. 			 
  748. 			if coop_is_active() then 
  749. 				remote_player_in_heli = character_is_in_vehicle( REMOTE_PLAYER, M14_vehicle.spotlight_heli ) 
  750. 			end 
  751. 			 
  752. 			if in_trigger == true then 
  753. 				if local_player_in_heli == false or remote_player_in_heli == false then 
  754. 					break 
  755. 				end 
  756. 			end 
  757. 		end 
  758. 		 
  759. 		thread_yield() 
  760. 	end 
  761. 	 
  762. 	m14_helipad_reached_cb( nil, M14_trigger.tower1_heli_validation ) 
  763. 	 
  764. 	-- kick off the kinzi convo if it wasn't already played 
  765. 	if kinzi_convo_played == false then 
  766. 		m14_interview_kill() 
  767. 		m14_convo_play( M14_convo.first_antenna ) 
  768. 		m14_convo_play( M14_convo.first_rooftop ) 
  769. 	end 
  770.  
  771. 	M14_status.do_tower1_validation = true 
  772. 	M14_status.do_timer_validation = false 
  773.  
  774. 	thread_kill(M14_thread.surprise_for_you) 
  775. 	M14_thread.surprise_for_you = INVALID_THREAD_HANDLE 
  776. 	M14_status.placement_nav = M14_navpoint.tower_one_placement 
  777.  
  778. 	M14_status.transmitter_placed = false 
  779. 	M14_status.transmitter_progress = 0 
  780. 	trigger_set_hold_to_repeat( M14_trigger.tower1, true ) 
  781. 	m14_set_trigger(M14_trigger.tower1, "m14_transmitter_placement_started_cb", true, true, MINIMAP_ICON_USE, OI_ASSET_USE) 
  782.  
  783. 	m14_objective_text_clear(0) 
  784. end 
  785.  
  786. function m14_objective_plant_first_transmitter() 
  787. 	m14_objective_text(0, M14_text.plant_transmitter, nil, nil, SYNC_ALL, OI_ASSET_USE) 
  788. 	M14_status.transmitter_bar_displayed = true 
  789. 	M14_status.at_tower = true 
  790. 	 
  791. 	trigger_enable(M14_trigger.t1_massacre, true) 
  792. 	on_trigger( "m14_studio_massacre_cb", M14_trigger.t1_massacre )   
  793.  
  794. 	-- Spawn the second group of guys after a few seconds 
  795. 	delay(3) 
  796. 	group_create(M14_group.deckers_t1_2.name, false) 
  797.  
  798. 	local line_played = false 
  799. 	repeat 
  800. 		thread_yield() 
  801. 		 
  802. 		if line_played == false and M14_status.transmitter_progress > 0 then 
  803. 			if m14_convo_is_playing() == false then 
  804. 				audio_play_persona_line( M14_status.transmitter_activator,  "M14_Placing_First_Transmitter" ) 
  805. 			end 
  806. 			 
  807. 			line_played = true 
  808. 		end 
  809. 	until M14_status.transmitter_placed 
  810. 	 
  811. 	audio_ambient_emitter_start( "transmitter_1" ) 
  812.  
  813. 	M14_status.transmitter_bar_displayed = false 
  814. 	hud_bar_off(M14_PROGRESS_INDEX) 
  815. end 
  816.  
  817. function m14_objective_get_in_heli_first_tower() 
  818. 	m14_objective_text(0, M14_text.get_in_heli, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  819.  
  820. 	marker_add(M14_vehicle.spotlight_heli, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL) 
  821.  
  822. 	-- Start the timer validation now, in case the helicopter is somehow unreachable, yet within the validation trigger 
  823. 	M14_status.do_timer_validation = true 
  824.  
  825. 	m14_wait_for_player_to_enter_vehicle() 
  826.  
  827. 	M14_status.do_tower1_validation = false 
  828.  
  829. 	marker_remove(M14_vehicle.spotlight_heli) 
  830.  
  831. 	m14_objective_text_clear(0) 
  832. 	M14_status.at_tower = false 
  833. 	trigger_enable(M14_trigger.t1_massacre, false) 
  834. 	on_trigger( "", M14_trigger.t1_massacre )   
  835. end 
  836.  
  837. --[[ TOWER 1 ]]-- 
  838.  
  839. function m14_initialize_tower1() 
  840. 	teleport(LOCAL_PLAYER, M14_navpoint.cp_tower1_lp, true) 
  841. 	if (coop_is_active()) then 
  842. 		teleport(REMOTE_PLAYER, M14_navpoint.cp_tower1_rp, true) 
  843. 	end 
  844. 	 
  845. 	 group_create(M14_group.cp_tower1, true) 
  846. 	M14_char.shaundi = M14_char.shaundi_t1 
  847. 	M14_vehicle.spotlight_heli = M14_vehicle.cp_t1_spotlight_heli 
  848. 	party_add(M14_char.shaundi) 
  849. 	follower_set_can_abandon(M14_char.shaundi, true) 
  850. 	on_dismiss("m14_shaundi_dismissed_cb", M14_char.shaundi) 
  851. 	on_vehicle_destroyed("m14_spotlight_heli_destroyed_cb", M14_vehicle.spotlight_heli) 
  852. 	on_death("m14_shaundi_died_cb", M14_char.shaundi) 
  853. 	radio_block( M14_vehicle.spotlight_heli, true ) 
  854.  
  855. 	-- Since the previous objective ends after you enter the heli, we need to put you in it now 
  856. 	vehicle_enter_teleport(LOCAL_PLAYER, M14_vehicle.spotlight_heli, VEHICLE_SEAT_DRIVER, true) 
  857. 	vehicle_enter_teleport(M14_char.shaundi, M14_vehicle.spotlight_heli, VEHICLE_SEAT_PASSENGER, true) 
  858. 	 
  859. 	if (coop_is_active()) then 
  860. 		vehicle_enter_teleport(REMOTE_PLAYER, M14_vehicle.spotlight_heli, VEHICLE_SEAT_HELI_BACK_DOOR, true) 
  861. 	end 
  862.  
  863. 	hud_timer_set(M14_TIMER_INDEX, M14_checkpoint_time_tower1_complete * 60 * 1000, "m14_timer_validation_fail_cb") 
  864. end 
  865.  
  866. function m14_objective_go_to_second_tower() 
  867. 	m14_objective_text(0, M14_text.go_to_tower, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  868. 	 
  869. 	m14_interview_play( "m14_interview_part3" ) 
  870.  
  871. 	M14_status.helipad_reached = false 
  872. 	m14_set_helipad_trigger(M14_trigger.tower2_heli_validation, nil, M14_navpoint.t2_helipad, true, true, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION) 
  873.  
  874. 	-- Wait until the player gets near the vicinity of the second tower 
  875. 	repeat 
  876. 		thread_yield() 
  877. 	until (get_dist_closest_player_to_object(M14_navpoint.t2_helipad) < 25) 
  878.  
  879. 	m14_convo_play( M14_convo.second_antenna ) 
  880. 	m14_convo_play( M14_convo.second_rooftop ) 
  881.  
  882. 	group_create(M14_group.t2_small.name, true) 
  883. 	 
  884. 	for i, n in pairs( M14_group.t2_small.chars ) do 
  885. 			on_attack_performed( "m14_on_attack_performed_cb", n ) 
  886. 	end 
  887.  
  888. 	-- wait until the heli is in the trigger and one of the players gets out 
  889. 	local in_trigger = false 
  890. 	local has_been_in_trigger = false 
  891. 	local local_player_in_heli = true 
  892. 	local remote_player_in_heli = true 
  893. 	while true do 
  894. 		in_trigger = object_is_in_trigger( M14_trigger.tower2_heli_validation, M14_vehicle.spotlight_heli ) 
  895. 		 
  896. 		if in_trigger then 
  897. 			if has_been_in_trigger == false then 
  898. 				-- Then spawn the Deckers defending the tower 
  899. 				continuous_spawn_regions_enable(M14_spawn_region.deckers_t2, true) 
  900. 				--m14_continuous_spawns_start(M14_spawn_group.deckers_t2, 3, 3) 
  901. 				call_function_on_each_member(continuous_spawn_start, M14_spawn_group.deckers_t2, 2, 2) 
  902. 				 
  903. 				has_been_in_trigger = true 
  904. 			end 
  905. 		 
  906. 			local_player_in_heli = character_is_in_vehicle( LOCAL_PLAYER, M14_vehicle.spotlight_heli  ) 
  907. 			 
  908. 			remote_player_in_heli = true 
  909. 			 
  910. 			if coop_is_active() then 
  911. 				remote_player_in_heli = character_is_in_vehicle( REMOTE_PLAYER, M14_vehicle.spotlight_heli ) 
  912. 			end 
  913. 			 
  914. 			if in_trigger == true then 
  915. 				if local_player_in_heli == false or remote_player_in_heli == false then 
  916. 					break 
  917. 				end 
  918. 			end 
  919. 		end 
  920. 		 
  921. 		thread_yield() 
  922. 	end 
  923. 	 
  924. 	m14_helipad_reached_cb( nil, M14_trigger.tower2_heli_validation ) 
  925.  
  926. 	M14_status.do_tower2_validation = true 
  927. 	M14_status.do_timer_validation = false 
  928. 	M14_status.placement_nav = M14_navpoint.tower_two_placement 
  929.  
  930. 	M14_status.transmitter_placed = false 
  931. 	M14_status.transmitter_progress = 0 
  932. 	trigger_set_hold_to_repeat( M14_trigger.tower2, true ) 
  933. 	m14_set_trigger(M14_trigger.tower2, "m14_transmitter_placement_started_cb", true, true, MINIMAP_ICON_USE, OI_ASSET_USE) 
  934.  
  935. 	m14_objective_text_clear(0) 
  936. end 
  937.  
  938. function m14_objective_plant_second_transmitter() 
  939. 	m14_objective_text(0, M14_text.plant_transmitter, nil, nil, SYNC_ALL, OI_ASSET_USE) 
  940. 	M14_status.transmitter_bar_displayed = true 
  941. 	M14_status.at_tower = true 
  942.  
  943. 	trigger_enable(M14_trigger.t2_massacre, true) 
  944. 	on_trigger( "m14_studio_massacre_cb", M14_trigger.t2_massacre )   
  945.  
  946. 	local line_played = false 
  947. 	repeat 
  948. 		if line_played == false and M14_status.transmitter_progress > 0 then 
  949. 			if m14_convo_is_playing() ~= true then 
  950. 				audio_play_persona_line( M14_status.transmitter_activator,  "M14_Placing_Second_Transmitter" ) 
  951. 			end 
  952. 			 
  953. 			line_played = true 
  954. 		end 
  955. 		 
  956. 		thread_yield() 
  957. 	until M14_status.transmitter_placed 
  958. 	 
  959. 	audio_ambient_emitter_start( "transmitter_2" ) 
  960.  
  961. 	call_function_on_each_member(continuous_spawn_stop, M14_spawn_group.deckers_t2) 
  962. 	continuous_spawn_regions_enable(M14_spawn_region.deckers_t2, false) 
  963.  
  964. 	M14_status.transmitter_bar_displayed = false 
  965. 	hud_bar_off(M14_PROGRESS_INDEX) 
  966. end 
  967.  
  968. function m14_objective_get_in_heli_second_tower() 
  969. 	-- create some more enemies 
  970. 	group_create( M14_group.deckers_t2_4.name, false ) 
  971.  
  972. 	m14_objective_text(0, M14_text.get_in_heli, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  973. 	 
  974. 	marker_add(M14_vehicle.spotlight_heli, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL) 
  975.  
  976. 	spotlight_heli_laser_enable(true) 
  977.  
  978. 	-- Start the timer validation now, in case the helicopter is somehow unreachable, yet within the validation trigger 
  979. 	M14_status.do_timer_validation = true 
  980.  
  981. 	m14_convo_play( M14_convo.target_van ) 
  982.  
  983. 	m14_wait_for_player_to_enter_vehicle() 
  984. 	 
  985. 	M14_status.do_tower2_validation = false 
  986.  
  987. 	marker_remove(M14_vehicle.spotlight_heli) 
  988.  
  989. 	m14_objective_text_clear(0) 
  990. 	M14_status.at_tower = false 
  991. 	trigger_enable(M14_trigger.t2_massacre, false) 
  992. 	on_trigger( "", M14_trigger.t2_massacre )   
  993. 	 
  994. 	-- wait until convo is done to start radio bit 
  995. 	while m14_convo_is_playing() == true do 
  996. 		thread_yield() 
  997. 	end 
  998.  
  999. 	m14_interview_play( "m14_interview_part4" ) 
  1000. end 
  1001.  
  1002. --[[ TOWER 2 ]]-- 
  1003.  
  1004. function m14_initialize_tower2() 
  1005. 	teleport(LOCAL_PLAYER, M14_navpoint.cp_tower2_lp, true) 
  1006. 	if (coop_is_active()) then 
  1007. 		teleport(REMOTE_PLAYER, M14_navpoint.cp_tower2_rp, true) 
  1008. 	end 
  1009. 	 
  1010. 	spotlight_heli_laser_enable(true) 
  1011. 	 
  1012. 	group_create(M14_group.cp_tower2, true) 
  1013. 	M14_char.shaundi = M14_char.shaundi_t2 
  1014. 	M14_vehicle.spotlight_heli = M14_vehicle.cp_t2_spotlight_heli 
  1015. 	party_add(M14_char.shaundi) 
  1016. 	follower_set_can_abandon(M14_char.shaundi, true) 
  1017. 	on_dismiss("m14_shaundi_dismissed_cb", M14_char.shaundi) 
  1018. 	--teleport_coop(M14_navpoint.cp_tower2_lp, M14_navpoint.cp_tower2_rp, true) 
  1019. 	-- Shaundi should teleport with us since she's in our party 
  1020. 	--teleport(M14_char.shaundi, M14_navpoint.cp_tower2_shaundi, true) 
  1021. 	on_vehicle_destroyed("m14_spotlight_heli_destroyed_cb", M14_vehicle.spotlight_heli) 
  1022. 	on_death("m14_shaundi_died_cb", M14_char.shaundi) 
  1023. 	radio_block( M14_vehicle.spotlight_heli, true ) 
  1024. 	 
  1025. 	-- Since the previous objective ends after you enter the heli, we need to put you in it now 
  1026. 	vehicle_enter_teleport(LOCAL_PLAYER, M14_vehicle.spotlight_heli, VEHICLE_SEAT_DRIVER, true) 
  1027. 	vehicle_enter_teleport(M14_char.shaundi, M14_vehicle.spotlight_heli, VEHICLE_SEAT_PASSENGER, true) 
  1028. 	 
  1029. 	if (coop_is_active()) then 
  1030. 		vehicle_enter_teleport(REMOTE_PLAYER, M14_vehicle.spotlight_heli, VEHICLE_SEAT_HELI_BACK_DOOR, true) 
  1031. 	end 
  1032. 	 
  1033. 	hud_timer_set(M14_TIMER_INDEX, M14_checkpoint_time_tower2_complete * 60 * 1000, "m14_timer_validation_fail_cb") 
  1034. end 
  1035.  
  1036. function m14_objective_target_the_van() 
  1037. 	local obj_target_van = true 
  1038. 	local obj_switch_dist = 110 
  1039. 	local van_fleeing = false 
  1040. 	local target_progress = 0 
  1041. 	local dist, player 
  1042. 	 
  1043. 	-- set up van 
  1044. 	group_create(M14_group.broadcast_van, true) 
  1045. 	on_vehicle_destroyed("m14_broadcast_van_destroyed_cb", M14_vehicle.broadcast_van) 
  1046. 	vehicle_enter_teleport(M14_char.broadcast_van, M14_vehicle.broadcast_van) 
  1047. 	vehicle_set_ambient(M14_vehicle.broadcast_van) 
  1048. 	vehicle_suppress_npc_exit(M14_vehicle.broadcast_van) 
  1049. 	vehicle_infinite_mass( M14_vehicle.broadcast_van ) 
  1050. 	 
  1051. 	spotlight_heli_laser_enable(true) 
  1052. 	spotlight_heli_laser_size( 1 ) 
  1053. 	 
  1054. 	local was_spotted = false 
  1055. 	local target_audio = -1 
  1056. 	 
  1057. 	while target_progress < HUD_BAR_MAX_VALUE do 
  1058. 		-- see if we need to switch the objective due to distance 
  1059. 		dist, player = get_dist_closest_player_to_object(M14_vehicle.broadcast_van) 
  1060. 	 
  1061. 		 
  1062. 		if obj_target_van then 
  1063. 			if dist > obj_switch_dist + 10 then 
  1064. 				-- switch to "approach the van" objective 
  1065. 				hud_bar_off(M14_PROGRESS_INDEX) 
  1066. 				m14_objective_text_clear(0) 
  1067. 				m14_objective_text(0, M14_text.go_to_van, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1068. 				marker_remove(M14_vehicle.broadcast_van) 
  1069. 				marker_add(M14_vehicle.broadcast_van, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL) 
  1070. 	 
  1071. 				-- Remove the fake reticle. 
  1072. 				m14_cleanup_fake_laser_reticle() 
  1073. 				 
  1074. 				if van_fleeing == true and m14_convo_is_playing() == false then 
  1075. 					m14_convo_play( M14_convo.van_escaping ) 
  1076. 				end 
  1077. 			 
  1078. 				obj_target_van = false 
  1079. 			end 
  1080. 		else 
  1081. 			if dist < obj_switch_dist - 10 then 
  1082. 				-- switch to "target the van" objective 
  1083. 				m14_objective_text_clear(0) 
  1084. 				hud_bar_on(M14_PROGRESS_INDEX, "health", M14_text.target_van, HUD_BAR_MAX_VALUE) 
  1085. 				hud_bar_set_value(M14_PROGRESS_INDEX, target_progress) 
  1086. 				marker_remove(M14_vehicle.broadcast_van) 
  1087. 				marker_add(M14_vehicle.broadcast_van, MINIMAP_ICON_USE, OI_ASSET_USE, OI_FLAGS_FULL) 
  1088. 				obj_target_van = true 
  1089. 	 
  1090. 				-- Give the player a fake reticle. 
  1091. 				m14_setup_fake_laser_reticle() 
  1092. 				 
  1093. 				if van_fleeing == false then 
  1094. 					-- the set crazy works, but is a little too fast 
  1095. 					local max_speed = vehicle_get_max_speed(M14_vehicle.broadcast_van) * 0.65 
  1096. 					vehicle_max_speed(M14_vehicle.broadcast_van, max_speed) 
  1097. 					vehicle_flee(M14_vehicle.broadcast_van, player) 
  1098. 					vehicle_set_crazy(M14_vehicle.broadcast_van, true) 
  1099. 					van_fleeing = true 
  1100. 					 
  1101. 					if m14_convo_is_playing() == false then 
  1102. 						m14_convo_play( M14_convo.spooked_van ) 
  1103. 					end 
  1104. 				end 
  1105. 			end 
  1106. 		end 
  1107. 		 
  1108. 		-- see if we need to tick up the target meter 
  1109. 		if obj_target_van then 
  1110. 			local is_spotted = false 
  1111. 			if (coop_is_active() and vehicle_spotlight_is_target_spotted(REMOTE_PLAYER, M14_vehicle.broadcast_van)) then 
  1112. 				target_progress = target_progress + HUD_BAR_STEP_VAN 
  1113. 				is_spotted = true 
  1114. 			elseif (vehicle_spotlight_is_target_spotted(LOCAL_PLAYER, M14_vehicle.broadcast_van)) then 
  1115. 				target_progress = target_progress + HUD_BAR_STEP_VAN 
  1116. 				is_spotted = true 
  1117. 			end 
  1118. 			 
  1119. 			if is_spotted == true and was_spotted == false then 
  1120. 				target_audio = audio_object_post_event( "M14_target_in_range" ) 
  1121. 			elseif is_spotted == false and was_spotted == true then 
  1122. 				audio_object_post_event( "M14_target_in_range_stop" ) 
  1123. 				audio_stop( target_audio ) 
  1124. 				target_audio = -1 
  1125. 			end 
  1126. 			 
  1127. 			was_spotted = is_spotted 
  1128.  
  1129. 			hud_bar_set_value(M14_PROGRESS_INDEX, target_progress) 
  1130. 			spotlight_heli_laser_size( 1 - ( target_progress / 100 ) ) 
  1131. 		end 
  1132. 		 
  1133. 		delay( HUD_BAR_DELAY_VAN ) 
  1134. 	end 
  1135. 	 
  1136. 	if target_audio ~= -1 then 
  1137. 		audio_stop( target_audio ) 
  1138. 	end 
  1139.  
  1140. 	audio_object_post_event( "M14_signal_intercepted" ) 
  1141.  
  1142. 	-- clean up objective 
  1143. 	marker_remove(M14_vehicle.broadcast_van) 
  1144. 	spotlight_heli_laser_enable( false ) 
  1145. 	vehicle_spotlight_cancel( LOCAL_PLAYER ) 
  1146. 	 
  1147. 	-- Remove the fake reticle. 
  1148. 	m14_cleanup_fake_laser_reticle() 
  1149. 	 
  1150. 	if coop_is_active() then 
  1151. 		vehicle_spotlight_cancel( REMOTE_PLAYER ) 
  1152. 	end 
  1153.  
  1154. 	hud_bar_off(M14_PROGRESS_INDEX) 
  1155. 	m14_objective_text_clear(0) 
  1156. 	 
  1157. 	-- make sure call in gets played at proper time 
  1158. 	M14_status.play_radio_call_in = true 
  1159. end 
  1160.  
  1161. function m14_radio_call_in_stop( block ) 
  1162. 	-- kill the thread 
  1163. 	if M14_thread.radio_call_in ~= INVALID_THREAD_HANDLE then 
  1164. 		thread_kill( M14_thread.radio_call_in ) 
  1165. 		 
  1166. 		-- We probably set up an audio failsafe, clear it. 
  1167. 		thread_kill(M14_thread.audio_failsafe) 
  1168. 		M14_thread.audio_failsafe = INVALID_THREAD_HANDLE 
  1169. 	end 
  1170.  
  1171. 	-- if there's a radio event playing, stop that 
  1172. 	if M14_status.radio_event ~= nil then 
  1173. 		audio_stop( M14_status.radio_event ) 
  1174. 		M14_status.radio_event = nil 
  1175. 	end 
  1176. 	 
  1177. 	-- the player may be speaking 
  1178. 	-- there isn't a way to stop that so we'll just 
  1179. 	-- wait for it to play out. 
  1180. 	-- of course we can't do this during clean up 
  1181. 	if block == true then 
  1182. 		m14_wait_for_persona_line_safe(LOCAL_PLAYER) 
  1183. 	end 
  1184. end 
  1185.  
  1186. function m14_radio_call_in_thread() 
  1187. 	local switch_groups = { "Radio_News_Breaks" } 
  1188. 	local switch_ids = { "M14_Interview_Call_In_Part1" } 
  1189. 	M14_status.radio_event = audio_object_post_event("Radio_News_Breaks", switch_groups, switch_ids, LOCAL_PLAYER) 
  1190.  
  1191. 	-- Wait until event is not active 
  1192. 	m14_wait_for_audio_safe(M14_status.radio_event) 
  1193.  
  1194. 	-- play player voice 
  1195. 	audio_play_persona_line(LOCAL_PLAYER, "M14_Radio_Interview_Call_In_02") 
  1196.  
  1197. 	-- wait for player line to finish 
  1198. 	m14_wait_for_persona_line_safe(LOCAL_PLAYER) 
  1199.  
  1200. 	switch_ids = { "M14_Interview_Call_In_Part2" } 
  1201. 	M14_status.radio_event = audio_object_post_event("Radio_News_Breaks", switch_groups, switch_ids, LOCAL_PLAYER) 
  1202.  
  1203. 	-- Wait until event is not active 
  1204. 	m14_wait_for_audio_safe(M14_status.radio_event) 
  1205.  
  1206. 	-- play player voice 
  1207. 	audio_play_persona_line(LOCAL_PLAYER, "M14_Radio_Interview_Call_In_04") 
  1208.  
  1209. 	-- wait for player line to finish 
  1210. 	m14_wait_for_persona_line_safe(LOCAL_PLAYER) 
  1211.  
  1212. 	switch_ids = { "M14_Interview_Call_In_Part3" } 
  1213. 	M14_status.radio_event = audio_object_post_event("Radio_News_Breaks", switch_groups, switch_ids, LOCAL_PLAYER) 
  1214.  
  1215. 	-- Wait until event is not active 
  1216. 	m14_wait_for_audio_safe(M14_status.radio_event) 
  1217.  
  1218. 	-- play player voice 
  1219. 	audio_play_persona_line(LOCAL_PLAYER, "M14_Radio_Interview_Call_In_07") 
  1220.  
  1221. 	-- wait for player line to finish 
  1222. 	m14_wait_for_persona_line_safe(LOCAL_PLAYER) 
  1223.  
  1224. 	switch_ids = { "M14_Interview_Call_In_Part4" } 
  1225. 	M14_status.radio_event = audio_object_post_event("Radio_News_Breaks", switch_groups, switch_ids, LOCAL_PLAYER) 
  1226.  
  1227. 	-- Wait until event is not active 
  1228. 	m14_wait_for_audio_safe(M14_status.radio_event) 
  1229.  
  1230. 	-- play player voice 
  1231. 	audio_play_persona_line(LOCAL_PLAYER, "M14_Radio_Interview_Call_In_10") 
  1232.  
  1233. 	-- wait for player line to finish 
  1234. 	m14_wait_for_persona_line_safe(LOCAL_PLAYER) 
  1235.  
  1236. 	switch_ids = { "M14_Interview_Call_In_Part5" } 
  1237. 	M14_status.radio_event = audio_object_post_event("Radio_News_Breaks", switch_groups, switch_ids, LOCAL_PLAYER) 
  1238.  
  1239. 	-- Wait until event is not active 
  1240. 	m14_wait_for_audio_safe(M14_status.radio_event) 
  1241.  
  1242. 	-- play player voice 
  1243. 	audio_play_persona_line(LOCAL_PLAYER, "M14_Radio_Interview_Call_In_12") 
  1244.  
  1245. 	-- wait for player line to finish 
  1246. 	m14_wait_for_persona_line_safe(LOCAL_PLAYER) 
  1247.  
  1248. 	switch_ids = { "M14_Interview_Call_In_Part6" } 
  1249. 	M14_status.radio_event = audio_object_post_event("Radio_News_Breaks", switch_groups, switch_ids, LOCAL_PLAYER) 
  1250.  
  1251. end 
  1252.  
  1253. function m14_objective_go_to_interview() 
  1254. 	spotlight_heli_laser_enable(false) 
  1255.  
  1256. 	m14_objective_text(0, M14_text.go_to_interview, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1257.  
  1258. 	M14_status.helipad_reached = false 
  1259.  
  1260. 	m14_set_helipad_trigger(M14_trigger.helipad, "m14_helipad_reached_cb", M14_navpoint.interview_helipad, true, true, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION) 
  1261.  
  1262. 	delay(1) 
  1263.  
  1264. 	-- do the player radio call-in in another thread 
  1265. 	if M14_status.play_radio_call_in then 
  1266. 		m14_convo_play(M14_convo.got_location, true) 
  1267. 		M14_thread.radio_call_in = thread_new("m14_radio_call_in_thread") 
  1268. 	end 
  1269.  
  1270. 	-- Wait until the player gets near the vicinity of the helipad 
  1271. 	repeat 
  1272. 		thread_yield() 
  1273. 	until (get_dist_closest_player_to_object(M14_trigger.helipad) < 100) 
  1274. 	 
  1275. 	m14_radio_call_in_stop( true ) 
  1276.  
  1277. 	m14_convo_play( M14_convo.land_on_office ) 
  1278.  
  1279. 	group_create(M14_group.helipad, false) 
  1280. 	 
  1281. 	for i, n in pairs( M14_group.helipad.chars ) do 
  1282. 			on_attack_performed( "m14_on_attack_performed_cb", n ) 
  1283. 	end 
  1284.  
  1285. 	repeat 
  1286. 		thread_yield() 
  1287. 	until (M14_status.helipad_reached) 
  1288.  
  1289. 	trigger_enable(M14_trigger.studio_massacre, true) 
  1290. 	on_trigger("m14_studio_massacre_cb", M14_trigger.studio_massacre) 
  1291.  
  1292. 	M14_status.do_interview_validation = true 
  1293. 	M14_status.do_timer_validation = false 
  1294.  
  1295. 	m14_objective_text_clear(0) 
  1296. end 
  1297.  
  1298. function m14_objective_enter_building() 
  1299. 	m14_objective_text(0, M14_text.enter_building, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1300. 	 
  1301. 	M14_status.interview_stairs_reached = false 
  1302.  
  1303. 	m14_set_trigger(M14_trigger.interview_stairs, "m14_interview_stairs_reached_cb", true, true, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION) 
  1304.  
  1305. 	repeat 
  1306. 		thread_yield() 
  1307. 	until (M14_status.interview_stairs_reached) 
  1308.  
  1309. 	m14_objective_text_clear(0) 
  1310. end 
  1311.  
  1312. --[[ INTERVIEW LOCATION ]]-- 
  1313.  
  1314. function m14_initialize_van() 
  1315. 	teleport(LOCAL_PLAYER, M14_navpoint.cp_studio_lp, true) 
  1316. 	if (coop_is_active()) then 
  1317. 		teleport(REMOTE_PLAYER, M14_navpoint.cp_studio_rp, true) 
  1318. 	end 
  1319. 	 
  1320. 	group_create(M14_group.cp_studio, true) 
  1321. 	M14_char.shaundi = M14_char.shaundi_studio 
  1322. 	M14_vehicle.spotlight_heli = M14_vehicle.cp_studio_spotlight_heli 
  1323.  
  1324. 	party_add(M14_char.shaundi) 
  1325. 	follower_set_can_abandon(M14_char.shaundi, true) 
  1326. 	on_dismiss("m14_shaundi_dismissed_cb", M14_char.shaundi) 
  1327. 	on_vehicle_destroyed("m14_spotlight_heli_destroyed_cb", M14_vehicle.spotlight_heli) 
  1328. 	on_death("m14_shaundi_died_cb", M14_char.shaundi) 
  1329. 	radio_block( M14_vehicle.spotlight_heli, true ) 
  1330.  
  1331. 	teleport_vehicle( M14_vehicle.spotlight_heli, M14_navpoint.cp_van_complete_heli, true ) 
  1332.  
  1333. 	-- Since the previous objective ends after you enter the heli, we need to put you in it now 
  1334. 	vehicle_enter_teleport(LOCAL_PLAYER, M14_vehicle.spotlight_heli, VEHICLE_SEAT_DRIVER, true) 
  1335. 	vehicle_enter_teleport(M14_char.shaundi, M14_vehicle.spotlight_heli, VEHICLE_SEAT_PASSENGER, true) 
  1336. 	 
  1337. 	if (coop_is_active()) then 
  1338. 		vehicle_enter_teleport(REMOTE_PLAYER, M14_vehicle.spotlight_heli, VEHICLE_SEAT_HELI_BACK_DOOR, true) 
  1339. 	end 
  1340. 	 
  1341. 	hud_timer_set(M14_TIMER_INDEX, M14_checkpoint_time_target_van_complete * 60 * 1000, "m14_timer_validation_fail_cb") 
  1342. end 
  1343.  
  1344. function m14_initialize_studio() 
  1345. 	teleport(LOCAL_PLAYER, M14_navpoint.cp_studio_lp, true) 
  1346. 	if (coop_is_active()) then 
  1347. 		teleport(REMOTE_PLAYER, M14_navpoint.cp_studio_rp, true) 
  1348. 	end 
  1349. 	 
  1350. 	group_create(M14_group.cp_studio, true) 
  1351. 	M14_char.shaundi = M14_char.shaundi_studio 
  1352. 	M14_vehicle.spotlight_heli = M14_vehicle.cp_studio_spotlight_heli 
  1353. 	party_add(M14_char.shaundi) 
  1354. 	follower_set_can_abandon(M14_char.shaundi, true) 
  1355. 	on_dismiss("m14_shaundi_dismissed_cb", M14_char.shaundi) 
  1356. 	on_vehicle_destroyed("m14_spotlight_heli_destroyed_cb", M14_vehicle.spotlight_heli) 
  1357. 	on_death("m14_shaundi_died_cb", M14_char.shaundi) 
  1358. 	M14_status.do_interview_validation = true 
  1359. 	M14_status.do_timer_validation = false 
  1360. 	trigger_enable(M14_trigger.studio_massacre, true) 
  1361. 	on_trigger("m14_studio_massacre_cb", M14_trigger.studio_massacre) 
  1362. 	radio_block( M14_vehicle.spotlight_heli, true ) 
  1363.  
  1364. 	hud_timer_set(M14_TIMER_INDEX, M14_checkpoint_time_get_to_studio * 60 * 1000, "m14_timer_validation_fail_cb") 
  1365. end 
  1366.  
  1367. function m14_objective_clear_deckers() 
  1368. 	group_create(M14_group.jane.name, true) 
  1369. 	group_create(M14_group.deckers_studio.name, true) 
  1370. 	 
  1371. 	character_prevent_explosion_fling( M14_char.jane, true ) 
  1372. 	M14_thread.jane_cower = thread_new( "m14_make_jane_cower" ) 
  1373. 	npc_leash_to_nav(M14_char.jane, M14_navpoint.jane_tether, 1) 
  1374. 	set_ignore_ai_flag( M14_char.jane, true ) 
  1375. 	character_prevent_bumping( M14_char.jane, true ) 
  1376. 	character_prevent_flinching( M14_char.jane, true ) 
  1377. 	on_death("m14_jane_died_cb", M14_char.jane) 
  1378. 	set_dont_attack_me_on_sight_flag( M14_char.jane, true ) 
  1379. 	 
  1380. 	m14_convo_play(M14_convo.enter_office, true) 
  1381. 	 
  1382. 	m14_objective_text(0, M14_text.clear_deckers, nil, nil, SYNC_ALL, OI_ASSET_KILL) 
  1383. 	 
  1384. 	M14_status.deckers_alive = 0 
  1385. 	for i,npc in pairs(M14_char.deckers_studio) do 
  1386. 		if (character_exists(npc) and not character_is_dead(npc)) then 
  1387. 			marker_add( npc, MINIMAP_ICON_KILL, OI_ASSET_KILL ) 
  1388. 			on_death("m14_remove_marker_cb", npc) 
  1389. 			M14_status.deckers_alive = M14_status.deckers_alive + 1 
  1390. 			on_attack_performed( "m14_on_attack_performed_cb", npc ) 
  1391. 		end 
  1392. 	end 
  1393.  
  1394. 	repeat 
  1395. 		thread_yield() 
  1396. 	until (M14_status.deckers_alive <= 2) 
  1397.  
  1398. 	--[[ Elevator Group ]]-- 
  1399.  
  1400. 	turn_invulnerable(LOCAL_PLAYER) 
  1401. 	if (coop_is_active()) then 
  1402. 		turn_invulnerable(REMOTE_PLAYER) 
  1403. 	end 
  1404.  
  1405. 	group_create(M14_group.deckers_elevator.name, true) 
  1406.  
  1407. 	for i,npc in pairs(M14_char.deckers_elevator_fs) do 
  1408. 		--teleport(npc, M14_navpoint.deckers_elevator[i]) 
  1409. 		npc_leash_to_nav(npc, M14_navpoint.deckers_elevator[i], 5) 
  1410. 		ai_do_scripted_move(npc, M14_navpoint.deckers_elevator[i], true, false) 
  1411. 		marker_add( npc, MINIMAP_ICON_KILL, OI_ASSET_KILL ) 
  1412. 		on_death("m14_remove_marker_cb", npc) 
  1413. 		M14_status.deckers_alive = M14_status.deckers_alive + 1 
  1414. 		on_attack_performed( "m14_on_attack_performed_cb", npc ) 
  1415. 	end 
  1416.  
  1417. 	for i,npc in pairs(M14_char.deckers_elevator_rb) do 
  1418. 		--teleport(npc, M14_navpoint.deckers_elevator[1]) 
  1419. 		ai_do_scripted_move(npc, M14_navpoint.elevator_rb, true, false) 
  1420. 		marker_add( npc, MINIMAP_ICON_KILL, OI_ASSET_KILL ) 
  1421. 		on_death("m14_remove_marker_cb", npc) 
  1422. 		M14_status.deckers_alive = M14_status.deckers_alive + 1 
  1423. 	end 
  1424.  
  1425. 	turn_vulnerable(LOCAL_PLAYER) 
  1426. 	if (coop_is_active()) then 
  1427. 		turn_vulnerable(REMOTE_PLAYER) 
  1428. 	end 
  1429. 	 
  1430. 	door_open(M14_script_mover.elevator) 
  1431. 	 
  1432. 	repeat 
  1433. 		thread_yield() 
  1434. 	until (M14_status.deckers_alive <= 3) 
  1435.  
  1436. 	--[[ Corner Group ]]-- 
  1437.  
  1438. 	turn_invulnerable(LOCAL_PLAYER) 
  1439. 	if (coop_is_active()) then 
  1440. 		turn_invulnerable(REMOTE_PLAYER) 
  1441. 	end 
  1442.  
  1443. 	group_create(M14_group.deckers_corner.name, true) 
  1444.  
  1445. 	for i,npc in pairs(M14_char.deckers_corner_fs) do 
  1446. 		npc_leash_to_nav(npc, M14_navpoint.deckers_corner[i], 5) 
  1447. 		ai_do_scripted_move(npc, M14_navpoint.deckers_corner[i], true, false) 
  1448. 		marker_add( npc, MINIMAP_ICON_KILL, OI_ASSET_KILL ) 
  1449. 		on_death("m14_remove_marker_cb", npc) 
  1450. 		M14_status.deckers_alive = M14_status.deckers_alive + 1 
  1451. 		on_attack_performed( "m14_on_attack_performed_cb", npc ) 
  1452. 	end 
  1453.  
  1454. 	for i,npc in pairs(M14_char.deckers_corner_rb) do 
  1455. 		ai_do_scripted_move(npc, M14_navpoint.corner_rb, true, false) 
  1456. 		marker_add( npc, MINIMAP_ICON_KILL, OI_ASSET_KILL ) 
  1457. 		on_death("m14_remove_marker_cb", npc) 
  1458. 		M14_status.deckers_alive = M14_status.deckers_alive + 1 
  1459. 		on_attack_performed( "m14_on_attack_performed_cb", npc ) 
  1460. 	end 
  1461.  
  1462. 	delay(1) 
  1463.  
  1464. 	--[[ Side Group ]]-- 
  1465.  
  1466. 	group_create(M14_group.deckers_side.name, true) 
  1467.  
  1468. 	for i,npc in pairs(M14_char.deckers_side_fs) do 
  1469. 		--teleport(npc, M14_navpoint.deckers_side[i]) 
  1470. 		npc_leash_to_nav(npc, M14_navpoint.deckers_side[i], 5) 
  1471. 		ai_do_scripted_move(npc, M14_navpoint.deckers_side[i], true, false) 
  1472. 		marker_add( npc, MINIMAP_ICON_KILL, OI_ASSET_KILL ) 
  1473. 		on_death("m14_remove_marker_cb", npc) 
  1474. 		M14_status.deckers_alive = M14_status.deckers_alive + 1 
  1475. 		on_attack_performed( "m14_on_attack_performed_cb", npc ) 
  1476. 	end 
  1477.  
  1478. 	for i,npc in pairs(M14_char.deckers_side_rb) do 
  1479. 		--teleport(npc, M14_navpoint.deckers_side[1]) 
  1480. 		ai_do_scripted_move(npc, M14_navpoint.side_rb, true, false) 
  1481. 		marker_add( npc, MINIMAP_ICON_KILL, OI_ASSET_KILL ) 
  1482. 		on_death("m14_remove_marker_cb", npc) 
  1483. 		M14_status.deckers_alive = M14_status.deckers_alive + 1 
  1484. 		on_attack_performed( "m14_on_attack_performed_cb", npc ) 
  1485. 	end 
  1486.  
  1487. 	door_open(M14_script_mover.side_door[1]) 
  1488. 	door_open(M14_script_mover.side_door[2]) 
  1489.  
  1490. 	turn_vulnerable(LOCAL_PLAYER) 
  1491. 	if (coop_is_active()) then 
  1492. 		turn_vulnerable(REMOTE_PLAYER) 
  1493. 	end 
  1494.  
  1495. 	repeat 
  1496. 		thread_yield() 
  1497. 	until (M14_status.deckers_alive <= 4) 
  1498.  
  1499. 	--[[ Stairs Group ]]-- 
  1500.  
  1501. 	turn_invulnerable(LOCAL_PLAYER) 
  1502. 	if (coop_is_active()) then 
  1503. 		turn_invulnerable(REMOTE_PLAYER) 
  1504. 	end 
  1505.  
  1506. 	group_create(M14_group.deckers_stairs.name, true) 
  1507.  
  1508. 	for i,npc in pairs(M14_char.deckers_stairs_fs) do 
  1509. 		npc_leash_to_nav(npc, M14_navpoint.deckers_stairs[i], 5) 
  1510. 		ai_do_scripted_move(npc, M14_navpoint.deckers_stairs[i], true, false) 
  1511. 		marker_add( npc, MINIMAP_ICON_KILL, OI_ASSET_KILL ) 
  1512. 		on_death("m14_remove_marker_cb", npc) 
  1513. 		M14_status.deckers_alive = M14_status.deckers_alive + 1 
  1514. 		on_attack_performed( "m14_on_attack_performed_cb", npc ) 
  1515. 	end 
  1516.  
  1517. 	for i,npc in pairs(M14_char.deckers_stairs_rb) do 
  1518. 		ai_do_scripted_move(npc, M14_navpoint.stairs_rb, true, false) 
  1519. 		marker_add( npc, MINIMAP_ICON_KILL, OI_ASSET_KILL ) 
  1520. 		on_death("m14_remove_marker_cb", npc) 
  1521. 		M14_status.deckers_alive = M14_status.deckers_alive + 1 
  1522. 		on_attack_performed( "m14_on_attack_performed_cb", npc ) 
  1523. 	end 
  1524.  
  1525. 	turn_vulnerable(LOCAL_PLAYER) 
  1526. 	if (coop_is_active()) then 
  1527. 		turn_vulnerable(REMOTE_PLAYER) 
  1528. 	end 
  1529.  
  1530. 	repeat 
  1531. 		thread_yield() 
  1532. 	until (M14_status.deckers_alive <= 0) 
  1533.  
  1534. 	clear_animation_state( M14_char.jane ) 
  1535. 	if M14_thread.jane_cower ~= nil then 
  1536. 		thread_kill( M14_thread.jane_cower ) 
  1537. 		M14_thread.jane_cower = nil 
  1538. 	end 
  1539.  
  1540. 	m14_objective_text_clear(0) 
  1541. end 
  1542.  
  1543. function m14_objective_talk_to_jane() 
  1544. 	-- keep Shaundi from attacking anyone 
  1545. 	npc_combat_enable( M14_char.shaundi, false ) 
  1546. 	 
  1547. 	m14_objective_text(0, M14_text.talk_to_jane, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1548.  
  1549. 	marker_add(M14_char.jane, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL) 
  1550.  
  1551. 	local dist, player 
  1552. 	repeat 
  1553. 		thread_yield() 
  1554. 		dist, player = get_dist_closest_player_to_object( M14_char.jane )  
  1555. 	until ( dist < 3 ) 
  1556.  
  1557. 	marker_remove(M14_char.jane) 
  1558.  
  1559. 	m14_objective_text_clear(0) 
  1560. 	 
  1561. 	M14_convo.question_jane.coop_player = player 
  1562. 	M14_convo.go_after_killbane.coop_player = player 
  1563. 	 
  1564. 	m14_convo_play( M14_convo.question_jane, nil, nil ) 
  1565. 	m14_convo_play( M14_convo.go_after_killbane, nil, nil ) 
  1566. 	 
  1567. 	npc_combat_enable( M14_char.shaundi, true ) 
  1568. end 
  1569.  
  1570. function m14_objective_get_in_heli_chase_killbane() 
  1571. 	m14_objective_text(0, M14_text.get_in_heli, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1572.  
  1573. 	M14_status.helipad_reached = false 
  1574.  
  1575. 	m14_set_trigger(M14_trigger.studio_stairs1, "m14_helipad_reached_cb", false, true, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION) 
  1576.  
  1577. 	repeat 
  1578. 		thread_yield() 
  1579. 	until (M14_status.helipad_reached) 
  1580. 	 
  1581. 	M14_status.helipad_reached = false 
  1582. 	m14_set_trigger(M14_trigger.studio_stairs2, "m14_helipad_reached_cb", false, true, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION) 
  1583.  
  1584. 	repeat 
  1585. 		thread_yield() 
  1586. 	until (M14_status.helipad_reached) 
  1587. 	 
  1588. 	M14_status.helipad_reached = false 
  1589. 	m14_set_trigger(M14_trigger.helipad, "m14_helipad_reached_cb", false, true, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION) 
  1590.  
  1591. 	repeat 
  1592. 		thread_yield() 
  1593. 	until (M14_status.helipad_reached) 
  1594.  
  1595. 	marker_add(M14_vehicle.spotlight_heli, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL) 
  1596.  
  1597. 	group_create(M14_group.killbane, true) 
  1598.  
  1599. 	vehicle_enter_teleport(M14_char.killbane, M14_vehicle.killbane_escape) 
  1600. 	vehicle_suppress_npc_exit(M14_vehicle.killbane_escape, true) 
  1601. 	set_unjackable_flag( M14_vehicle.killbane_escape, true ) 
  1602.  
  1603. 	-- Start the timer validation now, in case the helicopter is somehow unreachable, yet within the validation trigger 
  1604. 	M14_status.do_timer_validation = true 
  1605.  
  1606. 	m14_wait_for_player_to_enter_vehicle() 
  1607.  
  1608. 	marker_remove(M14_vehicle.spotlight_heli) 
  1609.  
  1610. 	trigger_enable(M14_trigger.studio_massacre, false) 
  1611. 	on_trigger("", M14_trigger.studio_massacre) 
  1612.  
  1613. 	m14_objective_text_clear(0) 
  1614. end 
  1615.  
  1616. function m14_objective_catch_killbane() 
  1617. 	m14_objective_text(0, M14_text.catch_killbane, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1618.  
  1619. 	M14_thread.killbane_escape = thread_new("m14_wrapper_thread", vehicle_pathfind_to, M14_vehicle.killbane_escape, M14_navpoint.killbane_escape) 
  1620.  
  1621. 	marker_add(M14_vehicle.killbane_escape, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL) 
  1622.  
  1623. 	delay( 5 ) 
  1624. 	 
  1625. 	m14_convo_play( M14_convo.helecopter_end ) 
  1626. 	 
  1627. 	-- finish when close enough and in heli 
  1628. 	if coop_is_active() then 
  1629. 		repeat 
  1630. 			thread_yield()			 
  1631. 			local local_caught_kb = character_is_in_vehicle( LOCAL_PLAYER, M14_vehicle.spotlight_heli ) and get_dist( LOCAL_PLAYER, M14_vehicle.killbane_escape ) < 55 
  1632. 			local remote_caught_kb = character_is_in_vehicle( REMOTE_PLAYER, M14_vehicle.spotlight_heli ) and get_dist( REMOTE_PLAYER, M14_vehicle.killbane_escape ) < 55 
  1633. 		until local_caught_kb or remote_caught_kb 
  1634. 	else 
  1635. 		while character_is_in_vehicle( LOCAL_PLAYER, M14_vehicle.spotlight_heli ) == false or get_dist( LOCAL_PLAYER, M14_vehicle.killbane_escape ) > 55 do 
  1636. 			thread_yield() 
  1637. 		end 
  1638. 	end 
  1639.  
  1640. 	M14_status.do_interview_validation = false 
  1641.  
  1642. 	object_indicator_remove(M14_vehicle.killbane_escape) 
  1643. 	hud_timer_stop(M14_TIMER_INDEX) 
  1644. 	m14_objective_text_clear(0) 
  1645. end 
  1646.  
  1647. -- Waits for an audio event to finish or until a maximum amount of time has elapsed. 
  1648. -- 
  1649. -- audio_id:  (int)             the event to wait for. 
  1650. -- max_wait:  (float, optional) the maximum amount of time to wait. 
  1651. -- 
  1652. function m14_wait_for_audio_safe(audio_id, max_wait) 
  1653. 	if max_wait == nil then 
  1654. 		max_wait = 60.0 
  1655. 	end 
  1656.  
  1657. 	-- Wait for anything that's using the failsafe thread to finish. 
  1658. 	while M14_thread.audio_failsafe ~= INVALID_THREAD_HANDLE do 
  1659. 		thread_yield() 
  1660. 	end 
  1661. 	 
  1662. 	M14_thread.audio_failsafe = thread_new("delay", max_wait) 
  1663. 	 
  1664. 	-- Wait for the audio to finish or for our failsafe to kick in. 
  1665. 	while audio_is_playing(audio_id) and thread_check_done(M14_thread.audio_failsafe) == false do 
  1666. 		thread_yield() 
  1667. 	end 
  1668. 	 
  1669. 	-- If the audio is still playing, kill it. 
  1670. 	if audio_is_playing(audio_id) then 
  1671. 		audio_stop(audio_id) 
  1672. 	end 
  1673. 	 
  1674. 	thread_kill(M14_thread.audio_failsafe) 
  1675. 	M14_thread.audio_failsafe = INVALID_THREAD_HANDLE 
  1676. end 
  1677.  
  1678. -- Waits for a conversation to finish or until a maximum amount of time has elapsed. 
  1679. -- 
  1680. -- convo_handle: (int)             handle to the conversation to wait for. 
  1681. -- max_wait:     (float, optional) the maximum amount of time to wait. 
  1682. -- 
  1683. function m14_wait_for_convo_safe(convo_handle, max_wait) 
  1684. 	if max_wait == nil then 
  1685. 		max_wait = 60.0 
  1686. 	end 
  1687. 	 
  1688. 	-- Wait for anything that's using the failsafe thread to finish. 
  1689. 	while M14_thread.audio_failsafe ~= INVALID_THREAD_HANDLE do 
  1690. 		thread_yield() 
  1691. 	end 
  1692. 	 
  1693. 	M14_thread.audio_failsafe = thread_new("delay", max_wait) 
  1694. 	 
  1695. 	-- Wait for the conversation to finish or for our failsafe to kick in. 
  1696. 	while audio_conversation_playing(convo_handle) and thread_check_done(M14_thread.audio_failsafe) == false do 
  1697. 		thread_yield() 
  1698. 	end 
  1699. 	audio_conversation_end(convo_handle) 
  1700. 	 
  1701. 	thread_kill(M14_thread.audio_failsafe) 
  1702. 	M14_thread.audio_failsafe = INVALID_THREAD_HANDLE 
  1703. end 
  1704.  
  1705. -- Waits for a persona line to finish on a human or until a maximum amount of time has elapsed. 
  1706. -- 
  1707. -- human_name: (string)          name of the human. 
  1708. -- max_wait:   (float, optional) the maximum amount of time to wait. 
  1709. -- 
  1710. function m14_wait_for_persona_line_safe(human_name, max_wait) 
  1711. 	if max_wait == nil then 
  1712. 		max_wait = 30.0 
  1713. 	end 
  1714. 	 
  1715. 	-- Wait for anything that's using the failsafe thread to finish. 
  1716. 	while M14_thread.audio_failsafe ~= INVALID_THREAD_HANDLE do 
  1717. 		thread_yield() 
  1718. 	end 
  1719. 	 
  1720. 	M14_thread.audio_failsafe = thread_new("delay", max_wait) 
  1721. 	 
  1722. 	-- Wait for the conversation to finish or for our failsafe to kick in. 
  1723. 	while audio_persona_line_playing(human_name) and thread_check_done(M14_thread.audio_failsafe) == false do 
  1724. 		thread_yield() 
  1725. 	end 
  1726. 	 
  1727. 	thread_kill(M14_thread.audio_failsafe) 
  1728. 	M14_thread.audio_failsafe = INVALID_THREAD_HANDLE 
  1729. end 
  1730.  
  1731.  
  1732.  
  1733. -- *************************************************** 
  1734. -- 
  1735. -- m14_initialize Helper Functions 
  1736. -- 
  1737. -- *************************************************** 
  1738.  
  1739.  
  1740.  
  1741.  
  1742.  
  1743. -- Handle any common initialization 
  1744. -- 
  1745. function m14_initialize_common() 
  1746. 	-- Always have timer validation when the mission starts 
  1747. 	M14_status.do_timer_validation = true 
  1748.  
  1749. 	notoriety_force_no_spawn("luchadores", true) 
  1750. 	notoriety_force_no_spawn("deckers", true) 
  1751. 	notoriety_force_no_spawn("morningstar", true) 
  1752. 	notoriety_force_no_spawn("police", true) 
  1753. 	 
  1754. 	radio_global_block( true ) 
  1755. 	 
  1756. 	-- Start up the conversation manager. 
  1757. 	M14_thread.convo_manager = thread_new( "m14_convo_manager" ) 
  1758. 	 
  1759. 	-- Load 2D personas. 
  1760. 	for i, persona in pairs(M14_2d_personas) do 
  1761. 		persona.handle = audio_persona_load_2d( persona.name ) 
  1762. 	end 
  1763. end 
  1764.  
  1765. -- Checkpoint specific initialization 
  1766. -- 
  1767. -- checkpoint:		The checkpoint to be initialized 
  1768. -- 
  1769. function m14_initialize_checkpoint(checkpoint) 
  1770. 	if (checkpoint == M14_CHECKPOINT_GET_TO_HELI) then 
  1771. 		m14_initialize_heli() 
  1772. 	elseif (checkpoint == M14_CHECKPOINT_TOWER1_COMPLETE) then 
  1773. 		m14_initialize_tower1() 
  1774. 	elseif (checkpoint == M14_CHECKPOINT_TOWER2_COMPLETE) then 
  1775. 		m14_initialize_tower2() 
  1776. 	elseif checkpoint == M14_CHECKPOINT_TARGET_VAN_COMPLETE then 
  1777. 		m14_initialize_van() 
  1778. 	elseif (checkpoint == M14_CHECKPOINT_GET_TO_STUDIO) then 
  1779. 		m14_initialize_studio() 
  1780. 	end 
  1781. 	 
  1782. 	if checkpoint ~= MISSION_START_CHECKPOINT  and checkpoint ~= M14_CHECKPOINT_GET_TO_HELI then 
  1783. 		M14_thread.abandon_heli  = thread_new( "m14_abandon_heli_thread" ) 
  1784. 	end 
  1785. end 
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791. -- *************************************************** 
  1792. -- 
  1793. -- Miscellaneous m14 Helper Funcrtions 
  1794. -- 
  1795. -- *************************************************** 
  1796.  
  1797.  
  1798.  
  1799.  
  1800.  
  1801. function m14_set_helipad_trigger(trigger, trigger_callback, navpoint, add_waypoint, add_marker, minimap_icon, indicator_id) 
  1802. 	M14_status.proxy_navpoint = navpoint 
  1803.  
  1804. 	trigger_enable(trigger, true) 
  1805. 	 
  1806. 	if (add_waypoint ~= false) then 
  1807. 		mission_waypoint_add(navpoint) 
  1808. 	end 
  1809. 	 
  1810. 	if (add_marker ~= false) then 
  1811. 		if (minimap_icon == nil) then 
  1812. 			minimap_icon = MINIMAP_ICON_LOCATION 
  1813. 		end 
  1814. 		marker_add(navpoint, minimap_icon, indicator_id, OI_FLAGS_FULL) 
  1815. 	end 
  1816.  
  1817. 	if trigger_callback ~= nil then 
  1818. 		on_trigger(trigger_callback, trigger) 
  1819. 	end 
  1820. end 
  1821.  
  1822. -- Set a trigger enabled with a mission marker 
  1823. -- 
  1824. -- trigger:				(string) Name of the trigger 
  1825. -- trigger_callback:	(string) Function name to call when trigger is activated 
  1826. -- add_waypoint:		(bool, optional) true to add a waypoint, false otherwise (defaults to true) 
  1827. -- add_marker:			(bool, optional) true to add a marker, false otherwise (defaults to true) 
  1828. -- minimap_icon:		(enum, optional) name of the minimap icon to add to the trigger 
  1829. -- indicator_id:		(enum, optional) ID of the object indicator to add to the trigger 
  1830. -- 
  1831. function m14_set_trigger(trigger, trigger_callback, add_waypoint, add_marker, minimap_icon, indicator_id) 
  1832. 	trigger_enable(trigger, true) 
  1833. 	 
  1834. 	if (add_waypoint ~= false) then 
  1835. 		mission_waypoint_add(trigger) 
  1836. 	end 
  1837. 	 
  1838. 	if (add_marker ~= false) then 
  1839. 		if (minimap_icon == nil) then 
  1840. 			minimap_icon = MINIMAP_ICON_LOCATION 
  1841. 		end 
  1842. 		marker_add_trigger(trigger, minimap_icon, INGAME_EFFECT_CHECKPOINT, indicator_id, OI_FLAGS_FULL, SYNC_ALL) 
  1843. 	end 
  1844.  
  1845. 	on_trigger(trigger_callback, trigger) 
  1846. end 
  1847.  
  1848. -- Disable trigger 
  1849. -- 
  1850. -- trigger:		(string) Name of the trigger 
  1851. -- 
  1852. function m14_clear_trigger(trigger) 
  1853. 	on_trigger("", trigger) 
  1854. 	trigger_enable(trigger, false) 
  1855. 	marker_remove_trigger(trigger, SYNC_ALL) 
  1856. 	mission_waypoint_remove() 
  1857. end 
  1858.  
  1859. function m14_continuous_spawns_start(spawn_group, num_spawns, delay, callback) 
  1860. 	call_function_on_each_member(continuous_spawn_start, spawn_group, num_spawns, delay, callback) 
  1861. end 
  1862.  
  1863. function m14_continuous_spawns_stop(spawn_group) 
  1864. 	call_function_on_each_member(continuous_spawn_stop, spawn_group) 
  1865. end 
  1866.  
  1867. function m14_wait_for_player_to_enter_vehicle() 
  1868. 	if (coop_is_active()) then 
  1869. 		repeat 
  1870. 			thread_yield() 
  1871. 		until (character_is_in_vehicle(LOCAL_PLAYER, M14_vehicle.spotlight_heli) or character_is_in_vehicle(REMOTE_PLAYER, M14_vehicle.spotlight_heli)) 
  1872. 	else 
  1873. 		repeat 
  1874. 			thread_yield() 
  1875. 		until character_is_in_vehicle(LOCAL_PLAYER, M14_vehicle.spotlight_heli) 
  1876. 	end 
  1877. end 
  1878.  
  1879. function m14_wait_for_players_to_exit_vehicle() 
  1880. 	if (coop_is_active()) then 
  1881. 		while (character_is_in_vehicle(LOCAL_PLAYER, M14_vehicle.spotlight_heli) or character_is_in_vehicle(REMOTE_PLAYER, M14_vehicle.spotlight_heli)) do 
  1882. 			thread_yield() 
  1883. 		end 
  1884. 	else 
  1885. 		while character_is_in_vehicle(LOCAL_PLAYER, M14_vehicle.spotlight_heli) do 
  1886. 			thread_yield() 
  1887. 		end 
  1888. 	end 
  1889. end 
  1890.  
  1891. -- Displays the heli warning objective 
  1892. -- 
  1893. function m14_display_heli_warning_objective() 
  1894. 	if (M14_status.transmitter_bar_displayed or M14_status.target_progress_displayed) then 
  1895. 		hud_bar_off(M14_PROGRESS_INDEX) 
  1896. 	end 
  1897. 	-- The warning message replaces whatever objective we currently have 
  1898. 	objective_text(0, M14_text.get_in_heli, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1899. 	marker_add(M14_vehicle.spotlight_heli, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION) 
  1900. end 
  1901.  
  1902. -- Clears the heli warning objective, and restores the current objective if we have one 
  1903. -- 
  1904. function m14_clear_heli_warning_objective() 
  1905. 	objective_text_clear(0) 
  1906. 	marker_remove(M14_vehicle.spotlight_heli) 
  1907.  
  1908. 	-- There may not be any text currently displayed 
  1909. 	if (M14_objective_text.gsi_index ~= nil) then 
  1910. 		-- Set the objective text back to what it was before the warning went up 
  1911. 		objective_text(M14_objective_text.gsi_index, M14_objective_text.text, M14_objective_text.sub1, M14_objective_text.sub2, M14_objective_text.sync_type, M14_objective_text.oi_asset) 
  1912. 	elseif (M14_status.target_progress_displayed) then 
  1913. 		hud_bar_on(M14_PROGRESS_INDEX, "health", M14_text.target_van, HUD_BAR_MAX_VALUE) 
  1914. 	elseif (M14_status.transmitter_bar_displayed) then 
  1915. 		hud_bar_on(M14_PROGRESS_INDEX, "health", M14_text.plant_transmitter, HUD_BAR_MAX_VALUE) 
  1916. 	end 
  1917. end 
  1918.  
  1919. -- Mission-specific wrapper for objective_text() that saves off the current objective in case the helicopter re-entry warning 
  1920. -- is displayed, to allow it to be restored when the helicopter has been re-entered 
  1921. -- 
  1922. -- gsi_index:	(int) index of the objective to display 
  1923. -- text:			(string) the objective text to display 
  1924. -- sub1:			(string) sub-string to be placed into the string (if the main text has format tags) 
  1925. -- sub2:			(string) sub-string to be placed into the string (if the main text has format tags) 
  1926. -- sync_type:	(enum) SYNC_LOCAL, SYNC_REMOTE, SYNC_ALL 
  1927. -- oi_asset:	(enum) asset to be displayed next to the objective (i.e. OI_ASSET_KILL, OI_ASSET_LOCATION, etc.) 
  1928. -- 
  1929. function m14_objective_text(gsi_index, text, sub1, sub2, sync_type, oi_asset) 
  1930. 	M14_objective_text.gsi_index = gsi_index 
  1931. 	M14_objective_text.text = text 
  1932. 	M14_objective_text.sub1 = sub1 
  1933. 	M14_objective_text.sub2 = sub2 
  1934. 	M14_objective_text.sync_type = sync_type 
  1935. 	M14_objective_text.oi_asset = oi_asset 
  1936. 	-- Only change the objective text if the helicopter re-entry warning isn't currently active 
  1937. 	if (not M14_status.timer_active) then 
  1938. 		objective_text(gsi_index, text, sub1, sub2, sync_type, oi_asset) 
  1939. 	end 
  1940. end 
  1941.  
  1942. -- Mission-specific wrapper for objective_text_clear() that ensures the helicopter re-entry warning isn't cleared accidentally 
  1943. -- 
  1944. -- gsi_index:	(int) index of the objective text to clear 
  1945. -- 
  1946. function m14_objective_text_clear(gsi_index) 
  1947. 	-- If the indices match, we are simply clearing the objective text so that it can be set to something else 
  1948. 	M14_objective_text.gsi_index = nil 
  1949. 	M14_objective_text.text = nil 
  1950. 	M14_objective_text.sub1 = nil 
  1951. 	M14_objective_text.sub2 = nil 
  1952. 	M14_objective_text.sync_type = nil 
  1953. 	M14_objective_text.oi_asset = nil 
  1954. 	-- Only clear the objective text if the helicopter re-entry warning isn't currently active 
  1955. 	if (not M14_status.timer_active) then 
  1956. 		objective_text_clear(gsi_index) 
  1957. 	end 
  1958. end 
  1959.  
  1960. -- ************************* 
  1961. -- 
  1962. -- Callback functions 
  1963. -- 
  1964. -- ************************* 
  1965. function m14_transmitter_placement_started_cb( activator, tower ) 
  1966. 	-- only one at a time please 
  1967. 	if M14_status.transmitter_activator ~= nil and M14_status.transmitter_activator ~= activator then 
  1968. 		return 
  1969. 	end 
  1970. 	 
  1971. 	player_movement_disable( activator ) 
  1972. 	 
  1973. 	local progress = M14_status.transmitter_progress 
  1974.  
  1975. 	if progress == 0 then 
  1976. 		m14_objective_text_clear(0) 
  1977. 		hud_bar_on(M14_PROGRESS_INDEX, "health", M14_text.plant_transmitter, HUD_BAR_MAX_VALUE) 
  1978. 		 
  1979. 		-- wait until player is ready to play an animation 
  1980. 		while character_is_ready( LOCAL_PLAYER ) == false do 
  1981. 			thread_yield() 
  1982. 		end 
  1983.  
  1984. 		M14_status.transmitter_activator = activator 
  1985. 		 
  1986. 		-- Play the intro animation 
  1987. 		if	M14_status.transmitter_started ~= true then 
  1988. 			action_play( activator, "m14 transmitter in", "m14 transmitter in", false, 0.8, true, true, M14_status.placement_nav ) 
  1989. 		end 
  1990. 		 
  1991. 		-- Play the middle section of the animation. 
  1992. 		set_animation_state( activator, "m14 transmitter idle", M14_status.placement_nav ) 
  1993. 	end 
  1994. 	 
  1995. 	if M14_thread.transmitter_monitor == nil then 
  1996. 		M14_thread.transmitter_monitor = thread_new( "m14_maybe_cancel_transmitter_thread" ) 
  1997. 	end 
  1998. 	 
  1999. 	progress = progress + HUD_BAR_STEP_TRANSMITTER 
  2000. 	hud_bar_set_value( M14_PROGRESS_INDEX, progress ) 
  2001.  
  2002. 	if progress >= HUD_BAR_MAX_VALUE then 
  2003. 		player_movement_enable( activator ) 
  2004. 		M14_status.transmitter_placed = true 
  2005. 		M14_status.transmitter_activator = nil 
  2006. 		 
  2007. 		m14_clear_trigger( tower ) 
  2008.  
  2009. 		-- kill the monitor thread, not needed any more 
  2010. 		if M14_thread.transmitter_monitor ~= nil then 
  2011. 			thread_kill( M14_thread.transmitter_monitor ) 
  2012. 			M14_thread.transmitter_monitor = nil 
  2013. 		end 
  2014.  
  2015. 		-- Play the outro animation. 
  2016. 		clear_animation_state( activator ) 
  2017. 		action_play( activator, "m14 transmitter out",  "m14 transmitter out", false, 1, true, true ) 
  2018. 		M14_status.transmitter_started  = nil 
  2019. 	else 
  2020. 		M14_status.transmitter_progress = progress 
  2021. 	end 
  2022. 	 
  2023. 	hud_bar_set_value( M14_PROGRESS_INDEX, progress ) 
  2024. end 
  2025.  
  2026. -- watches for lack of progress in getting the transmitter up 
  2027. -- and cancels if there is none 
  2028. function m14_maybe_cancel_transmitter_thread() 
  2029. 	local prev_progress = M14_status.transmitter_progress 
  2030. 	 
  2031. 	while true do 
  2032. 		delay( 1 ) 
  2033. 		 
  2034. 		if  M14_status.transmitter_progress <= prev_progress then 
  2035. 			-- no progress so break out and kill it 
  2036. 			break 
  2037. 		end 
  2038. 		 
  2039. 		prev_progress = M14_status.transmitter_progress 
  2040. 	end 
  2041. 	 
  2042. 	if M14_status.transmitter_activator ~= nil then 
  2043. 		player_movement_enable( M14_status.transmitter_activator ) 
  2044. 		 
  2045. 		-- remove the triangulator left behind by the anim 
  2046. 		character_remove_child_item_by_name( M14_status.transmitter_activator, "Triangulator" ) 
  2047. 		 
  2048. 		-- Play the outro animation. 
  2049. 		clear_animation_state( M14_status.transmitter_activator ) 
  2050. 	end 
  2051.  
  2052. 	hud_bar_off( M14_PROGRESS_INDEX ) 
  2053. 	m14_objective_text(0, M14_text.plant_transmitter, nil, nil, SYNC_ALL, OI_ASSET_USE) 
  2054. 	 
  2055. 	M14_status.transmitter_progress = 0 
  2056. 	M14_status.transmitter_activator = nil 
  2057. 	hud_bar_set_value( M14_PROGRESS_INDEX, 0 ) 
  2058. 	M14_thread.transmitter_monitor = nil 
  2059. 	M14_status.transmitter_started = true 
  2060. end 
  2061.  
  2062. function m14_studio_massacre_cb(poor_sumbitch) 
  2063. 	if poor_sumbitch == LOCAL_PLAYER or poor_sumbitch == REMOTE_PLAYER then 
  2064. 		mission_end_failure( "m14", M14_text.failure_heli_abandoned ) 
  2065. 	elseif poor_sumbitch ~= nil then 
  2066. 		character_kill(poor_sumbitch, true, nil, false) 
  2067. 	end 
  2068. end 
  2069.  
  2070. function m14_helipad_reached_cb(activator_name, trigger_name) 
  2071. 	m14_clear_trigger(trigger_name) 
  2072. 	mission_waypoint_remove() 
  2073. 	marker_remove(M14_status.proxy_navpoint) 
  2074. 	M14_status.helipad_reached = true 
  2075. end 
  2076.  
  2077. function m14_left_studio_cb() 
  2078. 	trigger_enable(M14_trigger.helipad, false) 
  2079. 	on_trigger_exit("", M14_trigger.helipad) 
  2080. 	M14_status.helipad_left = true 
  2081. end 
  2082.  
  2083. function m14_interview_stairs_reached_cb() 
  2084. 	m14_clear_trigger(M14_trigger.interview_stairs) 
  2085. 	M14_status.interview_stairs_reached = true 
  2086. end 
  2087.  
  2088. function m14_spotlight_heli_destroyed_cb() 
  2089. 	on_vehicle_destroyed("", M14_vehicle.spotlight_heli) 
  2090. 	mission_end_failure("m14", M14_text.failure_heli_destroyed) 
  2091. end 
  2092.  
  2093. function m14_broadcast_van_destroyed_cb() 
  2094. 	on_vehicle_destroyed("", M14_vehicle.broadcast_van) 
  2095. 	mission_end_failure("m14", M14_text.failure_van_destroyed) 
  2096. end 
  2097.  
  2098. function m14_shaundi_died_cb() 
  2099. 	on_death("", M14_char.shaundi) 
  2100. 	mission_end_failure("m14", M14_text.failure_shaundi_died) 
  2101. end 
  2102.  
  2103. function m14_jane_died_cb() 
  2104. 	on_death("", M14_char.jane) 
  2105. 	mission_end_failure("m14", M14_text.failure_jane_died) 
  2106. end 
  2107.  
  2108. function m14_shaundi_dismissed_cb() 
  2109. 	on_dismiss("", M14_char.shaundi) 
  2110. 	mission_end_failure("m14", M14_text.failure_shaundi_abandoned) 
  2111. end 
  2112.  
  2113. function m14_timer_validation_fail_cb() 
  2114. 	hud_timer_stop(M14_TIMER_INDEX) 
  2115. 	mission_end_failure("m14", M14_text.failure_killbane_escaped) 
  2116. end 
  2117.  
  2118. function m14_remove_marker_cb(npc) 
  2119. 	marker_remove(npc) 
  2120. 	M14_status.deckers_alive = M14_status.deckers_alive - 1 
  2121. end 
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127. -- ************************* 
  2128. -- 
  2129. -- Thread functions 
  2130. -- 
  2131. -- ************************* 
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137. -- Thread that runs for the entirety of the mission to validate mission status for things that can't be caught with callbacks 
  2138. -- 
  2139. function m14_failure_validation_thread() 
  2140. 	while (1) do 
  2141. 		if (vehicle_exists(M14_vehicle.spotlight_heli)) then 
  2142. 			local player_is_in_heli = character_is_in_vehicle(LOCAL_PLAYER, M14_vehicle.spotlight_heli) 
  2143. 			 
  2144. 			if (not player_is_in_heli and coop_is_active()) then 
  2145. 				player_is_in_heli = character_is_in_vehicle(REMOTE_PLAYER, M14_vehicle.spotlight_heli) 
  2146. 			end 
  2147.  
  2148. 			if (not player_is_in_heli) then 
  2149. 				-- it's ok for the player to be out of the heli if they in one of the action zones 
  2150. 				local heli_not_in_action_zone = false 
  2151. 				local total_time = 60000		-- 60 seconds by default 
  2152. 			 
  2153. 				-- If we're at tower 1, make sure the heli stays within the validation trigger 
  2154. 				if (M14_status.do_tower1_validation) then 
  2155. 					if (not object_is_in_trigger(M14_trigger.tower1_heli_validation, M14_vehicle.spotlight_heli)) then 
  2156. 						heli_not_in_action_zone = true 
  2157. 					end 
  2158. 				-- If we're at tower 2, make sure the heli stays within the validation trigger 
  2159. 				elseif (M14_status.do_tower2_validation) then 
  2160. 					total_time = 90000		-- a bit more to do, give more time 
  2161. 					 
  2162. 					if (not object_is_in_trigger(M14_trigger.tower2_heli_validation, M14_vehicle.spotlight_heli)) then 
  2163. 						heli_not_in_action_zone = true 
  2164. 					end 
  2165. 				-- If we're at the interview location, make sure the heli stays within the validation trigger 
  2166. 				elseif (M14_status.do_interview_validation) then 
  2167. 					if (not object_is_in_trigger(M14_trigger.helipad, M14_vehicle.spotlight_heli)) then 
  2168. 						heli_not_in_action_zone = true 
  2169. 					end 
  2170. 				end 
  2171. 				 
  2172. 				-- If we're not at any of the locations, give the player a timer to get back in their heli 
  2173. 				if heli_not_in_action_zone == true or M14_status.do_timer_validation then 
  2174. 					if (M14_status.timer_active) then 
  2175. 						if (not M14_status.timer_displayed and hud_timer_get_remainder(M14_TIMER_INDEX) < 15000) then 
  2176. 							-- Display the timer for the last 10 seconds 
  2177. 							hud_timer_hide(M14_TIMER_INDEX, false) 
  2178. 							M14_status.timer_displayed = true 
  2179. 						end 
  2180. 					else -- Timer not active, start it up, but keep it hidden at first 
  2181. 						if (M14_status.target_progress_displayed) then 
  2182. 							hud_bar_off(M14_PROGRESS_INDEX) 
  2183. 						end 
  2184. 						m14_display_heli_warning_objective() 
  2185. 						hud_timer_set(M14_TIMER_INDEX, total_time, "m14_timer_validation_fail_cb") 
  2186. 						hud_timer_hide(M14_TIMER_INDEX, true) 
  2187. 						M14_status.timer_active = true 
  2188. 						M14_status.timer_displayed = false 
  2189. 					end 
  2190. 				else -- Don't do timer validation 
  2191. 					if (M14_status.timer_active) then 
  2192. 						m14_clear_heli_warning_objective() 
  2193. 						hud_timer_stop(M14_TIMER_INDEX) 
  2194. 						M14_status.timer_active = false 
  2195. 						if (M14_status.timer_displayed) then 
  2196. 							hud_timer_hide(M14_TIMER_INDEX, true) 
  2197. 							M14_status.timer_displayed = false 
  2198. 						end 
  2199. 						if (M14_status.target_progress_displayed) then 
  2200. 							hud_bar_on(M14_PROGRESS_INDEX, "health", M14_text.label_acquiring_target, HUD_BAR_MAX_VALUE) 
  2201. 						end 
  2202. 					end 
  2203. 				end 
  2204.  
  2205. 			else -- player_is_in_heli 
  2206. 				 
  2207. 				-- Removing this for now as I suspect it's causing problems 
  2208. 				--if (not character_is_in_vehicle(M14_char.shaundi, M14_vehicle.spotlight_heli)) then 
  2209. 				--	vehicle_enter_teleport(M14_char.shaundi, M14_vehicle.spotlight_heli, VEHICLE_SEAT_PASSENGER, false) 
  2210. 				--end 
  2211.  
  2212. 				-- Timer validation stuffs 
  2213. 				if (M14_status.timer_active) then 
  2214. 					m14_clear_heli_warning_objective() 
  2215. 					hud_timer_stop(M14_TIMER_INDEX) 
  2216. 					M14_status.timer_active = false 
  2217. 					if (M14_status.timer_displayed) then 
  2218. 						hud_timer_hide(M14_TIMER_INDEX, true) 
  2219. 						M14_status.timer_displayed = false 
  2220. 					end 
  2221. 					if (M14_status.target_progress_displayed) then 
  2222. 						hud_bar_on(M14_PROGRESS_INDEX, "health", M14_text.label_acquiring_target, HUD_BAR_MAX_VALUE) 
  2223. 					end 
  2224. 				end 
  2225.  
  2226. 			end 
  2227.  
  2228. 		end 
  2229. 		thread_yield() 
  2230. 	end 
  2231. end 
  2232.  
  2233. -- During the conversation "Where's Killbane", "Bet she knows", etc., pan the camera to view Jane and the Deckers in the studio 
  2234. -- 
  2235. function m14_studio_cam_panning_thread() 
  2236. 	camera_look_through(M14_cam_nav.jane, 2, true) 
  2237. 	delay(2) 
  2238. 	camera_look_through(M14_cam_nav.deckers, 2, true) 
  2239. 	delay(1) 
  2240. 	camera_end_look_through(false) 
  2241. end 
  2242.  
  2243. function m14_wrapper_thread(func, ...) 
  2244. 	while true do 
  2245. 		func(unpack(arg)) 
  2246. 		thread_yield() 
  2247. 	end 
  2248. end 
  2249.  
  2250. function m14_make_jane_cower() 
  2251. 	while character_is_ready( M14_char.jane ) == false do 
  2252. 		thread_yield() 
  2253. 	end 
  2254.  
  2255. 	set_animation_state(M14_char.jane, "cower stand") 
  2256. 	M14_thread.jane_cower = nil 
  2257. end 
  2258.  
  2259. function m14_cellphone_call_wait( convo, recieving, persona ) 
  2260. 	M14_status.cellphone_call_in_progress = convo 
  2261. 	 
  2262. 	audio_play_for_mission_cellphone( convo, recieving, true, "", "m14_cellphone_call_cb", persona ) 
  2263. 	 
  2264. 	while M14_status.cellphone_call_in_progress ~= nil	do 
  2265. 		thread_yield() 
  2266. 	end 
  2267. end 
  2268.  
  2269. function m14_cellphone_call_cb() 
  2270. 	M14_status.cellphone_call_in_progress = nil 
  2271. end 
  2272.  
  2273. function m14_abandon_heli_thread() 
  2274. 	local dist, dist_remote 
  2275. 	 
  2276. 	local should_show_timer = false 
  2277. 	local showing_timer = false 
  2278. 	local time_away = 0 
  2279. 	local in_heli 
  2280. 	 
  2281. 	while true do 
  2282. 		-- no heli, nothing to do 
  2283. 		if vehicle_exists( M14_vehicle.spotlight_heli ) == false or vehicle_is_destroyed( M14_vehicle.spotlight_heli ) == true then 
  2284. 			return 
  2285. 		end 
  2286. 		 
  2287. 		-- get greatest distance from heli 
  2288. 		dist = get_dist( M14_vehicle.spotlight_heli, LOCAL_PLAYER ) 
  2289. 		 
  2290. 		if coop_is_active() then 
  2291. 			dist_remote = get_dist( M14_vehicle.spotlight_heli, REMOTE_PLAYER ) 
  2292. 			 
  2293. 			-- since coop player is optional we take the clostest d 
  2294. 			if dist_remote < dist then 
  2295. 				dist = dist_remote 
  2296. 			end 
  2297. 		end 
  2298. 		 
  2299. 		if M14_status.at_tower ~= true then 
  2300. 			in_heli = character_is_in_vehicle( LOCAL_PLAYER, M14_vehicle.spotlight_heli ) 
  2301. 			 
  2302. 			-- either player in heli counts 
  2303. 			if coop_is_active() == true and in_heli == false then 
  2304. 				in_heli = character_is_in_vehicle( REMOTE_PLAYER, M14_vehicle.spotlight_heli ) 
  2305. 			end 
  2306. 			 
  2307. 			if in_heli then 
  2308. 				should_show_timer = false 
  2309. 				time_away = 0 
  2310. 			elseif should_show_timer == false then		-- once we show the timer, keep it up until the heli is occupied 
  2311. 				time_away = time_away + get_frame_time() 
  2312. 				should_show_timer =  time_away > 90 or dist > 50 
  2313. 			end 
  2314. 		else 
  2315. 			should_show_timer = false 
  2316. 			time_away = 0 
  2317. 		end 
  2318.  
  2319. 		-- show/hide the critical timer as appropriate 
  2320. 		if should_show_timer == true and showing_timer == false then 
  2321. 			hud_critical_timer_set( ( 120 - time_away ) * 1000, M14_text.get_in_heli, "m14_timer_validation_fail_cb", SYNC_ALL ) 
  2322. 			showing_timer = true 
  2323. 		elseif should_show_timer == false and showing_timer == true then 
  2324. 			hud_critical_timer_stop() 
  2325. 			showing_timer = false 
  2326. 		end 
  2327. 		 
  2328. 		thread_yield() 
  2329. 	end 
  2330. end 
  2331.  
  2332. function m14_on_attack_performed_cb( name ) 
  2333. 	if M14_thread.attack_line_timer ~= nil and thread_check_done( M14_thread.attack_line_timer ) == false then 
  2334. 		return 
  2335. 	end 
  2336. 	 
  2337. 	M14_thread.attack_line_timer = thread_new( "delay", rand_float( 5, 15 ) ) 
  2338. 	audio_play_persona_line( name, "m14_attack" ) 
  2339. end 
  2340.  
  2341. function m14_cleanup_audio( convos )	 
  2342. 	-- clear pending events 
  2343. 	M14_convo_queue = { } 
  2344.  
  2345. 	-- sweep all convo data and clean it up 
  2346. 	for i, convo in pairs( convos ) do 
  2347. 		m14_cleanup_audio_item( convo ) 
  2348. 	end 
  2349. end 
  2350. 	 
  2351. function m14_cleanup_audio_item( convo ) 
  2352. 	if convo.convo_handle ~= nil then 
  2353. 		audio_conversation_end( convo.convo_handle ) 
  2354. 		convo.convo_handle = nil 
  2355. 	end 
  2356. 	 
  2357. 	if convo.audio_id ~= nil then 
  2358. 		audio_stop( convo.audio_id ) 
  2359. 		convo.audio_id = nil 
  2360. 	end 
  2361. 	 
  2362. 	-- clean up loaded personas 
  2363. 	if convo.persona_handles ~= nil then 
  2364. 		for i, handle in pairs( convo.persona_handles ) do 
  2365. 			audio_persona_remove_2d( handle ) 
  2366. 		end 
  2367. 		convo.persona_handles = nil 
  2368. 	end 
  2369. end 
  2370.  
  2371. M14_convo_queue = { } 
  2372.  
  2373. -- Play an audio conversation 
  2374. -- 
  2375. -- convo:	(table) the conversation to play - contains a name, handle, and table of non-player speakers 
  2376. -- wait:		(bool) don't return until convo has played 
  2377. -- clear:		(bool) clear any pending convos 
  2378. -- 
  2379. function m14_convo_play( convo, wait, clear ) 
  2380. 	if (convo == nil) then 
  2381. 		return 
  2382. 	end 
  2383.  
  2384. 	-- add to end of queue 
  2385. 	M14_convo_queue[ #M14_convo_queue + 1 ] = convo 
  2386.  
  2387. 	-- wait for convo to finish playing if requested 
  2388. 	if wait == true  then 
  2389. 		while m14_convo_is_playing( convo ) == true do 
  2390. 			thread_yield() 
  2391. 		end 
  2392. 	end 
  2393. end 
  2394.  
  2395. function m14_convo_is_playing( convo ) 
  2396. 	if convo == nil then 
  2397. 		return sizeof_table( M14_convo_queue ) > 0 
  2398. 	end 
  2399.  
  2400. 	for i, c in pairs( M14_convo_queue ) do 
  2401. 		if c == convo then 
  2402. 			return true 
  2403. 		end 
  2404. 	end 
  2405. 	 
  2406. 	return false 
  2407. end 
  2408.  
  2409. function m14_convo_manager() 
  2410. 	local convo 
  2411.  
  2412. 	-- Loop infinitely until the mission is cleaned up. 
  2413. 	while true do 
  2414. 		thread_yield() 
  2415. 		 
  2416. 		if #M14_convo_queue > 0 then 
  2417. 			convo = M14_convo_queue[ 1 ] 
  2418. 			convo.persona_handles = { } 
  2419.  
  2420. 			--[[ 
  2421. 			-- Load 2D personas when necessary 
  2422. 			if convo.speakers_2d ~= nil then 
  2423. 				for i, persona in pairs( convo.speakers_2d ) do 
  2424. 					convo.persona_handles[ i ] = audio_persona_load_2d( persona ) 
  2425. 				end 
  2426. 			end 
  2427. 			--]] 
  2428.  
  2429. 			-- Load the conversation 
  2430. 			if convo.persona_3d_params ~= nil then 
  2431. 				audio_play_persona_line( unpack( convo.persona_3d_params ) ) 
  2432. 				 
  2433. 				m14_wait_for_persona_line_safe( convo.persona_3d_params[ 1 ] ) 
  2434. 			elseif convo.persona_2d_params ~= nil then 
  2435. 				convo.audio_id = audio_play_persona_line_2d( convo.speakers_2d[ 1 ].handle, convo.persona_2d_params[ 1 ] ) 
  2436.  
  2437. 				-- see note below 
  2438. 				if convo.persona_2d_params[ 2 ] ~= nil then 
  2439. 					delay( convo.persona_2d_params[ 2 ] ) 
  2440. 				end 
  2441. 				 
  2442. 				-- audio_is_playing() doesn't currently work with this id 
  2443. 				-- I am told it should so I'll leave it here but the delay above 
  2444. 				-- is what's going to make this work right now  -SDR 
  2445. 				m14_wait_for_audio_safe( convo.audio_id ) 
  2446. 				 
  2447. 				convo.audio_id = nil 
  2448. 			elseif convo.cell_name ~= nil then 
  2449. 				m14_cellphone_call_wait( convo.cell_name, convo.recieving, convo.speakers_2d[ 1 ].handle ) 
  2450. 			elseif convo.convo_name ~= nil then 
  2451. 				-- load convo 
  2452. 				if convo.coop_player ~= nil then 
  2453. 					convo.convo_handle = audio_conversation_load_player( convo.convo_name, convo.coop_player ) 
  2454. 				elseif convo.player_speaks then 
  2455. 					convo.convo_handle = audio_conversation_load( convo.convo_name ) 
  2456. 				else 
  2457. 					convo.convo_handle = audio_conversation_load_direct( convo.convo_name ) 
  2458. 				end 
  2459.  
  2460. 				-- play the conversation 
  2461. 				debug_print( "MAD", "Playing convo: " .. convo.convo_name .. "\n" ) 
  2462. 				audio_conversation_play( convo.convo_handle ) 
  2463. 				thread_yield() 
  2464.  
  2465. 				-- wait for the conversation to end 
  2466. 				m14_wait_for_convo_safe( convo.convo_handle ) 
  2467. 				convo.convo_handle = nil 
  2468. 			end 
  2469.  
  2470. 			--[[ 
  2471. 			-- clean up personas 
  2472. 			for i, handle in pairs( convo.persona_handles ) do 
  2473. 				audio_persona_remove_2d( handle ) 
  2474. 			end 
  2475. 			convo.persona_handles = nil 
  2476. 			--]] 
  2477.  
  2478. 			-- delay if needed 
  2479. 			if convo.delay_after ~= nil then 
  2480. 				delay( convo.delay_after ) 
  2481. 			end 
  2482.  
  2483. 			-- roll up the queue 
  2484. 			if #M14_convo_queue > 1 then 
  2485. 				for i = 2, #M14_convo_queue do 
  2486. 					M14_convo_queue[ i - 1 ] = M14_convo_queue[ i ] 
  2487. 				end 
  2488. 			end 
  2489.  
  2490. 			M14_convo_queue[ #M14_convo_queue ] = nil 
  2491. 		end 
  2492. 	end 
  2493. end 
  2494.  
  2495. function m14_interview_kill() 
  2496. 	if (M14_status.interview_audio ~= nil) then 
  2497. 		-- one or the other should work..... depends on who you ask 
  2498. 		audio_stop( M14_status.interview_audio_id ) 
  2499. 		audio_object_post_event( "radio_news_breaks_stop", "radio_news_breaks", M14_status.interview_audio, M14_status.interview_vehicle ) 
  2500. 		M14_status.interview_audio = nil 
  2501. 	end 
  2502. end 
  2503.  
  2504. function m14_interview_play( interview, veh ) 
  2505. 	if veh == nil then 
  2506. 		veh = M14_vehicle.spotlight_heli 
  2507. 	end 
  2508.  
  2509. 	m14_interview_kill() 
  2510. 	M14_status.interview_audio = interview 
  2511. 	M14_status.interview_vehicle = veh 
  2512. 	M14_status.interview_audio_id = audio_object_post_event( "radio_news_breaks", "radio_news_breaks", interview, veh ) 
  2513. end 
  2514.  
  2515. function m14_setup_fake_laser_reticle() 
  2516. 	-- If a player exits the helicopter, clean up the fake reticle. 
  2517. 	on_vehicle_exit("m14_set_fake_reticle_for_players", M14_vehicle.spotlight_heli) 
  2518. 	on_vehicle_enter("m14_set_fake_reticle_for_players", M14_vehicle.spotlight_heli)	 
  2519. 	m14_set_fake_reticle_for_players() 
  2520. end 
  2521.  
  2522. function m14_cleanup_fake_laser_reticle() 
  2523. 	on_vehicle_exit("", M14_vehicle.spotlight_heli) 
  2524. 	on_vehicle_enter("", M14_vehicle.spotlight_heli) 
  2525. 	reticle_override_clear(SYNC_ALL) 
  2526. end 
  2527.  
  2528. -- Sets the fake reticle for the pilot of the spotlight heli if there's only 
  2529. -- one player in that vehicle, or the passenger if there are two. 
  2530. function m14_set_fake_reticle_for_players(player, vehicle, seat_idx) 
  2531. 	local local_player_in_heli = character_is_in_vehicle(LOCAL_PLAYER, M14_vehicle.spotlight_heli) 
  2532. 	local remote_player_in_heli = coop_is_active() and character_is_in_vehicle(REMOTE_PLAYER, M14_vehicle.spotlight_heli) 
  2533. 	local pilot_name = get_char_in_vehicle(M14_vehicle.spotlight_heli, 0) 
  2534. 	 
  2535. 	-- If both players are in the heli, give the fake reticle to the guy that's not flying. 
  2536. 	if local_player_in_heli and remote_player_in_heli then 
  2537. 		if pilot_name == LOCAL_PLAYER then 
  2538. 			reticle_override_clear(SYNC_LOCAL) 
  2539. 			reticle_override_set(HUD_FAKE_RETICLE_WEAPON_NAME, HUD_FAKE_RETICLE_WEAPON_CATEGORY_NAME, SYNC_REMOTE) 
  2540. 		elseif pilot_name == REMOTE_PLAYER then 
  2541. 			reticle_override_set(HUD_FAKE_RETICLE_WEAPON_NAME, HUD_FAKE_RETICLE_WEAPON_CATEGORY_NAME, SYNC_LOCAL) 
  2542. 			reticle_override_clear(SYNC_REMOTE) 
  2543. 		else 
  2544. 			-- Neither is flying? 
  2545. 			reticle_override_clear(SYNC_ALL) 
  2546. 		end 
  2547. 	elseif pilot_name == LOCAL_PLAYER then 
  2548. 		reticle_override_set(HUD_FAKE_RETICLE_WEAPON_NAME, HUD_FAKE_RETICLE_WEAPON_CATEGORY_NAME, SYNC_LOCAL) 
  2549. 		reticle_override_clear(SYNC_REMOTE) 
  2550. 	elseif pilot_name == REMOTE_PLAYER then 
  2551. 		reticle_override_clear(SYNC_LOCAL) 
  2552. 		reticle_override_set(HUD_FAKE_RETICLE_WEAPON_NAME, HUD_FAKE_RETICLE_WEAPON_CATEGORY_NAME, SYNC_REMOTE) 
  2553. 	else 
  2554. 		reticle_override_clear(SYNC_ALL) 
  2555. 	end 
  2556. end 
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.