./m16.lua

  1. --[[ 
  2. 	m16.lua 
  3. 	SR3 Mission Script 
  4. 	DATE: 07-21-10 
  5. 	AUTHOR:	John Karczewski 
  6. ]]-- 
  7.  
  8. -- Debug flags -- 
  9.  
  10. -- Tweakable Parameters -- 
  11. 		DELAY_BETWEEN_DECKER_GROUP_SPAWNS 		= 0.3 -- in ms -- this controls the time between each individual decker spawn when spawning a group 
  12. 		 
  13. 	-- Firewalls -- 
  14. 		TIME_BETWEEN_GATE_SPAWNS				= 8 -- seconds 
  15. 		TIME_UNTIL_KINZIE_UNLOCKS_LOCK			= 45 -- seconds 
  16. 		 
  17. 		FW1_SLOW_DURATION 						= 5000 -- ms 
  18. 		FW1_CHEAT_PERIOD						= 10000 -- ms, how often the cheat will occur 
  19. 		 
  20. 		FW2_LAG_DURATION 						= 6000 -- ms 
  21. 		FW2_CHEAT_PERIOD						= 7000 -- ms, how often the cheat will occur 
  22. 		 
  23. 		FW3_INVERT_DURATION 					= 3000 -- ms 
  24. 		FW3_CHEAT_PERIOD						= 10000 -- ms, how often the cheat will occur 
  25.  
  26. 	-- Matt Boss Battle-- 
  27. 		MATT_COOP_HEALTH_MULTIPLIER   		 	= 2.0 -- increases matt's max hp when in coop 
  28. 		TIME_BETWEEN_AIR_TELEPORTS				= 3.8 -- seconds 
  29. 		TIME_BETWEEN_GROUND_TELEPORTS			= 5 -- seconds 
  30. 		HP_PERCENT_TO_BULLRUSH					= .50 
  31. 		HP_PERCENT_TO_DOWN_P2					= .75 
  32. 		HP_PERCENT_TO_DOWN_P3					= .35 
  33. 		HP_PERCENT_TO_DOWN_P5					= .25 
  34. 		 
  35. 		-- QTE Fail Hp values -- 
  36. 		HP_P1_QTE_FAIL							= .75 
  37. 		HP_P5_QTE_FAIL							= .50 
  38. 	 
  39. 		-- Decker Phase -- 
  40. 		DECKER_SPAWN_RATE						= 1.5 
  41. 		DECKER_SEQUENCE_DURATION				= 45 
  42. 	 
  43. 		-- Avatar Battle -- 
  44. 		M16_MIN_DISTANCE_FOR_TELEPORT			= 22.5 -- Min distance for a teleport navopint to be valid 
  45. 		M16_PLAYER_DISTANCE_FOR_TELEPORT		= 15 -- Distance from the player at which Matt should teleport away 
  46. 		 
  47. 	M16_phase_matt_health = { 
  48. 		1.0,		-- phase 1 - "wing rip" QTE 
  49. 		0.75,		-- phase 2 - "downed" QTE 
  50. 		0.5,		-- phase 3 - standard fight 
  51. 		0.25,		-- phase 4 - decker phase, same as next value 
  52. 		0.25,		-- phase 5 - avatar fight 
  53. 		0.1,		-- final QTE 
  54. 	} 
  55. 	 
  56. 	-- how high to set Matt's health when the final phase triggers. 
  57. 	M16_final_phase_health_reset = 1.0 
  58. 	 
  59. 	-- Don't add customization items to wordrobe 
  60. 	M16_add_to_wardrobe = false 
  61.  
  62. -- Groups -- 
  63.  
  64. 	M16_groups = { 
  65. 	 
  66. 		---------------------------------- 
  67. 		-- FIRST SECTION SURPRISE GROUPS -- 
  68. 		---------------------------------- 
  69. 	 
  70. 		surprise1_group1 = { 
  71. 			name = "SURPRISE1_GROUP_01", 
  72. 			members = { "Surprise1_NPC 004" } 
  73. 		}, 
  74. 		 
  75. 		surprise1_group2 = { 
  76. 			name = "SURPRISE1_GROUP_02", 
  77. 			members = { "Surprise1_NPC 005", "Surprise1_NPC 014", "Surprise1_NPC 013" } 
  78. 		}, 
  79. 		surprise1_group3 = { 
  80. 			name = "SURPRISE1_GROUP_03", 
  81. 			members = { "Surprise1_NPC 003", "Surprise1_NPC 001" } 
  82. 		},	 
  83. 		 
  84. 		surprise1_group4 = { 
  85. 			name = "SURPRISE1_GROUP_04", 
  86. 			members = { "Surprise1_NPC 002", "Surprise1_NPC 012", "Surprise1_NPC 006", "Surprise1_NPC 007" } 
  87. 		},	 
  88. 		 
  89. 		surprise1_group5 = { 
  90. 			name = "SURPRISE1_GROUP_05", 
  91. 			members = { "Surprise1_NPC 008", "Surprise1_NPC 009", "Surprise1_NPC 010" } 
  92. 		},	 
  93. 		 
  94. 		surprise1_group6 = { 
  95. 			name = "SURPRISE1_GROUP_06", 
  96. 			members = { "Surprise1_NPC 015", "Surprise1_NPC 018", "Surprise1_NPC 011" } 
  97. 		},	 
  98. 		 
  99. 		surprise1_group7 = { 
  100. 			name = "SURPRISE1_GROUP_07", 
  101. 			members = { "Surprise1_NPC 016", "Surprise1_NPC 017" } 
  102. 		},	 
  103. 		 
  104. 		----------------------------------- 
  105. 		-- SECOND SECTION SURPRISE GROUPS -- 
  106. 		----------------------------------- 
  107. 		 
  108. 		surprise2_group1 = { 
  109. 			name = "SURPRISE2_GROUP_01", 
  110. 			members = { "Surprise2_NPC 007", "Surprise2_NPC 002", "Surprise2_NPC 004" } 
  111. 		}, 
  112. 		 
  113. 		surprise2_group2 = { 
  114. 			name = "SURPRISE2_GROUP_02", 
  115. 			members = { "Surprise2_NPC 009", "Surprise2_NPC 001", "Surprise2_NPC 005" } 
  116. 		}, 
  117. 		surprise2_group3 = { 
  118. 			name = "SURPRISE2_GROUP_03", 
  119. 			members = { "Surprise2_NPC 003" } 
  120. 		},	 
  121. 		 
  122. 		surprise2_group4 = { 
  123. 			name = "SURPRISE2_GROUP_04", 
  124. 			members = { "Surprise2_NPC 006", "Surprise2_NPC 011"} 
  125. 		},	 
  126. 		 
  127. 		---------------------------------- 
  128. 		-- THIRD SECTION SURPRISE GROUPS -- 
  129. 		---------------------------------- 
  130. 		 
  131. 		surprise3_group1 = { 
  132. 			name = "SURPRISE3_GROUP_01", 
  133. 			members = { "Surprise3_NPC 001", "Surprise3_NPC 004", "Surprise3_NPC 003" } 
  134. 		}, 
  135. 		 
  136. 		surprise3_group2 = { 
  137. 			name = "SURPRISE3_GROUP_02", 
  138. 			members = { "Surprise3_NPC 002", "Surprise3_NPC 006" } 
  139. 		}, 
  140. 		surprise3_group3 = { 
  141. 			name = "SURPRISE3_GROUP_03", 
  142. 			members = { "Surprise3_NPC 009" } 
  143. 		},	 
  144. 		 
  145. 		surprise3_group4 = { 
  146. 			name = "SURPRISE3_GROUP_04", 
  147. 			members = { "Surprise3_NPC 014", "Surprise3_NPC 015" } 
  148. 		},	 
  149. 		 
  150. 		--------------------- 
  151. 		-- FIREWALL GROUPS -- 
  152. 		--------------------- 
  153. 		 
  154. 		firewall_one = { 
  155. 			name = "FIREWALL_GROUP_01", 
  156. 			members = { "Gate1_NPC<001>", "Gate1_NPC<002>", "Gate1_NPC<003>", "Gate1_NPC<004>", "Gate1_NPC<005>" }				 
  157. 		}, 
  158. 	 
  159. 		firewall_two = { 
  160. 			name = "FIREWALL_GROUP_02", 
  161. 			members = { "Gate1_NPC<006>", "Gate1_NPC<007>", "Gate1_NPC<008>", "Gate1_NPC<009>" }				 
  162. 		}, 
  163. 		 
  164. 		firewall_three = { 
  165. 			name = "FIREWALL_GROUP_03", 
  166. 			members = { "Gate1_NPC<010>", "Gate1_NPC<011>", "Gate1_NPC<012>", "Gate1_NPC<013>" }				 
  167. 		}, 
  168. 		 
  169. 		firewall_four = { 
  170. 			name = "FIREWALL_GROUP_04", 
  171. 			members = { "Gate1_NPC<014>", "Gate1_NPC<015>", "Gate1_NPC<016>", "Gate1_NPC<017>" }					 
  172. 		}, 
  173. 		 
  174. 		firewall_five = { 
  175. 			name = "FIREWALL_GROUP_05", 
  176. 			members = { "Gate1_NPC<018>", "Gate1_NPC<019>", "Gate1_NPC<020>", "Gate1_NPC<021>" }					 
  177. 		}, 
  178. 		 
  179. 		firewall_six = { 
  180. 			name = "FIREWALL_GROUP_06", 
  181. 			members = { "Gate1_NPC<022>", "Gate1_NPC<023>", "Gate1_NPC<024>", "Gate1_NPC<025>" }					 
  182. 		}, 
  183. 		 
  184. 		firewall_seven = { 
  185. 			name = "FIREWALL_GROUP_07", 
  186. 			members = { "Gate1_NPC<026>", "Gate1_NPC<027>", "Gate1_NPC<028>", "Gate1_NPC<029>" }					 
  187. 		}, 
  188. 		 
  189. 		firewall_eight = { 
  190. 			name = "FIREWALL_GROUP_08", 
  191. 			members = { "Gate1_NPC<030>", "Gate1_NPC<031>", "Gate1_NPC<032>", "Gate1_NPC<033>",  
  192. 						"Gate1_NPC<034>", "Gate1_NPC<035>" }				 
  193. 		}, 
  194. 		 
  195. 		---------------------- 
  196. 		-- ANTIVIRUS GROUPS -- 
  197. 		---------------------- 
  198. 		 
  199. 		antivirus_one = { 
  200. 			name = "ANTIVIRUS_GROUP_01", 
  201. 			members_single = { "Gate2_NPC_Group_1_Single<001>" }, 
  202. 			members_coop = { "Gate2_NPC_Group_1_Coop<001>" }, 
  203. 			members = { "Gate2_NPC_Group_1_Single<001>", "Gate2_NPC_Group_1_Coop<001>" } 
  204. 		}, 
  205. 		 
  206. 		antivirus_two = { 
  207. 			name = "ANTIVIRUS_GROUP_02", 
  208. 			members_single = { "Gate2_NPC_Group_2_Single<001>"}, 
  209. 			members_coop = { "Gate2_NPC_Group_2_Coop<001>", "Gate2_NPC_Group_2_Coop<002>" }, 
  210. 			members = { "Gate2_NPC_Group_2_Single<001>", 
  211. 						"Gate2_NPC_Group_2_Coop<001>", "Gate2_NPC_Group_2_Coop<002>"} 
  212. 		}, 
  213. 	 
  214. 		antivirus_three = { 
  215. 			name = "ANTIVIRUS_GROUP_03", 
  216. 			members_single = { "Gate2_NPC_Group_3_Single<001>"}, --removed , "Gate2_NPC_Group_3_Single<002>"  
  217. 			members_coop = { "Gate2_NPC_Group_3_Coop<001>", "Gate2_NPC_Group_3_Coop<002>", "Gate2_NPC_Group_3_Coop<003>" }, 
  218. 			members = { "Gate2_NPC_Group_3_Single<001>", "Gate2_NPC_Group_3_Single<002>", 
  219. 						"Gate2_NPC_Group_3_Coop<001>", "Gate2_NPC_Group_3_Coop<002>", "Gate2_NPC_Group_3_Coop<003>"} 
  220. 		}, 
  221.  
  222. 		antivirus_four = { 
  223. 			name = "ANTIVIRUS_GROUP_04", 
  224. 			members_single = { "Gate2_NPC_Group_4_Single<001>", "Gate2_NPC_Group_4_Single<002>" }, 
  225. 			members_coop = { "Gate2_NPC_Group_4_Coop<001>", "Gate2_NPC_Group_4_Coop<002>", "Gate2_NPC_Group_4_Coop<003>" }, 
  226. 			members = { "Gate2_NPC_Group_4_Single<001>", "Gate2_NPC_Group_4_Single<002>", 
  227. 						"Gate2_NPC_Group_4_Coop<001>", "Gate2_NPC_Group_4_Coop<002>", "Gate2_NPC_Group_4_Coop<003>"} 
  228. 		},		 
  229. 		------------------------------ 
  230. 		-- INTERNET SECURITY GROUPS -- 
  231. 		------------------------------ 
  232. 		 
  233. 		security = { 
  234. 			name = "SECURITY_GROUP", 
  235. 			members = { "Gate3_NPC 001", "Gate3_NPC 003", "Gate3_NPC 005", 
  236. 							"Gate3_NPC 008", "Gate3_NPC 009", "Gate3_NPC 010", 
  237. 							"Gate3_NPC 011", "Gate3_NPC 012", 
  238. 							"Gate3_NPC 018", "Gate3_NPC 019" }, 
  239. 			wave1 = { "Gate3_NPC 001", "Gate3_NPC 005", "Gate3_NPC 008"}, 
  240. 			wave2 = { "Gate3_NPC 003", "Gate3_NPC 009" }, 
  241. 			wave3 = { "Gate3_NPC 010" }, 
  242. 			wave4 = { "Gate3_NPC 018", "Gate3_NPC 019" }, 
  243. 			wave5 = { "Gate3_NPC 011", "Gate3_NPC 012"}, 
  244. 		}, 
  245. 		 
  246. 		security_coop = { 
  247. 			name = "SECURITY_GROUP_COOP", 
  248. 			members = { "Gate3_NPC_Coop<001>", "Gate3_NPC_Coop<002>", "Gate3_NPC_Coop<003>", "Gate3_NPC_Coop<004>", "Gate3_NPC_Coop<005>" }, 
  249. 			wave1 = { "Gate3_NPC_Coop<001>" }, 
  250. 			wave2 = { "Gate3_NPC_Coop<002>" }, 
  251. 			wave3 = { "Gate3_NPC_Coop<003>" }, 
  252. 			wave4 = { "Gate3_NPC_Coop<004>" }, 
  253. 			wave5 = { "Gate3_NPC_Coop<005>" }, 
  254. 		}, 
  255. 		 
  256. 		----------------------------------- 
  257. 		-- TOP DOWN TANK SEQUENCE GROUPS -- 
  258. 		----------------------------------- 
  259. 	 
  260. 		tank_combat_player_one = { 
  261. 			name = "PLAYER_ONE_TANK_GROUP", 
  262. 			members = {  "Player_One_Tank 001" }, 
  263. 			player_tank_veh = "Player_One_Tank 001" 
  264. 		}, 
  265. 		 
  266. 		tank_combat_npc_one = { 
  267. 			name = "NPC_ONE_TANK_GROUP", 
  268. 			members = { "Tank_NPC 001", "NPC_Tank 001" }, 
  269. 			tank_npc = "Tank_NPC 001", 
  270. 			npc_tank_veh = "NPC_Tank 001",		 
  271. 		}, 
  272. 		 
  273. 		tank_combat_player_two = { 
  274. 			name = "PLAYER_TWO_TANK_GROUP", 
  275. 			members = { "Player_Two_Tank 001" }, 
  276. 			player_tank_veh = "Player_Two_Tank 001" 
  277. 		}, 
  278. 		 
  279. 		tank_combat_npc_two = { 
  280. 			name = "NPC_TWO_TANK_GROUP", 
  281. 			members = { "Tank_NPC 002", "NPC_Tank 002" }, 
  282. 			tank_npc = "Tank_NPC 002", 
  283. 			npc_tank_veh = "NPC_Tank 002",		 
  284. 		}, 
  285. 		 
  286. 		---------- 
  287. 		-- MATT -- 
  288. 		---------- 
  289. 		 
  290. 		matt = { 
  291. 			name = "MATT_GROUP", 
  292. 			members = { "matt" }, 
  293. 			matt = "matt" 
  294. 		}, 
  295. 		 
  296. 		------------------------------- 
  297. 		-- BOSS BATTLE DECKER GROUPS -- 
  298. 		------------------------------- 
  299. 		 
  300. 		wave1 = { 
  301. 			name = "DECKER_GROUP 001", 
  302. 			members = { "decker_phase_npc 003",   "decker_phase_npc 004", "decker_phase_npc 004a", "decker_phase_npc 004b",  
  303. 								"decker_phase_npc 004c", "decker_phase_npc 004d", "decker_phase_npc 004f", "decker_phase_npc 004g" } 
  304. 		}, 
  305. 		 
  306. 		wave2 = { 
  307. 			name = "DECKER_GROUP 002", 
  308. 			members = { "decker_phase_npc 006", "decker_phase_npc 008", "decker_phase_npc 008a", "decker_phase_npc 008c",  
  309. 								"decker_phase_npc 008d", "decker_phase_npc 008e", "decker_phase_npc 008f", "decker_phase_npc 008h" } 
  310. 		}, 
  311. 		 
  312. 		wave3 = { 
  313. 			name = "DECKER_GROUP 003", 
  314. 			members = { "decker_phase_npc 010",   "decker_phase_npc 011",   "decker_phase_npc 012", 
  315. 								"decker_phase_npc 012a", "decker_phase_npc 012d", "decker_phase_npc 012f", "decker_phase_npc 012h" } 
  316. 		}, 
  317. 	} 
  318. 	 
  319. 	-- decker waves 
  320. 	M16_wave_groups = { M16_groups.wave1, M16_groups.wave2, M16_groups.wave3 } 
  321.  
  322. 	M16_internet_security_waves = { M16_groups.security.wave1, M16_groups.security.wave2, M16_groups.security.wave3, 
  323. 												M16_groups.security.wave4, M16_groups.security.wave5 } 
  324. 	M16_internet_security_coop_waves = { M16_groups.security_coop.wave1, M16_groups.security_coop.wave2, M16_groups.security_coop.wave3, 
  325. 												M16_groups.security_coop.wave4, M16_groups.security_coop.wave5 } 
  326. -- Navpoints -- 
  327. 	M16_navpoints = { 
  328. 		local_start = "Local_Start_Navpoint", 
  329. 		remote_start = "Remote_Start_Navpoint", 
  330. 		start_navs = {"Local_Start_Navpoint", "Remote_Start_Navpoint"}, 
  331. 		local_exit = "M16_Local_Player_Exit", 
  332. 		remote_exit = "M16_Remote_Player_Exit", 
  333. 		waiting_room = {"Navpoint_WaitingRoom_Local", "Navpoint_WaitingRoom_Remote"}, 
  334. 		firewall_destroyed =  { "FW1_Destroy_Nav_Local", "FW1_Destroy_Nav_Remote"}, 
  335. 		antivirus_destroyed = { "FW2_Destroy_Nav_Local", "FW2_Destroy_Nav_Remote"}, 
  336. 		security_destroyed = { "FW3_Destroy_Nav_Local", "FW3_Destroy_Nav_Remote"}, 
  337. 		tank_combat_camera = "Tank_Camera_Navpoint", 
  338. 		local_matt_battle_start = "Local_Boss_Start_Navpoint", 
  339. 		remote_matt_battle_start = "Remote_Boss_Start_Navpoint", 
  340. 		matt_teleports = { "Matt_Teleport 001", "Matt_Teleport 002", "Matt_Teleport 003", 
  341. 							"Matt_Teleport 004", "Matt_Teleport 005", "Matt_Teleport 006" }, 
  342. 		matt_hide_loc = "Matt_Hide_Loc_Navpoint", 
  343. 		matt_summon = "Matt_Summon_Nav", 
  344. 		first_qte = "First_QTE_Nav", 
  345. 		final_qte = "Final_QTE_Nav", 
  346. 		tank_warp_local = "Tank_Warp_Navpoint_Local", 
  347. 		tank_warp_remote = "Tank_Warp_Navpoint_Remote", 
  348. 		error_warp_local = "Error_Warp_Navpoint_Local", 
  349. 		error_warp_remote = "Error_Warp_Navpoint_Remote", 
  350. 		final_warp_local = "Final_Warp_Navpoint_Local", 
  351. 		final_warp_remote = "Final_Warp_Navpoint_Remote", 
  352. 		final_choice_local = "Local_Final_Choice_Navpoint", 
  353. 		final_choice_remote = "Remote_Final_Choice_Navpoint" 
  354. 	} 
  355.  
  356. -- Triggers -- 
  357. 	M16_triggers = { 
  358. 		surprise1 = { "Surprise1_Trigger_01", "Surprise1_Trigger_02", "Surprise1_Trigger_03", "Surprise1_Trigger_04",  
  359. 							"Surprise1_Trigger_05", "Surprise1_Trigger_06", "Surprise1_Trigger_07" }, 
  360. 		surprise2 = { "Surprise2_Trigger_01", "Surprise2_Trigger_02", "Surprise2_Trigger_03", "Surprise2_Trigger_04" }, 
  361. 		surprise3 = { "Surprise3_Trigger_01", "Surprise3_Trigger_02", "Surprise3_Trigger_03", "Surprise3_Trigger_04" }, 
  362. 		firewall = { "Firewall_01_Trigger_01", "Firewall_01_Trigger_02", "Firewall_01_Trigger_03",  
  363. 						"Firewall_01_Trigger_04", "Firewall_01_Trigger_05", "Firewall_01_Trigger_06", 
  364. 						"Firewall_01_Trigger_07", "Firewall_01_Trigger_08" }, 
  365. 		cathedral_wall = { "Cathedral_Wall_Trigger<001>", "Cathedral_Wall_Trigger<002>" , "Cathedral_Wall_Trigger<003>" }, 
  366. 		firewall_destination = "Trigger_Firewall", 
  367. 		gate1 = "Gate1_Trigger", 
  368. 		gate2 = "Gate2_Trigger", 
  369. 		gate3 = "Gate3_Trigger", 
  370. 		final = "Final_Trigger", 
  371. 		choicea = "Company_A_Trigger", 
  372. 		choiceb = "Company_B_Trigger", 
  373. 		death = "Death_Region", 
  374. 	} 
  375. 	 
  376. 	M16_surprise_triggers = { 
  377. 		surprise1_01 = { 
  378. 			name = M16_triggers.surprise1[1], 
  379. 			script_group = M16_groups.surprise1_group1 
  380. 		}, 
  381.  
  382. 		surprise1_02 = { 
  383. 			name = M16_triggers.surprise1[2], 
  384. 			script_group = M16_groups.surprise1_group2 
  385. 		}, 
  386. 		 
  387. 		surprise1_03 = { 
  388. 			name = M16_triggers.surprise1[3], 
  389. 			script_group = M16_groups.surprise1_group3 
  390. 		}, 
  391. 		 
  392. 		surprise1_04 = { 
  393. 			name = M16_triggers.surprise1[4], 
  394. 			script_group = M16_groups.surprise1_group4 
  395. 		}, 
  396. 		 
  397. 		surprise1_05 = { 
  398. 			name = M16_triggers.surprise1[5], 
  399. 			script_group = M16_groups.surprise1_group5 
  400. 		}, 
  401. 		 
  402. 		surprise1_06 = { 
  403. 			name = M16_triggers.surprise1[6], 
  404. 			script_group = M16_groups.surprise1_group6 
  405. 		}, 
  406. 		 
  407. 		surprise1_07 = { 
  408. 			name = M16_triggers.surprise1[7], 
  409. 			script_group = M16_groups.surprise1_group7 
  410. 		}, 
  411. 		 
  412. 		surprise2_01 = { 
  413. 			name = M16_triggers.surprise2[1], 
  414. 			script_group = M16_groups.surprise2_group1 
  415. 		}, 
  416. 		 
  417. 		surprise2_02 = { 
  418. 			name = M16_triggers.surprise2[2], 
  419. 			script_group = M16_groups.surprise2_group2 
  420. 		}, 
  421. 		 
  422. 		surprise2_03 = { 
  423. 			name = M16_triggers.surprise2[3], 
  424. 			script_group = M16_groups.surprise2_group3 
  425. 		}, 
  426. 		 
  427. 		surprise2_04 = { 
  428. 			name = M16_triggers.surprise2[4], 
  429. 			script_group = M16_groups.surprise2_group4 
  430. 		}, 
  431. 		 
  432. 		surprise3_01 = { 
  433. 			name = M16_triggers.surprise3[1], 
  434. 			script_group = M16_groups.surprise3_group1 
  435. 		}, 
  436. 		 
  437. 		surprise3_02 = { 
  438. 			name = M16_triggers.surprise3[2], 
  439. 			script_group = M16_groups.surprise3_group2 
  440. 		}, 
  441. 		 
  442. 		surprise3_03 = { 
  443. 			name = M16_triggers.surprise3[3], 
  444. 			script_group = M16_groups.surprise3_group3 
  445. 		}, 
  446. 		 
  447. 		surprise3_04 = { 
  448. 			name = M16_triggers.surprise3[4], 
  449. 			script_group = M16_groups.surprise3_group4 
  450. 		}, 
  451. 	} 
  452. 	 
  453. 	M16_firewall_trigger_groups = { 
  454. 		firewall_01 = { 
  455. 			name = M16_triggers.firewall[1], 
  456. 			script_group = M16_groups.firewall_one 
  457. 		}, 
  458. 		 
  459. 		firewall_02 = { 
  460. 			name = M16_triggers.firewall[2], 
  461. 			script_group = M16_groups.firewall_two 
  462. 		}, 
  463. 		 
  464. 		firewall_03 = { 
  465. 			name = M16_triggers.firewall[3], 
  466. 			script_group = M16_groups.firewall_three 
  467. 		}, 
  468. 		 
  469. 		firewall_04 = { 
  470. 			name = M16_triggers.firewall[4], 
  471. 			script_group = M16_groups.firewall_four 
  472. 		}, 
  473. 		 
  474. 		firewall_05 = { 
  475. 			name = M16_triggers.firewall[5], 
  476. 			script_group = M16_groups.firewall_five 
  477. 		}, 
  478. 		 
  479. 		firewall_06 = { 
  480. 			name = M16_triggers.firewall[6], 
  481. 			script_group = M16_groups.firewall_six 
  482. 		}, 
  483. 		 
  484. 		firewall_07 = { 
  485. 			name = M16_triggers.firewall[7], 
  486. 			script_group = M16_groups.firewall_seven 
  487. 		}, 
  488. 		firewall_08 = { 
  489. 			name = M16_triggers.firewall[8], 
  490. 			script_group = M16_groups.firewall_eight 
  491. 		}, 
  492. 	} 
  493. 	 
  494. 	M16_surprise1_trigger_groups = { M16_surprise_triggers.surprise1_01, M16_surprise_triggers.surprise1_02, M16_surprise_triggers.surprise1_03, M16_surprise_triggers.surprise1_04, M16_surprise_triggers.surprise1_05, M16_surprise_triggers.surprise1_06, M16_surprise_triggers.surprise1_07 } 
  495. 												 
  496. 	M16_surprise2_trigger_groups = { M16_surprise_triggers.surprise2_01, M16_surprise_triggers.surprise2_02, M16_surprise_triggers.surprise2_03, M16_surprise_triggers.surprise2_04 } 
  497. 												 
  498. 	M16_surprise3_trigger_groups = { M16_surprise_triggers.surprise3_01, M16_surprise_triggers.surprise3_02, M16_surprise_triggers.surprise3_03, M16_surprise_triggers.surprise3_04 } 
  499. 	 
  500. -- Characters -- 
  501. 	M16_characters = { 
  502. 		tank_combat_tank_npc_one = M16_groups.tank_combat_npc_one.tank_npc, 
  503. 		tank_combat_tank_npc_two = M16_groups.tank_combat_npc_two.tank_npc, 
  504. 		matt = M16_groups.matt.matt 
  505. 	} 
  506.  
  507. -- Vehicles -- 
  508. 	M16_vehicles = { 
  509. 		tank_combat_npc_tank_one = M16_groups.tank_combat_npc_one.npc_tank_veh, 
  510. 		tank_combat_npc_tank_two = M16_groups.tank_combat_npc_two.npc_tank_veh, 
  511. 		tank_combat_player_tank_one = M16_groups.tank_combat_player_one.player_tank_veh, 
  512. 		tank_combat_player_tank_two = M16_groups.tank_combat_player_two.player_tank_veh 
  513. 	} 
  514.  
  515. -- Mesh Movers -- 
  516. 	M16_movers = { 
  517. 		gate1 = "Gate1_Mover", 
  518. 		gate2 = "Gate2_Mover", 
  519. 		gate3 = "Gate3_Mover", 
  520. 		final_gate_mover = "Final_Gate_Mover<001>", 
  521. 		triggered_final_gate_movers = { "Final_Gate_Mover<002>", "Final_Gate_Mover<003>", "Final_Gate_Mover<004>" } 
  522. 	} 
  523. -- Text -- 
  524.  
  525. -- Threads -- 
  526. 	M16_threads = { 
  527. 		process_convo	= INVALID_THREAD_HANDLE, 
  528. 		tank_one_thread_handle = INVALID_THREAD_HANDLE, 
  529. 		tank_two_thread_handle = INVALID_THREAD_HANDLE, 
  530. 		matt_teleport_thread_handle = INVALID_THREAD_HANDLE, 
  531. 		matt_health_thread_handle = INVALID_THREAD_HANDLE, 
  532. 		text_adventure_audio_handle = INVALID_THREAD_HANDLE, 
  533. 		cheat_audio_handle = INVALID_THREAD_HANDLE, 
  534. 		attack_line = INVALID_THREAD_HANDLE, 
  535. 		avatar_transform_handle = INVALID_THREAD_HANDLE, 
  536. 		local_avatar_transform_handle = INVALID_THREAD_HANDLE, 
  537. 		remote_avatar_transform_handle = INVALID_THREAD_HANDLE, 
  538. 		decker_spawn_handle = INVALID_THREAD_HANDLE, 
  539. 		decker_spawn_handle2 = INVALID_THREAD_HANDLE 
  540. 	} 
  541.  
  542. -- Checkpoints -- 
  543. 	M16_checkpoints = { 
  544. 		CHECKPOINT_START = MISSION_START_CHECKPOINT,			-- defined in ug_lib.lua 
  545. 		 
  546. 		TEXT_ADVENTURE_COMPLETE = "m16_checkpoint_text_adventure_complete", 
  547. 		TANK_COMBAT_COMPLETE = "m16_checkpoint_tank_combat_complete", 
  548. 		ERROR_SCREEN_DISABLED = "m16_checkpoint_error_screen_disabled", 
  549. 		MATT_BATTLE_START = "m16_checkpoint_matt_battle_start", 
  550. 		MATT_DEWINGED = "m16_checkpoint_matt_dewinged", 
  551. 		MATT_PHASE3	= "m16_checkpoint_matt_phase3", 
  552. 		DECKER_PHASE	= "m16_checkpoint_decker_phase", 
  553. 		AVATAR_BATTLE ="m16_checkpoint_avatar_battle" 
  554. 	} 
  555. 	 
  556. -- Cutscenes -- 
  557. 	M16_scene = { 
  558. 		intro = "16_IN", 
  559. 		matt_intro = "16_z01", 
  560. 		matt_defeated = "16_Z02", 
  561. 		outro = "16_out" 
  562. 	}	 
  563.  
  564. 		M16_cte_01 = { 
  565. 		name = "m16_cte_01" 
  566. 	} 
  567.  
  568. -- Conversations -- 
  569. 	M16_conv = { 
  570. 		mission_start = { 
  571. 			name = "m16_convo_1", 
  572. 			load_direct = false, 
  573. 			queued = false, 
  574. 			started = false, 
  575. 			completed = false, 
  576. 			ended = false, 
  577. 		}, 
  578. 		 
  579. 		second_avatar = { 
  580. 			name = "m16_second_avatar", 
  581. 			load_direct = false, 
  582. 			queued = false, 
  583. 			started = false, 
  584. 			completed = false, 
  585. 			ended = false, 
  586. 		}, 
  587. 		 
  588. 		actual_avatar = { 
  589. 			name = "m16_actual_avatar", 
  590. 			load_direct = false, 
  591. 			queued = false, 
  592. 			started = false, 
  593. 			completed = false, 
  594. 			ended = false, 
  595. 		}, 
  596. 		 
  597. 		defenses =  { 
  598. 			name = "m16_defenses", 
  599. 			load_direct = false, 
  600. 			queued = false, 
  601. 			started = false, 
  602. 			completed = false, 
  603. 			ended = false, 
  604. 		}, 
  605. 		 
  606. 		attack_firewall=  { 
  607. 			name = "m16_attack_firewall", 
  608. 			load_direct = false, 
  609. 			queued = false, 
  610. 			started = false, 
  611. 			completed = false, 
  612. 			ended = false, 
  613. 		}, 
  614. 		 
  615. 		text_adventure = { 
  616. 			name = "m16_convo_4", 
  617. 			load_direct = false, 
  618. 			queued = false, 
  619. 			started = false, 
  620. 			completed = false, 
  621. 			ended = false, 
  622. 		}, 
  623. 		 
  624. 		firewall_destroyed = { 
  625. 			name = "m16_firewall_destroyed", 
  626. 			load_direct = true, 
  627. 			queued = false, 
  628. 			started = false, 
  629. 			completed = false, 
  630. 			ended = false, 
  631. 		}, 
  632. 		 
  633. 		toilet_again = { 
  634. 			name = "m16_toilet_again", 
  635. 			load_direct = false, 
  636. 			queued = false, 
  637. 			started = false, 
  638. 			completed = false, 
  639. 			ended = false, 
  640. 		}, 
  641. 		 
  642. 		nyte_blade = { 
  643. 			name = "m16_matt_player_convo", 
  644. 			load_direct = false, 
  645. 			queued = false, 
  646. 			started = false, 
  647. 			completed = false, 
  648. 			ended = false,	 
  649. 		}, 
  650. 			 
  651. 		tank_sequence = { 
  652. 			name = "m16_tank", 
  653. 			load_direct = false, 
  654. 			queued = false, 
  655. 			started = false, 
  656. 			completed = false, 
  657. 			ended = false, 
  658. 		}, 
  659. 		 
  660. 		see_last_wall = { 
  661. 			name = "m16_see_last_wall", 
  662. 			load_direct = false, 
  663. 			queued = false, 
  664. 			started = false, 
  665. 			completed = false, 
  666. 			ended = false, 
  667. 		}, 
  668. 		 
  669. 		attack_security = { 
  670. 			name = "m16_attack_security", 
  671. 			load_direct = false, 
  672. 			queued = false, 
  673. 			started = false, 
  674. 			completed = false, 
  675. 			ended = false, 
  676. 		}, 
  677. 		 
  678. 		doll_again = { 
  679. 			name = "m16_doll_again", 
  680. 			load_direct = false, 
  681. 			queued = false, 
  682. 			started = false, 
  683. 			completed = false, 
  684. 			ended = false, 
  685. 		}, 
  686. 		 
  687. 		error_message = { 
  688. 			name = "m16_error_message", 
  689. 			load_direct = false, 
  690. 			queued = false, 
  691. 			started = false, 
  692. 			completed = false, 
  693. 			ended = false, 
  694. 		}, 
  695. 		 
  696. 		security_destroyed = { 
  697. 			name = "m16_destroy_security", 
  698. 			load_direct = false, 
  699. 			queued = false, 
  700. 			started = false, 
  701. 			completed = false, 
  702. 			ended = false, 
  703. 		}, 
  704. 		 
  705. 		graves_two = { 
  706. 			name = "m16_graves_2", 
  707. 			load_direct = false, 
  708. 			queued = false, 
  709. 			started = false, 
  710. 			completed = false, 
  711. 			ended = false, 
  712. 		}, 
  713. 		 
  714. 		cheat_one = { 
  715. 			name = "M16_Cheat_1", 
  716. 			load_direct = false, 
  717. 			queued = false, 
  718. 			started = false, 
  719. 			completed = false, 
  720. 			ended = false, 
  721. 		}, 
  722. 		 
  723. 		cheat_two = { 
  724. 			name = "M16_Cheat_2", 
  725. 			load_direct = false, 
  726. 			queued = false, 
  727. 			started = false, 
  728. 			completed = false, 
  729. 			ended = false, 
  730. 		},	 
  731. 		 
  732. 		graves_one = { 
  733. 			name = "m16_graves_1", 
  734. 			load_direct = false, 
  735. 			queued = false, 
  736. 			started = false, 
  737. 			completed = false, 
  738. 			ended = false, 
  739. 		}, 
  740. 		 
  741. 		matt_battle_begins = { 
  742. 			name = "m16_battle_begins", 
  743. 			load_direct = false, 
  744. 			queued = false, 
  745. 			started = false, 
  746. 			completed = false, 
  747. 			ended = false, 
  748. 		}, 
  749. 		 
  750. 		player_turned_into_avatar = { 
  751. 			name = "m16_bahamut", 
  752. 			load_direct = true, 
  753. 			queued = false, 
  754. 			started = false, 
  755. 			completed = false, 
  756. 			ended = false, 
  757. 		}, 
  758. 		 
  759. 		ability_explanation = { 
  760. 			name = "m16_ability_explanation", 
  761. 			load_direct = false, 
  762. 			queued = false, 
  763. 			started = false, 
  764. 			completed = false, 
  765. 			ended = false, 
  766. 		}, 
  767. 		 
  768. 		matt_returns = { 
  769. 			name = "m16_matt_returns", 
  770. 			load_direct = false, 
  771. 			queued = false, 
  772. 			started = false, 
  773. 			completed = false, 
  774. 			ended = false, 
  775. 		}, 
  776. 		 
  777. 		matt_qte_charge_three = { 
  778. 			name = "m16_charge_3", 
  779. 			load_direct = false, 
  780. 			queued = false, 
  781. 			started = false, 
  782. 			completed = false, 
  783. 			ended = false, 
  784. 		}, 
  785. 		 
  786. 		reward_choice = { 
  787. 			name = "m16_reward_choice", 
  788. 			load_direct = false, 
  789. 			queued = false, 
  790. 			started = false, 
  791. 			completed = false, 
  792. 			ended = false, 
  793. 		}, 
  794. 	} 
  795. 	 
  796. 	M16_dialog_lines = { 
  797.  
  798. 		--------------------------- 
  799. 		--  TEXT ADVENTURE LINES -- 
  800. 		--------------------------- 
  801. 		M16_TA_Go_Through_Hole_Fail = { 
  802. 			name = "M16_TA_Go_Through_Hole_Fail", 
  803. 			played = false 
  804. 		}, 
  805. 		 
  806. 		M16_TA_Open_Door_Fail = { 
  807. 			name = "M16_TA_Open_Door_Fail", 
  808. 			played = false 
  809. 		}, 
  810. 		 
  811. 		M16_TA_Nap_Fail_01 = { 
  812. 			name = "M16_TA_Nap_Fail_01", 
  813. 			played = false 
  814. 		}, 
  815. 		 
  816. 		M16_TA_Nap_Fail_02 = { 
  817. 			name = "M16_TA_Nap_Fail_02", 
  818. 			played = false 
  819. 		}, 
  820. 		 
  821. 		M16_TA_Secret_Door_Fail = { 
  822. 			name = "M16_TA_Secret_Door_Fail", 
  823. 			played = false 
  824. 		}, 
  825. 		 
  826. 		M16_TA_Run_Back_Fail = { 
  827. 			name = "M16_TA_Run_Back_Fail", 
  828. 			played = false 
  829. 		}, 
  830. 		 
  831. 		M16_TA_Cast_Spell_Fail = { 
  832. 			name = "M16_TA_Cast_Spell_Fail", 
  833. 			played = false 
  834. 		}, 
  835. 		 
  836. 		M16_TA_Draw_Sword_Fail = { 
  837. 			name = "M16_TA_Draw_Sword_Fail", 
  838. 			played = false 
  839. 		}, 
  840. 		 
  841. 		M16_TA_Look_At_Unicorn_Fail = { 
  842. 			name = "M16_TA_Look_At_Unicorn_Fail", 
  843. 			played = false 
  844. 		}, 
  845. 		 
  846. 		M16_TA_Pet_Unicorn_Fail = { 
  847. 			name = "M16_TA_Pet_Unicorn_Fail", 
  848. 			played = false 
  849. 		}, 
  850. 		 
  851. 		M16_TA_Kill_Unicorn_Win = { 
  852. 			name = "M16_TA_Kill_Unicorn_Win", 
  853. 			played = false 
  854. 		}, 
  855.  
  856. 	 
  857. 		banish_to_tank = { 
  858. 			name = "M16_Banish_To_Tank", 
  859. 			played = false 
  860. 		}, 
  861. 		 
  862. 		kinzie_boss_start = { 
  863. 			name = "M16_Boss_Fight", 
  864. 			played = false 
  865. 		}, 
  866.  
  867. 		------------------------- 
  868. 		--  KINZIE CHEAT LINES -- 
  869. 		------------------------- 
  870.  
  871. 		kinzie_lag_cheat = { 
  872. 			name = "M16_Lag_Cheat_Kinzie_01", 
  873. 			played = false 
  874. 		}, 
  875. 		 
  876. 		kinzie_inverted_cheat = { 
  877. 			name = "M16_Inverted_Cheat_Kinzie_01", 
  878. 			played = false 
  879. 		}, 
  880. 		 
  881. 		kinzie_weak_weapon_cheat = { 
  882. 			name = "M16_Weak_Weapon_Cheat_Kinzie_01", 
  883. 			played = false 
  884. 		}, 
  885.  
  886. 		kinzie_shrink_cheat = { 
  887. 			name = "M16_Shrink_Cheat_Kinzie_01", 
  888. 			played = false 
  889. 		}, 
  890. 		 
  891. 		kinzie_slow_cheat = { 
  892. 			name = "M16_Slow_Cheat_Kinzie_01", 
  893. 			played = false 
  894. 		}, 
  895. 		 
  896. 		------------------------- 
  897. 		--   MATT CHEAT LINES  -- 
  898. 		------------------------- 
  899.  
  900. 		matt_lag_cheat_01 = { 
  901. 			name = "M16_Lag_Cheat_Matt", 
  902. 			played = false 
  903. 		}, 
  904.  
  905. 		matt_lag_cheat_02 = { 
  906. 			name = "M16_Lag_Cheat_Matt_01", 
  907. 			played = false 
  908. 		}, 
  909. 		 
  910. 		matt_lag_cheat_03 = { 
  911. 			name = "M16_Lag_Cheat_Matt_02", 
  912. 			played = false 
  913. 		}, 
  914. 		 
  915. 		matt_inverted_cheat_01 = { 
  916. 			name = "M16_Inverted_Cheat_Matt", 
  917. 			played = false 
  918. 		}, 
  919. 		 
  920. 		matt_inverted_cheat_02 = { 
  921. 			name = "M16_Inverted_Cheat_Matt_01", 
  922. 			played = false 
  923. 		}, 
  924. 		 
  925. 		matt_inverted_cheat_03 = { 
  926. 			name = "M16_Inverted_Cheat_Matt_02", 
  927. 			played = false 
  928. 		}, 
  929. 		 
  930. 		matt_weak_weapon_cheat_01 = { 
  931. 			name = "M16_Weak_Weapon_Cheat_Matt", 
  932. 			played = false 
  933. 		}, 
  934. 		 
  935. 		matt_weak_weapon_cheat_02 = { 
  936. 			name = "M16_Weak_Weapon_Cheat_Matt_01", 
  937. 			played = false 
  938. 		}, 
  939.  
  940. 		matt_weak_weapon_cheat_03 = { 
  941. 			name = "M16_Weak_Weapon_Cheat_Matt_02", 
  942. 			played = false 
  943. 		}, 
  944. 		 
  945. 		matt_shrink_cheat_01 = { 
  946. 			name = "M16_Shrink_Cheat_Matt", 
  947. 			played = false 
  948. 		}, 
  949. 		 
  950. 		matt_shrink_cheat_02 = { 
  951. 			name = "M16_Shrink_Cheat_Matt_01", 
  952. 			played = false 
  953. 		}, 
  954. 		 
  955. 		matt_shrink_cheat_03 = { 
  956. 			name = "M16_Shrink_Cheat_Matt_02", 
  957. 			played = false 
  958. 		}, 
  959. 		 
  960. 		matt_slow_cheat_01 = { 
  961. 			name = "M16_Slow_Cheat_Matt", 
  962. 			played = false 
  963. 		}, 
  964. 		 
  965. 		matt_slow_cheat_02 = { 
  966. 			name = "M16_Slow_Cheat_Matt_01", 
  967. 			played = false 
  968. 		}, 
  969. 		 
  970. 		matt_slow_cheat_03 = { 
  971. 			name = "M16_Slow_Cheat_Matt_02", 
  972. 			played = false 
  973. 		}, 
  974. 	} 
  975. 	 
  976. 	M16_text_adventure_lines = { 
  977. 		{1, M16_dialog_lines.M16_TA_Go_Through_Hole_Fail}, 
  978. 		{2, M16_dialog_lines.M16_TA_Open_Door_Fail}, 
  979. 		{0, M16_dialog_lines.M16_TA_Nap_Fail_01}, 
  980. 		{0, M16_dialog_lines.M16_TA_Nap_Fail_02}, 
  981. 		{4, M16_dialog_lines.M16_TA_Secret_Door_Fail}, 
  982. 		{5, M16_dialog_lines.M16_TA_Run_Back_Fail}, 
  983. 		{7, M16_dialog_lines.M16_TA_Cast_Spell_Fail}, 
  984. 		{8, M16_dialog_lines.M16_TA_Draw_Sword_Fail}, 
  985. 		{10, M16_dialog_lines.M16_TA_Look_At_Unicorn_Fail}, 
  986. 		{11, M16_dialog_lines.M16_TA_Pet_Unicorn_Fail}, 
  987. 		{12, M16_dialog_lines.M16_TA_Kill_Unicorn_Win}, 
  988. 	} 
  989.  
  990. 	M16_kinzie_cheat_lines = { 
  991. 		M16_dialog_lines.kinzie_inverted_cheat, 
  992. 		M16_dialog_lines.kinzie_shrink_cheat, 
  993. 		M16_dialog_lines.kinzie_lag_cheat, 
  994. 		M16_dialog_lines.kinzie_weak_weapon_cheat, 
  995. 		M16_dialog_lines.kinzie_slow_cheat, 
  996. 	} 
  997. 	 
  998. 	M16_matt_cheat_lines_01 = { 
  999. 		M16_dialog_lines.matt_inverted_cheat_01, 
  1000. 		M16_dialog_lines.matt_shrink_cheat_01, 
  1001. 		M16_dialog_lines.matt_lag_cheat_01,	 
  1002. 		M16_dialog_lines.matt_weak_weapon_cheat_01, 
  1003. 		M16_dialog_lines.matt_slow_cheat_01,	 
  1004. 	} 
  1005. 	 
  1006. 	M16_matt_cheat_lines_02 = { 
  1007. 		M16_dialog_lines.matt_inverted_cheat_02, 
  1008. 		M16_dialog_lines.matt_shrink_cheat_02, 
  1009. 		M16_dialog_lines.matt_lag_cheat_02, 
  1010. 		M16_dialog_lines.matt_weak_weapon_cheat_02, 
  1011. 		M16_dialog_lines.matt_slow_cheat_02,	 
  1012. 	} 
  1013. 	 
  1014. 	M16_matt_cheat_lines_03 = { 
  1015. 		M16_dialog_lines.matt_inverted_cheat_03, 
  1016. 		M16_dialog_lines.matt_shrink_cheat_03, 
  1017. 		M16_dialog_lines.matt_lag_cheat_03, 
  1018. 		M16_dialog_lines.matt_weak_weapon_cheat_03, 
  1019. 		M16_dialog_lines.matt_slow_cheat_03,	 
  1020. 	} 
  1021. 	 
  1022. -- Persona Handles -- 
  1023. 	M16_personas = { 
  1024. 		kinzie = { 
  1025. 			name = "Kinzie", 
  1026. 			persona_id = INVALID_PERSONA_HANDLE, 
  1027. 		}, 
  1028. 		 
  1029. 		matt = { 
  1030. 			name = "Matt", 
  1031. 			persona_id = INVALID_PERSONA_HANDLE, 
  1032. 		} 
  1033. 	} 
  1034. 	 
  1035. 	M16_animations = { 
  1036. 		matt_taunt_a = "taunt 1", 
  1037. 		matt_taunt_b = "taunt 2", 
  1038. 		tele_start = "avatar tele start", 
  1039. 		tele_end = "avatar tele end", 
  1040. 		matt_summon = "avatar summon" 
  1041. 	} 
  1042. 	 
  1043. 	M16_animation_states = { 
  1044. 		avatar_stunned = "dbno suffer" 
  1045. 	} 
  1046. 		 
  1047. -- Other -- 
  1048. 	convo_queue = { 
  1049. 		playing  = { 
  1050. 			thread_id = -1, 
  1051. 			conv_handle = INVALID_CONVERSATION_HANDLE, 
  1052. 			convo_table = nil, 
  1053. 		}, 
  1054. 		list = {}, 
  1055. 		size = 0, 
  1056. 	} 
  1057. 	 
  1058. 	dialog_line_audio_id = -1 
  1059. 	M16_music = "" 
  1060. 	 
  1061. 	M16_hud_states = { 
  1062. 		minimap = -1, 
  1063. 		hide_all = -1, 
  1064. 		gsi = -1, 
  1065. 	} 
  1066.  
  1067. 	in_coop = false 
  1068. 	 
  1069. 	gate_reached = false 
  1070. 	gate_destroyed = false 
  1071. 	 
  1072. 	player_choice = "" 
  1073. 	 
  1074. 	M16_TYPE_NAME = "Mission" 
  1075. 	M16_MISSION = "Mission_16" 
  1076. 	M16_music_event_instance_id = -1 
  1077.  
  1078. 	-- Cheats 
  1079. 	M16_CHEAT_INVALID = -1 
  1080. 	M16_CHEAT_INVERTED = 0 
  1081. 	M16_CHEAT_SIZE = 1 
  1082. 	M16_CHEAT_LAG = 2 
  1083. 	M16_CHEAT_WEAPON = 3 
  1084. 	M16_CHEAT_SLOW = 4 
  1085. 	 
  1086. 	-- Effect navpoint names 
  1087. 	m16_vfx_spawn = "Vfx Cyberspace Spawn" 
  1088. 	m16_vfx_despawn = "Vfx Cyberspace Death" 
  1089. 	m16_vfx_deckers_damaged = "Vfx Emoticon Damaged" 
  1090. 	m16_vfx_deckers_attacking = "Vfx Emoticon Attacking" 
  1091. 	m16_vfx_forcefield_destroyed = "Vfx forcefield destroyed" 
  1092. 	m16_vfx_avatar_spawn = "Vfx Avatar Shockwave" 
  1093. 	 
  1094. 	-- Conversation enums 
  1095. 	M16_CONVO_PLAY_LAST = 0 
  1096. 	M16_CONVO_PLAY_NEXT = 1 
  1097. 	M16_CONVO_PLAY_IMMEDIATE = 2 
  1098. 	 
  1099. 	M16_PLAYER_GUN = "Special-CyberCannon" 
  1100. 	 
  1101. 	M16_AVATAR_SWORD = "Avatar_Sword" 
  1102. 	AVATAR_LOADOUT = { M16_AVATAR_SWORD } 
  1103. 	 
  1104. 	M16_LOADOUT = { M16_PLAYER_GUN, M16_AVATAR_SWORD } 
  1105. 	 
  1106. 	m16_local_player_special_weapon = "none" 
  1107. 	m16_remote_player_special_weapon = "none" 
  1108.  
  1109. 	-- Tank Combat -- 
  1110. 	ENEMY_TANK_PATHS_ONE_FORWARD = { "Enemy_Tank_One_Path 001", "Enemy_Tank_One_Path 002" } 
  1111. 	ENEMY_TANK_PATHS_ONE_BACK = { "Enemy_Tank_One_Path 001a", "Enemy_Tank_One_Path 002a" } 
  1112. 	ENEMY_TANK_PATHS_ONE = { ENEMY_TANK_PATHS_ONE_FORWARD, ENEMY_TANK_PATHS_ONE_BACK } 
  1113. 	ENEMY_TANK_PATHS_ONE_SINGLE_FORWARD = { "Enemy_Tank_One_Path 001", "Enemy_Tank_One_Path 002", "Enemy_Tank_One_Path 003" } 
  1114. 	ENEMY_TANK_PATHS_ONE_SINGLE_BACK = { "Enemy_Tank_One_Path 001a", "Enemy_Tank_One_Path 002a", "Enemy_Tank_One_Path 003a1" } 
  1115. 	ENEMY_TANK_PATHS_ONE_SINGLE = { ENEMY_TANK_PATHS_ONE_SINGLE_FORWARD, ENEMY_TANK_PATHS_ONE_SINGLE_BACK } 
  1116. 	ENEMY_TANK_PATHS_TWO_FORWARD = { "Enemy_Tank_Two_Path 001", "Enemy_Tank_Two_Path 002" } 
  1117. 	ENEMY_TANK_PATHS_TWO_BACK = { "Enemy_Tank_Two_Path 001a", "Enemy_Tank_Two_Path 002a" } 
  1118. 	ENEMY_TANK_PATHS_TWO = { ENEMY_TANK_PATHS_TWO_FORWARD, ENEMY_TANK_PATHS_TWO_BACK } 
  1119. 	CAMERA = M16_navpoints.tank_combat_camera 
  1120. 	 
  1121. 	M16_PHASE_ONE = 1 
  1122. 	M16_PHASE_TWO = 2 
  1123. 	M16_PHASE_THREE = 3 
  1124. 	M16_PHASE_FOUR = 4 
  1125. 	M16_PHASE_FIVE= 5 
  1126.  
  1127. 	-- Matt Battle -- 
  1128. 	Matt_health_pct = 1.0 
  1129. 	Matt_qte_complete = false 
  1130. 	Matt_qte_success = false 
  1131. 	current_phase = 0 
  1132. 	NUM_WAVES_DECKER_SEQUENCE			=		6  
  1133. 	num_times_matt_has_teleported		=		0 
  1134. 	 
  1135. 	-- Zone Swap -- 
  1136. 	M16_ZONE_NAME = "vr" 
  1137.  
  1138. -- ************************* 
  1139. -- 
  1140. -- Standard functions 
  1141. -- 
  1142. -- ************************* 
  1143.  
  1144. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  1145. -- at the specified checkpoint. 
  1146. -- CALLED FROM CODE 
  1147. -- 
  1148. -- m16_checkpoint:	The checkpoint the mission should begin at 
  1149. -- is_restart:					TRUE if the mission is restarting, FALSE otherwise 
  1150. -- 
  1151. function m16_start(m16_checkpoint, is_restart) 
  1152. 	in_coop = coop_is_active() 
  1153. 	 
  1154. 	--m16_checkpoint = M16_checkpoints.TEXT_ADVENTURE_COMPLETE 
  1155. 	--m16_checkpoint = M16_checkpoints.TANK_COMBAT_COMPLETE 
  1156. 	--m16_checkpoint = M16_checkpoints.ERROR_SCREEN_DISABLED 
  1157.  
  1158. 	--m16_checkpoint = M16_checkpoints.MATT_BATTLE_START 
  1159. 	--m16_checkpoint = M16_checkpoints.MATT_DEWINGED 
  1160. 	--m16_checkpoint = M16_checkpoints.DECKER_PHASE 
  1161. 	--m16_checkpoint = M16_checkpoints.AVATAR_BATTLE 
  1162. 	 
  1163. 	-- Check if this mission starting from the beginning 
  1164. 	if (m16_checkpoint == M16_checkpoints.CHECKPOINT_START) then 
  1165. 		if (is_restart == false) then 
  1166. 			-- First time playing mission 
  1167. 			 
  1168. 			-- Play the intro cinematic 
  1169. 			if (M16_scene.intro ~= "") then 
  1170. 				cutscene_play(M16_scene.intro, nil, nil, false) 
  1171. 			end 
  1172. 		end 
  1173. 	end 
  1174. 	 
  1175. 	city_zone_swap(M16_ZONE_NAME, true) 
  1176.  
  1177. 	-- Handle mission initialization for the current checkpoint 
  1178. 	m16_initialize(m16_checkpoint) 
  1179.   
  1180. 	-- Run the mission from the current checkpoint 
  1181. 	m16_run(m16_checkpoint) 
  1182. 	 
  1183. end 
  1184.  
  1185. -- This is the primary function responsible for running the entire mission from start to finish. 
  1186. -- 
  1187. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  1188. -- 
  1189. function m16_run(first_checkpoint) 
  1190. 	local current_checkpoint = first_checkpoint 
  1191. 	mission_set_cancel_warp_location(M16_navpoints.local_exit, M16_navpoints.remote_exit) 
  1192. 	 
  1193. 	if current_checkpoint == M16_checkpoints.CHECKPOINT_START then 
  1194. 	 
  1195. 		character_ragdoll_set_last_resort_position(M16_navpoints.local_start) 
  1196. 	 
  1197. 		m16_intro_sequence() 
  1198. 		m16_firewall_sequence() 
  1199. 		m16_text_adventure_process() 
  1200. 		m16_music_switch("M16_Music_01b_Play") 
  1201. 		m16_watch_firewall_disintegrate() 
  1202. 		 
  1203. 		current_checkpoint = M16_checkpoints.TEXT_ADVENTURE_COMPLETE 
  1204. 		mission_set_checkpoint(M16_checkpoints.TEXT_ADVENTURE_COMPLETE) 
  1205. 	end 
  1206. 	 
  1207. 	if current_checkpoint == M16_checkpoints.TEXT_ADVENTURE_COMPLETE then 
  1208. 	 
  1209. 		character_ragdoll_set_last_resort_position(M16_navpoints.tank_warp_local) 
  1210. 		 
  1211. 		m16_goto_antivirus() 
  1212. 		m16_antivirus_sequence() 
  1213. 		 
  1214. 		--can't do the tank sequence until both players are un-downed 
  1215. 		while human_is_downed(LOCAL_PLAYER) or (in_coop and human_is_downed(REMOTE_PLAYER)) do 
  1216. 			thread_yield() 
  1217. 		end 
  1218. 		 
  1219. 		m16_tank_combat_setup() 
  1220. 		m16_tank_combat_process() 
  1221. 		m16_tank_combat_clean_up() 
  1222. 		m16_watch_antivirus_disintegrate() 
  1223. 		 
  1224. 		current_checkpoint = M16_checkpoints.TANK_COMBAT_COMPLETE 
  1225. 		mission_set_checkpoint(M16_checkpoints.TANK_COMBAT_COMPLETE) 
  1226. 	end 
  1227. 	 
  1228. 	if current_checkpoint == M16_checkpoints.TANK_COMBAT_COMPLETE then 
  1229. 	 
  1230. 		character_ragdoll_set_last_resort_position(M16_navpoints.error_warp_local) 
  1231. 		 
  1232. 		m16_goto_internet_security() 
  1233. 		m16_internet_security_sequence() 
  1234. 		m16_error_screen_process() 
  1235. 		m16_watch_internet_security_disintegrate() 
  1236. 		 
  1237. 		current_checkpoint = M16_checkpoints.ERROR_SCREEN_DISABLED 
  1238. 		mission_set_checkpoint(M16_checkpoints.ERROR_SCREEN_DISABLED) 
  1239. 	end 
  1240. 	 
  1241. 	if current_checkpoint == M16_checkpoints.ERROR_SCREEN_DISABLED then 
  1242. 	 
  1243. 		character_ragdoll_set_last_resort_position(M16_navpoints.final_warp_local) 
  1244. 		 
  1245. 		m16_music_switch("M16_Music_Pre_Boss") 
  1246. 		m16_goto_cathedral() 
  1247. 	 
  1248. 		current_checkpoint = M16_checkpoints.MATT_BATTLE_START 
  1249. 		mission_set_checkpoint(M16_checkpoints.MATT_BATTLE_START) 
  1250. 	end 
  1251.  
  1252. 	if current_checkpoint == M16_checkpoints.MATT_BATTLE_START then 
  1253. 	 
  1254. 		character_ragdoll_set_last_resort_position(M16_navpoints.local_matt_battle_start) 
  1255.  
  1256. 		m16_set_phase(M16_PHASE_ONE) 
  1257. 		m16_run_matt_phase_one() 
  1258.  
  1259. 		current_checkpoint = M16_checkpoints.MATT_DEWINGED 
  1260. 		mission_set_checkpoint(M16_checkpoints.MATT_DEWINGED) 
  1261. 	end 
  1262. 	 
  1263. 	if current_checkpoint == M16_checkpoints.MATT_DEWINGED then 
  1264. 	 
  1265. 		character_ragdoll_set_last_resort_position(M16_navpoints.local_matt_battle_start) 
  1266. 	 
  1267. 		m16_set_phase(M16_PHASE_TWO) 
  1268. 		m16_run_matt_phase_two() 
  1269. 		 
  1270. 		current_checkpoint = M16_checkpoints.MATT_PHASE3 
  1271. 		mission_set_checkpoint(M16_checkpoints.MATT_PHASE3) 
  1272. 	end 
  1273. 	 
  1274. 	if current_checkpoint == M16_checkpoints.MATT_PHASE3 then 
  1275. 	 
  1276. 		character_ragdoll_set_last_resort_position(M16_navpoints.local_matt_battle_start) 
  1277. 	 
  1278. 		m16_set_phase(M16_PHASE_THREE) 
  1279. 		m16_run_matt_phase_three() 
  1280. 	 
  1281. 		current_checkpoint = M16_checkpoints.DECKER_PHASE 
  1282. 		mission_set_checkpoint(M16_checkpoints.DECKER_PHASE) 
  1283. 	end 
  1284. 	 
  1285. 	if current_checkpoint == M16_checkpoints.DECKER_PHASE then 
  1286. 	 
  1287. 		character_ragdoll_set_last_resort_position(M16_navpoints.local_matt_battle_start) 
  1288. 		 
  1289. 		m16_set_phase(M16_PHASE_FOUR)-- increment the phase on the code side 
  1290. 		m16_run_decker_phase_four() 
  1291. 		 
  1292. 		current_checkpoint = M16_checkpoints.AVATAR_BATTLE 
  1293. 		mission_set_checkpoint(M16_checkpoints.AVATAR_BATTLE) 
  1294. 	end 
  1295. 	 
  1296. 	if current_checkpoint == M16_checkpoints.AVATAR_BATTLE then 
  1297. 	 
  1298. 		character_ragdoll_set_last_resort_position(M16_navpoints.local_matt_battle_start) 
  1299. 	 
  1300. 		m16_set_phase(M16_PHASE_FIVE) -- increment the phase on the code side	 
  1301. 		zscene_prep(M16_scene.matt_defeated) 
  1302. 		m16_run_matt_phase_five() 
  1303. 		inv_remove_temp_loadout(AVATAR_LOADOUT) 
  1304. 	    boss_battle_matt_set_player_as_avatar(DISABLE) 
  1305. 	    customization_outfit_wear("Cyber Avatar")	-- put on the cyber suit. 
  1306. 		inv_item_equip(M16_PLAYER_GUN, LOCAL_PLAYER) 
  1307. 		if in_coop then 
  1308. 			inv_item_equip(M16_PLAYER_GUN, REMOTE_PLAYER) 
  1309. 		end 
  1310. 		m16_matt_defeated_zscene() 
  1311. 		m16_player_choice()	 
  1312. 	end 
  1313. 	 
  1314. 	-- Prevent Shaundi from being called as a homie until the end of M17 
  1315. 	homie_mission_lock("shaundi") 
  1316. 	 
  1317. 	-- SP 7/18: turn off the bloom/refraction screen effects before playing the outro cutscene 
  1318. 	hdr_bloom_set_multiplier(1) 
  1319. 	refraction_situation_clear() 
  1320.  
  1321. 	-- Call mission success?? 
  1322. 	mission_end_success("m16", M16_scene.outro, {M16_navpoints.local_exit, M16_navpoints.remote_exit}) 
  1323. 	 
  1324. end 
  1325.  
  1326. -- This is the primary function responsible for cleaning up the entire mission 
  1327. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  1328. -- 
  1329. function m16_cleanup() 
  1330. 	 
  1331. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, ENABLE) 
  1332. 	character_disable_revival(LOCAL_PLAYER, DISABLE) 
  1333. 		 
  1334. 	if in_coop then 
  1335. 		character_disable_revival(REMOTE_PLAYER, DISABLE) 
  1336. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, ENABLE) 
  1337. 	end 
  1338. 	 
  1339. 	city_zone_swap(M16_ZONE_NAME, false) 
  1340. 	 
  1341. 	on_damage("", M16_characters.matt) -- TEMP 
  1342. 	on_human_killed("") 
  1343. 	on_qte_animation_trigger("") 
  1344. 	 
  1345. 	on_hud_screen_exit( "", "msn_text_adventure" ) 
  1346. 	on_hud_screen_exit( "", "msn_cyber" ) 
  1347. 	 
  1348. 	-- cleanup groups 
  1349. 	m16_cleanup_groups() 
  1350. 	 
  1351. 	-- Kill all running threads 
  1352. 	m16_cleanup_threads() 
  1353. 	 
  1354. 	-- re-enable sprint, just in case they quit while it was disabled. 
  1355. 	player_can_sprint(true) 
  1356. 	 
  1357. 	-- kill the vehicle destroyed callbacks 
  1358. 	on_vehicle_destroyed("", M16_vehicles.tank_combat_npc_tank_one) 
  1359. 	on_vehicle_destroyed("", M16_vehicles.tank_combat_npc_tank_two) 
  1360. 	on_vehicle_destroyed("", M16_vehicles.tank_combat_player_tank_one) 
  1361. 	on_vehicle_destroyed("", M16_vehicles.tank_combat_player_tank_two) 
  1362. 	 
  1363. 	-- clean up triggers 
  1364. 	m16_cleanup_triggers(M16_triggers) 
  1365. 	 
  1366. 	m16_end_conversations() 
  1367. 	 
  1368. 	-- End cheats 
  1369. 	boss_battle_matt_cheats_stop() 
  1370. 	 
  1371. 	notoriety_force_no_spawn("police", false) 
  1372. 	notoriety_force_no_spawn("deckers", false) 
  1373. 	 
  1374. 	camera_end_look_through() 
  1375. 	vehicle_set_2d_tank_controls(false) 
  1376. 	 
  1377. 	qte_cleanup() 
  1378. 	 
  1379. 	player_grenades_enable() 
  1380. 	inv_remove_temp_loadout(AVATAR_LOADOUT) 
  1381. 	 
  1382. 	inv_item_equip(nil, LOCAL_PLAYER) -- Unequip the current weapon on the player 
  1383. 	inv_item_remove(M16_PLAYER_GUN, LOCAL_PLAYER) 
  1384. 	-- Add back any permenant special weapons 
  1385. 	if m16_local_player_special_weapon ~= "none" then 
  1386. 		inv_item_add(m16_local_player_special_weapon, 1, LOCAL_PLAYER) 
  1387. 	end 
  1388. 	 
  1389. 	if in_coop then 
  1390. 		inv_item_equip(nil, REMOTE_PLAYER) -- Unequip the current weapon on the player 
  1391. 		inv_item_remove(M16_PLAYER_GUN, REMOTE_PLAYER) 
  1392. 		if m16_remote_player_special_weapon ~= "none" then 
  1393. 			inv_item_add(m16_remote_player_special_weapon, 1, REMOTE_PLAYER) 
  1394. 		end	 
  1395. 	end 
  1396. 	 
  1397. 	-- restore characters 
  1398. 	character_show(LOCAL_PLAYER) 
  1399. 	player_controls_enable(LOCAL_PLAYER) 
  1400. 	turn_vulnerable(LOCAL_PLAYER) 
  1401. 	clear_animation_state(LOCAL_PLAYER) 
  1402. 	if in_coop then 
  1403. 		character_show(REMOTE_PLAYER) 
  1404. 		if character_exists(REMOTE_PLAYER) then 
  1405. 			player_controls_enable(REMOTE_PLAYER) 
  1406. 		end 
  1407. 		turn_vulnerable(REMOTE_PLAYER) 
  1408. 		clear_animation_state(REMOTE_PLAYER) 
  1409. 	end 
  1410. 	 
  1411. 	customization_item_revert() 
  1412.  
  1413. 	-- Stop using the mission specified ragdoll get up last resort. 
  1414. 	character_ragdoll_clear_last_resort_position() 
  1415. 	 
  1416. 	-- enable the players weapon radial 
  1417. 	hud_inventory_disable(false) 
  1418. 	 
  1419. 		if in_coop then 
  1420. 		hud_inventory_disable(false, REMOTE_PLAYER)  
  1421. 	end 
  1422. 	 
  1423. 	-- SP 7/13: turn off the bloom/refraction screen effects 
  1424. 	hdr_bloom_set_multiplier(1) 
  1425. 	refraction_situation_clear() 
  1426.  
  1427. 	-- turn off the music 
  1428. 	m16_music_switch("") 
  1429. 	audio_object_post_event( "M16_reset_all" ) 
  1430. 	-- Restore the HUD 
  1431. 	for i, hud_state in pairs(M16_hud_states) do 
  1432. 		if (hud_state ~= -1) then 
  1433. 			hud_display_remove_state(hud_state) 
  1434. 			hud_state = -1 
  1435. 		end 
  1436. 	end 
  1437.  
  1438. end 
  1439.  
  1440. -- Called when the mission has ended with success 
  1441. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  1442. -- 
  1443. function m16_success() 
  1444. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  1445. 	 
  1446. end 
  1447.  
  1448.  
  1449. -- ************************* 
  1450. -- 
  1451. -- Local functions 
  1452. -- 
  1453. -- ************************* 
  1454.  
  1455. function m16_music_switch(music_name) 
  1456. 	if (M16_music ~= music_name) then 
  1457. 		audio_object_post_event("M16_Music_Stop", nil, nil, LOCAL_PLAYER) 
  1458. 		audio_stop(M16_music_event_instance_id) 
  1459. 		M16_music_event_instance_id = -1 
  1460. 		if (music_name ~= "") then 
  1461. 			M16_music_event_instance_id = audio_object_post_event(music_name, nil, nil, LOCAL_PLAYER) 
  1462. 		end 
  1463. 		M16_music = music_name 
  1464. 	end 
  1465. end 
  1466.  
  1467. -- Initialize the mission for the specified checkpoint 
  1468. -- 
  1469. -- checkpoint:		Checkpoint to initialize the mission to 
  1470. -- 
  1471. function m16_initialize(checkpoint) 
  1472. 	-- Make sure the screen is completly faded out 
  1473. 	mission_start_fade_out(0.0) 
  1474.  
  1475. 	-- Set the mission author 
  1476. 	set_mission_author("John Karczewski") 
  1477.  
  1478. 	-- Common initialization 
  1479. 	m16_initialize_common() 
  1480.  
  1481. 	-- Checkpoint specific initialization 
  1482. 	m16_initialize_checkpoint(checkpoint) 
  1483.  
  1484. 	-- Start fading in  
  1485. 	--mission_start_fade_in() 
  1486.  
  1487. end 
  1488.  
  1489. -- Mission intro sequence, involving moving the player, setting up the surprise and conversation 
  1490. function m16_intro_sequence() 
  1491. 	teleport_coop(M16_navpoints.start_navs[1], M16_navpoints.start_navs[2], true) 
  1492.  
  1493. 	m16_music_switch("M16_Music_01_Play") 
  1494. 	cutscene_play( M16_cte_01.name, nil, nil, false) 
  1495. 	 
  1496. 	-- Setup surprise triggers 
  1497. 	m16_helper_surprise_groups_setup(M16_triggers.surprise1, "m16_cb_spawn_surprise_group") 
  1498. 	player_can_sprint(false) 
  1499. 	customization_item_wear("cm_toilet", "cm_toilet.cmeshx", "Material#9", M16_add_to_wardrobe) 
  1500. 	mission_start_fade_in() 
  1501. 	 
  1502. 	delay(2) 
  1503. 	 
  1504. 	-- Play the intro conversation 
  1505. 	m16_helper_conversation_play(M16_conv.mission_start, M16_CONVO_PLAY_IMMEDIATE, 1.5) 
  1506. 	 
  1507. 	objective_text( 0, "M16_OBJ_MOVE_THROUGH_DATA", "", "", SYNC_ALL, OI_ASSET_LOCATION ) 
  1508. 	delay(25) 
  1509. 	 
  1510. 	m16_helper_conversation_play(M16_conv.second_avatar, M16_CONVO_PLAY_IMMEDIATE, 2.5) 
  1511. 	 
  1512. 	-- Play spawning effect as the player changes shapes 
  1513. 	effect_play_on_human(m16_vfx_spawn, LOCAL_PLAYER)	 
  1514. 	if in_coop then 
  1515. 		effect_play_on_human(m16_vfx_spawn, REMOTE_PLAYER) 
  1516. 	end 
  1517. 	customization_item_wear("cm_blowupdoll", "cm_blowupdoll.cmeshx", "Blow_Up_Doll_A", M16_add_to_wardrobe) 
  1518. 	 
  1519. 	delay(10) 
  1520. 	 
  1521. 	-- Make sure the players aren't in the middle of anything 
  1522. 	player_can_sprint(true) 
  1523. 	m16_transform_player_into_human_avatar() 
  1524. 	 
  1525. 	delay(10) 
  1526. 	m16_helper_conversation_play(M16_conv.defenses, M16_CONVO_PLAY_IMMEDIATE,  4.0) -- play goto firewall conversation 
  1527. 	 
  1528. 	-- Set objective 
  1529. 	objective_text( 0, "m16_obj_goto_firewall", "", "", SYNC_ALL, OI_ASSET_LOCATION ) 
  1530. 	marker_add_trigger(M16_triggers.gate1, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL)	 
  1531. 	on_trigger("m16_cb_firewall_area_reached", M16_triggers.gate1) 
  1532. 	trigger_enable(M16_triggers.gate1, true) 
  1533. 	tutorial_start("weap_charge_weapon", 0, true, true)  
  1534. 	 
  1535. 	-- Wait until a player gets to the firewall 
  1536. 	while not gate_reached do 
  1537. 		thread_yield() 
  1538. 	end 
  1539. 	gate_reached = false 
  1540. end 
  1541.  
  1542. -- First onslaught sequence, the player must destroy the firewall 
  1543. function m16_firewall_sequence() 
  1544. 	 
  1545. 	m16_helper_surprise_groups_disable(M16_surprise1_trigger_groups) -- Destroy the surprise gruops 
  1546. 	m16_firewall_setup() -- begin firewall sequence 
  1547.  
  1548. 	-- Wait until the gate has been destroyed 
  1549. 	while(not gate_destroyed) do 
  1550. 		thread_yield() 
  1551. 	end 
  1552. 	 
  1553. 	gate_destroyed = false 
  1554. 	 
  1555. 	boss_battle_matt_cheats_stop() 
  1556. 	 
  1557. 	-- Disable firewall triggers and groups 
  1558. 	for i, firewall_trigger_group in pairs(M16_firewall_trigger_groups) do 
  1559. 		on_trigger("", firewall_trigger_group.name) 
  1560. 		trigger_enable(firewall_trigger_group.name, DISABLE) 
  1561. 		 
  1562. 		if group_is_loaded(firewall_trigger_group.script_group.name) then 
  1563. 			group_destroy(firewall_trigger_group.script_group.name) 
  1564. 		end 
  1565. 	end 
  1566. 	 
  1567. 	delay(4) 
  1568. end 
  1569.  
  1570. -- Spawning function for the firewall 
  1571. function m16_firewall_setup() 
  1572. 	-- Onslaught started, so a cheat, Slow! 
  1573. 	boss_battle_matt_cheats_start(M16_CHEAT_SLOW, FW1_SLOW_DURATION, FW1_CHEAT_PERIOD, false) 
  1574. 	m16_helper_conversation_play(M16_conv.cheat_one, M16_CONVO_PLAY_NEXT, 2.0) 
  1575.  
  1576. 	-- Set up the surprise triggers for the firewall groups 
  1577. 	for i, firewall_trigger_group in pairs(M16_firewall_trigger_groups) do 
  1578. 		on_trigger("m16_cb_spawn_firewall_group", firewall_trigger_group.name) 
  1579. 		trigger_enable(firewall_trigger_group.name, ENABLE) 
  1580. 	end 
  1581. 	 
  1582. 	-- Player must make it to the firewall to win, set up the trigger region 
  1583. 	marker_add_trigger(M16_triggers.firewall_destination, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL)	 
  1584. 	on_trigger("m16_cb_firewall_reached", M16_triggers.firewall_destination) 
  1585. 	trigger_enable(M16_triggers.firewall_destination, true) 
  1586.  
  1587. end 
  1588.  
  1589. -- Sets up the text adventure, handles audio, etc. 
  1590. UI_completion = { } 
  1591.  
  1592. function m16_UI_text_complete( screen_name, player_name ) 
  1593. 	if (screen_name ~= "msn_text_adventure") then 
  1594. 		return 
  1595. 	end 
  1596. 	 
  1597. 	player_controls_enable( player_name ) 
  1598. 	 
  1599. 	-- flag the player as completed 
  1600. 	UI_completion[ player_name ] = true 
  1601. end 
  1602.  
  1603. function m16_UI_error_complete( screen_name, player_name ) 
  1604. 	if (screen_name ~= "msn_cyber") then 
  1605. 		return 
  1606. 	end 
  1607. 	 
  1608. 	-- flag the player as completed 
  1609. 	UI_completion[ player_name ] = true 
  1610. 	 
  1611. 	-- if one finished first, teleport them to the waiting room until the other player is done 
  1612. 	if (not (UI_completion[ LOCAL_PLAYER ] and UI_completion[ REMOTE_PLAYER ])) then 
  1613. 		if player_name == LOCAL_PLAYER then 
  1614. 			player_controls_enable(LOCAL_PLAYER) 
  1615. 			teleport( player_name, M16_navpoints.waiting_room[1] ) 
  1616. 		else 
  1617. 			player_controls_enable(REMOTE_PLAYER) 
  1618. 			teleport( player_name, M16_navpoints.waiting_room[2] ) 
  1619. 		end 
  1620. 	end 
  1621. end 
  1622.  
  1623. function m16_text_adventure_process() 
  1624.  
  1625. 	mission_start_fade_out() 
  1626. 	delay(1) 
  1627. 	if in_coop then 
  1628. 		-- teleport to the waiting room if in coop 
  1629. 		teleport_coop(M16_navpoints.waiting_room[1], M16_navpoints.waiting_room[2], true) 
  1630. 	end 
  1631.  
  1632. 	objective_text_clear(0) 
  1633. 	objective_text( 0, "m16_obj_survive_text", "", "", SYNC_ALL, OI_ASSET_DEFEND) 
  1634. 	 
  1635. 	-- Play the intro conversation 
  1636. 	m16_helper_conversation_play(M16_conv.text_adventure, M16_CONVO_PLAY_IMMEDIATE, 1.0) 
  1637. 	 
  1638. 	-- Only play text adventure VO lines in single player 
  1639. 	if not in_coop then 
  1640. 		M16_threads.text_adventure_audio_handle = thread_new("m16_thread_text_adventure_audio_thread") 
  1641. 	end 
  1642. 	 
  1643. 	UI_completion[ LOCAL_PLAYER ] = false 
  1644. 	UI_completion[ REMOTE_PLAYER ] = not coop_is_active() 
  1645. 	 
  1646. 	-- start the text adventure and hook up a callback to know when they're done 
  1647. 	hud_push_screen( "msn_text_adventure", SYNC_ALL ) 
  1648. 	on_hud_screen_exit( "m16_UI_text_complete", "msn_text_adventure" ) 
  1649. 	mission_start_fade_in() 
  1650. 	 
  1651. 	player_controls_disable(LOCAL_PLAYER) 
  1652. 	if in_coop then 
  1653. 		player_controls_disable(REMOTE_PLAYER) 
  1654. 	end 
  1655. 	 
  1656. 	m16_music_switch("") 
  1657. 	audio_object_post_event("Text_Adventure_Mute_Audio") 
  1658. 	 
  1659. 	-- wait until both players have completed the adventure 
  1660. 	while (not (UI_completion[ LOCAL_PLAYER ] and UI_completion[ REMOTE_PLAYER ])) do 
  1661. 		thread_yield() 
  1662. 	end 
  1663. 	 
  1664. 	mission_start_fade_out() 
  1665. 	audio_object_post_event("Text_Adventure_Unmute_Audio") 
  1666. 	 
  1667. 	if not in_coop then 
  1668. 		thread_kill(M16_threads.text_adventure_audio_handle) 
  1669. 		M16_threads.text_adventure_audio_handle = INVALID_THREAD_HANDLE 
  1670. 	end 
  1671. end 
  1672.  
  1673. -- Players watch the firewall disintegrate 
  1674. function m16_watch_firewall_disintegrate() 
  1675. 	teleport_coop(M16_navpoints.firewall_destroyed[1], M16_navpoints.firewall_destroyed[2], true) 
  1676. 	mission_start_fade_in() 
  1677. 	player_controls_disable(LOCAL_PLAYER) 
  1678. 	if in_coop then 
  1679. 		player_controls_disable(REMOTE_PLAYER) 
  1680. 	end 
  1681. 	 
  1682. 	m16_helper_conversation_play(M16_conv.firewall_destroyed, M16_CONVO_PLAY_NEXT, 1.0) 
  1683. 	delay(2) 
  1684. 	effect_play_on_script_object(m16_vfx_forcefield_destroyed, M16_movers.gate1) 
  1685. 	delay(1.5) 
  1686. 	mesh_mover_hide(M16_movers.gate1) 
  1687. 	 
  1688. 	delay(5.0) 
  1689. 	 
  1690. 	player_controls_enable(LOCAL_PLAYER) 
  1691. 	if in_coop then 
  1692. 		player_controls_enable(REMOTE_PLAYER) 
  1693. 	end 
  1694. 	mission_start_fade_out() 
  1695. end 
  1696.  
  1697. -- Sets up the gameplay leading to the antivirus 
  1698. function m16_goto_antivirus() 
  1699.  
  1700. 	teleport_coop(M16_navpoints.tank_warp_local, M16_navpoints.tank_warp_remote, true) 
  1701. 	customization_item_wear("cm_toilet", "cm_toilet.cmeshx", "Material#9", M16_add_to_wardrobe) 
  1702. 		 
  1703. 	-- Setup surprise triggers 
  1704. 	m16_helper_surprise_groups_setup(M16_triggers.surprise2, "m16_cb_spawn_surprise_group") 
  1705.  
  1706. 	objective_text_clear(0) 
  1707. 	objective_text( 0, "m16_obj_goto_anti_virus", "", "", SYNC_ALL, OI_ASSET_LOCATION) 
  1708. 	 
  1709. 	on_trigger("m16_cb_antivirus_reached", M16_triggers.gate2) 
  1710. 	trigger_enable(M16_triggers.gate2, true) 
  1711. 	marker_add_trigger(M16_triggers.gate2, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1712. 	 
  1713. 	-- Make sure the cybercannon is equipped 
  1714. 	inv_item_equip(M16_PLAYER_GUN, LOCAL_PLAYER) 
  1715. 	if in_coop then 
  1716. 		inv_item_equip(M16_PLAYER_GUN, REMOTE_PLAYER) 
  1717. 	end 
  1718. 	 
  1719. 	mission_start_fade_in() 
  1720. 		 
  1721. 	m16_helper_conversation_play(M16_conv.toilet_again, M16_CONVO_PLAY_IMMEDIATE, 4.0) 
  1722.  
  1723. 	-- Wait until a player reaches the gate 2 trigger 
  1724. 	while not gate_reached do 
  1725. 		thread_yield() 
  1726. 	end 
  1727. 	gate_reached = false 
  1728. end 
  1729.  
  1730. -- 2nd onslaught, player must destroy the antivirus 
  1731. function m16_antivirus_sequence() 
  1732. 	customization_outfit_wear("Cyber Avatar")	-- put on the cyber suit. 
  1733. 	m16_helper_surprise_groups_disable(M16_surprise2_trigger_groups) 
  1734. 	tutorial_start("weap_charge_weapon", 0, true, true)  
  1735. 	 
  1736. 	-- Onslaught started, so a cheat, Lag! 
  1737. 	boss_battle_matt_cheats_start(M16_CHEAT_LAG, FW2_LAG_DURATION, FW2_CHEAT_PERIOD, false) 
  1738. 	m16_helper_conversation_play(M16_conv.cheat_two, M16_CONVO_PLAY_IMMEDIATE, 4.0) 
  1739. 	--m16_helper_conversation_play(M16_conv.graves_one, M16_CONVO_PLAY_NEXT, 6.0) 
  1740. 	 
  1741. 	objective_text_clear(0) 
  1742. 	objective_text( 0, "m16_obj_kill_all_enemies", "", "", SYNC_ALL, OI_ASSET_KILL ) 
  1743. 	 
  1744. 	m16_antivirus_process() -- spawns npcs 
  1745. 	 
  1746. 	boss_battle_matt_cheats_stop() -- Stop the cheats 
  1747.  
  1748. 	m16_helper_play_dialog_line(M16_personas.matt.persona_id, M16_dialog_lines.banish_to_tank.name) 
  1749. end 
  1750.  
  1751. -- Spawning function for the antivirus fight sequence 
  1752. -- 
  1753. -- gate_groups:		(string) name of the group to spawn 
  1754. -- 
  1755. function m16_antivirus_process() 
  1756.  
  1757. 	m16_process_antivirus_wave(M16_groups.antivirus_one) 
  1758. 	delay(1) 
  1759. 	m16_process_antivirus_wave(M16_groups.antivirus_two) 
  1760. 	delay(1) 
  1761. 	m16_process_antivirus_wave(M16_groups.antivirus_three) 
  1762. 	delay(1) 
  1763. 	m16_process_antivirus_wave(M16_groups.antivirus_four) 
  1764. 	 
  1765. 	group_destroy(M16_groups.antivirus_one) 
  1766. 	group_destroy(M16_groups.antivirus_two) 
  1767. 	group_destroy(M16_groups.antivirus_three) 
  1768. 	group_destroy(M16_groups.antivirus_four) 
  1769.  
  1770. end 
  1771.  
  1772. -- Spawns a group, sets it up, and then blocks until it is killed 
  1773. -- 
  1774. -- group:		(string) group to spawn 
  1775. function m16_process_antivirus_wave(group) 
  1776. 	-- Spawn wave one and wait for it to die 
  1777. 	group_create_hidden(group, true) 
  1778. 	 
  1779. 	-- hide the coop only npcs 
  1780. 	if not in_coop then 
  1781. 		for i, member in pairs(group.members_single) do 
  1782. 			m16_setup_cyberdecker(member) 
  1783. 		end 
  1784. 	else 
  1785. 		for i, member in pairs(group.members) do 
  1786. 			m16_setup_cyberdecker(member) 
  1787. 		end 
  1788. 	end 
  1789. 	 
  1790. 	-- Need to process different sets of enemies based on single/coop 
  1791. 	if not in_coop then 
  1792. 		m16_process_enemy_set(group.members_single) 
  1793. 	else 
  1794. 		m16_process_enemy_set(group.members) 
  1795. 	end 
  1796. end 
  1797.  
  1798. -- Creates tanks, teleports the player, and whatever else needs to be done to set up the tank combat 
  1799. function m16_tank_combat_setup() 
  1800. 	delay(1) 
  1801. 	mission_start_fade_out() 
  1802. 	 
  1803. 	-- restore player health, so we don't get any low hp blips 
  1804. 	set_current_hit_points(LOCAL_PLAYER, get_max_hit_points(LOCAL_PLAYER)) 
  1805. 	if in_coop then 
  1806. 		set_current_hit_points(REMOTE_PLAYER, get_max_hit_points(REMOTE_PLAYER)) 
  1807. 	end 
  1808. 	 
  1809. 	-- Hide everything on the HUD 
  1810. 	M16_hud_states.hide_all = hud_display_create_state() 
  1811. 	hud_display_set_element(M16_hud_states.hide_all, HUD_ALL_ELEM, HUD_FADE_HIDDEN) 
  1812. 	hud_display_commit_state(M16_hud_states.hide_all) 
  1813. 	 
  1814. 	-- Only display the GSI 
  1815. 	M16_hud_states.gsi = hud_display_create_state() 
  1816. 	hud_display_set_element(M16_hud_states.gsi, HUD_ELEM_GSI, HUD_FADE_VISIBLE) 
  1817. 	hud_display_commit_state(M16_hud_states.gsi) 
  1818. 	 
  1819. 	-- Setup player/npc tank one 
  1820. 	group_create(M16_groups.tank_combat_player_one.name, true) 
  1821. 	group_create(M16_groups.tank_combat_npc_one.name, true) 
  1822. 	vehicle_enter_teleport(LOCAL_PLAYER, M16_vehicles.tank_combat_player_tank_one) 
  1823. 	turn_invulnerable(LOCAL_PLAYER) 
  1824. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, DISABLE) 
  1825. 	vehicle_enter_teleport(M16_characters.tank_combat_tank_npc_one, M16_vehicles.tank_combat_npc_tank_one) 
  1826. 	npc_suppress_persona(M16_characters.tank_combat_tank_npc_one, ENABLE) 
  1827. 	on_vehicle_destroyed("m16_tank_one_destroyed_cb", M16_vehicles.tank_combat_npc_tank_one) 
  1828. 	on_vehicle_destroyed("m16_player_tank_destroyed_cb", M16_vehicles.tank_combat_player_tank_one) 
  1829. 	turn_invulnerable(M16_characters.tank_combat_tank_npc_one) 
  1830. 	vehicle_prevent_vehicle_collision_damage(M16_vehicles.tank_combat_player_tank_one, true) 
  1831. 	vehicle_prevent_vehicle_collision_damage(M16_vehicles.tank_combat_npc_tank_one, true) 
  1832. 	vehicle_max_speed(M16_vehicles.tank_combat_npc_tank_one, 35) 
  1833.  
  1834. 	if (in_coop) then 
  1835. 		group_create(M16_groups.tank_combat_player_two.name,true) 
  1836. 		group_create(M16_groups.tank_combat_npc_two.name, true) 
  1837. 		vehicle_enter_teleport(REMOTE_PLAYER, M16_vehicles.tank_combat_player_tank_two) 
  1838. 		turn_invulnerable(REMOTE_PLAYER) 
  1839. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, DISABLE) 
  1840. 		vehicle_enter_teleport(M16_characters.tank_combat_tank_npc_two, M16_vehicles.tank_combat_npc_tank_two) 
  1841. 		npc_suppress_persona(M16_characters.tank_combat_tank_npc_two, ENABLE) 
  1842. 		on_vehicle_destroyed("m16_tank_two_destroyed_cb", M16_vehicles.tank_combat_npc_tank_two) 
  1843. 		on_vehicle_destroyed("m16_player_tank_destroyed_cb", M16_vehicles.tank_combat_player_tank_two) 
  1844. 		turn_invulnerable(M16_characters.tank_combat_tank_npc_two) 
  1845. 		vehicle_prevent_vehicle_collision_damage(M16_vehicles.tank_combat_player_tank_two, true) 
  1846. 		vehicle_prevent_vehicle_collision_damage(M16_vehicles.tank_combat_npc_tank_two, true) 
  1847. 		vehicle_max_speed(M16_vehicles.tank_combat_npc_tank_two, 35) 
  1848.  
  1849. 	end 
  1850. 	 
  1851. 	objective_text_clear(0) 
  1852. 	objective_text( 0, "m16_obj_kill_tanks", "", "", SYNC_ALL, OI_ASSET_KILL) 
  1853. 	m16_music_switch("Tank_Battle_Music") 
  1854. 	camera_look_through(M16_navpoints.tank_combat_camera, 0, false, false) 
  1855. 	vehicle_set_2d_tank_controls(true) 
  1856.  
  1857. 	mission_start_fade_in() 
  1858. 	 
  1859. 	m16_helper_conversation_play(M16_conv.tank_sequence, M16_CONVO_PLAY_IMMEDIATE, 0.0) 
  1860. end 
  1861.  
  1862. -- Actually starts the combat, then waits for the combat to be completed 
  1863. function m16_tank_combat_process() 
  1864. 	if character_is_in_vehicle(M16_characters.tank_combat_tank_npc_one, M16_vehicles.tank_combat_npc_tank_one) then 
  1865. 		 
  1866. 		local tank_paths = ENEMY_TANK_PATHS_ONE 
  1867. 		if not in_coop then 
  1868. 			-- we want the enemy tank to take different paths in single player 
  1869. 			tank_paths = ENEMY_TANK_PATHS_ONE_SINGLE 
  1870. 		end 
  1871. 		 
  1872. 		M16_threads.tank_one_thread_handle = thread_new("m16_do_tank_pathing_thread", M16_vehicles.tank_combat_npc_tank_one, tank_paths) 
  1873. 		ai_add_enemy_target(M16_characters.tank_combat_tank_npc_one, LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE) 
  1874. 	end 
  1875. 	 
  1876. 	if (in_coop and character_is_in_vehicle(M16_characters.tank_combat_tank_npc_two, M16_vehicles.tank_combat_npc_tank_two)) then 
  1877. 		M16_threads.tank_two_thread_handle = thread_new("m16_do_tank_pathing_thread", M16_vehicles.tank_combat_npc_tank_two, ENEMY_TANK_PATHS_TWO) 
  1878. 		 
  1879. 		ai_add_enemy_target(M16_characters.tank_combat_tank_npc_one, REMOTE_PLAYER, ATTACK_NOW_NEVER_LOSE) 
  1880. 		ai_add_enemy_target(M16_characters.tank_combat_tank_npc_two, LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE) 
  1881. 		ai_add_enemy_target(M16_characters.tank_combat_tank_npc_two, REMOTE_PLAYER, ATTACK_NOW_NEVER_LOSE) 
  1882. 	end 
  1883. 	 
  1884. 	while(not m16_tank_combat_end_battle()) do		 
  1885. 		thread_yield() 
  1886. 	end 
  1887. 	 
  1888. 	thread_kill(M16_threads.tank_one_thread_handle) 
  1889. 	M16_threads.tank_one_thread_handle = INVALID_THREAD_HANDLE 
  1890. 	vehicle_set_invulnerable(M16_vehicles.tank_combat_player_tank_one) -- Make tank invulnerable, player has won. 
  1891. 	 
  1892. 	if (in_coop) then 
  1893. 		thread_kill(M16_threads.tank_two_thread_handle) 
  1894. 		M16_threads.tank_two_thread_handle = INVALID_THREAD_HANDLE 
  1895. 		vehicle_set_invulnerable(M16_vehicles.tank_combat_player_tank_two) -- Make tank invulnerable, player has won. 
  1896. 		 
  1897. 		-- restore player controls so we can prep for teleporting them 
  1898. 		if vehicle_is_destroyed(M16_vehicles.tank_combat_player_tank_one) then 
  1899. 			character_show(LOCAL_PLAYER) 
  1900. 			player_controls_enable(LOCAL_PLAYER) 
  1901. 		end 
  1902. 		 
  1903. 		if vehicle_is_destroyed(M16_vehicles.tank_combat_player_tank_two) then 
  1904. 			character_show(REMOTE_PLAYER) 
  1905. 			player_controls_enable(REMOTE_PLAYER) 
  1906. 		end 
  1907. 	end 
  1908. 	 
  1909. 	m16_music_switch("Tank_Battle_Music_Win") 
  1910. 	delay(6) 
  1911. end 
  1912.  
  1913. -- Checks to see if the NPC tanks have been killed yet 
  1914. function m16_tank_combat_end_battle() 
  1915.  
  1916. 	local continue = false 
  1917. 	 
  1918. 	continue = vehicle_is_destroyed(M16_vehicles.tank_combat_npc_tank_one) 
  1919. 	 
  1920. 	if (in_coop) then 
  1921. 		if (continue) then 
  1922. 			-- The tank associated with player one has been destroyed, whats the status of player two's? 
  1923. 			continue = vehicle_is_destroyed(M16_vehicles.tank_combat_npc_tank_two) 
  1924. 			return continue 
  1925. 		end 
  1926. 	end 
  1927. 	 
  1928. 	return continue 
  1929.  
  1930. end 
  1931.  
  1932. -- Clean up tank combat 
  1933. function m16_tank_combat_clean_up() 
  1934.  
  1935. 	mission_start_fade_out() 
  1936. 	delay(1) 
  1937. 	 
  1938. 	-- Unhide specific hud elements 
  1939. 	hud_display_remove_state(M16_hud_states.hide_all) 
  1940. 	M16_hud_states.hide_all = -1 
  1941. 	 
  1942. 	hud_display_remove_state(M16_hud_states.gsi) 
  1943. 	M16_hud_states.gsi = -1 
  1944. 	 
  1945. 	camera_end_look_through() 
  1946. 	vehicle_set_2d_tank_controls(false) 
  1947. 	 
  1948. 	vehicle_exit_do(LOCAL_PLAYER, true) 
  1949. 	turn_vulnerable(LOCAL_PLAYER) 
  1950. 	group_destroy(M16_groups.tank_combat_player_one.name) 
  1951. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, ENABLE) 
  1952. 	on_vehicle_destroyed("", M16_vehicles.tank_combat_player_tank_one) 
  1953. 	if (in_coop) then 
  1954. 		vehicle_exit_do(REMOTE_PLAYER, true) 
  1955. 		turn_vulnerable(REMOTE_PLAYER) 
  1956. 		group_destroy(M16_groups.tank_combat_player_two.name) 
  1957. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, ENABLE) 
  1958. 		on_vehicle_destroyed("", M16_vehicles.tank_combat_player_tank_two) 
  1959. 	end 
  1960. end 
  1961.  
  1962. -- Warp the player to watch the antivirus disintegrate 
  1963. function m16_watch_antivirus_disintegrate() 
  1964. 	m16_music_switch("M16_Music_02_Play") 
  1965. 	 
  1966. 	teleport_coop(M16_navpoints.antivirus_destroyed[1], M16_navpoints.antivirus_destroyed[2], true) 
  1967. 	mission_start_fade_in() 
  1968. 	 
  1969. 	player_controls_disable(LOCAL_PLAYER) 
  1970. 	if in_coop then 
  1971. 		player_controls_disable(REMOTE_PLAYER) 
  1972. 	end 
  1973. 	 
  1974. 	delay(1) 
  1975. 	effect_play_on_script_object(m16_vfx_forcefield_destroyed, M16_movers.gate2) 
  1976. 	delay(1.5) 
  1977. 	mesh_mover_hide(M16_movers.gate2) 
  1978. 	delay(0.5) 
  1979. 	 
  1980. 	player_controls_enable(LOCAL_PLAYER) 
  1981. 	if in_coop then 
  1982. 		player_controls_enable(REMOTE_PLAYER) 
  1983. 	end 
  1984. 	 
  1985. 	mission_start_fade_out() -- fade out to prep for the teleport 
  1986. end 
  1987.  
  1988. -- Sets up the gameplay leading to the antivirus 
  1989. function m16_goto_internet_security() 
  1990. 	teleport_coop(M16_navpoints.error_warp_local, M16_navpoints.error_warp_remote, true) 
  1991. 	 
  1992. 	objective_text_clear(0) 
  1993. 	objective_text( 0, "m16_obj_goto_internet_security", "", "", SYNC_ALL, OI_ASSET_LOCATION) 
  1994. 	 
  1995. 	-- Setup surprise triggers 
  1996. 	m16_helper_surprise_groups_setup(M16_triggers.surprise3, "m16_cb_spawn_surprise_group") 
  1997. 	 
  1998. 	customization_item_wear("cm_blowupdoll", "cm_blowupdoll.cmeshx", "Blow_Up_Doll_A", M16_add_to_wardrobe) 
  1999. 	 
  2000. 	m16_helper_conversation_play(M16_conv.doll_again, M16_CONVO_PLAY_IMMEDIATE, 3.0) 
  2001. 	 
  2002. 	m16_helper_conversation_play(M16_conv.see_last_wall, M16_CONVO_PLAY_NEXT, 10.0) 
  2003. 	 
  2004. 	--m16_helper_conversation_play(M16_conv.graves_two, M16_CONVO_PLAY_NEXT, 10.0) 
  2005. 	 
  2006. 	on_trigger("m16_cb_internet_security_reached", M16_triggers.gate3) 
  2007. 	trigger_enable(M16_triggers.gate3, true) 
  2008. 	marker_add_trigger(M16_triggers.gate3, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  2009.  
  2010. 	-- Make sure the cybercannon is equipped 
  2011. 	inv_item_equip(M16_PLAYER_GUN, LOCAL_PLAYER) 
  2012. 	if in_coop then 
  2013. 		inv_item_equip(M16_PLAYER_GUN, REMOTE_PLAYER) 
  2014. 	end 
  2015.  
  2016. 	mission_start_fade_in() 
  2017. 	 
  2018. 	while not gate_reached do 
  2019. 		thread_yield() 
  2020. 	end 
  2021. 	gate_reached = false 
  2022. end 
  2023.  
  2024. -- Third gate sequence 
  2025. function m16_internet_security_sequence() 
  2026. 	customization_outfit_wear("Cyber Avatar")	-- put on the cyber suit. 
  2027. 	 
  2028. 	-- Onslaught started, so a cheat, Inverted! 
  2029. 	boss_battle_matt_cheats_start(M16_CHEAT_INVERTED, FW3_INVERT_DURATION, FW3_CHEAT_PERIOD, false) 
  2030. 	 
  2031. 	m16_helper_conversation_play(M16_conv.attack_security, M16_CONVO_PLAY_NEXT, 2.0) 
  2032. 	 
  2033. 	m16_helper_conversation_play(M16_conv.nyte_blade, M16_CONVO_PLAY_LAST, 4.0) 
  2034. 	 
  2035. 	objective_text_clear(0) 
  2036. 	objective_text( 0, "m16_obj_kill_all_enemies", "", "", SYNC_ALL, OI_ASSET_KILL ) 
  2037. 	m16_internet_security_process()-- spawns npcs 
  2038. 	 
  2039. 	boss_battle_matt_cheats_stop() -- stop the cheats 
  2040. 	 
  2041. 	delay(2) -- wait 2 seconds for the line to complete 
  2042. end 
  2043.  
  2044. -- Function handles the spawning/tracking of npcs at the internet_security wall 
  2045. function m16_internet_security_process() 
  2046. 	m16_helper_surprise_groups_disable(M16_surprise3_trigger_groups) -- destroy the surprise groups 
  2047. 	 
  2048. 	group_create_hidden(M16_groups.security, true) 
  2049. 	 
  2050. 	if in_coop then 
  2051. 		group_create_hidden(M16_groups.security_coop, true) 
  2052. 	end 
  2053. 	 
  2054. 	for i, wave in pairs(M16_internet_security_waves) do 
  2055. 		 
  2056. 		for k, member in pairs(wave) do 
  2057. 			m16_setup_cyberdecker(member)			 
  2058. 			marker_add(member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL)			 
  2059. 			delay(DELAY_BETWEEN_DECKER_GROUP_SPAWNS) 
  2060. 		end 
  2061. 		 
  2062. 		if in_coop then 
  2063. 				 
  2064. 			for k, coop_member in pairs(M16_internet_security_coop_waves[i]) do 
  2065. 				m16_setup_cyberdecker(coop_member)			 
  2066. 				marker_add(coop_member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL)			 
  2067. 				delay(DELAY_BETWEEN_DECKER_GROUP_SPAWNS) 
  2068. 			end 
  2069. 		end 
  2070. 		delay(TIME_BETWEEN_GATE_SPAWNS) 
  2071. 		thread_yield() 
  2072. 	end 
  2073. 	 
  2074. 	m16_process_enemy_set(M16_groups.security.members) 
  2075. 	 
  2076. 	if in_coop then 
  2077. 		m16_process_enemy_set(M16_groups.security_coop.members) 
  2078. 	end 
  2079. 	 
  2080. 	group_destroy(M16_groups.security) 
  2081. 	 
  2082. 	if in_coop then 
  2083. 		group_destroy(M16_groups.security_coop) 
  2084. 	end 
  2085. end 
  2086.  
  2087. -- Sets up the error screen, handles audio, etc. 
  2088. function m16_error_screen_process() 
  2089.  
  2090. 	player_controls_disable(LOCAL_PLAYER) 
  2091. 	if in_coop then 
  2092. 		player_controls_disable(REMOTE_PLAYER) 
  2093. 	end 
  2094.  
  2095. 	m16_music_switch("M16_Screen_Crash") 
  2096. 	audio_object_post_event("M16_PC_Beep") 
  2097. 	 
  2098. 	UI_completion[ LOCAL_PLAYER ] = false 
  2099. 	UI_completion[ REMOTE_PLAYER ] = not coop_is_active() 
  2100.  
  2101. 	hud_push_screen("msn_cyber", SYNC_ALL) 
  2102. 	on_hud_screen_exit( "m16_UI_error_complete", "msn_cyber" ) 
  2103. 	 
  2104. 	objective_text_clear(0) 
  2105. 	objective_text( 0, "m16_obj_debug_error", "", "", SYNC_ALL) 
  2106. 	 
  2107. 	-- Play the conversation 
  2108. 	m16_helper_conversation_play(M16_conv.error_message, M16_CONVO_PLAY_IMMEDIATE, 6.0) 
  2109.  
  2110. 	 
  2111. 	while (not (UI_completion[ LOCAL_PLAYER ] and UI_completion[ REMOTE_PLAYER ])) do 
  2112. 		thread_yield() 
  2113. 	end 
  2114. 	 
  2115. 	audio_object_post_event("M16_Screen_Crash_Stop") 
  2116. 	 
  2117. 	player_controls_enable(LOCAL_PLAYER) 
  2118. 	if in_coop then 
  2119. 		player_controls_enable(REMOTE_PLAYER) 
  2120. 	end 
  2121. end 
  2122.  
  2123. -- Warp the player to watch the security disintegrate 
  2124. function m16_watch_internet_security_disintegrate() 
  2125. 	mission_start_fade_out() 
  2126. 	teleport_coop(M16_navpoints.security_destroyed[1], M16_navpoints.security_destroyed[2], true) 
  2127. 	mission_start_fade_in() 
  2128. 	 
  2129. 	player_controls_disable(LOCAL_PLAYER) 
  2130. 	if in_coop then 
  2131. 		player_controls_disable(REMOTE_PLAYER) 
  2132. 	end 
  2133. 	 
  2134. 	delay(1) 
  2135. 	effect_play_on_script_object(m16_vfx_forcefield_destroyed, M16_movers.gate3) 
  2136. 	delay(1.5) 
  2137. 	mesh_mover_hide(M16_movers.gate3) 
  2138. 	delay(0.5) 
  2139. 	 
  2140. 	player_controls_enable(LOCAL_PLAYER) 
  2141. 	if in_coop then 
  2142. 		player_controls_enable(REMOTE_PLAYER) 
  2143. 	end 
  2144. 	 
  2145. 	mission_start_fade_out() 
  2146. end 
  2147.  
  2148. -- All three defenses disabled, proceed to the cathedral 
  2149. function m16_goto_cathedral() 
  2150. 	m16_music_switch("m16_pre_boss_music") 
  2151. 	objective_text_clear(0) 
  2152. 	 
  2153. 	zscene_prep(M16_scene.matt_intro) 
  2154. 	 
  2155. 	teleport_coop(M16_navpoints.final_warp_local, M16_navpoints.final_warp_remote, true) 
  2156. 	mission_start_fade_in() 
  2157. 	 
  2158. 	m16_helper_conversation_play(M16_conv.security_destroyed, M16_CONVO_PLAY_IMMEDIATE, 1.0) -- play firewall conversation 
  2159. 	 
  2160. 	marker_add_trigger(M16_triggers.final, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  2161. 	on_trigger("m16_final_cb", M16_triggers.final) 
  2162. 	trigger_enable(M16_triggers.final, true) 
  2163. 	 
  2164. 	-- set up the triggers to cause the walls to fade 
  2165. 	for i, wall_trigger in pairs(M16_triggers.cathedral_wall) do 
  2166. 		on_trigger("m16_cathedral_walk_wall_fade", wall_trigger) 
  2167. 		trigger_enable(wall_trigger, true) 
  2168. 	end 
  2169. 	 
  2170. 	delay(1) 
  2171. 	 
  2172. 	effect_play_on_script_object(m16_vfx_forcefield_destroyed, M16_movers.final_gate_mover) 
  2173. 	delay(1.5) 
  2174. 	mesh_mover_hide(M16_movers.final_gate_mover) 
  2175. 	 
  2176. 	while(not gate_destroyed) do 
  2177. 		thread_yield() 
  2178. 	end 
  2179. 	 
  2180. 	m16_music_switch("") 
  2181. 	 
  2182. 	m16_matt_intro_zscene() 
  2183. end 
  2184.  
  2185. -- function yields until matt reaches a specified health 
  2186. function m16_wait_for_matt_health(health_pct) 
  2187. 	while not character_exists(M16_characters.matt) do 
  2188. 		thread_yield() 
  2189. 	end 
  2190. 	 
  2191. 	Matt_health_pct = get_current_hit_points(M16_characters.matt) / get_max_hit_points(M16_characters.matt) 
  2192. 	 
  2193. 	while (Matt_health_pct > health_pct) do 
  2194. 		thread_yield() 
  2195. 	end 
  2196. end 
  2197.  
  2198. -- Mark the QTE globals accordingly so m16_wait_for_qte_complete can function. 
  2199. -- 
  2200. function m16_qte_complete(success) 
  2201. 	Matt_qte_complete = true 
  2202. 	Matt_qte_success = success 
  2203. end 
  2204.  
  2205. -- Wait for a QTE to complete. 
  2206. -- 
  2207. -- Return true if the player won the QTE, false if they failed. 
  2208. -- 
  2209. function m16_wait_for_qte_complete() 
  2210. 	Matt_qte_complete = false 
  2211. 	while not Matt_qte_complete do 
  2212. 		thread_yield() 
  2213. 	end 
  2214. 	 
  2215. 	return Matt_qte_success 
  2216. end 
  2217.  
  2218. function m16_set_current_phase_hitpoints() 
  2219. 	local pct = M16_phase_matt_health[current_phase] 
  2220. 	 
  2221. 	-- the final phase sets the health a bit higher before continuing. 
  2222. 	if (current_phase == #M16_phase_matt_health - 1) then 
  2223. 		pct = M16_final_phase_health_reset 
  2224. 	end 
  2225. 	 
  2226. 	set_current_hit_points(M16_characters.matt, (get_max_hit_points(M16_characters.matt)*pct)) -- reset matt 
  2227. end 
  2228.  
  2229. function m16_set_phase(phase) 
  2230. 	current_phase = phase 
  2231. 	boss_battle_matt_set_phase(phase) 
  2232. 	 
  2233. 	-- Leave the first phase alone, since it'll start at full health. 
  2234. 	if (phase ~= 1) then 
  2235. 		m16_set_current_phase_hitpoints() 
  2236. 	end 
  2237. 	 
  2238. 	if M16_threads.matt_health_thread_handle ~= INVALID_THREAD_HANDLE then 
  2239. 		thread_kill(M16_threads.matt_health_thread_handle) 
  2240. 		M16_threads.matt_health_thread_handle = INVALID_THREAD_HANDLE 
  2241. 	end 
  2242.  
  2243. 	-- Min-cap matt's health for the phase. 
  2244. 	local next_index = phase+1 
  2245. 	if (next_index <= #M16_phase_matt_health) then 
  2246. 		M16_threads.matt_health_thread_handle = thread_new("m16_matt_health_thread", M16_phase_matt_health[next_index]) 
  2247. 	end 
  2248. end 
  2249.  
  2250. -- Run phase one fo the Matt boss battle. 
  2251. function m16_run_matt_phase_one() 
  2252. 	 
  2253. 	-- Initialize stuff... 
  2254. 	m16_init_matt_battle(M16_checkpoints.MATT_BATTLE_START) 
  2255. 	boss_battle_matt_set_matt_flying(ENABLE) 
  2256. 	set_ignore_ai_flag(M16_characters.matt, ENABLE) 
  2257. 	human_gravity_enable(M16_characters.matt, DISABLE) 
  2258. 	 
  2259. 	-- Fade in and play the conversation and a taunt 
  2260. 	mission_start_fade_in() 
  2261. 	m16_helper_conversation_play(M16_conv.matt_battle_begins, M16_CONVO_PLAY_IMMEDIATE, 0.0) 
  2262. 	 
  2263. 	action_play(M16_characters.matt, M16_animations.matt_taunt_b, nil, false, 1.0) 
  2264. 	 
  2265. 	-- Matt is in the air, so change his animation group 
  2266. 	set_script_animation_group(M16_characters.matt, "Pistol") 
  2267. 	 
  2268. 	-- Take off 
  2269. 	action_play(M16_characters.matt, "stand to ready", nil, false, 1.0) 
  2270. 	set_ignore_ai_flag(M16_characters.matt, DISABLE) 
  2271. 	 
  2272. 	M16_threads.matt_teleport_thread_handle = thread_new("m16_matt_air_teleport_thread") 
  2273. 	M16_threads.cheat_audio_handle = thread_new("m16_thread_cheat_audio_thread") 
  2274. 	 
  2275. 	-- Make sure the intro conversation is done 
  2276. 	while not m16_helper_conversation_check_done(M16_conv.matt_battle_begins) do 
  2277. 		thread_yield() 
  2278. 	end 
  2279. 	 
  2280. 	m16_helper_play_dialog_line(M16_personas.kinzie.persona_id, M16_dialog_lines.kinzie_boss_start.name) 
  2281. 	 
  2282. 	boss_battle_matt_begin(false) -- begin the fight, start cheats immediately 
  2283. 	 
  2284. 	-- Wait for him to get below the specified health level. 
  2285. 	m16_wait_for_matt_health(M16_phase_matt_health[current_phase+1]) 
  2286. 	 
  2287. 	-- If Matt is in the air, we need to bring him down 
  2288. 	m16_matt_land() 
  2289. 	 
  2290. 	m16_do_qte(M16_navpoints.first_qte) 
  2291. 	set_script_animation_group(M16_characters.matt, "Rifle") 
  2292. 	 
  2293. 	while (m16_wait_for_qte_complete() == false) do 
  2294. 		marker_add(M16_characters.matt, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL) 
  2295. 		m16_set_current_phase_hitpoints() 
  2296. 		m16_matt_lift_off_again() -- Matt goes back into the air on failure 
  2297. 		 
  2298. 		-- Wait for him to get below the specified health level (again). 
  2299. 		m16_wait_for_matt_health(M16_phase_matt_health[current_phase+1]) 
  2300. 		 
  2301. 		-- If Matt is in the air, we need to bring him down 
  2302. 		m16_matt_land() 
  2303. 		 
  2304. 		m16_do_qte(M16_navpoints.first_qte) 
  2305. 		set_script_animation_group(M16_characters.matt, "Rifle") 
  2306. 	end 
  2307. 	 
  2308. 	-- Put matt back on the ground and turn back on his AI 
  2309. 	human_gravity_enable(M16_characters.matt, ENABLE) 
  2310. 	set_ignore_ai_flag(M16_characters.matt, DISABLE) 
  2311. 	boss_battle_matt_set_matt_flying(DISABLE) 
  2312. 		 
  2313. 	-- Kill Matt's teleport thread. 
  2314. 	thread_kill(M16_threads.matt_teleport_thread_handle) 
  2315. 	M16_threads.matt_teleport_thread_handle = INVALID_THREAD_HANDLE 
  2316. end 
  2317.  
  2318. -- Matt just had his wings ripped off, he is grounded 
  2319. function m16_run_matt_phase_two() 
  2320.  
  2321. 	debug_print( "MAD", "-- PHASE 2 --" ) 
  2322. 	set_behavior_set(M16_characters.matt, "Matt Avatar Phase 2") 
  2323. 	set_script_animation_group(M16_characters.matt, "Rifle") 
  2324. 	 
  2325. 	-- Set up the 'shoot him in the head' sequence. 
  2326. 	marker_add(M16_characters.matt, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL) 
  2327. 	m16_wait_for_matt_health(M16_phase_matt_health[current_phase+1]) 
  2328. 	human_enter_downed(M16_characters.matt) 
  2329. end 
  2330.  
  2331. -- Matt has been blasted, next time he gets low the decker phase will start 
  2332. function m16_run_matt_phase_three() 
  2333. 	debug_print( "MAD", "-- PHASE 3 --" ) 
  2334. 	 
  2335. 	set_behavior_set(M16_characters.matt, "Matt Avatar Phase 2") 
  2336. 	set_script_animation_group(M16_characters.matt, "Rifle") 
  2337.  
  2338. 	-- After Matt's health is low enough, do the decker phase. 
  2339. 	m16_wait_for_matt_health(M16_phase_matt_health[current_phase+1]) 
  2340. 	 
  2341. 	-- Set up the player as an avatar. 
  2342. 	m16_prep_avatar_for_decker_battle() 
  2343. end 
  2344.  
  2345. -- Player avatar vs lots of deckers.   
  2346. function m16_run_decker_phase_four() 
  2347. 	debug_print( "MAD", "-- PHASE 4 --" ) 
  2348. 	 
  2349. 	if M16_threads.cheat_audio_handle ~= INVALID_THREAD_HANDLE then 
  2350. 		thread_kill(M16_threads.cheat_audio_handle) 
  2351. 		M16_threads.cheat_audio_handle = INVALID_THREAD_HANDLE 
  2352. 	end 
  2353.  
  2354. 	m16_helper_conversation_play(M16_conv.ability_explanation, M16_CONVO_PLAY_IMMEDIATE, 0.0) 
  2355.  
  2356. 	-- Remove the marker from Matt 
  2357. 	marker_remove(M16_characters.matt) 
  2358. 	 
  2359. 	objective_text( 0, "m16_obj_kill_all_enemies", "", "", SYNC_ALL, OI_ASSET_KILL ) 
  2360. 	 
  2361. 	M16_threads.decker_spawn_handle = thread_new("m16_thread_boss_battle_decker_spawn") 
  2362. 	delay(0.5) 
  2363. 	M16_threads.decker_spawn_handle2 = thread_new("m16_thread_boss_battle_decker_spawn") 
  2364. 	delay(DECKER_SEQUENCE_DURATION) -- this phase is timed, just wait for it to end 
  2365. 	 
  2366. 	set_ignore_ai_flag(M16_characters.matt, ENABLE) 
  2367. 	 
  2368. 	-- Cleanup spawning threads 
  2369. 	thread_kill(M16_threads.decker_spawn_handle) 
  2370. 	M16_threads.decker_spawn_handle = INVALID_THREAD_HANDLE 
  2371. 	thread_kill(M16_threads.decker_spawn_handle2) 
  2372. 	M16_threads.decker_spawn_handle2 = INVALID_THREAD_HANDLE 
  2373. 	 
  2374. 	delay(1) 
  2375. 	m16_helper_conversation_play(M16_conv.matt_returns, M16_CONVO_PLAY_IMMEDIATE, 0.0) 
  2376. 	-- Kill all remaining deckers 
  2377. 	for i, decker_group in pairs(M16_wave_groups) do 
  2378. 		if group_is_loaded(decker_group) then 
  2379. 			for member_number, member in pairs(decker_group.members) do 
  2380. 				if character_exists(member) and not character_is_dead(member) then 
  2381. 					character_kill(member) 
  2382. 				end 
  2383. 			end 
  2384. 			delay(0.5) 
  2385. 			group_destroy(decker_group) 
  2386. 		end 
  2387. 		 
  2388. 	end 
  2389.  
  2390. 	inv_item_remove_all(M16_characters.matt) 
  2391. 	inv_item_add("Avatar_Sword", 1, M16_characters.matt, true) 
  2392. 	 
  2393. 	teleport(M16_characters.matt, M16_navpoints.matt_summon, nil, false, 1.0) 
  2394. 	character_show(M16_characters.matt) 
  2395. 	action_play(M16_characters.matt, M16_animations.tele_end, nil, false, 1.0) 
  2396. 	action_play(M16_characters.matt, M16_animations.matt_taunt_b, nil, false, 1.0) 
  2397. 	turn_vulnerable(M16_characters.matt) 
  2398. 	set_ignore_ai_flag(M16_characters.matt, DISABLE) 
  2399. 	objective_text( 0, "m16_obj_kill_matt", "", "", SYNC_ALL, OI_ASSET_KILL) 
  2400. end 
  2401.  
  2402. function m16_run_matt_phase_five() 
  2403. 	set_behavior_set(M16_characters.matt, "Matt Avatar Phase 4") 
  2404. 	marker_add(M16_characters.matt, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL) 
  2405. 	set_script_animation_group(M16_characters.matt, "Default") 
  2406. 	M16_threads.matt_teleport_thread_handle = thread_new("m16_matt_ground_teleport_thread") 
  2407. 	 
  2408. 	m16_wait_for_matt_health(M16_phase_matt_health[current_phase+1]) 
  2409. 	 
  2410. 	thread_kill(M16_threads.matt_teleport_thread_handle) 
  2411. 	M16_threads.matt_teleport_thread_handle = INVALID_THREAD_HANDLE 
  2412. 	 
  2413. 	-- Warp Matt out 
  2414. 	character_prevent_flinching(M16_characters.matt, ENABLE) 
  2415. 	turn_invulnerable(M16_characters.matt) 
  2416. 	set_ignore_ai_flag(M16_characters.matt, true) 
  2417. 	action_stop_custom(M16_characters.matt) 
  2418. 	delay(0.5) 
  2419. 	action_play(M16_characters.matt, M16_animations.matt_taunt_b, nil, false, 1.0) 
  2420. 	action_play(M16_characters.matt, M16_animations.tele_start, nil, false, 1.0) 
  2421. 	 
  2422. 	boss_battle_matt_set_matt_flying(ENABLE) -- turn on flying so we can teleport him under the ground temporarily 
  2423. 	character_hide(M16_characters.matt) 
  2424. 	inv_item_remove_all(M16_characters.matt) 
  2425. 	marker_remove(M16_characters.matt) 
  2426. 	human_gravity_enable(M16_characters.matt, DISABLE) 
  2427.  
  2428. 	teleport(M16_characters.matt, M16_navpoints.matt_hide_loc) 
  2429. 	delay(1) 
  2430. 	character_show(M16_characters.matt) 
  2431. 	delay(1) 
  2432. 		 
  2433. 	on_qte_animation_trigger("m16_final_qte_fade_cb") 
  2434. 	 
  2435. 	m16_do_qte(M16_navpoints.final_qte) 
  2436. 	inv_item_add("Avatar_Sword", 1, M16_characters.matt, true) 
  2437. 	 
  2438. 	while (m16_wait_for_qte_complete() == false) do 
  2439. 		M16_threads.matt_teleport_thread_handle = thread_new("m16_matt_ground_teleport_thread") 
  2440. 	 
  2441. 		-- Player failed, reset HP and set up the gameplay qte 
  2442. 		m16_set_current_phase_hitpoints() 
  2443. 		turn_vulnerable(M16_characters.matt) 
  2444. 		set_ignore_ai_flag(M16_characters.matt, DISABLE) 
  2445. 		human_gravity_enable(M16_characters.matt, ENABLE) 
  2446. 		boss_battle_matt_set_matt_flying(DISABLE) 
  2447. 		character_prevent_flinching(M16_characters.matt, DISABLE) 
  2448. 		 
  2449. 		marker_add(M16_characters.matt, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL) 
  2450. 		 
  2451. 		-- Wait for him to get back below the amount, and do it again. 
  2452. 		m16_wait_for_matt_health(M16_phase_matt_health[current_phase+1]) 
  2453. 		thread_kill(M16_threads.matt_teleport_thread_handle) 
  2454. 		M16_threads.matt_teleport_thread_handle = INVALID_THREAD_HANDLE 
  2455. 		 
  2456. 		turn_invulnerable(M16_characters.matt) 
  2457. 		character_prevent_flinching(M16_characters.matt, ENABLE) 
  2458. 		set_ignore_ai_flag(M16_characters.matt, true) 
  2459. 		action_stop_custom(M16_characters.matt) 
  2460. 		delay(0.5) 
  2461. 		action_play(M16_characters.matt, M16_animations.matt_taunt_b, nil, false, 1.0) 
  2462. 		action_play(M16_characters.matt, M16_animations.tele_start, nil, false, 1.0) 
  2463. 		character_hide(M16_characters.matt) 
  2464. 		inv_item_remove_all(M16_characters.matt) 
  2465. 		marker_remove(M16_characters.matt) 
  2466. 		human_gravity_enable(M16_characters.matt, DISABLE) 
  2467. 		boss_battle_matt_set_matt_flying(ENABLE) 
  2468. 		teleport(M16_characters.matt, M16_navpoints.matt_hide_loc) 
  2469. 		delay(1) 
  2470. 		character_show(M16_characters.matt) 
  2471. 		delay(1) 
  2472. 		 
  2473. 		m16_do_qte(M16_navpoints.final_qte) 
  2474. 		inv_item_add("Avatar_Sword", 1, M16_characters.matt, true) 
  2475. 	end 
  2476. 	 
  2477. 	if M16_threads.matt_health_thread_handle ~= INVALID_THREAD_HANDLE then 
  2478. 		thread_kill(M16_threads.matt_health_thread_handle) 
  2479. 		M16_threads.matt_health_thread_handle = INVALID_THREAD_HANDLE 
  2480. 	end 
  2481. 	 
  2482. 	on_qte_animation_trigger("") 
  2483. 	boss_battle_matt_set_matt_flying(DISABLE) 
  2484. 	marker_remove(M16_characters.matt, SYNC_ALL) 
  2485. 	objective_text_clear(0) 
  2486. end 
  2487. -- Player choice sequence that happens once Matt has been defeated 
  2488. function m16_player_choice() 
  2489.  
  2490. 	if group_is_loaded(M16_groups.matt.name) then 
  2491. 		group_destroy(M16_groups.matt.name) 
  2492. 	end 
  2493. 	customization_item_revert() 
  2494. 	customization_outfit_wear("Cyber Avatar") 
  2495. 	objective_text_clear(0) 
  2496. 	teleport_coop(M16_navpoints.final_choice_local, M16_navpoints.final_choice_remote , true) 
  2497. 	mission_start_fade_in() 
  2498. 	 
  2499. 	delay(1.0) 
  2500. 	 
  2501. 	-- Play matt's conversation 
  2502. 	m16_helper_conversation_play(M16_conv.reward_choice, M16_CONVO_PLAY_IMMEDIATE, 0.0)  
  2503. 	 
  2504. 	delay(3.0) 
  2505. 	 
  2506. 	on_trigger("m16_player_choice_made_cb", M16_triggers.choicea) 
  2507. 	trigger_enable(M16_triggers.choicea, true) 
  2508. 	on_trigger("m16_player_choice_made_cb", M16_triggers.choiceb) 
  2509. 	trigger_enable(M16_triggers.choiceb, true) 
  2510. 	 
  2511. 	marker_add_trigger(M16_triggers.choicea, MINIMAP_ICON_USE, INGAME_EFFECT_CHECKPOINT, OI_ASSET_USE, OI_FLAGS_LOCATION, SYNC_ALL) 
  2512. 	marker_add_trigger(M16_triggers.choiceb, MINIMAP_ICON_USE, INGAME_EFFECT_CHECKPOINT, OI_ASSET_USE, OI_FLAGS_LOCATION, SYNC_ALL) 
  2513.  
  2514. 	object_indicator_add_objective_text(M16_triggers.choicea, "PLAYER_CHOICE_M16_OPTION2_TITLE", "PLAYER_CHOICE_M16_OPTION2_BODY") 
  2515. 	object_indicator_add_objective_text(M16_triggers.choiceb, "PLAYER_CHOICE_M16_OPTION1_TITLE", "PLAYER_CHOICE_M16_OPTION1_BODY") 
  2516. 	 
  2517. 	while (not M16_conv.reward_choice.completed) and (player_choice == "") do 
  2518. 		thread_yield() 
  2519. 	end 
  2520. 	 
  2521. 	objective_text( 0, "M16_OBJ_CHOOSE_A_COMPANY", "", "", SYNC_ALL, OI_ASSET_USE) 
  2522. 	 
  2523. 	while(player_choice == "") do 
  2524. 		thread_yield() 
  2525. 	end 
  2526. 	 
  2527. 	if (player_choice == "choicea") then 
  2528. 		mission_set_excluded_reward("Vehicle_Customization_Price") 
  2529. 	else 
  2530. 		mission_set_excluded_reward("Weapon_Customization_Price") 
  2531. 	end 
  2532. 	 
  2533. 	fade_out(0) 
  2534. 	delay(2) 
  2535. 	inv_item_equip(nil, LOCAL_PLAYER) -- Unequip the current weapon on the player 
  2536. 	if in_coop then 
  2537. 		inv_item_equip(nil, REMOTE_PLAYER) -- Unequip the current weapon on the player 
  2538. 	end 
  2539. end 
  2540.  
  2541. function m16_matt_intro_zscene() 
  2542. 	while (not zscene_is_loaded(M16_scene.matt_intro)) do 
  2543. 		thread_yield() 
  2544. 	end 
  2545.  
  2546. 	cutscene_play(M16_scene.matt_intro, nil, nil, false) 
  2547. end 
  2548.  
  2549. function m16_matt_defeated_zscene() 
  2550. 	m16_music_switch("") 
  2551. 	while (not zscene_is_loaded(M16_scene.matt_defeated)) do 
  2552. 		thread_yield() 
  2553. 	end 
  2554. 	cutscene_play(M16_scene.matt_defeated, nil, nil, false) 
  2555. end 
  2556.  
  2557.  
  2558.  
  2559. -- *************************************************** 
  2560. -- m16_run Helper Functions 
  2561. -- *************************************************** 
  2562.  
  2563. -- Perform the necessary things to get Matt back into the air after failing a QTE. 
  2564. -- 
  2565. function m16_matt_lift_off_again() 
  2566. 	 
  2567. 	set_behavior_set(M16_characters.matt, "Matt Avatar Phase 1") 
  2568. 	human_gravity_enable(M16_characters.matt, DISABLE) 
  2569. 	 
  2570. 	-- change his AI and animation group 
  2571. 	set_script_animation_group(M16_characters.matt, "Pistol") 
  2572.  
  2573. 	delay(3) 
  2574. 	set_animation_state(M16_characters.matt, "stand ready") 
  2575. 	set_ignore_ai_flag(M16_characters.matt, false) 
  2576. 	 
  2577. 	-- Fire back up the teleport thread 
  2578. 	M16_threads.matt_teleport_thread_handle = thread_new("m16_matt_air_teleport_thread") 
  2579. end 
  2580.  
  2581. -- Make Matt land on the ground 
  2582. function m16_matt_land() 
  2583. 	thread_kill(M16_threads.matt_teleport_thread_handle) 
  2584. 	M16_threads.matt_teleport_thread_handle = INVALID_THREAD_HANDLE 
  2585. 	 
  2586. 	set_ignore_ai_flag(M16_characters.matt, true) 
  2587. 	action_stop_custom(M16_characters.matt) 
  2588. 	delay(0.5) 
  2589. 	 
  2590. 	action_play_non_blocking(M16_characters.matt, "ready to stand") 
  2591. 	repeat 
  2592. 		thread_yield() 
  2593. 	until action_play_is_finished(M16_characters.matt, 0.75) 
  2594. 	 
  2595. 	marker_remove(M16_characters.matt) 
  2596. 	 
  2597. 	repeat 
  2598. 		thread_yield() 
  2599. 	until action_play_is_finished(M16_characters.matt, 1.0)	 
  2600. 	 
  2601. 	inv_item_remove_all(M16_characters.matt) 
  2602. 	teleport(M16_characters.matt, M16_navpoints.matt_hide_loc) 
  2603. 	inv_item_add("Avatar_Sword", 1, M16_characters.matt, true) 
  2604. 	delay(1) 
  2605. 	character_show(M16_characters.matt) 
  2606. end 
  2607.  
  2608. function m16_attach_emoticon(member) 
  2609. 	if(rand_int(1,2) == 1) then 
  2610. 		effect_play_on_human(m16_vfx_deckers_damaged, member, "Head", true) 
  2611. 	else 
  2612. 		effect_play_on_human(m16_vfx_deckers_attacking, member, "Head", true) 
  2613. 	end 
  2614. end 
  2615.  
  2616. function m16_setup_cyberdecker(member) 
  2617. 	turn_invulnerable(member) 
  2618. 	effect_play_on_human(m16_vfx_spawn, member) 
  2619. 	npc_suppress_persona(member, ENABLE)  
  2620. 	character_show(member) 
  2621. 	character_set_counter_on_grabbed_by_player(member, true) 
  2622. 	on_death("m16_clear_callbacks", member) 
  2623. 	if not character_is_dead(member) then 
  2624. 		m16_attach_emoticon(member) 
  2625. 	end 
  2626. 	ai_add_enemy_target(member, CLOSEST_PLAYER, ATTACK_NOW) 
  2627. 	turn_vulnerable(member) 
  2628. 	delay(DELAY_BETWEEN_DECKER_GROUP_SPAWNS) 
  2629. end 
  2630.  
  2631. -- Spawns a group as hidden, and plays the spawning effect on them just before unhiding them. 
  2632. -- 
  2633. -- group_name:		(string) name of the group to spawn 
  2634. -- 
  2635. function m16_spawn_cyberdecker_group(group_name) 
  2636. 	group_create_hidden(group_name, true) 
  2637. 	group_foreach_npc(group_name, m16_setup_cyberdecker) 
  2638. end 
  2639.  
  2640. -- Checks to see if the players are in the middle of a combat move and if they are 'ready' 
  2641. -- 
  2642. -- returns:			(bool) true - both players are not in a combat move and are ready, false otherwise 
  2643. function m16_players_are_ready_to_transform() 
  2644. 	local local_player_ready = false 
  2645. 	local remote_player_ready = false 
  2646.  
  2647. 	if not character_playing_combat_move(LOCAL_PLAYER) and character_is_ready(LOCAL_PLAYER) then 
  2648. 		local_player_ready = true 
  2649. 	end 
  2650.  
  2651. 	if in_coop then 
  2652. 		if not character_playing_combat_move(REMOTE_PLAYER) and character_is_ready(REMOTE_PLAYER) then 
  2653. 			remote_player_ready = true 
  2654. 		else 
  2655. 			remote_player_ready = false 
  2656. 		end 
  2657. 	else 
  2658. 		remote_player_ready = true -- just force this to true when no coop player is present 
  2659. 	end 
  2660. 	 
  2661. 	if local_player_ready and remote_player_ready then 
  2662. 		return true 
  2663. 	else 
  2664. 		return false 
  2665. 	end 
  2666. end 
  2667.  
  2668. -- Handles transforming the players into the human avatar and makes sure it is safe to do so 
  2669. function m16_transform_player_into_human_avatar() 
  2670. 	local safe_to_transform = false 
  2671. 	 
  2672. 	-- We need to make sure the players aren't doing anything like melee moves during the transform 
  2673. 	while not safe_to_transform do 
  2674. 		-- Check and see if the player is in the middle of anything 
  2675. 		while not m16_players_are_ready_to_transform() do 
  2676. 			-- They are, so block 
  2677. 			thread_yield() 
  2678. 		end 
  2679. 		 
  2680. 		-- Both players are either ready or are exiting synced melee animations 
  2681. 		delay(5) -- wait a few seconds for any animations to finish blending, then check again 
  2682. 		if m16_players_are_ready_to_transform() then 
  2683. 			-- Still not doing anything, its now safe to transform 
  2684. 			safe_to_transform = true 
  2685. 		end 
  2686. 		thread_yield() 
  2687. 	end 
  2688. 	 
  2689. 	m16_helper_conversation_play(M16_conv.actual_avatar, M16_CONVO_PLAY_IMMEDIATE, 2.0) 
  2690. 	-- Play spawning effect as the player changes shapes 
  2691. 	effect_play_on_human(m16_vfx_spawn, LOCAL_PLAYER)	 
  2692. 	if in_coop then 
  2693. 		effect_play_on_human(m16_vfx_spawn, REMOTE_PLAYER) 
  2694. 	end 
  2695.  
  2696. 	customization_outfit_wear("Cyber Avatar")	-- put on the cyber suit. 
  2697. 	inv_item_add(M16_PLAYER_GUN, 1, LOCAL_PLAYER, true) 
  2698. 	if in_coop then 
  2699. 		inv_item_add(M16_PLAYER_GUN, 1, REMOTE_PLAYER, true) 
  2700. 	end 
  2701. end 
  2702.  
  2703. -- *************************************************** 
  2704. -- m16_initialize Helper Functions 
  2705. -- *************************************************** 
  2706.  
  2707. -- Handle any common initialization 
  2708. -- 
  2709. function m16_initialize_common() 
  2710. 	on_human_killed("m16_cyberdecker_died_cb") 
  2711. 	 
  2712. 	-- No notoriety for this mission 
  2713. 	notoriety_force_no_spawn("police", true) 
  2714. 	notoriety_force_no_spawn("deckers", true) 
  2715. 	 
  2716. 	-- Bring no homies. 
  2717. 	party_dismiss_all() 
  2718. 	 
  2719. 	-- set up the death trigger 
  2720. 	on_trigger("m16_death_trigger", M16_triggers.death) 
  2721. 	trigger_enable(M16_triggers.death, true) 
  2722. 	 
  2723. 	-- Keep track of the special weapon for both players 
  2724. 	 
  2725. 	inv_item_equip(nil, LOCAL_PLAYER) -- Unequip the current weapon on the player 
  2726. 	 
  2727. 	m16_local_player_special_weapon = inv_item_in_slot(LOCAL_PLAYER, "special") -- if the player has a special weapon, remove it for the mission 
  2728. 	if m16_local_player_special_weapon ~= nil then 
  2729. 		inv_item_remove(m16_local_player_special_weapon, LOCAL_PLAYER) 
  2730. 	end 
  2731.  
  2732. 	if in_coop then 
  2733. 		inv_item_equip(nil, REMOTE_PLAYER) -- Unequip the current weapon on the player 
  2734. 		m16_remote_player_special_weapon = inv_item_in_slot(REMOTE_PLAYER, "special") -- remove the current special weapon for the mission 
  2735. 		if m16_remote_player_special_weapon ~= nil then 
  2736. 			inv_item_remove(m16_remote_player_special_weapon, REMOTE_PLAYER) 
  2737. 		end 
  2738. 	end 
  2739. 	 
  2740. 	-- Hide the minimap 
  2741. 	M16_hud_states.hide_minimap = hud_display_create_state() 
  2742. 	hud_display_set_element(M16_hud_states.hide_minimap, HUD_ELEM_MINIMAP, HUD_FADE_HIDDEN) 
  2743. 	hud_display_commit_state(M16_hud_states.hide_minimap) 
  2744. 	 
  2745. 	-- disable the players weapon radial 
  2746. 	hud_inventory_disable(true) 
  2747. 	 
  2748. 	if in_coop then 
  2749. 		hud_inventory_disable(true, REMOTE_PLAYER)  
  2750. 	end 
  2751. 	 
  2752. 	player_grenades_disable() 
  2753. 	 
  2754. 	-- Load 2d personas 
  2755. 	M16_personas.kinzie.persona_id = audio_persona_load_2d(M16_personas.kinzie.name) 
  2756. 	M16_personas.matt.persona_id = audio_persona_load_2d(M16_personas.matt.name) 
  2757. 	 
  2758. 	-- Start the conversation thread 
  2759. 	M16_threads.process_convo = thread_new("m16_thread_process_conversations") 
  2760.  
  2761. 	-- SP 7/13: screen effects turn on when mission starts 
  2762. 	hdr_bloom_set_multiplier(1.5) 
  2763. 	refraction_situation_set("cyber_m16") 
  2764.  
  2765. end 
  2766.  
  2767. -- Checkpoint specific initialization 
  2768. -- 
  2769. -- checkpoint:		The checkpoint to be initialized 
  2770. function m16_initialize_checkpoint(checkpoint) 
  2771. 	 
  2772. 	if (checkpoint == M16_checkpoints.TEXT_ADVENTURE_COMPLETE) then 
  2773. 		m16_music_switch("M16_Music_01b_Play") 
  2774. 	end 
  2775. 	 
  2776. 	if (checkpoint == M16_checkpoints.TANK_COMBAT_COMPLETE) then 
  2777. 		m16_music_switch("M16_Music_02_Play") 
  2778. 	end 
  2779. 	 
  2780. 	-- Put on the cyber suit. 
  2781. 	if (checkpoint ~= M16_checkpoints.CHECKPOINT_START) then 
  2782. 	 
  2783. 		inv_item_add(M16_PLAYER_GUN, 1, LOCAL_PLAYER, true) 
  2784. 		if in_coop then 
  2785. 			inv_item_add(M16_PLAYER_GUN, 1, REMOTE_PLAYER, true) 
  2786. 		end 
  2787. 		 
  2788. 		if (checkpoint ~= M16_checkpoints.DECKER_PHASE) and (checkpoint ~= M16_checkpoints.AVATAR_BATTLE) then 
  2789. 			customization_outfit_wear("Cyber Avatar") 
  2790. 		end 
  2791. 	end 
  2792. 	 
  2793. 	if (checkpoint == M16_checkpoints.MATT_DEWINGED) then 
  2794. 		m16_init_matt_battle(M16_checkpoints.MATT_DEWINGED) 
  2795. 		boss_battle_matt_begin() -- begin the fight, start cheats 
  2796. 		boss_battle_matt_set_matt_flying(DISABLE) 
  2797. 		delay(1) 
  2798. 		boss_battle_matt_hide_wings() 
  2799. 		M16_threads.cheat_audio_handle = thread_new("m16_thread_cheat_audio_thread") -- start up the cheat audio thread 
  2800. 		mission_start_fade_in() 
  2801. 	end 
  2802. 	 
  2803. 	if (checkpoint == M16_checkpoints.MATT_PHASE3) then 
  2804. 		m16_init_matt_battle(M16_checkpoints.MATT_PHASE3) 
  2805. 		boss_battle_matt_begin() -- begin the fight, start cheats 
  2806. 		boss_battle_matt_set_matt_flying(DISABLE) 
  2807. 		delay(1) 
  2808. 		boss_battle_matt_hide_wings() 
  2809. 		M16_threads.cheat_audio_handle = thread_new("m16_thread_cheat_audio_thread") -- start up the cheat audio thread 
  2810. 		mission_start_fade_in() 
  2811. 	end 
  2812. 	 
  2813. 	if (checkpoint == M16_checkpoints.DECKER_PHASE) then 
  2814. 		m16_init_matt_battle(M16_checkpoints.DECKER_PHASE) 
  2815. 		boss_battle_matt_set_player_as_avatar(ENABLE) 
  2816. 		set_behavior_set(M16_characters.matt, "Matt Avatar Phase 2") -- Override Matts behavior 
  2817. 		character_hide(M16_characters.matt) 
  2818. 		boss_battle_matt_set_matt_flying(DISABLE) 
  2819. 		delay(1) 
  2820. 		boss_battle_matt_hide_wings() 
  2821. 		inv_add_temp_loadout(AVATAR_LOADOUT) 
  2822. 		inv_item_remove_all(M16_characters.matt) 
  2823. 		delay(1) 
  2824. 		mission_start_fade_in() 
  2825. 	end 
  2826. 	 
  2827. 	if (checkpoint == M16_checkpoints.AVATAR_BATTLE) then 
  2828. 		m16_init_matt_battle(M16_checkpoints.AVATAR_BATTLE) 
  2829. 		set_ignore_ai_flag(M16_characters.matt, ENABLE) 
  2830. 		boss_battle_matt_set_player_as_avatar(ENABLE) 
  2831. 		set_behavior_set(M16_characters.matt, "Matt Avatar Phase 4") 
  2832. 		boss_battle_matt_set_matt_flying(DISABLE) 
  2833. 		delay(1) 
  2834. 		boss_battle_matt_hide_wings() 
  2835. 		inv_add_temp_loadout(AVATAR_LOADOUT) 
  2836. 		delay(1) 
  2837. 		set_ignore_ai_flag(M16_characters.matt, DISABLE) 
  2838. 		mission_start_fade_in() 
  2839. 	end 
  2840. end 
  2841.  
  2842. -- Initialzation for the boss battle, generic stuff - nothing phase specific 
  2843. function m16_init_matt_battle(checkpoint_name) 
  2844. 	teleport_coop(M16_navpoints.local_matt_battle_start, M16_navpoints.remote_matt_battle_start, true) 
  2845.  
  2846. 	objective_text( 0, "m16_obj_kill_matt", "", "", SYNC_ALL, OI_ASSET_KILL) 
  2847. 	group_create(M16_groups.matt.name, true) 
  2848. 	character_set_only_scripted_grabs(M16_characters.matt, true) 
  2849. 	set_behavior_set(M16_characters.matt, "Matt Avatar Phase 1") -- Set his behavior to the default behavior 
  2850. 	 
  2851. 	if checkpoint_name ~= M16_checkpoints.DECKER_PHASE then 
  2852. 		marker_add(M16_characters.matt, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL) 
  2853. 	end 
  2854. 	 
  2855. 	inv_item_remove_all(M16_characters.matt) 
  2856. 	set_cant_flee_flag(M16_characters.matt, ENABLE) 
  2857. 	inv_item_add("Avatar_Sword", 1, M16_characters.matt, true) 
  2858. 	character_allow_ragdoll(M16_characters.matt, false) 
  2859. 	character_set_never_fall(M16_characters.matt, false) 
  2860. 	ai_add_enemy_target(M16_characters.matt, CLOSEST_PLAYER, ATTACK_NOW_NEVER_LOSE) 
  2861. 	 
  2862. 	character_disable_revival(LOCAL_PLAYER, ENABLE) 
  2863. 	if in_coop then 
  2864. 		character_disable_revival(REMOTE_PLAYER, ENABLE) 
  2865. 		local single_player_hp = get_max_hit_points(M16_characters.matt) 
  2866. 		set_max_hit_points(M16_characters.matt, single_player_hp * MATT_COOP_HEALTH_MULTIPLIER, true)  
  2867. 	end 
  2868. 	 
  2869. 	-- Make sure the cybercannon is equipped 
  2870. 	inv_item_equip(M16_PLAYER_GUN, LOCAL_PLAYER) 
  2871. 	if in_coop then 
  2872. 		inv_item_equip(M16_PLAYER_GUN, REMOTE_PLAYER) 
  2873. 	end 
  2874. 	 
  2875. 	m16_music_switch("M16_Boss_Music_Play") 
  2876. end 
  2877.  
  2878.  
  2879. -- *************************************************** 
  2880. -- Miscellaneous m16 Helper Functions 
  2881. -- *************************************************** 
  2882.  
  2883. -- Cleanup all threads 
  2884. -- 
  2885. function m16_cleanup_threads() 
  2886. 	cleanup_threads(M16_threads) 
  2887. end 
  2888.  
  2889. -- Cleanup all the groups of characters and vehicles 
  2890. --  
  2891. function m16_cleanup_groups() 
  2892. 	cleanup_groups(M16_groups) 
  2893. 	 
  2894. 	for i, group in pairs(M16_groups) do 
  2895. 		group_foreach_npc(group.name, m16_clear_callbacks) 
  2896. 	end 
  2897. end 
  2898.  
  2899. function m16_cleanup_triggers(trigger_group) 
  2900. 	for i, trigger in pairs(trigger_group) do 
  2901. 		if (type(trigger) == "table") then 
  2902. 			m16_cleanup_triggers(trigger) 
  2903. 		else		 
  2904. 			on_trigger("", trigger) 
  2905. 			trigger_enable(trigger, false) 
  2906. 			marker_remove(trigger) 
  2907. 		end 
  2908. 	end 
  2909. end 
  2910.  
  2911. function m16_end_conversations() 
  2912. 	-- Kill the conversation thread 
  2913. 	m16_helper_conversation_kill_all() 
  2914. 	if (thread_check_done(M16_threads.process_convo) == false) then 
  2915. 		thread_kill(M16_threads.process_convo) 
  2916. 		M16_threads.process_convo = INVALID_THREAD_HANDLE 
  2917. 	end 
  2918. 	 
  2919. 	audio_persona_remove_2d(M16_personas.kinzie.persona_id) 
  2920. 	M16_personas.kinzie.persona_id = INVALID_PERSONA_HANDLE 
  2921. 		 
  2922. 	audio_persona_remove_2d(M16_personas.matt.persona_id) 
  2923. 	M16_personas.matt.persona_id = INVALID_PERSONA_HANDLE	 
  2924. end 
  2925.  
  2926. function m16_kill_group_member(member) 
  2927. 	if (not character_is_dead(member) and not character_hidden(member)) then 
  2928. 		character_kill(member) 
  2929. 	end 
  2930. end 
  2931.  
  2932. -- Kills all alive group members 
  2933. function m16_kill_all_group_members(gate_groups) 
  2934. 	for i, group in pairs(gate_groups) do 
  2935. 		group_foreach_npc(group.name, m16_kill_group_member) 
  2936. 	end 
  2937. end 
  2938.  
  2939. -- Helper function that enables all the surprise group triggers, and sets up their callbacks 
  2940. -- 
  2941. -- surprise_groups:		(table) Table of groups to set up 
  2942. -- callback:				(string) Correstponding on_trigger callback 
  2943. function m16_helper_surprise_groups_setup(surprise_groups, callback) 
  2944. 	for i, trigger in pairs(surprise_groups) do 
  2945. 		on_trigger(callback, trigger) 
  2946. 		trigger_enable(trigger, ENABLE) 
  2947. 	end 
  2948. end 
  2949.  
  2950. -- Helper function that disables all surprise group triggers, and cleans up all the surprise groups 
  2951. -- 
  2952. -- surprise_groups:		(table) Table of groups to set up (ex. M16_surprise_triggers.surprise1) 
  2953. function m16_helper_surprise_groups_disable(surprise_groups) 
  2954. 	for i, trigger in pairs(surprise_groups) do 
  2955. 		on_trigger("", trigger.name) 
  2956. 		trigger_enable(trigger.name, DISABLE) 
  2957. 		 
  2958. 		if group_is_loaded(trigger.script_group.name) then 
  2959. 			-- Remove all the callbacks on the group members 
  2960. 			for i, member in pairs(trigger.script_group.members) do 
  2961. 				on_death("", member) 
  2962. 			end 
  2963. 			group_destroy(trigger.script_group.name) 
  2964. 		end 
  2965. 	end 
  2966. end 
  2967.  
  2968. -- Custom process enemey set for m16.  Marks all npcs in the group spawned and waits for their death. 
  2969. function m16_process_enemy_set(enemy_table) 
  2970. 	enemy_set_setup(enemy_table, true) 
  2971.  
  2972. 	while (not Process_enemy_set_cleared) do 
  2973. 		thread_yield() 
  2974. 	end 
  2975. 	 
  2976. 	-- make sure everything is cleaned up 
  2977. 	enemy_set_cleanup(enemy_table) 
  2978. end 
  2979.  
  2980. -- Check if a particular conversation is done (Originally written by Matt Gawalek for Mission 02) 
  2981. -- 
  2982. -- convo_table:		Conversation Lua table (see M16_conversations) 
  2983. function m16_helper_conversation_check_done(convo_table) 
  2984. 	if (convo_table.queued == false) then 
  2985. 		return true 
  2986. 	else 
  2987. 		return convo_table.ended 
  2988. 	end 
  2989. end 
  2990.  
  2991. -- Helper to play conversations, by adding them to the cue (Originally written by Matt Gawalek for Mission 02) 
  2992. -- 
  2993. -- convo_table:		Conversation Lua table (see M16_conversations) 
  2994. -- priority:		Desired priority for the conversation 
  2995. -- delay:			Amonut of time to dalya after this conversation before playing the next conversation (in seconds) 
  2996. function m16_helper_conversation_play(convo_table, priority, delay) 
  2997. 	convo_table.queued = true 
  2998. 	convo_table.delay = delay 
  2999. 	 
  3000. 	if (priority == M16_CONVO_PLAY_LAST) then 
  3001. 		-- Insert this entry at the end of hte lsit 
  3002. 		convo_queue.list[convo_queue.size] = convo_table 
  3003. 		convo_queue.size = convo_queue.size + 1 
  3004. 	elseif (priority == M16_CONVO_PLAY_NEXT) then 
  3005. 		-- Shift the list to the right 
  3006. 		for i = convo_queue.size - 1, 0, -1 do 
  3007. 			convo_queue.list[i + 1] = convo_queue.list[i] 
  3008. 		end 
  3009. 		convo_queue.list[0] = convo_table 
  3010. 		convo_queue.size = convo_queue.size + 1 
  3011. 	elseif (priority == M16_CONVO_PLAY_IMMEDIATE) then 
  3012. 		-- Stop any actively playing conversations, and start this one immediatly 
  3013. 		m16_helper_conversation_cleanup_playing() 
  3014. 		convo_queue.playing.thread_id = thread_new("m16_thread_play_convo", convo_table) 
  3015. 	end 
  3016. end 
  3017.  
  3018. -- Kill any active conversation, and clear out the conversation queue (Originally written by Matt Gawalek for Mission 02) 
  3019. function m16_helper_conversation_kill_all() 
  3020. 	-- Stop any active conversation 
  3021. 	m16_helper_conversation_cleanup_playing() 
  3022. 	 
  3023. 	-- Clear out the queue 
  3024. 	for i = 0, convo_queue.size - 1 do 
  3025. 		convo_queue.list[i].ended = true 
  3026. 	end 
  3027. 	convo_queue.size = 0 
  3028. end 
  3029.  
  3030. -- Cleanup any playing conversation (Originally written by Matt Gawalek for Mission 02) 
  3031. function m16_helper_conversation_cleanup_playing() 
  3032. 	-- Stop the thread processing a playing conversation 
  3033. 	if (convo_queue.playing.thread_id ~= -1) then 
  3034. 		thread_kill(convo_queue.playing.thread_id) 
  3035. 		convo_queue.playing.thread_id = -1 
  3036. 	end 
  3037. 	-- Cleanup and conversation data for a playing conversation 
  3038. 	if (convo_queue.playing.conv_handle ~= INVALID_CONVERSATION_HANDLE) then 
  3039. 		audio_conversation_end(convo_queue.playing.conv_handle) 
  3040. 		convo_queue.playing.conv_handle = INVALID_CONVERSATION_HANDLE 
  3041. 	end 
  3042. 	-- Mark the playing conversation as ended 
  3043. 	if (convo_queue.playing.convo_table ~= nil) then 
  3044. 		convo_queue.playing.convo_table.ended = true 
  3045. 	end 
  3046. end 
  3047.  
  3048. -- Thread to process playing a single converation (Originally written by Matt Gawalek for Mission 02) 
  3049. function m16_thread_play_convo(convo_table) 
  3050. 	-- Add this conversatin to the playing conversation data 
  3051. 	convo_queue.playing.convo_table = convo_table 
  3052. 	convo_table.started = true	-- it has now started 
  3053. 	 
  3054. 	-- Load the conversation data 
  3055. 	if (convo_table.load_direct == false) then 
  3056. 		convo_queue.playing.conv_handle = audio_conversation_load(convo_table.name) 
  3057. 	else 
  3058. 		convo_queue.playing.conv_handle = audio_conversation_load_direct(convo_table.name) 
  3059. 	end 
  3060. 	 
  3061. 	-- Delay the desired amount 
  3062. 	delay(convo_table.delay) 
  3063. 	 
  3064. 	-- Play the conversation and wait for it to end 
  3065. 	audio_conversation_play(convo_queue.playing.conv_handle) 
  3066. 	audio_conversation_wait_for_end(convo_queue.playing.conv_handle) 
  3067. 	audio_conversation_end(convo_queue.playing.conv_handle) 
  3068. 	 
  3069. 	-- Do some book-keeping 
  3070. 	convo_queue.playing.conv_handle = INVALID_CONVERSATION_HANDLE 
  3071. 	convo_table.completed = true 
  3072. 	convo_table.ended = true 
  3073. end 
  3074.  
  3075. -- Given a persona and line, plays and blocks until completion 
  3076. -- 
  3077. -- persona_id:		(int)	id of the persona speaking 
  3078. -- line:				(string)	name of the line 
  3079. function m16_helper_play_dialog_line(persona_id, line) 
  3080. 	dialog_line_audio_id = audio_play_persona_line_2d(persona_id, line) 
  3081. 	while(audio_is_playing(dialog_line_audio_id) == true) do 
  3082. 		thread_yield() 
  3083. 	end 
  3084. 	dialog_line_audio_id = -1 
  3085. end 
  3086.  
  3087. -- Stops any currently playing dialog line 
  3088. function m16_helper_stop_dialog_line() 
  3089. 	if dialog_line_audio_id ~= -1 then 
  3090. 		audio_stop(dialog_line_audio_id) 
  3091. 	end 
  3092. end 
  3093.  
  3094. -- ************************* 
  3095. -- 
  3096. -- Callback functions 
  3097. -- 
  3098. -- ************************* 
  3099.  
  3100. function m16_clear_callbacks(npc) 
  3101. 	on_death("", npc) 
  3102. end 
  3103.  
  3104. -- Callback for on_human_death that plays the despawn effect on any human killed during the mission that is not 
  3105. -- the player or in a vehicle 
  3106. -- 
  3107. -- npc_team:		(string) team this npc belongs to 
  3108. -- killer_name:	(string) name of the person who killed this human 
  3109. -- npc_name:		(string) name of the npc that died 
  3110. -- 
  3111. function m16_cyberdecker_died_cb(npc_team, killer_name, npc_name) 
  3112. 	if npc_name ~= LOCAL_PLAYER and npc_name ~= REMOTE_PLAYER and npc_name ~= nil then 
  3113. 		if (not character_is_in_vehicle(npc_name) and character_exists(npc_name) and not character_hidden(npc_name)) then 
  3114. 			effect_play_on_human(m16_vfx_despawn, npc_name) 
  3115. 			delay(0.5) 
  3116. 			character_hide(npc_name) 
  3117. 		end 
  3118. 	end 
  3119. end 
  3120.  
  3121. -- On_trigger callback used to spawn in cyberdeckers in the areas before the gates 
  3122. -- 
  3123. -- 
  3124. -- triggerer:		(string) name of the player who entered 
  3125. -- trigger:			(string) name of the trigger that was hit 
  3126. function m16_cb_spawn_surprise_group(triggerer, trigger) 
  3127. 	on_trigger("", trigger) 
  3128. 	trigger_enable(trigger, DISABLE) 
  3129. 	 
  3130. 	-- Find which surprise group to spawn 
  3131. 	local trigger_group 
  3132. 	for i, surprise_trigger in pairs(M16_surprise_triggers) do 
  3133. 		if trigger == surprise_trigger.name then 
  3134. 			trigger_group = surprise_trigger.script_group 
  3135. 			break 
  3136. 		end 
  3137. 	end 
  3138. 	 
  3139. 	m16_spawn_cyberdecker_group(trigger_group) 
  3140. end 
  3141.  
  3142. -- On_trigger callback used to spawn in cyberdeckers during the firewall sequence 
  3143. -- 
  3144. -- 
  3145. -- triggerer:		(string) name of the player who entered 
  3146. -- trigger:			(string) name of the trigger that was hit 
  3147. function m16_cb_spawn_firewall_group(triggerer, trigger) 
  3148. 	on_trigger("", trigger) 
  3149. 	trigger_enable(trigger, DISABLE) 
  3150. 	 
  3151. 	-- Find which surprise group to spawn 
  3152. 	local firewall_group 
  3153. 	for i, firewall_trigger in pairs(M16_firewall_trigger_groups) do 
  3154. 		if trigger == firewall_trigger.name then 
  3155. 			firewall_group = firewall_trigger.script_group 
  3156. 			break 
  3157. 		end 
  3158. 	end 
  3159. 	 
  3160. 	m16_spawn_cyberdecker_group(firewall_group) 
  3161. end 
  3162.  
  3163. -- On_trigger callback for the death trigger 
  3164. -- 
  3165. -- triggerer:		(string) name of the player who entered 
  3166. -- trigger:			(string) name of the trigger that was hit 
  3167. function m16_death_trigger(triggerer, trigger) 
  3168. 	character_kill(triggerer) 
  3169. end 
  3170.  
  3171. -- On_trigger callback used when the player enters the firewall area 
  3172. -- 
  3173. -- triggerer:		(string) name of the player who entered 
  3174. -- trigger:			(string) name of the trigger that was hit 
  3175. function m16_cb_firewall_area_reached(triggerer, trigger) 
  3176. 	on_trigger("", trigger) 
  3177. 	trigger_enable(trigger, false) 
  3178. 	marker_remove(trigger) 
  3179. 	 
  3180. 	gate_reached = true 
  3181. end 
  3182.  
  3183. -- On_trigger callback used when the player reaches the firewall, and completes the objective 
  3184. -- 
  3185. -- triggerer:		(string) name of the player who entered 
  3186. -- trigger:			(string) name of the trigger that was hit 
  3187. function m16_cb_firewall_reached(triggerer, trigger) 
  3188. 	on_trigger("", trigger) 
  3189. 	trigger_enable(trigger, false) 
  3190. 	marker_remove(trigger) 
  3191. 	 
  3192. 	gate_destroyed = true 
  3193. end 
  3194.  
  3195. -- On_trigger callbacked used when a player reaches the antivirus 
  3196. function m16_cb_antivirus_reached(triggerer, trigger) 
  3197. 	on_trigger("", trigger) 
  3198. 	trigger_enable(trigger, false) 
  3199. 	marker_remove(trigger) 
  3200. 	 
  3201. 	gate_reached = true 
  3202. end 
  3203.  
  3204. function m16_cb_internet_security_reached(triggerer, trigger) 
  3205. 	on_trigger("", trigger) 
  3206. 	trigger_enable(trigger, false) 
  3207. 	marker_remove(trigger) 
  3208. 	 
  3209. 	gate_reached = true 
  3210. end 
  3211.  
  3212. function m16_final_cb(triggerer, trigger) 
  3213. 	on_trigger("", trigger) 
  3214. 	trigger_enable(trigger, false) 
  3215. 	marker_remove(trigger) 
  3216. 	gate_destroyed = true 
  3217. end 
  3218.  
  3219. function m16_player_tank_destroyed_cb(vehicle) 
  3220.  
  3221. 	if not in_coop then 
  3222. 		m16_music_switch("") 
  3223. 		audio_object_post_event( "Tank_Battle_Music_Loss" ) 
  3224. 		delay(4) 
  3225. 		turn_vulnerable(LOCAL_PLAYER) 
  3226. 		mission_end_failure("m16", "m16_failure_tank_destroyed") 
  3227. 	else 
  3228. 		if vehicle == M16_vehicles.tank_combat_player_tank_one then 
  3229. 			if vehicle_is_destroyed(M16_vehicles.tank_combat_player_tank_two) then 
  3230. 				-- if the other tank has been destroyed 
  3231. 				m16_music_switch("") 
  3232. 				audio_object_post_event( "Tank_Battle_Music_Loss" ) 
  3233. 				turn_vulnerable(LOCAL_PLAYER) 
  3234. 				turn_vulnerable(REMOTE_PLAYER) 
  3235. 				mission_end_failure("m16", "m16_failure_tank_destroyed") 
  3236. 			else 
  3237. 				character_hide(LOCAL_PLAYER) 
  3238. 				player_controls_disable(LOCAL_PLAYER) 
  3239. 				effect_play_on_script_object(m16_vfx_avatar_spawn, M16_vehicles.tank_combat_player_tank_two) 
  3240. 				delay(2) 
  3241. 				group_destroy(M16_groups.tank_combat_player_one.name) 
  3242. 			end 
  3243. 		else 
  3244. 			if vehicle_is_destroyed(M16_vehicles.tank_combat_player_tank_one) then 
  3245. 				-- if the other tank has been destroyed 
  3246. 				m16_music_switch("") 
  3247. 				audio_object_post_event( "Tank_Battle_Music_Loss" ) 
  3248. 				turn_vulnerable(LOCAL_PLAYER) 
  3249. 				turn_vulnerable(REMOTE_PLAYER) 
  3250. 				mission_end_failure("m16", "m16_failure_tank_destroyed") 
  3251. 			else 
  3252. 				character_hide(REMOTE_PLAYER) 
  3253. 				player_controls_disable(REMOTE_PLAYER) 
  3254. 				effect_play_on_script_object(m16_vfx_avatar_spawn, M16_vehicles.tank_combat_player_tank_one) 
  3255. 				delay(2) 
  3256. 				group_destroy(M16_groups.tank_combat_player_two.name) 
  3257. 			end 
  3258. 		end 
  3259. 	end 
  3260. 	audio_object_post_event( "Tank_Battle_Explode" ) 
  3261. 	on_vehicle_destroyed("", vehicle) 
  3262. end 
  3263.  
  3264. -- Kill the driver when the first tank is destroyed 
  3265. function m16_tank_one_destroyed_cb() 
  3266. 	-- The npc driver will pop out of the tank, turn off his AI so he won't attack the player 
  3267. 	character_hide(M16_characters.tank_combat_tank_npc_one) -- hide the npc 
  3268. 	set_ignore_ai_flag(M16_characters.tank_combat_tank_npc_one, ENABLE) 
  3269. 	turn_vulnerable(M16_characters.tank_combat_tank_npc_one, true) 
  3270. 	character_kill(M16_characters.tank_combat_tank_npc_one) 
  3271. 	on_vehicle_destroyed("", M16_vehicles.tank_combat_npc_tank_one) 
  3272. 	audio_object_post_event( "Tank_Battle_Explode" ) 
  3273. 	effect_play_on_script_object(m16_vfx_avatar_spawn, M16_vehicles.tank_combat_npc_tank_one) 
  3274. 	delay(2) 
  3275. 	group_destroy(M16_groups.tank_combat_npc_one.name) 
  3276. end 
  3277.  
  3278. -- Kill the driver when the second tank is destroyed 
  3279. function m16_tank_two_destroyed_cb() 
  3280. 	-- The npc driver will pop out of the tank, turn off his AI so he won't attack the player 
  3281. 	character_hide(M16_characters.tank_combat_tank_npc_two) -- hide the npc 
  3282. 	set_ignore_ai_flag(M16_characters.tank_combat_tank_npc_two, ENABLE) 
  3283. 	turn_vulnerable(M16_characters.tank_combat_tank_npc_two, true) 
  3284. 	character_kill(M16_characters.tank_combat_tank_npc_two) 
  3285. 	on_vehicle_destroyed("", M16_vehicles.tank_combat_npc_tank_two) 
  3286. 	audio_object_post_event( "Tank_Battle_Explode" ) 
  3287. 	effect_play_on_script_object(m16_vfx_avatar_spawn, M16_vehicles.tank_combat_npc_tank_two) 
  3288. 	delay(2) 
  3289. 	group_destroy(M16_groups.tank_combat_npc_two.name) 
  3290. end 
  3291.  
  3292. function m16_cathedral_walk_wall_fade(triggerer, trigger_name) 
  3293. 	on_trigger("", trigger_name) 
  3294. 	trigger_enable(trigger_name, false) 
  3295. 	 
  3296. 	for i, trigger in pairs(M16_triggers.cathedral_wall) do 
  3297. 		if trigger_name == trigger then 
  3298. 			-- we found which number this trigger is, get the mover and perform the effect 
  3299. 			local mover = M16_movers.triggered_final_gate_movers[i] 
  3300. 			effect_play_on_script_object(m16_vfx_forcefield_destroyed, mover) 
  3301. 			delay(1.5) 
  3302. 			mesh_mover_hide(mover) 
  3303. 			break 
  3304. 		end 
  3305. 	end	 
  3306. end 
  3307.  
  3308. -- Stats the final sequence up to and including the qte 
  3309. function m16_do_qte(play_at_nav) 
  3310. 	marker_remove(M16_characters.matt) 
  3311. 	boss_battle_matt_qte_begin(LOCAL_PLAYER, play_at_nav) 
  3312. end 
  3313.  
  3314. -- Once Matt gets to a certain health, this function hides him and beings the next phase 
  3315. function m16_prep_avatar_for_decker_battle() 
  3316. 	m16_helper_stop_dialog_line() -- stop cheat dialog 
  3317. 	boss_battle_matt_cheats_stop() -- stop cheats 
  3318. 	 
  3319. 	M16_threads.player_transform_handle = thread_new("m16_thread_boss_battle_avatar_player_transform") 
  3320. 	 
  3321. 	m16_helper_conversation_play(M16_conv.player_turned_into_avatar, M16_CONVO_PLAY_IMMEDIATE, 2.0) 
  3322.  
  3323. 	turn_invulnerable(M16_characters.matt) 
  3324. 	set_ignore_ai_flag(M16_characters.matt, ENABLE) 
  3325.  
  3326. 	 
  3327. 	-- Teleport to the summoning location 
  3328. 	action_play_non_blocking(M16_characters.matt, M16_animations.tele_start) 
  3329. 	repeat 
  3330. 		thread_yield() 
  3331. 	until action_play_is_finished(M16_characters.matt, 0.75) 
  3332. 	 
  3333. 	marker_remove(M16_characters.matt) 
  3334. 	 
  3335. 	repeat 
  3336. 		thread_yield() 
  3337. 	until action_play_is_finished(M16_characters.matt, 1.0) 
  3338.  
  3339. 	character_hide(M16_characters.matt) 
  3340. 	teleport(M16_characters.matt, M16_navpoints.matt_summon) 
  3341. 	inv_item_remove_all(M16_characters.matt) 
  3342. 	delay(1) 
  3343. 	character_show(M16_characters.matt) 
  3344. 	action_play(M16_characters.matt, M16_animations.tele_end, nil, false, 1.0) 
  3345. 	action_play(M16_characters.matt, M16_animations.matt_summon, nil, false, 1.0) 
  3346. 	action_play(M16_characters.matt, M16_animations.tele_start, nil, false, 1.0) 
  3347. 	character_hide(M16_characters.matt) 
  3348. 	 
  3349. 	threads_wait_for_completion(M16_threads.player_transform_handle) 
  3350. 	M16_threads.player_transform_handle = INVALID_THREAD_HANDLE 
  3351. end 
  3352.  
  3353. function m16_player_choice_made_cb(triggerer, trigger) 
  3354. 	-- Cleanup triggers 
  3355. 	on_trigger("", M16_triggers.choicea) 
  3356. 	trigger_enable(M16_triggers.choicea, false) 
  3357. 	 
  3358. 	on_trigger("", M16_triggers.choiceb) 
  3359. 	trigger_enable(M16_triggers.choiceb, false) 
  3360. 	 
  3361. 	if player_choice == "" then 
  3362. 		if (trigger == M16_triggers.choicea) then 
  3363. 			player_choice = "choicea" 
  3364. 		else 
  3365. 			player_choice = "choiceb" 
  3366. 		end 
  3367. 	end 
  3368. end 
  3369.  
  3370. function m16_final_qte_fade_cb() 
  3371. 	mission_start_fade_out() 
  3372. 	m16_qte_complete(true) 
  3373. 	qte_cleanup()	 
  3374. end 
  3375.  
  3376. -- ************************* 
  3377. -- 
  3378. -- Thread functions 
  3379. -- 
  3380. -- ************************* 
  3381.  
  3382. -- Simple thread that keeps a tank on a path.  Each path has a forward and backwards spline 
  3383. -- 
  3384. -- tank:		(string) name of tank 
  3385. -- path_list:	(table)	list of viable paths names for that tank 
  3386. -- 
  3387. function m16_do_tank_pathing_thread(tank, path_set) 
  3388. 	local forward_path_set = path_set[1] 
  3389. 	local backward_path_set = path_set[2] 
  3390. 	while true  do 
  3391. 		local path_index = rand_int(1, sizeof_table(forward_path_set)) 
  3392. 		 
  3393. 		local forward_path = forward_path_set[path_index] 
  3394. 		local backward_path = backward_path_set[path_index] 
  3395. 		 
  3396. 		vehicle_pathfind_to(tank, forward_path, true, false, false, false) 
  3397. 		vehicle_pathfind_to(tank, backward_path, true, false, false, false) 
  3398. 		thread_yield() 
  3399. 	end 
  3400. end 
  3401.  
  3402. -- Keeps matt's health above the appropriate amount. 
  3403. function m16_matt_health_thread(min_pct) 
  3404. 	while not character_exists(M16_characters.matt) do 
  3405. 		thread_yield() 
  3406. 	end 
  3407. 	 
  3408. 	while true do 
  3409. 		local min_hp = get_max_hit_points(M16_characters.matt) * min_pct 
  3410. 		min_hp = min_hp - 100	-- make sure it gets below the threshold so the battle will continue. 
  3411. 		local cur_hp = get_current_hit_points(M16_characters.matt) 
  3412. 		if cur_hp < min_hp then 
  3413. 			set_current_hit_points(M16_characters.matt, get_max_hit_points(M16_characters.matt) * min_pct) -- reset matt 
  3414. 			Matt_health_pct = min_pct 
  3415. 		end 
  3416. 		thread_yield() 
  3417. 	end 
  3418. end 
  3419.  
  3420. -- Teleports Matt to one of x number of navpoints within M16_navpoints.matt_teleports every TIME_BETWEEN_AIR_TELEPORTS seconds during the air phase 
  3421. function m16_matt_air_teleport_thread() 
  3422. 	local previous_teleport_navpoint_name = M16_navpoints.matt_teleports[2] -- matt is basically already at this one after liftoff 
  3423. 	while true do	 
  3424. 		set_ignore_ai_flag(M16_characters.matt, ENABLE) 
  3425. 		turn_invulnerable(M16_characters.matt) 
  3426. 		delay(0.5) 
  3427. 		 
  3428. 		local random_navpoint = get_random_table_entry(M16_navpoints.matt_teleports) 
  3429. 		 
  3430. 		-- Make sure we dont warp to the same spot 
  3431. 		while previous_teleport_navpoint_name == random_navpoint do 
  3432. 			random_navpoint = get_random_table_entry(M16_navpoints.matt_teleports) 
  3433. 			thread_yield() 
  3434. 		end 
  3435. 		 
  3436. 		previous_teleport_navpoint_name = random_navpoint	-- update the previous spot	 
  3437. 		 
  3438. 		action_play(M16_characters.matt, M16_animations.tele_start, nil, false, 1.0) 
  3439. 		 
  3440. 		teleport(M16_characters.matt, random_navpoint) 
  3441. 	 
  3442. 		action_play(M16_characters.matt, M16_animations.tele_end, nil, false, 1.0)	 
  3443. 		 
  3444. 		turn_vulnerable(M16_characters.matt) 
  3445. 		set_ignore_ai_flag(M16_characters.matt, DISABLE) 
  3446. 		ai_set_action_delay(M16_characters.matt, "avatar fireballs", 1.0) 
  3447. 		ai_add_enemy_target(M16_characters.matt, CLOSEST_PLAYER, 2) 
  3448. 		 
  3449. 		delay(TIME_BETWEEN_AIR_TELEPORTS) 
  3450. 		thread_yield() 
  3451. 	end 
  3452. end 
  3453.  
  3454. -- Teleports Matt to one of x number of navpoints within M16_navpoints.matt_teleports every TIME_BETWEEN_GROUND_TELEPORTS seconds when hes on the ground 
  3455. function m16_matt_ground_teleport_thread() 
  3456. 	delay(TIME_BETWEEN_GROUND_TELEPORTS) 
  3457. 	while true do 
  3458. 		 
  3459. 		local distance_from_local_player_to_matt = get_dist(M16_characters.matt, LOCAL_PLAYER) 
  3460. 		local distance_from_remote_player_to_matt = 0 
  3461. 		if in_coop then 
  3462. 			distance_from_remote_player_to_matt = get_dist(M16_characters.matt, REMOTE_PLAYER) 
  3463. 		end 
  3464. 		 
  3465. 		local player_is_within_teleport_range = false 
  3466. 		 
  3467. 		if distance_from_local_player_to_matt <= M16_PLAYER_DISTANCE_FOR_TELEPORT then 
  3468. 			player_is_within_teleport_range = true 
  3469. 		else 
  3470. 			if in_coop then 
  3471. 				if distance_from_remote_player_to_matt <= M16_PLAYER_DISTANCE_FOR_TELEPORT then 
  3472. 					player_is_within_teleport_range = true 
  3473. 				end			 
  3474. 			end 
  3475. 		end 
  3476. 		 
  3477. 		if player_is_within_teleport_range then 
  3478. 			local distance_to_navpoint = 0 
  3479. 			local local_dist_to_nav = 0 
  3480. 			local remote_dist_to_nav = 0 
  3481. 			local random_navpoint = "" 
  3482. 			local valid_teleport_navpoint = false 
  3483. 			 
  3484. 			-- Find a random navpoint that is atleast M16_MIN_DISTANCE_FOR_TELEPORT away from Matt and one that  
  3485. 			while not valid_teleport_navpoint do 
  3486. 				random_navpoint = get_random_table_entry(M16_navpoints.matt_teleports) 
  3487. 				distance_to_navpoint = get_dist(M16_characters.matt, random_navpoint) 
  3488. 				local local_dist_to_nav = get_dist(LOCAL_PLAYER, random_navpoint) 
  3489. 				 
  3490. 				if in_coop then 
  3491. 					remote_dist_to_nav = get_dist(REMOTE_PLAYER, random_navpoint) 
  3492. 				end 
  3493. 				 
  3494. 				if distance_to_navpoint >= M16_MIN_DISTANCE_FOR_TELEPORT then 
  3495. 					if local_dist_to_nav >= M16_MIN_DISTANCE_FOR_TELEPORT then 
  3496. 						if in_coop then 
  3497. 							if remote_dist_to_nav >= M16_MIN_DISTANCE_FOR_TELEPORT then 
  3498. 								valid_teleport_navpoint = true 
  3499. 							end 
  3500. 						else 
  3501. 							valid_teleport_navpoint = true 
  3502. 						end 
  3503. 					end 
  3504. 				end 
  3505. 				thread_yield() 
  3506. 			end 
  3507. 			 
  3508. 				 
  3509. 			set_ignore_ai_flag(M16_characters.matt, ENABLE) 
  3510. 			character_prevent_flinching(M16_characters.matt, ENABLE) 
  3511. 			turn_invulnerable(M16_characters.matt) 
  3512. 			 
  3513. 			delay(1) 
  3514. 			 
  3515. 			action_play(M16_characters.matt, M16_animations.tele_start, nil, false, 1.0) 
  3516. 			 
  3517. 			teleport(M16_characters.matt, random_navpoint) 
  3518. 		 
  3519. 			action_play(M16_characters.matt, M16_animations.tele_end, nil, false, 1.0)	 
  3520. 			 
  3521. 			turn_vulnerable(M16_characters.matt) 
  3522. 			character_prevent_flinching(M16_characters.matt, DISABLE) 
  3523. 			set_ignore_ai_flag(M16_characters.matt, DISABLE) 
  3524. 			ai_add_enemy_target(M16_characters.matt, CLOSEST_PLAYER, 2) 
  3525. 		end 
  3526. 		 
  3527. 		delay(TIME_BETWEEN_GROUND_TELEPORTS) 
  3528. 		thread_yield() 
  3529. 	end 
  3530. end 
  3531.  
  3532. -- Process the conversation queue (should be running the duration of the mission) (Originally written by Matt Gawalek for Mission 02) 
  3533. function m16_thread_process_conversations() 
  3534. 	-- Loop forever 
  3535. 	while(true) do 
  3536. 		-- Wait until something is added to the queue 
  3537. 		while(convo_queue.size == 0 or convo_queue.playing.conv_handle ~= INVALID_CONVERSATION_HANDLE) do 
  3538. 			thread_yield() 
  3539. 		end 
  3540. 		 
  3541. 		-- Play the first conversation from the queue, and then remove it from the queue 
  3542. 		-- Slone TODO: See if this works--Lua indexing starts at 1, not 0. 
  3543. 		convo_queue.playing.thread_id = thread_new("m16_thread_play_convo", convo_queue.list[0]) 
  3544. 		for i = 1, convo_queue.size do 
  3545. 			convo_queue.list[i - 1] = convo_queue.list[i] 
  3546. 		end 
  3547. 		convo_queue.size = convo_queue.size - 1 
  3548. 		 
  3549. 		-- Wait for the active conversation thread to end 
  3550. 		while(thread_check_done(convo_queue.playing.thread_id) == false) do 
  3551. 			thread_yield() 
  3552. 		end 
  3553. 	end 
  3554. end 
  3555.  
  3556. --callback function to play a sound if you fire the lame weapon 
  3557. function m16_thread_lame_weapon_cheat_cb(char, weap, attack) 
  3558. 	 
  3559. 	local cheat = boss_battle_matt_get_cheat() 
  3560. 	if (cheat == M16_CHEAT_WEAPON) then 
  3561. 		audio_object_post_event("M16_hotdog_fire") 
  3562. 	end 
  3563. 	 
  3564. end 
  3565.  
  3566. -- Thread that monitors the status of the cheats, playing audio when needed 
  3567. function m16_thread_text_adventure_audio_thread() 
  3568.  
  3569. 	local death_index = -1 
  3570. 	local audio_play_id = -1 
  3571. 	 
  3572. 	-- wait for the text adventure intro conversation to end 
  3573. 	while not m16_helper_conversation_check_done(M16_conv.text_adventure) do 
  3574. 		death_index = hud_get_text_adventure_current_screen_index() -- keep grabbing the index so that one wont play when the convo ends 
  3575. 		thread_yield() 
  3576. 	end 
  3577.  
  3578. 	while true do 
  3579. 		death_index = hud_get_text_adventure_current_screen_index() 
  3580. 		 
  3581. 		if not audio_is_playing(audio_play_id) then 
  3582. 			audio_play_id = -1	 
  3583.  
  3584. 			if death_index ~= -1 then 
  3585. 				for index, screen_line in pairs(M16_text_adventure_lines) do 
  3586. 					if death_index == screen_line[1] then 
  3587. 						local line = screen_line[2] 
  3588. 						if not line.played then 
  3589. 							delay(1) 
  3590. 							audio_play_id = audio_play_persona_line(LOCAL_PLAYER, line.name) 
  3591. 							line.played = true 
  3592. 						end 
  3593. 					end 
  3594. 				end 
  3595. 				death_index = -1 
  3596. 			end 
  3597. 		end 
  3598. 		thread_yield() 
  3599. 	end 
  3600. end 
  3601.  
  3602. -- Thread that monitors the status of the cheats, playing audio when needed 
  3603. function m16_thread_cheat_audio_thread() 
  3604. 	local cheat = M16_CHEAT_INVALID 
  3605. 	local line_played_for_current_cheat = false 
  3606.  
  3607. 	while true do 
  3608. 		cheat = boss_battle_matt_get_cheat() 
  3609.  
  3610. 		if cheat ~= M16_CHEAT_INVALID then 
  3611. 			if not line_played_for_current_cheat then 
  3612. 				debug_print( "MAD", "Boss battle cheat " .. cheat ) 
  3613. 				-- Make sure we only play one set of lines per cheat 
  3614.  
  3615. 				local cheat_index = cheat + 1 -- offset the index since tables start at 1 
  3616. 				if not M16_matt_cheat_lines_01[cheat_index].played then 
  3617. 					delay(0.5) 
  3618. 					-- play 
  3619. 					m16_helper_play_dialog_line(M16_personas.matt.persona_id, M16_matt_cheat_lines_01[cheat_index].name) 
  3620. 					M16_matt_cheat_lines_01[cheat_index].played = true 
  3621. 					 
  3622. 					delay(0.5) 
  3623. 					 
  3624. 					-- Make sure the cheat is still playing 
  3625. 					cheat = boss_battle_matt_get_cheat() 
  3626. 					 
  3627. 					if cheat ~= M16_CHEAT_INVALID then				 
  3628. 						m16_helper_play_dialog_line(M16_personas.kinzie.persona_id, M16_kinzie_cheat_lines[cheat_index].name) 
  3629. 						M16_kinzie_cheat_lines[cheat_index].played = true 
  3630. 					end 
  3631. 					 
  3632. 					line_played_for_current_cheat = true 
  3633. 				else 
  3634. 					-- try playing line 2 for this cheat 
  3635. 					if not M16_matt_cheat_lines_02[cheat_index].played then 
  3636. 						-- play 
  3637. 						m16_helper_play_dialog_line(M16_personas.matt.persona_id, M16_matt_cheat_lines_02[cheat_index].name) 
  3638. 						M16_matt_cheat_lines_02[cheat_index].played = true 
  3639. 						line_played_for_current_cheat = true 
  3640. 					else 
  3641. 						-- try playing line 3 for this cheat 
  3642. 						if not M16_matt_cheat_lines_03[cheat_index].played then 
  3643. 							-- play 
  3644. 							m16_helper_play_dialog_line(M16_personas.matt.persona_id, M16_matt_cheat_lines_03[cheat_index].name) 
  3645. 							M16_matt_cheat_lines_03[cheat_index].played = true 
  3646. 							line_played_for_current_cheat = true 
  3647. 						end 
  3648. 					end			 
  3649. 				end 
  3650. 			end 
  3651. 		else  
  3652. 			line_played_for_current_cheat = false 
  3653. 		end 
  3654. 		thread_yield() 
  3655. 	end 
  3656. end 
  3657.  
  3658. -- Thread that handles the players transformation into an avatar 
  3659. function m16_thread_boss_battle_avatar_player_transform() 
  3660. 	effect_play_on_human(m16_vfx_spawn, LOCAL_PLAYER) 
  3661. 	if in_coop then 
  3662. 		effect_play_on_human(m16_vfx_spawn, REMOTE_PLAYER) 
  3663. 	end 
  3664. 	 
  3665. 	delay(0.5) 
  3666. 	 
  3667. 	character_hide(LOCAL_PLAYER) 
  3668. 	if in_coop then 
  3669. 		character_hide(REMOTE_PLAYER) 
  3670. 	end 
  3671. 	 
  3672. 	customization_item_revert() 
  3673. 	delay(1) 
  3674. 	 
  3675. 	boss_battle_matt_set_player_as_avatar(ENABLE) 
  3676. 	inv_add_temp_loadout(AVATAR_LOADOUT) 
  3677. 	 
  3678. 	M16_threads.local_avatar_transform_handle = thread_new("m16_thread_boss_battle_avatar_individual_transform", LOCAL_PLAYER) 
  3679. 	if in_coop then 
  3680. 		M16_threads.remote_avatar_transform_handle = thread_new("m16_thread_boss_battle_avatar_individual_transform", REMOTE_PLAYER) 
  3681. 	end 
  3682. 	 
  3683. 	threads_wait_for_completion(M16_threads.local_avatar_transform_handle) 
  3684. 	threads_wait_for_completion(M16_threads.remote_avatar_transform_handle) 
  3685. 	 
  3686. 	M16_threads.local_avatar_transform_handle = INVALID_THREAD_HANDLE 
  3687. 	M16_threads.remote_avatar_transform_handle = INVALID_THREAD_HANDLE 
  3688. 	 
  3689. 	tutorial_start("mis_16_avatar_attacks", 0, true, false) --SP 7/14: Added tutorial, feel free to move it if it's in a bad place 
  3690. end 
  3691.  
  3692. function m16_thread_boss_battle_avatar_individual_transform(player) 
  3693. 	player_controls_disable(player) 
  3694. 	effect_play_on_human(m16_vfx_avatar_spawn, player) 
  3695. 	delay(0.5) 
  3696. 	character_show(player) 
  3697. 	action_play(player, M16_animations.matt_taunt_a, nil, false, 1.0) 
  3698. 	player_controls_enable(player) 
  3699. end 
  3700.  
  3701. -- Thread that will handle the spawning during the boss battle's 4th phase 
  3702. function m16_thread_boss_battle_decker_spawn() 
  3703. 	while true do 
  3704. 		local number_spawn_attempts = 0 
  3705. 	 
  3706. 	 
  3707. 		while number_spawn_attempts < 6 do 
  3708. 			local random_decker_group = get_random_table_entry(M16_wave_groups) 
  3709. 			if group_is_loaded(random_decker_group) then 
  3710. 				-- group already exists, try again 
  3711. 				number_spawn_attempts = number_spawn_attempts + 1 
  3712. 			else 
  3713. 				-- group doesn't already exist, spawn it 
  3714. 				m16_spawn_cyberdecker_group(random_decker_group) 
  3715. 					number_spawn_attempts = 6 
  3716. 			end 
  3717. 		end	 
  3718. 	 
  3719. 		-- Go through and clean up any killed groups 
  3720. 		for i, decker_group in pairs(M16_wave_groups) do 
  3721. 			if group_is_loaded(decker_group) then 
  3722. 				local group_dead = true -- assume the group has been killed 
  3723. 				for member_number, member in pairs(decker_group.members) do 
  3724. 					if character_exists(member) and not character_is_dead(member) then 
  3725. 						group_dead = false 
  3726. 						break 
  3727. 					end 
  3728. 				end 
  3729. 				 
  3730. 				if group_dead then 
  3731. 					delay(1) 
  3732. 					group_destroy(decker_group) 
  3733. 				end 
  3734. 			end 
  3735. 		end 
  3736. 	 
  3737. 		thread_yield() 
  3738. 		delay(DECKER_SPAWN_RATE)	 
  3739. 	end 
  3740. end 
  3741.