./m03.lua

  1.  
  2. --[[ 
  3. 	m03.lua 
  4. 	SR3 Mission Script 
  5. 	DATE: 5/18/10 
  6. 	AUTHOR:	Nick Heilmann 
  7. ]]-- 
  8.  
  9. M03_DEBUG = { 
  10. 	infinity = 999999999, 
  11. 	large_cash_sum = 100, 
  12. 	message_handle = INVALID_MESSAGE_HANDLE, 
  13. } 
  14.  
  15. M03_cte = { 
  16. 	name = "m03_cte_01", 
  17. } 
  18. 	 
  19. M03_status = { 
  20. 	convo_is_playing = false, 
  21. 	item_purchased = false, 
  22. 	warehouse_objective = false, 
  23. 	satellite_timer_elapsed = false, 
  24. 	helis_destroyed = 0, 
  25. 	fly_home_played = false, 
  26. } 
  27.  
  28. M03_weapon = { 
  29. 	satellite_drone_weapon = "Special-Drone", 
  30. 	helicopter_ride = "Rifle-Gang", 
  31.  
  32. 	cleanup = { "Rifle-Gang", "Special-Drone" }, 
  33. } 
  34.  
  35. M03_start_inventory = { 
  36. 	{ 
  37. 		name = "Pistol-Gang", 
  38. 		reserve_ammo = 16, 
  39. 	}, 
  40. 	{ 
  41. 		name = "SMG-Gang", 
  42. 		reserve_ammo = 39, 
  43. 	}, 
  44. } 
  45.  
  46. M03_navpoint = { 
  47. 	heli_landing_pos = "Nav Heli Landing Pos", 
  48. 	shaundi_house = "Nav Shaundi House", 
  49. 	heli_blow_up = "Nav Blow Up", 
  50. 	end_local = "Nav End Local Player", 
  51. 	end_remote = "Nav End Remote Player", 
  52. } 
  53.  
  54. M03_FlytoPoint = { "Flyto Point 001", "Flyto Point 002", "Flyto Point 003", "Flyto Point 004", 
  55. 					"Flyto Point 005", "Flyto Point 006" } 
  56.  
  57. M03_scripted_path = { 
  58. 	fly_home_pierce = { "Fly Home Pierce 001", "Fly Home Pierce 002", "Fly Home Pierce 003", "Fly Home Pierce 004" }, 
  59. 	fly_home_bomb = { "Fly Home Bomb 001", "Fly Home Bomb 002", "Fly Home Bomb 003", "Fly Home Bomb 004"}, 
  60. 	fly_home_backup = { "Fly Home Backup 001", "Fly Home Backup 002", "Fly Home Backup 003", "Fly Home Backup 004" }, 
  61. 	fly_home_enemy1 = { "Fly Home Enemy1 001", "Fly Home Enemy1 002", "Fly Home Enemy1 003", "Fly Home Enemy1 004" }, 
  62. 	fly_home_enemy2 = { "Fly Home Enemy2 001", "Fly Home Enemy2 002", "Fly Home Enemy2 003", "Fly Home Enemy2 004" }, 
  63. 	fly_home_enemy3 = { "Fly Home Enemy3 001", "Fly Home Enemy3 002", "Fly Home Enemy3 003", "Fly Home Enemy3 004" }, 
  64. 	fly_home_enemy4 = { "Fly Home Enemy4 001", "Fly Home Enemy4 002", "Fly Home Enemy4 003", "Fly Home Enemy4 004" }, 
  65. 	fly_home_enemy5 = { "Fly Home Enemy5 002", "Fly Home Enemy5 003", "Fly Home Enemy5 004" }, 
  66. 	fly_home_enemy6 = { "Fly Home Enemy6 002", "Fly Home Enemy6 003", "Fly Home Enemy6 004" }, 
  67. 	fly_home_enemy7 = { "Fly Home Enemy7 003", "Fly Home Enemy7 004" }, 
  68. 	fly_home_enemy8 = { "Fly Home Enemy8 003", "Fly Home Enemy8 004" }, 
  69. 	fly_home_enemy9 = { "Fly Home Enemy9 004" }, 
  70. 	fly_home_enemy10 = { "Fly Home Enemy10 004" }, 
  71. 	fly_home_secondary_enemies = { "Fly Home SE 001", "Fly Home SE 002" },  
  72. } 
  73.  
  74. M03_trigger = { 
  75. 	weapon_store = { 
  76. 		name = "Trigger Weapon Store", 
  77. 		triggered = false 
  78. 	}, 
  79. 	 
  80. 	weapon_store2 = { 
  81. 		name = "Trigger Weapon Store2", 
  82. 		triggered = false 
  83. 	}, 
  84. 	 
  85. 	armory_entrance = { 
  86. 		name = "Trigger Armory Entrance", 
  87. 		triggered = false 
  88. 	}, 
  89. 	 
  90. 	armory_warehouse = { 
  91. 		name = "Trigger Armory Warehouse", 
  92. 		triggered = false 
  93. 	}, 
  94. 	 
  95. 	armory_warehouse_door = { 
  96. 		name = "Trigger Warehouse Door", 
  97. 		triggered = false 
  98. 	}, 
  99. 	 
  100. 	armory_warehouse_inside = { 
  101. 		name = "Trigger Warehouse Inside", 
  102. 		triggered = false 
  103. 	}, 
  104. 	 
  105. 	weapons_cache = { 
  106. 		name = "Trigger Weapons Cache", 
  107. 		triggered = false 
  108. 	}, 
  109. 	 
  110. 	satellite_weapon = { 
  111. 		name = "Trigger Satellite Weapon", 
  112. 		triggered = false 
  113. 	}, 
  114. 	 
  115. 	enter_heli = { 
  116. 		name = "Enter_Heli_trigger", 
  117. 		triggered = false 
  118. 	}, 
  119. 	 
  120. 	fly_home_secondary_enemies = { 
  121. 		name = "Trigger Fly Home SE", 
  122. 		triggered = false 
  123. 	}, 
  124. 	 
  125. 	blow_up_helis = { 
  126. 		name = "Trigger Blow Up Helis", 
  127. 		triggered = false 
  128. 	}, 
  129. 	 
  130. 	callout1 = { 
  131. 		name = "Trigger Callout 1", 
  132. 		triggered = false 
  133. 	}, 
  134. 	callout2 = { 
  135. 		name = "Trigger Callout 2", 
  136. 		triggered = false 
  137. 	}, 
  138. 	callout3 = { 
  139. 		name = "Trigger Callout 3", 
  140. 		triggered = false 
  141. 	}, 
  142. 	callout4 = { 
  143. 		name = "Trigger Callout 4", 
  144. 		triggered = false 
  145. 	}, 
  146. 	traffic = { 
  147. 		name = "Trigger Traffic", 
  148. 		triggered = false 
  149. 	}, 
  150. 	traffic1 = { 
  151. 		name = "Trigger Traffic<001>", 
  152. 		triggered = false 
  153. 	}, 
  154. } 
  155.  
  156. M03_char = { 
  157. 	shaundi = "NPC Shaundi", 
  158. 	pierce = "NPC Pierce", 
  159. 	fly_home_enemies = { 
  160. 		{ "NPC Fly Home Enemy 001", "NPC Fly Home Enemy 002" }, 
  161. 		{ "NPC Fly Home Enemy 003", "NPC Fly Home Enemy 004" }, 
  162. 		{ "NPC Fly Home Enemy 005", "NPC Fly Home Enemy 006" }, 
  163. 		{ "NPC Fly Home Enemy 007", "NPC Fly Home Enemy 008" }, 
  164. 		{ "NPC Fly Home Enemy 009", "NPC Fly Home Enemy 010" }, 
  165. 		{ "NPC Fly Home Enemy 011", "NPC Fly Home Enemy 012" }, 
  166. 		{ "NPC Fly Home Enemy 013", "NPC Fly Home Enemy 014" }, 
  167. 		{ "NPC Fly Home Enemy 015", "NPC Fly Home Enemy 016" }, 
  168. 		{ "NPC Fly Home Enemy 017", "NPC Fly Home Enemy 018" }, 
  169. 		{ "NPC Fly Home Enemy 019", "NPC Fly Home Enemy 020" }, 
  170. 	}, 
  171. 	fly_home_secondary_enemies = { 
  172. 		{ "NPC Fly Home Secondary Enemy 001", "NPC Fly Home Secondary Enemy 002" },  
  173. 		{ "NPC Fly Home Secondary Enemy 003", "NPC Fly Home Secondary Enemy 004" },  
  174. 	}, 
  175. } 
  176.  
  177. M03_vehicle = { 
  178. 	fly_home_enemies = { "Veh Fly Home Enemy 001", "Veh Fly Home Enemy 002", "Veh Fly Home Enemy 003", "Veh Fly Home Enemy 004", 
  179. 						 "Veh Fly Home Enemy 005", "Veh Fly Home Enemy 006", "Veh Fly Home Enemy 007", "Veh Fly Home Enemy 008", 
  180. 						 "Veh Fly Home Enemy 009", "Veh Fly Home Enemy 010" }, 
  181. 	fly_home_secondary_enemies = { "Veh Fly Home Secondary Enemy 001", "Veh Fly Home Secondary Enemy 002" }, 
  182. } 
  183.  
  184. M03_item = { 
  185. 	satellite_weapon = "Item Satellite Weapon", 
  186. } 
  187.  
  188. M03_group = { 
  189. 	shaundi = {  
  190. 		name = "GRP Shaundi",  
  191. 		chars = { M03_char.shaundi }  
  192. 	}, 
  193. 	 
  194. 	starting_vehicle = {  
  195. 		name = "GRP Starting Veh", 
  196. 		vehicle = "Veh Starting Veh"  
  197. 	}, 
  198. 	 
  199. 	vehicle_get_the_goods = {  
  200. 		name = "GRP Get The Goods Veh"	 
  201. 	}, 
  202. 	 
  203. 	guns = { 
  204. 		name = "Guns_group" 
  205. 	}, 
  206. 	 
  207. 	armory_guards = {  
  208. 		name = "GRP Armory Guards", 
  209. 		-- group A 
  210. 		group_a_members = { "group_a_guard<001>", "group_a_guard<002>", "group_a_guard<003>", 
  211. 							"group_a_guard<004>", "group_a_guard<005>", "group_a_guard<006>" }, 
  212. 		group_a_navs = { "group_a_nav<001>", "group_a_nav<002>", "group_a_nav<003>" }, 
  213. 		 
  214. 		-- group B 
  215. 		group_b_members = { "group_b_guard<001>", --"group_b_guard<002>", --"group_b_guard<003>", 
  216. 							"group_b_guard<004>", --"group_b_guard<005>", "group_b_guard<006>", 
  217. 							"group_b_guard<007>", "group_b_guard<008>" }, 
  218. 		group_b_navs = { "group_b_nav<001>", --"group_b_nav<002>", "group_b_nav<003>", 
  219. 						 "group_b_nav<004>", "group_b_nav<005>", "group_b_nav<006>"}, 
  220. 						-- "group_b_nav<007>", --[["group_b_nav<008>"]]-- }, 
  221. 						  
  222. 		-- group C 
  223. 		group_c_members = { "group_c_guard<001>", "group_c_guard<002>", --"group_c_guard<003>", 
  224. 							-- too many "group_c_guard<004>",  
  225. 							"group_c_guard<005>", "group_c_guard<006>", 
  226. 							--"group_c_guard<007>",  
  227. 							-- too many "group_c_guard<008>"  
  228. 							}, 
  229. 		group_c_navs = { "group_c_nav<001>",-- "group_c_nav<002>",  
  230. 						 "group_c_nav<003>", 
  231. 						 "group_c_nav<004>",  
  232. 						 "group_c_nav<005>", --"group_c_nav<006>", 
  233. 						 --"group_c_nav<007>",  
  234. 						 --"group_c_nav<008>"  
  235. 						 }, 
  236. 	}, 
  237. 	 
  238. 	warehouse_cover_vehicles = {  
  239. 		name = "GRP Warehouse Cover Vehicles"  
  240. 	}, 
  241. 	 
  242. 	the_army = { 
  243. 		name = "GRP The Army", 
  244. 		squad1 = { 
  245. 			members = { "Squad1<001>", "Squad1<002>", "Squad1<003>", }, -- "Squad1<004>", }, 
  246. 			dest = "Squad1_dest", 
  247. 			thread = INVALID_THREAD_HANDLE 
  248. 		}, 
  249. 		 
  250. 		squad2 = { 
  251. 			members = { "Squad2<001>", "Squad2<002>", "Squad2<003>", }, -- "Squad2<004>", }, 
  252. 			dest = "Squad2_dest", 
  253. 			thread = INVALID_THREAD_HANDLE 
  254. 		}, 
  255. 		 
  256. 		squad3 = { 
  257. 			members = { "Squad3<001>", "Squad3<002>", "Squad3<003>", }, -- "Squad3<004>", }, 
  258. 			dest = "Squad3_dest", 
  259. 			thread = INVALID_THREAD_HANDLE 
  260. 		}, 
  261. 		 
  262. 		squad4 = { 
  263. 			members = { "Squad4<001>", "Squad4<002>", "Squad4<003>", }, -- "Squad4<004>", }, 
  264. 			dest = "Squad4_dest", 
  265. 			thread = INVALID_THREAD_HANDLE 
  266. 		}, 
  267. 		 
  268. 		squad5 = { 
  269. 			members = { "Squad5<001>", "Squad5<002>", "Squad5<003>", }, -- "Squad5<004>", }, 
  270. 			dest = "Squad5_dest", 
  271. 			thread = INVALID_THREAD_HANDLE 
  272. 		}, 
  273. 		 
  274. 		squad6 = { 
  275. 			members = { "Squad6<001>", "Squad6<002>", "Squad6<003>", }, -- "Squad6<004>", }, 
  276. 			dest = "Squad6_dest", 
  277. 			thread = INVALID_THREAD_HANDLE 
  278. 		}, 
  279. 	}, 
  280. 	 
  281. 	tank1 = { 
  282. 		name = "Tank1_group", 
  283. 		vehicle = "Tank1_tank", 
  284. 		members = { "Tank1_guard<001>", "Tank1_guard<002>" }, 
  285. 		dest = "Tank1_path", 
  286. 		move_thread = INVALID_THREAD_HANDLE, 
  287. 		delay_gunner_thread = INVALID_THREAD_HANDLE 
  288. 	}, 
  289. 	 
  290. 	tank2 = { 
  291. 		name = "Tank2_group", 
  292. 		vehicle = "Tank2_tank", 
  293. 		members = { "Tank2_guard<001>", "Tank2_guard<002>" }, 
  294. 		dest = "Tank2_path", 
  295. 		move_thread = INVALID_THREAD_HANDLE, 
  296. 		delay_gunner_thread = INVALID_THREAD_HANDLE 
  297. 	}, 
  298. 	 
  299. 	tank3 = { 
  300. 		name = "Tank3_group", 
  301. 		vehicle = "Tank3_tank", 
  302. 		members = { "Tank3_guard<001>", "Tank3_guard<002>" }, 
  303. 		dest = "Tank3_path", 
  304. 		move_thread = INVALID_THREAD_HANDLE, 
  305. 		delay_gunner_thread = INVALID_THREAD_HANDLE 
  306. 	}, 
  307. 	 
  308. 	satellite_weapon = {  
  309. 		name = "GRP Item Satellite Weapon",  
  310. 		items = { M03_item.satellite_weapon }  
  311. 	}, 
  312. 	 
  313. 	satellite_attack1 = { 
  314. 		name = "GRP CS Satellite Attack 001", 
  315. 		members = { "NPC Satellite Attack 001", "NPC Satellite Attack 002" }, 
  316. 		vehicle = "Veh Satellite Attack 001", 
  317. 		dest = "APC_path01", 
  318. 		thread = INVALID_THREAD_HANDLE 
  319. 	}, 
  320. 	 
  321. 	satellite_attack2 = { 
  322. 		name = "GRP CS Satellite Attack 002", 
  323. 		members = { "NPC Satellite Attack 003", "NPC Satellite Attack 004" }, 
  324. 		vehicle = "Veh Satellite Attack 002", 
  325. 		dest = "APC_path02", 
  326. 		thread = INVALID_THREAD_HANDLE 
  327. 	}, 
  328. 	 
  329. 	satellite_attack3 = { 
  330. 		name = "GRP CS Satellite Attack 003", 
  331. 		members = { "NPC Satellite Attack 005", "NPC Satellite Attack 006" }, 
  332. 		vehicle = "Veh Satellite Attack 003", 
  333. 		dest = "APC_path03", 
  334. 		thread = INVALID_THREAD_HANDLE 
  335. 	}, 
  336. 	 
  337. 	satellite_attack4 = { 
  338. 		name = "GRP CS Satellite Attack 004", 
  339. 		members = { "NPC Satellite Attack 007", "NPC Satellite Attack 008" }, 
  340. 		vehicle = "Veh Satellite Attack 004", 
  341. 		dest = "APC_path04", 
  342. 		thread = INVALID_THREAD_HANDLE 
  343. 	}, 
  344. 	 
  345. 	satellite_attack5 = { 
  346. 		name = "GRP CS Satellite Attack 005", 
  347. 		members = { "NPC Satellite Attack 009", "NPC Satellite Attack 010" }, 
  348. 		vehicle = "Veh Satellite Attack 005", 
  349. 		dest = "APC_path05", 
  350. 		thread = INVALID_THREAD_HANDLE 
  351. 	}, 
  352. 	 
  353. 	satellite_attack6 = { 
  354. 		name = "GRP CS Satellite Attack 006", 
  355. 		members = { "NPC Satellite Attack 011", "NPC Satellite Attack 012" }, 
  356. 		vehicle = "Veh Satellite Attack 006", 
  357. 		dest = "APC_path06", 
  358. 		thread = INVALID_THREAD_HANDLE 
  359. 	}, 
  360. 	 
  361. 	satellite_attack7 = { 
  362. 		name = "GRP CS Satellite Attack 007", 
  363. 		members = { "NPC Satellite Attack 013", "NPC Satellite Attack 014" }, 
  364. 		vehicle = "Veh Satellite Attack 007", 
  365. 		dest = "APC_path07", 
  366. 		thread = INVALID_THREAD_HANDLE 
  367. 	}, 
  368. 	 
  369. 	satellite_attack8 = { 
  370. 		name = "GRP CS Satellite Attack 008", 
  371. 		members = { "NPC Satellite Attack 015", "NPC Satellite Attack 016" }, 
  372. 		vehicle = "Veh Satellite Attack 008", 
  373. 		dest = "APC_path08", 
  374. 		thread = INVALID_THREAD_HANDLE 
  375. 	}, 
  376. 	 
  377. 	satellite_attack9 = { 
  378. 		name = "GRP CS Satellite Attack 009", 
  379. 		members = { "NPC Satellite Attack 017", "NPC Satellite Attack 018" }, 
  380. 		vehicle = "Veh Satellite Attack 009", 
  381. 		dest = "APC_path09", 
  382. 		thread = INVALID_THREAD_HANDLE 
  383. 	}, 
  384. 	 
  385. 	satellite_attack10 = { 
  386. 		name = "GRP CS Satellite Attack 010", 
  387. 		members = { "NPC Satellite Attack 019", "NPC Satellite Attack 020" }, 
  388. 		vehicle = "Veh Satellite Attack 010", 
  389. 		dest = "APC_path10", 
  390. 		thread = INVALID_THREAD_HANDLE 
  391. 	}, 
  392. 	 
  393. 	target_practice = { 
  394. 		name = "GRP Target Practice", 
  395. 		members = { "npc_NG_target 001", "npc_NG_target 002", "npc_NG_target 003",  
  396. 					"npc_NG_target 004", "npc_NG_target 005", "npc_NG_target 006", 
  397. 					"npc_NG_target 007", "npc_NG_target 008", "npc_NG_target 009" }, 
  398. 		vehicles = { "veh_NG_target 001", "veh_NG_target 002", "veh_NG_target 003" }, 
  399. 	}, 
  400. 	 
  401. 	choppers = {  
  402. 		name = "GRP Choppers", 
  403. 		pierce = { 
  404. 			vehicle = "Veh Chopper Pierce Normal",	-- NOTE: not actually in the group 
  405. 			pilots = { "NPC Pierce" },  --[[, "NPC Pierce Copilot"]]-- 
  406. 			float_nav = "Nav Heli Float Pos Pierce", 
  407. 			thread = INVALID_THREAD_HANDLE 
  408. 		}, 
  409. 		 
  410. 		bomb = { 
  411. 			vehicle = "Veh Chopper Bomb", 
  412. 			pilots = { "NPC Bomb Pilot 001" },--[[, "NPC Bomb Pilot 002"]]--  
  413. 			float_nav = "Nav Heli Float Pos Bomb", 
  414. 			pickup_nav = { "Bomb_pickup<001>", "Bomb_pickup<002>" }, 
  415. 			thread = INVALID_THREAD_HANDLE 
  416. 		}, 
  417. 		 
  418. 		backup = { 
  419. 			vehicle = "Veh Chopper Backup", 
  420. 			pilots = { "NPC Backup Pilot 001", "NPC Backup Pilot 002" }, 
  421. 			float_nav = "Nav Heli Float Pos Backup", 
  422. 			thread = INVALID_THREAD_HANDLE 
  423. 		}, 
  424. 	}, 
  425. 	 
  426. 	chopper_pierce_normal = {  
  427. 		name = "GRP Chopper Pierce Normal",  
  428. 		vehicles = { "Veh Chopper Pierce Normal" }  
  429. 	}, 
  430. 	 
  431. 	fly_home_enemies = {  
  432. 		name = "GRP Fly Home Enemies",  
  433. 		chars = M03_char.fly_home_enemies,  
  434. 		vehicles = M03_vehicle.fly_home_enemies  
  435. 	}, 
  436. 	 
  437. 	fly_home_secondary_enemies = {  
  438. 		name = "GRP Fly Home Secondary Enemies",  
  439. 		chars = M03_char.fly_home_secondary_enemies,  
  440. 		vehicles = M03_vehicle.fly_home_secondary_enemies  
  441. 	}, 
  442. 	 
  443. 	cte_shaundi_group = { 
  444. 		name = "m3_cte_shaundi_01", 
  445. 	}, 
  446. 	 
  447. 	cte_soldier_group = { 
  448. 		name = "m3_cte_soldiers_01", 
  449. 	}, 
  450. 	 
  451. 	cte_apc_group = { 
  452. 		name = "m3_cte_apcs_01", 
  453. 	}, 
  454. 	 
  455. 	initial_guard = { 
  456. 		name = "GRP Initial Guard", 
  457. 		members = { "npc_InitialGuard1", "npc_InitialGuard2" }, 
  458. 		vehicles = { "veh_Initial Guard1", "veh_Initial Guard2" }, 
  459. 	}, 
  460. } 
  461.  
  462. M03_choppers = { M03_group.choppers.pierce, M03_group.choppers.bomb, M03_group.choppers.backup } 
  463.  
  464. -- Guards running around as you enter the warehouse (required kills) 
  465. M03_warehouse_guard_wave = { 
  466. 	outside = { 
  467. 		trigger = M03_trigger.armory_warehouse, 
  468. 		members = M03_group.armory_guards.group_a_members, 
  469. 		locations = M03_group.armory_guards.group_a_navs 
  470. 	}, 
  471. 	 
  472. 	door = {		 
  473. 		trigger = M03_trigger.armory_warehouse_door, 
  474. 		members = M03_group.armory_guards.group_b_members, 
  475. 		locations = M03_group.armory_guards.group_b_navs 
  476. 	}, 
  477. 	 
  478. 	inside = {		 
  479. 		trigger = M03_trigger.armory_warehouse_inside, 
  480. 		members = M03_group.armory_guards.group_c_members, 
  481. 		locations = M03_group.armory_guards.group_c_navs 
  482. 	}, 
  483. } 
  484.  
  485. M03_tanks = { M03_group.tank1, M03_group.tank2, M03_group.tank3 } 
  486. M03_tank_attack1 = { M03_group.tank1 } 
  487. M03_tank_attack2 = { M03_group.tank2 } 
  488. M03_tank_attack3 = { M03_group.tank1, M03_group.tank3 } 
  489. M03_tank_attacks = { M03_tank_attack1, M03_tank_attack2, M03_tank_attack3 } 
  490.  
  491. M03_all_satellite_groups = { M03_group.satellite_attack1, M03_group.satellite_attack2, M03_group.satellite_attack3,  
  492. 							M03_group.satellite_attack4, M03_group.satellite_attack5, M03_group.satellite_attack6, 
  493. 							M03_group.satellite_attack7, M03_group.satellite_attack8, M03_group.satellite_attack9, 
  494. 							M03_group.satellite_attack10 } 
  495. M03_num_satellite_attackers = 3 
  496. M03_satellite_attack1 = { M03_group.satellite_attack1, M03_group.satellite_attack2, M03_group.satellite_attack3 } 
  497. M03_satellite_attack2 = { M03_group.satellite_attack1, M03_group.satellite_attack2, M03_group.satellite_attack3,  
  498. 							M03_group.satellite_attack4, M03_group.satellite_attack5 } 
  499. M03_satellite_attack3 = M03_all_satellite_groups 
  500.  
  501. M03_satellite_attack = { M03_satellite_attack1, M03_satellite_attack2, M03_satellite_attack3 } 
  502.  
  503. M03_text = { 
  504. 	steal_a_car = "M03_OBJ_STEAL_A_CAR", 
  505. 	set_gps = "M03_OBJ_ACCESS_MAP", --"M03_OBJ_SET_GPS", 
  506. 	go_to_weapon_store = "M03_OBJ_GO_TO_WEAPON_STORE", 
  507. 	purchase_an_upgrade = "M03_OBJ_PURCHASE_AN_UPGRADE", 
  508. 	go_to_armory = "M03_OBJ_GO_TO_ARMORY", 
  509. 	go_to_warehouse = "M03_OBJ_GO_TO_WAREHOUSE", 
  510. 	find_weapons_cache = "M03_OBJ_FIND_WEAPONS_CACHE", 
  511. 	kill_guards = "M03_OBJ_KILL_GUARDS", 
  512. 	cutscene_found_weapons_cache = "M03_OBJ_CUTSCENE_FOUND_WEAPONS_CACHE", 
  513. 	hold_your_position = "M03_OBJ_HOLD_YOUR_POSITION", 
  514. 	eliminate_reinforcements = "M03_OBJ_ELIMINATE_REINFORCEMENTS", 
  515. 	use_satellite_weapon = "M03_OBJ_USE_SATELLITE_WEAPON", 
  516. 	protect_the_stash = "M03_OBJ_PROTECT_THE_STASH", 
  517. 	go_to_chopper = "M03_OBJ_GO_TO_CHOPPER", 
  518. 	protect_the_bomb = "M03_OBJ_PROTECT_THE_BOMB", 
  519.  
  520. 	current_handle = INVALID_MESSAGE_HANDLE, 
  521.  
  522. 	failure_bomb_destroyed = "m03_failure_bomb_destroyed", 
  523. 	failure_heli_destroyed = "m03_failure_heli_destroyed", 
  524. 	failure_pierce_destroyed = "m03_failure_pierce_destroyed", 
  525. } 
  526.  
  527. M03_convo = { 
  528. 	phillipe_call = { 
  529. 		name = "m03_phillipe_call", 
  530. 		handle = INVALID_CONVERSATION_HANDLE, 
  531. 		persona_name = "Phillipe", 
  532. 		persona_id = INVALID_PERSONA_HANDLE, 
  533. 		call_complete = false 
  534. 	}, 
  535. 	 
  536. 	mission_start = { 
  537. 		name = "m03_convo_1", 
  538. 		handle = INVALID_CONVERSATION_HANDLE, 
  539. 		load_direct = false, 
  540. 		thread = INVALID_THREAD_HANDLE 
  541. 	}, 
  542. 	 
  543. 	set_gps = { 
  544. 		name = "M03_GPS_Tutorial_For_FF", 
  545. 		handle = INVALID_CONVERSATION_HANDLE, 
  546. 		load_direct = false 
  547. 	}, 
  548.  
  549. 	to_gun_store1 = { 
  550. 		name = "M03_To_Gun_Store_1", 
  551. 		handle = INVALID_CONVERSATION_HANDLE, 
  552. 		load_direct = false 
  553. 	}, 
  554. 	 
  555. 	to_gun_store2 = { 
  556. 		name = "M03_To_Gun_Store_2", 
  557. 		handle = INVALID_CONVERSATION_HANDLE, 
  558. 		load_direct = false 
  559. 	}, 
  560. 	 
  561. 	to_armory = { 
  562. 		name = "M03_To_Armory", 
  563. 		handle = INVALID_CONVERSATION_HANDLE, 
  564. 		load_direct = false 
  565. 	}, 
  566.  
  567. 	armory_arrival = { 
  568. 		name = "M03_Arrive_Warehouse", 
  569. 		handle = INVALID_CONVERSATION_HANDLE, 
  570. 		load_direct = false 
  571. 	}, 
  572. 	 
  573. 	armory_combat = { 
  574. 		name = "M03_Arrive_Combat", 
  575. 		handle = INVALID_CONVERSATION_HANDLE, 
  576. 		load_direct = false 
  577. 	}, 
  578.  
  579. 	bomb_found = { 
  580. 		name = "m03_convo_4", 
  581. 		handle = INVALID_CONVERSATION_HANDLE, 
  582. 		load_direct = false 
  583. 	}, 
  584.  
  585. 	cavalry = { 
  586. 		name = "m03_convo_5", 
  587. 		handle = INVALID_CONVERSATION_HANDLE, 
  588. 		load_direct = false, 
  589. 		-- added persona info in standard format 
  590. 		persona_name = "Pierce", 
  591. 		persona_id = INVALID_PERSONA_HANDLE 
  592. 	}, 
  593. 	 
  594. 	defend_area = { 
  595. 		name = "M03_Defend_Area", 
  596. 		handle = INVALID_CONVERSATION_HANDLE, 
  597. 		load_direct = false 
  598. 	}, 
  599.  
  600. 	satellite_start = { 
  601. 		name = "m03_convo_6", 
  602. 		handle = INVALID_CONVERSATION_HANDLE, 
  603. 		load_direct = false 
  604. 	}, 
  605.  
  606. 	drone_operator1 = { 
  607. 		name = "M03_Drone_Operator_1", 
  608. 		handle = INVALID_CONVERSATION_HANDLE, 
  609. 		load_direct = true 
  610. 	}, 
  611.  
  612. 	drone_operator2 = { 
  613. 		name = "M03_Drone_Operator_2", 
  614. 		handle = INVALID_CONVERSATION_HANDLE, 
  615. 		load_direct = true 
  616. 	}, 
  617.  
  618. 	stash_combat1 = { 
  619. 		name = "M03_Stash_Combat_1", 
  620. 		handle = INVALID_CONVERSATION_HANDLE, 
  621. 		load_direct = false 
  622. 	}, 
  623.  
  624. 	stash_combat2 = { 
  625. 		name = "M03_Stash_Combat_2", 
  626. 		handle = INVALID_CONVERSATION_HANDLE, 
  627. 		load_direct = false 
  628. 	}, 
  629. 		 
  630. 	get_in_chopper = { 
  631. 		name = "M03_Get_In_Chopper", 
  632. 		handle = INVALID_CONVERSATION_HANDLE, 
  633. 		load_direct = false 
  634. 	}, 
  635. 		 
  636. 	protect_bomb = { 
  637. 		name = "M03_Protect_Bomb", 
  638. 		handle = INVALID_CONVERSATION_HANDLE, 
  639. 		load_direct = false 
  640. 	}, 
  641.  
  642. 	fly_home = { 
  643. 		name = "M03_Arrive_Studio", 
  644. 		handle = INVALID_CONVERSATION_HANDLE, 
  645. 		load_direct = false 
  646. 	}, 
  647. 	 
  648. 	callout1 = { 
  649. 		name = "M03_Calling_Out_Places_1", 
  650. 		handle = INVALID_CONVERSATION_HANDLE, 
  651. 		load_direct = false 
  652. 	},	 
  653. } 
  654.  
  655. M03_attack_info = { 
  656. 	situation = "M03_attack", 
  657. 	delay = 10.0, 
  658. 	callback = "m03_process_attack_cb", 
  659. 	timer = INVALID_THREAD_HANDLE 
  660. } 
  661.  
  662. M03_see_saints_info = { 
  663. 	situation = "M03_defend_bomb", 
  664. 	delay = 10.0, 
  665. 	callback = "m03_process_see_saints_cb", 
  666. 	timer = INVALID_THREAD_HANDLE 
  667. } 
  668.  
  669. -- 2d voices 
  670. M03_drone_voices = {  
  671. 	operator1 = { 
  672. 		persona_name = "Interrogation", 
  673. 		persona_id = INVALID_PERSONA_HANDLE 
  674. 	}, 
  675. } 
  676.  
  677. M03_drone_operators = { 
  678. 	{ 
  679. 		is_conversation = true, 
  680. 		conversation = M03_convo.drone_operator1, 
  681. 		spoken = false 
  682. 	}, 
  683. 	 
  684. 	{ 
  685. 		is_conversation = true, 
  686. 		conversation = M03_convo.drone_operator2, 
  687. 		spoken = false 
  688. 	}, 
  689. 	 
  690. 	{ 
  691. 		is_conversation = false, 
  692. 		speaker = M03_drone_voices.operator1, 
  693. 		line = "M03_Drone_Operator_03", 
  694. 		spoken = false 
  695. 	}, 
  696. 	 
  697. 	{ 
  698. 		is_conversation = false, 
  699. 		speaker = M03_drone_voices.operator1, 
  700. 		line = "M03_Drone_Operator_04", 
  701. 		spoken = false 
  702. 	}, 
  703. } 
  704. 		 
  705.  
  706. M03_heli_shot_down = { 
  707. 	hit1 = { 
  708. 		speaker = M03_char.shaundi, 
  709. 		line = "M03_Nice_Hit_01", 
  710. 		spoken = false 
  711. 	}, 
  712. 	 
  713. 	hit2 = { 
  714. 		speaker = M03_char.pierce, 
  715. 		line = "M03_Nice_Hit_02", 
  716. 		spoken = false 
  717. 	}, 
  718. 	 
  719. 	hit1 = { 
  720. 		speaker = M03_char.shaundi, 
  721. 		line = "M03_Nice_Hit_03", 
  722. 		spoken = false 
  723. 	}, 
  724. } 
  725.  
  726. M03_radio_chatter = { 
  727. 	line1 = { 
  728. 		speaker = M03_char.pierce, 
  729. 		line = "M03_Radio_Chatter_01", 
  730. 		spoken = false 
  731. 	},	 
  732. 	line2 = { 
  733. 		speaker = M03_char.pierce, 
  734. 		line = "M03_Radio_Chatter_02", 
  735. 		spoken = false 
  736. 	}, 
  737. 	line3 = { 
  738. 		speaker = M03_char.pierce, 
  739. 		line = "M03_Radio_Chatter_03", 
  740. 		spoken = false 
  741. 	}, 
  742. 	line4 = { 
  743. 		speaker = M03_char.pierce, 
  744. 		line = "M03_Radio_Chatter_04", 
  745. 		spoken = false 
  746. 	}, 
  747. } 
  748.  
  749. M03_chopper_combat = { 
  750. 	line1 = { 
  751. 		speaker = M03_char.shaundi, 
  752. 		line = "M03_Chopper_Combat_01", 
  753. 		spoken = false 
  754. 	},	 
  755. 	line2 = { 
  756. 		speaker = M03_char.shaundi, 
  757. 		line = "M03_Chopper_Combat_02", 
  758. 		spoken = false 
  759. 	},	 
  760. 	line3 = { 
  761. 		speaker = M03_char.shaundi, 
  762. 		line = "M03_Chopper_Combat_03", 
  763. 		spoken = false 
  764. 	}, 
  765. } 
  766.  
  767. M03_thread = { 
  768. 	start_conversation = INVALID_THREAD_HANDLE, 
  769. 	drive_conversations = INVALID_THREAD_HANDLE, 
  770. 	gps_tutorial = INVALID_THREAD_HANDLE, 
  771. 	weapon_upgrade_purchased = INVALID_THREAD_HANDLE, 
  772. 	warehouse_approach = INVALID_THREAD_HANDLE, 
  773. 	fly_home_convo = INVALID_THREAD_HANDLE, 
  774. 	satellite_attack = INVALID_THREAD_HANDLE, 
  775. 	satellite_convos = INVALID_THREAD_HANDLE, 
  776. 	chatter = INVALID_THREAD_HANDLE, 
  777. 	chatter_timer = INVALID_THREAD_HANDLE, 
  778. 	move_to_float = { }, 
  779. 	fly_home = { }, 
  780. 	fly_home_enemy_chase = { }, 
  781. 	fly_home_secondary_enemy_chase = { }, 
  782. 	fly_home_enemy_setup = { }, 
  783. 	landing = INVALID_THREAD_HANDLE, 
  784. 	pierce_float = INVALID_THREAD_HANDLE, 
  785. } 
  786.  
  787. M03_checkpoint = { 
  788. 	start = { 
  789. 		name = MISSION_START_CHECKPOINT,									-- defined in ug_lib.lua 
  790. 		player_local = "Nav CP Start Local", 
  791. 		player_remote = "Nav CP Start Remote" 
  792. 	}, 
  793. 	 
  794. 	get_the_goods = { 
  795. 		name = "get the goods", 
  796. 		player_local = "Nav CP Get The Goods Local", 
  797. 		player_remote = "Nav CP Get The Goods Remote" 
  798. 	}, 
  799. 	 
  800. 	hold_your_ground = { 
  801. 		name = "hold your ground", 
  802. 		player_local = "Nav CP Protect The Stash Local", 
  803. 		player_remote = "Nav CP Protect The Stash Remote" 
  804. 	}, 
  805. 	 
  806. 	protect_the_stash = { 
  807. 		name = "protect the stash", 
  808. 		player_local = "Nav CP Protect The Stash Local", 
  809. 		player_remote = "Nav CP Protect The Stash Remote" 
  810. 	}, 
  811. 	 
  812. 	helicopter_ride = { 
  813. 		name = "helicopter ride", 
  814. 		player_local = "Nav CP Helicopter Ride Local", 
  815. 		player_remote = "Nav CP Helicopter Ride Remote" 
  816. 	}, 
  817. } 
  818.  
  819. M03_teleport = { 
  820. 	weapon_local = "Nav Weapon Store Local", 
  821. 	weapon_remote = "Nav Weapon Store Remote", 
  822. }	 
  823.  
  824. M03_cutscene = { 
  825. 	mission_intro = nil, 
  826. 	found_weapons_cache = nil, 
  827. 	pierce_entrance = "03_Z01", 
  828. 	mission_outro = "03_out", 
  829. } 
  830.  
  831.  
  832. M03_warehouse_guards_alive = 0 
  833. M03_warehouse_guards_killed = 0 
  834. M03_warehouse_triggers_left = 0 
  835.  
  836. M03_bomb_mover = "DaBomb" 
  837.  
  838. -- Stuff to kill the helis (don't know where to put this) 
  839. M03_Kill_Heli_Navs = { "nav_Heli_Kill 001", "nav_Heli_Kill 002", "nav_Heli_Kill 003", "nav_Heli_Kill 004" } 
  840. M03_kill_heli = "" 
  841.  
  842. -- Stuff to track the weapon store objective in coop 
  843. Weapon_store_completion = { } 
  844. Weapon_store_completion[LOCAL_PLAYER] = false 
  845. Weapon_store_completion[REMOTE_PLAYER] = not coop_is_active() 
  846.  
  847. M03_given_drone = false 
  848. M03_riding_helicopter = false 
  849.  
  850. -------------------------------------------------------------------------------------------------- 
  851.  
  852. 											--[[********************]]-- 
  853. 											--[[                    ]]-- 
  854. 											--[[ Standard functions ]]-- 
  855. 											--[[                    ]]-- 
  856. 											--[[********************]]-- 
  857.  
  858.  
  859.  
  860. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  861. -- at the specified checkpoint. 
  862. -- CALLED FROM CODE 
  863. -- 
  864. -- m03_checkpoint:	(string) The checkpoint the mission should begin at 
  865. -- is_restart:			(bool) TRUE if the mission is restarting, FALSE otherwise 
  866. -- 
  867. function m03_start(m03_checkpoint, is_restart) 
  868.  
  869.  
  870. 	-- Check if this mission starting from the beginning 
  871. 	if (m03_checkpoint == M03_checkpoint.start.name) then 
  872. 		set_ped_override_density(1) 
  873. 		if (not is_restart) then 
  874. 			-- First time playing mission 
  875. 			 
  876. 			-- Play an intro cutscene??? 
  877. 			if (M03_cutscene.mission_intro ~= nil) then 
  878. 				cutscene_play(M03_cutscene.mission_intro) 
  879. 			end 
  880. 		end 
  881. 	end 
  882.  
  883. 	-- Handle mission initialization for the current checkpoint 
  884. 	m03_initialize(m03_checkpoint) 
  885.  
  886. 	-- Run the mission from the current checkpoint 
  887. 	m03_run(m03_checkpoint) 
  888. 	 
  889. end 
  890.  
  891. -- Initialize the mission for the specified checkpoint 
  892. -- 
  893. -- checkpoint:		Checkpoint to initialize the mission to 
  894. -- 
  895. function m03_initialize(checkpoint) 
  896. 	-- Make sure the screen is completly faded out 
  897. 	mission_start_fade_out(0.0) 
  898.  
  899. 	-- Set the mission author 
  900. 	set_mission_author("Neil Ryan") 
  901.  
  902. 	-- Common initialization 
  903. 	m03_initialize_common() 
  904.  
  905. 	-- Checkpoint specific initialization 
  906. 	m03_initialize_checkpoint(checkpoint) 
  907.  
  908. 	-- Start fading in  
  909. 	mission_start_fade_in() 
  910.  
  911. end 
  912.  
  913. -- Handle any common initialization 
  914. -- 
  915. function m03_initialize_common() 
  916.  
  917. 	-- ignore clerk state for this mission 
  918. 	shop_ignore_clerk(true) 
  919. 	 
  920. 	-- don't play newsbreak unless we say so 
  921. 	radio_newsbreak_clear() 
  922. 	 
  923. 	M03_given_drone = false 
  924.  
  925. 	notoriety_force_no_spawn("luchadores", true) 
  926. 	notoriety_force_no_spawn("deckers", true) 
  927. 	notoriety_force_no_spawn("morningstar", true) 
  928. 	notoriety_force_no_spawn("police", true) 
  929. 	 
  930. 	-- TEST 
  931. 	--notoriety_set_min_and_max("police", 0, 0) 
  932. 	--notoriety_set_min_and_max("luchadores", 0, 0) 
  933. 	--notoriety_set_min_and_max("morningstar", 0, 0) 
  934. 	--notoriety_set_min_and_max("deckers", 0, 0) 
  935. 	 
  936. 	-- Set the persona situation override for Pierce 
  937. 	persona_set_global_situation_override(PS_OVERRIDE_MISSION03) 
  938. 	 
  939. 	-- Turn traffic splines around the armory off 
  940. 	m03_traffic_off() 
  941. 	 
  942. 	mesh_mover_reset(M03_bomb_mover) 
  943. 	mesh_mover_show(M03_bomb_mover) 
  944. end 
  945.  
  946. -- Checkpoint specific initialization 
  947. -- 
  948. -- checkpoint:	The checkpoint to be initialized 
  949. -- 
  950. function m03_initialize_checkpoint(checkpoint) 
  951. 	if (checkpoint == M03_checkpoint.start.name) then 
  952. 		m03_initialize_start() 
  953. 	elseif (checkpoint == M03_checkpoint.get_the_goods.name) then 
  954. 		m03_initialize_get_the_goods() 
  955. 	elseif (checkpoint == M03_checkpoint.hold_your_ground.name) then 
  956. 		group_create(M03_group.guns, true) 
  957. 		m03_initialize_hold_your_ground() 
  958. 	elseif (checkpoint == M03_checkpoint.protect_the_stash.name) then 
  959. 		mesh_mover_hide(M03_bomb_mover) 
  960. 		group_create(M03_group.guns, true) 
  961. 		m03_initialize_protect_the_stash() 
  962. 	elseif (checkpoint == M03_checkpoint.helicopter_ride.name) then 
  963. 		mesh_mover_hide(M03_bomb_mover) 
  964. 		m03_initialize_helicopter_ride() 
  965. 	end 
  966. end 
  967.  
  968. -- This is the primary function responsible for running the entire mission from start to finish. 
  969. -- 
  970. -- first_checkpoint:	(string) The first checkpoint to begin running the mission at 
  971. -- 
  972. function m03_run(first_checkpoint) 
  973. 	local current_checkpoint = first_checkpoint 
  974. 	local ignore_vehicles = false 
  975. 	 
  976. 	-- Run the mission from the beginning 
  977. 	if (current_checkpoint == M03_checkpoint.start.name) then 
  978. 		-- Prevent player from being able to get notoriety 
  979. 		notoriety_set_min_and_max("police", 0, 0)  
  980. 		notoriety_set_min_and_max("morningstar", 0, 0) 
  981.  
  982. 		m03_steal_a_car() 
  983. 		m03_go_to_weapon_store() 
  984. 		m03_weapon_upgrade_tutorial()		 
  985. 		 
  986. 		-- Now move on to the next checkpoint 
  987. 		current_checkpoint = M03_checkpoint.get_the_goods.name 
  988. 		mission_set_checkpoint(M03_checkpoint.get_the_goods.name, ignore_vehicles) 
  989. 	end 
  990. 	 
  991. 	-- Allow the player to get some notoriety now 
  992. 	notoriety_set_min_and_max("police", 0, 3) 
  993. 	notoriety_set_min_and_max("morningstar", 0, 3) 
  994.  
  995. 	ignore_vehicles = true 
  996. 	if (current_checkpoint == M03_checkpoint.get_the_goods.name) then 
  997. 		m03_go_to_armory() 
  998. 		m03_objective_find_the_weapons() 
  999. 		m03_cutscene_approach_stash() 
  1000. 		 
  1001. 		-- Now move on to the next checkpoint 
  1002. 		current_checkpoint = M03_checkpoint.hold_your_ground.name 
  1003. 		mission_set_checkpoint(M03_checkpoint.hold_your_ground.name, ignore_vehicles) 
  1004. 	end 
  1005.  
  1006. 	if (current_checkpoint == M03_checkpoint.hold_your_ground.name) then 
  1007. 		zscene_prep(M03_cutscene.pierce_entrance) 
  1008. 		m03_objective_hold_your_ground() 
  1009. 		m03_cutscene_pierce_entrance() 
  1010.  
  1011. 		-- Now move on to the next checkpoint 
  1012. 		current_checkpoint = M03_checkpoint.protect_the_stash.name 
  1013. 		mission_set_checkpoint(M03_checkpoint.protect_the_stash.name, ignore_vehicles) 
  1014. 	end 
  1015.  
  1016. 	if (current_checkpoint == M03_checkpoint.protect_the_stash.name) then 
  1017. 		m03_objective_protect_the_stash() 
  1018.  
  1019. 		-- Now move on to the next checkpoint 
  1020. 		current_checkpoint = M03_checkpoint.helicopter_ride.name 
  1021. 		mission_set_checkpoint(M03_checkpoint.helicopter_ride.name, ignore_vehicles) 
  1022. 	end 
  1023.  
  1024. 	if (current_checkpoint == M03_checkpoint.helicopter_ride.name) then 
  1025. 		M03_riding_helicopter = true 
  1026. 		m03_objective_helicopter_ride() 
  1027. 		M03_riding_helicopter = false 
  1028. 	end 
  1029. 	 
  1030. 	-- Call mission success?? 
  1031. 	local end_navs = {M03_navpoint.end_local, M03_navpoint.end_remote} 
  1032. 	mission_end_success("m03", M03_cutscene.mission_outro, end_navs) 
  1033. end 
  1034.  
  1035. -- This is the primary function responsible for cleaning up the entire mission 
  1036. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATELY+++) 
  1037. -- 
  1038. function m03_cleanup() 
  1039.  
  1040. 	-- make sure nothing is running first (or we may create things after they are cleaned up) 
  1041. 	cleanup_threads(M03_thread) 
  1042.  
  1043. 	if M03_riding_helicopter then 
  1044. 		-- set a cancel teleport so we don't fall when we fail 
  1045. 		teleport(LOCAL_PLAYER, M03_checkpoint.helicopter_ride.player_local, true) 
  1046. 		teleport(REMOTE_PLAYER, M03_checkpoint.helicopter_ride.player_remote, true) 
  1047. 	end 
  1048.  
  1049. 	-- set ped density back to normal levels 
  1050. 	set_ped_override_density(-1)  
  1051. 	 
  1052. 	-- kill guards and their callbacks 
  1053. 	m03_cleanup_warehouse_guards() 
  1054. 	 
  1055. 	-- kill hud prompt callback 
  1056. 	hud_prompt_clear() 
  1057. 	 
  1058. 	-- cleanup cell phone call 
  1059. 	m03_call_complete_cb() 
  1060. 	 
  1061. 	-- stupid tutorial thing 
  1062. 	tutorial_vehicle_controls_enabled(true) 
  1063. 	 
  1064. 	-- no more GPS tutorial 
  1065. 	pause_map_tutorial_mode(false) 
  1066.  
  1067. 	-- re-enable clerk checks for stores 
  1068. 	shop_ignore_clerk(false) 
  1069. 	 
  1070. 	-- done with this 
  1071. 	set_cops_shooting_from_vehicles(false) 
  1072.  
  1073. 	notoriety_force_no_spawn("luchadores", false) 
  1074. 	notoriety_force_no_spawn("deckers", false) 
  1075. 	notoriety_force_no_spawn("morningstar", false) 
  1076. 	notoriety_force_no_spawn("police", false) 
  1077.  
  1078. 	-- TEST 
  1079. 	notoriety_set_min_and_max("police", 0, MAX_NOTORIETY_LEVEL) 
  1080. 	notoriety_set_min_and_max("luchadores", 0, MAX_NOTORIETY_LEVEL) 
  1081. 	notoriety_set_min_and_max("morningstar", 0, MAX_NOTORIETY_LEVEL) 
  1082. 	notoriety_set_min_and_max("deckers", 0, MAX_NOTORIETY_LEVEL) 
  1083. 	-- END TEST 
  1084. 	 
  1085.  
  1086. 	-- njr - no longer care about teleporting them.  There is no exit except success for this mission. 
  1087. 	---- Teleport them to a safe location 
  1088. 	--teleport(LOCAL_PLAYER, M03_navpoint.end_local, true) 
  1089. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, true) 
  1090. 	if (coop_is_active()) then 
  1091. 	--	teleport(REMOTE_PLAYER, M03_navpoint.end_remote, true) 
  1092. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, true) 
  1093. 	end 
  1094. 	 
  1095. 	-- Stop the situation override. 
  1096. 	persona_clear_global_situation_override() 
  1097. 	 
  1098. 	-- no more callbacks 
  1099. 	on_attack_performed("", LOCAL_PLAYER) 
  1100. 	if coop_is_active() then 
  1101. 		on_attack_performed("", REMOTE_PLAYER) 
  1102. 	end 
  1103. 	m03_cleanup_army_callbacks() 
  1104. 	m03_forced_satellite_end() 
  1105. 	 
  1106. 	-- Unload personas 
  1107. 	m03_unload_persona(M03_convo.cavalry) 
  1108. 	m03_unload_persona(M03_drone_voices.operator1) 
  1109. 	 
  1110. 	cleanup_callbacks( { M03_char, M03_vehicle, M03_item } ) 
  1111. 	cleanup_callbacks( { M03_group.choppers.pierce.vehicle, M03_group.choppers.bomb.vehicle, M03_group.choppers.backup.vehicle } ) 
  1112. 	cleanup_groups(M03_group) 
  1113. 	m03_clear_trigger_table() 
  1114. 	on_purchase("") 
  1115. 	cleanup_conversations(M03_convo) 
  1116. 	inv_weapon_disable_all_slots(false) 
  1117. 	 
  1118. 	-- Turn traffic splines around the armory back on 
  1119. 	m03_traffic_on() 
  1120. 	 
  1121. 	-- skip this if we gave the player the drone in success 
  1122. 	if not M03_given_drone then 
  1123. 		cleanup_temporary_weapons(M03_weapon.cleanup) 
  1124. 	end 
  1125. end 
  1126.  
  1127. -- Called when the mission has ended with success 
  1128. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  1129. -- 
  1130. function m03_success() 
  1131. 	-- clean up temp weapons before we give the weapon 
  1132. 	cleanup_temporary_weapons(M03_weapon.cleanup) 
  1133. 	 
  1134. 	-- give the sat-drone weapon 
  1135. 	inv_item_add(M03_weapon.satellite_drone_weapon, 1, LOCAL_PLAYER) 
  1136. 	if (coop_is_active() == true) then 
  1137. 		inv_item_add(M03_weapon.satellite_drone_weapon, 1, REMOTE_PLAYER) 
  1138. 	end 
  1139. 	M03_given_drone = true 
  1140. 	 
  1141. 	m03_coop_skip( ) -- do the stuff we'd do in the skip case 
  1142. end 
  1143.  
  1144. -------------------------------------------------------------------------------------------------- 
  1145.  
  1146. 										--[[**************************]]-- 
  1147. 										--[[                          ]]-- 
  1148. 										--[[ m03_run Helper Functions ]]-- 
  1149. 										--[[                          ]]-- 
  1150. 										--[[**************************]]-- 
  1151. 	 
  1152. 	 
  1153. 								--[[                                     ]]-- 
  1154. 								--[[ FIRST CHECKPOINT (START OF MISSION) ]]-- 
  1155. 								--[[                                     ]]-- 
  1156.  
  1157. function m03_initialize_start() 
  1158. 	teleport_coop(M03_checkpoint.start.player_local, M03_checkpoint.start.player_remote, true) 
  1159. 	-- a bit of hackery to make sure the transition from mission 02 has happened ok 
  1160. 	repeat 
  1161. 		thread_yield() 
  1162. 	until (get_dist(LOCAL_PLAYER, M03_checkpoint.start.player_local) < 10) 
  1163. 	group_create(M03_group.shaundi.name, true) 
  1164. 	thread_yield() 
  1165. 	group_create(M03_group.starting_vehicle.name, true) 
  1166. 	--teleport(M03_char.shaundi, M03_checkpoint.start.player_remote, true) 
  1167. 	tutorial_vehicle_controls_enabled(false) 
  1168. 	 
  1169. 	m03_give_players_weapons() 
  1170. 	 
  1171. 	-- Player look cool GO! 
  1172. 	-- set_ped_override_density(1) -- more peds during walk through red light district 
  1173. 	local anim_name = "M03 Player Mission Start" 
  1174. 	local morph_name = "M03 Player Mission Start" 
  1175. 	local force_play = false 
  1176. 	local percentage = 0.0 
  1177. 	local stand_still = true 
  1178. 	local zero_movement = true 
  1179. 	action_play(LOCAL_PLAYER, anim_name, morph_name, force_play, percentage, stand_still, zero_movement)	 
  1180. end 
  1181.  
  1182. -- Have the player steal a car 
  1183. -- 
  1184. function m03_steal_a_car() 
  1185. 	 
  1186. 	m03_add_shaundi() 
  1187. 	M03_trigger.weapon_store.triggered = false 
  1188. 	M03_trigger.weapon_store2.triggered = false 
  1189. 	 
  1190. 	repeat 
  1191. 		thread_yield() 
  1192. 	until action_play_is_finished(LOCAL_PLAYER, 1.0) 
  1193. 	 
  1194. 	-- Mark the car to steal 
  1195. 	marker_add(M03_group.starting_vehicle.vehicle, MINIMAP_ICON_USE, OI_ASSET_USE, OI_FLAGS_FULL) 
  1196. 	-- Tell the player to steal a car 
  1197. 	objective_text(0, M03_text.steal_a_car, nil, nil, SYNC_ALL, OI_ASSET_USE) 
  1198.  
  1199. 	-- phillipe phone call timing 
  1200. 	M03_convo.phillipe_call.call_complete = false 
  1201. 	m03_load_persona(M03_convo.phillipe_call) 
  1202. 	audio_play_for_mission_cellphone(M03_convo.phillipe_call.name, true, true, nil, "m03_call_complete_cb", M03_convo.phillipe_call.persona_id)  
  1203. 	 
  1204. 	while not M03_convo.phillipe_call.call_complete do 
  1205. 		thread_yield() 
  1206. 	end 
  1207. 	 
  1208. 	delay(2.5) 
  1209. 	 
  1210. 	M03_thread.start_conversation = thread_new("m03_convo", M03_convo.mission_start) 
  1211. 		 
  1212. 	local redisplay = true 
  1213. 	local infinite_duration = true 
  1214. 	tutorial_start("vehicle entry", 10000, false, redisplay, infinite_duration) 
  1215. 	 
  1216. 	-- Wait till the player is in a car 
  1217. 	repeat 
  1218. 		thread_yield() 
  1219. 	until (character_is_in_vehicle(LOCAL_PLAYER) or (coop_is_active() and character_is_in_vehicle(REMOTE_PLAYER))) 
  1220. 	-- Take the marker off the car 
  1221. 	marker_remove(M03_group.starting_vehicle.vehicle) 
  1222. 	 
  1223. 	-- Ped density down 
  1224. 	set_ped_override_density(-1) 
  1225. 	 
  1226. 	-- Don't care if this is the vehicle anymore 
  1227. 	release_to_world(M03_group.starting_vehicle.name) 
  1228. 	 
  1229. 	tutorial_stop("vehicle entry") 
  1230. 	 
  1231. 	M03_thread.drive_conversations = thread_new("m03_start_convos_thread") 
  1232. 	 
  1233. 	objective_text_clear(0) 
  1234. end 
  1235.  
  1236. -- Direct the player to a weapon store so we can do the upgrade tutorial 
  1237. -- 
  1238. function m03_go_to_weapon_store()	 
  1239. 	local add_waypoint = false 
  1240. 	local add_marker = false 
  1241. 	-- no waypoint or marker for this one because we want the player to set the GPS 
  1242. 	m03_set_trigger(M03_trigger.weapon_store.name, "m03_weapon_store_trigger_cb", add_waypoint, add_marker) 
  1243. 	marker_add_trigger(M03_trigger.weapon_store.name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT) 
  1244.  
  1245. 	M03_thread.gps_tutorial = thread_new("m03_gps_tutorial_thread") 
  1246. 	 
  1247. 	thread_yield() 
  1248. 	-- Set up callout triggers 
  1249. 	m03_set_trigger(M03_trigger.callout1.name, "m03_callout_1_cb", add_waypoint, add_marker) 
  1250. 	m03_set_trigger(M03_trigger.callout2.name, "m03_callout_2_cb", add_waypoint, add_marker) 
  1251. 	m03_set_trigger(M03_trigger.callout3.name, "m03_callout_3_cb", add_waypoint, add_marker) 
  1252. 	m03_set_trigger(M03_trigger.callout4.name, "m03_callout_4_cb", add_waypoint, add_marker) 
  1253. 	 
  1254. 	repeat 
  1255. 		thread_yield() 
  1256. 	until (M03_trigger.weapon_store2.triggered) 
  1257. 	 
  1258. 	-- kill tutorial thread 
  1259. 	thread_kill(M03_thread.gps_tutorial) 
  1260. 	-- make sure tutorials are done 
  1261. 	tutorial_stop("pause_map") 
  1262. 	tutorial_stop("minimap")	 
  1263. 	tutorial_vehicle_controls_enabled(true) 
  1264. 	 
  1265. 	objective_text_clear(0) 
  1266. end 
  1267.  
  1268. -- Do the weapon upgrade tutorial 
  1269. -- 
  1270. function m03_weapon_upgrade_tutorial() 
  1271. 	-- Set objective 
  1272. 	objective_text(0, M03_text.purchase_an_upgrade, nil, nil, SYNC_ALL, OI_ASSET_USE) 
  1273. 	 
  1274. 	on_purchase("m03_item_purchased_cb") 
  1275. 	 
  1276. 	--tutorial_start("weapon_upgrades") 
  1277. 	 
  1278. 	-- Wait for player to buy something 
  1279. 	repeat thread_yield() until (M03_status.item_purchased) 
  1280. 		 
  1281. 	-- Wait for player to get out of the interface before continuing 
  1282. 	while (store_interface_is_active())do 
  1283. 		thread_yield() 
  1284. 	end 
  1285. 	 
  1286. 	objective_text_clear(0) 
  1287. end 
  1288.  
  1289. -- Placeholder processing for making sure the player has money for upgrades 
  1290. -- 
  1291. function m03_check_player_funds_for_upgrade() 
  1292. 	-- Check if the player has enough money for an upgrade, if not, do the following 
  1293. 	audio_play_persona_line(M03_char.shaundi, "M03_Out_Of_Cash") 
  1294. 	thread_yield() 
  1295. 	while audio_persona_line_playing(M03_char.shaundi) do 
  1296. 		thread_yield() 
  1297. 	end 
  1298. 	 
  1299. 	-- Give him the cash he needs... 
  1300. 	cash_add(M03_DEBUG.large_cash_sum) 
  1301. 	if(coop_is_active())then 
  1302. 		cash_add(M03_DEBUG.large_cash_sum, "#PLAYER2#") 
  1303. 	end 
  1304. end 
  1305.  
  1306. 							--[[                                   ]]-- 
  1307. 							--[[ SECOND CHECKPOINT (GET THE GOODS) ]]-- 
  1308. 							--[[                                   ]]-- 
  1309.  
  1310. function m03_initialize_get_the_goods() 
  1311. 	group_create(M03_group.shaundi.name, true) 
  1312. 	 
  1313. 	teleport_coop(M03_checkpoint.get_the_goods.player_local, M03_checkpoint.get_the_goods.player_remote, true) 
  1314. 	-- teleport Shaundi to where you are going to be 
  1315. 	teleport(M03_char.shaundi, M03_checkpoint.get_the_goods.player_local, nil, nil, 0.0, 0.0, 1.4) 
  1316. 	group_create(M03_group.vehicle_get_the_goods.name, true) 
  1317. 	 
  1318. 	-- NOW add Shaundi and she won't go through a bunch of bad teleports 
  1319. 	m03_add_shaundi() 
  1320. end 
  1321.  
  1322. function m03_go_to_armory() 
  1323. 	M03_thread.weapon_upgrade_purchased = thread_new("m03_convo", M03_convo.to_armory) 
  1324. 	 
  1325. 	objective_text(0, M03_text.go_to_armory, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1326. 	M03_trigger.armory_entrance.triggered = false 
  1327. 	 
  1328. 	-- Clean up callout triggers 
  1329. 	m03_clear_trigger(M03_trigger.callout1.name) 
  1330. 	m03_clear_trigger(M03_trigger.callout2.name) 
  1331. 	m03_clear_trigger(M03_trigger.callout3.name) 
  1332. 	m03_clear_trigger(M03_trigger.callout4.name) 
  1333. 	 
  1334. 	-- Create barricade guards 
  1335. 	group_create_hidden(M03_group.initial_guard.name, true) 
  1336. 	-- Direct them to the entrance of the armory 
  1337. 	local add_waypoint = false 
  1338. 	local add_marker = true 
  1339. 	m03_set_trigger(M03_trigger.armory_entrance.name, "m03_armory_entrance_trigger_cb", add_waypoint, add_marker) 
  1340. 	-- fake out gps a little 
  1341. 	mission_waypoint_add("Tank1_dest") 
  1342. 	 
  1343. 	local played_news = false 
  1344. 	repeat 
  1345. 		thread_yield() 
  1346. 		 
  1347. 		if (not played_news) and (not M03_status.convo_is_playing) then 
  1348. 			radio_newsbreak("m02") 
  1349. 			played_news = true 
  1350. 		end 
  1351. 	until (M03_trigger.armory_entrance.triggered) 
  1352. 	 
  1353. 	M03_thread.warehouse_approach = thread_new("m03_convo", M03_convo.armory_arrival) 
  1354. 	 
  1355. 	objective_text_clear(0) 
  1356. 	local add_waypoint = false 
  1357. 	objective_text(0, M03_text.go_to_warehouse, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1358. 	m03_set_trigger(M03_trigger.weapons_cache.name, "m03_weapons_cache_trigger_cb", add_waypoint) 
  1359. 	-- still direct to the front of warehouse 
  1360. 	mission_waypoint_add("Tank1_dest") 
  1361. 	 
  1362. 	group_create(M03_group.warehouse_cover_vehicles.name, true) 
  1363. 	 
  1364. 	-- m03_warehouse_advance_cb 
  1365. 	m03_setup_warehouse_guards() 
  1366. 		 
  1367. 	local completed_takeover = false 
  1368. 	local played_conversation = false 
  1369. 	while not completed_takeover do 
  1370. 		thread_yield() 
  1371. 		if (M03_warehouse_guards_alive == 0) then 
  1372. 			if (M03_warehouse_triggers_left == 0) then 
  1373. 				completed_takeover = true 
  1374. 			else 
  1375. 				-- set objective go inside 
  1376. 				m03_set_enter_warehouse_objective() 
  1377. 			end 
  1378. 		end 
  1379. 		 
  1380. 		if (not played_conversation) and (M03_warehouse_guards_killed > 0) then 
  1381. 			M03_thread.warehouse_approach = thread_new("m03_convo", M03_convo.armory_combat) 
  1382. 			played_conversation = true 
  1383. 		end 
  1384. 		 
  1385. 	end 
  1386. 	 
  1387. 	objective_text_clear(0) 
  1388. end 
  1389.  
  1390. function m03_objective_find_the_weapons() 
  1391. 	objective_text(0, M03_text.find_weapons_cache, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1392. 	M03_trigger.weapons_cache.triggered = false 
  1393. 	 
  1394. 	local add_waypoint = false 
  1395. 	m03_set_trigger(M03_trigger.weapons_cache.name, "m03_weapons_cache_trigger_cb", add_waypoint) 
  1396. 	 
  1397. 	-- This conversation should be done by now.  If not, kill it with FIRE!!! 
  1398. 	if not thread_check_done(M03_thread.warehouse_approach) then 
  1399. 		cleanup_conversations(M03_convo) 
  1400. 	end 
  1401.  
  1402. 	-- Whenever the conversation is done, wait until they've reached the weapons cache 
  1403. 	repeat 
  1404. 		thread_yield() 
  1405. 	until (M03_trigger.weapons_cache.triggered) 
  1406. 	 
  1407. 	objective_text_clear(0) 
  1408. end 
  1409.  
  1410. function m03_cutscene_approach_stash() 
  1411. 	local teleport_navs = {M03_checkpoint.hold_your_ground.player_local, M03_checkpoint.hold_your_ground.player_remote} 
  1412. --	cutscene_in() 
  1413. --	group_create_hidden( M03_group.cte_shaundi_group.name, true ) 
  1414. --	group_create_hidden( M03_group.cte_soldier_group.name, true ) 
  1415. --	group_create( M03_group.cte_apc_group.name, true ) 
  1416. --	cutscene_play(M03_cte.name, nil, teleport_navs) 
  1417. --	group_destroy( M03_group.cte_shaundi_group.name ) 
  1418. --	group_destroy( M03_group.cte_soldier_group.name ) 
  1419. --	group_destroy( M03_group.cte_apc_group.name ) 
  1420. 	-- This should also bring Shaundi in with us... 
  1421. 	--teleport_coop(M03_checkpoint.hold_your_ground.player_local, M03_checkpoint.hold_your_ground.player_remote, true) 
  1422. 	objective_text_clear(0) 
  1423.  
  1424. 	-- spawn a shitload of guys to (try to) hold you in the warehouse	 
  1425. 	group_create(M03_group.the_army.name, true) 
  1426. 	m03_spawn_tanks() 
  1427. 	group_create(M03_group.guns, true) 
  1428. --	cutscene_out() 
  1429. end 
  1430.  
  1431. 								----------------------------------------------- 
  1432.  
  1433. 								--[[                                     ]]-- 
  1434. 								--[[ THIRD CHECKPOINT (HOLD YOUR GROUND) ]]-- 
  1435. 								--[[                                     ]]-- 
  1436.  
  1437. function m03_initialize_hold_your_ground() 
  1438. 	group_create(M03_group.shaundi.name, true) 
  1439. 	 
  1440. 	-- Put everybody in their place 
  1441. 	teleport_coop(M03_checkpoint.hold_your_ground.player_local, M03_checkpoint.hold_your_ground.player_remote, true) 
  1442. 	-- teleport Shaundi to where you are going to be 
  1443. 	teleport(M03_char.shaundi, M03_checkpoint.hold_your_ground.player_local, nil, nil, 0.0, 0.0, 1.4) 
  1444. 	 
  1445. 	group_create(M03_group.warehouse_cover_vehicles.name, true) 
  1446. 	-- spawn a shitload of guys to (try to) hold you in the warehouse	 
  1447. 	group_create(M03_group.the_army.name, true) 
  1448. 	m03_spawn_tanks() 
  1449. 	 
  1450. 	-- NOW add Shaundi and she won't go through a bunch of bad teleports 
  1451. 	m03_add_shaundi() 
  1452. end 
  1453.  
  1454. function m03_objective_hold_your_ground() 
  1455. 	-- marker_add(M03_bomb_mover, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND) 
  1456. 	 
  1457. 	objective_text(0, M03_text.hold_your_position, nil, nil, SYNC_ALL, OI_ASSET_DEFEND) 
  1458. 	 
  1459. 	thread_new("m03_convo", M03_convo.defend_area) 
  1460. 	-- keep Shaundi in the back of the warehouse	 
  1461. 	npc_leash_to_nav( M03_char.shaundi, M03_checkpoint.hold_your_ground.player_local, 25.0 ) 
  1462. 	 
  1463. 	-- send in the tanks 
  1464. 	m03_deploy_tanks() 
  1465. 	 
  1466. 	local advance = false 
  1467. 	 
  1468. 	-- deploy the troops 
  1469. 	M03_group.the_army.squad1.thread = thread_new("m03_deploy_troops_thread", M03_group.the_army.squad1, advance) 
  1470. 	M03_group.the_army.squad2.thread = thread_new("m03_deploy_troops_thread", M03_group.the_army.squad2, advance) 
  1471. 	M03_group.the_army.squad5.thread = thread_new("m03_deploy_troops_thread", M03_group.the_army.squad5, advance) 
  1472. 	delay(2.0) 
  1473. 	advance = true 
  1474. 	M03_group.the_army.squad3.thread = thread_new("m03_deploy_troops_thread", M03_group.the_army.squad3, advance) 
  1475. 	delay(6.0) 
  1476. 	advance = false 
  1477. 	M03_group.the_army.squad4.thread = thread_new("m03_deploy_troops_thread", M03_group.the_army.squad4, advance) 
  1478. 	delay(2.0) 
  1479. 	M03_group.the_army.squad6.thread = thread_new("m03_deploy_troops_thread", M03_group.the_army.squad6, advance) 
  1480. 	delay(2.0) 
  1481. 	 
  1482. 	-- squad 3 has riot shields - They should enter first (offensive AI) 
  1483. 	 
  1484. 	-- squad 4 and half of squad 2 can go in (normal ai).  The rest stay defensive 
  1485. 		 
  1486. 	-- just wait for now, but go ahead and load pierce's persona 
  1487. 	m03_load_persona(M03_convo.cavalry) 
  1488. 	delay(60.0) 
  1489. 	 
  1490. 	-- Pierce needs a 2d persona loaded for this conversation 
  1491. 	m03_convo(M03_convo.cavalry)	 
  1492. 	-- Unload persona 
  1493. 	m03_unload_persona(M03_convo.cavalry) 
  1494. 	 
  1495. 	objective_text_clear(0) 
  1496. 	 
  1497. 	-- Shaundi is free again 
  1498. 	npc_leash_remove( M03_char.shaundi ) 
  1499. 	m03_nuke_tanks() 
  1500. 	if human_is_downed( M03_char.shaundi)then 
  1501. 		npc_revive( M03_char.shaundi) 
  1502. 	end 
  1503. 	delay(2.0) 
  1504. end 
  1505.  
  1506. function m03_cutscene_pierce_entrance() 
  1507. 	 
  1508. 	local fade_in_after = false 
  1509. 	local teleport_navs = { M03_checkpoint.protect_the_stash.player_local, M03_checkpoint.protect_the_stash.player_remote } 
  1510. 	cutscene_play(M03_cutscene.pierce_entrance, nil, teleport_navs, fade_in_after) 
  1511. 	 
  1512. 	-- hack to bring Shaundi back after cutscene due to teleporting everyone to the slate 
  1513. 	teleport(M03_char.shaundi, "m3_cte_playerteleport", true) 
  1514.  
  1515. 	group_create(M03_group.choppers.name, true) 
  1516. 	group_create(M03_group.chopper_pierce_normal.name, true) 
  1517. 	on_vehicle_destroyed("m03_chopper_destroyed_cb", M03_group.choppers.pierce.vehicle) 
  1518. 	on_vehicle_destroyed("m03_bomb_destroyed_cb", M03_group.choppers.bomb.vehicle)	 
  1519.  
  1520. 	-- Start three separate vehicle entry threads so they are all entering at the same time 
  1521. 	for i,chopper in pairs(M03_choppers) do 
  1522. 		chopper.thread = thread_new("m03_wrapper_thread", vehicle_enter_group_teleport, chopper.pilots, chopper.vehicle) 
  1523. 	end 
  1524. 	 
  1525. 	for i,chopper in pairs(M03_choppers) do 
  1526. 		threads_wait_for_completion(chopper.thread) 
  1527. 	end 
  1528.  
  1529. 	-- Put the choppers in their starting positions 
  1530. 	m03_float_choppers() 
  1531.  
  1532. 	-- marker_remove(M03_bomb_mover) 
  1533. 	-- Hide the giant bomb 
  1534. 	mesh_mover_hide("DaBomb") 
  1535. 	 
  1536. 	 
  1537. 	if group_is_loaded(M03_group.the_army.name) then 
  1538. 		m03_cleanup_army_callbacks() 
  1539. 		group_destroy(M03_group.the_army.name) 
  1540. 	end 
  1541.  
  1542. 	--objective_text_clear(0) 
  1543. 	mission_start_fade_in() 
  1544. end 
  1545.  
  1546. 								----------------------------------------------- 
  1547. 								 
  1548. 								--[[                                       ]]-- 
  1549. 								--[[ FOURTH CHECKPOINT (PROTECT THE STASH) ]]-- 
  1550. 								--[[                                       ]]-- 
  1551. 								 
  1552. function m03_initialize_protect_the_stash() 
  1553. 	group_create(M03_group.shaundi.name, true) 
  1554.  
  1555. 	group_create(M03_group.warehouse_cover_vehicles.name, true) 
  1556.  
  1557. 	-- Put everybody in their place 
  1558. 	teleport_coop(M03_checkpoint.protect_the_stash.player_local, M03_checkpoint.protect_the_stash.player_remote, true) 
  1559. 	-- teleport Shaundi to where you are going to be 
  1560. 	teleport(M03_char.shaundi, M03_checkpoint.protect_the_stash.player_local, nil, nil, 0.0, 0.0, 1.4) 
  1561. 	 
  1562. 	group_create(M03_group.choppers.name, true) 
  1563. 	group_create(M03_group.chopper_pierce_normal.name, true) 
  1564. 	on_vehicle_destroyed("m03_chopper_destroyed_cb", M03_group.choppers.pierce.vehicle) 
  1565. 	on_vehicle_destroyed("m03_heli_destroyed_cb", M03_group.choppers.bomb.vehicle) 
  1566. 	on_vehicle_destroyed("m03_heli_destroyed_cb", M03_group.choppers.backup.vehicle) 
  1567. 	 
  1568. 	-- Start three separate vehicle entry threads so they are all entering at the same time 
  1569. 	for i,chopper in pairs(M03_choppers) do 
  1570. 		chopper.thread = thread_new("m03_wrapper_thread", vehicle_enter_group_teleport, chopper.pilots, chopper.vehicle) 
  1571. 	end 
  1572. 	 
  1573. 	for i,chopper in pairs(M03_choppers) do 
  1574. 		threads_wait_for_completion(chopper.thread) 
  1575. 	end 
  1576. 	 
  1577. 	-- Put the choppers in their starting positions 
  1578. 	m03_float_choppers() 
  1579. 		 
  1580. 	-- NOW add Shaundi and she won't go through a bunch of bad teleports 
  1581. 	m03_add_shaundi() 
  1582. end 
  1583.  
  1584. function m03_objective_protect_the_stash() 
  1585.  
  1586. 	-- keep Shaundi in the back of the warehouse	 
  1587. 	npc_leash_to_nav( M03_char.shaundi, M03_checkpoint.hold_your_ground.player_local, 5.0 ) 
  1588. 	 
  1589. 	-- let cops shoot from turrets 
  1590. 	set_cops_shooting_from_vehicles(true) 
  1591.  
  1592. 	-- send choppers in loops 
  1593. 	helicopter_fly_to_direct_loop(M03_group.choppers.pierce.vehicle, 15, "heli_loop<001>") 
  1594. 	helicopter_fly_to_direct_loop(M03_group.choppers.backup.vehicle, 5, "heli_loop<002>") 
  1595. 	 
  1596. 	-- load personas for pred-drone conversations 
  1597. 	m03_load_persona(M03_drone_voices.operator1) 
  1598. 	-- set callbacks so we know if the pred-drone has been fired 
  1599. 	on_attack_performed("m03_player_fired_weapon_cb", LOCAL_PLAYER) 
  1600. 	if coop_is_active() then 
  1601. 		on_attack_performed("m03_player_fired_weapon_cb", REMOTE_PLAYER) 
  1602. 	end 
  1603. 	 
  1604. 	thread_new("m03_convo", M03_convo.satellite_start) 
  1605.  
  1606. 	-- Play some awesome audio SP: shifted to here to try getting some audio going during the drone sequence to see how it feels 
  1607. 	audio_object_post_event("M03_Heli_Intro_Score", nil, nil, LOCAL_PLAYER) 
  1608.  
  1609. 	-- Send the player(s) to the satellite weapon 
  1610. 	M03_trigger.satellite_weapon.triggered = false 
  1611. 	--objective_text(0, M03_text.protect_the_stash, nil, nil, SYNC_ALL, OI_ASSET_DEFEND) 
  1612. 	objective_text(0, M03_text.use_satellite_weapon, nil, nil, SYNC_ALL, OI_ASSET_USE) 
  1613. 	group_create(M03_group.satellite_weapon.name, true) 
  1614. 	thread_yield() 
  1615. 	marker_add(M03_item.satellite_weapon, MINIMAP_ICON_USE, OI_ASSET_USE, OI_FLAGS_FULL) 
  1616. 	local add_waypoint = false 
  1617. 	local add_marker = false 
  1618. 	m03_set_trigger(M03_trigger.satellite_weapon.name, "m03_satellite_weapon_used_cb", add_waypoint, add_marker) 
  1619. 	 
  1620. 	repeat 
  1621. 		thread_yield() 
  1622. 	until (M03_trigger.satellite_weapon.triggered) 
  1623.  
  1624. 	-- Put both players into satellite weapon mode 
  1625. 	-- njr: let players put themselves in sat mode -- satellite_weapon_mode_enter(M03_checkpoint.helicopter_ride.player_local) 
  1626. 	 
  1627. 	-- Once one player has started using the satellite weapon, clear the objective 
  1628. 	objective_text_clear(0) 
  1629. 	 
  1630. 	objective_text(0, M03_text.protect_the_stash, nil, nil, SYNC_ALL, OI_ASSET_DEFEND) 
  1631. 	 
  1632. 	-- slowly move the helicopter into position 
  1633. 	marker_add(M03_group.choppers.bomb.vehicle, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND) 
  1634. 	marker_add(M03_group.choppers.pierce.vehicle, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND) 
  1635. 	marker_add(M03_group.choppers.backup.vehicle, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND) 
  1636. 	M03_group.choppers.bomb.thread = thread_new("m03_pickup_bomb_thread") 
  1637.  
  1638. 	M03_num_satellite_attackers = 5	-- start out light 
  1639. 	-- M03_all_satellite_groups 
  1640. 	M03_thread.satellite_attack = thread_new("m03_satellite_attackers_thread", M03_all_satellite_groups) 
  1641. 	 
  1642. 	-- a few seconds to play with the attackers 
  1643. 	delay(10.0) 
  1644. 	 
  1645. 	-- stop spawning 
  1646. 	M03_status.satellite_timer_elapsed = true 
  1647. 	while not thread_check_done(M03_thread.satellite_attack) do 
  1648. 		thread_yield() 
  1649. 	end 
  1650. 		 
  1651. 	-- start the grunts again 
  1652. 	M03_thread.satellite_attack = thread_new("m03_satellite_attackers_thread", M03_all_satellite_groups) 
  1653. 	 
  1654. 	-- send in some tanks 
  1655. 	for i,tank_groups in pairs(M03_tank_attacks) do 
  1656. 		 
  1657. 		-- pause for dramatic effect 
  1658. 		delay(2.0) 
  1659. 		 
  1660. 		for tank_index,group in pairs(tank_groups) do 
  1661. 			-- send in a tank (only target for a few seconds) 
  1662. 			group_create(group.name, true)		 
  1663. 			vehicle_enter_group_teleport(group.members, group.vehicle) 
  1664. 			 
  1665. 			-- put a kill marker on it 
  1666. 			marker_add(group.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAG_STICKY) 
  1667. 			on_vehicle_destroyed("m03_satellite_tank_killed_cb", group.vehicle) 
  1668. 			group.move_thread = thread_new( "m03_wrapper_thread", vehicle_pathfind_to, group.vehicle, group.dest, true ) 
  1669. 			-- tell them who to attack 
  1670. 			ai_add_enemy_target(group.members[1], M03_group.choppers.bomb.pilots[1], ATTACK_NOW_NEVER_LOSE, true) 
  1671. 			ai_add_enemy_target(group.members[2], M03_group.choppers.bomb.pilots[1], ATTACK_NOW_NEVER_LOSE, true) 
  1672. 			 
  1673. 			-- and tell them not to attack for a bit 
  1674. 			group.delay_gunner_thread = thread_new( "m03_tank_delay_gunner_thread", group ) 
  1675. 		end 
  1676. 		 
  1677. 		objective_text(0, "M03_OBJ_DESTROY_TANKS", nil, nil, SYNC_ALL, OI_ASSET_KILL) 
  1678. 		 
  1679. 		-- A Tank!  OMG! 
  1680. 		 
  1681. 		-- wait for tank(s) to be destroyed 
  1682. 		for tank_index,group in pairs(tank_groups) do 
  1683. 			while not vehicle_is_destroyed(group.vehicle) do 
  1684. 				thread_yield() 
  1685. 			end 
  1686. 			marker_remove(group.vehicle) 
  1687. 			release_to_world(group.name) 
  1688. 		end 
  1689. 	 
  1690. 		objective_text(0, M03_text.protect_the_stash, nil, nil, SYNC_ALL, OI_ASSET_DEFEND) 
  1691.  
  1692. 		-- more attackers!  -- AC TEST: These #s were 7 and 10 
  1693. 		if i == 1 then 
  1694. 			M03_num_satellite_attackers = 5 
  1695. 		else 
  1696. 			M03_num_satellite_attackers = 5 
  1697. 		end 
  1698. 		---- stop spawning 
  1699. 		--M03_status.satellite_timer_elapsed = true 
  1700. 		--while not thread_check_done(M03_thread.satellite_attack) do 
  1701. 		--	thread_yield() 
  1702. 		--end 
  1703. 		 
  1704. 		if i == 1 then 
  1705. 			M03_thread.satellite_convos = thread_new("m03_convo", M03_convo.stash_combat1) 
  1706. 		end 
  1707. 		 
  1708. 		if i == 2 then 
  1709. 			if M03_status.convo_is_playing then 
  1710. 				audio_conversation_end(M03_convo.stash_combat1.handle) 
  1711. 			end 
  1712. 			M03_thread.satellite_convos = thread_new("m03_convo", M03_convo.stash_combat2) 
  1713. 		end 
  1714. 		 
  1715. 	end 
  1716. 	 
  1717. 	-- we can stop spawning new dudes now 
  1718. 	M03_status.satellite_timer_elapsed = true 
  1719. 	 
  1720. 	-- a little pause for the fallen tanks 
  1721. 	delay(3.0) 
  1722. 	 
  1723. 	-- kill attack thread and remove any leftover markers 
  1724. 	m03_forced_satellite_end() 
  1725.  
  1726. 	delay(1) 
  1727.  
  1728. 	-- no more satellite for U! 
  1729. 	if group_is_loaded(M03_group.satellite_weapon.name) then 
  1730. 		group_destroy(M03_group.satellite_weapon.name) 
  1731. 	end 
  1732. 	 
  1733. 	-- done talking 
  1734. 	cleanup_conversations(M03_convo) 
  1735.  
  1736. 	-- If the players haven't left satellite weapon mode yet, force them out of it 
  1737. 	satellite_weapon_mode_exit() 
  1738. 	 
  1739. 	 
  1740. 	-- done with these callbacks 
  1741. 	on_attack_performed("", LOCAL_PLAYER) 
  1742. 	if coop_is_active() then 
  1743. 		on_attack_performed("", REMOTE_PLAYER) 
  1744. 	end 
  1745. 	 
  1746. 	-- Shaundi is free again 
  1747. 	npc_leash_remove( M03_char.shaundi ) 
  1748. 	 
  1749. 	-- done with the drone operators 
  1750. 	m03_unload_persona(M03_drone_voices.operator1) 
  1751. 	 
  1752. 	m01_restore_heli(M03_group.choppers.bomb.vehicle) 
  1753. 	m01_restore_heli(M03_group.choppers.pierce.vehicle) 
  1754. 	m01_restore_heli(M03_group.choppers.backup.vehicle) 
  1755.  
  1756. 	-- Turn helicopters invulnerable till you get in them 
  1757. 	turn_invulnerable(M03_group.choppers.bomb.vehicle) 
  1758. 	turn_invulnerable(M03_group.choppers.pierce.vehicle) 
  1759. 	turn_invulnerable(M03_group.choppers.backup.vehicle) 
  1760. 	 
  1761. 	objective_text_clear(0) 
  1762. end 
  1763. 								 
  1764. 								----------------------------------------------- 
  1765. 								 
  1766. 								--[[                                    ]]-- 
  1767. 								--[[ FIFTH CHECKPOINT (HELICOPTER RIDE) ]]-- 
  1768. 								--[[                                    ]]-- 
  1769. 								 
  1770. function m03_initialize_helicopter_ride() 
  1771. 	group_create(M03_group.shaundi.name, true) 
  1772. 	 
  1773. 	group_create(M03_group.warehouse_cover_vehicles.name, true) 
  1774.  
  1775. 	teleport_coop(M03_checkpoint.helicopter_ride.player_local, M03_checkpoint.helicopter_ride.player_remote, true) 
  1776. 	-- teleport Shaundi to where you are going to be 
  1777. 	teleport(M03_char.shaundi, M03_checkpoint.helicopter_ride.player_local, nil, nil, 0.0, 0.0, 1.4) 
  1778.  
  1779. 	group_create(M03_group.choppers.name, true) 
  1780. 	group_create(M03_group.chopper_pierce_normal.name, true) 
  1781. 	on_vehicle_destroyed("m03_chopper_destroyed_cb", M03_group.choppers.pierce.vehicle) 
  1782. 	on_vehicle_destroyed("m03_bomb_destroyed_cb", M03_group.choppers.bomb.vehicle) 
  1783. 	 
  1784. 	-- Start three separate vehicle entry threads so they are all entering at the same time 
  1785. 	for i,chopper in pairs(M03_choppers) do 
  1786. 		chopper.thread = thread_new("m03_wrapper_thread", vehicle_enter_group_teleport, chopper.pilots, chopper.vehicle) 
  1787. 	end 
  1788. 	 
  1789. 	for i,chopper in pairs(M03_choppers) do 
  1790. 		threads_wait_for_completion(chopper.thread) 
  1791. 	end 
  1792. 	 
  1793. 	vehicle_suppress_npc_exit(M03_group.choppers.pierce.vehicle, true) 
  1794. 	 
  1795. 	-- Put the choppers in their starting positions 
  1796. 	m03_float_choppers() 
  1797. 	 
  1798. 	-- NOW add Shaundi and she won't go through a bunch of bad teleports 
  1799. 	m03_add_shaundi() 
  1800. 	 
  1801. 	inv_weapon_add_temporary(LOCAL_PLAYER, M03_weapon.satellite_drone_weapon, 1, true) 
  1802. 	if (coop_is_active()) then 
  1803. 		inv_weapon_add_temporary(REMOTE_PLAYER, M03_weapon.satellite_drone_weapon, 1, true) 
  1804. 	end 
  1805. 	 
  1806. 	-- Play some awesome audio 
  1807. 	audio_object_post_event("M03_Heli_Intro_Score", nil, nil, LOCAL_PLAYER) 
  1808. end 
  1809.  
  1810. function m03_objective_helicopter_ride() 
  1811.  
  1812. 	-- no more drone gun for you 
  1813. 	group_create_hidden(M03_group.fly_home_enemies.name, true) 
  1814.  
  1815. 	for i,chopper in pairs(M03_vehicle.fly_home_enemies) do 
  1816. 		M03_thread.fly_home_enemy_setup[i] = thread_new("m03_fly_home_enemy_setup_thread", i, chopper) 
  1817. 	end 
  1818. 	 
  1819. 	thread_new("m03_convo", M03_convo.get_in_chopper) 
  1820.  
  1821. 	tutorial_start("sprint", 2000) --SP: tell the player how to sprint to get to the chopper fast! 
  1822. 	 
  1823. 	-- TEST 
  1824. 	--notoriety_set_min("police", 5) 
  1825. 	notoriety_set_min_and_max("police", 3, 3) 
  1826. 	-- END TEST 
  1827. 	objective_text(0, M03_text.go_to_chopper, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1828.  
  1829. 	M03_thread.landing = thread_new("m03_wrapper_thread", helicopter_fly_to_direct, M03_group.choppers.pierce.vehicle, -1, M03_navpoint.heli_landing_pos) 
  1830. 	repeat  
  1831. 		thread_yield() 
  1832. 	until (get_dist(M03_group.choppers.pierce.vehicle, M03_navpoint.heli_landing_pos) < 5) 
  1833. 	thread_kill(M03_thread.landing) 
  1834.  
  1835. 	-- This line was not recorded 
  1836. --	audio_play_persona_line(M03_char.pierce, "M03_Heli_Rail_Start") 
  1837.  
  1838. 	marker_add(M03_group.choppers.pierce.vehicle, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL) 
  1839.  
  1840. 	-- Wait until the player gets close to the chopper before moving on 
  1841. 	M03_trigger.enter_heli.triggered = false 
  1842. 	local add_waypoint = false 
  1843. 	local add_marker = false 
  1844. 	m03_set_trigger(M03_trigger.enter_heli.name, "m03_enter_heli_cb", add_waypoint, add_marker) 
  1845. 	 
  1846. 	repeat  
  1847. 		thread_yield()  
  1848. 	until (M03_trigger.enter_heli.triggered == true) 
  1849.  
  1850. 	marker_remove(M03_group.choppers.pierce.vehicle) 
  1851. 	 
  1852. 	objective_text_clear(0) 
  1853.  
  1854. 	-- Here's what will happen when you get to the trigger: 
  1855. 	fade_out(0.5) 
  1856. 	fade_out_block() 
  1857. 	 
  1858. 	-- Stop the awesome audio 
  1859. 	audio_object_post_event("M03_Heli_Intro_Score_Stop", nil, nil, LOCAL_PLAYER) 
  1860. 	 
  1861. 	-- don't be in satellite mode 
  1862. 	satellite_weapon_mode_exit()	 
  1863. 	-- make sure Shaundi stays alive 
  1864. 	npc_revive(M03_char.shaundi) 
  1865. 	if character_is_in_vehicle(M03_char.shaundi) then 
  1866. 		vehicle_exit(M03_char.shaundi) 
  1867. 	end 
  1868. 	if character_is_in_vehicle(LOCAL_PLAYER) then 
  1869. 		vehicle_exit(LOCAL_PLAYER) 
  1870. 	end 
  1871. 	if coop_is_active() and character_is_in_vehicle(REMOTE_PLAYER) then 
  1872. 		vehicle_exit(REMOTE_PLAYER) 
  1873. 		while character_is_in_vehicle(REMOTE_PLAYER) do 
  1874. 			thread_yield() 
  1875. 		end 
  1876. 	end 
  1877. 	cleanup_callbacks({ M03_group.choppers.pierce.vehicle }) 
  1878. 	-- make sure everyone is out of their vehicles 
  1879. 	while character_is_in_vehicle(LOCAL_PLAYER) or character_is_in_vehicle(M03_char.shaundi) do 
  1880. 		thread_yield() 
  1881. 	end	 
  1882. 	 
  1883. 	-- make sure everyone has the right weapons 
  1884. 	local ammo = 1 
  1885. 	local equip_now = true 
  1886. 	local unlimited_ammo = true 
  1887. 	local dual_wielding = false 
  1888. 	local force_override = false 
  1889. 	inv_item_add(M03_weapon.helicopter_ride, ammo, M03_char.shaundi, equip_now) 
  1890. 	if (coop_is_active()) then 
  1891. 		inv_weapon_add_temporary(REMOTE_PLAYER, M03_weapon.helicopter_ride, 1, unlimited_ammo, equip_now, dual_wielding, force_override, 0x7) 
  1892. 	end 
  1893. 	inv_weapon_add_temporary(LOCAL_PLAYER, M03_weapon.helicopter_ride, 1, unlimited_ammo, equip_now, dual_wielding, force_override, 0x7) 
  1894. 	inv_weapon_disable_all_but_this_slot(WEAPON_SLOT_RIFLE) 
  1895. 	 
  1896. 	-- get in the damn heli Shaundi 
  1897. 	follower_make_independent(M03_char.shaundi, true) 
  1898. 	 
  1899. 	-- Put the player(s) into Pierce's chopper and lock them there 
  1900. 	-- (Note: Seat 0 is the driver's seat, seat 1 is the passenger's seat, 2 and 3 are the gunner seats) 
  1901. 	local shaundi_seat = 3 
  1902. 	local block = true 
  1903. 	if (coop_is_active()) then 
  1904. 		shaundi_seat = 1 
  1905. 		while not vehicle_enter_teleport(REMOTE_PLAYER, M03_group.choppers.pierce.vehicle, 3, block) do 
  1906. 			thread_yield() 
  1907. 		end 
  1908. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, false) 
  1909. 	end 
  1910. 	-- seat Shaundi first so she doesn't follow the player in 
  1911. 	while not vehicle_enter_teleport(M03_char.shaundi, M03_group.choppers.pierce.vehicle, shaundi_seat, block) do 
  1912. 		thread_yield() 
  1913. 	end 
  1914. 	 
  1915. 	while not vehicle_enter_teleport(LOCAL_PLAYER, M03_group.choppers.pierce.vehicle, 2, block) do 
  1916. 		thread_yield() 
  1917. 	end 
  1918. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, false) 
  1919. 	 
  1920. 	-- put it in the air 
  1921. 	m03_float_chopper(M03_group.choppers.pierce, M03_group.choppers.pierce.float_nav) 
  1922. 	 
  1923. 	-- no more destroying your heli 
  1924. 	turn_invulnerable(M03_group.choppers.pierce.vehicle) 
  1925. 	turn_invulnerable(M03_char.shaundi) 
  1926. 	 
  1927. 	-- The other helicopters can be damaged now 
  1928. 	turn_vulnerable(M03_group.choppers.bomb.vehicle) 
  1929. 	turn_vulnerable(M03_group.choppers.backup.vehicle) 
  1930. 	 
  1931. 	fade_in(0.5) 
  1932. 	 
  1933. 	M03_status.helis_destroyed = 0 
  1934.  
  1935. 	-- Now have all the helicopters rise up, and Pierce will fly to Shaundi's house while the player fights off the attacking choppers 
  1936. 	objective_text(0, M03_text.protect_the_bomb, nil, nil, SYNC_ALL, OI_ASSET_DEFEND) 
  1937.  
  1938. 	-- Show the player(s) which vehicle (the one carrying the bomb) they need to protect 
  1939. 	marker_add(M03_group.choppers.bomb.vehicle, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND, OI_FLAGS_FULL) 
  1940.  
  1941. 	-- Post an audio event to reduce the helicopter audio complexity 
  1942. 	audio_object_post_event("M03_Heli_Rail_Sequence", nil, nil, LOCAL_PLAYER) 
  1943. 	 
  1944. 	-- Post an audio event to start the Rail Music 
  1945. 	audio_object_post_event("M03_Heli_Rail_Score_Start", nil, nil, LOCAL_PLAYER) 
  1946. 	 
  1947. 	group_show(M03_group.fly_home_enemies.name) 
  1948.  
  1949. 	-- Keep the helicopter somewhat level 
  1950. 	helicopter_set_max_bank_angle(M03_group.choppers.pierce.vehicle, 0.25) 
  1951. 	 
  1952. 	local leader_speed = 20 
  1953. 	local follower_speed = 50 
  1954. 	 
  1955. 	-- DEBUG: TAKE THIS OUT, or shaundi will be standing up in the helicopter 
  1956. --	inv_item_remove_all(M03_char.shaundi) 
  1957. 		 
  1958. 	M03_trigger.fly_home_secondary_enemies.triggered = false 
  1959. 	add_waypoint = false 
  1960. 	add_marker = false 
  1961. 	M03_status.fly_home_played = false 
  1962. 	--m03_set_trigger(M03_trigger.fly_home_secondary_enemies.name, "m03_spawn_secondary_enemies_cb", add_waypoint, add_marker) 
  1963. 	M03_trigger.blow_up_helis.triggered = false 
  1964. 	m03_set_trigger(M03_trigger.blow_up_helis.name, "m03_blow_up_helis_cb", add_waypoint, add_marker) 
  1965. 	 
  1966. 	M03_kill_heli = M03_Kill_Heli_Navs[1] 
  1967. 	-- Saints 
  1968. 	M03_thread.fly_home[1] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_dont_stop, M03_group.choppers.bomb.vehicle, 50, M03_scripted_path.fly_home_bomb[1]) 
  1969. 	M03_thread.fly_home[2] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_group.choppers.pierce.vehicle, 70, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_pierce[1], 3) 
  1970. 	M03_thread.fly_home[3] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_group.choppers.backup.vehicle, 70, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_backup[1], 0) 
  1971. 	-- Give the player a few secs to look around 
  1972. 	--delay(3.0) 
  1973. 	-- Set up so that helicopters are hovering 
  1974. 	thread_new("m03_secondary_heli_hover_setup") 
  1975. 	-- Enemies 
  1976. 	M03_thread.fly_home_enemy_chase[1] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[1], 90, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy1[1], 4) 
  1977. 	M03_thread.fly_home_enemy_chase[2] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct, M03_vehicle.fly_home_enemies[2], 70, M03_scripted_path.fly_home_enemy2[1]) 
  1978. 	M03_thread.fly_home_enemy_chase[3] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[3], 90, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy3[1], 6) 
  1979. 	M03_thread.fly_home_enemy_chase[4] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[4], 70, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy4[1], 4) 
  1980. 	 
  1981. 	-- Add Object indicators 
  1982. 	marker_add(M03_vehicle.fly_home_enemies[1], MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  1983. 	marker_add(M03_vehicle.fly_home_enemies[2], MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  1984. 	marker_add(M03_vehicle.fly_home_enemies[3], MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  1985. 	marker_add(M03_vehicle.fly_home_enemies[4], MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  1986. 	 
  1987. 	-- For when they are almost dead and when they are destroyed 
  1988. 	for i, chopper in pairs (M03_vehicle.fly_home_enemies) do 
  1989. 		on_damage("m03_crash_heli", M03_vehicle.fly_home_enemies[i], 0.22) 
  1990. 		on_vehicle_destroyed("m03_heli_enemy_destroyed_cb", M03_vehicle.fly_home_enemies[i]) 
  1991. 	end 
  1992.  
  1993. 	M03_thread.fly_home_convo = thread_new("m03_convo", M03_convo.protect_bomb) 
  1994. 	 
  1995. 	-- get chatty 
  1996. 	on_take_damage("m03_heli_chatter_cb", M03_group.choppers.bomb.vehicle) 
  1997. 	on_take_damage("m03_heli_chatter_cb", M03_group.choppers.pierce.vehicle) 
  1998. 	on_take_damage("m03_heli_chatter_cb", M03_group.choppers.backup.vehicle) 
  1999. 	 
  2000. 	M03_thread.chatter = thread_new("m03_heli_chatter_thread") 
  2001. 	 
  2002. 	threads_wait_for_completion(M03_thread.fly_home[1]) 
  2003. 	 
  2004. 	-- Allow helis to shoot again 
  2005. 	for i,chopper in pairs(M03_vehicle.fly_home_enemies) do 
  2006. 		npc_combat_enable(M03_char.fly_home_enemies[i][1], true) 
  2007. 		npc_combat_enable(M03_char.fly_home_enemies[i][2], true) 
  2008. 		ai_add_enemy_target(M03_char.fly_home_enemies[i][1], M03_group.choppers.bomb.pilots[1], ATTACK_NOW, true) 
  2009. 		ai_add_enemy_target(M03_char.fly_home_enemies[i][2], M03_group.choppers.bomb.pilots[1], ATTACK_NOW, true) 
  2010. 	end 
  2011. 	M03_kill_heli = M03_Kill_Heli_Navs[2] 
  2012. 	-- Saints 
  2013. 	M03_thread.fly_home[1] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_dont_stop, M03_group.choppers.bomb.vehicle, leader_speed, M03_scripted_path.fly_home_bomb[2]) 
  2014. 	M03_thread.fly_home[2] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_group.choppers.pierce.vehicle, follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_pierce[2], 3) 
  2015. 	M03_thread.fly_home[3] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_group.choppers.backup.vehicle, follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_backup[2], 0) 
  2016. 	--Enemies 
  2017. 	M03_thread.fly_home_enemy_chase[1] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[1], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy1[2], 6) 
  2018. 	M03_thread.fly_home_enemy_chase[2] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[2], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy2[2], 3) 
  2019. 	M03_thread.fly_home_enemy_chase[3] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[3], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy3[2], 1) 
  2020. 	M03_thread.fly_home_enemy_chase[4] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[4], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy4[2], 4) 
  2021. 	M03_thread.fly_home_enemy_chase[5] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[5], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy5[1], 2) 
  2022. 	M03_thread.fly_home_enemy_chase[6] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[6], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy6[1], 5) 
  2023. 	 
  2024. 	-- New OI	 
  2025. 	marker_add(M03_vehicle.fly_home_enemies[5], MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  2026. 	marker_add(M03_vehicle.fly_home_enemies[6], MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  2027. 	 
  2028. 	threads_wait_for_completion(M03_thread.fly_home[1]) 
  2029. 	 
  2030. 	M03_kill_heli = M03_Kill_Heli_Navs[3] 
  2031. 	-- Saints 
  2032. 	M03_thread.fly_home[1] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_dont_stop, M03_group.choppers.bomb.vehicle, 50, M03_scripted_path.fly_home_bomb[3]) 
  2033. 	M03_thread.fly_home[2] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_group.choppers.pierce.vehicle, 70, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_pierce[3], 3) 
  2034. 	M03_thread.fly_home[3] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_group.choppers.backup.vehicle, 70, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_backup[3], 0) 
  2035. 	-- Enemies 
  2036. 	M03_thread.fly_home_enemy_chase[1] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[1], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy1[3], 4) 
  2037. 	M03_thread.fly_home_enemy_chase[2] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[2], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy2[3], 1) 
  2038. 	M03_thread.fly_home_enemy_chase[3] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[3], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy3[3], 2) 
  2039. 	M03_thread.fly_home_enemy_chase[4] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[4], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy4[3], 6) 
  2040. 	M03_thread.fly_home_enemy_chase[5] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[5], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy5[2], 4) 
  2041. 	M03_thread.fly_home_enemy_chase[6] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[6], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy6[2], 3) 
  2042. 	M03_thread.fly_home_enemy_chase[7] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[7], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy7[1], 6) 
  2043. 	M03_thread.fly_home_enemy_chase[8] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[8], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy8[1], 5) 
  2044. 	 
  2045. 	-- New OI	 
  2046. 	marker_add(M03_vehicle.fly_home_enemies[7], MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  2047. 	marker_add(M03_vehicle.fly_home_enemies[8], MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  2048. 	 
  2049. 	threads_wait_for_completion(M03_thread.fly_home[1]) 
  2050. 	 
  2051. 	M03_kill_heli = M03_Kill_Heli_Navs[4] 
  2052. 	-- Saints 
  2053. 	M03_thread.fly_home[1] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_dont_stop, M03_group.choppers.bomb.vehicle, leader_speed, M03_scripted_path.fly_home_bomb[4]) 
  2054. 	M03_thread.fly_home[2] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_group.choppers.pierce.vehicle, follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_pierce[4], 3) 
  2055. 	M03_thread.fly_home[3] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_group.choppers.backup.vehicle, follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_backup[4], 4) 
  2056. 	 
  2057. 	-- Enemies 
  2058. 	M03_thread.fly_home_enemy_chase[1] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[1], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy1[4], 3) 
  2059. 	M03_thread.fly_home_enemy_chase[2] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[2], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy2[4], 5) 
  2060. 	M03_thread.fly_home_enemy_chase[3] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[3], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy3[4], 4) 
  2061. 	M03_thread.fly_home_enemy_chase[4] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[4], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy4[4], 2) 
  2062. 	M03_thread.fly_home_enemy_chase[5] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[5], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy5[3], 3) 
  2063. 	M03_thread.fly_home_enemy_chase[6] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[6], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy6[3], 4) 
  2064. 	M03_thread.fly_home_enemy_chase[7] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[7], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy7[2], 6) 
  2065. 	M03_thread.fly_home_enemy_chase[8] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[8], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy8[2], 4) 
  2066. 	M03_thread.fly_home_enemy_chase[9] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[9], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy9[1], 2) 
  2067. 	M03_thread.fly_home_enemy_chase[10] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, M03_vehicle.fly_home_enemies[10], follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_enemy10[1], 5) 
  2068. 	 
  2069. 	-- New OI	 
  2070. 	marker_add(M03_vehicle.fly_home_enemies[9], MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  2071. 	marker_add(M03_vehicle.fly_home_enemies[10], MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  2072. 	 
  2073. 	threads_wait_for_completion(M03_thread.fly_home[1]) 
  2074.  
  2075. 	-- Switch music 
  2076. 	audio_object_post_event("M03_Heli_Rail_Sequence_Fade", nil, nil, LOCAL_PLAYER)	 
  2077. 	 
  2078. 	-- Move this convo to happen earlier 
  2079. --	M03_thread.fly_home_convo = thread_new("m03_convo", M03_convo.fly_home) 
  2080.  
  2081. 	repeat  
  2082. 		thread_yield() 
  2083. 	until (get_dist(M03_group.choppers.bomb.vehicle, M03_navpoint.shaundi_house) < 25) 
  2084.  
  2085. 	threads_wait_for_completion(M03_thread.fly_home[1]) 
  2086.  
  2087. 	M03_thread.fly_home[1] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct, M03_group.choppers.bomb.vehicle, -1, M03_navpoint.shaundi_house) 
  2088.  
  2089. 	repeat 
  2090. 		thread_yield() 
  2091. 	until (get_dist(M03_group.choppers.bomb.vehicle, M03_navpoint.shaundi_house) < 20) 
  2092.  
  2093. 	-- This line is now obsolete 
  2094. --	audio_play_persona_line(M03_char.shaundi, "M03_Arrive") 
  2095.  
  2096. 	-- This delay will be replaced with animations or a cutscene of the bomb being removed from the helicopter 
  2097. 	delay(5) 
  2098.  
  2099. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, true) 
  2100. 	if (coop_is_active()) then 
  2101. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, true) 
  2102. 	end 
  2103. 	 
  2104. 	turn_vulnerable(M03_char.shaundi) 
  2105. 	inv_weapon_disable_all_slots(false) 
  2106. 	 
  2107. 	-- Post an audio event to stop the custom heli audio 
  2108. 	audio_object_post_event("M03_Heli_Rail_Sequence_Stop", nil, nil, LOCAL_PLAYER) 
  2109. end 
  2110.  
  2111. -------------------------------------------------------------------------------------------------- 
  2112.  
  2113. 								--[[************************************]]-- 
  2114. 								--[[                                    ]]-- 
  2115. 								--[[ Miscellaneous m03 Helper Functions ]]-- 
  2116. 								--[[                                    ]]-- 
  2117. 								--[[************************************]]-- 
  2118.  
  2119. -- The player that finished m02 will have these weapons. 
  2120. -- The coop client that just joined will not, so we give them again. 
  2121. -- Just need to give at the first checkpoint.  Afterwards they should be saved 
  2122. -- 
  2123. function m03_give_players_weapons() 
  2124. 	for i, weapon in pairs(M03_start_inventory) do 
  2125. 		inv_item_add(weapon.name, weapon.reserve_ammo, LOCAL_PLAYER) 
  2126. 		inv_item_add(weapon.name, weapon.reserve_ammo, REMOTE_PLAYER) 
  2127. 	end 
  2128. end 
  2129.  
  2130. -- Set a trigger enabled with a mission marker 
  2131. -- 
  2132. -- trigger:				(string) Name of the trigger 
  2133. -- trigger_callback:	(string) Function name to call when trigger is activated 
  2134. -- add_waypoint:		(bool, optional) true to add a waypoint, false otherwise (defaults to true) 
  2135. -- add_marker:			(bool, optional) true to add a marker, false otherwise (defaults to true) 
  2136. -- 
  2137. function m03_set_trigger(trigger, trigger_callback, add_waypoint, add_marker) 
  2138. 	trigger_enable(trigger, true) 
  2139. 	if (add_waypoint ~= false) then 
  2140. 		mission_waypoint_add(trigger) 
  2141. 	end 
  2142. 	if (add_marker ~= false) then 
  2143. 		marker_add_trigger(trigger, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  2144. 	end 
  2145. 	on_trigger(trigger_callback, trigger) 
  2146. end 
  2147.  
  2148. -- Disable trigger 
  2149. -- 
  2150. -- trigger:		(string) Name of the trigger 
  2151. -- 
  2152. function m03_clear_trigger(trigger) 
  2153. 	on_trigger("", trigger) 
  2154. 	trigger_enable(trigger, false) 
  2155. 	marker_remove_trigger(trigger, SYNC_ALL) 
  2156. 	mission_waypoint_remove() 
  2157. end 
  2158.  
  2159. -- Disable all m03 triggers 
  2160. function m03_clear_trigger_table() 
  2161. 	for i,trigger_table in pairs(M03_trigger) do 
  2162. 		m03_clear_trigger(trigger_table.name) 
  2163. 	end 
  2164. end 
  2165.  
  2166. function m03_continuous_spawns_stop(spawn_group) 
  2167. 	call_function_on_each_member(continuous_spawn_stop, spawn_group) 
  2168. end 
  2169.  
  2170. -- Add a Shaundi as a crew member with all associated goodness 
  2171. -- 
  2172. function m03_add_shaundi() 
  2173. 	party_add(M03_char.shaundi, LOCAL_PLAYER) 
  2174. 	follower_set_can_abandon( M03_char.shaundi, true ) 
  2175. 	on_dismiss("m03_failure_dismissed_cb", M03_char.shaundi) 
  2176. 	on_death("m03_shaundi_killed_cb", M03_char.shaundi) 
  2177. end 
  2178.  
  2179. -- Play an audio conversation 
  2180. -- 
  2181. -- convo:				(table) the conversation to play - contains a name, handle, and table of non-player speakers 
  2182. -- 
  2183. function m03_convo(convo) 
  2184. 	if (convo == nil) then 
  2185. 		return 
  2186. 	end 
  2187. 	-- If another conversation is already playing, wait for it to finish 
  2188. 	if (M03_status.convo_is_playing) then 
  2189. 		repeat  
  2190. 			thread_yield()  
  2191. 		until (not M03_status.convo_is_playing) 
  2192. 	end 
  2193. 	M03_status.convo_is_playing = true 
  2194. 	-- Load the conversation 
  2195. 	if (convo.load_direct) then 
  2196. 		convo.handle = audio_conversation_load_direct(convo.name) 
  2197. 	else 
  2198. 		convo.handle = audio_conversation_load(convo.name) 
  2199. 	end 
  2200. 	-- Play the conversation 
  2201. 	audio_conversation_play(convo.handle) 
  2202. 	delay(1) 
  2203. 	-- Wait for the conversation to end 
  2204. 	audio_conversation_wait_for_end(convo.handle) 
  2205. 	convo.handle = INVALID_CONVERSATION_HANDLE 
  2206. 	M03_status.convo_is_playing = false 
  2207. end 
  2208.  
  2209. -- float a chopper at a given navpoint 
  2210. -- 
  2211. -- chopper_table:		(table)  chopper information 
  2212. -- float_nav:			(string) name of navpoint to float the chopper at 
  2213. -- 
  2214. function m03_float_chopper(chopper_table, float_nav) 
  2215. 	teleport_vehicle(chopper_table.vehicle, float_nav) 
  2216. 	thread_yield() 
  2217. 	 
  2218. 	-- tell choppers to move there so they stay in place 
  2219. 	chopper_table.thread = thread_new( "m03_wrapper_thread", helicopter_fly_to_direct, chopper_table.vehicle, -1,  float_nav) 
  2220. end 
  2221.  
  2222. -- make sure choppers are at the floating positions 
  2223. -- 
  2224. function m03_float_choppers() 
  2225. 	-- teleport choppers into position 
  2226. 	for i,chopper in pairs(M03_choppers) do 
  2227. 		m03_float_chopper(chopper, chopper.float_nav) 
  2228. 	end	 
  2229. end 
  2230.  
  2231. -- if we don't have guards left to kill, set the objective to go to warehouse 
  2232. -- 
  2233. function m03_set_enter_warehouse_objective() 
  2234. 	if (M03_warehouse_guards_alive == 0) then 
  2235. 		objective_text(0, M03_text.find_weapons_cache, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  2236. 	 
  2237. 		if not M03_status.warehouse_objective then 
  2238. 			-- mark trigger so you know where to go 
  2239. 			local add_waypoint = false 
  2240. 			m03_set_trigger(M03_trigger.weapons_cache.name, "m03_weapons_cache_trigger_cb", add_waypoint) 
  2241. 			M03_status.warehouse_objective = true 
  2242. 		end 
  2243. 	end 
  2244. end 
  2245.  
  2246. -- if we have guards left to kill, set the objective to kill guards 
  2247. -- 
  2248. function m03_set_kill_warehouse_guards_objective() 
  2249. 	if (M03_warehouse_guards_alive > 0) then 
  2250. 		objective_text(0, M03_text.kill_guards, "", "", SYNC_ALL, OI_ASSET_KILL) 
  2251. 		-- clear trigger stuff 
  2252. 		m03_clear_trigger(M03_trigger.weapons_cache.name) 
  2253. 		M03_status.warehouse_objective = false 
  2254. 	end 
  2255. end 
  2256.  
  2257. -- setup the waves of toops and triggers to move them around 
  2258. function m03_setup_warehouse_guards() 
  2259.  
  2260. 	-- Spawn the National Guard guys 
  2261. 	group_create(M03_group.armory_guards.name, true) 
  2262. 	 
  2263. 	M03_warehouse_guards_alive = 0 
  2264. 	M03_warehouse_guards_killed = 0 
  2265. 	M03_warehouse_triggers_left = 0 
  2266. 	 
  2267. 	local add_waypoint = false 
  2268. 	local add_marker = false 
  2269. 	for i,wave_table in pairs(M03_warehouse_guard_wave) do 
  2270. 		wave_table.trigger.triggered = false 
  2271. 		-- set trigger to make them move and add to the killing 
  2272. 		m03_set_trigger(wave_table.trigger.name, "m03_warehouse_advance_cb", add_waypoint, add_marker) 
  2273. 		-- mark this trigger as 'armed' 
  2274. 		M03_warehouse_triggers_left = M03_warehouse_triggers_left + 1 
  2275. 	end 
  2276. 	 
  2277. end 
  2278.  
  2279. -- cleanup the waves of toops and triggers to move them around 
  2280. function m03_cleanup_warehouse_guards() 
  2281. 	if group_is_loaded(M03_group.armory_guards.name) then 
  2282. 		for i,wave_table in pairs(M03_warehouse_guard_wave) do 
  2283. 			for j,guard in pairs(wave_table.members) do 
  2284. 				on_death("", guard) 
  2285. 				on_detection("", guard) 
  2286. 				on_attack_performed("", guard) 
  2287. 			end 
  2288. 		end 
  2289. 		group_destroy(M03_group.armory_guards.name) 
  2290. 	end 
  2291. end 
  2292.  
  2293. -- Spawn tanks and get the guards in them 
  2294. -- 
  2295. function m03_spawn_tanks() 
  2296. 	for i,group in pairs(M03_tanks) do 
  2297. 		group_create(group.name, true)		 
  2298. 		vehicle_enter_group_teleport(group.members, group.vehicle) 
  2299. 		vehicle_disable_chase(group.vehicle, true)	-- Stay.  Good tank. 
  2300. 	end 
  2301. 	-- await further orders 
  2302. end 
  2303.  
  2304. -- Roll tanks to their destinations 
  2305. -- 
  2306. function m03_deploy_tanks() 
  2307. 	for i,group in pairs(M03_tanks) do 
  2308. 		group.move_thread = thread_new( "m03_wrapper_thread", vehicle_pathfind_to, group.vehicle, group.dest, true ) 
  2309. 	end 
  2310. 	-- await further orders 
  2311. end 
  2312.  
  2313. -- destroy all of the tanks 
  2314. -- 
  2315. function m03_nuke_tanks() 
  2316. 	for i,group in pairs(M03_tanks) do 
  2317. 		-- destroy each tank 
  2318. 		vehicle_detonate(group.vehicle) 
  2319. 		-- release to world so we can respawn them 
  2320. 		release_to_world(group.name) 
  2321. 	end 
  2322. end 
  2323.  
  2324. -- remove markers and repair the helicopter 
  2325. -- 
  2326. -- heli_name:	(string) helicopter to restore 
  2327. function m01_restore_heli(heli_name) 
  2328. 	-- if the vehicle blew up this frame (don't laugh, it has happened), then it can't be repaired 
  2329. 	while vehicle_is_destroyed(heli_name) do 
  2330. 		-- stall until the callbacks kick in 
  2331. 		thread_yield() 
  2332. 	end 
  2333. 	 
  2334. 	marker_remove(heli_name) 
  2335. 	vehicle_repair(heli_name) 
  2336. end 
  2337.  
  2338. -- load a 2d persona 
  2339. -- 
  2340. -- persona_data:	(table) table containing persona_name and persona_id to load 
  2341. function m03_load_persona(persona_data) 
  2342. 	persona_data.persona_id = audio_persona_load_2d(persona_data.persona_name) 
  2343. end 
  2344.  
  2345. -- unload persona 
  2346. -- 
  2347. -- persona_data:	(table) table containing the persona_id to unload 
  2348. function m03_unload_persona(persona_data) 
  2349. 	if (persona_data.persona_id ~= INVALID_PERSONA_HANDLE) then 
  2350. 		audio_persona_remove_2d(persona_data.persona_id) 
  2351. 		persona_data.persona_id = INVALID_PERSONA_HANDLE 
  2352. 	end 
  2353. end 
  2354.  
  2355. -- kill satellite reinforcemetns thread and supporting threads 
  2356. -- Remove any markers and free groups to world 
  2357. -- 
  2358. function m03_forced_satellite_end() 
  2359. 	-- kill the main thread 
  2360. 	thread_kill(M03_thread.satellite_attack) 
  2361. 	 
  2362. 	-- clean up any leftover groups 
  2363. 	for sa_index,spawn_group in pairs(M03_all_satellite_groups) do 
  2364. 		-- remove callback 
  2365. 		on_vehicle_destroyed("", spawn_group.vehicle) 
  2366. 		-- don't need this marker anymore 
  2367. 		marker_remove(spawn_group.vehicle) 
  2368. 		-- release the whole group 
  2369. 		release_to_world(spawn_group.name) 
  2370. 		-- kill the thread 
  2371. 		thread_kill(spawn_group.thread) 
  2372. 	end 
  2373. 	 
  2374. 	-- make sure tanks don't have leftover markers/callbacks 
  2375. 	for tank_index,tank in pairs(M03_tanks) do 
  2376. 		on_vehicle_destroyed("", tank.vehicle) 
  2377. 		marker_remove(tank.vehicle) 
  2378. 	end 
  2379. end 
  2380.  
  2381. -- Turn off traffic splines around the armory 
  2382. -- 
  2383. function m03_traffic_off() 
  2384. 	sidewalk_disable_nodes(M03_trigger.traffic.name, true) 
  2385. 	traffic_disable_lanes(M03_trigger.traffic.name, true) 
  2386. 	sidewalk_disable_nodes(M03_trigger.traffic1.name, true) 
  2387. 	traffic_disable_lanes(M03_trigger.traffic1.name, true) 
  2388. end 
  2389. -- Turn traffic splines around the armory 
  2390. -- 
  2391. function m03_traffic_on() 
  2392. 	sidewalk_disable_nodes(M03_trigger.traffic.name, false) 
  2393. 	traffic_disable_lanes(M03_trigger.traffic.name, false) 
  2394. 	sidewalk_disable_nodes(M03_trigger.traffic1.name, false) 
  2395. 	traffic_disable_lanes(M03_trigger.traffic1.name, false) 
  2396. end 
  2397. -------------------------------------------------------------------------------------------------- 
  2398.  
  2399. 											--[[********************]]-- 
  2400. 											--[[                    ]]-- 
  2401. 											--[[ Callback functions ]]-- 
  2402. 											--[[                    ]]-- 
  2403. 											--[[********************]]-- 
  2404.  
  2405. -- Callback when Phillipe's phone call is complete (also works as a mission cleanup for call) 
  2406. -- 
  2407. function m03_call_complete_cb() 
  2408. 	-- flag it as complete 
  2409. 	M03_convo.phillipe_call.call_complete = true 
  2410. 	-- kill persona	 
  2411. 	m03_unload_persona(M03_convo.phillipe_call) 
  2412. 	 
  2413. 	-- kill any leftovers 
  2414. 	audio_remove_mission_cellphone(M03_convo.phillipe_call.name)	 
  2415. end 
  2416.  
  2417. -- Callback for hud prompt 
  2418. -- 
  2419. function m03_hud_prompt_cb() 
  2420. 	-- nop 
  2421. end 
  2422.  
  2423. -- Callback for player getting to the weapon store 
  2424. -- 
  2425. function m03_weapon_store_trigger_cb() 
  2426. 	-- Clear the trigger 
  2427. 	m03_clear_trigger(M03_trigger.weapon_store.name) 
  2428. 	-- Set secondary trigger for breadcrumbing 
  2429. 	m03_set_trigger(M03_trigger.weapon_store2.name, "m03_weapon_store2_trigger_cb", true, true) 
  2430. 	-- Reset notoriety 
  2431. 	notoriety_reset("police")  
  2432. 	notoriety_reset("Morningstar")  
  2433. 	-- Notify script that weapon store was reached 
  2434. 	M03_trigger.weapon_store.triggered = true 
  2435. end 
  2436.  
  2437. -- Callback for the player reaching the second weapon store trigger 
  2438. -- 
  2439. function m03_weapon_store2_trigger_cb() 
  2440. 	-- Clear the trigger 
  2441. 	m03_clear_trigger(M03_trigger.weapon_store2.name) 
  2442. 	m03_set_trigger(M03_trigger.weapon_store2.name, "m03_weapon_store2_trigger2_cb", false, false) 
  2443. 	marker_add_trigger(M03_trigger.weapon_store2.name, MINIMAP_ICON_USE) 
  2444. 	--marker_add(M03_trigger.weapon_store2.name, MINIMAP_ICON_USE, OI_ASSET_USE, OI_FLAG_NONE) 
  2445. 	-- Notify script that weapon store was reached 
  2446. 	M03_trigger.weapon_store2.triggered = true 
  2447. 	 
  2448. 	m03_check_player_funds_for_upgrade() 
  2449. 	 
  2450. 	fade_out(0.5) 
  2451. 	fade_out_block() 
  2452. 	teleport_coop(M03_teleport.weapon_local, M03_teleport.weapon_remote, true) 
  2453. 	if human_is_downed( M03_char.shaundi)then 
  2454. 		npc_revive( M03_char.shaundi) 
  2455. 	end 
  2456.  	hud_push_screen("store_common", SYNC_ALL) 
  2457. 	hud_push_screen("store_weapon", SYNC_ALL) 
  2458. 	fade_in(0.5) 
  2459. 	fade_in_block() 
  2460. end 
  2461. -- Secondary callback for when the player reaches the second weapon store trigger 
  2462. -- This is to prevent the player from getting lost if they don't make a purchase 
  2463. -- 
  2464. function m03_weapon_store2_trigger2_cb() 
  2465. 	m03_clear_trigger(M03_trigger.weapon_store2.name) 
  2466. end 
  2467. -- Callback for player reaching the armory entrance 
  2468. -- 
  2469. function m03_armory_entrance_trigger_cb() 
  2470. 	-- Clear the trigger 
  2471. 	m03_clear_trigger(M03_trigger.armory_entrance.name) 
  2472. 	-- Notify script that the entrance was reached 
  2473. 	M03_trigger.armory_entrance.triggered = true 
  2474. 	-- Unhide barricade guys 
  2475. 	group_show(M03_group.initial_guard.name) 
  2476. end 
  2477.  
  2478. -- Callback for advancing into the warehouse 
  2479. --    Mark enemies to kill and add to kill list 
  2480. -- 
  2481. -- player:		(string) name of character triggering the trigger 
  2482. -- trigger:		(string) name of the trigger that was triggered 
  2483. -- 
  2484. function m03_warehouse_advance_cb(player, trigger) 
  2485. 	-- which trigger is this? 
  2486. 	local wave_table 
  2487. 	local found = false 
  2488. 	 
  2489. 	for i,guard_wave_table in pairs(M03_warehouse_guard_wave) do 
  2490. 		if (guard_wave_table.trigger.name == trigger) then 
  2491. 			wave_table = guard_wave_table 
  2492. 			found = true 
  2493. 		end 
  2494. 	end 
  2495. 	 
  2496. 	if not found then 
  2497. 		return 
  2498. 	end 
  2499. 	 
  2500. 	if wave_table.triggered then 
  2501. 		return 
  2502. 	end 
  2503. 	wave_table.triggered = true 
  2504. 		 
  2505. 	-- clear trigger 
  2506. 	m03_clear_trigger(wave_table.trigger.name) 
  2507. 	M03_warehouse_triggers_left = M03_warehouse_triggers_left - 1	 
  2508. 	 
  2509. 	for i,guard in pairs(wave_table.members) do 
  2510. 		if (not character_is_dead(guard)) then 
  2511. 			-- set callback 
  2512. 			on_death("m03_warehouse_guard_killed_cb", guard) 
  2513. 			on_detection(M03_see_saints_info.callback, guard) 
  2514. 			on_attack_performed(M03_attack_info.callback, guard) 
  2515. 		 
  2516. 			-- turn ai on 
  2517. 			set_ignore_ai_flag( guard, false ) 
  2518. 			-- add marker 
  2519. 			marker_add(guard, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  2520. 			-- add count 
  2521. 			M03_warehouse_guards_alive = M03_warehouse_guards_alive + 1 
  2522. 		end 
  2523. 	end 
  2524. 	 
  2525. 	-- send guards to their navpoint 
  2526. 	-- Note: we may have more guards than navpoints.  Guards without navs will just not move 
  2527. 	local should_run = true 
  2528. 	local should_fire = false 
  2529. 	for i,mark in pairs(wave_table.locations) do 
  2530. 		if (not character_is_dead(wave_table.members[i])) then 
  2531. 			ai_do_scripted_move(wave_table.members[i], mark, should_run, should_fire) 
  2532. 			npc_leash_remove(wave_table.members[i]) 
  2533. 		end 
  2534. 	end 
  2535. 	 
  2536. 	m03_set_kill_warehouse_guards_objective() 
  2537. 	 
  2538. 	if M03_warehouse_triggers_left == 1 then 
  2539. 		m03_convo(M03_convo.bomb_found) 
  2540. 	end 
  2541. end 
  2542.  
  2543. -- Handle playing the attack lines 
  2544. -- 
  2545. -- name:	(string) name of character 
  2546. -- weapon:	(string) name of weapon 
  2547. -- attack:	(string) type of attack performed 
  2548. -- 
  2549. function m03_process_attack_cb(name, weapon, attack)	 
  2550. 	-- don't play this if we have done this recently 
  2551. 	if (not thread_check_done(M03_attack_info.timer)) then 
  2552. 		return 
  2553. 	end 
  2554. 	 
  2555. 	-- start timer 
  2556. 	M03_attack_info.timer = thread_new("delay", M03_attack_info.delay) 
  2557. 	 
  2558. 	-- play situation 
  2559. 	if not audio_play_persona_line(name, M03_attack_info.situation) then 
  2560. 		-- line didn't play, kill our timer 
  2561. 		thread_kill(M03_attack_info.timer) 
  2562. 		M03_attack_info.timer = INVALID_THREAD_HANDLE 
  2563. 	end 
  2564.  
  2565. end 
  2566.  
  2567. -- Handle playing the attack lines 
  2568. -- 
  2569. -- name:	(string) name of character 
  2570. -- weapon:	(string) name of weapon 
  2571. -- attack:	(string) type of attack performed 
  2572. -- 
  2573. function m03_process_see_saints_cb(name, weapon, attack)	 
  2574. 	-- don't play this if we have done this recently 
  2575. 	if (not thread_check_done(M03_see_saints_info.timer)) then 
  2576. 		return 
  2577. 	end 
  2578. 	 
  2579. 	-- start timer 
  2580. 	M03_see_saints_info.timer = thread_new("delay", M03_see_saints_info.delay) 
  2581. 	 
  2582. 	-- play situation 
  2583. 	if not audio_play_persona_line(name, M03_see_saints_info.situation) then 
  2584. 		-- line didn't play, kill our timer 
  2585. 		thread_kill(M03_see_saints_info.timer) 
  2586. 		M03_see_saints_info.timer = INVALID_THREAD_HANDLE 
  2587. 	end 
  2588.  
  2589. end 
  2590.  
  2591. -- Report warhouse guard killed 
  2592. -- 
  2593. -- guard:	(string) name of guard killed 
  2594. -- 
  2595. function m03_warehouse_guard_killed_cb(guard) 
  2596. 	on_death("", guard) 
  2597. 	on_detection("", guard) 
  2598. 	on_attack_performed("", guard) 
  2599. 	marker_remove(guard) 
  2600. 	M03_warehouse_guards_alive = M03_warehouse_guards_alive - 1 
  2601. 	M03_warehouse_guards_killed = M03_warehouse_guards_killed + 1 
  2602. end 
  2603.  
  2604. -- tell an attacker to advance on the player 
  2605. -- 
  2606. -- attacker:		(string) name of attacker 
  2607. -- 
  2608. function m03_advance_cb(attacker) 
  2609. 	on_ai_do_action_complete("", attacker) 
  2610. 	ai_do_scripted_advance(attacker) 
  2611. end 
  2612.  
  2613. -- tell an attacker to take cover 
  2614. -- 
  2615. -- attacker:		(string) name of attacker 
  2616. -- 
  2617. function m03_take_cover_cb(attacker) 
  2618. 	on_ai_do_action_complete("", attacker) 
  2619. 	ai_do_scripted_take_cover(attacker) 
  2620. end 
  2621.  
  2622. -- Callback for player purchasing an item at a store 
  2623. -- 
  2624. -- item_type:		(string) type of item that was purchased 
  2625. -- player_name:	(string) name of the player who purchased the item 
  2626. -- 
  2627. function m03_item_purchased_cb(item_type, player_name) 
  2628. 	if (item_type ~= "weapon" and item_type ~= "weapon-ammo") then 
  2629. 		return 
  2630. 	end 
  2631.  
  2632. 	-- Clear the callback 
  2633. 	on_purchase("") 
  2634. 	m03_weapon_store2_trigger2_cb() 
  2635. 	-- Notify script that item was purchased 
  2636. 	M03_status.item_purchased = true 
  2637. end 
  2638.  
  2639. -- Callback for player reaching the weapons cache 
  2640. function m03_weapons_cache_trigger_cb() 
  2641. 	-- Clear the trigger 
  2642. 	m03_clear_trigger(M03_trigger.weapons_cache.name) 
  2643. 	-- Notify script that the weapons cache was reached 
  2644. 	M03_trigger.weapons_cache.triggered = true 
  2645. end 
  2646.  
  2647. -- Callback for a player using the satellite weapon via trigger 
  2648. -- 
  2649. -- player_user:	(string) the player that triggered the satellite weapon 
  2650. -- trigger:			(string) the trigger that was activated 
  2651. -- 
  2652. function m03_satellite_weapon_used_cb(player_user, trigger) 
  2653. 	-- Note: We need to put both players into satellite weapon mode 
  2654. 	--satellite_weapon_mode_set(true)--, sync_type) 
  2655. 	--on_pickup("", M03_item.satellite_weapon) 
  2656. 	marker_remove(M03_item.satellite_weapon) 
  2657. 	m03_clear_trigger(M03_trigger.satellite_weapon.name) 
  2658. 	inv_weapon_add_temporary(LOCAL_PLAYER, M03_weapon.satellite_drone_weapon, 1, true, true) 
  2659. 	--inv_item_remove_in_slot("special", LOCAL_PLAYER) 
  2660. 	--inv_item_add(M03_weapon.satellite_drone_weapon, 1, LOCAL_PLAYER, true) 
  2661. 	if (coop_is_active()) then 
  2662. 		inv_weapon_add_temporary(REMOTE_PLAYER, M03_weapon.satellite_drone_weapon, 1, true, true) 
  2663. 		--inv_item_remove_in_slot("special", REMOTE_PLAYER) 
  2664. 		--inv_item_add(M03_weapon.satellite_drone_weapon, 1, REMOTE_PLAYER, true) 
  2665. 	end 
  2666. 	-- destroy the item 
  2667. 	if group_is_loaded(M03_group.satellite_weapon.name) then 
  2668. 		group_destroy(M03_group.satellite_weapon.name) 
  2669. 	end 
  2670. 	-- If we are in coop, make sure the player that didn't trigger the weapon is nearby 
  2671. 	if coop_is_active() then 
  2672. 		local other_player = REMOTE_PLAYER 
  2673. 		if player_user == REMOTE_PLAYER then 
  2674. 			other_player = LOCAL_PLAYER 
  2675. 		end 
  2676. 		local nearby = 30.0 
  2677. 		if get_dist(other_player, M03_checkpoint.protect_the_stash.player_remote) > nearby then 
  2678. 			-- you are too far away.  We are going to bring you both back, so we are going to bite the bullet and fade out 
  2679. 			mission_start_fade_out() 
  2680. 			-- surprise! back you go			 
  2681. 			teleport_coop(M03_checkpoint.protect_the_stash.player_local, M03_checkpoint.protect_the_stash.player_remote, true) 
  2682. 			mission_start_fade_in() 
  2683. 		end 
  2684. 	end 
  2685. 	-- Yield, just to make sure the players actually have the weapon equipped before trying to put them in satellite mode 
  2686. 	thread_yield() 
  2687. 	M03_trigger.satellite_weapon.triggered = true 
  2688. 	-- let's use some drones!  I'll show you.  Here! 
  2689. 	satellite_weapon_mode_set(true) 
  2690. end 
  2691.  
  2692. -- Callback for entering trigger near Pierce's helicopter 
  2693. -- 
  2694. function m03_enter_heli_cb() 
  2695. 	m03_clear_trigger(M03_trigger.enter_heli.name) 
  2696. 	M03_trigger.enter_heli.triggered = true 
  2697. end 
  2698.  
  2699. -- Callback for the helicopter carrying the bomb being destroyed 
  2700. -- 
  2701. -- vehicle_name:	(string) name of the helicopter 
  2702. -- 
  2703. function m03_bomb_destroyed_cb(vehicle_name) 
  2704. 	on_vehicle_destroyed("", vehicle_name) 
  2705. 	mission_end_failure("m03", M03_text.failure_bomb_destroyed) 
  2706. end 
  2707.  
  2708. -- Callback for the helicopter picking up the bomb being destroyed 
  2709. -- 
  2710. -- vehicle_name:	(string) name of the helicopter 
  2711. -- 
  2712. function m03_heli_destroyed_cb(vehicle_name) 
  2713. 	on_vehicle_destroyed("", vehicle_name) 
  2714. 	mission_end_failure("m03", M03_text.failure_heli_destroyed) 
  2715. end 
  2716.  
  2717. -- Callback for Pierce's chopper being destroyed 
  2718. -- 
  2719. -- vehicle_name:	(string) name of the helicopter 
  2720. -- 
  2721. function m03_chopper_destroyed_cb(vehicle_name) 
  2722. 	on_vehicle_destroyed("", vehicle_name) 
  2723. 	mission_end_failure("m03", M03_text.failure_pierce_destroyed) 
  2724. end 
  2725.  
  2726. -- Callback for an enemy chopper being destroyed during the fly home sequence 
  2727. -- 
  2728. -- chopper:	(string) name of the chopper 
  2729. -- 
  2730. function m03_heli_enemy_destroyed_cb(chopper) 
  2731. 	marker_remove(chopper) 
  2732. 	on_vehicle_destroyed("", chopper) 
  2733. 	-- not required, no marker -- marker_remove(chopper) 
  2734. 	M03_status.helis_destroyed = M03_status.helis_destroyed + 1 
  2735. 	 
  2736. 	if M03_status.helis_destroyed == 1 then 
  2737. 		audio_play_persona_line(M03_char.shaundi, "M03_Nice_Hit_01") 
  2738. 	end 
  2739. 	if M03_status.helis_destroyed == 3 then 
  2740. 		audio_play_persona_line(M03_char.pierce, "M03_Nice_Hit_02") 
  2741. 	end 
  2742. 	if M03_status.helis_destroyed == 5 then 
  2743. 		audio_play_persona_line(M03_char.shaundi, "M03_Nice_Hit_03") 
  2744. 	end 
  2745. end 
  2746. -- Cause the helicopter to fly away from the player when dying 
  2747. -- 
  2748. -- heli_name: (string) name of the vehicle that reached the hitpoint threshold 
  2749. -- killer: (string) name of the character or vehicle responsible for causing the damage 
  2750. -- 
  2751. function m03_crash_heli(heli_name, killer) 
  2752. 	on_damage("", heli_name, 0.20) 
  2753. 	-- go to the navpoint away from the player 
  2754. 	helicopter_fly_to_direct(heli_name, 80.0, M03_kill_heli) 
  2755. 	delay(1.0) 
  2756. 	vehicle_detonate(heli_name) 
  2757. end 
  2758. -- Callback to determine if a player just fired the satellite weapon 
  2759. -- 
  2760. -- attacker:		(string) name of attacker 
  2761. -- weapon:			(string) name of weapon used or "unarmed" if melee 
  2762. -- attack:			(string) "melee", "firearm" or "thrown" 
  2763. function m03_player_fired_weapon_cb(attacker, weapon, attack) 
  2764. 	-- we only set this callback for the players, so I don't care who the attacker is 
  2765. 	 
  2766. 	-- is this the pred-drone? 
  2767. 	if weapon == M03_weapon.satellite_drone_weapon then 
  2768. 		-- maybe say something 
  2769. 		 
  2770. 		-- if a conversation is going, don't talk 
  2771. 		if M03_status.convo_is_playing then 
  2772. 			return 
  2773. 		end 
  2774. 		 
  2775. 		-- if we chatted recently, don't talk 
  2776. 		if (not thread_check_done(M03_thread.chatter_timer)) then 
  2777. 			return 
  2778. 		end 
  2779. 		 
  2780. 		local playing_line = false 
  2781. 		 
  2782. 		-- find something to say 
  2783. 		for i,chat in pairs(M03_drone_operators) do 
  2784. 			if (not playing_line) and (not chat.spoken) then 
  2785. 				chat.spoken = true 
  2786. 				playing_line = true 
  2787. 				if chat.is_conversation then 
  2788. 					m03_convo(chat.conversation) 
  2789. 				else 
  2790. 					audio_play_persona_line_2d(chat.speaker.persona_id, chat.line) 
  2791. 				end 
  2792. 				 
  2793. 				-- set the timer so someone else doesn't try to talk 
  2794. 				M03_thread.chatter_timer = thread_new("delay", 5.0) 
  2795. 			end 
  2796. 		end 
  2797. 	end 
  2798. end 
  2799.  
  2800. -- Callback for a vehicle being killed during the satellite attack portion 
  2801. -- 
  2802. -- vehicle_name:	(string) name of the vehicle 
  2803. -- 
  2804. function m03_satellite_vehicle_killed_cb(vehicle_name) 
  2805. 	-- clear our callback 
  2806. 	on_vehicle_destroyed("", vehicle_name) 
  2807. 	-- find our vehicle 
  2808. 	for i,sat_group in pairs(M03_all_satellite_groups) do 
  2809. 		if sat_group.vehicle == vehicle_name then 
  2810. 			-- don't need this marker anymore 
  2811. 			marker_remove(sat_group.vehicle) 
  2812. 			-- release the whole group 
  2813. 			release_to_world(sat_group.name) 
  2814. 			-- kill the thread 
  2815. 			thread_kill(sat_group.thread) 
  2816. 			-- we're done here 
  2817. 			return 
  2818. 		end 
  2819. 	end 
  2820. end 
  2821.  
  2822. -- Callback for an attacker being killed during the satellite attack portion 
  2823. -- 
  2824. -- attacker:	(string) name of the attacker 
  2825. -- 
  2826. function m03_satellite_attacker_killed_cb(attacker) 
  2827. 	on_death("", attacker) 
  2828. 	marker_remove(attacker) 
  2829. end 
  2830.  
  2831. -- Callback for a tank being killed during the satellite attack portion 
  2832. -- 
  2833. -- tank:	(string) name of the tank 
  2834. -- 
  2835. function m03_satellite_tank_killed_cb(tank) 
  2836. 	on_vehicle_destroyed("", tank) 
  2837. 	marker_remove(tank) 
  2838. end 
  2839.  
  2840. -- Shaundi is killed and you lose 
  2841. -- 
  2842. function m03_shaundi_killed_cb() 
  2843. 	mission_end_failure("m03", "m03_failure_shaundi_killed") 
  2844. end 
  2845.  
  2846. -- Abandoned Shaundi, you lose 
  2847. -- 
  2848. function m03_failure_dismissed_cb() 
  2849. 	mission_end_failure("m03", "m03_failure_homie_dismissed") 
  2850. end 
  2851.  
  2852. -- Handle Pierce talking when getting shot 
  2853. -- 
  2854. function m03_heli_chatter_cb() 
  2855. 	-- if a conversation is going, don't talk 
  2856. 	if M03_status.convo_is_playing then 
  2857. 		return 
  2858. 	end 
  2859. 	 
  2860. 	-- if we chatted recently, don't talk 
  2861. 	if (not thread_check_done(M03_thread.chatter_timer)) then 
  2862. 		return 
  2863. 	end 
  2864. 	 
  2865. 	local playing_line = false 
  2866. 	 
  2867. 	-- find something to say 
  2868. 	for i,chat in pairs(M03_radio_chatter) do 
  2869. 		if (not playing_line) and (not chat.spoken) then 
  2870. 			audio_play_persona_line(chat.speaker, chat.line) 
  2871. 			chat.spoken = true 
  2872. 			playing_line = true 
  2873. 			 
  2874. 			-- set the timer so someone else doesn't try to talk 
  2875. 			M03_thread.chatter_timer = thread_new("delay", 5.0) 
  2876. 		end 
  2877. 	end 
  2878. end 
  2879.  
  2880. -- Callback for spawning a second set of enemy choppers when the player reaches a certain point in the fly home portion 
  2881. -- 
  2882. function m03_spawn_secondary_enemies_cb() 
  2883. 	-- Make them fast so they can get in position behind the bomb chopper 
  2884. 	local follower_speed = 50 
  2885. 	group_create(M03_group.fly_home_secondary_enemies.name, true) 
  2886. 	for i,chopper in pairs(M03_vehicle.fly_home_secondary_enemies) do 
  2887. 		vehicle_enter_group_teleport(M03_char.fly_home_secondary_enemies[i], chopper) 
  2888. 		vehicle_suppress_npc_exit(chopper, true) 
  2889. 	end 
  2890. 	for i,chopper in pairs(M03_vehicle.fly_home_secondary_enemies) do 
  2891. 		M03_thread.fly_home_secondary_enemy_chase[i] = thread_new("m03_wrapper_thread", helicopter_fly_to_direct_follow, chopper, follower_speed, M03_group.choppers.bomb.vehicle, M03_scripted_path.fly_home_secondary_enemies[i], 5) 
  2892. 		-- not required, no marker -- marker_add(chopper, MINIMAP_ICON_KILL, OI_ASSET_KILL) 
  2893. 		on_vehicle_destroyed("m03_heli_enemy_destroyed_cb", chopper) 
  2894. 	end 
  2895. 	 
  2896. 	-- Make sure they don't hit the player or the bomb when they die 
  2897. 	on_damage("m03_crash_heli", M03_vehicle.fly_home_secondary_enemies[1], 0.20) 
  2898. 	on_damage("m03_crash_heli", M03_vehicle.fly_home_secondary_enemies[2], 0.20) 
  2899. 	 
  2900. 	for i,npc_group in pairs(M03_char.fly_home_enemies) do 
  2901. 		for j,npc in pairs(npc_group) do 
  2902. 			ai_add_enemy_target(npc, M03_group.choppers.bomb.pilots[1], ATTACK_NOW_NEVER_LOSE, true) 
  2903. 		end 
  2904. 	end 
  2905. 	M03_trigger.fly_home_secondary_enemies.triggered = true 
  2906. end 
  2907.  
  2908. -- Callback for when an NPC enters the "blow up helis" trigger 
  2909. -- 
  2910. -- npc:	(string) name of the NPC that entered the trigger 
  2911. -- 
  2912. function m03_blow_up_helis_cb(npc) 
  2913. 	-- If an ambient ped activates the trigger, the callback is called with an empty string for the NPC name 
  2914. 	if (npc == nil or npc == "") then 
  2915. 		return 
  2916. 	end 
  2917. 	local vehicle_name = get_char_vehicle_name(npc) 
  2918. 	-- Just in case the NPC is somehow not in a vehicle... 
  2919. 	if (vehicle_name == nil or vehicle_name == "") then 
  2920. 		return 
  2921. 	end 
  2922. 	-- Don't destroy any of the good guys 
  2923. 	if (vehicle_name == M03_group.choppers.bomb.vehicle) then 
  2924. 		return 
  2925. 	end 
  2926. 	if (vehicle_name == M03_group.choppers.backup.vehicle) then 
  2927. 		return 
  2928. 	end 
  2929. 	if (vehicle_name == M03_group.choppers.pierce.vehicle) then 
  2930. 		if M03_status.fly_home_played then 
  2931. 			return 
  2932. 		end 
  2933. 		--Have Shaundi point out ex bf's apartment 
  2934. 		M03_thread.fly_home_convo = thread_new("m03_convo", M03_convo.fly_home) 
  2935. 		M03_status.fly_home_played = true 
  2936. 		-- Switch music 
  2937. 		audio_object_post_event("M03_Heli_Rail_Score_Finish", nil, nil, LOCAL_PLAYER) 
  2938. 		return 
  2939. 	end 
  2940.  
  2941. 	local smoke, fire = vehicle_get_smoke_and_fire_state(vehicle_name) 
  2942. 	-- Make sure they're smoking and on fire 
  2943. 	if ((smoke and fire) == false) then 
  2944. 		helicopter_fly_to_direct(vehicle_name, 80.0, M03_navpoint.heli_blow_up) 
  2945. 		vehicle_set_smoke_and_fire_state(vehicle_name, true, true) 
  2946. 	end 
  2947. 	M03_trigger.blow_up_helis.triggered = true 
  2948. end 
  2949.  
  2950. -- Callback for when player enters the "callout 1" trigger 
  2951. -- 
  2952. function m03_callout_1_cb() 
  2953. --	message("Convo trigger 1") 
  2954. 	if (M03_trigger.callout1.triggered) then 
  2955. 		return 
  2956. 	end 
  2957. 	M03_trigger.callout1.triggered = true 
  2958. 	on_trigger("", M03_trigger.callout1.name) 
  2959. 	trigger_enable(M03_trigger.callout1.name, false) 
  2960. 	m03_convo(M03_convo.callout1) 
  2961. end 
  2962. -- Callback for when player enters the "callout 2" trigger 
  2963. -- 
  2964. function m03_callout_2_cb() 
  2965. --	message("Convo trigger 2") 
  2966. 	if (M03_trigger.callout2.triggered)then 
  2967. 		return 
  2968. 	end 
  2969. 	M03_trigger.callout2.triggered = true 
  2970. 	on_trigger("", M03_trigger.callout2.name) 
  2971. 	trigger_enable(M03_trigger.callout2.name, false) 
  2972. 	audio_play_persona_line(M03_char.shaundi, "M03_Calling_Out_Places_02") 
  2973. end 
  2974. -- Callback for when player enters the "callout 3" trigger 
  2975. -- 
  2976. function m03_callout_3_cb() 
  2977. --	message("Convo trigger 3") 
  2978. 	if (M03_trigger.callout3.triggered)then 
  2979. 		return 
  2980. 	end 
  2981. 	M03_trigger.callout3.triggered = true 
  2982. 	on_trigger("", M03_trigger.callout3.name) 
  2983. 	trigger_enable(M03_trigger.callout3.name, false) 
  2984. 	audio_play_persona_line(M03_char.shaundi, "M03_Calling_Out_Places_03") 
  2985. end 
  2986. -- Callback for when player enters the "callout 4" trigger 
  2987. -- 
  2988. function m03_callout_4_cb() 
  2989. --	message("Convo trigger 4") 
  2990. 	if(M03_trigger.callout4.triggered)then 
  2991. 		return 
  2992. 	end 
  2993. 	M03_trigger.callout4.triggered = true 
  2994. 	on_trigger("", M03_trigger.callout4.name) 
  2995. 	trigger_enable(M03_trigger.callout4.name, false) 
  2996. 	audio_play_persona_line(M03_char.shaundi, "M03_Calling_Out_Places_04") 
  2997. end 
  2998. -- Callback for when a player leaves the weapon store 
  2999. -- 
  3000. function m03_weapon_store_complete(screen_name, player_name) 
  3001. 	if (screen_name ~= "store_weapon") then 
  3002. 		return 
  3003. 	end 
  3004. 	 
  3005. 	-- flag the player as completed 
  3006. 	Weapon_store_completion[player_name] = true 
  3007. 	 
  3008. 	-- TODO: if one finished first, figure out what to do here, maybe just have a wait objective 
  3009. 	--if(not(Weapon_store_completion[LOCAL_PLAYER] and Weapon_store_completion[REMOTE_PLAYER]))then 
  3010. 	--end 
  3011. end 
  3012. -------------------------------------------------------------------------------------------------- 
  3013.  
  3014. 											--[[******************]]-- 
  3015. 											--[[                  ]]-- 
  3016. 											--[[ Thread functions ]]-- 
  3017. 											--[[                  ]]-- 
  3018. 											--[[******************]]-- 
  3019.  
  3020. -- Handle playing all of the conversations on the drive to the weapons shop 
  3021. -- Exit if weapons shop trigger is hit 
  3022. -- 
  3023. function m03_start_convos_thread() 
  3024. 	--M03_convo.mission_start.thread = thread_new("m03_convo", M03_convo.mission_start) 
  3025. 	--delay(1.0) 
  3026.  
  3027. 	repeat  
  3028. 		thread_yield()  
  3029. 	until (not M03_status.convo_is_playing) or (M03_trigger.weapon_store.triggered) 
  3030. 	 
  3031. 	if M03_status.convo_is_playing then 
  3032. 		audio_conversation_end(M03_convo.mission_start.handle) 
  3033. 	end 
  3034.  
  3035. 	if (not M03_trigger.weapon_store.triggered) then 
  3036. 		delay(2.0) 
  3037. 	end 
  3038. 	 
  3039. 	if (not M03_trigger.weapon_store.triggered) then 
  3040. 		M03_convo.mission_start.thread = thread_new("m03_convo", M03_convo.set_gps) 
  3041. 		delay(1.0) 
  3042. 		 
  3043. 		repeat  
  3044. 			thread_yield()  
  3045. 		until (not M03_status.convo_is_playing) or (M03_trigger.weapon_store2.triggered) 
  3046. 	 
  3047. 		if M03_status.convo_is_playing then 
  3048. 			audio_conversation_end(M03_convo.set_gps.handle) 
  3049. 		end 
  3050. 	end 
  3051.  
  3052. 	if (not M03_trigger.weapon_store.triggered) then 
  3053. 		delay(2.0) 
  3054. 	end 
  3055. 	 
  3056. 	if (not M03_trigger.weapon_store.triggered) then 
  3057. 		M03_convo.mission_start.thread = thread_new("m03_convo", M03_convo.to_gun_store1) 
  3058. 		delay(1.0) 
  3059. 		 
  3060. 		repeat  
  3061. 			thread_yield()  
  3062. 		until (not M03_status.convo_is_playing) or (M03_trigger.weapon_store2.triggered) 
  3063. 	 
  3064. 		if M03_status.convo_is_playing then 
  3065. 			audio_conversation_end(M03_convo.to_gun_store1.handle) 
  3066. 		end 
  3067. 	end 
  3068.  
  3069.  
  3070. 	if (not M03_trigger.weapon_store.triggered) then 
  3071. 		delay(3.0) 
  3072. 	end 
  3073. 	 
  3074. 	if (not M03_trigger.weapon_store.triggered) then 
  3075. 		M03_convo.mission_start.thread = thread_new("m03_convo", M03_convo.to_gun_store2) 
  3076. 		delay(1.0) 
  3077. 	 
  3078. 		repeat  
  3079. 			thread_yield()  
  3080. 		until (not M03_status.convo_is_playing) or (M03_trigger.weapon_store2.triggered) 
  3081. 	 
  3082. 		if M03_status.convo_is_playing then 
  3083. 			audio_conversation_end(M03_convo.to_gun_store2.handle) 
  3084. 		end 
  3085. 	end 
  3086. 		 
  3087. 	if (not M03_trigger.weapon_store.triggered) then 
  3088. 		radio_newsbreak("m01") 
  3089. 	end 
  3090. end				 
  3091.  
  3092. -- Handle the GPS tutorial 
  3093. -- People miss this, so set this up as a separate thread that will let the player continue 
  3094. --   if they can't figure this out. 
  3095. -- 
  3096. function m03_gps_tutorial_thread() 
  3097.  
  3098. 	-- set the objective to set the GPS 
  3099. 	objective_text(0, M03_text.set_gps, nil, nil, SYNC_ALL, OI_ASSET_USE) 
  3100. 	 
  3101. 	-- SP: display the hud prompt TO THE LOCAL PLAYER to pull up the cell phone/map. NEIL - you'll need to change this to happen on the player who got into a car and not the other player, or some such logic, to cover co-op variations 
  3102. 	hud_prompt(LOCAL_PLAYER, "M03_OBJ_ACCESS_MAP_USE_MSG", "m03_hud_prompt_cb") 
  3103. 	if coop_is_active() then 
  3104. 		hud_prompt(REMOTE_PLAYER, "M03_OBJ_ACCESS_MAP_USE_MSG", "m03_hud_prompt_cb") 
  3105. 	end 
  3106.  
  3107. 	-- Tell the player to place a waypoint 
  3108. 	local redisplay = true 
  3109. 	local infinite_duration = true 
  3110. 	tutorial_start("pause_map", 0,false,redisplay, infinite_duration) 
  3111. 	-- prep the map 
  3112. 	pause_map_tutorial_mode(true) 
  3113.  
  3114. 	repeat 
  3115. 		thread_yield() 
  3116. 	until (waypoint_is_placed() or M03_trigger.weapon_store.triggered) 
  3117. 	pause_map_tutorial_mode(false) 
  3118.  
  3119. 	tutorial_stop("pause_map") 
  3120. 	hud_prompt_clear() --SP: remove the HUD prompt when the waypoint is placed 
  3121. 	if not M03_trigger.weapon_store.triggered then 
  3122. 		-- clear the trigger and set it with proper marker 
  3123. 		marker_remove_trigger(M03_trigger.weapon_store.name, SYNC_ALL) 
  3124. 		marker_add_trigger(M03_trigger.weapon_store.name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  3125.  
  3126. 		-- Tell the player to drive to the weapon store. 
  3127. 		objective_text(0, M03_text.go_to_weapon_store, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  3128. 		tutorial_vehicle_controls_enabled(true) 
  3129. 		 
  3130. 		-- if we are still in the car, maybe start the tutorial 
  3131. 		if character_is_in_vehicle(LOCAL_PLAYER) then 
  3132. 			tutorial_start("np_car_controls") 
  3133. 		end 
  3134. 		 
  3135. 		-- queue up the minimap tutorial 
  3136. 		tutorial_start("minimap") 
  3137. 	end 
  3138. 	tutorial_vehicle_controls_enabled(true) 
  3139. end 
  3140.  
  3141. -- Send troops to their post 
  3142. -- 
  3143. -- squad:			(table) squad members and destination 
  3144. -- advance:			{boolean) if true, guards will advance on the player 
  3145. -- 
  3146. function m03_deploy_troops_thread(squad, advance) 
  3147. 	local should_run = true 
  3148. 	local should_fire = false 
  3149. 	for i,guard in pairs(squad.members) do 
  3150. 		if (not character_is_dead(guard)) then 
  3151. 			ai_add_enemy_target(guard, LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE) 
  3152. 			if (coop_is_active()) then 
  3153. 				ai_add_enemy_target(guard, REMOTE_PLAYER, ATTACK_NOW_NEVER_LOSE) 
  3154. 			end 
  3155. 			ai_do_scripted_move(guard, squad.dest, should_run, should_fire) 
  3156. 			if advance then 
  3157. 				on_ai_do_action_complete("m03_advance_cb", guard) 
  3158. 			else 
  3159. 				on_ai_do_action_complete("m03_take_cover_cb", guard) 
  3160. 			end 
  3161. 		end 
  3162. 	end 
  3163. end 
  3164. 											 
  3165. -- Thread for setting up an enemy chopper and its pilots for the fly home portion 
  3166. -- 
  3167. -- index:	(number) index of the group we are setting up 
  3168. -- chopper:	(string) name of the chopper in the group 
  3169. -- 
  3170. function m03_fly_home_enemy_setup_thread(index, chopper) 
  3171. 	vehicle_enter_group_teleport(M03_char.fly_home_enemies[index], chopper) 
  3172. 	npc_combat_enable(M03_char.fly_home_enemies[index][1], false) 
  3173. 	npc_combat_enable(M03_char.fly_home_enemies[index][2], false) 
  3174. 	vehicle_suppress_npc_exit(chopper, true) 
  3175. end 
  3176.  
  3177. -- Move the bomb heli in to 'pickup' the bomb 
  3178. -- 
  3179. function m03_pickup_bomb_thread() 
  3180. 	local speed = 4.0 
  3181. 	helicopter_fly_to_direct(M03_group.choppers.bomb.vehicle, speed, M03_group.choppers.bomb.pickup_nav[1]) 
  3182. 	-- really slow for lowering to pick up 
  3183. 	speed = 2.0 
  3184. 	helicopter_fly_to_direct(M03_group.choppers.bomb.vehicle, speed, M03_group.choppers.bomb.pickup_nav[2]) 
  3185. 	 
  3186. 	-- just stay here when done so we can be shot up 
  3187. end 
  3188.  
  3189. -- Thread for processing one group of attackers in the satellite portion 
  3190. -- 
  3191. -- spawn_group:	(table) group attackers information 
  3192. -- 
  3193. function m03_satellite_attacker_thread(spawn_group) 
  3194. 	group_create(spawn_group.name, true) 
  3195. 	vehicle_enter_group_teleport(spawn_group.members, spawn_group.vehicle) 
  3196. 	vehicle_ignore_repulsors(spawn_group.vehicle, true) 
  3197. 	marker_add(spawn_group.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  3198. 	vehicle_suppress_npc_exit(spawn_group.vehicle) 
  3199. 	vehicle_speed_override(spawn_group.vehicle, 30) 
  3200. 	on_vehicle_destroyed("m03_satellite_vehicle_killed_cb", spawn_group.vehicle) 
  3201. 	-- make driver dumb 
  3202. 	local driver = vehicle_get_driver(spawn_group.vehicle, false) 
  3203. 	set_ignore_ai_flag( driver, true ) 
  3204. 	 
  3205. 	local use_navmesh = true 
  3206. 	local stop_at_goal = true 
  3207. 	local force_path = false 
  3208. 	local suppress_errors = false 
  3209. 	vehicle_pathfind_to(spawn_group.vehicle, spawn_group.dest, use_navmesh, stop_at_goal, force_path, suppress_errors)  
  3210. 	 
  3211. 	-- NOBODY gets out, because killing specs on foot is kinda dull 
  3212. 	----- vehicle is no longer the threat 
  3213. 	---marker_remove(spawn_group.vehicle) 
  3214. 	---on_vehicle_destroyed("", spawn_group.vehicle)	 
  3215. 	---vehicle_exit_group(spawn_group.members) 
  3216. 	 
  3217. 	vehicle_freeze(spawn_group.vehicle, true) 
  3218. 	-- For fuck's sake, don't drive your car into the water! 
  3219. 	character_kill(driver) 
  3220. 	--vehicle_max_speed(spawn_group.vehicle, 0.0) 
  3221. 	--vehicle_disable_chase(spawn_group.vehicle, true) 
  3222. 	--vehicle_disable_flee(spawn_group.vehicle, true) 
  3223.  
  3224. 	 
  3225. 	for npc_index,npc in pairs(spawn_group.members) do 
  3226. 		if (character_exists(npc) and not character_is_dead(npc)) then 
  3227. 	--		force_fire(npc, "group_a_nav<002>") 
  3228. 	---		marker_add(npc, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  3229. 			ai_add_enemy_target(npc, M03_group.choppers.bomb.pilots[1], ATTACK_NOW_NEVER_LOSE) 
  3230. 	---		ai_add_enemy_target(npc, M03_group.choppers.pierce.pilots[1], ATTACK_NOW_NEVER_LOSE) 
  3231. 	---		ai_add_enemy_target(npc, M03_group.choppers.backup.pilots[1], ATTACK_NOW_NEVER_LOSE) 
  3232. 	---		on_death("m03_satellite_attacker_killed_cb", npc) 
  3233. 		end 
  3234. 	end 
  3235. 	 
  3236. 	-- when the vehicle is destroyed, this thread will be killed 
  3237. 	while true do 
  3238. 		if vehicle_in_water(spawn_group.vehicle) then 
  3239. 			vehicle_detonate(spawn_group.vehicle) 
  3240. 		end 
  3241. 		thread_yield() 
  3242. 	end 
  3243. --[[ 
  3244. 	-- Wait until all the NPCs in this group have died 
  3245. 	for npc_index,npc in pairs(spawn_group.members) do 
  3246. 		repeat 
  3247. 			thread_yield() 
  3248. 		until (not character_exists(npc) or character_is_dead(npc)) 
  3249. 	end 
  3250. 	delay(2.0) 
  3251. 	-- Release them to the world, so they can be respawned 
  3252. 	release_to_world(spawn_group.name) 
  3253. 	delay(2.0) 
  3254. ]]-- 
  3255. end 
  3256.  
  3257. -- Continuously respawn attackers and send them to attack positions until we are told to stop 
  3258. -- 
  3259. --	spawn_table:		(table) table of group information for attackers 
  3260. -- 
  3261. function m03_satellite_attackers_thread(spawn_table) 
  3262. 	 
  3263. 	-- flag that tells us to go/stop 
  3264. 	M03_status.satellite_timer_elapsed = false 
  3265.  
  3266. 	while not M03_status.satellite_timer_elapsed do 
  3267. 		-- respawn where necessary 
  3268. 		for sa_index,spawn_group in pairs(spawn_table) do 
  3269. 			if sa_index <= M03_num_satellite_attackers then 
  3270. 				if thread_check_done(spawn_group.thread) then 
  3271. 					spawn_group.thread = thread_new("m03_satellite_attacker_thread", spawn_group) 
  3272. 					delay(0.5) 
  3273. 				end 
  3274. 			end 
  3275. 		end 
  3276. 		 
  3277. 		-- at least one yield 
  3278. 		thread_yield() 
  3279. 	end 
  3280. 	 
  3281. 	-- wait for all of the spawns to be done 
  3282. 	for sa_index,spawn_group in pairs(spawn_table) do 
  3283. 		while not thread_check_done(spawn_group.thread) do 
  3284. 			thread_yield() 
  3285. 		end 
  3286. 	end 
  3287. 	 
  3288. end 
  3289.  
  3290. -- Since tanks are so uber powerful, delay attacking until some time to blow them up has passed 
  3291. -- 
  3292. -- group_table:		(table) information about the tank group 
  3293. -- 
  3294. function m03_tank_delay_gunner_thread( group_table ) 
  3295. 	-- nobody in the tank attacks...yet 
  3296. 	npc_combat_enable(group_table.members[1], false) 
  3297. 	npc_combat_enable(group_table.members[2], false) 
  3298. 	 
  3299. 	-- wait some time and enable the machine gunner 
  3300. 	delay(10.0) 
  3301. 	npc_combat_enable(group_table.members[2], true) 
  3302. 	delay(5.0) 
  3303. 	-- let the main gunner go (you are the dead) 
  3304. 	npc_combat_enable(group_table.members[1], true) 
  3305. 	 
  3306. end 
  3307.  
  3308. -- If noone is speaking, say something 
  3309. -- 
  3310. function m03_heli_chatter_thread() 
  3311.  
  3312. 	for i,chat in pairs(M03_chopper_combat) do 
  3313. 	 
  3314. 		local playing_line = false 
  3315. 		 
  3316. 		while (not playing_line) do 
  3317. 			if M03_status.convo_is_playing then 
  3318. 				-- if a conversation is going, don't talk 
  3319. 				thread_yield() 
  3320. 			elseif (not thread_check_done(M03_thread.chatter_timer)) then 
  3321. 				-- if we chatted recently, don't talk 
  3322. 				thread_yield() 
  3323. 			elseif (not playing_line) and (not chat.spoken) then 
  3324. 				audio_play_persona_line(chat.speaker, chat.line) 
  3325. 				chat.spoken = true 
  3326. 				playing_line = true 
  3327. 				 
  3328. 				-- set the timer so someone else doesn't try to talk 
  3329. 				M03_thread.chatter_timer = thread_new("delay", 5.0) 
  3330. 			end 
  3331. 		end 
  3332. 		 
  3333. 		delay(10.0)	-- wait before trying to say one of these lines again 
  3334. 	end 
  3335. end 
  3336.  
  3337. function m03_wrapper_thread(function_ref, ...) 
  3338. 	function_ref(unpack(arg)) 
  3339. end 
  3340.  
  3341. -- Set it up so that secondary enemies hover in the air prior to the player getting near 
  3342. -- 
  3343. function m03_secondary_heli_hover_setup() 
  3344. 	helicopter_fly_to(M03_vehicle.fly_home_enemies[5], 80, M03_FlytoPoint[1]) 
  3345. 	helicopter_fly_to(M03_vehicle.fly_home_enemies[6], 80, M03_FlytoPoint[2]) 
  3346. 	helicopter_fly_to(M03_vehicle.fly_home_enemies[7], 80, M03_FlytoPoint[3]) 
  3347. 	helicopter_fly_to(M03_vehicle.fly_home_enemies[8], 80, M03_FlytoPoint[4]) 
  3348. 	helicopter_fly_to(M03_vehicle.fly_home_enemies[9], 80, M03_FlytoPoint[5]) 
  3349. 	helicopter_fly_to(M03_vehicle.fly_home_enemies[10], 80, M03_FlytoPoint[6]) 
  3350. end 
  3351.  
  3352. -- Cleanup any callback on army guys if the mission is ended while they are still active 
  3353. -- 
  3354. function m03_cleanup_army_callbacks() 
  3355. 	if(group_is_loaded(M03_group.the_army.name))then 
  3356. 		for i,guard in pairs(M03_group.the_army.squad1.members) do 
  3357. 			on_ai_do_action_complete("", guard) 
  3358. 		end 
  3359. 		for i,guard in pairs(M03_group.the_army.squad2.members) do 
  3360. 			on_ai_do_action_complete("", guard) 
  3361. 		end 
  3362. 		for i,guard in pairs(M03_group.the_army.squad3.members) do 
  3363. 			on_ai_do_action_complete("", guard) 
  3364. 		end 
  3365. 		for i,guard in pairs(M03_group.the_army.squad4.members) do 
  3366. 			on_ai_do_action_complete("", guard) 
  3367. 		end 
  3368. 		for i,guard in pairs(M03_group.the_army.squad5.members) do 
  3369. 			on_ai_do_action_complete("", guard) 
  3370. 		end 
  3371. 		for i,guard in pairs(M03_group.the_army.squad6.members) do 
  3372. 			on_ai_do_action_complete("", guard) 
  3373. 		end 
  3374. 	end 
  3375. end 
  3376.