./m17.lua

  1. --[[ 
  2. 	m17.lua 
  3. 	SR3 Mission Script 
  4. 	DATE: 05-07-2010 
  5. 	AUTHOR:	Albert McDaniel 
  6. ]]-- 
  7.  
  8. -- Tweakable values -- 
  9. M17_SALUTE_DIST = 10.0      -- Distance at which STAG guys will salute the player while they're following Kia. 
  10. M17_TEMP_PISTOL_NAME = "Pistol-Gang"  -- We give the player a temporary pistol after the cutscene to make sure a pistol  
  11.                                       -- is equipped at that point; if the player has a better pistol they'll keep that. 
  12. M17_NO_NOTORIETY_TIME = 2 * 60        -- How long to prevent notoriety and cop spawns at the beginning of the mission (in seconds). 
  13. M17_ESCAPE_VTOL_AUTO_SPLODE_DIST = 15.0 
  14.  
  15. M17_KEYPAD_ANIM = "m13_cardswipe" 
  16. M17_KEYPAD_DELAY = 1.0 
  17. 									   
  18. M17_HOMIE_WEAPON_1 = "Rifle-STAG" 
  19. M17_HOMIE_WEAPON_2 = "Shotgun-STAG" 
  20.  
  21. -- Debug flags -- 
  22.  
  23. -- Groups --										 
  24. 	M17_group = { 
  25. 		homies = { 
  26. 			name = "m17_group_homies", 
  27. 			pierce = "m17_pierce", 
  28. 			viola = "m17_viola" 
  29. 		}, 
  30.  
  31. 		heli = { 
  32. 			name = "m17_group_heli", 
  33. 			heli = "m17_heli" 
  34. 		}, 
  35.  
  36. 		kia = { 
  37. 			name = "m17_group_kia", 
  38. 			kia = "m17_kia" 
  39. 		}, 
  40.  
  41. 		-- meeting = { 
  42. 		-- 	name = "m17_group_meeting", 
  43. 		-- }, 
  44.  
  45. 		ambush = { 
  46. 			name = "m17_group_ambush", 
  47. 			npcs = {  
  48. 				{ 
  49. 					name = "m17_ambush 001",  
  50. 					has_saluted = false, 
  51. 				}, 
  52. 				{ 
  53. 					name = "m17_ambush 002",  
  54. 					has_saluted = false, 
  55. 				}, 
  56. 				{ 
  57. 					name = "m17_ambush 003", 
  58. 					has_saluted = false, 
  59. 				}, 
  60. 				{ 
  61. 					name = "m17_ambush 004", 
  62. 					has_saluted = false, 
  63. 				}, 
  64. 				{ 
  65. 					name = "m17_ambush 005", 
  66. 					has_saluted = false, 
  67. 				}, 
  68. 				{ 
  69. 					name = "m17_ambush 006", 
  70. 					has_saluted = false, 
  71. 				}, 
  72. 				{ 
  73. 					name = "m17_ambush 007", 
  74. 					has_saluted = false, 
  75. 				}, 
  76. 				{ 
  77. 					name = "m17_ambush 008", 
  78. 					has_saluted = false, 
  79. 				}, 
  80. 				{ 
  81. 					name = "m17_ambush 009", 
  82. 					has_saluted = false, 
  83. 				}, 
  84. 				{ 
  85. 					name = "m17_ambush 010", 
  86. 					has_saluted = false, 
  87. 				}, 
  88. 			}, 
  89. 		}, 
  90.  
  91. 		captive_homies = { 
  92. 			name = "m17_group_captive_homies", 
  93. 			pierce = "m17_captive_pierce", 
  94. 			shaundi = "m17_captive_shaundi", 
  95. 			viola = "m17_captive_viola" 
  96. 		}, 
  97. 		 
  98. 		captives_misc = { 
  99. 			name = "m17_group_captives_misc", 
  100. 		}, 
  101.  
  102. 		tanks = { 
  103. 			name = "m17_group_tanks", 
  104. 			vehicles = { "m17_tank 001", "m17_tank 002", "m17_tank 003" }, 
  105. 			drivers = { "m17_tank_driver 001", "m17_tank_driver 002", "m17_tank_driver 003" } 
  106. 		}, 
  107.  
  108. 		jailors = { 
  109. 			name = "m17_group_jailors" 
  110. 		}, 
  111. 	 
  112. 		barricade = { 
  113. 			name = "m17_group_barricade", 
  114. 			npcs = { "m17_barricade 001", "m17_barricade 002", "m17_barricade 003", "m17_barricade 004", "m17_barricade 005" } 
  115. 		}, 
  116.  
  117. 		reactor_hall = { 
  118. 			name = "m17_group_reactor_hall", 
  119. 			script = { 
  120. 				[1] = { 
  121. 					{ npc = "m17_guard_rhall<001>", nav = "m17_nav_rhall<001>" }, 
  122. 					{ npc = "m17_guard_rhall<002>", nav = "m17_nav_rhall<002>" }, 
  123. 				}, 
  124.  
  125. 				[2] = { 
  126. 					{ npc = "m17_guard_rhall<003>", nav = "m17_nav_rhall<003>" }, 
  127. 					{ npc = "m17_guard_rhall<004>", nav = "m17_nav_rhall<004>" }, 
  128. 					{ npc = "m17_guard_rhall<005>", nav = "m17_nav_rhall<005>" }, 
  129. 				}, 
  130. 			}, 
  131. 			npcs = { "m17_guard_rhall<001>", "m17_guard_rhall<002>", "m17_guard_rhall<003>", "m17_guard_rhall<004>", "m17_guard_rhall<005>",  } 
  132. 		}, 
  133.  
  134. 		reactor = { 
  135. 			name = "m17_group_reactor", 
  136. 			npcs = { "m17_guard_reactor 001", "m17_guard_reactor 002", "m17_guard_reactor 003", "m17_guard_reactor 004", "m17_guard_reactor 005",  
  137. 					 "m17_guard_reactor 006", "m17_guard_reactor 007", "m17_guard_reactor 008", "m17_guard_reactor 009", "m17_guard_reactor 010",  
  138. 					 "m17_guard_reactor 011", } 
  139. 		}, 
  140.  
  141. 		ehall = { 
  142. 			name = "m17_group_ehall", 
  143. 			script = { 
  144. 				[1] = "m17_ehall<001>", 
  145. 				[2] = { 
  146. 					{ npc = "m17_ehall<002>", nav = "m17_nav_ehall<002>" }, 
  147. 					{ npc = "m17_ehall<003>", nav = "m17_nav_ehall<003>" }, 
  148. 					{ npc = "m17_ehall<004>", nav = "m17_nav_ehall<004>" }, 
  149. 					{ npc = "m17_ehall<005>", nav = "m17_nav_ehall<005>" }, 
  150. 					{ npc = "m17_ehall<006>", nav = "m17_nav_ehall<006>" }, 
  151. 				}, 
  152. 				[3] = { 
  153. 					{ npc = "m17_ehall<007>", nav = "m17_nav_ehall<007>" }, 
  154. 					{ npc = "m17_ehall<008>", nav = "m17_nav_ehall<008>" }, 
  155. 				}, 
  156. 			}, 
  157. 			explosion = { "m17_nav_ehall<001>", "m17_nav_ehall<009>" }, 
  158. 		}, 
  159.  
  160. 		fire = { 
  161. 			name = "m17_group_fire", 
  162. 			script = { 
  163. 				[1] = { "m17_fire<001>", "m17_fire<002>", "m17_fire<003>", "m17_fire<006>" }, 
  164. 				[2] = { "m17_fire<004>", "m17_fire<005>" }, 
  165. 			}, 
  166. 			nav = { "m17_nav_fire<001>" }, 
  167. 		}, 
  168.  
  169. 		hanger = { 
  170. 			name = "m17_group_hanger", 
  171. 			vtols = 		{ "m17_fake_vtol<001>", 		"m17_fake_vtol<002>", 		"m17_fake_vtol<003>" 		}, 
  172. 			npcs = 		{ "m17_fake_pilot<001>", 		"m17_fake_pilot<002>", 		"m17_fake_pilot<003>" 		}, 
  173. 			triggers = 	{ "m17_tgr_fake_vtol 001", 	"m17_tgr_fake_vtol 002", 	"m17_tgr_fake_vtol 003" 	}, 
  174. 		}, 
  175.  
  176. 		at_1 = { 
  177. 			name = "m17_group_at 001" 
  178. 		}, 
  179. 	 
  180. 		at_2 = { 
  181. 			name = "m17_group_at 002" 
  182. 		}, 
  183. 	 
  184. 		cs_1 = { 
  185. 			name = "m17_group_cs 001" 
  186. 		}, 
  187.  
  188. 		cs_2 = { 
  189. 			name = "m17_group_cs 002" 
  190. 		}, 
  191.  
  192. 		cs_3 = { 
  193. 			name = "m17_group_cs 003" 
  194. 		}, 
  195.  
  196. 		vtol = { 
  197. 			name = "m17_group_vtol", 
  198. 			vtol = "m17_vtol" 
  199. 		}, 
  200.  
  201. 		vtol_reward = { 
  202. 			name = "m17_group_vtol_reward", 
  203. 			vtol = "m17_vtol_reward" 
  204. 		}, 
  205. 	} 
  206. 	 
  207. 	M17_self_exploding_guys = {M17_group.reactor, M17_group.reactor_hall, M17_group.barricade} 
  208.  
  209. -- Navpoints -- 
  210. 	M17_nav_anim = { 
  211. 		brig_entry = "nav_brig_entry_anim", 
  212. 		brig = "nav_brig_anim", 
  213. 		pierce_cell = "nav_pierce_cell_anim", 
  214. 		viola_cell = "nav_viola_cell_anim", 
  215. 		shaundi_cell = "nav_shaundi_cell_anim", 
  216. 	} 
  217.  
  218. 	M17_nav_cancel = { 
  219. 		dock_local = "m17_nav_cancel_dock", 
  220. 		dock_remote = "m17_nav_cancel_dock_coop", 
  221. 	} 
  222.  
  223. 	M17_nav_wp = { 
  224. 		heli = "m17_nav_heli", 
  225. 		tank_hall = "m17_nav_tank_hall", 
  226. 		tank_entry = "m17_nav_tank_entry", 
  227. 		brig_hall = "m17_nav_brig_hall", 
  228. 		brig_stairs = "m17_nav_brig_stairs", 
  229. 		reactor = "m17_nav_reactor", 
  230. 		escape_stairs = "m17_nav_escape_stairs", 
  231. 		hanger_n = "m17_nav_hanger_n", 
  232. 	} 
  233.  
  234. 	M17_path_kia = { "kia_path_01", "kia_path_02", "kia_path_03", "kia_path_04", "kia_path_05", "kia_path_06", "kia_path_07", "kia_path_08",  
  235. 					"kia_path_09", "kia_path_10", "kia_path_11", "kia_path_12", "kia_path_13", --[["kia_path_14",--]] "kia_path_15", "kia_path_16",  
  236. 					"kia_path_17", "kia_path_18", "kia_path_19", } 
  237.  
  238. 	M17_nav_barricade = { "m17_nav_barricade 001", "m17_nav_barricade 002", "m17_nav_barricade 003", "m17_nav_barricade 004", "m17_nav_barricade 005" } 
  239.  
  240. 	M17_explosions = { 
  241. 		effect = { "rpg", "satchel" }, 
  242.  
  243. 		reactor = {	"m17_explosion 001", "m17_explosion 002", "m17_explosion 003", "m17_explosion 004", "m17_explosion 005", 
  244. 					"m17_explosion 006", "m17_explosion 007", "m17_explosion 008", "m17_explosion 009", "m17_explosion 010", 
  245. 					"m17_explosion 011", "m17_explosion 012", "m17_explosion 013", "m17_explosion 014", "m17_explosion 015", 
  246. 					"m17_explosion 035", "m17_explosion 036" }, 
  247.  
  248. 		hall = {	"m17_explosion 037", "m17_explosion 038", "m17_explosion 039", "m17_explosion 040", "m17_explosion 041", 
  249. 					"m17_explosion 042", "m17_explosion 043", "m17_explosion 044", "m17_explosion 045", "m17_explosion 046", 
  250. 					"m17_explosion 047", "m17_explosion 048", "m17_explosion 049", "m17_explosion 050", "m17_explosion 051", 
  251. 					"m17_explosion 052", "m17_explosion 053", "m17_explosion 054", "m17_explosion 055", "m17_explosion 056", 
  252. 					"m17_explosion 057", "m17_explosion 058", "m17_explosion 059", "m17_explosion 060", "m17_explosion 061", 
  253. 					"m17_explosion 062" }, 
  254.  
  255. 		deck = {	"m17_explosion 016", "m17_explosion 017", "m17_explosion 018", "m17_explosion 019", "m17_explosion 020", 
  256. 					"m17_explosion 021", "m17_explosion 022", "m17_explosion 023", "m17_explosion 024", "m17_explosion 025", 
  257. 					"m17_explosion 026", "m17_explosion 027", "m17_explosion 028", "m17_explosion 029", "m17_explosion 030", 
  258. 					"m17_explosion 031", "m17_explosion 032", "m17_explosion 033", "m17_explosion 034", "m17_explosion 063", 
  259. 					"m17_explosion 064", "m17_explosion 065", "m17_explosion 066", "m17_explosion 067", "m17_explosion 068", 
  260. 					"m17_explosion 069", "m17_explosion 070", "m17_explosion 071", "m17_explosion 072" }, 
  261. 	} 
  262.  
  263. -- Triggers -- 
  264. 	M17_triggers = { 
  265. 		armory_island = "m17_trigger_armory_island", 
  266. 		convo_getting_close = "m17_trigger_convo_close", 
  267. 		armory = "m17_trigger_nga", 
  268. 		carrier = "m17_trigger_carrier", 
  269. 		tank_exit = "m17_trigger_tank_exit", 
  270. 		brig = "m17_trigger_brig", 
  271. 		brig_entry = "m17_trigger_brig_entry", 
  272. 		brig_esc = "m17_trigger_brig_esc_001", 
  273. 		brig_stairs = "m17_trigger_brig_stairs", 
  274. 		reactor_spawn = "m17_trigger_rspawn", 
  275. 		reactor_hall = "m17_trigger_rhall", 
  276. 		pierce = "m17_trigger_pierce", 
  277. 		shaundi = "m17_trigger_shaundi", 
  278. 		viola = "m17_trigger_viola", 
  279. 		ehall_1 = "m17_trigger_ehall<001>", 
  280. 		ehall_2 = "m17_trigger_ehall<002>", 
  281. 		escape_hall = "m17_trigger_escape_hall", 
  282. 		fire = "m17_trigger_fire", 
  283. 		enter_tank_bay = "trigger_enter_tank_bay", 
  284. 		enter_reactor = "trigger_enter_reactor", 
  285. 		enter_hangar = "trigger_enter_hangar", 
  286. 	} 
  287.  
  288. -- Spawn Regions -- 
  289. 	M17_regions = { 
  290. 		start_stairs = "m17_region_start_stairs", 
  291. 		start_hall = "m17_region_start_hall", 
  292. 		tank_e = "m17_region_tank_e", 
  293. 		tank_w = "m17_region_tank_w", 
  294. 		tank_exit = "m17_region_tank_exit", 
  295. 		brig_exit = "m17_region_brig_exit", 
  296. 		reactor_hall = "m17_region_reactor_hall", 
  297. 		escape_hall = "m17_region_escape_hall", 
  298. 		escape_stairs = "m17_region_escape_stairs", 
  299. 		reactor_1 = "m17_region_reactor 001", 
  300. 		reactor_2 = "m17_region_reactor 002", 
  301. 	} 
  302.  
  303. -- Spawn Groups -- 
  304.  
  305. -- Script Movers -- 
  306. 	M17_CONSOLE = "m17_console" 
  307. 	M17_MEETING_DOOR_1 = "m17_door_meeting_1" 
  308. 	M17_MEETING_DOOR_2 = "m17_door_meeting_2" 
  309.  
  310. 	M17_doors = { 
  311. 		start_stairs = "m17_door_start_stairs", 
  312. 		start_hall = "m17_door_start_hall", 
  313. 		tank_hall = "m17_door_tank_hall", 
  314. 		tank_exit = "m17_door_tank_exit", 
  315. 		brig_hall = "m17_door_brig_hall", 
  316. 		pierce = "m17_door_pierce", 
  317. 		shaundi = "m17_door_shaundi", 
  318. 		viola = "m17_door_viola", 
  319. 		brig_big = "m17_door_brig_big", 
  320. 		brig_inner = "m17_door_brig_inner", 
  321. 		brig_outer = "m17_door_brig_outer", 
  322. 		brig_ambush = "m17_door_brig_ambush", 
  323. 		brig_stairs_1 = "m17_door_brig_stairs", 
  324. 		brig_stairs_2 = "m17_door_brig_stairs_2", 
  325. 		escape_stairs = "m17_door_escape_stairs", 
  326. 		hanger_s = "m17_door_hanger_s", 
  327. 		brig_1 = "m17_door_brig_001", 
  328. 		brig_2 = "m17_door_brig_002", 
  329. 		brig_3 = "m17_door_brig_003", 
  330. 		brig_4 = "m17_door_brig_004", 
  331. 	} 
  332.  
  333. 	M17_automatic_doors = { 
  334. 		tank_entry = { 
  335. 			trigger = "m17_trigger_tank_entry", 
  336. 			door = "m17_door_tank_entry", 
  337. 		}, 
  338. 		tank_ne = { 
  339. 			trigger = "m17_trigger_tank_ne", 
  340. 			door = "m17_door_tank_ne", 
  341. 		}, 
  342. 		tank_nw = { 
  343. 			trigger = "m17_trigger_tank_nw", 
  344. 			door = "m17_door_tank_nw", 
  345. 		}, 
  346. 		tank_se = { 
  347. 			trigger = "m17_trigger_tank_se", 
  348. 			door = "m17_door_tank_se", 
  349. 		}, 
  350. 		tank_sw = { 
  351. 			trigger = "m17_trigger_tank_sw", 
  352. 			door = "m17_door_tank_sw", 
  353. 		}, 
  354.  
  355. 		reactor = { 
  356. 			trigger = "m17_trigger_reactor", 
  357. 			door = "m17_door_reactor", 
  358. 		}, 
  359. 		reactor_1 = { 
  360. 			trigger = "m17_trigger_reactor 001", 
  361. 			door = "m17_door_reactor 001", 
  362. 		}, 
  363. 		reactor_2 = { 
  364. 			trigger = "m17_trigger_reactor 002", 
  365. 			door = "m17_door_reactor 002", 
  366. 		}, 
  367. 		reactor_3 = { 
  368. 			trigger = "m17_trigger_reactor 003", 
  369. 			door = "m17_door_reactor 003", 
  370. 		}, 
  371. 		reactor_4 = { 
  372. 			trigger = "m17_trigger_reactor 004", 
  373. 			door = "m17_door_reactor 004", 
  374. 		}, 
  375. 		reactor_5 = { 
  376. 			trigger = "m17_trigger_reactor 005", 
  377. 			door = "m17_door_reactor 005", 
  378. 		}, 
  379. 		reactor_6 = { 
  380. 			trigger = "m17_trigger_reactor 006", 
  381. 			door = "m17_door_reactor 006", 
  382. 		}, 
  383. 		reactor_7 = { 
  384. 			trigger = "m17_trigger_reactor 007", 
  385. 			door = "m17_door_reactor 007", 
  386. 		}, 
  387. 		reactor_8 = { 
  388. 			trigger = "m17_trigger_reactor 008", 
  389. 			door = "m17_door_reactor 008", 
  390. 		}, 
  391.  
  392. 		-- Locked automatic door 
  393. 		hanger_n = { 
  394. 			trigger = "m17_trigger_hanger_n", 
  395. 			door = "m17_door_hanger_n", 
  396. 		}, 
  397. 	} 
  398.  
  399. -- Text -- 
  400.  
  401. -- Conversations -- 
  402. 	M17_conv = { 
  403. 		start = { 
  404. 			name = "m17_convo_1", 
  405. 			handle = INVALID_CONVERSATION_HANDLE, 
  406. 		}, 
  407. 		drive_1 = { 
  408. 			name = "M17_Drive_To_Heli_1", 
  409. 			handle = INVALID_CONVERSATION_HANDLE, 
  410. 		}, 
  411. 		drive_2 = { 
  412. 			name = "M17_Drive_To_Heli_2", 
  413. 			handle = INVALID_CONVERSATION_HANDLE, 
  414. 		}, 
  415. 		flying = { 
  416. 			name = "M17_Flying", 
  417. 			handle = INVALID_CONVERSATION_HANDLE, 
  418. 		}, 
  419. 		handcuffs = { 
  420. 			name = "m17_convo_2", 
  421. 			handle = INVALID_CONVERSATION_HANDLE, 
  422. 		}, 
  423. 		lead_the_way = { 
  424. 			name = "M17_Lead_The_Way", 
  425. 			handle = INVALID_CONVERSATION_HANDLE, 
  426. 		},		 
  427. 		kia = { 
  428. 			name = "m17_convo_3", 
  429. 			handle = INVALID_CONVERSATION_HANDLE, 
  430. 		}, 
  431. 		reward = { 
  432. 			name = "M17_Reward_Choices", 
  433. 			handle = INVALID_CONVERSATION_HANDLE, 
  434. 		}, 
  435. 		shaundi_thanks = { 
  436. 			name = "M17_Shaundi_Thanks", 
  437. 			handle = INVALID_CONVERSATION_HANDLE, 
  438. 		}, 
  439. 		reactor = { 
  440. 			name = "M17_Reactor", 
  441. 			handle = INVALID_CONVERSATION_HANDLE, 
  442. 		}, 
  443. 		flash_bang = { 
  444. 			name = "M17_Flash_Bang_Event", 
  445. 			handle = INVALID_CONVERSATION_HANDLE, 
  446. 		}, 
  447. 		consoles = { 
  448. 			name = "M17_Consoles", 
  449. 			handle = INVALID_CONVERSATION_HANDLE, 
  450. 		}, 
  451. 		escape = { 
  452. 			name = "M17_Escape", 
  453. 			handle = INVALID_CONVERSATION_HANDLE, 
  454. 		}, 
  455. 	} 
  456.  
  457. 	M17_personas = { 
  458. 		kia = { 
  459. 			name = "Kia", 
  460. 			id = INVALID_PERSONA_HANDLE, 
  461. 		}, 
  462. 		cyrus = { 
  463. 			name = "Cyrus", 
  464. 			id = INVALID_PERSONA_HANDLE, 
  465. 		}, 
  466. 		computer = { 
  467. 			name = "Code9857", 
  468. 			id = INVALID_PERSONA_HANDLE, 
  469. 		}, 
  470. 	} 
  471. 	 
  472. 	M17_music = { 
  473. 		music_a = "M17_music_a", 
  474. 		music_a_stop = "M17_music_a_stop", 
  475. 		music_b = "M17_music_b", 
  476. 		music_b_stop = "M17_music_b_stop", 
  477. 	} 
  478.  
  479. -- Threads -- 
  480. 	M17_threads = { 
  481. 		no_notoriety = INVALID_THREAD_HANDLE, 
  482. 		police_notoriety_monitor = INVALID_THREAD_HANDLE, 
  483. 		follow = INVALID_THREAD_HANDLE, 
  484. 		kia_path = INVALID_THREAD_HANDLE, 
  485. 		convo = INVALID_THREAD_HANDLE, 
  486. 		salute = INVALID_THREAD_HANDLE, 
  487. 		pa = INVALID_THREAD_HANDLE, 
  488. 		explosions = INVALID_THREAD_HANDLE, 
  489. 		escape_talk = INVALID_THREAD_HANDLE, 
  490. 		convo_failsafe = INVALID_THREAD_HANDLE, 
  491. 		explode_guys = INVALID_THREAD_HANDLE, 
  492. 		auto_explode_vtols = INVALID_THREAD_HANDLE, 
  493. 	} 
  494.  
  495. -- Checkpoints -- 
  496. 	M17_checkpoint_start = { 
  497. 		name = MISSION_START_CHECKPOINT,					-- defined in ug_lib.lua 
  498. 		player = "m17_nav_cp_start_player", 
  499. 		coop = "m17_nav_cp_start_coop", 
  500. 		player_vehicle = "m17_nav_start_host_veh", 
  501. 		coop_vehicle = "m17_nav_start_client_veh", 
  502. 	} 
  503.  
  504. 	M17_checkpoint_meeting = { 
  505. 		name = "meeting", 
  506. 		player = "m17_nav_cp_meeting_player", 
  507. 		coop = "m17_nav_cp_meeting_coop" 
  508. 	} 
  509.  
  510. 	M17_checkpoint_jailbreak = { 
  511. 		name = "jailbreak", 
  512. 		player = "m17_nav_cp_jailbreak_player", 
  513. 		coop = "m17_nav_cp_jailbreak_coop" 
  514. 	} 
  515.  
  516. 	M17_checkpoint_reactor = { 
  517. 		name = "reactor", 
  518. 		player = "m17_nav_cp_reactor_player", 
  519. 		coop = "m17_nav_cp_reactor_coop" 
  520. 	} 
  521.  
  522. 	M17_checkpoint_escape = { 
  523. 		name = "escape", 
  524. 		player = "m17_nav_cp_escape_player", 
  525. 		coop = "m17_nav_cp_escape_coop" 
  526. 	} 
  527.  
  528. -- Cutscenes -- 
  529. 	M17_CUTSCENE_MISSION_INTRO = "17_in" 
  530. 	M17_CUTSCENE_THERM_LANDING = "17_mid" 
  531. 	M17_CUTSCENE_MISSION_OUTRO = "17_out" 
  532. 	M17_ZSCENE_01 = "17_z01" 
  533.  
  534. -- Other -- 
  535. 	M17_in_coop = false 
  536. 	M17_has_reached_goal = false 
  537. 	M17_began_freeing_pierce = false 
  538. 	M17_has_pierce = false 
  539. 	M17_began_freeing_shaundi = false 
  540. 	M17_has_shaundi = false 
  541. 	M17_began_freeing_viola = false 
  542. 	M17_has_viola = false 
  543. 	M17_mission_success = false 
  544. 	M17_stealh_section = false 
  545.  
  546. 	M17_MAX_KIA_DISTANCE = 8 
  547. 	M17_MIN_KIA_DISTANCE = 2 
  548. 	M17_ESCAPE_TIME = 180000 
  549. 	M17_ESCAPE_TIMER_TAG = "M17_TIMER_ESCAPE" 
  550. 	M17_BAR_INDEX = 0 
  551. 	M17_TIMER_INDEX = 0 
  552.  
  553. 	M17_CHOICE_SCREEN = "msn_proto_select" 
  554. 	M17_rewards = { 
  555. 		[1] = "M17_Vehicle_Jet_Bike", 
  556. 		[2] = "Crib_Weapon_Satchel_Charges", 
  557. 		[3] = "M17_Vehicle_STAG_Tank_Upgrade" 
  558. 	} 
  559.  
  560. -- ************************* 
  561. -- 
  562. -- Standard functions 
  563. -- 
  564. -- ************************* 
  565.  
  566. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  567. -- at the specified checkpoint. 
  568. -- CALLED FROM CODE 
  569. -- 
  570. -- m17_checkpoint:	The checkpoint the mission should begin at 
  571. -- is_restart:			TRUE if the mission is restarting, FALSE otherwise 
  572. -- 
  573. function m17_start(m17_checkpoint, is_restart)	 
  574. 	-- Override the checkpoint 
  575. 	--m17_checkpoint = M17_checkpoint_reactor.name 
  576.  
  577. 	M17_in_coop = coop_is_active() 
  578.  
  579. 	-- Release any homies ASAP 
  580. 	party_dismiss_all() 
  581.  
  582. 	-- Check if this mission starting from the beginning 
  583. 	if (m17_checkpoint == M17_checkpoint_start.name) then 
  584. 		if (is_restart == false) then 
  585. 			-- First time playing mission 
  586. 			cutscene_play(M17_CUTSCENE_MISSION_INTRO, nil, {M17_checkpoint_start.player, M17_checkpoint_start.coop}, false) 
  587. 		end 
  588. 	end 
  589.  
  590. 	-- Handle mission initialization for the current checkpoint 
  591. 	m17_initialize(m17_checkpoint, is_restart) 
  592.  
  593. 	-- Run the mission from the current checkpoint 
  594. 	m17_run(m17_checkpoint)	 
  595. end 
  596.  
  597. -- This is the primary function responsible for running the entire mission from start to finish. 
  598. -- 
  599. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  600. -- 
  601. function m17_run(first_checkpoint) 
  602. 	local current_checkpoint = first_checkpoint 
  603.  
  604. 	-- For this section, warp to the plastic surgeon on cancel 
  605. 	mission_set_cancel_warp_location(M17_checkpoint_start.player, M17_checkpoint_start.coop) 
  606. 	 
  607. 	audio_ambient_emitter_stop("NG_Island_Siren<001>") 
  608. 	 
  609. 	-- Run the mission from the beginning 
  610. 	if current_checkpoint == M17_checkpoint_start.name then 
  611. 		--[[ INSERT PROCESSING FOR THE FIRST CHECKPOINT HERE ]]-- 
  612. 		 
  613. 		-- Begin a stealth section; notoriety increases will fail the mission. 
  614. 		m17_begin_stealth_section() 
  615.  
  616. 		-- Find a helicopter 
  617. 		m17_hijack_heli() 
  618.  
  619. 		-- Land on the carrier 
  620. 		m17_board_ship() 
  621.  
  622. 		-- Set the next checkpoint 
  623. 		current_checkpoint = M17_checkpoint_meeting.name 
  624. 		mission_set_checkpoint(M17_checkpoint_meeting.name, true) 
  625. 	end 
  626.  
  627. 	-- For the rest of the mission, warp to the dock on cancel 
  628. 	mission_set_cancel_warp_location(M17_nav_cancel.dock_local, M17_nav_cancel.dock_remote) 
  629. 	 
  630. 	-- Set up the automatic doors (except the hanger) 
  631. 	for i, auto in pairs(M17_automatic_doors) do 
  632. 		trigger_enable(auto.trigger, true) 
  633. 		on_trigger("m17_door_enter", auto.trigger) 
  634. 		on_trigger_exit("m17_door_exit", auto.trigger) 
  635. 	end 
  636. 	trigger_enable(M17_automatic_doors.hanger_n.trigger, false) 
  637. 	on_trigger("", M17_automatic_doors.hanger_n.trigger) 
  638. 	on_trigger_exit("", M17_automatic_doors.hanger_n.trigger) 
  639. 	 
  640. 	if current_checkpoint == M17_checkpoint_meeting.name then	 
  641. 		character_ragdoll_set_last_resort_position(M17_checkpoint_meeting.player) 
  642. 		 
  643. 		-- Make music happen. 
  644. 		m17_post_music_event(M17_music.music_a) 
  645. 	 
  646. 		-- Begin a stealth section; notoriety increases will fail the mission. 
  647. 		m17_begin_stealth_section() 
  648. 		 
  649. 		-- Follow Kia to the meeting 
  650. 		m17_follow_kia() 
  651. 		 
  652. 		m17_cleanup_stealth_section() 
  653. 		 
  654. 		m17_meeting() 
  655.  
  656. 		-- Set the next checkpoint 
  657. 		current_checkpoint = M17_checkpoint_jailbreak.name 
  658. 		mission_set_checkpoint(M17_checkpoint_jailbreak.name, true) 
  659. 	end 
  660.  
  661. 	-- Turn off special Cyrus status 
  662. 	m17_cover_broken() 
  663.  
  664. 	-- Set up the brig doors 
  665. 	trigger_enable(M17_triggers.brig, true) 
  666. 	on_trigger("m17_brig_activated", M17_triggers.brig) 
  667. 	door_open(M17_doors.brig_outer, false, false) 
  668.  
  669. 	-- Open the doors to the rest of the ship 
  670. 	door_open(M17_doors.start_stairs) 
  671. 	door_open(M17_doors.start_hall) 
  672. 	door_open(M17_doors.brig_hall) 
  673. 	door_open(M17_doors.brig_1, false, false) 
  674. 	door_open(M17_doors.brig_2, false, false) 
  675. 	door_open(M17_doors.brig_3, false, false) 
  676. 	door_open(M17_doors.brig_4, false, false) 
  677. 	door_open(M17_doors.brig_stairs_1, false, false) 
  678. 	door_open(M17_doors.brig_stairs_2, false, false) 
  679.  
  680. 	-- Load Cyrus' persona for intercom VO 
  681. 	M17_personas.cyrus.id = audio_persona_load_2d(M17_personas.cyrus.name) 
  682. 	 
  683. 	if current_checkpoint == M17_checkpoint_jailbreak.name then 
  684. 		character_ragdoll_set_last_resort_position(M17_checkpoint_jailbreak.player) 
  685. 	 
  686. 		-- Fire up some audio action. 
  687. 		audio_object_post_event("m17_checkpoint_jailbreak") 
  688. 	 
  689. 		-- Free the Saints from the brig 
  690. 		m17_free_friends() 
  691.  
  692. 		-- Set the next checkpoint 
  693. 		current_checkpoint = M17_checkpoint_reactor.name 
  694. 		mission_set_checkpoint(M17_checkpoint_reactor.name, true) 
  695. 	end 
  696.  
  697. 	if current_checkpoint == M17_checkpoint_reactor.name then 
  698. 		character_ragdoll_set_last_resort_position(M17_checkpoint_reactor.player) 
  699. 		 
  700. 		-- Fire up some audio action. 
  701. 		audio_object_post_event("m17_checkpoint_reactor") 
  702. 		 
  703. 		-- Destroy the nuclear reactor 
  704. 		m17_destroy_reactor() 
  705.  
  706. 		-- Set the next checkpoint 
  707. 		current_checkpoint = M17_checkpoint_escape.name 
  708. 		mission_set_checkpoint(M17_checkpoint_escape.name, true) 
  709. 	end 
  710.  
  711. 	-- Load the computer persona for intercom VO 
  712. 	--M17_personas.computer.id = audio_persona_load_2d(M17_personas.computer.name) 
  713.  
  714. 	if current_checkpoint == M17_checkpoint_escape.name then	 
  715. 		character_ragdoll_set_last_resort_position(M17_checkpoint_escape.player) 
  716. 		 
  717. 		-- Fire up some audio action. 
  718. 		audio_object_post_event("m17_checkpoint_escape") 
  719. 		 
  720. 		-- Escape the carrier 
  721. 		m17_escape() 
  722. 	end 
  723. 	 
  724. 	M17_mission_success = true 
  725.  
  726. 	-- Create the reward VTOL 
  727. 	group_create(M17_group.vtol_reward.name, true) 
  728. 	 
  729. 	-- Stop the music. 
  730. 	m17_post_music_event(M17_music.music_b_stop) 
  731.  
  732. 	homie_mission_unlock("shaundi") -- Allow Shaundi to be called as a homie again (locked in M16) 
  733. 	mission_end_success("m17", M17_CUTSCENE_MISSION_OUTRO, {M17_nav_cancel.dock_local, M17_nav_cancel.dock_remote}) 
  734. end 
  735.  
  736. -- This is the primary function responsible for cleaning up the entire mission 
  737. -- CALLED FROM CODE 
  738. -- 
  739. function m17_cleanup() 
  740. 	--[[ INSERT ANY MISSION SPECIFIC CLEAN-UP ]]-- 
  741. 	-- Restart ambient alarms on NG island 
  742. 	audio_ambient_emitter_start("NG_Island_Siren<001>") 
  743. 	 
  744. 	-- Stop the situation override. 
  745. 	persona_clear_global_situation_override() 
  746. 	 
  747. 	-- Check to see if we're still in co-op; the remote player may have dropped. 
  748. 	M17_in_coop = coop_is_active() 
  749. 	 
  750. 	-- Swap out the interior. 
  751. 	city_zone_swap("ThermInt1", false) 
  752. 	 
  753. 	-- If the player didn't complete the mission, we need to swap the Thermopylae 
  754. 	-- exterior back in. 
  755. 	if M17_mission_success == false then 
  756. 		city_zone_swap("therm2", true) 
  757. 		city_zone_swap("thermext1", true) 
  758. 	end 
  759.  
  760. 	-- Stop any threads 
  761. 	for i, thrd in pairs(M17_threads) do 
  762. 		if (thrd ~= INVALID_THREAD_HANDLE) then 
  763. 			thread_kill(thrd) 
  764. 			thrd = INVALID_THREAD_HANDLE 
  765. 		end 
  766. 	end 
  767.  
  768. 	--- Cut short any conversations 
  769. 	for i, conv in pairs(M17_conv) do 
  770. 		if conv.handle ~= INVALID_CONVERSATION_HANDLE then 
  771. 			audio_conversation_end(conv.handle) 
  772. 			conv.handle = INVALID_CONVERSATION_HANDLE 
  773. 		end 
  774. 	end 
  775.  
  776. 	-- Remove loaded personas 
  777. 	for i, pers in pairs(M17_personas) do 
  778. 		if pers.id ~= INVALID_PERSONA_HANDLE then 
  779. 			audio_persona_remove_2d(pers.id) 
  780. 			pers.id = INVALID_PERSONA_HANDLE 
  781. 		end 
  782. 	end 
  783. 	 
  784. 	-- Clean up all triggers. 
  785. 	for i, trigger in pairs(M17_triggers) do 
  786. 		m17_clear_trigger(trigger) 
  787. 	end 
  788.  
  789. 	-- Clean up objective-specific items 
  790. 	m17_hijack_heli_cleanup() 
  791. 	m17_board_ship_cleanup() 
  792. 	m17_follow_kia_cleanup() 
  793. 	m17_meeting_cleanup() 
  794. 	m17_free_friends_cleanup() 
  795. 	m17_reactor_cleanup() 
  796. 	m17_escape_cleanup() 
  797. 		 
  798. 	m17_cleanup_stealth_section() 
  799. 	 
  800. 	-- Reenable recruitment. 
  801. 	party_set_recruitable(true)  
  802.  
  803. 	-- Clear any objective text 
  804. 	objective_text_clear(0) 
  805. 	mission_waypoint_remove() 
  806.  
  807. 	-- Cleanup waypoint markers 
  808. 	for i, wp in pairs(M17_nav_wp) do 
  809. 		marker_remove(wp, SYNC_ALL) 
  810. 	end 
  811.  
  812. 	-- Disable automatic doors 
  813. 	for i, auto in pairs(M17_automatic_doors) do 
  814. 		trigger_enable(auto.trigger, false) 
  815. 		on_trigger("", auto.trigger) 
  816. 		on_trigger_exit("", auto.trigger) 
  817. 	end 
  818.  
  819. 	-- Clear any triggers 
  820. 	for i, trig in pairs(M17_triggers) do 
  821. 		m17_clear_trigger(trig) 
  822. 	end 
  823.  
  824. 	-- Clear any spawn regions and spawn groups 
  825. 	continuous_spawn_stop(M17_group.cs_1.name) 
  826. 	continuous_spawn_stop(M17_group.cs_2.name) 
  827. 	continuous_spawn_stop(M17_group.cs_3.name) 
  828. 	continuous_spawn_stop(M17_group.at_1.name) 
  829. 	continuous_spawn_stop(M17_group.at_2.name) 
  830. 	 
  831. 	for i, region in pairs(M17_regions) do 
  832. 		spawn_region_enable(region, false) 
  833. 	end 
  834.  
  835. 	-- Clean up spawned groups 
  836. 	if group_is_loaded(M17_group.captive_homies.name) then 
  837. 		on_death("", M17_group.captive_homies.pierce) 
  838. 		on_death("", M17_group.captive_homies.shaundi) 
  839. 		on_death("", M17_group.captive_homies.viola) 
  840. 		on_dismiss("", M17_group.captive_homies.pierce) 
  841. 		on_dismiss("", M17_group.captive_homies.shaundi) 
  842. 		on_dismiss("", M17_group.captive_homies.viola) 
  843. 	end 
  844. 	if group_is_loaded(M17_group.homies.name) then 
  845. 		on_death("", M17_group.homies.pierce) 
  846. 		on_death("", M17_group.homies.viola) 
  847. 		on_dismiss("", M17_group.homies.pierce) 
  848. 		on_dismiss("", M17_group.homies.viola) 
  849. 	end 
  850. 	if group_is_loaded(M17_group.vtol.name) then 
  851. 		marker_remove(M17_group.vtol.vtol, SYNC_ALL) 
  852. 	end 
  853. 	if group_is_loaded(M17_group.vtol_reward.name) then 
  854. 		release_to_world(M17_group.vtol_reward.name) 
  855. 	end 
  856. 	if group_is_loaded(M17_group.tanks.name) then 
  857. 		group_destroy(M17_group.tanks.name) 
  858. 	end 
  859. 	cleanup_groups(M17_group) 
  860.  
  861. 	-- Allow notoriety again 
  862. 	hud_set_fake_notoriety("police", false, 0) 
  863. 	notoriety_set_can_decay(true) 
  864. 	notoriety_force_no_spawn("police", false) 
  865. 	notoriety_restricted_zones_enable(true) 
  866. 	notoriety_set_max("police", 5) 
  867. 	notoriety_spawn_only_air(false) 
  868. 	notoriety_force_no_spawn_group("stag_attack_heli", false) 
  869. 	notoriety_force_no_spawn_group("stag_heli", false) 
  870.  
  871. 	-- Turn the player back into themselves	 
  872. 	customization_item_revert( SYNC_LOCAL ) 
  873. 	customization_restore_player_rig( SYNC_LOCAL ) 
  874. 	 
  875. 	if coop_is_active() then 
  876. 		customization_item_revert( SYNC_REMOTE ) 
  877. 	end 
  878.  
  879. 	-- Allow human shields again and reset team 
  880. 	set_player_can_take_human_shields(LOCAL_PLAYER, true) 
  881. 	set_player_undercover_team(LOCAL_PLAYER, "None") 
  882. 	if (M17_in_coop == true) then 
  883. 		set_player_can_take_human_shields(REMOTE_PLAYER, true) 
  884. 		set_player_undercover_team(REMOTE_PLAYER, "None") 
  885. 	end 
  886.  
  887. 	-- Allow weapon selection again 
  888. 	inv_weapon_disable_all_slots(false) 
  889. 	player_grenades_enable() 
  890. 	auto_pickup_enable(); 
  891. 	 
  892. 	action_nodes_enable(true) 
  893. 		 
  894. 	-- Allow ped spawning again. 
  895. 	spawning_pedestrians(true) 
  896. 	 
  897. 	-- Remove the temporary pistol we give the player after the meeting cutscene. 
  898. 	inv_weapon_remove_temporary(LOCAL_PLAYER, M17_TEMP_PISTOL_NAME) 
  899. 		 
  900. 	-- Stop using the mission specified ragdoll get up last resort. 
  901. 	character_ragdoll_clear_last_resort_position() 
  902. 	 
  903. 	-- Stop all music. 
  904. 	m17_post_music_event(M17_music.music_a_stop) 
  905. 	m17_post_music_event(M17_music.music_b_stop) 
  906. end 
  907.  
  908. -- Called when the mission has ended with success 
  909. -- CALLED FROM CODE 
  910. -- 
  911. function m17_success()	 
  912. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  913. 	local skip_teleport = true 
  914. 	m17_coop_skip(skip_teleport) -- do the stuff we'd do in the skip case 
  915. end 
  916.  
  917. -- ************************* 
  918. -- 
  919. -- Local functions 
  920. -- 
  921. -- ************************* 
  922.  
  923. -- Initialize the mission for the specified checkpoint 
  924. -- 
  925. -- checkpoint:		Checkpoint to initialize the mission to 
  926. -- is_restart:      Whether or not the mission is restarting. 
  927. -- 
  928. function m17_initialize(checkpoint, is_restart) 
  929. 	-- Make sure the screen is completly faded out 
  930. 	mission_start_fade_out(0.0) 
  931.  
  932. 	-- Set the mission author 
  933. 	set_mission_author("Albert McDaniel") 
  934. 	 
  935. 	-- Set the persona situation override for the player dressed as Cyrus. 
  936. 	persona_set_global_situation_override(PS_OVERRIDE_MISSION17) 
  937.  
  938. 	-- Ensure the requisite zones are swapped in 
  939. 	 
  940. 	-- Swap in the interior. 
  941. 	if checkpoint == M17_checkpoint_meeting.name or 
  942. 		checkpoint == M17_checkpoint_jailbreak.name or 
  943. 		checkpoint == M17_checkpoint_reactor.name or 
  944. 		checkpoint == M17_checkpoint_escape.name then 
  945. 		city_zone_swap("ThermInt1", true) 
  946. 		city_zone_swap("thermext1", false) 
  947. 		city_zone_swap("therm2", false) 
  948. 	else 
  949. 		-- If we're starting the mission fresh or restarting the mission from the 
  950. 		-- start we need to swap out the interior and make sure the exterior is swapped in. 
  951. 		-- Swapping it out in the cleanup function only disables the zone swap 
  952. 		-- if the mission is cancelled. 
  953. 		city_zone_swap("ThermInt1", false) 
  954. 		city_zone_swap("thermext1", true) 
  955. 		city_zone_swap("Therm2", true) 
  956. 	end 
  957.  
  958. 	-- Any notoriety is fake for this mission 
  959. 	notoriety_force_no_spawn("police", true) 
  960. 	notoriety_set_can_decay(false) 
  961. 	notoriety_set_max("police", 0) 
  962. 	notoriety_restricted_zones_enable(false) 
  963. 	notoriety_force_no_spawn_group("stag_attack_heli", true) 
  964. 	notoriety_force_no_spawn_group("stag_heli", true) 
  965.  
  966. 	-- Turn the player into Cyrus 
  967. 	customization_item_wear( "Cyrus Suit", "cyrus_hires.cmeshx", "Cyrus", false, SYNC_LOCAL ) 
  968. 	customization_item_wear( "Cyrus Head", "cyrus_hires_head.cmeshx", "Cyrus", false, SYNC_LOCAL ) 
  969. 	customization_swap_player_rig( "cyrus.rig", "PLYM", SYNC_LOCAL ) 
  970. 	 
  971. 	if coop_is_active() then 
  972. 		-- Put the remote player into a regular STAG soldier outfit. 
  973. 		customization_item_wear("cm_stag", "cm_stag.cmeshx", "Stag_Body", false, SYNC_REMOTE) 
  974. 		customization_item_wear("cm_hat_m_staghelmet", "cm_hat_m_staghelmet.cmeshx", "StagCommando_Body", false, SYNC_REMOTE) 
  975. 	end 
  976.  
  977. 	-- Prevent taking human shields and set the players to the STAG team 
  978. 	set_player_can_take_human_shields(LOCAL_PLAYER, false) 
  979. 	set_player_undercover_team(LOCAL_PLAYER, "STAG") 
  980. 	if (M17_in_coop == true) then 
  981. 		set_player_can_take_human_shields(REMOTE_PLAYER, false) 
  982. 		set_player_undercover_team(REMOTE_PLAYER, "STAG") 
  983. 	end 
  984.  
  985. 	-- Prevent weapon selection 
  986. 	auto_pickup_disable(); 
  987. 	inv_weapon_disable_all_but_this_slot(WEAPON_SLOT_UNARMED) 
  988. 	player_grenades_disable() 
  989. 	 
  990. 	-- Prevent recruitment, otherwise the player could recruit STAG, which is funny but probably bad. 
  991. 	party_set_recruitable(false)  
  992.  
  993. 	-- Set up the mission based on the checkpoint 
  994. 	if (checkpoint == M17_checkpoint_start.name) then 
  995. 		--[[ INSERT ANY INITIALIZATION CODE FOR STARTING THE MISSION AT THE BEGINNING ]]-- 
  996. 		 
  997. 		-- Get the players' vehicles out of the way. 
  998. 		teleport_player_vehicles(M17_checkpoint_start.player_vehicle, M17_checkpoint_start.coop_vehicle) 
  999. 		 
  1000. 		-- Teleport the players 
  1001. 		if is_restart == true then 
  1002. 			teleport_coop(M17_checkpoint_start.player, M17_checkpoint_start.coop, true) 
  1003. 		end 
  1004.  
  1005. 		-- Spawn and add homies 
  1006. 		group_create(M17_group.homies.name, true) 
  1007. 		set_dont_attack_me_on_sight_flag(M17_group.homies.pierce, true) 
  1008. 		set_dont_attack_me_on_sight_flag(M17_group.homies.viola, true) 
  1009. 		 
  1010. 		-- Pierce and Viola shouldn't enter combat; they're supposed to be prisoners. 
  1011. 		npc_combat_enable(M17_group.homies.pierce, false) 
  1012. 		npc_combat_enable(M17_group.homies.viola, false) 
  1013. 		 
  1014. 		on_death("m17_fail_pierce_died", M17_group.homies.pierce) 
  1015. 		on_death("m17_fail_viola_died", M17_group.homies.viola) 
  1016. 		party_add_ignore_limits(M17_group.homies.pierce, LOCAL_PLAYER) 
  1017. 		if (M17_in_coop) then 
  1018. 			party_add_ignore_limits(M17_group.homies.viola, REMOTE_PLAYER) 
  1019. 		else 
  1020. 			party_add_ignore_limits(M17_group.homies.viola, LOCAL_PLAYER) 
  1021. 		end 
  1022. 		follower_set_can_abandon(M17_group.homies.pierce, true) 
  1023. 		follower_set_can_abandon(M17_group.homies.viola, true) 
  1024. 		on_dismiss("m17_fail_dismissed_cb", M17_group.homies.pierce) 
  1025. 		on_dismiss("m17_fail_dismissed_cb", M17_group.homies.viola) 
  1026.  
  1027. 		tutorial_start("mis_undercover", 5, true, false) --SP 7/12: Added tutorial about undercover, feel free to move it if it's in a bad place 
  1028.  
  1029. 		-- Spawn a heli (the player does NOT have to use this heli) 
  1030. 		group_create(M17_group.heli.name, true) 
  1031. 	end 
  1032.  
  1033. 	if (checkpoint == M17_checkpoint_meeting.name) then 
  1034. 		-- Teleport the players 
  1035. 		teleport_coop(M17_checkpoint_meeting.player, M17_checkpoint_meeting.coop, true) 
  1036. 		 
  1037. 		-- We need to hide the door to the R&D lab because it sticks through the wall when it's open... 
  1038. 		mesh_mover_hide(M17_MEETING_DOOR_1) 
  1039. 		mesh_mover_hide(M17_MEETING_DOOR_2) 
  1040.  
  1041. 		-- Spawn Kia 
  1042. 		group_create(M17_group.kia.name, true) 
  1043.  
  1044. 		-- Spawn the scientists 
  1045. 		-- group_create(M17_group.meeting.name, true) 
  1046.  
  1047. 		-- Spawn guards to ambush the player later 
  1048. 		group_create(M17_group.ambush.name, true) 
  1049. 		 
  1050. 		-- Disable ped spawning while inside the Thermopylae. 
  1051. 		spawning_pedestrians(false) 
  1052. 	end 
  1053.  
  1054. 	if (checkpoint == M17_checkpoint_jailbreak.name) then 
  1055. 		-- Make music happen. 
  1056. 		m17_post_music_event(M17_music.music_a) 
  1057. 		 
  1058. 		-- Teleport the players 
  1059. 		teleport_coop(M17_checkpoint_jailbreak.player, M17_checkpoint_jailbreak.coop, true) 
  1060.  
  1061. 		-- Spawn guards to ambush the player 
  1062. 		group_create(M17_group.ambush.name, true) 
  1063. 		 
  1064. 		-- Equip a pistol on the local player to match the cutscene after the meeting. 
  1065. 		m17_equip_pistol() 
  1066.  
  1067. 		-- Spawn the next objective before fading in 
  1068. 		m17_free_friends_setup() 
  1069. 		 
  1070. 		-- Disable ped spawning while inside the Thermopylae. 
  1071. 		spawning_pedestrians(false) 
  1072. 	end 
  1073.  
  1074. 	if (checkpoint == M17_checkpoint_reactor.name) then 
  1075.  
  1076. 		-- Spawn the captive homies 
  1077. 		group_create(M17_group.captive_homies.name, true) 
  1078. 		--group_create(M17_group.captive_misc.name, true) 
  1079. 		on_death("m17_fail_pierce_died", M17_group.captive_homies.pierce) 
  1080. 		on_death("m17_fail_shaundi_died", M17_group.captive_homies.shaundi) 
  1081. 		on_death("m17_fail_viola_died", M17_group.captive_homies.viola) 
  1082. 		 
  1083. 		-- Give them some weapons. 
  1084. 		inv_item_add(M17_HOMIE_WEAPON_1, 1, M17_group.captive_homies.pierce, true) 
  1085. 		inv_item_add(M17_HOMIE_WEAPON_2, 1, M17_group.captive_homies.shaundi, true) 
  1086. 		inv_item_add(M17_HOMIE_WEAPON_1, 1, M17_group.captive_homies.viola, true) 
  1087.  
  1088. 		-- Add everyone to the player's party 
  1089. 		if (M17_in_coop) then 
  1090. 			party_add_ignore_limits(M17_group.captive_homies.pierce, M17_group.captive_homies.shaundi, LOCAL_PLAYER) 
  1091. 			party_add_ignore_limits(M17_group.captive_homies.viola, REMOTE_PLAYER) 
  1092. 		else 
  1093. 			party_add_ignore_limits(M17_group.captive_homies.pierce, M17_group.captive_homies.viola, M17_group.captive_homies.shaundi, LOCAL_PLAYER) 
  1094. 		end 
  1095. 		follower_set_can_abandon(M17_group.captive_homies.pierce, true) 
  1096. 		follower_set_can_abandon(M17_group.captive_homies.viola, true) 
  1097. 		follower_set_can_abandon(M17_group.captive_homies.shaundi, true) 
  1098. 		on_dismiss("m17_fail_dismissed_cb", M17_group.captive_homies.pierce) 
  1099. 		on_dismiss("m17_fail_dismissed_cb", M17_group.captive_homies.viola) 
  1100. 		on_dismiss("m17_fail_dismissed_cb", M17_group.captive_homies.shaundi) 
  1101. 		 
  1102. 		-- Teleport the players after adding followers so they come along with. 
  1103. 		teleport_coop(M17_checkpoint_reactor.player, M17_checkpoint_reactor.coop, true) 
  1104. 		 
  1105. 		-- Disable ped spawning while inside the Thermopylae. 
  1106. 		spawning_pedestrians(false) 
  1107. 	end 
  1108.  
  1109. 	if (checkpoint == M17_checkpoint_escape.name) then 
  1110. 		-- Make music happen. 
  1111. 		m17_post_music_event(M17_music.music_b) 
  1112. 		 
  1113. 		-- Spawn the captive homies 
  1114. 		group_create(M17_group.captive_homies.name, true) 
  1115. 		on_death("m17_fail_pierce_died", M17_group.captive_homies.pierce) 
  1116. 		on_death("m17_fail_shaundi_died", M17_group.captive_homies.shaundi) 
  1117. 		on_death("m17_fail_viola_died", M17_group.captive_homies.viola) 
  1118. 		 
  1119. 		-- Give them some weapons. 
  1120. 		inv_item_add(M17_HOMIE_WEAPON_1, 1, M17_group.captive_homies.pierce, true) 
  1121. 		inv_item_add(M17_HOMIE_WEAPON_2, 1, M17_group.captive_homies.shaundi, true) 
  1122. 		inv_item_add(M17_HOMIE_WEAPON_1, 1, M17_group.captive_homies.viola, true) 
  1123.  
  1124. 		-- Add everyone to the player's party 
  1125. 		if (M17_in_coop) then 
  1126. 			party_add_ignore_limits(M17_group.captive_homies.pierce, M17_group.captive_homies.shaundi, LOCAL_PLAYER) 
  1127. 			party_add_ignore_limits(M17_group.captive_homies.viola, REMOTE_PLAYER) 
  1128. 		else 
  1129. 			party_add_ignore_limits(M17_group.captive_homies.pierce, M17_group.captive_homies.viola, M17_group.captive_homies.shaundi, LOCAL_PLAYER) 
  1130. 		end 
  1131.  
  1132. 		-- Teleport the players after adding followers so they come along with. 
  1133. 		teleport_coop(M17_checkpoint_escape.player, M17_checkpoint_escape.coop, true) 
  1134. 		 
  1135. 		-- Disable ped spawning while inside the Thermopylae. 
  1136. 		spawning_pedestrians(false) 
  1137. 	end 
  1138.  
  1139. 	-- Start fading in  
  1140. 	mission_start_fade_in() 
  1141. end 
  1142.  
  1143. -- Turn off special Cyrus status 
  1144. function m17_cover_broken() 
  1145. 	-- Set the notoriety to 5 stars to force attacking 
  1146. 	notoriety_set_max("police", 3) 
  1147. 	notoriety_set("police", 3) 
  1148. 	hud_set_fake_notoriety("police", false, 5) 
  1149.  
  1150. 	-- Allow human shields again and reset team 
  1151. 	set_player_can_take_human_shields(LOCAL_PLAYER, true) 
  1152. 	set_player_undercover_team(LOCAL_PLAYER, "None") 
  1153. 	if (M17_in_coop == true) then 
  1154. 		set_player_can_take_human_shields(REMOTE_PLAYER, true) 
  1155. 		set_player_undercover_team(REMOTE_PLAYER, "None") 
  1156. 	end 
  1157.  
  1158. 	-- Allow weapon selection again 
  1159. 	inv_weapon_disable_all_slots(false) 
  1160. 	player_grenades_enable() 
  1161. 	auto_pickup_enable(); 
  1162. end 
  1163.  
  1164. -- Disable trigger 
  1165. -- 
  1166. -- trigger:			(string) Name of the trigger 
  1167. -- 
  1168. function m17_clear_trigger(trigger) 
  1169. 	on_trigger("", trigger) 
  1170. 	on_trigger_exit("", trigger) 
  1171. 	trigger_enable(trigger, false) 
  1172. 	marker_remove_trigger(trigger, SYNC_ALL) 
  1173. end 
  1174.  
  1175. -- ************************* 
  1176. -- Objective: Hijack Heli 
  1177. -- ************************* 
  1178.  
  1179. -- Find a helicopter 
  1180. function m17_hijack_heli() 
  1181. 	-- Load the intro conversation 
  1182. 	M17_conv.start.handle = audio_conversation_load(M17_conv.start.name) 
  1183. 			 
  1184. 	-- Disable notoriety and ambient cop spawns for a while at the beginning of the mission. 
  1185. 	M17_threads.no_notoriety = thread_new("m17_disable_notoriety_for_drive_to_armory_thread") 
  1186.  
  1187. 	-- Set the heli as the next goal 
  1188. 	M17_has_reached_goal = false 
  1189. 	objective_text(0, "M17_OBJ_FIND_HELI", "", "", SYNC_ALL, OI_ASSET_LOCATION) 
  1190. 	on_vehicle_enter("m17_heli_entered", LOCAL_PLAYER) 
  1191. 	if (M17_in_coop == true) then 
  1192. 		on_vehicle_enter("m17_heli_entered", REMOTE_PLAYER) 
  1193. 	end 
  1194. 	mission_waypoint_add(M17_triggers.armory, SYNC_ALL) 
  1195. 	trigger_enable(M17_triggers.armory, true) 
  1196. 	on_trigger("m17_armory_enter_cb", M17_triggers.armory) 
  1197. 	marker_add_trigger(M17_triggers.armory, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1198.  
  1199. 	turn_invulnerable(M17_group.heli.heli) 
  1200.  
  1201. 	-- Tell the player to hijack a heli 
  1202. 	audio_conversation_play(M17_conv.start.handle) 
  1203. 	audio_conversation_wait_for_end(M17_conv.start.handle) 
  1204. 	M17_conv.start.handle = INVALID_CONVERSATION_HANDLE 
  1205.  
  1206. 	-- Load the next conversation 
  1207. 	M17_conv.drive_1.handle = audio_conversation_load(M17_conv.drive_1.name) 
  1208. 	delay(6) 
  1209.  
  1210. 	-- Start the conversation 
  1211. 	audio_conversation_play(M17_conv.drive_1.handle) 
  1212. 	audio_conversation_wait_for_end(M17_conv.drive_1.handle) 
  1213. 	M17_conv.drive_1.handle = INVALID_CONVERSATION_HANDLE 
  1214.  
  1215. 	-- Load the next conversation 
  1216. 	M17_conv.drive_2.handle = audio_conversation_load(M17_conv.drive_2.name) 
  1217. 	delay(6) 
  1218.  
  1219. 	-- Start the conversation 
  1220. 	audio_conversation_play(M17_conv.drive_2.handle) 
  1221.  
  1222. 	-- Wait until the player enters a heli 
  1223. 	while not M17_has_reached_goal do 
  1224. 		thread_yield() 
  1225. 	end 
  1226.  
  1227. 	-- Clean up the objective 
  1228. 	m17_hijack_heli_cleanup() 
  1229. 	objective_text_clear(0) 
  1230. 	mission_waypoint_remove() 
  1231. end 
  1232.  
  1233. -- When the player enters the NG armory island. 
  1234. -- 
  1235. function m17_enter_armory_island_cb() 
  1236. 	m17_clean_up_notoriety_stuff_for_driving_to_armory() 
  1237. end 
  1238.  
  1239. function m17_armory_enter_cb() 
  1240. 	m17_clear_trigger(M17_triggers.armory) 
  1241. 	mission_waypoint_remove() 
  1242. 	marker_add(M17_group.heli.heli, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1243. end 
  1244.  
  1245. -- Clean up the Hijack Heli objective 
  1246. function m17_hijack_heli_cleanup() 
  1247. 	if group_is_loaded(M17_group.heli.name) then 
  1248. 		marker_remove(M17_group.heli.heli, SYNC_ALL) 
  1249. 		turn_vulnerable(M17_group.heli.heli) 
  1250. 	end 
  1251.  
  1252. 	on_vehicle_enter("", LOCAL_PLAYER) 
  1253. 	if (M17_in_coop == true) then 
  1254. 		on_vehicle_enter("", REMOTE_PLAYER) 
  1255. 	end 
  1256. 	 
  1257. 	m17_clean_up_notoriety_stuff_for_driving_to_armory() 
  1258. end 
  1259.  
  1260. -- ************************* 
  1261. -- Objective: Board Ship 
  1262. -- ************************* 
  1263.  
  1264. -- Land on the carrier 
  1265. function m17_board_ship() 
  1266. 	-- Tell the player to board the ship 
  1267. 	M17_has_reached_goal = false 
  1268. 	objective_text(0, "M17_OBJ_BOARD_SHIP", "", "", SYNC_ALL, OI_ASSET_LOCATION) 
  1269. 	trigger_enable(M17_triggers.carrier, true) 
  1270. 	marker_add_trigger(M17_triggers.carrier, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1271. 	 
  1272. 	-- Enable the trigger that kicks off the "getting close" conversation. 
  1273. 	trigger_enable(M17_triggers.convo_getting_close, true) 
  1274. 	on_trigger("m17_trigger_reached", M17_triggers.convo_getting_close) 
  1275.  
  1276. 	-- Load the compliment conversation 
  1277. 	audio_conversation_wait_for_end(M17_conv.drive_2.handle) 
  1278. 	M17_conv.drive_2.handle = INVALID_CONVERSATION_HANDLE 
  1279. 	M17_conv.flying.handle = audio_conversation_load_direct(M17_conv.flying.name) 
  1280. 	delay(6) 
  1281.  
  1282. 	-- Tell the player he looks good 
  1283. 	audio_conversation_play(M17_conv.flying.handle) 
  1284. 	audio_conversation_wait_for_end(M17_conv.flying.handle) 
  1285. 	M17_conv.flying.handle = INVALID_CONVERSATION_HANDLE 
  1286.  
  1287. 	-- Load the handcuffs conversation 
  1288. 	M17_conv.handcuffs.handle = audio_conversation_load(M17_conv.handcuffs.name) 
  1289. 	delay(6) 
  1290.  
  1291. 	-- Wait until the player reached the trigger to start the "getting close" conversation. 
  1292. 	while not M17_has_reached_goal do 
  1293. 		thread_yield() 
  1294. 	end 
  1295. 	M17_has_reached_goal = false 
  1296. 	 
  1297. 	-- Set the trigger for landing on the carrier. 
  1298. 	on_trigger("m17_trigger_reached", M17_triggers.carrier) 
  1299.  
  1300. 	-- Tell the homies to put on handcuffs 
  1301. 	audio_conversation_play(M17_conv.handcuffs.handle) 
  1302.  
  1303. 	-- Wait until the player reached the carrier 
  1304. 	while not M17_has_reached_goal do 
  1305. 		thread_yield() 
  1306. 	end 
  1307.  
  1308. 	-- If the last conversation is not yet done, force-end it 
  1309. 	audio_conversation_end(M17_conv.handcuffs.handle) 
  1310. 	M17_conv.handcuffs.handle = INVALID_CONVERSATION_HANDLE 
  1311. 	objective_text_clear(0) 
  1312.  
  1313. 	-- Play the arrival cutscene 
  1314. 	m17_board_ship_cutscene() 
  1315. end 
  1316.  
  1317. -- Play the boarding cutscene 
  1318. function m17_board_ship_cutscene() 
  1319. 	-- Make sure the screen is completly faded out 
  1320. 	--fade_out(0.5) 
  1321. 	--fade_out_block() 
  1322.  
  1323. 	-- Play the Z-scene 
  1324. 	--bink_play("17_Mid_Block_v01") 
  1325. 	cutscene_play(M17_CUTSCENE_THERM_LANDING, nil, nil, false) 
  1326.  
  1327. 	-- Clean up the objective 
  1328. 	m17_board_ship_cleanup() 
  1329. 	 
  1330. 	-- Swap in the interior and swap out the exterior. 
  1331. 	city_zone_swap("ThermInt1", true) 
  1332. 	city_zone_swap("thermext1", false) 
  1333. 	city_zone_swap("therm2", false) 
  1334. 	thread_yield() 
  1335.  
  1336. 	-- Put the players in the correct location following the cutscene 
  1337. 	teleport_coop(M17_checkpoint_meeting.player, M17_checkpoint_meeting.coop, true) 
  1338. 	 
  1339. 	-- We need to hide the door to the R&D lab because it sticks through the wall when it's open... 
  1340. 	mesh_mover_hide(M17_MEETING_DOOR_1) 
  1341. 	mesh_mover_hide(M17_MEETING_DOOR_2) 
  1342.  
  1343. 	-- Spawn Kia 
  1344. 	group_create(M17_group.kia.name, true) 
  1345.  
  1346. 	-- Spawn the scientists 
  1347. 	-- group_create(M17_group.meeting.name, true) 
  1348.  
  1349. 	-- Spawn guards to ambush the player later 
  1350. 	group_create(M17_group.ambush.name, true) 
  1351.  
  1352. 	-- Start fading in  
  1353. 	fade_in(0.5) 
  1354. 	fade_in_block() 
  1355. end 
  1356.  
  1357. -- Clean up the Board Ship objective 
  1358. function m17_board_ship_cleanup() 
  1359. 	-- Remove homies 
  1360. 	if group_is_loaded(M17_group.homies.name) then 
  1361. 		on_death("", M17_group.homies.pierce) 
  1362. 		on_death("", M17_group.homies.viola) 
  1363. 		on_dismiss("", M17_group.homies.pierce) 
  1364. 		on_dismiss("", M17_group.homies.viola) 
  1365. 		group_destroy(M17_group.homies.name) 
  1366. 	end 
  1367.  
  1368. 	-- Remove heli 
  1369. 	if group_is_loaded(M17_group.heli.name) then 
  1370. 		group_destroy(M17_group.heli.name) 
  1371. 	end 
  1372. end 
  1373.  
  1374. -- ************************* 
  1375. -- Objective: Follow Kia 
  1376. -- ************************* 
  1377.  
  1378. -- Follow Kia to the meeting 
  1379. function m17_follow_kia() 
  1380.  
  1381. 	while not character_is_ready(M17_group.kia.kia) do 
  1382. 		thread_yield() 
  1383. 	end 
  1384. 		 
  1385. 	-- Stop spawning peds while inside the Thermopylae. 
  1386. 	spawning_pedestrians(false) 
  1387.  
  1388. 	-- Set the meeting room as the next goal 
  1389. 	objective_text(1, "M17_OBJ_FOLLOW_KIA", "", "", SYNC_ALL, OI_ASSET_LOCATION) 
  1390.  
  1391. 	marker_add(M17_group.kia.kia, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL, SYNC_ALL) 
  1392.  
  1393. 	-- Display a "suspicion" bar 
  1394. 	hud_bar_on(M17_BAR_INDEX, "annoyance", "", M17_MAX_KIA_DISTANCE - M17_MIN_KIA_DISTANCE, SYNC_ALL) 
  1395. 	 
  1396. 	-- Start a thread to update the conversation 
  1397. 	M17_threads.convo = thread_new("m17_follow_kia_conversation") 
  1398. 	 
  1399. 	delay(2.0) 
  1400. 	 
  1401. 	-- Start a thread to update the suspicion bar 
  1402. 	M17_threads.follow = thread_new("m17_follow_kia_update") 
  1403. 	 
  1404. 	-- Start up a thread to make STAG soldiers salute the player. 
  1405. 	M17_threads.salute = thread_new("m17_salute_thread") 
  1406.  
  1407. 	-- Open the door to the meeting room 
  1408. 	--door_open(M17_doors.meeting, false, false) 
  1409.  
  1410. 	-- Damaging Kia or killing a guard results in fail 
  1411. 	on_damage("m17_fail_suspicion", M17_group.kia.kia) 
  1412. 	for i, npc in pairs(M17_group.ambush.npcs) do 
  1413. 		on_damage("m17_fail_suspicion", npc.name) 
  1414. 		 
  1415. 		-- Also prevent them from entering combat.  This prevents them 
  1416. 		-- from hunkering down briefly after they salute.  And really... 
  1417. 		-- I don't think they'd attack Cyrus. 
  1418. 		npc_combat_enable(npc.name, false) 
  1419. 	end 
  1420. 	 
  1421. 	-- Start prepping the Z-scene 
  1422. 	zscene_prep(M17_ZSCENE_01)	 
  1423.  
  1424. 	-- Start Kia walking to the meeting 
  1425. 	npc_combat_enable(M17_group.kia.kia, false) 
  1426. 	delay(1) 
  1427. 	M17_threads.kia_path = thread_new("m17_kia_path_thread") 
  1428. 	 
  1429. 	-- Wait for the conversation to end, we won't force the player to wait 
  1430. 	-- for Kia if they're a jerk and block her path or something. 
  1431. 	threads_wait_for_completion(M17_threads.convo) 
  1432. 	 
  1433. 	delay(20.0) 
  1434. 	 
  1435. 	action_nodes_enable(false) 
  1436. 	 
  1437. 	-- Unhide the door to the R&D lab. (Doing this in cleanup would rarely cause an assert in  
  1438. 	-- co-op if we cancel the mission and the client doesn't get the packet before the door 
  1439. 	-- streams out). 
  1440. 	mesh_mover_show(M17_MEETING_DOOR_1) 
  1441. 	mesh_mover_show(M17_MEETING_DOOR_2) 
  1442. 	 
  1443. 	-- Clean up the objective 
  1444. 	m17_follow_kia_cleanup() 
  1445. end 
  1446.  
  1447. -- Update the Follow Kia thread 
  1448. function m17_follow_kia_update() 
  1449. 	local furthest_dist = 0 
  1450. 	while(true) do 
  1451. 		-- Get the furthest player's distance from Kia 
  1452. 		furthest_dist = get_dist(LOCAL_PLAYER, M17_group.kia.kia) 
  1453. 		if (M17_in_coop == true) then 
  1454. 			local p2_dist = get_dist(REMOTE_PLAYER, M17_group.kia.kia) 
  1455. 			if (p2_dist > furthest_dist) then 
  1456. 				furthest_dist = p2_dist 
  1457. 			end 
  1458. 		end 
  1459.  
  1460. 		-- Update the suspicion bar based on distance 
  1461. 		if (furthest_dist < M17_MIN_KIA_DISTANCE) then 
  1462. 			-- They're close enough, so show a full bar 
  1463. 			hud_bar_set_value(M17_BAR_INDEX, M17_MAX_KIA_DISTANCE - M17_MIN_KIA_DISTANCE) 
  1464. 		else 
  1465. 			hud_bar_set_value(M17_BAR_INDEX, M17_MAX_KIA_DISTANCE - furthest_dist) 
  1466. 		end 
  1467.  
  1468. 		-- Fail if the player strayed too far 
  1469. 		if (furthest_dist > M17_MAX_KIA_DISTANCE) then 
  1470. 			m17_fail_suspicion() 
  1471. 		end 
  1472.  
  1473. 		thread_yield() 
  1474. 	end 
  1475. end 
  1476.  
  1477. -- Update the Kia 'lead-the-way' thread 
  1478. function m17_lead_the_way_conversation() 
  1479. 	-- Load the Kia conversation 
  1480. 	M17_conv.lead_the_way.handle = audio_conversation_load(M17_conv.lead_the_way.name) 
  1481.  
  1482. 	-- Now start the Kia conversation 
  1483. 	audio_conversation_play(M17_conv.lead_the_way.handle) 
  1484. 	audio_conversation_wait_for_end(M17_conv.lead_the_way.handle) 
  1485. 	M17_conv.lead_the_way.handle = INVALID_CONVERSATION_HANDLE 
  1486. end 
  1487.  
  1488. -- Update the Kia conversation thread 
  1489. function m17_follow_kia_conversation() 
  1490. 	-- Load the Kia start convo 
  1491. 	M17_conv.lead_the_way.handle = audio_conversation_load(M17_conv.lead_the_way.name) 
  1492.  
  1493. 	-- Now start the Kia start convo 
  1494. 	audio_conversation_play(M17_conv.lead_the_way.handle) 
  1495. 	audio_conversation_wait_for_end(M17_conv.lead_the_way.handle) 
  1496. 	M17_conv.lead_the_way.handle = INVALID_CONVERSATION_HANDLE 
  1497. 	 
  1498. 	-- Load the Kia conversation 
  1499. 	M17_conv.kia.handle = audio_conversation_load(M17_conv.kia.name) 
  1500.  
  1501. 	-- Wait a bit after the following starts 
  1502. 	delay(6) 
  1503.  
  1504. 	-- Now start the Kia conversation 
  1505. 	audio_conversation_play(M17_conv.kia.handle) 
  1506. 	audio_conversation_wait_for_end(M17_conv.kia.handle) 
  1507. 	M17_conv.kia.handle = INVALID_CONVERSATION_HANDLE 
  1508.  
  1509. 	-- After a few seconds, Kia explains choices 
  1510. 	M17_conv.reward.handle = audio_conversation_load(M17_conv.reward.name) 
  1511. 	delay(4) 
  1512. 	audio_conversation_play(M17_conv.reward.handle) 
  1513. 	audio_conversation_wait_for_end(M17_conv.reward.handle) 
  1514. 	M17_conv.reward.handle = INVALID_CONVERSATION_HANDLE 
  1515. end 
  1516.  
  1517. -- Clean up the Follow Kia objective 
  1518. function m17_follow_kia_cleanup() 
  1519. 	-- Stop the update thread 
  1520. 	if (M17_threads.follow ~= INVALID_THREAD_HANDLE) then 
  1521. 		thread_kill(M17_threads.follow) 
  1522. 		M17_threads.follow = INVALID_THREAD_HANDLE 
  1523. 	end 
  1524.  
  1525. 	-- Stop the conversation thread 
  1526. 	if (M17_threads.convo ~= INVALID_THREAD_HANDLE) then 
  1527. 		thread_kill(M17_threads.convo) 
  1528. 		M17_threads.convo = INVALID_THREAD_HANDLE 
  1529. 	end 
  1530. 	 
  1531. 	-- Stop the salute thread 
  1532. 	if (M17_threads.salute ~= INVALID_THREAD_HANDLE) then 
  1533. 		thread_kill(M17_threads.salute) 
  1534. 		M17_threads.salute = INVALID_THREAD_HANDLE 
  1535. 	end 
  1536. 	 
  1537. 	-- Stop Kia's pathing thread 
  1538. 	if (M17_threads.kia_path ~= INVALID_THREAD_HANDLE) then 
  1539. 		thread_kill(M17_threads.kia_path) 
  1540. 		M17_threads.kia_path = INVALID_THREAD_HANDLE 
  1541. 	end 
  1542. 	 
  1543. 	-- Clean up anything we set up for the saluting guys. 
  1544. 	if group_is_loaded(M17_group.ambush.name) then 
  1545. 		for i, npc in pairs(M17_group.ambush.npcs) do 
  1546. 			npc.has_saluted = false 
  1547. 			npc_combat_enable(npc.name, true) 
  1548. 			ai_clear_scripted_action(npc.name) 
  1549. 		end 
  1550. 	end 
  1551.  
  1552. 	-- Clear the suspicion bar 
  1553. 	hud_bar_off(M17_BAR_INDEX) 
  1554.  
  1555. 	-- Remove the objective markers 
  1556. 	marker_remove(M17_group.kia.kia, SYNC_ALL) 
  1557.  
  1558. 	objective_text_clear(1) 
  1559. end 
  1560.  
  1561. -- ************************* 
  1562. -- Objective: Meeting 
  1563. -- ************************* 
  1564.  
  1565. -- Hold the meeting 
  1566. function m17_meeting() 
  1567. 	-- Put up the choice screen 
  1568. 	hud_push_screen(M17_CHOICE_SCREEN, SYNC_ALL) 
  1569.  
  1570. 	-- Wait until the choice is complete 
  1571. 	local sel = -1 
  1572. 	while (sel == -1) do 
  1573. 		thread_yield() 
  1574. 		sel = hud_get_proto_selection() 
  1575. 	end 
  1576. 	sel = sel + 1	-- Convert from 0-based to 1-based index 
  1577.  
  1578. 	-- Exclude the reward not chosen 
  1579. 	mission_set_excluded_reward(M17_rewards[sel]) 
  1580. 	 
  1581. 	-- Remove the screen for the client. 
  1582. 	hud_pop_screen(M17_CHOICE_SCREEN, SYNC_REMOTE) 
  1583. 	 
  1584. 	-- Start the meeting cutscene 
  1585. 	m17_meeting_cutscene() 
  1586. end 
  1587.  
  1588. -- Play the meeting cutscene 
  1589. function m17_meeting_cutscene() 
  1590. 	-- Make sure the screen is completly faded out 
  1591. 	--fade_out(0.5) 
  1592. 	--fade_out_block() 
  1593.  
  1594. 	-- Play the Z-scene 
  1595. 	cutscene_play(M17_ZSCENE_01, nil, nil, false) 
  1596. 	 
  1597. 	-- Equip a pistol, since the player has one equipped at the end of the cutscene. 
  1598. 	m17_equip_pistol() 
  1599.  
  1600. 	-- Put the players in the correct location following the cutscene 
  1601. 	teleport_coop(M17_checkpoint_jailbreak.player, M17_checkpoint_jailbreak.coop, true) 
  1602.  
  1603. 	-- Close the door to the meeting room 
  1604. 	--door_close(M17_doors.meeting, false) 
  1605.  
  1606. 	-- Clean up the objective 
  1607. 	m17_meeting_cleanup() 
  1608.  
  1609. 	-- Spawn the next objective before fading in 
  1610. 	m17_free_friends_setup() 
  1611.  
  1612. 	-- Start fading in  
  1613. 	fade_in(0.5) 
  1614. 	fade_in_block() 
  1615. end 
  1616.  
  1617. -- Clean up the meeting 
  1618. function m17_meeting_cleanup() 
  1619. 	-- Remove Kia 
  1620. 	if group_is_loaded(M17_group.kia.name) then 
  1621. 		on_damage("", M17_group.kia.kia) 
  1622. 		group_destroy(M17_group.kia.name) 
  1623. 	end 
  1624. 	-- if group_is_loaded(M17_group.meeting.name) then 
  1625. 	-- 	group_destroy(M17_group.meeting.name) 
  1626. 	-- end 
  1627.  
  1628. 	-- Remove the kill guard fail condition 
  1629. 	for i, npc in pairs(M17_group.ambush.npcs) do 
  1630. 		on_damage("", npc.name) 
  1631. 		on_death("", npc.name) 
  1632. 	end 
  1633. end 
  1634.  
  1635. -- ************************* 
  1636. -- Objective: Free Friends 
  1637. -- ************************* 
  1638.  
  1639. -- Free the Saints from the brig 
  1640. function m17_free_friends_setup() 
  1641. 	-- Load Kia's persona, now that she's unloaded 
  1642. 	M17_personas.kia.id = audio_persona_load_2d(M17_personas.kia.name) 
  1643.  
  1644. 	-- Spawn the captive homies 
  1645. 	group_create(M17_group.captive_homies.name, true) 
  1646. 	on_death("m17_fail_pierce_died", M17_group.captive_homies.pierce) 
  1647. 	on_death("m17_fail_shaundi_died", M17_group.captive_homies.shaundi) 
  1648. 	on_death("m17_fail_viola_died", M17_group.captive_homies.viola) 
  1649. 	 
  1650. 	-- Prevent your homies from saying anything (especially complimenting you) 
  1651. 	-- before they are freed. 
  1652. 	npc_suppress_persona(M17_group.captive_homies.pierce, true) 
  1653. 	npc_suppress_persona(M17_group.captive_homies.shaundi, true) 
  1654. 	npc_suppress_persona(M17_group.captive_homies.viola, true) 
  1655.  
  1656. 	-- Ignore homies until they are freed 
  1657. 	set_ignore_ai_flag(M17_group.captive_homies.pierce, true) 
  1658. 	set_ignore_ai_flag(M17_group.captive_homies.shaundi, true) 
  1659. 	set_ignore_ai_flag(M17_group.captive_homies.viola, true) 
  1660. 	set_dont_attack_me_on_sight_flag(M17_group.captive_homies.pierce, true) 
  1661. 	set_dont_attack_me_on_sight_flag(M17_group.captive_homies.shaundi, true) 
  1662. 	set_dont_attack_me_on_sight_flag(M17_group.captive_homies.viola, true) 
  1663.  
  1664. 	-- Spawn the tank bay as hidden, so they don't move around until the player reaches them 
  1665. 	group_create_hidden(M17_group.tanks.name, true) 
  1666. 	 
  1667. 	-- Prevent the tanks from going ambient.  They get confused by the fact that they're in the middle of the bay. 
  1668. 	for i, vehicle in pairs(M17_group.tanks.vehicles) do 
  1669. 		vehicle_prevent_transition_to_ambient(vehicle, true) 
  1670. 	end 
  1671.  
  1672. 	-- Spawn the jailors 
  1673. 	group_create_hidden(M17_group.jailors.name, false) 
  1674. end 
  1675.  
  1676. -- Free the Saints from the brig 
  1677. function m17_free_friends() 
  1678. 	-- Enable the spawn regions and spawn groups 
  1679. 	--spawn_region_enable(M17_regions.start_stairs, true) 
  1680. 	spawn_region_enable(M17_regions.start_hall, true) 
  1681. 	continuous_spawn_start(M17_group.cs_1.name, 3, 10) 
  1682. 	--continuous_spawn_start(M17_group.cs_2.name, 2, 10) 
  1683. 	action_nodes_enable(false) 
  1684.  
  1685. 	-- Set the brig security room as the objective 
  1686. 	objective_text(0, "M17_OBJ_FIND_BRIG", "", "", SYNC_ALL, OI_ASSET_LOCATION) 
  1687.  
  1688. 	-- Start a thread to update the PA announcements 
  1689. 	M17_threads.pa = thread_new("m17_pa_kia") 
  1690.  
  1691. 	-- Mark the hall door as an intermediate waypoint 
  1692. 	marker_add(M17_nav_wp.tank_hall, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1693.  
  1694. 	-- Wait until the player reaches the hall door 
  1695. 	while not door_is_open(M17_doors.tank_hall) do 
  1696. 		thread_yield() 
  1697. 	end 
  1698.  
  1699. 	marker_remove(M17_nav_wp.tank_hall, SYNC_ALL) 
  1700.  
  1701. 	-- Release existing spawn groups as ambient 
  1702. 	continuous_spawn_stop(M17_group.cs_1.name) 
  1703. 	--continuous_spawn_stop(M17_group.cs_2.name) 
  1704.  
  1705. 	-- Disable the entry spawn regions 
  1706. 	--spawn_region_enable(M17_regions.start_stairs, false) 
  1707. 	spawn_region_enable(M17_regions.start_hall, false) 
  1708.  
  1709. 	--== WAYPOINT ==-- 
  1710.  
  1711. 	-- Mark the tank bay door as an intermediate waypoint 
  1712. 	marker_add(M17_nav_wp.tank_entry, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1713.  
  1714. 	-- Wait until the player reaches the tank bay 
  1715. 	M17_has_reached_goal = false 
  1716. 	trigger_enable(M17_triggers.enter_tank_bay, true) 
  1717. 	on_trigger("m17_trigger_reached", M17_triggers.enter_tank_bay) 
  1718. 	while M17_has_reached_goal == false do 
  1719. 		thread_yield() 
  1720. 	end 
  1721.  
  1722. 	marker_remove(M17_nav_wp.tank_entry, SYNC_ALL) 
  1723.  
  1724. 	--== WAYPOINT ==-- 
  1725.  
  1726. 	-- Done with the ambush 
  1727. 	release_to_world(M17_group.ambush.name) 
  1728.  
  1729. 	-- Show the tank bay enemies 
  1730. 	group_show(M17_group.tanks.name) 
  1731.  
  1732. 	-- Set the brig hallway as the next waypoint 
  1733. 	marker_add(M17_nav_wp.brig_hall, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1734.  
  1735. 	-- Enable the tank bay spawn regions 
  1736. 	spawn_region_enable(M17_regions.tank_e, true) 
  1737. 	spawn_region_enable(M17_regions.tank_w, true) 
  1738. 	spawn_region_enable(M17_regions.tank_exit, true) 
  1739. 	 
  1740. 	-- Enable the tank bay exit trigger 
  1741. 	trigger_enable(M17_triggers.tank_exit, true) 
  1742. 	on_trigger("m17_tank_exit_cb", M17_triggers.tank_exit) 
  1743.  
  1744. 	-- Re-spawn continuous spawn groups further ahead 
  1745. 	continuous_spawn_start(M17_group.cs_1.name, 3, 10) 
  1746. 	continuous_spawn_start(M17_group.cs_2.name, 2, 10) 
  1747.  
  1748. 	-- Wait a moment, then send the drivers to the tanks 
  1749. 	delay(8) 
  1750. 	audio_play_persona_line_2d(M17_personas.cyrus.id, "M17_PA_Enter_Tank_Bay") 
  1751. 	 
  1752. 	vehicle_enter(M17_group.tanks.drivers[1], M17_group.tanks.vehicles[1], 0, false, false) 
  1753. 	vehicle_enter(M17_group.tanks.drivers[2], M17_group.tanks.vehicles[2], 0, false, false) 
  1754. 	-- vehicle_enter(M17_group.tanks.drivers[3], M17_group.tanks.vehicles[3], 0, false, false) 
  1755. 	 
  1756. 	on_vehicle_destroyed("m17_antitank_spawn_cb", M17_group.tanks.vehicles[1]) 
  1757. 	on_vehicle_destroyed("m17_antitank_spawn_cb", M17_group.tanks.vehicles[2]) 
  1758.  
  1759. 	-- Wait until the player reaches the brig hallway 
  1760. 	while not door_is_open(M17_doors.tank_exit) do 
  1761. 		thread_yield() 
  1762. 	end 
  1763.  
  1764. 	marker_remove(M17_nav_wp.brig_hall, SYNC_ALL) 
  1765.  
  1766. 	--== WAYPOINT ==-- 
  1767.  
  1768. 	-- Show the jailors 
  1769. 	group_show(M17_group.jailors.name) 
  1770.  
  1771. 	-- Set the brig as the next objective 
  1772. 	objective_text_clear(0) 
  1773. 	objective_text(0, "M17_OBJ_JAILBREAK", "", "", SYNC_ALL, OI_ASSET_USE) 
  1774.  
  1775. 	marker_add_trigger(M17_triggers.brig, MINIMAP_ICON_USE, INGAME_EFFECT_CHECKPOINT, OI_ASSET_USE, OI_FLAGS_LOCATION, SYNC_ALL) 
  1776.  
  1777. 	-- Stop continuous spawn while the player is in the brig 
  1778. 	continuous_spawn_stop(M17_group.cs_1.name) 
  1779. 	continuous_spawn_stop(M17_group.cs_2.name) 
  1780. 	continuous_spawn_stop(M17_group.at_1.name) 
  1781. 	continuous_spawn_stop(M17_group.at_2.name) 
  1782.  
  1783. 	-- Disable the tank bay spawn regions 
  1784. 	spawn_region_enable(M17_regions.tank_e, false) 
  1785. 	spawn_region_enable(M17_regions.tank_w, false) 
  1786.  
  1787. 	-- Wait until the player activates the brig doors 
  1788. 	while (not door_is_open(M17_doors.brig_inner)) do 
  1789. 		thread_yield() 
  1790. 	end 
  1791.  
  1792. 	marker_remove_trigger(M17_triggers.brig, SYNC_ALL) 
  1793. 	-- Leave the effect there, since you can still use the trigger. 
  1794. 	ingame_effect_add_trigger(M17_triggers.brig, INGAME_EFFECT_CHECKPOINT, SYNC_ALL) 
  1795.  
  1796. 	--== WAYPOINT ==-- 
  1797.  
  1798. 	-- Disable the tank bay exit spawn region 
  1799. 	spawn_region_enable(M17_regions.tank_exit, false) 
  1800.  
  1801. 	-- Mark each homie so the player can find them 
  1802. 	marker_add_trigger(M17_triggers.pierce, MINIMAP_ICON_USE, INGAME_EFFECT_LOCATION, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL) 
  1803. 	trigger_enable(M17_triggers.pierce, true) 
  1804. 	on_trigger("m17_pierce_freed", M17_triggers.pierce) 
  1805.  
  1806. 	marker_add_trigger(M17_triggers.shaundi, MINIMAP_ICON_USE, INGAME_EFFECT_LOCATION, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL) 
  1807. 	trigger_enable(M17_triggers.shaundi, true) 
  1808. 	on_trigger("m17_shaundi_freed", M17_triggers.shaundi) 
  1809.  
  1810. 	marker_add_trigger(M17_triggers.viola, MINIMAP_ICON_USE, INGAME_EFFECT_LOCATION, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL) 
  1811. 	trigger_enable(M17_triggers.viola, true) 
  1812. 	on_trigger("m17_viola_freed", M17_triggers.viola) 
  1813.  
  1814. 	-- Wait until all homies are free 
  1815. 	while M17_has_shaundi == false or M17_has_pierce == false or M17_has_viola == false do 
  1816. 		thread_yield() 
  1817. 	end 
  1818.  
  1819. 	objective_text_clear(0) 
  1820.  
  1821. 	-- Done with Kia 
  1822. 	if (M17_threads.pa ~= INVALID_THREAD_HANDLE) then 
  1823. 		thread_kill(M17_threads.pa) 
  1824. 		M17_threads.pa = INVALID_THREAD_HANDLE 
  1825. 	end 
  1826. 	if M17_personas.kia.id ~= INVALID_PERSONA_HANDLE then 
  1827. 		audio_persona_remove_2d(M17_personas.kia.id) 
  1828. 		M17_personas.kia.id = INVALID_PERSONA_HANDLE 
  1829. 	end 
  1830.  
  1831. 	-- Release the tank bay and jailor guys, as we are now past that part 
  1832. 	--release_to_world(M17_group.tanks.name) 	-- Don't release the tanks; they freak out after the mission is over  
  1833. 												-- when they find themselves in the middle of the bay if they're not destroyed. 
  1834. 	release_to_world(M17_group.jailors.name) 
  1835. 	 
  1836. 	m17_free_friends_cleanup() 
  1837. end 
  1838.  
  1839. function m17_free_friends_cleanup() 
  1840. 	on_vehicle_destroyed("", M17_group.tanks.vehicles[1]) 
  1841. 	on_vehicle_destroyed("", M17_group.tanks.vehicles[2]) 
  1842. end 
  1843.  
  1844. -- Make PA announcements every so often 
  1845. function m17_pa_kia() 
  1846. 	audio_play_persona_line_2d(M17_personas.kia.id, "M17_Kia_PA_First_Announcement") 
  1847. 	delay(8) 
  1848. 	audio_play_persona_line(LOCAL_PLAYER, "M17_Fight_To_Brig") 
  1849. 	delay(22) 
  1850. 	while(true) do 
  1851. 		audio_play_persona_line_2d(M17_personas.kia.id, "M17_PA_Attack_Player_Kia_01") 
  1852. 		delay(30) 
  1853. 		audio_play_persona_line_2d(M17_personas.kia.id, "M17_PA_Attack_Player_Kia_02") 
  1854. 		delay(30) 
  1855. 		audio_play_persona_line_2d(M17_personas.kia.id, "M17_PA_Attack_Player_Kia_03") 
  1856. 		delay(30) 
  1857. 	end 
  1858. end 
  1859.  
  1860. function m17_tank_exit_cb() 
  1861. 	m17_clear_trigger(M17_triggers.tank_exit) 
  1862. 	-- group_foreach_npc(M17_group.tanks.name, npc_leash_remove) 
  1863. end 
  1864.  
  1865. -- ************************* 
  1866. -- Objective: Destroy Reactor 
  1867. -- ************************* 
  1868.  
  1869. -- Destroy the nuclear reactor 
  1870. function m17_destroy_reactor() 
  1871. 	-- Load the blow up boat conversation 
  1872. 	M17_conv.reactor.handle = audio_conversation_load(M17_conv.reactor.name) 
  1873. 	action_nodes_enable(false) 
  1874. 	 
  1875. 	-- Spawn the brig response barricade and reactor personnel 
  1876. 	group_create(M17_group.barricade.name, true) 
  1877. 	group_create_hidden(M17_group.reactor_hall.name, false) 
  1878. 	group_create_hidden(M17_group.reactor.name, false) 
  1879. 	 
  1880. 	-- Enable the stairs spawn regions 
  1881. 	--spawn_region_enable(M17_regions.brig_exit, true) 
  1882.  
  1883. 	-- Re-enable continuous spawn groups 
  1884. 	--continuous_spawn_start(M17_group.cs_1.name, 0, 10) 
  1885.  
  1886. 	-- Tell the player to blow up the ship 
  1887. 	audio_conversation_play(M17_conv.reactor.handle) 
  1888. 	audio_conversation_wait_for_end(M17_conv.reactor.handle) 
  1889.  
  1890. 	-- Set up the ambush 
  1891. 	trigger_enable(M17_triggers.brig_esc, true) 
  1892. 	on_trigger("m17_brig_esc_flash", M17_triggers.brig_esc) 
  1893.  
  1894. 	-- Start a thread to update the PA announcements 
  1895. 	M17_threads.pa = thread_new("m17_pa_cyrus") 
  1896.  
  1897. 	-- Set the reactor room as the objective 
  1898. 	objective_text(0, "M17_OBJ_FIND_REACTOR", "", "", SYNC_ALL, OI_ASSET_LOCATION) 
  1899.  
  1900. 	-- Set up a gate as an intermediate waypoint 
  1901. 	M17_has_reached_goal = false 
  1902. 	trigger_enable(M17_triggers.brig_stairs, true) 
  1903. 	marker_add_trigger(M17_triggers.brig_stairs, MINIMAP_ICON_LOCATION, "", OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1904. 	on_trigger("m17_trigger_reached", M17_triggers.brig_stairs) 
  1905. 	 
  1906. 	-- Delay slightly and kick off the second stage of music. 
  1907. 	delay(3.0) 
  1908. 	m17_post_music_event(M17_music.music_b) 
  1909. 	 
  1910. 	while not M17_has_reached_goal do 
  1911. 		thread_yield() 
  1912. 	end 
  1913.  
  1914. 	-- Enable the lower spawn region 
  1915. 	--spawn_region_enable(M17_regions.brig_exit, false) 
  1916. 	--spawn_region_enable(M17_regions.reactor_hall, true) 
  1917.  
  1918. 	-- Show the reactor hall NPCs 
  1919. 	group_show(M17_group.reactor_hall.name) 
  1920.  
  1921. 	--== WAYPOINT ==-- 
  1922.  
  1923. 	-- Set the reactor room as the next waypoint 
  1924. 	marker_add(M17_nav_wp.reactor, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1925.  
  1926. 	-- Wait until the player reaches the bottom of the stairs 
  1927. 	M17_has_reached_goal = false 
  1928. 	trigger_enable(M17_triggers.reactor_spawn, true) 
  1929. 	on_trigger("m17_trigger_reached", M17_triggers.reactor_spawn) 
  1930. 	while not M17_has_reached_goal do 
  1931. 		thread_yield() 
  1932. 	end 
  1933.  
  1934. 	-- Release existing spawn groups as ambient 
  1935. 	--continuous_spawn_stop(M17_group.cs_1.name) 
  1936. 	 
  1937. 	-- Enable the spawn region further ahead 
  1938. 	--spawn_region_enable(M17_regions.escape_hall, true) 
  1939.  
  1940. 	-- Re-spawn continuous spawn groups further ahead 
  1941. 	--continuous_spawn_start(M17_group.cs_1.name, 0, 10) 
  1942. 	--continuous_spawn_start(M17_group.cs_2.name, 0, 10) 
  1943.  
  1944. 	-- Script some guys to run out 
  1945. 	for i, group in pairs(M17_group.reactor_hall.script[1]) do 
  1946. 		ai_do_scripted_move(group.npc, group.nav, true, false) 
  1947. 	end 
  1948.  
  1949. 	-- Wait until the player reaches the mid-hallway 
  1950. 	M17_has_reached_goal = false 
  1951. 	trigger_enable(M17_triggers.reactor_hall, true) 
  1952. 	on_trigger("m17_trigger_reached", M17_triggers.reactor_hall) 
  1953. 	while not M17_has_reached_goal do 
  1954. 		thread_yield() 
  1955. 	end 
  1956.  
  1957. 	-- Script some guys to run out 
  1958. 	for i, group in pairs(M17_group.reactor_hall.script[2]) do 
  1959. 		ai_do_scripted_move(group.npc, group.nav, true, false) 
  1960. 	end 
  1961. 	 
  1962. 	-- Show the reactor NPCs 
  1963. 	group_show(M17_group.reactor.name) 
  1964.  
  1965. 	-- Wait until the player reaches the reactor room 
  1966. 	M17_has_reached_goal = false 
  1967. 	trigger_enable(M17_triggers.enter_reactor, true) 
  1968. 	on_trigger("m17_trigger_reached", M17_triggers.enter_reactor) 
  1969. 	while M17_has_reached_goal == false do 
  1970. 		thread_yield() 
  1971. 	end 
  1972.  
  1973. 	marker_remove(M17_nav_wp.reactor, SYNC_ALL) 
  1974.  
  1975. 	--== WAYPOINT ==-- 
  1976.  
  1977. 	-- Load the blow up console conversation 
  1978. 	M17_conv.consoles.handle = audio_conversation_load(M17_conv.consoles.name) 
  1979.  
  1980. 	objective_text_clear(0) 
  1981.  
  1982. 	-- Disable continuous spawn until the reactor is blown 
  1983. 	--continuous_spawn_stop(M17_group.cs_1.name) 
  1984. 	--continuous_spawn_stop(M17_group.cs_2.name) 
  1985. 	--spawn_region_enable(M17_regions.reactor_hall, false) 
  1986. 	--spawn_region_enable(M17_regions.escape_hall, false) 
  1987.  
  1988. 	-- Set the reactor console as the goal 
  1989. 	marker_add(M17_CONSOLE, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL) 
  1990. 	objective_text(0, "M17_OBJ_DESTROY_REACTOR", "", "", SYNC_ALL, OI_ASSET_KILL) 
  1991.  
  1992. 	-- Point out the consoles 
  1993. 	audio_conversation_play(M17_conv.consoles.handle) 
  1994. 	audio_conversation_wait_for_end(M17_conv.consoles.handle) 
  1995. 	M17_conv.consoles.handle = INVALID_CONVERSATION_HANDLE 
  1996.  
  1997. 	-- Wait until the player destroys the reactor console 
  1998. 	while not mesh_mover_destroyed(M17_CONSOLE) do 
  1999. 		thread_yield() 
  2000. 	end 
  2001.  
  2002. 	--[[ 
  2003. 	-- Release the NPCs we're done with 
  2004. 	release_to_world(M17_group.barricade.name) 
  2005. 	release_to_world(M17_group.reactor_hall.name) 
  2006. 	--]] 
  2007.  
  2008. 	-- Clean up the reactor objective 
  2009. 	m17_reactor_cleanup() 
  2010.  
  2011. 	-- Pause a moment for dramatic effect 
  2012. 	delay(4) 
  2013.  
  2014. 	-- Explode everything nearby 
  2015. 	for i, effect_nav in pairs(M17_explosions.reactor) do 
  2016. 		explosion_create(M17_explosions.effect[rand_int(1, 2)], effect_nav) 
  2017. 		delay(0.1) 
  2018. 	end 
  2019. 	 
  2020. 	-- Explode all the guards in the area. 
  2021. 	M17_threads.explode_guys = thread_new("m17_blow_up_dudes_thread") 
  2022. end 
  2023.  
  2024. -- Make PA announcements every so often 
  2025. function m17_pa_cyrus() 
  2026. 	audio_conversation_wait_for_end(M17_conv.reactor.handle) 
  2027. 	M17_conv.reactor.handle = INVALID_CONVERSATION_HANDLE 
  2028. 	delay(4) 
  2029. 	audio_play_persona_line_2d(M17_personas.cyrus.id, "M17_PA_After_Prisoner_Release") 
  2030. 	delay(30) 
  2031. 	while(true) do 
  2032. 		audio_play_persona_line_2d(M17_personas.cyrus.id, "M17_PA_Attack_Player_Cyrus_01") 
  2033. 		delay(30) 
  2034. 		audio_play_persona_line_2d(M17_personas.cyrus.id, "M17_PA_Attack_Player_Cyrus_02") 
  2035. 		delay(30) 
  2036. 		audio_play_persona_line_2d(M17_personas.cyrus.id, "M17_PA_Attack_Player_Cyrus_03") 
  2037. 		delay(30) 
  2038. 	end 
  2039. end 
  2040.  
  2041. -- Clean up the reactor objective 
  2042. function m17_reactor_cleanup() 
  2043. 	-- Remove the console markers 
  2044. 	marker_remove(M17_CONSOLE, SYNC_ALL) 
  2045. 	objective_text_clear(0) 
  2046.  
  2047. 	-- Done with Cyrus 
  2048. 	if (M17_threads.pa ~= INVALID_THREAD_HANDLE) then 
  2049. 		thread_kill(M17_threads.pa) 
  2050. 		M17_threads.pa = INVALID_THREAD_HANDLE 
  2051. 	end 
  2052. end 
  2053.  
  2054. -- ************************* 
  2055. -- Objective: Escape 
  2056. -- ************************* 
  2057.  
  2058. -- Escape the carrier 
  2059. function m17_escape() 
  2060. 	-- Load the countdown conversation 
  2061. 	M17_conv.escape.handle = audio_conversation_load(M17_conv.escape.name) 
  2062. 	 
  2063. 	-- Don't allow your followers to be abandoned when you're trying to escape. 
  2064. 	follower_set_can_abandon(M17_group.captive_homies.pierce, false) 
  2065. 	follower_set_can_abandon(M17_group.captive_homies.viola, false) 
  2066. 	follower_set_can_abandon(M17_group.captive_homies.shaundi, false)	 
  2067. 	on_dismiss("", M17_group.captive_homies.pierce) 
  2068. 	on_dismiss("", M17_group.captive_homies.shaundi) 
  2069. 	on_dismiss("", M17_group.captive_homies.viola) 
  2070.  
  2071. 	action_nodes_enable(false) 
  2072. 	 
  2073. 	--[[ 
  2074. 	-- Enable the reactor and escape path spawn regions 
  2075. 	spawn_region_enable(M17_regions.reactor_1, true) 
  2076. 	spawn_region_enable(M17_regions.reactor_2, true) 
  2077. 	spawn_region_enable(M17_regions.escape_hall, true) 
  2078. 	--spawn_region_enable(M17_regions.escape_stairs, true) 
  2079.  
  2080. 	-- Restart continuous spawn in the reactor 
  2081. 	continuous_spawn_start(M17_group.cs_1.name, 0, 10) 
  2082. 	continuous_spawn_start(M17_group.cs_2.name, 0, 10) 
  2083. 	--continuous_spawn_start(M17_group.cs_3.name, 0, 10) 
  2084. 	--]] 
  2085.  
  2086. 	-- Prepare scripted events on the way out 
  2087. 	group_create(M17_group.ehall.name, true) 
  2088. 	trigger_enable(M17_triggers.ehall_1, true) 
  2089. 	on_trigger("m17_escape_event_1", M17_triggers.ehall_1) 
  2090. 	trigger_enable(M17_triggers.ehall_2, true) 
  2091. 	on_trigger("m17_escape_event_2", M17_triggers.ehall_2) 
  2092.  
  2093. 	-- Set the VTOL as the next objective 
  2094. 	objective_text(1, "M17_OBJ_ESCAPE_SHIP", "", "", SYNC_ALL, OI_ASSET_LOCATION) 
  2095.  
  2096. 	-- Set the reactor room as the next waypoint 
  2097. 	marker_add(M17_nav_wp.reactor, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  2098.  
  2099. 	-- Start the countdown 
  2100. 	hud_critical_timer_set(M17_ESCAPE_TIME, M17_ESCAPE_TIMER_TAG, "m17_fail_timer_expired", SYNC_ALL) 
  2101.  
  2102. 	-- Start a thread to create random explosions 
  2103. 	M17_threads.explosions = thread_new("m17_escape_explosions") 
  2104.  
  2105. 	-- Start a thread to tell the player to escape 
  2106. 	M17_threads.escape_talk = thread_new("m17_escape_talk") 
  2107.  
  2108. 	-- Wait until the player reaches the reactor room 
  2109. 	M17_has_reached_goal = false 
  2110. 	trigger_enable(M17_triggers.enter_reactor, true) 
  2111. 	on_trigger("m17_trigger_reached", M17_triggers.enter_reactor) 
  2112. 	while M17_has_reached_goal == false do 
  2113. 		thread_yield() 
  2114. 	end 
  2115.  
  2116. 	marker_remove(M17_nav_wp.reactor, SYNC_ALL) 
  2117.  
  2118. 	--== WAYPOINT ==-- 
  2119.  
  2120. 	-- Set the escape hallway as the next waypoint 
  2121. 	M17_has_reached_goal = false 
  2122. 	trigger_enable(M17_triggers.escape_hall, true) 
  2123. 	marker_add_trigger(M17_triggers.escape_hall, MINIMAP_ICON_LOCATION, "", OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  2124. 	on_trigger("m17_trigger_reached", M17_triggers.escape_hall) 
  2125.  
  2126. 	-- Wait until the player reaches the hallway 
  2127. 	while not M17_has_reached_goal do 
  2128. 		thread_yield() 
  2129. 	end 
  2130.  
  2131. 	--== WAYPOINT ==-- 
  2132.  
  2133. 	-- Done with the reactor 
  2134. 	release_to_world(M17_group.reactor.name) 
  2135.  
  2136. 	-- Open the way forward 
  2137. 	door_lock(M17_doors.escape_stairs, false) 
  2138.  
  2139. 	-- Set the stairs to the flight deck as the next waypoint 
  2140. 	marker_add(M17_nav_wp.escape_stairs, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  2141.  
  2142. 	-- Release existing spawn groups as ambient 
  2143. 	continuous_spawn_stop(M17_group.cs_1.name) 
  2144. 	continuous_spawn_stop(M17_group.cs_2.name) 
  2145. 	--continuous_spawn_stop(M17_group.cs_3.name) 
  2146.  
  2147. 	-- Disable the spawn regions which are now behind the player 
  2148. 	spawn_region_enable(M17_regions.reactor_1, false) 
  2149. 	spawn_region_enable(M17_regions.reactor_2, false) 
  2150. 	spawn_region_enable(M17_regions.escape_hall, false) 
  2151. 	 
  2152. 	-- Re-spawn continuous spawn groups further ahead 
  2153. 	continuous_spawn_start(M17_group.cs_1.name, 0, 10) 
  2154. 	continuous_spawn_start(M17_group.cs_2.name, 0, 10) 
  2155.  
  2156. 	-- Script some guys to walk toward the exit, firing 
  2157. 	for i, group in pairs(M17_group.ehall.script[3]) do 
  2158. 		if not character_is_dead(group.npc) then 
  2159. 			ai_add_enemy_target(group.npc, CLOSEST_PLAYER, ATTACK_NOW) 
  2160. 			ai_do_scripted_move(group.npc, group.nav, true, true) 
  2161. 		end 
  2162. 	end 
  2163.  
  2164. 	-- Wait until the player reaches the stairs 
  2165. 	while not door_is_open(M17_doors.escape_stairs) do 
  2166. 		thread_yield() 
  2167. 	end 
  2168.  
  2169. 	marker_remove(M17_nav_wp.escape_stairs, SYNC_ALL) 
  2170.  
  2171. 	--== WAYPOINT ==-- 
  2172.  
  2173. 	-- Spawn the escaping scientists 
  2174. 	-- group_create(M17_group.fire.name, true) 
  2175.  
  2176. 	-- Watch for the player to reach the top of the stairs 
  2177. 	-- trigger_enable(M17_triggers.fire, true) 
  2178. 	-- on_trigger("m17_escape_event_3", M17_triggers.fire) 
  2179.  
  2180. 	-- Open the final door 
  2181. 	trigger_enable(M17_automatic_doors.hanger_n.trigger, true) 
  2182. 	on_trigger("m17_door_enter", M17_automatic_doors.hanger_n.trigger) 
  2183. 	on_trigger_exit("m17_door_exit", M17_automatic_doors.hanger_n.trigger) 
  2184.  
  2185. 	-- Set the flight deck as the next waypoint 
  2186. 	marker_add(M17_nav_wp.hanger_n, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  2187.  
  2188. 	-- Disable the spawn regions which are now behind the player 
  2189. 	spawn_region_enable(M17_regions.escape_stairs, false) 
  2190.  
  2191. 	-- Re-enable the entry spawn regions 
  2192. 	spawn_region_enable(M17_regions.start_stairs, true) 
  2193. 	spawn_region_enable(M17_regions.start_hall, true) 
  2194.  
  2195. 	-- Spawn the hanger 
  2196. 	release_to_world(M17_group.ehall.name) 
  2197. 	group_create(M17_group.hanger.name, true) 
  2198. 	group_create(M17_group.vtol.name, true) 
  2199.  
  2200. 	-- Wait until the player reaches the flight deck 
  2201. 	M17_has_reached_goal = false 
  2202. 	trigger_enable(M17_triggers.enter_hangar, true) 
  2203. 	on_trigger("m17_trigger_reached", M17_triggers.enter_hangar) 
  2204. 	while M17_has_reached_goal == false do 
  2205. 		thread_yield() 
  2206. 	end 
  2207.  
  2208. 	marker_remove(M17_nav_wp.hanger_n, SYNC_ALL) 
  2209.  
  2210. 	--== WAYPOINT ==-- 
  2211.  
  2212. 	-- Set the VTOL as the next waypoint 
  2213. 	objective_text_clear(1) 
  2214. 	objective_text(1, "M17_OBJ_HIJACK_VTOL", "", "", SYNC_ALL, OI_ASSET_USE) 
  2215. 	marker_add(M17_group.vtol.vtol, MINIMAP_ICON_USE, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL) 
  2216. 	vehicle_set_invulnerable(M17_group.vtol.vtol) 
  2217. 	marker_add(M17_group.hanger.vtols[1], MINIMAP_ICON_USE, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL) 
  2218. 	marker_add(M17_group.hanger.vtols[2], MINIMAP_ICON_USE, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL) 
  2219. 	marker_add(M17_group.hanger.vtols[3], MINIMAP_ICON_USE, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL) 
  2220. 	for i, trigger in pairs(M17_group.hanger.triggers) do 
  2221. 		trigger_enable(trigger, true) 
  2222. 	end 
  2223. 	on_trigger("m17_fake_vtol_01_cb", M17_group.hanger.triggers[1]) 
  2224. 	on_trigger("m17_fake_vtol_02_cb", M17_group.hanger.triggers[2]) 
  2225. 	on_trigger("m17_fake_vtol_03_cb", M17_group.hanger.triggers[3]) 
  2226.  
  2227. 	-- Set people on fire 
  2228. 	explosion_create("Molotov Explosion", M17_group.hanger.npcs[2]) 
  2229. 	explosion_create("Molotov Explosion", M17_group.hanger.npcs[3]) 
  2230. 	 
  2231. 	-- Fire up a thread to automatically detonate the VTOLs if a player gets close enough. 
  2232. 	M17_threads.auto_explode_vtols = thread_new("m17_blow_up_vtols_on_proximity") 
  2233.  
  2234. 	-- Wait until the player enters the VTOL 
  2235. 	while (get_dist_closest_player_to_object(M17_group.vtol.vtol) > 20) do 
  2236. 		thread_yield() 
  2237. 	end 
  2238. 	 
  2239. 	audio_play_persona_line(LOCAL_PLAYER, "M17_Entering_Escape_VTOL") 
  2240. 	 
  2241. 	continuous_spawn_stop(M17_group.cs_1.name) 
  2242. 	continuous_spawn_stop(M17_group.cs_2.name) 
  2243.  
  2244. 	-- Clean up the escape objective 
  2245. 	m17_escape_cleanup() 
  2246. end 
  2247.  
  2248. function m17_fake_vtol_01_cb() 
  2249. 	-- Script a pilot to run toward a VTOL, then BOOM! 
  2250. 	vehicle_enter(M17_group.hanger.npcs[1], M17_group.hanger.vtols[1]) 
  2251. 	delay(2.5) 
  2252. 	audio_play_persona_line(LOCAL_PLAYER, "M17_Wrong_Vtol_Explosion_01") 
  2253. 	marker_remove(M17_group.hanger.vtols[1], SYNC_ALL) 
  2254. 	vehicle_detonate(M17_group.hanger.vtols[1]) 
  2255. end 
  2256.  
  2257. function m17_fake_vtol_02_cb() 
  2258. 	marker_remove(M17_group.hanger.vtols[2], SYNC_ALL) 
  2259. 	vehicle_detonate(M17_group.hanger.vtols[2]) 
  2260. end 
  2261.  
  2262. function m17_fake_vtol_03_cb() 
  2263. 	audio_play_persona_line(LOCAL_PLAYER, "M17_Wrong_Vtol_Explosion_02") 
  2264. 	marker_remove(M17_group.hanger.vtols[3], SYNC_ALL) 
  2265. 	vehicle_detonate(M17_group.hanger.vtols[3]) 
  2266. end 
  2267.  
  2268. -- Genarate random explosions 
  2269. function m17_escape_explosions() 
  2270. 	while(true) do 
  2271. 		-- Delay a random time and explode a random navpoint 
  2272. 		delay(0.1 * rand_int(1, 10)) 
  2273. 		explosion_create(M17_explosions.effect[rand_int(1, 2)], get_random_table_entry(M17_explosions.reactor)) 
  2274. 		delay(0.1 * rand_int(1, 10)) 
  2275. 		explosion_create(M17_explosions.effect[rand_int(1, 2)], get_random_table_entry(M17_explosions.hall)) 
  2276. 		delay(0.1 * rand_int(1, 10)) 
  2277. 		explosion_create(M17_explosions.effect[rand_int(1, 2)], get_random_table_entry(M17_explosions.deck)) 
  2278. 	end 
  2279. end 
  2280.  
  2281. -- Play the escape conversation and warn when low on time 
  2282. function m17_escape_talk() 
  2283. 	-- Announce the destruction of the ship 
  2284. 	--audio_play_persona_line_2d(M17_personas.computer.id, "M17_Computer_Countdown_01") 
  2285. 	--delay(3) 
  2286.  
  2287. 	-- Tell the player to escape 
  2288. 	audio_conversation_play(M17_conv.escape.handle) 
  2289. 	audio_conversation_wait_for_end(M17_conv.escape.handle) 
  2290. 	M17_conv.escape.handle = INVALID_CONVERSATION_HANDLE 
  2291.  
  2292. 	-- Cyrus announcement 
  2293. 	delay(4) 
  2294. 	audio_play_persona_line_2d(M17_personas.cyrus.id, "M17_Cyrus_Abandon_Ship_01") 
  2295.  
  2296. 	-- Warn the player when low on time 
  2297. 	local warning_played = 1 
  2298. 	while (warning_played < 6) do 
  2299. 		if (warning_played == 1) and (hud_critical_timer_get_remainder() < 120000) then 
  2300. 			warning_played = 2 
  2301. 		--	audio_play_persona_line_2d(M17_personas.computer.id, "M17_Computer_Countdown_02") 
  2302. 		elseif (warning_played == 2) and (hud_critical_timer_get_remainder() < 90000) then 
  2303. 			warning_played = 3 
  2304. 			audio_play_persona_line(M17_group.captive_homies.pierce, "M17_Meltdown_Timer") 
  2305. 		elseif (warning_played == 3) and (hud_critical_timer_get_remainder() < 60000) then 
  2306. 			warning_played = 4 
  2307. 		--	audio_play_persona_line_2d(M17_personas.computer.id, "M17_Computer_Countdown_03") 
  2308. 			delay(5) 
  2309. 			audio_play_persona_line_2d(M17_personas.cyrus.id, "M17_Cyrus_Abandon_Ship_02") 
  2310. 		elseif (warning_played == 4) and (hud_critical_timer_get_remainder() < 30000) then 
  2311. 			warning_played = 5 
  2312. 		--	audio_play_persona_line_2d(M17_personas.computer.id, "M17_Computer_Countdown_04") 
  2313. 		end 
  2314.  
  2315. 		thread_yield() 
  2316. 	end 
  2317. end 
  2318.  
  2319. -- Clean up the escape objective 
  2320. function m17_escape_cleanup() 
  2321. 	-- Stop the explosions thread 
  2322. 	if (M17_threads.explosions ~= INVALID_THREAD_HANDLE) then 
  2323. 		thread_kill(M17_threads.explosions) 
  2324. 		M17_threads.explosions = INVALID_THREAD_HANDLE 
  2325. 	end 
  2326.  
  2327. 	-- Stop the talk thread 
  2328. 	if (M17_threads.escape_talk ~= INVALID_THREAD_HANDLE) then 
  2329. 		thread_kill(M17_threads.escape_talk) 
  2330. 		M17_threads.escape_talk = INVALID_THREAD_HANDLE 
  2331. 	end 
  2332.  
  2333. 	-- Stop the VTOL auto detonate thread 
  2334. 	if (M17_threads.auto_explode_vtols ~= INVALID_THREAD_HANDLE) then 
  2335. 		thread_kill(M17_threads.auto_explode_vtols) 
  2336. 		M17_threads.auto_explode_vtols = INVALID_THREAD_HANDLE 
  2337. 	end 
  2338.  
  2339. 	-- Clean up VTOLs 
  2340. 	if group_is_loaded(M17_group.hanger.name) then 
  2341. 		for i, vtol in pairs(M17_group.hanger.vtols) do 
  2342. 			marker_remove(vtol, SYNC_ALL) 
  2343. 		end 
  2344. 		group_destroy(M17_group.hanger.name) 
  2345. 	end 
  2346. 	 
  2347. 	for i, trigger in pairs(M17_group.hanger.triggers) do 
  2348. 		trigger_enable(trigger, false) 
  2349. 		on_trigger("", trigger) 
  2350. 	end 
  2351.  
  2352. 	hud_critical_timer_stop() 
  2353. 	objective_text_clear(1) 
  2354. end 
  2355.  
  2356. -- ************************* 
  2357. -- 
  2358. -- Callback functions 
  2359. -- 
  2360. -- ************************* 
  2361.  
  2362. function m17_heli_entered() 
  2363. 	-- Check if either player is in an aircraft 
  2364. 	local v_type_p = get_char_vehicle_type(LOCAL_PLAYER) 
  2365. 	local v_type_c = VT_NONE 
  2366. 	if (M17_in_coop == true) then 
  2367. 		v_type_c = get_char_vehicle_type(REMOTE_PLAYER) 
  2368. 	end 
  2369.  
  2370. 	if ((v_type_p == VT_HELICOPTER) or (v_type_c == VT_HELICOPTER)) or ((v_type_p == VT_AIRPLANE) or (v_type_c == VT_AIRPLANE)) or ((v_type_p == VT_VTOL) or (v_type_c == VT_VTOL)) then 
  2371. 		-- Mark the next goal as reached 
  2372. 		m17_clear_trigger(M17_triggers.armory) 
  2373. 		mission_waypoint_remove() 
  2374. 		M17_has_reached_goal = true 
  2375. 	end 
  2376. end 
  2377.  
  2378. -- Reached the next trigger 
  2379. function m17_trigger_reached(char, trig) 
  2380. 	m17_clear_trigger(trig) 
  2381.  
  2382. 	-- Mark the next goal as reached 
  2383. 	M17_has_reached_goal = true 
  2384. end 
  2385.  
  2386. -- Open a door automatically when someone nears it 
  2387. function m17_door_enter(char, trig) 
  2388. 	for i, auto in pairs(M17_automatic_doors) do 
  2389. 		if (trig == auto.trigger) then 
  2390. 			door_open(auto.door) 
  2391. 		end 
  2392. 	end 
  2393. end 
  2394.  
  2395. -- Close a door automatically when noone is near it 
  2396. function m17_door_exit(char, trig) 
  2397. 	-- If someone else is still in the region, leave it open 
  2398. 	if (get_num_humans_in_trigger(trig) > 0) then 
  2399. 		return 
  2400. 	end 
  2401.  
  2402. 	-- Close the door 
  2403. 	for i, auto in pairs(M17_automatic_doors) do 
  2404. 		if (trig == auto.trigger) then 
  2405. 			door_close(auto.door) 
  2406. 		end 
  2407. 	end 
  2408. end 
  2409.  
  2410. -- Activate anti-tank spawns once two of the tanks in the tank bay have been destroyed. 
  2411. function m17_antitank_spawn_cb() 
  2412. 	if (character_is_in_vehicle(LOCAL_PLAYER) or character_is_in_vehicle(REMOTE_PLAYER)) then 
  2413. 		if (vehicle_is_destroyed(M17_group.tanks.vehicles[1]) and vehicle_is_destroyed(M17_group.tanks.vehicles[2])) then 
  2414. 			audio_play_persona_line_2d(M17_personas.cyrus.id, "M17_PA_Anti_Armor_On_Tanks") 
  2415. 			 
  2416. 			-- Stop regular continuous spawns 
  2417. 			continuous_spawn_stop(M17_group.cs_1.name) 
  2418. 			continuous_spawn_stop(M17_group.cs_2.name) 
  2419. 			 
  2420. 			-- Start anti-tank continuous spawns 
  2421. 			continuous_spawn_start(M17_group.at_1.name, 2, 10) 
  2422. 			continuous_spawn_start(M17_group.at_2.name, 2, 10) 
  2423. 		end 
  2424. 	end 
  2425. end 
  2426.  
  2427. -- Toggle the open brig doors when activated 
  2428. function m17_brig_activated(char, trigger) 
  2429. 	-- Play the door open anim on the player. 
  2430. 	action_play(char, M17_KEYPAD_ANIM, M17_KEYPAD_ANIM, false, 0.8, false, true, M17_nav_anim.brig) 
  2431. 	delay(M17_KEYPAD_DELAY) 
  2432. 	 
  2433. 	-- Make some audio magic. 
  2434. 	audio_object_post_event("m17_cell_door_terminal_activate") 
  2435. 	 
  2436. 	if door_is_open(M17_doors.brig_inner) then 
  2437. 		door_close(M17_doors.brig_inner) 
  2438. 		delay(1) 
  2439. 		-- door_open(M17_doors.brig_outer) 
  2440. 		-- delay(1) 
  2441. 	else 
  2442. 		-- door_close(M17_doors.brig_outer) 
  2443. 		-- delay(1) 
  2444. 		door_open(M17_doors.brig_inner) 
  2445. 		delay(1) 
  2446. 	end 
  2447. 	 
  2448. 	-- Enable the trigger to get back in if someone is stuck outside (co-op) 
  2449. 	trigger_enable(M17_triggers.brig_entry) 
  2450. 	on_trigger("m17_brig_entry_activated", M17_triggers.brig_entry) 
  2451. 	ingame_effect_add_trigger(M17_triggers.brig_entry, INGAME_EFFECT_CHECKPOINT, SYNC_ALL) 
  2452. end 
  2453.  
  2454. -- Opens the door into the brig control room for 5 seconds. 
  2455. function m17_brig_entry_activated(char, trigger) 
  2456. 	-- Play the door open anim on the player. 
  2457. 	action_play(char, M17_KEYPAD_ANIM, M17_KEYPAD_ANIM, false, 0.8, false, true, M17_nav_anim.brig_entry) 
  2458. 	delay(M17_KEYPAD_DELAY) 
  2459. 	 
  2460. 	door_open(M17_doors.brig_outer) 
  2461. 	delay(5.0) 
  2462. 	door_close(M17_doors.brig_outer) 
  2463. end 
  2464.  
  2465. function m17_pierce_freed(char, trig) 
  2466. 	-- First thing, disable the trigger. 
  2467. 	m17_clear_trigger(trig) 
  2468. 	 
  2469. 	-- There's a slim chance the players could manage to double up the trigger, so prevent that. 
  2470. 	if M17_began_freeing_pierce then 
  2471. 		return 
  2472. 	end 
  2473. 	M17_began_freeing_pierce = true 
  2474. 	 
  2475. 	-- Let your homie talk again. 
  2476. 	npc_suppress_persona(M17_group.captive_homies.pierce, false) 
  2477. 	 
  2478. 	-- Play the door open anim on the player. 
  2479. 	action_play(char, M17_KEYPAD_ANIM, M17_KEYPAD_ANIM, false, 0.8, false, true, M17_nav_anim.pierce_cell) 
  2480. 	delay(M17_KEYPAD_DELAY) 
  2481. 	 
  2482. 	-- Open the door 
  2483. 	door_open(M17_doors.pierce) 
  2484. 	 
  2485. 	-- Wait to make sure we don't stomp on one of the other prisoner freed conversations. 
  2486. 	M17_threads.convo_failsafe = thread_new("delay", 5.0) 
  2487. 	while audio_persona_line_playing(M17_group.captive_homies.viola) and not thread_check_done(M17_threads.convo_failsafe) do 
  2488. 		thread_yield() 
  2489. 	end 
  2490. 	M17_threads.convo_failsafe = INVALID_THREAD_HANDLE 
  2491. 	 
  2492. 	audio_conversation_wait_for_end(M17_conv.shaundi_thanks.handle) 
  2493.  
  2494. 	-- Add as a homie 
  2495. 	party_add_ignore_limits(M17_group.captive_homies.pierce, char) 
  2496. 	set_ignore_ai_flag(M17_group.captive_homies.pierce, false) 
  2497. 	set_dont_attack_me_on_sight_flag(M17_group.captive_homies.pierce, false) 
  2498. 	follower_set_can_abandon(M17_group.captive_homies.pierce, true) 
  2499. 	on_dismiss("m17_fail_dismissed_cb", M17_group.captive_homies.pierce) 
  2500.  
  2501. 	audio_conversation_wait_for_end(M17_conv.shaundi_thanks.handle) 
  2502. 	audio_play_persona_line(M17_group.captive_homies.pierce, "M17_Pierce_Thanks") 
  2503. 	 
  2504. 	M17_has_pierce = true 
  2505. end 
  2506.  
  2507. function m17_shaundi_freed(char, trig) 
  2508. 	-- First thing, disable the trigger. 
  2509. 	m17_clear_trigger(trig) 
  2510. 	 
  2511. 	-- There's a slim chance the players could manage to double up the trigger, so prevent that. 
  2512. 	if M17_began_freeing_shaundi then 
  2513. 		return 
  2514. 	end 
  2515. 	M17_began_freeing_shaundi = true 
  2516. 	 
  2517. 	-- Let your homie talk again. 
  2518. 	npc_suppress_persona(M17_group.captive_homies.shaundi, false) 
  2519. 	 
  2520. 	-- Play the door open anim on the player. 
  2521. 	action_play(char, M17_KEYPAD_ANIM, M17_KEYPAD_ANIM, false, 0.8, false, true, M17_nav_anim.shaundi_cell) 
  2522. 	delay(M17_KEYPAD_DELAY) 
  2523. 	 
  2524. 	-- Load the Shaundi thanks conversation 
  2525. 	M17_conv.shaundi_thanks.handle = audio_conversation_load(M17_conv.shaundi_thanks.name) 
  2526.  
  2527. 	-- Open the door 
  2528. 	door_open(M17_doors.shaundi) 
  2529. 	 
  2530. 	-- Wait to make sure we don't stomp on one of the other prisoner freed conversations. 
  2531. 	M17_threads.convo_failsafe = thread_new("delay", 5.0) 
  2532. 	while audio_persona_line_playing(M17_group.captive_homies.viola) and not thread_check_done(M17_threads.convo_failsafe) do 
  2533. 		thread_yield() 
  2534. 	end 
  2535. 	M17_threads.convo_failsafe = thread_new("delay", 5.0) 
  2536. 	while audio_persona_line_playing(M17_group.captive_homies.pierce) and not thread_check_done(M17_threads.convo_failsafe) do 
  2537. 		thread_yield() 
  2538. 	end 
  2539. 	M17_threads.convo_failsafe = INVALID_THREAD_HANDLE 
  2540.  
  2541. 	-- Add as a homie 
  2542. 	party_add_ignore_limits(M17_group.captive_homies.shaundi, char) 
  2543. 	set_ignore_ai_flag(M17_group.captive_homies.shaundi, false) 
  2544. 	set_dont_attack_me_on_sight_flag(M17_group.captive_homies.shaundi, false) 
  2545. 	follower_set_can_abandon(M17_group.captive_homies.shaundi, true) 
  2546. 	on_dismiss("m17_fail_dismissed_cb", M17_group.captive_homies.shaundi) 
  2547.  
  2548. 	-- Talk to Shaundi 
  2549. 	audio_conversation_play(M17_conv.shaundi_thanks.handle) 
  2550. 	audio_conversation_wait_for_end(M17_conv.shaundi_thanks.handle) 
  2551. 	M17_conv.shaundi_thanks.handle = INVALID_CONVERSATION_HANDLE 
  2552. 	 
  2553. 	M17_has_shaundi = true 
  2554. end 
  2555.  
  2556. function m17_viola_freed(char, trig) 
  2557. 	-- First thing, disable the trigger. 
  2558. 	m17_clear_trigger(trig) 
  2559. 	 
  2560. 	-- There's a slim chance the players could manage to double up the trigger, so prevent that. 
  2561. 	if M17_began_freeing_viola then 
  2562. 		return 
  2563. 	end 
  2564. 	M17_began_freeing_viola = true 
  2565. 	 
  2566. 	-- Let your homie talk again. 
  2567. 	npc_suppress_persona(M17_group.captive_homies.viola, false) 
  2568. 	 
  2569. 	-- Play the door open anim on the player. 
  2570. 	action_play(char, M17_KEYPAD_ANIM, M17_KEYPAD_ANIM, false, 0.8, false, true, M17_nav_anim.viola_cell) 
  2571. 	delay(M17_KEYPAD_DELAY) 
  2572. 	 
  2573. 	-- Open the door 
  2574. 	door_open(M17_doors.viola) 
  2575. 	 
  2576. 	-- Wait to make sure we don't stomp on one of the other prisoner freed conversations. 
  2577. 	M17_threads.convo_failsafe = thread_new("delay", 5.0) 
  2578. 	while audio_persona_line_playing(M17_group.captive_homies.pierce) and not thread_check_done(M17_threads.convo_failsafe) do 
  2579. 		thread_yield() 
  2580. 	end 
  2581. 	M17_threads.convo_failsafe = INVALID_THREAD_HANDLE 
  2582. 	 
  2583. 	audio_conversation_wait_for_end(M17_conv.shaundi_thanks.handle) 
  2584.  
  2585. 	-- Add as a homie 
  2586. 	party_add_ignore_limits(M17_group.captive_homies.viola, char) 
  2587. 	set_ignore_ai_flag(M17_group.captive_homies.viola, false) 
  2588. 	set_dont_attack_me_on_sight_flag(M17_group.captive_homies.viola, false) 
  2589. 	follower_set_can_abandon(M17_group.captive_homies.viola, true) 
  2590. 	on_dismiss("m17_fail_dismissed_cb", M17_group.captive_homies.viola) 
  2591.  
  2592. 	audio_conversation_wait_for_end(M17_conv.shaundi_thanks.handle) 
  2593. 	audio_play_persona_line(M17_group.captive_homies.viola, "M17_Viola_Thanks") 
  2594. 	 
  2595. 	M17_has_viola = true 
  2596. end 
  2597.  
  2598. function m17_brig_esc_flash() 
  2599. 	-- Clear the trigger 
  2600. 	trigger_enable(M17_triggers.brig_esc, false) 
  2601. 	on_trigger("", M17_triggers.brig_esc) 
  2602.  
  2603. 	-- Open the way forward 
  2604. 	door_open(M17_doors.brig_big) 
  2605. 	door_open(M17_doors.brig_ambush) 
  2606. 	delay(1.0) 
  2607. 	 
  2608. 	-- Throw the flashbangs 
  2609. 	for i, char in pairs(M17_group.barricade.npcs) do 
  2610. 		explosion_create("Flashbang", M17_nav_barricade[i], char, false) 
  2611. 		delay(0.1) 
  2612. 	end 
  2613. 	 
  2614. 	-- Send the barricaders into the room 
  2615. 	for i,npc in pairs(M17_group.barricade.npcs) do 
  2616. 		ai_do_scripted_move(npc, M17_nav_barricade[i], true, false) 
  2617. 	end 
  2618.  
  2619. 	-- Play a response 
  2620. 	M17_conv.flash_bang.handle = audio_conversation_load(M17_conv.flash_bang.name) 
  2621. 	audio_conversation_end(M17_conv.reactor.handle) 
  2622. 	M17_conv.reactor.handle = INVALID_CONVERSATION_HANDLE 
  2623. 	audio_conversation_play(M17_conv.flash_bang.handle) 
  2624. 	audio_conversation_wait_for_end(M17_conv.flash_bang.handle) 
  2625. 	M17_conv.flash_bang.handle = INVALID_CONVERSATION_HANDLE 
  2626. end 
  2627.  
  2628. function m17_escape_event_1(char, trig) 
  2629. 	-- Clear the trigger 
  2630. 	trigger_enable(trig, false) 
  2631. 	on_trigger("", trig) 
  2632.  
  2633. 	-- BOOM!  Knock the guy across the intersection 
  2634. 	explosion_create(M17_explosions.effect[1], M17_group.ehall.explosion[1], nil, false) 
  2635. 	if not character_is_dead(M17_group.ehall.script[1]) then 
  2636. 		character_kill(M17_group.ehall.script[1]) 
  2637. 	end 
  2638. end 
  2639.  
  2640. function m17_escape_event_2(char, trig) 
  2641. 	-- Clear the trigger 
  2642. 	trigger_enable(trig, false) 
  2643. 	on_trigger("", trig) 
  2644.  
  2645. 	-- Script some guys to run out 
  2646. 	for i, group in pairs(M17_group.ehall.script[2]) do 
  2647. 		if not character_is_dead(group.npc) then 
  2648. 			ai_do_scripted_move(group.npc, group.nav, true, false) 
  2649. 		end 
  2650. 	end 
  2651.  
  2652. 	-- Wait for it... 
  2653. 	delay(3) 
  2654.  
  2655. 	-- BOOM! 
  2656. 	explosion_create(M17_explosions.effect[1], M17_group.ehall.explosion[2], nil, false) 
  2657. 	for i, group in pairs(M17_group.ehall.script[2]) do 
  2658. 		if not character_is_dead(group.npc) then 
  2659. 			character_kill(group.npc) 
  2660. 		end 
  2661. 	end 
  2662.  
  2663. 	-- Stumble the players (can't call non-blocking because it will never give control back to the player) 
  2664. 	thread_new("m17_stumble", LOCAL_PLAYER, M17_group.ehall.explosion[2]) 
  2665. 	if (coop_is_active() == true) then 
  2666. 		thread_new("m17_stumble", REMOTE_PLAYER, M17_group.ehall.explosion[2]) 
  2667. 	end 
  2668.  
  2669. 	-- Stumble the homies 
  2670. 	--if (character_is_ready(M17_group.captive_homies.pierce) and (not character_playing_combat_move(M17_group.captive_homies.pierce)) and (not character_is_jumping(M17_group.captive_homies.pierce))) then 
  2671. 	--	character_release_human_shield(M17_group.captive_homies.pierce, true) 
  2672. 	--	action_play_non_blocking(M17_group.captive_homies.pierce, "Plane Cabin Stumble") 
  2673. 	--end 
  2674. 	--if (character_is_ready(M17_group.captive_homies.shaundi) and (not character_playing_combat_move(M17_group.captive_homies.shaundi)) and (not character_is_jumping(M17_group.captive_homies.shaundi))) then 
  2675. 	--	character_release_human_shield(M17_group.captive_homies.shaundi, true) 
  2676. 	--	action_play_non_blocking(M17_group.captive_homies.shaundi, "Plane Cabin Stumble") 
  2677. 	--end 
  2678. 	--if (character_is_ready(M17_group.captive_homies.viola) and (not character_playing_combat_move(M17_group.captive_homies.viola)) and (not character_is_jumping(M17_group.captive_homies.viola))) then 
  2679. 	--	character_release_human_shield(M17_group.captive_homies.viola, true) 
  2680. 	--	action_play_non_blocking(M17_group.captive_homies.viola, "Plane Cabin Stumble") 
  2681. 	--end 
  2682. end 
  2683.  
  2684. function m17_escape_event_3(char, trig) 
  2685. 	-- Clear the trigger 
  2686. 	trigger_enable(trig, false) 
  2687. 	on_trigger("", trig) 
  2688.  
  2689. 	-- Set some scientists on fire 
  2690. 	for i, npc in pairs(M17_group.fire.script[2]) do 
  2691. 		explosion_create("Molotov Explosion", npc) 
  2692. 	end 
  2693.  
  2694. 	-- Send the rest running for the exit 
  2695. 	for i, npc in pairs(M17_group.fire.script[1]) do 
  2696. 		set_always_cower_flag(npc, true) 
  2697. 		ai_do_scripted_move(npc, M17_group.fire.nav[1], true, false) 
  2698. 	end 
  2699.  
  2700. 	-- Set another on fire after a bit 
  2701. 	delay(4) 
  2702. 	explosion_create("Molotov Explosion", M17_group.fire.script[1][4]) 
  2703. 	delay(2) 
  2704. 	explosion_create("Molotov Explosion", M17_group.fire.script[1][2]) 
  2705. end 
  2706.  
  2707. function m17_fail_suspicion() 
  2708. 	-- End the mission, the carrier blew up 
  2709. 	mission_end_failure("m17", "m17_failure_follow") 
  2710. end 
  2711.  
  2712. function m17_fail_timer_expired() 
  2713. 	-- End the mission, the carrier blew up 
  2714. 	mission_end_failure("m17", "m17_failure_escape") 
  2715. end 
  2716.  
  2717. function m17_fail_pierce_died() 
  2718. 	-- End the mission, Pierce died 
  2719. 	mission_end_failure("m17", "m17_failure_pierce_died") 
  2720. end 
  2721.  
  2722. function m17_fail_shaundi_died() 
  2723. 	-- End the mission, Shaundi died 
  2724. 	mission_end_failure("m17", "m17_failure_shaundi_died") 
  2725. end 
  2726.  
  2727. function m17_fail_viola_died() 
  2728. 	-- End the mission, Viola died 
  2729. 	mission_end_failure("m17", "m17_failure_viola_died") 
  2730. end 
  2731.  
  2732. function m17_fail_dismissed_cb() 
  2733. 	mission_end_failure("m17", "m17_failure_homie_abandoned") 
  2734. end 
  2735.  
  2736. -- ************************* 
  2737. -- 
  2738. -- Thread functions 
  2739. -- 
  2740. -- ************************* 
  2741.  
  2742. -- Fails the mission if the player reaches level 1 police notoriety. 
  2743. -- 
  2744. function m17_monitor_police_notoriety_thread() 
  2745. 	-- Loop until killed. 
  2746. 	while true do 
  2747. 		if M17_stealh_section == false then 
  2748. 			return 
  2749. 		end 
  2750. 		if notoriety_get("police") > 0 then 
  2751. 			m17_fail_suspicion() 
  2752. 			return 
  2753. 		end 
  2754. 		thread_yield() 
  2755. 	end 
  2756. end 
  2757.  
  2758. -- Immediately destroys any of the VTOLs that are scripted to explode in the 
  2759. -- hangar if a player gets too close to them. 
  2760. -- 
  2761. function m17_blow_up_vtols_on_proximity() 
  2762. 	-- Just loop until the thread is killed. 
  2763. 	while true do 
  2764. 		for i, vtol in pairs(M17_group.hanger.vtols) do 
  2765. 			if vehicle_exists(vtol) then 
  2766. 				if vehicle_is_destroyed(vtol) == false then 
  2767. 					if get_dist(vtol, LOCAL_PLAYER) < M17_ESCAPE_VTOL_AUTO_SPLODE_DIST then 
  2768. 						vehicle_detonate(vtol) 
  2769. 					elseif coop_is_active() and get_dist(vtol, REMOTE_PLAYER) < M17_ESCAPE_VTOL_AUTO_SPLODE_DIST then 
  2770. 						vehicle_detonate(vtol) 
  2771. 					end 
  2772. 				end 
  2773. 			end 
  2774. 		end 
  2775. 		thread_yield() 
  2776. 	end 
  2777. end 
  2778.  
  2779. -- For every guy in the provided table, this function creates an explosion 
  2780. -- at their position and kills them, with a slight delay between booms. 
  2781. -- 
  2782. function m17_blow_up_dudes_thread() 
  2783. 	local dist_okay = true 
  2784. 	for i, group in pairs(M17_self_exploding_guys) do 
  2785. 		for i, dude in pairs(group.npcs) do 
  2786. 			-- Make sure this guy isn't too close to a player. 
  2787. 			dist_okay = (get_dist(dude, LOCAL_PLAYER) > 3.0) 
  2788. 			if dist_okay == true and coop_is_active() then 
  2789. 				dist_okay = (get_dist(dude, REMOTE_PLAYER) > 3.0) 
  2790. 			end 
  2791. 			 
  2792. 			if dist_okay == true then 
  2793. 				-- This guy's far enough from a player.  Blow him up! 
  2794. 				delay(rand_float(0.25, 0.75)) 
  2795. 				explosion_create(M17_explosions.effect[2], dude, nil, nil, nil, 1.0) 
  2796. 				character_kill(dude) 
  2797. 			end 
  2798. 		end 
  2799. 	end 
  2800. end 
  2801.  
  2802. -- Thread used to disable notoriety stuff at the beginning of the mission. 
  2803. -- 
  2804. function m17_disable_notoriety_for_drive_to_armory_thread() 
  2805. 	m17_disable_notoriety_stuff_for_drive_to_armory() 
  2806. 	 
  2807. 	-- Set up the NG armory island trigger which will also re-enable notoriety. 
  2808. 	trigger_enable(M17_triggers.armory_island, true) 
  2809. 	on_trigger("m17_enter_armory_island_cb", M17_triggers.armory_island) 
  2810. 	 
  2811. 	-- Wait until our time limit on disabled notoriety elapses. 
  2812. 	delay(M17_NO_NOTORIETY_TIME) 
  2813. 	 
  2814. 	m17_enable_notoriety_stuff_after_drive_to_armory() 
  2815. end 
  2816.  
  2817. -- Thread to make Kia follow her path. 
  2818. -- 
  2819. function m17_kia_path_thread() 
  2820. 	for i, nav_name in pairs(M17_path_kia) do 
  2821. 		-- Walk to the nav, retry if we fail.  The thread will be killed 
  2822. 		-- even if we get stuck somehow. 
  2823. 		local path_index = move_to_do(M17_group.kia.kia, nav_name, 1, true, false, false, 0) 
  2824. 		while get_dist(M17_group.kia.kia, nav_name) > 0.5 do 
  2825. 			if move_to_check_done(path_index, M17_group.kia.kia, nav_name, 1, true, false, false, 0) then 
  2826. 				-- Looks like we failed somehow, try again. 
  2827. 				path_index = move_to_do(M17_group.kia.kia, nav_name, 1, true, false, false, 0) 
  2828. 			end 
  2829. 			thread_yield() 
  2830. 		end 
  2831. 	end 
  2832. 	ai_clear_scripted_action(M17_group.kia.kia) 
  2833. end 
  2834.  
  2835. -- Thread to make STAG dudes salute the player as they walk by while following Kia. 
  2836. -- 
  2837. function m17_salute_thread() 
  2838. 	-- Loop until the thread is killed. 
  2839. 	while true do 
  2840. 		-- We can't script dudes on action nodes, so just settle for the guys we spawn from scripting. 
  2841. 		for i, npc in pairs(M17_group.ambush.npcs) do 
  2842. 			if npc.has_saluted == false and get_dist(npc.name, LOCAL_PLAYER) < M17_SALUTE_DIST then 
  2843. 				npc.has_saluted = true 
  2844. 			 
  2845. 				-- Turn to face the player. 
  2846. 				turn_to(npc.name, LOCAL_PLAYER) 
  2847. 				 
  2848. 				-- Play the salute action, don't block for it to finish. 
  2849. 				action_play_non_blocking(npc.name, "stag stand salute") 
  2850. 				 
  2851. 				-- Go back into idle, otherwise they tend to start wandering around all hunched over and comat ready. 
  2852. 				ai_suggest_action(npc.name, "idle") 
  2853. 				character_set_combat_ready(npc.name, false) 
  2854. 			end 
  2855. 		end 
  2856. 		 
  2857. 		-- Only check every so often. 
  2858. 		delay(0.5) 
  2859. 	end 
  2860. end 
  2861.  
  2862. -- Thread to process player stumble animations (can't call non-blocking because it will never give control back to the player) 
  2863. -- 
  2864. -- player: 	Player to play the stumble animation for 
  2865. -- nav:     The nav to stumble away from. 
  2866. -- 
  2867. function m17_stumble(player, nav) 
  2868. 	player_release_human_shield(player, true) 
  2869. 	character_clear_combat_move(player)  
  2870. 	if (character_is_ready(player) and (not character_is_jumping(player))) then 
  2871. 		action_play_directional_stumble(player, nav) 
  2872. 	end 
  2873. end 
  2874.  
  2875. -- ************************* 
  2876. -- 
  2877. -- Helper functions 
  2878. -- 
  2879. -- ************************* 
  2880.  
  2881. -- Posts a music event. 
  2882. -- 
  2883. -- event_name:  Name of the event to post. 
  2884. -- 
  2885. function m17_post_music_event(event_name) 
  2886. 	audio_object_post_event(event_name, nil, nil, LOCAL_PLAYER) 
  2887. end 
  2888.  
  2889. -- Sets up the mission to fail if a player breaks their cover. 
  2890. -- 
  2891. function m17_begin_stealth_section() 
  2892. 	-- Register a callback to check to for anything that would blow the players cover 
  2893. 	M17_stealh_section = true 
  2894. 	M17_threads.police_notoriety_monitor = thread_new("m17_monitor_police_notoriety_thread") 
  2895. end 
  2896.  
  2897. -- Cleans up a stealth section for this mission. 
  2898. -- 
  2899. function m17_cleanup_stealth_section() 
  2900. 	M17_stealh_section = false 
  2901. 	thread_kill(M17_threads.police_notoriety_monitor) 
  2902. 	M17_threads.police_notoriety_monitor = INVALID_THREAD_HANDLE 
  2903. end 
  2904.  
  2905. -- Re-enables notoriety and cleans up the trigger and the notoriety thread if it's running. 
  2906. -- 
  2907. function m17_clean_up_notoriety_stuff_for_driving_to_armory() 
  2908. 	if M17_threads.no_notoriety ~= INVALID_THREAD_HANDLE then 
  2909. 		thread_kill(M17_threads.no_notoriety) 
  2910. 	end 
  2911. 	M17_threads.no_notoriety = INVALID_THREAD_HANDLE 
  2912. 	 
  2913. 	m17_clear_trigger(M17_triggers.armory_island) 
  2914. 	 
  2915. 	m17_enable_notoriety_stuff_after_drive_to_armory() 
  2916. end 
  2917.  
  2918. -- Prevent the player from getting any notoriety while driving to the NG island and disable ambient cop spawns. 
  2919. -- 
  2920. function m17_disable_notoriety_stuff_for_drive_to_armory() 
  2921. 	spawning_allow_cop_ambient_spawns(false) 
  2922. 	notoriety_set_max("police", 0) 
  2923. end 
  2924.  
  2925. -- Undo anything we do in m17_disable_notoriety_stuff_for_drive_to_armory. 
  2926. -- 
  2927. function m17_enable_notoriety_stuff_after_drive_to_armory() 
  2928. 	spawning_allow_cop_ambient_spawns(true) 
  2929. 	notoriety_reset("police") 
  2930. end 
  2931.  
  2932. -- Equips the player's pistol or gives them a temporary pistol to match the 
  2933. -- fact that the player had their pistol equipped at the end of the meeting 
  2934. -- cutscene. 
  2935. -- 
  2936. function m17_equip_pistol() 
  2937. 	local pistol_name = inv_item_in_slot(LOCAL_PLAYER, "pistol") 
  2938. 	if pistol_name ~= "none" then 
  2939. 		inv_item_equip(pistol_name, LOCAL_PLAYER) 
  2940. 	else 
  2941. 		-- The player has no pistol, give them a crappy temporary pistol. 
  2942. 		inv_weapon_add_temporary(LOCAL_PLAYER, M17_TEMP_PISTOL_NAME, 1, false, true) 
  2943. 	end 
  2944. end 
  2945.