./m13.lua

  1. --[[ 
  2. 	m13.lua 
  3. 	SR3 Mission Script 
  4. 	DATE: 09-13-2010 
  5. 	AUTHOR:	Craig Williams 
  6. ]]-- 
  7.  
  8.  
  9. -- Debug flags -- 
  10. 	M13_ENABLE_BINKS = true 
  11.  
  12. -- Tweakable Parameters -- 
  13. 	M13_config = { 
  14. 		-- PR Center settings 
  15. 		min_notoriety_after_banner_damaged			= 1, 
  16. 		min_notoriety_after_banner_destroyed		= 2, 
  17. 		min_notoreity_after_all_banners_destroyed	= 3, 
  18.  
  19. 		-- Chain reaction settings 
  20. 		chain_reaction_max_dist		= 40.00, -- Radius of the chain reaction effect from a car bomb 
  21. 		chain_reaction_delay			=  3.00, -- Delay in seconds to wait before a chain reaction detonates another car bomb 
  22. 		chain_reaction_scale_delay	=  true, -- True to scale the delay. Closer bombs will go off sooner then farther ones. 
  23. 		chain_reaction_scale_mul	=  1.00, -- Scales the amount of delay based off the distance 
  24.  
  25. 		-- Wave specific settings 
  26. 		saints_hq_radius				=  75.0, -- Distance in meters that the player is allowed to get away from the Saints HQ enterance 
  27. 		saints_hq_radius_warn		=  50.0, -- Distance to warn the player if they are getting to far away from the HQ 
  28.  
  29. 		-- Decision scene settings 
  30. 		time_to_escape					=  30.0, -- Time, in seconds, that the player has to escape the penthouse 
  31. 		fov_to_shaundi					=  15.0, -- Field of view in degrees to use to check if Shaundi is in the player's view 
  32. 		fov_to_cyrus					=  20.0, -- Field of view in degrees to use to check if Cyrus is in the player's view 
  33.  
  34. 		-- Temporary weapon settings 
  35. 		grenade 							= "molotov", 
  36. 		airstrike 						= "Special-Airstrike", 
  37. 	} 
  38.  
  39. -- Non-Respawning Groups -- 
  40. 	-- List of all non-wave related groups in the mission 
  41. 	M13_groups = { 
  42. 		vehicles_start = { 
  43. 			name 		= "group_vehicles_start", 
  44. 			vehicles = { "vehicle_start 001", "vehicle_start 002" } 
  45. 		}, 
  46.  
  47. 		vehicles_cover = { 
  48. 			name		= "group_vehicles_cover", 
  49. 			vehicles = { "vehicle_cover 001", "vehicle_cover 002", "vehicle_cover 003" } 
  50. 		}, 
  51.  
  52. 		pierce_start = { 
  53. 			name		= "group_pierce_start", 
  54. 			pierce	= "npc_pierce_start", 
  55. 			vehicle	= "Script_Vehicle 003", 
  56. 		}, 
  57.  
  58. 		pr_static = { 
  59. 			name		= "group_pr_static", 
  60. 		}, 
  61.  
  62. 		homies = { 
  63. 			name		= "group_homies", 
  64. 			viola		= "npc_viola", 
  65. 			--oleg		= "npc_oleg", 
  66. 		}, 
  67.  
  68. 		weapons = { 
  69. 			name			= "group_weapons", 
  70. 			airstrike	= "weapon_airstrike", 
  71. 		}, 
  72.  
  73. 		pierce_rescue = { 
  74. 			name		= "group_pierce_rescue", 
  75. 			pierce	= "npc_pierce_rescue", 
  76. 			vehicle	= "vehicle_pierce_rescue", 
  77. 			path		= "path_pierce_rescue", 
  78. 		}, 
  79. 		 
  80. 		pierce_attack = { 
  81. 			name 		= "group_pierce_attack", 
  82. 			tank		= "vehicle_pierce_tank", 
  83. 			tank_members = {"npc_pierce_tank_driver", "npc_pierce_tank_gunner",}, 
  84. 			path 		= "path_pierce_attack", 
  85. 		}, 
  86.  
  87. 		penthouse_homies = { 
  88. 			name		= "group_penthouse_homies", 
  89. 			josh		= "npc_josh_penthouse", 
  90. 			shaundi	= "npc_shaundi_penthouse", 
  91. 		}, 
  92.  
  93. 		penthouse_stag = { 
  94. 			name		= "group_penthouse_stag", 
  95. 			cyrus		= "npc_cyrus", 
  96.  
  97. 			vtols = { 
  98. 				{ 
  99. 					name		= "vehicle_vtol 001", 
  100. 					members	= {"npc_vtol 001",}, 
  101. 					nav		= "nav_vtol 001", 
  102. 					nav_fire = "nav_vtol_fire 001", 
  103. 					fly_to	= "", 
  104. 					nav_flee = "nav_vtol 006", 
  105. 					thread	= INVALID_THREAD_HANDLE, 
  106. 					nav_turn_around = "nav_vtol 005", 
  107. 				}, 
  108. 				{ 
  109. 					name		= "vehicle_vtol 002", 
  110. 					members	= {"npc_vtol 006", "npc_vtol 007",}, 
  111. 					nav		= "nav_vtol 002", 
  112. 					nav_fire = "nav_vtol_fire 002", 
  113. 					fly_to	= "nav_vtol 002<001>", 
  114. 					nav_flee = "nav_vtol 007", 
  115. 					thread	= INVALID_THREAD_HANDLE, 
  116. 				}, 
  117. 				{ 
  118. 					name		= "vehicle_vtol 003", 
  119. 					members	= {"npc_vtol 010",}, 
  120. 					nav		= "nav_vtol 003<001>", 
  121. 					nav_fire = "nav_vtol_fire 003", 
  122. 					fly_to	= "nav_vtol 003", 
  123. 					nav_flee = "nav_vtol 009", 
  124. 					thread	= INVALID_THREAD_HANDLE, 
  125. 				}, 
  126. 				{ 
  127. 					name		= "vehicle_vtol 004", 
  128. 					members	= {"npc_vtol 005",}, 
  129. 					nav		= "nav_vtol 004<001>", 
  130. 					nav_fire = "nav_vtol_fire 004", 
  131. 					fly_to	= "nav_vtol 004", 
  132. 					nav_flee = "nav_vtol 008", 
  133. 					thread	= INVALID_THREAD_HANDLE, 
  134. 				}, 
  135. 			}, 
  136. 		}, 
  137. 		 
  138. 		clutter_south = { 
  139. 			name = "grp clutter south",  
  140. 			vehicles = {  
  141. 				"veh_clutter_south_apc <001>", "veh_clutter_south_apc <002>", "veh_clutter_south_apc <003>",  
  142. 				"veh_clutter_south_apc <004>", "veh_clutter_south_apc <005>", "veh_clutter_south_apc <006>",  
  143. 			} 
  144. 		}, 
  145.  
  146. 		clutter_north = { 
  147. 			name = "grp clutter north",  
  148. 			vehicles = {  
  149. 				"veh_clutter_north_apc <001>", "veh_clutter_north_apc <002>", "veh_clutter_north_apc <003>",  
  150. 				"veh_clutter_north_apc <004>", "veh_clutter_north_apc <005>", "veh_clutter_north_apc <006>",  
  151. 			} 
  152. 		}, 
  153.  
  154. 		clutter_general = { 
  155. 			name = "grp clutter general",  
  156. 			vehicles = {  
  157. 				"veh_clutter_general_apc <001>", "veh_clutter_general_apc <002>", "veh_clutter_general_apc <003>",  
  158. 				"veh_clutter_general_apc <004>", "veh_clutter_general_apc <005>", "veh_clutter_general_apc <006>",  
  159. 				"veh_clutter_general_apc <007>", "veh_clutter_general_apc <008>", "veh_clutter_general_apc <009>",  
  160. 				"veh_clutter_general_apc <010>", "veh_clutter_general_apc <011>", "veh_clutter_general_apc <012>",  
  161. 				"veh_clutter_general_apc <013>", "veh_clutter_general_apc <014>", "veh_clutter_general_apc <015>",  
  162. 			} 
  163. 		}, 
  164. 	} 
  165.  
  166. -- Continuous Spawn Groups -- 
  167. 	M13_continuous_spawns = { 
  168. 		-- pr_center_wave_1 = { 
  169. 		-- 	groups	= {"group_pr_spawn 001",}, 
  170. 		-- 	regions	= {"Script_Spawn_Region 004", "Script_Spawn_Region 006",}, 
  171. 		-- 	filter	= SRF_1, 
  172. 		-- 	respawn_delay = 2.0, 
  173. 		-- }, 
  174.  
  175. 		-- pr_center_wave_2 = { 
  176. 		-- 	groups	= {"group_pr_spawn 002", "group_pr_spawn 003",}, 
  177. 		-- 	regions	= {"Script_Spawn_Region 003", "Script_Spawn_Region 005",}, 
  178. 		-- 	filter	= SRF_1, 
  179. 		-- 	respawn_delay = 2.0, 
  180. 		-- }, 
  181.  
  182. 		saints_north_ground = { 
  183. 			groups	= {"group_saints_ground 001", "group_saints_ground 002"}, 
  184. 			regions	= {"Script_Spawn_Region 001",}, 
  185. 			filter	= SRF_1, 
  186. 			respawn_delay = 3.0, 
  187. 		}, 
  188. 			 
  189. 		saints_north_balcony = { 
  190. 			groups	= {"group_saints_ground 003"}, 
  191. 			regions	= {"Script_Spawn_Region 001<001>",}, 
  192. 			filter	= SRF_1, 
  193. 			respawn_delay = 3.0, 
  194. 		}, 
  195. 		 
  196. 		saints_south_ground = { 
  197. 			groups	= {"group_saints_ground 005", "group_saints_ground 006",}, 
  198. 			regions	= {"Script_Spawn_Region 002",}, 
  199. 			filter	= SRF_2, 
  200. 			respawn_delay = 3.0, 
  201. 		}, 
  202. 		 
  203. 		saints_south_balcony = { 
  204. 			groups	= {"group_saints_ground 007"}, 
  205. 			regions	= {"Script_Spawn_Region 001<002>",}, 
  206. 			filter	= SRF_2, 
  207. 			respawn_delay = 3.0, 
  208. 		}, 
  209. 		 
  210. 		stag_deck_01 = { 
  211. 			groups	= { "deck_wave_group 001", "deck_wave_group 002" }, 
  212. 			regions	= { "stag_deck_spn 001", "stag_deck_spn 002", "stag_deck_spn 003", "stag_deck_spn 004" }, 
  213. 			filter	= SRF_3, 
  214. 			respawn_delay = 3.0, 
  215. 		}, 
  216. 		 
  217. 		stag_deck_02 = { 
  218. 			groups	= { "deck_wave_group 003", "deck_wave_group 004" }, 
  219. 			regions	= { "stag_deck_spn 001", "stag_deck_spn 002", "stag_deck_spn 003", "stag_deck_spn 004" }, 
  220. 			filter	= SRF_3, 
  221. 			respawn_delay = 3.0, 
  222. 		}, 
  223. 	} 
  224. 	 
  225. 	M13_passengers_available = { 
  226. --[[		[ "group_passengers_001" ] = { members = { "npc_stag 032", "npc_stag 042", "npc_stag 072", } }, 
  227. 		[ "group_passengers_002" ] = { members = { "npc_stag 082", "npc_stag 112", "npc_stag 122", } }, 
  228. 		[ "group_passengers_003" ] = { members = { "npc_stag 262", "npc_stag 263", "npc_stag 264", } }, 
  229. 		[ "group_passengers_004" ] = { members = { "npc_stag 265", "npc_stag 266", "npc_stag 267", } }, 
  230. 		[ "group_passengers_005" ] = { members = { "npc_stag 268", "npc_stag 269", "npc_stag 270", } }, 
  231. 		[ "group_passengers_006" ] = { members = { "npc_stag 271", "npc_stag 272", "npc_stag 273", } }, 
  232. 		[ "group_passengers_007" ] = { members = { "npc_stag 274", "npc_stag 275", "npc_stag 276", } }, 
  233. 		[ "group_passengers_008" ] = { members = { "npc_stag 277", "npc_stag 278", "npc_stag 279", } }, 
  234. 		[ "group_passengers_009" ] = { members = { "npc_stag 280", "npc_stag 281", "npc_stag 282", } }, ]] 
  235. 	} 
  236. 	 
  237. 	M13_passengers_active = { } 
  238.  
  239. -- Spawn Wave Groups -- 
  240. 	-- name				- Name of the group 
  241. 	-- members			- Script NPCs of the group 
  242. 	-- vehicle			- Vehicle in the group. Set this to "" if there isn't one. 
  243. 	-- initial_delay	- Amount of time to wait before spawning the first iteration of this group 
  244. 	-- respawn_delay	- Amount of time to wait between respawns 
  245. 	-- thread			- Lua thread controlling the group. 
  246. 	M13_spawn_groups = { 
  247. 		apc_001 = { 
  248. 			name		= "group_stag_apc 001", 
  249. 			members	= {"npc_stag 010", "npc_stag 011",}, 
  250. 			vehicle	= "vehicle_apc 001", 
  251. 		}, 
  252. 		apc_002 = { 
  253. 			name		= "group_stag_apc 002", 
  254. 			members	= {"npc_stag 020", "npc_stag 021",}, 
  255. 			vehicle	= "vehicle_apc 002", 
  256. 		}, 
  257. 		apc_003 = { 
  258. 			name		= "group_stag_apc 003", 
  259. 			members	= {"npc_stag 030", "npc_stag 031", }, 
  260. 			vehicle	= "vehicle_apc 003", 
  261. 		}, 
  262. 		apc_004 = { 
  263. 			name		= "group_stag_apc 004", 
  264. 			members	= {"npc_stag 040", "npc_stag 041", }, 
  265. 			vehicle	= "vehicle_apc 004", 
  266. 		}, 
  267. 		apc_005 = { 
  268. 			name		= "group_stag_apc 005", 
  269. 			members	= {"npc_stag 050", "npc_stag 051",}, 
  270. 			vehicle	= "vehicle_apc 005", 
  271. 		}, 
  272. 		apc_006 = { 
  273. 			name		= "group_stag_apc 006", 
  274. 			members	= {"npc_stag 060", "npc_stag 061",}, 
  275. 			vehicle	= "vehicle_apc 006", 
  276. 		}, 
  277. 		apc_007 = { 
  278. 			name		= "group_stag_apc 007", 
  279. 			members	= {"npc_stag 070", "npc_stag 071", }, 
  280. 			vehicle	= "vehicle_apc 007", 
  281. 		}, 
  282. 		apc_008 = { 
  283. 			name		= "group_stag_apc 008", 
  284. 			members	= {"npc_stag 080", "npc_stag 081",}, 
  285. 			vehicle	= "vehicle_apc 008", 
  286. 		}, 
  287. 		apc_009 = { 
  288. 			name		= "group_stag_apc 009", 
  289. 			members	= {"npc_stag 090", "npc_stag 091",}, 
  290. 			vehicle	= "vehicle_apc 009", 
  291. 		}, 
  292. 		apc_010 = { 
  293. 			name		= "group_stag_apc 010", 
  294. 			members	= {"npc_stag 100", "npc_stag 101",}, 
  295. 			vehicle	= "vehicle_apc 010", 
  296. 		}, 
  297. 		apc_011 = { 
  298. 			name		= "group_stag_apc 011", 
  299. 			members	= {"npc_stag 110", "npc_stag 111", }, 
  300. 			vehicle	= "vehicle_apc 011", 
  301. 		}, 
  302. 		apc_012 = { 
  303. 			name		= "group_stag_apc 012", 
  304. 			members	= {"npc_stag 120", "npc_stag 121",}, 
  305. 			vehicle	= "vehicle_apc 012", 
  306. 		}, 
  307. 		apc_013 = { 
  308. 			name		= "group_stag_apc 013", 
  309. 			members	= {"npc_stag 130", "npc_stag 131",}, 
  310. 			vehicle	= "vehicle_apc 013", 
  311. 		}, 
  312. 		apc_014 = { 
  313. 			name		= "group_stag_apc 014", 
  314. 			members	= {"npc_stag 140", "npc_stag 141",}, 
  315. 			vehicle	= "vehicle_apc 014", 
  316. 		}, 
  317. 		apc_015 = { 
  318. 			name		= "group_stag_apc 015", 
  319. 			members	= {"npc_stag 150", "npc_stag 151",}, 
  320. 			vehicle	= "vehicle_apc 015", 
  321. 		}, 
  322. 		apc_016 = { 
  323. 			name		= "group_stag_apc 016", 
  324. 			members	= {"npc_stag 160", "npc_stag 161",}, 
  325. 			vehicle	= "vehicle_apc 016", 
  326. 		}, 
  327. 		apc_017 = { 
  328. 			name		= "group_stag_apc 017", 
  329. 			members	= {"npc_stag 170", "npc_stag 171",}, 
  330. 			vehicle	= "vehicle_apc 017", 
  331. 		}, 
  332. 		apc_018 = { 
  333. 			name		= "group_stag_apc 018", 
  334. 			members	= {"npc_stag 180", "npc_stag 181",}, 
  335. 			vehicle	= "vehicle_apc 018", 
  336. 		}, 
  337. 		apc_019 = { 
  338. 			name		= "group_stag_apc 019", 
  339. 			members	= {"npc_stag 190", "npc_stag 191",}, 
  340. 			vehicle	= "vehicle_apc 019", 
  341. 		}, 
  342. 		apc_020 = { 
  343. 			name		= "group_stag_apc 020", 
  344. 			members	= {"npc_stag 200", "npc_stag 201",}, 
  345. 			vehicle	= "vehicle_apc 020", 
  346. 		}, 
  347. 		apc_021 = { 
  348. 			name		= "group_stag_apc 021", 
  349. 			members	= {"npc_stag 210", "npc_stag 211",}, 
  350. 			vehicle	= "vehicle_apc 021", 
  351. 		}, 
  352. 		apc_022 = { 
  353. 			name		= "group_stag_apc 022", 
  354. 			members	= {"npc_stag 220", "npc_stag 221",}, 
  355. 			vehicle	= "vehicle_apc 022", 
  356. 		}, 
  357. 		apc_023 = { 
  358. 			name		= "group_stag_apc 023", 
  359. 			members	= {"npc_stag 230", "npc_stag 231",}, 
  360. 			vehicle	= "vehicle_apc 023", 
  361. 		}, 
  362. 		apc_024 = { 
  363. 			name		= "group_stag_apc 024", 
  364. 			members	= {"npc_stag 240", "npc_stag 241",}, 
  365. 			vehicle	= "vehicle_apc 024", 
  366. 		}, 
  367. 		apc_025 = { 
  368. 			name		= "group_stag_apc 025", 
  369. 			members	= {"npc_stag 250", "npc_stag 251",}, 
  370. 			vehicle	= "vehicle_apc 025", 
  371. 		}, 
  372. 		apc_026 = { 
  373. 			name		= "group_stag_apc 026", 
  374. 			members	= {"npc_stag 260", "npc_stag 261",}, 
  375. 			vehicle	= "vehicle_apc 026", 
  376. 		}, 
  377. 		heli_001 = { 
  378. 			name		= "group_stag_heli 001", 
  379. 			members	= {"npc_heli 010", "npc_heli 011"}, 
  380. 			vehicle	= "vehicle_heli 001", 
  381. 		}, 
  382. 		heli_002 = { 
  383. 			name		= "group_stag_heli 002", 
  384. 			members	= {"npc_heli 020", "npc_heli 021"}, 
  385. 			vehicle	= "vehicle_heli 002", 
  386. 		}, 
  387. 		heli_003 = { 
  388. 			name		= "group_stag_heli 003", 
  389. 			members	= {"npc_heli 030", "npc_heli 031"}, 
  390. 			vehicle	= "vehicle_heli 003", 
  391. 		}, 
  392.  
  393. 		tank_001 = { 
  394. 			name		= "group_stag_tank 001", 
  395. 			members	= {"npc_tank 010", "npc_tank 011"}, 
  396. 			vehicle	= "vehicle_tank 001", 
  397. 		}, 
  398. 		tank_002 = { 
  399. 			name		= "group_stag_tank 002", 
  400. 			members	= {"npc_tank 020", "npc_tank 021"}, 
  401. 			vehicle	= "vehicle_tank 002", 
  402. 		}, 
  403. 		tank_003 = { 
  404. 			name		= "group_stag_tank 003", 
  405. 			members	= {"npc_tank 030", "npc_tank 031"}, 
  406. 			vehicle	= "vehicle_tank 003", 
  407. 		}, 
  408.  
  409. 		snipers_001 = { 
  410. 			name		= "group_stag_snipers 001", 
  411. 			members	= {"npc_sniper 010", "npc_sniper 011"}, 
  412. 			vehicle	= "", 
  413. 		}, 
  414. 		snipers_002 = { 
  415. 			name		= "group_stag_snipers 002", 
  416. 			members	= {"npc_sniper 020", "npc_sniper 021"}, 
  417. 			vehicle	= "", 
  418. 		}, 
  419. 		snipers_003 = { 
  420. 			name		= "group_stag_snipers 003", 
  421. 			members	= {"npc_sniper 030", "npc_sniper 031", "npc_sniper 032"}, 
  422. 			vehicle	= "", 
  423. 		}, 
  424. 		deck_001 = { 
  425. 			name		= "group_stag_deck 001", 
  426. 			members	= { "stag_viola_deck 001", "stag_viola_deck 002", "stag_viola_deck 003" }, 
  427. 			vehicle	= "", 
  428. 		}, 
  429. 		deck_002 = { 
  430. 			name		= "group_stag_deck 002", 
  431. 			members	= { "stag_deck_end 001", "stag_deck_end 002", "stag_deck_end 003" }, 
  432. 			vehicle	= "", 
  433. 		}, 
  434. 	} 
  435.  
  436. 	-- List of spawn locations a group can start at and the path(s) from the spawn point to the Saints HQ enterance 
  437. 	-- Expected members: 
  438. 	-- 	nav	- Name of the nave point to teleport the group to 
  439. 	-- 	path	- Path to follow to the Saints HQ 
  440. 	M13_spawn_points = { 
  441. 		drop_off_north = { 
  442. 			{nav = "nav_spawn <001>", path = "path <001>", flee = "",}, {nav = "nav_spawn <002>", path = "path <002>", flee = "",}, 
  443. 			{nav = "nav_spawn <003>", path = "path <003>", flee = "",}, {nav = "nav_spawn <004>", path = "path <004>", flee = "",}, 
  444. 			{nav = "nav_spawn <005>", path = "path <005>", flee = "",}, {nav = "nav_spawn <006>", path = "path <006>", flee = "",}, 
  445. 			{nav = "nav_spawn <007>", path = "path <007>", flee = "",}, {nav = "nav_spawn <008>", path = "path <008>", flee = "",}, 
  446. 			{nav = "nav_spawn <009>", path = "path <009>", flee = "",}, {nav = "nav_spawn <010>", path = "path <010>", flee = "",}, 
  447. 			{nav = "nav_spawn <011>", path = "path <011>", flee = "",}, {nav = "nav_spawn <012>", path = "path <012>", flee = "",}, 
  448. 			{nav = "nav_spawn <013>", path = "path <013>", flee = "",}, {nav = "nav_spawn <014>", path = "path <014>", flee = "",}, 
  449. 			{nav = "nav_spawn <015>", path = "path <015>", flee = "",}, 
  450. 		}, 
  451. 		 
  452. 		drop_off_south = { 
  453. 			{nav = "nav_spawn <016>", path = "path <016>", flee = "",}, {nav = "nav_spawn <017>", path = "path <017>", flee = "",}, 
  454. 			{nav = "nav_spawn <018>", path = "path <018>", flee = "",}, {nav = "nav_spawn <019>", path = "path <019>", flee = "",}, 
  455. 			{nav = "nav_spawn <020>", path = "path <020>", flee = "",}, {nav = "nav_spawn <021>", path = "path <021>", flee = "",}, 
  456. 		}, 
  457. 		 
  458. 		scene_5_drop_off = { 
  459. 			{nav = "nav_spawn <022>", path = "path <022>", flee = "",}, {nav = "nav_spawn <023>", path = "path <023>", flee = "",}, 
  460. 		}, 
  461. 		 
  462. 		flee_north = { 
  463. 			{nav = "nav_spawn <007>", path = "path <007>", flee = "flee_path <007>",}, {nav = "nav_spawn <013>", path = "path <013>", flee = "flee_path <008>",}, 
  464. 			{nav = "nav_spawn <005>", path = "path <005>", flee = "flee_path <009>",}, {nav = "nav_spawn <012>", path = "path <012>", flee = "flee_path <007>",}, 
  465. 			{nav = "nav_spawn <001>", path = "path <001>", flee = "flee_path <008>",}, {nav = "nav_spawn <006>", path = "path <006>", flee = "flee_path <009>",}, 
  466. 		}, 
  467. 		 
  468. 		flee_south = { 
  469. 			{nav = "nav_spawn <016>", path = "path <016>", flee = "flee_path <002>",}, {nav = "nav_spawn <017>", path = "path <017>", flee = "flee_path <001>",}, 
  470. 			{nav = "nav_spawn <018>", path = "path <018>", flee = "flee_path <003>",}, {nav = "nav_spawn <019>", path = "path <019>", flee = "flee_path <005>",}, 
  471. 			{nav = "nav_spawn <020>", path = "path <020>", flee = "flee_path <004>",}, {nav = "nav_spawn <021>", path = "path <021>", flee = "flee_path <006>",}, 
  472. 		}, 
  473.  
  474. 		heli_west_01 = { 
  475. 			{nav = "nav_heli 001", path = { "path_heli 001a", "path_heli 001b" }, flee = "",}, 
  476. 		}, 
  477. 		 
  478. 		heli_west_02 = { 
  479. 			{nav = "nav_heli 003", path = "path_heli 003", flee = "flee_path_heli",}, 
  480. 		}, 
  481. 		 
  482. 		heli_west_03 = { 
  483. 			{nav = "nav_heli 004", path = "path_heli 004", flee = "flee_path_heli",}, 
  484. 		}, 
  485.  
  486. 		heli_east_01 = { 
  487. 			{nav = "nav_heli 002", path = "path_heli 002", flee = "",}, 
  488. 		}, 
  489. 		 
  490. 		heli_east_02 = { 
  491. 			{nav = "nav_heli 005", path = "path_heli 005", flee = "",}, 
  492. 		}, 
  493. 		 
  494. 		heli_fake = { 
  495. 			{nav = "nav_heli 006", path = "path_heli 006", flee = "flee_path_heli",}, 
  496. 			{nav = "nav_heli 007", path = "path_heli 007", flee = "flee_path_heli",},			 
  497. 			{nav = "nav_heli 008", path = "path_heli 008", flee = "flee_path_heli",}, 
  498. 		}, 
  499. 		 
  500. 		dummy = {nav = "", path = "", flee = "",}, 
  501. 	} 
  502.  
  503. -- Spawn Waves -- 
  504. 	-- Expected members: 
  505. 	--   groups - Table with the following members 
  506. 	--      group       - M13_spawn_groups table to spawn 
  507. 	--      spawn_point - Nav point and path the group will follow 
  508. 	-- 
  509. 	--   initial_delay    - Delay before the first group is spawned 
  510. 	--   next_group_delay - Amount of time to wait before spawning the next group 
  511. 	--   release_delay    - Amount of time to wait after a group has completed it's path before releasing and moving on to the next group. 
  512. 	--                      Ignored if required_kill is set to true 
  513. 	--   required_kill    - Flag the group with a kill icon 
  514. 	--   repeat_wave      - Loop through the group until the wave is stopped. 
  515. 	--                      Ignored if required_kill is set to true 
  516. 	--   thread           - Thread managing the wave 
  517. 	M13_wave_states = { 
  518. 		invalid								= 0, 
  519. 		spawning						= 1, 
  520. 		pathfinding					= 2, 
  521. 		release_delay			= 3, 
  522. 		next_group_delay	= 4, 
  523. 		complete						= 5, 
  524. 	} 
  525. 	 
  526. 	M13_wave_templates = { 
  527. 		scene_1 = { 
  528. 			vehicle_speed		= 35.0, 
  529. 			initial_delay		=  0.0, 
  530. 			next_group_delay	=  1.0, 
  531. 			release_delay		= -1.0, -- negative number to never release 
  532. 			required_kill		= false, 
  533. 			repeat_wave			= false, 
  534. 			thread				= INVALID_THREAD_HANDLE, 
  535. 			state					= M13_wave_states.invalid, 
  536. 		}, 
  537. 		scene_2 = { 
  538. 			vehicle_speed		= 35.0, 
  539. 			initial_delay		=  0.0, 
  540. 			next_group_delay	=  0.0, 
  541. 			release_delay		= -1.0, 
  542. 			required_kill		= false, 
  543. 			repeat_wave			= false, 
  544. 			thread				= INVALID_THREAD_HANDLE, 
  545. 			state					= M13_wave_states.invalid, 
  546. 		}, 
  547. 		scene_2_deck = { 
  548. 			vehicle_speed		= 0.0, 
  549. 			initial_delay		= 0.0, 
  550. 			next_group_delay	= 5.0, 
  551. 			release_delay		= 0.0, 
  552. 			required_kill		= true, 
  553. 			repeat_wave			= false, 
  554. 			attack_target = M13_groups.homies.viola, 
  555. 			thread				= INVALID_THREAD_HANDLE, 
  556. 			state					= M13_wave_states.invalid, 
  557. 		}, 
  558. 		scene_3_snipers = { 
  559. 			vehicle_speed		= 0.0, 
  560. 			initial_delay		= 0.0, 
  561. 			next_group_delay	= 2.0, 
  562. 			release_delay		= 0.0, 
  563. 			required_kill		= true, 
  564. 			repeat_wave			= false, 
  565. 			thread				= INVALID_THREAD_HANDLE, 
  566. 			state					= M13_wave_states.invalid, 
  567. 		}, 
  568. 		scene_4_tanks = { 
  569. 			vehicle_speed		= 35.0, 
  570. 			initial_delay		= 5.0, 
  571. 			next_group_delay	= 5.0, 
  572. 			release_delay		= 0.0, 
  573. 			required_kill		= true, 
  574. 			repeat_wave			= false, 
  575. 			thread				= INVALID_THREAD_HANDLE, 
  576. 			state					= M13_wave_states.invalid, 
  577. 		}, 
  578. 		scene_5_drop_off = { 
  579. 			vehicle_speed		= 35.0, 
  580. 			initial_delay		= 0.0, 
  581. 			next_group_delay	= 5.0, 
  582. 			release_delay		= -1.0, 
  583. 			required_kill		= false, 
  584. 			repeat_wave			= false, 
  585. 			thread				= INVALID_THREAD_HANDLE, 
  586. 			state					= M13_wave_states.invalid, 
  587. 		}, 
  588. 		scene_6_tanks = { 
  589. 			vehicle_speed		= 35.0, 
  590. 			initial_delay		= 0.0, 
  591. 			next_group_delay	= 3.0, 
  592. 			release_delay		= 0.0, 
  593. 			required_kill		= true, 
  594. 			repeat_wave			= false, 
  595. 			thread				= INVALID_THREAD_HANDLE, 
  596. 			state					= M13_wave_states.invalid, 
  597. 		}, 
  598. 		scene_6_vtol = { 
  599. 			vehicle_speed		= 0.0, 
  600. 			initial_delay		= 0.0, 
  601. 			next_group_delay	= 5.0, 
  602. 			release_delay		= 0.0, 
  603. 			required_kill		= true, 
  604. 			repeat_wave			= false, 
  605. 			thread				= INVALID_THREAD_HANDLE, 
  606. 			state					= M13_wave_states.invalid, 
  607. 		}, 
  608. 		scene_6_vtol_xtra = { 
  609. 			vehicle_speed		= 0.0, 
  610. 			initial_delay		= 0.0, 
  611. 			next_group_delay	= 5.0, 
  612. 			release_delay		= 0.0, 
  613. 			required_kill		= false, 
  614. 			repeat_wave			= false, 
  615. 			thread				= INVALID_THREAD_HANDLE, 
  616. 			state					= M13_wave_states.invalid, 
  617. 		}, 
  618. 		scene_6_snipers = { 
  619. 			vehicle_speed		= 0.0, 
  620. 			initial_delay		= 0.0, 
  621. 			next_group_delay	= 0.0, 
  622. 			release_delay		= 0.0, 
  623. 			required_kill		= true, 
  624. 			repeat_wave			= false, 
  625. 			thread				= INVALID_THREAD_HANDLE, 
  626. 			state					= M13_wave_states.invalid, 
  627. 		}, 
  628. 		scene_7_deck = { 
  629. 			vehicle_speed		=  0.0, 
  630. 			initial_delay		=  0.0, 
  631. 			next_group_delay	=  0.0, 
  632. 			release_delay		= -1.0, 
  633. 			required_kill		= true, 
  634. 			repeat_wave			= false, 
  635. 			thread				= INVALID_THREAD_HANDLE, 
  636. 			state					= M13_wave_states.invalid, 
  637. 		}, 
  638. 		apcs_ambient = { 
  639. 			vehicle_speed		= 50.0, 
  640. 			initial_delay		=  0.0, 
  641. 			next_group_delay	=  0.0, 
  642. 			release_delay		= 25.0, 
  643. 			required_kill		= false, 
  644. 			repeat_wave			= true, 
  645. 			thread				= INVALID_THREAD_HANDLE, 
  646. 			state					= M13_wave_states.invalid, 
  647. 		}, 
  648. 	} 
  649.  
  650. 	M13_waves = { 
  651. 		apcs_north_1 = { 
  652. 			{groups = { {group = M13_spawn_groups.apc_001, spawn_point = M13_spawn_points.flee_north[ 1],},}, initial_delay = 0.0, template = M13_wave_templates.apcs_ambient}, 
  653. 			{groups = { {group = M13_spawn_groups.apc_002, spawn_point = M13_spawn_points.flee_north[ 2],},}, initial_delay = 2.0, template = M13_wave_templates.apcs_ambient}, 
  654. 		}, 
  655. 		apcs_north_2 = { 
  656. 			{groups = { {group = M13_spawn_groups.apc_003, spawn_point = M13_spawn_points.flee_north[ 3],},}, initial_delay = 4.0, template = M13_wave_templates.apcs_ambient}, 
  657. 			{groups = { {group = M13_spawn_groups.apc_004, spawn_point = M13_spawn_points.flee_north[ 4],},}, initial_delay = 6.0, template = M13_wave_templates.apcs_ambient}, 
  658. 		}, 
  659. 		apcs_north_3 = { 
  660. 			{groups = { {group = M13_spawn_groups.apc_005, spawn_point = M13_spawn_points.flee_north[ 5],},}, initial_delay = 8.0, template = M13_wave_templates.apcs_ambient}, 
  661. 			{groups = { {group = M13_spawn_groups.apc_006, spawn_point = M13_spawn_points.flee_north[ 6],},}, initial_delay =10.0, template = M13_wave_templates.apcs_ambient}, 
  662. 		}, 
  663. 		apcs_south_1 = { 
  664. 			{groups = { {group = M13_spawn_groups.apc_007, spawn_point = M13_spawn_points.flee_south[ 1],},}, initial_delay = 0.0, template = M13_wave_templates.apcs_ambient}, 
  665. 			{groups = { {group = M13_spawn_groups.apc_008, spawn_point = M13_spawn_points.flee_south[ 2],},}, initial_delay = 2.0, template = M13_wave_templates.apcs_ambient}, 
  666. 		}, 
  667. 		apcs_south_2 = { 
  668. 			{groups = { {group = M13_spawn_groups.apc_009, spawn_point = M13_spawn_points.flee_south[ 3],},}, initial_delay = 4.0, template = M13_wave_templates.apcs_ambient}, 
  669. 			{groups = { {group = M13_spawn_groups.apc_010, spawn_point = M13_spawn_points.flee_south[ 4],},}, initial_delay = 6.0, template = M13_wave_templates.apcs_ambient}, 
  670. 		}, 
  671. 		apcs_south_3 = { 
  672. 			{groups = { {group = M13_spawn_groups.apc_011, spawn_point = M13_spawn_points.flee_south[ 5],},}, initial_delay = 8.0, template = M13_wave_templates.apcs_ambient}, 
  673. 			{groups = { {group = M13_spawn_groups.apc_012, spawn_point = M13_spawn_points.flee_south[ 6],},}, initial_delay =10.0, template = M13_wave_templates.apcs_ambient}, 
  674. 		}, 
  675.  
  676. 		scene_1 = { 
  677. 			{groups = { {group = M13_spawn_groups.apc_013,  spawn_point = M13_spawn_points.drop_off_north[ 4],},}, template = M13_wave_templates.scene_1}, 
  678. 			{groups = { {group = M13_spawn_groups.apc_014,  spawn_point = M13_spawn_points.drop_off_north[ 5],},}, template = M13_wave_templates.scene_1}, 
  679. 			{groups = { {group = M13_spawn_groups.apc_015,  spawn_point = M13_spawn_points.drop_off_north[ 6],},}, template = M13_wave_templates.scene_1}, 
  680. 			{groups = { {group = M13_spawn_groups.apc_016,  spawn_point = M13_spawn_points.drop_off_north[ 7],},}, template = M13_wave_templates.scene_1}, 
  681. 			{groups = { {group = M13_spawn_groups.apc_017,  spawn_point = M13_spawn_points.drop_off_north[ 8],},}, template = M13_wave_templates.scene_1}, 
  682. 			{groups = { {group = M13_spawn_groups.apc_018,  spawn_point = M13_spawn_points.drop_off_north[11],},}, template = M13_wave_templates.scene_1}, 
  683. 			{groups = { {group = M13_spawn_groups.apc_019,  spawn_point = M13_spawn_points.drop_off_north[12],},}, template = M13_wave_templates.scene_1}, 
  684. 			{groups = { {group = M13_spawn_groups.apc_020,  spawn_point = M13_spawn_points.drop_off_north[13],},}, template = M13_wave_templates.scene_1}, 
  685. 		}, 
  686. 		 
  687. 		scene_2 = { 
  688. 			{groups = { {group = M13_spawn_groups.apc_021,  spawn_point = M13_spawn_points.drop_off_south[ 1],},}, template = M13_wave_templates.scene_1}, 
  689. 			{groups = { {group = M13_spawn_groups.apc_022,  spawn_point = M13_spawn_points.drop_off_south[ 2],},}, template = M13_wave_templates.scene_1}, 
  690. 			{groups = { {group = M13_spawn_groups.apc_023,  spawn_point = M13_spawn_points.drop_off_south[ 3],},}, template = M13_wave_templates.scene_1}, 
  691. 			{groups = { {group = M13_spawn_groups.apc_024,  spawn_point = M13_spawn_points.drop_off_south[ 4],},}, template = M13_wave_templates.scene_1}, 
  692. 			{groups = { {group = M13_spawn_groups.apc_025,  spawn_point = M13_spawn_points.drop_off_south[ 5],},}, template = M13_wave_templates.scene_1}, 
  693. 			{groups = { {group = M13_spawn_groups.apc_026,  spawn_point = M13_spawn_points.drop_off_south[ 6],},}, template = M13_wave_templates.scene_1}, 
  694. 		}, 
  695. 		scene_2_deck = { 
  696. 			{ groups = { {group = M13_spawn_groups.deck_001, spawn_point = M13_spawn_points.dummy,},}, template = M13_wave_templates.scene_2_deck}, 
  697. 		}, 
  698.  
  699. 		scene_3_snipers = { 
  700. 			{ 
  701. 				groups = {  
  702. 					{group = M13_spawn_groups.snipers_001, spawn_point = M13_spawn_points.dummy,}, 
  703. 					{group = M13_spawn_groups.snipers_002, spawn_point = M13_spawn_points.dummy,}, 
  704. 				},  
  705. 				template = M13_wave_templates.scene_3_snipers 
  706. 			}, 
  707. 			{groups = { {group = M13_spawn_groups.heli_001, spawn_point = M13_spawn_points.heli_fake[ 1],},}, template = M13_wave_templates.scene_6_vtol_xtra}, 
  708. 			{groups = { {group = M13_spawn_groups.heli_002, spawn_point = M13_spawn_points.heli_fake[ 2],},}, template = M13_wave_templates.scene_6_vtol_xtra}, 
  709. 			{groups = { {group = M13_spawn_groups.heli_003, spawn_point = M13_spawn_points.heli_fake[ 3],},}, template = M13_wave_templates.scene_6_vtol_xtra}, 
  710. 			{groups = { {group = M13_spawn_groups.apc_021,  spawn_point = M13_spawn_points.drop_off_south[ 1],},}, template = M13_wave_templates.scene_1}, 
  711. 			{groups = { {group = M13_spawn_groups.apc_022,  spawn_point = M13_spawn_points.drop_off_south[ 2],},}, template = M13_wave_templates.scene_1}, 
  712. 		}, 
  713.  
  714. 		scene_4_tanks = { 
  715. 			{ 
  716. 				groups = {  
  717. 					--{group = M13_spawn_groups.tank_001, spawn_point = M13_spawn_points.drop_off_north[ 2],}, 
  718. 					{group = M13_spawn_groups.tank_002, spawn_point = M13_spawn_points.drop_off_north[ 9],}, 
  719. 					--{group = M13_spawn_groups.tank_003, spawn_point = M13_spawn_points.drop_off_north[14],}, 
  720. 				},  
  721. 				template = M13_wave_templates.scene_4_tanks 
  722. 			}, 
  723. 			{ 
  724. 				groups = {  
  725. 					{group = M13_spawn_groups.tank_001, spawn_point = M13_spawn_points.drop_off_north[ 1],}, 
  726. 				},  
  727. 				template = M13_wave_templates.scene_4_tanks 
  728. 			}, 
  729. 			{groups = { {group = M13_spawn_groups.apc_013,  spawn_point = M13_spawn_points.drop_off_north[ 4],},}, template = M13_wave_templates.scene_1}, 
  730. 			{groups = { {group = M13_spawn_groups.apc_014,  spawn_point = M13_spawn_points.drop_off_north[ 5],},}, template = M13_wave_templates.scene_1}, 
  731. 		}, 
  732.  
  733. 		scene_5_drop_off = { 
  734. 			{groups = { {group = M13_spawn_groups.apc_011, spawn_point = M13_spawn_points.scene_5_drop_off[ 1],},}, template = M13_wave_templates.scene_5_drop_off}, 
  735. 			{groups = { {group = M13_spawn_groups.apc_012, spawn_point = M13_spawn_points.scene_5_drop_off[ 2],},}, template = M13_wave_templates.scene_5_drop_off}, 
  736. 		}, 
  737. 		 
  738. 		scene_6_tanks = { 
  739. 			{ 
  740. 				groups = {  
  741. 					{group = M13_spawn_groups.tank_001, spawn_point = M13_spawn_points.drop_off_north[ 2],}, 
  742. 					{group = M13_spawn_groups.tank_002, spawn_point = M13_spawn_points.drop_off_north[ 9],}, 
  743. 				},  
  744. 				template = M13_wave_templates.scene_6_tanks 
  745. 			}, 
  746. 			{ 
  747. 				groups = {  
  748. 					{group = M13_spawn_groups.tank_003, spawn_point = M13_spawn_points.drop_off_north[14],}, 
  749. 				},  
  750. 				template = M13_wave_templates.scene_6_tanks 
  751. 			}, 
  752. 		}, 
  753. 		scene_6_vtol_01 = { 
  754. 			{ 
  755. 				groups = {  
  756. 					{group = M13_spawn_groups.heli_001, spawn_point = M13_spawn_points.heli_west_01[ 1],}, 
  757. 				},  
  758. 				template = M13_wave_templates.scene_6_vtol 
  759. 			}, 
  760. 			{groups = { {group = M13_spawn_groups.heli_002,  spawn_point = M13_spawn_points.heli_west_02[ 1],},}, template = M13_wave_templates.scene_6_vtol_xtra}, 
  761. 			{groups = { {group = M13_spawn_groups.heli_003,  spawn_point = M13_spawn_points.heli_west_03[ 1],},}, template = M13_wave_templates.scene_6_vtol_xtra}, 
  762. 			{groups = { {group = M13_spawn_groups.apc_013,  spawn_point = M13_spawn_points.drop_off_north[ 4],},}, template = M13_wave_templates.scene_1}, 
  763. 			{groups = { {group = M13_spawn_groups.apc_014,  spawn_point = M13_spawn_points.drop_off_north[ 5],},}, template = M13_wave_templates.scene_1}, 
  764. 			{groups = { {group = M13_spawn_groups.apc_015,  spawn_point = M13_spawn_points.drop_off_north[ 6],},}, template = M13_wave_templates.scene_1}, 
  765. 			{groups = { {group = M13_spawn_groups.apc_016,  spawn_point = M13_spawn_points.drop_off_north[ 7],},}, template = M13_wave_templates.scene_1}, 
  766. 			{groups = { {group = M13_spawn_groups.apc_017,  spawn_point = M13_spawn_points.drop_off_north[ 8],},}, template = M13_wave_templates.scene_1}, 
  767. 			{groups = { {group = M13_spawn_groups.apc_018,  spawn_point = M13_spawn_points.drop_off_north[11],},}, template = M13_wave_templates.scene_1}, 
  768. 			{groups = { {group = M13_spawn_groups.apc_019,  spawn_point = M13_spawn_points.drop_off_north[12],},}, template = M13_wave_templates.scene_1}, 
  769. 			{groups = { {group = M13_spawn_groups.apc_020,  spawn_point = M13_spawn_points.drop_off_north[13],},}, template = M13_wave_templates.scene_1}, 
  770. 			{groups = { {group = M13_spawn_groups.apc_021,  spawn_point = M13_spawn_points.drop_off_south[ 1],},}, template = M13_wave_templates.scene_1}, 
  771. 			{groups = { {group = M13_spawn_groups.apc_022,  spawn_point = M13_spawn_points.drop_off_south[ 2],},}, template = M13_wave_templates.scene_1}, 
  772. 		}, 
  773. 		 
  774. 		scene_6_vtol_02 = { 
  775. 			{groups = { {group = M13_spawn_groups.heli_001, spawn_point = M13_spawn_points.heli_east_01[ 1],},}, template = M13_wave_templates.scene_6_vtol}, 
  776. 			{groups = { {group = M13_spawn_groups.heli_002, spawn_point = M13_spawn_points.heli_east_02[ 1],},}, template = M13_wave_templates.scene_6_vtol}, 
  777. 		}, 
  778. 		 
  779. 		scene_6_snipers = { 
  780. 			{ 
  781. 				groups = {  
  782. 					{group = M13_spawn_groups.snipers_001, spawn_point = M13_spawn_points.dummy,}, 
  783. 					{group = M13_spawn_groups.snipers_003, spawn_point = M13_spawn_points.dummy,}, 
  784. 				},  
  785. 				template = M13_wave_templates.scene_6_snipers 
  786. 			}, 
  787. 			{groups = { {group = M13_spawn_groups.heli_001, spawn_point = M13_spawn_points.heli_fake[ 1],},}, template = M13_wave_templates.scene_6_vtol_xtra}, 
  788. 			{groups = { {group = M13_spawn_groups.heli_002, spawn_point = M13_spawn_points.heli_fake[ 2],},}, template = M13_wave_templates.scene_6_vtol_xtra}, 
  789. 			{groups = { {group = M13_spawn_groups.heli_003, spawn_point = M13_spawn_points.heli_fake[ 3],},}, template = M13_wave_templates.scene_6_vtol_xtra}, 
  790. 			{groups = { {group = M13_spawn_groups.apc_025,  spawn_point = M13_spawn_points.drop_off_south[ 5],},}, template = M13_wave_templates.scene_1}, 
  791. 			{groups = { {group = M13_spawn_groups.apc_026,  spawn_point = M13_spawn_points.drop_off_south[ 6],},}, template = M13_wave_templates.scene_1}, 
  792. 		}, 
  793.  
  794. 		scene_7_deck = { 
  795. 			{groups = { {group = M13_spawn_groups.deck_001, 	spawn_point = M13_spawn_points.dummy,},}, 					template = M13_wave_templates.scene_7_deck}, 
  796. 			{groups = { {group = M13_spawn_groups.deck_002, 	spawn_point = M13_spawn_points.dummy,},}, 					template = M13_wave_templates.scene_7_deck}, 
  797. 			{groups = { {group = M13_spawn_groups.apc_017,  	spawn_point = M13_spawn_points.drop_off_north[ 8],},}, 	template = M13_wave_templates.scene_1}, 
  798. 			{groups = { {group = M13_spawn_groups.apc_018,  	spawn_point = M13_spawn_points.drop_off_north[11],},}, 	template = M13_wave_templates.scene_1}, 
  799. 			{groups = { {group = M13_spawn_groups.apc_019,  	spawn_point = M13_spawn_points.drop_off_north[12],},}, 	template = M13_wave_templates.scene_1}, 
  800. 			{groups = { {group = M13_spawn_groups.apc_020,  	spawn_point = M13_spawn_points.drop_off_north[13],},}, 	template = M13_wave_templates.scene_1}, 
  801. 		}, 
  802. 	} 
  803.  
  804. -- Navpoints -- 
  805. 	M13_nav = { 
  806. 		player_start			= "nav_player_start", 
  807. 		elevator_to_ground	= "nav_elevator_to_ground", 
  808. 		elevator_to_balcony	= "nav_elevator_to_balcony", 
  809. 		player_penthouse		= "nav_player_penthouse", 
  810. 		penthouse_elevator	= "nav_penthouse_elevator", 
  811.  
  812. 		remote_start					= "nav_remote_start", 
  813. 		remote_penthouse				= "nav_remote_penthouse", 
  814. 		elevator_to_ground_remote	= "nav_elevator_to_ground_remote", 
  815. 		elevator_to_balcony_remote	= "nav_elevator_to_balcony_remote", 
  816. 		penthouse_elevator_remote	= "nav_penthouse_elevator_remote", 
  817.  
  818. 		saints_hq_base					= "nav_saints_hq_base", 
  819.  
  820. 		josh_to_cyrus		= "nav_josh_to_cyrus", 
  821. 		josh_to_shaundi	= "nav_josh_to_shaundi", 
  822. 		cyrus_to_vtol		= "nav_cyrus_to_vtol", 
  823. 		 
  824. 		jump_to				= "nav_jump_to", 
  825. 		 
  826. 		banners_player_start = "nav_cp_banners_player_start", 
  827. 		banners_remote_start = "nav_cp_banners_remote_start", 
  828. 	} 
  829.  
  830. 	M13_paths = { 
  831. 		pierce_to_saints_hq	= "path_pierce_saints_hq", 
  832. 		pierce_to_crash 		= "path_pierce_crash", 
  833. 	} 
  834.  
  835. -- Triggers -- 
  836. 	M13_triggers = { 
  837. 		pr_center_front			= "trigger_pr_center_front", 
  838. 		saints_hq_front			= "trigger_saints_hq_front", 
  839. 		north_side					= "trigger_north_side", 
  840. 		south_side					= "trigger_south_side", 
  841. 		elevator_to_ground		= "trigger_elevator_to_ground",			-- Use trigger 
  842. 		elevator_to_penthouse	= "trigger_elevator_to_penthouse",		-- Use trigger 
  843. 		penthouse_cutscene		= "trigger_penthouse_cutscene", 
  844. 		penthouse_jumped			= "trigger_penthouse_jumped", 
  845. 		no_traffic									= "Trigger No Traffic", 
  846. 		elevator_proximity				= "trigger_elevator_proximity", 
  847. 	} 
  848.  
  849. -- Trigger Flags -- 
  850. 	M13_trigger_reached = false 
  851.  
  852. -- Mesh Movers -- 
  853. 	M13_movers = { 
  854. 		pr_center_banners = { 
  855. 			{name = "mover_mission_accomplished 001", destroyed = false,}, 
  856. 			{name = "mover_mission_accomplished 002", destroyed = false,}, 
  857. 		}, 
  858.  
  859. 		bombs = { 
  860. 			{mover = "mover_bomb 001", detonate = false, delay = 0.0, north_side = false,}, 
  861. 			{mover = "mover_bomb 002", detonate = false, delay = 0.0, north_side = true,}, 
  862. 			{mover = "mover_bomb 003", detonate = false, delay = 0.0, north_side = false,}, 
  863. 			{mover = "mover_bomb 004", detonate = false, delay = 0.0, north_side = false,}, 
  864. 			{mover = "mover_bomb 005", detonate = false, delay = 0.0, north_side = false,}, 
  865. 			{mover = "mover_bomb 006", detonate = false, delay = 0.0, north_side = true,}, 
  866. 			{mover = "mover_bomb 007", detonate = false, delay = 0.0, north_side = true,}, 
  867. 			{mover = "mover_bomb 008", detonate = false, delay = 0.0, north_side = false,}, 
  868. 			{mover = "mover_bomb 009", detonate = false, delay = 0.0, north_side = false,}, 
  869. 			{mover = "mover_bomb 010", detonate = false, delay = 0.0, north_side = true,}, 
  870. 			{mover = "mover_bomb 011", detonate = false, delay = 0.0, north_side = false,}, 
  871. 			{mover = "mover_bomb 012", detonate = false, delay = 0.0, north_side = false,}, 
  872. 			{mover = "mover_bomb 013", detonate = false, delay = 0.0, north_side = false,}, 
  873. 			{mover = "mover_bomb 014", detonate = false, delay = 0.0, north_side = false,}, 
  874. 			{mover = "mover_bomb 015", detonate = false, delay = 0.0, north_side = true,}, 
  875. 			{mover = "mover_bomb 016", detonate = false, delay = 0.0, north_side = true,}, 
  876. 			{mover = "mover_bomb 017", detonate = false, delay = 0.0, north_side = true,}, 
  877. 			{mover = "mover_bomb 018", detonate = false, delay = 0.0, north_side = true,}, 
  878. 			{mover = "mover_bomb 019", detonate = false, delay = 0.0, north_side = true,}, 
  879. 			{mover = "mover_bomb 020", detonate = false, delay = 0.0, north_side = true,}, 
  880. 			{mover = "mover_bomb 021", detonate = false, delay = 0.0, north_side = true,}, 
  881. 			{mover = "mover_bomb 022", detonate = false, delay = 0.0, north_side = true,}, 
  882. 			{mover = "mover_bomb 023", detonate = false, delay = 0.0, north_side = true,}, 
  883. 			{mover = "mover_bomb 024", detonate = false, delay = 0.0, north_side = false,}, 
  884. 			{mover = "mover_bomb 025", detonate = false, delay = 0.0, north_side = false,}, 
  885. 			{mover = "mover_bomb 026", detonate = false, delay = 0.0, north_side = false,}, 
  886. 			{mover = "mover_bomb 027", detonate = false, delay = 0.0, north_side = true,}, 
  887. 		}, 
  888. 		 
  889. 		clutter = { "mvr_vehicle_clutter 001", "mvr_vehicle_clutter 002", "mvr_vehicle_clutter 003", "mvr_vehicle_clutter 004",  
  890. 						"mvr_vehicle_clutter 005", "mvr_vehicle_clutter 006", "mvr_vehicle_clutter 007", 
  891. 		}, 
  892. 	} 
  893. 	 
  894. -- VFX -- 
  895. 	M13_vfxs = { 
  896. 		north_01 = { 
  897. 			smoke_01 = { nav = "vfx_n_smoke 001", handle = -1 }, 
  898. 			--smoke_02 = { nav = "vfx_n_smoke 002", handle = -1 }, 
  899. 			smoke_03 = { nav = "vfx_n_smoke 003", handle = -1 }, 
  900. 			--smoke_04 = { nav = "vfx_n_smoke 004", handle = -1 }, 
  901. 			smoke_05 = { nav = "vfx_n_smoke 005", handle = -1 }, 
  902. 			smoke_06 = { nav = "vfx_n_smoke 006", handle = -1 }, 
  903. 		}, 
  904. 		north_02 = { 
  905. 			fire_01 = { nav = "vfx_n_fire 001", handle = -1 }, 
  906. 			fire_02 = { nav = "vfx_n_fire 002", handle = -1 }, 
  907. 			fire_03 = { nav = "vfx_n_fire 003", handle = -1 }, 
  908. 			fire_04 = { nav = "vfx_n_fire 004", handle = -1 }, 
  909. 			fire_05 = { nav = "vfx_n_fire 005", handle = -1 }, 
  910. 			--fire_06 = { nav = "vfx_n_fire 012", handle = -1 }, 
  911. 			--fire_07 = { nav = "vfx_n_fire 013", handle = -1 }, 
  912. 			smoke_01 = { nav = "vfx_n_smoke 007", handle = -1 }, 
  913. 			smoke_02 = { nav = "vfx_n_smoke 008", handle = -1 }, 
  914. 		}, 
  915. 		north_03 = { 
  916. 			--fire_01 = { nav = "vfx_n_fire 006", handle = -1 }, 
  917. 			fire_02 = { nav = "vfx_n_fire 007", handle = -1 }, 
  918. 			--fire_03 = { nav = "vfx_n_fire 008", handle = -1 }, 
  919. 			fire_04 = { nav = "vfx_n_fire 009", handle = -1 }, 
  920. 			fire_05 = { nav = "vfx_n_fire 010", handle = -1 }, 
  921. 			big_01 = { nav = "vfx_n_big 001", handle = -1 }, 
  922. 		}, 
  923. 		south_01 = { 
  924. 			smoke_01 = { nav = "vfx_s_smoke 001", handle = -1 }, 
  925. 			--smoke_02 = { nav = "vfx_s_smoke 002", handle = -1 }, 
  926. 			smoke_03 = { nav = "vfx_s_smoke 003", handle = -1 }, 
  927. 			smoke_04 = { nav = "vfx_s_smoke 004", handle = -1 }, 
  928. 		}, 
  929. 		south_02 = { 
  930. 			fire_01 = { nav = "vfx_s_fire 001", handle = -1 }, 
  931. 			--fire_02 = { nav = "vfx_s_fire 002", handle = -1 }, 
  932. 		}, 
  933. 		hq_01 = { 
  934. 			smoke_01 = { nav = "vfx_hq_smoke 001", handle = -1 }, 
  935. 			smoke_02 = { nav = "vfx_hq_smoke 002", handle = -1 }, 
  936. 		}, 
  937. 		hq_02 = { 
  938. 			-- smoke_01 = { nav = "vfx_hq_smoke 003", handle = -1 }, 
  939. 			smoke_02 = { nav = "vfx_hq_smoke 004", handle = -1 }, 
  940. 			fire_01 = { nav = "vfx_hq_fire 001", handle = -1 }, 
  941. 		}, 
  942.  
  943. 	} 
  944.  
  945. -- Text -- 
  946. 	M13_OBJ_GOTO_PR_CENTER			= "m13_obj_goto_pr_center" 
  947. 	M13_OBJ_DESTROY_STAG_BANNER	= "m13_obj_destroy_stag_banner" 
  948. 	M13_OBJ_GOTO_SAINTS_HQ			= "m13_obj_goto_saints_hq" 
  949. 	M13_OBJ_GOTO_ELEVATOR			= "m13_obj_goto_elevator" 
  950. 	M13_OBJ_DEFEND_THE_NORTH		= "m13_obj_defend_the_north" 
  951. 	M13_OBJ_DEFEND_THE_SOUTH		= "m13_obj_defend_the_south" 
  952. 	M13_OBJ_DETONATE_CAR_BOMBS		= "m13_obj_detonate_car_bombs" 
  953. 	M13_OBJ_HELP_VIOLA				= "m13_obj_help_viola" 
  954. 	M13_OBJ_TAKE_OUT_THE_SNIPERS	= "m13_obj_take_out_the_snipers" 
  955. 	M13_OBJ_TAKE_OUT_THE_TANKS		= "m13_obj_take_out_the_tanks" 
  956. 	M13_OBJ_TAKE_OUT_THE_VTOLS		= "m13_obj_take_out_the_vtols" 
  957. 	M13_OBJ_CLEAR_THE_FLOOR			= "m13_obj_clear_the_floor" 
  958. 	M13_OBJ_COVER_PIERCE				= "m13_obj_cover_pierce" 
  959. 	M13_OBJ_GOTO_PIERCE				= "m13_obj_goto_pierce" 
  960. 	M13_OBJ_THROW_JOSH				= "m13_obj_throw_josh" 
  961. 	M13_OBJ_GOTO_PENTHOUSE			= "m13_obj_goto_penthouse" 
  962. 	M13_OBJ_GOTO_SHAUNDI				= "m13_obj_goto_shaundi" 
  963. 	M13_OBJ_ESCAPE						= "m13_obj_escape" 
  964.  
  965. 	M13_PROMPT_THROW_JOSH_TO_CYRUS	= "m13_prompt_throw_josh_to_cyrus" 
  966. 	M13_PROMPT_THROW_JOSH_TO_SHAUNDI	= "m13_prompt_throw_josh_to_shaundi" 
  967.  
  968. 	M13_FAILURE_VIOLA_DIED				= "m13_failure_viola_died" 
  969. 	M13_FAILURE_VIOLA_ABANDONED		= "m13_failure_viola_abandoned" 
  970. 	-- M13_FAILURE_OLEG_DIED				= "m13_failure_oleg_died" 
  971. 	M13_FAILURE_PIERCE_DIED				= "m13_failure_pierce_died" 
  972. 	M13_FAILURE_PIERCE_ABANDONED		= "m13_failure_pierce_abandoned" 
  973. 	M13_FAILURE_SAINTS_HQ_ABANDONED	= "m13_failure_saints_hq_abandoned" 
  974. 	M13_FAILURE_JOSH_DIED				= "m13_failure_josh_died" 
  975. 	M13_FAILURE_FAILED_TO_ESCAPE		= "m13_failure_failed_to_escape" 
  976.  
  977. -- Threads -- 
  978. 	M13_THREAD_CAR_BOMB_MANAGER	= INVALID_THREAD_HANDLE 
  979.  
  980. 	-- Conversation threads 
  981. 	M13_THREAD_PIERCE_CONVO_AND_LEAVE = INVALID_THREAD_HANDLE 
  982.  
  983. -- Checkpoints -- 
  984. 	M13_CHECKPOINT_START				= MISSION_START_CHECKPOINT			-- defined in ug_lib.lua 
  985. 	M13_CHECKPOINT_BANNERS					= "m13_checkpoint_banners" 
  986. 	M13_CHECKPOINT_WAVE_1_START	= "m13_checkpoint_wave_1_start" 
  987. 	M13_CHECKPOINT_WAVE_2_START	= "m13_checkpoint_wave_2_start" 
  988. 	M13_CHECKPOINT_WAVE_3_START	= "m13_checkpoint_wave_3_start" 
  989. 	M13_CHECKPOINT_DECISION			= "m13_checkpoint_decision" 
  990.  
  991. -- Cutscenes -- 
  992. 	CUTSCENE_MISSION_INTRO = "13_in" 
  993. 	CUTSCENE_MISSION_OUTRO = "13_out" 
  994.  
  995. -- Personas -- 
  996. 	M13_personas = { 
  997. 		{ name = "Oleg", 			handle = INVALID_PERSONA_HANDLE }, 
  998. 		{ name = "Suko", 			handle = INVALID_PERSONA_HANDLE }, 
  999. 		{ name = "Pierce",		handle = INVALID_PERSONA_HANDLE }, 
  1000. 		{ name = "Shaundi",		handle = INVALID_PERSONA_HANDLE }, 
  1001. 		{ name = "Saint_WM_04",	handle = INVALID_PERSONA_HANDLE }, 
  1002. 		{ name = "Saint_HF_04",	handle = INVALID_PERSONA_HANDLE }, 
  1003. 	} 
  1004.  
  1005. 	M13_persona_line = { 
  1006. 		--drive_to_pr = 		{ name = "M13_Drive_To_PR_Center", 	character = LOCAL_PLAYER, 		play_2d = false 	}, 
  1007. 		banners = 			{ name = "M13_Banners", 				character = LOCAL_PLAYER,		play_2d = false 	}, 
  1008. 		molotov_remind = 	{ name = "M13_Molotov_Reminder",		character = LOCAL_PLAYER,		play_2d = false	}, 
  1009. 		attack_start =		{ name = "M13_Wave_One_Start",		character = "Oleg",				cell = true,	recieving = true  	}, 
  1010. 		car_bombs_01 = 	{ name = "M13_Use_Car_Bombs_01",		character = "Oleg",				play_2d = true		}, 
  1011. 		car_bombs_02 = 	{ name = "M13_Use_Car_Bombs_02",		character = "Suko",				play_2d = true		}, 
  1012. 		north =				{ name = "M13_North",					character = "Oleg",				play_2d = true	 	}, 
  1013. 		south =				{ name = "M13_South",					character = "Oleg",				play_2d = true	 	}, 
  1014. 		east =				{ name = "M13_East",						character = "Oleg",				play_2d = true	 	}, 
  1015. 		west =				{ name = "M13_West",						character = "Oleg",				play_2d = true	 	}, 
  1016. 		help_viola_01 =	{ name = "M13_Help_Viola_In_Building",	character = "Suko",			play_2d = true	 	}, 
  1017. 		help_viola_02 =	{ name = "M13_Go_Help_Viola",			character = "Oleg",				play_2d = true	 	}, 
  1018. 		focus_south =		{ name = "M13_Focus_On_South_Side",	character = "Suko",				play_2d = true	 	}, 
  1019. 		snipers_01 =		{ name = "M13_Snipers_On_South_01",	character = "Suko",				play_2d = true	 	}, 
  1020. 		snipers_02 =		{ name = "M13_Snipers_On_South_0",	character = "Suko",				play_2d = true	 	}, 
  1021. 		tanks_01 =			{ name = "M13_Tank_On_North_01",		character = "Oleg",				play_2d = true	 	}, 
  1022. 		tanks_02 =			{ name = "M13_Tank_On_North_02",		character = "Oleg",				play_2d = true	 	}, 
  1023. 		arriving =			{ name = "M13_Arriving",				character = "Pierce",			cell = true,	recieving = true  	}, 
  1024. 		in_trouble_01 =	{ name = "M13_In_Trouble_01",			character = "Pierce",			play_2d = true		}, 
  1025. 		in_trouble_02 =	{ name = "M13_In_trouble_02",			character = "Pierce",			cell = true,	recieving = true		}, 
  1026. 		elevator =			{ name = "M13_Elevator",				character = "Oleg",				play_2d = true		}, 
  1027. 		stag_inside =		{ name = "M13_STAG_Inside_Oleg",		character = "Oleg",				play_2d = true		}, 
  1028. 		losing =				{ name = "M13_Losing_Viola",			character = "Suko",				play_2d = true		}, 
  1029. 		seconds_60 =		{ name = "M13_60_Seconds",				character = M13_groups.penthouse_stag.cyrus,	play_2d = false		}, 
  1030. 		seconds_30 =		{ name = "M13_30_Seconds",				character = M13_groups.penthouse_stag.cyrus,	play_2d = false		}, 
  1031. 		seconds_10 =		{ name = "M13_10_Seconds",				character = M13_groups.penthouse_stag.cyrus,	play_2d = false		}, 
  1032. 		shell =				{ name = "M13_Shell_Building",		character = M13_groups.penthouse_stag.cyrus,	play_2d = false		}, 
  1033. 		with_birk =			{ name = "M13_Shaundi_With_Birk",	character = "Shaundi",			play_2d = true		}, 
  1034. 		without_birk =		{ name = "M13_Shaundi_Without_Birk",	character = "Shaundi",			play_2d = true		}, 
  1035. 		get_out = 			{ name = "M13_Get_Out", 				character = LOCAL_PLAYER,		play_2d = false 	}, 
  1036. 	} 
  1037. 	 
  1038. -- Conversations -- 
  1039. 	-- Table of audio conversations to play. Either a actual audio file can be specifed, or a message can be used in its place. 
  1040. 	-- Expected Table Members: 
  1041. 	--   name    - Name of the audio file to play 
  1042. 	--   delay   - Amount of time (in seconds) to delay after a audio file has played 
  1043. 	M13_convo = { 
  1044. 		-- Played as soon as the mission starts 
  1045. 		start = { 
  1046. 			files = { 
  1047. 				{name = "m13_convo_1", delay = 0.0}, 
  1048. 			}, 
  1049. 			thread = INVALID_THREAD_HANDLE, 
  1050. 		}, 
  1051.  
  1052. 		-- Played after the banner is destroyed. The objective will be updated once this is completed. 
  1053. 		banner_destroyed = { 
  1054. 			files = { 
  1055. 				{ name = "M13_Return_To_Crib", delay = 2.0, cell = true, recieving = false }, 
  1056. 			}, 
  1057. 			thread = INVALID_THREAD_HANDLE, 
  1058. 		}, 
  1059. 		 
  1060. 		help_viola = { 
  1061. 			files = { 
  1062. 				{name = M13_persona_line.help_viola_01, delay = 3.0}, 
  1063. 				{name = M13_persona_line.help_viola_02, delay = 0.0}, 
  1064. 			}, 
  1065. 			thread = INVALID_THREAD_HANDLE, 
  1066. 		}, 
  1067. 		 
  1068. 		pierce_drive_in = { 
  1069. 			files = { 
  1070. 				{name = M13_persona_line.arriving, delay = 8.0}, 
  1071. 				{name = M13_persona_line.in_trouble_01, delay = 0.0}, 
  1072. 			}, 
  1073. 			thread = INVALID_THREAD_HANDLE, 
  1074. 		}, 
  1075.  
  1076. 		-- Played once the player saves Pierce 
  1077. 		save_pierce_4 = { 
  1078. 			files = { 
  1079. 				{name = "M13_Thanks", delay = 0.0}, 
  1080. 			}, 
  1081. 			thread = INVALID_THREAD_HANDLE, 
  1082. 		}, 
  1083.  
  1084. 		-- Played after the player returns to the Saints HQ with Pierce 
  1085. 		airstrike = { 
  1086. 			files = { 
  1087. 				{name = "M13_Laser_Target", delay = 2.0}, 
  1088. 			}, 
  1089. 			thread = INVALID_THREAD_HANDLE, 
  1090. 		}, 
  1091.  
  1092. 		-- Played when the first helicopter spawns. 
  1093. 		first_heli = { 
  1094. 			files = { 
  1095. 				{name = "M13_Helicopters", delay = 2.0}, 
  1096. 			}, 
  1097. 			thread = INVALID_THREAD_HANDLE, 
  1098. 		}, 
  1099.  
  1100. 		-- Played when the final wave is totally complete. 
  1101. 		check_roof_01 = { 
  1102. 			files = { 
  1103. 				-- {name = M13_persona_line.losing, delay = 5.0}, 
  1104. 				{name = M13_persona_line.stag_inside, delay = 10.0}, 
  1105. 				-- {name = "M13_Retreating", delay = 1.0}, 
  1106. 			}, 
  1107. 			thread = INVALID_THREAD_HANDLE, 
  1108. 		}, 
  1109. 		 
  1110. 		check_roof_02 = { 
  1111. 			files = { 
  1112. 				{name = M13_persona_line.losing, delay = 4.0}, 
  1113. 				-- {name = M13_persona_line.stag_inside, delay = 7.0}, 
  1114. 				-- {name = "M13_Retreating", delay = 1.0}, 
  1115. 			}, 
  1116. 			thread = INVALID_THREAD_HANDLE, 
  1117. 		}, 
  1118. 		 
  1119. 		check_roof_03 = { 
  1120. 			files = { 
  1121. 				-- {name = M13_persona_line.losing, delay = 4.0}, 
  1122. 				-- {name = M13_persona_line.stag_inside, delay = 5.0}, 
  1123. 				{name = "M13_Retreating", delay = 1.0}, 
  1124. 			}, 
  1125. 			thread = INVALID_THREAD_HANDLE, 
  1126. 		}, 
  1127. 		 
  1128. 		-- Played when Cyrus gives the player a choice. 
  1129. 		decision1 = { 
  1130. 			files = { 
  1131. 				{name = "M13_Choice", delay = 0.0, direct = true}, 
  1132. 				{name = M13_persona_line.seconds_60, delay = 30.0}, 
  1133. 				{name = M13_persona_line.seconds_30, delay = 20.0}, 
  1134. 				{name = M13_persona_line.seconds_10, delay = 10.0}, 
  1135. 			}, 
  1136. 			thread = INVALID_THREAD_HANDLE, 
  1137. 		}, 
  1138. 		 
  1139. 		shell_the_building = { 
  1140. 			files = { 
  1141. 				{name = M13_persona_line.shell, delay = 2.5}, 
  1142. 				-- {name = M13_persona_line.with_birk, delay = 2.0}, 
  1143. 				-- {name = M13_persona_line.get_out, delay = 0.0}, 
  1144. 			}, 
  1145. 			thread = INVALID_THREAD_HANDLE, 
  1146. 		}, 
  1147. 		 
  1148. 		shell_with_birk = { 
  1149. 			files = { 
  1150. 				-- {name = M13_persona_line.shell, delay = 2.5}, 
  1151. 				{name = M13_persona_line.with_birk, delay = 2.0}, 
  1152. 				{name = M13_persona_line.get_out, delay = 0.0}, 
  1153. 			}, 
  1154. 			thread = INVALID_THREAD_HANDLE, 
  1155. 		}, 
  1156. 		 
  1157. 		shell_without_birk = { 
  1158. 			files = { 
  1159. 				-- {name = M13_persona_line.shell, delay = 3.5}, 
  1160. 				{name = M13_persona_line.without_birk, delay = 1.0}, 
  1161. 				{name = M13_persona_line.get_out, delay = 0.0}, 
  1162. 			}, 
  1163. 			thread = INVALID_THREAD_HANDLE, 
  1164. 		}, 
  1165. 	} 
  1166. 	 
  1167. 	M13_threads = { } 
  1168. 	M13_num_troops = 0 
  1169. 	M13_max_troops = 40 
  1170.  
  1171. -- Variables -- 
  1172. 	M13_in_coop = false 
  1173.  
  1174. 	-- PR Center Banner variables 
  1175. 	M13_banners_alive		= 0 
  1176. 	M13_banner_damaged	= false 
  1177. 	M13_banner_destroyed	= false 
  1178.  
  1179. 	M13_checkpoint	= "" 
  1180.  
  1181. 	-- Decision variables 
  1182. 	M13_josh_given_to_cyrus = false 
  1183. 	M13_josh_given_to_homies = false 
  1184.  
  1185. 	M13_active_convo = "" 
  1186. 	 
  1187. 	M13_north_apc_level = 0 
  1188. 	M13_south_apc_level = 0 
  1189. 	 
  1190. 	M13_status = { } 
  1191. 	 
  1192. -- ************************* 
  1193. -- 
  1194. -- Standard functions 
  1195. -- 
  1196. -- ************************* 
  1197.  
  1198. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  1199. -- at the specified checkpoint. 
  1200. -- CALLED FROM CODE 
  1201. -- 
  1202. -- m13_checkpoint:  The checkpoint the mission should begin at 
  1203. -- is_restart:      TRUE if the mission is restarting, FALSE otherwise 
  1204. -- 
  1205. function m13_start(m13_checkpoint, is_restart) 
  1206. 	M13_in_coop = coop_is_active() 
  1207.  
  1208. 	-- TODO: Remove. For Debugging only. 
  1209. 	--if not is_restart then 
  1210. 		--m13_checkpoint = M13_CHECKPOINT_WAVE_1_START 
  1211. 		--m13_checkpoint = M13_CHECKPOINT_WAVE_2_START 
  1212. 		--m13_checkpoint = M13_CHECKPOINT_WAVE_3_START 
  1213. 		--m13_checkpoint = M13_CHECKPOINT_DECISION 
  1214. 		--mission_set_checkpoint(m13_checkpoint, true, true) 
  1215. 	--end 
  1216.  
  1217. 	M13_checkpoint = m13_checkpoint 
  1218. 	 
  1219. 	if is_restart then 
  1220. 		M13_status.restart_checkpoint = m13_checkpoint 
  1221. 	end 
  1222.  
  1223. 	-- Handle mission initialization for the current checkpoint 
  1224. 	m13_initialize(m13_checkpoint, is_restart) 
  1225.  
  1226. 	-- Check if this mission starting from the beginning 
  1227. 	if (m13_checkpoint == M13_CHECKPOINT_START) then 
  1228. 		if (not is_restart) then 
  1229. 			-- First time playing mission 
  1230. 			cutscene_play(CUTSCENE_MISSION_INTRO, nil, { M13_nav.player_start, M13_nav.remote_start }, false) 
  1231. 			m13_mission_zscene_post_init() 
  1232. 		else 
  1233. 			teleport_coop( M13_nav.player_start, M13_nav.remote_start, true ) 
  1234. 			m13_mission_zscene_post_init() 
  1235. 		end 
  1236. 	end 
  1237.  
  1238. 	mission_start_fade_in() 
  1239.  
  1240. 	-- Run the mission from the current checkpoint 
  1241. 	m13_run(m13_checkpoint) 
  1242. end 
  1243.  
  1244. -- This is the primary function responsible for running the entire mission from start to finish. 
  1245. -- 
  1246. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  1247. -- 
  1248. function m13_run(first_checkpoint) 
  1249. 	local current_checkpoint = first_checkpoint 
  1250.  
  1251. 	-- Run the mission from the beginning 
  1252. 	if current_checkpoint == M13_CHECKPOINT_START then 
  1253. 		-- Have pierce talk to the player for a bit 
  1254. 		M13_THREAD_PIERCE_CONVO_AND_LEAVE = thread_new("m13_thread_pierce_convo_and_leave") 
  1255.  
  1256. 		-- Intro animations 
  1257. 		-- Player(s) look cool GO! 
  1258. 		local anim_name = "M06 Player Mission Start" 
  1259. 		local morph_name = "M06 Player Mission Start" 
  1260. 		local force_play = false 
  1261. 		local stand_still = false 
  1262. 		local zero_movement = false 
  1263. 		action_play_non_blocking(LOCAL_PLAYER, anim_name, morph_name, force_play, stand_still, zero_movement) 
  1264. 		player_script_controlled_clear(LOCAL_PLAYER)	-- let player escape this animation 
  1265. 		if (coop_is_active()) then 
  1266. 			action_play_non_blocking(REMOTE_PLAYER, anim_name, morph_name, force_play, stand_still, zero_movement) 
  1267. 			player_script_controlled_clear(REMOTE_PLAYER)	-- let player escape this animation 
  1268. 		end 
  1269.  
  1270. 		-- Guide the player to the PR Center and wait until the banner is destroyed 
  1271. 		m13_destroy_banner() 
  1272.  
  1273. 		current_checkpoint = M13_CHECKPOINT_BANNERS 
  1274. 		mission_set_checkpoint(current_checkpoint, true, true) 
  1275. 	end 
  1276. 		 
  1277. 	if current_checkpoint == M13_CHECKPOINT_BANNERS then 
  1278. 		-- Setup the battle scene while the player is at the pr_center 
  1279. 		m13_show_car_bombs() 
  1280. 		 
  1281. 		-- Tell the player to get back to the saints hq 
  1282. 		objective_text(0, M13_OBJ_GOTO_SAINTS_HQ, "", "", SYNC_ALL, OI_ASSET_LOCATION) 
  1283. 		 
  1284. 		-- Have Oleg acknowledge the player's actions 
  1285. 		m13_play_convo_set(M13_convo.banner_destroyed) 
  1286. 		 
  1287. 		m13_goto_a_trigger(M13_triggers.saints_hq_front, M13_OBJ_GOTO_SAINTS_HQ, true) 
  1288. 		m13_goto_balcony(M13_OBJ_GOTO_SAINTS_HQ) 
  1289. 		 
  1290. 		audio_object_post_event("M13_Score_Start", nil, nil, LOCAL_PLAYER) 
  1291. 		M13_status.score_start_began = true 
  1292. 		 
  1293. 		m13_cleanup_start() 
  1294.  
  1295. 		m13_setup_balcony_battle() 
  1296. 		m13_setup_car_bombs() 
  1297. 		 
  1298. 		current_checkpoint = M13_CHECKPOINT_WAVE_1_START 
  1299. 		mission_set_checkpoint(current_checkpoint, true, true) 
  1300. 	end 
  1301.  
  1302. 	if current_checkpoint == M13_CHECKPOINT_WAVE_1_START then 
  1303. 		-- Setup the battle scene while the player is at the pr_center 
  1304. 		m13_show_car_bombs() 
  1305. 		 
  1306. 		m13_disable_ambient_spawning( true ) 
  1307.  
  1308. 		m13_scene_1() -- Large northward assault, focusing on the use of the car bombs 
  1309. 		m13_create_clutter( "south" ) 
  1310. 		m13_scene_2() -- Southern assault, focusing on the car bombs 
  1311. 		m13_scene_3() -- Snipers take to the southern rooftops 
  1312. 		m13_create_clutter( "north" ) 
  1313. 		m13_scene_4() -- Spawn some tanks on the north side of the building 
  1314. 		m13_clear_clutter( "south" ) 
  1315.  
  1316. 		current_checkpoint = M13_CHECKPOINT_WAVE_2_START 
  1317. 		mission_set_checkpoint(current_checkpoint, true, true) 
  1318. 	end 
  1319.  
  1320. 	m13_vfx_play(M13_vfxs.north_01) 
  1321. 	m13_vfx_play(M13_vfxs.south_01) 
  1322. 		 
  1323. 	if current_checkpoint == M13_CHECKPOINT_WAVE_2_START then 
  1324. 		 
  1325. 		m13_scene_5() -- Have the player rescue Pierce 
  1326.  
  1327. 		current_checkpoint = M13_CHECKPOINT_WAVE_3_START 
  1328. 		mission_set_checkpoint(current_checkpoint, true, true) 
  1329. 	end 
  1330.  
  1331. 	m13_vfx_play(M13_vfxs.hq_01) 
  1332. 	m13_vfx_play(M13_vfxs.north_02) 
  1333. 	m13_distance_clutter_show() 
  1334. 	m13_vfx_play(M13_vfxs.south_02) 
  1335. 	m13_vfx_play(M13_vfxs.north_03) 
  1336. 	m13_vfx_play(M13_vfxs.hq_02) 
  1337.  
  1338. 	if current_checkpoint == M13_CHECKPOINT_WAVE_3_START then 
  1339. 		m13_scene_6() -- Tanks and VTOLs from the North 
  1340. 		m13_scene_7() -- Have the player flee to the penthouse 
  1341. 		 
  1342. 		-- Stop all continuious spawns, remove your homies, and cleanup the the weapons 
  1343. 		m13_cleanup_balcony_battle() 
  1344. 		m13_cleanup_car_bombs() 
  1345. 		 
  1346. 		m13_set_north_apc_level(0) 
  1347. 		m13_set_south_apc_level(0) 
  1348.  
  1349. 		m13_clear_clutter( "north" ) 
  1350. 		m13_clear_clutter( "general" ) 
  1351.  
  1352. 		current_checkpoint = M13_CHECKPOINT_DECISION 
  1353. 		mission_set_checkpoint(current_checkpoint, true, true) 
  1354.  
  1355. 		-- Spawn Josh, Shaundi, and teleport the player to the penthouse. 
  1356. 		fade_out(0.5) 
  1357. 		fade_out_block() 
  1358. 		teleport_coop(M13_nav.penthouse_elevator, M13_nav.penthouse_elevator_remote, true) 
  1359. 		m13_setup_decision() 
  1360. 		fade_in(0.5) 
  1361. 		fade_in_block() 
  1362. 	end 
  1363.  
  1364.  
  1365. 	if current_checkpoint == M13_CHECKPOINT_DECISION then 
  1366. 		-- m13_setup_decision() will be called by m13_initialize_checkpoint() on a mission restart. 
  1367.  
  1368. 		local josh = M13_groups.penthouse_homies.josh 
  1369. 		local cyrus = M13_groups.penthouse_stag.cyrus 
  1370. 		local shaundi = M13_groups.penthouse_homies.shaundi 
  1371. 		local vtol = M13_groups.penthouse_stag.vtols[1] 
  1372. 		 
  1373. 		audio_object_post_event("M13_Score_Decision", nil, nil, LOCAL_PLAYER) 
  1374. 		M13_threads.music_cue = thread_new( "m13_audio_event_at_dist", M13_triggers.penthouse_cutscene, 20, "M13_Score_Decision_End" ) 
  1375. 		zscene_prep( "13_Z01" ) 
  1376. 		m13_goto_a_trigger(M13_triggers.penthouse_cutscene, M13_OBJ_GOTO_SHAUNDI, false) 
  1377. 		thread_kill( M13_threads.music_cue ) 
  1378.  
  1379. 		-- Play the mid-mission cutscene and setup the STAG to reflect the scene 
  1380. 		m13_penthouse_cutscene() 
  1381.  
  1382. 		objective_text(0, M13_OBJ_THROW_JOSH, "", "", SYNC_ALL, OI_ASSET_USE) 
  1383.  
  1384. 		m13_player_decision() 
  1385. 		m13_cyrus_enter_vtol(cyrus, josh, M13_josh_given_to_cyrus, vtol) 
  1386. 		m13_unrestrict_players() 
  1387. 		M13_cyrus_fly_off(cyrus, M13_josh_given_to_cyrus, vtol) 
  1388. 		 
  1389. 		m13_player_leave_penthouse() 
  1390. 	end 
  1391. 	 
  1392. 	M13_status.succeeded = true 
  1393. 	 
  1394. 	if M13_josh_given_to_cyrus == true then 
  1395. 		mission_set_excluded_reward("Homie_Nyteblayde") 
  1396. 		mission_set_excluded_reward("Homie_Josh") 
  1397. 	elseif M13_josh_given_to_homies == true then 
  1398. 		mission_set_excluded_reward("Auto_Complete_City_Takeover_District") 
  1399. 	end 
  1400. 	 
  1401. 	mission_end_success("m13", CUTSCENE_MISSION_OUTRO) 
  1402. end 
  1403.  
  1404. -- This is the primary function responsible for cleaning up the entire mission 
  1405. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  1406. -- 
  1407. function m13_cleanup() 
  1408. 	--[[ INSERT ANY MISSION SPECIFIC CLEAN-UP ]]-- 
  1409. 	 
  1410. 	-- crib access is now allowed 
  1411. 	crib_disable_interface( false ) 
  1412.  
  1413. 	-- The mission may have failed due to a remote player disconnecting. Double check to see if they are connected. 
  1414. 	if M13_in_coop then 
  1415. 		M13_in_coop = coop_is_active() 
  1416. 	end 
  1417.  
  1418. 	objective_text_clear(0) 
  1419. 	hud_timer_stop(1) 
  1420. 	hud_timer_hide(1, true) 
  1421.  
  1422. 	m13_cleanup_start() 
  1423. 	m13_cleanup_banner_scene() 
  1424. 	m13_cleanup_balcony_battle() 
  1425. 	m13_cleanup_car_bombs() 
  1426. 	m13_cleanup_decision() 
  1427.  
  1428. 	for trigger in pairs(M13_triggers) do 
  1429. 		local trigger_name = M13_triggers[trigger] 
  1430. 		on_trigger("", trigger_name) 
  1431. 		on_trigger_exit("", trigger_name) 
  1432. 		trigger_enable(trigger_name, false) 
  1433. 	end 
  1434.  
  1435. 	notoriety_set_min( "police", 0) 
  1436. 	notoriety_force_no_spawn("police", false) 
  1437. 	notoriety_force_no_spawn("stag", false) 
  1438. 	notoriety_force_no_spawn("luchadores", false) 
  1439. 	notoriety_force_no_spawn("deckers", false) 
  1440. 	notoriety_force_no_spawn("morningstar", false) 
  1441.  
  1442. 	m13_unload_all_convos() 
  1443. 	m13_unload_personas() 
  1444.  
  1445. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, true) 
  1446. 	inv_weapon_remove_temporary(LOCAL_PLAYER, M13_config.grenade) 
  1447. 	inv_weapon_remove_temporary(LOCAL_PLAYER, M13_config.airstrike) 
  1448.  
  1449. 	if M13_in_coop then 
  1450. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, true) 
  1451. 		inv_weapon_remove_temporary(REMOTE_PLAYER, M13_config.grenade) 
  1452. 		inv_weapon_remove_temporary(REMOTE_PLAYER, M13_config.airstrike) 
  1453. 	end 
  1454. 	 
  1455. 	-- Make sure any VFX are cleaned up 
  1456. 	for key, vfx_group in pairs(M13_vfxs) do 
  1457. 		for i, vfx in pairs(vfx_group) do 
  1458. 			if (vfx.handle ~= -1) then 
  1459. 				effect_stop(vfx.handle) 
  1460. 				vfx.handle = -1 
  1461. 			end 
  1462. 		end 
  1463. 	end 
  1464. 	 
  1465. 	-- for i, vfx in pairs(M13_vfxs.south_01) do 
  1466. 	-- 	if (vfx.handle ~= -1) then 
  1467. 	-- 		effect_stop(vfx.handle) 
  1468. 	-- 		vfx.handle = -1 
  1469. 	-- 	end 
  1470. 	-- end 
  1471. 	 
  1472. 	-- for i, vfx in pairs(M13_vfxs.hq_01) do 
  1473. 	-- 	if (vfx.handle ~= -1) then 
  1474. 	-- 		effect_stop(vfx.handle) 
  1475. 	-- 		vfx.handle = -1 
  1476. 	-- 	end 
  1477. 	-- end 
  1478.  
  1479. 	m13_unrestrict_players() 
  1480. 	hud_prompt_clear() 
  1481. 	 
  1482. 	marker_remove(M13_nav.jump_to) 
  1483.  
  1484. 	teleport(LOCAL_PLAYER, M13_nav.elevator_to_balcony, true) 
  1485. 	if M13_in_coop then 
  1486. 		teleport(REMOTE_PLAYER, M13_nav.elevator_to_balcony_remote, true) 
  1487. 	end 
  1488.  
  1489. 	m13_disable_traffic( false ) 
  1490. 	 
  1491. 	cleanup_threads( M13_threads ) 
  1492. 	 
  1493. 	m13_disable_ambient_spawning( false ) 
  1494. 	 
  1495. 	crib_disable_interface( false ) 
  1496. 	action_nodes_enable( true ) 
  1497. 	 
  1498. 	audio_object_post_event("M13_Score_Stop", nil, nil, LOCAL_PLAYER) 
  1499. 	 
  1500. 	if M13_status.cellphone_call_in_progress ~= nil then 
  1501. 		audio_remove_mission_cellphone( M13_status.cellphone_call_in_progress ) 
  1502. 	end 
  1503. end 
  1504.  
  1505. -- Called when the mission has ended with success 
  1506. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  1507. -- 
  1508. function m13_success()	 
  1509. 	local skip_teleport = true 
  1510. 	m13_coop_skip(skip_teleport) -- do the stuff we'd do in the skip case 
  1511. 	city_zone_swap( "hq", false ) 
  1512. 	city_zone_swap( "hq_dmg", true ) 
  1513. end 
  1514.  
  1515.  
  1516. -- ************************* 
  1517. -- 
  1518. -- Local functions 
  1519. -- 
  1520. -- ************************* 
  1521.  
  1522. -- Initialize the mission for the specified checkpoint 
  1523. -- 
  1524. -- checkpoint:		Checkpoint to initialize the mission to 
  1525. -- 
  1526. function m13_initialize(checkpoint) 
  1527. 	-- Make sure the screen is completly faded out 
  1528. 	mission_start_fade_out(0.0) 
  1529.  
  1530. 	-- Set the mission author 
  1531. 	set_mission_author("Craig Williams") 
  1532. 	 
  1533. 	-- don't allow crib interaction during this mission 
  1534. 	crib_disable_interface( true ) 
  1535.  
  1536. 	-- Common initialization 
  1537. 	m13_initialize_common() 
  1538.  
  1539. 	-- Checkpoint specific initialization 
  1540. 	m13_initialize_checkpoint(checkpoint) 
  1541. 	 
  1542. 	-- don't allow crib interaction during this mission 
  1543. 	crib_disable_interface( true ) 
  1544. end 
  1545.  
  1546.  
  1547. -- *************************************************** 
  1548. -- m13_run Helper Functions 
  1549. -- *************************************************** 
  1550.  
  1551. -- Move the player(s) to the mission start, and setup the required npcs 
  1552. -- 
  1553. function m13_setup_start() 
  1554. 	group_create_hidden(M13_groups.vehicles_start.name, true) 
  1555. 	group_create_hidden(M13_groups.pierce_start.name, true) 
  1556.  
  1557. 	set_unenterable_for_player(M13_groups.pierce_start.vehicle, true) 
  1558.  
  1559. 	inv_weapon_add_temporary(LOCAL_PLAYER, M13_config.grenade, 1, true, true, false) 
  1560. 	if M13_in_coop then 
  1561. 		inv_weapon_add_temporary(REMOTE_PLAYER, M13_config.grenade, 1, true, true, false) 
  1562. 	end 
  1563. end 
  1564.  
  1565. function m13_mission_zscene_post_init() 
  1566. 	vehicle_show(M13_groups.vehicles_start.vehicles[1]) 
  1567. 	if coop_is_active() then 
  1568. 		vehicle_show(M13_groups.vehicles_start.vehicles[2]) 
  1569. 	end 
  1570. 	group_show(M13_groups.pierce_start.name) 
  1571. end 
  1572.  
  1573. -- Unload any groups created during the start of the mission 
  1574. -- 
  1575. function m13_cleanup_start() 
  1576. 	if group_is_loaded(M13_groups.vehicles_start.name) then 
  1577. 		group_destroy(M13_groups.vehicles_start.name) 
  1578. 	end 
  1579.  
  1580. 	if group_is_loaded(M13_groups.pierce_start.name) then 
  1581. 		group_destroy(M13_groups.pierce_start.name) 
  1582. 	end 
  1583. end 
  1584.  
  1585. -- Spawn some statically placed STAG at the pr center, some vehicles for cover, 
  1586. -- and setup all the banners. 
  1587. -- 
  1588. function m13_setup_banner_scene() 
  1589. 	m13_play_persona_line(M13_persona_line.banners) 
  1590. 	M13_banners_alive		= 0 
  1591. 	M13_banner_damaged	= false 
  1592. 	M13_banner_destroyed	= false 
  1593. 	for key, banner in pairs(M13_movers.pr_center_banners) do 
  1594. 		if not mesh_mover_destroyed(banner.name) then 
  1595. 			marker_add(banner.name, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL) 
  1596. 			banner.destroyed = false 
  1597. 			on_mover_destroyed("m13_banner_destroyed", banner.name) 
  1598. 			on_take_damage("m13_banner_damaged", banner.name) 
  1599. 			M13_banners_alive = M13_banners_alive + 1 
  1600. 		else 
  1601. 			M13_banner_damaged	= true 
  1602. 			M13_banner_destroyed	= true 
  1603. 		end 
  1604. 	end 
  1605. end 
  1606.  
  1607. function m13_cleanup_banner_scene() 
  1608. 	if group_is_loaded(M13_groups.pr_static.name) then 
  1609. 		release_to_world(M13_groups.pr_static.name) 
  1610. 		group_destroy(M13_groups.pr_static.name) 
  1611. 	end 
  1612.  
  1613. 	for key, banner in pairs(M13_movers.pr_center_banners) do 
  1614. 		marker_remove(banner.name) 
  1615. 		on_mover_destroyed("", banner.name) 
  1616. 		on_take_damage("", banner.name) 
  1617. 	end 
  1618.  
  1619. 	m13_stop_all_continuous_spawns() 
  1620. end 
  1621.  
  1622.  
  1623. -- Move the player to the observation deck/balcony, start the ambient Saints spawns, and 
  1624. -- create your homies 
  1625. -- 
  1626. function m13_setup_balcony_battle() 
  1627. 	action_nodes_enable( false ) 
  1628. 	m13_setup_balcony_homies() 
  1629.  
  1630. 	-- Setup the some ambient spawns to ocassionaly produce Saints members to slow down the STAG 
  1631. 	-- from entering the building, also add cars for them to take cover behind 
  1632.  
  1633. 	group_create(M13_groups.vehicles_cover.name, true) 
  1634. 	for key, car in pairs(M13_groups.vehicles_cover.vehicles) do 
  1635. 		vehicle_make_corpse(car, false) 
  1636. 	end 
  1637. 	m13_start_continuous_spawns(M13_continuous_spawns.saints_north_ground) 
  1638. 	m13_start_continuous_spawns(M13_continuous_spawns.saints_south_ground) 
  1639. 	--m13_start_continuous_spawns(M13_continuous_spawns.saints_north_balcony) 
  1640. 	m13_start_continuous_spawns(M13_continuous_spawns.saints_south_balcony) 
  1641.  
  1642. 	notoriety_force_no_spawn("Police", true) 
  1643. 	notoriety_force_no_spawn("stag", true) 
  1644. 	notoriety_force_no_spawn("luchadores", true) 
  1645. 	notoriety_force_no_spawn("deckers", true) 
  1646. 	notoriety_force_no_spawn("morningstar", true) 
  1647.  
  1648. 	notoriety_set_min("Police", 5) 
  1649. 	notoriety_set_max("Police", 5) 
  1650.  
  1651. 	if M13_checkpoint == M13_CHECKPOINT_WAVE_3_START then 
  1652. 		local pierce = M13_groups.pierce_rescue.pierce 
  1653.  
  1654. 		group_create(M13_groups.pierce_rescue.name, true) 
  1655. 		party_add(pierce, LOCAL_PLAYER) 
  1656.  
  1657. 		on_death("m13_homie_died", pierce) 
  1658.  
  1659. 		teleport(pierce, M13_nav.elevator_to_ground, true, true, 2.0) 
  1660.  
  1661. 		inv_weapon_add_temporary(LOCAL_PLAYER, M13_config.airstrike, 1, true, true, false) 
  1662. 		if M13_in_coop then 
  1663. 			inv_weapon_add_temporary(REMOTE_PLAYER, M13_config.airstrike, 1, true, true, false) 
  1664. 		end 
  1665. 	end 
  1666. end 
  1667.  
  1668. function m13_setup_balcony_homies() 
  1669. 	-- Create your homies and the aviable weapons to fend off the STAG 
  1670. 	group_create(M13_groups.homies.name, true) 
  1671. 	group_create(M13_groups.weapons.name, true) 
  1672.  
  1673. 	--npc_leash_to_nav(M13_groups.homies.oleg, "nav_oleg_leash", 15.0) 
  1674. 	--follower_make_independent(M13_groups.homies.oleg, true) 
  1675. 	--party_add(M13_groups.homies.oleg, LOCAL_PLAYER) 
  1676. 	--on_death("m13_homie_died", M13_groups.homies.oleg) 
  1677.  
  1678. 	npc_leash_to_nav(M13_groups.homies.viola, "nav_viola_leash", 15.0) 
  1679. 	follower_make_independent(M13_groups.homies.viola, true) 
  1680. 	party_add(M13_groups.homies.viola, LOCAL_PLAYER) 
  1681. 	on_death("m13_homie_died", M13_groups.homies.viola) 
  1682. 	turn_invulnerable( M13_groups.homies.viola ) 
  1683. end 
  1684.  
  1685.  
  1686.  
  1687.  
  1688. function m13_start_continuous_spawns(spawns) 
  1689. 	for key, region in pairs(spawns.regions) do 
  1690. 		spawn_region_toggle_filter(region, spawns.filter) 
  1691. 		spawn_region_enable(region, true) 
  1692. 	end 
  1693.  
  1694. 	for key, group in pairs(spawns.groups) do 
  1695. 		continuous_spawn_start(group, 0, spawns.respawn_delay, "", spawns.filter) 
  1696. 	end 
  1697.  
  1698. 	spawns.loaded = true 
  1699. end 
  1700.  
  1701. function m13_stop_continuous_spawns(spawns) 
  1702. 	if spawns.loaded ~= true then 
  1703. 		return 
  1704. 	end 
  1705.  
  1706. 	for key, group in pairs(spawns.groups) do 
  1707. 		continuous_spawn_stop(group, false) 
  1708. 	end 
  1709. 	continuous_spawn_regions_enable(spawns.regions, false) 
  1710.  
  1711. 	spawns.loaded = nil 
  1712. end 
  1713.  
  1714. function m13_stop_all_continuous_spawns() 
  1715. 	for key, spawns in pairs(M13_continuous_spawns) do 
  1716. 		m13_stop_continuous_spawns(spawns) 
  1717. 	end 
  1718. end 
  1719.  
  1720. -- Cleans up everything setup by m13_setup_balcony_battle() 
  1721. -- 
  1722. function m13_cleanup_balcony_battle() 
  1723. 	m13_cleanup_balcony_homies() 
  1724.  
  1725. 	if group_is_loaded(M13_groups.pierce_rescue.name) then 
  1726. 		if npc_is_in_party(M13_groups.pierce_rescue.pierce) then 
  1727. 			on_dismiss("", M13_groups.pierce_rescue.pierce) 
  1728. 			party_dismiss(M13_groups.pierce_rescue.pierce) 
  1729. 		end 
  1730. 		marker_remove(M13_groups.pierce_rescue.pierce, SYNC_ALL) 
  1731. 		on_death("", M13_groups.pierce_rescue.pierce) 
  1732. 		group_destroy(M13_groups.pierce_rescue.name) 
  1733. 	end 
  1734. 	 
  1735. 	if group_is_loaded(M13_groups.pierce_attack.name) then 
  1736. 		marker_remove(M13_groups.pierce_rescue.tank, SYNC_ALL) 
  1737. 		group_destroy(M13_groups.pierce_attack.name) 
  1738. 	end 
  1739.  
  1740. 	m13_stop_wave_set(M13_waves) 
  1741. 	m13_stop_all_continuous_spawns() 
  1742.  
  1743. 	if group_is_loaded(M13_groups.vehicles_cover.name) then 
  1744. 		group_destroy(M13_groups.vehicles_cover.name) 
  1745. 	end 
  1746. end 
  1747.  
  1748. function m13_cleanup_balcony_homies() 
  1749. 	if group_is_loaded(M13_groups.homies.name) then 
  1750. 		marker_remove(M13_groups.homies.viola) 
  1751. 		party_dismiss(M13_groups.homies.viola) 
  1752. 		--party_dismiss(M13_groups.homies.oleg) 
  1753. 		--on_death("", M13_groups.homies.oleg) 
  1754. 		on_death("", M13_groups.homies.viola) 
  1755. 		group_destroy(M13_groups.homies.name) 
  1756. 	end 
  1757.  
  1758. 	if group_is_loaded(M13_groups.weapons.name) then 
  1759. 		group_destroy(M13_groups.weapons.name) 
  1760. 	end 
  1761. end 
  1762.  
  1763. -- Moves the player to the penthouse and spawn any needed homies 
  1764. -- 
  1765. function m13_setup_decision() 
  1766. 	world_despawn_all_vehicles() 
  1767. 	group_create(M13_groups.penthouse_homies.name, true) 
  1768. 	on_death("m13_homie_died", M13_groups.penthouse_homies.josh) 
  1769. end 
  1770.  
  1771. -- Cleanup any groups set up by m13_setup_decision() 
  1772. -- 
  1773. function m13_cleanup_decision() 
  1774. 	if group_is_loaded(M13_groups.penthouse_homies.name) then 
  1775. 		on_death("", M13_groups.penthouse_homies.josh) 
  1776. 		group_destroy(M13_groups.penthouse_homies.name) 
  1777. 	end 
  1778.  
  1779. 	-- penthouse_stag is setup by m13_penthouse_cutscene(). Clean it up here. 
  1780. 	if group_is_loaded(M13_groups.penthouse_stag.name) then 
  1781. 		for key, vtol in pairs(M13_groups.penthouse_stag.vtols) do 
  1782. 			if vtol.thread ~= INVALID_THREAD_HANDLE then 
  1783. 				thread_kill(vtol.thread) 
  1784. 				vtol.thread = INVALID_THREAD_HANDLE 
  1785. 			end 
  1786. 		end 
  1787.  
  1788. 		group_destroy(M13_groups.penthouse_stag.name) 
  1789. 	end 
  1790. end 
  1791.  
  1792. -- Hides the car bombs 
  1793. -- 
  1794. function m13_hide_car_bombs() 
  1795. 	for key, bomb in pairs(M13_movers.bombs) do 
  1796. 		local mover_name = bomb.mover 
  1797. 		mesh_mover_hide(mover_name) 
  1798. 	end 
  1799. end 
  1800.  
  1801. -- Unhides and resets the car bombs 
  1802. -- 
  1803. function m13_show_car_bombs() 
  1804. 	for key, bomb in pairs(M13_movers.bombs) do 
  1805. 		local mover_name = bomb.mover 
  1806. 		mesh_mover_reset(mover_name) 
  1807. 		mesh_mover_show(mover_name) 
  1808. 	end 
  1809. end 
  1810.  
  1811. function m13_find_closest_car_bomb(north_side) 
  1812. 	local closest = "" 
  1813. 	local closest_dist = 100000.0 
  1814. 	 
  1815. 	for key, bomb in pairs(M13_movers.bombs) do 
  1816. 		local mover_name = bomb.mover 
  1817. 		if bomb.north_side == north_side and not mesh_mover_destroyed(mover_name) then 
  1818. 			local dist = get_dist(LOCAL_PLAYER, mover_name) 
  1819. 			if dist < closest_dist then 
  1820. 				closest = mover_name 
  1821. 				closest_dist = dist 
  1822. 			end 
  1823. 		end 
  1824. 	end 
  1825. 	 
  1826. 	return closest, closest_dist 
  1827. end 
  1828.  
  1829. function m13_car_bomb_destroyed(north_side)	 
  1830. 	for key, bomb in pairs(M13_movers.bombs) do 
  1831. 		local mover_name = bomb.mover 
  1832. 		if bomb.north_side == north_side and mesh_mover_destroyed(mover_name) then 
  1833. 			return true 
  1834. 		end 
  1835. 	end 
  1836. 	 
  1837. 	return false 
  1838. end 
  1839.  
  1840. -- Setup all the car bombs 
  1841. -- 
  1842. function m13_setup_car_bombs() 
  1843. 	-- Setup a callback to detect when the player damage the bombs 
  1844. 	for key, bomb in pairs(M13_movers.bombs) do 
  1845. 		local mover_name = bomb.mover 
  1846. 		on_take_damage("m13_mover_damaged", mover_name) 
  1847. 	end 
  1848.  
  1849. 	-- Setup a thread to handle the chain reactions and bomb respawning 
  1850. 	M13_THREAD_CAR_BOMB_MANAGER = thread_new("m13_thread_car_bomb_manager") 
  1851. end 
  1852.  
  1853. -- Cleans up everything setup by m13_setup_car_bombs() 
  1854. -- 
  1855. function m13_cleanup_car_bombs() 
  1856. 	for key, bomb in pairs(M13_movers.bombs) do 
  1857. 		local mover_name = bomb.mover 
  1858. 		on_take_damage("", mover_name) 
  1859. 	end 
  1860.  
  1861. 	if M13_THREAD_CAR_BOMB_MANAGER ~= INVALID_THREAD_HANDLE then 
  1862. 		thread_kill(M13_THREAD_CAR_BOMB_MANAGER) 
  1863. 		M13_THREAD_CAR_BOMB_MANAGER = INVALID_THREAD_HANDLE 
  1864. 	end 
  1865. end 
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878. -- Tell the player to go to the PR Center and destroy the STAG's banner 
  1879. -- 
  1880. function m13_destroy_banner() 
  1881. 	-- start creating the group now 
  1882. 	group_create(M13_groups.pr_static.name, true) 
  1883. 	mesh_mover_show(M13_movers.pr_center_banners[1].name) 
  1884. 	mesh_mover_show(M13_movers.pr_center_banners[2].name) 
  1885. 	 
  1886. 	m13_goto_a_trigger(M13_triggers.pr_center_front, M13_OBJ_GOTO_PR_CENTER, true) 
  1887.  
  1888. 	m13_setup_banner_scene() 
  1889.  
  1890. 	objective_text(0, M13_OBJ_DESTROY_STAG_BANNER, "", "", SYNC_ALL, OI_ASSET_KILL) 
  1891.  
  1892. 	-- if not M13_banner_damaged then 
  1893. 	-- 	m13_play_persona_line(M13_persona_line.molotov_remind) 
  1894. 	-- end 
  1895. 	 
  1896. 	-- Wait until a banner is damaged 
  1897. 	while not M13_banner_damaged do 
  1898. 		thread_yield() 
  1899. 	end 
  1900.  
  1901. 	-- Remove the on_take_damage callbacks since we no longer care about this event 
  1902. 	for key, banner in pairs(M13_movers.pr_center_banners) do 
  1903. 		on_take_damage("", banner.name) 
  1904. 	end 
  1905.  
  1906. 	-- Start some ambient STAG and notoriety spawns 
  1907. 	-- m13_start_continuous_spawns(M13_continuous_spawns.pr_center_wave_1) 
  1908. 	notoriety_set_min("Police", M13_config.min_notoriety_after_banner_damaged) 
  1909.  
  1910. 	-- Wait until the banner is destroyed 
  1911. 	while not M13_banner_destroyed do 
  1912. 		thread_yield() 
  1913. 	end 
  1914.  
  1915. 	-- Start some additional STAG spawns and up the notoriety 
  1916. 	-- m13_start_continuous_spawns(M13_continuous_spawns.pr_center_wave_2) 
  1917. 	notoriety_set_min("Police", M13_config.min_notoriety_after_banner_destroyed) 
  1918.  
  1919. 	-- Wait until all banners are destroyed 
  1920. 	while M13_banners_alive > 0 do 
  1921. 		thread_yield() 
  1922. 	end 
  1923.  
  1924. 	notoriety_set_min("Police", M13_config.min_notoreity_after_all_banners_destroyed) 
  1925.  
  1926. 	m13_cleanup_banner_scene() 
  1927. end 
  1928.  
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937. -- Plays the mid mission cutscene and sets up the STAG to reflect the scene. 
  1938. -- 
  1939. function m13_penthouse_cutscene() 
  1940. 		-- Prevent the player from moving 
  1941. 	player_movement_disable(LOCAL_PLAYER) 
  1942.  
  1943. 	group_create_hidden(M13_groups.penthouse_stag.name, true) 
  1944.  
  1945. 	if false then 
  1946. 		teleport_coop( M13_nav.player_penthouse, M13_nav.remote_penthouse ) 
  1947. 	else 
  1948. 		cutscene_play( "13_Z01", nil, { M13_nav.player_penthouse, M13_nav.remote_penthouse } ) 
  1949. 	end 
  1950. 	 
  1951. 	-- Ensure the local and remote player are in the proper location 
  1952. 	-- Prevent the Player from doing anything bad 
  1953. 	m13_restrict_players() 
  1954.  
  1955. 	m13_setup_penthouse_stag() 
  1956. 	 
  1957. 	group_show( M13_groups.penthouse_stag.name ) 
  1958. 	 
  1959. 	while character_is_ready( M13_groups.penthouse_homies.josh ) == false do 
  1960. 		thread_yield() 
  1961. 	end 
  1962. 	 
  1963. 	-- Force the player to take Josh as a Human Shield 
  1964. 	player_take_human_shield(LOCAL_PLAYER, M13_groups.penthouse_homies.josh, true) 
  1965. 	action_play_synced_state(LOCAL_PLAYER, M13_groups.penthouse_homies.josh, "HS_Stand_M13") 
  1966. 	player_human_shield_lock(LOCAL_PLAYER, true) 
  1967. end 
  1968.  
  1969. -- Sets up the STAG to match the cutscene 
  1970. -- 
  1971. function m13_setup_penthouse_stag() 
  1972. 	for key, vtol in pairs(M13_groups.penthouse_stag.vtols) do 
  1973. 		m13_setup_penthouse_vtol(vtol) 
  1974. 	end 
  1975. end 
  1976.  
  1977. -- Populates a vtol and moves it to the proper location 
  1978. -- 
  1979. function m13_setup_penthouse_vtol(vtol) 
  1980. 	-- Populate the vtol 
  1981. 	vehicle_enter_group_teleport(vtol.members, vtol.name) 
  1982. 	vehicle_suppress_npc_exit(vtol.name, true) 
  1983. 	thread_yield() 
  1984.  
  1985. 	-- Move the vtol to the proper location 
  1986. 	teleport_vehicle(vtol.name, vtol.nav) 
  1987. 	thread_yield() 
  1988.  
  1989. 	if vtol.fly_to ~= "" then 
  1990. 		M13_threads[ vtol.name .. "_fly_to" ] = thread_new( "m13_decision_heli_thread", vtol.name, vtol.fly_to) 
  1991. 	else 
  1992. 		M13_threads[ vtol.name .. "_fly_to" ] = thread_new( "m13_decision_heli_thread", vtol.name, vtol.nav) 
  1993. 	end 
  1994. end 
  1995.  
  1996. -- another wrapper for the fly_to so it can be threaded without barfing Lua 
  1997. function m13_decision_heli_thread( name, fly_to ) 
  1998. 	helicopter_fly_to_direct( name, -1, fly_to) 
  1999. end 
  2000.  
  2001. -- Prevents the player from doing anything harmful during the decision scene 
  2002. -- 
  2003. function m13_restrict_players() 
  2004. 	-- Prevent the player from using any weapons 
  2005. 	inv_item_equip(nil, LOCAL_PLAYER) 
  2006. 	inv_weapon_disable_all_slots(true, SYNC_LOCAL) 
  2007. 	player_actions_disable(LOCAL_PLAYER) 
  2008.  
  2009. 	-- Limit the Player's view range to Cyrus and Shaundi 
  2010. 	camera_restrict_target_object(M13_groups.penthouse_stag.vtols[1].name, 0, LOCAL_PLAYER) 
  2011. 	camera_restrict_set_limits(-10, 10, -35, 30, LOCAL_PLAYER) 
  2012. 	camera_restrict_set_active(true, LOCAL_PLAYER) 
  2013. 	player_grenades_disable() 
  2014. 	turn_invulnerable( LOCAL_PLAYER ) 
  2015.  
  2016. 	-- Do the same for the remote player if needed 
  2017. 	if M13_in_coop then 
  2018. 		player_movement_disable(REMOTE_PLAYER) 
  2019. 		player_actions_disable(REMOTE_PLAYER) 
  2020. 		inv_item_equip(nil, REMOTE_PLAYER) 
  2021. 		inv_weapon_disable_all_slots(true, SYNC_REMOTE) 
  2022. 		camera_restrict_target_object(M13_groups.penthouse_stag.vtols[1].name, 0, REMOTE_PLAYER) 
  2023. 		camera_restrict_set_limits(-10, 10, -35, 30, REMOTE_PLAYER) 
  2024. 		camera_restrict_set_active(true, REMOTE_PLAYER) 
  2025. 		turn_invulnerable( REMOTE_PLAYER ) 
  2026. 	end 
  2027. end 
  2028.  
  2029. -- Allows the player to move, use weapons, and unrestricts the camera 
  2030. -- 
  2031. function m13_unrestrict_players() 
  2032. 	player_movement_enable(LOCAL_PLAYER) 
  2033. 	inv_weapon_disable_all_slots(false, SYNC_LOCAL) 
  2034. 	camera_restrict_set_active(false, LOCAL_PLAYER) 
  2035. 	player_grenades_enable() 
  2036. 	player_actions_enable(LOCAL_PLAYER) 
  2037. 	turn_vulnerable( LOCAL_PLAYER ) 
  2038.  
  2039. 	if M13_in_coop then 
  2040. 		player_movement_enable(REMOTE_PLAYER) 
  2041. 		player_actions_enable(REMOTE_PLAYER) 
  2042. 		inv_weapon_disable_all_slots(false, SYNC_REMOTE) 
  2043. 		camera_restrict_set_active(false, REMOTE_PLAYER) 
  2044. 		turn_vulnerable( REMOTE_PLAYER ) 
  2045. 	end 
  2046.  
  2047. 	player_human_shield_lock(LOCAL_PLAYER, false) 
  2048. end 
  2049.  
  2050. -- Haandles the logic of the Player's decision. Wait until the player throws Josh to Cyrus, the player 
  2051. -- throws Josh to Shuandi, or if the player doesn't do anything for ~60 seconds. 
  2052. -- 
  2053. function m13_player_decision() 
  2054. 	local josh = M13_groups.penthouse_homies.josh 
  2055. 	local cyrus = M13_groups.penthouse_stag.cyrus 
  2056. 	local shaundi = M13_groups.penthouse_homies.shaundi 
  2057.  
  2058. 	-- Initialize the variables used by the callbacks 
  2059. 	M13_josh_given_to_cyrus	 = false 
  2060. 	M13_josh_given_to_homies = false 
  2061.  
  2062. 	player_human_shield_lock(LOCAL_PLAYER, true) 
  2063. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, false) 
  2064. 	set_unjackable_flag( M13_groups.penthouse_stag.vtols[ 1 ].name, true ) 
  2065. 	if M13_in_coop then 
  2066. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, false) 
  2067. 	end 
  2068.  
  2069. 	delay(2.0) 
  2070. 	m13_start_convo_thread( M13_convo.decision1 ) 
  2071. 	 
  2072. 	-- show tutorial after delay 
  2073. 	marker_add( cyrus, MINIMAP_ICON_USE, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL) 
  2074. 	marker_add( shaundi, MINIMAP_ICON_USE, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL) 
  2075.  
  2076. 	object_indicator_add_objective_text( cyrus, "PLAYER_CHOICE_M13_OPTION1_TITLE", "PLAYER_CHOICE_M13_OPTION1_BODY") 
  2077. 	object_indicator_add_objective_text( shaundi, "PLAYER_CHOICE_M13_OPTION2_TITLE", "PLAYER_CHOICE_M13_OPTION2_BODY") 
  2078.  
  2079. 	local active_prompt = "" 
  2080. 	while not M13_josh_given_to_cyrus and not M13_josh_given_to_homies do 
  2081. 		thread_yield() 
  2082.  
  2083. 		-- Check to see who the player is looking at 
  2084. 		if fov_check_xz_plane(LOCAL_PLAYER, shaundi, M13_config.fov_to_shaundi) then 
  2085. 			if active_prompt ~= M13_PROMPT_THROW_JOSH_TO_SHAUNDI then 
  2086. 				hud_prompt(LOCAL_PLAYER, M13_PROMPT_THROW_JOSH_TO_SHAUNDI, "m13_josh_thrown_to_homies") 
  2087. 				active_prompt = M13_PROMPT_THROW_JOSH_TO_SHAUNDI 
  2088. 			end 
  2089.  
  2090. 		elseif fov_check_xz_plane(LOCAL_PLAYER, cyrus, M13_config.fov_to_cyrus) then 
  2091. 			if active_prompt ~= M13_PROMPT_THROW_JOSH_TO_CYRUS then 
  2092. 				hud_prompt(LOCAL_PLAYER, M13_PROMPT_THROW_JOSH_TO_CYRUS, "m13_josh_thrown_to_cyrus") 
  2093. 				active_prompt = M13_PROMPT_THROW_JOSH_TO_CYRUS 
  2094. 			end 
  2095.  
  2096. 		else 
  2097. 			if active_prompt ~= "" then 
  2098. 				hud_prompt_clear(LOCAL_PLAYER) 
  2099. 				active_prompt = "" 
  2100. 			end 
  2101.  
  2102. 		end 
  2103.  
  2104. 		-- If the conversation thread was terminated, then Cyrus is done waiting. 
  2105. 		-- Assume the Player wanted to keep josh in this situation 
  2106. 		if M13_convo.decision1.thread == INVALID_THREAD_HANDLE then 
  2107. 			m13_josh_thrown_to_homies() 
  2108. 		end 
  2109. 	end 
  2110.  
  2111. 	marker_remove( cyrus ) 
  2112. 	marker_remove( shaundi ) 
  2113.  
  2114. 	player_human_shield_lock(LOCAL_PLAYER, false) 
  2115. 	player_release_human_shield( LOCAL_PLAYER, true ) 
  2116. 	action_stop_synced_state(LOCAL_PLAYER) 
  2117. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, true) 
  2118. 	set_unjackable_flag( M13_groups.penthouse_stag.vtols[ 1 ].name, false ) 
  2119. 	if M13_in_coop then 
  2120. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, true) 
  2121. 	end 
  2122. 	hud_prompt_clear(LOCAL_PLAYER) 
  2123. 	m13_unload_all_convos() 
  2124.  
  2125. 	-- The player has made their decision. Have them release Josh. 
  2126. 	action_play_synced( LOCAL_PLAYER, josh, "Mad13_Human_Shield_release1" ) 
  2127.  
  2128. 	-- Add a short delay to ensure that the NPC is in a useable state 
  2129. 	set_ignore_ai_flag(josh, false) 
  2130. 	delay(0.4) 
  2131. 	npc_go_idle(josh) 
  2132. 	 
  2133. 	-- Tell Josh to run to who ever he was told to go to 
  2134. 	-- if M13_josh_given_to_homies then 
  2135. 	-- 	ai_do_scripted_move(josh, M13_nav.josh_to_shaundi, true, false) 
  2136. 	-- else 
  2137. 	-- 	ai_do_scripted_move(josh, M13_nav.josh_to_cyrus, true, false) 
  2138. 	-- end 
  2139.  
  2140. 	while ai_scripted_action_is_processing(josh) and not ai_scripted_action_is_complete(josh) do 
  2141. 		thread_yield() 
  2142. 	end 
  2143. 	delay(0.2) 
  2144. 	set_ignore_ai_flag(josh, true) 
  2145. end 
  2146.  
  2147. -- Turns a VTOL around, tells Cyrus to walk up to it, and then have him jump on board with or without Josh 
  2148. -- 
  2149. -- cyrus				- Name of Cyrus 
  2150. -- josh				- Name of Josh 
  2151. -- cyrus_has_josh	- Was Josh given to Cyrus? 
  2152. -- vtol				- Name of the VTOL Cyrus should enter 
  2153. -- 
  2154. function m13_cyrus_enter_vtol(cyrus, josh, cyrus_has_josh, vtol) 
  2155. 	local r 
  2156.  
  2157. 	if cyrus_has_josh then 
  2158. 		vehicle_enter(cyrus, vtol.name, 4, false) 
  2159. 		m13_start_convo_thread(M13_convo.shell_the_building) 
  2160. 		vehicle_enter(josh, vtol.name, 3, false) 
  2161.  
  2162. 		repeat 
  2163. 			thread_yield() 
  2164. 			r = vehicle_enter_check_done(cyrus, false, vtol.name) 
  2165. 		until r ~= 0 
  2166.  
  2167. 		repeat 
  2168. 			thread_yield() 
  2169. 			r = vehicle_enter_check_done(josh, false, vtol.name) 
  2170. 		until r ~= 0 
  2171. 	else 
  2172. 		m13_start_convo_thread(M13_convo.shell_the_building) 
  2173. 		vehicle_enter(cyrus, vtol.name, 4, true) 
  2174. 	end 
  2175. end 
  2176.  
  2177. -- Tells Cyrus to fly off. If Josh was given to cryus, the guard VTOLs will follow; otherwise, 
  2178. -- the VTOLs will be told to attack the player. 
  2179. -- 
  2180. -- cyrus				- Name of the Cyrus NPC 
  2181. -- cyrus_has_josh	- Was josh given to cyrus? 
  2182. -- cyrus_vtol		- VTOL Cyrus is in 
  2183. -- 
  2184. function M13_cyrus_fly_off(cyrus, cyrus_has_josh, cyrus_vtol) 
  2185. 	ai_do_scripted_move(M13_groups.penthouse_homies.shaundi, M13_nav.penthouse_elevator, true, false) 
  2186. 	 
  2187. 	if not cyrus_has_josh then 
  2188. 		ai_do_scripted_move(M13_groups.penthouse_homies.josh, M13_nav.penthouse_elevator, true, false) 
  2189. 	end 
  2190.  
  2191. 	for key, vtol in pairs(M13_groups.penthouse_stag.vtols) do 
  2192. 		if vtol == cyrus_vtol then 
  2193. 			vtol.thread = thread_new("m13_thread_vtol_fly_away", vtol) 
  2194. 		else 
  2195. 			local driver = vtol.members[1] 
  2196. 			ai_set_action_delay(driver, "throw grenade", 9999) 
  2197. 			set_ignore_ai_flag(driver, false) 
  2198. 			npc_hearing_enable(driver, true) 
  2199. 			ai_add_enemy_target(driver, LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE, true) 
  2200. 		end 
  2201. 	end 
  2202. 	 
  2203. 	if cyrus_has_josh then 
  2204. 		m13_start_convo_thread(M13_convo.shell_without_birk) 
  2205. 	else 
  2206. 		m13_start_convo_thread(M13_convo.shell_with_birk) 
  2207. 	end 
  2208. end 
  2209.  
  2210. -- Blocks until the player runs to the elevator or jumps off the building 
  2211. -- 
  2212. function m13_player_leave_penthouse() 
  2213. 	-- Setup a time limit to escape the battle 
  2214. 	hud_timer_set(1, M13_config.time_to_escape * 1000.0, "m13_time_is_up", SYNC_ALL) 
  2215. 	hud_timer_hide(1, false) 
  2216.  
  2217. 	-- The player can complete this objective by jumping off the building. Enable to trigger to disable this. 
  2218. 	trigger_enable(M13_triggers.penthouse_jumped, true) 
  2219. 	on_trigger_exit("m13_jumped_off_penthouse", M13_triggers.penthouse_jumped) 
  2220.  
  2221. 	-- Instruct the player to get to the Penthouse elevator 
  2222. 	M13_status.jumped_off_penthouse = false 
  2223. 	objective_text(0, M13_OBJ_ESCAPE, "", "", SYNC_ALL, OI_ASSET_LOCATION) 
  2224. 	marker_add(M13_nav.jump_to, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL, SYNC_ALL) 
  2225.  
  2226. 	-- wait for a player to leave area 
  2227. 	while M13_status.jumped_off_penthouse == false do 
  2228. 		thread_yield() 
  2229. 	end 
  2230. 	 
  2231. 	hud_timer_stop( 1 ) 
  2232. end 
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239. -- Marks a car bomb to explode 
  2240. -- 
  2241. -- mover_name: Name of the mover to detonate 
  2242. -- 
  2243. function m13_car_bomb_detonate(mover_name) 
  2244. 	for key, bomb in pairs(M13_movers.bombs) do 
  2245. 		if bomb.mover == mover_name then 
  2246. 			-- Mark the bomb to explode 
  2247. 			bomb.detonate 	= true 
  2248.  
  2249. 			-- Set the bomb to explode without a delay 
  2250. 			bomb.delay		= 0.0 
  2251. 			return 
  2252. 		end 
  2253. 	end 
  2254. end 
  2255.  
  2256. -- A bomb has exploded. Find all bombs that should detontate based off the chain reaction effect. 
  2257. -- 
  2258. -- exploding_bomb: Bomb that has just exploded 
  2259. -- 
  2260. function m13_car_bomb_start_chain_reaction(exploding_bomb) 
  2261. 	-- Iterate through the entire table and check to see if the other bombs are affected. 
  2262. 	-- Since these are all movers, we cannot cache the relationship between bombs. 
  2263. 	for key, bomb in pairs(M13_movers.bombs) do 
  2264. 		local dist	= get_dist(exploding_bomb.mover, bomb.mover) 
  2265.  
  2266. 		if not mesh_mover_destroyed(bomb.mover) and dist < M13_config.chain_reaction_max_dist then 
  2267. 			-- The bomb is alive and within the chain reaction range. Calculte the explosion delay and update 
  2268. 			-- the bomb as such. 
  2269. 			local delay = M13_config.chain_reaction_delay 
  2270.  
  2271. 			if M13_config.chain_reaction_scale_delay == true then 
  2272. 				-- Scale the delay based off how far the bomb is from the exploding bomb. 
  2273. 				delay = M13_config.chain_reaction_scale_mul * delay * dist / M13_config.chain_reaction_max_dist 
  2274. 			end 
  2275.  
  2276. 			if not bomb.detonate or delay < bomb.delay then 
  2277. 				bomb.detonate	= true 
  2278. 				bomb.delay		= delay 
  2279. 			end 
  2280. 		end 
  2281. 	end 
  2282. end 
  2283.  
  2284. -- Iterates through the active bomb list and check for any bombs that should explode. 
  2285. -- Returns an updated list of active bombs 
  2286. -- 
  2287. -- active:	Table of active car bombs 
  2288. -- 
  2289. function m13_car_bombs_check_for_detonation(active) 
  2290. 	if #active == 0 then 
  2291. 		return active 
  2292. 	end 
  2293.  
  2294. 	local frame_time = get_frame_time() 
  2295. 	local still_active = {} 
  2296.  
  2297. 	for key, bomb in pairs(active) do 
  2298. 		-- Check to see if the bomb is marked to explode 
  2299. 		if bomb.detonate and bomb.delay <= 0.0 then 
  2300. 				-- Bomb timer is up. 
  2301. 				m13_car_bomb_start_chain_reaction(bomb) 
  2302.  
  2303. 				-- Destroy the mover and trigger the on death explosion 
  2304. 				mesh_mover_kill(bomb.mover) 
  2305. 		else 
  2306. 			if bomb.detonate then 
  2307. 				-- Bomb timer still has some time left. Wait to actually detonate it. 
  2308. 				bomb.delay = bomb.delay - frame_time 
  2309. 			end 
  2310. 			still_active[#still_active + 1] = bomb 
  2311. 		end 
  2312. 	end 
  2313.  
  2314. 	return still_active 
  2315. end 
  2316.  
  2317.  
  2318.  
  2319.  
  2320.  
  2321.  
  2322.  
  2323.  
  2324.  
  2325. function m13_setup_save_pierce_wave() 
  2326. 	-- Spawn Pierce and have him enter his car 
  2327. 	group_create(M13_groups.pierce_rescue.name, true) 
  2328. 	group_create(M13_groups.pierce_attack.name, true) 
  2329. 	local pierce			= M13_groups.pierce_rescue.pierce 
  2330. 	local vehicle			= M13_groups.pierce_rescue.vehicle 
  2331. 	local tank				= M13_groups.pierce_attack.tank 
  2332. 	local tank_members	= M13_groups.pierce_attack.tank_members 
  2333.  
  2334. 	on_death("m13_homie_died", pierce) 
  2335.  
  2336. 	-- Don't allow Pierce to take damage until he gets to the crash site 
  2337. 	turn_invulnerable(pierce) 
  2338.  
  2339. 	-- It may take a few frames for Pierce to enter his vehicle, so prevent him from being disrupted 
  2340. 	set_ignore_ai_flag(pierce, true) 
  2341. 	character_prevent_explosion_fling(pierce, true) 
  2342. 	character_prevent_flinching(pierce, true) 
  2343.  
  2344. 	vehicle_suppress_npc_exit(tank, true) 
  2345. 	vehicle_enter_teleport(tank_members[1], tank, 0, true) 
  2346. 	vehicle_enter_teleport(tank_members[2], tank, 1, true) 
  2347. 	vehicle_enter_teleport(pierce, vehicle, 0, true) 
  2348.  
  2349. 	vehicle_suppress_npc_exit(vehicle, true) 
  2350. 	set_ignore_ai_flag(pierce, false) 
  2351. 	character_prevent_flinching(pierce, false) 
  2352.  
  2353. 	-- Set the tank to be hostile to Pierce 
  2354. 	for key, npc in pairs(tank_members) do 
  2355. 		ai_add_enemy_target(npc, pierce, ATTACK_NOW_NEVER_LOSE) 
  2356. 	end 
  2357. end 
  2358.  
  2359. function m13_pierce_drive_in() 
  2360. 	local pierce			= M13_groups.pierce_rescue.pierce 
  2361. 	local vehicle			= M13_groups.pierce_rescue.vehicle 
  2362. 	local tank				= M13_groups.pierce_attack.tank 
  2363.  
  2364. 	-- Make sure the tank and pierce actually get to their destination 
  2365. 	-- vehicle_infinite_mass(tank, true) 
  2366. 	vehicle_infinite_mass(vehicle, true) 
  2367. 	vehicle_set_script_hard_goto(vehicle, true) 
  2368. 	vehicle_suppress_flipping(vehicle, true) 
  2369.  
  2370. 	-- Add the marker as soon as possible, since it's hard to pick him out otherwise 
  2371. 	marker_add(pierce, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND, OI_FLAGS_FULL, SYNC_ALL) 
  2372. 	m13_start_convo_thread(M13_convo.pierce_drive_in) 
  2373.  
  2374. 	if M13_status.restart_checkpoint == M13_CHECKPOINT_WAVE_2_START then 
  2375. 		audio_object_post_event("M13_Score_Checkpoint_Wave2", nil, nil, LOCAL_PLAYER) 
  2376. 	else 
  2377. 		audio_object_post_event("M13_Score_Cover_Pierce", nil, nil, LOCAL_PLAYER) 
  2378. 	end 
  2379.  
  2380. 	objective_text(0, M13_OBJ_COVER_PIERCE, "", "", SYNC_ALL, OI_ASSET_DEFEND) 
  2381. 	m13_setup_side("clear") 
  2382. 	-- vehicle_chase(tank, pierce, false, false, true, false) 
  2383. 	 
  2384. 	vehicle_speed_override(vehicle, 30.0) 
  2385. 	vehicle_speed_override(tank, 20.0) 
  2386. 	M13_threads.pierce_flee = thread_new( "m13_thread_wrapper", vehicle_pathfind_to, vehicle, M13_groups.pierce_rescue.path, true, true, false, true ) 
  2387. 	M13_threads.tank_chase_pierce = thread_new( "m13_thread_wrapper", vehicle_pathfind_to, tank, M13_groups.pierce_attack.path, true, true, false, true ) 
  2388. 	 
  2389. 	local time_waited = 0 
  2390. 	while time_waited < 45 and vehicle_pathfind_check_done( vehicle ) == 0 do 
  2391. 		time_waited = time_waited + get_frame_time() 
  2392. 		thread_yield() 
  2393. 	end 
  2394. 	 
  2395. 	thread_kill( M13_threads.pierce_flee ) 
  2396. 	vehicle_stop( vehicle ) 
  2397.  
  2398. 	-- Allow the tank and pierce's car to be pushed around again 
  2399. 	-- vehicle_infinite_mass(tank, false) 
  2400. 	vehicle_infinite_mass(vehicle, false) 
  2401.  
  2402. 	-- Setting a vehicle on fire will force pierce to exit as well 
  2403. 	vehicle_suppress_npc_exit(vehicle, false) 
  2404. 	vehicle_set_smoke_and_fire_state(vehicle, true, true) 
  2405. 	 
  2406. 	-- lets make sure he gets out and stays out 
  2407. 	vehicle_exit_teleport( pierce ) 
  2408. 	ai_clear_scripted_action ( pierce ) 
  2409.  
  2410. 	marker_remove(pierce) 
  2411. end 
  2412.  
  2413. function m13_cleanup_save_pierce_wave() 
  2414. end 
  2415.  
  2416. function m13_goto_ground(obj_text) 
  2417. 	m13_play_persona_line(M13_persona_line.elevator) 
  2418. 	m13_goto_a_trigger(M13_triggers.elevator_to_ground, obj_text) 
  2419. 	fade_out(0.5) 
  2420. 	fade_out_block() 
  2421. 	teleport_coop(M13_nav.elevator_to_balcony, M13_nav.elevator_to_balcony_remote) 
  2422. 	fade_in(0.5) 
  2423. 	fade_in_block() 
  2424. end 
  2425.  
  2426. function m13_goto_balcony(obj_text) 
  2427. 	m13_goto_a_trigger(M13_triggers.elevator_proximity, obj_text) 
  2428. 	fade_out(0.5) 
  2429. 	fade_out_block() 
  2430. 	teleport_coop(M13_nav.elevator_to_ground, M13_nav.elevator_to_ground_remote, true) 
  2431. 	fade_in(0.5) 
  2432. 	fade_in_block() 
  2433. end 
  2434.  
  2435. function m13_save_pierce() 
  2436. 	local pierce = M13_groups.pierce_rescue.pierce 
  2437. 	local normal_hitpoints = 0 
  2438. 	 
  2439. 	normal_hitpoints = get_max_hit_points(pierce) 
  2440. 	set_max_hit_points(pierce, 50000, true)  
  2441.  
  2442. 	-- Allow Pierce to be killed now 
  2443. 	turn_vulnerable(pierce) 
  2444. 	objective_text(0, M13_OBJ_GOTO_PIERCE, "", "", SYNC_ALL, OI_ASSET_LOCATION) 
  2445. 	m13_setup_side("clear") 
  2446. 	marker_add(pierce, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_FULL, SYNC_ALL) 
  2447. 	 
  2448. 	m13_vfx_play(M13_vfxs.hq_01) 
  2449. 	m13_vfx_play(M13_vfxs.north_02) 
  2450. 	m13_distance_clutter_show() 
  2451. 	m13_vfx_play(M13_vfxs.south_02) 
  2452. 	 
  2453. 	m13_play_persona_line(M13_persona_line.in_trouble_02) 
  2454.  
  2455. 	-- Wait until the player is in range of pierce 
  2456. 	while true do 
  2457. 		if get_dist( pierce, LOCAL_PLAYER ) < 7 then 
  2458. 			party_add( pierce, LOCAL_PLAYER ) 
  2459. 			break 
  2460. 		end 
  2461. 		 
  2462. 		if coop_is_active() then 
  2463. 			if get_dist( pierce, REMOTE_PLAYER ) < 7 then 
  2464. 				party_add( pierce, REMOTE_PLAYER ) 
  2465. 				break 
  2466. 			end 
  2467. 		end 
  2468. 		 
  2469. 		thread_yield() 
  2470. 	end 
  2471.  
  2472. 	marker_remove(pierce, SYNC_ALL) 
  2473. 	 
  2474. 	follower_set_can_abandon(pierce, true) 
  2475. 	on_dismiss("m13_pierce_abandoned", pierce) 
  2476. 	m13_play_convo_set(M13_convo.save_pierce_4) 
  2477. 	set_max_hit_points(pierce, normal_hitpoints, true) 
  2478. end 
  2479.  
  2480. function m13_pierce_give_player_airstrike() 
  2481. 	-- m13_play_convo_set(M13_convo.save_pierce_4) 
  2482. 	inv_weapon_add_temporary(LOCAL_PLAYER, M13_config.airstrike, 1, true, true, false) 
  2483. 	if M13_in_coop then 
  2484. 		inv_weapon_add_temporary(REMOTE_PLAYER, M13_config.airstrike, 1, true, true, false) 
  2485. 	end 
  2486. 	m13_play_convo_set(M13_convo.airstrike) 
  2487. end 
  2488.  
  2489. function m13_mini_tank_wave() 
  2490. end 
  2491.  
  2492.  
  2493. -- Tells Pierce to drive into the scene, get shot up, and wait until the player picks up Pierce 
  2494. -- 
  2495. function m13_save_pierce_wave() 
  2496. 	m13_setup_save_pierce_wave() 
  2497.  
  2498. 	m13_pierce_drive_in() 
  2499. 	m13_start_wave_set(M13_waves.scene_5_drop_off) 
  2500. 	 
  2501. 		M13_threads.music_cue = thread_new( "m13_audio_event_at_dist", M13_triggers.elevator_to_ground, 10, "M13_Score_Elevator" ) 
  2502.  
  2503. 		m13_goto_ground(M13_OBJ_GOTO_ELEVATOR) 
  2504. 		 
  2505. 		thread_kill( M13_threads.music_cue ) 
  2506. 		 
  2507. 		m13_cleanup_balcony_homies() 
  2508. 		 
  2509. 		audio_object_post_event("M13_Score_Get_Pierce", nil, nil, LOCAL_PLAYER) 
  2510. 		 
  2511. 		m13_save_pierce() 
  2512. 		 
  2513. 		audio_object_post_event("M13_Score_Return_HQ", nil, nil, LOCAL_PLAYER) 
  2514. 		 
  2515. 		M13_threads.music_cue = thread_new( "m13_audio_event_at_dist", M13_triggers.elevator_proximity, 25, "M13_Score_Arrive_HQ" ) 
  2516.  
  2517. 		m13_goto_balcony(M13_OBJ_GOTO_SAINTS_HQ) 
  2518. 		 
  2519. 		m13_vfx_play(M13_vfxs.north_03) 
  2520. 		m13_distance_clutter_show() 
  2521. 		m13_vfx_play(M13_vfxs.hq_02) 
  2522. 		 
  2523. 		thread_kill( M13_threads.music_cue ) 
  2524. 	m13_stop_wave_set(M13_waves.scene_5_drop_off) 
  2525. 	objective_text(0, M13_OBJ_DEFEND_THE_NORTH, "", "", SYNC_ALL, OI_ASSET_DEFEND) 
  2526. 	m13_setup_side("north") 
  2527. 	m13_setup_balcony_homies() 
  2528. 	m13_pierce_give_player_airstrike() 
  2529.  
  2530. 	m13_cleanup_save_pierce_wave() 
  2531. end 
  2532.  
  2533. function m13_audio_event_at_dist( target, dist, event ) 
  2534. 	local l_dist 
  2535. 	local r_dist = 999999 
  2536. 	 
  2537. 	while true do 
  2538. 		l_dist = get_dist( LOCAL_PLAYER, target ) 
  2539. 		 
  2540. 		if coop_is_active() then 
  2541. 			r_dist = get_dist( REMOTE_PLAYER, target ) 
  2542. 		end 
  2543. 		 
  2544. 		if l_dist < dist or r_dist < dist then 
  2545. 			audio_object_post_event( event, nil, nil, LOCAL_PLAYER ) 
  2546. 			return 
  2547. 		end 
  2548. 		 
  2549. 		thread_yield() 
  2550. 	end 
  2551. end 
  2552.  
  2553. function m13_flag_closest_car_bomb(north_side) 
  2554. 	if m13_car_bomb_destroyed(north_side) then 
  2555. 		return 
  2556. 	end 
  2557.  
  2558. 	objective_text(0, M13_OBJ_DETONATE_CAR_BOMBS, "", "", SYNC_ALL, OI_ASSET_KILL) 
  2559. 	m13_setup_side("clear") 
  2560. 	 
  2561. 	if north_side then 
  2562. 		m13_play_persona_line(M13_persona_line.car_bombs_01) 
  2563. 	else 
  2564. 		m13_play_persona_line(M13_persona_line.car_bombs_02) 
  2565. 	end 
  2566. 	 
  2567. 	for key, bomb in pairs(M13_movers.bombs) do 
  2568. 		if bomb.north_side == north_side and not mesh_mover_destroyed(bomb.mover) then 
  2569. 			marker_add(bomb, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_FULL, SYNC_ALL) 
  2570. 		end 
  2571. 	end 
  2572. 	 
  2573. 	while not m13_car_bomb_destroyed(north_side) do 
  2574. 		thread_yield() 
  2575. 	end 
  2576. 	 
  2577. 	for key, bomb in pairs(M13_movers.bombs) do 
  2578. 		if bomb.north_side == north_side then 
  2579. 			marker_remove(bomb) 
  2580. 		end 
  2581. 	end 
  2582. end 
  2583.  
  2584. -- Automatically enable and disable the proper waves, based of the provided level. 
  2585. -- Up to 3 levels are supported 
  2586. -- 
  2587. -- level:	(integer) Defines the number of wave sets to attack the North side. 
  2588. -- 
  2589. function m13_set_north_apc_level(level, trigger) 
  2590. 	if level >= 1 then 
  2591. 		if M13_north_apc_level < 1 then 
  2592. 			m13_start_wave_set(M13_waves.apcs_north_1) 
  2593. 		end 
  2594. 	elseif M13_north_apc_level >= 1 then 
  2595. 		m13_stop_wave_set(M13_waves.apcs_north_1, trigger) 
  2596. 	end 
  2597. 	 
  2598. 	if level >= 2 then 
  2599. 		if M13_north_apc_level < 2 then 
  2600. 			m13_start_wave_set(M13_waves.apcs_north_2) 
  2601. 		end 
  2602. 	elseif M13_north_apc_level >= 2 then 
  2603. 		m13_stop_wave_set(M13_waves.apcs_north_2, trigger) 
  2604. 	end 
  2605. 	 
  2606. 	if level >= 3 then 
  2607. 		if M13_north_apc_level < 3 then 
  2608. 			m13_start_wave_set(M13_waves.apcs_north_3) 
  2609. 		end 
  2610. 	elseif M13_north_apc_level >= 3 then 
  2611. 		m13_stop_wave_set(M13_waves.apcs_north_3, trigger) 
  2612. 	end 
  2613. 	 
  2614. 	M13_north_apc_level = level 
  2615. end 
  2616.  
  2617. -- Automatically enable and disable the proper waves, based of the provided level. 
  2618. -- Up to 3 levels are supported 
  2619. -- 
  2620. -- level:	(integer) Defines the number of wave sets to attack the South side. 
  2621. -- 
  2622. function m13_set_south_apc_level(level) 
  2623. 	if level >= 1 then 
  2624. 		if M13_south_apc_level < 1 then 
  2625. 			m13_start_wave_set(M13_waves.apcs_south_1) 
  2626. 		end 
  2627. 	elseif M13_south_apc_level >= 1 then 
  2628. 		m13_stop_wave_set(M13_waves.apcs_south_1) 
  2629. 	end 
  2630. 	 
  2631. 	if level >= 2 then 
  2632. 		if M13_south_apc_level < 2 then 
  2633. 			m13_start_wave_set(M13_waves.apcs_south_2) 
  2634. 		end 
  2635. 	elseif M13_south_apc_level >= 2 then 
  2636. 		m13_stop_wave_set(M13_waves.apcs_south_2) 
  2637. 	end 
  2638. 	 
  2639. 	if level >= 3 then 
  2640. 		if M13_south_apc_level < 3 then 
  2641. 			m13_start_wave_set(M13_waves.apcs_south_3) 
  2642. 		end 
  2643. 	elseif M13_south_apc_level >= 3 then 
  2644. 		m13_stop_wave_set(M13_waves.apcs_south_3) 
  2645. 	end 
  2646. 	 
  2647. 	M13_south_apc_level = level 
  2648. end 
  2649.  
  2650. -- Draw the player's attention towards the north side of the building, bring in a large convoy of 
  2651. -- STAG, and then point out a car bomb if the player didn't already detonate (shoot) one 
  2652. -- 
  2653. function m13_scene_1() 
  2654. 	objective_text(0, M13_OBJ_DEFEND_THE_NORTH, "", "", SYNC_ALL, OI_ASSET_DEFEND) 
  2655. 	m13_setup_side("north") 
  2656. 	 
  2657. 	if M13_status.score_start_began ~= true then 
  2658. 		audio_object_post_event("M13_Score_Start", nil, nil, LOCAL_PLAYER) 
  2659. 		M13_status.score_start_began = true 
  2660. 	end 
  2661.  
  2662. 	delay(3.0) 
  2663. 	m13_play_persona_line(M13_persona_line.attack_start) 
  2664.  
  2665. 	-- M13_waves.scene_1 uses most of the APC groups. The north and south APC level must be set 
  2666. 	-- to 0 for the convoy to work. 
  2667. 	m13_set_north_apc_level(0) 
  2668. 	m13_set_south_apc_level(0) 
  2669. 	 
  2670. 	-- Bring in the massive convoy 
  2671. 	m13_start_wave_set(M13_waves.scene_1) 
  2672. 		 
  2673. 		-- objective_text(0, M13_OBJ_TAKE_OUT_THE_TANKS, "", "", SYNC_ALL, OI_ASSET_KILL)	 
  2674. 		-- Wait until all the groups are finished pathfinding 
  2675. 		m13_wait_for_waves_to_complete_state(M13_waves.scene_1, M13_wave_states.pathfinding) 
  2676. 		m13_set_north_apc_level(2) 
  2677. 		m13_set_south_apc_level(0) 
  2678. 		local north_side = true 
  2679. 		m13_flag_closest_car_bomb(north_side) 
  2680. 		 
  2681. 		-- objective_text(0, M13_OBJ_TAKE_OUT_THE_TANKS, "", "", SYNC_ALL, OI_ASSET_KILL) 
  2682. 		--m13_wait_for_required_kills(M13_waves.scene_1) 
  2683. 		objective_text(0, M13_OBJ_DEFEND_THE_NORTH, "", "", SYNC_ALL, OI_ASSET_DEFEND) 
  2684. 		m13_setup_side("north") 
  2685. 		 
  2686. 	m13_set_north_apc_level(2) 
  2687. 	m13_set_south_apc_level(0) 
  2688. 	delay(30.0) 
  2689. 	m13_stop_wave_set(M13_waves.scene_1, M13_triggers.south_side) 
  2690. end 
  2691.  
  2692. -- Spawn some STAG on the observation deck to attack Viola, followed by a large convoy 
  2693. -- 
  2694. function m13_scene_2() 
  2695. 	turn_vulnerable( M13_groups.homies.viola ) 
  2696. 	 
  2697. 	m13_set_north_apc_level(0, M13_triggers.south_side) 
  2698. 	m13_set_south_apc_level(0) 
  2699. 	 
  2700. 	-- Give the south side some time to become populated with STAG 
  2701. 	-- delay(30.0) 
  2702. 		 
  2703. 	-- Spawn some STAG on the observation deck to attack Viola 
  2704. 	m13_start_wave_set(M13_waves.scene_2_deck) 
  2705. 		m13_start_convo_thread(M13_convo.help_viola) 
  2706. 		objective_text(0, M13_OBJ_HELP_VIOLA, "", "", SYNC_ALL, OI_ASSET_DEFEND) 
  2707. 		m13_setup_side("clear")	 
  2708. 		 
  2709. 		audio_object_post_event("M13_Score_Viola", nil, nil, LOCAL_PLAYER) 
  2710.  
  2711. 		marker_add(M13_groups.homies.viola, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND, OI_FLAGS_FULL, SYNC_ALL) 
  2712. 		m13_wait_for_required_kills(M13_waves.scene_2_deck) 
  2713. 		marker_remove(M13_groups.homies.viola) 
  2714. 	m13_stop_wave_set(M13_waves.scene_2_deck) 
  2715.  
  2716. 	-- these are delayed in scene 1 
  2717. 	-- make absolutely sure these get turned off now 
  2718. 	m13_set_north_apc_level(0) 
  2719. 	m13_stop_wave_set(M13_waves.scene_1) 
  2720. 	 
  2721. 	-- Bring in the massive convoy 
  2722. 	m13_start_wave_set(M13_waves.scene_2) 
  2723.  
  2724. 	m13_play_persona_line(M13_persona_line.focus_south) 
  2725. 	objective_text(0, M13_OBJ_DEFEND_THE_SOUTH, "", "", SYNC_ALL, OI_ASSET_DEFEND) 
  2726. 	m13_setup_side("south") 
  2727. 	 
  2728. 	audio_object_post_event("M13_Score_South1", nil, nil, LOCAL_PLAYER) 
  2729. 	 
  2730. 	m13_wait_for_waves_to_complete_state(M13_waves.scene_2, M13_wave_states.pathfinding) 
  2731. 	local north_side = false 
  2732. 	m13_flag_closest_car_bomb(north_side) 
  2733. 	objective_text(0, M13_OBJ_DEFEND_THE_SOUTH, "", "", SYNC_ALL, OI_ASSET_DEFEND) 
  2734. 	m13_setup_side("south") 
  2735. 	 
  2736. 	-- Turn on north side VFX 
  2737. 	m13_vfx_play(M13_vfxs.north_01) 
  2738. end 
  2739.  
  2740. -- Spawn some snipers on the rooftops across the street 
  2741. -- 
  2742. function m13_scene_3() 
  2743. 	-- Focus the waves on the south side 
  2744. 	m13_set_north_apc_level(1) 
  2745. 	m13_set_south_apc_level(3) 
  2746. 	 
  2747. 	delay(15.0)	 
  2748.  
  2749. 	m13_start_wave_set(M13_waves.scene_3_snipers) 
  2750. 		m13_play_persona_line(M13_persona_line.snipers_01) 
  2751. 		objective_text(0, M13_OBJ_TAKE_OUT_THE_SNIPERS, "", "", SYNC_ALL, OI_ASSET_KILL) 
  2752. 		m13_setup_side("clear") 
  2753. 		 
  2754. 		audio_object_post_event("M13_Score_Snipers", nil, nil, LOCAL_PLAYER) 
  2755.  
  2756. 		m13_wait_for_required_kills(M13_waves.scene_3_snipers) 
  2757. 		objective_text(0, M13_OBJ_DEFEND_THE_SOUTH, "", "", SYNC_ALL, OI_ASSET_DEFEND) 
  2758. 		m13_setup_side("south") 
  2759. 		 
  2760. 		audio_object_post_event("M13_Score_South2", nil, nil, LOCAL_PLAYER) 
  2761.  
  2762. 	m13_stop_wave_set(M13_waves.scene_3_snipers) 
  2763. end 
  2764.  
  2765. -- Continue the assault from the North with some tanks 
  2766. -- 
  2767. function m13_scene_4() 
  2768. 	turn_invulnerable( M13_groups.homies.viola ) 
  2769. 	 
  2770. 	m13_set_north_apc_level(3) 
  2771. 	m13_set_south_apc_level(0) 
  2772. 	delay(2.0) 
  2773. 	m13_start_wave_set(M13_waves.scene_4_tanks) 
  2774. 		objective_text(0, M13_OBJ_TAKE_OUT_THE_TANKS, "", "", SYNC_ALL, OI_ASSET_KILL) 
  2775. 		m13_setup_side("clear") 
  2776. 		m13_play_persona_line(M13_persona_line.tanks_01) 
  2777. 		m13_wait_for_required_kills(M13_waves.scene_4_tanks) 
  2778. 		objective_text(0, M13_OBJ_DEFEND_THE_NORTH, "", "", SYNC_ALL, OI_ASSET_DEFEND) 
  2779. 		m13_setup_side("north") 
  2780. 		-- Turn on south side VFX 
  2781. 		m13_vfx_play(M13_vfxs.south_01) 
  2782. 	m13_stop_wave_set(M13_waves.scene_4_tanks) 
  2783. end 
  2784.  
  2785. -- Have Pierce drive on the scene and instruct the player to save him 
  2786. -- 
  2787. function m13_scene_5() 
  2788. 	-- Only have some light waves from the North, since the player will be on the ground 
  2789. 	m13_set_north_apc_level(2) 
  2790. 	m13_set_south_apc_level(0) 
  2791. 	delay(3.0) 
  2792. 	m13_save_pierce_wave() 
  2793. end 
  2794.  
  2795. -- Large Northward assault with some tanks and VTOls 
  2796. -- 
  2797. function m13_scene_6() 
  2798. 	-- Focus the waves on the North 
  2799. 	m13_set_north_apc_level(3) 
  2800. 	m13_set_south_apc_level(1) 
  2801.  
  2802. 	m13_start_wave_set(M13_waves.scene_6_tanks) 
  2803. 		objective_text(0, M13_OBJ_TAKE_OUT_THE_TANKS, "", "", SYNC_ALL, OI_ASSET_KILL) 
  2804. 		m13_setup_side("clear") 
  2805. 		if M13_status.restart_checkpoint == M13_CHECKPOINT_WAVE_3_START then 
  2806. 			audio_object_post_event("M13_Score_Checkpoint_Wave3", nil, nil, LOCAL_PLAYER) 
  2807. 		else 
  2808. 			audio_object_post_event("M13_Score_Tanks", nil, nil, LOCAL_PLAYER) 
  2809. 		end 
  2810. 		m13_wait_for_required_kills(M13_waves.scene_6_tanks) 
  2811. 	m13_stop_wave_set(M13_waves.scene_6_tanks) 
  2812. 	 
  2813. 	objective_text(0, M13_OBJ_DEFEND_THE_NORTH, "", "", SYNC_ALL, OI_ASSET_DEFEND) 
  2814. 	m13_setup_side("north") 
  2815. 	delay(2.0) 
  2816. 		 
  2817. 	m13_start_wave_set(M13_waves.scene_6_vtol_01) 
  2818. 		m13_setup_side("clear") 
  2819. 		audio_object_post_event("M13_Score_VTOLS", nil, nil, LOCAL_PLAYER) 
  2820. 		m13_play_convo_set(M13_convo.first_heli) 
  2821. 		objective_text(0, M13_OBJ_TAKE_OUT_THE_VTOLS, "", "", SYNC_ALL, OI_ASSET_KILL) 
  2822. 		m13_wait_for_required_kills(M13_waves.scene_6_vtol_01) 
  2823. 	m13_stop_wave_set(M13_waves.scene_6_vtol_01) 
  2824. 	 
  2825. 	m13_start_wave_set(M13_waves.scene_6_vtol_02) 
  2826. 		m13_setup_side("clear") 
  2827. 		objective_text(0, M13_OBJ_TAKE_OUT_THE_VTOLS, "", "", SYNC_ALL, OI_ASSET_KILL) 
  2828. 		m13_wait_for_required_kills(M13_waves.scene_6_vtol_02) 
  2829. 	m13_stop_wave_set(M13_waves.scene_6_vtol_02) 
  2830. 	 
  2831. 	objective_text(0, M13_OBJ_DEFEND_THE_NORTH, "", "", SYNC_ALL, OI_ASSET_DEFEND) 
  2832. 	m13_setup_side("north") 
  2833. 	delay(2.0) 
  2834. 	 
  2835. 	m13_set_north_apc_level(3) 
  2836. 	m13_set_south_apc_level(1) 
  2837. 	 
  2838. 	turn_vulnerable( M13_groups.homies.viola ) 
  2839.  
  2840. 	-- m13_start_wave_set(M13_waves.scene_6_snipers) 
  2841. 	-- 	objective_text(0, M13_OBJ_TAKE_OUT_THE_SNIPERS, "", "", SYNC_ALL, OI_ASSET_KILL) 
  2842. 	-- 	m13_play_persona_line(M13_persona_line.snipers_02) 
  2843. 	-- 	m13_wait_for_required_kills(M13_waves.scene_6_snipers) 
  2844. 	-- m13_stop_wave_set(M13_waves.scene_6_snipers) 
  2845. end 
  2846.  
  2847. -- Large on going assault from the North, South, and the observation deck. Instruct the player to flee. 
  2848. -- 
  2849. function m13_scene_7() 
  2850. 	turn_invulnerable( M13_groups.homies.viola ) 
  2851.  
  2852. 	-- Full out assault on both sides 
  2853. 	m13_set_north_apc_level(3) 
  2854. 	m13_set_south_apc_level(3) 
  2855. 	 
  2856. 	-- m13_stop_wave_set(M13_waves.scene_2_deck) 
  2857. 	 
  2858. 	-- Spawn some STAG on the observation deck 
  2859. 	delay(1.0) 
  2860. 	m13_start_wave_set(M13_waves.scene_7_deck) 
  2861. 	m13_setup_side("clear")	 
  2862. 	objective_text(0, M13_OBJ_CLEAR_THE_FLOOR, "", "", SYNC_ALL, OI_ASSET_KILL) 
  2863. 	m13_play_convo_set(M13_convo.check_roof_01) 
  2864. 	m13_wait_for_required_kills(M13_waves.scene_7_deck) 
  2865. 	objective_text(0, M13_OBJ_DEFEND_THE_NORTH, "", "", SYNC_ALL, OI_ASSET_DEFEND) 
  2866. 	m13_setup_side("north") 
  2867. 	m13_play_convo_set(M13_convo.check_roof_02) 
  2868. 	delay(1.0) 
  2869. 	m13_start_continuous_spawns(M13_continuous_spawns.stag_deck_02) 
  2870. 	delay(2.0) 
  2871. 	m13_start_continuous_spawns(M13_continuous_spawns.stag_deck_01) 
  2872. 	m13_play_convo_set(M13_convo.check_roof_03) 
  2873. 	M13_threads.music_cue = thread_new( "m13_audio_event_at_dist", M13_triggers.elevator_to_penthouse, 14, "M13_Score_To_Roof" ) 
  2874. 	m13_setup_side("clear") 
  2875. 	m13_goto_a_trigger(M13_triggers.elevator_to_penthouse, M13_OBJ_GOTO_PENTHOUSE, false) 
  2876. 		thread_kill( M13_threads.music_cue ) 
  2877. 	m13_stop_wave_set(M13_waves.scene_7_deck) 
  2878. 	m13_setup_side("clear") 
  2879. end 
  2880.  
  2881.  
  2882.  
  2883. -- *************************************************** 
  2884. -- m13_initialize Helper Functions 
  2885. -- *************************************************** 
  2886.  
  2887. -- Handle any common initialization 
  2888. -- 
  2889. function m13_initialize_common() 
  2890. 	--[[ INSERT ANY COMMON INITIALIZATION CODE HERE ]]-- 
  2891. 	m13_load_personas() 
  2892. 	 
  2893. 	m13_disable_traffic( true ) 
  2894. 	 
  2895. 	M13_threads.passenger_cleanup = thread_new( "m13_monitor_passengers_thread" ) 
  2896. end 
  2897.  
  2898. -- Checkpoint specific initialization 
  2899. -- 
  2900. -- checkpoint:		The checkpoint to be initialized 
  2901. function m13_initialize_checkpoint(checkpoint) 
  2902. 	if checkpoint == M13_CHECKPOINT_START then 
  2903. 		m13_setup_start() 
  2904. 		m13_hide_car_bombs() 
  2905. 		m13_distance_clutter_hide() 
  2906. 		 
  2907. 	elseif checkpoint == M13_CHECKPOINT_BANNERS then 
  2908. 		-- create banner group 
  2909. 		group_create(M13_groups.pr_static.name, true) 
  2910.  
  2911. 		-- increase notoriety 
  2912. 		notoriety_set( "Police", 3 ) 
  2913.  
  2914. 		teleport_coop( M13_nav.banners_player_start, M13_nav.banners_remote_start, true ) 
  2915.  
  2916. 	elseif checkpoint == M13_CHECKPOINT_DECISION then 
  2917. 		teleport_coop(M13_nav.penthouse_elevator, M13_nav.penthouse_elevator_remote, true) 
  2918. 		m13_setup_decision() 
  2919.  
  2920. 	else -- Wave 1, Wave 2, or Wave 3 
  2921. 		-- The car bombs are detonated in the first wave. Hide them for the 2nd and 3rd waves. 
  2922. 		if checkpoint ~= M13_CHECKPOINT_WAVE_1_START then 
  2923. 			m13_hide_car_bombs() 
  2924. 		end 
  2925.  
  2926. 		objective_text(0, M13_OBJ_DEFEND_THE_NORTH, "", "", SYNC_ALL, OI_ASSET_DEFEND) 
  2927. 		m13_setup_side("north") 
  2928. 		teleport_coop(M13_nav.elevator_to_ground, M13_nav.elevator_to_ground_remote, true) 
  2929. 		m13_setup_balcony_battle() 
  2930. 		m13_setup_car_bombs() 
  2931. 		 
  2932. 		m13_disable_ambient_spawning( true ) 
  2933. 	end 
  2934. end 
  2935.  
  2936. -- ********************************************************** 
  2937. -- Miscellaneous m13 Helper Functions 
  2938. -- *************************************************** 
  2939.  
  2940. -- General task. Instructs the player to go to the specific trigger. Blocks until the 
  2941. -- trigger is reached/used. 
  2942. -- 
  2943. -- trigger  - Name of the trigger to activate and go to. 
  2944. -- obj_text - Objective text to display 
  2945. -- gps      - Should a gps waypoint be added? 
  2946. -- 
  2947. function m13_goto_a_trigger(trigger, obj_text, gps) 
  2948. 	if gps == nil then 
  2949. 		gps = false 
  2950. 	end 
  2951.  
  2952. 	m13_goto_a_trigger_setup(trigger, obj_text, gps) 
  2953.  
  2954. 	while not M13_trigger_reached do 
  2955. 		thread_yield() 
  2956. 	end 
  2957.  
  2958. 	m13_goto_a_trigger_cleanup(trigger, gps) 
  2959. end 
  2960.  
  2961. -- Sets up the trigger to be used and updates the objective text to the specified string. 
  2962. -- 
  2963. -- trigger	- Name of the trigger the player is going to 
  2964. -- obj_text	- Name of the localized objective string to use 
  2965. -- gps		- True if a GPS waypoint should be added 
  2966. -- 
  2967. function m13_goto_a_trigger_setup(trigger, obj_text, gps) 
  2968. 	-- Teleportation and navagation related functions don't play nice so give pathfinding 
  2969. 	-- and similar a frame to finialize everything. 
  2970. 	thread_yield() 
  2971.  
  2972. 	if obj_text ~= "" and obj_text ~= nil then 
  2973. 		objective_text(0, obj_text, "", "", SYNC_ALL, OI_ASSET_LOCATION) 
  2974. 	end 
  2975.  
  2976. 	marker_add_trigger(trigger, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  2977. 	if gps then 
  2978. 		waypoint_add(trigger) 
  2979. 	end 
  2980. 	M13_trigger_reached = false 
  2981. 	trigger_enable(trigger, true) 
  2982. 	on_trigger("m13_trigger_cback", trigger) 
  2983. end 
  2984.  
  2985. -- Cleans up a trigger and gps setup by m13_goto_a_trigger_setup(). 
  2986. -- 
  2987. -- trigger	- Name of the trigger to disable 
  2988. -- gps		- True if a GPS waypoint was setup 
  2989. -- 
  2990. function m13_goto_a_trigger_cleanup(trigger, gps) 
  2991. 	on_trigger("", trigger) 
  2992. 	trigger_enable(trigger, false) 
  2993. 	marker_remove_trigger(trigger) 
  2994. 	if gps then 
  2995. 		waypoint_remove() 
  2996. 	end 
  2997.  
  2998. 	-- To be on the safe side, give pathfinding a similar a full frame to remove the nav points and such 
  2999. 	thread_yield() 
  3000. end 
  3001.  
  3002.  
  3003.  
  3004.  
  3005.  
  3006.  
  3007.  
  3008.  
  3009. -- Checks to see if a vehicle is a helicopter or a vtol 
  3010. -- 
  3011. -- vehicle: Name of the script vehicle to check 
  3012. -- 
  3013. function m13_vehicle_is_helicopter(vehicle) 
  3014. 	if vehicle == nil or vehicle == "" then 
  3015. 		return false 
  3016. 	end 
  3017.  
  3018. 	return vehicle_is_helicopter(vehicle) or vehicle_is_vtol(vehicle) 
  3019. end 
  3020.  
  3021.  
  3022. -- Check to see if a vehicle is a tank 
  3023. -- 
  3024. -- vehicle: Name of the script vehicle to check 
  3025. -- 
  3026. function m13_vehicle_is_tank(vehicle) 
  3027. 	if vehicle == nil or vehicle == "" then 
  3028. 		return false 
  3029. 	end 
  3030.  
  3031. 	return vehicle_is_tank(vehicle) 
  3032. end 
  3033.  
  3034. -- ************************* 
  3035. -- 
  3036. -- Callback functions 
  3037. -- 
  3038. -- ************************* 
  3039.  
  3040. -- Called when the player jumps off the penthouse. This is a valid escape scenario 
  3041. -- 
  3042. -- human:	Name of the human that triggered the trigger 
  3043. -- tirgger:	Name of the triggered trigger 
  3044. -- 
  3045. function m13_jumped_off_penthouse(human, trigger) 
  3046. 	if human ~= LOCAL_PLAYER and human ~= REMOTE_PLAYER then 
  3047. 		return 
  3048. 	end 
  3049.  
  3050. 	marker_remove(M13_nav.jump_to) 
  3051. 	M13_status.jumped_off_penthouse = true 
  3052. end 
  3053.  
  3054. -- General trigger callback. Sets M13_trigger_reached if a player triped a trigger. 
  3055. -- 
  3056. -- human:	Name of the human that triggered the trigger 
  3057. -- tirgger:	Name of the triggered trigger 
  3058. -- 
  3059. function m13_trigger_cback(human, trigger) 
  3060. 	if human == LOCAL_PLAYER or human == REMOTE_PLAYER then 
  3061. 		M13_trigger_reached = true 
  3062. 	end 
  3063. end 
  3064.  
  3065. -- Called when a car bomb is shot. 
  3066. -- 
  3067. -- mover_name:			Name of the mover that was damaged 
  3068. -- attacker:			Who did the damage 
  3069. -- damage:				Amount of damage done 
  3070. -- from_explosion:	Was the damage from an explosion? 
  3071. -- melee_used:			Was melee used? 
  3072. -- 
  3073. function m13_mover_damaged(mover_name, attacker, damage, from_explosion, melee_used) 
  3074. 	-- Don't allow the player to detonate a car bomb with a melee attack. 
  3075. 	if melee_used == true then 
  3076. 		return 
  3077. 	end 
  3078.  
  3079. 	-- Ensure that is was actually a player that caused the damage. 
  3080. 	if attacker == LOCAL_PLAYER or attacker == REMOTE_PLAYER then 
  3081. 		-- Mark the car bomb to explode 
  3082. 		m13_car_bomb_detonate(mover_name) 
  3083. 	end 
  3084. end 
  3085.  
  3086. -- Sets M13_banner_damaged when a banner is damaged by a player 
  3087. -- 
  3088. -- mover_name:			Name of the mover that was damaged 
  3089. -- attacker:			Who did the damage 
  3090. -- damage:				Amount of damage done 
  3091. -- from_explosion:	Was the damage from an explosion? 
  3092. -- melee_used:			Was melee used? 
  3093. -- 
  3094. function m13_banner_damaged(mover_name, attacker, damage, from_explosion, melee_used) 
  3095. 	if attacker == LOCAL_PLAYER or attacker == REMOTE_PLAYER then 
  3096. 		M13_banner_damaged = true 
  3097. 	end 
  3098. end 
  3099.  
  3100. -- Called when a banner is destroyed 
  3101. -- 
  3102. -- mover_name:	Name of the banner that was destroyed 
  3103. -- attacker:	Who destroyed the banner 
  3104. -- 
  3105. function m13_banner_destroyed(mover_name, attacker) 
  3106. 	local movers_alive = 0 
  3107.  
  3108. 	-- Search through the list of banners and mark which banner was destroyed 
  3109. 	for key, banner in pairs(M13_movers.pr_center_banners) do 
  3110. 		if banner.name == mover_name then 
  3111. 			banner.destroyed = true 
  3112. 		elseif banner.destroyed == false then 
  3113. 			movers_alive = movers_alive + 1 
  3114. 		end 
  3115. 	end 
  3116.  
  3117. 	on_mover_destroyed("", mover_name) 
  3118. 	marker_remove(mover_name) 
  3119.  
  3120. 	M13_banners_alive		= movers_alive 
  3121. 	M13_banner_damaged	= true 
  3122. 	M13_banner_destroyed = true 
  3123. end 
  3124.  
  3125. -- Called when Josh is throw to Cyrus 
  3126. -- 
  3127. function m13_josh_thrown_to_cyrus() 
  3128. 	M13_josh_given_to_cyrus = true 
  3129. end 
  3130.  
  3131. -- Called when Josh is thrown to your homies 
  3132. -- 
  3133. function m13_josh_thrown_to_homies() 
  3134. 	M13_josh_given_to_homies = true 
  3135. end 
  3136.  
  3137. -- Called when a mission critical homie has died. 
  3138. -- 
  3139. function m13_homie_died(victim, attacker) 
  3140. 	if victim == M13_groups.homies.viola then 
  3141. 		mission_end_failure("m13", M13_FAILURE_VIOLA_DIED) 
  3142. 	end 
  3143. 	 
  3144. 	-- if victim == M13_groups.homies.oleg then 
  3145. 	-- 	mission_end_failure("m13", M13_FAILURE_OLEG_DIED) 
  3146. 	-- end 
  3147. 	 
  3148. 	if victim == M13_groups.pierce_rescue.pierce then 
  3149. 		mission_end_failure("m13", M13_FAILURE_PIERCE_DIED) 
  3150. 	end 
  3151.  
  3152. 	if victim == M13_groups.penthouse_homies.josh then 
  3153. 		mission_end_failure("m13", M13_FAILURE_JOSH_DIED) 
  3154. 	end 
  3155. end 
  3156.  
  3157. -- Called when the alloted time to escape the penthouse has elapsed. 
  3158. -- 
  3159. function m13_time_is_up() 
  3160. 	mission_end_failure("m13", M13_FAILURE_FAILED_TO_ESCAPE) 
  3161. end 
  3162.  
  3163.  
  3164. function m13_pierce_abandoned() 
  3165. 	mission_end_failure("m13", M13_FAILURE_PIERCE_ABANDONED) 
  3166. end 
  3167.  
  3168. -- ************************* 
  3169. -- 
  3170. -- Thread functions 
  3171. -- 
  3172. -- ************************* 
  3173.  
  3174. -- Detonate and respawns car bombs as necessary 
  3175. -- 
  3176. function m13_thread_car_bomb_manager() 
  3177. 	local active = {} 
  3178.  
  3179. 	for key, bomb in pairs(M13_movers.bombs) do 
  3180. 		if not mesh_mover_destroyed(bomb.mover) then 
  3181. 			active[#active + 1] = bomb 
  3182. 		end 
  3183. 	end 
  3184.  
  3185. 	while #active > 0 do 
  3186. 		active = m13_car_bombs_check_for_detonation(active) 
  3187.  
  3188. 		thread_yield() 
  3189. 	end 
  3190.  
  3191. 	M13_THREAD_CAR_BOMB_MANAGER = INVALID_THREAD_HANDLE 
  3192. end 
  3193.  
  3194.  
  3195. -- Initial conversation between Pierce and the player. Once the converstion is over, have 
  3196. -- Pierce leave the area. 
  3197. -- 
  3198. function m13_thread_pierce_convo_and_leave() 
  3199. 	local target_vehicle = M13_groups.pierce_start.vehicle 
  3200. 	local pierce			= M13_groups.pierce_start.pierce 
  3201. 	set_unrecruitable_flag(pierce, true) 
  3202. 	character_allow_ragdoll(pierce, false) 
  3203. 	character_prevent_explosion_fling(pierce, true) 
  3204. 	character_prevent_flinching(pierce, true) 
  3205. 	character_prevent_bumping(pierce, true) 
  3206.  
  3207. 	-- Play the initial conversation and wait for it to end. 
  3208. 	m13_play_convo_set(M13_convo.start) 
  3209.  
  3210. 	ai_clear_scripted_action(pierce) 
  3211. 	npc_go_idle(pierce) 
  3212.  
  3213. 	-- set_player_can_enter_exit_vehicles(LOCAL_PLAYER, false) 
  3214. 	-- if M13_in_coop then 
  3215. 	-- 	set_player_can_enter_exit_vehicles(REMOTE_PLAYER, false) 
  3216. 	-- end 
  3217.  
  3218. 	if vehicle_enter(pierce, target_vehicle, 0, true, true) then 
  3219. 		set_ignore_ai_flag(pierce, false) 
  3220. 		vehicle_set_ambient(target_vehicle) 
  3221. 	end 
  3222.  
  3223. 	-- set_player_can_enter_exit_vehicles(LOCAL_PLAYER, true) 
  3224. 	-- if M13_in_coop then 
  3225. 	-- 	set_player_can_enter_exit_vehicles(REMOTE_PLAYER, true) 
  3226. 	-- end 
  3227.  
  3228. 	-- Wait until both players are pretty far away from Pierce 
  3229. 	while get_dist(LOCAL_PLAYER, pierce) < 150.0 or (M13_in_coop and get_dist(LOCAL_PLAYER, pierce) < 150.0) do 
  3230. 		thread_yield() 
  3231. 	end 
  3232. 	 
  3233. 	--m13_play_persona_line(M13_persona_line.drive_to_pr) 
  3234. 	 
  3235. 	-- Allow Pierce to stream out 
  3236. 	release_to_world(target_vehicle) 
  3237. 	release_to_world(pierce) 
  3238.  
  3239. 	M13_THREAD_PIERCE_CONVO_AND_LEAVE = INVALID_THREAD_HANDLE 
  3240. end 
  3241.  
  3242. function m13_thread_vtol_fly_away(vehicle) 
  3243. 	helicopter_fly_to_dont_stop(vehicle.name, -1.0, vehicle.nav_flee) 
  3244.  
  3245. 	vehicle.thread = INVALID_THREAD_HANDLE 
  3246. end 
  3247.  
  3248.  
  3249.  
  3250.  
  3251.  
  3252.  
  3253.  
  3254.  
  3255.  
  3256.  
  3257. -- Plays a conversation 
  3258. -- 
  3259. -- convo: Conversation to play 
  3260. function m13_play_convo(convo) 
  3261. 	if convo.name ~= "" and convo.name ~= nil then 
  3262. 		if type(convo.name) == "table" then 
  3263. 			m13_play_persona_line(convo.name) 
  3264. 		else 
  3265. 			--local msg_handle = message("Playing Convo: " .. convo.name, 99999999.0) 
  3266. 			if convo.cell ~= true then 
  3267. 				if convo.direct == true then 
  3268. 					convo.handle = audio_conversation_load_direct(convo.name) 
  3269. 				else 
  3270. 					convo.handle = audio_conversation_load(convo.name) 
  3271. 				end 
  3272. 			end 
  3273. 			 
  3274. 			if convo.cell == true then 
  3275. 				m13_cellphone_call_wait( convo.name, convo.recieving ) 
  3276. 			else 
  3277. 				audio_conversation_play(convo.handle) 
  3278. 				audio_conversation_wait_for_end(convo.handle) 
  3279. 				convo.handle = nil 
  3280. 			end 
  3281. 			--message_remove(msg_handle) 
  3282. 		end 
  3283. 	end 
  3284.  
  3285. 	if convo.delay ~= nil and convo.delay > 0.01 then 
  3286. 		delay(convo.delay) 
  3287. 	end 
  3288. end 
  3289.  
  3290. -- Unloads a conversation 
  3291. -- 
  3292. -- convo: Conversation to unload 
  3293. function m13_unload_convo(convo) 
  3294. 	if convo.handle == nil then 
  3295. 		return 
  3296. 	end 
  3297.  
  3298. 	audio_conversation_end(convo.handle) 
  3299. 	convo.handle = nil 
  3300. end 
  3301.  
  3302. -- Unloads all conversations from the convo table 
  3303. -- 
  3304. function m13_unload_all_convos() 
  3305. 	for convo_key, convo_set in pairs(M13_convo) do 
  3306. 		m13_unload_convo_set(convo_set) 
  3307.  
  3308. 		if convo_set.thread ~= INVALID_THREAD_HANDLE then 
  3309. 			thread_kill(convo_set.thread) 
  3310. 		end 
  3311. 	end 
  3312.  
  3313. 	if M13_THREAD_PIERCE_CONVO_AND_LEAVE ~= INVALID_THREAD_HANDLE then 
  3314. 		thread_kill(M13_THREAD_PIERCE_CONVO_AND_LEAVE) 
  3315. 		M13_THREAD_PIERCE_CONVO_AND_LEAVE = INVALID_THREAD_HANDLE 
  3316. 	end 
  3317. end 
  3318.  
  3319. -- Iterates through a table of conversations and plays them. 
  3320. -- 
  3321. -- convo_set: Table of conversations 
  3322. -- 
  3323. function m13_play_convo_set(convo_set) 
  3324. 	for key, convo in pairs(convo_set.files) do 
  3325. 		m13_play_convo(convo) 
  3326. 	end 
  3327. end 
  3328.  
  3329. -- Unloads a convo table (array) 
  3330. -- 
  3331. -- convo_set Table of conversations to unload 
  3332. -- 
  3333. function m13_unload_convo_set(convo_set) 
  3334. 	for key, convo in pairs(convo_set.files) do 
  3335. 		m13_unload_convo(convo) 
  3336. 	end 
  3337. end 
  3338.  
  3339. -- Starts an audio conversation as a thread 
  3340. -- 
  3341. -- convo_table: Conversation to play 
  3342. -- 
  3343. function m13_start_convo_thread(convo_table) 
  3344. 	if M13_active_convo ~= "" then 
  3345. 		m13_unload_convo_set(M13_active_convo) 
  3346. 		M13_active_convo = "" 
  3347. 	end 
  3348. 	convo_table.thread = thread_new("m13_audio_thread", convo_table) 
  3349. end 
  3350.  
  3351. -- Loads the necessary 2D personas for the heli rail sequence 
  3352. -- 
  3353. function m13_load_personas() 
  3354. 	for key, persona in pairs(M13_personas) do 
  3355. 		persona.handle = audio_persona_load_2d(persona.name) 
  3356. 	end 
  3357. end 
  3358.  
  3359. -- Unloads all 2d personas 
  3360. -- 
  3361. function m13_unload_personas() 
  3362. 	for key, persona in pairs(M13_personas) do 
  3363. 		if persona.handle ~= INVALID_PERSONA_HANDLE then 
  3364. 			audio_persona_remove_2d(persona.handle) 
  3365. 			persona.handle = INVALID_PERSONA_HANDLE 
  3366. 		end 
  3367. 	end 
  3368. end 
  3369.  
  3370. -- Gets the 2d persona handle from a character name 
  3371. -- 
  3372. function m13_get_persona_handle(line) 
  3373. 	for key, persona in pairs(M13_personas) do 
  3374. 		if persona.name == line.character then 
  3375. 			return persona.handle 
  3376. 		end 
  3377. 	end 
  3378.  
  3379. 	return nil 
  3380. end 
  3381.  
  3382. -- Plays a persona line. 
  3383. -- 
  3384. function m13_play_persona_line(line) 
  3385. 	--message("Playing Persona Line: " .. line.name, 4.0) 
  3386. 	 
  3387. 	if line.cell == true then 
  3388. 		m13_cellphone_call_wait( line.name, line.recieving, m13_get_persona_handle(line) ) 
  3389. 	elseif line.play_2d then 
  3390. 		audio_play_persona_line_2d(m13_get_persona_handle(line), line.name) 
  3391. 	else 
  3392. 		audio_play_persona_line(line.character, line.name) 
  3393. 	end 
  3394. end 
  3395.  
  3396.  
  3397.  
  3398. -- Play a audio conversation 
  3399. -- 
  3400. -- convo_table: Table of the audio conversation files to play 
  3401. -- 
  3402. function m13_audio_thread(convo_table) 
  3403. 	M13_active_convo = convo_table 
  3404. 	m13_play_convo_set(convo_table) 
  3405. 	convo_table.thread = INVALID_THREAD_HANDLE 
  3406. 	M13_active_convo = "" 
  3407. end 
  3408.  
  3409. -- Starts a table of waves. If a template is specified, propagate the values to all the waves. 
  3410. function m13_start_wave_set(wave_set) 
  3411. 	for key, wave in pairs(wave_set) do 
  3412. 		-- Propagate the template values to the wave 
  3413. 		local template = wave.template 
  3414. 		if template ~= nil and template ~= "" then 
  3415. 			for key, value in pairs(template) do 
  3416. 				-- If the wave doesn't contain the value, copy the template value to the wave 
  3417. 				if wave[key] == nil then 
  3418. 					wave[key] = value 
  3419. 				end 
  3420. 			end 
  3421. 		end 
  3422.  
  3423. 		m13_start_wave(wave) 
  3424. 	end 
  3425. end 
  3426.  
  3427. -- Stop a table of waves. 
  3428. -- 
  3429. function m13_stop_wave_set(wave_set, trigger) 
  3430. 	for key, wave in pairs(wave_set) do 
  3431. 		if wave.groups ~= nil then 
  3432. 			m13_stop_wave(wave, nil, trigger) 
  3433. 		else 
  3434. 			m13_stop_wave_set(wave, trigger) 
  3435. 		end 
  3436. 	end 
  3437. end 
  3438.  
  3439. -- Sets up a wave to start spawning enemies 
  3440. -- 
  3441. -- wave: M13_waves member to setup 
  3442. -- 
  3443. function m13_start_wave(wave) 
  3444. 	if wave.thread ~= INVALID_THREAD_HANDLE then 
  3445. 		debug_print ( "MAD", "ERROR: Wave is already running: " .. wave.groups[1].group.name .. "\n" ) 
  3446. 		return 
  3447. 	end 
  3448.  
  3449. 	wave.state  = M13_wave_states.invalid 
  3450. 	wave.thread = thread_new("m13_wave_thread", wave) 
  3451. end 
  3452.  
  3453. -- Cleans up all groups in a wave 
  3454. -- 
  3455. function m13_stop_wave(wave, kill_thread, trigger) 
  3456. 	if wave.thread == nil or wave.thread == INVALID_THREAD_HANDLE then 
  3457. 		return 
  3458. 	end 
  3459. 	 
  3460. 	-- if a trigger was passed then set up a trigger kill 
  3461. 	if trigger ~= nil then 
  3462. 		wave.kill_trigger = trigger 
  3463. 		return 
  3464. 	end 
  3465.  
  3466. 	-- Remove any markers or callbacks 
  3467. 	local pass_to_destroy = { } 
  3468. 	for group_key, group_set in pairs(wave.groups) do 
  3469. 		m13_destroy_wave_group(group_set.group, false) 
  3470.  
  3471. 		-- flag associated groups for destruction 
  3472. 		for pass_group_name, pass_group_data in pairs( M13_passengers_active ) do 
  3473. 			if pass_group_data.spawn_group == group_set.group.name then 
  3474. 				pass_to_destroy[ pass_group_name ] = true 
  3475. 			end 
  3476. 		end 
  3477. 	end 
  3478.  
  3479. 	if kill_thread ~= false then 
  3480. 		thread_kill(wave.thread) 
  3481. 		wave.thread = INVALID_THREAD_HANDLE 
  3482. 	end 
  3483.  
  3484. 	-- destroy the passengers 
  3485. 	for pass_group_name, duh in pairs( pass_to_destroy ) do 
  3486. 		m13_destroy_passenger_group( pass_group_name, false ) 
  3487. 	end 
  3488. end 
  3489.  
  3490. -- Cleans up a wave's group 
  3491. -- 
  3492. function m13_destroy_wave_group(group, release) 
  3493. 	if group_is_loaded(group.name) then 
  3494. 		local vehicle = group.vehicle 
  3495. 		local members = group.members 
  3496.  
  3497. 		for key, npc in pairs(members) do 
  3498. 			on_death("", npc) 
  3499. 			marker_remove(npc) 
  3500. 		end 
  3501.  
  3502. 		if vehicle ~= "" and vehicle ~= nil then 
  3503. 			on_vehicle_destroyed("", vehicle) 
  3504. 			marker_remove(vehicle) 
  3505. 		end 
  3506.  
  3507. 		if release ~= false then 
  3508. 			release_to_world(group.name) 
  3509. 		end 
  3510. 		 
  3511. 		group_destroy(group.name) 
  3512. 		 
  3513. 		M13_num_troops = M13_num_troops - #members 
  3514. 	end 
  3515. end 
  3516.  
  3517. -- Wait until all of the required kills have been taken care of 
  3518. -- 
  3519. function m13_wait_for_required_kills(wave_set) 
  3520. 	for key, wave in pairs(wave_set) do 
  3521. 		if wave.required_kill then 
  3522. 			while wave.thread ~= INVALID_THREAD_HANDLE do 
  3523. 				thread_yield() 
  3524. 			end 
  3525. 		end 
  3526. 	end 
  3527. end 
  3528.  
  3529. -- Wait for all non repeating waves to completely end 
  3530. function m13_wait_for_all_non_repeating_waves(wave_set) 
  3531. 	for key, wave in pairs(wave_set) do 
  3532. 		if wave.required_kill or wave.repeat_wave == false then 
  3533. 			while wave.thread ~= INVALID_THREAD_HANDLE do 
  3534. 				thread_yield() 
  3535. 			end 
  3536. 		end 
  3537. 	end 
  3538. end 
  3539.  
  3540. -- Wait until all the non repeating waves have completed the specified state 
  3541. -- 
  3542. function m13_wait_for_waves_to_complete_state(wave_set, state) 
  3543. 	for key, wave in pairs(wave_set) do 
  3544. 		if wave.required_kill or wave.repeat_wave == false then 
  3545. 			while wave.state <= state do 
  3546. 				thread_yield() 
  3547. 			end 
  3548. 		end 
  3549. 	end 
  3550. end 
  3551.  
  3552. -- Checks to see how many waves are in the specified state 
  3553. -- 
  3554. function m13_waves_in_state(wave_set, state) 
  3555. 	local in_state = 0 
  3556. 	 
  3557. 	for key, wave in pairs(wave_set) do 
  3558. 		if wave.required_kill or wave.repeat_wave == false then 
  3559. 			if wave.state == state then 
  3560. 				in_state = in_state + 1 
  3561. 			end 
  3562. 		end 
  3563. 	end 
  3564. 	 
  3565. 	return in_state 
  3566. end 
  3567.  
  3568. -- Spawns a group. 
  3569. -- 
  3570. -- group:			Group to spawn 
  3571. -- spawn_point:	Location to spawn the group at 
  3572. function m13_group_spawn(wave, group, spawn_point) 
  3573. 	if group_is_loaded(group.name) then 
  3574. 		debug_print( "MAD", "ERROR: Group " .. group.name .. " is already loaded\n" ) 
  3575. 		return 
  3576. 	end 
  3577. 	 
  3578. 	if wave.required_kill ~= true and wave.critical_spawn ~= true then 
  3579. 		-- wait until we have the room to create some more 
  3580. 		while M13_num_troops >= M13_max_troops do 
  3581. 			thread_yield() 
  3582. 		end 
  3583. 	end 
  3584. 	 
  3585. 	M13_num_troops = M13_num_troops + #group.members 
  3586. 	 
  3587. 	group_create(group.name, true) 
  3588. 	 
  3589. 	debug_print( "MAD", "M13_num_troops: " .. M13_num_troops .. "\n" ) 
  3590. 	 
  3591. 	local death_cb 
  3592.  
  3593. 	if group.vehicle ~= "" then 
  3594. 		if wave.vehicle_speed ~= nil and wave.vehicle_speed ~= "" and wave.vehicle_speed > 0.1 then 
  3595. 			vehicle_speed_override(group.vehicle, wave.vehicle_speed) 
  3596. 		end 
  3597.  
  3598. 		if m13_vehicle_is_tank( group.vehicle ) or m13_vehicle_is_helicopter( group.vehicle ) then 
  3599. 			-- just load em up 
  3600. 			vehicle_enter_group_teleport( group.members, group.vehicle ) 
  3601. 		else 
  3602. 			-- driver and gunner 
  3603. 			vehicle_enter_teleport( group.members[ 1 ], group.vehicle, 0 ) 
  3604. 			vehicle_enter_teleport( group.members[ 2 ], group.vehicle, 1 ) 
  3605. 		end 
  3606. 		 
  3607. 		teleport_vehicle( group.vehicle, spawn_point.nav ) 
  3608.  
  3609. 		-- Make the driver invulnerable to ensure he can get to his destination. If the vehicle is 
  3610. 		-- destroyed, the driver will be taken care of in the callback. 
  3611. 		local driver = vehicle_get_driver(group.vehicle) 
  3612. 		turn_invulnerable(driver) 
  3613. 		 
  3614. 		if not m13_vehicle_is_tank(group.vehicle) and not m13_vehicle_is_helicopter(group.vehicle) then 
  3615. 			-- look for some passengers 
  3616. 			if  M13_num_troops < M13_max_troops and sizeof_table( M13_passengers_available ) > 0 then 
  3617. 				local pass_group_name, pass_group_data 
  3618. 				for k,v in pairs( M13_passengers_available ) do 
  3619. 					pass_group_name = k 
  3620. 					pass_group_data = v 
  3621. 					break 
  3622. 				end 
  3623. 				 
  3624. 				-- move to active 
  3625. 				M13_passengers_active[ pass_group_name ] = pass_group_data 
  3626. 				M13_passengers_available[ pass_group_name ] = nil 
  3627. 				 
  3628. 				-- set the attached spawn group for cleanup later 
  3629. 				pass_group_data.spawn_group = group.name 
  3630. 				 
  3631. 				M13_num_troops = M13_num_troops + #pass_group_data.members 
  3632. 				group_create( pass_group_name, true ) 
  3633. 				 
  3634. 				-- load them up after the driver, starting as seat 3 
  3635. 				for i = 1, #pass_group_data.members do 
  3636. 					vehicle_enter_teleport( pass_group_data.members[ i ], group.vehicle, i + 1 ) 
  3637. 				end 
  3638. 			end 
  3639. 			 
  3640. 			set_ignore_ai_flag(driver, true) 
  3641. 			vehicle_suppress_npc_exit(group.vehicle, true) 
  3642. 		end 
  3643.  
  3644. 		-- special case: if a list of paths are given then OI will be set later 
  3645. 		if wave.required_kill and type( spawn_point.path ) ~= "table" then 
  3646. 			marker_add(group.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  3647. 		end 
  3648. 		 
  3649. 		on_vehicle_destroyed("m13_wave_vehicle_killed_cb", group.vehicle) 
  3650. 		 
  3651. 		if m13_vehicle_is_helicopter(group.vehicle) then 
  3652. 			-- turn off missile firing, we'll fire them from script 
  3653. 			ai_set_action_delay( vehicle_get_driver( group.vehicle ), "throw grenade", 99999 ) 
  3654. 		end 
  3655. 	else 
  3656. 		if wave.required_kill then 
  3657. 			death_cb = "m13_required_kill_cb" 
  3658. 			 
  3659. 			for key, npc in pairs(group.members) do 
  3660. 				marker_add(npc, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  3661. 			end 
  3662. 		end 
  3663. 	end 
  3664. 	 
  3665. 	if death_cb ~= nil then 
  3666. 		for key, npc in pairs(group.members) do 
  3667. 			on_death(death_cb, npc) 
  3668. 		end 
  3669. 	end 
  3670. 	 
  3671. 	-- Prevent STAG from dropping their guns since the player won't be able to get to them 
  3672. 	-- and for memory related reasons. 
  3673. 	for key, npc in pairs(group.members) do 
  3674. 		npc_dont_drop_weapon_on_death(npc, true) 
  3675. 	end 
  3676. end 
  3677.  
  3678. -- Returns true if all the script npcs are dead 
  3679. -- 
  3680. -- group: group to check the members state of 
  3681. -- 
  3682. function m13_group_is_dead(group) 
  3683. 	if m13_vehicle_is_tank(group.vehicle) or m13_vehicle_is_helicopter(group.vehicle) then 
  3684. 		return vehicle_is_destroyed(group.vehicle) 
  3685. 	end 
  3686.  
  3687. 	return group_members_alive(group.name) == 0 
  3688. end 
  3689.  
  3690. -- Instruct a group to pathfind along a path or to a nav point. 
  3691. -- 
  3692. -- group: Group to instruct to move 
  3693. -- nav_or_path: Name of a nav point to go to or a path to follow 
  3694. -- 
  3695. function m13_group_pathfind_to(group, nav_or_path) 
  3696. 	if nav_or_path == "" or group.vehicle == "" or vehicle_is_destroyed(group.vehicle) then 
  3697. 		return 
  3698. 	end 
  3699.  
  3700. 	if m13_vehicle_is_helicopter(group.vehicle) then 
  3701. 		if type( nav_or_path ) == "table" then 
  3702. 			-- special case - totally one off 
  3703. 			-- if we have more than one path then we will set the OI after the first one 
  3704. 			helicopter_fly_to_direct( group.vehicle, -1.0, nav_or_path[ 1 ] ) 
  3705. 			marker_add( group.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  3706. 			helicopter_fly_to_direct( group.vehicle, -1.0, nav_or_path[ 2 ] ) 
  3707. 		else 
  3708. 			helicopter_fly_to_direct( group.vehicle, -1.0, nav_or_path ) 
  3709. 		end 
  3710. 	else 
  3711. 		vehicle_pathfind_to(group.vehicle, nav_or_path, true, true, false, false) 
  3712. 	end 
  3713. end 
  3714.  
  3715. -- Tell all the passengers in the vehicle to get out, and flag them with a kill icon if necessary. 
  3716. -- 
  3717. function m13_group_drop_off_passengers(wave, group) 
  3718. 	if group.vehicle == "" or vehicle_is_destroyed(group.vehicle) then 
  3719. 		return 
  3720. 	end 
  3721. 	 
  3722. 	-- Tanks and Heli's cannot drop anyone off. 
  3723. 	if m13_vehicle_is_tank(group.vehicle) then 
  3724. 		vehicle_speed_cancel(group.vehicle) 
  3725. 		vehicle_speed_override(group.vehicle, 0.0) 
  3726. 		return 
  3727. 	end 
  3728. 	 
  3729. 	if m13_vehicle_is_helicopter(group.vehicle) then 
  3730. 		vehicle_speed_cancel(group.vehicle) 
  3731. 		return 
  3732. 	end 
  3733.  
  3734. 	local driver = vehicle_get_driver(group.vehicle) 
  3735. 	if driver ~= "" and driver ~= nil then 
  3736. 		turn_vulnerable(driver) 
  3737. 	end 
  3738. 	 
  3739. 	vehicle_speed_cancel(group.vehicle) 
  3740. 	vehicle_stop(group.vehicle) 
  3741. 	vehicle_suppress_npc_exit(group.vehicle, false) 
  3742. 	 
  3743. 	if wave.required_kill then 
  3744. 		marker_remove(group.vehicle) 
  3745. 	end 
  3746. 	 
  3747. 	local gunner = get_char_in_vehicle( group.vehicle, 1 ) 
  3748. 	if gunner ~= nil then 
  3749. 		if not character_is_dead( gunner ) then 
  3750. 			set_ignore_ai_flag( gunner, true ) 
  3751. 			squad_enable( gunner, false ) 
  3752. 		end 
  3753. 	end 
  3754.  
  3755. 	for i = 0, 7 do 
  3756. 		local npc = get_char_in_vehicle( group.vehicle, i ) 
  3757. 		if npc ~= nil and npc ~= "" then 
  3758. 			if not character_is_dead(npc) then 
  3759. 				if i ~= 1 then	-- skip 1, that's the gunner 
  3760. 					set_ignore_ai_flag( npc, false ) 
  3761. 					vehicle_exit(npc) 
  3762. 					 
  3763. 					if wave.attack_target ~= nil then 
  3764. 						ai_add_enemy_target( npc, wave.attack_target, ATTACK_NOW_NEVER_LOSE, true ) 
  3765. 					else 
  3766. 						ai_add_enemy_target( npc, m13_get_closest_player( npc ), ATTACK_NOW_NEVER_LOSE, true ) 
  3767. 					end 
  3768. 				end	-- if 
  3769. 				 
  3770. 				if wave.required_kill then 
  3771. 					marker_add(npc, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  3772. 					on_death("m13_required_kill_cb", npc) 
  3773. 				end	-- if 
  3774. 			end	-- if 
  3775. 		end	-- if 
  3776. 	end	-- for 
  3777.  
  3778. 	vehicle_suppress_npc_exit(group.vehicle, true) 
  3779. 	 
  3780. 	-- after everyone is out except the gunner, process the gunner 
  3781. 	if gunner ~= nil and gunner ~= "" then 
  3782. 		if not character_is_dead( gunner ) then 
  3783. 			set_ignore_ai_flag( gunner, false ) 
  3784. 			ai_add_enemy_target( gunner, m13_get_closest_player( gunner ), ATTACK_NOW_NEVER_LOSE, true ) 
  3785. 		end 
  3786. 	end 
  3787. end	-- function 
  3788.  
  3789. function m13_vehicle_flee(group, spawn_point) 
  3790. 	if group.vehicle == "" or vehicle_is_destroyed(group.vehicle) then 
  3791. 		return 
  3792. 	end 
  3793.  
  3794. 	-- Helicopters and Tanks cannot flee. Tell them to attack the player instead. 
  3795. 	if m13_vehicle_is_tank(group.vehicle) then 
  3796. 		local driver = vehicle_get_driver(group.vehicle) 
  3797. 		ai_add_enemy_target(driver, CLOSEST_PLAYER, ATTACK_NOW_NEVER_LOSE, true) 
  3798. 		if (character_is_ready(group.members[2])) then 
  3799. 			ai_add_enemy_target(group.members[2], CLOSEST_PLAYER, ATTACK_NOW_NEVER_LOSE, true) 
  3800. 			set_perfect_aim(group.members[2], true) 
  3801. 		end 
  3802. 		return 
  3803. 	end 
  3804. 	 
  3805. 	if (m13_vehicle_is_helicopter(group.vehicle) and spawn_point.flee == "") then 
  3806. 		return 
  3807. 	end 
  3808.  
  3809. 	m13_group_pathfind_to(group, spawn_point.flee) 
  3810. 	on_vehicle_destroyed("", group.vehicle) 
  3811.  
  3812. 	local driver = vehicle_get_driver(group.vehicle) 
  3813. 	local driver_valid = driver ~= nil and driver ~= "" 
  3814. 	local flee_valid = spawn_point.flee ~= "" and spawn_point.flee ~= nil 
  3815.  
  3816. 	if driver_valid and flee_valid and not vehicle_is_destroyed(group.vehicle) then 
  3817. 		-- The vehicle was not stopped by the player. Kill the driver so he doesn't attempt to get 
  3818. 		-- back to the player. 
  3819. 		character_kill(driver) 
  3820. 	else 
  3821. 		-- The vehicle did not complete it's path. Tell the driver to get out and release everyone to the world 
  3822. 		if driver_valid then 
  3823. 			vehicle_exit(driver) 
  3824. 			release_to_world(driver) 
  3825. 		end 
  3826. 		release_to_world(group.vehicle) 
  3827. 	end 
  3828. end 
  3829.  
  3830. -- Main wave logic. Iterates through all the groups, and then restart the wave is told to do so. 
  3831. -- 
  3832. function m13_wave_thread( wave ) 
  3833. 	local dont_repeat = false 
  3834. 	delay( wave.initial_delay ) 
  3835.  
  3836. 	while true do 
  3837. 		-- Iterate through all the groups in the wave 
  3838. 		for key, group_set in pairs( wave.groups ) do 
  3839. 			local group = group_set.group 
  3840. 			local spawn_point = group_set.spawn_point 
  3841.  
  3842. 			-- Spawn the group 
  3843. 			wave.state = M13_wave_states.spawning 
  3844. 			m13_group_spawn( wave, group, spawn_point ) 
  3845. 			 
  3846. 			-- Have the group follow their path, exit the vehicle, and fire at the player 
  3847. 			wave.state = M13_wave_states.pathfinding 
  3848. 			m13_group_pathfind_to( group, spawn_point.path ) 
  3849. 			m13_group_drop_off_passengers( wave, group ) 
  3850. 			 
  3851. 			if m13_vehicle_is_tank( group.vehicle ) then 
  3852. 				local driver = vehicle_get_driver( group.vehicle ) 
  3853. 				ai_add_enemy_target( driver, m13_get_closest_player( group.vehicle ), ATTACK_NOW_NEVER_LOSE, true ) 
  3854. 				if character_is_ready( group.members[ 2 ] ) then 
  3855. 					ai_add_enemy_target( group.members[ 2 ], m13_get_closest_player( group.vehicle ), ATTACK_NOW_NEVER_LOSE, true ) 
  3856. 					set_perfect_aim( group.members[ 2 ], true ) 
  3857. 				end 
  3858. 				vehicle_freeze(group.vehicle) 
  3859. 				vehicle_set_keyframed_physics(group.vehicle, true) 
  3860. 			elseif m13_vehicle_is_helicopter( group.vehicle ) then 
  3861. 				ai_add_enemy_target( vehicle_get_driver( group.vehicle ), m13_get_closest_player( group.vehicle ), ATTACK_NOW_NEVER_LOSE, true ) 
  3862. 				helicopter_shoot_human( group.vehicle, m13_get_closest_player( group.vehicle ) ) 
  3863. 				helicopter_go_to_set_target( group.vehicle, m13_get_closest_player( group.vehicle ) ) 
  3864. 			else 
  3865. 				for i, m in pairs( group.members ) do 
  3866. 					if wave.attack_target ~= nil then 
  3867. 						ai_add_enemy_target( m, wave.attack_target , ATTACK_NOW_NEVER_LOSE, true ) 
  3868. 					else 
  3869. 						ai_add_enemy_target( m, m13_get_closest_player( m ), ATTACK_NOW_NEVER_LOSE, true ) 
  3870. 					end 
  3871. 				end 
  3872. 			end 
  3873. 			 
  3874. 			wave.state = M13_wave_states.release_delay 
  3875. 			 
  3876. 			-- Wait until the group is dead 
  3877. 			local fire_delay = 100 
  3878. 			 
  3879. 			while true do 
  3880. 				-- all dead?  move on. 
  3881. 				if group_is_loaded( group.name ) == false or m13_group_is_dead( group )  == true then 
  3882. 					break 
  3883. 				end 
  3884. 				 
  3885. 				-- if a kill trigger has been given, check it 
  3886. 				if wave.kill_trigger ~= nil and object_is_in_trigger( wave.kill_trigger, LOCAL_PLAYER ) == true then 
  3887. 					dont_repeat = true 
  3888. 					break 
  3889. 				end 
  3890. 				 
  3891. 				if m13_vehicle_is_helicopter( group.vehicle ) then 
  3892. 					-- fire up the missiles 
  3893. 					if fire_delay > 10 then 
  3894. 						local closest_player = LOCAL_PLAYER 
  3895. 						 
  3896. 						if coop_is_active() then 
  3897. 							if get_dist( group.vehicle, LOCAL_PLAYER ) > get_dist( group.vehicle, REMOTE_PLAYER ) then 
  3898. 								closest_player = REMOTE_PLAYER 
  3899. 							end 
  3900. 						end 
  3901. 						 
  3902. 						helicopter_shoot_human( group.vehicle, closest_player, true, 10 ) 
  3903. 						 
  3904. 						fire_delay = 0 
  3905. 					end 
  3906. 					 
  3907. 					fire_delay = fire_delay + get_frame_time() 
  3908. 				end 
  3909. 				 
  3910. 				thread_yield() 
  3911. 			end 
  3912. 			 
  3913. 			m13_destroy_wave_group(group) 
  3914.  
  3915. 			-- Wait the specified amount of time before spawning the next group 
  3916. 			wave.state = M13_wave_states.next_group_delay 
  3917. 			delay(wave.next_group_delay) 
  3918. 		end 
  3919.  
  3920. 		-- If we are not allowed to repeat the wave, break out 
  3921. 		if dont_repeat == true or wave.repeat_wave == false or wave.required_kill then 
  3922. 			break 
  3923. 		end 
  3924. 	end 
  3925.  
  3926. 	wave.state = M13_wave_states.complete 
  3927. 	local kill_thread = false 
  3928. 	m13_stop_wave(wave, kill_thread) 
  3929. 	wave.thread = INVALID_THREAD_HANDLE 
  3930. end 
  3931.  
  3932. -- Sets up the system to tell the player to go to the selected side of the building. 
  3933. function m13_setup_side(side) 
  3934. 	M13_status.current_side = side 
  3935. 	 
  3936. 	if M13_threads.side_marker == nil then 
  3937. 		M13_threads.side_marker = thread_new( "m13_setup_side_thread" ) 
  3938. 	end 
  3939. end 
  3940.  
  3941. function m13_setup_side_thread() 
  3942. 	local north_marked_local = false 
  3943. 	local north_marked_coop = false 
  3944. 	local south_marked_local = false 
  3945. 	local south_marked_coop= false 
  3946. 	local should_mark_north_local = false 
  3947. 	local should_mark_north_coop = false 
  3948. 	local should_mark_south_local = false 
  3949. 	local should_mark_south_coop = false 
  3950. 	 
  3951. 	trigger_enable(M13_triggers.north_side, true) 
  3952. 	trigger_enable(M13_triggers.south_side, true) 
  3953. 	 
  3954. 	while true do 
  3955. 		if M13_status.current_side == "north" then 
  3956. 			should_mark_north_local = object_is_in_trigger( M13_triggers.north_side, LOCAL_PLAYER ) ~= true 
  3957. 			 
  3958. 			if coop_is_active() then 
  3959. 				should_mark_north_coop = object_is_in_trigger( M13_triggers.north_side, REMOTE_PLAYER ) ~= true 
  3960. 			end 
  3961. 			 
  3962. 			should_mark_south_local  = false 
  3963. 			should_mark_south_coop = false 
  3964. 		elseif M13_status.current_side == "south" then 
  3965. 			should_mark_south_local = object_is_in_trigger( M13_triggers.south_side, LOCAL_PLAYER ) ~= true 
  3966. 			 
  3967. 			if coop_is_active() then 
  3968. 				should_mark_south_coop = object_is_in_trigger( M13_triggers.south_side, REMOTE_PLAYER ) ~= true 
  3969. 			end 
  3970. 			 
  3971. 			should_mark_north_local  = false 
  3972. 			should_mark_north_coop = false 
  3973. 		else 
  3974. 			should_mark_south_local  = false 
  3975. 			should_mark_south_coop = false 
  3976. 			should_mark_north_local  = false 
  3977. 			should_mark_north_coop = false 
  3978. 		end 
  3979. 		 
  3980. 		if north_marked_local ~= should_mark_north_local then 
  3981. 			m13_side_change_marked( M13_triggers.north_side, should_mark_north_local, SYNC_LOCAL ) 
  3982. 			north_marked_local = should_mark_north_local 
  3983. 		end 
  3984. 		 
  3985. 		if south_marked_local ~= should_mark_south_local then 
  3986. 			m13_side_change_marked( M13_triggers.south_side, should_mark_south_local, SYNC_LOCAL ) 
  3987. 			south_marked_local = should_mark_south_local 
  3988. 		end 
  3989.  
  3990. 		if north_marked_coop ~= should_mark_north_coop then 
  3991. 			m13_side_change_marked( M13_triggers.north_side, should_mark_north_coop, SYNC_REMOTE ) 
  3992. 			north_marked_coop = should_mark_north_coop 
  3993. 		end 
  3994. 		 
  3995. 		if south_marked_coop ~= should_mark_south_coop then 
  3996. 			m13_side_change_marked( M13_triggers.south_side, should_mark_south_coop, SYNC_REMOTE ) 
  3997. 			south_marked_coop = should_mark_south_coop 
  3998. 		end 
  3999.  
  4000. 		thread_yield() 
  4001. 	end 
  4002. end 
  4003.  
  4004. function m13_side_change_marked( trig, mark, sync ) 
  4005. 	if mark then 
  4006. 		marker_add_trigger( trig, MINIMAP_ICON_PROTECT_ACQUIRE, INGAME_EFFECT_LOCATION, OI_ASSET_DEFEND, OI_FLAGS_FULL, sync ) 
  4007. 	else 
  4008. 		marker_remove_trigger( trig, SYNC_ALL ) 
  4009. 	end 
  4010. end 
  4011.  
  4012. -- Removes any markers from a killed NPC 
  4013. -- 
  4014. function m13_required_kill_cb(victim, killer) 
  4015. 	on_death("", victim) 
  4016. 	marker_remove(victim) 
  4017. end 
  4018.  
  4019. -- Removes any markers attached to a vehicle, and kill the driver if they are still alive 
  4020. -- 
  4021. function m13_wave_vehicle_killed_cb(vehicle) 
  4022. 	on_vehicle_destroyed("", vehicle) 
  4023. 	marker_remove(vehicle) 
  4024. 	 
  4025. 	local driver = vehicle_get_driver(vehicle) 
  4026. 	if driver ~= nil and driver ~= "" then 
  4027. 		turn_vulnerable(driver) 
  4028. 		if not character_is_dead(driver) then 
  4029. 			character_kill(driver, true) 
  4030. 		end 
  4031. 		release_to_world(driver) 
  4032. 	end 
  4033. 	 
  4034. 	release_to_world(vehicle) 
  4035. end 
  4036.  
  4037. function m13_disable_traffic( b ) 
  4038. 	local enable = false 
  4039. 	 
  4040. 	if b == false then 
  4041. 		enable = true 
  4042. 	end 
  4043. 	 
  4044. 	sidewalk_disable_nodes ( M13_triggers.no_traffic, enable ) 
  4045. 	traffic_disable_lanes ( M13_triggers.no_traffic, enable ) 
  4046. end 
  4047.  
  4048. -- create destroyed vehicles to give illusion of chaos 
  4049. -- area can be "north", "south" or "general" 
  4050. function m13_create_clutter( area ) 
  4051. 	local groups, r 
  4052. 	 
  4053. 	groups = m13_get_clutter_groups( area ) 
  4054. 	 
  4055. 	for i, g in pairs( groups ) do 
  4056. 		group_create( g.name, true ) 
  4057. 		 
  4058. 		for j, v in pairs( g.vehicles ) do 
  4059. 			r = rand_int( 1, 4 ) 
  4060. 			 
  4061. 			if r == 1 then 
  4062. 				vehicle_hide( v ) 
  4063. 			elseif r == 2 then 
  4064. 				vehicle_set_smoke_and_fire_state( v, true, true ) 
  4065. 			elseif r == 3 then 
  4066. 				vehicle_make_corpse( v, true ) 
  4067. 			else 
  4068. 				vehicle_make_corpse( v, false ) 
  4069. 			end 
  4070. 		end 
  4071. 	end 
  4072. end 
  4073.  
  4074. function m13_clear_clutter( area ) 
  4075. 	local groups 
  4076. 	 
  4077. 	groups = m13_get_clutter_groups( area ) 
  4078. 	 
  4079. 	for i, g in pairs( groups ) do 
  4080. 		group_destroy( g ) 
  4081. 	end 
  4082. end 
  4083.  
  4084. function m13_get_clutter_groups( area ) 
  4085. 	if area == "north" then 
  4086. 		return { M13_groups.clutter_north } 
  4087. 	elseif area == "south" then 
  4088. 		return { M13_groups.clutter_south } 
  4089. 	elseif area == "general" then 
  4090. 		return {M13_groups.clutter_north, M13_groups.clutter_south, M13_groups.clutter_general } 
  4091. 	else 
  4092. 		return { } 
  4093. 	end 
  4094. end 
  4095.  
  4096. function m13_monitor_passengers_thread() 
  4097. 	local groups_cleared = { } 
  4098. 	 
  4099. 	while true do 
  4100. 		-- check to see if any passenger groups have been killed 
  4101. 		-- so they can be reused 
  4102. 		for group_name, group_data in pairs( M13_passengers_active ) do 
  4103. 			local all_dead = true 
  4104. 			for i, member in pairs( group_data.members ) do 
  4105. 				if character_is_dead( member ) == false then 
  4106. 					all_dead = false 
  4107. 					break 
  4108. 				end 
  4109. 			end 
  4110. 			 
  4111. 			if all_dead then 
  4112. 				groups_cleared[ group_name ] = true 
  4113. 			end 
  4114. 		end 
  4115. 		 
  4116. 		-- clear the groups up now so we don't mess up iteration above 
  4117. 		for group_name, duh in pairs( groups_cleared ) do 
  4118. 			m13_destroy_passenger_group( group_name ) 
  4119. 		end 
  4120. 		 
  4121. 		groups_cleared = { } 
  4122. 		 
  4123. 		thread_yield() 
  4124. 	end 
  4125. end 
  4126.  
  4127. function m13_destroy_passenger_group( group_name, release ) 
  4128. 	if M13_passengers_active[ group_name ] == nil then 
  4129. 		return 
  4130. 	end 
  4131. 	 
  4132. 	if release ~= false then 
  4133. 		release_to_world( group_name ) 
  4134. 	end 
  4135. 	 
  4136. 	group_destroy( group_name ) 
  4137. 	M13_num_troops = M13_num_troops - #M13_passengers_active[ group_name ].members 
  4138. 	 
  4139. 	M13_passengers_available[ group_name ] = M13_passengers_active[ group_name ] 
  4140. 	M13_passengers_active[ group_name ] = nil 
  4141. end 
  4142.  
  4143. function m13_get_closest_player( obj ) 
  4144. 	local closest = LOCAL_PLAYER 
  4145. 	 
  4146. 	if coop_is_active() then 
  4147. 		if get_dist( obj, REMOTE_PLAYER ) < get_dist( obj, LOCAL_PLAYER ) then 
  4148. 			closest = REMOTE_PLAYER 
  4149. 		end 
  4150. 	end 
  4151. 	 
  4152. 	return closest 
  4153. end 
  4154.  
  4155. function m13_disable_ambient_spawning( b ) 
  4156. 	local spawn = ( b == false ) 
  4157. 	spawning_vehicles( spawn ) 
  4158. 	spawning_pedestrians( spawn ) 
  4159. end 
  4160.  
  4161. function m13_vfx_play(vfx_group) 
  4162. 	for i, vfx in pairs(vfx_group) do 
  4163. 		if vfx.handle == -1 then 
  4164. 			vfx.handle = effect_play(vfx.nav, true) 
  4165. 		end 
  4166. 	end 
  4167. end 
  4168.  
  4169. function m13_distance_clutter_show() 
  4170. 	for i, mover in pairs(M13_movers.clutter) do 
  4171. 		mesh_mover_reset(mover) 
  4172. 		mesh_mover_show(mover) 
  4173. 		mesh_mover_set_invulnerable(mover, true) 
  4174. 	end 
  4175. end 
  4176.  
  4177. function m13_distance_clutter_hide() 
  4178. 	for i, mover in pairs(M13_movers.clutter) do 
  4179. 		mesh_mover_hide(mover) 
  4180. 	end 
  4181. end 
  4182.  
  4183. function m13_cellphone_call_wait( convo, recieving, persona ) 
  4184. 	M13_status.cellphone_call_in_progress = convo 
  4185. 	 
  4186. 	audio_play_for_mission_cellphone( convo, recieving, true, "", "m13_cellphone_call_cb", persona ) 
  4187. 	 
  4188. 	while M13_status.cellphone_call_in_progress do 
  4189. 		thread_yield() 
  4190. 	end 
  4191. end 
  4192.  
  4193. function m13_cellphone_call_cb() 
  4194. 	M13_status.cellphone_call_in_progress = nil 
  4195. end 
  4196.  
  4197. function m13_thread_wrapper( function_ref, ... ) 
  4198. 	function_ref( unpack( arg ) ) 
  4199. end