./m09.lua

  1. --[[ 
  2. 	m09.lua 
  3. 	SR3 Mission Script 
  4. 	DATE: 09-22-2010 
  5. 	AUTHOR:	Neil Ryan and Craig Williams 
  6. ]]-- 
  7.  
  8.  
  9. -- Debug flags -- 
  10. 	M09_enable_binks             = true 
  11. 	M09_debug_skip_to_heli_scene = false 
  12.  
  13. -- Tweakable Parameters -- 
  14. 	M09_give_rocket_launcher		= true 
  15. 	M09_continuous_respawn_delay	= 10.0	-- time in seconds before a continuous spawn group respawns 
  16. 	M09_delay_between_boats			= 2.0 
  17. 	M09_boat_is_close				=  7.0 
  18. 	M09_max_player_dist_from_boat	=140.0 
  19. 	M09_cargo_ship_camera_shake     = "cargo_plane_interior" 
  20. 	M09_cargo_ship_camera_shake_amt = 0.4 
  21. 	M09_chase_boat_min_dist_to_player = 30.0 
  22. 	M09_chase_boat_slow_speed       = 20.0 
  23. 	M09_dead_boat_release_delay     = 5.0  -- How long after a ho boat attacker boat is destroyed should we wait before releasing it? 
  24. 	 
  25. 	M09_min_notoriety  = 3 -- Actual notoriety range to use when driving to the Saints HQ or Brothel 
  26. 	M09_max_notoriety  = 3 
  27. 	 
  28. -- Audio emitters -- 
  29. 	M09_audio_emitters = { 
  30. 		girls_1 = "Container_Stripper<001>", 
  31. 		girls_2 = "Container_Stripper<002>", 
  32. 		girls_3 = "Container_Stripper<003>", 
  33. 		girls_4 = "Container_Stripper<004>", 
  34. 		brute_1 = "Container_Brute<001>", 
  35. 		brute_2 = "Container_Brute<002>", 
  36. 	} 
  37.  
  38. -- Navpoints -- 
  39. 	M09_nav = { 
  40. 		zimos_girls = { 
  41. 			"zimos_nav 1", "zimos_nav 2", "zimos_nav 3", 
  42. 		}, 
  43. 		boat_advance_positions = { "boat_advance_pos 001", "boat_advance_pos 002", }, 
  44. 		choice_saints_hq = { 
  45. 			host = "nav_hq_host", 
  46. 			client = "nav_hq_client", 
  47. 		}, 
  48. 		choice_brothel = { 
  49. 			host = "nav_brothel_host", 
  50. 			client = "nav_brothel_client", 
  51. 		}, 
  52. 	} 
  53. 	 
  54. 	M09_boat_paths = { 
  55. 		north = { 
  56. 			boat_paths = {"north_boat_path 001", "north_boat_path 002", "north_boat_path 003", },  
  57. 			approach_path = "north_boat_approach", 
  58. 			boat_holding_path = "north_boat_holding_loop", 
  59. 			jetski_holding_path = "north_jetski_holding_loop", 
  60. 			drive_back = {"north_boat_drive_back_path 001", }, 
  61. 			boat_stop =  "north_boat_stairs_dest 001", 
  62. 			boat_abandon_stop = "north_boat_stairs_dest 002", 
  63. 			stairs_nav = "Boat_stairs_front 001", 
  64. 			upstairs = "Boat_front_upstairs", 
  65. 		}, 
  66. 		 
  67. 		south = { 
  68. 			boat_paths = {"south_boat_path 001", "south_boat_path 002", "south_boat_path 003", }, 
  69. 			approach_path = "south_boat_approach", 
  70. 			boat_holding_path = "south_boat_holding_loop", 
  71. 			jetski_holding_path = "south_jetski_holding_loop", 
  72. 			drive_back = {"south_boat_drive_back_path 001" }, 
  73. 			boat_stop =  "south_boat_stairs_dest 001", 
  74. 			boat_abandon_stop = "south_boat_stairs_dest 002", 
  75. 			stairs_nav = "Boat_stairs_rear 001", 
  76. 			upstairs = "Boat_rear_upstairs", 
  77. 		}, 
  78. 	} 
  79. 	 
  80. -- Groups -- 
  81.  
  82. 	M09_group = { 
  83. 		local_start_vehicle = { 
  84. 			name = "local_start_vehicle_group", 
  85. 			members = {}, 
  86. 			vehicle = "start_vehicle 001", 
  87. 		}, 
  88. 		 
  89. 		remote_start_vehicle = { 
  90. 			name = "remote_start_vehicle_group", 
  91. 			members = {}, 
  92. 			vehicle = "start_vehicle 002", 
  93. 		}, 
  94. 		 
  95. 		girls1 = { 
  96. 			name = "girls_group 001", 
  97. 			members = { "girl 001", "girl 002",} 
  98. 		}, 
  99. 		 
  100. 		girls2 = { 
  101. 			name = "girls_group 002", 
  102. 			members = { "girl 003", "girl 004",} 
  103. 		}, 
  104. 		 
  105. 		girls3 = { 
  106. 			name = "girls_group 003", 
  107. 			members = { "girl 005", "girl 006",} 
  108. 		}, 
  109. 		 
  110. 		girls4 = { 
  111. 			name = "girls_group 004", 
  112. 			members = { "girl 007", "girl 008",} 
  113. 		}, 
  114. 		 
  115. 		girls_in_heli_crate = { 
  116. 			name = "girls_in_heli_crate_group", 
  117. 			members = { "girl_in_heli_crate 001", "girl_in_heli_crate 002", "girl_in_heli_crate 003", "girl_in_heli_crate 004",  
  118. 						"girl_in_heli_crate 005", "girl_in_heli_crate 006", "girl_in_heli_crate 007", "girl_in_heli_crate 008", } 
  119. 		}, 
  120.  
  121. 		brute1 = { 
  122. 			name = "Brute_group 001", 
  123. 			members = { "Brute 001" } 
  124. 		}, 
  125. 		 
  126. 		minigun_brute = { 
  127. 			name = "Minigun_Brute_group 001", 
  128. 			members = { "Minigun_Brute 001" } 
  129. 		}, 
  130.  
  131. 		weapons = { 
  132. 			name = "weapon_group", 
  133. 		}, 
  134. 		 
  135. 		ammo_crate_smg = { 
  136. 			name = "Weapon_Pickup_SMG", 
  137. 		}, 
  138. 		 
  139. 		ammo_crate_grenades = { 
  140. 			name = "Weapon_Pickup_Grenades", 
  141. 		}, 
  142. 		 
  143. 		ammo_crate_rpg = { 
  144. 			name = "Weapon_Pickup_RPG", 
  145. 		}, 
  146. 		 
  147. 		-- guards waiting on the boat 
  148. 		boat_guards = { 
  149. 			name = "boat_guards", 
  150. 			members = { "boat_guard 001", "boat_guard 002", "boat_guard 003", "boat_guard 004", "boat_guard 005", "boat_guard 006", } 
  151. 		}, 
  152. 		 
  153. 		-- Helicopters that orbit the ho boat. 
  154. 		attack_heli_01 = { 
  155. 			name = "attack_heli_group 001", 
  156. 			vehicle = "attack_heli <001>", 
  157. 			pilot = "attack_heli_pilot <001>", 
  158. 			gunner = "attack_heli_gunner <001>", 
  159. 			approach_path = "attack_heli_approach <001>", 
  160. 			orbit_path = "attack_heli_orbit <001>", 
  161. 			orbit_speed = 7, 
  162. 			thread = INVALID_THREAD_HANDLE, 
  163. 		},		 
  164. 		attack_heli_02 = { 
  165. 			name = "attack_heli_group 002", 
  166. 			vehicle = "attack_heli <002>", 
  167. 			pilot = "attack_heli_pilot <002>", 
  168. 			gunner = "attack_heli_gunner <002>", 
  169. 			approach_path = "attack_heli_approach <002>", 
  170. 			orbit_path = "attack_heli_orbit <002>", 
  171. 			orbit_speed = 12, 
  172. 			thread = INVALID_THREAD_HANDLE, 
  173. 		}, 
  174. 		 
  175. 		-- Transport helicopters that attack the ho boat. 
  176. 		attack_transport_01 = { 
  177. 			name = "transport_heli_group 001", 
  178. 			vehicle = "transport_heli <001>", 
  179. 			pilot = "trans_heli_npc_1<1>", 
  180. 			approach_path = "trans_heli_north_path", 
  181. 			land_path = "trans_heli_north_land_path", 
  182. 			exit_path = "trans_heli_north_exit_path", 
  183. 			thread = INVALID_THREAD_HANDLE, 
  184. 			debug_done = false, 
  185. 		}, 
  186. 		attack_transport_soldiers_01 = { 
  187. 			name = "transport_soldiers 001", 
  188. 			members = { "trans_heli_npc_1<2>", "trans_heli_npc_1<3>", "trans_heli_npc_1<4>", "trans_heli_npc_1<5>" }, 
  189. 		}, 
  190. 		attack_transport_02 = { 
  191. 			name = "transport_heli_group 002", 
  192. 			vehicle = "transport_heli <002>", 
  193. 			pilot = "trans_heli_npc_2<1>", 
  194. 			approach_path = "trans_heli_center_path", 
  195. 			land_path = "trans_heli_center_land_path", 
  196. 			exit_path = "trans_heli_center_exit_path", 
  197. 			thread = INVALID_THREAD_HANDLE, 
  198. 			debug_done = false, 
  199. 		}, 
  200. 		attack_transport_soldiers_02 = { 
  201. 			name = "transport_soldiers 002", 
  202. 			members = { "trans_heli_npc_2<2>", "trans_heli_npc_2<3>", "trans_heli_npc_2<4>", "trans_heli_npc_2<5>" }, 
  203. 		}, 
  204. 		attack_transport_03 = { 
  205. 			name = "transport_heli_group 003", 
  206. 			vehicle = "transport_heli <003>", 
  207. 			pilot = "trans_heli_npc_3<1>", 
  208. 			approach_path = "trans_heli_south_path", 
  209. 			land_path = "trans_heli_south_land_path", 
  210. 			exit_path = "trans_heli_south_exit_path", 
  211. 			thread = INVALID_THREAD_HANDLE, 
  212. 			debug_done = false, 
  213. 		}, 
  214. 		attack_transport_soldiers_03 = { 
  215. 			name = "transport_soldiers 003", 
  216. 			members = { "trans_heli_npc_3<2>", "trans_heli_npc_3<3>", "trans_heli_npc_3<4>", "trans_heli_npc_3<5>" }, 
  217. 		}, 
  218. 		 
  219. 		-- four seater 
  220. 		boat1 = { 
  221. 			name = "Boat_group 001", 
  222. 			drive_boat_back = true, 
  223. 			is_jetski = false, 
  224. 			is_docking = false, 
  225. 			members = { "Boat1_attacker 001", "Boat1_attacker 002", "Boat1_attacker 003", "Boat1_attacker 004" }, 
  226. 			vehicle = "Attack_boat 001", 
  227. 			thread = INVALID_THREAD_HANDLE, 
  228. 			pathfind_thread = INVALID_THREAD_HANDLE, 
  229. 		}, 
  230. 		 
  231. 		-- four seater 
  232. 		boat2 = { 
  233. 			name = "Boat_group 002", 
  234. 			drive_boat_back = true, 
  235. 			is_jetski = false, 
  236. 			is_docking = false, 
  237. 			members = { "Boat2_attacker 001", "Boat2_attacker 002", "Boat2_attacker 003", "Boat2_attacker 004" }, 
  238. 			vehicle = "Attack_boat 002", 
  239. 			thread = INVALID_THREAD_HANDLE, 
  240. 			pathfind_thread = INVALID_THREAD_HANDLE, 
  241. 		}, 
  242. 		 
  243. 		-- two seater 
  244. 		boat3 = { 
  245. 			name = "Boat_group 003", 
  246. 			drive_boat_back = false, 
  247. 			is_jetski = true, 
  248. 			is_docking = false, 
  249. 			members = { "Boat3_attacker 001", "Boat3_attacker 002" }, 
  250. 			vehicle = "Attack_boat 003", 
  251. 			thread = INVALID_THREAD_HANDLE, 
  252. 			pathfind_thread = INVALID_THREAD_HANDLE, 
  253. 		}, 
  254. 		 
  255. 		-- two seater 
  256. 		boat4 = { 
  257. 			name = "Boat_group 004", 
  258. 			drive_boat_back = false, 
  259. 			is_jetski = true, 
  260. 			is_docking = false, 
  261. 			members = { "Boat4_attacker 001", "Boat4_attacker 002" }, 
  262. 			vehicle = "Attack_boat 004", 
  263. 			thread = INVALID_THREAD_HANDLE, 
  264. 			pathfind_thread = INVALID_THREAD_HANDLE, 
  265. 		}, 
  266. 		 
  267. 		-- four seater 
  268. 		boat5 = { 
  269. 			name = "Boat_group 005", 
  270. 			drive_boat_back = true, 
  271. 			is_jetski = false, 
  272. 			is_docking = false, 
  273. 			members = { "Boat5_attacker 001", "Boat5_attacker 002", "Boat5_attacker 003", "Boat5_attacker 004" }, 
  274. 			vehicle = "Attack_boat 005", 
  275. 			thread = INVALID_THREAD_HANDLE, 
  276. 			pathfind_thread = INVALID_THREAD_HANDLE, 
  277. 		}, 
  278. 		 
  279. 		player_pickup = { 
  280. 			name = "Player_pickup_heli_group", 
  281. 			pilot = "Player_pickup_heli_pilot", 
  282. 			vehicle = "Player_pickup_heli", 
  283. 			float_nav = "Player_pickup_heli_start", 
  284. 			path = {{path = "Player_pickup_path", speed = 40.0},}, 
  285. 			thread = INVALID_THREAD_HANDLE, 
  286. 		}, 
  287. 		 
  288. 		girls_pickup = { 
  289. 			name = "Girls_pickup_heli_group", 
  290. 			pilot = "Girls_pickup_heli_pilot", 
  291. 			vehicle = "Girls_pickup_heli", 
  292. 			float_nav = "Girls_pickup_heli_start", 
  293. 			path = {{path = "Girls_float_nav", speed = 40.0},}, 
  294. 			thread = INVALID_THREAD_HANDLE, 
  295. 		}, 
  296. 		 
  297. 		player_rail = { 
  298. 			name = "heli_rail_group", 
  299. 			pilot = "player_pilot", 
  300. 			vehicle = "rail_heli", 
  301. 			path = "Player_heli_route", 
  302. 			start = "Player_pickup_heli_end", 
  303. 			pause_nav = "Player_heli_pause_nav", 
  304. 		}, 
  305. 		 
  306. 		girls_heli = { 
  307. 			name = "Girls_heli_group", 
  308. 			pilot = "Girls_heli_pilot", 
  309. 			vehicle = "Girls_heli", 
  310. 			float_nav = "Girls_float_nav", 
  311. 			pause_nav = "Girls_float_nav_2", 
  312. 			path = { 
  313. 					{path = "Girls_heli_route 001 a", speed  = 15.5}, 
  314. 					{path = "Girls_heli_route 001 b", speed  = 11.0}, 
  315. 					{path = "Girls_heli_route 001 c", speed  = 12.0}, 
  316. 					{path = "Girls_heli_route 001 d", speed  = 19.0}, 
  317. 					{path = "Girls_heli_route 002 a", speed = 16.0}, 
  318. 					{path = "Girls_heli_route 002 a2", speed = 12.0}, 
  319. 					{path = "Girls_heli_route 002 b", speed = 12.0}, 
  320. 					{path = "Girls_heli_route 002 c", speed = 9.0}, 
  321. 					{path = "Girls_heli_route 002 c2", speed = 6.0}, 
  322. 					{path = "Girls_heli_route 002 c3", speed = 6.0}, 
  323. 					{path = "Girls_heli_route 002 d", speed = 10.0}, 
  324. 					{path = "Girls_heli_route 002 e", speed = 15.0}, 
  325. 					{path = "Girls_heli_route 002 f", speed = 12.5}, 
  326. 					--[[ 
  327. 					{path = "Girls_heli_route 003 a", speed = 11.0}, 
  328. 					{path = "Girls_heli_route 003 b", speed = 2.0}, 
  329. 					{path = "Girls_heli_route 003 c", speed = 17.0}, 
  330. 					{path = "Girls_heli_route 003 d", speed = 11.0}, 
  331. 					{path = "Girls_heli_route 004", speed = 12.0}, 
  332. 					--]] 
  333. 				}, 
  334. 			thread = INVALID_THREAD_HANDLE, 
  335. 		}, 
  336. 		 
  337. 		girls_truck = { 
  338. 			name = "girls_truck_group", 
  339. 			vehicle = "girls_truck" 
  340. 		}, 
  341. 		 
  342. 		-- homies 
  343. 		start_homies = { 
  344. 			name = "homies_start", 
  345. 			zimos = "zimos_start" 
  346. 		}, 
  347. 		 
  348. 		gangway_homies = { 
  349. 			name = "homies_gangway", 
  350. 			zimos = "zimos_gangway" 
  351. 		}, 
  352. 		 
  353. 		-- Rail lookat groups 
  354. 		player_lookat_1 = { 
  355. 			name = "player_lookat_group_1", 
  356. 			spawned = false, 
  357. 			members = {"Player_route_lookat_1", } 
  358. 		}, 
  359. 		 
  360. 		-- Roof Groups 
  361. 		roof1 = { 
  362. 			name = "roof_group 001", 
  363. 			spawned = false, 
  364. 			members = { --[["roof_npc 001",--]] "roof_npc 001<001>", "roof_npc 001<002>", "roof_npc 001<003>", "roof_npc 001<004>", "roof_npc 001<005>", "roof_npc 001<067>", "roof_npc 001<068>",  
  365. 															"roof_npc 001<069>", "roof_npc 001<070>", "roof_npc 001<071>",  "roof_npc 001<072>",  "roof_npc 001<073>",  "roof_npc 001<074>",  "roof_npc 001<075>", 
  366. 															 "roof_npc 001<076>",  "roof_npc 001<077>",  } 
  367. 		}, 
  368. 		 
  369. 		roof2 = { 
  370. 			name = "roof_group 002", 
  371. 			spawned = false, 
  372. 			members = { "roof_npc 001<006>", "roof_npc 001<007>", "roof_npc 001<008>", "roof_npc 001<009>", "roof_npc 001<010>", "roof_npc 001<011>", "roof_npc 001<012>", } 
  373. 		}, 
  374. 		 
  375. 		roof3 = { 
  376. 			name = "roof_group 003", 
  377. 			spawned = false, 
  378. 			members = { "roof_npc 001<013>", "roof_npc 001<014>", "roof_npc 001<015>", "roof_npc 001<016>", "roof_npc 001<017>", } 
  379. 		}, 
  380. 		 
  381. 		roof4 = { 
  382. 			name = "roof_group 004", 
  383. 			spawned = false, 
  384. 			members = { "roof_npc 001<018>", "roof_npc 001<019>", "roof_npc 001<020>", "roof_npc 001<021>", "roof_npc 001<022>", "roof_npc 001<023>", "roof_npc 001<060>", } 
  385. 		}, 
  386. 		 
  387. 		roof5 = { 
  388. 			name = "roof_group 005", 
  389. 			spawned = false, 
  390. 			members = { "roof_npc 001<024>", "roof_npc 001<025>", "roof_npc 001<026>", "roof_npc 001<027>", "roof_npc 001<028>", "roof_npc 001<029>", 
  391. 							"roof_npc 001<030>", "roof_npc 001<031>", "roof_npc 001<032>", "roof_npc 001<033>", } 
  392. 		}, 
  393. 		 
  394. 		roof6 = { 
  395. 			name = "roof_group 006", 
  396. 			spawned = false, 
  397. 			members = { "roof_npc 001<034>", "roof_npc 001<035>", "roof_npc 001<036>", "roof_npc 001<037>", "roof_npc 001<038>", "roof_npc 001<039>", 
  398. 							"roof_npc 001<040>", "roof_npc 001<041>", "roof_npc 001<042>", "roof_npc 001<043>", "roof_npc 001<044>", "roof_npc 001<045>", 
  399. 							"roof_npc 001<046>", "roof_npc 001<047>", "roof_npc 001<048>", "roof_npc 001<049>", "roof_npc 001<050>", } 
  400. 		}, 
  401. 		 
  402. 		roof7 = { 
  403. 			name = "roof_group 007", 
  404. 			spawned = false, 
  405. 			members = { "roof_npc 001<051>", "roof_npc 001<052>", "roof_npc 001<053>", "roof_npc 001<054>", "roof_npc 001<055>", "roof_npc 001<056>", 
  406. 							"roof_npc 001<057>", "roof_npc 001<058>", "roof_npc 001<059>", } 
  407. 		}, 
  408. 		 
  409. 		-- Murderbrawl roof 
  410. 		roof_mb  = { 
  411. 			name = "roof_mb_group", 
  412. 			spawned = false, 
  413. 			members = { "roof_mb_npc <001>", "roof_mb_npc <002>", "roof_mb_npc <003>", "roof_mb_npc <004>", "roof_mb_npc <005>", "roof_mb_npc <006>",  
  414. 						"roof_mb_npc <007>", "roof_mb_npc <008>", "roof_mb_npc <009>", "roof_mb_npc <010>", "roof_mb_npc <011>", } 
  415. 		}, 
  416. 		 
  417. 		-- Rail sequence boats 
  418. 		heli_boats = { 
  419. 			name = "heli_boat_group", 
  420. 			spawned = false, 
  421. 			speed = 37.0, 
  422. 			start_ai_disabled = true, 
  423. 			vehicles = { 
  424. 				{ 
  425. 					vehicle = "heli_boat <001>",  
  426. 					members = {"heli_boat_npc <002>", "heli_boat_npc <004>",},  
  427. 					path = {"heli_boat_path <001>", "river_chase_path 1", }, 
  428. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  429. 				}, 
  430. 				{ 
  431. 					vehicle = "heli_boat <002>",  
  432. 					members = {"heli_boat_npc <006>", "heli_boat_npc <008>",},  
  433. 					path = {"heli_boat_path <002>", "river_chase_path 2", }, 
  434. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  435. 					trailing_aim = true, 
  436. 				},--[[ 
  437. 				{ 
  438. 					vehicle = "heli_boat <003>",  
  439. 					members = {"heli_boat_npc <009>", "heli_boat_npc <010>", },  
  440. 					path = {"heli_boat_path <003>", "river_chase_path 2", }, 
  441. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  442. 				},--]] 
  443. 				{ 
  444. 					vehicle = "heli_boat <004>",  
  445. 					members = {"heli_boat_npc <012>", "heli_boat_npc <014>",},  
  446. 					path = {"heli_boat_path <004>", "river_chase_path 2", }, 
  447. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  448. 					target_player = true, 
  449. 				}, 
  450. 				{ 
  451. 					vehicle = "heli_boat <005>",  
  452. 					members = {"heli_boat_npc <016>", "heli_boat_npc <018>",},  
  453. 					path = {"heli_boat_path <005>", "river_chase_path 1", }, 
  454. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  455. 					trailing_aim = true, 
  456. 					target_player = true, 
  457. 				}, 
  458. 			}, 
  459. 		}, 
  460. 		 
  461. 		heli_boats_2 = { 
  462. 			name = "heli_boat_group_2", 
  463. 			spawned = false, 
  464. 			speed = 37.0, 
  465. 			start_ai_disabled = true, 
  466. 			vehicles = { 
  467. 				{ 
  468. 					vehicle = "heli_boat_2 1",  
  469. 					members = {"heli_boat_2_npc 02", "heli_boat_2_npc 04",},  
  470. 					path = {"heli_boat_2_path 1", "river_chase_path 1", }, 
  471. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  472. 					target_player = true, 
  473. 				}, 
  474. 				{ 
  475. 					vehicle = "heli_boat_2 2",  
  476. 					members = {"heli_boat_2_npc 06", "heli_boat_2_npc 08",},  
  477. 					path = {"heli_boat_2_path 2", "river_chase_path 3", }, 
  478. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  479. 					trailing_aim = true, 
  480. 				}, 
  481. 				{ 
  482. 					vehicle = "heli_boat_2 3",  
  483. 					members = {"heli_boat_2_npc 10", "heli_boat_2_npc 12",},  
  484. 					path = {"heli_boat_2_path 2", "river_chase_path 3", }, 
  485. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  486. 					trailing_aim = true, 
  487. 					target_player = true, 
  488. 				}, 
  489. 				{ 
  490. 					vehicle = "heli_boat_2 4",  
  491. 					members = {"heli_boat_2_npc 14", "heli_boat_2_npc 16",},  
  492. 					path = {"heli_boat_2_path 1", "river_chase_path 1", }, 
  493. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  494. 					target_player = true, 
  495. 				}, 
  496. 			}, 
  497. 		}, 
  498. 		 
  499. 		heli_boats_3 = { 
  500. 			name = "heli_boat_group_3", 
  501. 			spawned = false, 
  502. 			speed = 50.0, 
  503. 			start_ai_disabled = true, 
  504. 			thread_func = "m09_throttle_heli_boats", 
  505. 			thread = INVALID_THREAD_HANDLE, 
  506. 			vehicles = { 
  507. 				{ 
  508. 					vehicle = "heli_boat_3 1",  
  509. 					members = {"heli_boat_3_npc 04", "heli_boat_3_npc 10",},  
  510. 					path = {"heli_boat_3_path 1", "river_chase_path 1", }, 
  511. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  512. 					target_player = true, 
  513. 				}, 
  514. 				{ 
  515. 					vehicle = "heli_boat_3 2",  
  516. 					members = {"heli_boat_3_npc 05", "heli_boat_3_npc 11",},  
  517. 					path = {"heli_boat_3_path 1", "river_chase_path 1", }, 
  518. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  519. 					trailing_aim = true, 
  520. 					target_player = true, 
  521. 				}, 
  522. 				{ 
  523. 					vehicle = "heli_boat_3 3",  
  524. 					members = {"heli_boat_3_npc 06", "heli_boat_3_npc 12",},  
  525. 					path = {"heli_boat_3_path 3", "river_chase_path 3", }, 
  526. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  527. 				}, 
  528. 				{ 
  529. 					vehicle = "heli_boat_3 4",  
  530. 					members = {"heli_boat_3_npc 16", "heli_boat_3_npc 22",},  
  531. 					path = {"heli_boat_3_path 2", "river_chase_path 2", }, 
  532. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  533. 					target_player = true, 
  534. 				}, 
  535. 				{ 
  536. 					vehicle = "heli_boat_3 5",  
  537. 					members = {"heli_boat_3_npc 17", "heli_boat_3_npc 23",},  
  538. 					path = {"heli_boat_3_path 2", "river_chase_path 2", }, 
  539. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  540. 					trailing_aim = true, 
  541. 					target_player = true, 
  542. 				}, 
  543. 				{ 
  544. 					vehicle = "heli_boat_3 6",  
  545. 					members = {"heli_boat_3_npc 18", "heli_boat_3_npc 24",},  
  546. 					path = {"heli_boat_3_path 3", "river_chase_path 3", }, 
  547. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  548. 					trailing_aim = true, 
  549. 				}, 
  550. 			}, 
  551. 		}, 
  552. 		 
  553. 		-- Rail sequence tank 
  554. 		heli_tank1 = { 
  555. 			name = "heli_tank_group 001", 
  556. 			spawned = false, 
  557. 			vehicles = { 
  558. 				{ 
  559. 					vehicle = "heli_tank <001>", 
  560. 					members = {"heli_tank_npc <001>", "heli_tank_npc <002>",}, 
  561. 					path = "tank_spline_1", 
  562. 					speed = 30, 
  563. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  564. 				}, 
  565. 				{ 
  566. 					vehicle = "heli_tank <002>", 
  567. 					members = {"heli_tank_npc <003>", "heli_tank_npc <004>",}, 
  568. 					path = "tank_spline_1", 
  569. 					speed = 30, 
  570. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  571. 				}, 
  572. 				{ 
  573. 					vehicle = "heli_tank <003>", 
  574. 					members = {"heli_tank_npc <005>", "heli_tank_npc <006>",}, 
  575. 					path = {"tank_spline_2", "tank_spline_1",}, 
  576. 					speed = 30, 
  577. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  578. 				}, 
  579. 				{ 
  580. 					vehicle = "heli_tank <006>", 
  581. 					--members = {"heli_tank_npc <009>", "heli_tank_npc <010>",}, 
  582. 					gunner = "heli_tank_npc <009>", 
  583. 					path = "", 
  584. 					speed = 40, 
  585. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  586. 				}, 
  587. 				{ 
  588. 					vehicle = "heli_tank <007>", 
  589. 					--members = {"heli_tank_npc <011>", "heli_tank_npc <012>",}, 
  590. 					gunner = "heli_tank_npc <011>", 
  591. 					path = "", 
  592. 					speed = 40, 
  593. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  594. 				}, 
  595. 				{ 
  596. 					vehicle = "heli_tank <008>", 
  597. 					--members = {"heli_tank_npc <013>", "heli_tank_npc <014>",}, 
  598. 					gunner = "heli_tank_npc <013>", 
  599. 					path = "", 
  600. 					speed = 40, 
  601. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  602. 				}, 
  603. 			}, 
  604. 		}, 
  605. 		heli_tank2 = { 
  606. 			name = "heli_tank_group 002", 
  607. 			spawned = false, 
  608. 			vehicles = { 
  609. 				{ 
  610. 					vehicle = "heli_tank <004>", 
  611. 					--members = {"heli_tank_npc <007>",}, 
  612. 					gunner = "heli_tank_npc <007>", 
  613. 					path = "", 
  614. 					speed = 0, 
  615. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  616. 				}, 
  617. 				{ 
  618. 					vehicle = "heli_tank <005>", 
  619. 					--members = {"heli_tank_npc <008>",}, 
  620. 					gunner = "heli_tank_npc <008>", 
  621. 					path = "", 
  622. 					speed = 0, 
  623. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  624. 				}, 
  625. 				{ 
  626. 					vehicle = "heli_tank <009>", 
  627. 					members = {"heli_tank_npc <015>", "heli_tank_npc <016>",}, 
  628. 					path = "tank_spline_3", 
  629. 					speed = 15, 
  630. 					pathfind_thread = INVALID_THREAD_HANDLE, 
  631. 				}, 
  632. 			}, 
  633. 		}, 
  634. 		cte_npc_group = { 
  635. 			name = "m09_cte_group", 
  636. 		}, 
  637. 	} 
  638. 	 
  639. 	M09_attack_helis = { M09_group.attack_heli_01, M09_group.attack_heli_02, } 
  640. 	M09_trans_attack_helis = {  
  641. 		{ 
  642. 			heli_group = M09_group.attack_transport_01,  
  643. 			soldier_group = M09_group.attack_transport_soldiers_01, 
  644. 		}, 
  645. 		{ 
  646. 			heli_group = M09_group.attack_transport_02,  
  647. 			soldier_group = M09_group.attack_transport_soldiers_02, 
  648. 		}, 
  649. 		{ 
  650. 			heli_group = M09_group.attack_transport_03,  
  651. 			soldier_group = M09_group.attack_transport_soldiers_03 
  652. 		}, 
  653. 	} 
  654. 	M09_boats = { M09_group.boat1, M09_group.boat2, M09_group.boat3, M09_group.boat4, M09_group.boat5 } 
  655. 	M09_boat_wave1 = { M09_group.boat5, M09_group.boat3, M09_group.boat4, M09_group.boat2, M09_group.boat1 } 
  656. 	M09_boat_wave2 = { M09_group.boat4, M09_group.boat5, M09_group.boat3, M09_group.boat2, M09_group.boat1 } 
  657. 	M09_boat_wave3 = { M09_group.boat2, M09_group.boat4, M09_group.boat1, M09_group.boat3, M09_group.boat5, } 
  658. 	M09_boat_wave4 = { M09_group.boat1, M09_group.boat5, M09_group.boat3, M09_group.boat2, M09_group.boat4, } 
  659. 	 
  660. 	M09_spawn_regions = { 
  661. 		front = {"Front_Spawn_Region 001",}, 
  662. 	} 
  663. 	 
  664. 	M09_spawn_groups = { 
  665. 		normal = {"Continuous_spawn_group 001", "Continuous_spawn_group 002",},  
  666. 		snipers = {"Continuous_spawn_group 003",}, 
  667. 	} 
  668.  
  669. -- current homie 
  670. 	M09_Zimos = M09_group.start_homies.zimos 
  671. 	 
  672. 	-- indexed table that gives order of segments to traverse 
  673. 	M09_player_rail_segments = { 
  674. 		{ 
  675. 			path = "Player_route 001 a", 
  676. 			speed = 15.0, 
  677. 			stop_at_end = false, 
  678. 			end_callback = { 
  679. 				func = "m09_heli_face_target", 
  680. 				args = { 
  681. 					M09_group.player_rail.vehicle, M09_group.player_lookat_1.members[1] 
  682. 				}, 
  683. 			}, 
  684. 		}, 
  685. 		 
  686. 		{ 
  687. 			path = "Player_route 001 b", 
  688. 			speed = 12.0, 
  689. 			stop_at_end = false, 
  690. 			end_callback = { 
  691. 				func = "m09_heli_stop_facing_target", 
  692. 				args = { 
  693. 					M09_group.player_rail.vehicle 
  694. 				}, 
  695. 			}, 
  696. 		}, 
  697. 		 
  698. 		{ 
  699. 			path = "Player_route 002", 
  700. 			speed = 15.0, 
  701. 			stop_at_end = false, 
  702. 		}, 
  703. 		 
  704. 		{ 
  705. 			path = "Player_route 003", 
  706. 			speed = 10.0, 
  707. 			stop_at_end = false, 
  708. 			end_callback = { 
  709. 				func = "m09_fire_scripted_rpg", 
  710. 				args = { 
  711. 					{ 
  712. 						origin = "mb_script_rpg_1_origin", 
  713. 						target = "mb_script_rpg_1_target", 
  714. 						delay = 1.0, 
  715. 					}, 
  716. 					{ 
  717. 						origin = "mb_script_rpg_2_origin", 
  718. 						target = "mb_script_rpg_2_target", 
  719. 						delay = 0.2, 
  720. 					}, 
  721. 				}, 
  722. 			}, 
  723. 		}, 
  724. 		 
  725. 		{ 
  726. 			path = "Player_route 004", 
  727. 			speed = 16.0, 
  728. 			stop_at_end = false, 
  729. 		}, 
  730. 		 
  731. 		{ 
  732. 			path = "Player_route 004 a", 
  733. 			speed = 6.5, 
  734. 			stop_at_end = false, 
  735. 		}, 
  736. 		 
  737. 		{ 
  738. 			path = "Player_route 004 b", 
  739. 			speed = 13.0, 
  740. 			stop_at_end = false, 
  741. 		}, 
  742. 		 
  743. 		{ 
  744. 			path = "Player_route 005", 
  745. 			speed = 23.0, 
  746. 			stop_at_end = false, 
  747. 			end_callback = { 
  748. 				func = "m09_wind_down_rail_music", 
  749. 				args = nil, 
  750. 			}, 
  751. 		}, 
  752. 		 
  753. 		{ 
  754. 			path = "Player_route 006", 
  755. 			speed = 12.0, 
  756. 			stop_at_end = true, 
  757. 		}, 
  758. 		--[[ 
  759. 		{ 
  760. 			path = "Player_route 006 a", 
  761. 			speed = 08.0, 
  762. 			stop_at_end = false, 
  763. 			end_callback = { 
  764. 				func = "m09_fire_scripted_rpg", 
  765. 				args = { 
  766. 					{ 
  767. 						origin = "pc_script_rpg_1_origin", 
  768. 						target = "pc_script_rpg_1_target", 
  769. 						delay = 0.0, 
  770. 					}, 
  771. 					{ 
  772. 						origin = "pc_script_rpg_2_origin", 
  773. 						target = "pc_script_rpg_2_target", 
  774. 						delay = 0.5, 
  775. 					}, 
  776. 					{ 
  777. 						origin = "pc_script_rpg_3_origin", 
  778. 						target = "pc_script_rpg_3_target", 
  779. 						delay = 1.0, 
  780. 					}, 
  781. 				}, 
  782. 			}, 
  783. 		}, 
  784. 		 
  785. 		{ 
  786. 			path = "Player_route 006 a<001>", 
  787. 			speed = 08.0, 
  788. 			stop_at_end = false, 
  789. 		}, 
  790. 		 
  791. 		{ 
  792. 			path = "Player_route 006 b", 
  793. 			speed = 06.0, 
  794. 			stop_at_end = false, 
  795. 		}, 
  796. 		 
  797. 		{ 
  798. 			path = "Player_route 007", 
  799. 			speed = 12.0, 
  800. 			stop_at_end = true, 
  801. 		}, 
  802. 		 
  803. 		{ 
  804. 			path = "Player_route 008", 
  805. 			speed = 10.0, 
  806. 			stop_at_end = true, 
  807. 		}, 
  808. 		 
  809. 		{ 
  810. 			path = "Player_route 009", 
  811. 			speed = 20.0, 
  812. 			stop_at_end = true, 
  813. 		}, 
  814. 		--]] 
  815. 	} 
  816.  
  817. -- Characters -- 
  818.  
  819. -- Vehicles -- 
  820.  
  821. -- Mesh Movers -- 
  822.  
  823. -- Text -- 
  824. 	M09_objective = { 
  825. 		go_to_ship			= {name = "M09_OBJ_GO_TO_SHIP", icon = OI_ASSET_LOCATION}, 
  826. 		find_girls			= {name = "M09_OBJ_FIND_THE_GIRLS", icon = OI_ASSET_USE}, 
  827. 		wait_for_chopper	= {name = "M09_OBJ_WAIT_FOR_CHOPPER", icon = OI_ASSET_INVALID}, 
  828. 		jump_to_chopper	= {name = "SH03_OBJ_ENTER_HELI", icon = OI_ASSET_LOCATION}, 
  829. 		defend_heli			= {name = "M09_OBJ_DEFEND_HELI", icon = OI_ASSET_DEFEND}, 
  830. 		take_truck			= {name = "M09_OBJ_GET_INTO_TRUCK", icon = OI_ASSET_USE}, 
  831. 		choice				= {name = "M09_OBJ_CHOICE", icon = OI_ASSET_LOCATION}, 
  832. 		kill_guards			= {name = "M09_OBJ_KILL_GUARDS", icon = OI_ASSET_KILL}, 
  833. 		north_platform		= {name = "M09_OBJ_NORTH_PLATFORM", icon = OI_ASSET_LOCATION}, 
  834. 		clear_the_boat		= {name = "M09_OBJ_KILL_ATTACKERS", icon = OI_ASSET_KILL}, 
  835. 		south_platform		= {name = "M09_OBJ_SOUTH_PLATFORM", icon = OI_ASSET_LOCATION}, 
  836. 		to_hq				= {name = "M09_OBJ_TO_SAINTS_HQ", icon = OI_ASSET_LOCATION}, 
  837. 		to_brothel			= {name = "M09_OBJ_TO_BROTHEL", icon = OI_ASSET_LOCATION}, 
  838. 	} 
  839.  
  840. -- Threads -- 
  841. 	M09_zimos_girl_thread   = INVALID_THREAD_HANDLE 
  842. 	M09_girls_follow_zimos_thread = INVALID_THREAD_HANDLE 
  843. 	M09_line_failsafe_thread = INVALID_THREAD_HANDLE 
  844. 	M09_get_to_south_platform_thread = INVALID_THREAD_HANDLE 
  845. 	M09_path_end_callback_thread = INVALID_THREAD_HANDLE 
  846. 	M09_delay_thread = INVALID_THREAD_HANDLE 
  847. 	M09_failsafe_thread = INVALID_THREAD_HANDLE 
  848. 	M09_zimos_comforting_hos_thread = INVALID_THREAD_HANDLE 
  849.  
  850. -- Checkpoints -- 
  851. 	M09_checkpoint = { 
  852. 		start = { 
  853. 			name = MISSION_START_CHECKPOINT, 
  854. 			nav1 = "start_nav 001", 
  855. 			nav2 = "start_nav 002" 
  856. 		}, 
  857. 		 
  858. 		gangway = { 
  859. 			name = "m09_checkpoint_gangway", 
  860. 			nav1 = "gangway_nav 001", 
  861. 			nav2 = "gangway_nav 002" 
  862. 		}, 
  863. 		 
  864. 		defend_girls = { 
  865. 			name = "m09_checkpoint_defend_girls", 
  866. 			nav1 = "Defend_girls_nav 001", 
  867. 			nav2 = "Defend_girls_nav 002", 
  868. 		}, 
  869. 		 
  870. 		heli_rail = { 
  871. 			name = "m09_checkpoint_heli_rail", 
  872. 			nav1 = "rail_heli_nav 001", 
  873. 			nav2 = "rail_heli_nav 002" 
  874. 		}, 
  875. 		 
  876. 		truck_route = { 
  877. 			name = "m09_checkpoint_truck_route", 
  878. 			nav1 = "truck_nav 001", 
  879. 			nav2 = "truck_nav 002", 
  880. 		}, 
  881. 	} 
  882. 	 
  883. -- Cutscenes -- 
  884. 	CUTSCENE_MISSION_INTRO	=	"09_in" 
  885. 	CUTSCENE_CTE_BOATS		=	"m09_cte_01" 
  886. 	CUTSCENE_MISSION_OUTRO	=	"09_out" 
  887. 	 
  888. -- Music -- 
  889. 	M09_music = { 
  890. 		boat_begin = "M09_Boat_Music_Start", 
  891. 		boat_pierce_arrive = "M09_Boat_Music_Pierce", 
  892. 		boat_stop = "M09_Boat_Music_Stop", 
  893. 		rail_begin = "M09_Rail_Music_Start", 
  894. 		rail_wind_down = "M09_Rail_Music_Finish", 
  895. 		rail_stop = "M09_Rail_Music_Stop", 
  896. 	} 
  897. 	 
  898. -- Audio events -- 
  899. 	M09_audio_events = { 
  900. 		heli_walla = { 
  901. 			event = "M09_Heli_Walla", 
  902. 			switch_group = nil, 
  903. 			switch = nil, 
  904. 		}, 
  905. 		heli_walla_stop = { 
  906. 			event = "M09_Heli_Walla_Stop", 
  907. 			switch_group = nil, 
  908. 			switch = nil, 
  909. 		}, 
  910. 		stripper_cargo = { 
  911. 			event = "Mission_09", 
  912. 			switch_group = "Mission_09", 
  913. 			switch = "M09_Stripper_Cargo", 
  914. 		}, 
  915. 		stripper_cargo_stop = { 
  916. 			event = "Mission_09_Stop", 
  917. 			switch_group = "Mission_09", 
  918. 			switch = "M09_Stripper_Cargo", 
  919. 		}, 
  920. 		load_truck = { 
  921. 			event = "Mission_09", 
  922. 			switch_group = "Mission_09", 
  923. 			switch = "M09_Load_Truck", 
  924. 		}, 
  925. 	} 
  926. 	 
  927. -- Personas -- 
  928. 	M09_personas = { 
  929. 		{name = "Pierce", handle = INVALID_PERSONA_HANDLE}, 
  930. 		{name = "Zimos", handle = INVALID_PERSONA_HANDLE}, 
  931. 		{name = "Paparazzi_WM", handle = INVALID_PERSONA_HANDLE}, 
  932. 		{name = "Interrogation", handle = INVALID_PERSONA_HANDLE}, 
  933. 		{name = "Matt", handle = INVALID_PERSONA_HANDLE}, 
  934. 	} 
  935. 	 
  936. 	M09_persona_line = { 
  937. 		take_a_boat = { character = LOCAL_PLAYER, name = "M09_Mission_Start_01", play_2d = false, }, 
  938. 		 
  939. 		goto_zimos = { 
  940. 			{ character = LOCAL_PLAYER, name = "M09_Go_To_Zimos_01", play_2d = false, }, 
  941. 			{ character = LOCAL_PLAYER, name = "M09_Go_To_Zimos_02", play_2d = false, }, 
  942. 			{ character = LOCAL_PLAYER, name = "M09_Go_To_Zimos_03", play_2d = false, }, 
  943. 			{ character = LOCAL_PLAYER, name = "M09_Go_To_Zimos_04", play_2d = false, }, 
  944. 		}, 
  945. 		 
  946. 		-- Character reference updated in m09_setup_crew() 
  947. 		follow_zimos = { 
  948. 			{ character = M09_Zimos, name = "M09_Follow_Zimos_01", play_2d = false, }, 
  949. 			{ character = M09_Zimos, name = "M09_Follow_Zimos_02", play_2d = false, }, 
  950. 			{ character = M09_Zimos, name = "M09_Follow_Zimos_03", play_2d = false, }, 
  951. 			{ character = M09_Zimos, name = "M09_Follow_Zimos_04", play_2d = false, }, 
  952. 		}, 
  953. 		 
  954. 		zimos_to_hos = { character = M09_Zimos, name = "M09_Zimos_Taking_Care_Of_Hoes", play_2d = false, }, 
  955. 		 
  956. 		find_ammo = { 
  957. 			{ character = LOCAL_PLAYER, name = "M09_Find_Ammo_03", play_2d = false, }, 
  958. 			{ character = LOCAL_PLAYER, name = "M09_Find_Ammo_02", play_2d = false, }, 
  959. 			{ character = LOCAL_PLAYER, name = "M11_Get_To_VTOL_02", play_2d = false, }, 
  960. 		}, 
  961. 		 
  962. 		find_gag = { 
  963. 			{ character = LOCAL_PLAYER, name = "M09_Find_Gag_01", play_2d = false, }, 
  964. 			{ character = LOCAL_PLAYER, name = "M09_Find_Gag_03", play_2d = false, }, 
  965. 			{ character = LOCAL_PLAYER, name = "M09_Find_Gag_02", play_2d = false, }, 
  966. 			{ character = LOCAL_PLAYER, name = "M09_Find_Ammo_01", play_2d = false, }, 
  967. 		}, 
  968. 		 
  969. 		girl_thanks_1 = { character = "", name = "M09_Box_Thanks", play_2d = false, }, 
  970. 		girl_thanks_2 = { character = "", name = "M09_Box_Thanks", play_2d = false, }, 
  971. 		 
  972. 		girl_complain_1 = { character = "", name = "M09_Back_In_Box", play_2d = false }, 
  973. 		girl_complain_2 = { character = "", name = "M09_Back_In_Box", play_2d = false }, 
  974. 		 
  975. 		melee_brute = { character = LOCAL_PLAYER, name = "M09_Melee_Brute", play_2d = false, },  
  976. 		gat_brute = { character = LOCAL_PLAYER, name = "M09_Gat_Brute", play_2d = false, },  
  977. 		 
  978. 		crates = { character = LOCAL_PLAYER, name = "M09_Many_Crates", play_2d = false, },  
  979. 		 
  980. 		find_minigun = { character = LOCAL_PLAYER, name = "M09_Find_Minigun_01", play_2d = false }, 
  981. 		 
  982. 		heli_drop_off_02 = { character = M09_Zimos, name = "M09_Helis_Drop_Off_Guys_02", play_2d = false }, 
  983. 		heli_drop_off_03 = { character = M09_Zimos, name = "M09_Helis_Drop_Off_Guys_03", play_2d = false }, 
  984. 		 
  985. 		clear_the_boat = { character = "Pierce", name = "M09_Clear_to_Land", play_2d = true, cell_receive = true, }, 
  986. 		heli_at_platform = { character = M09_Zimos, name = "M09_Helicopter_At_Platform", play_2d = false, }, 
  987. 		start_flying   = { character = "Pierce", name = "M09_Flying_Start", play_2d = true, }, 
  988. 		 
  989. 		protect_pierce_1 = { character = "Pierce", name = "M09_Protect_Pierce_01", play_2d = true, }, 
  990. 		protect_pierce_2 = { character = "Pierce", name = "M09_Protect_Pierce_02", play_2d = true, }, 
  991. 		protect_pierce_3 = { character = "Pierce", name = "M09_Protect_Pierce_03", play_2d = true, }, 
  992. 		protect_pierce_4 = { character = "Pierce", name = "M09_Protect_Pierce_04", play_2d = true, }, 
  993. 		 
  994. 		girls_in_truck_1 = { character = LOCAL_PLAYER, name = "M09_Girls_In_Truck_01", play_2d = false, }, 
  995. 		girls_in_truck_2 = { character = LOCAL_PLAYER, name = "M09_Girls_In_Truck_02", play_2d = false, }, 
  996. 		girls_in_truck_3 = { character = LOCAL_PLAYER, name = "M09_Girls_In_Truck_03", play_2d = false, }, 
  997. 		 
  998. 		choice_crib = { character = LOCAL_PLAYER, name = "M09_Choice_Crib_01", play_2d = false, }, 
  999. 		choice_morningstar = { character = LOCAL_PLAYER, name = "M09_Choice_Morningstar_01", play_2d = false, }, 
  1000. 	} 
  1001.  
  1002. -- Conversations -- 
  1003. 	M09_convo = { 
  1004. 		-- Started as soon as the player gets on a boat 
  1005. 		to_boat = { 
  1006. 			files = { 
  1007. 				--{name = M09_persona_line.take_a_boat, delay = 1.0}, 
  1008. 				{name = "m09_boat_ride_01", delay = 4.0}, 
  1009. 				{name = "m09_boat_ride_02", delay = 0.0}, 
  1010. 			}, 
  1011. 			thread = INVALID_THREAD_HANDLE, 
  1012. 		}, 
  1013. 		 
  1014. 		-- Played after the player hits the gangway trigger 
  1015. 		gangway = { 
  1016. 			files = { 
  1017. 				{name = "m09_arrive_boat", delay = 0.0}, 
  1018. 			}, 
  1019. 			thread = INVALID_THREAD_HANDLE, 
  1020. 		}, 
  1021. 		 
  1022. 		-- Played as the player approaches a crate with a brute in it. 
  1023. 		brute_crate = { 
  1024. 			files = { 
  1025. 				{name = "M09_Brute_Crate", delay = 0.0}, 
  1026. 			}, 
  1027. 			thread = INVALID_THREAD_HANDLE, 
  1028. 		}, 
  1029. 		 
  1030. 		--[[ 
  1031. 		-- Played when the player hits a trigger partway through the deck of the boat. 
  1032. 		banter_on_boat = { 
  1033. 			files = { 
  1034. 				{name = "M09_Banter_On_Boat", delay = 0.0}, 
  1035. 			}, 
  1036. 			thread = INVALID_THREAD_HANDLE, 
  1037. 		}, 
  1038. 		--]] 
  1039. 		 
  1040. 		zimos_01 = { 
  1041. 			files = { 
  1042. 				{name = M09_persona_line.girl_thanks_1, delay = 0.0}, 
  1043. 				{name = M09_persona_line.girl_thanks_2, delay = 0.0}, 
  1044. 				{name = M09_persona_line.goto_zimos[1], delay = 3.0}, 
  1045. 				{name = M09_persona_line.follow_zimos[1], delay = 1.0}, 
  1046. 			}, 
  1047. 			thread = INVALID_THREAD_HANDLE, 
  1048. 		}, 
  1049. 		 
  1050. 		zimos_02 = { 
  1051. 			files = { 
  1052. 				{name = M09_persona_line.girl_thanks_1, delay = 0.0}, 
  1053. 				{name = M09_persona_line.girl_thanks_2, delay = 0.0}, 
  1054. 				{name = M09_persona_line.goto_zimos[2], delay = 2.0}, 
  1055. 				{name = M09_persona_line.follow_zimos[2], delay = 1.0}, 
  1056. 			}, 
  1057. 			thread = INVALID_THREAD_HANDLE, 
  1058. 		}, 
  1059. 		 
  1060. 		zimos_03 = { 
  1061. 			files = { 
  1062. 				{name = M09_persona_line.girl_thanks_1, delay = 0.0}, 
  1063. 				{name = M09_persona_line.girl_thanks_2, delay = 0.0}, 
  1064. 				{name = M09_persona_line.goto_zimos[3], delay = 3.0}, 
  1065. 				{name = M09_persona_line.follow_zimos[3], delay = 1.0}, 
  1066. 			}, 
  1067. 			thread = INVALID_THREAD_HANDLE, 
  1068. 		}, 
  1069. 		 
  1070. 		zimos_04 = { 
  1071. 			files = { 
  1072. 				{name = M09_persona_line.girl_thanks_1, delay = 0.0}, 
  1073. 				{name = M09_persona_line.girl_thanks_2, delay = 0.0}, 
  1074. 				{name = M09_persona_line.goto_zimos[4], delay = 2.0}, 
  1075. 				{name = M09_persona_line.follow_zimos[4], delay = 1.0}, 
  1076. 			}, 
  1077. 			thread = INVALID_THREAD_HANDLE, 
  1078. 		}, 
  1079. 		 
  1080. 		crates = { 
  1081. 			files = { 
  1082. 				{name = M09_persona_line.crates, delay = 0.0}, 
  1083. 			}, 
  1084. 			thread = INVALID_THREAD_HANDLE, 
  1085. 		}, 
  1086. 		 
  1087. 		-- Played shortly after the final crate has been found 
  1088. 		load_girls = { 
  1089. 			files = { 
  1090. 				{name = "m09_get_in_crate", delay = 0.0}, 
  1091. 				{name = M09_persona_line.girl_complain_1, delay = 0.0}, 
  1092. 				{name = M09_persona_line.girl_complain_2, delay = 4.0}, 
  1093. 			}, 
  1094. 			thread = INVALID_THREAD_HANDLE, 
  1095. 		}, 
  1096. 		 
  1097. 		defend_girls = { 
  1098. 			files = { 
  1099. 				{name = "M09_Enemies_On_Sides", delay = 5.0}, 
  1100. 				{name = M09_persona_line.clear_the_boat, delay = 1.0, cell_receive = true}, 
  1101. 			}, 
  1102. 			thread = INVALID_THREAD_HANDLE, 
  1103. 		}, 
  1104. 		 
  1105. 		zimos_to_hos = { 
  1106. 			files = { 
  1107. 				{name = M09_persona_line.zimos_to_hos, delay = 1.0}, 
  1108. 			}, 
  1109. 			thread = INVALID_THREAD_HANDLE, 
  1110. 		}, 
  1111. 		 
  1112. 		-- Played between waves of attackers while waiting for the chopper. 
  1113. 		hold_off_attackers = { 
  1114. 			files = { 
  1115. 				{name = "m09_hold_off", delay = 2.0, cell_receive = true}, 
  1116. 				{name = "m09_combat", delay = 0.0}, 
  1117. 			}, 
  1118. 			thread = INVALID_THREAD_HANDLE, 
  1119. 		}, 
  1120. 		 
  1121. 		heli_drop_off_01 = { 
  1122. 			files = { 
  1123. 				{name = "M09_Helis_Drop_Off_Guys_1", delay = 0.0}, 
  1124. 			}, 
  1125. 			thread = INVALID_THREAD_HANDLE, 
  1126. 		}, 
  1127. 		 
  1128. 		heli_drop_off_02 = { 
  1129. 			files = { 
  1130. 				{name = M09_persona_line.heli_drop_off_02, delay = 0.0}, 
  1131. 			}, 
  1132. 			thread = INVALID_THREAD_HANDLE, 
  1133. 		}, 
  1134. 		 
  1135. 		heli_drop_off_03 = { 
  1136. 			files = { 
  1137. 				{name = M09_persona_line.heli_drop_off_03, delay = 0.0}, 
  1138. 			}, 
  1139. 			thread = INVALID_THREAD_HANDLE, 
  1140. 		}, 
  1141. 		 
  1142. 		-- Played when the ho boat is clear and Pierce should come in. 
  1143. 		boat_clear_of_danger = { 
  1144. 			files = { 
  1145. 				{name = "M09_Clear_Of_Danger", delay = 4.0}, 
  1146. 				{name = "M09_Banter_On_Boat", delay = 0.0}, 
  1147. 			}, 
  1148. 			thread = INVALID_THREAD_HANDLE, 
  1149. 		}, 
  1150. 		 
  1151. 		-- Played when the helicopter arrives. 
  1152. 		get_to_the_chopper = { 
  1153. 			files = { 
  1154. 				{name = M09_persona_line.heli_at_platform, delay = 2.0}, 
  1155. 			}, 
  1156. 			thread = INVALID_THREAD_HANDLE, 
  1157. 		}, 
  1158. 		 
  1159. 		boat_chase = { 
  1160. 			files = { 
  1161. 				{name = "M09_Tell_Pilot_To_Follow", delay = 0.0}, 
  1162. 			}, 
  1163. 			thread = INVALID_THREAD_HANDLE, 
  1164. 		}, 
  1165. 		 
  1166. 		rockets = { 
  1167. 			files = { 
  1168. 				{name = "m09_roof_01", delay = 15.0}, 
  1169. 				{name = M09_persona_line.protect_pierce_1, delay = 1.0}, 
  1170. 			}, 
  1171. 			thread = INVALID_THREAD_HANDLE, 
  1172. 		}, 
  1173. 		 
  1174. 		down_there = { 
  1175. 			files = { 
  1176. 				{name = "m09_roof_02", delay = 0.0}, 
  1177. 			}, 
  1178. 			thread = INVALID_THREAD_HANDLE, 
  1179. 		}, 
  1180. 		 
  1181. 		all_over_roofs = { 
  1182. 			files = { 
  1183. 				{name = "M09_roof_3", delay = 10.0}, 
  1184. 				{name = M09_persona_line.protect_pierce_2, delay = 1.0}, 
  1185. 			}, 
  1186. 			thread = INVALID_THREAD_HANDLE, 
  1187. 		}, 
  1188. 		 
  1189. 		why_shoot_at_us = { 
  1190. 			files = { 
  1191. 				{name = "M09_Pilot_Combat_1", delay = 0.0}, 
  1192. 			}, 
  1193. 			thread = INVALID_THREAD_HANDLE, 
  1194. 		}, 
  1195. 		 
  1196. 		too_much_fire = { 
  1197. 			files = { 
  1198. 				{name = "M09_Pilot_Combat_2", delay = 0.0}, 
  1199. 			}, 
  1200. 			thread = INVALID_THREAD_HANDLE, 
  1201. 		}, 
  1202. 		 
  1203. 		first_tank_attack = { 
  1204. 			files = { 
  1205. 				{name = "M09_First_Tank_Attack", delay = 0.0}, 
  1206. 			}, 
  1207. 			thread = INVALID_THREAD_HANDLE, 
  1208. 		}, 
  1209. 		 
  1210. --[[		second_tank_attack = { 
  1211. 			files = { 
  1212. 				{name = "M09_Second_Tank_Attack", delay = 0.0}, 
  1213. 			}, 
  1214. 			thread = INVALID_THREAD_HANDLE, 
  1215. 		}, 
  1216. --]]		 
  1217. 		choice_suggestion = { 
  1218. 			files = { 
  1219. 				{name = "M09_Choice_Suggestion", delay = 0.0, cell_receive = true, }, 
  1220. 			}, 
  1221. 			thread = INVALID_THREAD_HANDLE, 
  1222. 		}, 
  1223. 	} 
  1224. 	 
  1225. 	 
  1226.  
  1227. -- Triggers -- 
  1228. 	M09_trigger = { 
  1229. 		gangway = { 
  1230. 			name = "Gangway_trigger", 
  1231. 			callback = "m09_gangway_trigger_cb", 
  1232. 			on_exit = "", 
  1233. 			hit = false 
  1234. 		}, 
  1235. 	 
  1236. 		heli_entrance = { 
  1237. 			name = "heli_entrance_trigger", 
  1238. 			callback = "m09_heli_entrance_trigger_cb", 
  1239. 			on_exit = "", 
  1240. 			hit = false 
  1241. 		}, 
  1242.  
  1243. 		 
  1244. 		to_saints_trigger = { 
  1245. 			name = "to_saints_trigger", 
  1246. 			callback = "m09_set_trigger_hit_cb", 
  1247. 			on_exit = "", 
  1248. 			hit = false, 
  1249. 		}, 
  1250. 		 
  1251. 		to_brothel_trigger = { 
  1252. 			name = "to_brothel_trigger", 
  1253. 			callback = "m09_set_trigger_hit_cb", 
  1254. 			on_exit = "", 
  1255. 			hit = false, 
  1256. 		}, 
  1257. 		 
  1258. 		on_boat_trigger = { 
  1259. 			name = "on_boat_trigger", 
  1260. 			callback = "m09_on_boat_enter_cb", 
  1261. 			on_exit = "m09_on_boat_exit_cb", 
  1262. 			hit = false 
  1263. 		}, 
  1264. 		 
  1265. 		player_on_boat_trigger = { 
  1266. 			name = "on_boat_trigger", 
  1267. 			callback = "m09_player_on_boat_enter_cb", 
  1268. 			on_exit = "m09_player_on_boat_exit_cb", 
  1269. 			hit = false 
  1270. 		}, 
  1271. 		 
  1272. 		disable_front_spawns = { 
  1273. 			name = "disable_front_spawns_trigger", 
  1274. 			callback = "m09_disable_front_spawns_cb", 
  1275. 			on_exit = "", 
  1276. 			hit = false 
  1277. 		}, 
  1278. 		 
  1279. 		audio_how_many_crates = { 
  1280. 			name = "audio_trigger_crates", 
  1281. 			callback = "m09_audio_trigger_cb", 
  1282. 			on_exit = "", 
  1283. 			hit = false, 
  1284. 			convo = M09_convo.crates, 
  1285. 		}, 
  1286. 		 
  1287. 		ho_heli_crate = { 
  1288. 			name = "Ho_Heli_Crate_Trigger", 
  1289. 			callback = "m09_ho_heli_crate_trigger_cb", 
  1290. 			on_exit = "", 
  1291. 			hit = false, 
  1292. 			hoes_run_to = "Ho_Heli_Crate_Nav", 
  1293. 		}, 
  1294. 		 
  1295. 		dist_warn = { 
  1296. 			name = "dist_warn_trigger", 
  1297. 			callback = "m09_remove_warn_radius_cb", 
  1298. 			on_exit = "m09_show_warn_radius_cb", 
  1299. 			hit = false, 
  1300. 		}, 
  1301. 		 
  1302. 		dist_fail = { 
  1303. 			name = "dist_fail_trigger", 
  1304. 			callback = "", 
  1305. 			on_exit = "m09_fail_ship_abandoned_cb", 
  1306. 			hit = false, 
  1307. 		}, 
  1308. 		 
  1309. 		north_vantage = { 
  1310. 			name = "North_vantage_point_trigger", 
  1311. 			callback = "m09_north_vantage_cb", 
  1312. 			on_exit = "", 
  1313. 			hit = false, 
  1314. 		}, 
  1315. 		south_vantage = { 
  1316. 			name = "South_vantage_point_trigger", 
  1317. 			callback = "m09_south_vantage_cb", 
  1318. 			on_exit = "", 
  1319. 			hit = false, 
  1320. 		}, 
  1321. 		 
  1322. 		 
  1323. 		roof1 = { 
  1324. 			name = "roof_prep_trigger 001", 
  1325. 			callback = "m09_prep_roof_group_cb", 
  1326. 			on_exit = "", 
  1327. 			hit = false, 
  1328. 			group = M09_group.roof1, 
  1329. 		}, 
  1330. 		 
  1331. 		roof2 = { 
  1332. 			name = "roof_prep_trigger 002", 
  1333. 			callback = "m09_prep_roof_group_cb", 
  1334. 			on_exit = "", 
  1335. 			hit = false, 
  1336. 			group = M09_group.roof2, 
  1337. 		}, 
  1338. 		 
  1339. 		heli_boat = { 
  1340. 			name = "boat_prep_trigger", 
  1341. 			callback = "m09_setup_boats_cb", 
  1342. 			on_exit = "", 
  1343. 			hit = false, 
  1344. 			group = M09_group.heli_boats, 
  1345. 		}, 
  1346. 		mark_boats = { 
  1347. 			name = "mark_boats_trigger", 
  1348. 			callback = "m09_mark_rail_group_trigger", 
  1349. 			on_exit = "", 
  1350. 			hit = false, 
  1351. 			groups = {M09_group.heli_boats}, 
  1352. 		}, 
  1353. 		heli_boat_2 = { 
  1354. 			name = "boat_prep_trigger 2", 
  1355. 			callback = "m09_setup_boats_cb", 
  1356. 			on_exit = "", 
  1357. 			hit = false, 
  1358. 			group = M09_group.heli_boats_2, 
  1359. 		}, 
  1360. 		mark_boats_2 = { 
  1361. 			name = "mark_boats_2_trigger", 
  1362. 			callback = "m09_mark_rail_group_trigger", 
  1363. 			on_exit = "", 
  1364. 			hit = false, 
  1365. 			groups = {M09_group.heli_boats_2}, 
  1366. 		}, 
  1367. 		heli_boat_3 = { 
  1368. 			name = "boat_prep_trigger 3", 
  1369. 			callback = "m09_setup_boats_cb", 
  1370. 			on_exit = "", 
  1371. 			hit = false, 
  1372. 			group = M09_group.heli_boats_3, 
  1373. 		}, 
  1374. 		mark_boats_3 = { 
  1375. 			name = "mark_boats_3_trigger", 
  1376. 			callback = "m09_mark_rail_group_trigger", 
  1377. 			on_exit = "", 
  1378. 			hit = false, 
  1379. 			groups = {M09_group.heli_boats_3}, 
  1380. 		}, 
  1381. 		cleanup_boats = { 
  1382. 			name = "cleanup_boats_trigger", 
  1383. 			callback = "m09_cleanup_rail_group_trigger", 
  1384. 			on_exit = "", 
  1385. 			hit = false, 
  1386. 			groups = {M09_group.heli_boats, M09_group.heli_boats_2, M09_group.heli_boats_3}, 
  1387. 		}, 
  1388. 		tank1 = { 
  1389. 			name = "tank_prep_trigger <001>", 
  1390. 			callback = "m09_setup_boats_cb", 
  1391. 			on_exit = "", 
  1392. 			hit = false, 
  1393. 			group = M09_group.heli_tank1, 
  1394. 		}, 
  1395. 		mark_tanks = { 
  1396. 			name = "mark_tanks_trigger_1", 
  1397. 			callback = "m09_mark_rail_group_trigger", 
  1398. 			on_exit = "", 
  1399. 			hit = false, 
  1400. 			groups = {M09_group.heli_tank1}, 
  1401. 		}, 
  1402. 		cleanup_tanks = { 
  1403. 			name = "cleanup_tanks_trigger", 
  1404. 			callback = "m09_cleanup_rail_group_trigger", 
  1405. 			on_exit = "", 
  1406. 			hit = false, 
  1407. 			groups = {M09_group.heli_tank1}, 
  1408. 		}, 
  1409. 		tank2 = { 
  1410. 			name = "tank_prep_trigger_2", 
  1411. 			callback = "m09_setup_boats_cb", 
  1412. 			on_exit = "", 
  1413. 			hit = false, 
  1414. 			group = M09_group.heli_tank2, 
  1415. 		}, 
  1416. 		mark_tanks_2 = { 
  1417. 			name = "mark_tanks_trigger_2", 
  1418. 			callback = "m09_mark_rail_group_trigger", 
  1419. 			on_exit = "", 
  1420. 			hit = false, 
  1421. 			groups = {M09_group.heli_tank2}, 
  1422. 		}, 
  1423. 		cleanup_tanks_2 = { 
  1424. 			name = "cleanup_tanks_trigger_2", 
  1425. 			callback = "m09_cleanup_rail_group_trigger", 
  1426. 			on_exit = "", 
  1427. 			hit = false, 
  1428. 			groups = {M09_group.heli_tank2}, 
  1429. 		}, 
  1430. 		audio_rockets = { 
  1431. 			name = "audio_trigger_rockets", 
  1432. 			callback = "m09_audio_trigger_cb", 
  1433. 			on_exit = "", 
  1434. 			hit = false, 
  1435. 			convo = M09_convo.rockets, 
  1436. 		}, 
  1437. 		audio_down_there = { 
  1438. 			name = "audio_trigger_down_there", 
  1439. 			callback = "m09_audio_trigger_cb", 
  1440. 			on_exit = "", 
  1441. 			hit = false, 
  1442. 			convo = M09_convo.down_there, 
  1443. 		}, 
  1444. 		audio_all_over_roofs = { 
  1445. 			name = "audio_trigger_all_over_roofs", 
  1446. 			callback = "m09_audio_trigger_cb", 
  1447. 			on_exit = "", 
  1448. 			hit = false, 
  1449. 			convo = M09_convo.all_over_roofs, 
  1450. 		}, 
  1451. 		audio_why_shoot_at_us = { 
  1452. 			name = "audio_trigger_why_shoot_at_us", 
  1453. 			callback = "m09_audio_trigger_cb", 
  1454. 			on_exit = "", 
  1455. 			hit = false, 
  1456. 			convo = M09_convo.why_shoot_at_us, 
  1457. 		}, 
  1458. 		audio_apcs = { 
  1459. 			name = "audio_trigger_apcs", 
  1460. 			callback = "m09_audio_trigger_cb", 
  1461. 			on_exit = "", 
  1462. 			hit = false, 
  1463. 			convo = M09_convo.first_tank_attack, 
  1464. 		}, 
  1465. 	--[[	audio_apcs_2 = { 
  1466. 			name = "audio_trigger_apcs_2", 
  1467. 			callback = "m09_audio_trigger_cb", 
  1468. 			on_exit = "", 
  1469. 			hit = false, 
  1470. 			convo = M09_convo.second_tank_attack, 
  1471. 		}, 
  1472. 		--]] 
  1473. 		audio_too_much_fire = { 
  1474. 			name = "audio_trigger_too_much_fire", 
  1475. 			callback = "m09_audio_trigger_cb", 
  1476. 			on_exit = "", 
  1477. 			hit = false, 
  1478. 			convo = M09_convo.too_much_fire, 
  1479. 		}, 
  1480. 	} 
  1481. 	 
  1482. 	M09_rail_triggers = { 
  1483. 		M09_trigger.heli_boat, M09_trigger.heli_boat_2, M09_trigger.heli_boat_3, 
  1484. 		M09_trigger.mark_boats, M09_trigger.mark_boats_2, M09_trigger.mark_boats_3, 
  1485. 		M09_trigger.cleanup_boats, 
  1486. 		 
  1487. 		M09_trigger.tank1, M09_trigger.mark_tanks, M09_trigger.cleanup_tanks, 
  1488. 		M09_trigger.tank2, M09_trigger.mark_tanks_2, M09_trigger.cleanup_tanks_2, 
  1489.  
  1490. 		M09_trigger.roof1, M09_trigger.roof2,  
  1491. 		--[[ 
  1492. 		M09_trigger.roof3, 
  1493. 		M09_trigger.roof4, M09_trigger.roof5, M09_trigger.roof6, 
  1494. 		M09_trigger.roof7, M09_trigger.roof_mb, M09_trigger.clear_roof7, 
  1495. 		--]] 
  1496. 		 
  1497. 		M09_trigger.audio_rockets, M09_trigger.audio_down_there, M09_trigger.audio_all_over_roofs, 
  1498. 		M09_trigger.audio_why_shoot_at_us, M09_trigger.audio_apcs, M09_trigger.audio_apcs_2, M09_trigger.audio_too_much_fire, 
  1499. 	} 
  1500.  
  1501. -- Other -- 
  1502.  
  1503. -- Shipping Containers -- 
  1504. 	M09_CRATE_GIRLS = 1 
  1505. 	M09_CRATE_BOMB = 2 
  1506. 	M09_CRATE_GAG = 3 
  1507. 	M09_CRATE_ENEMIES = 4 
  1508. 	M09_CRATE_BRUTE = 5 
  1509. 	M09_CRATE_BRUTE_GAT = 6 
  1510. 	M09_CRATE_AMMO = 7 
  1511. 	 
  1512. 	M09_crate_sets = { 
  1513. 		[1] = { 
  1514. 			crates = { 
  1515. 				girls1 = { 
  1516. 					trigger = "Girls_trigger 001",					-- open_door trigger 
  1517. 					door = "Girls_door_1",							-- door script mover 
  1518. 					player_anim = "M09 open container",				-- animation to play on the player when they open the crate 
  1519. 					anim_nav = "nav_crate_anim<011>",				-- nav point to move the player to for the animation 
  1520. 					emitter_to_stop = M09_audio_emitters.girls_1,	-- audio emitter to stop when the crate is opened 
  1521. 					door_open_event = nil,						-- audio event to post when the door opens 
  1522. 					door_open_switch_group = nil,				-- switch group for the event to post when the door opens 
  1523. 					door_open_switch = nil,						-- switch for the event to post when the door opens 
  1524. 					door_open_event_object = nil,				-- the object to post an audio event on when the door opens 
  1525. 					content = M09_CRATE_GIRLS,						-- what's inside? 
  1526. 					qte = "", --"m09_open_container",				-- qte to open the door 
  1527. 					group = M09_group.girls1,						-- group if needed 
  1528. 					run_to = "Girls_nav 001",						-- nav to run to 
  1529. 					just_opened = false, 
  1530. 					opened = false, 
  1531. 					zimos_nav = M09_nav.zimos_girls[1], 
  1532. 				}, 
  1533. 				ammo1 = { 
  1534. 					trigger = "Ammo_Trigger 001",		-- open_door trigger 
  1535. 					door = "Ammo_door_1",			-- door script mover 
  1536. 					player_anim = "M09 open container",			-- animation to play on the player when they open the crate 
  1537. 					anim_nav = "nav_crate_anim<009>",			-- nav point to move the player to for the animation 
  1538. 					emitter_to_stop = nil,						-- audio emitter to stop when the crate is opened 
  1539. 					door_open_event = nil,						-- audio event to post when the door opens 
  1540. 					door_open_switch_group = nil,				-- switch group for the event to post when the door opens 
  1541. 					door_open_switch = nil,						-- switch for the event to post when the door opens 
  1542. 					door_open_event_object = nil,				-- the object to post an audio event on when the door opens 
  1543. 					content = M09_CRATE_AMMO,			-- what's inside? 
  1544. 					qte = "", --"m09_open_container",			-- qte to open the door 
  1545. 					group = "",							-- group if needed 
  1546. 					run_to = "",						-- nav to run to 
  1547. 					opened = false, 
  1548. 					ammo_group = M09_group.ammo_crate_grenades, -- Script group of weapons to spawn in this container. 
  1549. 				}, 
  1550. 				ammo2 = { 
  1551. 					trigger = "Ammo_Trigger 002",		-- open_door trigger 
  1552. 					door = "Ammo_door_2",			-- door script mover 
  1553. 					player_anim = "M09 open container",			-- animation to play on the player when they open the crate 
  1554. 					anim_nav = "nav_crate_anim<007>",			-- nav point to move the player to for the animation 
  1555. 					emitter_to_stop = nil,						-- audio emitter to stop when the crate is opened 
  1556. 					door_open_event = nil,						-- audio event to post when the door opens 
  1557. 					door_open_switch_group = nil,				-- switch group for the event to post when the door opens 
  1558. 					door_open_switch = nil,						-- switch for the event to post when the door opens 
  1559. 					door_open_event_object = nil,				-- the object to post an audio event on when the door opens 
  1560. 					content = M09_CRATE_AMMO,			-- what's inside? 
  1561. 					qte = "", --"m09_open_container",			-- qte to open the door 
  1562. 					group = "",							-- group if needed 
  1563. 					run_to = "",						-- nav to run to 
  1564. 					opened = false, 
  1565. 					ammo_group = M09_group.ammo_crate_rpg,		-- Script group of weapons to spawn in this container. 
  1566. 				}, 
  1567. 				gag1 = { 
  1568. 					trigger = "Gag_Trigger 001",		-- open_door trigger 
  1569. 					door = "Gag_door_1",				-- door script mover 
  1570. 					player_anim = "M09 open container",			-- animation to play on the player when they open the crate 
  1571. 					anim_nav = "nav_crate_anim<010>",			-- nav point to move the player to for the animation 
  1572. 					emitter_to_stop = nil,						-- audio emitter to stop when the crate is opened 
  1573. 					door_open_event = nil,						-- audio event to post when the door opens 
  1574. 					door_open_switch_group = nil,				-- switch group for the event to post when the door opens 
  1575. 					door_open_switch = nil,						-- switch for the event to post when the door opens 
  1576. 					door_open_event_object = nil,				-- the object to post an audio event on when the door opens 
  1577. 					content = M09_CRATE_GAG,			-- what's inside? 
  1578. 					qte = "", --"m09_open_container",			-- qte to open the door 
  1579. 					group = "",							-- group if needed 
  1580. 					run_to = "",						-- nav to run to 
  1581. 					opened = false, 
  1582. 				}, 
  1583. 			}, 
  1584. 		}, 
  1585. 		 
  1586. 		[2] = { 
  1587. 			zimos_nav = M09_nav.zimos_girls[2], 
  1588. 			crates = { 
  1589. 				brute1 = { 
  1590. 					trigger = "Brute_Trigger 001",				-- open_door trigger 
  1591. 					door = "Brute_Mover 001",					-- door script mover 
  1592. 					player_anim = nil,							-- animation to play on the player when they open the crate 
  1593. 					anim_nav = nil,								-- nav point to move the player to for the animation 
  1594. 					emitter_to_stop = M09_audio_emitters.brute_1,-- audio emitter to stop when the crate is opened 
  1595. 					door_open_event = "Mission_09",				-- audio event to post when the door opens 
  1596. 					door_open_switch_group = "Mission_09",		-- switch group for the event to post when the door opens 
  1597. 					door_open_switch = "M09_Brute_Crash",		-- switch for the event to post when the door opens 
  1598. 					door_open_event_object = M09_group.brute1.members[1], -- the object to post an audio event on when the door opens 
  1599. 					content = M09_CRATE_BRUTE,					-- what's inside? 
  1600. 					qte = "",									-- qte to open the door 
  1601. 					group = M09_group.brute1,					-- group if needed 
  1602. 					run_to = "Brute_Nav 001", 					-- nav point to run to  
  1603. 					opened = false, 
  1604. 				},			 
  1605. 				gag2 = { 
  1606. 					trigger = "Gag_Trigger 002",		-- open_door trigger 
  1607. 					door = "Gag_door_2",				-- door script mover 
  1608. 					player_anim = "M09 open container",			-- animation to play on the player when they open the crate 
  1609. 					anim_nav = "nav_crate_anim<004>",			-- nav point to move the player to for the animation 
  1610. 					emitter_to_stop = nil,						-- audio emitter to stop when the crate is opened 
  1611. 					door_open_event = nil,						-- audio event to post when the door opens 
  1612. 					door_open_switch_group = nil,				-- switch group for the event to post when the door opens 
  1613. 					door_open_switch = nil,						-- switch for the event to post when the door opens 
  1614. 					door_open_event_object = nil,				-- the object to post an audio event on when the door opens 
  1615. 					content = M09_CRATE_GAG,			-- what's inside? 
  1616. 					qte = "", --"m09_open_container",			-- qte to open the door 
  1617. 					group = "",							-- group if needed 
  1618. 					run_to = "",						-- nav to run to 
  1619. 					opened = false, 
  1620. 				},	 
  1621. 				gag3 = { 
  1622. 					trigger = "Gag_Trigger 003",		-- open_door trigger 
  1623. 					door = "Gag_door_3",				-- door script mover 
  1624. 					player_anim = "M09 open container",			-- animation to play on the player when they open the crate 
  1625. 					anim_nav = "nav_crate_anim<013>",			-- nav point to move the player to for the animation 
  1626. 					emitter_to_stop = nil,						-- audio emitter to stop when the crate is opened 
  1627. 					door_open_event = nil,						-- audio event to post when the door opens 
  1628. 					door_open_switch_group = nil,				-- switch group for the event to post when the door opens 
  1629. 					door_open_switch = nil,						-- switch for the event to post when the door opens 
  1630. 					door_open_event_object = nil,				-- the object to post an audio event on when the door opens 
  1631. 					content = M09_CRATE_GAG,			-- what's inside? 
  1632. 					qte = "", --"m09_open_container",			-- qte to open the door 
  1633. 					group = "",							-- group if needed 
  1634. 					run_to = "",						-- nav to run to 
  1635. 					opened = false, 
  1636. 				},		 
  1637. 				girls2 = { 
  1638. 					trigger = "Girls_trigger 002",					-- open_door trigger 
  1639. 					door = "Girls_door_2",							-- door script mover 
  1640. 					player_anim = "M09 open container",				-- animation to play on the player when they open the crate 
  1641. 					anim_nav = "nav_crate_anim<001>",				-- nav point to move the player to for the animation 
  1642. 					emitter_to_stop = M09_audio_emitters.girls_2,	-- audio emitter to stop when the crate is opened 
  1643. 					door_open_event = nil,						-- audio event to post when the door opens 
  1644. 					door_open_switch_group = nil,				-- switch group for the event to post when the door opens 
  1645. 					door_open_switch = nil,						-- switch for the event to post when the door opens 
  1646. 					door_open_event_object = nil,				-- the object to post an audio event on when the door opens 
  1647. 					content = M09_CRATE_GIRLS,						-- what's inside? 
  1648. 					qte = "", --"m09_open_container",				-- qte to open the door 
  1649. 					group = M09_group.girls2,						-- group if needed 
  1650. 					run_to = "Girls_nav 002",						-- nav to run to 
  1651. 					just_opened = false, 
  1652. 					opened = false, 
  1653. 				}, 
  1654. 			}, 
  1655. 		}, 
  1656. 		 
  1657. 		[3] = { 
  1658. 			zimos_nav = M09_nav.zimos_girls[3], 
  1659. 			crates = { 
  1660. 				girls3 = { 
  1661. 					trigger = "Girls_trigger 003",					-- open_door trigger 
  1662. 					door = "Girls_door_3",							-- door script mover 
  1663. 					player_anim = "M09 open container",				-- animation to play on the player when they open the crate 
  1664. 					anim_nav = "nav_crate_anim<014>",				-- nav point to move the player to for the animation 
  1665. 					emitter_to_stop = M09_audio_emitters.girls_3,	-- audio emitter to stop when the crate is opened 
  1666. 					door_open_event = nil,						-- audio event to post when the door opens 
  1667. 					door_open_switch_group = nil,				-- switch group for the event to post when the door opens 
  1668. 					door_open_switch = nil,						-- switch for the event to post when the door opens 
  1669. 					door_open_event_object = nil,				-- the object to post an audio event on when the door opens 
  1670. 					content = M09_CRATE_GIRLS,						-- what's inside? 
  1671. 					qte = "", --"m09_open_container",				-- qte to open the door 
  1672. 					group = M09_group.girls3,						-- group if needed 
  1673. 					run_to = "Girls_nav 003",						-- nav to run to 
  1674. 					just_opened = false, 
  1675. 					opened = false, 
  1676. 				}, 
  1677. 				 
  1678. 				girls4 = { 
  1679. 					trigger = "Girls_trigger 004",					-- open_door trigger 
  1680. 					door = "Girls_door_4",							-- door script mover 
  1681. 					player_anim = "M09 open container",				-- animation to play on the player when they open the crate 
  1682. 					anim_nav = "nav_crate_anim<005>",				-- nav point to move the player to for the animation 
  1683. 					emitter_to_stop = M09_audio_emitters.girls_4,	-- audio emitter to stop when the crate is opened 
  1684. 					door_open_event = nil,						-- audio event to post when the door opens 
  1685. 					door_open_switch_group = nil,				-- switch group for the event to post when the door opens 
  1686. 					door_open_switch = nil,						-- switch for the event to post when the door opens 
  1687. 					door_open_event_object = nil,				-- the object to post an audio event on when the door opens 
  1688. 					content = M09_CRATE_GIRLS,						-- what's inside? 
  1689. 					qte = "", --"m09_open_container",				-- qte to open the door 
  1690. 					group = M09_group.girls4,						-- group if needed 
  1691. 					run_to = "Girls_nav 004",						-- nav to run to 
  1692. 					just_opened = false, 
  1693. 					opened = false, 
  1694. 				}, 
  1695. 				 
  1696. 				 
  1697. 				ammo3 = { 
  1698. 					trigger = "Ammo_Trigger 003",		-- open_door trigger 
  1699. 					door = "Ammo_door_3",				-- door script mover 
  1700. 					player_anim = "M09 open container",			-- animation to play on the player when they open the crate 
  1701. 					anim_nav = "nav_crate_anim<008>",			-- nav point to move the player to for the animation 
  1702. 					emitter_to_stop = nil,						-- audio emitter to stop when the crate is opened 
  1703. 					door_open_event = nil,						-- audio event to post when the door opens 
  1704. 					door_open_switch_group = nil,				-- switch group for the event to post when the door opens 
  1705. 					door_open_switch = nil,						-- switch for the event to post when the door opens 
  1706. 					door_open_event_object = nil,				-- the object to post an audio event on when the door opens 
  1707. 					content = M09_CRATE_AMMO,			-- what's inside? 
  1708. 					qte = "", --"m09_open_container",			-- qte to open the door 
  1709. 					group = "",							-- group if needed 
  1710. 					run_to = "",						-- nav to run to 
  1711. 					opened = false, 
  1712. 					ammo_group = M09_group.ammo_crate_smg,		-- Script group of weapons to spawn in this container. 
  1713. 				}, 
  1714. 				 
  1715. 				minigun_brute1 = { 
  1716. 					trigger = "Minigun_Brute_Trigger 001",		-- open_door trigger 
  1717. 					door = "Minigun_Brute_Mover 001",			-- door script mover 
  1718. 					player_anim = nil,							-- animation to play on the player when they open the crate 
  1719. 					anim_nav = nil,								-- nav point to move the player to for the animation 
  1720. 					emitter_to_stop = M09_audio_emitters.brute_2,-- audio emitter to stop when the crate is opened 
  1721. 					door_open_event = "Mission_09",				-- audio event to post when the door opens 
  1722. 					door_open_switch_group = "Mission_09",		-- switch group for the event to post when the door opens 
  1723. 					door_open_switch = "M09_Brute_Crash",		-- switch for the event to post when the door opens 
  1724. 					door_open_event_object = M09_group.minigun_brute.members[1], -- the object to post an audio event on when the door opens 
  1725. 					content = M09_CRATE_BRUTE_GAT,				-- what's inside? 
  1726. 					qte = "",									-- qte to open the door 
  1727. 					group = M09_group.minigun_brute,			-- group if needed 
  1728. 					run_to = "Minigun_Brute_Nav 001", 			-- nav point to run to  
  1729. 					opened = false, 
  1730. 				}, 
  1731.  
  1732. 				gag4 = { 
  1733. 					trigger = "Gag_Trigger 004",		-- open_door trigger 
  1734. 					door = "Gag_door_4",				-- door script mover 
  1735. 					player_anim = "M09 open container",			-- animation to play on the player when they open the crate 
  1736. 					anim_nav = "nav_crate_anim<003>",			-- nav point to move the player to for the animation 
  1737. 					emitter_to_stop = nil,						-- audio emitter to stop when the crate is opened 
  1738. 					door_open_event = nil,						-- audio event to post when the door opens 
  1739. 					door_open_switch_group = nil,				-- switch group for the event to post when the door opens 
  1740. 					door_open_switch = nil,						-- switch for the event to post when the door opens 
  1741. 					door_open_event_object = nil,				-- the object to post an audio event on when the door opens 
  1742. 					content = M09_CRATE_GAG,			-- what's inside? 
  1743. 					qte = "", --"m09_open_container",			-- qte to open the door 
  1744. 					group = "",							-- group if needed 
  1745. 					run_to = "",						-- nav to run to 
  1746. 					opened = false, 
  1747. 				}, 
  1748. 			}, 
  1749. 		}, 
  1750. 	} 
  1751. 	 
  1752. 	M09_girl_crate = { 
  1753. 		M09_crate_sets[1].crates.girls1, M09_crate_sets[2].crates.girls2, M09_crate_sets[3].crates.girls3, M09_crate_sets[3].crates.girls4 
  1754. 	} 
  1755. 	 
  1756. 	-- These emitters get disabled when restarting from the "defend girls" checkpoint. 
  1757. 	M09_temporary_emitters = {M09_audio_emitters.girls_1, M09_audio_emitters.girls_2, M09_audio_emitters.girls_3, M09_audio_emitters.girls_4, M09_audio_emitters.brute_1, M09_audio_emitters.brute_2} 
  1758. 	 
  1759. 	M09_heli_weapon = "Rifle-Gang" 
  1760. 	 
  1761. 	M09_local_crate = M09_crate_sets[1].crates.girls1 
  1762. 	M09_remote_crate = M09_crate_sets[1].crates.girls1 
  1763. 		 
  1764. 	M09_active_convo = "" 
  1765. 	M09_goto_zimos_line = 1 
  1766. 	M09_found_girl_crates = 0 
  1767. 	M09_found_gag_line = 1 
  1768. 	M09_found_ammo_line = 1 
  1769. 	M09_girls_found = false 
  1770. 	M09_zimos_drop_off_girls = false 
  1771. 	M09_play_find_minigun_line = false 
  1772. 	M09_just_opened_girls_crates = {} 
  1773. 	M09_girls_following = {} 
  1774. 	M09_girls_flee_nav = "" 
  1775. 	M09_allow_attacker_docking = true 
  1776. 	M09_enemies_on_the_boat = {} 
  1777. 	M09_heli_drop_off_convo = 1 
  1778. 	 
  1779. 	M09_local_on_boat		= false 
  1780. 	M09_remote_on_boat	= false 
  1781. 	 
  1782. 	M09_current_obj	= "" 
  1783. 	M09_obj_str1		= "" 
  1784. 	M09_obj_str2		= "" 
  1785. 	M09_secondary_obj	= {} -- Need one for each player 
  1786. 	 
  1787. 	M09_crates_disabled = false 
  1788. 	M09_active_crate_set = "" 
  1789. 	 
  1790. 	M09_brute_list = { } 
  1791. 	 
  1792. 	M09_cur_cell_call = "" 
  1793. 	 
  1794. 	M09_stripper_cower_variants = { 
  1795. 		0, -- Hunched 
  1796. 		2, -- Knee 
  1797. 		3, -- Other knee 
  1798. 	} 
  1799. 	 
  1800. 	M09_player_chose_brothel = false	 
  1801. 	M09_mission_success = false 
  1802. 	 
  1803. 	In_coop = false 
  1804.  
  1805. -- ************************* 
  1806. -- 
  1807. -- Standard functions 
  1808. -- 
  1809. -- ************************* 
  1810.  
  1811. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  1812. -- at the specified checkpoint. 
  1813. -- CALLED FROM CODE 
  1814. -- 
  1815. -- m09_checkpoint:	The checkpoint the mission should begin at 
  1816. -- is_restart:					TRUE if the mission is restarting, FALSE otherwise 
  1817. -- 
  1818. function m09_start(m09_checkpoint, is_restart) 
  1819. 	In_coop = coop_is_active() 
  1820.  
  1821. 	--if not is_restart then 
  1822. 		--m09_checkpoint = M09_checkpoint.start.name 
  1823. 		--m09_checkpoint = M09_checkpoint.gangway.name 
  1824. 		--m09_checkpoint = M09_checkpoint.defend_girls.name 
  1825. 		--m09_checkpoint = M09_checkpoint.heli_rail.name 
  1826. 		--m09_checkpoint = M09_checkpoint.truck_route.name 
  1827. 		--mission_set_checkpoint(m09_checkpoint, true, true) 
  1828. 	--end 
  1829. 	 
  1830. 	if M09_debug_skip_to_heli_scene then 
  1831. 		m09_checkpoint = M09_checkpoint.heli_rail.name 
  1832. 		mission_set_checkpoint(m09_checkpoint, true, true) 
  1833. 	end 
  1834. 		 
  1835. 	-- Check if this mission starting from the beginning 
  1836. 	if (m09_checkpoint == M09_checkpoint.start.name) then 
  1837. 		if (is_restart == false) then 
  1838. 			-- First time playing mission 
  1839. 			cutscene_play(CUTSCENE_MISSION_INTRO, nil, {M09_checkpoint.start.nav1, M09_checkpoint.start.nav2}, false) 
  1840. 		end 
  1841. 	end 
  1842.  
  1843. 	-- Handle mission initialization for the current checkpoint 
  1844. 	m09_initialize(m09_checkpoint, is_restart) 
  1845.  
  1846. 	-- Run the mission from the current checkpoint 
  1847. 	m09_run(m09_checkpoint) 
  1848. 	 
  1849. end 
  1850.  
  1851. -- This is the primary function responsible for running the entire mission from start to finish. 
  1852. -- 
  1853. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  1854. -- 
  1855. function m09_run(first_checkpoint) 
  1856. 	local current_checkpoint = first_checkpoint 
  1857. 	 
  1858. 	mission_set_cancel_warp_location(M09_checkpoint.start.nav1, M09_checkpoint.start.nav2) 
  1859. 	 
  1860. 	-- Make sure all crate doors are locked. 
  1861. 	m09_lock_crate_doors() 
  1862.  
  1863. 	-- Run the mission from the beginning 
  1864. 	if current_checkpoint == M09_checkpoint.start.name then 
  1865. 		m09_go_to_boat() 
  1866. 		m09_setup_distance_check_triggers() 
  1867. 	 
  1868. 		current_checkpoint = M09_checkpoint.gangway.name 
  1869. 		mission_set_checkpoint(M09_checkpoint.gangway.name, true, true) 
  1870. 	end 
  1871. 	 
  1872. 	if current_checkpoint == M09_checkpoint.gangway.name then 
  1873. 		character_ragdoll_set_last_resort_position(M09_checkpoint.gangway.nav1) 
  1874. 		 
  1875. 		-- Begin camera shake when on the boat. 
  1876. 		camera_shake_play_looping(M09_cargo_ship_camera_shake, M09_cargo_ship_camera_shake_amt) 
  1877. 	 
  1878. 		m09_find_girls() 
  1879. 		-- Zimos wil bring the girls to their final crate 
  1880. 		 
  1881. 		m09_set_trigger(M09_trigger.on_boat_trigger, false, false) 
  1882. 		delay(1.0) 
  1883.  
  1884. 		--m09_clear_boat_guards() 
  1885.  
  1886. 		current_checkpoint = M09_checkpoint.defend_girls.name 
  1887. 		mission_set_checkpoint(M09_checkpoint.defend_girls.name, true, true) 
  1888. 	end 
  1889. 	 
  1890. 	if current_checkpoint == M09_checkpoint.defend_girls.name then 
  1891. 		character_ragdoll_set_last_resort_position(M09_checkpoint.defend_girls.nav1) 
  1892. 		 
  1893. 		m09_defend_girls() 
  1894. 		 
  1895. 		m09_call_the_helis() 
  1896. 		 
  1897. 		-- End the camera shake. 
  1898. 		camera_shake_stop() 
  1899.  
  1900. 		fade_out(0.5) 
  1901. 		fade_out_block() 
  1902. 		m09_cleanup_cargo_ship() 
  1903. 		teleport_coop(M09_checkpoint.heli_rail.nav1, M09_checkpoint.heli_rail.nav2, true) 
  1904. 		m09_setup_heli_rail() 
  1905. 		 
  1906. 		current_checkpoint = M09_checkpoint.heli_rail.name 
  1907. 		mission_set_checkpoint(M09_checkpoint.heli_rail.name, true, true) 
  1908. 		 
  1909. 		m09_players_enter_rail_heli() 
  1910. 		fade_in(0.5) 
  1911. 		fade_in_block() 
  1912. 	end 
  1913. 	 
  1914. 	-- Stop using the mission specified ragdoll get up last resort. 
  1915. 	character_ragdoll_clear_last_resort_position() 
  1916. 	 
  1917. 	if current_checkpoint == M09_checkpoint.heli_rail.name then 
  1918. 		m09_heli_rail() 
  1919. 	 
  1920. 		current_checkpoint = M09_checkpoint.truck_route.name 
  1921. 		mission_set_checkpoint(M09_checkpoint.truck_route.name, true, true) 
  1922. 	end 
  1923. 	 
  1924. 	if current_checkpoint == M09_checkpoint.truck_route.name then 
  1925. 		m09_truck_route() 
  1926. 	end 
  1927. 	 
  1928. 	M09_mission_success = true 
  1929.  
  1930. 	mission_end_success("m09", CUTSCENE_MISSION_OUTRO) 
  1931. end 
  1932.  
  1933. -- This is the primary function responsible for cleaning up the entire mission 
  1934. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  1935. -- 
  1936. function m09_cleanup() 
  1937.  
  1938. 	persona_suppress_ambient_lines(false) 
  1939.  
  1940. 	In_coop = coop_is_active() 
  1941. 		 
  1942. 	m09_kill_all_threads() 
  1943. 	m09_cleanup_heli_rail() 
  1944. 	 
  1945. 	-- Clear any QTE 
  1946. 	qte_cleanup() 
  1947. 	character_allow_ragdoll(LOCAL_PLAYER, true) 
  1948. 	character_allow_ragdoll(REMOTE_PLAYER, true) 
  1949. 	 
  1950. 	-- cleanup triggers 
  1951. 	m09_clear_all_triggers() 
  1952. 	 
  1953. 	-- make sure the crates are all cleaned up 
  1954. 	m09_clear_all_crates() 
  1955. 	 
  1956. 	-- cleanup any continuous spawn groups or regions 
  1957. 	m09_cleanup_all_continuous_spawns() 
  1958. 	 
  1959. 	-- cleanup any homies 
  1960. 	m09_clear_all_crew() 
  1961. 	 
  1962. 	m09_cleanup_roof() 
  1963. 	 
  1964. 	-- cleanup groups 
  1965. 	m09_cleanup_groups() 
  1966. 	 
  1967. 	-- Cleanup any boat attackers. 
  1968. 	for human in pairs(M09_enemies_on_the_boat) do 
  1969. 		M09_enemies_on_the_boat[human] = nil 
  1970. 		marker_remove(human) 
  1971. 		on_death("", human) 
  1972. 	end 
  1973.  
  1974. 	minimap_icon_remove_radius("Cargo_Ship_Center", SYNC_ALL) 
  1975. 	 
  1976. 	inv_weapon_disable_all_slots(false) 
  1977. 	cleanup_temporary_weapons(M09_heli_weapon) 
  1978. 	if M09_give_rocket_launcher then 
  1979. 		cleanup_temporary_weapons("Explosive-RocketLauncher") 
  1980. 	end 
  1981. 	 
  1982. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, true) 
  1983. 	if In_coop then 
  1984. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, true) 
  1985. 	end 
  1986. 	 
  1987. 	if M09_mission_success then 
  1988. 		-- Teleport the player to the location they chose. 
  1989. 		if M09_player_chose_brothel then 
  1990. 			teleport(LOCAL_PLAYER, M09_nav.choice_brothel.host, true) 
  1991. 			if In_coop then 
  1992. 				teleport(REMOTE_PLAYER, M09_nav.choice_brothel.client, true) 
  1993. 			end 
  1994. 		else 
  1995. 			teleport(LOCAL_PLAYER, M09_nav.choice_saints_hq.host, true) 
  1996. 			if In_coop then 
  1997. 				teleport(REMOTE_PLAYER, M09_nav.choice_saints_hq.client, true) 
  1998. 			end 
  1999. 		end 
  2000. 	end 
  2001. 	 
  2002. 	-- reset notoriety 
  2003. 	notoriety_set_min("morningstar", 0) 
  2004. 	notoriety_set_max("morningstar", MAX_NOTORIETY_LEVEL) 
  2005. 	notoriety_force_no_spawn("morningstar", false)	 
  2006. 	notoriety_set("morningstar", 0) 
  2007. 	notoriety_reset("morningstar") 
  2008.  
  2009. 	-- TODO: Remove once poper follower/water interaction is added 
  2010. 	on_vehicle_enter("", LOCAL_PLAYER) 
  2011. 	 
  2012. 	city_zone_swap("cargo", DISABLE) -- Remove Cargo ship zone swap 
  2013. 	 
  2014. 	-- Cleanup any on going audio threads 
  2015. 	m09_unload_all_convos() 
  2016. 	m09_unload_personas() 
  2017. 	 
  2018. 	-- End the camera shake. 
  2019. 	camera_shake_stop() 
  2020. 	 
  2021. 	-- Post any sudio stop events. 
  2022. 	m09_post_audio_event(M09_audio_events.heli_walla_stop, LOCAL_PLAYER) 
  2023. 	if group_is_loaded(M09_group.girls_truck) then 
  2024. 		m09_post_audio_event(M09_audio_events.stripper_cargo_stop, M09_group.girls_truck.vehicle) 
  2025. 	end 
  2026. 	 
  2027. 	-- Enable warp to shore 
  2028. 	player_warp_to_shore_enable(LOCAL_PLAYER) 
  2029. 	if In_coop then 
  2030. 		player_warp_to_shore_enable(REMOTE_PLAYER) 
  2031. 	end 
  2032. 	 
  2033. 	mission_waypoint_remove() 
  2034. 	 
  2035. 	-- Stop any cell calls. 
  2036. 	audio_remove_mission_cellphone(M09_cur_cell_call) 
  2037. 	 
  2038. 	mission_cleanup_maybe_reenable_player_controls() 
  2039. 		 
  2040. 	-- Stop using the mission specified ragdoll get up last resort. 
  2041. 	character_ragdoll_clear_last_resort_position() 
  2042.  end 
  2043.  
  2044. -- Called when the mission has ended with success 
  2045. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  2046. -- 
  2047. function m09_success() 
  2048. end 
  2049.  
  2050.  
  2051. -- ************************* 
  2052. -- 
  2053. -- Local functions 
  2054. -- 
  2055. -- ************************* 
  2056.  
  2057. -- Initialize the mission for the specified checkpoint 
  2058. -- 
  2059. -- checkpoint:		Checkpoint to initialize the mission to 
  2060. -- is_restart:      Whether or not the mission is restarting. 
  2061. -- 
  2062. function m09_initialize(checkpoint, is_restart) 
  2063. 	-- Make sure the screen is completly faded out 
  2064. 	mission_start_fade_out(0.0) 
  2065. 	 
  2066. 	-- Set the mission author 
  2067. 	set_mission_author("Neil Ryan") 
  2068.  
  2069. 	-- Common initialization 
  2070. 	m09_initialize_common() 
  2071.  
  2072. 	-- Checkpoint specific initialization 
  2073. 	m09_initialize_checkpoint(checkpoint, is_restart) 
  2074. 	 
  2075. 	-- Start fading in  
  2076. 	mission_start_fade_in() 
  2077. end 
  2078.  
  2079. -- Go to the boat because it is cool 
  2080. -- 
  2081. function m09_go_to_boat()	 
  2082. 	m09_set_objective(M09_objective.go_to_ship) 
  2083. 	m09_set_trigger(M09_trigger.player_on_boat_trigger, false, false) 
  2084. 	 
  2085. 	-- TODO: Remove once poper follower/water interaction is added 
  2086. 	--on_vehicle_enter("m09_player_entered_boat", LOCAL_PLAYER) 
  2087. 	 
  2088. 	trigger_enable(M09_trigger.gangway.name, true) -- Trigger needs to be enabled for the minimap icon. 
  2089. 	marker_add_trigger(M09_trigger.gangway.name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  2090. 	 
  2091. 	-- GPS looks stupid going to the boat, so don't do it. 
  2092. 	--mission_waypoint_add(M09_trigger.gangway.name) 
  2093. 	 
  2094. 	if not In_coop then 
  2095. 		M09_remote_on_boat = true 
  2096. 	end 
  2097. 	 
  2098. 	while not M09_local_on_boat or not M09_remote_on_boat do 
  2099. 		thread_yield() 
  2100. 	end 
  2101.  
  2102. 	trigger_enable(M09_trigger.gangway.name, false) 
  2103. 	marker_remove_trigger(M09_trigger.gangway.name, SYNC_ALL) 
  2104. 	--mission_waypoint_remove() 
  2105. 	 
  2106. 	m09_clear_trigger(M09_trigger.player_on_boat_trigger.name) 
  2107. 	 
  2108. 	-- Start spawning guards on the deck. 
  2109. 	m09_start_continuous_spawns(M09_spawn_groups.normal, M09_continuous_respawn_delay, M09_spawn_regions.front) 
  2110.  
  2111. 	m09_start_convo_thread(M09_convo.gangway) 
  2112. 	 
  2113. 	-- TODO: Remove once poper follower/water interaction is added 
  2114. 	on_vehicle_enter("", LOCAL_PLAYER) 
  2115. 	 
  2116. 	notoriety_force_no_spawn("morningstar", true) 
  2117. 	notoriety_set_min("morningstar", M09_min_notoriety) 
  2118. 	notoriety_set_max("morningstar", M09_max_notoriety) 
  2119. end 
  2120.  
  2121. function m09_spawn_ship_guards() 
  2122. 	if group_is_loaded(M09_group.weapons.name) then 
  2123. 		return 
  2124. 	end 
  2125.  
  2126. 	group_create(M09_group.weapons, true) 
  2127. 	group_create(M09_group.boat_guards.name, true) 
  2128. end 
  2129.  
  2130. function m09_setup_distance_check_triggers() 
  2131. 	m09_set_trigger(M09_trigger.dist_warn, false, false) 
  2132. 	m09_set_trigger(M09_trigger.dist_fail, false, false) 
  2133. 	M09_local_on_boat  = true 
  2134. 	M09_remote_on_boat = In_coop 
  2135. 	 
  2136. 	-- Prevent the player from attempting to warp away from the ship 
  2137. 	player_warp_to_shore_disable(LOCAL_PLAYER) 
  2138. 	if In_coop then 
  2139. 		player_warp_to_shore_disable(REMOTE_PLAYER) 
  2140. 	end 
  2141. end 
  2142.  
  2143. function m09_cleanup_distance_check_triggers() 
  2144. 	m09_clear_trigger(M09_trigger.dist_warn.name) 
  2145. 	m09_clear_trigger(M09_trigger.dist_fail.name) 
  2146. 	 
  2147. 	player_warp_to_shore_enable(LOCAL_PLAYER) 
  2148. 	if In_coop then 
  2149. 		player_warp_to_shore_enable(REMOTE_PLAYER) 
  2150. 	end 
  2151. end 
  2152.  
  2153. -- find the crate with the girls 
  2154. -- 
  2155. function m09_find_girls() 
  2156. 	local num_girl_crates = sizeof_table(M09_girl_crate) 
  2157. 	local found_crates = 0 
  2158. 	 
  2159. 	M09_goto_zimos_line = 1 
  2160. 	M09_found_gag_line = 1 
  2161. 	M09_found_ammo_line = 1 
  2162. 	M09_found_girl_crates = 0 
  2163. 	m09_set_objective(M09_objective.find_girls, M09_found_girl_crates, num_girl_crates) 
  2164. 	m09_set_trigger(M09_trigger.disable_front_spawns, false, false) 
  2165. 	m09_set_trigger(M09_trigger.audio_how_many_crates, false, false) 
  2166. 	 
  2167. 	-- Don't allow Zimos to die. 
  2168. 	turn_invulnerable(M09_Zimos) 
  2169. 	 
  2170. 	-- Zimos may lag behind the player, don't pop up the warning that you're abandoning him. 
  2171. 	follower_set_can_abandon(M09_Zimos, false) 
  2172. 	 
  2173. 	set_force_combat_ready_team("Playas") 
  2174. 	 
  2175. 	M09_zimos_girl_thread = thread_new("m09_zimos_girl_behavior_thread") 
  2176. 	M09_girls_follow_zimos_thread = thread_new("m09_girls_follow_zimos_thread") 
  2177. 	 
  2178. 	for i, crate_set in pairs(M09_crate_sets) do 
  2179. 		m09_setup_crate_set(crate_set) 
  2180. 		while m09_num_crates_left(crate_set) ~= 0 and M09_found_girl_crates < num_girl_crates do 
  2181. 			thread_yield() 
  2182. 		end 
  2183. 		 
  2184. 		if crate_set.zimos_nav ~= nil then 
  2185. 			-- Move Zimos to the specified nav. 
  2186. 			m09_move_zimos_and_girls(crate_set.zimos_nav) 
  2187. 		end 
  2188. 	end 
  2189. 	 
  2190. 	m09_clear_trigger(M09_trigger.audio_how_many_crates.name) 
  2191. 	 
  2192. 	m09_clear_all_crate_triggers() 
  2193. 	m09_cleanup_all_continuous_spawns() 
  2194. 	 
  2195. 	m09_start_convo_thread(M09_convo.load_girls) 
  2196. 	 
  2197. 	m09_clear_objective() 
  2198. 	 
  2199. 	-- Wait for the conversation to finish. 
  2200. 	m09_wait_for_convo(30.0) 
  2201. 	 
  2202. 	-- Start music for the boat segment. 
  2203. 	m09_post_music_event(M09_music.boat_begin) 
  2204. 	 
  2205. 	delay(1.0) 
  2206. 	 
  2207. 	m09_start_convo_thread(M09_convo.defend_girls) 
  2208. 	 
  2209. 	M09_zimos_drop_off_girls = true 
  2210. 	M09_girls_found = true 
  2211.  
  2212. 	delay(3.0) 
  2213. end 
  2214.  
  2215. -- defend against waves of attackers 
  2216. -- 
  2217. function m09_defend_girls() 
  2218. 	m09_set_objective(M09_objective.north_platform) 
  2219. 	m09_set_trigger(M09_trigger.north_vantage, false, true) 
  2220. 	 
  2221. 	while not M09_trigger.north_vantage.hit do 
  2222. 		thread_yield() 
  2223. 	end 
  2224. 	 
  2225. 	set_force_combat_ready_team("Playas") 
  2226. 	-- Only play the "find minigun" line the first time through, it'd 
  2227. 	-- be weird to play it after restarting the checkpoint. 
  2228. 	if (M09_play_find_minigun_line) then 
  2229. 		m09_play_persona_line(M09_persona_line.find_minigun) 
  2230. 		delay(2.0) 
  2231. 	end 
  2232. 		 
  2233. 	--m09_play_cte() 
  2234. 	 
  2235. 	m09_set_objective(M09_objective.clear_the_boat) 
  2236. 	 
  2237. 	local wave_data = { 
  2238. 		-- Boats 
  2239. 		{ 
  2240. 			thread_func = "m09_do_boat_wave_thread", 
  2241. 			thread = INVALID_THREAD_HANDLE, 
  2242. 			waves = { 
  2243. 				{ 
  2244. 					boats = M09_boat_wave1, 
  2245. 					paths = M09_boat_paths.north, 
  2246. 					do_south_platform_breadcrumb = false, 
  2247. 				}, 
  2248. 				{ 
  2249. 					boats = M09_boat_wave2, 
  2250. 					paths = M09_boat_paths.north, 
  2251. 					do_south_platform_breadcrumb = false, 
  2252. 					play_convo = true, 
  2253. 				}, 
  2254. 			}, 
  2255. 			num_waves = 2, 
  2256. 			cur_wave = 1, 
  2257. 			finished = false, 
  2258. 		}, 
  2259. 		-- Sniper helis 
  2260. 		{ 
  2261. 			thread_func = "m09_do_attack_heli_wave_thread", 
  2262. 			thread = INVALID_THREAD_HANDLE, 
  2263. 			waves = { nil, nil }, 
  2264. 			num_waves = 2, 
  2265. 			cur_wave = 1, 
  2266. 			finished = false, 
  2267. 		}, 
  2268. 		-- Transport helis 
  2269. 		{ 
  2270. 			thread_func = "m09_do_transport_heli_wave_thread", 
  2271. 			thread = INVALID_THREAD_HANDLE, 
  2272. 			waves = { nil, nil }, 
  2273. 			num_waves = 1, 
  2274. 			cur_wave = 1, 
  2275. 			finished = false, 
  2276. 		}, 
  2277. 	} 
  2278. 	 
  2279. 	M09_zimos_comforting_hos_thread = thread_new("m09_zimos_comforting_hos") 
  2280. 	 
  2281. 	local waves_done = false 
  2282. 	 
  2283. 	-- Keep spawning waves until all waves sets are finished. 
  2284. 	while (waves_done == false) do 
  2285. 		waves_done = true 
  2286. 		for i, wave_set in pairs(wave_data) do 
  2287. 			if (wave_set.finished == false) then 
  2288. 				-- This wave set hasn't finished yet. 
  2289. 				waves_done = false 
  2290. 				if (wave_set.thread == INVALID_THREAD_HANDLE or thread_check_done(wave_set.thread)) then 
  2291. 					if (wave_set.cur_wave <= wave_set.num_waves) then 
  2292. 						--message(wave_set.thread_func, 2.0) 
  2293. 						-- Spawn the next wave for this wave set. 
  2294. 						wave_set.thread = thread_new(wave_set.thread_func, wave_set.waves[wave_set.cur_wave]) 
  2295. 						wave_set.cur_wave = wave_set.cur_wave + 1 
  2296. 					else 
  2297. 						-- This wave set has ended, everyone's dead. 
  2298. 						wave_set.finished = true 
  2299. 					end 
  2300. 				end 
  2301. 			end 
  2302. 		end	 
  2303. 		 
  2304. 		thread_yield() 
  2305. 	end 
  2306. 	 
  2307. 	-- Wait for all straggling attackers to be taken care of. 
  2308. 	while sizeof_table(M09_enemies_on_the_boat) ~= 0 do 
  2309. 		thread_yield() 
  2310. 	end 
  2311. 	 
  2312. 	set_force_combat_ready_team("") 
  2313. 	 
  2314. 	thread_kill(M09_zimos_comforting_hos_thread) 
  2315. 	M09_zimos_comforting_hos_thread = INVALID_THREAD_HANDLE 
  2316. 	 
  2317. 	-- All attackers are dead. 
  2318. 	thread_kill(M09_get_to_south_platform_thread) 
  2319. 	m09_clear_trigger(M09_trigger.south_vantage.name) 
  2320. 	 
  2321. 	delay(3.0) 
  2322. 	 
  2323. 	m09_start_convo_thread(M09_convo.boat_clear_of_danger) 
  2324. end 
  2325.  
  2326. -- Call the helis in to pickup the hoes and the player 
  2327. -- 
  2328. function m09_call_the_helis() 
  2329. 	-- set up the escape helis 
  2330. 	m09_prep_heli(M09_group.player_pickup) 
  2331. 	m09_prep_heli(M09_group.girls_pickup) 
  2332. 	 
  2333. 	m09_set_objective(M09_objective.wait_for_chopper) 
  2334. 	 
  2335. 	-- Switch up the music while we wait for Pierce. 
  2336. 	m09_post_music_event(M09_music.boat_pierce_arrive) 
  2337. 	 
  2338. 	-- launch the escape helis 
  2339. 	m09_launch_heli(M09_group.player_pickup) 
  2340. 	m09_launch_heli(M09_group.girls_pickup)	 
  2341. 	 
  2342. 	threads_wait_for_completion(M09_group.player_pickup.thread) 
  2343. 	threads_wait_for_completion(M09_group.girls_pickup.thread) 
  2344. 	 
  2345. 	m09_cleanup_distance_check_triggers() 
  2346.  
  2347. 	m09_set_objective(M09_objective.jump_to_chopper) 
  2348. 	 
  2349. 	m09_start_convo_thread(M09_convo.get_to_the_chopper) 
  2350. 	 
  2351. 	-- Cleanup any markers 
  2352. 	for human in pairs(M09_enemies_on_the_boat) do 
  2353. 		M09_enemies_on_the_boat[human] = nil 
  2354. 		marker_remove(human) 
  2355. 		on_death("", human) 
  2356. 	end 
  2357. 	m09_clear_trigger(M09_trigger.on_boat_trigger.name) 
  2358. 	 
  2359. 	m09_set_trigger(M09_trigger.heli_entrance, false, true) 
  2360. 	while not M09_trigger.heli_entrance.hit do 
  2361. 		thread_yield() 
  2362. 	end 
  2363. 	 
  2364. 	-- End boat segment music. 
  2365. 	m09_post_music_event(M09_music.boat_stop) 
  2366. end 
  2367.  
  2368. function m09_cleanup_cargo_ship() 
  2369. 	m09_cleanup_all_boat_wave_attackers() 
  2370. 	m09_cleanup_all_heli_attackers() 
  2371. 	m09_cleanup_all_transport_heli_wave_attackers() 
  2372. 	m09_cleanup_all_helis() 
  2373. 	m09_clear_all_crates() 
  2374. 	m09_clear_all_crew() 
  2375.  
  2376. 	if group_is_loaded(M09_group.local_start_vehicle.name) then 
  2377. 		group_destroy(M09_group.local_start_vehicle.name) 
  2378. 	end 
  2379. 	 
  2380. 	if group_is_loaded(M09_group.remote_start_vehicle.name) then 
  2381. 		group_destroy(M09_group.remote_start_vehicle.name) 
  2382. 	end 
  2383. 		 
  2384. 	if group_is_loaded(M09_group.weapons.name) then 
  2385. 		group_destroy(M09_group.weapons.name) 
  2386. 	end 
  2387. end 
  2388.  
  2389. -- Launch a wave of attack helicopters and wait until it is complete. 
  2390. -- 
  2391. function m09_do_attack_heli_wave_thread()	 
  2392. 	for i, heli_group in pairs(M09_attack_helis) do 
  2393. 		heli_group.thread = thread_new("m09_spawn_attack_heli_thread", heli_group) 
  2394. 		delay(20.0) 
  2395. 	end 
  2396. 	 
  2397. 	-- wait for everything to get started 
  2398. 	delay(2.0) 
  2399. 	 
  2400. 	for i, heli_group in pairs(M09_attack_helis) do 
  2401. 		threads_wait_for_completion(heli_group.thread) 
  2402. 	end 
  2403. 	 
  2404. 	m09_cleanup_all_heli_attackers() 
  2405. end 
  2406.  
  2407. -- Sets an objective to move to the south platform of the boat. 
  2408. -- 
  2409. function m09_do_south_platform_breadcrumb_thread() 
  2410. 	m09_set_objective(M09_objective.south_platform) 
  2411. 	m09_set_trigger(M09_trigger.south_vantage) 
  2412. 	while not M09_trigger.south_vantage.hit do 
  2413. 		thread_yield() 
  2414. 	end 
  2415.  
  2416. 	m09_set_objective(M09_objective.clear_the_boat) 
  2417. end 
  2418.  
  2419. -- launch a boat wave and wait until it is complete 
  2420. -- 
  2421. -- wave_info:			(table) information about all of the attacking boats 
  2422. -- 
  2423. function m09_do_boat_wave_thread(wave_info) 
  2424. 	local boat_info = wave_info.boats 
  2425. 	local paths = wave_info.paths 
  2426.  
  2427. 	M09_allow_attacker_docking = true 
  2428. 	 
  2429. 	if (wave_info.do_south_platform_breadcrumb) then 
  2430. 		M09_get_to_south_platform_thread = thread_new("m09_do_south_platform_breadcrumb_thread") 
  2431. 	end 
  2432.  
  2433. 	for i, boat_group in pairs(boat_info) do 
  2434. 		boat_group.thread = thread_new("m09_spawn_attacker_thread", boat_group, paths) 
  2435. 		-- wait before launching next group 
  2436. 		delay(M09_delay_between_boats) 
  2437. 	end 
  2438. 	 
  2439. 	-- wait for everything to get started 
  2440. 	delay(2.0) 
  2441. 	 
  2442. 	if wave_info.play_convo == true then 
  2443. 		m09_start_convo_thread(M09_convo.hold_off_attackers) 
  2444. 	end 
  2445. 	 
  2446. 	-- wait until we are done (all are dead) 
  2447. 	for i, boat_group in pairs(boat_info) do		 
  2448. 		threads_wait_for_completion(boat_group.thread) 
  2449. 	end 
  2450. 	 
  2451. 	-- Wait as long as we might wait to clean up a boat that was destroyed. 
  2452. 	delay(M09_dead_boat_release_delay) 
  2453. 	 
  2454. 	m09_cleanup_all_boat_wave_attackers() 
  2455. end 
  2456.  
  2457. -- launch a wave of transport helis to land on the ho boat. 
  2458. -- 
  2459. function m09_do_transport_heli_wave_thread() 
  2460. 	for i, group in pairs(M09_trans_attack_helis) do 
  2461. 		group.heli_group.thread = thread_new("m09_spawn_transport_attack_heli_thread", group) 
  2462. 		delay(20.0) 
  2463. 	end 
  2464. 	 
  2465. 	for i, group in pairs(M09_trans_attack_helis) do 
  2466. 		threads_wait_for_completion(group.heli_group.thread) 
  2467. 	end 
  2468. 	 
  2469. 	m09_cleanup_all_transport_heli_wave_attackers() 
  2470. end 
  2471.  
  2472. -- setup heli rail stuff 
  2473. -- 
  2474. function m09_setup_heli_rail() 
  2475. 	 
  2476. 	-- turn off chatter, congrat lines, etc 
  2477. 	persona_suppress_ambient_lines(true) 
  2478.  
  2479. 	group_create_hidden(M09_group.player_rail.name, true) 
  2480. 	-- create helicopter to defend as well 
  2481. 	group_create_hidden(M09_group.girls_heli.name, true) 
  2482. 	 
  2483. 	group_create_hidden(M09_group.player_lookat_1.name, true) 
  2484. 	 
  2485. 	-- put the pilots in the helis	 
  2486. 	vehicle_suppress_npc_exit(M09_group.player_rail.vehicle, true) 
  2487. 	vehicle_enter_group_teleport(M09_group.player_rail.pilot, M09_group.player_rail.vehicle) 
  2488. 	vehicle_suppress_npc_exit(M09_group.girls_heli.vehicle, true) 
  2489. 	vehicle_enter_group_teleport(M09_group.girls_heli.pilot, M09_group.girls_heli.vehicle) 
  2490. 	 
  2491. 	-- Put the girls in the heli container, they go in seats 1-4 and 6-7, per Zach. 
  2492. 	if group_is_loaded(M09_group.girls_in_heli_crate.name) == false then 
  2493. 		group_create_hidden(M09_group.girls_in_heli_crate.name) 
  2494. 	end 
  2495. 	local num_girls = sizeof_table(M09_group.girls_in_heli_crate.members) 
  2496. 	for i = 1,num_girls do 
  2497. 		if i ~= 5 and i <= 7 then 
  2498. 			vehicle_enter_teleport(M09_group.girls_in_heli_crate.members[i], M09_group.girls_heli.vehicle, i, true) 
  2499. 		else  
  2500. 			character_hide(M09_group.girls_in_heli_crate.members[i]) 
  2501. 		end 
  2502. 	end 
  2503. 	 
  2504. 	-- Prevent the radio from turning on in either heli. 
  2505. 	radio_block(M09_group.player_rail.vehicle) 
  2506. 	radio_block(M09_group.girls_heli.vehicle) 
  2507. 	 
  2508. 	turn_invulnerable(M09_group.player_rail.vehicle) 
  2509. 	 
  2510. 	on_vehicle_destroyed("m09_failure_heli_destroyed_cb", M09_group.girls_heli.vehicle) 
  2511. 	marker_add(M09_group.girls_heli.vehicle, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND, OI_FLAGS_FULL) 
  2512.  
  2513. 	teleport_vehicle(M09_group.girls_heli.vehicle, M09_group.girls_heli.float_nav) 
  2514. 	thread_yield() 
  2515. 	 
  2516. 	group_show(M09_group.girls_heli.name) 
  2517. 	group_show(M09_group.girls_in_heli_crate.name) 
  2518. 	 
  2519. 	-- Start the heli flying to a nav point to keep it from plumeting. 
  2520. 	helicopter_fly_to_do(M09_group.girls_heli.vehicle, 1, true, "", false, M09_group.girls_heli.pause_nav, 0, false, false, false, false) 
  2521. 	 
  2522. 	spawning_pedestrians(false) 
  2523. 	spawning_vehicles(false) 
  2524. end 
  2525.  
  2526. -- Teleports the players into the rail heli 
  2527. -- 
  2528. function m09_players_enter_rail_heli() 
  2529. 	teleport_vehicle(M09_group.player_rail.vehicle, M09_group.player_rail.start) 
  2530. 	group_show(M09_group.player_rail.name) 
  2531. 	 
  2532. 	-- Start the heli flying to a nav point to keep it from plumeting. 
  2533. 	helicopter_fly_to_do(M09_group.player_rail.vehicle, 1, true, "", false, M09_group.player_rail.pause_nav, 0, false, false, false, false) 
  2534. 		 
  2535. 	vehicle_enter_teleport(LOCAL_PLAYER, M09_group.player_rail.vehicle, 2, true) 
  2536. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, false) 
  2537. 	--inv_weapon_add_temporary(LOCAL_PLAYER, M09_heli_weapon, 1, true, true) 
  2538. 	inv_weapon_disable_all_but_this_slot(WEAPON_SLOT_EXPLOSIVE, true, SYNC_ALL) 
  2539. 	if M09_give_rocket_launcher then 
  2540. 		inv_weapon_add_temporary(LOCAL_PLAYER, "Explosive-RocketLauncher", 1, true, true, false, true, WEAPON_LEVEL4) 
  2541. 		inv_weapon_disable_slot(WEAPON_SLOT_EXPLOSIVE, false) 
  2542. 	end 
  2543. 	 
  2544. 	if In_coop then 
  2545. 		vehicle_enter_teleport(REMOTE_PLAYER, M09_group.player_rail.vehicle, 3, true) 
  2546. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, false) 
  2547. 		inv_weapon_add_temporary(REMOTE_PLAYER, M09_heli_weapon, 1, true, true) 
  2548. 		 
  2549. 		if M09_give_rocket_launcher then 
  2550. 			inv_weapon_add_temporary(REMOTE_PLAYER, "Explosive-RocketLauncher", 1, true, true, false, true, WEAPON_LEVEL4) 
  2551. 			inv_weapon_disable_slot(WEAPON_SLOT_EXPLOSIVE, false) 
  2552. 		end 
  2553. 	end	 
  2554. end 
  2555.  
  2556. -- handle all of the speed changes of the player on the rail sequence 
  2557. -- 
  2558. function m09_do_player_rail() 
  2559.  
  2560. 	-- start the girls heli going 
  2561. 	M09_group.girls_heli.thread = thread_new("m09_fly_path_set_thread", M09_group.girls_heli.vehicle, M09_group.girls_heli.path) 
  2562.  
  2563. 	-- maybe also setup next trigger 
  2564. 	for key, trigger in pairs(M09_rail_triggers) do 
  2565. 		m09_set_rail_trigger(trigger) 
  2566. 	end 
  2567. 	 
  2568. 	delay(0.75) 
  2569. 	 
  2570. 	-- might want this still trigger based to keep things smooth 
  2571. 	for i, segment in ipairs(M09_player_rail_segments) do 
  2572. 		if segment.stop_at_end then 
  2573. 			helicopter_fly_to_direct(M09_group.player_rail.vehicle, segment.speed, segment.path) 
  2574. 		else 
  2575. 			helicopter_fly_to_direct_dont_stop(M09_group.player_rail.vehicle, segment.speed, segment.path) 
  2576. 		end 
  2577. 		 
  2578. 		if (segment.end_callback ~= nil) then 
  2579. 			thread_kill(M09_path_end_callback_thread) 
  2580. 			M09_path_end_callback_thread = thread_new(segment.end_callback.func, segment.end_callback.args) 
  2581. 		end 
  2582. 		 
  2583. 		if vehicle_is_destroyed(M09_group.player_rail.vehicle) and not character_is_dead(LOCAL_PLAYER) then 
  2584. 			character_kill(LOCAL_PLAYER) 
  2585. 		end 
  2586. 	end 
  2587. end 
  2588.  
  2589. -- protect the girls on a helicopter 
  2590. -- 
  2591. function m09_heli_rail() 
  2592. 	m09_set_objective(M09_objective.defend_heli) 
  2593. 	 
  2594. 	-- Start the heli walla thingy. 
  2595. 	m09_post_audio_event(M09_audio_events.heli_walla, LOCAL_PLAYER) 
  2596. 	 
  2597. 	-- Kick off the music. 
  2598. 	m09_post_music_event(M09_music.rail_begin) 
  2599. 	 
  2600. 	delay (3.5) 
  2601. 		 
  2602. 	m09_start_convo_thread(M09_convo.boat_chase) 
  2603. 	 
  2604. 	m09_do_player_rail() 
  2605.  
  2606. 	-- Wait for the conversation to finish. 
  2607. 	m09_wait_for_convo(30.0) 
  2608. 	 
  2609. 	-- get out 
  2610. 	fade_out(0.5) 
  2611. 	fade_out_block() 
  2612. 	 
  2613. 	-- Play some audio for loading the truck. 
  2614. 	m09_post_audio_event(M09_audio_events.load_truck, LOCAL_PLAYER) 
  2615. 	 
  2616. 	-- Start a delay thread to keep the screen faded out at least as long as the sound plays. 
  2617. 	M09_delay_thread = thread_new("delay", 7.5) 
  2618. 	 
  2619. 	group_create(M09_group.girls_truck.name, true) 
  2620. 	 
  2621. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, true) 
  2622. 	vehicle_exit_teleport(LOCAL_PLAYER) 
  2623. 	 
  2624. 	if In_coop then 
  2625. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, true) 
  2626. 		vehicle_exit_teleport(REMOTE_PLAYER) 
  2627. 	end 
  2628. 	 
  2629. 	m09_cleanup_heli_rail() 
  2630. 	 
  2631. 	teleport_coop(M09_checkpoint.truck_route.nav1, M09_checkpoint.truck_route.nav2, true) 
  2632. 	 
  2633. 	-- Get into the truck. 
  2634. 	vehicle_enter_teleport(LOCAL_PLAYER, M09_group.girls_truck.vehicle) 
  2635. 	if In_coop then 
  2636. 		vehicle_enter_teleport(REMOTE_PLAYER, M09_group.girls_truck.vehicle) 
  2637. 	end 
  2638. 	 
  2639. 	threads_wait_for_completion(M09_delay_thread) 
  2640. 	 
  2641. 	fade_in(0.5) 
  2642. 	fade_in_block() 
  2643. end 
  2644.  
  2645. function m09_cleanup_heli_rail()	 
  2646. 	-- Stop the heli walla thingy. 
  2647. 	m09_post_audio_event(M09_audio_events.heli_walla_stop, LOCAL_PLAYER) 
  2648. 	 
  2649. 	-- Stop the rail music. 
  2650. 	m09_post_music_event(M09_music.rail_stop) 
  2651. 	 
  2652. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, true) 
  2653. 	if coop_is_active() then 
  2654. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, true) 
  2655. 	end 
  2656. 	 
  2657. 	-- kill the copter 
  2658. 	if group_is_loaded(M09_group.player_rail.name) then 
  2659. 		group_destroy(M09_group.player_rail.name) 
  2660. 	end 
  2661. 	-- kill girls copter 
  2662. 	if group_is_loaded(M09_group.girls_heli.name) then 
  2663. 		marker_remove(M09_group.girls_heli.vehicle) 
  2664. 		on_vehicle_destroyed("", M09_group.girls_heli.vehicle) 
  2665. 		group_destroy(M09_group.girls_heli.name) 
  2666. 	end 
  2667. 	 
  2668. 	-- Players' and girls' helis 
  2669. 	m09_cleanup_all_helis() 
  2670. 	 
  2671. 	-- Destroy the girl group. 
  2672. 	if group_is_loaded(M09_group.girls_in_heli_crate.name) then 
  2673. 		group_destroy(M09_group.girls_in_heli_crate.name) 
  2674. 	end 
  2675. 	 
  2676. 	-- Allow the player to use weapons again 
  2677. 	inv_weapon_disable_all_slots(false, SYNC_ALL) 
  2678. 	 
  2679. 	-- Cleanup any audio threads 
  2680. 	m09_unload_all_convos() 
  2681.  
  2682. 	-- Clean up all attacker groups. 
  2683. 	local vehicle_groups = { 
  2684. 		M09_group.heli_boats, M09_group.heli_boats_2, M09_group.heli_boats_3, M09_group.heli_tank1, M09_group.heli_tank2, 
  2685. 	} 
  2686.  
  2687. 	for group_key, group in pairs(vehicle_groups) do 
  2688. 		m09_cleanup_rail_group(group) 
  2689. 		if group_is_loaded(group.name) then 
  2690. 			group_destroy(group.name) 
  2691. 		end 
  2692. 	end 
  2693. 	 
  2694. 	-- Reset ambient ped and traffic spawning. 
  2695. 	spawning_pedestrians(true) 
  2696. 	spawning_vehicles(true) 
  2697.  
  2698. 	-- allow ambient lines 
  2699. 	persona_suppress_ambient_lines(false) 
  2700. end 
  2701.  
  2702. -- Check to see if any player is in the girls truck 
  2703. -- 
  2704. function m09_player_in_truck() 
  2705. 	if In_coop then 
  2706. 		return get_char_vehicle_name(REMOTE_PLAYER) == M09_group.girls_truck.vehicle 
  2707. 	end 
  2708. 	return get_char_vehicle_name(LOCAL_PLAYER) == M09_group.girls_truck.vehicle 
  2709. end 
  2710.  
  2711. -- Block until a player enters the truck 
  2712. -- 
  2713. function m09_get_into_truck() 
  2714. 	if m09_player_in_truck() then 
  2715. 		return 
  2716. 	end 
  2717.  
  2718. 	m09_set_secondary_objective(M09_objective.take_truck, SYNC_ALL) 
  2719. 	marker_add(M09_group.girls_truck.vehicle, MINIMAP_ICON_USE, M09_objective.take_truck.icon) 
  2720. 	while not m09_player_in_truck() do 
  2721. 		thread_yield() 
  2722. 	end 
  2723. 	marker_remove(M09_group.girls_truck.vehicle) 
  2724. 	m09_clear_seconodary_objective(SYNC_ALL) 
  2725. end 
  2726.  
  2727. -- Drive the truck to the specified location. If the player leaves the truck, they will be 
  2728. -- told to enter it again 
  2729. -- 
  2730. -- obj_text:	(string) Objective text to display when taveling to the trigger 
  2731. -- trigger:		(table) triggr to tell the player to go to 
  2732. -- 
  2733. function m09_truck_goto_trigger(obj_text, trigger) 
  2734. 	m09_set_objective(obj_text) 
  2735. 	m09_set_trigger(trigger) 
  2736. 	while not trigger.hit do 
  2737. 		if not m09_player_in_truck() then 
  2738. 			m09_clear_trigger(trigger.name) 
  2739. 		 
  2740. 			m09_get_into_truck() 
  2741. 			 
  2742. 			m09_set_trigger(trigger) 
  2743. 		end 
  2744. 	 
  2745. 		thread_yield() 
  2746. 	end 
  2747. end 
  2748.  
  2749. -- drive the truck to one of 2 destinations 
  2750. -- 
  2751. function m09_truck_route() 
  2752. 	on_vehicle_destroyed("m09_failure_truck_destroyed_cb", M09_group.girls_truck.vehicle) 
  2753. 	on_vehicle_enter_water("m09_failure_truck_destroyed_cb", M09_group.girls_truck.vehicle) 
  2754. 	 
  2755. 	--m09_get_into_truck() 
  2756. 	--player_choice_tut_open("m09") 
  2757. 	 
  2758. 	-- Post the event to start the girls whining/tumbling around in the truck. 
  2759. 	m09_post_audio_event(M09_audio_events.stripper_cargo, M09_group.girls_truck.vehicle) 
  2760.  
  2761. 	m09_set_objective(M09_objective.choice) 
  2762. 	m09_set_trigger(M09_trigger.to_saints_trigger, false, false) 
  2763. 	marker_add_trigger(M09_trigger.to_saints_trigger.name, MINIMAP_ICON_SAINTS, INGAME_EFFECT_CHECKPOINT, OI_ASSET_COOP, OI_FLAGS_LOCATION, SYNC_ALL) 
  2764. 	m09_set_trigger(M09_trigger.to_brothel_trigger, false, false) 
  2765. 	marker_add_trigger(M09_trigger.to_brothel_trigger.name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  2766. 	 
  2767. 	object_indicator_add_objective_text(M09_trigger.to_brothel_trigger.name, "PLAYER_CHOICE_M09_OPTION1_TITLE", "PLAYER_CHOICE_M09_OPTION1_BODY") 
  2768. 	object_indicator_add_objective_text(M09_trigger.to_saints_trigger.name, "PLAYER_CHOICE_M09_OPTION2_TITLE", "PLAYER_CHOICE_M09_OPTION2_BODY") 
  2769. 	 
  2770. 	while not M09_trigger.to_saints_trigger.hit and not M09_trigger.to_brothel_trigger.hit do 
  2771. 		if not m09_player_in_truck() then 
  2772. 			m09_clear_trigger(M09_trigger.to_saints_trigger.name) 
  2773. 			m09_clear_trigger(M09_trigger.to_brothel_trigger.name) 
  2774.  
  2775. 			m09_get_into_truck() 
  2776.  
  2777. 			m09_set_trigger(M09_trigger.to_saints_trigger, false, false) 
  2778. 			marker_add_trigger(M09_trigger.to_saints_trigger.name, MINIMAP_ICON_SAINTS, INGAME_EFFECT_CHECKPOINT, OI_ASSET_COOP, OI_FLAGS_LOCATION, SYNC_ALL) 
  2779. 			m09_set_trigger(M09_trigger.to_brothel_trigger, false, false) 
  2780. 			marker_add_trigger(M09_trigger.to_brothel_trigger.name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  2781. 		end 
  2782. 	 
  2783. 		thread_yield() 
  2784. 	end 
  2785. 	 
  2786. 	-- we want notoriety spawns here 
  2787. 	notoriety_force_no_spawn("morningstar", false) 
  2788. 	 
  2789. 	m09_clear_trigger(M09_trigger.to_saints_trigger.name) 
  2790. 	m09_clear_trigger(M09_trigger.to_brothel_trigger.name) 
  2791. 	 
  2792. 	if M09_trigger.to_saints_trigger.hit then 
  2793. 		--m09_start_convo_thread(M09_convo.choice_crib) 
  2794. 		--m09_truck_goto_trigger(M09_objective.to_hq, M09_trigger.saints_hq) 
  2795. 		mission_set_excluded_reward("Lump_Sum_of_Money") 
  2796. 		m09_play_persona_line(M09_persona_line.choice_crib) 
  2797. 	else 
  2798. 		--m09_start_convo_thread(M09_convo.choice_morningstar) 
  2799. 		--m09_truck_goto_trigger(M09_objective.to_brothel, M09_trigger.brothel) 
  2800. 		mission_set_excluded_reward("Weekly_cash_for_hos") 
  2801. 		M09_player_chose_brothel = true 
  2802. 		m09_play_persona_line(M09_persona_line.choice_morningstar) 
  2803. 	end 
  2804. 	 
  2805. 	delay(1.0) 
  2806. 	 
  2807. 	-- Wait for a maximum of 10 seconds in case things break horribly. 
  2808. 	m09_wait_for_persona_line(LOCAL_PLAYER, 10.0) 
  2809. 	 
  2810. 	delay(1.0)	 
  2811. end 
  2812.  
  2813.  
  2814. -- *************************************************** 
  2815. -- m09_run Helper Functions 
  2816. -- *************************************************** 
  2817.  
  2818. -- Waits for a conversation to finish, or a maximum wait time has elapsed in 
  2819. -- the case that the conversation fails to play. 
  2820. -- 
  2821. -- max_wait:  (float) Max seconds to wait before we stop the conversation and continue. 
  2822. -- 
  2823. function m09_wait_for_convo(max_wait) 
  2824. 	-- Waits for anything else that's using the failsafe thread to finish. 
  2825. 	if M09_failsafe_thread ~= INVALID_THREAD_HANDLE then 
  2826. 		while thread_check_done(M09_failsafe_thread) == false do 
  2827. 			thread_yield() 
  2828. 		end 
  2829. 	end 
  2830.  
  2831. 	M09_failsafe_thread = thread_new("delay", max_wait) 
  2832. 	 
  2833. 	-- Wait for the conversation to finish or for our max wait time to elapse. 
  2834. 	while M09_active_convo ~= "" and thread_check_done(M09_failsafe_thread) == false do 
  2835. 		thread_yield() 
  2836. 	end 
  2837. 	 
  2838. 	if M09_active_convo ~= "" then 
  2839. 		-- End the conversation if it's still playing. 
  2840. 		for key, convo in pairs(M09_active_convo.files) do 
  2841. 			if convo.handle ~= nil then 
  2842. 				audio_conversation_end(convo.handle) 
  2843. 				convo.handle = nil 
  2844. 			end 
  2845. 		end 
  2846. 		if M09_active_convo.thread ~= INVALID_THREAD_HANDLE then 
  2847. 			thread_kill(M09_active_convo.thread) 
  2848. 			M09_active_convo.thread = INVALID_THREAD_HANDLE 
  2849. 		end 
  2850. 		 
  2851. 		M09_active_convo = "" 
  2852. 	end 
  2853. 	 
  2854. 	thread_kill(M09_failsafe_thread) 
  2855. 	M09_failsafe_thread = INVALID_THREAD_HANDLE 
  2856. end 
  2857.  
  2858. -- Waits for a character's voice line to finish, or until a maximum time has elapsed. 
  2859. -- 
  2860. -- char:     (string) character whose voice line we're waiting for. 
  2861. -- max_wait: (float)  maximum time to wait. 
  2862. -- 
  2863. function m09_wait_for_persona_line(char, max_wait) 
  2864. 	-- Waits for anything else that's using the failsafe thread to finish. 
  2865. 	if M09_failsafe_thread ~= INVALID_THREAD_HANDLE then 
  2866. 		while thread_check_done(M09_failsafe_thread) == false do 
  2867. 			thread_yield() 
  2868. 		end 
  2869. 	end 
  2870. 	 
  2871. 	M09_failsafe_thread = thread_new("delay", max_wait) 
  2872. 	 
  2873. 	-- Wait for the line to finish or for our max wait time to elapse. 
  2874. 	while audio_persona_line_playing(char) and thread_check_done(M09_failsafe_thread) == false do 
  2875. 		thread_yield() 
  2876. 	end 
  2877. 	 
  2878. 	thread_kill(M09_failsafe_thread) 
  2879. 	M09_failsafe_thread = INVALID_THREAD_HANDLE	 
  2880. end 
  2881.  
  2882. -- Leashes Zimos to a new nav point.  The girls following him will 
  2883. -- in turn move there as well. 
  2884. -- 
  2885. -- nav_point:  Name of the nav point to move Zimos to. 
  2886. -- 
  2887. function m09_move_zimos_and_girls(nav_point) 
  2888. 	M09_girls_flee_nav = nav_point 
  2889. end 
  2890.  
  2891. -- Locks all the crate doors; cutscenes will unlock the script movers in reset_peer... 
  2892. -- 
  2893. function m09_lock_crate_doors() 
  2894. 	for i, set in pairs(M09_crate_sets) do 
  2895. 		for j, crate in pairs(set.crates) do 
  2896. 			door_lock(crate.door, true) 
  2897. 		end 
  2898. 	end 
  2899. end 
  2900.  
  2901. -- Plays the next heli drop off conversation in the progression. 
  2902. -- 
  2903. function m09_play_heli_drop_off_convo() 
  2904. 	if M09_heli_drop_off_convo == 1 then 
  2905. 		m09_start_convo_thread(M09_convo.heli_drop_off_01) 
  2906. 	elseif M09_heli_drop_off_convo == 2 then 
  2907. 		m09_start_convo_thread(M09_convo.heli_drop_off_02) 
  2908. 	elseif M09_heli_drop_off_convo == 3 then 
  2909. 		m09_start_convo_thread(M09_convo.heli_drop_off_03) 
  2910. 	end 
  2911. 	 
  2912. 	M09_heli_drop_off_convo = M09_heli_drop_off_convo + 1 
  2913. end 
  2914.  
  2915. -- Posts a music event. 
  2916. -- 
  2917. -- event_name:  Name of the event to post. 
  2918. -- 
  2919. function m09_post_music_event(event_name) 
  2920. 	audio_object_post_event(event_name, nil, nil, LOCAL_PLAYER) 
  2921. end 
  2922.  
  2923. -- Posts an event on an object's audio object. 
  2924. -- 
  2925. -- event_table: Table containing info for the event. 
  2926. -- event_obj:   The object to post the event on. 
  2927. function m09_post_audio_event(event_table, event_obj) 
  2928. 	audio_object_post_event(event_table.event, event_table.switch_group, event_table.switch, event_obj) 
  2929. end 
  2930.  
  2931. -- setup followers as necessary 
  2932. -- 
  2933. -- homie_table:  (table) homie information 
  2934. -- 
  2935. function m09_setup_crew( homie_table ) 
  2936. 	group_create(homie_table.name, true) 
  2937. 	party_add( homie_table.zimos, LOCAL_PLAYER )	 
  2938. 	on_death("m09_failure_zimos_died_cb", homie_table.zimos) 
  2939. 	M09_Zimos = homie_table.zimos 
  2940.  
  2941. 	for key, line in pairs(M09_persona_line.follow_zimos) do 
  2942. 		line.character = M09_Zimos 
  2943. 	end 
  2944. 	M09_persona_line.zimos_to_hos.character = M09_Zimos 
  2945. 	M09_persona_line.heli_at_platform.character = M09_Zimos 
  2946. 	M09_persona_line.heli_drop_off_02.character = M09_Zimos 
  2947. 	M09_persona_line.heli_drop_off_03.character = M09_Zimos 
  2948. 	 
  2949. 	follower_set_can_abandon(M09_Zimos, true) 
  2950. 	on_dismiss("m09_zimos_abandoned_cb", M09_Zimos) 
  2951. end 
  2952.  
  2953. -- setup and play cte 
  2954. -- 
  2955. function m09_play_cte() 
  2956. 	-- Fade out early to spawn CTE group 
  2957. 	fade_out(0.5) 
  2958. 	fade_out_block() 
  2959. 	-- Spawn CTE group members 
  2960. 	group_create( M09_group.cte_npc_group.name, true ) 
  2961. 	 
  2962. 	-- Stop the cargo ship camera shake. 
  2963. 	camera_shake_stop() 
  2964. 	 
  2965. 	-- Fade to black and set up widescreen bars 
  2966. 	cutscene_in() 
  2967. 	-- Play CTE 
  2968. 	cutscene_play( CUTSCENE_CTE_BOATS ) 
  2969. 	-- Fade to black and take off widescreen bars 
  2970. 	cutscene_out() 
  2971. 	-- Destroy the CTE group 
  2972. 	group_destroy( M09_group.cte_npc_group.name ) 
  2973. 	 
  2974. 	-- Start up the camera shake again. 
  2975. 	camera_shake_play_looping(M09_cargo_ship_camera_shake, M09_cargo_ship_camera_shake_amt) 
  2976. 		 
  2977. 	-- Fade back in 
  2978. 	fade_in(0.5) 
  2979. 	fade_in_block() 
  2980. end 
  2981.  
  2982. -- clear followers as necessary 
  2983. -- 
  2984. -- homie_table:		(table) homie information 
  2985. -- 
  2986. function m09_clear_crew( homie_table ) 
  2987. 	if group_is_loaded(homie_table.name) then 
  2988. 		on_death("", homie_table.zimos)		 
  2989. 		on_dismiss("", M09_Zimos) 
  2990. 		group_destroy(homie_table.name) 
  2991. 	end 
  2992. end 
  2993.  
  2994. -- clear all crew tables 
  2995. -- 
  2996. function m09_clear_all_crew() 
  2997. 	m09_clear_crew(M09_group.start_homies) 
  2998. 	m09_clear_crew(M09_group.gangway_homies) 
  2999. end 
  3000.  
  3001. -- Set a trigger enabled with a mission marker 
  3002. -- 
  3003. -- trigger_table:	(table) trigger information 
  3004. -- add_waypoint:	(bool, optional) true to add a waypoint, else dont (default true) 
  3005. -- add_marker:		(bool, optional) true to add a marker, else dont (default true) 
  3006. -- 
  3007. function m09_set_trigger(trigger_table, add_waypoint, add_marker) 
  3008. 	trigger_table.hit = false 
  3009. 	if add_waypoint == nil or add_waypoint == true then 
  3010. 		mission_waypoint_add(trigger_table.name) 
  3011. 	end 
  3012. 	if add_marker == nil or add_marker == true then 
  3013. 		marker_add_trigger(trigger_table.name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  3014. 	end 
  3015. 	trigger_enable(trigger_table.name, true) 
  3016. 	on_trigger(trigger_table.callback, trigger_table.name) 
  3017. 	on_trigger_exit(trigger_table.on_exit, trigger_table.name) 
  3018. end 
  3019.  
  3020. -- Disable trigger/clear callback/remove markers 
  3021. -- 
  3022. -- trigger:		(string) name of the trigger 
  3023. -- 
  3024. function m09_clear_trigger(trigger) 
  3025. 	on_trigger("", trigger) 
  3026. 	on_trigger_exit("", trigger) 
  3027. 	trigger_enable(trigger, false) 
  3028. 	marker_remove_trigger(trigger, SYNC_ALL) 
  3029. 	mission_waypoint_remove() 
  3030. end 
  3031.  
  3032. -- Clear all of the triggers in this mission 
  3033. -- 
  3034. function m09_clear_all_triggers() 
  3035. 	for i, trigger in pairs(M09_trigger) do 
  3036. 		m09_clear_trigger(trigger.name) 
  3037. 	end 
  3038. end 
  3039.  
  3040. -- setup a trigger for the rail sequence (no indicator) 
  3041. -- 
  3042. -- rail_trigger:	(table) trigger information 
  3043. -- 
  3044. function m09_set_rail_trigger(rail_trigger) 
  3045. 	rail_trigger.hit = false 
  3046. 	trigger_enable(rail_trigger.name, true) 
  3047. 	on_trigger(rail_trigger.callback, rail_trigger.name) 
  3048. end 
  3049.  
  3050. -- Enables the specified spawn regions and loads the table of groups into the continuous spawn system 
  3051. -- 
  3052. -- groups:			(table) groups to enable 
  3053. -- respawn_delay:	(float) time, in seconds, to wait before respawing a group 
  3054. -- regions:			(table) spawn regions to enable 
  3055. -- 
  3056. function m09_start_continuous_spawns(groups, respawn_delay, regions) 
  3057. 	continuous_spawn_regions_enable(regions, true) 
  3058. 	 
  3059. 	for key, group in pairs(groups) do 
  3060. 		continuous_spawn_start(group, 0, respawn_delay) 
  3061. 	end 
  3062. end 
  3063.  
  3064. -- Disables all continuous spawn groups and regions 
  3065. -- 
  3066. function m09_cleanup_all_continuous_spawns() 
  3067. 	cleanup_spawn_groups(M09_spawn_groups) 
  3068. 	cleanup_spawn_regions(M09_spawn_regions) 
  3069. end 
  3070.  
  3071.  
  3072.  
  3073. local M09_active_roof_group = "" 
  3074.  
  3075. function m09_find_trigger(trigger_name) 
  3076. 	for key, trigger in pairs(M09_trigger) do 
  3077. 		if trigger.name == trigger_name then 
  3078. 			return trigger 
  3079. 		end 
  3080. 	end 
  3081. 	 
  3082. 	return "" 
  3083. end 
  3084.  
  3085. function m09_heli_face_target(args) 
  3086. 	helicopter_set_path_orientation(args[1], HELI_PF_RIGHT_SIDE_FACE_TARGT, args[2]) 
  3087. end 
  3088.  
  3089. function m09_heli_stop_facing_target(args) 
  3090. 	helicopter_set_path_orientation(args[1], HELI_PF_FACE_ALONG_PATH) 
  3091. end 
  3092.  
  3093. function m09_wind_down_rail_music() 
  3094. 	m09_post_music_event(M09_music.rail_wind_down) 
  3095. 	delay (2.0) 
  3096. 	m09_start_convo_thread(M09_convo.choice_suggestion) 
  3097. end 
  3098.  
  3099. function m09_fire_scripted_rpg(rpgs) 
  3100. 	--[[ 
  3101. 	local trigger = m09_find_trigger(trigger_name) 
  3102. 	if trigger == "" then 
  3103. 		--message("Missing Trigger: " .. trigger_name, 4.0) 
  3104. 		return 
  3105. 	end 
  3106. 	--]] 
  3107. 	 
  3108. 	for i, rpg in pairs(rpgs) do 
  3109. 		delay(rpg.delay) 
  3110. 		projectile_fire_from_navpoint(rpg.origin, rpg.target, "Explosive-RocketLauncher", 0.0) 
  3111. 	end 
  3112. 	 
  3113. 	--m09_clear_trigger(trigger_name) 
  3114. end 
  3115.  
  3116. function m09_prep_roof_group_cb(human, trigger_name) 
  3117. 	local trigger = m09_find_trigger(trigger_name) 
  3118. 	if trigger == "" then 
  3119. 		--message("Missing Trigger: " .. trigger_name, 4.0) 
  3120. 		return 
  3121. 	end 
  3122. 	 
  3123. 	if trigger.group.spawned == true then 
  3124. 		return 
  3125. 	end 
  3126. 	trigger.group.spawned = true 
  3127. 	 
  3128. 	m09_clear_trigger(trigger_name) 
  3129. 	m09_cleanup_roof() 
  3130. 	m09_setup_roof(trigger.group) 
  3131. end 
  3132.  
  3133. function m09_cleanup_roof() 
  3134. 	if M09_active_roof_group == "" then 
  3135. 		return 
  3136. 	end 
  3137. 	 
  3138. 	if group_is_loaded(M09_active_roof_group.name) then 
  3139. 		for key, npc in pairs(M09_active_roof_group.members) do 
  3140. 			marker_remove(npc) 
  3141. 			on_death("", npc) 
  3142. 		end 
  3143. 		 
  3144. 		release_to_world(M09_active_roof_group.name) 
  3145. 		group_destroy(M09_active_roof_group.name) 
  3146. 	end 
  3147.  
  3148. 	M09_active_roof_group = "" 
  3149. end 
  3150.  
  3151. function m09_setup_roof(group) 
  3152. 	group_create(group.name, true) 
  3153. 	 
  3154. 	--[[ 
  3155. 	for key, npc in pairs(group.members) do 
  3156. 		marker_add(npc, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  3157. 		on_death("m09_attacker_killed_cb", npc) 
  3158. 	end 
  3159. 	]] 
  3160. 	 
  3161. 	M09_active_roof_group = group 
  3162. end 
  3163.  
  3164. function m09_setup_boats_cb(human, trigger_name) 
  3165. 	local trigger = m09_find_trigger(trigger_name) 
  3166. 	local group = trigger.group 
  3167. 	 
  3168. 	-- Make sure we only spawn this group once. 
  3169. 	if trigger.spawned == true then 
  3170. 		return 
  3171. 	end 
  3172. 	trigger.spawned = true 
  3173. 	 
  3174. 	m09_clear_trigger(trigger_name) 
  3175. 	group_create_hidden(group.name, true) 
  3176. 	 
  3177. 	for key, boat in pairs(group.vehicles) do 
  3178. 		vehicle_suppress_npc_exit(boat.vehicle, true) 
  3179. 		if boat.gunner ~= nil then 
  3180. 			vehicle_enter_teleport(boat.gunner, boat.vehicle, 1, true) 
  3181. 		end 
  3182. 		 
  3183. 		if boat.members ~= nil then 
  3184. 			vehicle_enter_group_teleport(boat.members, boat.vehicle) 
  3185. 		end 
  3186. 		 
  3187. 		if boat.start_ai_disabled == true then 
  3188. 			-- Disable all AI for the group until it is enabled later. 
  3189. 			for i, member in pairs(group.members) do 
  3190. 				set_ignore_ai_flag(member) 
  3191. 			end 
  3192. 		else 
  3193. 			-- Make the driver ignore stuff so that they don't chase the player after they finish their path. 
  3194. 			local driver_name = vehicle_get_driver(boat.vehicle) 
  3195. 			if driver_name ~= nil then 
  3196. 				set_ignore_ai_flag(driver_name) 
  3197. 			end 
  3198. 		end 
  3199. 		 
  3200. 		if boat.speed ~= nil and boat.speed ~= "" then 
  3201. 			vehicle_speed_override(boat.vehicle, boat.speed) 
  3202. 		elseif group.speed ~= nil and group.speed ~= "" then 
  3203. 			vehicle_speed_override(boat.vehicle, group.speed) 
  3204. 		end 
  3205. 		 
  3206. 		if boat.path ~= "" then 
  3207. 			boat.pathfind_thread = thread_new("M09_vehicle_pathfind_thread", boat.vehicle, boat.path, boat) 
  3208. 		else 
  3209. 			while vehicle_exists(boat.vehicle) == false do 
  3210. 				thread_yield() 
  3211. 			end 
  3212. 			vehicle_stop(boat.vehicle) 
  3213. 		end 
  3214. 	 
  3215. 		if boat.members ~= nil then 
  3216. 			for key, member in pairs(boat.members) do 
  3217. 				-- If the group is flagged with trailing aim, then set that on all NPCs in the group. 
  3218. 				if boat.trailing_aim == true then 
  3219. 					set_trailing_aim_flag(member, true) 
  3220. 				end 
  3221. 				 
  3222. 				-- Inform the dudes of the helicopter. 
  3223. 				if boat.target_player == true then 
  3224. 					ai_add_enemy_target(member, LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE, true) 
  3225. 				else 
  3226. 					ai_add_enemy_target(member, M09_group.girls_heli.pilot, ATTACK_NOW_NEVER_LOSE) 
  3227. 				end 
  3228. 				npc_refire_rate_override(member, 5000) 
  3229. 			end 
  3230. 		end 
  3231. 	end 
  3232. 	 
  3233. 	group_show(group.name) 
  3234. 	 
  3235. 	-- If a thread function was specified for this group, start it up. 
  3236. 	if group.thread_func ~= nil then 
  3237. 		group.thread = thread_new(group.thread_func, group) 
  3238. 	end 
  3239. 	 
  3240. 	for key, boat in pairs(group.vehicles) do 
  3241. 		if boat.pathfind_thread ~= INVALID_THREAD_HANDLE then 
  3242. 			threads_wait_for_completion(boat.pathfind_thread) 
  3243. 		end 
  3244. 	end 
  3245. 	delay(20.0) 
  3246.  
  3247. 	m09_cleanup_rail_group(group) 
  3248.  
  3249. 	group_destroy(group.name) 
  3250. end 
  3251.  
  3252. function m09_audio_trigger_cb(human, trigger_name) 
  3253. 	local trigger	= m09_find_trigger(trigger_name) 
  3254. 	local audio_set= trigger.convo 
  3255. 	m09_clear_trigger(trigger_name) 
  3256. 	m09_start_convo_thread(audio_set) 
  3257. end 
  3258.  
  3259.  
  3260. -- *************************************************** 
  3261. -- m09_initialize Helper Functions 
  3262. -- *************************************************** 
  3263.  
  3264. -- Handle any common initialization 
  3265. -- 
  3266. function m09_initialize_common() 
  3267. 	-- Perform any necessary zone swaps 
  3268. 	city_zone_swap("cargo") 
  3269.  
  3270. 	m09_load_heli_rail_personas() 
  3271. 	 
  3272. 	-- Start all ambient emitters. 
  3273. 	for i, emitter in pairs(M09_temporary_emitters) do 
  3274. 		audio_ambient_emitter_start(emitter) 
  3275. 	end 
  3276. end 
  3277.  
  3278. -- Checkpoint specific initialization 
  3279. -- 
  3280. -- checkpoint:		The checkpoint to be initialized 
  3281. -- is_restart:      Whether or not the mission is restarting. 
  3282. -- 
  3283. function m09_initialize_checkpoint(checkpoint, is_restart) 
  3284.  
  3285. 	if (checkpoint == M09_checkpoint.start.name) then 
  3286. 		if is_restart == true then 
  3287. 			teleport_coop(M09_checkpoint.start.nav1, M09_checkpoint.start.nav2, true) 
  3288. 		end 
  3289. 		m09_setup_crew(M09_group.start_homies) 
  3290. 		 
  3291. 		group_create(M09_group.local_start_vehicle.name, true) 
  3292. 		vehicle_enter_teleport(LOCAL_PLAYER, M09_group.local_start_vehicle.vehicle, 0, true) 
  3293. 		vehicle_enter_teleport(M09_Zimos, M09_group.local_start_vehicle.vehicle, 1, true) 
  3294. 		 
  3295. 		if In_coop then 
  3296. 			group_create(M09_group.remote_start_vehicle.name, true) 
  3297. 			vehicle_enter_teleport(REMOTE_PLAYER, M09_group.remote_start_vehicle.vehicle, 0, true) 
  3298. 		end 
  3299. 		 
  3300. 		m09_spawn_ship_guards() 
  3301. 		 
  3302. 		delay(1.5) 
  3303. 		m09_start_convo_thread(M09_convo.to_boat) 
  3304. 		 
  3305. 		M09_play_find_minigun_line = true 
  3306. 		 
  3307. 		-- Make sure morningstar notoriety is what we'd expect it to be. 
  3308. 		notoriety_reset("morningstar") 
  3309. 	else 
  3310. 		-- any other checkpoint should be high notoriety 
  3311. 		notoriety_force_no_spawn("morningstar", true)	 
  3312. 		notoriety_set_min("morningstar", M09_min_notoriety) 
  3313. 		notoriety_set_max("morningstar", M09_max_notoriety) 
  3314. 	end 
  3315. 	 
  3316. 	if (checkpoint == M09_checkpoint.gangway.name) then		 
  3317. 		teleport_coop(M09_checkpoint.gangway.nav1, M09_checkpoint.gangway.nav2, true) 
  3318. 		m09_setup_crew(M09_group.gangway_homies) 
  3319. 		teleport(M09_Zimos, M09_checkpoint.gangway.nav1, true, false, 1.0) 
  3320. 		m09_spawn_ship_guards() 
  3321. 		m09_setup_distance_check_triggers() 
  3322. 		 
  3323. 		M09_play_find_minigun_line = true 
  3324. 	end 
  3325. 	 
  3326. 	if (checkpoint == M09_checkpoint.defend_girls.name) then 
  3327. 		teleport_coop(M09_checkpoint.defend_girls.nav1, M09_checkpoint.defend_girls.nav2, true) 
  3328. 		 
  3329. 		-- Disable all audio emitters that were disabled by opening crates. 
  3330. 		for i, emitter in pairs(M09_temporary_emitters) do 
  3331. 			audio_ambient_emitter_stop(emitter) 
  3332. 		end 
  3333. 			 
  3334. 		-- Start music for the boat segment. 
  3335. 		m09_post_music_event(M09_music.boat_begin) 
  3336. 		 
  3337. 		group_create(M09_group.girls_in_heli_crate, true) 
  3338. 		group_create(M09_group.weapons, true) 
  3339. 		m09_setup_crew(M09_group.gangway_homies) 
  3340. 		teleport(M09_Zimos, M09_nav.zimos_girls[3], true, false, 0.0, 0.0, -1.0) 
  3341. 		m09_setup_distance_check_triggers() 
  3342. 		M09_girls_found = true 
  3343. 		m09_set_trigger(M09_trigger.on_boat_trigger, false, false) 
  3344. 		 
  3345. 		-- Start the girls cowering. 
  3346. 		for i, girl in pairs(M09_group.girls_in_heli_crate.members) do 
  3347. 			set_always_cower_flag(girl, true) 
  3348. 		end 
  3349. 	 
  3350. 		-- Leash Zimos to a nav point near the girls 
  3351. 		m09_move_zimos_and_girls(M09_nav.zimos_girls[3]) 
  3352. 		if M09_zimos_girl_thread == INVALID_THREAD_HANDLE then 
  3353. 			M09_zimos_girl_thread = thread_new("m09_zimos_girl_behavior_thread") 
  3354. 		end 
  3355. 		 
  3356. 		-- Start the camera shake, must be done after the teleport. 
  3357. 		camera_shake_play_looping(M09_cargo_ship_camera_shake, M09_cargo_ship_camera_shake_amt)		 
  3358. 	end	 
  3359. 	 
  3360. 	if (checkpoint == M09_checkpoint.heli_rail.name) then 
  3361. 		teleport_coop(M09_checkpoint.heli_rail.nav1, M09_checkpoint.heli_rail.nav2, true) 
  3362. 		 
  3363. 		-- Disable all audio emitters that were disabled by opening crates. 
  3364. 		for i, emitter in pairs(M09_temporary_emitters) do 
  3365. 			audio_ambient_emitter_stop(emitter) 
  3366. 		end 
  3367. 		 
  3368. 		group_create(M09_group.girls_in_heli_crate, true) 
  3369. 		 
  3370. 		m09_setup_heli_rail() 
  3371. 		m09_players_enter_rail_heli() 
  3372. 	end 
  3373. 		 
  3374. 	if (checkpoint == M09_checkpoint.truck_route.name) then 
  3375. 		group_create(M09_group.girls_truck.name, true) 
  3376. 		teleport_coop(M09_checkpoint.truck_route.nav1, M09_checkpoint.truck_route.nav2, true) 
  3377. 		vehicle_enter_teleport(LOCAL_PLAYER, M09_group.girls_truck.vehicle) 
  3378. 		if In_coop then 
  3379. 			vehicle_enter_teleport(REMOTE_PLAYER, M09_group.girls_truck.vehicle) 
  3380. 		end 
  3381. 	end 
  3382.  
  3383. end 
  3384.  
  3385. -- *************************************************** 
  3386. -- Miscellaneous m09 Helper Funcrtions 
  3387. -- *************************************************** 
  3388.  
  3389. -- Places small kill markers over guys in a rail group. 
  3390. -- 
  3391. function m09_mark_rail_group_trigger(human, trigger_name) 
  3392. 	local trigger = m09_find_trigger(trigger_name) 
  3393. 	if trigger == "" then 
  3394. 		--message("Missing Trigger: " .. trigger_name, 4.0) 
  3395. 		return 
  3396. 	end 
  3397. 	 
  3398. 	m09_clear_trigger(trigger_name) 
  3399. 	 
  3400. 	for i, group in pairs(trigger.groups) do 
  3401. 		for key, vehicle_info in pairs(group.vehicles) do 
  3402. 			if vehicle_is_destroyed(vehicle_info.vehicle) == false then 
  3403. 				marker_add(vehicle_info.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  3404. 				on_vehicle_destroyed("m09_remove_vehicle_marker_cb", vehicle_info.vehicle) 
  3405. 			end 
  3406. 		 
  3407. 			if group.start_ai_disabled == true then 
  3408. 				-- Enable the AI for everyone but the driver. 
  3409. 				local driver_name = vehicle_get_driver(vehicle_info.vehicle) 
  3410. 				for i, member in pairs(vehicle_info.members) do 
  3411. 					if member ~= driver_name then 
  3412. 						set_ignore_ai_flag(member, false) 
  3413. 					end 
  3414. 				end 
  3415. 			end 
  3416. 		end 
  3417. 	end 
  3418. end 
  3419.  
  3420. -- Cleans up a group's markers and stuff during the rail section. 
  3421. -- 
  3422. -- human:        The human that tripped the trigger. 
  3423. -- trigger_name: The name of the trigger that was tripped. 
  3424. -- 
  3425. function m09_cleanup_rail_group_trigger(human, trigger_name) 
  3426. 	local trigger = m09_find_trigger(trigger_name) 
  3427. 	if trigger == "" then 
  3428. 		--message("Missing Trigger: " .. trigger_name, 4.0) 
  3429. 		return 
  3430. 	end 
  3431. 	 
  3432. 	m09_clear_trigger(trigger_name) 
  3433. 	 
  3434. 	for i, group in pairs(trigger.groups) do 
  3435. 		m09_cleanup_rail_group(group) 
  3436. 	end 
  3437. end 
  3438.  
  3439. -- Cleans up a rail group, removing the marker from the vehicles in the group. 
  3440. -- 
  3441. -- group: (table) group info 
  3442. -- 
  3443. function m09_cleanup_rail_group(group) 
  3444. 	if group_is_loaded(group.name) == false then 
  3445. 		return 
  3446. 	end 
  3447. 	 
  3448. 	if group.vehicles ~= nil then 
  3449. 		for i, vehicle_info in pairs(group.vehicles) do 
  3450. 			marker_remove(vehicle_info.vehicle) 
  3451. 			on_vehicle_destroyed("", vehicle_info.vehicle) 
  3452. 			if vehicle_info.pathfind_thread ~= INVALID_THREAD_HANDLE then 
  3453. 				thread_kill(vehicle_info.pathfind_thread) 
  3454. 				vehicle_info.pathfind_thread = INVALID_THREAD_HANDLE 
  3455. 			end 
  3456. 		end 
  3457. 	end 
  3458. 	 
  3459. 	if group.members ~= nil then 
  3460. 		for i, member in pairs(group.members) do 
  3461. 			on_death("", member) 
  3462. 			marker_remove(member) 
  3463. 		end 
  3464. 	end 
  3465. 	 
  3466. 	if group.thread ~= nil then 
  3467. 		thread_kill(group.thread) 
  3468. 		group.thread = INVALID_THREAD_HANDLE 
  3469. 	end 
  3470. end 
  3471.  
  3472. -- common cleanup stuff 
  3473. -- 
  3474. -- attacker:    (table) attacker information 
  3475. function m09_cleanup_attacker_common(attacker) 
  3476. 	if group_is_loaded(attacker.name) then 
  3477. 		marker_remove(attacker.vehicle) 
  3478. 		on_vehicle_destroyed("", attacker.vehicle) 
  3479. 		release_to_world(attacker.name) 
  3480. 		group_destroy(attacker.name) 
  3481. 	end 
  3482. 	thread_kill(attacker.thread) 
  3483. end 
  3484.  
  3485. -- cleanup attacker 
  3486. -- 
  3487. -- attacker:	(table) attacker information 
  3488. -- 
  3489. function m09_cleanup_boat_attacker(attacker) 
  3490. 	-- remove on death callback and markers for members 
  3491. 	if group_is_loaded(attacker.name) then 
  3492. 		for i,baddie in pairs(attacker.members) do 
  3493. 			on_death("", baddie) 
  3494. 			on_ai_do_action_complete("", baddie) 
  3495. 			marker_remove(baddie) 
  3496. 			if not character_is_dead(baddie) then 
  3497. 				set_ignore_ai_flag(baddie, false) 
  3498. 				npc_hearing_enable(baddie, true) 
  3499. 				npc_combat_enable(baddie, true) 
  3500. 			end 
  3501. 			M09_enemies_on_the_boat[baddie] = nil 
  3502. 		end 
  3503. 	end 
  3504. 	 
  3505. 	m09_cleanup_attacker_common(attacker) 
  3506. 	attacker.is_docking = false 
  3507. 	thread_kill(attacker.pathfind_thread) 
  3508. end 
  3509.  
  3510. -- cleanup transport helicopter attacker 
  3511. -- 
  3512. -- attacker:	(table) attacker information 
  3513. -- 
  3514. function m09_cleanup_transport_heli_attacker(attacker) 
  3515. 	-- remove on death callback and markers for members 
  3516. 	if group_is_loaded(attacker.heli_group.name) then 
  3517. 		--[[ 
  3518. 		if (attacker.heli_group.debug_done == false) then 
  3519. 			message("Cleaning up transport that isn't done", 4.0) 
  3520. 		end 
  3521. 		--]] 
  3522. 		on_death("", attacker.heli_group.pilot) 
  3523. 		on_ai_do_action_complete("", attacker.heli_group.pilot) 
  3524. 		marker_remove(attacker.heli_group.pilot) 
  3525. 		on_vehicle_destroyed("", attacker.heli_group.vehicle) 
  3526. 	end 
  3527. 	 
  3528. 	if group_is_loaded(attacker.soldier_group.name) then 
  3529. 		for i,baddie in pairs(attacker.soldier_group.members) do 
  3530. 			on_death("", baddie) 
  3531. 			on_ai_do_action_complete("", baddie) 
  3532. 			marker_remove(baddie) 
  3533. 		end 
  3534. 		release_to_world(attacker.soldier_group.name) 
  3535. 		group_destroy(attacker.soldier_group.name) 
  3536. 	end 
  3537. 	 
  3538. 	m09_cleanup_attacker_common(attacker.heli_group) 
  3539. end 
  3540.  
  3541. -- Cleans up a helicopter attacker. 
  3542. -- 
  3543. -- attacker:  (table) attacker information 
  3544. -- 
  3545. function m09_cleanup_heli_attacker(attacker) 
  3546. 	if group_is_loaded(attacker.name) then 
  3547. 		marker_remove(attacker.vehicle) 
  3548. 		on_vehicle_destroyed("", attacker.vehicle) 
  3549. 		release_to_world(attacker.name) 
  3550. 		group_destroy(attacker.name) 
  3551. 	end 
  3552. end 
  3553.  
  3554. -- Clean up all attack helicopters. 
  3555. -- 
  3556. function m09_cleanup_all_heli_attackers() 
  3557. 	for key, heli_group in pairs(M09_attack_helis) do 
  3558. 		m09_cleanup_heli_attacker(heli_group) 
  3559. 	end 
  3560. end 
  3561.  
  3562. -- do the cleanup dance for all boat wave attackers 
  3563. -- 
  3564. function m09_cleanup_all_boat_wave_attackers() 
  3565. 	for key, boat_group in pairs(M09_boats) do 
  3566. 		m09_cleanup_boat_attacker(boat_group) 
  3567. 	end 
  3568. end 
  3569.  
  3570. -- Clean up all transport attack helis. 
  3571. -- 
  3572. function m09_cleanup_all_transport_heli_wave_attackers() 
  3573. 	for i, heli_group in pairs(M09_trans_attack_helis) do 
  3574. 		m09_cleanup_transport_heli_attacker(heli_group) 
  3575. 	end 
  3576. end 
  3577.  
  3578. -- Create heli group, put pilot into heli and hold at initial navpoint 
  3579. -- 
  3580. -- heli:		(table) heli information 
  3581. -- 
  3582. function m09_prep_heli(heli) 
  3583. 	group_create(heli.name, true) 
  3584. 	vehicle_enter_teleport(heli.pilot, heli.vehicle) 
  3585. 	-- pop the chopper off the ground to get it going 
  3586. 	teleport_vehicle(heli.vehicle,  heli.float_nav) 
  3587. 	-- stay there 
  3588. 	heli.thread = thread_new("m09_fly_path_thread", heli.vehicle, 10.0, heli.float_nav) 
  3589. end 
  3590.  
  3591. -- send heli on his path 
  3592. -- 
  3593. -- heli:		(table) heli information 
  3594. -- 
  3595. function m09_launch_heli(heli) 
  3596. 	-- kill the float thread 
  3597. 	thread_kill(heli.thread) 
  3598. 	-- clean up any markers set on them 
  3599. 	on_vehicle_destroyed("m09_remove_marker_cb", heli.vehicle) 
  3600. 	-- send them on their way 
  3601. 	heli.thread = thread_new("m09_fly_path_set_thread", heli.vehicle, heli.path) 
  3602. end 
  3603.  
  3604. -- cleanup the heli 
  3605. -- 
  3606. -- heli:		(table) heli information 
  3607. -- 
  3608. function m09_cleanup_heli(heli) 
  3609. 	if group_is_loaded(heli.name) then 
  3610. 		on_vehicle_destroyed("", heli.vehicle) 
  3611. 		marker_remove(heli.vehicle) 
  3612. 		group_destroy(heli.name) 
  3613. 	end 
  3614. 	thread_kill(heli.thread) 
  3615. end 
  3616.  
  3617. -- do the cleanup dance for all generic helis 
  3618. -- 
  3619. function m09_cleanup_all_helis() 
  3620. 	m09_cleanup_heli(M09_group.player_pickup) 
  3621. 	m09_cleanup_heli(M09_group.girls_pickup) 
  3622. end 
  3623.  
  3624. -- Sets the primary and secondary objectives for the players. 
  3625. -- 
  3626. function m09_set_objectives_internal() 
  3627. 	-- Clear objectives for both players. 
  3628. 	objective_text_clear(0) 
  3629. 	objective_text_clear(1) 
  3630. 	 
  3631. 	if M09_secondary_obj[SYNC_LOCAL] == nil then 
  3632. 		-- No secondary objective for the local player, set the primary objective. 
  3633. 		if M09_current_obj ~= nil and M09_current_obj ~= "" then 
  3634. 			objective_text(0, M09_current_obj.name, M09_obj_str1, M09_obj_str2, SYNC_LOCAL, M09_current_obj.icon) 
  3635. 		end 
  3636. 	else 
  3637. 		-- Local player has a secondary objective, use that. 
  3638. 		objective_text(0, M09_secondary_obj[SYNC_LOCAL].name, "", "", SYNC_LOCAL, M09_secondary_obj[SYNC_LOCAL].icon) 
  3639. 	end 
  3640. 	 
  3641. 	 
  3642. 	if M09_secondary_obj[SYNC_REMOTE] == nil then 
  3643. 		-- No secondary objective for the remote player, set the primary objective. 
  3644. 		if M09_current_obj ~= nil and M09_current_obj ~= ""  then 
  3645. 			objective_text(1, M09_current_obj.name, M09_obj_str1, M09_obj_str2, SYNC_REMOTE, M09_current_obj.icon) 
  3646. 		end 
  3647. 	else 
  3648. 		-- Remote player has a secondary objective, use that. 
  3649. 		objective_text(1, M09_secondary_obj[SYNC_REMOTE].name, "", "", SYNC_REMOTE, M09_secondary_obj[SYNC_REMOTE].icon) 
  3650. 	end 
  3651. end 
  3652.  
  3653. function m09_set_objective(obj, str1, str2) 
  3654. 	M09_current_obj = obj 
  3655. 	 
  3656. 	if str1 == nil then 
  3657. 		str1 = "" 
  3658. 	end 
  3659. 	if str2 == nil then 
  3660. 		str2 = "" 
  3661. 	end 
  3662. 	 
  3663. 	M09_obj_str1 = str1 
  3664. 	M09_obj_str2 = str2 
  3665. 	 
  3666. 	m09_set_objectives_internal() 
  3667. end 
  3668.  
  3669. function m09_clear_objective() 
  3670. 	M09_current_obj = "" 
  3671. 	M09_obj_str1 = "" 
  3672. 	M09_obj_str2 = "" 
  3673. 	 
  3674. 	m09_set_objectives_internal() 
  3675. end 
  3676.  
  3677. function m09_set_secondary_objective(obj, sync) 
  3678. 	M09_secondary_obj[sync] = obj 
  3679. 	 
  3680. 	m09_set_objectives_internal()	 
  3681. 	 
  3682. 	-- Don't disable the crates anymore, since we're not displaying the "get 
  3683. 	-- back to the boat" radius/message for both players in co-op. 
  3684. 	--m09_disable_active_crates() 
  3685. end 
  3686.  
  3687. function m09_clear_seconodary_objective(sync) 
  3688. 	M09_secondary_obj[sync] = nil 
  3689. 	 
  3690. 	m09_set_objectives_internal() 
  3691. 	 
  3692. 	m09_enable_active_crates() 
  3693. end	 
  3694.  
  3695. -- ***************                 *************** 
  3696. -- ***************  Crate Stuff    *************** 
  3697. -- ***************                 *************** 
  3698.  
  3699. -- Set a trigger enabled with a mission marker 
  3700. -- 
  3701. -- trigger:		(string) Name of the trigger 
  3702. -- 
  3703. function m09_set_crate_trigger(crate) 
  3704. 	if M09_crates_disabled then 
  3705. 		return 
  3706. 	end 
  3707. 	 
  3708. 	trigger_enable(crate.trigger, true) 
  3709. 	if crate.content ~= M09_CRATE_BRUTE and crate.content ~= M09_CRATE_BRUTE_GAT then 
  3710. 		marker_add_trigger(crate.trigger, MINIMAP_ICON_USE, nil, OI_ASSET_USE, OI_FLAGS_DEFAULT + OI_FLAG_FADE, SYNC_ALL) 
  3711. 	end 
  3712. 	on_trigger("m09_trigger_crate_cb", crate.trigger) 
  3713. end 
  3714.  
  3715. -- Disable crate trigger 
  3716. -- 
  3717. -- trigger:		(string) trigger name 
  3718. -- 
  3719. function m09_clear_crate_trigger(trigger) 
  3720. 	on_trigger("", trigger) 
  3721. 	trigger_enable(trigger, false) 
  3722. 	marker_remove_trigger(trigger, SYNC_ALL) 
  3723. end 
  3724.  
  3725. -- Process a complete crate open QTE 
  3726. -- 
  3727. -- crate:		(table) crate information 
  3728. -- successful:	(boolean) true if QTE was successful 
  3729. -- player:		(string) player opening the crate 
  3730. -- 
  3731. function m09_crate_door_open(crate, successful, player) 
  3732. 	if successful then 
  3733. 		-- Make sure we don't somehow open the same crate multiple times. 
  3734. 		if crate.opened == true then 
  3735. 			return 
  3736. 		end 
  3737. 		crate.opened = true 
  3738. 		 
  3739. 		-- Stop the audio emitter if one is specified. 
  3740. 		if crate.emitter_to_stop ~= nil then 
  3741. 			audio_ambient_emitter_stop(crate.emitter_to_stop) 
  3742. 		end 
  3743. 		 
  3744. 		-- Post the audio event if one is specified. 
  3745. 		if crate.door_open_event ~= nil then 
  3746. 			audio_object_post_event(crate.door_open_event, crate.door_open_switch_group, crate.door_open_switch, crate.door_open_event_object) 
  3747. 		end 
  3748. 		 
  3749. 		-- Before opening a crate full of girls, set them up to cower 'n stuff. 
  3750. 		if crate.content == M09_CRATE_GIRLS then 
  3751. 			for i, girl in pairs(crate.group.members) do 
  3752. 				set_ignore_ai_flag(girl, false) 
  3753. 				npc_hearing_enable(girl, false) 
  3754. 				npc_combat_enable(girl, false) 
  3755. 				set_always_cower_flag(girl, true) 
  3756. 				character_allow_ragdoll(girl, false) 
  3757. 				set_dont_attack_me_on_sight_flag(girl, true) 
  3758. 				set_team(girl, "Playas") 
  3759. 			end 
  3760. 		end 
  3761. 		 
  3762. 		-- If the crate has a script group of weapons to spawn, do that now. 
  3763. 		if crate.ammo_group ~= nil then 
  3764. 			group_create(crate.ammo_group.name, true) 
  3765. 		end 
  3766. 	 
  3767. 		-- Play the animation to open the crate door. 
  3768. 		door_open(crate.door) 
  3769. 		if crate.player_anim ~= nil then 
  3770. 			action_play(player, crate.player_anim, crate.player_anim, false, 0.8, false, true, crate.anim_nav) 
  3771. 		end 
  3772. 		if crate.content == M09_CRATE_BOMB then 
  3773. 			delay(0.25) 
  3774. 			explosion_create("Flashbang", crate.door, player) 
  3775. 		elseif crate.content == M09_CRATE_ENEMIES or crate.content == M09_CRATE_BRUTE or crate.content == M09_CRATE_BRUTE_GAT then 
  3776. 			for i, enemy in pairs(crate.group.members) do 
  3777. 				set_ignore_ai_flag( enemy, false ) 
  3778. 				npc_hearing_enable(enemy, true) 
  3779. 				turn_vulnerable(enemy) 
  3780. 				ai_add_enemy_target(enemy, player, ATTACK_NOW_NEVER_LOSE) 
  3781. 				if crate.run_to ~= "" then 
  3782. 					local should_fire = true 
  3783. 					local should_run  = true 
  3784. 					ai_do_scripted_move(enemy, crate.run_to, should_run, should_fire) 
  3785. 				end 
  3786. 			end 
  3787.  
  3788. 			if crate.content == M09_CRATE_BRUTE then 
  3789. 				delay(3.0) 
  3790. 				m09_play_persona_line(M09_persona_line.melee_brute) 
  3791. 				M09_brute_list[crate.group.members[1]] = true 
  3792. 			elseif crate.content == M09_CRATE_BRUTE_GAT then 
  3793. 				delay(3.0) 
  3794. 				m09_play_persona_line(M09_persona_line.gat_brute) 
  3795. 				M09_brute_list[crate.group.members[1]] = true 
  3796. 			end 
  3797. 			 
  3798. 		elseif crate.content == M09_CRATE_GIRLS then 
  3799. 			M09_found_girl_crates = M09_found_girl_crates + 1 
  3800. 			m09_set_objective(M09_objective.find_girls, M09_found_girl_crates, sizeof_table(M09_girl_crate)) 
  3801. 			for i, girl in pairs(crate.group.members) do 
  3802. 				M09_girls_following[girl] = girl 
  3803. 			end 
  3804. 			crate.just_opened = true 
  3805. 			 
  3806. 			-- Set characters for the girl thanks and complain lines. 
  3807. 			M09_persona_line.girl_thanks_1.character = crate.group.members[1] 
  3808. 			M09_persona_line.girl_thanks_2.character = crate.group.members[2] 
  3809. 			M09_persona_line.girl_complain_1.character = crate.group.members[1] 
  3810. 			M09_persona_line.girl_complain_2.character = crate.group.members[2] 
  3811.  
  3812. 			if M09_goto_zimos_line == 1 then 
  3813. 				M09_persona_line.goto_zimos[1].character = player 
  3814. 				m09_start_convo_thread(M09_convo.zimos_01) 
  3815. 			elseif M09_goto_zimos_line == 2 then 
  3816. 				M09_persona_line.goto_zimos[2].character = player 
  3817. 				m09_start_convo_thread(M09_convo.zimos_02) 
  3818. 			elseif M09_goto_zimos_line == 3 then 
  3819. 				M09_persona_line.goto_zimos[3].character = player 
  3820. 				m09_start_convo_thread(M09_convo.zimos_03) 
  3821. 			else 
  3822. 				-- Does this line make sense to play?  We're going to tell the hos to get into the crate immediately 
  3823. 				-- following, so why tell them to follow Zimos? 
  3824. 				--m09_start_convo_thread(M09_convo.zimos_04) 
  3825. 			end 
  3826. 			M09_goto_zimos_line = M09_goto_zimos_line + 1 
  3827. 			 
  3828. 		elseif crate.content == M09_CRATE_GAG then 
  3829. 			delay(1.0) 
  3830. 			if M09_found_gag_line < 5 then 
  3831. 				M09_persona_line.find_gag[M09_found_gag_line].character = player 
  3832. 				m09_play_persona_line(M09_persona_line.find_gag[M09_found_gag_line]) 
  3833. 			end 
  3834. 			M09_found_gag_line = M09_found_gag_line + 1 
  3835. 			 
  3836. 		elseif crate.content == M09_CRATE_AMMO then			 
  3837. 			delay(1.0) 
  3838. 			if M09_found_ammo_line < 4 then 
  3839. 				M09_persona_line.find_ammo[M09_found_ammo_line].character = player 
  3840. 				m09_play_persona_line(M09_persona_line.find_ammo[M09_found_ammo_line]) 
  3841. 			end 
  3842. 			M09_found_ammo_line = M09_found_ammo_line + 1 
  3843. 		end 
  3844. 		 
  3845. 		if crate.zimos_nav ~= nil then 
  3846. 			-- Move Zimos to the specified nav. 
  3847. 			m09_move_zimos_and_girls(crate.zimos_nav) 
  3848. 		end 
  3849. 	else 
  3850. 		-- fail, reset triggers 
  3851. 		m09_setup_crate(crate) 
  3852. 	end 
  3853. end 
  3854.  
  3855. -- setup the trigger on the crate and spawn any people inside if needed 
  3856. -- 
  3857. -- crate:		(table) crate information 
  3858. -- 
  3859. function m09_setup_crate(crate) 
  3860. 	crate.opened = false 
  3861. 	m09_set_crate_trigger(crate) 
  3862. 	if crate.group ~= "" and not group_is_loaded(crate.group.name) then 
  3863. 		group_create(crate.group.name, true) 
  3864. 	end 
  3865. end 
  3866.  
  3867. -- setup all crates in a set 
  3868. -- 
  3869. function m09_setup_crate_set(crate_set) 
  3870. 	M09_active_crate_set = crate_set 
  3871. 	for key, crate in pairs(crate_set.crates) do 
  3872. 		door_close(crate.door) 
  3873. 		m09_setup_crate(crate) 
  3874. 	end 
  3875. end 
  3876.  
  3877. function m09_disable_active_crates() 
  3878. 	M09_crates_disabled = true 
  3879. 	if M09_active_crate_set == "" then 
  3880. 		return 
  3881. 	end 
  3882. 	 
  3883. 	for key, crate in pairs(M09_active_crate_set.crates) do 
  3884. 		m09_clear_crate_trigger(crate.trigger) 
  3885. 	end 
  3886. end 
  3887.  
  3888. function m09_enable_active_crates() 
  3889. 	M09_crates_disabled = false 
  3890. 	if M09_active_crate_set == "" then 
  3891. 		return 
  3892. 	end 
  3893. 	 
  3894. 	for key, crate in pairs(M09_active_crate_set.crates) do 
  3895. 		if not door_is_open(crate.door) then 
  3896. 			m09_set_crate_trigger(crate) 
  3897. 		end 
  3898. 	end 
  3899. end 
  3900.  
  3901. function m09_num_crates_left(crate_set) 
  3902. 	local left = 0 
  3903. 	for key, crate in pairs(crate_set.crates) do 
  3904. 		if crate.opened == false then 
  3905. 			left = left + 1 
  3906. 		end 
  3907. 	end 
  3908. 	return left 
  3909. end 
  3910.  
  3911. -- close the doors to all of the crates (WARNING: Don't trap a player inside) 
  3912. -- 
  3913. function m09_close_all_crate_doors() 
  3914. 	for i, crate_set in pairs(M09_crate_sets) do 
  3915. 		for key, crate in pairs(crate_set.crates) do 
  3916. 			door_close(crate.door) 
  3917. 		end 
  3918. 	end 
  3919. end 
  3920.  
  3921. -- Clear the trigger callback to all of the crates 
  3922. -- 
  3923. function m09_clear_all_crates() 
  3924. 	for i, crate_set in pairs(M09_crate_sets) do 
  3925. 		for key, crate in pairs(crate_set.crates) do 
  3926. 			m09_clear_crate_trigger(crate.trigger) 
  3927. 			if crate.group ~= "" and group_is_loaded(crate.group.name) then 
  3928. 				if crate.content == M09_CRATE_BRUTE or crate.content == M09_CRATE_BRUTE_GAT then 
  3929. 					m09_remove_makers_and_callbacks(crate) 
  3930. 				end 
  3931. 				group_destroy(crate.group.name) 
  3932. 				if crate.ammo_group ~= nil then 
  3933. 					group_destroy(crate.ammo_group.name) 
  3934. 				end 
  3935. 			end 
  3936. 		end 
  3937. 	end 
  3938. end 
  3939.  
  3940. -- Disables the triggers on all the crates 
  3941. -- 
  3942. function m09_clear_all_crate_triggers() 
  3943. 	for i, crate_set in pairs(M09_crate_sets) do 
  3944. 		for key, crate in pairs(crate_set.crates) do 
  3945. 			m09_clear_crate_trigger(crate.trigger) 
  3946. 		end 
  3947. 	end 
  3948. 	 
  3949. 	M09_active_crate_set = "" 
  3950. end 
  3951.  
  3952. -- Remove any markers and callbacks associated with a crates members 
  3953. -- 
  3954. function m09_remove_makers_and_callbacks(crate) 
  3955. 	if crate.group == "" or not group_is_loaded(crate.group.name) then 
  3956. 		return 
  3957. 	end 
  3958. 	for i, enemy in pairs(crate.group.members) do 
  3959. 		marker_remove(enemy) 
  3960. 		on_death("", enemy) 
  3961. 	end 
  3962. end 
  3963.  
  3964. -- clean up all mission groups 
  3965. -- 
  3966. function m09_cleanup_groups() 
  3967. 	-- defense stuff 
  3968. 	m09_cleanup_all_boat_wave_attackers() 
  3969. 	m09_cleanup_all_heli_attackers() 
  3970. 	m09_cleanup_all_transport_heli_wave_attackers() 
  3971. 	 
  3972. 	-- rail stuff 
  3973. 	if group_is_loaded(M09_group.girls_heli.name) then 
  3974. 		marker_remove(M09_group.girls_heli.vehicle) 
  3975. 		on_vehicle_destroyed("", M09_group.girls_heli.vehicle) 
  3976. 	end 
  3977. 		 
  3978. 	m09_cleanup_all_helis() 
  3979. 	 
  3980. 	-- driving stuff 
  3981. 	if group_is_loaded(M09_group.girls_truck.name) then 
  3982. 		marker_remove(M09_group.girls_truck.vehicle) 
  3983. 		on_vehicle_destroyed("", M09_group.girls_truck.vehicle) 
  3984. 		on_vehicle_enter_water("", M09_group.girls_truck.vehicle) 
  3985. 	end 
  3986. 	cleanup_groups(M09_group) 
  3987. end 
  3988.  
  3989. -- ************************* 
  3990. -- 
  3991. -- Callback functions 
  3992. -- 
  3993. -- ************************* 
  3994.  
  3995. -- Called when a vehicle is destroyed and we need to remove the marker from it. 
  3996. function m09_remove_vehicle_marker_cb(vehicle_name) 
  3997. 	on_vehicle_destroyed("", vehicle_name) 
  3998. 	marker_remove(vehicle_name) 
  3999. end 
  4000.  
  4001. -- Called when a cell call ends. 
  4002. function m09_cell_call_ended() 
  4003. 	M09_cur_cell_call = "" 
  4004. end 
  4005.  
  4006. -- Disable front spawns trigger has been hit 
  4007. -- 
  4008. -- player:		(string) player that activated trigger 
  4009. -- trigger:		(string) name of trigger hit 
  4010. -- 
  4011. function m09_disable_front_spawns_cb(player, trigger) 
  4012. 	m09_cleanup_all_continuous_spawns() 
  4013. 	m09_clear_trigger(trigger) 
  4014. end 
  4015.  
  4016. -- Gangway trigger has been hit 
  4017. -- 
  4018. -- player:		(string) player that activated trigger 
  4019. -- trigger:		(string) name of trigger hit 
  4020. -- 
  4021. function m09_gangway_trigger_cb(player, trigger) 
  4022. 	M09_trigger.gangway.hit = true 
  4023. 	m09_clear_trigger(trigger) 
  4024. end 
  4025.  
  4026. function m09_heli_entrance_trigger_cb(player, trigger) 
  4027. 	M09_trigger.heli_entrance.hit = true 
  4028. 	m09_clear_trigger(trigger) 
  4029. end 
  4030.  
  4031. function m09_north_vantage_cb(player, trigger) 
  4032. 	M09_trigger.north_vantage.hit = true 
  4033. 	m09_clear_trigger(trigger) 
  4034. end 
  4035.  
  4036. function m09_south_vantage_cb(player, trigger) 
  4037. 	M09_trigger.south_vantage.hit = true 
  4038. 	m09_clear_trigger(trigger) 
  4039. end 
  4040.  
  4041. -- Ho heli crate trigger has been hit 
  4042. -- 
  4043. -- player:		(string) player that activated trigger 
  4044. -- trigger:		(string) name of trigger hit 
  4045. -- 
  4046. function m09_ho_heli_crate_trigger_cb(player, trigger) 
  4047. 	M09_trigger.ho_heli_crate.hit = true 
  4048. 	m09_clear_trigger(trigger) 
  4049. end 
  4050.  
  4051. -- Zimos death callback 
  4052. function m09_failure_zimos_died_cb() 
  4053. 	-- End the mission, Zimos died 
  4054. 	mission_end_failure("m09", "m09_failure_zimos_died") 
  4055. end 
  4056.  
  4057. -- Zimos abandoned 
  4058. function m09_zimos_abandoned_cb() 
  4059. 	mission_end_failure("m09", "m09_failure_zimos_abandoned") 
  4060. end 
  4061.  
  4062. -- helicopter of girls is gone 
  4063. function m09_failure_heli_destroyed_cb()	 
  4064. 	mission_end_failure("m09", "m09_failure_girls_heli") 
  4065. end 
  4066.  
  4067. -- truck of girls is gone 
  4068. function m09_failure_truck_destroyed_cb()	 
  4069. 	mission_end_failure("m09", "m09_failure_girls_truck") 
  4070. end 
  4071.  
  4072. -- count another attacker 
  4073. -- 
  4074. -- attacker:	(string) name of attacker killed 
  4075. -- 
  4076. function m09_attacker_killed_cb(attacker) 
  4077. 	marker_remove(attacker) 
  4078. 	release_to_world(attacker) 
  4079. 	M09_enemies_on_the_boat[attacker] = nil 
  4080. 	on_death("", attacker) 
  4081. end 
  4082.  
  4083. -- remove marker on killed object 
  4084. -- 
  4085. -- killed:	(string) name of npc or vehicle killed 
  4086. -- 
  4087. function m09_remove_marker_cb(killed) 
  4088. 	marker_remove(killed) 
  4089. end 
  4090.  
  4091. -- Handle an attack heli being blown up. 
  4092. -- 
  4093. -- heli_name:   (string) name of the heli destroyed 
  4094. -- 
  4095. function m09_attack_heli_destroyed_cb(heli_name) 
  4096. 	-- clear our callback 
  4097. 	on_vehicle_destroyed("", heli_name) 
  4098. 	-- find our boat 
  4099. 	for i, heli in pairs(M09_attack_helis) do 
  4100. 		if heli.vehicle == heli_name then 
  4101. 			marker_remove(heli.vehicle) 
  4102. 			thread_kill(heli.thread) 
  4103. 			heli.thread = INVALID_THREAD_HANDLE 
  4104. 		end 
  4105. 	end 
  4106. end 
  4107.  
  4108. -- Attacker transport helicopter was destroyed. 
  4109. -- 
  4110. -- heli_name:  (string) name of the heli destroyed 
  4111. -- 
  4112. function m09_transport_heli_destroyed_cb(heli_name) 
  4113. 	for i, heli in pairs(M09_trans_attack_helis) do 
  4114. 		if heli.heli_group.vehicle == heli_name then 
  4115. 			m09_cleanup_transport_heli_attacker(heli) 
  4116. 		end 
  4117. 	end 
  4118. end 
  4119.  
  4120. -- handle a boat being blown up before arriving 
  4121. -- 
  4122. -- boat_name:	(string) name of vehicle destroyed 
  4123. -- 
  4124. function m09_boat_destroyed_cb(boat_name) 
  4125. 	-- clear our callback 
  4126. 	on_vehicle_destroyed("", boat_name) 
  4127. 	-- find our boat 
  4128. 	for i,boat in pairs(M09_boats) do 
  4129. 		if boat.vehicle == boat_name then 
  4130. 			if (boat.is_docking) then 
  4131. 				M09_allow_attacker_docking = true 
  4132. 			end 
  4133. 			 
  4134. 			-- don't need this marker anymore 
  4135. 			marker_remove(boat.vehicle) 
  4136. 			 
  4137. 			-- kill the threads 
  4138. 			thread_kill(boat.pathfind_thread) 
  4139. 			thread_kill(boat.thread) 
  4140. 			 
  4141. 			-- Wait a little while before releasing the group. 
  4142. 			-- The ambient spawn system is pretty aggressive at 
  4143. 			-- destroying vehicles. 
  4144. 			delay(M09_dead_boat_release_delay) 
  4145. 			 
  4146. 			-- release the whole group 
  4147. 			release_to_world(boat.name) 
  4148. 			group_destroy(boat.name) 
  4149. 			 
  4150. 			-- we're done here 
  4151. 			return 
  4152. 		end 
  4153. 	end 
  4154. end 
  4155.  
  4156. -- Sets the hit flag of a trigger when its hit 
  4157. -- 
  4158. -- human:	(string) human that activated the trigger 
  4159. -- tirgger:	(string) trigger that was activated 
  4160. function m09_set_trigger_hit_cb(human, trigger_name) 
  4161. 	for key, trigger in pairs(M09_trigger) do 
  4162. 		if trigger.name == trigger_name then 
  4163. 			trigger.hit = true 
  4164. 			return 
  4165. 		end 
  4166. 	end 
  4167.  
  4168. 	--message("Error: Could not find the trigger " .. trigger_name, 4.0) 
  4169. 	return 
  4170. end 
  4171.  
  4172. -- Keep track of when NPCs enter the boat 
  4173. -- 
  4174. function m09_on_boat_enter_cb(human, trigger) 
  4175. 	if human == nil or human == "" or get_team(human) ~= "Morningstar" or M09_enemies_on_the_boat[human] == true then 
  4176. 		return 
  4177. 	end 
  4178. 	 
  4179. 	-- If the dude's in a helicopter, leave him alone. 
  4180. 	if get_char_vehicle_type(human) == VT_HELICOPTER then 
  4181. 		return 
  4182. 	end 
  4183. 	 
  4184. 	marker_remove(human) 
  4185. 	if M09_brute_list[human] == true then 
  4186. 		marker_add(human, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  4187. 	else 
  4188. 		marker_add(human, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  4189. 	end 
  4190. 	M09_enemies_on_the_boat[human] = true 
  4191. 	on_death("m09_attacker_killed_cb", human) 
  4192. end 
  4193.  
  4194. -- Keep track of when NPCs leave the boat 
  4195. -- 
  4196. function m09_on_boat_exit_cb(human, trigger) 
  4197. 	if human == nil or human == "" or get_team(human) ~= "Morningstar" then 
  4198. 		return 
  4199. 	end 
  4200. 	 
  4201. 	-- If the dude's in a helicopter, leave him alone. 
  4202. 	if get_char_vehicle_type(human) == VT_HELICOPTER then 
  4203. 		return 
  4204. 	end 
  4205. 	 
  4206. 	on_death("", human) 
  4207. 	 
  4208. 	if not character_is_dead(human) then 
  4209. 		character_kill(human) 
  4210. 	end 
  4211. 	 
  4212. 	marker_remove(human) 
  4213. 	M09_enemies_on_the_boat[human] = nil 
  4214. end 
  4215.  
  4216. function m09_player_on_boat_enter_cb(human, trigger) 
  4217. 	if human == LOCAL_PLAYER then 
  4218. 		M09_local_on_boat = true 
  4219. 		marker_remove_trigger(M09_trigger.gangway.name, SYNC_LOCAL) 
  4220. 	elseif human == REMOTE_PLAYER then 
  4221. 		M09_remote_on_boat = true 
  4222. 		marker_remove_trigger(M09_trigger.gangway.name, SYNC_REMOTE)	 
  4223. 	end 
  4224. end 
  4225.  
  4226. function m09_player_on_boat_exit_cb(human, trigger) 
  4227. 	if human == LOCAL_PLAYER then 
  4228. 		M09_local_on_boat = false 
  4229. 		marker_add_trigger(M09_trigger.gangway.name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_LOCAL) 
  4230. 		 
  4231. 	elseif human == REMOTE_PLAYER then 
  4232. 		M09_remote_on_boat = false 
  4233. 		marker_add_trigger(M09_trigger.gangway.name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_REMOTE) 
  4234. 		 
  4235. 	end 
  4236. end 
  4237.  
  4238. function m09_show_warn_radius_cb(human, trigger) 
  4239. 	if human == LOCAL_PLAYER then 
  4240. 		minimap_icon_add_radius("Cargo_Ship_Center", M09_max_player_dist_from_boat * 0.95, SYNC_LOCAL) 
  4241. 		m09_set_secondary_objective(M09_objective.go_to_ship, SYNC_LOCAL) 
  4242. 	elseif human == REMOTE_PLAYER then 
  4243. 		minimap_icon_add_radius("Cargo_Ship_Center", M09_max_player_dist_from_boat * 0.95, SYNC_REMOTE) 
  4244. 		m09_set_secondary_objective(M09_objective.go_to_ship, SYNC_REMOTE) 
  4245. 	end 
  4246. end 
  4247.  
  4248. function m09_remove_warn_radius_cb(human, trigger) 
  4249. 	if human == LOCAL_PLAYER then 
  4250. 		minimap_icon_remove_radius("Cargo_Ship_Center", SYNC_LOCAL) 
  4251. 		m09_clear_seconodary_objective(SYNC_LOCAL)	 
  4252. 	elseif human == REMOTE_PLAYER then 
  4253. 		minimap_icon_remove_radius("Cargo_Ship_Center", SYNC_REMOTE) 
  4254. 		m09_clear_seconodary_objective(SYNC_REMOTE)	 
  4255. 	end 
  4256. end 
  4257.  
  4258. function m09_fail_ship_abandoned_cb(human, trigger) 
  4259. 	-- TOOD: End Mission Failure 
  4260. 	mission_end_failure("m09", "m09_failure_ship_abandoned") 
  4261. end 
  4262.  
  4263. -- Returns a gril crate that was just opened, or "" if one isn't found 
  4264. -- 
  4265. function m09_just_opened_girls_crate() 
  4266. 	for key, crate in pairs(M09_girl_crate) do 
  4267. 		if crate.just_opened == true then 
  4268. 			return crate 
  4269. 		end 
  4270. 	end 
  4271. 	 
  4272. 	return "" 
  4273. end 
  4274.  
  4275. -- Tells a group of NPCs to perform a scripted move and block until the path is complete. 
  4276. -- 
  4277. -- npcs				- Table of npcs to move 
  4278. -- dest				- Destination nav point 
  4279. -- should_run		- Should the NPCs run to the destination? 
  4280. -- dist_tolerance	- Distance the destination the NPC must be within for the path to be considered complete 
  4281. -- max_sec			- Max amount of time, in seconds, the npcs are allowed to pathfind for 
  4282. -- 
  4283. function m09_do_scripted_move(npcs, dest, should_run, dist_tolerance, max_sec) 
  4284. 	local active = {} 
  4285.  
  4286. 	-- Tell all NPCs to move to the specified point 
  4287. 	for key, npc in pairs(npcs) do 
  4288. 		ai_do_scripted_move(npc, dest, should_run, false) 
  4289. 		active[key] = npc 
  4290. 	end 
  4291. 	 
  4292. 	local sec = 0 
  4293. 	while sizeof_table(active) > 0 do 
  4294. 		thread_yield() 
  4295. 		 
  4296. 		for key, npc in pairs(active) do 
  4297. 			if not ai_scripted_action_is_processing(npc) or get_dist(npc, dest) <= dist_tolerance then 
  4298. 				active[key] = nil 
  4299. 			end 
  4300. 		end 
  4301. 		 
  4302. 		sec = sec + get_frame_time() 
  4303. 		if sec > max_sec then 
  4304. 			break 
  4305. 		end 
  4306. 	end 
  4307. 	 
  4308. 	for key, npc in pairs(npcs) do 
  4309. 		ai_clear_scripted_action(npc) 
  4310. 	end 
  4311. end 
  4312.  
  4313. --[[ 
  4314. -- Tells Zimos to collect any girls from a crate that was just opened. 
  4315. -- 
  4316. function m09_zimos_go_to_opened_crate() 
  4317. 	local crate = m09_just_opened_girls_crate() 
  4318. 	 
  4319. 	while crate ~= "" do 
  4320. 		-- A crate was just opened. Tell Zimos to go pick up some hoes! 
  4321. 		--m09_do_scripted_move({M09_Zimos}, crate.run_to, true, 1.0, 60.0) 
  4322. 		 
  4323. 		-- Zimos should now be in range of the crate. Have them run to Zimos 
  4324. 		--m09_do_scripted_move(crate.group.members, crate.run_to, true, 1.0, 6.0) 
  4325. 		 
  4326. 		-- Have all of them follow zimos 
  4327. 		for key, girl in pairs(crate.group.members) do 
  4328. 			M09_girls_following[girl] = girl 
  4329. 			set_team(girl, "Playas") 
  4330. 			--npc_leash_to_object(girl, M09_Zimos, 2.0) 
  4331. 			inv_item_remove_all(girl) 
  4332. 		end 
  4333. 		 
  4334. 		crate.just_opened = false 
  4335. 		 
  4336. 		crate = m09_just_opened_girls_crate() 
  4337. 	end 
  4338. end 
  4339. --]] 
  4340.  
  4341. -- Tell Zimos to wander to a near by nav point 
  4342. -- 
  4343. function m09_zimos_move_to_close_nav() 
  4344. 	local dist_to_closest = 1000000.0 
  4345.  
  4346. 	for key, nav in pairs(M09_nav.girls_flee_to) do 
  4347. 		local dist = get_dist(LOCAL_PLAYER, nav) 
  4348. 		if dist < dist_to_closest then 
  4349. 			M09_girls_flee_nav = nav 
  4350. 			dist_to_closest = dist 
  4351. 		end 
  4352. 	end 
  4353. 	 
  4354. 	if dist_to_closest < 3.0 then 
  4355. 		return 
  4356. 	end 
  4357. 	 
  4358. 	-- Is Zimos already there? 
  4359. 	if get_dist(M09_Zimos, M09_girls_flee_nav) < 1.0 then 
  4360. 		return 
  4361. 	end 
  4362. 	 
  4363. 	m09_do_scripted_move({M09_Zimos}, M09_girls_flee_nav, true, 1.0, 5.0) 
  4364. end 
  4365.  
  4366. function m09_girls_follow_zimos_thread() 
  4367. 	local dist = 0.0 
  4368. 	 
  4369. 	while true do	 
  4370. 		for girl in pairs(M09_girls_following) do			 
  4371. 			dist = get_dist(girl, M09_girls_flee_nav) 
  4372. 			if dist > 5.0 then 
  4373. 				if ai_scripted_action_is_processing(girl) == false then 
  4374. 					set_ignore_ai_flag(girl, false) 
  4375. 					set_always_cower_flag(girl, false) 
  4376. 					ai_do_scripted_move(girl, M09_girls_flee_nav, true, false) 
  4377. 				end 
  4378. 			elseif dist < 3.0 then 
  4379. 				if ai_scripted_action_is_processing(girl) then 
  4380. 					ai_clear_scripted_action(girl) 
  4381. 					set_cower_variant(girl, get_random_table_entry(M09_stripper_cower_variants)) 
  4382. 					--set_ignore_ai_flag(girl, true) 
  4383. 					set_always_cower_flag(girl, true) 
  4384. 				end 
  4385. 			end 
  4386. 			--ai_do_scripted_move(girl, closest_nav, true, false) 
  4387. 		end 
  4388. 		delay(0.2) 
  4389. 	end 
  4390. end 
  4391.  
  4392. --[[ 
  4393. -- Checks to see if Zimos has all the girls. If he does, lead them to the heli crate. 
  4394. -- 
  4395. function m09_zimos_maybe_drop_off_girls() 
  4396. 	if M09_zimos_drop_off_girls == false then 
  4397. 		return false 
  4398. 	end 
  4399.  
  4400. 	ai_do_scripted_move(M09_Zimos, M09_trigger.ho_heli_crate.hoes_run_to, true, false) 
  4401. 	 
  4402. 	m09_start_convo_thread(M09_convo.defend_girls) 
  4403. 	 
  4404. 	thread_kill(M09_girls_follow_zimos_thread) 
  4405. 	M09_girls_follow_zimos_thread = INVALID_THREAD_HANDLE 
  4406. 	 
  4407. 	for girl in pairs(M09_girls_following) do 
  4408. 		npc_leash_remove(girl) 
  4409. 		set_ignore_ai_flag(girl, true) 
  4410. 	end 
  4411. 	 
  4412. 	thread_yield() 
  4413. 	 
  4414. 	for girl in pairs(M09_girls_following) do 
  4415. 		local should_run  = true 
  4416. 		local should_fire = false 
  4417. 		ai_do_scripted_move(girl, M09_trigger.ho_heli_crate.hoes_run_to, should_run, should_fire) 
  4418. 	end 
  4419. 	 
  4420. 	return true 
  4421. end 
  4422. --]] 
  4423.  
  4424. function m09_play_cell_convo(convo) 
  4425. 	M09_cur_cell_call = convo.name 
  4426. 	audio_play_for_mission_cellphone(convo.name, convo.cell_receive == true, true, "", "m09_cell_call_ended", m09_get_persona_handle(convo)) 
  4427. 	while M09_cur_cell_call ~= "" do 
  4428. 		thread_yield() 
  4429. 	end 
  4430. end 
  4431.  
  4432. -- Plays a conversation 
  4433. -- 
  4434. -- convo: Conversation to play 
  4435. function m09_play_convo(convo) 
  4436. 	if convo.name ~= "" and convo.name ~= nil then 
  4437. 		if type(convo.name) == "table" then 
  4438. 			if convo.cell_call == true or convo.cell_receive == true then 
  4439. 				m09_play_cell_convo(convo.name) 
  4440. 			else 
  4441. 				local result = m09_play_persona_line(convo.name, true) 
  4442. 				 
  4443. 				-- Proceed with the conversation if the line fails. 
  4444. 				M09_line_failsafe_thread = thread_new("delay", 2.0) 
  4445. 				 
  4446. 				-- Wait for the line to finish. 
  4447. 				delay(0.25) 
  4448. 				if (convo.name.play_2d == true) then 
  4449. 					-- For 2D lines the result we got back is the play ID of the line. 
  4450. 					while (audio_is_playing(result)) do 
  4451. 						thread_yield() 
  4452. 					end 
  4453. 				else 
  4454. 					-- For 3D lines, wait for the human we played it on to stop talking. 
  4455. 					while audio_persona_line_playing(convo.name.character) and not thread_check_done(M09_line_failsafe_thread) do 
  4456. 						thread_yield() 
  4457. 					end 
  4458. 				end 
  4459. 				 
  4460. 				M09_line_failsafe_thread = INVALID_THREAD_HANDLE 
  4461. 			end 
  4462. 		else 
  4463. 			if convo.cell_call == true or convo.cell_receive == true then 
  4464. 				m09_play_cell_convo(convo) 
  4465. 			else 
  4466. 				--local msg_handle = message("Playing Convo: " .. convo.name, 99999999.0) 
  4467. 				if convo.direct == true then 
  4468. 					convo.handle = audio_conversation_load_direct(convo.name) 
  4469. 				else 
  4470. 					convo.handle = audio_conversation_load(convo.name) 
  4471. 				end 
  4472. 				audio_conversation_play(convo.handle) 
  4473. 				audio_conversation_wait_for_end(convo.handle) 
  4474. 				convo.handle = nil 
  4475. 				--message_remove(msg_handle) 
  4476. 			end 
  4477. 		end 
  4478. 	end 
  4479. 	 
  4480. 	if convo.delay ~= nil and convo.delay > 0.01 then 
  4481. 		delay(convo.delay) 
  4482. 	end 
  4483. end 
  4484.  
  4485. -- Unloads a conversation 
  4486. -- 
  4487. -- convo: Conversation to unload 
  4488. function m09_unload_convo(convo) 
  4489. 	if convo.handle == nil then 
  4490. 		return 
  4491. 	end 
  4492. 	 
  4493. 	audio_conversation_end(convo.handle) 
  4494. 	convo.handle = nil 
  4495. end 
  4496.  
  4497. -- Unloads all conversations from the convo table 
  4498. -- 
  4499. function m09_unload_all_convos() 
  4500. 	for convo_key, convo_set in pairs(M09_convo) do 
  4501. 		m09_unload_convo_set(convo_set) 
  4502. 	 
  4503. 		if convo_set.thread ~= INVALID_THREAD_HANDLE then 
  4504. 			thread_kill(convo_set.thread) 
  4505. 		end 
  4506. 	end 
  4507. end 
  4508.  
  4509. -- Iterates through a table of conversations and plays them. 
  4510. -- 
  4511. -- convo_set: Table of conversations 
  4512. -- 
  4513. function m09_play_convo_set(convo_set) 
  4514. 	for key, convo in pairs(convo_set.files) do 
  4515. 		m09_play_convo(convo) 
  4516. 	end 
  4517. end 
  4518.  
  4519. -- Unloads a convo table (array) 
  4520. -- 
  4521. -- convo_set Table of conversations to unload 
  4522. -- 
  4523. function m09_unload_convo_set(convo_set) 
  4524. 	for key, convo in pairs(convo_set.files) do 
  4525. 		m09_unload_convo(convo) 
  4526. 	end 
  4527. end 
  4528.  
  4529. -- Starts an audio conversation as a thread 
  4530. -- 
  4531. -- convo_table: Conversation to play 
  4532. -- 
  4533. function m09_start_convo_thread(convo_table) 
  4534. 	--[[ 
  4535. 	if M09_active_convo ~= "" then 
  4536. 		m09_unload_convo_set(M09_active_convo) 
  4537. 		M09_active_convo = "" 
  4538. 	end 
  4539. 	M09_active_convo = convo_table 
  4540. 	--]] 
  4541. 	convo_table.thread = thread_new("m09_audio_thread", convo_table) 
  4542. end 
  4543.  
  4544. -- Loads the necessary 2D personas for the heli rail sequence 
  4545. -- 
  4546. function m09_load_heli_rail_personas() 
  4547. 	for key, persona in pairs(M09_personas) do 
  4548. 		persona.handle = audio_persona_load_2d(persona.name) 
  4549. 	end 
  4550. end 
  4551.  
  4552. -- Unloads all 2d personas 
  4553. -- 
  4554. function m09_unload_personas() 
  4555. 	for key, persona in pairs(M09_personas) do 
  4556. 		if persona.handle ~= INVALID_PERSONA_HANDLE then 
  4557. 			audio_persona_remove_2d(persona.handle) 
  4558. 			persona.handle = INVALID_PERSONA_HANDLE 
  4559. 		end 
  4560. 	end 
  4561. end 
  4562.  
  4563. -- Gets the 2d persona handle from a character name 
  4564. -- 
  4565. function m09_get_persona_handle(line) 
  4566. 	for key, persona in pairs(M09_personas) do 
  4567. 		if persona.name == line.character then 
  4568. 			return persona.handle 
  4569. 		end 
  4570. 	end 
  4571. 	 
  4572. 	return nil 
  4573. end 
  4574.  
  4575. -- Plays a persona line. 
  4576. -- 
  4577. -- line:                 (string) name of the line to play 
  4578. -- during_conversations: (bool) indicates whether or not this line should play if a conversation is active 
  4579. -- 
  4580. -- returns:               For 2D lines, the play ID of the line is returned, for 3D lines, a boolean 
  4581. --                          indicating whether the line succeeded. 
  4582. -- 
  4583. function m09_play_persona_line(line, during_conversations) 
  4584. 	--message("Playing Persona Line: " .. line.name, 4.0) 
  4585. 	 
  4586. 	-- If there's a conversation playing, then skip this line. 
  4587. 	if M09_active_convo ~= "" then 
  4588. 		if (during_conversations == nil or during_conversations == false) then 
  4589. 			--message("Line aborted:" .. line.name, 2.0) 
  4590. 			return nil 
  4591. 		end 
  4592. 	end 
  4593. 	 
  4594. 	if line.play_2d then 
  4595. 		return audio_play_persona_line_2d(m09_get_persona_handle(line), line.name) 
  4596. 	else 
  4597. 		return audio_play_persona_line(line.character, line.name) 
  4598. 	end 
  4599. end 
  4600.  
  4601. -- ***************                     *************** 
  4602. -- ***************  Crate Callbacks    *************** 
  4603. -- ***************                     *************** 
  4604.  
  4605. -- Start the QTE to open the crate 
  4606. -- 
  4607. -- player:		(string) player opening the crate 
  4608. -- trigger:		(string) trigger being used 
  4609. -- 
  4610. function m09_trigger_crate_cb(player, trigger) 
  4611. 	local is_local = (player == LOCAL_PLAYER) 
  4612. 	for i, crate_set in pairs(M09_crate_sets) do 
  4613. 		for key, crate in pairs(crate_set.crates) do 
  4614. 			if trigger == crate.trigger then 
  4615. 				if is_local then 
  4616. 					M09_local_crate = crate 
  4617. 					-- Clear the trigger first, so that the player can't trigger it again 
  4618. 					-- during a delay in the crate door open function. 
  4619. 					m09_clear_crate_trigger(trigger) 
  4620. 					m09_crate_door_open(crate, true, LOCAL_PLAYER) 
  4621. 				else 
  4622. 					M09_remote_crate = crate 
  4623. 					-- Clear the trigger first, so that the player can't trigger it again 
  4624. 					-- during a delay in the crate door open function. 
  4625. 					m09_clear_crate_trigger(trigger) 
  4626. 					m09_crate_door_open(crate, true, REMOTE_PLAYER) 
  4627. 				end 
  4628. 				return 
  4629. 			end 
  4630. 		end 
  4631. 	end 
  4632. 	--message("ERROR: NO CRATE FOUND", 4.0) 
  4633. end 
  4634.  
  4635. -- local player completed the crate opening QTE 
  4636. -- 
  4637. -- successful:		(boolean) true if QTE was successful 
  4638. -- 
  4639. function m09_crate_door_open_local_cb(successful) 
  4640. 	character_allow_ragdoll(LOCAL_PLAYER, true) 
  4641. 	m09_crate_door_open(M09_local_crate, successful, LOCAL_PLAYER) 
  4642. end 
  4643.  
  4644. -- remote player completed the crate opening QTE 
  4645. -- 
  4646. -- successful:		(boolean) true if QTE was successful 
  4647. -- 
  4648. function m09_crate_door_open_remote_cb(successful) 
  4649. 	character_allow_ragdoll(REMOTE_PLAYER, true) 
  4650. 	m09_crate_door_open(M09_remote_crate, successful, REMOTE_PLAYER) 
  4651. end 
  4652.  
  4653. function m09_destroy_heli_cb(human, trigger) 
  4654. 	if human == "" or human == nil or character_is_in_vehicle(human) == false then 
  4655. 		return 
  4656. 	end 
  4657. 	 
  4658. 	local vehicle = get_char_vehicle_name(human) 
  4659. 	if vehicle == "" or vehicle == nil then 
  4660. 		return 
  4661. 	end 
  4662. 	 
  4663. 	if not vehicle_is_destroyed(vehicle) then 
  4664. 		vehicle_detonate(vehicle) 
  4665. 	end 
  4666. end 
  4667.  
  4668. --[[ 
  4669. -- TODO: Remove after proper homie water interaction is added 
  4670. function m09_player_entered_boat(player, vehicle, seat) 
  4671. 	if not character_is_in_vehicle(M09_Zimos) then 
  4672. 		vehicle_enter_teleport(M09_Zimos, vehicle, 1, true) 
  4673. 	end 
  4674. 	on_vehicle_enter("", LOCAL_PLAYER)	 
  4675. 	delay(1.5) 
  4676. 	m09_start_convo_thread(M09_convo.to_boat) 
  4677. end 
  4678. --]] 
  4679.  
  4680. -- ************************* 
  4681. -- 
  4682. -- Thread functions 
  4683. -- 
  4684. -- ************************* 
  4685.  
  4686. -- Plays Zimos lines comforting the hos. 
  4687. -- 
  4688. function m09_zimos_comforting_hos() 
  4689. 	while true do 
  4690. 		delay(rand_float(10.0, 20.0)) 
  4691. 		if (M09_active_convo ~= "") then 
  4692. 			m09_start_convo_thread(M09_convo.zimos_to_hos) 
  4693. 		end 
  4694. 	end 
  4695. end 
  4696.  
  4697. -- Kill any misc threads 
  4698. -- 
  4699. function m09_kill_all_threads() 
  4700. 	thread_kill(M09_group.girls_heli.thread) 
  4701. 	thread_kill(M09_zimos_girl_thread) 
  4702. 	thread_kill(M09_girls_follow_zimos_thread) 
  4703. 	thread_kill(M09_line_failsafe_thread) 
  4704. 	thread_kill(M09_get_to_south_platform_thread) 
  4705. 	thread_kill(M09_path_end_callback_thread) 
  4706. 	thread_kill(M09_delay_thread) 
  4707. 	thread_kill(M09_failsafe_thread) 
  4708. 	thread_kill(M09_zimos_comforting_hos_thread) 
  4709. end 
  4710.  
  4711. function m09_clear_boat_guards() 
  4712. 	if sizeof_table(M09_enemies_on_the_boat) ~= 0 then 
  4713. 		m09_set_objective(M09_objective.kill_guards) 
  4714. 		while sizeof_table(M09_enemies_on_the_boat) ~= 0 do 
  4715. 			thread_yield() 
  4716. 		end 
  4717. 	end 
  4718. end 
  4719.  
  4720. -- Slows down any boats chasing the helicopter if they get too close. 
  4721. -- 
  4722. -- boat_group:  Table with boat group info. 
  4723. -- 
  4724. function m09_throttle_heli_boats(boat_group) 
  4725. 	while true do 
  4726. 		for i, boat_info in pairs(boat_group.vehicles) do 
  4727. 			if get_dist(boat_info.vehicle, LOCAL_PLAYER, false, true) < M09_chase_boat_min_dist_to_player then 
  4728. 				vehicle_speed_override(boat_info.vehicle, M09_chase_boat_slow_speed) 
  4729. 			else 
  4730. 				vehicle_speed_override(boat_info.vehicle, boat_group.speed) 
  4731. 			end 
  4732. 		end 
  4733. 		 
  4734. 		delay(0.5) 
  4735. 	end 
  4736. end 
  4737.  
  4738. -- Creates a helicopter to attack the ho boat after the player has captured it. 
  4739. -- 
  4740. -- attacker:    (table) attacker information 
  4741. -- 
  4742. function m09_spawn_attack_heli_thread(attacker) 
  4743. 	group_create(attacker.name, true) 
  4744. 	-- make sure the heli exists 
  4745. 	while (vehicle_exists(attacker.vehicle) == false) do 
  4746. 		thread_yield() 
  4747. 	end 
  4748. 	 
  4749. 	-- Put the guys in the heli. 
  4750. 	vehicle_suppress_npc_exit(attacker.vehicle, true) 
  4751. 	vehicle_enter_teleport(attacker.gunner, attacker.vehicle, 4, true) 
  4752. 	vehicle_enter_teleport(attacker.pilot, attacker.vehicle, 0, true) 
  4753. 	 
  4754. 	-- Once everyone is in, set the vehicle as unjackable to prevent RC. 
  4755. 	set_unjackable_flag(attacker.vehicle, true) 
  4756. 	 
  4757. 	on_vehicle_destroyed("m09_attack_heli_destroyed_cb", attacker.vehicle) 
  4758. 	 
  4759. 	-- Mark vehicle as a target. 
  4760. 	marker_add(attacker.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL) 
  4761. 	 
  4762. 	-- Fly the approach path. 
  4763. 	helicopter_fly_to_direct_dont_stop(attacker.vehicle, 20, attacker.approach_path) 
  4764. 	 
  4765. 	-- Have the gunners attack the player. 
  4766. 	ai_add_enemy_target(attacker.gunner, LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE) 
  4767. 	if In_coop then 
  4768. 		ai_add_enemy_target(attacker.gunner, REMOTE_PLAYER, ATTACK_NOW_NEVER_LOSE) 
  4769. 	end 
  4770. 	 
  4771. 	-- Start the heli on its looping path. 
  4772. 	helicopter_set_path_orientation(attacker.vehicle, HELI_PF_LEFT_SIDE_FACE_TARGET) 
  4773. 	helicopter_fly_to_direct_loop(attacker.vehicle, attacker.orbit_speed, attacker.orbit_path) 
  4774. 	 
  4775. 	-- Wait until the chopper is killed. 
  4776. 	while (true) do 
  4777. 		thread_yield() 
  4778. 	end 
  4779. end 
  4780.  
  4781. -- Create attack group, put them in the vehicle (boat), send them to kill the player 
  4782. -- 
  4783. -- attacker:	(table) attacker information 
  4784. -- entry:		(table) entry navpoints 
  4785. -- 
  4786. function m09_spawn_attacker_thread(attacker, entry) 
  4787. 	group_create(attacker.name, true) 
  4788. 	-- make sure the car exists 
  4789. 	while not vehicle_exists(attacker.vehicle) do 
  4790. 		thread_yield() 
  4791. 	end 
  4792. 	-- nobody leaves until I say so 
  4793. 	vehicle_suppress_npc_exit(attacker.vehicle, true) 
  4794. 	vehicle_enter_group_teleport(attacker.members, attacker.vehicle) 
  4795. 	 
  4796. 	-- Once everyone is in, set the vehicle as unjackable to prevent RC. 
  4797. 	set_unjackable_flag(attacker.vehicle, true) 
  4798. 	 
  4799. 	for i, baddie in pairs(attacker.members) do 
  4800. 		if character_is_in_a_driver_seat(baddie) then 
  4801. 			set_ignore_ai_flag(baddie, false) 
  4802. 			npc_hearing_enable(baddie, false) 
  4803. 			npc_combat_enable(baddie, false) 
  4804. 		else 
  4805. 			-- Have the passengers attack the player. 
  4806. 			ai_add_enemy_target(baddie, LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE) 
  4807. 			if In_coop then 
  4808. 				ai_add_enemy_target(baddie, REMOTE_PLAYER, ATTACK_NOW_NEVER_LOSE) 
  4809. 			end 
  4810. 		end 
  4811. 	end 
  4812. 	on_vehicle_destroyed("m09_boat_destroyed_cb", attacker.vehicle) 
  4813. 	 
  4814. 	-- mark vehicle as a target 
  4815. 	marker_add(attacker.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL) 
  4816. 	 
  4817. 	-- Send them to a navpoint (this may need to change to a path when we get boats) 
  4818. 	--vehicle_ignore_repulsors(attacker.vehicle, true) 
  4819. 		 
  4820. 	-- Follow the approach path.  The first guy gets to dock without stopping. 
  4821. 	if (M09_allow_attacker_docking == true) then 
  4822. 		M09_allow_attacker_docking = false 
  4823. 		attacker.is_docking = true 
  4824. 	end 
  4825. 	 
  4826. 	--attacker.pathfind_thread = thread_new("M09_vehicle_pathfind_thread", attacker.vehicle, get_random_table_entry(paths), attacker) 
  4827. 	 
  4828. 	-- Path to the boat, set a speed limit to avoid guys running over one another. 
  4829. 	vehicle_speed_override(attacker.vehicle, 35) 
  4830. 	vehicle_pathfind_to(attacker.vehicle, get_random_table_entry(entry.boat_paths), true, false) 
  4831. 	 
  4832. 	-- Wait until we're free to dock. 
  4833. 	if (attacker.is_docking == false and M09_allow_attacker_docking == false) then 
  4834. 		-- Go into a holding loop until we can dock. 
  4835. 		while (M09_allow_attacker_docking == false) do 
  4836. 			if (attacker.is_jetski) then 
  4837. 				vehicle_speed_override(attacker.vehicle, 30) 
  4838. 				vehicle_pathfind_to(attacker.vehicle, entry.jetski_holding_path, true, false) 
  4839. 			else 
  4840. 				vehicle_speed_override(attacker.vehicle, 40) 
  4841. 				vehicle_pathfind_to(attacker.vehicle, entry.boat_holding_path, true, false) 
  4842. 			end 
  4843. 			thread_yield() 
  4844. 		end 
  4845. 	end 
  4846. 	M09_allow_attacker_docking = false 
  4847. 	attacker.is_docking = true 
  4848. 	 
  4849. 	vehicle_speed_cancel(attacker.vehicle) 
  4850. 	 
  4851. 	-- Approach the dock 
  4852. 	local destination = nil 
  4853. 	if (attacker.drive_boat_back) then 
  4854. 		-- Take the approach path to the destination so we don't end up in a position 
  4855. 		-- where we have to awkwardly back around. 
  4856. 		vehicle_pathfind_to(attacker.vehicle, entry.approach_path, true, true) 
  4857. 		destination = entry.boat_stop 
  4858. 	else 
  4859. 		-- Just drive to the abandon point. 
  4860. 		destination = entry.boat_abandon_stop 
  4861. 		vehicle_pathfind_to(attacker.vehicle, destination, true, true) 
  4862. 	end 
  4863. 	 
  4864. 	-- Get close 
  4865. 	while get_dist(attacker.vehicle, destination) > M09_boat_is_close do 
  4866. 		if attacker.pathfind_thread == INVALID_THREAD_HANDLE then 
  4867. 			m09_cleanup_boat_attacker(attacker) 
  4868. 			M09_allow_attacker_docking = true 
  4869. 			delay(10.0) 
  4870. 			return 
  4871. 		end 
  4872. 		thread_yield() 
  4873. 	end 
  4874. 	 
  4875. 	thread_kill(attacker.pathfind_thread) 
  4876. 	vehicle_stop(attacker.vehicle) 
  4877. 	 
  4878. 	-- vehicle is no longer the problem 
  4879. 	marker_remove(attacker.vehicle) 
  4880. 	on_vehicle_destroyed("", attacker.vehicle)	 
  4881. 	 
  4882. 	-- Let's see what the AI can do for now 
  4883. 	for i, baddie in pairs(attacker.members) do 
  4884. 		if not character_is_dead(baddie) and character_is_in_vehicle(baddie) then 
  4885. 			-- don't let the driver exit if we want to take the boat back 
  4886. 			if not attacker.drive_boat_back or not character_is_in_a_driver_seat(baddie) then 
  4887. 				on_death("m09_attacker_killed_cb", baddie) 
  4888. 				-- target players 
  4889. 				ai_add_enemy_target(baddie, LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE) 
  4890. 				if In_coop then 
  4891. 					ai_add_enemy_target(baddie, REMOTE_PLAYER, ATTACK_NOW_NEVER_LOSE) 
  4892. 				end 
  4893. 				 
  4894. 				-- out of the vehicle 
  4895. 				vehicle_exit_teleport(baddie) 
  4896. 				while character_is_in_vehicle(baddie) do 
  4897. 					thread_yield() 
  4898. 				end 
  4899. 				-- on to the stairs 
  4900. 				teleport(baddie, entry.stairs_nav) 
  4901. 				 
  4902. 				-- Enable AI again 
  4903. 				set_ignore_ai_flag(baddie, false) 
  4904. 				npc_hearing_enable(baddie, true) 
  4905. 				npc_combat_enable(baddie, true) 
  4906. 				 
  4907. 				marker_add(baddie, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  4908. 				M09_enemies_on_the_boat[baddie] = true 
  4909.  
  4910. 				-- go upstairs 
  4911. 				ai_do_scripted_move(baddie, entry.upstairs, true, false) 
  4912. 				on_ai_do_action_complete("m09_advance_on_player", baddie) 
  4913. 				 
  4914. 				-- wait 
  4915. 				delay(0.5) 
  4916. 			end 
  4917. 		else 
  4918. 			if not character_is_dead(baddie) then 
  4919. 				character_kill(baddie) 
  4920. 			end 
  4921. 		end 
  4922. 	end 
  4923. 	 
  4924. 	local driver = vehicle_get_driver(attacker.vehicle) 
  4925. 	 
  4926. 	-- if we didn't tell the driver to get out of the boat, drive it back 
  4927. 	if attacker.drive_boat_back and driver ~= nil and not character_is_dead(driver) and character_is_in_vehicle(driver) then 
  4928. 		attacker.pathfind_thread = thread_new("M09_vehicle_pathfind_thread", attacker.vehicle, get_random_table_entry(entry.drive_back), attacker) 
  4929. 	end 
  4930. 	 
  4931. 	-- Allow the next dude to dock now. 
  4932. 	M09_allow_attacker_docking = true 
  4933. 	attacker.is_docking = false 
  4934. 	 
  4935. 	-- keep this thread going until all of the guys have been released to the world and or killed 
  4936. 	for i, baddie in pairs(attacker.members) do 
  4937. 		if not character_is_in_a_driver_seat(baddie) then 
  4938. 			while character_exists(baddie) and not character_is_dead(baddie) do 
  4939. 				thread_yield() 
  4940. 			end 
  4941. 		end 
  4942. 	end 
  4943. 	 
  4944. 	-- nuke it so we can reuse it 
  4945. 	m09_cleanup_boat_attacker(attacker) 
  4946. end 
  4947.  
  4948. -- Creates and controls a group to attack the boat with a transport helicopter. 
  4949. -- 
  4950. -- attacker:   (table) attacker information. 
  4951. -- 
  4952. function m09_spawn_transport_attack_heli_thread(attacker) 
  4953. 	group_create_hidden(attacker.heli_group.name, true) 
  4954. 	group_create_hidden(attacker.soldier_group.name, true) 
  4955. 	 
  4956. 	-- make sure the heli exists 
  4957. 	while not vehicle_exists(attacker.heli_group.vehicle) do 
  4958. 		thread_yield() 
  4959. 	end 
  4960. 	 
  4961. 	attacker.heli_group.debug_done = false 
  4962. 	 
  4963. 	-- Get everyone in the heli. 
  4964. 	vehicle_enter_teleport(attacker.heli_group.pilot, attacker.heli_group.vehicle, 0) 
  4965. 	--turn_invulnerable(attacker.heli_group.pilot) 
  4966. 	--vehicle_enter_group_teleport(attacker.soldiers, attacker.vehicle) 
  4967. 	 
  4968. 	local seat_idx = 1 
  4969. 	for i, soldier in pairs(attacker.soldier_group.members) do 
  4970. 		vehicle_enter_teleport(soldier, attacker.heli_group.vehicle, seat_idx) 
  4971. 		seat_idx = seat_idx + 1 
  4972. 	end 
  4973. 	 
  4974. 	-- Once everyone is in, set the vehicle as unjackable to prevent RC. 
  4975. 	set_unjackable_flag(attacker.heli_group.vehicle, true) 
  4976. 	 
  4977. 	group_show(attacker.heli_group.name) 
  4978. 	group_show(attacker.soldier_group.name)	 
  4979. 	 
  4980. 	-- Add a merker to the heli. 
  4981. 	marker_add(attacker.heli_group.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL) 
  4982. 	 
  4983. 	-- Clean up the heli if it's destroyed. 
  4984. 	on_vehicle_destroyed("m09_transport_heli_destroyed_cb", attacker.heli_group.vehicle) 
  4985. 	 
  4986. 	 
  4987. 	-- Follow the approach path. 
  4988. 	helicopter_fly_to_direct_dont_stop(attacker.heli_group.vehicle, -1, attacker.heli_group.approach_path) 
  4989.  
  4990. 	-- Slow down and follow the landing path. 
  4991. 	-- directly call to helicopter_fly_to_do because we don't want to wait for completion 
  4992. 	helicopter_fly_to_do(attacker.heli_group.vehicle, 5, true, "", false, attacker.heli_group.land_path) 
  4993. 		 
  4994. 	-- Wait until either the chopper comes to a stop or hits the deck. 
  4995. 	while (get_char_vehicle_is_in_air(attacker.heli_group.pilot) == true and get_vehicle_speed(attacker.heli_group.vehicle) > 1.0) do 
  4996. 		thread_yield() 
  4997. 	end 
  4998. 	 
  4999. 	-- If the helicopter didn't make it to the boat, clean them up. 
  5000. 	if object_is_in_trigger(M09_trigger.on_boat_trigger.name, attacker.heli_group.vehicle) == false then 
  5001. 		m09_cleanup_transport_heli_attacker(attacker) 
  5002. 		return 
  5003. 	end 
  5004. 	 
  5005. 	-- Stop the pathfind. 
  5006. 	helicopter_fly_to_stop(attacker.heli_group.vehicle) 
  5007. 	 
  5008. 	-- Everybody out! 
  5009. 	vehicle_exit_group(attacker.soldier_group.members) 
  5010.  
  5011. 	-- Add markers to all the guys and tell them to attack the player(s). 
  5012. 	for i, baddie in pairs(attacker.soldier_group.members) do 
  5013. 		if character_exists(baddie) and not character_is_dead(baddie) then 
  5014. 			marker_add(baddie, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  5015. 			ai_add_enemy_target(baddie, LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE) 
  5016. 			if In_coop then 
  5017. 				ai_add_enemy_target(baddie, REMOTE_PLAYER, ATTACK_NOW_NEVER_LOSE) 
  5018. 			end 
  5019. 		end 
  5020. 	end 
  5021. 	 
  5022. 	-- Remove the marker from the transport heli and remove it's callback, it's no longer a target. 
  5023. 	marker_remove(attacker.heli_group.vehicle) 
  5024. 	on_vehicle_destroyed("", attacker.heli_group.vehicle) 
  5025. 	 
  5026. 	-- Wait for everyone to get out 
  5027. 	for i, soldier in pairs(attacker.soldier_group.members) do 
  5028. 		while (character_is_in_vehicle(soldier, attacker.heli_group.vehicle)) do 
  5029. 			thread_yield() 
  5030. 		end 
  5031. 	end 
  5032. 	 
  5033. 	delay(2.0) 
  5034. 	 
  5035. 	m09_play_heli_drop_off_convo() 
  5036. 	 
  5037. 	-- Fly the exit path. 
  5038. 	helicopter_fly_to_direct_dont_stop(attacker.heli_group.vehicle, -1, attacker.heli_group.exit_path) 
  5039. 	 
  5040. 	-- Run away! 
  5041. 	helicopter_enter_retreat(attacker.heli_group.vehicle) 
  5042. 	 
  5043. 	-- Release the guy so he can be destroyed when out of range. 
  5044. 	release_to_world(attacker.heli_group.name) 
  5045. 	 
  5046. 	-- Wait until all the attackers are dead. 
  5047. 	for i, baddie in pairs(attacker.soldier_group.members) do 
  5048. 		while character_exists(baddie) and not character_is_dead(baddie) do 
  5049. 			thread_yield() 
  5050. 		end 
  5051. 	end 
  5052. 	 
  5053. 	attacker.heli_group.debug_done = true 
  5054. end 
  5055.  
  5056. -- When a scripted action is completed, tell the AI to advance on the player 
  5057. -- 
  5058. -- npc:  (string) name of the NPC that completed their action. 
  5059. -- 
  5060. function m09_advance_on_player(npc) 
  5061. 	on_ai_do_action_complete("", (npc)) 
  5062. 	 
  5063. 	local target = LOCAL_PLAYER 
  5064. 	if (In_coop and rand_int(1, 2) == 2) then 
  5065. 		target = REMOTE_PLAYER 
  5066. 	end 
  5067. 	 
  5068. 	local closest_nav = nil 
  5069. 	local closest_dist = 99999 
  5070. 	for i, pos in pairs(M09_nav.boat_advance_positions) do 
  5071. 		local dist = get_dist(target, pos) 
  5072. 		if (dist < closest_dist) then 
  5073. 			closest_dist = dist 
  5074. 			closest_nav = pos 
  5075. 		end 
  5076. 	end 
  5077. 	 
  5078. 	ai_attack_region(npc, closest_nav, 20.0) 
  5079. end 
  5080.  
  5081. -- pathfind to a destination 
  5082. -- 
  5083. -- vehicle:		(string) name of vehicle 
  5084. -- navpoint:	(string) name of navpoint to pathfind to 
  5085. -- 
  5086. function M09_vehicle_pathfind_thread(vehicle, navpoint, handle_table) 
  5087. 	local stop_at_goal = true 
  5088. 	 
  5089. 	local nav_table = nil 
  5090. 	 
  5091. 	-- If we passed in a single path, make a table out of it. 
  5092. 	if type(navpoint) == "string" then 
  5093. 		nav_table = {navpoint} 
  5094. 	else 
  5095. 		nav_table = navpoint 
  5096. 	end 
  5097. 	 
  5098. 	-- Pathfind along each path in the table. 
  5099. 	for i, nav in pairs(nav_table) do 
  5100. 		if i < sizeof_table(nav_table) then 
  5101. 			stop_at_goal = false 
  5102. 		else 
  5103. 			stop_at_goal = true 
  5104. 		end 
  5105.  
  5106. 		local path_done = 0 
  5107. 		if vehicle_pathfind_navmesh_do(vehicle,nav, false, stop_at_goal, true, 0) == false then 
  5108. 			path_done = 1 
  5109. 		end 
  5110.  
  5111. 		while ( path_done == 0) do 
  5112. 			thread_yield() 
  5113. 			path_done = vehicle_is_destroyed(vehicle) or vehicle_pathfind_check_done(vehicle) 
  5114. 		end 
  5115. 		 
  5116. 		if vehicle_is_destroyed(vehicle) then 
  5117. 			break 
  5118. 		end 
  5119. 	end 
  5120. 	 
  5121. 	if handle_table ~= nil then 
  5122. 		handle_table.pathfind_thread = INVALID_THREAD_HANDLE 
  5123. 	end 
  5124. end 
  5125.  
  5126. -- fly a path 
  5127. -- 
  5128. -- vehicle:		(string) name of vehicle 
  5129. -- speed:		(float) speed to fly 
  5130. -- path:		(path or navpoint) path to fly 
  5131. -- 
  5132. function m09_fly_path_thread( vehicle, speed, path ) 
  5133. 	helicopter_fly_to_direct(vehicle, speed, path) 
  5134. end 
  5135.  
  5136. -- fly through a set of path segments 
  5137. -- 
  5138. -- vehicle:		(string) name of the vehicle 
  5139. -- path_set:	(table) table with a speed and path member 
  5140. -- 
  5141. function m09_fly_path_set_thread( vehicle, path_set ) 
  5142. 	local segments_left = sizeof_table(path_set) 
  5143. 	for key, segment in pairs(path_set) do 
  5144. 		--message("Path: " .. segment.path .. " Speed: " .. segment.speed, 2.0) 
  5145. 		if segments_left > 1 then 
  5146. 			helicopter_fly_to_direct_dont_stop(vehicle, segment.speed, segment.path) 
  5147. 			segments_left = segments_left - 1 
  5148. 		else 
  5149. 			helicopter_fly_to_direct(vehicle, segment.speed, segment.path) 
  5150. 		end 
  5151. 	end 
  5152. end 
  5153.  
  5154. -- Have Zimos collect any girls and hang back out of the player's way 
  5155. -- 
  5156. function m09_zimos_girl_behavior_thread() 
  5157. 	-- Don't allow Zimos to die. 
  5158. 	turn_invulnerable(M09_Zimos) 
  5159. 	 
  5160. 	while true do 
  5161. 		if M09_girls_flee_nav ~= "" then 
  5162. 			local dist = get_dist(M09_Zimos, M09_girls_flee_nav) 
  5163. 			if dist > 10.0 then 
  5164. 				npc_leash_remove(M09_Zimos) 
  5165. 				ai_do_scripted_move(M09_Zimos, M09_girls_flee_nav, true, false) 
  5166. 			elseif dist < 5.0 then 
  5167. 				npc_leash_to_nav(M09_Zimos, M09_girls_flee_nav, 3.0) 
  5168. 			end 
  5169. 		end 
  5170. 		 
  5171. 		delay(0.5) 
  5172. 	end 
  5173. 	 
  5174. 	M09_zimos_girl_thread = INVALID_THREAD_HANDLE 
  5175. end 
  5176.  
  5177. -- Play a audio conversation 
  5178. -- 
  5179. -- convo_table: Table of the audio conversation files to play 
  5180. -- 
  5181. function m09_audio_thread(convo_table) 
  5182. 	if (M09_active_convo ~= "") then 
  5183. 		-- Wait for the current conversation to end. 
  5184. 		while (M09_active_convo ~= "") do 
  5185. 			thread_yield() 
  5186. 		end 
  5187. 		M09_active_convo = convo_table 
  5188. 		 
  5189. 		-- Delay a moment before starting the next conversation. 
  5190. 		delay(2.0) 
  5191. 	end 
  5192. 	 
  5193. 	M09_active_convo = convo_table 
  5194. 	m09_play_convo_set(convo_table) 
  5195. 	convo_table.thread = INVALID_THREAD_HANDLE 
  5196. 	M09_active_convo = "" 
  5197. end 
  5198.