./m11.lua

  1. --[[ 
  2. 	m11.lua 
  3. 	SR3 Mission Script 
  4. 	DATE: 8/9/2010 
  5. 	AUTHOR:	Albert McDaniel & Darryl Davis 
  6. ]]-- 
  7.  
  8. -- Debug flags -- 
  9.  
  10. -- Tweakable Parameters -- 
  11.  
  12. -- Groups -- 
  13.  
  14. 	M11_groups = { 
  15. 		vehicle_start = { 
  16. 			name = "grp_veh_start", 
  17. 			vehicles = { "veh_start" } 
  18. 		}, 
  19. 		vehicle_cp = { 
  20. 			name = "grp_veh_cp", 
  21. 			vehicles = { "veh_cp_vtol 001", "veh_cp_vtol 002" }, 
  22. 		}, 
  23.  
  24. 		stag_bases = { 
  25. 			-- Base 1 (the hijacking objective) 
  26. 			{ 	 
  27. 				name = "sb 001", 
  28. 				npcs = {  
  29. 					"n_sb1_grunt 001", "n_sb1_grunt 002", "n_sb1_grunt 003", "n_sb1_grunt 004",   
  30. 					"n_sb1_grunt 006", "n_sb1_grunt 008", "n_sb1_grunt 009", "n_sb1_grunt 010",   
  31. 					"n_sb1_grunt 011", "n_sb1_grunt 014", "n_sb1_grunt 015", "n_sb1_grunt 016",   
  32. 					"n_sb1_grunt 017", "n_sb1_grunt 018", "n_sb1_grunt 019", "n_sb1_grunt 020",   
  33. 					"n_sb1_grunt 021", "n_sb1_grunt 022", "n_sb1_grunt 023",  
  34. 				}, 
  35. 				boxes = { 
  36. 					{ name = "mov_sb1_battlebox 001", destroyed = false }, 
  37. 					{ name = "mov_sb1_battlebox 002", destroyed = false }, 
  38. 					{ name = "mov_sb1_battlebox 003", destroyed = false }, 
  39. 					{ name = "mov_sb1_battlebox 004", destroyed = false }, 
  40. 					{ name = "mov_sb1_battlebox 005", destroyed = false }, 
  41. 					{ name = "mov_sb1_battlebox 006", destroyed = false }, 
  42. 				}, 
  43. 				 
  44. 				vehicle_group = "sb 001 vehicles", 
  45. 				vehicles_created = false, 
  46.  
  47. 				vtols = { 
  48. 					name = "sb 001 vtols", 
  49. 					save = false, 
  50. 					vehicles = { "v_sb1_vtol 001", "v_sb1_vtol 002" }, 
  51. 				}, 
  52.  
  53. 				nav = "nav_sb1", 
  54. 				location = "t_sb1_location", 
  55. 				zone =  "t_sb1_zone", 
  56. 				restricted = "t_sb1_restricted", 
  57. 				destroyed = false, 
  58. 			}, 
  59.  
  60. 			-- Base 2 
  61. 			{ 
  62. 				name = "sb 002", 
  63. 				npcs = { 
  64. 					"n_sb2_grunt 001", "n_sb2_grunt 002", "n_sb2_grunt 003", "n_sb2_grunt 004",  
  65. 					"n_sb2_grunt 005", "n_sb2_grunt 006", "n_sb2_grunt 007", "n_sb2_grunt 008", 
  66. 					"n_sb2_grunt 009", "n_sb2_grunt 010", "n_sb2_grunt 011", "n_sb2_grunt 012", 
  67. 					"n_sb2_grunt 013", "n_sb2_grunt 014", "n_sb2_grunt 015", 
  68. 				}, 
  69. 				boxes = { 
  70. 					{ name = "mov_sb2_battlebox 001", destroyed = false }, 
  71. 					{ name = "mov_sb2_battlebox 002", destroyed = false }, 
  72. 					{ name = "mov_sb2_battlebox 003", destroyed = false }, 
  73. 					{ name = "mov_sb2_battlebox 004", destroyed = false }, 
  74. 					{ name = "mov_sb2_battlebox 005", destroyed = false }, 
  75. 					{ name = "mov_sb2_battlebox 006", destroyed = false }, 
  76. 				}, 
  77. 				 
  78. 				vehicle_group = "sb 002 vehicles", 
  79. 				vehicles_created = false, 
  80.  
  81. 				vtols = { 
  82. 					name = "sb 002 vtols", 
  83. 					save = false, 
  84. 					vehicles = { "v_sb2_vtol 001", "v_sb2_vtol 002" }, 
  85. 				}, 
  86.  
  87. 				script = { 
  88. 					name = "sb 002 script", 
  89. 					trigger = "t_sb2_script", 
  90. 					vehicles = { 
  91. 						{ name = "v_sb2_vtol 003", pilot = "n_sb2_pilot<001>", nav = "nav_sb2_lift<001>" }, 
  92. 						{ name = "v_sb2_vtol 004", pilot = "n_sb2_pilot<002>", nav = "nav_sb2_lift<002>" }, 
  93. 						{ name = "v_sb2_vtol 005", pilot = "n_sb2_pilot<003>", nav = { "nav_sb2_land<001>", "nav_sb2_land<002>" }, }, 
  94. 					}, 
  95. 				}, 
  96.  
  97. 				nav = "nav_sb2", 
  98. 				location = "t_sb2_location", 
  99. 				zone =  "t_sb2_zone", 
  100. 				destroyed = false, 
  101. 			}, 
  102.  
  103. 			-- Base 3 
  104. 			{ 
  105. 				name = "sb 003", 
  106. 				npcs = { 
  107. 					"n_sb3_grunt 001", "n_sb3_grunt 002", "n_sb3_grunt 003", "n_sb3_grunt 004", 
  108. 					"n_sb3_grunt 005", "n_sb3_grunt 006", "n_sb3_grunt 007", "n_sb3_grunt 008",  
  109. 					"n_sb3_grunt 009", "n_sb3_grunt 010", "n_sb3_grunt 011",  
  110. 				}, 
  111. 				boxes = { 
  112. 					{ name = "mov_sb3_battlebox 001", destroyed = false }, 
  113. 					{ name = "mov_sb3_battlebox 002", destroyed = false }, 
  114. 					{ name = "mov_sb3_battlebox 003", destroyed = false }, 
  115. 					{ name = "mov_sb3_battlebox 004", destroyed = false }, 
  116. 					{ name = "mov_sb3_battlebox 005", destroyed = false }, 
  117. 					{ name = "mov_sb3_battlebox 006", destroyed = false }, 
  118. 				}, 
  119. 				 
  120. 				vehicle_group = "sb 003 vehicles", 
  121. 				vehicles_created = false, 
  122.  
  123. 				vtols = { 
  124. 					name = "sb 003 vtols", 
  125. 					save = false, 
  126. 					vehicles = { "v_sb3_vtol 001"}, 
  127. 				}, 
  128.  
  129. 				nav = "nav_sb3", 
  130. 				location = "t_sb3_location", 
  131. 				zone =  "t_sb3_zone", 
  132. 				destroyed = false, 
  133. 			}, 
  134.  
  135. 			-- Base 5 
  136. 			{ 
  137. 				name = "sb 005", 
  138. 				npcs = { 
  139. 					"n_sb5_grunt 001", "n_sb5_grunt 002", "n_sb5_grunt 003", "n_sb5_grunt 004", "n_sb5_grunt 005", 
  140. 					"n_sb5_grunt 006", "n_sb5_grunt 007", "n_sb5_grunt 008", "n_sb5_grunt 009", 
  141. 					"n_sb5_sniper 001",	"n_sb5_sniper 002", "n_sb5_sniper 003", "n_sb5_sniper 004" 
  142. 				}, 
  143. 				boxes = { 
  144. 					{ name = "mov_sb5_battlebox 001", destroyed = false }, 
  145. 					{ name = "mov_sb5_battlebox 002", destroyed = false }, 
  146. 					{ name = "mov_sb5_battlebox 003", destroyed = false }, 
  147. 					{ name = "mov_sb5_battlebox 004", destroyed = false }, 
  148. 				}, 
  149.  
  150. 				vtols = { 
  151. 					name = "sb 005 vtols", 
  152. 					save = false, 
  153. 					vehicles = { "v_sb5_vtol 001", "v_sb5_vtol 002" }, 
  154. 				}, 
  155.  
  156. 				nav = "nav_sb5", 
  157. 				location = "t_sb5_location", 
  158. 				zone =  "t_sb5_zone", 
  159. 				destroyed = false, 
  160. 			}, 
  161. 		}, 
  162.  
  163. 		roadblocks = { 
  164. 			{ 
  165. 				name = "rb 001", 
  166. 				npcs = {  
  167. 					"n_rb1_stag 001", "n_rb1_stag 002", "n_rb1_stag 003", "n_rb1_stag 004", "n_rb1_stag 005", "n_rb1_stag 006", 
  168. 					"n_rb1_stag 007", "n_rb1_stag 008", "n_rb1_stag 009", "n_rb1_stag 010", "n_rb1_stag 011", "n_rb1_stag 012",  
  169. 					"n_rb1_stag 013", "n_rb1_stag 014" 
  170. 				}, 
  171. 				vehicles = { 
  172. 					"v_rb1_apc 001", "v_rb1_apc 002", "v_rb1_apc 003", "v_rb1_apc 004", "v_rb1_apc 005", "v_rb1_apc 006", 
  173. 					"v_rb1_tank 001", "v_rb1_tank 002", "v_rb1_tank 003", "v_rb1_tank 004" 
  174. 				}, 
  175. 				tanks = { 
  176. 					{ name = "v_rb1_tank 001", driver = "n_rb1_stag 001" }, 
  177. 					{ name = "v_rb1_tank 002", driver = "n_rb1_stag 002" }, 
  178. 					{ name = "v_rb1_tank 003", driver = "n_rb1_stag 013" }, 
  179. 					{ name = "v_rb1_tank 004", driver = "n_rb1_stag 012" }, 
  180. 					 
  181. 					 
  182. 				},				 
  183. 				convoy = { 
  184. 					pierce = "n_rb1_pierce", 
  185. 					-- convoy vehicles, followed by an array of who goes in that vehicle 
  186. 					vehicles = { 
  187. 						{ name = "v_rb1_convoy 001", passengers = { "n_rb1_pierce" }, }, 
  188. 						{ name = "v_rb1_convoy 002", passengers = { "n_rb1_saint 001" }, }, 
  189. 						{ name = "v_rb1_truck 001",  passengers = { "n_rb1_saint 002" }, }, 
  190. 						{ name = "v_rb1_truck 002",  passengers = { "n_rb1_saint 003" }, }, 
  191. 					}, 
  192. 				}, 
  193.  
  194. 				location = "t_rb1_location", 
  195. 				destroyed = false, 
  196. 			}, 
  197. 		}, 
  198.  
  199. 		air_base = { 
  200. 			name = "grp_sba", 
  201. 			npcs = { "n_sba 001", "n_sba 002", "n_sba 003",  
  202. 					--"n_sba 004", "n_sba 005", "n_sba 006", 
  203. 						"n_sba 007", "n_sba 008", "n_sba 009",  
  204. 						--"n_sba 010", "n_sba 011" 
  205. 			}, 
  206. 			vehicles = { --"v_sba 001",  
  207. 						"v_sba 002", "v_sba 003",  
  208. 						--"v_sba 004", "v_sba 005", "v_sba 006", 
  209. 						"v_sba_target 002", "v_sba_target 003", 
  210. 						--"v_sba_target 004", "v_sba_target 005" 
  211. 			}, 
  212. 			guards = { 
  213. 				--{ vehicle = "v_sba 001", pilot = "n_sba 001", path = "p_sba 001" }, 
  214. 				{ vehicle = "v_sba 002", pilot = "n_sba 002", path = "p_sba 004" }, 
  215. 				{ vehicle = "v_sba 003", pilot = "n_sba 003", path = "p_sba 005" }, 
  216. 				--[[ 
  217. 				{ vehicle = "v_sba 004", pilot = "n_sba 004", path = "p_sba 004" }, 
  218. 				{ vehicle = "v_sba 005", pilot = "n_sba 005", path = "p_sba 005" }, 
  219. 				{ vehicle = "v_sba 006", pilot = "n_sba 006", path = "p_sba 001" }, 
  220. 				--]] 
  221. 			}, 
  222. 			targets = { 
  223. 				{ vehicle = "v_sba_target 002", pilot = "n_sba 008", path = "p_sba 002" }, 
  224. 				{ vehicle = "v_sba_target 003", pilot = "n_sba 009", path = "p_sba 003" }, 
  225. 				--[[ 
  226. 				{ vehicle = "v_sba_target 004", pilot = "n_sba 010", path = "p_sba 002" }, 
  227. 				{ vehicle = "v_sba_target 005", pilot = "n_sba 011", path = "p_sba 003" }, 
  228. 				--]] 
  229. 			}, 
  230. 			final_plane = { vehicle = "v_sba_target 001", pilot = "n_sba 007", path = "p_sba 001" }, 
  231. 		}, 
  232. 		 
  233. 		air_base_jumbo_plane = { 
  234. 			name = "grp_sba_jumbo_plane", 
  235. 			vehicles = { "v_sba_target 001" }, 
  236. 		}, 
  237.  
  238. 		oleg_battle = { 
  239. 			location = "t_oleg_battle", 
  240. 			nav = { "nav_ob_stag_n 001", "nav_ob_stag_n 002" }, 
  241. 			nav_vtol = { "nav_ob_stag_v 001", "nav_ob_stag_v 002" }, 
  242. 			dest = { "nav_ob_stag_n_dest 001", "nav_ob_stag_n_dest 002",  }, 
  243.  
  244. 			oleg = { 
  245. 				name = "grp_oleg", 
  246. 				oleg = "n_oleg", 
  247. 			}, 
  248.  
  249. 			oleg_vtols = { 
  250. 				name = "grp_oleg_vtols", 
  251. 				save = false, 
  252. 				vtols = { "veh_oleg_vtol<001>", "veh_oleg_vtol<002>" }, 
  253. 			}, 
  254. 			 
  255. 			tank1 = { 
  256. 				name = "oleg tanks", 
  257. 				vehicle = "v_ob_tank 002", 
  258. 				members = { "n_ob_stag_t 001"}, 
  259. 				dest = "nav_tank_spline 001", 
  260. 				move_thread = INVALID_THREAD_HANDLE, 
  261. 				 
  262. 			}, 
  263. 			 
  264. 			tank2 = { 
  265. 				name = "oleg tanks2", 
  266. 				vehicle = "v_ob_tank 003", 
  267. 				members = { "n_ob_stag_t 002"}, 
  268. 				dest = "nav_tank_spline 002", 
  269. 				move_thread = INVALID_THREAD_HANDLE, 
  270. 				 
  271. 			}, 
  272. 			 
  273. 			tank3 = { 
  274. 				name = "oleg tanks3", 
  275. 				vehicle = "v_ob_tank 004", 
  276. 				members = { "n_ob_stag_t 003"}, 
  277. 				dest = "nav_tank_spline 003", 
  278. 				move_thread = INVALID_THREAD_HANDLE, 
  279. 				 
  280. 			}, 
  281.  
  282. 			waves = { 
  283. 				{ 
  284. 					name = "oleg_battle 001", 
  285. 					vehicles = { 
  286. 						{ name = "v_ob_apc 001" }, 
  287. 						{ name = "v_ob_apc 002" }, 
  288. 						{ name = "v_ob_apc 003" }, 
  289. 					 
  290. 					}, 
  291. 					npcs = { 
  292. 						"n_ob_stag 001", "n_ob_stag 002", "n_ob_stag 003", "n_ob_stag 005", "n_ob_stag 006", "n_ob_stag 007", "n_ob_stag 008",  
  293. 						 
  294. 					}, 
  295. 				 --	tanks = { 
  296. 				 	--	{ name = "v_ob_tank 002", driver = "n_ob_stag_t 001", dest = "nav_dest_tank 001" }, 
  297. 					--	{ name = "v_ob_tank 003", driver = "n_ob_stag_t 002", dest = "nav_dest_tank 002" }, 
  298. 					--	{ name = "v_ob_tank 004", driver = "n_ob_stag_t 003", dest = "nav_dest_tank 003" }, 
  299. 				 --	}, 
  300. 				},	 
  301. 			 
  302. 				{ 
  303. 					name = "oleg_battle 002", 
  304. 					vehicles = { 
  305. 						{ name = "v_ob_apc 004", members = { "n_ob_stag 013", "n_ob_stag 014", "n_ob_stag 015", "n_ob_stag 016", } }, 
  306. 						{ name = "v_ob_apc 005", members = { "n_ob_stag 017", "n_ob_stag 018", "n_ob_stag 019", "n_ob_stag 020", } }, 
  307. 					}, 
  308. 				}, 
  309. 				 
  310. 				{ 
  311. 					name = "oleg_battle_vtols 002", 
  312. 					vehicles = { 
  313. 						{ name = "v_ob_vtol 001", driver = "n_ob_vpilot 001" }, 
  314. 						{ name = "v_ob_vtol 002", driver = "n_ob_vpilot 002" }, 
  315. 					}, 
  316. 				}, 
  317. 			 
  318. 				--{ 
  319. 				 	--name = "oleg_battle 003", 
  320. 				 	--vehicles = { 
  321. 				 	--	{ name = "v_ob_tank 002", driver = "n_ob_stag_t 001", gunner = "n_ob_stag_t 002" }, 
  322. 				 	--}, 
  323. 				--}, 
  324. 			}, 
  325. 		}, 
  326. 	} 
  327. 	 
  328. 	 
  329. oleg_tanks = { M11_groups.oleg_battle.tank1, M11_groups.oleg_battle.tank2, M11_groups.oleg_battle.tank3 } 
  330.  
  331. 	 
  332. -- Navpoints -- 
  333. 	M11_navpoints = { 
  334. 		start_local = "nav_start_local", 
  335. 		start_remote = "nav_start_remote", 
  336. 		end_local = "nav_end_local", 
  337. 		end_remote = "nav_end_remote", 
  338. 	} 
  339.  
  340. -- Threads -- 
  341. 	M11_threads = { 
  342. 		stag_attention = nil, 
  343. 		pilots = { 
  344. 			[1] = INVALID_THREAD_HANDLE, 
  345. 			[2] = INVALID_THREAD_HANDLE, 
  346. 			[3] = INVALID_THREAD_HANDLE, 
  347. 		}, 
  348. 		battle = { 
  349. 			[1] = INVALID_THREAD_HANDLE, 
  350. 			[2] = INVALID_THREAD_HANDLE, 
  351. 			[3] = INVALID_THREAD_HANDLE, 
  352. 			[4] = INVALID_THREAD_HANDLE, 
  353. 			[5] = INVALID_THREAD_HANDLE, 
  354. 		}, 
  355. 		fly_guard = { 
  356. 			[1] = INVALID_THREAD_HANDLE, 
  357. 			[2] = INVALID_THREAD_HANDLE, 
  358. 			[3] = INVALID_THREAD_HANDLE, 
  359. 			[4] = INVALID_THREAD_HANDLE, 
  360. 			[5] = INVALID_THREAD_HANDLE, 
  361. 			[6] = INVALID_THREAD_HANDLE, 
  362. 		}, 
  363. 		fly_target = { 
  364. 			[1] = INVALID_THREAD_HANDLE, 
  365. 			[2] = INVALID_THREAD_HANDLE, 
  366. 			[3] = INVALID_THREAD_HANDLE, 
  367. 			[4] = INVALID_THREAD_HANDLE, 
  368. 			[5] = INVALID_THREAD_HANDLE, 
  369. 		}, 
  370. 		fly_final_plane = INVALID_THREAD_HANDLE, 
  371. 		local_player_vtol_health = INVALID_THREAD_HANDLE, 
  372. 		remote_player_vtol_health = INVALID_THREAD_HANDLE, 
  373. 		radio_chatter = INVALID_THREAD_HANDLE, 
  374. 		convoy_cleanup = INVALID_THREAD_HANDLE, 
  375. 		intro_convos = INVALID_THREAD_HANDLE, 
  376. 		air_base_convos = INVALID_THREAD_HANDLE, 
  377. 	} 
  378. 	 
  379. -- Checkpoints -- 
  380. 	M11_checkpoints = { 
  381. 		start = MISSION_START_CHECKPOINT, 
  382. 		destroy_bases = "destroy_bases", 
  383. 		roadblock12 = "roadblock12", 
  384. 		roadblock13 = "roadblock13", 
  385. 		roadblock14 = "roadblock14", 
  386. 		roadblock23 = "roadblock23", 
  387. 		roadblock24 = "roadblock24", 
  388. 		roadblock34 = "roadblock34", 
  389. 		oleg_battle = "oleg_battle", 
  390. 		air_base = "air_base", 
  391. 	} 
  392. 	 
  393. -- Cutscenes -- 
  394. 	M11_cutscenes = { 
  395. 		intro = "11_in", 
  396. 		outro = "11_out", 
  397. 	} 
  398. 	 
  399. 	M11_personas = { 
  400. 		oleg = { 
  401. 			name = "Oleg", 
  402. 			handle = INVALID_PERSONA_HANDLE, 
  403. 		}, 
  404. 		pierce = { 
  405. 			name = "Pierce", 
  406. 			handle = INVALID_PERSONA_HANDLE, 
  407. 		}, 
  408. 		stag_am = { 
  409. 			name = "STAG_AM", 
  410. 			handle = INVALID_PERSONA_HANDLE, 
  411. 		}, 
  412. 		stag_bm = { 
  413. 			name = "STAG_BM", 
  414. 			handle = INVALID_PERSONA_HANDLE, 
  415. 		}, 
  416. 		stag_wf = { 
  417. 			name = "STAG_WF", 
  418. 			handle = INVALID_PERSONA_HANDLE, 
  419. 		}, 
  420. 		stag_wm = { 
  421. 			name = "STAG_WM", 
  422. 			handle = INVALID_PERSONA_HANDLE, 
  423. 		}, 
  424. 		cyrus = { 
  425. 			name = "Cyrus", 
  426. 			handle = INVALID_PERSONA_HANDLE, 
  427. 		}, 
  428. 		kia = { 
  429. 			name = "Kia", 
  430. 			handle = INVALID_PERSONA_HANDLE, 
  431. 		}, 
  432. 		interrogation = { 
  433. 			name = "Interrogation", 
  434. 			handle = INVALID_PERSONA_HANDLE, 
  435. 		}, 
  436. 	} 
  437. 	 
  438. 	M11_stag_personas = { M11_personas.stag_am, M11_personas.stag_bm, M11_personas.stag_wf, M11_personas.stag_wm } 
  439. 	 
  440. --- Lines --- 
  441. 	M11_lines = { 
  442. 		vtol_steal = "M11_Vtol_Steal",-- 
  443. 		arrive_at_first_base = "M11_Arriving_At_First_Base",-- 
  444. 		vtols_are_cool = "M11_VTOLs_Are_Cool",-- 
  445. 		inside_vtol = "M11_Inside_VTOL",-- 
  446. 		jet_mode = "M11_Jet_Mode_Awesomeness",-- 
  447. 		vtol_damaged = "M11_Need_New_VTOL_01",-- 
  448. 		vtol_very_damaged = "M11_Need_New_VTOL_02",-- 
  449. 		get_to_base = "M11_Get_To_A_Base",-- 
  450. 		roadblock_start = "M11_Roadblock_01",-- 
  451. 		roadblock_finish = "M11_Roadblock_Thanks_01",-- 
  452. 		after_takeoff1 = "M11_STAG_Convo_After_Takeoff_01a",-- 
  453. 		after_takeoff2 = "M11_STAG_Convo_After_Takeoff_02",-- 
  454. 		fight_at_park = "M11_Fight_At_Park_03",-- 
  455. 		stag_chatter = "M11_Stag_Radio_Chatter",-- 
  456. 		 
  457. 		air_base = "M11_STAG_Convo_To_Air_Base_03",-- 
  458. 		 
  459. 		random_lines = { 
  460. 			lines = { 
  461. 				{ 
  462. 					name = "M11_STAG_Attention_01", 
  463. 					persona = M11_personas.pierce, 
  464. 					played = false, 
  465. 				}, 
  466. 				{ 
  467. 					name = "M11_STAG_Attention_02", 
  468. 					persona = M11_personas.pierce, 
  469. 					played = false, 
  470. 				}, 
  471. 				{ 
  472. 					name = "M11_Oleg_Is_Attacking_01", 
  473. 					persona = M11_personas.stag_wf, 
  474. 					played = false, 
  475. 				}, 
  476. 				{ 
  477. 					name = "M11_Oleg_Is_Attacking_02", 
  478. 					persona = M11_personas.stag_wf, 
  479. 					played = false, 
  480. 				}, 
  481. 				{ 
  482. 					name = "M11_Cyrus_Warns_Bases", 
  483. 					persona = M11_personas.cyrus, 
  484. 					played = false, 
  485. 				}, 
  486. 				{ 
  487. 					name = "M11_Cyrus_Lookout_For_Convoy", 
  488. 					persona = M11_personas.cyrus, 
  489. 					played = false, 
  490. 				}, 
  491. 				{ 
  492. 					name = "M11_Cyrus_Reports_Of_Convoy", 
  493. 					persona = M11_personas.cyrus, 
  494. 					played = false, 
  495. 				}, 
  496. 				{ 
  497. 					name = "M11_Cyrus_Park_Is_Diversion", 
  498. 					persona = M11_personas.cyrus, 
  499. 					played = false, 
  500. 				}, 
  501. 				{ 
  502. 					name = "M11_Cyrus_Generic_Orders_01", 
  503. 					persona = M11_personas.cyrus, 
  504. 					played = false, 
  505. 				}, 
  506. 				{ 
  507. 					name = "M11_Cyrus_Generic_Orders_02", 
  508. 					persona = M11_personas.cyrus, 
  509. 					played = false, 
  510. 				}, 
  511. 				{ 
  512. 					name = "M11_Cyrus_Generic_Orders_03", 
  513. 					persona = M11_personas.cyrus, 
  514. 					played = false, 
  515. 				}, 
  516. 				{ 
  517. 					name = "M11_Cyrus_Generic_Orders_04", 
  518. 					persona = M11_personas.cyrus, 
  519. 					played = false, 
  520. 				}, 
  521. 				{ 
  522. 					name = "M11_Kia_Bring_Down_VTOL_Order", 
  523. 					persona = M11_personas.kia, 
  524. 					played = false, 
  525. 				}, 
  526. 				{ 
  527. 					name = "M11_Kia_Warns_Bases", 
  528. 					persona = M11_personas.kia, 
  529. 					played = false, 
  530. 				}, 
  531. 				{ 
  532. 					name = "M11_Kia_Set_Up_Roadblocks", 
  533. 					persona = M11_personas.kia, 
  534. 					played = false, 
  535. 				}, 
  536. 				{ 
  537. 					name = "M11_Kia_Focus_Fire_On_VTOL", 
  538. 					persona = M11_personas.kia, 
  539. 					played = false, 
  540. 				}, 
  541. 				{ 
  542. 					name = "M11_Kia_Prepare_For_Support", 
  543. 					persona = M11_personas.kia, 
  544. 					played = false, 
  545. 				}, 
  546. 				{ 
  547. 					name = "M11_Kia_Generic_Orders_01", 
  548. 					persona = M11_personas.kia, 
  549. 					played = false, 
  550. 				}, 
  551. 				{ 
  552. 					name = "M11_Kia_Generic_Orders_02", 
  553. 					persona = M11_personas.kia, 
  554. 					played = false, 
  555. 				}, 
  556. 				{ 
  557. 					name = "M11_Kia_Generic_Orders_03", 
  558. 					persona = M11_personas.kia, 
  559. 					played = false, 
  560. 				}, 
  561. 				 
  562. 			}, 
  563. 			num_lines = 20, 
  564. 			num_played = 0, 
  565. 		} 
  566. 	} 
  567. 	 
  568. -- Conversations -- 
  569. 	M11_conv = { 
  570. 		start = {-- 
  571. 			name = "M11_Mission_Start", 
  572. 			handle = INVALID_CONVERSATION_HANDLE, 
  573. 		}, 
  574. 		pack = {-- 
  575. 			name = "M11_Drive_1", 
  576. 			handle = INVALID_CONVERSATION_HANDLE, 
  577. 		}, 
  578. 		to_vtols = {-- 
  579. 			name = "M11_Get_To_VTOL", 
  580. 			handle = INVALID_CONVERSATION_HANDLE, 
  581. 		}, 
  582. 		convoy_start = {-- 
  583. 			name = "M11_Convoy_Start", 
  584. 			handle = INVALID_CONVERSATION_HANDLE, 
  585. 		}, 
  586. 		call_plane = {-- 
  587. 			name = "M11_Call_In_Plane", 
  588. 			handle = INVALID_CONVERSATION_HANDLE, 
  589. 		}, 
  590. 		oleg_help = {-- 
  591. 			name = "M11_Oleg_Help", 
  592. 			handle = INVALID_CONVERSATION_HANDLE, 
  593. 		}, 
  594. 		oleg_arrive = {-- 
  595. 			name = "M11_Arrive_At_Park", 
  596. 			handle = INVALID_CONVERSATION_HANDLE, 
  597. 		},	 
  598. 		reinforcements = {-- 
  599. 			name = "M11_Air_Reinforcement", 
  600. 			handle = INVALID_CONVERSATION_HANDLE, 
  601. 		},	 
  602. 		awacs = {-- 
  603. 			name = "M11_On_Way_To_AWACS", 
  604. 			handle = INVALID_CONVERSATION_HANDLE, 
  605. 			play = false, 
  606. 			kill = false, 
  607. 		}, 
  608. 		air_base = {-- 
  609. 			name = "M11_STAG_Convo_Air_Base", 
  610. 			handle = INVALID_CONVERSATION_HANDLE, 
  611. 		}, 
  612. 		killing_escorts = {-- 
  613. 			name = "M11_Killing_Escort_Crafts_1", 
  614. 			handle = INVALID_CONVERSATION_HANDLE, 
  615. 			play = false, 
  616. 			kill = false, 
  617. 		}, 
  618. 		kill_plane = {-- 
  619. 			name = "M11_Hurry_Kill_Plane", 
  620. 			handle = INVALID_CONVERSATION_HANDLE, 
  621. 		},	 
  622. 		pierce_end = {-- 
  623. 			name = "M11_Pierce_End", 
  624. 			handle = INVALID_CONVERSATION_HANDLE, 
  625. 		},	 
  626. 	} 
  627. 	 
  628. 	M11_audio_emitters = { 
  629. 		alarm = "M11_alarm_a", 
  630. 	} 
  631. 	 
  632. 	-- These emitters are automatically stopped at the end of the mission. 
  633. 	M11_temporary_audio_emitters = { M11_audio_emitters.alarm, } 
  634.  
  635. -- Other -- 
  636. 	M11_globals = {  
  637. 		-- Objective flags 
  638. 		vtol_hijacked = false, 
  639. 		objective_reached = false, 
  640.  
  641. 		-- STAG progress 
  642. 		stag_attention = { 
  643. 			max_value = 1.0, 
  644. 			value = 1.0, 
  645. 			diminish_rate = 3, 
  646. 			diminish_value = 0.02, 
  647. 			target_value = 0.20, 
  648. 			first_warning = false, 
  649. 			second_warning = false, 
  650. 			third_warning = false, 
  651. 		}, 
  652. 		air_base_time = 240000, 
  653. 		warn_time = 120000, 
  654.  
  655. 		num_bases_destroyed = 0, 
  656. 		num_bases_destroyed_goal = 0, 
  657. 		 
  658. 		first_base_destroyed = false, 
  659. 		third_base_destroyed = false, 
  660. 		 
  661. 		num_guards = 0, 
  662. 		num_targets = 0, 
  663. 		num_transports = 0, 
  664. 		final_plane_alive = false, 
  665. 		final_targets_attack = false, 
  666. 		 
  667. 		local_vtol_jet = false, 
  668. 		local_vtol_hover = false, 
  669. 		remote_vtol_jet = false, 
  670. 		remote_vtol_hover = false, 
  671. 		 
  672. 		playing_line = false, 
  673. 		ped_density = 0.1, 
  674. 		vehicle_density = 0.25, 
  675. 		 
  676. 		cell_call_finished = true, 
  677. 		cur_cell_call = "", 
  678. 	} 
  679. 	 
  680. 	M11_triggers = { 
  681. 		traffic_rb = "tgr_traffic_rb1 001", 
  682. 	} 
  683.  
  684. -- ************************* 
  685. -- 
  686. -- Standard functions 
  687. -- 
  688. -- ************************* 
  689.  
  690. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  691. -- at the specified checkpoint. 
  692. -- CALLED FROM CODE 
  693. -- 
  694. -- m11_checkpoint:	The checkpoint the mission should begin at 
  695. -- is_restart:		TRUE if the mission is restarting, FALSE otherwise 
  696. -- 
  697. function m11_start(m11_checkpoint, is_restart) 
  698. 	-- Debug checkpoint override 
  699. 	--m11_checkpoint = M11_checkpoints.oleg_battle 
  700.  
  701. 	-- Check if this mission starting from the beginning 
  702. 	if (m11_checkpoint == M11_checkpoints.start) then 
  703. 		if (is_restart == false) then 
  704. 			-- First time playing mission 
  705. 			 
  706. 			-- TODO: Play an intro cutscene 
  707. 			if (M11_cutscenes.intro ~= "") then 
  708. 				cutscene_play(M11_cutscenes.intro, nil, {M11_navpoints.start_local, M11_navpoints.start_remote}, false) 
  709. 			end 
  710. 		end 
  711. 		fade_out(0) 
  712. 	end 
  713.  
  714. 	-- Handle mission initialization for the current checkpoint 
  715. 	m11_initialize(m11_checkpoint, is_restart) 
  716.  
  717. 	-- Run the mission from the current checkpoint 
  718. 	m11_run(m11_checkpoint) 
  719. end 
  720.  
  721. -- This is the primary function responsible for running the entire mission from start to finish. 
  722. -- 
  723. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  724. -- 
  725. function m11_run(first_checkpoint) 
  726. 	local current_checkpoint = first_checkpoint 
  727.  
  728. 	-- Run the mission from the beginning 
  729. 	if (current_checkpoint == M11_checkpoints.start) then 
  730. 		-- OBJECTIVE: Get to the base 
  731. 		m11_go_to_first_base() 
  732.  
  733. 		-- OBJECTIVE: Hijack a VTOL 
  734. 		m11_hijack_vtol() 
  735.  
  736. 		-- Next checkpoint 
  737. 		current_checkpoint = M11_checkpoints.destroy_bases 
  738. 		mission_set_checkpoint(M11_checkpoints.destroy_bases, true) 
  739. 	end 
  740.  
  741. 	-- Fake notoriety from here on 
  742. 	notoriety_set_can_decay(false) 
  743. 	notoriety_spawn_only_air(true) 
  744. 	notoriety_force_no_spawn("police", true) 
  745. 	notoriety_force_no_spawn("stag", true) 
  746. 	notoriety_set_min("police", 2) 
  747. 	hud_set_fake_notoriety("police", true, 5) 
  748.  
  749. 	--lower ped density from here on out 
  750. 	set_ped_density(M11_globals.ped_density) 
  751. 	set_traffic_density(M11_globals.vehicle_density) 
  752. 	 
  753. 	-- Start radio chatter thread 
  754. 	M11_globals.playing_line = false 
  755. 	M11_threads.radio_chatter = thread_new("m11_radio_chatter_thread") 
  756. 	 
  757. 	-- Enable the STAG Attention bar 
  758. 	--m11_setup_stag_attention() 
  759. 	 
  760. 	if (current_checkpoint == M11_checkpoints.destroy_bases) then 
  761. 		-- Start the Pierce phone call 
  762. 		M11_conv.convoy_start.handle = audio_conversation_load(M11_conv.convoy_start.name) 
  763. 		audio_conversation_play(M11_conv.convoy_start.handle) 
  764.  
  765. 		-- OBJECTIVE: The players must destroy 2 bases to proceed 
  766. 		 
  767. 		-- Have them kill one base, then we need to do some setup 
  768. 		M11_globals.num_bases_destroyed_goal = 1 
  769. 		m11_distract_stag() 
  770. 		 
  771. 		-- Spawn the convoy group now, so that its good to go when we need it 
  772. 		group_create_hidden(M11_groups.roadblocks[1]) 
  773. 		 
  774. 		M11_globals.num_bases_destroyed_goal = 2 
  775. 		m11_distract_stag() 
  776.  
  777. 		audio_conversation_wait_for_end(M11_conv.convoy_start.handle) 
  778. 		M11_conv.convoy_start.handle = INVALID_CONVERSATION_HANDLE 
  779. 		m11_wait_for_audio() 
  780. 		M11_globals.playing_line = true 
  781. 		audio_play_persona_line(LOCAL_PLAYER, M11_lines.get_to_base) 
  782. 		delay(3) 
  783. 		M11_globals.playing_line = false 
  784.  
  785. 		-- Figure out the next checkpoint based on destroyed bases 
  786. 		current_checkpoint = m11_determine_checkpoint() 
  787. 		mission_set_checkpoint(current_checkpoint, true) 
  788. 	end 
  789.  
  790. 	if ((current_checkpoint == M11_checkpoints.roadblock12) or (current_checkpoint == M11_checkpoints.roadblock13) or 
  791. 		 (current_checkpoint == M11_checkpoints.roadblock14) or (current_checkpoint == M11_checkpoints.roadblock23) or 
  792. 		 (current_checkpoint == M11_checkpoints.roadblock24) or (current_checkpoint == M11_checkpoints.roadblock34)) then 
  793. 		 
  794. 		-- OBJECTIVE: Help Convoy 
  795. 		m11_help_convoy(M11_groups.roadblocks[1]) 
  796. 		 
  797. 		-- Re-enable STAG notoriety aircraft. 
  798. 		notoriety_force_no_spawn("stag", false) 
  799.  
  800. 		-- Increase notoriety 
  801. 		notoriety_set_min("police", 4) 
  802. 		 
  803. 		-- Pierce calls with the OK 
  804. 		m11_wait_for_audio() 
  805. 		M11_globals.playing_line = true 
  806. 		audio_play_persona_line_2d(M11_personas.pierce.handle, M11_lines.roadblock_finish) 
  807. 		delay(5) 
  808. 		M11_globals.playing_line = false 
  809. 		M11_conv.call_plane.handle = audio_conversation_load(M11_conv.call_plane.name) 
  810. 		audio_conversation_play(M11_conv.call_plane.handle) 
  811.  
  812. 		audio_conversation_wait_for_end(M11_conv.call_plane.handle) 
  813. 		M11_conv.call_plane.handle = INVALID_CONVERSATION_HANDLE 
  814. 		 
  815. 		-- OBJECTIVE: The players must destroy the remaining bases to proceed 
  816. 		M11_globals.num_bases_destroyed_goal = 4 
  817. 		m11_distract_stag() 
  818.  
  819. 		-- Disable STAG notoriety aircraft again. 
  820. 		notoriety_force_no_spawn("stag", true) 
  821.  
  822. 		-- Next checkpoint 
  823. 		current_checkpoint = M11_checkpoints.oleg_battle 
  824. 		mission_set_checkpoint(M11_checkpoints.oleg_battle, true) 
  825. 	end 
  826. 	 
  827. 	-- Decrease notoriety 
  828. 	notoriety_set_min("police", 2) 
  829. 	notoriety_set_max("police", 2) 
  830.  
  831. 	if (current_checkpoint == M11_checkpoints.oleg_battle) then 
  832. 		-- OBJECTIVE: Help Oleg 
  833. 		m11_help_oleg() 
  834.  
  835. 		current_checkpoint = M11_checkpoints.air_base 
  836. 		mission_set_checkpoint(M11_checkpoints.air_base, true) 
  837. 	end 
  838.  
  839. 	-- Slow the attention meter due to travel distance 
  840. 	--M11_globals.stag_attention.diminish_value = 0.015 
  841.  
  842. 	-- Increase notoriety 
  843. 	notoriety_set_max("police", 4) 
  844. 	notoriety_set_min("police", 4) 
  845. 	 
  846. 	if (current_checkpoint == M11_checkpoints.air_base) then 
  847. 		-- OBJECTIVE: Take out the Air Base 
  848. 		m11_air_base() 
  849. 	end 
  850.  
  851. 	-- Stop the attention meter 
  852. 	--m11_remove_stag_attention() 
  853.  
  854. 	-- End at Shaundi's ex's 
  855. 	 
  856. 	-- Call mission success 
  857. 	mission_end_success("m11", M11_cutscenes.outro, {M11_navpoints.end_local, M11_navpoints.end_remote}) 
  858. end 
  859.  
  860. -- This is the primary function responsible for cleaning up the entire mission 
  861. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  862. -- 
  863. function m11_cleanup() 
  864. 	waypoint_remove(SYNC_ALL) 
  865. 	objective_text_clear(0) 
  866. 	 
  867. 	m11_cleanup_hijack_vtol() 
  868. 	m11_cleanup_help_oleg() 
  869.  
  870. 	-- Kill the HUD bar and threads 
  871. 	--m11_remove_stag_attention() 
  872. 	hud_timer_stop(1) 
  873. 	cleanup_threads(M11_threads) 
  874.  
  875. 	-- Stop all conversations 
  876. 	for i, convo in pairs(M11_conv) do 
  877. 		if (convo.handle ~= INVALID_CONVERSATION_HANDLE) then 
  878. 			audio_conversation_end(convo.handle) 
  879. 			convo.handle = INVALID_CONVERSATION_HANDLE 
  880. 		end 
  881. 	end 
  882. 	 
  883. 	-- Stop all temporary audio emitters 
  884. 	for i, emitter in pairs(M11_temporary_audio_emitters) do 
  885. 		audio_ambient_emitter_stop(emitter) 
  886. 	end 
  887.  
  888. 	-- Unload personas 
  889. 	for i, persona in pairs(M11_personas) do 
  890. 		if (persona.handle ~= INVALID_PERSONA_HANDLE) then 
  891. 			audio_persona_remove_2d(persona.handle) 
  892. 			persona.handle = INVALID_PERSONA_HANDLE 
  893. 		end 
  894. 	end 
  895.  
  896. 	-- Unregister callbacks 
  897. 	on_trigger("", M11_groups.stag_bases[1].restricted) 
  898. 	on_trigger("", M11_groups.stag_bases[2].script.trigger) 
  899. 	on_trigger("", M11_groups.oleg_battle.location) 
  900. 	 
  901. 	-- Destroy the STAG bases 
  902. 	for i, base in pairs(M11_groups.stag_bases) do 
  903. 		on_trigger("", base.location) 
  904. 		on_trigger_exit("", base.location) 
  905. 		on_trigger("", base.zone) 
  906. 		on_trigger_exit("", base.zone) 
  907. 		marker_remove(base.nav, SYNC_ALL) 
  908.  
  909. 		for i, box in pairs(base.boxes) do 
  910. 			if (not mesh_mover_destroyed(box.name)) then 
  911. 				marker_remove(box.name, SYNC_ALL) 
  912. 				on_mover_destroyed("", box.name) 
  913. 			end 
  914. 		end 
  915.  
  916. 		if (group_is_loaded(base.name)) then 
  917. 			group_destroy(base.name) 
  918. 		end 
  919. 		 
  920. 		if base.vehicle_group ~= nil then 
  921. 			if group_is_loaded(base.vehicle_group) then 
  922. 				group_destroy(base.vehicle_group) 
  923. 			end 
  924. 		end 
  925.  
  926. 		if (group_is_loaded(base.vtols.name)) then 
  927. 			for i, vtol in pairs(base.vtols.vehicles) do 
  928. 				marker_remove(vtol, SYNC_ALL) 
  929. 				on_vehicle_enter("", vtol) 
  930. 			end 
  931. 			group_destroy(base.vtols.name) 
  932. 		end 
  933. 	end 
  934.  
  935. 	-- Clean up road blocks 
  936. 	for i, roadblock in pairs(M11_groups.roadblocks) do 
  937. 		marker_remove_trigger(roadblock.location, SYNC_ALL) 
  938. 		on_trigger("", roadblock.location) 
  939.  
  940. 		for j, vehicle in pairs(roadblock.vehicles) do 
  941. 			marker_remove(vehicle, SYNC_ALL) 
  942. 			on_vehicle_destroyed("", vehicle) 
  943. 		end 
  944.  
  945. 		for j, vehicle in pairs(roadblock.convoy.vehicles) do 
  946. 			marker_remove(vehicle, SYNC_ALL) 
  947. 			on_vehicle_destroyed("", vehicle.name) 
  948. 			for j, person in pairs(vehicle.passengers) do 
  949. 				on_death("", person) 
  950. 			end 
  951. 		end 
  952.  
  953. 		if (group_is_loaded(roadblock.name)) then 
  954. 			group_destroy(roadblock.name) 
  955. 		end 
  956. 	end 
  957.  
  958. 	if (group_is_loaded(M11_groups.stag_bases[2].script.name)) then 
  959. 		group_destroy(M11_groups.stag_bases[2].script.name) 
  960. 	end 
  961.  
  962. 	if (group_is_loaded(M11_groups.air_base.name)) then 
  963. 		for i, target in pairs(M11_groups.air_base.targets) do 
  964. 			on_vehicle_destroyed("", target.vehicle) 
  965. 			marker_remove(target.vehicle, SYNC_ALL) 
  966. 		end 
  967. 		for i, guard in pairs(M11_groups.air_base.guards) do 
  968. 			on_vehicle_destroyed("", guard.vehicle) 
  969. 			marker_remove(guard.vehicle, SYNC_ALL) 
  970. 		end 
  971. 		on_vehicle_destroyed("", M11_groups.air_base.final_plane.vehicle) 
  972. 		on_damage("", M11_groups.air_base.final_plane.vehicle) 
  973. 		marker_remove(M11_groups.air_base.final_plane.vehicle, SYNC_ALL) 
  974. 		group_destroy(M11_groups.air_base.name) 
  975. 	end 
  976.  
  977. 	for i, battle in pairs(M11_groups.oleg_battle.waves) do 
  978. 		if (group_is_loaded(battle.name)) then 
  979. 			for i, vehicle in pairs(battle.vehicles) do 
  980. 				marker_remove(vehicle.name, SYNC_ALL) 
  981. 				on_vehicle_destroyed("", vehicle.name) 
  982. 			end 
  983. 			group_destroy(battle.name) 
  984. 		end 
  985. 	end 
  986. 	if (group_is_loaded(M11_groups.oleg_battle.oleg_vtols.name)) then 
  987. 		for i, vtol in pairs(M11_groups.oleg_battle.oleg_vtols.vtols) do 
  988. 			on_vehicle_enter("", vtol) 
  989. 		end 
  990. 		group_destroy(M11_groups.oleg_battle.oleg_vtols.name) 
  991. 	end 
  992. 	if (group_is_loaded(M11_groups.oleg_battle.oleg.name)) then 
  993. 		group_destroy(M11_groups.oleg_battle.oleg.name) 
  994. 		on_death("", M11_groups.oleg_battle.oleg.oleg) 
  995. 	end 
  996. 	 
  997. 	if group_is_loaded(M11_groups.vehicle_start.name) then 
  998. 		group_destroy(M11_groups.vehicle_start.name) 
  999. 	end 
  1000. 	if group_is_loaded(M11_groups.vehicle_cp.name) then 
  1001. 		group_destroy(M11_groups.vehicle_cp.name) 
  1002. 	end 
  1003.  
  1004. 	-- Reset notoriety 
  1005. 	hud_set_fake_notoriety("police", false, 0) 
  1006. 	notoriety_set_can_decay(true) 
  1007. 	notoriety_reset("police") 
  1008. 	notoriety_force_no_spawn("police", false) 
  1009. 	notoriety_force_no_spawn("stag", false) 
  1010. 	notoriety_spawn_only_air(false) 
  1011. 	notoriety_force_no_air_spawn(false) 
  1012. 	 
  1013. 	-- Reset ambient density. 
  1014. 	set_ped_density(1.0) 
  1015. 	set_traffic_density(1.0) 
  1016. 	 
  1017. 	audio_remove_mission_cellphone(M11_globals.cur_cell_call) 
  1018. end 
  1019.  
  1020. -- Called when the mission has ended with success 
  1021. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  1022. function m11_success() 
  1023. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  1024. 	 
  1025. end 
  1026.  
  1027.  
  1028. -- ************************* 
  1029. -- 
  1030. -- Local functions 
  1031. -- 
  1032. -- ************************* 
  1033.  
  1034. -- Figure out the next checkpoint based on destroyed bases 
  1035. -- Returns: Checkpoint name 
  1036. function m11_determine_checkpoint() 
  1037. 	-- 12, 13, 14, 23, 24, or 34 
  1038. 	if (M11_groups.stag_bases[1].destroyed) then 
  1039. 		-- 12, 13, or 14 
  1040. 		if (M11_groups.stag_bases[2].destroyed) then 
  1041. 			return M11_checkpoints.roadblock12 
  1042. 		elseif (M11_groups.stag_bases[3].destroyed) then 
  1043. 			return M11_checkpoints.roadblock13 
  1044. 		else 
  1045. 			return M11_checkpoints.roadblock14 
  1046. 		end 
  1047. 	elseif (M11_groups.stag_bases[2].destroyed) then 
  1048. 		-- 23 or 24 
  1049. 		if (M11_groups.stag_bases[3].destroyed) then 
  1050. 			return M11_checkpoints.roadblock23 
  1051. 		else 
  1052. 			return M11_checkpoints.roadblock24 
  1053. 		end 
  1054. 	else 
  1055. 		return M11_checkpoints.roadblock34 
  1056. 	end 
  1057. end 
  1058.  
  1059. -- Initialize the mission for the specified checkpoint 
  1060. -- 
  1061. -- checkpoint:		Checkpoint to initialize the mission to 
  1062. -- is_restart:      Whether or not the mission is restarting. 
  1063. function m11_initialize(checkpoint, is_restart) 
  1064. 	-- Make sure the screen is completly faded out 
  1065. 	mission_start_fade_out(0.0) 
  1066.  
  1067. 	-- Set the mission author 
  1068. 	set_mission_author("Albert McDaniel") 
  1069.  
  1070. 	-- This can be removed in the future after the world takes care of stag 
  1071. 	set_stag_active(true) 
  1072.  
  1073. 	-- Always warp to the start location on cancel 
  1074. 	mission_set_cancel_warp_location(M11_navpoints.start_local, M11_navpoints.start_remote) 
  1075.  
  1076. 	-- Load the personas used 
  1077. 	for i, persona in pairs(M11_personas) do 
  1078. 		persona.handle = audio_persona_load_2d(persona.name) 
  1079. 	end 
  1080. 	 
  1081. 	-- create the giant plane so we make sure we have the resources (customized vehicle slot) 
  1082. 	group_create_hidden(M11_groups.air_base_jumbo_plane.name, true) 
  1083. 	group_create_hidden(M11_groups.air_base.name, true) 
  1084.  
  1085. 	-- Checkpoint specific initialization 
  1086. 	m11_initialize_checkpoint(checkpoint, is_restart) 
  1087.  
  1088. 	-- Start fading in  
  1089. 	mission_start_fade_in() 
  1090. end 
  1091.  
  1092. -- *************************************************** 
  1093. -- m11_initialize Helper Functions 
  1094. -- *************************************************** 
  1095.  
  1096. -- Checkpoint specific initialization 
  1097. -- 
  1098. -- checkpoint:		The checkpoint to be initialized 
  1099. -- is_restart:      Whether or not the mission is restarting. 
  1100. function m11_initialize_checkpoint(checkpoint, is_restart) 
  1101. 	-- Always use the same start location 
  1102. 	if is_restart == true then 
  1103. 		teleport_coop(M11_navpoints.start_local, M11_navpoints.start_remote) 
  1104. 	end 
  1105.  
  1106. 	if (checkpoint == M11_checkpoints.start) then 
  1107. 		group_create(M11_groups.vehicle_start.name, true) 
  1108. 		vehicle_set_team(M11_groups.vehicle_start.vehicles[1], "Playas") 
  1109.  
  1110. 		-- Start with low STAG attention to force the players to fill it 
  1111. 		--M11_globals.stag_attention.value = M11_globals.stag_attention.max_value * 0.4 
  1112. 	else 
  1113. 		if (checkpoint ~= M11_checkpoints.destroy_bases) then 
  1114. 			--don't play plane lines again 
  1115. 			M11_globals.local_vtol_jet = true 
  1116. 			M11_globals.local_vtol_hover = true 
  1117. 			M11_globals.remote_vtol_jet = true 
  1118. 			M11_globals.remote_vtol_hover = true 
  1119. 			 
  1120. 		end 
  1121. 		-- If not the starting cp, spawn the players in VTOLs 
  1122. 		group_create(M11_groups.vehicle_cp.name, true) 
  1123. 		while not vehicle_enter_teleport(LOCAL_PLAYER, M11_groups.vehicle_cp.vehicles[1], 0) do 
  1124. 			thread_yield() 
  1125. 		end 
  1126. 		if (coop_is_active()) then 
  1127. 			vehicle_enter_teleport(REMOTE_PLAYER, M11_groups.vehicle_cp.vehicles[2], 0) 
  1128. 		else 
  1129. 			object_destroy(M11_groups.vehicle_cp.vehicles[2]) 
  1130. 		end 
  1131. 		--start threads to keep track of players VTOL health 
  1132. 		M11_threads.local_player_vtol_health = thread_new("m11_player_vtol_tracking_thread", LOCAL_PLAYER) 
  1133. 		if (coop_is_active()) then 
  1134. 			M11_threads.remote_player_vtol_heath = thread_new("m11_player_vtol_tracking_thread", REMOTE_PLAYER) 
  1135. 		end 
  1136. 		-- Start with full STAG attention, as the bases are far away 
  1137. 		--M11_globals.stag_attention.value = M11_globals.stag_attention.max_value 
  1138. 	end 
  1139. 	 
  1140. 	 
  1141.  
  1142. 	-- Determine how many bases have been destroyed 
  1143. 	if (checkpoint == M11_checkpoints.roadblock12) then 
  1144. 		M11_groups.stag_bases[1].destroyed = true 
  1145. 		M11_groups.stag_bases[2].destroyed = true 
  1146. 	elseif (checkpoint == M11_checkpoints.roadblock13) then 
  1147. 		M11_groups.stag_bases[1].destroyed = true 
  1148. 		M11_groups.stag_bases[3].destroyed = true 
  1149. 	elseif (checkpoint == M11_checkpoints.roadblock14) then 
  1150. 		M11_groups.stag_bases[1].destroyed = true 
  1151. 		M11_groups.stag_bases[4].destroyed = true 
  1152. 	elseif (checkpoint == M11_checkpoints.roadblock23) then 
  1153. 		M11_groups.stag_bases[2].destroyed = true 
  1154. 		M11_groups.stag_bases[3].destroyed = true 
  1155. 	elseif (checkpoint == M11_checkpoints.roadblock24) then 
  1156. 		M11_groups.stag_bases[2].destroyed = true 
  1157. 		M11_groups.stag_bases[4].destroyed = true 
  1158. 	elseif (checkpoint == M11_checkpoints.roadblock34) then 
  1159. 		M11_groups.stag_bases[3].destroyed = true 
  1160. 		M11_groups.stag_bases[4].destroyed = true 
  1161. 	elseif (checkpoint == M11_checkpoints.oleg_battle) then 
  1162. 		M11_groups.stag_bases[1].destroyed = true 
  1163. 		M11_groups.stag_bases[2].destroyed = true 
  1164. 		M11_groups.stag_bases[3].destroyed = true 
  1165. 		M11_groups.stag_bases[4].destroyed = true 
  1166. 	elseif (checkpoint == M11_checkpoints.air_base) then 
  1167. 		M11_groups.stag_bases[1].destroyed = true 
  1168. 		M11_groups.stag_bases[2].destroyed = true 
  1169. 		M11_groups.stag_bases[3].destroyed = true 
  1170. 		M11_groups.stag_bases[4].destroyed = true 
  1171. 	end 
  1172.  
  1173. 	-- Set up the remaining bases 
  1174. 	m11_initialize_bases() 
  1175. end 
  1176.  
  1177. -- Set up all bases that have not already been destroyed 
  1178. function m11_initialize_bases() 
  1179. 	-- Check if each base has been destroyed; if not, set it up 
  1180. 	for i, base in pairs(M11_groups.stag_bases) do 
  1181. 		if (base.destroyed) then 
  1182. 			-- Count the destroyed bases 
  1183. 			M11_globals.num_bases_destroyed = M11_globals.num_bases_destroyed + 1 
  1184. 		else 
  1185. 			-- Set up the spawn and despawn regions 
  1186. 			trigger_enable(base.location, true) 
  1187. 			on_trigger("m11_base_spawn_callback", base.location) 
  1188. 			on_trigger_exit("m11_base_despawn_callback", base.location) 
  1189.  
  1190. 			-- Set all boxes to invulnerable until the player is close and register their destroyed callback 
  1191. 			for i, box in pairs(base.boxes) do 
  1192. 				mesh_mover_set_invulnerable(box.name, true) 
  1193. 				on_mover_destroyed("m11_box_destroyed", box.name) 
  1194. 			end 
  1195. 		end 
  1196. 	end 
  1197.  
  1198. 	-- Set up the airport base script sequence 
  1199. 	if (M11_groups.stag_bases[2].destroyed == false) then 
  1200. 		trigger_enable(M11_groups.stag_bases[2].script.trigger, true) 
  1201. 		on_trigger("m11_airport_spawn_callback", M11_groups.stag_bases[2].script.trigger) 
  1202. 	end 
  1203. end 
  1204.  
  1205. -- ************************* 
  1206. -- Objective: Go to STAG Base 
  1207. -- ************************* 
  1208.  
  1209. -- Setup for the initial "Go to STAG Base" objective 
  1210. function m11_go_to_first_base() 
  1211. 	-- Tell the player to get to the closest STAG base 
  1212. 	objective_text(0, "M11_OBJ_GO_STAG_BASE", nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1213.  
  1214. 	-- Intro animations 
  1215. 	-- Player(s) look cool GO! 
  1216. 	local anim_name = "M06 Player Mission Start" 
  1217. 	local morph_name = "M06 Player Mission Start" 
  1218. 	local force_play = false 
  1219. 	local stand_still = false 
  1220. 	local zero_movement = false 
  1221. 	action_play_non_blocking(LOCAL_PLAYER, anim_name, morph_name, force_play, stand_still, zero_movement) 
  1222. 	player_script_controlled_clear(LOCAL_PLAYER)	-- let player escape this animation 
  1223. 	if (coop_is_active()) then 
  1224. 		action_play_non_blocking(REMOTE_PLAYER, anim_name, morph_name, force_play, stand_still, zero_movement) 
  1225. 		player_script_controlled_clear(REMOTE_PLAYER)	-- let player escape this animation 
  1226. 	end 
  1227.  
  1228. 	-- Set the base as the destination 
  1229. 	M11_globals.objective_reached = false 
  1230. 	trigger_enable(M11_groups.stag_bases[1].restricted, true) 
  1231. 	on_trigger("m11_reached_callback", M11_groups.stag_bases[1].restricted) 
  1232. 	marker_add(M11_groups.stag_bases[1].nav, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1233. 	waypoint_add(M11_groups.stag_bases[1].location) 
  1234. 	 
  1235. 	M11_threads.intro_convos = thread_new("m11_intro_convos_thread") 
  1236.  
  1237. 	-- Wait until the player reaches the first base 
  1238. 	while not M11_globals.objective_reached do 
  1239. 		thread_yield() 
  1240. 	end 
  1241.  
  1242. 	waypoint_remove(SYNC_ALL) 
  1243. 	marker_remove(M11_groups.stag_bases[1].nav, SYNC_ALL) 
  1244. 	objective_text_clear(0) 
  1245.  
  1246. 	-- these conversations should be done 
  1247. 	thread_kill(M11_threads.intro_convos) 
  1248. end 
  1249.  
  1250. -- ************************* 
  1251. -- Objective: Hijack VTOL 
  1252. -- ************************* 
  1253.  
  1254. -- Setup for the hijack a VTOL objective at the first STAG base 
  1255. function m11_hijack_vtol() 
  1256. 	-- Increase notoriety 
  1257. 	notoriety_set_min("police", 2) 
  1258.  
  1259. 	-- Ensure the VTOLs are loaded 
  1260. 	while not group_is_loaded(M11_groups.stag_bases[1].vtols.name) do 
  1261. 		thread_yield() 
  1262. 	end 
  1263. 	 
  1264. 	M11_globals.vtol_hijacked = false 
  1265. 	 
  1266. 	audio_conversation_wait_for_end(M11_conv.pack.handle) 
  1267. 	M11_conv.pack.handle = INVALID_CONVERSATION_HANDLE 
  1268. 	m11_wait_for_audio() 
  1269. 	M11_globals.playing_line = true 
  1270. 	audio_play_persona_line(LOCAL_PLAYER, M11_lines.arrive_at_first_base) 
  1271. 	delay(4.0) 
  1272. 	M11_globals.playing_line = false 
  1273. 	--For Aaron 
  1274. 	--M11_conv.to_vtols.handle = audio_conversation_load(M11_conv.to_vtols.name) 
  1275. 	--audio_conversation_play(M11_conv.to_vtols.handle) 
  1276. 	--audio_conversation_wait_for_end(M11_conv.to_vtols.handle) 
  1277. 	-- Tell the player to hijack a VTOL 
  1278. 	objective_text(0, "M11_OBJ_HIJACK_VTOL", nil, nil, SYNC_ALL, OI_ASSET_USE) 
  1279. 	 
  1280. 	-- Mark each vtol in the first base 
  1281. 	for i, vtol in pairs(M11_groups.stag_bases[1].vtols.vehicles) do 
  1282. 		marker_add(vtol, MINIMAP_ICON_USE, OI_ASSET_USE, OI_FLAGS_DEFAULT, SYNC_ALL) 
  1283.  
  1284. 		-- If both are destroyed, auto-advance 
  1285. 		on_vehicle_destroyed("m11_vtol_destroyed_callback", vtol) 
  1286. 		on_vehicle_enter_water("m11_vtol_destroyed_callback", vtol) 
  1287. 	end 
  1288. 	 
  1289. 	-- Wait for the player to hijack a vtol 
  1290. 	while (M11_globals.vtol_hijacked == false) do 
  1291. 		thread_yield() 
  1292. 	end 
  1293. 	 
  1294. 	objective_text_clear(0) 
  1295. 	 
  1296. 	delay(1) 
  1297. 	 
  1298. 	audio_ambient_emitter_start(M11_audio_emitters.alarm) 
  1299. 	 
  1300. 	delay(1) 
  1301. 	 
  1302. 	-- Play a line on the nearest living STAG dude about the player stealing the VTOL. 
  1303. 	local nearest_dist = 999999 
  1304. 	local nearest_dude = "" 
  1305. 	for i, npc in pairs(M11_groups.stag_bases[1].npcs) do 
  1306. 		local dist = get_dist(npc, M11_groups.stag_bases[1].vtols.vehicles[1]) 
  1307. 		if dist < nearest_dist then 
  1308. 			nearest_dist = dist 
  1309. 			nearest_dude = npc 
  1310. 		end 
  1311. 	end 
  1312. 	if nearest_dude ~= "" then 
  1313. 		audio_play_persona_line(nearest_dude, M11_lines.vtol_steal) 
  1314. 		delay(2) 
  1315. 	end 
  1316.  
  1317. 	-- Cleanup first objective 
  1318. 	for i, vtol in pairs(M11_groups.stag_bases[1].vtols.vehicles) do 
  1319. 		marker_remove(vtol, SYNC_ALL) 
  1320. 		on_vehicle_destroyed("", vtol) 
  1321. 	end 
  1322.  
  1323. 	--start threads to keep track of players VTOL health 
  1324. 	M11_threads.local_player_vtol_health = thread_new("m11_player_vtol_tracking_thread", LOCAL_PLAYER) 
  1325. 	if (coop_is_active()) then 
  1326. 		M11_threads.remote_player_vtol_heath = thread_new("m11_player_vtol_tracking_thread", REMOTE_PLAYER) 
  1327. 	end 
  1328. 	 
  1329. 	-- Show the player the bases 
  1330. 	m11_wait_for_audio() 
  1331. 	M11_globals.playing_line = true 
  1332. 	audio_play_persona_line(LOCAL_PLAYER, M11_lines.inside_vtol) 
  1333. 	delay(4) 
  1334. 	M11_globals.playing_line = false 
  1335. 	 
  1336. 	m11_cleanup_hijack_vtol() 
  1337. end 
  1338.  
  1339. function m11_cleanup_hijack_vtol() 
  1340. 	for i, vtol in pairs(M11_groups.stag_bases[1].vtols.vehicles) do 
  1341. 		marker_remove(vtol, SYNC_ALL) 
  1342. 		on_vehicle_destroyed("", vtol) 
  1343. 		on_vehicle_enter_water("", vtol) 
  1344. 	end 
  1345. end 
  1346.  
  1347. -- ************************* 
  1348. -- Objective: Distract STAG 
  1349. -- ************************* 
  1350.  
  1351. -- The player must destroy STAG bases to keep them distracted 
  1352. function m11_distract_stag() 
  1353. 	objective_text_clear(0) 
  1354. 	objective_text_clear(1) 
  1355. 	objective_text(0, "M11_OBJ_DISTRACT_STAG", nil, nil, SYNC_LOCAL, OI_ASSET_LOCATION) 
  1356. 	objective_text(1, "M11_OBJ_DISTRACT_STAG", nil, nil, SYNC_REMOTE, OI_ASSET_LOCATION) 
  1357. 	 
  1358.  
  1359. 	-- Check if each base has been destroyed; if not, mark it 
  1360. 	for i, base in pairs(M11_groups.stag_bases) do 
  1361. 		if (not base.destroyed) then 
  1362. 			-- Set up the enter and leave regions 
  1363. 			trigger_enable(base.zone, true) 
  1364. 			on_trigger("m11_base_entered_callback", base.zone) 
  1365. 			on_trigger_exit("m11_base_left_callback", base.zone) 
  1366.  
  1367. 			-- Mark the base 
  1368. 			marker_add(base.nav, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1369. 		end 
  1370. 	end 
  1371.  
  1372. 	-- Wait until the player has destroyed the requisite number of bases 
  1373. 	while (M11_globals.num_bases_destroyed < M11_globals.num_bases_destroyed_goal) do 
  1374. 		--possibly play some lines 
  1375. 		if (M11_globals.num_bases_destroyed == 3 and M11_globals.third_base_destroyed == false) then 
  1376. 			M11_globals.third_base_destroyed = true 
  1377. 			m11_wait_for_audio() 
  1378. 			M11_globals.playing_line = true 
  1379. 			audio_play_persona_line_2d(M11_personas.kia.handle, M11_lines.after_takeoff1) 
  1380. 			delay(3) 
  1381. 			audio_play_persona_line_2d(M11_personas.stag_bm.handle, M11_lines.after_takeoff2) 
  1382. 			delay(3) 
  1383. 			M11_globals.playing_line = false 
  1384. 		end 
  1385. 		thread_yield() 
  1386. 	end 
  1387. 	 
  1388. 	-- Remove all base markers 
  1389. 	for i, base in pairs(M11_groups.stag_bases) do 
  1390. 		marker_remove(base.nav, SYNC_ALL) 
  1391. 	end 
  1392. 	 
  1393. 	objective_text_clear(0) 
  1394. 	objective_text_clear(1) 
  1395. end 
  1396.  
  1397. -- ************************* 
  1398. -- Objective: Help Convoy 
  1399. -- ************************* 
  1400.  
  1401. -- Add markers, objectives, to go to a roadblock 
  1402. function m11_help_convoy(roadblock) 
  1403.  
  1404. 	-- Pierce calls about a roadblock 
  1405. 	m11_wait_for_audio() 
  1406. 	M11_globals.playing_line = true 
  1407. 	audio_play_persona_line_2d(M11_personas.pierce.handle, M11_lines.roadblock_start) 
  1408. 		 
  1409. 	-- Spawn the roadblock 
  1410. 	m11_spawn_roadblock(roadblock) 
  1411. 	traffic_disable_lanes(M11_triggers.traffic_rb, true) 
  1412. 	 
  1413. 	-- Change the objective to the convoy 
  1414. 	objective_text(0, "M11_OBJ_HELP_CONVOY", nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1415.  
  1416. 	M11_globals.objective_reached = false 
  1417. 	trigger_enable(roadblock.location, true) 
  1418. 	on_trigger("m11_reached_callback", roadblock.location) 
  1419. 	marker_add_trigger(roadblock.location, MINIMAP_ICON_LOCATION, "", OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1420. 	waypoint_add(roadblock.location) 
  1421. 	delay(3) 
  1422. 	M11_globals.playing_line = false 
  1423. 	-- wait for roadblock group to spawn 
  1424. 	while group_is_loaded(roadblock.name) == false do 
  1425. 		thread_yield() 
  1426. 	end 
  1427.  
  1428. 	-- mark all targets invul 
  1429. 	for i, vehicle in pairs(roadblock.vehicles) do 
  1430. 		vehicle_set_invulnerable( vehicle, true ) 
  1431. 	end 
  1432.  
  1433. 	-- Wait until a player approaches the roadblock 
  1434. 	while (M11_globals.objective_reached == false) do 
  1435. 		thread_yield() 
  1436. 	end 
  1437. 	 
  1438. 	-- clear invul flag 
  1439. 	for i, vehicle in pairs(roadblock.vehicles) do 
  1440. 		vehicle_set_invulnerable( vehicle, false ) 
  1441. 	end 
  1442.  
  1443. 	trigger_enable(roadblock.location, false) 
  1444. 	on_trigger("", roadblock.location) 
  1445. 	marker_remove_trigger(roadblock.location, SYNC_ALL) 
  1446. 	waypoint_remove(SYNC_ALL) 
  1447.  
  1448. 	-- Change the objective to the roadblock 
  1449. 	objective_text_clear(0) 
  1450. 	objective_text(0, "M11_OBJ_KILL_ROADBLOCK", nil, nil, SYNC_ALL, OI_ASSET_KILL) 
  1451.  
  1452. 	-- Mark the targets 
  1453. 	for i, vehicle in pairs(roadblock.vehicles) do 
  1454. 		if vehicle_is_tank(vehicle) then 
  1455. 			marker_add(vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL) 
  1456. 		else 
  1457. 			marker_add(vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  1458. 		end 
  1459. 	end 
  1460.  
  1461. 	-- Mark the convoy as defend targets 
  1462. 	for i, vehicle in pairs(roadblock.convoy.vehicles) do 
  1463. 		marker_add(vehicle.name, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND, OI_FLAG_STICKY, SYNC_ALL) 
  1464. 	end 
  1465.  
  1466. 	-- Wait until all targets have been destroyed 
  1467. 	while (M11_globals.num_targets > 0) do 
  1468. 		thread_yield() 
  1469. 	end 
  1470.  
  1471. 	-- Remove convoy markers 
  1472. 	for i, vehicle in pairs(roadblock.convoy.vehicles) do 
  1473. 		marker_remove(vehicle.name, SYNC_ALL) 
  1474. 	end 
  1475. 	 
  1476. 	-- Start a tracking thread before waiting to release the convoy 
  1477. 	M11_threads.convoy_cleanup = thread_new("m11_convoy_cleanup_thread", roadblock) 
  1478. 	 
  1479. 	traffic_disable_lanes(M11_triggers.traffic_rb, false) 
  1480. 	roadblock.destroyed = true 
  1481. 	--M11_globals.stag_attention.value = M11_globals.stag_attention.max_value 
  1482. 	objective_text_clear(0) 
  1483. end 
  1484.  
  1485. -- Spawns and sets up a roadblock 
  1486. function m11_spawn_roadblock(roadblock) 
  1487. 	-- Spawn the roadblock 
  1488. 	if not group_is_loaded(roadblock.name) then 
  1489. 		group_create(roadblock.name, true) 
  1490. 	end 
  1491.  
  1492. 	-- Set up death callbacks 
  1493. 	M11_globals.num_targets = 0 
  1494. 	for i, vehicle in pairs(roadblock.vehicles) do 
  1495. 		on_vehicle_destroyed("m11_target_destroyed", vehicle) 
  1496. 		M11_globals.num_targets = M11_globals.num_targets + 1 
  1497. 	end 
  1498.  
  1499. 	-- Put the drivers in the tanks 
  1500. 	for i, tank in pairs(roadblock.tanks) do 
  1501. 		vehicle_enter_teleport(tank.driver, tank.name, 0) 
  1502. 		vehicle_max_speed(tank.name, 15) 
  1503. 		vehicle_disable_chase(tank.name) 
  1504. 		vehicle_disable_flee(tank.name) 
  1505. 	end 
  1506. 	 
  1507. 	-- Set up the convoy 
  1508. 	for i, vehicle in pairs(roadblock.convoy.vehicles) do 
  1509. 		-- Fail if any convoy vehicle dies 
  1510. 		on_vehicle_destroyed("m11_pre_obj_convoy_death_callback", vehicle.name) 
  1511.  
  1512. 		-- Prevent jacking 
  1513. 		set_unjackable_flag(vehicle.name, true) 
  1514. 		vehicle_suppress_npc_exit(vehicle.name, true) 
  1515.  
  1516. 		-- Put the Saints in the vehicles and prevent AI from attacking them 
  1517. 		for j, person in pairs(vehicle.passengers) do 
  1518. 			vehicle_enter_teleport(person, vehicle.name, j - 1) 
  1519. 			set_ignore_ai_flag(person, true) 
  1520. 			set_dont_attack_me_on_sight_flag(person, true) 
  1521. 			on_death("m11_pre_obj_convoy_death_callback", person) 
  1522. 		end 
  1523. 	end 
  1524.  
  1525. 	group_show(roadblock.name) 
  1526. end 
  1527.  
  1528. -- ************************* 
  1529. -- Objective: Air Base 
  1530. -- ************************* 
  1531.  
  1532. -- Spawn and setup the air base 
  1533. function m11_air_base() 
  1534. 	-- Create the group 
  1535. 	group_show(M11_groups.air_base.name) 
  1536. 	group_show(M11_groups.air_base_jumbo_plane.name) 
  1537. 	helicopter_set_dont_explode_in_air(M11_groups.air_base.final_plane.vehicle , true) 
  1538. 	helicopter_set_large_dspiral(M11_groups.air_base.final_plane.vehicle , true) 
  1539. 	helicopter_set_path_orientation(M11_groups.air_base.final_plane.vehicle, HELI_PF_PATH_PITCH) 
  1540. 	helicopter_set_max_bank_angle(M11_groups.air_base.final_plane.vehicle, 0) 
  1541. 	vehicle_prevent_vehicle_collision_damage(M11_groups.air_base.final_plane.vehicle, true) 
  1542. 	vehicle_infinite_mass(M11_groups.air_base.final_plane.vehicle, true) 
  1543. 	 
  1544. 	 
  1545. 	--we're low on high component vehicles don't spawn any for notoriety 
  1546. 	notoriety_force_no_air_spawn(true) 
  1547. 	notoriety_force_no_spawn("stag", true) 
  1548. 	 
  1549. 	-- Set up the targets 
  1550. 	M11_globals.num_transports = 0 
  1551. 	M11_globals.num_guards = 0 
  1552. 	M11_globals.final_targets_attack = false 
  1553. 	for i, target in pairs(M11_groups.air_base.targets) do 
  1554. 		vehicle_enter_teleport(target.pilot, target.vehicle, 0) 
  1555. 		M11_threads.fly_target[i] = thread_new("m11_fly_path_target_thread", target.vehicle, target.path) 
  1556. 		vehicle_set_invulnerable(target.vehicle, true) 
  1557. 	end 
  1558. 	 
  1559. 	--setup the final plane 
  1560. 	vehicle_enter_teleport(M11_groups.air_base.final_plane.pilot, M11_groups.air_base.final_plane.vehicle, 0) 
  1561. 	M11_threads.fly_final_plane = thread_new("m11_fly_path_thread", M11_groups.air_base.final_plane.vehicle, M11_groups.air_base.final_plane.path) 
  1562. 	on_vehicle_destroyed("m11_final_plane_destroyed", M11_groups.air_base.final_plane.vehicle) 
  1563. 	on_damage("m11_final_plane_destroyed", M11_groups.air_base.final_plane.vehicle, 0.1) 
  1564. 	M11_globals.final_plane_alive = true 
  1565. 	vehicle_set_invulnerable(M11_groups.air_base.final_plane.vehicle, true) 
  1566. 	 
  1567. 	M11_conv.awacs.play = false 
  1568. 	M11_conv.awacs.kill = false 
  1569. 	M11_conv.killing_escorts.play = false 
  1570. 	M11_conv.killing_escorts.kill = false 
  1571. 	M11_threads.air_base_convos = thread_new("m11_air_base_convos_thread") 
  1572. 		 
  1573. 	-- Set up the guards 
  1574. 	for i, guard in pairs(M11_groups.air_base.guards) do 
  1575. 		vehicle_enter_teleport(guard.pilot, guard.vehicle, 0) 
  1576. 		M11_threads.fly_guard[i] = thread_new("m11_fly_path_guard_thread", guard.vehicle, guard.path) 
  1577. 		vehicle_set_invulnerable(guard.vehicle, true) 
  1578. 	end 
  1579.  
  1580. 	M11_conv.awacs.play = true 
  1581. 	 
  1582. 	-- Send the player to the air base 
  1583. 	objective_text(0, "M11_OBJ_GO_AIR_BASE", nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1584. 	marker_add(M11_groups.air_base.final_plane.vehicle, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1585. 	--waypoint_add(M11_groups.air_base.final_plane.vehicle) 
  1586.  
  1587. 	-- Limit them with a timer 
  1588. 	M11_threads.stag_attention = thread_new("m11_timer_thread") 
  1589.  
  1590. 	-- Repair the player's vehicle and make it mission critical 
  1591. 	vehicle_repair(get_char_vehicle_name(LOCAL_PLAYER)) 
  1592. 	if coop_is_active() then 
  1593. 		vehicle_repair(get_char_vehicle_name(REMOTE_PLAYER)) 
  1594. 	end 
  1595. 	 
  1596. 	-- Wait for the player to arrive 
  1597. 	while (get_dist_closest_player_to_object(M11_groups.air_base.final_plane.vehicle) > 600) do 
  1598. 		thread_yield() 
  1599. 	end 
  1600. 	 
  1601. 	-- Been having a bit of problems with the callbacks in release final.  Setting up later to hopfully get better results 
  1602. 	for i, target in pairs(M11_groups.air_base.targets) do 
  1603. 		if not vehicle_is_destroyed(target.vehicle) then 
  1604. 			vehicle_set_invulnerable(target.vehicle, false) 
  1605. 			on_vehicle_destroyed("m11_transport_destroyed", target.vehicle) 
  1606. 			M11_globals.num_transports = M11_globals.num_transports + 1 
  1607. 		end 
  1608. 	end 
  1609. 	for i, guard in pairs(M11_groups.air_base.guards) do 
  1610. 		if not vehicle_is_destroyed(guard.vehicle) then 
  1611. 			vehicle_set_invulnerable(guard.vehicle, false) 
  1612. 			on_vehicle_destroyed("m11_guard_destroyed", guard.vehicle) 
  1613. 			M11_globals.num_guards = M11_globals.num_guards + 1 
  1614. 		end 
  1615. 	end 
  1616. 	on_damage("m11_final_plane_destroyed", M11_groups.air_base.final_plane.vehicle, 0.1) 
  1617. 	 
  1618. 	M11_conv.awacs.kill = true 
  1619. 	 
  1620. 	-- Decrease notoriety 
  1621. 	notoriety_set_min("police", 2) 
  1622. 	--waypoint_remove(SYNC_ALL) 
  1623. 	marker_remove(M11_groups.air_base.final_plane.vehicle) 
  1624. 	objective_text_clear(0) 
  1625.  
  1626. 	--== WAYPOINT ==-- 
  1627.  
  1628. 	objective_text(0, "M11_OBJ_KILL_AIR_BASE", nil, nil, SYNC_ALL, OI_ASSET_KILL) 
  1629.  
  1630. 	-- Mark the guards and targets 
  1631. 	for i, guard in pairs(M11_groups.air_base.guards) do 
  1632. 		marker_add(guard.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL) 
  1633. 	end 
  1634.  
  1635. 	m11_wait_for_audio() 
  1636. 	M11_globals.playing_line = true 
  1637. 	audio_play_persona_line(LOCAL_PLAYER, M11_lines.air_base) 
  1638. 	delay(3) 
  1639. 	M11_globals.playing_line = false 
  1640. 	 
  1641. 		 
  1642. 	-- End the Saints chatter and start up some STAG chatter. 
  1643. 	thread_kill(M11_threads.radio_chatter) 
  1644. 	M11_globals.playing_line = false 
  1645. 	M11_threads.radio_chatter = thread_new("m11_stag_vtol_radio_chatter_thread") 
  1646. 	 
  1647. 	delay(10) 
  1648. 	 
  1649. 	M11_conv.killing_escorts.play = true 
  1650. 	 
  1651. 	-- Wait for the guards to be destroyed 
  1652. 	while (M11_globals.num_guards > 0) do 
  1653. 		thread_yield() 
  1654. 	end 
  1655. 	 
  1656. 	vehicle_prevent_explosion_fling(M11_groups.air_base.final_plane.vehicle, true) 
  1657.  
  1658. 	objective_text_clear(0) 
  1659.  
  1660. 	--== WAYPOINT ==-- 
  1661.  
  1662. 	objective_text(0, "M11_OBJ_KILL_AIR_BASE", nil, nil, SYNC_ALL, OI_ASSET_KILL) 
  1663.  
  1664. 	M11_globals.final_targets_attack = true 
  1665. 	 
  1666. 	-- Mark the targets and attack the player 
  1667. 	for i, target in pairs(M11_groups.air_base.targets) do 
  1668. 			marker_add(target.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL) 
  1669. 			ai_add_enemy_target(target.pilot, CLOSEST_PLAYER, ATTACK_ON_SIGHT) 
  1670. 	end 
  1671. 	 
  1672. 	M11_conv.killing_escorts.kill = true 
  1673.  
  1674. 	-- Wait for the targets to be destroyed 
  1675. 	local dist = 0 
  1676. 	local player = nil 
  1677. 	while (M11_globals.num_transports > 0) do 
  1678. 		thread_yield() 
  1679. 	end 
  1680. 	 
  1681. 	-- End the STAG chatter after the guards are killed. 
  1682. 	thread_kill(M11_threads.radio_chatter) 
  1683. 	M11_globals.playing_line = false 
  1684. 	M11_threads.radio_chatter = INVALID_THREAD_HANDLE 
  1685. 	 
  1686. 	-- Mark the final plane 
  1687. 	marker_add(M11_groups.air_base.final_plane.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL) 
  1688. 	vehicle_set_invulnerable(M11_groups.air_base.final_plane.vehicle, false) 
  1689. 	 
  1690. 	while (M11_globals.final_plane_alive) do 
  1691. 		thread_yield() 
  1692. 	end 
  1693. 	 
  1694. 	audio_object_post_event( "m11_carrier_plane_dive" ) 
  1695. 	 
  1696. 	--make the plane play a specail 'on fire' effect 
  1697. 	effect_play_on_script_object("Vfx Mis11 Big Engine Fire 001", M11_groups.air_base.final_plane.vehicle, nil, true) 
  1698. 	 
  1699. 	hud_timer_stop(1) 
  1700. 	thread_kill(M11_threads.stag_attention) 
  1701. 	M11_threads.stag_attention = INVALID_THREAD_HANDLE 
  1702. 	 
  1703. 	objective_text_clear(0) 
  1704. 	M11_conv.pierce_end.handle = audio_conversation_load(M11_conv.pierce_end.name) 
  1705. 	audio_conversation_play(M11_conv.pierce_end.handle) 
  1706. 	 
  1707. 	-- Delay a short time before ending 
  1708. 	delay(6) 
  1709. end 
  1710.  
  1711. -- ************************* 
  1712. -- Objective: Help Oleg 
  1713. -- ************************* 
  1714.  
  1715. -- Spawn Oleg, and setup the big battle 
  1716. function m11_help_oleg() 
  1717. 	-- Start the Oleg battle phone call 
  1718. 	M11_conv.oleg_help.handle = audio_conversation_load(M11_conv.oleg_help.name) 
  1719. 	audio_conversation_play(M11_conv.oleg_help.handle) 
  1720.  
  1721. 	-- Set up the VTOLs 
  1722. 	group_create(M11_groups.oleg_battle.oleg_vtols.name, true) 
  1723. 	for i, vtol in pairs(M11_groups.oleg_battle.oleg_vtols.vtols) do 
  1724. 		on_vehicle_enter("m11_vtol_hijacked_callback_oleg", vtol) 
  1725. 	end 
  1726. 	 
  1727. 	-- Set up the targets 
  1728. 	group_create(M11_groups.oleg_battle.waves[1].name, true) 
  1729. 	M11_globals.num_targets = 0 
  1730. 	for i, vehicle in pairs(M11_groups.oleg_battle.waves[1].vehicles) do 
  1731. 		on_vehicle_destroyed("m11_target_destroyed", vehicle.name) 
  1732. 		M11_globals.num_targets = M11_globals.num_targets + 1 
  1733. 	end 
  1734. 	for i, npc in pairs(M11_groups.oleg_battle.waves[1].npcs) do 
  1735. 		on_death("m11_target_destroyed", npc) 
  1736. 		M11_globals.num_targets = M11_globals.num_targets + 1 
  1737. 	end 
  1738. 	 
  1739. 	--Spawn Tank Group	 
  1740. 	m11_spawn_oleg_tanks() 
  1741. 	 
  1742. 	vehicle_enter_teleport(M11_groups.oleg_battle.waves[1].npcs[1], M11_groups.oleg_battle.waves[1].vehicles[1].name, 3, false) 
  1743. 	 
  1744. 	-- Send the player to help Oleg 
  1745. 	M11_globals.objective_reached = false 
  1746. 	trigger_enable(M11_groups.oleg_battle.location, true) 
  1747. 	on_trigger("m11_reached_callback", M11_groups.oleg_battle.location) 
  1748. 	objective_text(0, "M11_OBJ_GO_OLEG", nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1749. 	marker_add(M11_groups.oleg_battle.location, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1750. 	waypoint_add(M11_groups.oleg_battle.location) 
  1751.  
  1752. 	-- Wait for the player to arrive 
  1753. 	while (M11_globals.objective_reached == false) do 
  1754. 		thread_yield() 
  1755. 	end 
  1756. 	waypoint_remove(SYNC_ALL) 
  1757. 	marker_remove(M11_groups.oleg_battle.location) 
  1758. 	trigger_enable(M11_groups.oleg_battle.location, false) 
  1759. 	on_trigger("", M11_groups.oleg_battle.location)	 
  1760.  
  1761. 	 
  1762. 	-- Change the objective to defense 
  1763. 	objective_text_clear(0) 
  1764. 	objective_text(0, "M11_OBJ_HELP_OLEG", nil, nil, SYNC_ALL, OI_ASSET_DEFEND) 
  1765.  
  1766. 	 
  1767. 	-- Add markers for the enemies 
  1768. 	for i, vehicle in pairs(M11_groups.oleg_battle.waves[1].vehicles) do 
  1769. 		if not vehicle_is_destroyed(vehicle.name) then 
  1770. 			marker_add(vehicle.name, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  1771. 			 
  1772. 		end 
  1773. 	end 
  1774. 	for i, npc in pairs(M11_groups.oleg_battle.waves[1].npcs) do 
  1775. 		if not character_is_dead(npc) then 
  1776. 			marker_add(npc, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  1777. 		end 
  1778. 		 
  1779. 	end 
  1780. 	 
  1781. 	 
  1782. 	vehicle_enter_teleport(M11_groups.oleg_battle.waves[1].npcs[1], M11_groups.oleg_battle.waves[1].vehicles[1].name, 4) 
  1783. 	 
  1784. 	 
  1785. 	--Make the tanks targets 
  1786. 	m11_tank_targets() 
  1787. 	--Deploy Tanks  oleg_tanks 
  1788. 	m11_deploy_tanks() 
  1789. 	 
  1790. 	-- Unload Oleg's persona before Oleg is loaded 
  1791. 	audio_conversation_wait_for_end(M11_conv.oleg_help.handle) 
  1792. 	M11_conv.oleg_help.handle = INVALID_CONVERSATION_HANDLE 
  1793. 	audio_persona_remove_2d(M11_personas.oleg.handle) 
  1794. 	M11_personas.oleg.handle = INVALID_PERSONA_HANDLE 
  1795.  
  1796. 	-- Create Oleg 
  1797. 	group_create(M11_groups.oleg_battle.oleg.name, true) 
  1798. 	set_max_hit_points(M11_groups.oleg_battle.oleg.oleg, 50000, true) 
  1799. 	on_death("m11_oleg_died_callback", M11_groups.oleg_battle.oleg.oleg) 
  1800. 	marker_add(M11_groups.oleg_battle.oleg.oleg, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND, OI_FLAG_STICKY + OI_FLAG_DISPLAY_DISTANCE, SYNC_ALL) 
  1801. 	 
  1802.  
  1803. 	 
  1804. 	for i, npc in pairs(M11_groups.oleg_battle.waves[1].npcs) do 
  1805. 		if not character_is_dead(npc) then 
  1806. 			ai_add_enemy_target(npc, M11_groups.oleg_battle.oleg.oleg, ATTACK_NOW, true) 
  1807. 		end 
  1808. 	end 
  1809. 	 
  1810. 	m11_tank_attack() 
  1811.  
  1812.  
  1813. 	-- This is hanging in release. commenting out until its fixed 
  1814. 	--M11_conv.oleg_arrive.handle = audio_conversation_load(M11_conv.oleg_arrive.name) 
  1815. 	--audio_conversation_play(M11_conv.oleg_arrive.handle) 
  1816. 	--audio_conversation_wait_for_end(M11_conv.oleg_arrive.handle) 
  1817. 	--M11_conv.oleg_arrive.handle = INVALID_CONVERSATION_HANDLE 
  1818. 	delay(5) 
  1819. 	m11_wait_for_audio() 
  1820. 	M11_globals.playing_line = true 
  1821. 	audio_play_persona_line(M11_groups.oleg_battle.oleg.oleg, M11_lines.fight_at_park) 
  1822. 	delay(3) 
  1823. 	M11_globals.playing_line = false 
  1824. 	 
  1825. 	-- Wait for us to win this wave 
  1826. 	while (M11_globals.num_targets > 0) do 
  1827. 		thread_yield() 
  1828. 	end 
  1829.  
  1830. 	-- Release the remnants 
  1831. 	if group_is_loaded(M11_groups.oleg_battle.waves[1].name) then 
  1832. 		release_to_world(M11_groups.oleg_battle.waves[1].name) 
  1833. 		group_destroy(M11_groups.oleg_battle.waves[1].name) 
  1834. 	end 
  1835.  
  1836. 	 
  1837. 	 
  1838. 	delay(3.0) 
  1839.  
  1840. 	-- Spawn a second wave 
  1841. 	M11_globals.num_targets = 0 
  1842. 	-- group_create(M11_groups.oleg_battle.waves[2].name, true) 
  1843. 	group_create(M11_groups.oleg_battle.waves[3].name, true) 
  1844. 	 
  1845. 	for i, vehicle in pairs (M11_groups.oleg_battle.waves[3].vehicles) do 
  1846. 		vehicle_enter_teleport(vehicle.driver, vehicle.name, 0) 
  1847. 		teleport_vehicle(vehicle.name, M11_groups.oleg_battle.nav_vtol[i]) 
  1848. 		 
  1849. 		marker_add(vehicle.name, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL) 
  1850. 		on_vehicle_destroyed("m11_target_destroyed", vehicle.name) 
  1851. 		M11_globals.num_targets = M11_globals.num_targets + 1 
  1852. 		 
  1853. 		-- Set up a move-to-and-attack thread 
  1854. 		M11_threads.battle[i] = thread_new("m11_battle_thread", vehicle, i) 
  1855. 	end 
  1856. 	 
  1857. 	-- End the Saints chatter and start up some STAG chatter. 
  1858. 	thread_kill(M11_threads.radio_chatter) 
  1859. 	M11_globals.playing_line = false 
  1860. 	M11_threads.radio_chatter = thread_new("m11_stag_vtol_radio_chatter_thread") 
  1861. 	 
  1862. 	-- Wait for us to win 
  1863. 	while (M11_globals.num_targets > 0) do 
  1864. 		thread_yield() 
  1865. 	end 
  1866.  
  1867. 	-- Clear the threads 
  1868. 	for i, th in pairs(M11_threads.battle) do 
  1869. 		if (th ~= INVALID_THREAD_HANDLE) then 
  1870. 			thread_kill(th) 
  1871. 			M11_threads.battle[i] = INVALID_THREAD_HANDLE 
  1872. 		end 
  1873. 	end 
  1874.  
  1875. 	-- Release the remnants 
  1876. 	if group_is_loaded(M11_groups.oleg_battle.waves[2].name) then 
  1877. 		release_to_world(M11_groups.oleg_battle.waves[2].name) 
  1878. 		group_destroy(M11_groups.oleg_battle.waves[2].name) 
  1879. 	end 
  1880. 	 
  1881. 	M11_conv.reinforcements.handle = audio_conversation_load(M11_conv.reinforcements.name) 
  1882. 	audio_conversation_play(M11_conv.reinforcements.handle) 
  1883. 	 
  1884. 	delay(2.0) 
  1885.  
  1886. 	objective_text_clear(0) 
  1887. 	audio_conversation_wait_for_end(M11_conv.reinforcements.handle) 
  1888. 	M11_conv.reinforcements.handle = INVALID_CONVERSATION_HANDLE 
  1889. 	 
  1890. 		-- Switch back to Saints chatter 
  1891. 	thread_kill(M11_threads.radio_chatter) 
  1892. 	M11_globals.playing_line = false 
  1893. 	M11_threads.radio_chatter = thread_new("m11_radio_chatter_thread") 
  1894. 	 
  1895. 	m11_cleanup_help_oleg() 
  1896. end 
  1897.  
  1898. function m11_cleanup_help_oleg() 
  1899. 	-- Clean up battle waves. 
  1900. 	if group_is_loaded(M11_groups.oleg_battle.waves[1].name) then 
  1901. 		for i, vehicle in pairs(M11_groups.oleg_battle.waves[1].vehicles) do 
  1902. 			on_vehicle_destroyed("", vehicle.name) 
  1903. 		end 
  1904. 		for i, npc in pairs(M11_groups.oleg_battle.waves[1].npcs) do 
  1905. 			on_death("", npc) 
  1906. 		end 
  1907. 	end 
  1908. 	 
  1909. 	if group_is_loaded(M11_groups.oleg_battle.waves[3].name) then 
  1910. 		for i, vehicle in pairs (M11_groups.oleg_battle.waves[3].vehicles) do 
  1911. 			marker_remove(vehicle.name) 
  1912. 			on_vehicle_destroyed("", vehicle.name) 
  1913. 			if M11_threads.battle[i] ~= nil then 
  1914. 				thread_kill(M11_threads.battle[i]) 
  1915. 			end 
  1916. 			M11_threads.battle[i] = INVALID_THREAD_HANDLE 
  1917. 		end 
  1918. 	end 
  1919.  
  1920. 	-- Clean up tanks. 
  1921. 	for i,group in pairs(oleg_tanks) do 
  1922. 		if group_is_loaded(group.name) then 
  1923. 			marker_remove(group.vehicle) 
  1924. 			on_vehicle_destroyed("", group.vehicle) 
  1925. 			if group.move_thread ~= nil then 
  1926. 				thread_kill(group.move_thread) 
  1927. 			end 
  1928. 			group.move_thread = INVALID_THREAD_HANDLE 
  1929. 		end 
  1930. 	end 
  1931. 	 
  1932. 	on_death("", M11_groups.oleg_battle.oleg.oleg) 
  1933. 	marker_remove(M11_groups.oleg_battle.oleg.oleg) 
  1934. end 
  1935.  
  1936.  
  1937. -- *************************************************** 
  1938. -- Miscellaneous m11 Helper Functions 
  1939. -- *************************************************** 
  1940.  
  1941. function m11_cell_convo_finished() 
  1942. 	M11_globals.cell_call_finished = true 
  1943. end 
  1944.  
  1945. function m11_play_cell_convo(conv_name, receiving_call, persona_override_id) 
  1946. 	while M11_globals.cell_call_finished == false do 
  1947. 		thread_yield() 
  1948. 	end 
  1949. 	M11_globals.cell_call_finished = false 
  1950. 	audio_play_for_mission_cellphone(conv_name, receiving_call, true, "", "m11_cell_convo_finished", persona_override_id) 
  1951. 	M11_globals.cur_cell_call = conv_name 
  1952. 	while M11_globals.cell_call_finished == false do 
  1953. 		thread_yield() 
  1954. 	end 
  1955. 	M11_globals.cur_cell_call = "" 
  1956. end 
  1957.  
  1958. -- Add the GSI meter 
  1959. --function m11_setup_stag_attention() 
  1960. --	hud_bar_on(1, "annoyance", "", M11_globals.stag_attention.max_value, SYNC_ALL) 
  1961. -- 
  1962. --	-- Reset the variables pertaining to stag_attention 
  1963. --	M11_globals.stag_attention.first_warning = false 
  1964. --	M11_globals.stag_attention.second_warning = false 
  1965. --	M11_globals.stag_attention.third_warning = false 
  1966. -- 
  1967. --	M11_threads.stag_attention = thread_new("m11_process_stag_attention_thread") 
  1968. --end 
  1969.  
  1970. -- Remove the GSI meter 
  1971. --function m11_remove_stag_attention() 
  1972. --	hud_bar_off(1) 
  1973. -- 
  1974. --	if (M11_threads.stag_attention ~= nil) then 
  1975. --		thread_kill(M11_threads.stag_attention) 
  1976. --	end 
  1977. --	M11_threads.stag_attention = nil 
  1978. --end 
  1979.  
  1980. -- Check if all targets in the STAG base have been destroyed, and update the base if so 
  1981. function m11_check_base_destroyed(base) 
  1982. 	-- Only check bases that have not yet been destroyed 
  1983. 	if ((base == nil) or base.destroyed) then 
  1984. 		return 
  1985. 	end 
  1986.  
  1987. 	-- Check the battle boxes 
  1988. 	for i, box in pairs(base.boxes) do 
  1989. 		if not box.destroyed then 
  1990. 			-- There is a surviving target 
  1991. 			return 
  1992. 		end 
  1993. 	end 
  1994.  
  1995. 	-- All targets have been destroyed 
  1996. 	base.destroyed = true 
  1997. 	--M11_globals.stag_attention.value = M11_globals.stag_attention.max_value 
  1998. 	M11_globals.num_bases_destroyed = M11_globals.num_bases_destroyed + 1 
  1999.  
  2000. 	-- Remove the stream-in trigger, but leave the stream-out 
  2001. 	-- NOTE: This is because releasing them as ambient causes them to immediately despawn due to distance, so for now they must remain script NPCs 
  2002. 	on_trigger("", base.location) 
  2003.  
  2004. 	-- Remove the base marker and zone callbacks 
  2005. 	trigger_enable(base.zone, true) 
  2006. 	on_trigger("", base.zone) 
  2007. 	on_trigger_exit("", base.zone) 
  2008. 	marker_remove(base.nav, SYNC_ALL) 
  2009. 	 
  2010. 	-- Release the ground vehicles so the player can drive them off. 
  2011. 	if base.vehicle_group ~= nil and group_is_loaded(base.vehicle_group) then 
  2012. 		release_to_world(base.vehicle_group) 
  2013. 		group_destroy(base.vehicle_group) 
  2014. 	end 
  2015.  
  2016. 	-- Despawn the base 
  2017. 	if (group_is_loaded(base.name)) then 
  2018. 		release_to_world(base.name) 
  2019. 		group_destroy(base.name) 
  2020. 	end 
  2021.  
  2022. 	-- Skip the rest if not hunting bases 
  2023. 	if (M11_globals.num_bases_destroyed >= M11_globals.num_bases_destroyed_goal) then 
  2024. 		return 
  2025. 	end 
  2026.  
  2027. 	-- Figure out which players are in this base 
  2028. 	local sync = nil 
  2029. 	if coop_is_active() then 
  2030. 		if object_is_in_trigger(base.zone, REMOTE_PLAYER) then 
  2031. 			if object_is_in_trigger(base.zone, LOCAL_PLAYER) then 
  2032. 				sync = SYNC_ALL 
  2033. 			else 
  2034. 				sync = SYNC_REMOTE 
  2035. 			end 
  2036. 		elseif object_is_in_trigger(base.zone, LOCAL_PLAYER) then 
  2037. 			sync = SYNC_LOCAL 
  2038. 		end 
  2039. 	elseif object_is_in_trigger(base.zone, LOCAL_PLAYER) then 
  2040. 		sync = SYNC_ALL 
  2041. 	end 
  2042.  
  2043. 	-- Update the objective accordingly 
  2044. 	if (sync == SYNC_ALL or sync == SYNC_LOCAL) then 
  2045. 		objective_text_clear(0) 
  2046. 		objective_text(0, "M11_OBJ_DISTRACT_STAG", nil, nil, SYNC_LOCAL, OI_ASSET_LOCATION) 
  2047.  
  2048. 		-- Restore all base markers 
  2049. 		for i, base in pairs(M11_groups.stag_bases) do 
  2050. 			if (not base.destroyed) then 
  2051. 				marker_add(base.nav, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_LOCAL) 
  2052. 			end 
  2053. 		end 
  2054. 	end 
  2055. 	if coop_is_active() then 
  2056. 		if (sync == SYNC_ALL or sync == SYNC_REMOTE) then 
  2057. 			objective_text_clear(1) 
  2058. 			objective_text(1, "M11_OBJ_DISTRACT_STAG", nil, nil, SYNC_REMOTE, OI_ASSET_LOCATION) 
  2059.  
  2060. 			-- Restore all base markers 
  2061. 			for i, base in pairs(M11_groups.stag_bases) do 
  2062. 				if (not base.destroyed) then 
  2063. 					marker_add(base.nav, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_REMOTE) 
  2064. 				end 
  2065. 			end 
  2066. 		end 
  2067. 	end 
  2068. end 
  2069.  
  2070. -- ************************* 
  2071. -- 
  2072. -- Callback functions 
  2073. -- 
  2074. -- ************************* 
  2075.  
  2076. -- Called when the player reaches their objective 
  2077. function m11_reached_callback(player_name, trigger_name) 
  2078. 	M11_globals.objective_reached = true 
  2079. end 
  2080.  
  2081. -- Vehicle Callback: Called when a vehicle in the Convoy is destroyed before the objective is completed 
  2082. function m11_pre_obj_convoy_death_callback(victim_name) 
  2083. 	mission_end_failure("m11", "m11_fail_convoy") 
  2084. end 
  2085.  
  2086. -- Vehicle Callback: Called when a vehicle in the Convoy is destroyed after the objective is completed 
  2087. function m11_post_obj_convoy_death_callback(victim_name, attacker_name) 
  2088. 	if (attacker_name == LOCAL_PLAYER or attacker_name == REMOTE_PLAYER) then 
  2089. 		mission_end_failure("m11", "m11_fail_convoy") 
  2090. 	end 
  2091. end 
  2092.  
  2093. -- NPC Callback: Called if Oleg is killed, ending the mission 
  2094. function m11_oleg_died_callback() 
  2095. 	mission_end_failure("m11", "m11_fail_oleg") 
  2096. end 
  2097.  
  2098. -- Fail if the timer runs out 
  2099. function m11_fail_timer() 
  2100. 	mission_end_failure("m11", "m11_fail_stag") 
  2101. end 
  2102.  
  2103. -- ************************* 
  2104. -- VTOL Callbacks 
  2105. -- ************************* 
  2106.  
  2107. -- Called when the player enters a VTOL 
  2108. function m11_vtol_hijacked_callback1(player_name, vehicle_name, seat_index) 
  2109. 	M11_globals.vtol_hijacked = true 
  2110.  
  2111. 	marker_remove(vehicle_name, SYNC_ALL) 
  2112. 	on_vehicle_destroyed("", vehicle_name) 
  2113. 	on_vehicle_enter("", vehicle_name) 
  2114. 	--release_to_world(vehicle_name) 
  2115. 	--don't release, mark the group as don't destroy so we can track the players vehicle 
  2116. 	M11_groups.stag_bases[1].vtols.save = true 
  2117. end 
  2118.  
  2119. function m11_vtol_hijacked_callback2(player_name, vehicle_name, seat_index) 
  2120. 	M11_globals.vtol_hijacked = true 
  2121.  
  2122. 	marker_remove(vehicle_name, SYNC_ALL) 
  2123. 	on_vehicle_destroyed("", vehicle_name) 
  2124. 	on_vehicle_enter("", vehicle_name) 
  2125. 	--release_to_world(vehicle_name) 
  2126. 	--don't release, mark the group as don't destroy so we can track the players vehicle 
  2127. 	M11_groups.stag_bases[2].vtols.save = true 
  2128. end 
  2129.  
  2130. function m11_vtol_hijacked_callback3(player_name, vehicle_name, seat_index) 
  2131. 	M11_globals.vtol_hijacked = true 
  2132.  
  2133. 	marker_remove(vehicle_name, SYNC_ALL) 
  2134. 	on_vehicle_destroyed("", vehicle_name) 
  2135. 	on_vehicle_enter("", vehicle_name) 
  2136. 	--release_to_world(vehicle_name) 
  2137. 	--don't release, mark the group as don't destroy so we can track the players vehicle 
  2138. 	M11_groups.stag_bases[3].vtols.save = true 
  2139. end 
  2140.  
  2141. function m11_vtol_hijacked_callback4(player_name, vehicle_name, seat_index) 
  2142. 	M11_globals.vtol_hijacked = true 
  2143.  
  2144. 	marker_remove(vehicle_name, SYNC_ALL) 
  2145. 	on_vehicle_destroyed("", vehicle_name) 
  2146. 	on_vehicle_enter("", vehicle_name) 
  2147. 	--release_to_world(vehicle_name) 
  2148. 	--don't release, mark the group as don't destroy so we can track the players vehicle 
  2149. 	M11_groups.stag_bases[4].vtols.save = true 
  2150. end 
  2151.  
  2152. function m11_vtol_hijacked_callback_oleg(player_name, vehicle_name, seat_index) 
  2153. 	M11_globals.vtol_hijacked = true 
  2154.  
  2155. 	marker_remove(vehicle_name, SYNC_ALL) 
  2156. 	on_vehicle_destroyed("", vehicle_name) 
  2157. 	on_vehicle_enter("", vehicle_name) 
  2158. 	--release_to_world(vehicle_name) 
  2159. 	--don't release, mark the group as don't destroy so we can track the players vehicle 
  2160. 	M11_groups.oleg_battle.oleg_vtols.save = true 
  2161. end 
  2162.  
  2163.  
  2164. -- Called when a VTOL is destroyed in STAG base 1 
  2165. function m11_vtol_destroyed_callback(vtol) 
  2166. 	marker_remove(vtol, SYNC_ALL) 
  2167. 	on_vehicle_destroyed("", vtol) 
  2168. 	on_vehicle_enter_water("", vtol) 
  2169. 	on_vehicle_enter("", vtol) 
  2170.  
  2171. 	-- Check if both VTOLs are destroyed 
  2172. 	for i, vtol in pairs(M11_groups.stag_bases[1].vtols.vehicles) do 
  2173. 		if (vehicle_exists(vtol) and not vehicle_is_destroyed(vtol) and not vehicle_in_water(vtol)) then 
  2174. 			return 
  2175. 		end 
  2176. 	end 
  2177.  
  2178. 	-- Progress the mission if they destroy both VTOLs 
  2179. 	M11_globals.vtol_hijacked = true 
  2180. end 
  2181.  
  2182. -- ************************* 
  2183. -- STAG Base Callbacks 
  2184. -- ************************* 
  2185.  
  2186. -- Called when the player nears one of the STAG bases 
  2187. function m11_base_spawn_callback(player_name, trigger_name) 
  2188. 	-- Find which base it is 
  2189. 	local base_entered = nil 
  2190. 	local base_num = nil 
  2191. 	for i, base in pairs(M11_groups.stag_bases) do 
  2192. 		if (trigger_name == base.location) then 
  2193. 			-- This is the base we reached 
  2194. 			base_entered = base 
  2195. 			base_num = i 
  2196. 		end 
  2197. 	end 
  2198.  
  2199. 	-- Skip if this base has already been destroyed 
  2200. 	if base_entered.destroyed then 
  2201. 		return 
  2202. 	end 
  2203. 	 
  2204. 	-- Spawn the ground vehicles they will be released rather than destroyed 
  2205. 	-- when the player exits the base so they can drive them off.  As such 
  2206. 	-- we only want to spawn them once. 
  2207. 	if base_entered.vehicle_group ~= nil then 
  2208. 		if base_entered.vehicles_created == false then 
  2209. 			base_entered.vehicles_created = true 
  2210. 			group_create(base_entered.vehicle_group, true) 
  2211. 		end 
  2212. 	end 
  2213.  
  2214. 	-- Spawn the base (if not already spawned) 
  2215. 	if (not group_is_loaded(base_entered.name)) then 
  2216. 		group_create(base_entered.name, true) 
  2217. 	end 
  2218. 	if (not group_is_loaded(base_entered.vtols.name)) then 
  2219. 		group_create(base_entered.vtols.name, true) 
  2220.  
  2221. 		-- Set up the VTOL hijack callback 
  2222. 		for i, vtol in pairs(base_entered.vtols.vehicles) do 
  2223. 			if(base_num == 1) then 
  2224. 				on_vehicle_enter("m11_vtol_hijacked_callback1", vtol) 
  2225. 			elseif (base_num == 2) then 
  2226. 				on_vehicle_enter("m11_vtol_hijacked_callback2", vtol) 
  2227. 			elseif (base_num == 3) then 
  2228. 				on_vehicle_enter("m11_vtol_hijacked_callback3", vtol) 
  2229. 			else 
  2230. 				on_vehicle_enter("m11_vtol_hijacked_callback4", vtol) 
  2231. 			end 
  2232. 		end 
  2233. 	end 
  2234. end 
  2235.  
  2236. -- Called when the player gets too far from one of the STAG bases 
  2237. function m11_base_despawn_callback(player_name, trigger_name) 
  2238. 	-- Find which base it is 
  2239. 	local base_left = nil 
  2240. 	for i, base in pairs(M11_groups.stag_bases) do 
  2241. 		if (trigger_name == base.location) then 
  2242. 			-- This is the base we reached 
  2243. 			base_left = base 
  2244. 		end 
  2245. 	end 
  2246.  
  2247. 	-- Skip if another player is still in the base 
  2248. 	if (object_is_in_trigger(trigger_name, LOCAL_PLAYER) or (coop_is_active() and object_is_in_trigger(trigger_name, REMOTE_PLAYER))) then 
  2249. 		return 
  2250. 	end 
  2251. 	 
  2252. 	-- Release the ground vehicles so the player can drive them off. 
  2253. 	if base_left.vehicle_group ~= nil and group_is_loaded(base_left.vehicle_group) then 
  2254. 		release_to_world(base_left.vehicle_group) 
  2255. 		group_destroy(base_left.vehicle_group) 
  2256. 	end 
  2257.  
  2258. 	-- Despawn the base 
  2259. 	if (group_is_loaded(base_left.name)) then 
  2260. 		group_destroy(base_left.name) 
  2261. 	end 
  2262. 	if (group_is_loaded(base_left.vtols.name)) then 
  2263. 		-- Remove the VTOL hijack callback 
  2264. 		for i, vtol in pairs(base_left.vtols.vehicles) do 
  2265. 			on_vehicle_enter("", vtol) 
  2266. 		end 
  2267. 		if (base_left.vtols.save == false) then 
  2268. 			group_destroy(base_left.vtols.name) 
  2269. 		end 
  2270. 	end 
  2271. end 
  2272.  
  2273. -- Called when the player enters one of the STAG bases 
  2274. function m11_base_entered_callback(player_name, trigger_name) 
  2275. 	-- Find which base it is 
  2276. 	local base_entered = nil 
  2277. 	for i, base in pairs(M11_groups.stag_bases) do 
  2278. 		if (trigger_name == base.zone) then 
  2279. 			-- This is the base we reached 
  2280. 			base_entered = base 
  2281. 			break 
  2282. 		end 
  2283. 	end 
  2284.  
  2285. 	-- Skip if this base has already been destroyed, or if not currently hunting bases 
  2286. 	if base_entered.destroyed or (M11_globals.num_bases_destroyed >= M11_globals.num_bases_destroyed_goal) then 
  2287. 		return 
  2288. 	end 
  2289.  
  2290. 	-- Was this the local or remote player 
  2291. 	local sync = SYNC_LOCAL 
  2292. 	local tag_num = 0 
  2293. 	if (coop_is_active() and (player_name == REMOTE_PLAYER)) then 
  2294. 		sync = SYNC_REMOTE 
  2295. 		tag_num = 1 
  2296. 	end 
  2297.  
  2298. 	-- Remove all base markers 
  2299. 	for i, base in pairs(M11_groups.stag_bases) do 
  2300. 		marker_remove(base.nav, sync) 
  2301. 	end 
  2302.  
  2303. 	-- Change the objective 
  2304. 	objective_text_clear(tag_num) 
  2305. 	objective_text(tag_num, "M11_OBJ_DESTROY_STAG", nil, nil, sync, OI_ASSET_KILL) 
  2306.  
  2307. 	-- Enable and mark the battle boxes 
  2308. 	for i, box in pairs(base_entered.boxes) do 
  2309. 		if not box.destroyed then 
  2310. 			mesh_mover_set_invulnerable(box.name, false) 
  2311. 			marker_add(box.name, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, sync) 
  2312. 		end 
  2313. 	end 
  2314. end 
  2315.  
  2316. -- Called when the player exits one of the STAG bases 
  2317. function m11_base_left_callback(player_name, trigger_name) 
  2318. 	-- Find which base it is 
  2319. 	local base_left = nil 
  2320. 	for i, base in pairs(M11_groups.stag_bases) do 
  2321. 		if (trigger_name == base.zone) then 
  2322. 			-- This is the base we reached 
  2323. 			base_left = base 
  2324. 			break 
  2325. 		end 
  2326. 	end 
  2327.  
  2328. 	-- Was this the local or remote player 
  2329. 	local sync = SYNC_LOCAL 
  2330. 	local tag_num = 0 
  2331. 	if (coop_is_active() and (player_name == REMOTE_PLAYER)) then 
  2332. 		sync = SYNC_REMOTE 
  2333. 		tag_num = 1 
  2334. 	end 
  2335. 	 
  2336. 	-- Is the other player still inside the trigger? 
  2337. 	local other_player_inside = false 
  2338. 	if coop_is_active() then 
  2339. 		if player_name == LOCAL_PLAYER then 
  2340. 			other_player_inside = object_is_in_trigger(trigger_name, REMOTE_PLAYER) 
  2341. 		else 
  2342. 			other_player_inside = object_is_in_trigger(trigger_name, LOCAL_PLAYER) 
  2343. 		end 
  2344. 	end 
  2345.  
  2346. 	-- Disable the battle boxes 
  2347. 	for i, box in pairs(base_left.boxes) do 
  2348. 		marker_remove(box.name, sync) 
  2349.  
  2350. 		if not other_player_inside and not box.destroyed then 
  2351. 			mesh_mover_set_invulnerable(box.name, true) 
  2352. 		end 
  2353. 	end 
  2354.  
  2355. 	-- Skip the rest if not currently hunting bases 
  2356. 	if (M11_globals.num_bases_destroyed >= M11_globals.num_bases_destroyed_goal) then 
  2357. 		return 
  2358. 	end 
  2359.  
  2360. 	-- Restore all base markers 
  2361. 	for i, base in pairs(M11_groups.stag_bases) do 
  2362. 		if (not base.destroyed) then 
  2363. 			marker_add(base.nav, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, sync) 
  2364. 		end 
  2365. 	end 
  2366.  
  2367. 	-- Change the objective 
  2368. 	objective_text_clear(tag_num) 
  2369. 	objective_text(tag_num, "M11_OBJ_DISTRACT_STAG", nil, nil, sync, OI_ASSET_LOCATION) 
  2370. end 
  2371.  
  2372. -- Called when the player first nears the airport STAG base 
  2373. function m11_airport_spawn_callback(player_name, trigger_name) 
  2374. 	on_trigger("", M11_groups.stag_bases[2].script.trigger) 
  2375.  
  2376. 	-- Spawn the script and set up a thread for each of the pilots 
  2377. 	group_create(M11_groups.stag_bases[2].script.name, true) 
  2378. 	M11_threads.pilots[1] = thread_new("m11_airport_lift_thread", M11_groups.stag_bases[2].script.vehicles[1]) 
  2379. 	M11_threads.pilots[2] = thread_new("m11_airport_lift_thread", M11_groups.stag_bases[2].script.vehicles[2]) 
  2380. 	M11_threads.pilots[3] = thread_new("m11_airport_land_thread", M11_groups.stag_bases[2].script.vehicles[3]) 
  2381. end 
  2382.  
  2383. -- ************************* 
  2384. -- Target Callbacks 
  2385. -- ************************* 
  2386.  
  2387. -- Called when one of the STAG targets at a base is destroyed 
  2388. function m11_box_destroyed(box_name) 
  2389. 	-- Add STAG attention 
  2390. 	--M11_globals.stag_attention.value = M11_globals.stag_attention.value + M11_globals.stag_attention.target_value 
  2391. 	--if (M11_globals.stag_attention.value > M11_globals.stag_attention.max_value) then 
  2392. 	--	M11_globals.stag_attention.value = M11_globals.stag_attention.max_value 
  2393. 	--end 
  2394. 	--hud_bar_set_value(1, M11_globals.stag_attention.value) 
  2395.  
  2396. 	-- Remove the marker and callback 
  2397. 	marker_remove(box_name, SYNC_ALL) 
  2398. 	on_mover_destroyed("", box_name) 
  2399.  
  2400. 	-- Find the base this mover belonged to 
  2401. 	local base_in = nil 
  2402. 	for i, base in pairs(M11_groups.stag_bases) do 
  2403. 		if base.destroyed == false and base_in == nil then 
  2404. 			for j, box in pairs(base.boxes) do 
  2405. 				if box_name == box.name then 
  2406. 					box.destroyed = true 
  2407. 					base_in = base 
  2408. 					break 
  2409. 				end 
  2410. 			end 
  2411. 		end 
  2412. 	end 
  2413.  
  2414. 	-- Check if the base has now been destroyed 
  2415. 	m11_check_base_destroyed(base_in) 
  2416. end 
  2417.  
  2418. -- Called when one of the STAG air guards is destroyed 
  2419. function m11_guard_destroyed(guard_name) 
  2420. 	M11_globals.num_guards = M11_globals.num_guards - 1 
  2421. 	marker_remove(guard_name, SYNC_ALL) 
  2422. 	on_vehicle_destroyed("", guard_name) 
  2423. end 
  2424.  
  2425. -- Called when one of the STAG targets at a roadblock is destroyed 
  2426. function m11_target_destroyed(target_name) 
  2427. 	M11_globals.num_targets = M11_globals.num_targets - 1 
  2428.  
  2429. 	-- Update STAG attention 
  2430. 	--M11_globals.stag_attention.value = M11_globals.stag_attention.value + M11_globals.stag_attention.target_value 
  2431. 	--if (M11_globals.stag_attention.value > M11_globals.stag_attention.max_value) then 
  2432. 	--	M11_globals.stag_attention.value = M11_globals.stag_attention.max_value 
  2433. 	--end 
  2434. 	--hud_bar_set_value(1, M11_globals.stag_attention.value) 
  2435.  
  2436. 	marker_remove(target_name, SYNC_ALL) 
  2437. 	if (is_a_vehicle(target_name)) then 
  2438. 		on_vehicle_destroyed("", target_name) 
  2439. 	else 
  2440. 		on_death("", target_name) 
  2441. 	end 
  2442. end 
  2443.  
  2444. -- Called when one of the VTOL Tansports is destroyed 
  2445. function m11_transport_destroyed(target_name) 
  2446. 	M11_globals.num_transports = M11_globals.num_transports - 1 
  2447.  
  2448. 	marker_remove(target_name, SYNC_ALL) 
  2449. 	on_vehicle_destroyed("", target_name) 
  2450. end 
  2451.  
  2452. function m11_final_plane_destroyed(plane_name) 
  2453. 	M11_globals.final_plane_alive = false 
  2454. 	marker_remove(plane_name, SYNC_ALL) 
  2455. 	on_vehicle_destroyed("", plane_name) 
  2456. 	on_damage("", plane_name) 
  2457. end 
  2458.  
  2459. function m11_wait_for_audio() 
  2460. 	while (audio_any_conversation_playing() or M11_globals.playing_line) do 
  2461. 		delay(2) 
  2462. 	end 
  2463. end 
  2464.  
  2465. -- ************************* 
  2466. -- 
  2467. -- Thread functions 
  2468. -- 
  2469. -- ************************* 
  2470.  
  2471. -- Wrapper function for calling thread functions.  Any function that begins with the mission name 
  2472. -- will automatically have their thread killed when the mission ends in case we forget to clean it up. 
  2473. -- 
  2474. function m11_wrapper_thread(function_ref, ...) 
  2475. 	function_ref(unpack(arg)) 
  2476. end 
  2477.  
  2478. function m11_intro_convos_thread() 
  2479. 	-- make sure we are initialized 
  2480. 	M11_globals.cell_call_finished = true 
  2481. 	 
  2482. 	-- Start the Oleg phone call 
  2483. 	m11_play_cell_convo(M11_conv.start.name, true) 
  2484. 	 
  2485. 	delay(12.0) 
  2486.  
  2487. 	-- Once the conversation is finished, play the next one 
  2488. 	m11_play_cell_convo(M11_conv.pack.name, true) 
  2489. end 
  2490.  
  2491. function m11_stag_vtol_radio_chatter_thread() 
  2492. 	-- Loop until we kill the thread. 
  2493. 	while true do 
  2494. 		-- Pick a random STAG persona to play the line. 
  2495. 		local persona = get_random_table_entry(M11_stag_personas) 
  2496. 		 
  2497. 		m11_wait_for_audio() 
  2498. 			 
  2499. 		-- Say one of the VTOL lines. 
  2500. 		M11_globals.playing_line = true 
  2501. 		audio_play_persona_line_2d(persona.handle, M11_lines.stag_chatter) 
  2502. 		delay(3) 
  2503. 		M11_globals.playing_line = false 
  2504. 		 
  2505. 		delay(rand_int(20, 30)) 
  2506. 	end 
  2507. end 
  2508.  
  2509. function m11_radio_chatter_thread() 
  2510. 	while true do 
  2511. 		local delay_time = rand_int(25, 35) 
  2512. 		delay(delay_time) 
  2513. 		local in_vehicle = character_is_in_vehicle(LOCAL_PLAYER) 
  2514. 		if(coop_is_active() and not in_vehicle) then 
  2515. 			in_vehicle = character_is_in_vehicle(REMOTE_PLAYER) 
  2516. 		end 
  2517. 		if(in_vehicle) then 
  2518. 			--select a line to play 
  2519. 			local starting_line = rand_int(1, M11_lines.random_lines.num_lines) 
  2520. 			local play_line 
  2521. 			for i=0,M11_lines.random_lines.num_lines - 1 do 
  2522. 				play_line = starting_line + i 
  2523. 				if (play_line > M11_lines.random_lines.num_lines) then 
  2524. 					play_line = play_line - M11_lines.random_lines.num_lines 
  2525. 				end 
  2526. 				if (M11_lines.random_lines.lines[play_line].played == false) then 
  2527. 					break 
  2528. 				end 
  2529. 			end 
  2530. 			--now we've selected a random line that hasn't yet been played 
  2531. 			m11_wait_for_audio() 
  2532. 			M11_globals.playing_line = true 
  2533. 			audio_play_persona_line_2d(M11_lines.random_lines.lines[play_line].persona.handle, M11_lines.random_lines.lines[play_line].name) 
  2534. 			delay(3) 
  2535. 			M11_globals.playing_line = false 
  2536. 			M11_lines.random_lines.lines[play_line].played = true 
  2537. 			M11_lines.random_lines.num_played = M11_lines.random_lines.num_played + 1 
  2538. 			if(M11_lines.random_lines.num_played >= M11_lines.random_lines.num_lines) then 
  2539. 				m11_clear_rand_lines() 
  2540. 			end 
  2541. 		end 
  2542. 	end 
  2543.  
  2544. end 
  2545.  
  2546. function m11_clear_rand_lines() 
  2547. 	for i=1,M11_lines.random_lines.num_lines do 
  2548. 		M11_lines.random_lines.lines[i].played = false 
  2549. 	end 
  2550. 	M11_lines.random_lines.num_played = 0 
  2551. end 
  2552.  
  2553. function m11_player_vtol_tracking_thread(player) 
  2554.  
  2555. 	local below_50 = false 
  2556. 	local below_15 = false 
  2557. 	while true do 
  2558. 		local player_vehicle = get_char_vehicle_name(player) 
  2559. 		if (player_vehicle ~= nil and player_vehicle ~= "") then 
  2560. 			if (get_vehicle_type(player_vehicle) == 4) then --4 = SSVT_VTOL 
  2561. 				--if (vehicle_is_vtol(player_vehicle)) then 
  2562. 				 
  2563. 					-- health tracking 
  2564. 					local current_health = get_current_hit_points(player_vehicle) 
  2565. 					local max_health = get_max_hit_points(player_vehicle) 
  2566. 					local pct = current_health/max_health 
  2567. 					if(pct > 0.50) then 
  2568. 						below_50 = false 
  2569. 						below_15 = false 
  2570. 					elseif((pct > 0.15) and (below_50 == false)) then 
  2571. 						below_50 = true 
  2572. 						below_15 = false 
  2573. 						--play line 
  2574. 						m11_wait_for_audio() 
  2575. 						M11_globals.playing_line = true 
  2576. 						audio_play_persona_line(player, M11_lines.vtol_damaged) 
  2577. 						delay(3) 
  2578. 						M11_globals.playing_line = false 
  2579. 					elseif (below_15 == false) then 
  2580. 						below_50 = true 
  2581. 						below_15 = true 
  2582. 						--play line 
  2583. 						m11_wait_for_audio() 
  2584. 						M11_globals.playing_line = true 
  2585. 						audio_play_persona_line(player, M11_lines.vtol_very_damaged) 
  2586. 						delay(3) 
  2587. 						M11_globals.playing_line = false 
  2588. 					end 
  2589. 					 
  2590. 					--vtol mode tracking 
  2591. 					if (player == LOCAL_PLAYER) then 
  2592. 						if(vehicle_is_vtol_jet(player_vehicle) and M11_globals.local_vtol_jet == false) then 
  2593. 							M11_globals.local_vtol_jet = true 
  2594. 							m11_wait_for_audio() 
  2595. 							M11_globals.playing_line = true 
  2596. 							audio_play_persona_line(player, M11_lines.jet_mode) 
  2597. 							delay(3) 
  2598. 							M11_globals.playing_line = false 
  2599. 							--play line 
  2600. 						elseif(vehicle_is_vtol_hover(player_vehicle) and M11_globals.local_vtol_jet == true and M11_globals.local_vtol_hover == false) then 
  2601. 							M11_globals.local_vtol_hover = true 
  2602. 							m11_wait_for_audio() 
  2603. 							M11_globals.playing_line = true 
  2604. 							audio_play_persona_line(player, M11_lines.vtols_are_cool) 
  2605. 							delay(3) 
  2606. 							M11_globals.playing_line = false 
  2607. 							--play line 
  2608. 						end 
  2609. 					else  
  2610. 						if(vehicle_is_vtol_jet(player_vehicle) and M11_globals.remote_vtol_jet == false) then 
  2611. 							M11_globals.remote_vtol_jet = true 
  2612. 							m11_wait_for_audio() 
  2613. 							M11_globals.playing_line = true 
  2614. 							audio_play_persona_line(player, M11_lines.jet_mode) 
  2615. 							delay(3) 
  2616. 							M11_globals.playing_line = false 
  2617. 							--play line 
  2618. 						elseif(vehicle_is_vtol_hover(player_vehicle) and M11_globals.remote_vtol_jet == true and M11_globals.remote_vtol_hover == false) then 
  2619. 							M11_globals.remote_vtol_hover = true 
  2620. 							m11_wait_for_audio() 
  2621. 							M11_globals.playing_line = true 
  2622. 							audio_play_persona_line(player, M11_lines.vtols_are_cool) 
  2623. 							delay(3) 
  2624. 							M11_globals.playing_line = false 
  2625. 							--play line 
  2626. 						end 
  2627. 					end 
  2628. 				--end 
  2629. 			end 
  2630. 		end 
  2631. 		delay(2) 
  2632. 	end 
  2633. end 
  2634.  
  2635. -- Trigger Pierce's warning line when appropriate 
  2636. function m11_timer_thread() 
  2637. 	-- Start the countdown 
  2638. 	hud_timer_set(1, M11_globals.air_base_time, "m11_fail_timer", SYNC_ALL) 
  2639.  
  2640. 	local played = false 
  2641. 	while not played do 
  2642. 		if (hud_timer_get_remainder(1) < M11_globals.warn_time) then 
  2643. 			M11_conv.kill_plane.handle = audio_conversation_load(M11_conv.kill_plane.name) 
  2644. 			audio_conversation_play(M11_conv.kill_plane.handle) 
  2645. 			played = true 
  2646. 		end 
  2647. 		thread_yield() 
  2648. 	end 
  2649. end 
  2650.  
  2651.  
  2652. -- Process decrementing the attention meter, and trigger Pierce's lines when appropriate 
  2653. --function m11_process_stag_attention_thread() 
  2654. --	while true do 
  2655. --		delay(M11_globals.stag_attention.diminish_rate) 
  2656. --		M11_globals.stag_attention.value = M11_globals.stag_attention.value - M11_globals.stag_attention.diminish_value 
  2657. --		hud_bar_set_value(1, M11_globals.stag_attention.value) 
  2658. -- 
  2659. --		-- Only play the warnings exactly at the marks 
  2660. --		if (M11_globals.stag_attention.value < 0.75 and M11_globals.stag_attention.value >= 0.74 and M11_globals.stag_attention.first_warning == false) then 
  2661. --			-- Play Pierce's 75% complaint 
  2662. --			audio_play_persona_line_2d(M11_personas.pierce.handle, "M11_STAG_Attention_01") 
  2663. --			M11_globals.stag_attention.first_warning = true 
  2664. --		elseif (M11_globals.stag_attention.value < 0.5 and M11_globals.stag_attention.value >= 0.49 and M11_globals.stag_attention.second_warning == false) then 
  2665. --			-- Play Pierce's 50% complaint 
  2666. --			audio_play_persona_line_2d(M11_personas.pierce.handle, "M11_STAG_Attention_02") 
  2667. --			M11_globals.stag_attention.second_warning = true 
  2668. --		elseif (M11_globals.stag_attention.value < 0.25 and M11_globals.stag_attention.third_warning == false) then 
  2669. --			-- TODO: Play Pierce's 25% complaint 
  2670. --			audio_play_persona_line_2d(M11_personas.pierce.handle, "M11_STAG_Attention_01") 
  2671. --			M11_globals.stag_attention.third_warning = true 
  2672. --		elseif (M11_globals.stag_attention.value < 0.01) then 
  2673. --			-- The player has failed 
  2674. --			mission_end_failure("m11", "m11_fail_stag") 
  2675. --		end 
  2676. --	end 
  2677. --end 
  2678.  
  2679. -- Take off to a given location 
  2680. -- 
  2681. -- lifter:	(table) table containing a vtol, pilot, and destination navpoint 
  2682. -- 
  2683. function m11_airport_lift_thread(lifter) 
  2684. 	-- Wait for a player to get close 
  2685. 	while (get_dist_closest_player_to_object(lifter.pilot) > 200) do 
  2686. 		thread_yield() 
  2687. 	end 
  2688.  
  2689. 	-- Send the pilot running to the VTOL 
  2690. 	vehicle_enter_teleport(lifter.pilot, lifter.name, 0, true) 
  2691. 	-- TODO: No vehicle animations for VTOL, so this doesn't work, yet 
  2692. 	--vehicle_enter(lifter.pilot, lifter.name, 0, true, true) 
  2693.  
  2694. 	-- Lift off! 
  2695. 	helicopter_fly_to_direct(lifter.name, 10.0, lifter.nav) 
  2696.  
  2697. 	-- Once the destination is reached, attack the player 
  2698. 	vehicle_chase(lifter.name, CLOSEST_PLAYER, false) 
  2699. end 
  2700.  
  2701. -- Land at a given location 
  2702. -- 
  2703. -- lander:	(table) table containing a vtol, pilot, and landing navpoints 
  2704. -- 
  2705. function m11_airport_land_thread(lander) 
  2706. 	-- Warp the pilot in and start the VTOL on its way 
  2707. 	vehicle_enter_teleport(lander.pilot, lander.name, 0) 
  2708. 	helicopter_fly_to_direct_dont_stop(lander.name, 25.0, lander.nav[1]) 
  2709.  
  2710. 	-- Once the destination is reached, land 
  2711. 	helicopter_land(lander.name, lander.nav[2]) 
  2712. 	delay(10) 
  2713.  
  2714. 	-- Release the VTOL, now that its script is done 
  2715. 	release_to_world(lander.name) 
  2716. 	release_to_world(lander.pilot) 
  2717. end 
  2718.  
  2719. -- Drive to the specified point and perform a new action 
  2720. -- 
  2721. -- vehicle:	(table) contains the name of the vehicle to move and its occupants 
  2722. -- index:	(int) index of the navpoint to move to, also used for following action 
  2723. -- 
  2724. function m11_battle_thread(vehicle, index) 
  2725. 	if (vehicle_is_vtol(vehicle.name)) then 
  2726. 	 	-- Start aiming at player 
  2727. 		ai_add_enemy_target(vehicle.driver, CLOSEST_PLAYER, ATTACK_NOW, true) 
  2728. 		vehicle_chase(vehicle.name, CLOSEST_PLAYER) 
  2729. 		 
  2730. 	-- 	-- Path to the player 
  2731. 	-- vehicle_pathfind_to(vehicle.name, M11_groups.oleg_battle.dest[index], false, true) 
  2732. 	--	while not vehicle_pathfind_check_done(vehicle.name) do 
  2733. 	-- 	thread_yield() 
  2734. 	-- end 
  2735. 	else 
  2736. 		-- Focus on Oleg to provide threat 
  2737. 		-- Chase Oleg (via navmesh; no traffic splines in his area) 
  2738. 		vehicle_pathfind_to(vehicle.name, M11_groups.oleg_battle.dest[index], true, false) 
  2739. 		while not vehicle_pathfind_check_done(vehicle.name) do 
  2740. 			thread_yield() 
  2741. 		end 
  2742. 		vehicle_disable_chase(vehicle.name) 
  2743. 		vehicle_exit_group(vehicle.members) 
  2744. 		for i, npc in pairs (vehicle.members) do 
  2745. 			ai_add_enemy_target(npc, M11_groups.oleg_battle.oleg.oleg, ATTACK_NOW_NEVER_LOSE, true) 
  2746. 		end 
  2747. 		--vehicle_chase(vehicle.name, M11_groups.oleg_battle.oleg.oleg, false, false, true, false) 
  2748. 	end 
  2749. end 
  2750.  
  2751.  
  2752. function m11_spawn_oleg_tanks() 
  2753. 	for i,group in pairs(oleg_tanks) do 
  2754. 		if group_is_loaded(group.name) == false then 
  2755. 			group_create(group.name, true) 
  2756. 		end 
  2757. 		vehicle_enter_group_teleport(group.members, group.vehicle) 
  2758. 		--Mark tanks add to required kill group 
  2759. 		--marker_add(group.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAG_STICKY) 
  2760. 		--on_vehicle_destroyed("m11_target_destroyed", group.vehicle) 
  2761. 		--M11_globals.num_targets = M11_globals.num_targets + 1 
  2762. 	end 
  2763.  
  2764. end 
  2765.  
  2766. -- Send tanks to their destinations 
  2767. -- 
  2768. function m11_deploy_tanks() 
  2769. 	for i,group in pairs(oleg_tanks) do 
  2770. 		if not vehicle_is_destroyed(group.vehicle) then 
  2771. 			group.move_thread = thread_new( "m11_wrapper_thread", vehicle_pathfind_to, group.vehicle, group.dest, true ) 
  2772. 			--vehicle_pathfind_to(group.vehicle, group.dest, use_navmesh, stop_at_goal, force_path, suppress_errors)  
  2773. 		end 
  2774. 	end 
  2775. end 
  2776.  
  2777. function m11_tank_targets() 
  2778. 	for i,group in pairs(oleg_tanks) do 
  2779. 		if not vehicle_is_destroyed(group.vehicle) then 
  2780. 			--ai_add_enemy_target(group.driver, M11_groups.oleg_battle.oleg.oleg, ATTACK_NOW_NEVER_LOSE, true) 
  2781. 			--Mark tanks add to required kill group 
  2782. 			marker_add(group.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAG_STICKY) 
  2783. 			on_vehicle_destroyed("m11_target_destroyed", group.vehicle) 
  2784. 			M11_globals.num_targets = M11_globals.num_targets + 1 
  2785. 		end 
  2786. 	end 
  2787. end 
  2788.  
  2789. function m11_tank_attack() 
  2790. 	for i,group in pairs(oleg_tanks) do 
  2791. 		ai_add_enemy_target(group.members[1], M11_groups.oleg_battle.oleg.oleg, ATTACK_NOW_NEVER_LOSE, true) 
  2792. 		ai_add_enemy_target(group.members[1], M11_groups.oleg_battle.oleg.oleg, ATTACK_NOW_NEVER_LOSE, true) 
  2793. 		ai_add_enemy_target(group.members[1], M11_groups.oleg_battle.oleg.oleg, ATTACK_NOW_NEVER_LOSE, true) 
  2794. 	end 
  2795. end 
  2796.  
  2797.  
  2798.  
  2799. -- Fly a helicopter along the specified path 
  2800. -- 
  2801. -- heli:		(string) name of the helicotper to move 
  2802. -- nav:		(string) name of the path to move along 
  2803. -- 
  2804. function m11_fly_path_thread(heli, path) 
  2805. 	-- Force the heli to keep following the path 
  2806. 	while (true) do 
  2807. 		helicopter_fly_to_direct_dont_stop(heli, 25.0, path) 
  2808. 		thread_yield() 
  2809. 	end 
  2810. end 
  2811.  
  2812. -- Fly a helicopter along the specified path, but chase nearby players 
  2813. -- 
  2814. -- heli:		(string) name of the helicotper to move 
  2815. -- nav:		(string) name of the path to move along 
  2816. -- 
  2817. function m11_fly_path_guard_thread(heli, path) 
  2818. 	local abort = false 
  2819. 	local dist = 0 
  2820. 	local player = nil 
  2821.  
  2822. 	-- Send it on a path 
  2823. 	helicopter_fly_to_do(heli, 25.0, true, "", true, path, 0.0, false) 
  2824.  
  2825. 	while not abort do 
  2826. 		-- If the player approaches, break off and attack 
  2827. 		dist, player = get_dist_closest_player_to_object(heli) 
  2828. 		if (dist < 500) then 
  2829. 			vehicle_chase(heli, player, false, false) 
  2830. 			abort = true 
  2831. 		--elseif vehicle_pathfind_check_done(heli) then 
  2832. 		--	-- If the path is finished, send it on the same path again 
  2833. 		--	helicopter_fly_to_do(heli, 25.0, true, "", true, path, 0.0, false) 
  2834. 		end 
  2835.  
  2836. 		thread_yield() 
  2837. 	end 
  2838. end 
  2839.  
  2840. function m11_fly_path_target_thread(heli, path) 
  2841. 	local abort = false 
  2842. 	local dist = 0 
  2843. 	local player = nil 
  2844.  
  2845. 	-- Send it on a path 
  2846. 	helicopter_fly_to_do(heli, 25.0, true, "", true, path, 0.0, false) 
  2847.  
  2848. 	while not M11_globals.final_targets_attack do 
  2849. 		thread_yield() 
  2850. 	end 
  2851. 	 
  2852. 	while not abort do 
  2853. 		-- If the player approaches, break off and attack 
  2854. 		dist, player = get_dist_closest_player_to_object(heli) 
  2855. 		if (dist < 500) then 
  2856. 			vehicle_chase(heli, player, false, false) 
  2857. 			abort = true 
  2858. 		--elseif vehicle_pathfind_check_done(heli) then 
  2859. 		--	-- If the path is finished, send it on the same path again 
  2860. 		--	helicopter_fly_to_do(heli, 25.0, true, "", true, path, 0.0, false) 
  2861. 		end 
  2862.  
  2863. 		thread_yield() 
  2864. 	end 
  2865. end 
  2866.  
  2867. function m11_convoy_cleanup_thread(roadblock) 
  2868. 	-- Set up the convoy 
  2869. 	for i, vehicle in pairs(roadblock.convoy.vehicles) do 
  2870. 		-- Now we should fail only if the players kill the convoy 
  2871. 		on_vehicle_destroyed("m11_post_obj_convoy_death_callback", vehicle.name) 
  2872.  
  2873. 		for j, person in pairs(vehicle.passengers) do 
  2874. 			on_death("m11_post_obj_convoy_death_callback", person) 
  2875. 		end 
  2876. 	end 
  2877.  
  2878. 	local abort = false 
  2879. 	local dist = 0 
  2880. 	local player = nil 
  2881. 	 
  2882. 	while not abort do 
  2883. 		-- When the player gets a good distance away, release the convoy to the world. 
  2884. 		dist, player = get_dist_closest_player_to_object(roadblock.location) 
  2885. 		if (dist > 500) then 
  2886. 			-- Release the remnants 
  2887. 			if group_is_loaded(roadblock.name) then 
  2888. 				release_to_world(roadblock.name) 
  2889. 				group_destroy(roadblock.name) 
  2890. 			end 
  2891. 			abort = true 
  2892. 		end 
  2893. 		 
  2894. 		thread_yield() 
  2895. 	end 
  2896. end 
  2897.  
  2898. -- Thead the convos for the air base because they tend to get stuck 
  2899. function m11_air_base_convos_thread() 
  2900.  
  2901. 	M11_conv.awacs.handle = audio_conversation_load(M11_conv.awacs.name) 
  2902. 	while not M11_conv.awacs.play do 
  2903. 		thread_yield() 
  2904. 	end 
  2905. 	 
  2906. 	audio_conversation_play(M11_conv.awacs.handle) 
  2907. 	delay(1.0) 
  2908. 	 
  2909. 	-- emergency kill if needed 
  2910. 	local convo_over = false 
  2911. 	while not convo_over do 
  2912. 		if not audio_conversation_playing(M11_conv.awacs.handle) then 
  2913. 			convo_over = true 
  2914. 		end 
  2915. 		if M11_conv.awacs.kill then 
  2916. 			convo_over = true 
  2917. 		end 
  2918. 		thread_yield() 
  2919. 	end 
  2920. 	audio_conversation_end(M11_conv.awacs.handle)	 
  2921. 	M11_conv.awacs.handle = INVALID_CONVERSATION_HANDLE 
  2922. 	 
  2923. 	 
  2924. 	M11_conv.killing_escorts.handle = audio_conversation_load(M11_conv.killing_escorts.name) 
  2925. 	while not M11_conv.killing_escorts.play do 
  2926. 		thread_yield() 
  2927. 	end 
  2928. 	 
  2929. 	audio_conversation_play(M11_conv.killing_escorts.handle) 
  2930. 	delay(1.0) 
  2931. 	 
  2932. 	-- emergency kill if needed 
  2933. 	convo_over = false 
  2934. 	while not convo_over do 
  2935. 		if not audio_conversation_playing(M11_conv.killing_escorts.handle) then 
  2936. 			convo_over = true 
  2937. 		end 
  2938. 		if M11_conv.killing_escorts.kill then 
  2939. 			convo_over = true 
  2940. 		end 
  2941. 		thread_yield() 
  2942. 	end 
  2943. 	audio_conversation_end(M11_conv.killing_escorts.handle)	 
  2944. 	M11_conv.killing_escorts.handle = INVALID_CONVERSATION_HANDLE 
  2945. 	 
  2946. end 
  2947.  
  2948.  
  2949.