./m01.lua

  1. --[[ 
  2. 	m01.lua 
  3. 	SR3 Mission Script 
  4. 	DATE: 03-10-2010 
  5. 	AUTHOR:	Neil Ryan 
  6. ]]-- 
  7.  
  8.  
  9. -- Debug flags -- 
  10.  
  11. -- Tweakable Parameters -- 
  12. 	M01_TRANSITION_TIME = 1000 
  13. 	 
  14. 	M01_seconds_to_wait_for_gat_to_kill_guard = 18 
  15. 	 
  16. 	M01_MIN_PITCH = -20 
  17. 	M01_MAX_PITCH = 20 
  18. 	M01_MIN_HEADING = -45 
  19. 	M01_MAX_HEADING = 45 
  20. 		 
  21. 	M01_VAULT_TARGET_TIME1 = 3.0 
  22. 	M01_VAULT_TARGET_TIME2 = 6.0 
  23. 	 
  24. 	-- damage required to kill the first helicopter as percent health left 
  25. 	M01_HELI_DAMAGE = 0.80 
  26. 	 
  27. 	-- delay between calling the M01_Get_Robbed situation 
  28. 	M01_Get_Robbed_Line_Time = 15.0 
  29. 	 
  30. 	-- delay between calling the M01_Attack situation 
  31. 	M01_Attack_Line_Time = 10.0 
  32. 	 
  33. 	M01_player_health = { 
  34. 		shot1 = 0.7, 
  35. 		shot2 = 0.4, 
  36. 		shot3 = 0.3, 
  37. 		break_chains = 0.2 
  38. 	} 
  39.  
  40. -- Groups -- 
  41.  
  42. 	M01_group = { 
  43. 		lobby_cower = { 
  44. 			name = "cower_npc_group", 
  45. 			on_ground = { "cower_npc<001>", "cower_npc<003>", --"cower_npc<002>",  
  46. 						"cower_npc<006>", --"cower_npc<004>", "cower_npc<005>",  
  47. 						"cower_npc<007>", "cower_npc<008>", "cower_npc<009>" }, 
  48. 			members = { "cower_npc<010>", "cower_npc<011>", "cower_npc<012>", 
  49. 						"cower_npc<013>", "cower_npc<014>", "cower_npc<015>", 
  50. 						"cower_npc<016>", "cower_npc<017>" }, 
  51. 			saints_fan = "cower_npc<009>" 
  52. 		}, 
  53. 		 
  54. 		lobby = { 
  55. 			name = "lobby_group 001", 
  56. 			members = {	"lobby_guard 001", "lobby_guard 002", --"lobby_guard 003", "lobby_guard 004", "lobby_guard 005", 
  57. 						"Teller 001", "Teller 002", "Teller 003", "Teller 004" }, 
  58. 			tellers = {	"Teller 001", "Teller 002", "Teller 003", "Teller 004" }, 
  59. 			moving_guards = {	"lobby_guard 001", "lobby_guard 002"},-- "lobby_guard 003", "lobby_guard 004" }, 
  60. 			guard_navs = { "Lobby_guard_nav<001>", "Lobby_guard_nav<002>"},-- "Lobby_guard_nav<003>", "Lobby_guard_nav<004>" }, 
  61. 		}, 
  62. 		 
  63. 		lobby2 = { 
  64. 			name = "lobby_group 002", 
  65. 			members = {	"lobby2_guard 001", "lobby2_guard 002" }, 
  66. 		}, 
  67. 		 
  68. 		lobby3 = { 
  69. 			name = "lobby_group 003", 
  70. 			doorman = "lobby2_guard 003", 
  71. 			members = { "lobby2_guard 004", "lobby2_guard 005", "lobby2_guard 006" }, 
  72. 		}, 
  73. 		 
  74. 		fine_aim = { 
  75. 			name = "fine_aim_group", 
  76. 			members = { "fine_aim 001", "fine_aim 002" } 
  77. 		}, 
  78. 		 
  79. 		second_floor = { 
  80. 			name = "second_floor_group 001", 
  81. 			members = { "second_floor 001", "second_floor 002", "second_floor 003", 
  82. 							"second_floor 004", "second_floor 005", "second_floor 006" }, 
  83. 			shaundi_attacker = "shaundi_attacker" 
  84. 		}, 
  85. 		 
  86. 		third_floor = { 
  87. 			name = "third_floor_group 001", 
  88. 			to_second_members = { "third_floor 003", "third_floor 004" } 
  89. 		}, 
  90. 		 
  91. 		bomb_security2 = { 
  92. 			name = "bomb_security 002", 
  93. 			members = { "fourth_floor 001", "fourth_floor 002", "fourth_floor 003",  
  94. 							"fourth_floor 004", "fourth_floor 005", "fourth_floor 006" }, 
  95. 			rocket_guys = { "fourth_floor 006" }, 
  96. 		}, 
  97. 		 
  98. 		bomb_cower = { 
  99. 			name = "bomb_cower_group", 
  100. 			on_ground = {}, 
  101. 			members = { "bomb_cower<001>", "bomb_cower<002>", "bomb_cower<003>", 
  102. 						"bomb_cower<004>" } 
  103. 		}, 
  104. 		 
  105. 		bomb_flee = { 
  106. 			name = "bomb_flee_group", 
  107. 			members = { "bomb_flee<001>", --"bomb_flee<002>", "bomb_flee<003>", 
  108. 						--"bomb_flee<004>", --"bomb_flee<005>", "bomb_flee<006>", 
  109. 						--"bomb_flee<007>",  
  110. 						--"bomb_flee<008>", --"bomb_flee<009>", 
  111. 						--"bomb_flee<010>" 
  112. 						}, 
  113. 			dest = "bomb_flee_dest"						 
  114. 		}, 
  115. 		 
  116. 		autograph = { 
  117. 			name = "autograph_guy_group", 
  118. 			guy = "autograph_guy", 
  119. 			trigger = "autograph_trigger", 
  120. 			josh_nav = "Josh_autograph", 
  121. 			josh_close_nav = "Josh_autograph_close", 
  122. 			thread = INVALID_THREAD_HANDLE, 
  123. 			effect_handle = -1 
  124. 		}, 
  125. 		 
  126. 		rope = { 
  127. 			name = "rope_group", 
  128. 			members = {  
  129. 				{	name = "rope<001>", 
  130. 					is_down = false		}, 
  131. 					 
  132. 				{	name = "rope<002>", 
  133. 					is_down = false		}, 
  134. 					 
  135. 				{	name = "rope<003>", 
  136. 					is_down = false		}, 
  137. 					 
  138. 				{	name = "rope<004>", 
  139. 					is_down = false		}, 
  140. 					 
  141. 				{	name = "rope<005>", 
  142. 					is_down = false		}, 
  143. 					 
  144. 				{	name = "rope<006>",	-- place of 2a 
  145. 					is_down = false		}, 
  146. 			}				 
  147. 		}, 
  148. 		 
  149. 		swat1_pair = { 
  150. 			name = "swat1_pair_group", 
  151. 			members = { "swat1_pair<001>", "swat1_pair<002>" }, 
  152. 			navs = {	{ "window_mark 005", "window_mark 004" },  
  153. 						{ "window_mark 005", "window_mark 004" } }, 
  154. 			ropes = { 5, 4 }, 
  155. 			set = 1, 
  156. 			thread = INVALID_THREAD_HANDLE, 
  157. 			entry_thread = INVALID_THREAD_HANDLE, 
  158. 			window_entry = true, 
  159. 			active = false 
  160. 		}, 
  161. 		 
  162. 		swat2_pair = { 
  163. 			name = "swat2_pair_group", 
  164. 			members = { "swat2_pair<001>", "swat2_pair<002>" }, 
  165. 			navs = {	{ "window_mark 003", "window_mark 002a" },  
  166. 						{ "window_mark 003", "window_mark 002a" } }, 
  167. 			ropes = { 3, 6 }, 
  168. 			set = 1, 
  169. 			thread = INVALID_THREAD_HANDLE, 
  170. 			entry_thread = INVALID_THREAD_HANDLE, 
  171. 			window_entry = true, 
  172. 			active = false 
  173. 		}, 
  174. 		 
  175. 		swat3_pair = { 
  176. 			name = "swat3_pair_group", 
  177. 			members = { "swat3_pair<001>", "swat3_pair<002>" }, 
  178. 			navs = {	{ "window_mark 002", "window_mark 001" },  
  179. 						{ "window_mark 002", "window_mark 001" } }, 
  180. 			ropes = { 2, 1 }, 
  181. 			set = 1, 
  182. 			thread = INVALID_THREAD_HANDLE, 
  183. 			entry_thread = INVALID_THREAD_HANDLE, 
  184. 			window_entry = true, 
  185. 			active = false 
  186. 		}, 
  187. 		 
  188. 		swat4_pair = { 
  189. 			name = "swat4_pair_group", 
  190. 			members = { "swat4_pair 001", "swat4_pair 002" }, 
  191. 			navs = {	{ "fifth_floor_mark 001", "fifth_floor_mark 002" },  
  192. 						{ "fifth_floor_mark 001", "fifth_floor_mark 002" } }, 
  193. 			set = 1, 
  194. 			thread = INVALID_THREAD_HANDLE, 
  195. 			window_entry = false, 
  196. 			active = false 
  197. 		}, 
  198. 		 
  199. 		swat5_pair = { 
  200. 			name = "swat5_pair_group", 
  201. 			members = { "swat5_pair 001", "swat5_pair 002" }, 
  202. 			navs = {	{ "fifth_floor_mark 003", "fifth_floor_mark 004" },  
  203. 						{ "fifth_floor_mark 003", "fifth_floor_mark 004" } }, 
  204. 			set = 1, 
  205. 			thread = INVALID_THREAD_HANDLE, 
  206. 			window_entry = false, 
  207. 			active = false 
  208. 		}, 
  209. 		 
  210. 		swat_riot_pair = { 
  211. 			name = "swat_riot_pair_group", 
  212. 			members = { "swat_riot_pair<001>", "swat_riot_pair<002>" }, 
  213. 			navs = {	{ "window_mark 005", "window_mark 004" },  
  214. 						{ "window_mark 005", "window_mark 004" } }, 
  215. 			ropes = { 5, 4 }, 
  216. 			set = 1, 
  217. 			thread = INVALID_THREAD_HANDLE, 
  218. 			entry_thread = INVALID_THREAD_HANDLE, 
  219. 			window_entry = true, 
  220. 			active = false 
  221. 		}, 
  222. 		 
  223. 		-- ***************** 
  224. 		--	News Heli's 
  225. 		--		News helis have spotlights that move around and no gunner.  These are just for show. 
  226. 		--		News helis have multiple locations and interest points to highlight the action. 
  227. 		--		A global control M01_news_location determines where to be and what to look at 
  228. 		--		If a M01_news_location is greater than max_locations, news chopper stays at last location. 
  229. 		-- *****************		 
  230. 		news_heli1 = { 
  231. 			name = "news1_heli_group", 
  232. 			vehicle = "News1_heli", 
  233. 			members = { "News1_pilot<001>", "News1_pilot<002>" }, 
  234. 			float_nav = "news1_float", 
  235. 			location = { 
  236. 				{	-- 1 fine_aim 
  237. 					hover_nav = "fine_aim_news1_nav", -- place to hover (or looping path) 
  238. 					looping_path = false, 
  239. 					interest = { "fine_aim_spot<001>", "fine_aim_spot<002>" }, -- groups of 2 interest points for each location 
  240. 					delay_time = 4.0,	-- time to look at each point of interest 
  241. 				}, 
  242. 				{	-- 2 swat 
  243. 					hover_nav = "swat_news1_nav", 
  244. 					looping_path = false, 
  245. 					interest = { "glass<001>", "glass<005>" }, 
  246. 					delay_time = 2.2, 
  247. 				}, 
  248. 				{	-- 3 vault 
  249. 					hover_nav = "news1_vault<001>", 
  250. 					looping_path = false, 
  251. 					interest = { "roof_mark 001", "roof_mark 007" }, 
  252. 					delay_time = 4.0, 
  253. 				}, 
  254. 				{	-- 4 loop 
  255. 					hover_nav = "news1_loop_path", 
  256. 					looping_path = true, 
  257. 					interest = { "roof_mark 001", "roof_mark 007" }, 
  258. 					delay_time = 4.0, 
  259. 				}, 
  260. 			}, 
  261. 			max_locations = 4,	-- number of locations setup for this heli (interest groups and locations) 
  262. 			news_thread = INVALID_THREAD_HANDLE, 
  263. 			thread = INVALID_THREAD_HANDLE 
  264. 		}, 
  265. 		 
  266. 		news_heli2 = { 
  267. 			name = "news2_heli_group", 
  268. 			vehicle = "News2_heli", 
  269. 			members = { "News2_pilot<001>", "News2_pilot<002>" }, 
  270. 			float_nav = "news2_float", 
  271. 			location = { 
  272. 				{	-- 1 fine_aim 
  273. 					hover_nav = "fine_aim_news2_nav", 
  274. 					looping_path = false, 
  275. 					interest = { "fine_aim_spot<002>", "fine_aim_spot<001>" }, 
  276. 					delay_time = 3.0, 
  277. 				}, 
  278. 				{	-- 2 swat 
  279. 					hover_nav = "swat_news2_nav", 
  280. 					looping_path = false, 
  281. 					interest = { "glass<005>", "glass<001>" }, 
  282. 					delay_time = 2.0, 
  283. 				}, 
  284. 				{	-- 3 vault 
  285. 					hover_nav = "news2_vault<001>", 
  286. 					looping_path = false, 
  287. 					interest = { LOCAL_PLAYER, "roof_mark 001" }, 
  288. 					delay_time = 6.0, 
  289. 				}, 
  290. 				{	-- 4 loop 
  291. 					hover_nav = "news2_loop_path", 
  292. 					looping_path = true, 
  293. 					interest = { LOCAL_PLAYER, "roof_mark 001" }, 
  294. 					delay_time = 6.0, 
  295. 				}, 
  296. 			}, 
  297. 			max_locations = 4, 
  298. 			news_thread = INVALID_THREAD_HANDLE, 
  299. 			thread = INVALID_THREAD_HANDLE 
  300. 		}, 
  301. 		 
  302. 		vault_heli = { 
  303. 			name = "vault_heli_group", 
  304. 			vehicle = "heli_vault 001", 
  305. 			pilot = "vault_pilot 001", 
  306. 			nav = "vault_nav 001" 
  307. 		}, 
  308. 		 
  309. 		vault_attackers2 = { 
  310. 			name = "vault_attackers_group", 
  311. 			members = { "vault_attacker<001>", "vault_attacker<002>", "vault_attacker<003>", "vault_attacker<004>", 
  312. 						"vault_attacker<005>", "vault_attacker<006>", "vault_attacker<007>", "vault_attacker<008>", 
  313. 						"vault_attacker<009>", "vault_attacker<010>" }, 
  314. 			navs = { "vault_attack_nav<001>", "vault_attack_nav<002>", "vault_attack_nav<003>", "vault_attack_nav<004>", 
  315. 						"vault_attack_nav<005>", "vault_attack_nav<006>", "vault_attack_nav<007>", "vault_attack_nav<008>", 
  316. 						"vault_attack_nav<009>", "vault_attack_nav<010>" }, 
  317. 			gat = "vault_attacker Gat", 
  318. 			shaundi = "vault_attacker Shaundi" 
  319. 		}, 
  320. 		 
  321. 		roof1_pair = { 
  322. 			name = "roof1_pair_group", 
  323. 			members = { "roof1_pair 001", "roof1_pair 002" }, 
  324. 			navs = {	{ "roof_mark 001", "roof_mark 002" },  
  325. 						{ "roof_mark 003", "roof_mark 004" } }, 
  326. 			set = 1, 
  327. 			thread = INVALID_THREAD_HANDLE, 
  328. 			window_entry = false, 
  329. 			active = false 
  330. 		}, 
  331. 		 
  332. 		roof2_pair = { 
  333. 			name = "roof2_pair_group", 
  334. 			members = { "roof2_pair 001", "roof2_pair 002" }, 
  335. 			navs = {	{ "roof_mark 003", "roof_mark 004" },  
  336. 						{ "roof_mark 001", "roof_mark 002" } }, 
  337. 			set = 1, 
  338. 			thread = INVALID_THREAD_HANDLE, 
  339. 			window_entry = false, 
  340. 			active = false 
  341. 		}, 
  342. 		 
  343. 		roof3_pair = { 
  344. 			name = "roof3_pair_group", 
  345. 			members = { "roof3_pair 001", "roof3_pair 002" }, 
  346. 			navs = {	{ "roof_mark 007", "roof_mark 008" },  
  347. 						{ "roof_mark 001", "roof_mark 002" } }, 
  348. 			set = 1, 
  349. 			thread = INVALID_THREAD_HANDLE, 
  350. 			window_entry = false, 
  351. 			active = false 
  352. 		}, 
  353. 		 
  354. 		roof4_pair = { 
  355. 			name = "roof4_pair_group", 
  356. 			members = { "roof4_pair 001", "roof4_pair 002" }, 
  357. 			navs = {	{ "Fifth_window 001", "Fifth_window 002" },  
  358. 						{ "Fifth_window 003", "Fifth_window 004" } }, 
  359. 			set = 1, 
  360. 			thread = INVALID_THREAD_HANDLE, 
  361. 			window_entry = false, 
  362. 			active = false 
  363. 		}, 
  364. 		 
  365. 		roof5_pair = { 
  366. 			name = "roof5_pair_group", 
  367. 			members = { "roof5_pair 001", "roof5_pair 002" }, 
  368. 			navs = {	{ "Fifth_window 003", "Fifth_window 004" },  
  369. 						{ "Fifth_window 001", "Fifth_window 002" } }, 
  370. 			set = 1, 
  371. 			thread = INVALID_THREAD_HANDLE, 
  372. 			window_entry = false, 
  373. 			active = false 
  374. 		}, 
  375. 		 
  376. 		-- ***************** 
  377. 		-- Transports 
  378. 		--		Transports float high above.  They land, drop off their soldiers and fly away 
  379. 		-- ***************** 
  380.  
  381. 		transport1 = { 
  382. 			name = "transport1_heli_group",  
  383. 			vehicle = "transport1_heli", 
  384. 			pilots = { "transport1_heli_pilot 001", "transport1_heli_pilot 002" }, 
  385. 			soldiers = { "transport1_heli_soldier 001", "transport1_heli_soldier 002", "transport1_heli_soldier 003"}, 
  386. 			soldier_dest = "roof_mark 005", 
  387. 			float_nav = "transport1_float", 
  388. 			path = "transport1_heli_nav", 
  389. 			exit_nav = "transport1_float", 
  390. 			pilot_persona = "", 
  391. 			persona_line = "", 
  392. 			complete = false, 
  393. 			ground_delay = 3.0, 
  394. 			thread = INVALID_THREAD_HANDLE, 
  395. 			drop_off_thread = INVALID_THREAD_HANDLE, 
  396. 			setup_thread = INVALID_THREAD_HANDLE 
  397. 		},		 
  398.  
  399. 		transport2 = { 
  400. 			name = "transport2_heli_group",  
  401. 			vehicle = "transport2_heli", 
  402. 			pilots = { "transport2_heli_pilot 001", "transport2_heli_pilot 002" }, 
  403. 			soldiers = { "transport2_heli_soldier 001", "transport2_heli_soldier 002", "transport2_heli_soldier 003"}, 
  404. 			soldier_dest = "roof_mark 006", 
  405. 			float_nav = "transport2_float", 
  406. 			path = "transport2_heli_nav", 
  407. 			exit_nav = "transport2_float", 
  408. 			pilot_persona = "Interrogation", 
  409. 			persona_line = "M01_Bullhorn_Heli_Drop_02", 
  410. 			complete = false, 
  411. 			ground_delay = 3.0, 
  412. 			flyby_float = "transport2_flyby_start", 
  413. 			flyby_path = "transport2_flyby_path", 
  414. 			thread = INVALID_THREAD_HANDLE, 
  415. 			drop_off_thread = INVALID_THREAD_HANDLE, 
  416. 			setup_thread = INVALID_THREAD_HANDLE 
  417. 		},		 
  418.  
  419. 		transport3 = { 
  420. 			name = "transport3_heli_group",  
  421. 			vehicle = "transport3_heli", 
  422. 			pilots = { "transport3_heli_pilot<001>", "transport3_heli_pilot<002>" }, 
  423. 			soldiers = { "transport3_heli_soldier<001>", "transport3_heli_soldier<002>", "transport3_heli_soldier<003>"}, 
  424. 			soldier_dest = "roof_mark 002", 
  425. 			float_nav = "transport3_float", 
  426. 			path = "transport3_heli_nav", 
  427. 			exit_nav = "transport3_float", 
  428. 			pilot_persona = "Interrogation", 
  429. 			persona_line = "M01_Bullhorn_Heli_Drop_After_Crash", 
  430. 			complete = false, 
  431. 			ground_delay = 7.0, 
  432. 			flyby_float = "transport3_flyby_start", 
  433. 			flyby_path = "transport3_flyby_path", 
  434. 			thread = INVALID_THREAD_HANDLE, 
  435. 			drop_off_thread = INVALID_THREAD_HANDLE, 
  436. 			setup_thread = INVALID_THREAD_HANDLE 
  437. 		},	 
  438. 		 
  439. 		roof2 = { 
  440. 			name = "roof_2set_group", 
  441. 			members = { "roof_2set 001", "roof_2set 002", "roof_2set 003", 
  442. 							"roof_2set 004", "roof_2set 005" } 
  443. 		}, 
  444. 		 
  445. 		heli_police1 = { 
  446. 			name= "heli_police_group 001", 
  447. 			vehicle = "police_heli 001", 
  448. 			members = { "heli_police 001", "heli_police 002" }, 
  449. 			shooter = "heli_police 003", 
  450. 			shooter_seat = 4, 
  451. 			crash_nav = "cubicle_cover 002", 
  452. 			pilot_persona = "Interrogation", 
  453. 			persona_line = "M01_Bullhorn_Sniper_Heli_02", 
  454. 			thread = INVALID_THREAD_HANDLE, 
  455. 			setup_thread = INVALID_THREAD_HANDLE 
  456. 		}, 
  457. 		 
  458. 		heli_police2 = { 
  459. 			name= "heli_police_group 002", 
  460. 			vehicle = "police_heli 002", 
  461. 			members = { "heli_police 004", "heli_police 005" }, 
  462. 			shooter = "heli_police 006", 
  463. 			home_nav = "heli_police2_home", 
  464. 			shooter_seat = 4, 
  465. 			crash_nav = "police_heli_nav 005", 
  466. 			pilot_persona = "Interrogation", 
  467. 			persona_line = "M01_Bullhorn_Sniper_Heli_01", 
  468. 			thread = INVALID_THREAD_HANDLE, 
  469. 			setup_thread = INVALID_THREAD_HANDLE 
  470. 		}, 
  471. 		 
  472. 		heli_fighter1 = { 
  473. 			name= "heli_police_group 003", 
  474. 			vehicle = "police_heli 003", 
  475. 			members = { "heli_police 007", "heli_police 008" }, 
  476. 			damaged = false, 
  477. 			damage1 = 0.6, 
  478. 			damage2 = 0.4, 
  479. 			damage3 = 0.2, 
  480. 			flyby_float = "flyby_float_nav", 
  481. 			flyby_path = "flyby 001", 
  482. 			 
  483. 			run1 = { 
  484. 				enter_path = "run1_enter", 
  485. 				exit_path = "run1_exit", 
  486. 				float_from_nav = "run1_dest<001>",	-- start gunning here 
  487. 				float_to_nav = "run1_dest<002>",	-- end gunning here 
  488. 				float_speed = 4.0, 
  489. 				gun_target = "run1_gun_target", 
  490. 				gun_time = 3.0, 
  491. 				hit_delay = 0.7, 
  492. 				persona_line = "M01_Bullhorn_Attack_Heli_Hover_01" 
  493. 			}, 
  494. 			run2 = { 
  495. 				enter_path = "run2_enter", 
  496. 				exit_path = "run2_exit", 
  497. 				float_from_nav = "run2_dest<001>",	-- start gunning here 
  498. 				float_to_nav = "run2_dest<002>",	-- end gunning here 
  499. 				float_speed = 1.0, 
  500. 				gun_target = "run2_gun_target", 
  501. 				gun_time = 2.2, 
  502. 				hit_delay = 0.8, 
  503. 				persona_line = "M01_Bullhorn_Attack_Heli_Hover_02" 
  504. 			}, 
  505. 			attack_path1 = "attack_path 001", 
  506. 			attack_path2 = "attack_path 002", 
  507. 			 
  508. 			first_float = "first_float_nav", 
  509. 			roof_target = "roof_target", 
  510. 			first_target = "first_target", 
  511. 			hover_nav2 = "behind_building_nav", 
  512. 			attack_nav1 = "attack_position_nav", 
  513. 			attack_target1 = "attack_target1_nav", 
  514. 			attack_path2_part2 = "attack_path 002<001>", 
  515. 			attack_nav2 = "attack_position2_nav", 
  516. 			attack_target2 = "attack_target2_nav", 
  517. 			attack_path3 = "attack_path 003", 
  518. 			bail_path = "bail_path", 
  519. 			from_behind_float = "from_behind_float_nav", 
  520. 			from_behind_path = "from_behind_path", 
  521. 			suicide_path = "suicide_path", 
  522. 			final_nav = { "final_battle<001>", "final_battle<002>" }, 
  523. 			attack_run_thread = INVALID_THREAD_HANDLE, 
  524. 			thread = INVALID_THREAD_HANDLE, 
  525. 			permission_to_fire = false, 
  526. 			gunner_thread = INVALID_THREAD_HANDLE 
  527. 		}, 
  528. 		 
  529. 		start_homies = { 
  530. 			name = "start_homies", 
  531. 			gat = "Gat_bobble", 
  532. 			gat_bobble = true, 
  533. 			shaundi = "Shaundi_bobble", 
  534. 			shaundi_bobble = true, 
  535. 			josh = "Josh_bobble", 
  536. 			josh_bobble = true, 
  537. 			captive = "gat_captive", 
  538. 			captive_nav = "gat_captive_nav" 
  539. 		}, 
  540. 		 
  541. 		bomb_homies = { 
  542. 			name = "bomb_homies", 
  543. 			gat = "Gat_bomb", 
  544. 			gat_bobble = false, 
  545. 			shaundi = "Shaundi_bomb", 
  546. 			shaundi_bobble = false, 
  547. 			josh = "Josh_bomb", 
  548. 			josh_bobble = false, 
  549. 		}, 
  550. 		 
  551. 		swat_homies = { 
  552. 			name = "swat_homies", 
  553. 			gat = "Gat_swat", 
  554. 			gat_bobble = false, 
  555. 			shaundi = "Shaundi_swat", 
  556. 			shaundi_bobble = false, 
  557. 			josh = "", 
  558. 			josh_bobble = false, 
  559. 		}, 
  560. 		 
  561. 	} 
  562. 	M01_josh = "" 
  563. 	M01_gat = "" 
  564. 	M01_shaundi = "" 
  565. 	M01_nyteblayde_advance_nav = { "lobby_mark 001", "lobby_mark 005", "second_floor_mark 004", "second_floor_mark 004", "Vault_player_nav" } 
  566. 	M01_grandstand_nav = "grandstand_nav" 
  567. 		 
  568. 	M01_heli_police_groups = { M01_group.heli_police1, M01_group.heli_police2, M01_group.heli_fighter1 } 
  569. 	 
  570. 	M01_pairs_spawned = 0 
  571. 	 
  572. 	M01_HELI_SHOOTER_GROUP = "heli_shooter_group 001" 
  573. 	M01_HELI_SHOOTER = "heli_shooter 001" 
  574. 	M01_HELI_SHOOTER2 = "heli_shooter 002" 
  575. 	 
  576. -- Navpoints -- 
  577. 	CAMERA_TARGET1 = "res_cam_target 001" 
  578. 	CAMERA_TARGET2 = "res_cam_target 002" 
  579. 	CAMERA_TARGET3 = "res_cam_target 003" 
  580. 	CAMERA_TARGET4 = "res_cam_target 004" 
  581. 	CAMERA_TARGET_YOUR_HELI = "res_cam_target 005" 
  582. 	 
  583. 	LOBBY_MARK = { "lobby_mark 001", "lobby_mark 002" } 
  584. 	LOBBY_MARK2 = { "lobby_mark 004", "lobby_mark 005", "lobby_mark 006" } 
  585. 	 
  586. 	SECOND_FLOOR_MARK = { "second_floor_mark 001", "second_floor_mark 002", "second_floor_mark 003", 
  587. 									"second_floor_mark 004", "second_floor_mark 005", "second_floor_mark 006" } 
  588. 		 
  589. 	M01_HOMIE_VAULT_MARK = { "Gat_mark_vault", "Shaundi_mark_vault", "Josh_mark_vault" } 
  590. 	M01_HOMIE_BOMB_MARK = { "Gat_mark_bomb", "Shaundi_mark_bomb", "Josh_mark_bomb" } 
  591. 	 
  592. 		 
  593. 	 
  594. 	FIFTH_FLOOR_MARK = { "fifth_floor_mark 001", "fifth_floor_mark 002", "fifth_floor_mark 003", "fifth_floor_mark 004" } 
  595. 	 
  596. 	ROOF_MARK = { "roof_mark 001", "roof_mark 002", "roof_mark 003", 
  597. 						"roof_mark 004", "roof_mark 005" } 
  598. 						 
  599. 	ROCKET_MARK = { "roof_mark 006" } 
  600. 										 
  601. 	POLICE_HELI_NEWS_NAV = "police_heli_nav 001" 
  602. 	POLICE_HELI_WAIT_LOCATION1 = "police_heli_nav 002" 
  603. 	POLICE_HELI_WAIT_LOCATION2 = "police_heli_nav 003" 
  604. 	POLICE_HELI_SHOOT_AT_ME1 = "police_heli_nav 004" 
  605. 	POLICE_HELI_BUILDING_CRASH = "police_heli_nav 005" 
  606. 	POLICE_HELI2_START = "police_heli_nav 006" 
  607. 	POLICE_HELI_WAIT_LOCATION3 = "police_heli_nav 009" 
  608. 	POLICE_HELI_SHOOT_AT_ME2 = "police_heli_nav 007" 
  609. 	POLICE_HELI_SHOOT_AT_ME3 = "police_heli_nav 008" 
  610. 	POLICE_HELI_TO_HELI_CRASH = "police_heli_nav 010" 
  611. 	POLICE_HELI_CLOSE_CALL = "police_heli_nav 011" 
  612. 	 
  613. 	POLICE_HELI_SURPRISE_NAV1 = "surprise_nav 001" 
  614. 	 
  615. 	M01_cover = { 
  616. 		tellers = { 
  617. 			shaundi = "shaundi_tellers", 
  618. 			gat = "gat_tellers" 
  619. 		}, 
  620. 		 
  621. 		lobby2 = { 
  622. 			shaundi = "shaundi_lobby2", 
  623. 			gat = "gat_lobby2" 
  624. 		}, 
  625. 		 
  626. 		fine_aim = { 
  627. 			shaundi = "fine_aim_navpoint<001>", 
  628. 			gat = "fine_aim_navpoint<002>" 
  629. 		}, 
  630. 		 
  631. 		second_floor = { 
  632. 			shaundi = "shaundi_2floor", 
  633. 			gat = "gat_2floor" 
  634. 		} 
  635. 	} 
  636. 	 
  637. -- Triggers -- 
  638. 	M01_trigger = { 
  639. 		freerun = { 
  640. 			name = "Freerun_trigger 001", 
  641. 			hit = false 
  642. 		}, 
  643. 		 
  644. 		shaundi_attack = { 
  645. 			name = "shaundi_attack_trigger", 
  646. 			hit = false 
  647. 		},			 
  648. 		 
  649. 		pre_vault = { 
  650. 			name = "vault_trigger 000", 
  651. 			hit = false 
  652. 		}, 
  653. 		 
  654. 		vault = { 
  655. 			name = "vault_trigger 001", 
  656. 			hit = false 
  657. 		}, 
  658. 		 
  659. 		pre_bomb = { 
  660. 			name = "bomb_trigger 000", 
  661. 			hit = false 
  662. 		}, 
  663. 		 
  664. 		pre_bomb2 = { 
  665. 			name = "bomb_trigger 000<001>", 
  666. 			hit = false 
  667. 		}, 
  668. 		 
  669. 		bomb = { 
  670. 			name = "bomb_trigger 001", 
  671. 			hit = false 
  672. 		}, 
  673. 		 
  674. 		kill = { 
  675. 			name = "Kill_trigger", 
  676. 			hit = false 
  677. 		}, 
  678. 		 
  679. 		swat_kill = { 
  680. 			name = "Swat_kill_trigger", 
  681. 			hit = false 
  682. 		}, 
  683. 		 
  684. 		horse = { 
  685. 			name = "Horse_trigger", 
  686. 			hit = false 
  687. 		}, 
  688. 	} 
  689.  
  690. -- Characters -- 
  691.  
  692. -- Vehicles -- 
  693.  
  694. -- Mesh Movers -- 
  695. 	LOBBY_DOOR01 = "Bank_Lobby_Door 001" 
  696. 	LOBBY_DOOR02 = "Bank_Lobby_Door 002" 
  697. 	M01_ELEVATOR_DOOR = "Bank_Lobby_Elevator" 
  698. 	M01_vault_mover = "Bank_vault" 
  699. 	M01_fine_aim_glass = { "fine_aim_glass<001>", "fine_aim_glass<002>", "fine_aim_glass<003>" } 
  700.  
  701. -- Effects -- 
  702.  
  703. -- Text -- 
  704. 	HELPTEXT_FAILURE_GAT_DIED				= "m01_failure_gat_died" 
  705. 	HELPTEXT_FAILURE_SHAUNDI_DIED			= "m01_failure_shaundi_died" 
  706. 	HELPTEXT_FAILURE_JOSH_DIED				= "m01_failure_josh_died" 
  707.  
  708. -- Threads -- 
  709. 	M01_thread = { 
  710. 		move_guards = INVALID_THREAD_HANDLE, 
  711. 		josh_ai = INVALID_THREAD_HANDLE, 
  712. 		people_cower = INVALID_THREAD_HANDLE, 
  713. 		fine_aim_glass = INVALID_THREAD_HANDLE, 
  714. 		saints_fan = INVALID_THREAD_HANDLE, 
  715. 		conversation = INVALID_THREAD_HANDLE, 
  716. 		gat_hostage = INVALID_THREAD_HANDLE, 
  717. 		shaundi_move = INVALID_THREAD_HANDLE, 
  718. 		gat_move = INVALID_THREAD_HANDLE, 
  719. 		elevator = INVALID_THREAD_HANDLE, 
  720. 		respawn_timer = INVALID_THREAD_HANDLE, 
  721. 		homies_prep = INVALID_THREAD_HANDLE, 
  722. 		tutorial_timer = INVALID_THREAD_HANDLE, 
  723. 		battle_timer = INVALID_THREAD_HANDLE, 
  724. 		vault_setup = INVALID_THREAD_HANDLE, 
  725. 		vault_environ_setup = INVALID_THREAD_HANDLE, 
  726. 		attack_line_timer = INVALID_THREAD_HANDLE, 
  727. 		reset_movers = INVALID_THREAD_HANDLE, 
  728. 		line_timer = INVALID_THREAD_HANDLE, 
  729. 	} 
  730. 	 
  731. 	M01_TUTORIAL_FINEAIM = INVALID_THREAD_HANDLE 
  732. 	M01_TUTORIAL_SWITCH_WEAPON = INVALID_THREAD_HANDLE 
  733.  
  734. -- Checkpoints -- 
  735. 	M01_checkpoint = { 
  736. 		start = { 
  737. 			name = MISSION_START_CHECKPOINT, 
  738. 			nav1 = "Start_player_nav<001>", 
  739. 			nav2 = "Start_player_nav<002>" 
  740. 		}, 
  741. 		 
  742. 		plant_bombs = { 
  743. 			name = "m01_checkpoint_plant_bombs", 
  744. 			nav1 = "Vault_player_nav", 
  745. 			nav2 = "Vault_player_nav<001>" 
  746. 		}, 
  747. 		 
  748. 		survive = { 
  749. 			name = "m01_checkpoint_survive", 
  750. 			nav1 = "player1_swat", 
  751. 			nav2 = "player2_swat" 
  752. 		}, 
  753. 		 
  754. 		ride_vault = { 
  755. 			name = "m01_checkpoint_ride_vault", 
  756. 			nav1 = "player1_vault", 
  757. 			nav2 = "player2_vault" 
  758. 		}, 
  759. 		 
  760. 		debug_swaps = { 
  761. 			name = "m01_just_swap", 
  762. 			nav1 = "debug_nav", 
  763. 			nav2 = "debug_nav" 
  764. 		}, 
  765. 	} 
  766. 	 
  767. -- Cutscenes -- 
  768.  
  769. 	M01_scene = { 
  770. 		intro = "01_IN", 
  771. 		at_vault = "01_z01", 
  772. 		explosives = "01_Z02", 
  773. 		connect_vault = "01_Z03", 
  774. 		heli_crash = "01_Z04", 
  775. 	}	 
  776. 	 
  777. 	 
  778. -- Conversations -- 
  779. 	M01_convo = {		 
  780. 		gat_interrogate = { 
  781. 			name = "m01_convo_2", 
  782. 			handle = INVALID_CONVERSATION_HANDLE 
  783. 		}, 
  784. 		 
  785. 		gat_interrogate2 = { 
  786. 			name = "m01_convo_2a", 
  787. 			handle = INVALID_CONVERSATION_HANDLE 
  788. 		}, 
  789. 		 
  790. 		berate_josh = { 
  791. 			name = "M01_Berating_Josh", 
  792. 			handle = INVALID_CONVERSATION_HANDLE 
  793. 		}, 
  794. 		 
  795. 		look_for_vault = { 
  796. 			name = "m01_convo_3", 
  797. 			handle = INVALID_CONVERSATION_HANDLE 
  798. 		}, 
  799. 		 
  800. 		morningstar = { 
  801. 			name = "m01_convo_8", 
  802. 			handle = INVALID_CONVERSATION_HANDLE 
  803. 		}, 
  804. 		 
  805. 		josh_and_shaundi = { 
  806. 			name = "M01_Josh_Banter", 
  807. 			handle = INVALID_CONVERSATION_HANDLE 
  808. 		}, 
  809. 		 
  810. 		more_guys = { 
  811. 			name = "M01_More_Guys_Coming", 
  812. 			handle = INVALID_CONVERSATION_HANDLE 
  813. 		}, 
  814. 		 
  815. 		sign_autograph = { 
  816. 			name = "M01_Celebrity_Autographs", 
  817. 			handle = INVALID_CONVERSATION_HANDLE 
  818. 		}, 
  819. 		 
  820. 		set_explosives = { 
  821. 			name = "m01_convo_6", 
  822. 			handle = INVALID_CONVERSATION_HANDLE 
  823. 		}, 
  824. 		 
  825. 		swat_on_way = { 
  826. 			name = "M01_Swat_Almost_There", 
  827. 			handle = INVALID_CONVERSATION_HANDLE 
  828. 		}, 
  829. 		 
  830. 		swat_chit_chat = { 
  831. 			name = "M01_Annoyed_At_Birk_SWAT", 
  832. 			handle = INVALID_CONVERSATION_HANDLE 
  833. 		}, 
  834. 		 
  835. 		attack_chopper = { 
  836. 			name = "M01_Attack_Chopper", 
  837. 			handle = INVALID_CONVERSATION_HANDLE 
  838. 		}, 
  839. 		 
  840. 		hooked_up = { 
  841. 			name = "M01_Heli_Hooked_On", 
  842. 			handle = INVALID_CONVERSATION_HANDLE, 
  843. 			start = false, 
  844. 			delay = 0.0 
  845. 		}, 
  846. 		 
  847. 		heli_rising = { 
  848. 			name = "M01_Helicopter_Rising", 
  849. 			handle = INVALID_CONVERSATION_HANDLE, 
  850. 			start = false, 
  851. 			delay = 0.0 
  852. 		}, 
  853. 		 
  854. 		heli_jerk_back = { 
  855. 			name = "M01_Helicopter_Jerks_Back", 
  856. 			handle = INVALID_CONVERSATION_HANDLE, 
  857. 			start = false, 
  858. 			delay = 0.0 
  859. 		}, 
  860. 		 
  861. 		heli_not_leaving = { 
  862. 			name = "M01_Heli_Not_Leaving", 
  863. 			handle = INVALID_CONVERSATION_HANDLE, 
  864. 			start = false, 
  865. 			delay = 0.0 
  866. 		}, 
  867. 		 
  868. 		heli_drag_vault = { 
  869. 			name = "M01_Helicopter_Drag_Vault", 
  870. 			handle = INVALID_CONVERSATION_HANDLE, 
  871. 			start = false, 
  872. 			delay = 2.0 
  873. 		}, 
  874. 		 
  875. 		heli_near_collision = { 
  876. 			name = "M01_Heli_Near_Collision", 
  877. 			handle = INVALID_CONVERSATION_HANDLE, 
  878. 			start = false, 
  879. 			delay = 3.2 
  880. 		}, 
  881. 		 
  882. 		vault_tipped = { 
  883. 			name = "M01_Heli_Vault_Tipped", 
  884. 			handle = INVALID_CONVERSATION_HANDLE, 
  885. 			start = false, 
  886. 			delay = 0.0 
  887. 		}, 
  888. 	} 
  889. 	M01_conversation_playing = false 
  890. 	M01_doing_autograph = false 
  891. 	M01_setting_bomb = false 
  892. 	 
  893.  
  894. 	M01_gat_attack_info = { 
  895. 		situation = "M01_Gat_attack", 
  896. 		delay = 10.0, 
  897. 		callback = "m01_process_gat_attack_cb", 
  898. 		timer = INVALID_THREAD_HANDLE 
  899. 	} 
  900.  
  901. -- Audio -- 
  902. 	M01_audio_emitter = { 
  903. 		bank_lobby = { "Bank_Lobby" }, 
  904. 		fine_aim = { "Fine_Aim_City_Ambience" }, 
  905. 		office = { "Office_Ambience" }, 
  906. 		city_noise = { "Distant_Traffic" }, 
  907. 		vault_noise = { "Distant_Sirens" }, 
  908. 	} 
  909. 	 
  910. -- HUD states -- 
  911. 	M01_hud_state = { 
  912. 		hide_minimap = -1, 
  913. 		hide_everything = -1 
  914. 	} 
  915. 	 
  916. -- Other -- 
  917. 	-- heli-vault animations 
  918. 	 
  919. 	M01_WAIT = true 
  920. 	M01_DO_NOT_WAIT = false 
  921. 	M01_INTERRUPT = true 
  922. 	M01_DO_NOT_INTERRUPT = false 
  923. 	 
  924. 	M01_PLAYER_PISTOL = "Pistol-Gang" 
  925. 	M01_PLAYER_SHOTGUN = "Shotgun-Police" 
  926. 	M01_PLAYER_RIFLE = "Rifle-Gang" 
  927. 	M01_PLAYER_SMG = "SMG-Gang" 
  928. 	M01_PLAYER_GRENADE = "grenade" 
  929.  
  930. 	M01_PLAYER_PISTOL_UPGRADES = WEAPON_LEVEL2 
  931. 	M01_PLAYER_SHOTGUN_UPGRADES = 0 
  932. 	M01_PLAYER_RIFLE_UPGRADES = WEAPON_LEVEL4 
  933. 	 
  934. 	SNAP_CAMERA = true 
  935. 	BLEND_CAMERA = false 
  936. 	 
  937. 	FLOOR_LEASH_RADIUS_METERS = 4.5 
  938. 			 
  939. 	Helicopter_killed = false 
  940. 	 
  941. 	M01_skip_fineaim_release = false 
  942. 	M01_weapon_changed = false 
  943. 	 
  944. 	M01_guard_killed = false 
  945. 	M01_player_over_desk = false 
  946. 	M01_gat_at_door = false 
  947. 	M01_gat_finished_shooting = false 
  948. 	M01_lobby_cleared = false 
  949. 	M01_josh_grandstanded = false 
  950. 	 
  951. 	M01_zone_name = "bank" 
  952. 	M01_zone_damaged_name = "bank_destroy" 
  953. 	M01_zone_stilwater = "stilwater" 
  954. 	 
  955. 	M01_end_mission_nav1 = "end_mission 001" 
  956. 	M01_end_mission_nav2 = "end_mission 002" 
  957. 	M01_end_mission_demo = "end_mission_demo" 
  958. 	 
  959. 	M01_window_entry_melee_id = 0 
  960. 	M01_throw_flashbangs = false 
  961. 	 
  962. 	-- SWAT section lighting for power outage 
  963. 	M01_light_group = {	 
  964. 		alarm = { 
  965. 			name = "Game_alarm_lights", 
  966. 			intensity = 0.0		-- scripted intensity is "off" 
  967. 		} 
  968. 	} 
  969. 	 
  970. 	-- tell news choppers where to go and what to look at 
  971. 	M01_news = { 
  972. 		fine_aim = 1, 
  973. 		swat = 2, 
  974. 		vault = 3, 
  975. 		loop = 4 
  976. 	} 
  977. 	M01_news_location = M01_news.fine_aim 
  978. 	 
  979. 	M01_fighter_run_complete = false 
  980. 	 
  981. 	-- Shaundi attack info 
  982. 	M01_shaundi_attack = { 
  983. 		shuandi_nav = "shaundi_attacked_nav<001>", 
  984. 		shuandi_attack = "shaundi_attacked_nav", 
  985. 		josh_nav = "Josh_mark_vault", 
  986. 		in_place = false, 
  987. 		attacker = M01_group.second_floor.shaundi_attacker, 
  988. 		thread = INVALID_THREAD_HANDLE 
  989. 	} 
  990. 	 
  991. 	M01_vault_camera_shake = "m01_vault_ride" 
  992. 	M01_swap_vault_seats = false 
  993.  
  994. -- ************************* 
  995. -- 
  996. -- Standard functions 
  997. -- 
  998. -- ************************* 
  999.  
  1000.  
  1001. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  1002. -- at the specified checkpoint. 
  1003. -- CALLED FROM CODE 
  1004. -- 
  1005. -- m01_checkpoint:	The checkpoint the mission should begin at 
  1006. -- is_restart:					TRUE if the mission is restarting, FALSE otherwise 
  1007. -- 
  1008. function m01_start(m01_checkpoint, is_restart) 
  1009. 	mission_start_fade_out(0.0) 
  1010. 	 
  1011. 	crib_weapon_add_disable() 
  1012.  
  1013. 	-- turn off spawning for the speedz 
  1014. 	m01_do_ambient_spawns(false) 
  1015. 	 
  1016. 	-- turn off grenade drops 
  1017. 	npc_drop_grenades(false) 
  1018. 	 
  1019. 	-- debug checkpoint 
  1020. 	if m01_checkpoint == "m01_checkpoint_coop" then 
  1021. 		M01_swap_vault_seats = true 
  1022. 		m01_checkpoint = M01_checkpoint.ride_vault.name 
  1023. 	end 
  1024. 		 
  1025. 	-- do swaps before we get to the cutscene 
  1026. 	m01_initialize_swaps(m01_checkpoint) 
  1027. 	 
  1028. 	-- suit up	 
  1029. 	customization_item_wear( "cm_suit_gatsuit", "cm_suit_gatsuit.cmeshx", "mGat_Body", false ) 
  1030. 	customization_item_wear( "cm_hat_gatbobble", "Cm_hat_gatbobble.cmeshx", "Gatbobble", false ) 
  1031. 	customization_swap_player_rig( "cm_body.rig", "PLYM" ) 
  1032. 	 
  1033. 	-- Check if this mission starting from the beginning 
  1034. 	if (m01_checkpoint == M01_checkpoint.start.name) then 
  1035. 		if (is_restart == false) then 
  1036. 			-- First time playing mission 
  1037. 			local player_starts = {M01_checkpoint.start.nav1, M01_checkpoint.start.nav2} 
  1038. 			local fade_in_after = false 
  1039. 			cutscene_play(M01_scene.intro, nil, player_starts, fade_in_after) 
  1040. 		else 
  1041. 			-- put players back at the start 
  1042. 			teleport_coop(M01_checkpoint.start.nav1, M01_checkpoint.start.nav2, true) 
  1043. 		end 
  1044. 	end 
  1045.  
  1046. 	-- Handle mission initialization for the current checkpoint 
  1047. 	m01_initialize(m01_checkpoint) 
  1048.  
  1049. 	-- Run the mission from the current checkpoint 
  1050. 	m01_run(m01_checkpoint) 
  1051. 	 
  1052. end 
  1053.  
  1054. -- This is the primary function responsible for running the entire mission from start to finish. 
  1055. -- 
  1056. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  1057. -- 
  1058. function m01_run(first_checkpoint) 
  1059. 	local current_checkpoint = first_checkpoint 
  1060. 	local ignore_vehicles = true 
  1061. 	local ignore_notoriety = true 
  1062.  
  1063. 	-- post voice event to mute non-modulated voice 
  1064. 	audio_object_post_event("Mission_VO_Override") 
  1065.  
  1066. 	-- Run the mission from the beginning 
  1067. 	if current_checkpoint == M01_checkpoint.start.name then 
  1068. 		objective_text( 0, "m01_kill_lobby_guards", "", "", SYNC_ALL, OI_ASSET_KILL ) 
  1069. 		m01_kill_lobby_guards() 
  1070. 		zscene_prep(M01_scene.at_vault) 
  1071. 		m01_kill_lobby2_guards() 
  1072. 		m01_fine_aim_guards() 
  1073. 		objective_text_clear(0) 
  1074. 		objective_text( 0, "m01_go_to_vault", "", "", SYNC_ALL, OI_ASSET_LOCATION ) 
  1075. 		m01_go_to_vault() 
  1076. 		objective_text_clear(0) 
  1077. 		m01_plan_b_scene() 
  1078. 		current_checkpoint = M01_checkpoint.plant_bombs.name 
  1079. 		mission_set_checkpoint(M01_checkpoint.plant_bombs.name, ignore_vehicles, ignore_notoriety) 
  1080. 	end 
  1081. 	 
  1082. 	if current_checkpoint == M01_checkpoint.plant_bombs.name then 
  1083. 		zscene_prep(M01_scene.explosives) 
  1084. 		m01_set_bomb() 
  1085. 		objective_text_clear(0) 
  1086. 		m01_detonate_bomb_scene() 
  1087. 		current_checkpoint = M01_checkpoint.survive.name 
  1088. 		mission_set_checkpoint(M01_checkpoint.survive.name, ignore_vehicles, ignore_notoriety) 
  1089. 	end 
  1090. 	notoriety_set_min_and_max("Police", 1, 1)	-- since we don't see it, just give enough to attack us 
  1091. 	 
  1092. 	if current_checkpoint == M01_checkpoint.survive.name then 
  1093. 		-- Hang out a beat until power is cut 
  1094. 		m01_cut_power() 
  1095. 		zscene_prep(M01_scene.connect_vault) 
  1096. 		objective_text( 0, "m01_survive", "", "", SYNC_ALL, OI_ASSET_DEFEND ) 
  1097. 		-- defend against cops 
  1098. 		m01_survive_cops() 
  1099. 		objective_text_clear(0) 
  1100. 		m01_heli_arrive_scene() 
  1101. 		current_checkpoint = M01_checkpoint.ride_vault.name 
  1102. 		mission_set_checkpoint(M01_checkpoint.ride_vault.name, ignore_vehicles, ignore_notoriety) 
  1103. 	end 
  1104. 	 
  1105. 	if current_checkpoint == M01_checkpoint.ride_vault.name then 
  1106. 		zscene_prep(M01_scene.heli_crash) 
  1107. 		--objective_text( 0, "m01_ride_vault", "", "", SYNC_ALL, OI_ASSET_INVALID ) 
  1108. 		objective_text( 0, "m01_survive", "", "", SYNC_ALL, OI_ASSET_DEFEND ) 
  1109. 		m01_vault_above_cam() 
  1110. 		m01_vault_first_guards() 
  1111. 		m01_vault_roof_setup() 
  1112. 		m01_roof_guards1() 
  1113. 		m01_shoot_heli_alt() 
  1114. 		m01_building_crash() 
  1115. 		m01_heli_crash_other_building() 
  1116. 		m01_shoot_even_more() 
  1117. 		m01_break_chains() 
  1118. 		m01_shoot_most() 
  1119. 		m01_finale_scene() 
  1120. 	end 
  1121. 	 
  1122. 	-- debug only swap 
  1123. 	if current_checkpoint == M01_checkpoint.debug_swaps.name then 
  1124. 		-- big delay to start 
  1125. 		delay(1.0) 
  1126. 		while true do 
  1127. 			delay(3.0) 
  1128. 			city_zone_swap(M01_zone_damaged_name, true) 
  1129. 			delay(3.0) 
  1130. 			city_zone_swap(M01_zone_name, false)		 
  1131. 			delay(0.5) 
  1132. 			city_zone_swap(M01_zone_damaged_name, false) 
  1133. 			delay(0.5) 
  1134. 			city_zone_swap(M01_zone_name, true)			 
  1135. 		end 
  1136. 	end 
  1137. 	 
  1138. 	-- Go directly to customization misson (w/Do_intro_sequence) 
  1139. 	mission_set_next_mission("mm_m1_5") 
  1140. 	 
  1141. 	-- we're done 
  1142. 	mission_end_success("m01", M01_scene.heli_crash)	 
  1143. end 
  1144.  
  1145. -- This is the primary function responsible for cleaning up the entire mission 
  1146. -- CALLED FROM CODE 
  1147. -- 
  1148. function m01_cleanup() 
  1149. 	-- default it up 
  1150. 	character_set_damage_multiplier(LOCAL_PLAYER, 1.0) 
  1151. 	character_set_damage_multiplier(REMOTE_PLAYER, 1.0) 
  1152. 	 
  1153. 	-- turn spawning back on 
  1154. 	m01_do_ambient_spawns(true)	 
  1155.  
  1156. 	-- stop muting voice 
  1157. 	audio_object_post_event("Mission_VO_Override_Stop") 
  1158.  
  1159. 	flashlights_enable() 
  1160. 	m01_players_stop_vault_health() 
  1161. 	 
  1162. 	-- Stop the camera shake 
  1163. 	camera_shake_stop() 
  1164.  
  1165. 	m01_clear_hud_states() 
  1166.  
  1167. 	-- this should be a light swap 
  1168. 	--set_time_of_day(21, 0) 
  1169. 	 
  1170. 	-- Audio emitters 
  1171. 	m01_stop_all_emitters() 
  1172. 	 
  1173. 	-- turn off the lights before you go 
  1174. 	-- not needed and causes problems on success -- m01_all_lights_off() 
  1175. 	 
  1176. 	-- clear objective 
  1177. 	objective_text_clear( 0 ) 
  1178. 	m01_clear_tutorial(true) 
  1179. 	 
  1180. 	-- clean up the valut sequence 
  1181. 	action_sequence_end() 
  1182. 	 
  1183. 	-- cleanup groups 
  1184. 	m01_cleanup_first_checkpoint_groups() 
  1185. 	m01_cleanup_first_checkpoint_crew() 
  1186. 	m01_cleanup_second_checkpoint_groups() 
  1187. 	m01_cleanup_second_checkpoint_crew() 
  1188. 	m01_cleanup_cop_wave_groups() 
  1189. 	m01_cleanup_swat_crew() 
  1190. 	m01_cleanup_final_checkpoint_groups() 
  1191.  
  1192. 	 
  1193. 	m01_kill_heli_move_threads() 
  1194. 	m01_stop_respawn_pairs() 
  1195. 	 
  1196. 	-- cleanup the threads 
  1197. 	cleanup_threads(M01_thread) 
  1198. 	 
  1199. 	-- end any conversations 
  1200. 	m01_end_conversations() 
  1201. 	 
  1202. 	-- remove triggers 
  1203. 	m01_clear_trigger(M01_trigger.freerun.name) 
  1204. 	m01_clear_trigger(M01_trigger.shaundi_attack.name) 
  1205. 	m01_clear_trigger(M01_trigger.pre_vault.name) 
  1206. 	m01_clear_trigger(M01_trigger.vault.name) 
  1207. 	m01_clear_trigger(M01_trigger.pre_bomb.name) 
  1208. 	m01_clear_trigger(M01_trigger.pre_bomb2.name) 
  1209. 	m01_clear_trigger(M01_trigger.bomb.name) 
  1210. 	m01_clear_trigger(M01_trigger.kill.name) 
  1211. 	m01_clear_trigger(M01_trigger.swat_kill.name) 
  1212. 	m01_clear_trigger(M01_trigger.horse.name) 
  1213. 	 
  1214. 	-- remove temp weapons 
  1215. 	m01_clear_player_loadout() 
  1216. 	 
  1217. 	-- re-enable all weapons 
  1218. 	inv_weapon_disable_all_slots(false) 
  1219. 	 
  1220. 	-- Don't force me to look at anything 
  1221. 	camera_restrict_set_active(DISABLE)	 
  1222. 	-- camera_end_look_through( SNAP_CAMERA ) 
  1223. 	 
  1224. 	-- allow notoriety spawning again 
  1225. 	notoriety_set_min_and_max("Police", 0, MAX_NOTORIETY_LEVEL) 
  1226. 	notoriety_set_min_and_max("morningstar", 0, MAX_NOTORIETY_LEVEL) 
  1227. 	notoriety_force_no_spawn("police", false)	 
  1228. 	notoriety_force_no_spawn("morningstar", false)	 
  1229. 	 
  1230. 	-- allow enter/exit vehicles 
  1231. 	action_stop_custom(LOCAL_PLAYER) 
  1232. 	clear_animation_state(LOCAL_PLAYER) 
  1233. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, true) 
  1234. 	player_movement_enable(LOCAL_PLAYER) 
  1235. 	if coop_is_active() then 
  1236. 		action_stop_custom(REMOTE_PLAYER) 
  1237. 		clear_animation_state(REMOTE_PLAYER) 
  1238. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, true) 
  1239. 		player_movement_enable(REMOTE_PLAYER) 
  1240. 	end 
  1241. 	 
  1242. 	mission_set_cancel_warp_location( M01_end_mission_demo, M01_end_mission_demo ) 
  1243. --[[  DEMO 
  1244. 	mission_set_cancel_warp_location( M01_end_mission_nav1, M01_end_mission_nav1 ) 
  1245. ]]-- 
  1246. 	 
  1247. 	-- turn player back 
  1248. 	customization_item_revert( ) 
  1249. 	customization_restore_player_rig( ) 
  1250. 	 
  1251. 	-- done swap 
  1252. 	city_zone_swap(M01_zone_name, false) 
  1253. 	city_zone_swap(M01_zone_damaged_name, false) 
  1254. 	city_zone_swap(M01_zone_stilwater, false) 
  1255. 	 
  1256. 	crib_weapon_add_enable() 
  1257. end 
  1258.  
  1259. -- Called when the mission has ended with success 
  1260. -- CALLED FROM CODE 
  1261. -- 
  1262. function m01_success()	 
  1263. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  1264. 	 
  1265. 	-- teleport players to not be in mid-air 
  1266. 	local exit_vehicles = true 
  1267. 	 
  1268. 	teleport(LOCAL_PLAYER, M01_end_mission_demo, exit_vehicles) 
  1269. 	if (coop_is_active()) then 
  1270. 		teleport( REMOTE_PLAYER, M01_end_mission_demo, exit_vehicles) 
  1271. 	end 
  1272. --[[  DEMO 
  1273. 	teleport(LOCAL_PLAYER, M01_end_mission_nav1, exit_vehicles) 
  1274. 	if (coop_is_active()) then 
  1275. 		teleport( REMOTE_PLAYER, M01_end_mission_nav2, exit_vehicles) 
  1276. 	end 
  1277. ]]-- 
  1278. 	 
  1279. 	-- turn player back 
  1280. 	customization_item_revert( ) 
  1281. 	customization_restore_player_rig( ) 
  1282. end 
  1283.  
  1284. -- ************************* 
  1285. -- 
  1286. -- Local functions 
  1287. -- 
  1288. -- ************************* 
  1289.  
  1290. -- Initialize the mission for the specified checkpoint 
  1291. -- 
  1292. -- checkpoint:		Checkpoint to initialize the mission to 
  1293. -- 
  1294. function m01_initialize(checkpoint) 
  1295.  
  1296. 	-- Set the mission author 
  1297. 	set_mission_author("Neil Ryan") 
  1298.  
  1299. 	-- Common initialization 
  1300. 	m01_initialize_common() 
  1301.  
  1302. 	-- Checkpoint specific initialization 
  1303. 	m01_initialize_checkpoint(checkpoint) 
  1304. 	 
  1305. 	-- any notoriety is fake for this mission 
  1306. 	notoriety_force_no_spawn("police", true) 
  1307. 	notoriety_force_no_spawn("morningstar", true)	 
  1308. 	 
  1309. 	-- set a kill trigger to kill anything that falls 
  1310. 	m01_set_trigger(M01_trigger.kill.name, "m01_kill_trigger_cb") 
  1311. 	 
  1312. 	-- Start fading in  
  1313. 	mission_start_fade_in() 
  1314.  
  1315. end 
  1316.  
  1317. -- Kill the first group of guards 
  1318. -- 
  1319. function m01_kill_lobby_guards() 
  1320. 	M01_gat_finished_shooting = false 
  1321. 	M01_player_over_desk = false 
  1322. 	 
  1323. 	-- send in the guards 
  1324. 	M01_thread.move_guards = thread_new("m01_enter_guards_thread") 
  1325. 	 
  1326. 	-- everyone else cowers 
  1327. 	M01_thread.people_cower = thread_new("m01_group_cower_thread", M01_group.lobby_cower) 
  1328. 	 
  1329. 	-- saints fan blabs 
  1330. 	M01_thread.saints_fan = thread_new("m01_get_robbed_line_thread", M01_group.lobby_cower.saints_fan) 
  1331. 		 
  1332. 	M01_thread.josh_ai = thread_new("m01_josh_is_dumbass_thread") 
  1333. 	 
  1334. 	-- make sure peds and guards fight 
  1335. 	m01_group_no_flee_or_cower(M01_group.lobby.tellers) 
  1336. 	 
  1337. 	-- action! 
  1338. 	clear_animation_state(LOCAL_PLAYER) 
  1339. 	 
  1340. 	-- trigger Gat interrogate 
  1341. 	M01_thread.conversation = thread_new("m01_gat_guard_convo_thread") 
  1342. 	 
  1343. 	-- Player look cool, go! 
  1344. 	local anim_name = "Mission 1 Start" 
  1345. 	local morph_name = "Mission 1 Start" 
  1346. 	local force_play = false	 
  1347. 	local percentage = 1.0 
  1348. 	local stand_still = true 
  1349. 	local zero_movement = true 
  1350. 	action_play(LOCAL_PLAYER, anim_name, morph_name, force_play, percentage, stand_still, zero_movement, M01_checkpoint.start.nav1) 
  1351. 	M01_player_over_desk = true 
  1352. 		 
  1353. 	set_ignore_ai_flag( M01_shaundi, false ) 
  1354. 	hud_display_remove_state(M01_hud_state.hide_everything) 
  1355. 	M01_hud_state.hide_everything = -1 
  1356. 	 
  1357. 	-- Josh and Shaundi can start moving 
  1358. 	npc_leash_remove(M01_group.start_homies.josh) 
  1359. 	npc_leash_remove(M01_group.start_homies.shaundi) 
  1360. 	follower_make_independent(M01_group.start_homies.shaundi, true) 
  1361. 	 
  1362. 	-- 1 spotlight heli for fine_aim area 
  1363. 	M01_news_location = M01_news.fine_aim 
  1364. 	 
  1365. 	-- kill the guards 
  1366. 	process_enemy_set(M01_group.lobby.members) 
  1367. 	M01_lobby_cleared = true 
  1368. 	 
  1369. 	M01_thread.fine_aim_glass = thread_new("m01_fine_aim_glass_thread") 
  1370. 	 
  1371. 	delay(2.0) 
  1372. 				 
  1373. end 
  1374.  
  1375. -- Kill the second group of guards 
  1376. -- 
  1377. function m01_kill_lobby2_guards() 
  1378. 	group_create_hidden(M01_group.second_floor.name, true) 
  1379. 	local should_run = true 
  1380. 	local should_fire = false	 
  1381. 	 
  1382. 	ai_do_scripted_move(M01_group.start_homies.shaundi, M01_cover.lobby2.shaundi, should_run, should_fire)	 
  1383. 	-- keep her out of the way 
  1384. 	npc_leash_to_nav( M01_shaundi, M01_cover.lobby2.shaundi, 1.0 ) 
  1385. 	 
  1386. 	group_create_hidden(M01_group.lobby3.name, true) 
  1387. 	group_create(M01_group.fine_aim.name, true) 
  1388. 	m01_setup_see_saints(M01_group.fine_aim.members) 
  1389. 		 
  1390. 	-- when Gat is in position, do the action and open the door 
  1391. 	while not M01_josh_grandstanded do 
  1392. 		thread_yield() 
  1393. 	end 
  1394. 	 
  1395. 	-- move Gat to door 
  1396. 	npc_leash_remove(M01_group.start_homies.gat) 
  1397. 	set_ignore_ai_flag( M01_group.start_homies.gat, true ) 
  1398. 	ai_do_scripted_move(M01_group.start_homies.gat, "grandstand_nav", should_run, should_fire)	 
  1399. 	 
  1400. 	while not ai_scripted_action_is_complete(M01_group.start_homies.gat) do 
  1401. 		thread_yield() 
  1402. 	end 
  1403. 	 
  1404. 	group_show(M01_group.lobby3.name) 
  1405. 	npc_unholster_best_weapon(M01_group.lobby3.doorman) 
  1406. 	 
  1407. 	local anim_name = "Gat Door Kick Killed" 
  1408. 	local morph_name = "Gat Door Kick Killed" 
  1409. 	local force_play = false	 
  1410. 	local percentage = 1.0 
  1411. 	local stand_still = true 
  1412. 	local zero_movement = true 
  1413. 	 
  1414. 	--gatdoor 
  1415. 	local reverse_door = true 
  1416. 	local animate_door = true 
  1417. 	door_open(LOBBY_DOOR02, reverse_door, animate_door, M01_group.start_homies.gat, "Gat Door Kick", "grandstand_nav") 
  1418. 		 
  1419. 	-- this will force Gat to wait 
  1420. 	action_play(M01_group.lobby3.doorman, anim_name, morph_name, force_play, percentage, stand_still, zero_movement) 
  1421. 	character_kill(M01_group.lobby3.doorman) 
  1422. 	 
  1423. 	set_ignore_ai_flag( M01_group.start_homies.gat, false ) 
  1424. 	M01_gat_finished_shooting = true 
  1425. 	 
  1426. 	npc_leash_remove(M01_shaundi) 
  1427. 	 
  1428. 	recall_crew() 
  1429. 	 
  1430. 	-- setup freerun trigger now in case of advanced player 
  1431. 	M01_trigger.freerun.hit = false 
  1432. 	m01_set_trigger(M01_trigger.freerun.name, "m01_reached_freerun") 
  1433. 	 
  1434. 	-- gotta prep this waaaay early...dammit QA 
  1435. 	M01_shaundi_attack.thread = thread_new( "m01_shaundi_attacked_thread" ) 
  1436.  
  1437. 	-- spawn threads to move guards to their marks 
  1438. 	for i, guard in pairs(M01_group.lobby3.members) do 
  1439. 		ai_do_scripted_move(guard, LOBBY_MARK2[i]) 
  1440. 	end 
  1441. 	 
  1442. 	recall_crew() 
  1443.  
  1444. 	process_enemy_set(M01_group.lobby3.members) 
  1445. 	recall_crew() 
  1446. 	 
  1447. 	if not M01_trigger.freerun.hit then	-- if this was already hit, she should be headed upstairs 
  1448. 		M01_thread.shaundi_move = thread_new("m01_homie_move_thread", M01_group.start_homies.shaundi, M01_cover.fine_aim.shaundi)	 
  1449. 	end 
  1450. 	M01_thread.gat_move = thread_new("m01_homie_move_thread", M01_group.start_homies.gat, M01_cover.fine_aim.gat) 
  1451. 	 
  1452. end 
  1453.  
  1454. -- Do fine aim tutorial and kill the fine aim group of guards 
  1455. -- 
  1456. function m01_fine_aim_guards() 
  1457. 	 
  1458. 	-- Start the fine aim tutorial 
  1459. 	M01_skip_fineaim_release = false 
  1460. 	if M01_TUTORIAL_FINEAIM ~= INVALID_THREAD_HANDLE then 
  1461. 		thread_close(M01_TUTORIAL_FINEAIM) 
  1462. 	end 
  1463. 	M01_TUTORIAL_FINEAIM = thread_new("m01_fineaim_tutorial") 
  1464. 		 
  1465. 	M01_thread.tutorial_timer = thread_new("delay", 2.0)		 
  1466. 	 
  1467. 	-- Josh takes off 
  1468. 	-- kill Josh's current thread 
  1469. 	thread_kill(M01_thread.josh_ai) 
  1470. 	clear_animation_state(M01_josh) 
  1471. 	set_ignore_ai_flag(M01_josh, false) 
  1472. 	thread_yield()	 
  1473. 	M01_thread.josh_ai = thread_new("m01_josh_run_upstairs") 
  1474. 	 
  1475. 	process_enemy_set(M01_group.fine_aim.members) 
  1476. 	recall_crew() 
  1477. 	 
  1478. 	if not M01_trigger.freerun.hit then	-- if this was already hit, she should be headed upstairs 
  1479. 		M01_thread.shaundi_move = thread_new("m01_homie_move_thread", M01_group.start_homies.shaundi, M01_cover.second_floor.shaundi)	 
  1480. 	end 
  1481. 	M01_thread.gat_move = thread_new("m01_homie_move_thread", M01_group.start_homies.gat, M01_cover.second_floor.gat) 
  1482. 	 
  1483. end 
  1484.  
  1485. -- Reinforcements on the second floor, kill them 
  1486. -- 
  1487. function m01_second_floor_guards()	 
  1488. 	notoriety_set_min_and_max("morningstar", 1, 1)	-- since we don't see it, just give enough to attack us 
  1489. 	-- show all of these guys now so we can't watch them pop in 
  1490. 	group_show(M01_group.second_floor.name) 
  1491. 	 
  1492. 	m01_setup_see_saints(M01_group.second_floor.members) 
  1493. 	 
  1494. 	local should_run = true 
  1495. 	local should_fire = false 
  1496. 	for i, guard in pairs(M01_group.second_floor.members) do 
  1497. 		ai_do_scripted_move(guard, SECOND_FLOOR_MARK[i], should_run, should_fire) 
  1498. 	end 
  1499. end 
  1500.  
  1501. -- Set the vault as the next objective.  There's a lot of guards, but not required kills 
  1502. function m01_go_to_vault()	 
  1503. 	-- Add the bread crumb to lead to the vault 
  1504. 	M01_trigger.pre_vault.hit = false	 
  1505. 	if not M01_trigger.freerun.hit then 
  1506. 		-- tell player where to go 
  1507. 		objective_text( 0, "M01_GO_UPSTAIRS", "", "", SYNC_ALL, OI_ASSET_LOCATION ) 
  1508. 		m01_set_trigger(M01_trigger.pre_vault.name, "m01_reached_vault_breadcrumb") 
  1509. 		marker_add_trigger(M01_trigger.pre_vault.name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1510. 	end 
  1511. 	 
  1512. 	while not M01_trigger.freerun.hit do 
  1513. 		thread_yield() 
  1514. 	end 
  1515. 	 
  1516. 	objective_text( 0, "m01_kill_lobby_guards", "", "", SYNC_ALL, OI_ASSET_KILL ) 
  1517. 	m01_clear_trigger(M01_trigger.pre_vault.name) 
  1518. 	 
  1519. 	-- set the trigger again without the marker 
  1520. 	M01_trigger.pre_vault.hit = false	 
  1521. 	m01_set_trigger(M01_trigger.pre_vault.name, "m01_reached_vault_breadcrumb")	 
  1522. 	 
  1523. 	-- create new homies hidden as we go into cutscene (preload way early so all character resources are loaded for 
  1524. 	-- the zscene) 
  1525. 	local block = false 
  1526. 	group_create_hidden(M01_group.bomb_homies.name, block) 
  1527. 	 
  1528. 	process_enemy_set(M01_group.second_floor.members) 
  1529. 	 
  1530. 	-- if we haven't hit it yet 
  1531. 	if not M01_trigger.pre_vault.hit then  
  1532. 		-- tell player where to go 
  1533. 		objective_text( 0, "M01_GO_UPSTAIRS", "", "", SYNC_ALL, OI_ASSET_LOCATION ) 
  1534. 		marker_add_trigger(M01_trigger.pre_vault.name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1535. 	end 
  1536. 	 
  1537. 	while not M01_trigger.pre_vault.hit do 
  1538. 		thread_yield() 
  1539. 	end 
  1540. 	recall_crew() 
  1541. 	objective_text( 0, "m01_go_to_vault", "", "", SYNC_ALL, OI_ASSET_LOCATION ) 
  1542. 	 
  1543. 	M01_trigger.vault.hit = false 
  1544. 	m01_set_trigger(M01_trigger.vault.name, "m01_reached_vault") 
  1545. 	marker_add_trigger(M01_trigger.vault.name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1546. 	 
  1547. 	 
  1548. 	-- wait until you get to the vault 
  1549. 	while not M01_trigger.vault.hit do 
  1550. 		thread_yield() 
  1551. 	end 
  1552. 	 
  1553. 	m01_clear_tutorial() 
  1554. 			 
  1555. 	-- kill conversations 
  1556. 	thread_kill(M01_thread.conversation) 
  1557. 	M01_thread.conversation = INVALID_THREAD_HANDLE 
  1558. 	m01_end_conversations() 
  1559. 	 
  1560. 	-- stop custom Josh ai 
  1561. 	thread_kill(M01_thread.josh_ai) 
  1562. end 
  1563.  
  1564. -- Gat says it is time for plan B 
  1565. function m01_plan_b_scene() 
  1566.  
  1567. 	thread_kill(M01_thread.fine_aim_glass) 
  1568. 	m01_stop_emitters(M01_audio_emitter.fine_aim) 
  1569. 	audio_object_post_event("M01_Score_Z01_Start") 
  1570. 	local teleport_navs = { M01_checkpoint.plant_bombs.nav1, M01_checkpoint.plant_bombs.nav2 } 
  1571. 	cutscene_play(M01_scene.at_vault, nil, teleport_navs) 
  1572. 	player_controls_disable(LOCAL_PLAYER)	-- don't move while doing the animation thing 
  1573. --[[	 
  1574. 	set_animation_state(LOCAL_PLAYER, "M01 Z01 Stand") 
  1575. 	 
  1576. 	local anim_name = "m01 z01 transition" 
  1577. 	local morph_name = "m01 z01 transition" 
  1578. 	local force_play = false	 
  1579. 	local percentage = 0.8 
  1580. 	local stand_still = true 
  1581. 	local zero_movement = true 
  1582. 	action_play(LOCAL_PLAYER, anim_name, morph_name, force_play, percentage, stand_still, zero_movement) 
  1583. 	clear_animation_state(LOCAL_PLAYER) 
  1584. ]]--	 
  1585. 	m01_cleanup_first_checkpoint_groups() 
  1586. 	 
  1587. 	-- cleanup old guys	 
  1588. 	m01_cleanup_first_checkpoint_crew() 
  1589. 		 
  1590. 	-- make sure new homies are spawned 
  1591. 	while (not(group_create_check_done(M01_group.bomb_homies.name))) do 
  1592. 		thread_yield() 
  1593. 	end 
  1594. 	group_show(M01_group.bomb_homies) 
  1595. 	m01_setup_crew(M01_group.bomb_homies) 
  1596. 	 
  1597. 	 
  1598. 	-- Horse is broke 
  1599. 	mesh_mover_update_control("Horsie", "is statue broken", true) 
  1600. 	 
  1601. 	-- doors need to be opened again (WTF?) 
  1602. 	local reverse_door = true 
  1603. 	door_open(LOBBY_DOOR01, reverse_door) 
  1604. 	door_open(LOBBY_DOOR02, reverse_door) 
  1605. 			 
  1606. 	-- make Shaundi and Josh independent for their conversation 
  1607. 	follower_make_independent(M01_josh, true) 
  1608. 	follower_make_independent(M01_shaundi, true) 
  1609. 	 
  1610. 	-- wait until the player is done with his animation 
  1611. 	delay(2.7) 
  1612. 	player_controls_enable(LOCAL_PLAYER) 
  1613. end 
  1614.  
  1615. function m01_set_bomb() 
  1616. 	-- tell guards to do their thing 
  1617. 	M01_thread.elevator = thread_new("m01_elevator_guards_thread") 
  1618. 		 
  1619. 	--group_create(M01_group.bomb_flee) 
  1620. 	M01_thread.people_cower = thread_new("m01_group_cower_thread", M01_group.bomb_cower) 
  1621. 	M01_group.autograph.thread = thread_new("m01_setup_autograph_thread") 
  1622. 	objective_text( 0, "M01_GO_UPSTAIRS", "", "", SYNC_ALL, OI_ASSET_LOCATION ) 
  1623. 	on_attack_performed(M01_gat_attack_info.callback, M01_gat) 
  1624. 	character_prevent_flinching(M01_josh, true) 
  1625. 	character_prevent_flinching(M01_shaundi, true) 
  1626.  
  1627. 	M01_trigger.pre_bomb.hit = false 
  1628. 	m01_set_trigger(M01_trigger.pre_bomb.name, "m01_reached_pre_bomb")	 
  1629. 	m01_set_trigger(M01_trigger.pre_bomb2.name, "m01_reached_pre_bomb")	-- hidden trigger for other staircase 
  1630. 	marker_add_trigger(M01_trigger.pre_bomb.name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1631. 				 
  1632. 	M01_thread.conversation = thread_new("m01_bomb_convo_thread") 
  1633. 	 
  1634. 	-- allow time for Josh to get to the doorway 
  1635. 	delay(1.0) 
  1636. 	while not M01_trigger.pre_bomb.hit and ai_scripted_action_is_processing(M01_josh) do 
  1637. 		thread_yield() 
  1638. 	end 
  1639. 	 
  1640. 	if not M01_trigger.pre_bomb.hit then 
  1641. 		M01_thread.josh_ai = thread_new("m01_josh_just_cower_thread") 
  1642. 	end 
  1643. 	 
  1644. 	-- wait until you get to the stairs 
  1645. 	while not M01_trigger.pre_bomb.hit do 
  1646. 		thread_yield() 
  1647. 	end 
  1648. 	 
  1649. 	-- stop custom Josh ai 
  1650. 	--thread_kill(M01_thread.josh_ai) 
  1651. 	 
  1652. 	-- give Josh time to get upstairs 
  1653. 	delay(5.0) 
  1654. 	 
  1655. 	-- Shaundi can stop force-firing at guy 
  1656. 	npc_leash_remove(M01_shaundi) 
  1657. 	ai_clear_scripted_action(M01_shaundi) 
  1658. 	npc_leash_remove(M01_gat) 
  1659. 		 
  1660. 	--follower_make_independent(M01_josh, false) 
  1661. 	follower_make_independent(M01_shaundi, false) 
  1662. 	follower_make_independent(M01_gat, false) 
  1663. 		 
  1664. 	objective_text( 0, "m01_set_explosives", "", "", SYNC_ALL, OI_ASSET_USE ) 
  1665. 		 
  1666. 	-- target the bomb area 
  1667. 	M01_trigger.bomb.hit = false 
  1668. 	M01_setting_bomb = false 
  1669. 	m01_set_trigger(M01_trigger.bomb.name, "m01_reached_bomb")	 
  1670. 	marker_add_trigger(M01_trigger.bomb.name, MINIMAP_ICON_USE, INGAME_EFFECT_CHECKPOINT, OI_ASSET_USE, OI_FLAGS_LOCATION, SYNC_ALL) 
  1671.  
  1672. 	delay(1.0) 
  1673. 	-- wait until you get to the bomb 
  1674. 	while not M01_trigger.bomb.hit do 
  1675. 		thread_yield() 
  1676. 	end 
  1677. 	thread_kill(M01_thread.elevator) 
  1678. 	 
  1679. 	-- kill conversations 
  1680. 	thread_kill(M01_thread.conversation) 
  1681. 	M01_thread.conversation = INVALID_THREAD_HANDLE 
  1682. 	m01_end_conversations() 
  1683. 	 
  1684. 	thread_kill(M01_thread.josh_ai) 
  1685. end 
  1686.  
  1687. -- Set off bomb and trigger the alarm 
  1688. function m01_detonate_bomb_scene() 
  1689. 	group_create_hidden(M01_group.swat_homies.name, true)	 
  1690. 	 
  1691. 	--bink_play(M01_scene.explosives) 
  1692. 	local teleport_navs = { M01_checkpoint.survive.nav1, M01_checkpoint.survive.nav2 } 
  1693. 	local fade_in_after = true 
  1694. 	m01_stop_emitters(M01_audio_emitter.office) 
  1695. 	cutscene_play(M01_scene.explosives, nil, teleport_navs, fade_in_after)		 
  1696. 	-- swap to damaged version of bank 
  1697. 	city_zone_swap(M01_zone_name, false) 
  1698. 	city_zone_swap(M01_zone_damaged_name, true) 
  1699. 	M01_thread.reset_movers = thread_new("m01_reset_movers_thread") 
  1700. 	 
  1701. 	audio_object_post_event("M01_Office_Heli_Mute") 
  1702. 	m01_start_emitters(M01_audio_emitter.city_noise) 
  1703. 	audio_object_post_event("M01_Score_SWAT") 
  1704. 	 
  1705. 	m01_cleanup_second_checkpoint_groups() 
  1706. 	m01_cleanup_second_checkpoint_crew() 
  1707. 	 
  1708. 	-- spawn new homies 
  1709. 	M01_thread.homies_prep = thread_new("m01_homies_prep_thread") 
  1710. 	 
  1711. 	-- make sure everyone can move (may be turned off due to autograph sign) 
  1712. 	player_movement_enable(LOCAL_PLAYER) 
  1713. 	if coop_is_active() then  
  1714. 		player_movement_enable(REMOTE_PLAYER) 
  1715. 	end 
  1716. end 
  1717.  
  1718. function m01_cut_power() 
  1719. 	-- alarm lights are on 
  1720. 	m01_alarm_lights(true) 
  1721. 	 
  1722. 	m01_setup_ropes() 
  1723. 	m01_start_swat_respawn_pairs() 
  1724.  
  1725. 	-- no weapons so we can do tutorial 
  1726. 	inv_item_equip(nil, LOCAL_PLAYER) -- Unequip the current weapon on the player 
  1727. 	if coop_is_active() then 
  1728. 		inv_item_equip(nil, REMOTE_PLAYER) -- Unequip the current weapon on the player 
  1729. 	end 
  1730. 	 
  1731. 	if M01_TUTORIAL_SWITCH_WEAPON ~= INVALID_THREAD_HANDLE then 
  1732. 		thread_kill(M01_TUTORIAL_SWITCH_WEAPON) 
  1733. 	end 
  1734. 	M01_TUTORIAL_SWITCH_WEAPON = thread_new("m01_change_weapons_tutorial")	 
  1735. 	 
  1736. 	-- kill any cops that fall below your floor 
  1737. 	m01_set_trigger(M01_trigger.swat_kill.name, "m01_kill_trigger_cb") 
  1738. 	 
  1739. 	delay(2.0) 
  1740. 	 
  1741. 	M01_convo.swat_on_way.handle = audio_conversation_load(M01_convo.swat_on_way.name)	 
  1742. 	 
  1743. 	audio_conversation_play(M01_convo.swat_on_way.handle) 
  1744. 	on_attack_performed(M01_gat_attack_info.callback, M01_gat) 
  1745. 	 
  1746. 	delay(4.0) 
  1747. 	 
  1748. 	-- cut the power -- not anymore 
  1749. 	--local lights_on = false 
  1750. 	--m01_set_lights_on(lights_on) 
  1751. 	 
  1752. 	M01_news_location = M01_news.swat 
  1753. 	--M01_group.news_heli1.news_thread = thread_new("m01_news_heli_thread", M01_group.news_heli1) 
  1754. 	--M01_group.news_heli2.news_thread = thread_new("m01_news_heli_thread", M01_group.news_heli2) 
  1755. 	 
  1756. end 
  1757.  
  1758. -- defend against the waves of cops 
  1759. function m01_survive_cops()	 
  1760. 	-- spawn and float attack chopper 
  1761. 	group_create(M01_group.heli_fighter1.name, true) 
  1762. 	vehicle_enter_group_teleport(M01_group.heli_fighter1.members, M01_group.heli_fighter1.vehicle)	 
  1763. 	-- don't take explosion damage 
  1764. 	vehicle_set_explosion_damage_multiplier(M01_group.heli_fighter1.vehicle, 0.0) 
  1765. 	vehicle_prevent_explosion_fling(M01_group.heli_fighter1.vehicle, true) 
  1766. 	vehicle_suppress_npc_exit(M01_group.heli_fighter1.vehicle, true) 
  1767. 	m01_float_heli(M01_group.heli_fighter1, M01_group.heli_fighter1.flyby_float) 
  1768. 	 
  1769. 	npc_combat_enable(M01_group.heli_fighter1.members[1], false)	 
  1770. 	npc_combat_enable(M01_group.heli_fighter1.members[2], false) 
  1771. 	 
  1772. 	-- set hard limit on how much damage can be taken 
  1773. 	local total_hitpoints = get_max_hit_points(M01_group.heli_fighter1.vehicle) 
  1774. 	set_min_hit_points(M01_group.heli_fighter1.vehicle, total_hitpoints * M01_group.heli_fighter1.damage2) 
  1775. 	 
  1776. 	--M01_convo.set_explosives.handle = audio_conversation_load(M01_convo.set_explosives.name) 
  1777. 	M01_convo.attack_chopper.handle = audio_conversation_load(M01_convo.attack_chopper.name)	 
  1778. 	 
  1779.  
  1780. 	-- attack wall diagram 
  1781. 	-- Respawn pairs go here (pair 1 = p1) 
  1782. 	-- Riot guys use pair 1's positions 
  1783. 	-------------------------------------------------------- 
  1784. 	-- | p5  || p5 |      |  p4  ||  p4   ||     |    <---Uppper floor 
  1785. 	----------------------------------------------- 
  1786. 	-- | p1  || p1 |      | p2   || p2 p3 ||  p3 |    <---Lower floor 
  1787. 	----------------------------------------------- 
  1788. 	 
  1789. 	-- Spawn in first set 
  1790. 	M01_throw_flashbangs = true 
  1791. 	-- two guys up front 
  1792. 	M01_group.swat2_pair.active = true 
  1793. 	M01_group.swat3_pair.active = true 
  1794. 	 
  1795. 	-- give them a second to spawn 
  1796. 	delay(1.0) 
  1797. 	-- turn them off 
  1798. 	M01_group.swat2_pair.active = false 
  1799. 	M01_group.swat3_pair.active = false 
  1800.  
  1801. 	delay(1.0) 
  1802. 		 
  1803. 	audio_conversation_wait_for_end(M01_convo.swat_on_way.handle) 
  1804. 	M01_convo.swat_on_way.handle = INVALID_CONVERSATION_HANDLE	 
  1805. 	set_ignore_ai_flag( M01_gat, false ) 
  1806. 	set_ignore_ai_flag( M01_shaundi, false ) 
  1807. 	 
  1808. 	delay(3.0) 
  1809. 	 
  1810. 	-- "Here they come"  "Cover me" 
  1811. 	--audio_conversation_play(M01_convo.set_explosives.handle)		 
  1812. 	--thread_yield() 
  1813. 	--audio_conversation_wait_for_end(M01_convo.set_explosives.handle) 
  1814. 	--M01_convo.set_explosives.handle = INVALID_CONVERSATION_HANDLE 
  1815. 	 
  1816. 	-- just say "Here they come" 
  1817. 	audio_play_persona_line(M01_gat, "M01_Set_Explosives_02") 
  1818. 	M01_thread.line_timer = thread_new("delay", 3.0) -- emergency timer in case line fails	 
  1819. 	thread_yield() 
  1820. 	 
  1821. 	while audio_persona_line_playing(M01_gat) and (not thread_check_done(M01_thread.line_timer)) do 
  1822. 		thread_yield() 
  1823. 	end 
  1824. 	delay(0.5) 
  1825. 	 
  1826. 	-- Flashbang callout! 
  1827. 	audio_play_persona_line(M01_shaundi, "M01_Flashbang_Callout") 
  1828. 	delay(1.0) 
  1829. 	 
  1830. 	-- just blow up the player		 
  1831. 	explosion_create("Flashbang", LOCAL_PLAYER, M01_group.swat2_pair.members[1], false) 
  1832. 	-- and the remote player 
  1833. 	if (coop_is_active() == true) then 
  1834. 		explosion_create("Flashbang", REMOTE_PLAYER, M01_group.swat2_pair.members[1], false) 
  1835. 	end 
  1836. 	 
  1837. 	clear_animation_state(M01_shaundi) 
  1838. 	clear_animation_state(M01_gat) 
  1839. 	 
  1840. 	delay(10.0)	-- give some time for player to figure out what is going on and kill some guys 
  1841. 	M01_throw_flashbangs = false 
  1842. 	 
  1843. 	-- start spawn group 2 and 3 
  1844. 	M01_group.swat2_pair.active = true 
  1845. 	M01_group.swat3_pair.active = true 
  1846. 	 
  1847. 	-- shoot for a little bit 
  1848. 	delay(10.0) 
  1849. 	-- add some upstairs action 
  1850. 	M01_group.swat4_pair.active = true 
  1851. 	 
  1852. 	-- Shanundi bitching 
  1853. 	M01_convo.swat_chit_chat.handle = audio_conversation_load(M01_convo.swat_chit_chat.name)		 
  1854. 	audio_conversation_play(M01_convo.swat_chit_chat.handle) 
  1855. 	audio_conversation_wait_for_end(M01_convo.swat_chit_chat.handle) 
  1856. 	M01_convo.swat_chit_chat.handle = INVALID_CONVERSATION_HANDLE	 
  1857. 	delay(10.0) 
  1858. 	audio_object_post_event("M01_Office_Heli_Closer") 
  1859. 	 
  1860. 	-- more guys 
  1861. 	M01_group.swat1_pair.active = true 
  1862. 	-- less on right 
  1863. 	M01_group.swat3_pair.active = false 
  1864. 	delay(5.0) 
  1865. 	-- move upstairs spawns 
  1866. 	--M01_group.swat5_pair.active = true 
  1867. 	--M01_group.swat4_pair.active = false 
  1868. 	delay(10.0) 
  1869. 	M01_group.swat2_pair.active = false 
  1870. 	 
  1871. 	-- two riot sheild guys 
  1872. 	M01_group.swat_riot_pair.active = true 
  1873. 	delay(2.0) 
  1874. 	M01_group.swat_riot_pair.active = false 
  1875. 	 
  1876. 	-- Gat says almost done 
  1877. 	audio_play_persona_line(M01_group.swat_homies.gat, "M01_Wait_For_Helicopter") 
  1878. 	M01_thread.line_timer = thread_new("delay", 3.0) -- emergency timer in case line fails 
  1879. 	thread_yield() 
  1880. 	 
  1881. 	while audio_persona_line_playing(M01_gat) and (not thread_check_done(M01_thread.line_timer)) do 
  1882. 		thread_yield() 
  1883. 	end 
  1884. 	 
  1885. 	audio_play_persona_line(M01_shaundi, "M01_Calling_Out_Riot_Shields") 
  1886. 	 
  1887. 	delay(10.0) 
  1888. 		 
  1889. 	-- turn off continuous spawn 
  1890. 	M01_group.swat1_pair.active = false 
  1891. 	M01_group.swat2_pair.active = false 
  1892. 	M01_group.swat3_pair.active = false 
  1893. 	M01_group.swat4_pair.active = false 
  1894. 	M01_group.swat5_pair.active = false 
  1895. 	 
  1896. 	-- wait until most are killed 
  1897. 	while M01_pairs_spawned > 2 do 
  1898. 		thread_yield() 
  1899. 	end 
  1900. 	 
  1901. 	-- send guys trhough the front windows again 
  1902. 	M01_group.swat1_pair.active = true 
  1903. 	delay(1.0) 
  1904. 	M01_group.swat1_pair.active = false	 
  1905. 	-- let the chopper come in 
  1906. 	 
  1907. 	-- send heli in 
  1908. 	audio_object_post_event("M01_Office_Heli_PassBy", nil, nil, M01_group.heli_fighter1.vehicle) 
  1909. 	M01_group.heli_fighter1.thread = thread_new("m01_fly_direct_thread", M01_group.heli_fighter1.vehicle, M01_group.heli_fighter1.flyby_path, 30.0) 
  1910. 	M01_group.heli_fighter1.permission_to_fire = false 
  1911. 	M01_group.heli_fighter1.gunner_thread = thread_new("m01_attack_heli_building_battle_thread", M01_group.heli_fighter1) 
  1912. 	delay(6.0) 
  1913. 	 
  1914. 	-- notice attack heli 
  1915. 	audio_conversation_play(M01_convo.attack_chopper.handle) 
  1916. 	audio_conversation_wait_for_end(M01_convo.attack_chopper.handle) 
  1917. 	M01_convo.attack_chopper.handle = INVALID_CONVERSATION_HANDLE	 
  1918. 	 
  1919. 	-- require XX% damage on heli 
  1920. 	M01_group.heli_fighter1.damaged = false 
  1921. 	turn_vulnerable(M01_group.heli_fighter1.vehicle) 
  1922. 	marker_add(M01_group.heli_fighter1.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL) 
  1923. 	objective_text( 0, "M01_KILL_CHOPPER", "", "", SYNC_ALL, OI_ASSET_KILL ) 
  1924. 	on_damage("m01_attack_heli_damaged_cb", M01_group.heli_fighter1.vehicle, M01_group.heli_fighter1.damage1) 
  1925. 	 
  1926. 	delay(1.0) 
  1927. 	M01_group.heli_fighter1.permission_to_fire = true 
  1928. 	 
  1929. 	delay(2.0) 
  1930. 	 
  1931. 	audio_play_persona_line(M01_shaundi, "M01_Helicopter") 
  1932.  
  1933. 	-- wait for heli damage 
  1934. 	while not M01_group.heli_fighter1.damaged do 
  1935. 		thread_yield() 
  1936. 	end 
  1937. 	 
  1938. 	-- start a thread to get the vault created 
  1939. 	--M01_thread.vault_setup = thread_new("m01_vault_setup_part1_thread") 
  1940. 	 
  1941. 	thread_kill(M01_group.heli_fighter1.gunner_thread) 
  1942. 	marker_remove(M01_group.heli_fighter1.vehicle) 
  1943. 	objective_text( 0, "m01_survive", "", "", SYNC_ALL, OI_ASSET_DEFEND ) 
  1944. 	M01_group.heli_fighter1.permission_to_fire = false 
  1945. 	npc_combat_enable(M01_group.heli_fighter1.members[1], false)	 
  1946. 	npc_combat_enable(M01_group.heli_fighter1.members[2], false) 
  1947.  
  1948. 	thread_kill(M01_group.heli_fighter1.thread) 
  1949. 	M01_group.heli_fighter1.thread = thread_new("m01_fly_direct_thread", M01_group.heli_fighter1.vehicle, "heli_police2_home", 30.0) 
  1950. 	audio_object_post_event("M01_Score_Z03_Transition") 
  1951. 	 
  1952. 	delay(1.7) 
  1953. 	 
  1954. 	audio_play_persona_line(M01_shaundi, "M01_Chopper_Arrives") 
  1955. 	delay(1.0) 
  1956.  
  1957. 	m01_stop_swat_respawn_pairs() 
  1958. 	 
  1959. 	m01_clear_tutorial() 
  1960. 	 
  1961. 	m01_clear_trigger(M01_trigger.swat_kill.name) 
  1962. 	 
  1963. end 
  1964.  
  1965. -- Helicopter arrives to take vault away 
  1966. function m01_heli_arrive_scene() 
  1967. 		 
  1968. 	-- make sure any conversations are over 
  1969. 	m01_end_conversations() 
  1970. 	 
  1971. 	local teleport_navs = { M01_checkpoint.ride_vault.nav1, M01_checkpoint.ride_vault.nav2 } 
  1972. 	local fade_in_after = false 
  1973. 	cutscene_play(M01_scene.connect_vault, nil, teleport_navs, fade_in_after) 
  1974. 	 
  1975. 	m01_vault_setup_part1_thread( ) 
  1976. 	-- get on the vault 
  1977. 	m01_vault_setup_part2_thread() 
  1978. 	fade_in(0.5) 
  1979. 			 
  1980. 	-- cleanup groups 
  1981. 	m01_cleanup_cop_wave_groups() 
  1982. 	m01_cleanup_swat_crew()		 
  1983. end 
  1984.  
  1985. -- Show helicopter coming out of m01, pan down to player 
  1986. function m01_vault_above_cam() 
  1987.  
  1988. 	audio_object_post_event("M01_Vault_Foley") 
  1989.  
  1990. 	-- start thread to spawn everything else 
  1991. 	M01_thread.vault_environ_setup = thread_new("m01_vault_environ_setup_thread") 
  1992. 	 
  1993. 	-- back to more normal restrictions (infinite down look) 
  1994. 	camera_restrict_set_limits( M01_MIN_PITCH, 90, M01_MIN_HEADING, M01_MAX_HEADING ) 
  1995. 		 
  1996. end 
  1997.  
  1998. -- Kill guards hanging out on the fifth floor 
  1999. function m01_vault_first_guards() 
  2000.  
  2001. 	-- and now the news! 
  2002. 	M01_news_location = M01_news.vault 
  2003. 	M01_group.news_heli1.news_thread = thread_new("m01_news_heli_thread", M01_group.news_heli1) 
  2004. 	M01_group.news_heli2.news_thread = thread_new("m01_news_heli_thread", M01_group.news_heli2) 
  2005. 	 
  2006. 	audio_object_post_event("M01_Vault_Liftoff") 
  2007. 	delay(2.0) 
  2008. 	M01_convo.hooked_up.start = true 
  2009. 	delay(4.1) 
  2010. 	 
  2011. end 
  2012.  
  2013. -- move guards to the roof and show them setting up 
  2014. function m01_vault_roof_setup() 
  2015. 	M01_group.roof1_pair.active = true 
  2016. 	M01_group.roof2_pair.active = true 
  2017. 	M01_group.roof3_pair.active = true 
  2018. 	ai_set_action_delay(M01_group.heli_fighter1.members[1], "throw grenade", 99999) 
  2019. 	ai_set_action_delay(M01_group.heli_fighter1.members[2], "throw grenade", 99999) 
  2020. 	-- no more shooting 
  2021. 	npc_combat_enable(M01_group.heli_fighter1.members[1], false) 
  2022. 	npc_combat_enable(M01_group.heli_fighter1.members[2], false) 
  2023. 		 
  2024. 	-- start moving 
  2025. 	camera_shake_play("explosion_large", 4.0) 
  2026. 	 
  2027. 	-- switch to new animation 
  2028. 	m01_play_next_vault_animations(M01_DO_NOT_WAIT, M01_INTERRUPT) 
  2029. 		 
  2030. 	-- do a slow, looping camera shake while on the vault 
  2031. 	camera_shake_play_looping(M01_vault_camera_shake) 
  2032. 		 
  2033. 	delay(2.0) 
  2034. 	 
  2035. 	M01_convo.heli_rising.start = true 
  2036. 	 
  2037. 	delay(6.0) 
  2038. 		 
  2039. 	m01_heli_move_to(POLICE_HELI_WAIT_LOCATION1, M01_group.heli_police1) 
  2040. 	 
  2041. 	m01_path_complete_thread() 
  2042. 	 
  2043. 	M01_news_location = M01_news.loop 
  2044. 	 
  2045. 	-- vulnerable up to a point 
  2046. 	turn_vulnerable(M01_group.heli_fighter1.vehicle) 
  2047. 	M01_group.heli_fighter1.damaged = false 
  2048. 	on_damage("m01_attack_heli_damaged_cb", M01_group.heli_fighter1.vehicle, M01_group.heli_fighter1.damage2) 
  2049. 	 
  2050. 	-- It's a fighter! 
  2051. 	delay(0.7) 
  2052. 	 
  2053. 	-- It's a moving fighter! 
  2054. 	thread_kill(M01_group.heli_fighter1.thread) 
  2055. 	M01_group.heli_fighter1.attack_run_thread = thread_new("m01_fighter_attack_run_thread", M01_group.heli_fighter1, M01_group.heli_fighter1.run1) 
  2056. 	delay(3.0) 
  2057. 		 
  2058. 	audio_play_persona_line(LOCAL_PLAYER, "M01_Same_Attack_Chopper_01") 
  2059.  
  2060. 	-- remove Gat, Shaundi and SWAT because they can pop out if we look down at them 
  2061. 	if group_is_loaded(M01_group.vault_attackers2.name) then 
  2062. 		group_destroy(M01_group.vault_attackers2.name) 
  2063. 	end 
  2064. 	 
  2065. 	while not M01_fighter_run_complete do 
  2066. 		thread_yield() 
  2067. 	end 
  2068. 	m01_players_set_vault_health(M01_player_health.shot1) 
  2069. 	 
  2070. 	camera_restrict_set_active(DISABLE) 
  2071. 	m01_play_next_vault_animations(M01_DO_NOT_WAIT, M01_INTERRUPT) 
  2072. 	thread_yield() -- wait for camera to change 
  2073.  
  2074. 	camera_restrict_set_limits( M01_MIN_PITCH, M01_MAX_PITCH, M01_MIN_HEADING, M01_MAX_HEADING ) 
  2075. 	camera_restrict_target_object(CAMERA_TARGET3) 
  2076. 	camera_restrict_set_active(ENABLE) 
  2077. 	 
  2078. 	M01_convo.heli_jerk_back.start = true 
  2079. 		 
  2080. 	--delay(1.0) 
  2081. 	m01_transport_show(M01_group.transport1, true) 
  2082. 	 
  2083. 	-- hack in other line (you won't get to hear transport1's line during dropoff) 
  2084. 	persona_override_persona_start(M01_group.transport2.pilots[1], "Interrogation") 
  2085. 	 
  2086. 	-- choppa! 
  2087. 	delay(1.0) 
  2088. 	M01_group.transport2.setup_thread = thread_new("m01_transport_flyby_thread", M01_group.transport2) 
  2089. 	delay(2.0) 
  2090. 	M01_group.transport3.setup_thread = thread_new("m01_transport_flyby_thread", M01_group.transport3) 
  2091. 	-- wait until moving is done 
  2092. 	m01_path_complete_thread() 
  2093. 	 
  2094. end 
  2095.  
  2096. -- Kill guards on roof, end with chopper 
  2097. function m01_roof_guards1() 
  2098. 	delay(1.5) 
  2099. 	audio_play_persona_line(M01_group.transport2.pilots[1], "M01_Bullhorn_Heli_Drop_01")	 
  2100. 	-- send heli across the screen	 
  2101. 	-- teleport first so he is hopefully facing the correct direction 
  2102. 	m01_float_heli(M01_group.heli_police1, POLICE_HELI_WAIT_LOCATION1) 
  2103. 	thread_yield() 
  2104. 	m01_heli_move_to(POLICE_HELI_WAIT_LOCATION2, M01_group.heli_police1) 
  2105. 	 
  2106. 	-- kill chopper  
  2107. 	Helicopter_killed = false 
  2108. 	m01_heli_move_to(POLICE_HELI_SHOOT_AT_ME1, M01_group.heli_police2) 
  2109. 	turn_vulnerable( M01_group.heli_police2.vehicle ) 
  2110. 	persona_override_persona_start(M01_group.heli_police2.members[1], M01_group.heli_police2.pilot_persona) 
  2111. 	on_damage("m01_crash_heli", M01_group.heli_police2.vehicle, M01_HELI_DAMAGE) 
  2112. 	ai_add_enemy_target(M01_group.heli_police2.shooter, LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE, true) 
  2113. 	 
  2114. 	-- prep the fighter	 
  2115. 	m01_float_heli(M01_group.heli_fighter1, M01_group.heli_fighter1.hover_nav2) 
  2116. 		 
  2117. 	m01_do_transport(M01_group.transport1) 
  2118. 	delay(3.0)	 
  2119. 	 
  2120. 	audio_play_persona_line(M01_group.heli_police2.members[1], M01_group.heli_police2.persona_line) 
  2121. 	 
  2122. 	delay(2.0) 
  2123. 	M01_convo.heli_not_leaving.start = true 
  2124. 	persona_override_persona_stop(M01_group.transport2.pilots[1]) 
  2125. 	 
  2126. 	-- make sure transport is out of the way 
  2127. 	while not M01_group.transport1.complete do 
  2128. 		thread_yield() 
  2129. 	end 
  2130. 	 
  2131. 	delay(1.0) 
  2132. 	 
  2133. 	-- move heli back 
  2134. 	-- teleport first so he is hopefully facing the correct direction 
  2135. 	m01_float_heli(M01_group.heli_police1, POLICE_HELI_WAIT_LOCATION2) 
  2136. 	thread_yield() 
  2137. 	 
  2138. 	m01_heli_move_to(POLICE_HELI_WAIT_LOCATION1, M01_group.heli_police1) 
  2139. 	 
  2140. end 
  2141.  
  2142. -- shoot down another heli getting real close to you 
  2143. function m01_shoot_heli_alt() 
  2144.  
  2145. 	M01_group.heli_fighter1.attack_run_thread = thread_new("m01_fighter_attack_run_thread", M01_group.heli_fighter1, M01_group.heli_fighter1.run2) 
  2146. 	delay(3.0) 
  2147. 	persona_override_persona_stop(M01_group.heli_police2.members[1]) 
  2148.  
  2149. 	-- Are you still alive?  Get out of here 
  2150. 	if vehicle_exists(M01_group.heli_police2.vehicle) and not vehicle_is_destroyed(M01_group.heli_police2.vehicle) then 
  2151. 		m01_heli_move_to(M01_group.heli_police2.home_nav, M01_group.heli_police2) 
  2152. 		on_damage("", M01_group.heli_police2.vehicle, 0.99) 
  2153. 	end 
  2154.  
  2155. 	while not M01_fighter_run_complete do 
  2156. 		thread_yield() 
  2157. 	end 
  2158.  
  2159. 	-- back over here 
  2160. 	m01_heli_move_to(POLICE_HELI_WAIT_LOCATION2, M01_group.heli_police1) 
  2161. 		 
  2162. 	camera_restrict_target_object(CAMERA_TARGET3) 
  2163. 	 
  2164. end 
  2165.  
  2166. -- Player's heli is shot again.  Crash through roof 
  2167. function m01_building_crash() 
  2168. 	 
  2169. 	-- transition to the next area 
  2170. 	M01_convo.heli_drag_vault.start = true 
  2171. 	m01_players_set_vault_health(M01_player_health.shot2) 
  2172. 	m01_play_next_vault_animations(M01_DO_NOT_WAIT, M01_DO_NOT_INTERRUPT) 
  2173. 	 
  2174. 	-- put this guy in place for "surprise" 
  2175. 	m01_float_heli(M01_group.heli_police1, POLICE_HELI_SURPRISE_NAV1) 
  2176. 	 
  2177. 	delay(2.0) 
  2178. 	-- don't wait for this group.  If the spawn fails, the game is stuck.  Not going to crash for these guys 
  2179. 	group_create(M01_group.roof2.name, false) 
  2180. 	 
  2181. 	-- delete first transport corpse completely 
  2182. 	vehicle_delete_all_corpses() 
  2183. 	 
  2184. 	delay(8.0) 
  2185. 	 
  2186. 	-- now finish coming back around 
  2187. 	thread_kill(M01_group.heli_fighter1.thread) 
  2188. 	M01_group.heli_fighter1.thread = thread_new("m01_fly_direct_thread", M01_group.heli_fighter1.vehicle, M01_group.heli_fighter1.attack_path2_part2, 40.0) 
  2189. 	 
  2190. 	-- wait until the animation is done 
  2191. 	m01_path_complete_thread() 
  2192. 	 
  2193. 	delay(3.0) 
  2194. 	 
  2195. 	marker_add(M01_group.heli_fighter1.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL) 
  2196. 	 
  2197. 	if not M01_group.heli_fighter1.damaged then 
  2198. 		turn_vulnerable(M01_group.heli_fighter1.vehicle) 
  2199. 	end 
  2200. 	objective_text( 0, "M01_KILL_CHOPPER", "", "", SYNC_ALL, OI_ASSET_KILL ) 
  2201. 	 
  2202. 	delay(4.0) 
  2203. 	M01_thread.line_timer = thread_new("m01_same_chopper2_thread") -- threaded because this could go poorly 
  2204. 	 
  2205. --[[	delay(4.9) 
  2206. 	-- do some blasting	 
  2207. 	npc_combat_enable(M01_group.heli_fighter1.members[1], true)	 
  2208. 	npc_combat_enable(M01_group.heli_fighter1.members[2], true) 
  2209. 	-- shoot here 
  2210. 	m01_heli_shoot_gun_at_nav(M01_group.heli_fighter1.vehicle, "hang_on_target", 1.5) 
  2211. 	 
  2212. 	npc_combat_enable(M01_group.heli_fighter1.members[1], false)	 
  2213. 	npc_combat_enable(M01_group.heli_fighter1.members[2], false) 
  2214. ]]--	 
  2215. end 
  2216.  
  2217. function m01_heli_crash_other_building() 
  2218.  
  2219. --[[	while get_dist(M01_group.heli_fighter1.vehicle, M01_group.heli_fighter1.attack_nav2) > 30.0 do 
  2220. 		thread_yield() 
  2221. 	end]]-- 
  2222.  
  2223. 	-- when you are close, shoot the player's heli 
  2224. 	while get_dist(M01_group.heli_fighter1.vehicle, M01_group.heli_fighter1.attack_nav2) > 20.0 do 
  2225. 		thread_yield() 
  2226. 	end 
  2227. 	 
  2228. 	m01_fighter_shoot_vault(0.6) 
  2229. 	 
  2230. 	thread_yield() 
  2231. 	marker_remove(M01_group.heli_fighter1.vehicle) 
  2232. 	objective_text( 0, "m01_survive", "", "", SYNC_ALL, OI_ASSET_DEFEND ) 
  2233. 	 
  2234. 	m01_players_set_vault_health(M01_player_health.shot3) 
  2235. 	m01_play_next_vault_animations(M01_DO_NOT_WAIT, M01_DO_NOT_INTERRUPT)	 
  2236. 	camera_restrict_set_active(DISABLE) 
  2237. 	M01_convo.heli_near_collision.start = true 
  2238. 	 
  2239. 	delay(3.0) 
  2240. 	 
  2241. 	-- send in another transport 
  2242. 	m01_do_transport(M01_group.transport2) 
  2243. 		 
  2244. 	-- wait until the animation is done 
  2245. 	m01_path_complete_thread() 
  2246. 	 
  2247. 	-- target your current view 
  2248. 	camera_restrict_target_object() 
  2249. 	camera_restrict_set_limits( 0.0, 0.0, 0.0, 0.0) 
  2250. 	-- lock it 
  2251. 	camera_restrict_set_active(ENABLE) 
  2252. 	thread_yield() 
  2253. 	 
  2254. 	-- follow the chopper 
  2255. 	camera_restrict_target_object(CAMERA_TARGET3, 500) 
  2256. 	camera_restrict_set_limits( M01_MIN_PITCH, M01_MAX_PITCH, M01_MIN_HEADING, M01_MAX_HEADING ) 
  2257. 	 
  2258. 	-- we should be done with these lines 
  2259. 	thread_kill(M01_thread.line_timer) 
  2260. end 
  2261.  
  2262. -- Oh Shit! 
  2263. function m01_shoot_even_more() 
  2264. 	-- a lot of guys on the way on transports, so chill the spawns a bit 
  2265. 	M01_group.roof2_pair.active = false 
  2266. 	M01_group.roof3_pair.active = false 
  2267. 	 
  2268. 	-- and another 
  2269. 	delay(4.0) 
  2270. 	m01_do_transport(M01_group.transport3) 
  2271. 	 
  2272. 	thread_kill(M01_group.heli_fighter1.thread) 
  2273. 	 
  2274. 	delay(3.0) 
  2275. end 
  2276.  
  2277. function m01_break_chains() 
  2278. 	-- Play creaking noise before cables break 
  2279. 	delay(5.0) 
  2280. 	 
  2281. 	-- big explosion!! 
  2282. 	camera_shake_play("explosion_large", 4.0) 
  2283. 	m01_players_set_vault_health(M01_player_health.break_chains) 
  2284. 	m01_play_next_vault_animations(M01_WAIT, M01_DO_NOT_INTERRUPT) 
  2285. 	 
  2286. 	M01_convo.vault_tipped.start = true 
  2287. 	 
  2288. 	-- change "seats" 
  2289. end 
  2290.  
  2291. function m01_shoot_most() 
  2292. 	delay(1.0) 
  2293. 	 
  2294. 	M01_group.heli_fighter1.thread = thread_new("m01_fly_direct_thread", M01_group.heli_fighter1.vehicle, M01_group.heli_fighter1.attack_path3, 30.0) 
  2295. 		 
  2296. 	-- another sniper	 
  2297. 	Helicopter_killed = false 
  2298. 	persona_override_persona_start(M01_group.heli_police1.members[1], M01_group.heli_police1.pilot_persona) 
  2299. 	m01_heli_move_to("sniper_heli_nav<002>", M01_group.heli_police1) 
  2300. 	turn_vulnerable( M01_group.heli_police1.vehicle ) 
  2301. 	on_damage("m01_crash_heli", M01_group.heli_police1.vehicle, M01_HELI_DAMAGE) 
  2302. 	ai_add_enemy_target(M01_group.heli_police1.shooter, LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE, true) 
  2303. 	delay(1.0) 
  2304. 	delay(5.0) 
  2305. 	audio_play_persona_line(M01_group.heli_police1.members[1], M01_group.heli_police1.persona_line) 
  2306. 	M01_group.heli_fighter1.damaged = false 
  2307. 	turn_vulnerable(M01_group.heli_fighter1.vehicle) 
  2308. 	marker_add(M01_group.heli_fighter1.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL) 
  2309. 	objective_text( 0, "M01_KILL_CHOPPER", "", "", SYNC_ALL, OI_ASSET_KILL )	 
  2310. 	on_damage("m01_attack_heli_damaged_cb", M01_group.heli_fighter1.vehicle, M01_group.heli_fighter1.damage3) 
  2311. 	-- allow more damage 
  2312. 	local total_hitpoints = get_max_hit_points(M01_group.heli_fighter1.vehicle) 
  2313. 	set_min_hit_points(M01_group.heli_fighter1.vehicle, (total_hitpoints * M01_group.heli_fighter1.damage3) - 10) 
  2314. 	 
  2315. 	M01_group.heli_fighter1.gunner_thread = thread_new("m01_attack_heli_gunner_thread", M01_group.heli_fighter1) 
  2316. 	M01_group.heli_fighter1.permission_to_fire = true 
  2317. 	 
  2318. 	delay(4.0) 
  2319. 	-- pilot is losing it 
  2320. 	audio_play_persona_line(M01_group.vault_heli.pilot, "M01_Helicopter_Going_Down_01") 
  2321. 	delay(4.0) 
  2322. 	audio_play_persona_line(M01_group.heli_fighter1.members[1], "M01_Bullhorn_Cables_Break") 
  2323. 	 
  2324. 	-- wait for heli damage 
  2325. 	while not M01_group.heli_fighter1.damaged do 
  2326. 		thread_yield() 
  2327. 	end 
  2328. 	marker_remove(M01_group.heli_fighter1.vehicle) 
  2329. 	objective_text( 0, "m01_survive", "", "", SYNC_ALL, OI_ASSET_DEFEND ) 
  2330. 	M01_group.heli_fighter1.permission_to_fire = false 
  2331. 	npc_combat_enable(M01_group.heli_fighter1.members[1], false)	 
  2332. 	npc_combat_enable(M01_group.heli_fighter1.members[2], false) 
  2333. 	 
  2334. 	-- That's enough damage 
  2335. 	turn_invulnerable(M01_group.heli_fighter1.vehicle) 
  2336. 	 
  2337. 	-- light it up 
  2338. 	vehicle_set_smoke_and_fire_state(M01_group.heli_fighter1.vehicle, true, false) 
  2339. 	 
  2340. 	-- do a little dance 
  2341. 	local anim_state = "" 
  2342. 	local anim_action = "heli trans21" 
  2343. 	audio_object_post_event("M01_Score_Z04_Transition") 
  2344. 	vehicle_anim_start(M01_group.heli_fighter1.vehicle, anim_state, anim_action) 
  2345. 	audio_play_persona_line(LOCAL_PLAYER, "M01_Shot_Down_Attack_Chopper") 
  2346. 	delay(0.5) 
  2347. 	while not vehicle_anim_finished(M01_group.heli_fighter1.vehicle, 0.9) do 
  2348. 		thread_yield() 
  2349. 	end 
  2350. end 
  2351.  
  2352. -- mission finale 
  2353. function m01_finale_scene() 
  2354.  
  2355. 	-- Stop the camera shake 
  2356. 	camera_shake_stop() 
  2357. 	 
  2358. 	-- stop threads that may cause problems with the cutscene 
  2359. 	thread_kill(M01_group.heli_police1.setup_thread) 
  2360. 	thread_kill(M01_group.heli_police1.thread) 
  2361. 	thread_kill(M01_group.heli_police2.setup_thread) 
  2362. 	thread_kill(M01_group.heli_police2.thread) 
  2363. 	thread_kill(M01_group.heli_fighter1.thread) 
  2364. 	thread_kill(M01_group.heli_fighter1.gunner_thread) 
  2365. 	thread_kill(M01_group.transport1.drop_off_thread) 
  2366. 	thread_kill(M01_group.transport1.setup_thread) 
  2367. 	thread_kill(M01_group.transport1.thread) 
  2368. 	thread_kill(M01_group.transport2.drop_off_thread) 
  2369. 	thread_kill(M01_group.transport2.setup_thread) 
  2370. 	thread_kill(M01_group.transport2.thread) 
  2371. 	thread_kill(M01_group.transport3.drop_off_thread) 
  2372. 	thread_kill(M01_group.transport3.setup_thread) 
  2373. 	thread_kill(M01_group.transport3.thread) 
  2374. 	thread_kill(M01_group.news_heli1.news_thread) 
  2375. 	thread_kill(M01_group.news_heli1.thread) 
  2376. 	thread_kill(M01_group.news_heli2.news_thread) 
  2377. 	thread_kill(M01_group.news_heli2.thread) 
  2378. 		 
  2379. 	audio_object_post_event("M01_Heli_Heist_Stop") 
  2380.  
  2381. end 
  2382.  
  2383. -- *************************************************** 
  2384. -- m01_run Helper Functions 
  2385. -- *************************************************** 
  2386.  
  2387.  
  2388. -- *************************************************** 
  2389. -- m01_initialize Helper Functions 
  2390. -- *************************************************** 
  2391.  
  2392. -- Turn on or off the spawning systems to speed things up 
  2393. -- 
  2394. -- enable_spawn: (bool) true to enable the spawns, false to disable the spawns 
  2395. -- 
  2396. function m01_do_ambient_spawns(enable_spawn) 
  2397. 	spawning_boats(enable_spawn) 
  2398. 	spawning_pedestrians(enable_spawn) 
  2399. 	spawning_vehicles(enable_spawn) 
  2400. end 
  2401.  
  2402. -- setup all of our hud states 
  2403. -- 
  2404. function m01_setup_hud_states() 
  2405.  
  2406. 	M01_hud_state.hide_minimap = hud_display_create_state() 
  2407. 	hud_display_set_element(M01_hud_state.hide_minimap, HUD_ELEM_MINIMAP, HUD_FADE_HIDDEN) 
  2408. 	-- hide minimap for the whole mission 
  2409. 	hud_display_commit_state(M01_hud_state.hide_minimap) 
  2410. end 
  2411.  
  2412. -- clear out all of the hud states 
  2413. function m01_clear_hud_states() 
  2414. 	for i, hud_state in pairs(M01_hud_state) do 
  2415. 		if (hud_state ~= -1) then 
  2416. 			hud_display_remove_state(hud_state) 
  2417. 			hud_state = -1 
  2418. 		end 
  2419. 	end 
  2420. end 
  2421.  
  2422. -- Handle any common initialization 
  2423. -- 
  2424. function m01_initialize_common() 
  2425. 	--[[ INSERT ANY COMMON INITIALIZATION CODE HERE ]]-- 
  2426. 	flashlights_disable() 
  2427. 	m01_set_player_loadout() 
  2428. 	 
  2429. 	M01_window_entry_melee_id = melee_get_move_id_from_name("Window Entry") 
  2430. 	 
  2431. 	team_make_allies("Police", "Morningstar") 
  2432. 	 
  2433. 	m01_setup_hud_states() 
  2434. 	 
  2435. 	-- Make it easy because Greg isn't that good 
  2436. 	character_set_damage_multiplier(LOCAL_PLAYER, 0.44) 
  2437. 	character_set_damage_multiplier(REMOTE_PLAYER, 0.44) 
  2438. end 
  2439.  
  2440. -- do swap stuff right away 
  2441. -- 
  2442. -- checkpoint:		The checkpoint to be initialized 
  2443. function m01_initialize_swaps(checkpoint) 
  2444.  
  2445. 	city_zone_swap(M01_zone_stilwater, true) 
  2446. 	if (checkpoint == M01_checkpoint.start.name) then	 
  2447. 		city_zone_swap(M01_zone_damaged_name, false) 
  2448. 		city_zone_swap(M01_zone_name, true) 
  2449. 	end 
  2450. 	 
  2451. 	if (checkpoint == M01_checkpoint.plant_bombs.name) then		 
  2452. 		-- swap! 
  2453. 		city_zone_swap(M01_zone_name, true) 
  2454. 	end 
  2455. 	 
  2456. 	if (checkpoint == M01_checkpoint.survive.name) then 
  2457. 		-- swap to damaged version of bank 
  2458. 		city_zone_swap(M01_zone_damaged_name, true) 
  2459. 	end 
  2460. 	 
  2461. 	if (checkpoint == M01_checkpoint.ride_vault.name) then 
  2462. 		-- swap to damaged version of bank 
  2463. 		city_zone_swap(M01_zone_damaged_name, true) 
  2464. 	end 
  2465. 	 
  2466. 	if (checkpoint == M01_checkpoint.debug_swaps.name) then 
  2467. 		-- swap to damaged version of bank 
  2468. 		city_zone_swap(M01_zone_name, true) 
  2469. 	end 
  2470. end 
  2471.  
  2472. -- Checkpoint specific initialization 
  2473. -- 
  2474. -- checkpoint:		The checkpoint to be initialized 
  2475. function m01_initialize_checkpoint(checkpoint) 
  2476. 	local lights_on = true 
  2477. 	local alarm_lights = false 
  2478. 	local animate_door = false 
  2479. 	door_close(M01_ELEVATOR_DOOR, animate_door) 
  2480. 	local locked = true 
  2481. 	door_lock(M01_ELEVATOR_DOOR, locked) 
  2482. 	if (checkpoint == M01_checkpoint.start.name) then	 
  2483. 		m01_start_emitters(M01_audio_emitter.office)	 
  2484. 		m01_start_emitters(M01_audio_emitter.bank_lobby) 
  2485. 		 
  2486. 		-- no hud until after animation	 
  2487. 		M01_hud_state.hide_everything = hud_display_create_state() 
  2488. 		hud_display_set_element(M01_hud_state.hide_everything, HUD_ALL_ELEM, HUD_FADE_HIDDEN) 
  2489. 		hud_display_commit_state(M01_hud_state.hide_everything) 
  2490. 		-- start by spawning everyone without blocking 
  2491. 		local block = true 
  2492. 		mesh_mover_reset("Horsie") 
  2493. 		mesh_mover_update_control("Horsie", "is statue broken", false) 
  2494. 		 
  2495. 		-- spawn guards and tellers 
  2496. 		group_create(M01_group.lobby.name, block) 
  2497. 		 
  2498. 		-- spawn my crew 
  2499. 		group_create(M01_group.start_homies.name, block) 
  2500. 		 
  2501. 		-- make sure Gat is ready before starting (or we error on animations) 
  2502. 		while not character_is_ready(M01_group.start_homies.gat) do 
  2503. 			thread_yield() 
  2504. 		end 
  2505. 		 
  2506. 		M01_thread.gat_hostage = thread_new("m01_take_hostage", M01_group.start_homies.gat, M01_group.start_homies.captive) 
  2507. 		 
  2508. 		-- setup my crew 
  2509. 		m01_setup_crew(M01_group.start_homies) 
  2510.  
  2511. 		npc_leash_to_nav( M01_group.start_homies.gat, M01_group.start_homies.captive_nav, 0.0 ) 
  2512. 		npc_leash_to_nav( M01_group.start_homies.captive, M01_group.start_homies.captive_nav, FLOOR_LEASH_RADIUS_METERS ) 
  2513. 		character_allow_ragdoll(M01_group.start_homies.gat, false) 
  2514. 		character_allow_ragdoll(M01_group.start_homies.captive, false) 
  2515. 		character_prevent_flinching(M01_group.start_homies.captive, true) 
  2516. 		character_prevent_flinching(M01_group.start_homies.gat, true) 
  2517. 		--character_take_human_shield(M01_group.start_homies.gat, M01_group.start_homies.captive) 
  2518. 				 
  2519. 		npc_leash_to_nav( M01_shaundi, "Shaundi_start_leash", 1.0 ) 
  2520. 		 
  2521. 		set_animation_state(LOCAL_PLAYER, "Mission 1 Start State") 
  2522. 		 
  2523. 		persona_override_persona_start(M01_group.start_homies.captive, "Interrogation") 
  2524. 		 
  2525. 		-- start with some pissed off guards 
  2526. 		notoriety_set_min_and_max("Police", 1, 1)	-- since we don't see it, just give enough to attack us 
  2527. 		notoriety_set_min_and_max("morningstar", 1, 1)	-- since we don't see it, just give enough to attack us 
  2528. 		thread_yield() 
  2529. 	else 
  2530. 		local reverse_door = true 
  2531. 		door_open(LOBBY_DOOR01, reverse_door) 
  2532. 		door_open(LOBBY_DOOR02, reverse_door) 
  2533. 	end 
  2534. 	 
  2535. 	if (checkpoint == M01_checkpoint.plant_bombs.name) then 
  2536. 		m01_start_emitters(M01_audio_emitter.office)	 
  2537. 		 
  2538. 		-- teleport players 
  2539. 		teleport_coop(M01_checkpoint.plant_bombs.nav1, M01_checkpoint.plant_bombs.nav2, true) 
  2540. 		 
  2541. 		-- Horse is broke 
  2542. 		mesh_mover_update_control("Horsie", "is statue broken", true) 
  2543. 		audio_object_post_event("M01_Checkpoint_Plant") 
  2544. 		 
  2545. 		--set_animation_state(LOCAL_PLAYER, "M01 Z01 Stand") 
  2546. 		 
  2547. 		-- spawn new homies 
  2548. 		group_create(M01_group.bomb_homies.name, true) 
  2549. 		m01_setup_crew(M01_group.bomb_homies) 
  2550. 		 
  2551. 		-- make Shaundi and Josh independent for their conversation 
  2552. 		follower_make_independent(M01_josh, true) 
  2553. 		follower_make_independent(M01_shaundi, true) 
  2554. 		 
  2555. 		notoriety_set_min_and_max("Police", 1, 1)	-- since we don't see it, just give enough to attack us 
  2556. 		notoriety_set_min_and_max("morningstar", 1, 1)	-- since we don't see it, just give enough to attack us 
  2557. 	end 
  2558. 	 
  2559. 	if (checkpoint == M01_checkpoint.survive.name) then		 
  2560. 		-- teleport players 
  2561. 		teleport_coop(M01_checkpoint.survive.nav1, M01_checkpoint.survive.nav2, true) 
  2562. 		 
  2563. 		-- spawn new homies 
  2564. 		group_create_hidden(M01_group.swat_homies.name, true)	 
  2565. 		M01_thread.homies_prep = thread_new("m01_homies_prep_thread") 
  2566. 		 
  2567. 		audio_object_post_event("M01_Office_Heli_Mute") 
  2568. 		m01_start_emitters(M01_audio_emitter.city_noise) 
  2569. 		audio_object_post_event("M01_Checkpoint_Survive") 
  2570. 		M01_thread.reset_movers = thread_new("m01_reset_movers_thread") 
  2571. 		 
  2572. 		alarm_lights = true 
  2573. 		 
  2574. 		notoriety_set_min_and_max("Police", 1, 1)	-- since we don't see it, just give enough to attack us 
  2575. 		notoriety_set_min_and_max("morningstar", 1, 1)	-- since we don't see it, just give enough to attack us 
  2576. 	end 
  2577. 	 
  2578. 	if (checkpoint == M01_checkpoint.ride_vault.name) then		 
  2579. 		-- teleport players 
  2580. 		teleport_coop(M01_checkpoint.ride_vault.nav1, M01_checkpoint.ride_vault.nav2, true) 
  2581. 		 
  2582. 		m01_start_emitters(M01_audio_emitter.city_noise) 
  2583. 		m01_start_emitters(M01_audio_emitter.vault_noise) 
  2584. 		audio_object_post_event("M01_Checkpoint_Ride_Vault") 
  2585. 		M01_thread.reset_movers = thread_new("m01_reset_movers_thread") 
  2586. 		 
  2587. 		-- run setup parts sequentially 
  2588. 		m01_vault_setup_part1_thread() 
  2589. 		m01_vault_setup_part2_thread() 
  2590. 		 
  2591. 		-- only checkpoint to start with the lights off 
  2592. 		lights_on = false 
  2593. 		alarm_lights = true		 
  2594. 		 
  2595. 		notoriety_set_min_and_max("Police", 1, 1)	-- since we don't see it, just give enough to attack us 
  2596. 		notoriety_set_min_and_max("morningstar", 1, 1)	-- since we don't see it, just give enough to attack us 
  2597. 	end 
  2598. 	 
  2599. 	if (checkpoint == M01_checkpoint.debug_swaps.name) then		 
  2600. 		-- teleport players 
  2601. 		teleport_coop(M01_checkpoint.debug_swaps.nav1, M01_checkpoint.debug_swaps.nav2, true) 
  2602. 	end 
  2603. 	 
  2604. 	m01_setup_light_group(M01_light_group.alarm) 
  2605. 	m01_alarm_lights(alarm_lights) 
  2606.  
  2607. end 
  2608.  
  2609. -- setup script light groups 
  2610. -- 
  2611. -- light_group_table:	(table) info about light group 
  2612. -- 
  2613. function m01_setup_light_group(light_group_table) 
  2614. 	if light_group_table.name ~= "" then 
  2615. 		light_group_set_intensity(light_group_table.name, light_group_table.intensity) 
  2616. 	end 
  2617. end 
  2618.  
  2619. -- Turn the lights on or off 
  2620. -- 
  2621. -- lights_on:		(bool) true to turn lights on, false to turn lights off 
  2622. -- 
  2623. function m01_set_lights_on(lights_on)	 
  2624. 	-- This looks a bit confusing 
  2625. 	--		The scripted intensity is 0.0.  Using this intenstiy esentially turns off that light. 
  2626. 	--		If the lights are on, 'light' set has normal intensity and 'dark' set has 0 intensity	 
  2627. 	local set_intensity_to_0 = false --not lights_on 
  2628. 	if M01_light_group.light.name ~= "" then 
  2629. 		light_group_use_intensity(M01_light_group.light.name, set_intensity_to_0) 
  2630. 	end 
  2631. end 
  2632.  
  2633. -- Turn on or off the alarm lights 
  2634. -- 
  2635. -- turn_on:		(bool) true to turn alarm lights on, false to turn them off 
  2636. function m01_alarm_lights(turn_on) 
  2637. 	local set_intensity_to_0 = not turn_on 
  2638. 	if M01_light_group.alarm.name ~= "" then 
  2639. 		light_group_use_intensity(M01_light_group.alarm.name, set_intensity_to_0) 
  2640. 	end 
  2641. end 
  2642.  
  2643. -- turn off all of the script intensity before you leave 
  2644. function m01_all_lights_off() 
  2645. 	local lights_on = false 
  2646. 	for i,light in pairs(M01_light_group) do 
  2647. 		if light.name ~= "" then 
  2648. 			light_group_use_intensity(light.name, lights_on) 
  2649. 		end 
  2650. 	end 
  2651. end 
  2652.  
  2653. -- setup followers as necessary 
  2654. function m01_setup_crew( homie_table ) 
  2655. 	party_add( homie_table.gat, LOCAL_PLAYER ) 
  2656. 	on_death("m01_failure_gat_died", homie_table.gat) 
  2657. 	turn_invulnerable(homie_table.gat) 
  2658. 	M01_gat = homie_table.gat 
  2659. 	if homie_table.gat_bobble then 
  2660. 		character_add_prop(homie_table.gat, "bobblehead_gat") 
  2661. 		character_add_prop(homie_table.gat, "voice_modulator_gat") 
  2662. 	end 
  2663. 	 
  2664. 	-- in coop, remote gets Shaundi 
  2665. 	if coop_is_active() then 
  2666. 		party_add( homie_table.shaundi, REMOTE_PLAYER ) 
  2667. 	else 
  2668. 		party_add( homie_table.shaundi, LOCAL_PLAYER ) 
  2669. 	end 
  2670. 	on_death("m01_failure_shaundi_died", homie_table.shaundi) 
  2671. 	turn_invulnerable(homie_table.shaundi) 
  2672. 	if homie_table.shaundi_bobble then 
  2673. 		character_add_prop(homie_table.shaundi, "bobblehead_shaundi") 
  2674. 		character_add_prop(homie_table.shaundi, "voice_modulator_shaundi") 
  2675. 	end 
  2676. 	M01_shaundi = homie_table.shaundi 
  2677.  
  2678. 	-- Josh might have left 
  2679. 	if homie_table.josh ~= "" then 
  2680. 		party_add( homie_table.josh, LOCAL_PLAYER ) 
  2681. 		turn_invulnerable(homie_table.josh) 
  2682. 		on_death("m01_failure_josh_died", homie_table.josh) 
  2683. 		inv_item_dual_wield(homie_table.josh, WEAPON_SLOT_PISTOL) 
  2684. 		if homie_table.josh_bobble then 
  2685. 			character_add_prop(homie_table.josh, "bobblehead_josh") 
  2686. 			character_add_prop(homie_table.josh, "voice_modulator_josh") 
  2687. 		end 
  2688. 		character_add_prop(homie_table.josh, "Josh_DuffelBag") 
  2689. 		-- Josh is no combat EVAR! 
  2690. 		npc_combat_enable(homie_table.josh, false) 
  2691. 	end 
  2692. 	M01_josh = homie_table.josh 
  2693. 	 
  2694. end 
  2695.  
  2696. -- clear followers as necessary 
  2697. function m01_clear_crew( homie_table ) 
  2698. 	on_death("", homie_table.gat) 
  2699. 	on_attack_performed("", homie_table.gat) 
  2700. 	on_death("", homie_table.shaundi) 
  2701. 	 
  2702. 	-- Josh might have left 
  2703. 	if homie_table.josh ~= "" then 
  2704. 		on_death("", homie_table.josh) 
  2705. 	end 
  2706. end 
  2707.  
  2708. -- teleport followers to a set of navpoints 
  2709. function m01_teleport_crew( homie_table, navs )	 
  2710. 	teleport(homie_table.gat, navs[1]) 
  2711. 	teleport(homie_table.shaundi, navs[2]) 
  2712. 	 
  2713. 	if homie_table.josh ~= "" then 
  2714. 		teleport(homie_table.josh, navs[3]) 
  2715. 	end 
  2716. end 
  2717.  
  2718. -- set crew to ignore ai (to say lines) 
  2719. function m01_dumb_crew( homie_table ) 
  2720. 	set_ignore_ai_flag( homie_table.gat, true ) 
  2721. 	set_ignore_ai_flag( homie_table.shaundi, true ) 
  2722. 	 
  2723. 	if homie_table.josh ~= "" then 
  2724. 		set_ignore_ai_flag( homie_table.josh, true ) 
  2725. 	end 
  2726. end 
  2727.  
  2728. -- recall crew back to your side 
  2729. function recall_crew() 
  2730. 	-- only care about Gat and Shaundi.  Josh does his own thing 
  2731. 	thread_kill(M01_thread.shaundi_move)	 
  2732. 	follower_make_independent(M01_shaundi, false) 
  2733. 	ai_clear_scripted_action(M01_shaundi) 
  2734. 	ai_clear_priority_target(M01_shaundi) 
  2735. 	ai_set_personality(M01_shaundi, "gang normal") 
  2736. 	ai_set_in_scripted_cover(M01_shaundi, false) 
  2737. 	npc_leash_remove(M01_shaundi) 
  2738. 	 
  2739. 	thread_kill(M01_thread.gat_move) 
  2740. 	follower_make_independent(M01_gat, false) 
  2741. 	ai_clear_scripted_action(M01_gat) 
  2742. 	ai_clear_priority_target(M01_gat) 
  2743. 	ai_set_personality(M01_gat, "gang normal") 
  2744. 	ai_set_in_scripted_cover(M01_gat, false) 
  2745. 	npc_leash_remove(M01_gat) 
  2746. 	 
  2747. 	thread_yield() 
  2748. end 
  2749.  
  2750. -- *************************************************** 
  2751. -- Miscellaneous m01 Helper Funcrtions 
  2752. -- *************************************************** 
  2753.  
  2754. function m01_set_player_loadout() 
  2755. 	-- Clear out what you have.  You only get what we give you 
  2756. 	inv_item_remove_all(LOCAL_PLAYER) 
  2757.  
  2758. 	local magazines = 1 
  2759. 	local unlimited = true 
  2760. 	local equip_now = false 
  2761. 	local dual_wield = false 
  2762. 	local force_override = false 
  2763. 	inv_weapon_add_temporary(LOCAL_PLAYER, M01_PLAYER_PISTOL, magazines, unlimited, equip_now, dual_wield, force_override, M01_PLAYER_PISTOL_UPGRADES) 
  2764. 	inv_weapon_add_temporary(LOCAL_PLAYER, M01_PLAYER_SHOTGUN, magazines, unlimited, equip_now, dual_wield, force_override, M01_PLAYER_SHOTGUN_UPGRADES) 
  2765. 	inv_weapon_add_temporary(LOCAL_PLAYER, M01_PLAYER_RIFLE, magazines, unlimited, true, dual_wield, force_override, M01_PLAYER_RIFLE_UPGRADES) 
  2766. 	inv_weapon_add_temporary(LOCAL_PLAYER, M01_PLAYER_SMG, magazines, unlimited, equip_now, dual_wield, force_override) 
  2767. 	--inv_weapon_add_temporary(LOCAL_PLAYER, M01_PLAYER_GRENADE, magazines, false, equip_now, dual_wield) 
  2768.  
  2769. 	if coop_is_active() then 
  2770. 		inv_item_remove_all(REMOTE_PLAYER) 
  2771. 		inv_weapon_add_temporary(REMOTE_PLAYER, M01_PLAYER_PISTOL, magazines, unlimited, equip_now, dual_wield, force_override, M01_PLAYER_PISTOL_UPGRADES) 
  2772. 		inv_weapon_add_temporary(REMOTE_PLAYER, M01_PLAYER_SHOTGUN, magazines, unlimited, equip_now, dual_wield, force_override, M01_PLAYER_SHOTGUN_UPGRADES) 
  2773. 		inv_weapon_add_temporary(REMOTE_PLAYER, M01_PLAYER_RIFLE, magazines, unlimited, true, dual_wield, force_override, M01_PLAYER_RIFLE_UPGRADES) 
  2774. 		inv_weapon_add_temporary(REMOTE_PLAYER, M01_PLAYER_SMG, magazines, unlimited, equip_now, dual_wield, force_override) 
  2775. 		--inv_weapon_add_temporary(REMOTE_PLAYER, M01_PLAYER_GRENADE, magazines, false, equip_now, dual_wield) 
  2776. 	end 
  2777. end 
  2778.  
  2779. -- remove all of the player's temp weapons 
  2780. function m01_clear_player_loadout() 
  2781. 	inv_weapon_remove_temporary(LOCAL_PLAYER, M01_PLAYER_PISTOL) 
  2782. 	inv_weapon_remove_temporary(LOCAL_PLAYER, M01_PLAYER_SHOTGUN) 
  2783. 	inv_weapon_remove_temporary(LOCAL_PLAYER, M01_PLAYER_RIFLE) 
  2784. 	inv_weapon_remove_temporary(LOCAL_PLAYER, M01_PLAYER_SMG) 
  2785. 	--inv_weapon_remove_temporary(LOCAL_PLAYER, M01_PLAYER_GRENADE) 
  2786. 	 
  2787. 	if coop_is_active() then 
  2788. 		inv_weapon_remove_temporary(REMOTE_PLAYER, M01_PLAYER_PISTOL) 
  2789. 		inv_weapon_remove_temporary(REMOTE_PLAYER, M01_PLAYER_SHOTGUN) 
  2790. 		inv_weapon_remove_temporary(REMOTE_PLAYER, M01_PLAYER_RIFLE) 
  2791. 		inv_weapon_remove_temporary(REMOTE_PLAYER, M01_PLAYER_SMG) 
  2792. 		--inv_weapon_remove_temporary(REMOTE_PLAYER, M01_PLAYER_GRENADE) 
  2793. 	end 
  2794. end 
  2795. 	 
  2796. -- set a group to not flee or cower (used so peds act like cops) 
  2797. -- 
  2798. -- group_table:		(table) information about the group 
  2799. function m01_group_no_flee_or_cower(group_table) 
  2800. 	for i,npc in pairs(group_table) do 
  2801. 		set_cant_cower_flag(npc, true) 
  2802. 		set_cant_flee_flag(npc, true) 
  2803. 		set_behavior_set(npc, "Civilian Rifle") 
  2804. 		set_team(npc, "Police") 
  2805. 		ai_add_enemy_target(npc, LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE)	 
  2806. 		if coop_is_active() then 
  2807. 			ai_add_enemy_target(npc, LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE)	 
  2808. 		end 
  2809. 	end 
  2810. end 
  2811.  
  2812. function m01_clear_tutorial(force_kill) 
  2813. 	if tutorial_queued("combat_fineaim") then 
  2814. 		-- Tutorial is waiting to be played. Just remove it. 
  2815. 		tutorial_stop("combat_fineaim") 
  2816. 	elseif tutorial_active("combat_fineaim") then 
  2817. 		-- Let the tutorial play out if possible (not waiting for a trigger) 
  2818. 		if tutorial_get_case("combat_fineaim") == 0 or force_kill then 
  2819. 			tutorial_stop("combat_fineaim") 
  2820. 		end 
  2821. 	end 
  2822. 	 
  2823. 	if M01_TUTORIAL_FINEAIM ~= INVALID_THREAD_HANDLE then 
  2824. 		thread_kill(M01_TUTORIAL_FINEAIM) 
  2825. 		M01_TUTORIAL_FINEAIM = INVALID_THREAD_HANDLE 
  2826. 	end 
  2827. 	 
  2828. 	if tutorial_queued("combat_weapons") then 
  2829. 		tutorial_stop("combat_weapons") 
  2830. 	elseif tutorial_active("combat_weapons") then 
  2831. 		-- Let the tutorial play out if possible (not waiting for a trigger) 
  2832. 		if tutorial_get_case("combat_weapons") == 0 or force_kill then 
  2833. 			tutorial_stop("combat_weapons") 
  2834. 		end 
  2835. 	end 
  2836. 	 
  2837. 	if M01_TUTORIAL_SWITCH_WEAPON ~= INVALID_THREAD_HANDLE then 
  2838. 		thread_kill(M01_TUTORIAL_SWITCH_WEAPON) 
  2839. 		M01_TUTORIAL_SWITCH_WEAPON = INVALID_THREAD_HANDLE 
  2840. 	end 
  2841.  
  2842. 	on_weapon_equip("", LOCAL_PLAYER) 
  2843. end 
  2844.  
  2845. -- End all conversations 
  2846. function m01_end_conversations()	 
  2847. 	for i,convo in pairs(M01_convo) do 
  2848. 		if convo.handle ~= INVALID_CONVERSATION_HANDLE then 
  2849. 			audio_conversation_end(convo.handle) 
  2850. 			convo.handle = INVALID_CONVERSATION_HANDLE 
  2851. 		end 
  2852. 	end 
  2853. end 
  2854.  
  2855. function m01_cleanup_first_checkpoint_groups() 
  2856. 	thread_kill(M01_shaundi_attack.thread) 
  2857. 	 
  2858. 	if group_is_loaded(M01_group.lobby.name) then 
  2859. 		group_destroy(M01_group.lobby.name) 
  2860. 	end 
  2861. 	if group_is_loaded(M01_group.lobby_cower.name) then 
  2862. 		persona_override_persona_stop(M01_group.lobby_cower.saints_fan) 
  2863. 		group_destroy(M01_group.lobby_cower.name) 
  2864. 	end 
  2865. 	if group_is_loaded(M01_group.lobby2.name) then 
  2866. 		group_destroy(M01_group.lobby2.name) 
  2867. 	end 
  2868. 	if group_is_loaded(M01_group.lobby3.name) then 
  2869. 		group_destroy(M01_group.lobby3.name) 
  2870. 	end 
  2871. 	if group_is_loaded(M01_group.fine_aim.name) then 
  2872. 		m01_clear_see_saints(M01_group.fine_aim.members) 
  2873. 		group_destroy(M01_group.fine_aim.name) 
  2874. 	end 
  2875. 	if group_is_loaded(M01_group.second_floor.name) then 
  2876. 		m01_clear_see_saints(M01_group.second_floor.members) 
  2877. 		group_destroy(M01_group.second_floor.name) 
  2878. 	end 
  2879. 	if group_is_loaded(M01_group.third_floor.name) then 
  2880. 		group_destroy(M01_group.third_floor.name) 
  2881. 	end	 
  2882. 	if group_is_loaded(M01_group.news_heli2.name) then 
  2883. 		thread_kill(M01_group.news_heli2.news_thread) 
  2884. 		thread_kill(M01_group.news_heli2.thread) 
  2885. 		group_destroy(M01_group.news_heli2.name) 
  2886. 	end	 
  2887. end 
  2888.  
  2889. function m01_cleanup_first_checkpoint_crew() 
  2890. 	if group_is_loaded(M01_group.start_homies.name) then 
  2891. 		persona_override_persona_stop(M01_group.start_homies.captive) 
  2892. 		m01_clear_crew(M01_group.start_homies) 
  2893. 		group_destroy(M01_group.start_homies.name) 
  2894. 	end 
  2895. end 
  2896.  
  2897. function m01_cleanup_second_checkpoint_groups() 
  2898. 	if group_is_loaded(M01_group.bomb_security2.name) then 
  2899. 		m01_clear_see_saints(M01_group.bomb_security2.members) 
  2900. 		group_destroy(M01_group.bomb_security2.name) 
  2901. 	end	 
  2902. 	 
  2903. 	if group_is_loaded(M01_group.bomb_cower.name) then 
  2904. 		group_destroy(M01_group.bomb_cower.name) 
  2905. 	end 
  2906. 	 
  2907. 	if group_is_loaded(M01_group.bomb_flee.name) then 
  2908. 		group_destroy(M01_group.bomb_flee.name) 
  2909. 	end 
  2910. 	 
  2911. 	if group_is_loaded(M01_group.autograph.name) then 
  2912. 		if (M01_group.autograph.effect_handle ~= -1) then 
  2913. 			effect_stop(M01_group.autograph.effect_handle) 
  2914. 			M01_group.autograph.effect_handle = -1 
  2915. 		end 
  2916. 		m01_clear_trigger(M01_group.autograph.trigger) 
  2917. 		thread_kill(M01_group.autograph.thread) 
  2918. 		on_death("", M01_group.autograph.guy) 
  2919. 		on_take_damage("", M01_group.autograph.guy) 
  2920. 		group_destroy(M01_group.autograph.name) 
  2921. 	end 
  2922. end 
  2923.  
  2924. function m01_cleanup_second_checkpoint_crew() 
  2925. 	if group_is_loaded(M01_group.bomb_homies.name) then 
  2926. 		m01_clear_crew(M01_group.bomb_homies) 
  2927. 		group_destroy(M01_group.bomb_homies.name) 
  2928. 	end 
  2929. end 
  2930.  
  2931. function m01_cleanup_cop_wave_groups() 
  2932. 	if group_is_loaded(M01_group.rope.name) then 
  2933. 		group_destroy(M01_group.rope.name) 
  2934. 	end 
  2935. 	if group_is_loaded(M01_group.swat1_pair.name) then 
  2936. 		on_attack_performed("", M01_group.swat1_pair.members[1]) 
  2937. 		on_attack_performed("", M01_group.swat1_pair.members[2]) 
  2938. 		group_destroy(M01_group.swat1_pair.name) 
  2939. 	end 
  2940. 	if group_is_loaded(M01_group.swat2_pair.name) then 
  2941. 		on_attack_performed("", M01_group.swat2_pair.members[1]) 
  2942. 		on_attack_performed("", M01_group.swat2_pair.members[2]) 
  2943. 		group_destroy(M01_group.swat2_pair.name) 
  2944. 	end 
  2945. 	if group_is_loaded(M01_group.swat3_pair.name) then 
  2946. 		on_attack_performed("", M01_group.swat3_pair.members[1]) 
  2947. 		on_attack_performed("", M01_group.swat3_pair.members[2]) 
  2948. 		group_destroy(M01_group.swat3_pair.name) 
  2949. 	end 
  2950. 	if group_is_loaded(M01_group.swat4_pair.name) then 
  2951. 		on_attack_performed("", M01_group.swat4_pair.members[1]) 
  2952. 		on_attack_performed("", M01_group.swat4_pair.members[2]) 
  2953. 		group_destroy(M01_group.swat4_pair.name) 
  2954. 	end 
  2955. 	if group_is_loaded(M01_group.swat5_pair.name) then 
  2956. 		on_attack_performed("", M01_group.swat5_pair.members[1]) 
  2957. 		on_attack_performed("", M01_group.swat5_pair.members[2]) 
  2958. 		group_destroy(M01_group.swat5_pair.name) 
  2959. 	end 
  2960. 	if group_is_loaded(M01_group.swat_riot_pair.name) then 
  2961. 		on_attack_performed("", M01_group.swat_riot_pair.members[1]) 
  2962. 		on_attack_performed("", M01_group.swat_riot_pair.members[2]) 
  2963. 		group_destroy(M01_group.swat_riot_pair.name) 
  2964. 	end	 
  2965. 	if group_is_loaded(M01_group.news_heli1.name) then 
  2966. 		thread_kill(M01_group.news_heli1.news_thread) 
  2967. 		thread_kill(M01_group.news_heli1.thread) 
  2968. 		group_destroy(M01_group.news_heli1.name) 
  2969. 	end	 
  2970. 	if group_is_loaded(M01_group.news_heli2.name) then 
  2971. 		thread_kill(M01_group.news_heli2.news_thread) 
  2972. 		thread_kill(M01_group.news_heli2.thread) 
  2973. 		group_destroy(M01_group.news_heli2.name) 
  2974. 	end	 
  2975. end 
  2976.  
  2977. function m01_cleanup_swat_crew() 
  2978. 	if group_is_loaded(M01_group.swat_homies.name) then 
  2979. 		m01_clear_crew(M01_group.swat_homies) 
  2980. 		group_destroy(M01_group.swat_homies.name) 
  2981. 	end 
  2982. end 
  2983.  
  2984. function m01_cleanup_final_checkpoint_groups() 
  2985. 	if group_is_loaded(M01_group.vault_heli.name) then 
  2986. 		persona_override_persona_stop(M01_group.vault_heli.pilot) 
  2987. 		group_destroy(M01_group.vault_heli.name) 
  2988. 	end 
  2989. 	if group_is_loaded(M01_group.vault_attackers2.name) then 
  2990. 		group_destroy(M01_group.vault_attackers2.name) 
  2991. 	end 
  2992. 	if group_is_loaded(M01_group.roof2.name) then 
  2993. 		group_destroy(M01_group.roof2.name) 
  2994. 	end 
  2995. 	if group_is_loaded(M01_HELI_SHOOTER_GROUP) then 
  2996. 		group_destroy(M01_HELI_SHOOTER_GROUP) 
  2997. 	end	 
  2998. 	if group_is_loaded(M01_group.heli_police1.name) then 
  2999. 		persona_override_persona_stop(M01_group.heli_police1.members[1]) 
  3000. 		on_damage("", M01_group.heli_police1.vehicle, 0.99) 
  3001. 		thread_kill(M01_group.heli_police1.setup_thread) 
  3002. 		thread_kill(M01_group.heli_police1.thread) 
  3003. 		group_destroy(M01_group.heli_police1.name) 
  3004. 	end	 
  3005. 	if group_is_loaded(M01_group.heli_police2.name) then 
  3006. 		persona_override_persona_stop(M01_group.heli_police2.members[1]) 
  3007. 		on_damage("", M01_group.heli_police2.vehicle, 0.99) 
  3008. 		thread_kill(M01_group.heli_police2.setup_thread) 
  3009. 		thread_kill(M01_group.heli_police2.thread) 
  3010. 		group_destroy(M01_group.heli_police2.name) 
  3011. 	end	 
  3012. 	if group_is_loaded(M01_group.heli_fighter1.name) then 
  3013. 		persona_override_persona_stop(M01_group.heli_fighter1.members[1]) 
  3014. 		on_damage("", M01_group.heli_fighter1.vehicle, 0.99) 
  3015. 		thread_kill(M01_group.heli_fighter1.thread) 
  3016. 		thread_kill(M01_group.heli_fighter1.gunner_thread) 
  3017. 		group_destroy(M01_group.heli_fighter1.name) 
  3018. 	end	 
  3019. 	if group_is_loaded(M01_group.roof1_pair.name) then 
  3020. 		group_destroy(M01_group.roof1_pair.name) 
  3021. 	end 
  3022. 	if group_is_loaded(M01_group.roof2_pair.name) then 
  3023. 		group_destroy(M01_group.roof2_pair.name) 
  3024. 	end 
  3025. 	if group_is_loaded(M01_group.roof3_pair.name) then 
  3026. 		group_destroy(M01_group.roof3_pair.name) 
  3027. 	end 
  3028. 	if group_is_loaded(M01_group.roof4_pair.name) then 
  3029. 		group_destroy(M01_group.roof4_pair.name) 
  3030. 	end 
  3031. 	if group_is_loaded(M01_group.roof5_pair.name) then 
  3032. 		group_destroy(M01_group.roof5_pair.name) 
  3033. 	end 
  3034. 	if group_is_loaded(M01_group.transport1.name) then 
  3035. 		persona_override_persona_stop(M01_group.transport1.pilots[1]) 
  3036. 		thread_kill(M01_group.transport1.drop_off_thread) 
  3037. 		thread_kill(M01_group.transport1.setup_thread) 
  3038. 		thread_kill(M01_group.transport1.thread) 
  3039. 		on_vehicle_destroyed("", M01_group.transport1.vehicle) 
  3040. 		group_destroy(M01_group.transport1.name) 
  3041. 	end		 
  3042. 	if group_is_loaded(M01_group.transport2.name) then 
  3043. 		persona_override_persona_stop(M01_group.transport2.pilots[1]) 
  3044. 		thread_kill(M01_group.transport2.drop_off_thread) 
  3045. 		thread_kill(M01_group.transport2.setup_thread) 
  3046. 		thread_kill(M01_group.transport2.thread) 
  3047. 		on_vehicle_destroyed("", M01_group.transport2.vehicle) 
  3048. 		group_destroy(M01_group.transport2.name) 
  3049. 	end	 
  3050. 	if group_is_loaded(M01_group.transport3.name) then 
  3051. 		persona_override_persona_stop(M01_group.transport3.pilots[1]) 
  3052. 		thread_kill(M01_group.transport3.drop_off_thread) 
  3053. 		thread_kill(M01_group.transport3.setup_thread) 
  3054. 		thread_kill(M01_group.transport3.thread) 
  3055. 		on_vehicle_destroyed("", M01_group.transport3.vehicle) 
  3056. 		group_destroy(M01_group.transport3.name) 
  3057. 	end	 
  3058. 	if group_is_loaded(M01_group.news_heli1.name) then 
  3059. 		thread_kill(M01_group.news_heli1.news_thread) 
  3060. 		thread_kill(M01_group.news_heli1.thread) 
  3061. 		group_destroy(M01_group.news_heli1.name) 
  3062. 	end	 
  3063. 	if group_is_loaded(M01_group.news_heli2.name) then 
  3064. 		thread_kill(M01_group.news_heli2.news_thread) 
  3065. 		thread_kill(M01_group.news_heli2.thread) 
  3066. 		group_destroy(M01_group.news_heli2.name) 
  3067. 	end	 
  3068. end 
  3069.  
  3070. -- Set a trigger enabled with a mission marker 
  3071. -- 
  3072. -- trigger:					(string) Name of the trigger 
  3073. -- trigger_callback:		(string) Function name to call when trigger is activated 
  3074. -- 
  3075. function m01_set_trigger(trigger, trigger_callback) 
  3076. 	trigger_enable(trigger, true) 
  3077. 	-- marker_add_trigger(trigger, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  3078. 	on_trigger(trigger_callback, trigger) 
  3079. end 
  3080.  
  3081. -- Disable trigger 
  3082. -- 
  3083. -- trigger:			(string) Name of the trigger 
  3084. -- 
  3085. function m01_clear_trigger(trigger) 
  3086. 	on_trigger("", trigger) 
  3087. 	trigger_enable(trigger, false) 
  3088. 	marker_remove_trigger(trigger, SYNC_ALL) 
  3089. 	mission_waypoint_remove() 
  3090. end 
  3091.  
  3092. -- Move police heli to a navpoint 
  3093. -- 
  3094. -- go_here:		(string) navpoint name to move to 
  3095. -- heli_group:	(table) heli group table 
  3096. -- 
  3097. function m01_heli_move_to(go_here, heli_group) 
  3098. 	-- kill this thread if currently active (we gotta go somewhere else) 
  3099. 	thread_kill(heli_group.thread) 
  3100. 	 
  3101. 	heli_group.thread = thread_new("m01_fly_direct_thread", heli_group.vehicle, go_here, 45.0) 
  3102. end 
  3103.  
  3104. -- Teleport and float a heli at a navpoint 
  3105. -- 
  3106. -- heli_table:	(table) helicopter table info 
  3107. -- float_nav:	(string) name of navpoint to float at 
  3108. function m01_float_heli(heli_table, float_nav) 
  3109. 	-- teleport heli into position 
  3110. 	teleport_vehicle(heli_table.vehicle, float_nav) 
  3111. 	 
  3112. 	-- wait for that 
  3113. 	thread_yield() 
  3114. 	 
  3115. 	-- tell choppers to move there so they stay in place 
  3116. 	m01_heli_move_to(float_nav, heli_table)		 
  3117. end 
  3118.  
  3119. -- tell the attack heli to fire at the vault 
  3120. -- 
  3121. -- hit_delay:	(float) time to wait for missiles to "hit" 
  3122. function m01_fighter_shoot_vault(hit_delay) 
  3123.  
  3124. 	npc_combat_enable(M01_group.heli_fighter1.members[1], true) 
  3125. 	npc_combat_enable(M01_group.heli_fighter1.members[2], true)	 
  3126. 	 
  3127. 	while not helicopter_shoot_human(M01_group.heli_fighter1.vehicle, M01_group.vault_heli.pilot, false) do  
  3128. 		thread_yield() 
  3129. 	end 
  3130. 	 
  3131. 	-- no more shooting 
  3132. 	npc_combat_enable(M01_group.heli_fighter1.members[1], false) 
  3133. 	npc_combat_enable(M01_group.heli_fighter1.members[2], false)	 
  3134. 	 
  3135. 	-- wait for missiles to hit 
  3136. 	delay(hit_delay) 
  3137.  
  3138. 	-- explosions 
  3139. 	camera_shake_play("explosion_large", 4.0) 
  3140. end 
  3141.  
  3142. -- Do the drop-off sequence 
  3143. -- 
  3144. -- transport_table:	(table) transportatiion information 
  3145. -- 
  3146. function m01_do_transport(transport_table) 
  3147. 	-- make sure we aren't doing something else 
  3148. 	thread_kill(transport_table.thread) 
  3149. 	 
  3150. 	transport_table.drop_off_thread = thread_new("m01_transport_drop_off_thread", transport_table) 
  3151. end 
  3152.  
  3153. -- setup health on the players so we control how much damage he takes 
  3154. function m01_players_start_vault_health() 
  3155. 	-- beef them up 
  3156. 	local max_hp = get_max_hit_points(LOCAL_PLAYER) 
  3157. 	set_current_hit_points(LOCAL_PLAYER, max_hp) 
  3158. 	if coop_is_active() then 
  3159. 		set_current_hit_points(REMOTE_PLAYER, max_hp) 
  3160. 	end 
  3161. 	-- only I will kill you 
  3162. 	turn_invulnerable(LOCAL_PLAYER) 
  3163. 	if coop_is_active() then 
  3164. 		turn_invulnerable(REMOTE_PLAYER) 
  3165. 	end 
  3166. 	-- Only I will give you life 
  3167. 	character_dont_regenerate(LOCAL_PLAYER, true) 
  3168. 	if coop_is_active() then 
  3169. 		character_dont_regenerate(REMOTE_PLAYER, true) 
  3170. 	end 
  3171. end 
  3172.  
  3173. -- ok, back to normal, nothing to see here 
  3174. function m01_players_stop_vault_health() 
  3175. 	-- die freely 
  3176. 	turn_vulnerable(LOCAL_PLAYER) 
  3177. 	if coop_is_active() then 
  3178. 		turn_vulnerable(REMOTE_PLAYER) 
  3179. 	end 
  3180. 	-- Regen again 
  3181. 	character_dont_regenerate(LOCAL_PLAYER, false) 
  3182. 	if coop_is_active() then 
  3183. 		character_dont_regenerate(REMOTE_PLAYER, false) 
  3184. 	end 
  3185. end 
  3186.  
  3187. -- set player's health 
  3188. -- 
  3189. -- health_pct:	(float) percentage of health for players to go to 
  3190. function m01_players_set_vault_health(health_pct) 
  3191. 	local max_hp = get_max_hit_points(LOCAL_PLAYER) 
  3192. 	local new_hp = max_hp * health_pct 
  3193. 	set_current_hit_points(LOCAL_PLAYER, new_hp) 
  3194. 	if coop_is_active() then 
  3195. 		set_current_hit_points(REMOTE_PLAYER, new_hp) 
  3196. 	end 
  3197. end 
  3198.  
  3199. -- unleash and move to navpoint 
  3200. function m01_swat_backup(guard_table, nav_table) 
  3201.  
  3202. 	for i, guard in pairs(guard_table) do 
  3203. 		npc_leash_remove( guard ) 
  3204. 		ai_do_scripted_move(guard, nav_table[i]) 
  3205. 	end 
  3206. end 
  3207.  
  3208. -- every half-second check to see if someone in the group is still alive 
  3209. function m01_delay_or_dead(wait_time, group_table) 
  3210. 	local time_elapsed = 0.0 
  3211. 	delay(0.5) 
  3212. 	time_elapsed = time_elapsed + 0.5 
  3213. 	 
  3214. 	while (time_elapsed < wait_time) do 
  3215. 		local alive = false 
  3216. 		for i, enemy in pairs(group_table) do 
  3217. 			if(not alive) and (not character_is_dead(enemy)) then 
  3218. 				alive = true 
  3219. 			end 
  3220. 		end 
  3221. 		 
  3222. 		if not alive then 
  3223. 			-- if everyone is dead, exit early 
  3224. 			time_elapsed = wait_time 
  3225. 		else 
  3226. 			delay(0.5) 
  3227. 			time_elapsed = time_elapsed + 0.5 
  3228. 		end 
  3229. 	end 
  3230. end 
  3231. 	 
  3232. -- Play the next vault animations 
  3233. -- Handle all animations while on the vault including 
  3234. --			vault vehicle animations 
  3235. --			vfx 
  3236. --			player animations 
  3237. --			player animation state changes 
  3238. -- 
  3239. -- wait:			(bool) true to wait for the vehicle actions to complete 
  3240. -- interrupt:	(bool) true to possibly interrupt a playing animation 
  3241. function m01_play_next_vault_animations(wait, interrupt) 
  3242. 	action_sequence_advance(interrupt) 
  3243. 	 
  3244. 	if wait then 
  3245. 		repeat 
  3246. 			thread_yield() 
  3247. 		until not action_sequence_is_playing() 
  3248. 	end 
  3249. end 
  3250.  
  3251. -- start up the swat respawn pairs threads 
  3252. function m01_start_swat_respawn_pairs() 
  3253. 	M01_pairs_spawned = 0 
  3254. 	M01_group.swat1_pair.thread = thread_new("m01_respawn_pair_thread", M01_group.swat1_pair)	 
  3255. 	M01_group.swat2_pair.thread = thread_new("m01_respawn_pair_thread", M01_group.swat2_pair)	 
  3256. 	M01_group.swat3_pair.thread = thread_new("m01_respawn_pair_thread", M01_group.swat3_pair) 
  3257. 	M01_group.swat4_pair.thread = thread_new("m01_respawn_pair_thread", M01_group.swat4_pair) 
  3258. 	M01_group.swat5_pair.thread = thread_new("m01_respawn_pair_thread", M01_group.swat5_pair) 
  3259. 	M01_group.swat_riot_pair.thread = thread_new("m01_respawn_pair_thread", M01_group.swat_riot_pair) 
  3260. end 
  3261.  
  3262. -- shut down the swat respawn pairs threads 
  3263. function m01_stop_swat_respawn_pairs() 
  3264. 	thread_kill(M01_group.swat1_pair.thread) 
  3265. 	thread_kill(M01_group.swat2_pair.thread) 
  3266. 	thread_kill(M01_group.swat3_pair.thread) 
  3267. 	thread_kill(M01_group.swat_riot_pair.thread) 
  3268. 	thread_kill(M01_group.swat4_pair.thread) 
  3269. 	thread_kill(M01_group.swat5_pair.thread) 
  3270. 	M01_pairs_spawned = 0 
  3271. end 
  3272.  
  3273. -- start up the respawn pairs threads 
  3274. function m01_start_respawn_pairs() 
  3275. 	M01_pairs_spawned = 0 
  3276. 	M01_group.roof1_pair.thread = thread_new("m01_respawn_pair_thread", M01_group.roof1_pair)	 
  3277. 	M01_group.roof2_pair.thread = thread_new("m01_respawn_pair_thread", M01_group.roof2_pair)	 
  3278. 	M01_group.roof3_pair.thread = thread_new("m01_respawn_pair_thread", M01_group.roof3_pair) 
  3279. 	M01_group.roof4_pair.thread = thread_new("m01_respawn_pair_thread", M01_group.roof4_pair) 
  3280. 	M01_group.roof5_pair.thread = thread_new("m01_respawn_pair_thread", M01_group.roof5_pair) 
  3281. end 
  3282.  
  3283. -- shut down the respawn pairs threads 
  3284. function m01_stop_respawn_pairs() 
  3285. 	thread_kill(M01_group.roof1_pair.thread) 
  3286. 	thread_kill(M01_group.roof2_pair.thread) 
  3287. 	thread_kill(M01_group.roof3_pair.thread) 
  3288. 	thread_kill(M01_group.roof4_pair.thread) 
  3289. 	thread_kill(M01_group.roof5_pair.thread) 
  3290. 	M01_pairs_spawned = 0 
  3291. end 
  3292.  
  3293. -- setup ropes for action 
  3294. function m01_setup_ropes() 
  3295. 	group_create(M01_group.rope.name, true) 
  3296. 	 
  3297. 	local action = "" 
  3298. 	local high_priority = false 
  3299. 	local state = "Rope Up" 
  3300. 	for i,rope in pairs(M01_group.rope.members) do 
  3301. 		item_anim_play(rope.name, action, high_priority, state) 
  3302. 		rope.is_down = false 
  3303. 	end 
  3304. end 
  3305.  
  3306. -- put rope into lowered position or return if already lowered 
  3307. -- 
  3308. -- rope_index:	(int) number of rope to lower 
  3309. function m01_lower_rope(rope_index) 
  3310. 	local rope = M01_group.rope.members[rope_index] 
  3311. 	if not rope.is_down then 
  3312. 		local action = "Rope Drop" 
  3313. 		local high_priority = false 
  3314. 		local state = "Rope Down" 
  3315. 		item_anim_play(rope.name, action, high_priority, state) 
  3316. 		rope.is_down = true 
  3317. 		 
  3318. 		delay(4.0) 
  3319. 	end	 
  3320. end 
  3321.  
  3322. -- play rope entry animation (hopefully matching the repelling human) 
  3323. -- 
  3324. -- rope_index:	(int) number of rope to play anim 
  3325. function m01_rope_entry(rope_index) 
  3326. 	local action = "Window Entry" 
  3327. 	local high_priority = true	-- use high priority to override the drop animation if necessary 
  3328. 	item_anim_play(M01_group.rope.members[rope_index].name, action, high_priority)	 
  3329. end 
  3330.  
  3331. -- do the swat repelling animation 
  3332. -- 
  3333. -- npc_name:		(string) name of npc to do repelling 
  3334. -- navpoint:		(string) name of navpoint to enter from 
  3335. -- rope_index:		(int) number of rope repelling from 
  3336. --  
  3337. function m01_swat_entry(npc_name, navpoint, rope_index)	 
  3338. 	-- grab the global value as it may change before we use it 
  3339. 	local throw_flashbangs = M01_throw_flashbangs 
  3340. 	local action = "Window Entry" 
  3341. 	local anim_name = action 
  3342. 	local morph_name = action 
  3343. 	local force_play = true	 
  3344. 	local percentage = 0.9 
  3345. 	local stand_still = true 
  3346. 	local zero_movement = true 
  3347.  
  3348. 	ai_add_enemy_target(npc_name, LOCAL_PLAYER, ATTACK_NOW, false) 
  3349. 	-- turn AI off while we do the action 
  3350. 	set_ignore_ai_flag( npc_name, true ) 
  3351. 	 
  3352. 	human_gravity_enable( npc_name, false ) 
  3353. 	character_prevent_flinching(npc_name, true) 
  3354. 	 
  3355. 	-- he needs his weapon equipped to get the animation 
  3356. 	while not inv_item_is_firearm_equipped(npc_name) and not character_is_dead(npc_name) do 
  3357. 		npc_unholster_best_weapon(npc_name) 
  3358. 		delay(0.4) 
  3359. 	end 
  3360. 	 
  3361. 	m01_lower_rope(rope_index) 
  3362. 	 
  3363. 	-- make sure he starts exactly on the navpoint 
  3364. 	teleport(npc_name, navpoint) 
  3365. 	 
  3366. 	-- tell npc to play action at navpoint (sliding into place as necessary)	 
  3367. 	if not character_is_dead(npc_name) then 
  3368. 		m01_rope_entry(rope_index) 
  3369. 		action_play(npc_name, anim_name, morph_name, force_play, percentage, stand_still, zero_movement, navpoint) 
  3370. 	end 
  3371. 	 
  3372. 	-- turn AI back on 
  3373. 	set_ignore_ai_flag( npc_name, false ) 
  3374. 	human_gravity_enable( npc_name, true ) 
  3375. 	character_prevent_flinching(npc_name, false) 
  3376. 	character_set_combat_ready( npc_name, true, 3000 ) 
  3377. 	 
  3378. 	-- setup attack lines 
  3379. 	on_attack_performed("m01_swat_attack_line_cb", npc_name) 
  3380. 	 
  3381. 	--if throw_flashbangs then 
  3382. 	--	force_throw_char(npc_name, LOCAL_PLAYER) 
  3383. 	--end 
  3384. end 
  3385.  
  3386. -- tell the heli to shoot gun at a navpoint for a given amout of time 
  3387. -- 
  3388. -- heli_name:	(string) name of heli to shoot 
  3389. -- nav_name:	(string) name of navpoint to shoot at 
  3390. -- seconds:		(float) time to shoot at navpoint 
  3391. -- 
  3392. function m01_heli_shoot_gun_at_nav(heli_name, nav_name, seconds) 
  3393. 	M01_thread.battle_timer = thread_new("delay", seconds) 
  3394. 	local alt_fire = false 
  3395. 	while (not thread_check_done(M01_thread.battle_timer)) do 
  3396. 		helicopter_shoot_navpoint(heli_name, nav_name, alt_fire) 
  3397. 		thread_yield() 
  3398. 	end 
  3399. end 
  3400.  
  3401. -- tell the heli to shoot gun at a human for a given amout of time 
  3402. -- 
  3403. -- heli_name:	(string) name of heli to shoot 
  3404. -- human_name:	(string) name of human to shoot at 
  3405. -- seconds:		(float) time to shoot at human 
  3406. -- 
  3407. function m01_heli_shoot_gun_at_human(heli_name, human_name, seconds) 
  3408. 	M01_thread.battle_timer = thread_new("delay", seconds) 
  3409. 	local alt_fire = false 
  3410. 	local unit_sphere = true 
  3411. 	local multiplier = 1.0 
  3412. 	while (not thread_check_done(M01_thread.battle_timer)) do 
  3413. 		helicopter_shoot_human(heli_name, human_name, unit_sphere, multiplier, alt_fire) 
  3414. 		thread_yield() 
  3415. 	end 
  3416. end 
  3417.  
  3418. -- Break the horsie 
  3419. -- 
  3420. function m01_break_horsie() 
  3421. 	-- clear trigger 
  3422. 	m01_clear_trigger(M01_trigger.horse.name) 
  3423. 	M01_trigger.horse.hit = true 
  3424. 	 
  3425. 	-- kill the dude 
  3426. 	character_prevent_flinching(M01_group.start_homies.captive, false) 
  3427. 	turn_vulnerable(M01_group.start_homies.captive) 
  3428. 	character_kill(M01_group.start_homies.captive) 
  3429. 	action_stop_synced_state(M01_group.start_homies.captive) 
  3430. 	 
  3431. 	-- update, launch guard into statue and blow it up 
  3432. 	mesh_mover_update_control("Horsie", "is statue broken", true) 
  3433. 	 
  3434. 	-- play the sound 
  3435. 	audio_object_post_event("Mission_01", "Mission_01", "Statue_Fall", "Horsie") 
  3436. 	 
  3437. 	local explode_source = false 
  3438. 	explosion_create("M1_StatueExp", "horsie_nav", M01_group.start_homies.gat, explode_source) 
  3439. 	effect_play("Vfx Horse Fall<001>")	 
  3440. 	 
  3441. 	delay(3.6) 
  3442. 	-- set off an explosion 
  3443. 	camera_shake_play("explosion_large", 4.0) 
  3444. end 
  3445.  
  3446. -- setup the (Morningstar) see saints line callbacks 
  3447. -- 
  3448. -- members:	(table) list of group members to setup callback on 
  3449. -- 
  3450. function m01_setup_see_saints(members) 
  3451. 	for i,thug in pairs(members) do 
  3452. 		on_detection("m01_morningstar_see_saints_line_cb", thug) 
  3453. 	end 
  3454. end 
  3455.  
  3456. -- clear the (Morningstar) see saints line callbacks 
  3457. -- 
  3458. -- members:	(table) list of group members to setup callback on 
  3459. -- 
  3460. function m01_clear_see_saints(members) 
  3461. 	for i,thug in pairs(members) do 
  3462. 		on_detection("", thug) 
  3463. 	end 
  3464. end 
  3465.  
  3466. -- ************************* 
  3467. -- 
  3468. -- Audio functions 
  3469. -- 
  3470. -- ************************* 
  3471.  
  3472. -- start emitters in a group 
  3473. -- 
  3474. -- emitter_group:	(table) list of emitter names to start 
  3475. -- 
  3476. function m01_start_emitters(emitter_group) 
  3477. 	for i,emitter in pairs(emitter_group) do 
  3478. 		audio_ambient_emitter_start(emitter) 
  3479. 	end 
  3480. end 
  3481.  
  3482. -- stop emitters in a group 
  3483. -- 
  3484. -- emitter_group:	(table) list of emitter names to stop 
  3485. -- 
  3486. function m01_stop_emitters(emitter_group) 
  3487. 	for i,emitter in pairs(emitter_group) do 
  3488. 		audio_ambient_emitter_stop(emitter) 
  3489. 	end 
  3490. end 
  3491.  
  3492. -- stop all mission emitters 
  3493. function m01_stop_all_emitters() 
  3494. 	for i,emitter_group in pairs(M01_audio_emitter) do 
  3495. 		m01_stop_emitters(emitter_group) 
  3496. 	end 
  3497. end 
  3498.  
  3499. -- ************************* 
  3500. -- 
  3501. -- Callback functions 
  3502. -- 
  3503. -- ************************* 
  3504.  
  3505. -- do the horse stuff 
  3506. function m01_trigger_horse_cb(human, trigger) 
  3507. 	-- not our guy, we don't care 
  3508. 	if human == M01_group.start_homies.captive then 
  3509. 		-- break horsie clears trigger in case of emergency 
  3510. 		-- do the horsie 
  3511. 		m01_break_horsie()		 
  3512. 	end 
  3513. end 
  3514.  
  3515. -- Player has reached the freerun trigger 
  3516. function m01_reached_freerun() 
  3517. 	M01_trigger.freerun.hit = true 
  3518. 	m01_clear_trigger(M01_trigger.freerun.name) 
  3519. 	m01_second_floor_guards() 
  3520. end 
  3521.  
  3522. -- Player reached trigger to make shaundi get attacked 
  3523. function m01_attack_shaundi_cb() 
  3524. 	-- if Shaundi isn't ready, don't try to do the animation 
  3525. 	if not M01_shaundi_attack.in_place then 
  3526. 		-- kill the thread 
  3527. 		thread_kill(M01_shaundi_attack.thread) 
  3528. 		-- make attacker and shaundi not dumb 
  3529. 		set_ignore_ai_flag(M01_shaundi, false) 
  3530. 		set_ignore_ai_flag(M01_shaundi_attack.attacker, false) 
  3531. 	end 
  3532. 	M01_trigger.shaundi_attack.hit = true 
  3533. 	m01_clear_trigger(M01_trigger.shaundi_attack.name) 
  3534. end	 
  3535.  
  3536. -- Player has reached the vault breadcrumb 
  3537. function m01_reached_vault_breadcrumb() 
  3538. 	M01_trigger.pre_vault.hit = true 
  3539. 	m01_clear_trigger(M01_trigger.pre_vault.name) 
  3540. end 
  3541.  
  3542. -- Player has reached the vault trigger 
  3543. function m01_reached_vault() 
  3544. 	M01_trigger.vault.hit = true 
  3545. 	m01_clear_trigger(M01_trigger.vault.name) 
  3546. end 
  3547.  
  3548. -- Player has reached the pre bomb trigger 
  3549. function m01_reached_pre_bomb() 
  3550. 	M01_trigger.pre_bomb.hit = true 
  3551. 	m01_clear_trigger(M01_trigger.pre_bomb.name) 
  3552. 	m01_clear_trigger(M01_trigger.pre_bomb2.name) 
  3553. 	 
  3554. 	-- peds flee 
  3555. 	--local should_run = true 
  3556. 	--local should_fire = false 
  3557. 	--for i, flee_ped in pairs(M01_group.bomb_flee.members) do 
  3558. 	--	-- if ignore AI isn't set, they just run all over the place 
  3559. 	--	set_ignore_ai_flag(flee_ped, false) 
  3560. 	--	ai_do_scripted_move(flee_ped, M01_group.bomb_flee.dest, should_run, should_fire) 
  3561. 	--end	 
  3562. 	 
  3563. 	-- tell Josh to go to his autograph navpoint 
  3564. 	thread_kill(M01_thread.josh_ai) 
  3565. 	M01_thread.josh_ai = thread_new("m01_josh_to_autograph") 
  3566. 	 
  3567. end 
  3568.  
  3569. -- Player signs an autograph for his fan 
  3570. -- 
  3571. -- triggerer:	(string) name of person that fired the trigger 
  3572. -- 
  3573. function m01_sign_autograph_cb(triggerer) 
  3574. 	if M01_doing_autograph then 
  3575. 		-- one per customer, thank you 
  3576. 		return 
  3577. 	end 
  3578. 	 
  3579. 	M01_doing_autograph = true 
  3580. 	-- kill startup thread 
  3581. 	thread_kill(M01_group.autograph.thread) 
  3582. 	 
  3583. 	-- clear trigger 
  3584. 	m01_clear_trigger(M01_group.autograph.trigger) 
  3585.  
  3586. 	-- end effect 
  3587. 	if (M01_group.autograph.effect_handle ~= -1) then 
  3588. 		effect_stop(M01_group.autograph.effect_handle) 
  3589. 		M01_group.autograph.effect_handle = -1 
  3590. 	end 
  3591. 	 
  3592. 	-- Don't fuck with autograph guy (girl) 
  3593. 	turn_invulnerable( M01_group.autograph.guy )	 
  3594. 	character_allow_ragdoll(M01_group.autograph.guy, false) 
  3595. 	character_prevent_flinching(M01_group.autograph.guy, true) 
  3596. 	 
  3597. 	-- kill any running conversations	 
  3598. 	m01_end_conversations() 
  3599. 	 
  3600. 	-- make sure they are done playing 
  3601. 	while audio_any_conversation_playing() do 
  3602. 		thread_yield() 
  3603. 	end 
  3604. 	 
  3605. 	if M01_setting_bomb then 
  3606. 		return 
  3607. 	end 
  3608. 		 
  3609. 	M01_convo.more_guys.handle = audio_conversation_load_direct(M01_convo.more_guys.name)	 
  3610. 	 
  3611. 	-- load and play autograph conversation	 
  3612. 	M01_convo.sign_autograph.handle = audio_conversation_load(M01_convo.sign_autograph.name)	 
  3613. 	audio_conversation_play(M01_convo.sign_autograph.handle) 
  3614. 	 
  3615. 	thread_kill(M01_thread.josh_ai) 
  3616. 	M01_thread.josh_ai = thread_new("m01_josh_to_autograph2") 
  3617. 	 
  3618. 	-- sign stuff 
  3619. 	player_movement_disable(triggerer) 
  3620. 	action_play_synced_non_blocking(triggerer, M01_group.autograph.guy, "AutoGraph Sign") 
  3621. 		 
  3622. 	repeat 
  3623. 		-- watch for that crazy coop player screwing things up 
  3624. 		if M01_setting_bomb then 
  3625. 			return 
  3626. 		end 
  3627. 		thread_yield() 
  3628. 	until action_play_synced_is_finished(triggerer, M01_group.autograph.guy) 
  3629. 	 
  3630. 	player_movement_enable(triggerer) 
  3631. 		 
  3632. 	if M01_setting_bomb then 
  3633. 		return 
  3634. 	end 
  3635. 	 
  3636. 	delay(3.0) 
  3637. 	 
  3638. 	if M01_setting_bomb then 
  3639. 		return 
  3640. 	end 
  3641. 	 
  3642. 	local anim_name = "react Avoid Person" 
  3643. 	local morph_name = "react Avoid Person" 
  3644. 	local force_play = false	 
  3645. 	local percentage = 0.1 
  3646. 	local stand_still = true 
  3647. 	local zero_movement = true 
  3648. 	action_play(M01_group.autograph.guy, anim_name, morph_name, force_play, percentage, stand_still, zero_movement, "Facing_josh") 
  3649. 	 
  3650. 	repeat 
  3651. 		-- watch for that crazy coop player screwing things up 
  3652. 		if M01_setting_bomb then 
  3653. 			return 
  3654. 		end 
  3655. 		thread_yield() 
  3656. 	until action_play_is_finished(M01_group.autograph.guy, 1.0) 
  3657. 	 
  3658. 	delay(2.5) 
  3659. 	 
  3660. 	if M01_setting_bomb then 
  3661. 		return 
  3662. 	end 
  3663. 	 
  3664. 	-- react Avoid Person 
  3665. 	clear_animation_state(M01_group.autograph.guy) 
  3666. 	on_death("", M01_group.autograph.guy) 
  3667. 	on_take_damage("", M01_group.autograph.guy) 
  3668. 	character_prevent_flinching(M01_group.autograph.guy, false) 
  3669. 	turn_vulnerable( M01_group.autograph.guy )	 
  3670. 	character_allow_ragdoll(M01_group.autograph.guy, true) 
  3671. 	 
  3672. 	if M01_setting_bomb then 
  3673. 		return 
  3674. 	end 
  3675. 	 
  3676. 	-- send dude on his way 
  3677. 	local should_run = true 
  3678. 	local should_fire = false 
  3679. 	ai_do_scripted_move(M01_group.autograph.guy, M01_group.bomb_flee.dest, should_run, should_fire) 
  3680. 	 
  3681. 	audio_conversation_wait_for_end(M01_convo.sign_autograph.handle) 
  3682. 	M01_convo.sign_autograph.handle = INVALID_CONVERSATION_HANDLE	 
  3683. 	 
  3684. 	-- slight delay so if we have waiting conversations, they don't run together 
  3685. 	delay(3.0) 
  3686. 	 
  3687. 	M01_doing_autograph = false 
  3688. end 
  3689.  
  3690. -- Oh Noes! Shut down all autograph guy stuffs 
  3691. function m01_autograph_death_cb() 
  3692. 	m01_clear_trigger(M01_group.autograph.trigger) 
  3693. 	on_death("", M01_group.autograph.guy) 
  3694. 	on_take_damage("", M01_group.autograph.guy) 
  3695. 	-- end effect 
  3696. 	if (M01_group.autograph.effect_handle ~= -1) then 
  3697. 		effect_stop(M01_group.autograph.effect_handle) 
  3698. 		M01_group.autograph.effect_handle = -1 
  3699. 	end 
  3700. end 
  3701.  
  3702. -- Player has reached the bomb trigger 
  3703. -- 
  3704. -- triggerer:	(string) name of person triggering 
  3705. -- 
  3706. function m01_reached_bomb(triggerer) 
  3707. 	if M01_setting_bomb then 
  3708. 		return 
  3709. 	end 
  3710. 	M01_setting_bomb = true 
  3711. 	-- make sure this is done 
  3712. 	thread_kill(M01_group.autograph.thread) 
  3713. 	thread_kill(M01_thread.josh_ai) 
  3714. 	 
  3715. 	inv_item_equip(nil, triggerer) -- Unequip the current weapon on the player 
  3716. 	 
  3717. 	audio_object_post_event("M01_Score_Z02_Transition") 
  3718. 	m01_clear_trigger(M01_trigger.bomb.name) 
  3719. 	 
  3720. 	-- Player sets the bomb 
  3721. 	local anim_name = "Bomb Plant" 
  3722. 	local morph_name = "Bomb Plant" 
  3723. 	local force_play = false	 
  3724. 	local percentage = 0.8 
  3725. 	local stand_still = true 
  3726. 	local zero_movement = true 
  3727. 	action_play(triggerer, anim_name, morph_name, force_play, percentage, stand_still, zero_movement) 
  3728. 		 
  3729. 	M01_trigger.bomb.hit = true 
  3730. end 
  3731.  
  3732. -- have swat say a line when attacking 
  3733. -- 
  3734. -- name:	(string) name of character detecting player 
  3735. -- player:	(string) name of player detected 
  3736. -- 
  3737. function m01_morningstar_see_saints_line_cb(name, player) 
  3738. 	-- SAY IT! 
  3739. 	local situation = "M01_See_Saints" 
  3740. 	 
  3741. 	-- wait until we are not in a conversation 
  3742. 	while M01_conversation_playing do 
  3743. 		thread_yield() 
  3744. 	end 
  3745. 	 
  3746. 	-- don't play this if we have done this recently 
  3747. 	if (not thread_check_done(M01_thread.attack_line_timer)) then 
  3748. 		return 
  3749. 	end 
  3750. 	 
  3751. 	-- start timer 
  3752. 	M01_thread.attack_line_timer = thread_new("delay", 10.0) 
  3753. 	-- play situation 
  3754. 	audio_play_persona_line(name, situation) 
  3755. end 
  3756.  
  3757. -- have swat say a line when attacking 
  3758. -- 
  3759. -- name:	(string) name of character 
  3760. -- weapon:	(string) name of weapon 
  3761. -- attack:	(string) type of attack performed 
  3762. -- 
  3763. function m01_swat_attack_line_cb(name, weapon, attack) 
  3764. 	-- SAY IT! 
  3765. 	local situation = "M01_Attack" 
  3766. 	 
  3767. 	-- don't play this if we have done this recently 
  3768. 	if (not thread_check_done(M01_thread.attack_line_timer)) then 
  3769. 		return 
  3770. 	end 
  3771. 	 
  3772. 	-- start timer 
  3773. 	M01_thread.attack_line_timer = thread_new("delay", M01_Attack_Line_Time) 
  3774. 	-- play situation 
  3775. 	audio_play_persona_line(name, situation) 
  3776. end 
  3777.  
  3778. -- Handle playing the attack lines 
  3779. -- 
  3780. -- name:	(string) name of character 
  3781. -- weapon:	(string) name of weapon 
  3782. -- attack:	(string) type of attack performed 
  3783. -- 
  3784. function m01_process_gat_attack_cb(name, weapon, attack)	 
  3785. 	-- don't play this if we have done this recently 
  3786. 	if (not thread_check_done(M01_gat_attack_info.timer)) then 
  3787. 		return 
  3788. 	end 
  3789. 	 
  3790. 	if M01_conversation_playing then 
  3791. 		return 
  3792. 	end 
  3793. 	 
  3794. 	-- start timer 
  3795. 	M01_gat_attack_info.timer = thread_new("delay", M01_gat_attack_info.delay) 
  3796. 	 
  3797. 	-- play situation 
  3798. 	if not audio_play_persona_line(name, M01_gat_attack_info.situation) then 
  3799. 		-- line didn't play, kill our timer 
  3800. 		thread_kill(M01_gat_attack_info.timer) 
  3801. 		M01_gat_attack_info.timer = INVALID_THREAD_HANDLE 
  3802. 	end 
  3803.  
  3804. end 
  3805.  
  3806. -- Cause the helicopter to fly into building 
  3807. function m01_crash_heli(heli_name, killer) 
  3808. 	on_damage("", heli_name, 0.99) 
  3809. 	local heli_group = M01_group.heli_police2 
  3810. 	if heli_name == M01_group.heli_police1.vehicle then 
  3811. 		heli_group = M01_group.heli_police1 
  3812. 	end 
  3813. 	-- make everyone vulnerable 
  3814. 	for i,pilot in pairs(heli_group.members) do 
  3815. 		turn_vulnerable(pilot) 
  3816. 	end 
  3817. 	turn_vulnerable(heli_group.shooter) 
  3818. 	-- go to the forbidden navpoint 
  3819. 	m01_heli_move_to(heli_group.crash_nav, heli_group) 
  3820. 	delay(1.0) 
  3821. 	vehicle_detonate(heli_name) 
  3822. 	Helicopter_killed = true 
  3823. end 
  3824.  
  3825. -- Send heli to final location and watch it move 
  3826. function m01_move_heli(heli_name, killer)	 
  3827. 	Helicopter_killed = true 
  3828. 	on_damage("", heli_name, 0.99) 
  3829. 	 
  3830. 	-- don't damage us more...yet 
  3831. 	turn_invulnerable( heli_name ) 
  3832. 	-- reset camera restrict	 
  3833. 	camera_restrict_set_active(DISABLE) 
  3834. 	-- target your current view 
  3835. 	camera_restrict_target_object() 
  3836. 	camera_restrict_set_limits( 0.0, 0.0, 0.0, 0.0) 
  3837. 	-- lock it 
  3838. 	camera_restrict_set_active(ENABLE) 
  3839. 	thread_yield() 
  3840. 	 
  3841. 	-- follow the chopper 
  3842. 	camera_restrict_target_object(heli_name, 500) 
  3843. 	delay(1.0) 
  3844. 	-- go to the last navpoint 
  3845. 	m01_heli_move_to(POLICE_HELI_SHOOT_AT_ME3, M01_group.heli_police1)	 
  3846. 	delay(2.5) 
  3847. 	camera_restrict_target_object(CAMERA_TARGET4, 500) 
  3848. 	camera_restrict_set_limits( M01_MIN_PITCH, M01_MAX_PITCH, M01_MIN_HEADING, M01_MAX_HEADING ) 
  3849. 	Helicopter_killed = true 
  3850. end 
  3851.  
  3852. function m01_failure_gat_died() 
  3853. 	-- End the mission, Gat died 
  3854. 	mission_end_failure("m01", HELPTEXT_FAILURE_GAT_DIED) 
  3855. end 
  3856.  
  3857. function m01_failure_shaundi_died() 
  3858. 	-- End the mission, Shaundi died 
  3859. 	mission_end_failure("m01", HELPTEXT_FAILURE_SHAUNDI_DIED) 
  3860. end 
  3861.  
  3862. function m01_failure_josh_died() 
  3863. 	-- End the mission, Josh died 
  3864. 	mission_end_failure("m01", HELPTEXT_FAILURE_JOSH_DIED) 
  3865. end 
  3866.  
  3867. function m01_weapon_was_equiped(weapon, is_firearm) 
  3868. 	M01_weapon_changed = true 
  3869. 	on_weapon_equip("", LOCAL_PLAYER) 
  3870. end 
  3871.  
  3872. -- kill whoever triggered this 
  3873. function m01_kill_trigger_cb(human, trigger) 
  3874. 	if human ~= nil then 
  3875. 		if human == M01_gat or human == M01_shaundi then 
  3876. 			teleport(human, "Fifth_window 003") 
  3877. 		else 
  3878. 			character_kill(human) 
  3879. 		end 
  3880. 	end 
  3881. end 
  3882.  
  3883. -- the attack heli has met the damage threshold 
  3884. -- 
  3885. -- vehicle:		(string) name of the vehicle damaged 
  3886. -- attacker:	(string) name of person causing the damage 
  3887. function m01_attack_heli_damaged_cb(vehicle, attacker) 
  3888. 	on_damage("", M01_group.heli_fighter1.vehicle) 
  3889. 	M01_group.heli_fighter1.damaged = true 
  3890. 	turn_invulnerable(M01_group.heli_fighter1.vehicle) 
  3891. end 
  3892.  
  3893. -- notify that a transport has been destroyed 
  3894. -- 
  3895. -- vehicle:		(string) name of vehicle destroyed 
  3896. -- 
  3897. function m01_transport_destroyed_cb(vehicle) 
  3898. 	-- find out which transport this was 
  3899. 	local transport_group 
  3900. 	if vehicle == M01_group.transport1.vehicle then 
  3901. 		transport_group = M01_group.transport1 
  3902. 	elseif vehicle == M01_group.transport2.vehicle then 
  3903. 		transport_group = M01_group.transport2 
  3904. 	elseif vehicle == M01_group.transport2.vehicle then 
  3905. 		transport_group = M01_group.transport3 
  3906. 	else 
  3907. 		-- that's all we had.  IDK what this is 
  3908. 		return 
  3909. 	end 
  3910. 	 
  3911. 	on_vehicle_destroyed("", transport_group.vehicle) 
  3912. 	transport_group.complete = true 
  3913. 	 
  3914. 	-- make sure pilots are killed 
  3915. 	for i,pilot in pairs(transport_group.pilots) do 
  3916. 		turn_vulnerable(pilot) 
  3917. 		character_kill(pilot) 
  3918. 	end 
  3919. 	persona_override_persona_stop(transport_group.pilots[1]) 
  3920. 	 
  3921. 	-- short cleanup delay 
  3922. 	delay(1.5) 
  3923. 	vehicle_delete_all_corpses() 
  3924. 	 
  3925. 	-- release so we can really delete the corpse when we have the chance 
  3926. 	release_to_world(transport_group.name) 
  3927. end 
  3928.  
  3929. -- ************************* 
  3930. -- 
  3931. -- Thread functions 
  3932. -- 
  3933. -- ************************* 
  3934.  
  3935. -- Reset all our movers 
  3936. -- 
  3937. function m01_reset_movers_thread() 
  3938. 	mesh_mover_reset(M01_vault_mover) 
  3939. 	-- make sure our roof is in place 
  3940. 	mesh_mover_reset("Break_ceiling") 
  3941. 	mesh_mover_reset("Break_roof")	 
  3942. 	mesh_mover_reset("Break_wall")	 
  3943. 	mesh_mover_reset("Break_light<001>")		 
  3944. 	mesh_mover_reset("Break_light<002>") 
  3945. end 
  3946.  
  3947. -- setup fine aim glass to turn on emitter when broken 
  3948. -- 
  3949. function m01_fine_aim_glass_thread() 
  3950. 	for i,pane in pairs(M01_fine_aim_glass) do 
  3951. 		mesh_mover_reset(pane) 
  3952. 	end 
  3953. 	 
  3954. 	local broken = false 
  3955. 	 
  3956. 	while not broken do 
  3957. 		for i, pane in pairs(M01_fine_aim_glass) do 
  3958. 			if mesh_mover_destroyed(pane) then 
  3959. 				broken = true 
  3960. 			end 
  3961. 		end 
  3962. 		thread_yield() 
  3963. 	end 
  3964. 	 
  3965. 	if broken then 
  3966. 		m01_start_emitters(M01_audio_emitter.fine_aim) 
  3967. 	end 
  3968. end 
  3969.  
  3970. -- Open the door and let the guards out 
  3971. -- 
  3972. function m01_enter_guards_thread() 
  3973. 	-- wait for player's animation to get going 
  3974. 	delay(1.5) 
  3975.  
  3976. 	-- open the door	 
  3977. 	local reverse_door = true 
  3978. 	local animate_door = true 
  3979. 	door_open(LOBBY_DOOR01, reverse_door, animate_door) --, M01_group.lobby.moving_guards[1]) 
  3980. 	 
  3981. 	-- wait for door to open 
  3982. 	--delay(0.5) 
  3983. 	 
  3984. 	-- go here 
  3985. 	local should_run = true 
  3986. 	local should_fire = false 
  3987. 	for i,guard in pairs(M01_group.lobby.moving_guards) do 
  3988. 		ai_do_scripted_move(guard, M01_group.lobby.guard_navs[i], should_run, should_fire) 
  3989. 		delay(1.0) 
  3990. 	end 
  3991. end 
  3992.  
  3993. -- Say the get robbed line 
  3994. -- 
  3995. -- name:	(string) name of character 
  3996. -- 
  3997. function m01_get_robbed_line_thread(name) 
  3998. 	local situation = "M01_Get_Robbed" 
  3999. 	 
  4000. 	-- setup the persona 
  4001. 	persona_override_persona_start(name, "Saints_Fan_AM") 
  4002.  
  4003. 	while not character_is_dead(name) do 
  4004. 		delay(M01_Get_Robbed_Line_Time) 
  4005.  
  4006. 		-- SAY IT! 
  4007. 		if not character_is_dead(name) then 
  4008. 			audio_play_persona_line(name, situation) 
  4009. 		end 
  4010. 	 
  4011. 	end 
  4012. end 
  4013.  
  4014. -- spawn a group of peds and make them cower (threaded because it takes some time to desync anims) 
  4015. -- 
  4016. -- group_table:	(table) information about the group to make cower 
  4017. function m01_group_cower_thread(group_table) 
  4018. 	group_create(group_table.name) 
  4019. 	for i,npc in pairs(group_table.on_ground) do 
  4020. 		while not character_is_ready(npc) do 
  4021. 			thread_yield()	-- once the first is done, the rest should be done 
  4022. 		end 
  4023. 		set_cower_variant(npc, 1) 
  4024. 		set_cant_cower_flag(npc, false) 
  4025. 		set_cant_flee_flag(npc, true) 
  4026. 		cower(npc, LOCAL_PLAYER, true, true) 
  4027. 		delay(0.1)	-- don't start everyone at the same time 
  4028. 	end 
  4029. 	for i,npc in pairs(group_table.members) do 
  4030. 		set_cant_cower_flag(npc, false) 
  4031. 		set_cant_flee_flag(npc, true) 
  4032. 		cower(npc, LOCAL_PLAYER, true, true) 
  4033. 		delay(0.1)	-- don't start everyone at the same time 
  4034. 	end 
  4035. end 
  4036.  
  4037. -- keep telling homie to take the hostage 
  4038. -- attacker:	(string) attacker to take the hostage 
  4039. -- hostage:		(string) name of hostage 
  4040. function m01_take_hostage(attacker, hostage) 
  4041. 	-- tell Gat to grab the guard (bypass AI because we've set them up for this) 
  4042.    character_take_human_shield(attacker, hostage, true)	 
  4043. end 
  4044.  
  4045. -- tell a homie to move to a navpoint and find cover 
  4046. -- 
  4047. -- homie_name:		(string) name of homie to move 
  4048. -- navpoint:		(string) nave of navpoint to go to 
  4049. -- 
  4050. function m01_homie_move_thread(homie_name, navpoint) 
  4051. 	-- need to do this on your own 
  4052. 	follower_make_independent(homie_name, true) 
  4053. 	ai_clear_scripted_action(homie_name) 
  4054. 	 
  4055. 	-- find cover 
  4056. 	ai_do_scripted_take_cover(homie_name, navpoint) 
  4057. 	ai_set_in_scripted_cover(homie_name, true)	 
  4058. 	npc_leash_to_nav(homie_name, navpoint, 5) 
  4059. 	ai_set_personality(homie_name, "gang defensive")	 
  4060. 	 
  4061. 	-- wait for completion 
  4062. 	while not ai_scripted_action_is_complete(homie_name) do 
  4063. 		thread_yield() 
  4064. 	end 
  4065.  
  4066. end 
  4067.  
  4068. function m01_gat_guard_convo_thread() 
  4069.  
  4070. 	-- Not waiting yet 
  4071. 	M01_guard_killed = false 
  4072. 	M01_gat_at_door = false 
  4073. 	M01_lobby_cleared = false 
  4074. 	 
  4075. 	M01_convo.gat_interrogate.handle = audio_conversation_load(M01_convo.gat_interrogate.name) 
  4076. 	M01_convo.gat_interrogate2.handle = audio_conversation_load(M01_convo.gat_interrogate2.name) 
  4077. 	 
  4078. --	-- start interrogation with 4 dudes left 
  4079. --	while (Num_enemies_alive > 4) do 
  4080. --	--while not M01_lobby_cleared do 
  4081. --		thread_yield() 
  4082. --	end 
  4083. 	-- start right away 
  4084. 	 
  4085. 	-- if you think you should be doing something, you are wrong 
  4086. 	set_ignore_ai_flag(M01_group.start_homies.gat, true) 
  4087. 	 
  4088. 	-- let go so we don't have any animation fighting 
  4089. 	local instant_release = true 
  4090. 	character_set_only_scripted_grabs(M01_group.start_homies.captive)  -- make sure Shaundi doesn't grab him	 
  4091. 	if M01_thread.gat_hostage ~= INVALID_THREAD_HANDLE then	-- make sure Gat doesn't try again 
  4092. 		thread_kill(M01_thread.gat_hostage) 
  4093. 	end	 
  4094. 	 
  4095. 	-- roll into the interrogation 
  4096. 	-- pop to nav 
  4097. 	teleport(M01_group.start_homies.gat, M01_group.start_homies.captive_nav) 
  4098. 	thread_yield() 
  4099. 		 
  4100. 	-- start the state 
  4101. 	-- pop to nav 
  4102. 	--teleport(M01_group.start_homies.gat, M01_group.start_homies.captive_nav) 
  4103. 	action_play_synced_state(M01_group.start_homies.gat, M01_group.start_homies.captive, "Gat Interrogation State") 
  4104. 	action_play_synced(M01_group.start_homies.gat, M01_group.start_homies.captive, "Gat Interrogation Entry") 
  4105. 	 
  4106. 	delay(1.5) 
  4107. 	 
  4108. 	-- do interrogation 
  4109. 	-- Gat is going to interrogate 
  4110. 	M01_conversation_playing = true 
  4111. 	 
  4112. 	-- Gat just says one line now 
  4113. 	--audio_play_persona_line(M01_group.start_homies.gat, "M01_Interrogate_Guard_05") 
  4114. 	 
  4115. 	audio_conversation_play(M01_convo.gat_interrogate.handle) 
  4116. 	 
  4117. 	-- set up our horse trigger 
  4118. 	m01_set_trigger(M01_trigger.horse.name, "m01_trigger_horse_cb") 
  4119.  
  4120. 	-- wait until the player gets done with his animation 
  4121. 	while not M01_player_over_desk do 
  4122. 		thread_yield() 
  4123. 	end 
  4124. 	 
  4125. 	-- When the conversation is done, Gat kills him 
  4126. 	audio_conversation_wait_for_end(M01_convo.gat_interrogate.handle) 
  4127. 	M01_convo.gat_interrogate.handle = INVALID_CONVERSATION_HANDLE 
  4128. 	M01_conversation_playing = false 
  4129. 	-- launch him 
  4130. 	character_allow_ragdoll(M01_group.start_homies.captive, true) 
  4131. 	 
  4132. 	-- pop to nav 
  4133. 	--teleport(M01_group.start_homies.gat, M01_group.start_homies.captive_nav) 
  4134. 	character_release_human_shield(M01_group.start_homies.gat, instant_release) 
  4135. 	action_play_synced(M01_group.start_homies.gat, M01_group.start_homies.captive, "Gat Interrogation Exit") 
  4136. 	 
  4137. 	-- wait until Gat is done.  Horse should blow up on trigger 
  4138. 	while not action_play_is_finished(M01_group.start_homies.gat) do 
  4139. 		thread_yield() 
  4140. 	end 
  4141. 	-- kill him 
  4142. 	set_ignore_ai_flag(M01_group.start_homies.gat, false) 
  4143. 	action_stop_synced_state(M01_group.start_homies.gat) 
  4144. 		 
  4145. 	if not M01_trigger.horse.hit then 
  4146. 		-- we didn't break the horse yet?  Crappy! 
  4147. 		m01_break_horsie() 
  4148. 	end 
  4149. 	 
  4150. 	-- free up Gat 
  4151. 	character_allow_ragdoll(M01_group.start_homies.gat, true) 
  4152. 	character_prevent_flinching(M01_group.start_homies.gat, false) 
  4153. 	follower_make_independent(M01_group.start_homies.gat, true) 
  4154. 	 
  4155. 	-- larger leash, but still leashed (makes slide over counter go smoother) 
  4156. 	npc_leash_to_nav( M01_group.start_homies.gat, M01_group.start_homies.captive_nav, 5.0 ) 
  4157. 	 
  4158. 	-- move to close to the door	 
  4159. 	local should_run = true 
  4160. 	local should_fire = false 
  4161. 	--ai_do_scripted_move(M01_group.start_homies.gat, "lobby_mark 001", should_run, should_fire)	 
  4162. 	 
  4163. 	-- after guard killed conversation 
  4164. 	M01_conversation_playing = true 
  4165. 	audio_conversation_play(M01_convo.gat_interrogate2.handle) 
  4166. 	thread_yield() 
  4167. 	 
  4168. 	-- signal the main thread that guard has been killed 
  4169. 	M01_guard_killed = true 
  4170. 	 
  4171. 	M01_convo.look_for_vault.handle = audio_conversation_load(M01_convo.look_for_vault.name) 
  4172. 	 
  4173. 	while not M01_lobby_cleared do 
  4174. 		thread_yield() 
  4175. 	end 
  4176. 	 
  4177. 	npc_leash_remove( M01_group.start_homies.gat ) 
  4178. 	 
  4179. 	-- Gat slide (hahaha) 
  4180. 	 
  4181. 	-- start by telling Gat to go to the navpoint 
  4182. 	ai_do_scripted_move(M01_group.start_homies.gat, "Gat_slide_nav", should_run, should_fire) 
  4183. 	 
  4184. 	-- when he gets close, play the animation 
  4185. 	while not ai_scripted_action_is_complete(M01_group.start_homies.gat) and (get_dist(M01_group.start_homies.gat, "Gat_slide_nav") > 0.5) do 
  4186. 		thread_yield() 
  4187. 	end 
  4188. 	 
  4189. 	-- this should look great 
  4190. 	--ai_clear_scripted_action(M01_group.start_homies.gat) 
  4191. 	 
  4192. 	-- turn AI off while we do the action 
  4193. 	--set_ignore_ai_flag( M01_group.start_homies.gat, true ) 
  4194. 	-- tell npc to play action at navpoint (sliding into place as necessary) 
  4195. 	local anim_name = "Gat Sounter Slide" 
  4196. 	local morph_name = "Gat Sounter Slide" 
  4197. 	local force_play = false	 
  4198. 	local percentage = 1.0 
  4199. 	local stand_still = true 
  4200. 	local zero_movement = true 
  4201. 	action_play(M01_group.start_homies.gat, anim_name, morph_name, force_play, percentage, stand_still, zero_movement, "Gat_slide_nav")	 
  4202. 	 
  4203. 	-- Gat takes a position by the door 
  4204. 	m01_have_to_get_there_thread(M01_group.start_homies.gat, M01_cover.lobby2.gat) 
  4205. 	 
  4206. 	-- don't move 
  4207. 	npc_leash_to_nav(M01_group.start_homies.gat, M01_cover.lobby2.gat, 0.0) 
  4208. 		 
  4209. 	audio_conversation_wait_for_end(M01_convo.gat_interrogate2.handle) 
  4210. 	M01_convo.gat_interrogate2.handle = INVALID_CONVERSATION_HANDLE 
  4211. 	M01_conversation_playing = false 
  4212. 	 
  4213. 	M01_gat_at_door = true 
  4214. 		 
  4215. 	-- wait for Josh's grandstanding 
  4216. 	while not M01_josh_grandstanded do 
  4217. 		thread_yield() 
  4218. 	end 
  4219. 	 
  4220. 	-- Shaundi: Oh Jesus.. 
  4221. 	--audio_play_persona_line(M01_shaundi, "M01_Berating_Josh_03") 
  4222. 	 
  4223. 	delay(6.5) 
  4224. 	 
  4225. 	while M01_conversation_playing do 
  4226. 		thread_yield() 
  4227. 	end 
  4228. 	 
  4229. 	-- talk about going to vault 
  4230. 	M01_conversation_playing = true 
  4231. 	audio_conversation_play(M01_convo.look_for_vault.handle) 
  4232. 	thread_yield() 
  4233. 	 
  4234. 	M01_convo.morningstar.handle = audio_conversation_load(M01_convo.morningstar.name) 
  4235. 		 
  4236. 	audio_conversation_wait_for_end(M01_convo.look_for_vault.handle) 
  4237. 	M01_convo.look_for_vault.handle = INVALID_CONVERSATION_HANDLE 
  4238. 	M01_conversation_playing = false 
  4239. 	 
  4240. 	-- wait a smidge 
  4241. 	delay(2.0) 
  4242. 	 
  4243. 	-- talk about the morningstar 
  4244. 	M01_conversation_playing = true 
  4245. 	audio_conversation_play(M01_convo.morningstar.handle) 
  4246. 	thread_yield() 
  4247. 		 
  4248. 	audio_conversation_wait_for_end(M01_convo.morningstar.handle) 
  4249. 	M01_convo.morningstar.handle = INVALID_CONVERSATION_HANDLE 
  4250. 	M01_conversation_playing = false 
  4251.  
  4252. end 
  4253.  
  4254. -- Josh and Shaundi talk when going to set the bomb 
  4255. function m01_bomb_convo_thread() 
  4256. 	-- we should put this above the vault 
  4257. 	audio_play_persona_line(LOCAL_PLAYER, "M01_Head_Above_Vault_01") 
  4258. 	 
  4259. 	delay(3.5) 
  4260. 	 
  4261. 	M01_convo.more_guys.handle = audio_conversation_load_direct(M01_convo.more_guys.name)	 
  4262. 	thread_yield() 
  4263. 	 
  4264. 	-- More guards from elevator 
  4265. 	M01_conversation_playing = true 
  4266. 	audio_conversation_play(M01_convo.more_guys.handle) 
  4267. 	thread_yield() 
  4268. 	 
  4269. 	audio_conversation_wait_for_end(M01_convo.more_guys.handle) 
  4270. 	M01_convo.more_guys.handle = INVALID_CONVERSATION_HANDLE 
  4271. 	M01_conversation_playing = false 
  4272. 	 
  4273. 	-- break 
  4274. 	delay(2.3) 
  4275. 		 
  4276. 	M01_convo.josh_and_shaundi.handle = audio_conversation_load_direct(M01_convo.josh_and_shaundi.name) 
  4277. 	thread_yield() 
  4278. 	 
  4279. 	-- Don't play if autograph thing is currently happening 
  4280. 	while M01_doing_autograph do 
  4281. 		thread_yield() 
  4282. 	end 
  4283. 	 
  4284. 	-- Josh professes his love to Shaundi 
  4285. 	M01_conversation_playing = true 
  4286. 	audio_conversation_play(M01_convo.josh_and_shaundi.handle) 
  4287. 	thread_yield() 
  4288.  
  4289. 	audio_conversation_wait_for_end(M01_convo.josh_and_shaundi.handle) 
  4290. 	M01_convo.josh_and_shaundi.handle = INVALID_CONVERSATION_HANDLE 
  4291. 	M01_conversation_playing = false 
  4292. end 
  4293.  
  4294. -- spawn the bad-guys in the elevator, open doors and send them out 
  4295. function m01_elevator_guards_thread() 
  4296. 	-- spawn and go 
  4297. 	group_create(M01_group.bomb_security2.name, true) 
  4298. 	for i,rocket_man in pairs(M01_group.bomb_security2.members) do 
  4299. 		-- no rocket for you!! 
  4300. 		npc_dont_drop_weapon_on_death(rocket_man, true) 
  4301. 	end 
  4302. 	 
  4303. 	local should_run = true 
  4304. 	local should_fire = false 
  4305. 	ai_do_scripted_move(M01_shaundi, "Shaundi_leash", should_run, should_fire) 
  4306. 	ai_do_scripted_move(M01_gat, "Gat_leash<001>", should_run, true) 
  4307. 	 
  4308. 	thread_kill(M01_thread.josh_ai) 
  4309. 	ai_do_scripted_move(M01_josh, "Josh_leash", should_run, should_fire) 
  4310. 	 
  4311. 	m01_setup_see_saints(M01_group.bomb_security2.members) 
  4312. 	local locked = false 
  4313. 	door_lock(M01_ELEVATOR_DOOR, locked) 
  4314. 	door_open(M01_ELEVATOR_DOOR) 
  4315. 	 
  4316. 	-- need to leash Shaundi so she doesn't run away and hide 
  4317. 	npc_leash_to_nav(M01_shaundi, "Shaundi_leash", 3.0) 
  4318. 	npc_leash_to_nav(M01_gat, "Gat_leash<001>", 5.0) 
  4319. 	 
  4320. 	delay(2.0) 
  4321. 	 
  4322. 	local nav1 = "Start_player_nav<001>" 
  4323. 	local nav2 = "Start_player_nav<002>" 
  4324. 	local move_to = nav1 
  4325. 	for i, guard in pairs(M01_group.bomb_security2.members) do 
  4326. 		npc_leash_to_nav(guard, move_to, 12) 
  4327. 		ai_do_scripted_take_cover(guard, move_to) 
  4328. 		ai_add_enemy_target(M01_shaundi, guard, ATTACK_NOW, false) 
  4329. 		delay(0.1) 
  4330. 		if move_to == nav1 then 
  4331. 			move_to = nav2 
  4332. 		else 
  4333. 			move_to = nav1 
  4334. 		end 
  4335. 	end	 
  4336. end 
  4337.  
  4338. -- setup the Saints Fan wanting an autograph from player 
  4339. function m01_setup_autograph_thread() 
  4340. 	M01_doing_autograph = false 
  4341. 	-- spawn the group of 1 
  4342. 	local block = true 
  4343. 	group_create(M01_group.autograph.name, block) 
  4344. 	 
  4345. 	while not character_is_ready(M01_group.autograph.guy) do 
  4346. 		thread_yield() 
  4347. 	end 
  4348. 	 
  4349. 	-- don't cower 
  4350. 	set_cant_cower_flag(M01_group.autograph.guy, true) 
  4351. 	 
  4352. 	-- don't fight me 
  4353. 	npc_combat_enable(M01_group.autograph.guy, false) 
  4354. 	 
  4355. 	-- don't flinch 
  4356. 	character_prevent_flinching(M01_group.autograph.guy, true) 
  4357. 	 
  4358. 	-- setup voice 
  4359. 	persona_override_persona_start(M01_group.autograph.guy, "Interrogation") 
  4360. 	 
  4361. 	-- setup fallback in case he is killed 
  4362. 	on_death("m01_autograph_death_cb", M01_group.autograph.guy) 
  4363. 	on_take_damage("m01_autograph_death_cb", M01_group.autograph.guy) 
  4364. 	 
  4365. 	-- put him in his animation 
  4366. 	set_animation_state(M01_group.autograph.guy, "AutoGraph Stand") 
  4367. 	 
  4368. 	-- setup his trigger 
  4369. 	m01_set_trigger(M01_group.autograph.trigger, "m01_sign_autograph_cb") 
  4370. 		 
  4371. 	M01_group.autograph.effect_handle = effect_play_finisher(M01_group.autograph.guy, 2.4) 
  4372. 	 
  4373. 	-- just stay in this state unless you die or sign something 
  4374. 	while true do 
  4375. 		if not check_animation_state(M01_group.autograph.guy, "AutoGraph Stand") then 
  4376. 			set_animation_state(M01_group.autograph.guy, "AutoGraph Stand") 
  4377. 		end 
  4378. 		thread_yield() 
  4379. 	end 
  4380. 	-- add special effect for photo-op 
  4381. 	--marker_add_trigger(M01_group.autograph.trigger, MINIMAP_ICON_USE, INGAME_EFFECT_LOCATION)--"VFX_PhotoOpIcon") 
  4382. end 
  4383.  
  4384. -- handle conversations while on the vault 
  4385. function m01_vault_convo_thread() 
  4386. 	-- init all of our triggers 
  4387. 	M01_convo.heli_rising.start = false 
  4388. 	M01_convo.heli_jerk_back.start = false 
  4389. 	M01_convo.heli_not_leaving.start = false 
  4390. 	M01_convo.heli_drag_vault.start = false 
  4391. 	M01_convo.heli_near_collision.start = false 
  4392. 	M01_convo.vault_tipped.start = false 
  4393. 	 
  4394. 	 
  4395. 	M01_convo.hooked_up.handle = audio_conversation_load(M01_convo.hooked_up.name)	 
  4396. 		 
  4397. 	-- wait until signaled 
  4398. 	while not M01_convo.hooked_up.start do 
  4399. 		thread_yield() 
  4400. 	end	 
  4401. 	delay(M01_convo.hooked_up.delay)	 
  4402. 	audio_conversation_play(M01_convo.hooked_up.handle) 
  4403. 	thread_yield() 
  4404. 	audio_conversation_wait_for_end(M01_convo.hooked_up.handle) 
  4405. 	M01_convo.hooked_up.handle = INVALID_CONVERSATION_HANDLE	 
  4406. 	 
  4407. 	 
  4408. 	-- load the first 3 conversations 
  4409. 	M01_convo.heli_rising.handle = audio_conversation_load(M01_convo.heli_rising.name) 
  4410. 	--M01_convo.heli_jerk_back.handle = audio_conversation_load(M01_convo.heli_jerk_back.name) 
  4411. 	 
  4412. 	-- wait until signaled 
  4413. 	while not M01_convo.heli_rising.start do 
  4414. 		thread_yield() 
  4415. 	end	 
  4416. 	delay(M01_convo.heli_rising.delay)	 
  4417. 	audio_conversation_play(M01_convo.heli_rising.handle) 
  4418. 	thread_yield() 
  4419. 	audio_conversation_wait_for_end(M01_convo.heli_rising.handle) 
  4420. 	M01_convo.heli_rising.handle = INVALID_CONVERSATION_HANDLE	 
  4421. 	 
  4422. 	M01_convo.heli_not_leaving.handle = audio_conversation_load(M01_convo.heli_not_leaving.name) 
  4423. 	 
  4424. 	-- wait until signaled 
  4425. 	while not M01_convo.heli_jerk_back.start do 
  4426. 		thread_yield() 
  4427. 	end	 
  4428. 	delay(M01_convo.heli_jerk_back.delay)	 
  4429. 			 
  4430. 	audio_play_persona_line(M01_group.vault_heli.pilot, "M01_Helicopter_Jerks_Back_01") 
  4431. 	 
  4432. 	M01_convo.heli_drag_vault.handle = audio_conversation_load(M01_convo.heli_drag_vault.name) 
  4433. 	 
  4434. 	-- wait until signaled 
  4435. 	while not M01_convo.heli_not_leaving.start do 
  4436. 		thread_yield() 
  4437. 	end	 
  4438. 	delay(M01_convo.heli_not_leaving.delay)	 
  4439. 	audio_conversation_play(M01_convo.heli_not_leaving.handle) 
  4440. 	thread_yield() 
  4441. 	audio_conversation_wait_for_end(M01_convo.heli_not_leaving.handle) 
  4442. 	M01_convo.heli_not_leaving.handle = INVALID_CONVERSATION_HANDLE		 
  4443. 	 
  4444. 	M01_convo.heli_near_collision.handle = audio_conversation_load(M01_convo.heli_near_collision.name) 
  4445. 	 
  4446. 	-- wait until signaled 
  4447. 	while not M01_convo.heli_drag_vault.start do 
  4448. 		thread_yield() 
  4449. 	end	 
  4450. 	delay(M01_convo.heli_drag_vault.delay)	 
  4451. 	audio_conversation_play(M01_convo.heli_drag_vault.handle) 
  4452. 	thread_yield() 
  4453. 	audio_conversation_wait_for_end(M01_convo.heli_drag_vault.handle) 
  4454. 	M01_convo.heli_drag_vault.handle = INVALID_CONVERSATION_HANDLE	 
  4455. 	 
  4456. 	M01_convo.vault_tipped.handle = audio_conversation_load(M01_convo.vault_tipped.name) 
  4457. 	 
  4458. 	-- wait until signaled 
  4459. 	while not M01_convo.heli_near_collision.start do 
  4460. 		thread_yield() 
  4461. 	end	 
  4462. 	delay(M01_convo.heli_near_collision.delay)	 
  4463. 	audio_conversation_play(M01_convo.heli_near_collision.handle) 
  4464. 	thread_yield() 
  4465. 	audio_conversation_wait_for_end(M01_convo.heli_near_collision.handle) 
  4466. 	M01_convo.heli_near_collision.handle = INVALID_CONVERSATION_HANDLE	 
  4467. 	 
  4468. 	-- wait until signaled 
  4469. 	while not M01_convo.vault_tipped.start do 
  4470. 		thread_yield() 
  4471. 	end	 
  4472. 	delay(M01_convo.vault_tipped.delay)	 
  4473. 	audio_conversation_play(M01_convo.vault_tipped.handle) 
  4474. 	thread_yield() 
  4475. 	audio_conversation_wait_for_end(M01_convo.vault_tipped.handle) 
  4476. 	M01_convo.vault_tipped.handle = INVALID_CONVERSATION_HANDLE 
  4477. end 
  4478.  
  4479. -- These lines play at a critical time and we don't want to blow it if they play late/don't play 
  4480. function m01_same_chopper2_thread() 
  4481. 	audio_play_persona_line(LOCAL_PLAYER, "M01_Same_Attack_Chopper_02") 
  4482. 	thread_yield() 
  4483. 	 
  4484. 	while audio_persona_line_playing(LOCAL_PLAYER) do 
  4485. 		thread_yield() 
  4486. 	end 
  4487. 	audio_play_persona_line(M01_group.heli_fighter1.members[1], "M01_Bullhorn_Attack_Heli_Strafe_01") 
  4488. end 
  4489.  
  4490. -- Show Gat and Shaundi prepping for SWAT attack 
  4491. function m01_homies_prep_thread() 
  4492. 	group_show(M01_group.swat_homies.name) 
  4493. 	m01_setup_crew(M01_group.swat_homies) 
  4494. 	 
  4495. 	-- make sure we are ready before we start playing animations 
  4496. 	while not character_is_ready(M01_shaundi) do 
  4497. 		thread_yield() 
  4498. 	end 
  4499. 	 
  4500. 	npc_unholster_best_weapon(M01_gat)	 
  4501. 	npc_unholster_best_weapon(M01_shaundi) 
  4502.  
  4503. 	follower_make_independent(M01_gat, true) 
  4504. 	follower_make_independent(M01_shaundi, true) 
  4505. 	 
  4506. 	local anim_name = "Shaundi M01 Prep" 
  4507. 	local morph_name = "Shaundi M01 Prep" 
  4508. 	local force_play = false	 
  4509. 	local percentage = 0.1 
  4510. 	local stand_still = true 
  4511. 	local zero_movement = true 
  4512. 	action_play(M01_shaundi, anim_name, morph_name, force_play, percentage, stand_still, zero_movement) 
  4513. 			 
  4514. 	anim_name = "Gat M01 Prep" 
  4515. 	morph_name = "Gat M01 Prep" 
  4516. 	action_play(M01_gat, anim_name, morph_name, force_play, percentage, stand_still, zero_movement) 
  4517. end 
  4518.  
  4519. -- kill all of the helicopter movement threads if active 
  4520. function m01_kill_heli_move_threads() 
  4521. 	for i, group in pairs(M01_heli_police_groups) do 
  4522. 		if group.thread ~= INVALID_THREAD_HANDLE then 
  4523. 			thread_kill(group.thread) 
  4524. 		end 
  4525. 	end 
  4526. end 
  4527.  
  4528. -- Monitor the m01 vault's animation 
  4529. function m01_path_complete_thread()	 
  4530. 	-- wait for transition to complete 
  4531. 	while (vehicle_anim_playing(M01_group.vault_heli.vehicle)) do 
  4532. 		thread_yield() 
  4533. 	end 
  4534. end 
  4535.  
  4536. -- fly a helicopter to a specified point 
  4537. -- 
  4538. -- heli:	(string) name of the helicotper to move 
  4539. -- nav:		(string) name of the navpoint to move to 
  4540. -- speed:	(float) speed to move 
  4541. -- 
  4542. function m01_fly_direct_thread(heli, nav, speed) 
  4543. 	-- fly direct because we are very close to buildings 
  4544. 	helicopter_fly_to_direct(heli, speed, nav) 
  4545. end 
  4546.  
  4547. function m01_fineaim_tutorial() 
  4548. 	-- Fine aim tutorial 
  4549. 	tutorial_start("combat_fineaim", 1000, true) 
  4550. 	 
  4551. 	-- Wait for the fine aim tutorial to actally start displaying 
  4552. 	while not tutorial_active("combat_fineaim") do 
  4553. 		if not tutorial_queued("combat_fineaim") then 
  4554. 			-- The tutorial died for some reason. Just give up. 
  4555. 			M01_TUTORIAL_FINEAIM = INVALID_THREAD_HANDLE 
  4556. 			return 
  4557. 		end 
  4558. 		thread_yield() 
  4559. 	end 
  4560. 	 
  4561. 	-- Show the first message for at least 2 seconds 
  4562. 	delay(2.0)  
  4563. 	 
  4564. 	-- Wait for the player to hold the shoulder button 
  4565. 	while not inv_item_is_firearm_equipped() or not player_action_is_pressed("CBA_OFC_SHOULDER_CAMERA") do 
  4566. 		thread_yield() 
  4567. 	end 
  4568. 	 
  4569. 	-- Advance to case 1 
  4570. 	tutorial_advance("combat_fineaim") 
  4571. 	 
  4572. 	-- Tutorial should clean up it's self after this point 
  4573. 	M01_TUTORIAL_FINEAIM = INVALID_THREAD_HANDLE 
  4574. end 
  4575.  
  4576. -- Weapon changing tutorial. Waits until the palyer changed his weapon. 
  4577. function m01_change_weapons_tutorial() 
  4578. 	M01_weapon_changed = false 
  4579. 	on_weapon_equip("m01_weapon_was_equiped", LOCAL_PLAYER) 
  4580.  
  4581. 	tutorial_start("combat_weapons", 1000, true) 
  4582. 	 
  4583. 	-- Wait for the fine aim tutorial to actally start displaying 
  4584. 	while not tutorial_active("combat_weapons") do 
  4585. 		if not tutorial_queued("combat_weapons") then 
  4586. 			-- The tutorial died for some reason. Just give up. 
  4587. 			M01_TUTORIAL_SWITCH_WEAPON = INVALID_THREAD_HANDLE 
  4588. 			return 
  4589. 		end 
  4590. 		thread_yield() 
  4591. 	end 
  4592. 	 
  4593. 	-- Show the first message for at least 2 seconds 
  4594. 	delay(2.0)  
  4595. 	 
  4596. 	-- Wait for the player to switch weapons 
  4597. 	while not M01_weapon_changed do 
  4598. 		if not tutorial_active("combat_weapons") then 
  4599. 			-- The tutorial died for some reason. Just give up. 
  4600. 			M01_TUTORIAL_SWITCH_WEAPON = INVALID_THREAD_HANDLE 
  4601. 			return 
  4602. 		end 
  4603. 		thread_yield() 
  4604. 	end 
  4605. 	 
  4606. 	tutorial_advance("combat_weapons")	 
  4607. 	 
  4608. 	M01_TUTORIAL_SWITCH_WEAPON = INVALID_THREAD_HANDLE 
  4609. end 
  4610.  
  4611. -- Thread to get helicopters loaded and off the ground 
  4612. -- 
  4613. -- group_table:		(table) information about the heli group 
  4614. -- float_nav:		(string) name of navpoint to float the heli at 
  4615. -- 
  4616. function m01_spawn_and_float_heli_thread(group_table, float_nav) 
  4617. 	group_create(group_table.name, true) 
  4618. 	vehicle_enter_group_teleport(group_table.members, group_table.vehicle) 
  4619. 	vehicle_enter_teleport(group_table.shooter, group_table.vehicle, group_table.shooter_seat) 
  4620. 	m01_float_heli(group_table, float_nav) 
  4621. end 
  4622.  
  4623. -- handle news heli stuff (spotlights) 
  4624. -- 
  4625. -- group_table:		(table) everything I need to make news heli work 
  4626. -- 
  4627. function m01_news_heli_thread(group_table) 
  4628. -- news_heli1 
  4629. 	local current_location = 0	-- always start at float nav 
  4630. 	-- spawn it, load it and get it in the air 
  4631. 	group_create(group_table.name, true) 
  4632. 	vehicle_enter_group_teleport(group_table.members, group_table.vehicle) 
  4633. 	m01_float_heli(group_table, group_table.float_nav) 
  4634. 	local current_nav = group_table.float_nav 
  4635. 	 
  4636. 	while true do 
  4637. 		if current_location ~= M01_news_location then 
  4638. 			if M01_news_location <= group_table.max_locations then 
  4639. 				current_location = M01_news_location 
  4640. 			else 
  4641. 				current_location = group_table.max_locations 
  4642. 			end 
  4643. 		end 
  4644. 		 
  4645. 		if vehicle_is_destroyed(group_table.vehicle) then 
  4646. 			return 
  4647. 		end 
  4648. 		 
  4649. 		local location_info = group_table.location[current_location] 
  4650. 		if current_nav ~= location_info.hover_nav then 
  4651. 			-- go to where I need to be 
  4652. 			current_nav = location_info.hover_nav 
  4653. 			if location_info.looping_path then 
  4654. 				helicopter_fly_to_direct_loop(group_table.vehicle, 20, current_nav) 
  4655. 			else 
  4656. 				-- direct call waits for completion before continuing 
  4657. 				helicopter_fly_to_direct(group_table.vehicle, -1, current_nav) 
  4658. 			end 
  4659. 		else 
  4660. 			-- make sure we haven't strayed too far from our hover nav 
  4661. 			if not location_info.looping_path and get_dist(group_table.vehicle, current_nav) > 5.0 then 
  4662. 				-- get back over there 
  4663. 				helicopter_fly_to_direct(group_table.vehicle, -1, current_nav) 
  4664. 			end 
  4665. 		end 
  4666. 		 
  4667. 		thread_yield() 
  4668. 		-- art no like spotlights 
  4669. --		-- make my spotlight look at stuff 
  4670. --		for i,point in pairs(location_info.interest) do 
  4671. --			if vehicle_is_destroyed(group_table.vehicle) or character_is_dead(group_table.members[1]) then 
  4672. --				return 
  4673. --			end 
  4674. --			vehicle_spotlight_is_target_spotted(group_table.members[1], point) 
  4675. --			delay(location_info.delay_time) 
  4676. --		end 
  4677. 	end		 
  4678. end 
  4679.  
  4680. -- Thread to handle a respawning pair 
  4681. -- 
  4682. -- pair_table:		(table) group information about the pair 
  4683. function m01_respawn_pair_thread(pair_table) 
  4684. 	-- start disabled 
  4685. 	pair_table.active = false 
  4686. 	 
  4687. 	-- run until killed 
  4688. 	while true do 
  4689. 		-- see if we should spawn/respawn 
  4690. 		while not pair_table.active do 
  4691. 			thread_yield() 
  4692. 		end 
  4693. 		 
  4694. 		while (not thread_check_done(M01_thread.respawn_timer)) do 
  4695. 			thread_yield() 
  4696. 		end 
  4697. 		 
  4698. 		-- claim it		 
  4699. 		M01_thread.respawn_timer = thread_new("delay", 1.5) 
  4700. 		 
  4701. 		-- spawn the group 
  4702. 		group_create(pair_table.name, true) 
  4703. 		 
  4704. 		-- keep a count 
  4705. 		M01_pairs_spawned = M01_pairs_spawned + 1 
  4706. 		 
  4707. 		if (pair_table.window_entry) then 
  4708. 			-- play swat animation 
  4709. 			pair_table.entry_thread = thread_new("m01_swat_entry", pair_table.members[1], pair_table.navs[pair_table.set][1], pair_table.ropes[1]) 
  4710. 			delay(0.3) 
  4711. 			pair_table.entry_thread = thread_new("m01_swat_entry", pair_table.members[2], pair_table.navs[pair_table.set][2], pair_table.ropes[2])			 
  4712. 		else 
  4713. 			-- tell them to go to their navpoints	 
  4714. 			local should_run = true 
  4715. 			local should_fire = false 
  4716. 			ai_do_scripted_move(pair_table.members[1], pair_table.navs[pair_table.set][1], should_run, should_fire) 
  4717. 			ai_do_scripted_move(pair_table.members[2], pair_table.navs[pair_table.set][2], should_run, should_fire) 
  4718. 			-- target player, not the pilot 
  4719. 			ai_add_enemy_target(pair_table.members[1], LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE, true) 
  4720. 			if (coop_is_active() == true) then 
  4721. 				ai_add_enemy_target(pair_table.members[2], REMOTE_PLAYER, ATTACK_NOW_NEVER_LOSE, true) 
  4722. 			else 
  4723. 				ai_add_enemy_target(pair_table.members[2], LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE, true) 
  4724. 			end 
  4725. 		end 
  4726. 		 
  4727. 		-- wait until they are dead 
  4728. 		while not character_is_dead(pair_table.members[1]) do 
  4729. 			thread_yield() 
  4730. 		end 
  4731. 		 
  4732. 		while not character_is_dead(pair_table.members[2]) do 
  4733. 			thread_yield() 
  4734. 		end 
  4735. 		 
  4736. 		-- clear callback 
  4737. 		on_attack_performed("", pair_table.members[1]) 
  4738. 		on_attack_performed("", pair_table.members[2]) 
  4739. 		 
  4740. 		-- release so we can respawn 
  4741. 		release_to_world(pair_table.name) 
  4742. 		 
  4743. 		-- keep a count 
  4744. 		M01_pairs_spawned = M01_pairs_spawned - 1 
  4745. 		 
  4746. 		-- change where we send them to 
  4747. 		if pair_table.set == 1 then 
  4748. 			pair_table.set = 2 
  4749. 		else 
  4750. 			pair_table.set = 1 
  4751. 		end 
  4752. 		 
  4753. 		-- delay before respawn 
  4754. 		delay(2.3) 
  4755. 	end 
  4756. end 
  4757.  
  4758. -- Spawn a transport, load passengers and float at navpoint 
  4759. -- 
  4760. -- transport_table:		(table) transport information 
  4761. -- 
  4762. function m01_setup_transport_thread(transport_table) 
  4763. 	group_create(transport_table.name, true) 
  4764. 	 
  4765. 	transport_table.complete = false 
  4766. 	-- pilots first 
  4767. 	local seat_idx = 0 
  4768. 	for i, char in pairs(transport_table.pilots) do 
  4769. 		-- Put the pilots into the vehicle 
  4770. 		vehicle_enter_teleport(char, transport_table.vehicle, seat_idx, true) 
  4771. 		follower_remain_in_car(char, true) 
  4772. 		-- no floating weapons when vehicle is destroyed 
  4773. 		npc_combat_enable(char, false) 
  4774. 		while(not character_is_in_vehicle(char, transport_table.vehicle)) do 
  4775. 			thread_yield() 
  4776. 		end 
  4777. 		 
  4778. 		seat_idx = seat_idx + 1 
  4779. 	end 
  4780. 	for i, char in pairs(transport_table.soldiers) do 
  4781. 		-- Put the soldiers into the vehicle 
  4782. 		vehicle_enter_teleport(char, transport_table.vehicle, seat_idx, true) 
  4783. 		follower_remain_in_car(char, true)		 
  4784. 		while(not character_is_in_vehicle(char, transport_table.vehicle)) do 
  4785. 			thread_yield() 
  4786. 		end 
  4787. 		 
  4788. 		seat_idx = seat_idx + 1 
  4789. 	end 
  4790. 	 
  4791. 	m01_float_heli(transport_table, transport_table.float_nav) 
  4792. 	 
  4793. end 
  4794.  
  4795. -- tell a transport to do a flyby and teleport back to float nav 
  4796. -- 
  4797. -- transport_table:		(table) Information about our transport heli 
  4798. -- 
  4799. function m01_transport_flyby_thread(transport_table) 
  4800. 	-- make heli invulnerable for flyby 
  4801. 	turn_invulnerable(transport_table.vehicle) 
  4802. 	 
  4803. 	-- float at the start	 
  4804. 	m01_float_heli(transport_table, transport_table.flyby_float) 
  4805. 	 
  4806. 	-- pause for effect 
  4807. 	delay(2.0) 
  4808. 	 
  4809. 	-- fly the path 
  4810. 	m01_fly_direct_thread(transport_table.vehicle, transport_table.flyby_path, 30.0)	 
  4811. 	 
  4812. 	-- move back to starting float area 
  4813. 	m01_float_heli(transport_table, transport_table.float_nav) 
  4814. 	turn_vulnerable(transport_table.vehicle) 
  4815. end 
  4816.  
  4817. -- Hide or show a transport helicopter and crew 
  4818. -- 
  4819. -- transport_table:		(table) Information about our transport heli 
  4820. -- show:				(boolean) true to show, false to hide 
  4821. -- 
  4822. function m01_transport_show(transport_table, show) 
  4823. 	if show then 
  4824. 		vehicle_show(transport_table.vehicle) 
  4825. 		for i,char in pairs(transport_table.soldiers) do 
  4826. 			character_show(char) 
  4827. 		end 
  4828. 		for j,pilots in pairs(transport_table.pilots) do 
  4829. 			character_show(pilots) 
  4830. 		end		 
  4831. 	else 
  4832. 		vehicle_hide(transport_table.vehicle) 
  4833. 		for i,char in pairs(transport_table.soldiers) do 
  4834. 			character_hide(char) 
  4835. 		end 
  4836. 		for j,pilots in pairs(transport_table.pilots) do 
  4837. 			character_hide(pilots) 
  4838. 		end 
  4839. 	end 
  4840. end 
  4841.  
  4842. -- Emergency destroy in case the transport does not land properly (flips upsidedown or gets caught on something) 
  4843. -- 
  4844. -- vehicle:		(string) name of the transport helicopter 
  4845. -- 
  4846. function m01_transport_emergency_destroy_thread(vehicle) 
  4847. 	-- simple delay to determine how long we have (extra long) 
  4848. 	delay(45.0) 
  4849. 	 
  4850. 	-- times up, you are now vulnerable 
  4851. 	turn_vulnerable(vehicle) 
  4852. 	-- so blow up (callback will clean the rest up 
  4853. 	vehicle_detonate(vehicle) 
  4854. end 
  4855. 	 
  4856.  
  4857. -- Drop off some troops and get out (weak helicopter drop-off) (script stolen from m10) 
  4858. -- 
  4859. -- transport_table:		(table) Information about our drop-off group 
  4860. -- 
  4861. function m01_transport_drop_off_thread(transport_table) 
  4862. 	 
  4863. 	if (transport_table.persona_line ~= "") then 
  4864. 		persona_override_persona_start(transport_table.pilots[1], transport_table.pilot_persona) 
  4865. 	end 
  4866. 	 
  4867. 	turn_invulnerable(transport_table.vehicle) 
  4868. 	 
  4869. 	-- mark transport as complete if the heli is destroyed 
  4870. 	on_vehicle_destroyed("m01_transport_destroyed_cb", transport_table.vehicle) 
  4871. 	 
  4872. 	-- reuse setup thread as emergency timer 
  4873. 	transport_table.setup_thread = thread_new("m01_transport_emergency_destroy_thread", transport_table.vehicle) 
  4874. 	 
  4875. 	-- get close 
  4876. 	transport_table.thread = thread_new("m01_fly_direct_thread", transport_table.vehicle, transport_table.path, 45.0) 
  4877. 	while get_dist(transport_table.vehicle, transport_table.path) > 70.0 do 
  4878. 		thread_yield() 
  4879. 	end	 
  4880. 	thread_kill(transport_table.thread) 
  4881. 	 
  4882. 	-- get closer slower 
  4883. 	transport_table.thread = thread_new("m01_fly_direct_thread", transport_table.vehicle, transport_table.path, 10.0) 
  4884. 	while get_dist(transport_table.vehicle, transport_table.path) > 6.0 do 
  4885. 		thread_yield() 
  4886. 	end	 
  4887. 	thread_kill(transport_table.thread) 
  4888. 	 
  4889. 	-- get closer slower 
  4890. 	transport_table.thread = thread_new("m01_fly_direct_thread", transport_table.vehicle, transport_table.path, 3.0) 
  4891. 	while get_dist(transport_table.vehicle, transport_table.path) > 2.0 do 
  4892. 		thread_yield() 
  4893. 	end	 
  4894. 	thread_kill(transport_table.thread) 
  4895. 	 
  4896. 	-- get closer slower 
  4897. 	transport_table.thread = thread_new("m01_fly_direct_thread", transport_table.vehicle, transport_table.path, 1.5) 
  4898. 	while get_dist(transport_table.vehicle, transport_table.path) > 2.2 do 
  4899. 		thread_yield() 
  4900. 	end	 
  4901. 	thread_kill(transport_table.thread) 
  4902. 	 
  4903. 	-- lets play a line 
  4904. 	if (transport_table.persona_line ~= "") then 
  4905. 		audio_play_persona_line(transport_table.pilots[1], transport_table.persona_line) 
  4906. 	end 
  4907. 	 
  4908. 	delay(0.5) 
  4909. 		 
  4910. 	turn_vulnerable(transport_table.vehicle) 
  4911. 	 
  4912. 	-- don't auto-destroy from here on 
  4913. 	thread_kill(transport_table.setup_thread) 
  4914. 	 
  4915. 	for i, char in pairs(transport_table.soldiers) do 
  4916. 		follower_remain_in_car(char, false) 
  4917. 	end 
  4918. 	vehicle_exit_group(transport_table.soldiers, true)	-- unenterable to make sure the soldiers don't try to get back in the transport 
  4919. 	 
  4920. 	local should_run = true 
  4921. 	local should_fire = false 
  4922. 	 
  4923. 	-- close enough 
  4924. 	for j, char in pairs(transport_table.soldiers) do 
  4925. 		if (character_is_dead(char) == false) then 
  4926. 			ai_add_enemy_target(char, LOCAL_PLAYER, ATTACK_ON_SIGHT, true) 
  4927. 			if (coop_is_active() == true) then 
  4928. 				ai_add_enemy_target(char, REMOTE_PLAYER, ATTACK_ON_SIGHT, true) 
  4929. 			end 
  4930. 			 
  4931. 			--ai_do_scripted_take_cover(char) 
  4932. 			ai_do_scripted_move(char, transport_table.soldier_dest, should_run, should_fire) 
  4933. 		end 
  4934. 	end 
  4935. 	delay(transport_table.ground_delay) 
  4936. 	persona_override_persona_stop(transport_table.pilots[1]) 
  4937.  
  4938. 	transport_table.thread = thread_new("m01_fly_direct_thread", transport_table.vehicle, transport_table.exit_nav, 25.0) 
  4939. 	 
  4940. 	while get_dist(transport_table.vehicle, transport_table.path) < 20.0 do 
  4941. 		thread_yield() 
  4942. 	end 
  4943. 	 
  4944. 	-- if we make it out, consider it complete 
  4945. 	transport_table.complete = true 
  4946. end 
  4947.  
  4948. -- Attack heli AI while the player is in the building 
  4949. -- 
  4950. -- group_table:		(table) information about the attack heli 
  4951. function m01_attack_heli_building_battle_thread( group_table ) 
  4952. 	while not M01_group.heli_fighter1.permission_to_fire do 
  4953. 		thread_yield() 
  4954. 	end 
  4955. 	 
  4956. 	npc_combat_enable(group_table.members[1], true)	 
  4957. 	npc_combat_enable(group_table.members[2], true) 
  4958.  
  4959. 	local path_orient = HELI_PF_FACE_TARGET -- front face target 
  4960. 	helicopter_set_path_orientation( group_table.vehicle, path_orient, LOCAL_PLAYER) 
  4961. 	 
  4962. 	local missle_delay = 1.0 
  4963. 	local attack_delay = 2.5 
  4964. 		 
  4965. 	-- shoot warning missiles at back wall 
  4966. 	local alt_fire = true 
  4967. 	helicopter_shoot_navpoint(group_table.vehicle, "battle_rocket_target<004>", alt_fire) 
  4968. 	delay(missle_delay) 
  4969. 	helicopter_shoot_navpoint(group_table.vehicle, "battle_rocket_target<004>", alt_fire)	 
  4970. 	 
  4971. 	M01_group.heli_fighter1.thread = thread_new("m01_fly_direct_thread", group_table.vehicle, "battle_retreat_point", 8.0) 
  4972. 	while get_dist(group_table.vehicle, "battle_retreat_point") > 5.0 do 
  4973. 		thread_yield() 
  4974. 	end	 
  4975. 	delay(attack_delay) 
  4976. 	 
  4977. 	local do_sweep = true 
  4978. 	 
  4979. 	while M01_group.heli_fighter1.permission_to_fire do 
  4980. 			 
  4981. 		if M01_group.heli_fighter1.permission_to_fire then 
  4982. 			M01_group.heli_fighter1.thread = thread_new("m01_fly_direct_thread", group_table.vehicle, "battle_attack_point<002>", 7.0) 
  4983. 		end 
  4984. 		while get_dist(group_table.vehicle, "battle_attack_point<002>") > 5.0 do 
  4985. 			thread_yield() 
  4986. 		end	 
  4987. 		 
  4988. 		if M01_group.heli_fighter1.permission_to_fire then 
  4989. 			M01_group.heli_fighter1.thread = thread_new("m01_fly_direct_thread", group_table.vehicle, "battle_attack_point<003>", 1.0) 
  4990. 		end 
  4991. 		 
  4992. 		if do_sweep then 
  4993. 			-- sweep the gun 
  4994. 			local seconds = 0.4 
  4995. 			if M01_group.heli_fighter1.permission_to_fire then 
  4996. 				m01_heli_shoot_gun_at_nav(group_table.vehicle, "battle_target<001>", seconds) 
  4997. 			end 
  4998. 			if M01_group.heli_fighter1.permission_to_fire then 
  4999. 				m01_heli_shoot_gun_at_nav(group_table.vehicle, "battle_target<002>", seconds) 
  5000. 			end 
  5001. 			if M01_group.heli_fighter1.permission_to_fire then 
  5002. 				m01_heli_shoot_gun_at_nav(group_table.vehicle, "battle_target<003>", seconds) 
  5003. 			end 
  5004. 			if M01_group.heli_fighter1.permission_to_fire then 
  5005. 				m01_heli_shoot_gun_at_nav(group_table.vehicle, "battle_target<004>", seconds) 
  5006. 			end 
  5007. 			if M01_group.heli_fighter1.permission_to_fire then 
  5008. 				m01_heli_shoot_gun_at_nav(group_table.vehicle, "battle_target<005>", seconds) 
  5009. 			end 
  5010. 			if M01_group.heli_fighter1.permission_to_fire then 
  5011. 				m01_heli_shoot_gun_at_nav(group_table.vehicle, "battle_target<006>", seconds) 
  5012. 			end 
  5013. 			if M01_group.heli_fighter1.permission_to_fire then 
  5014. 				m01_heli_shoot_gun_at_nav(group_table.vehicle, "battle_target<007>", seconds) 
  5015. 			end 
  5016. 			if M01_group.heli_fighter1.permission_to_fire then 
  5017. 				m01_heli_shoot_gun_at_nav(group_table.vehicle, "battle_target<008>", seconds) 
  5018. 			end 
  5019. 			if M01_group.heli_fighter1.permission_to_fire then 
  5020. 				m01_heli_shoot_gun_at_nav(group_table.vehicle, "battle_target<007>", seconds) 
  5021. 			end 
  5022. 			if M01_group.heli_fighter1.permission_to_fire then 
  5023. 				m01_heli_shoot_gun_at_nav(group_table.vehicle, "battle_target<006>", seconds) 
  5024. 			end 
  5025. 			if M01_group.heli_fighter1.permission_to_fire then 
  5026. 				m01_heli_shoot_gun_at_nav(group_table.vehicle, "battle_target<005>", seconds) 
  5027. 			end 
  5028. 			if M01_group.heli_fighter1.permission_to_fire then 
  5029. 				m01_heli_shoot_gun_at_nav(group_table.vehicle, "battle_target<004>", seconds) 
  5030. 			end 
  5031. 			if M01_group.heli_fighter1.permission_to_fire then 
  5032. 				m01_heli_shoot_gun_at_nav(group_table.vehicle, "battle_target<003>", seconds) 
  5033. 			end 
  5034. 			if M01_group.heli_fighter1.permission_to_fire then 
  5035. 				m01_heli_shoot_gun_at_nav(group_table.vehicle, "battle_target<002>", seconds) 
  5036. 			end 
  5037. 			if M01_group.heli_fighter1.permission_to_fire then 
  5038. 				m01_heli_shoot_gun_at_nav(group_table.vehicle, "battle_target<001>", seconds) 
  5039. 			end 
  5040. 			--do_sweep = false 
  5041. 		else 
  5042. 			-- shoot player or another target 
  5043. 			local shoot_human_seconds = 6.0 
  5044. 			m01_heli_shoot_gun_at_human(group_table.vehicle, LOCAL_PLAYER, shoot_human_seconds) 
  5045. 			--do_sweep = true 
  5046. 		end 
  5047.  
  5048. 		if M01_group.heli_fighter1.permission_to_fire then 
  5049. 			M01_group.heli_fighter1.thread = thread_new("m01_fly_direct_thread", group_table.vehicle, "battle_retreat_point", 8.0) 
  5050. 			while get_dist(group_table.vehicle, "battle_retreat_point") > 5.0 do 
  5051. 				thread_yield() 
  5052. 			end	 
  5053. 		end 
  5054. 		 
  5055. 		if M01_group.heli_fighter1.permission_to_fire then 
  5056. 			delay(attack_delay) 
  5057. 		end		 
  5058. 		 
  5059. 		if M01_group.heli_fighter1.permission_to_fire then 
  5060. 			M01_group.heli_fighter1.thread = thread_new("m01_fly_direct_thread", group_table.vehicle, "battle_attack_point<001>", 10.0) 
  5061. 			while get_dist(group_table.vehicle, "battle_attack_point<001>") > 5.0 do 
  5062. 				thread_yield() 
  5063. 			end	 
  5064. 		end 
  5065. 		 
  5066. 		-- Rockets in center 
  5067. 		if M01_group.heli_fighter1.permission_to_fire then 
  5068. 			helicopter_shoot_navpoint(group_table.vehicle, "battle_rocket_target<001>", alt_fire) 
  5069. 			delay(missle_delay) 
  5070. 			helicopter_shoot_navpoint(group_table.vehicle, "battle_rocket_target<002>", alt_fire)		 
  5071. 			delay(missle_delay) 
  5072. 			helicopter_shoot_navpoint(group_table.vehicle, "battle_rocket_target<004>", alt_fire) 
  5073. 			delay(missle_delay) 
  5074. 			helicopter_shoot_navpoint(group_table.vehicle, "battle_rocket_target<003>", alt_fire)		 
  5075. 			delay(attack_delay) 
  5076. 		end 
  5077. 		 
  5078. 		 
  5079. 		if M01_group.heli_fighter1.permission_to_fire then 
  5080. 			M01_group.heli_fighter1.thread = thread_new("m01_fly_direct_thread", group_table.vehicle, "battle_retreat_point", 8.0) 
  5081. 			while get_dist(group_table.vehicle, "battle_retreat_point") > 5.0 do 
  5082. 				thread_yield() 
  5083. 			end	 
  5084. 			delay(attack_delay) 
  5085. 		end 
  5086. 		 
  5087. 	end 
  5088.  
  5089. end 
  5090.  
  5091. -- Send the heli fighter on an attack run 
  5092. -- 
  5093. -- group_table:		(table) information about the attack heli 
  5094. -- attack_run:		(table) information about the attack run 
  5095. -- 
  5096. function m01_fighter_attack_run_thread( group_table, attack_run ) 
  5097. 	M01_fighter_run_complete = false 
  5098. 	-- fly this path 
  5099. 	group_table.thread = thread_new("m01_fly_direct_thread", group_table.vehicle, attack_run.enter_path, 30.0) 
  5100. 	 
  5101. 	-- get kinda close 
  5102. 	while get_dist(group_table.vehicle, attack_run.float_from_nav) > 15.0 do 
  5103. 		thread_yield() 
  5104. 	end 
  5105. 	 
  5106. 	-- target the fighter and tell the player 
  5107. 	marker_add(group_table.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL)	 
  5108. 	objective_text( 0, "M01_KILL_CHOPPER", "", "", SYNC_ALL, OI_ASSET_KILL ) 
  5109. 	 
  5110. 	-- focus on the player 
  5111. 	local path_orient = HELI_PF_FACE_TARGET -- front face target 
  5112. 	helicopter_set_path_orientation( group_table.vehicle, path_orient, LOCAL_PLAYER) 
  5113. 	 
  5114. 	 
  5115. 	-- until you are close to this navpoint or thread complete 
  5116. 	while (not thread_check_done(group_table.thread)) or get_dist(group_table.vehicle, attack_run.float_from_nav) > 5.0 do 
  5117. 		thread_yield() 
  5118. 	end 
  5119. 	 
  5120. 	-- move to this navpoint 
  5121. 	group_table.thread = thread_new("m01_fly_direct_thread", group_table.vehicle, attack_run.float_to_nav, attack_run.float_speed) 
  5122. 	 
  5123. 	-- short pause 
  5124. 	delay(0.5) 
  5125. 	 
  5126. 	npc_combat_enable(group_table.members[1], true)	 
  5127. 	npc_combat_enable(group_table.members[2], true) 
  5128. 	-- shoot here 
  5129. 	m01_heli_shoot_gun_at_nav(group_table.vehicle, attack_run.gun_target, attack_run.gun_time) 
  5130. 	 
  5131. 	delay(0.2) 
  5132. 	audio_play_persona_line(M01_group.heli_fighter1.members[1], attack_run.persona_line) 
  5133. 	 
  5134. 	npc_combat_enable(group_table.members[1], false)	 
  5135. 	npc_combat_enable(group_table.members[2], false) 
  5136. 	 
  5137. 	-- get this close 
  5138. 	while get_dist(group_table.vehicle, attack_run.float_to_nav) > 1.0 do 
  5139. 		thread_yield() 
  5140. 	end 
  5141. 	 
  5142. 	-- fire some missles at the pilot 
  5143. 	m01_fighter_shoot_vault(attack_run.hit_delay)	 
  5144. 	 
  5145. 	-- take the exit path 
  5146. 	M01_fighter_run_complete = true 
  5147. 	 
  5148. 	-- back to old objective 
  5149. 	marker_remove(group_table.vehicle) 
  5150. 	turn_invulnerable(group_table.vehicle) 
  5151. 	objective_text( 0, "m01_survive", "", "", SYNC_ALL, OI_ASSET_DEFEND ) 
  5152. 	 
  5153. 	-- get out of here 
  5154. 	path_orient = HELI_PF_FACE_ALONG_PATH -- back to normal 
  5155. 	helicopter_set_path_orientation(group_table.vehicle, path_orient) 
  5156. 	 
  5157. 	group_table.thread = thread_new("m01_fly_direct_thread", group_table.vehicle, attack_run.exit_path, 30.0) 
  5158. 	 
  5159. end 
  5160.  
  5161. -- Let the attack heli attack in little chunks 
  5162. -- 
  5163. -- group_table:		(table) information about the attack heli 
  5164. -- 
  5165. function m01_attack_heli_gunner_thread( group_table ) 
  5166. 	-- nobody in the heli attacks...yet 
  5167. 	npc_combat_enable(group_table.members[1], false)	 
  5168. 	npc_combat_enable(group_table.members[2], false)	 
  5169. 	 
  5170. 	while true do 
  5171. 		while not group_table.permission_to_fire do 
  5172. 			thread_yield() 
  5173. 		end 
  5174. 		 
  5175. 		while get_dist(group_table.vehicle, group_table.final_nav[2]) > 5.0 do 
  5176. 			thread_yield() 
  5177. 		end 
  5178. 		 
  5179. 		local path_orient = HELI_PF_FACE_TARGET -- front face target 
  5180. 		helicopter_set_path_orientation( group_table.vehicle, path_orient, LOCAL_PLAYER) 
  5181. 		 
  5182. 		 
  5183. 		if group_table.permission_to_fire then 
  5184. 			-- as soon as we are released, take a few shots 
  5185. 			npc_combat_enable(group_table.members[1], true) 
  5186. 			npc_combat_enable(group_table.members[2], true) 
  5187. 			-- target the player 
  5188. 			ai_add_enemy_target(group_table.members[1], LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE, true)	 
  5189. 			ai_add_enemy_target(group_table.members[2], LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE, true)		 
  5190. 		end 
  5191. 			 
  5192. 		if group_table.permission_to_fire then 
  5193. 			-- fire for a few seconds 
  5194. 			delay(1.0) 
  5195. 		end 
  5196. 		 
  5197. 		-- stop 
  5198. 		npc_combat_enable(group_table.members[1], false) 
  5199. 		npc_combat_enable(group_table.members[2], false)	 
  5200. 		 
  5201. 		if group_table.permission_to_fire then 
  5202. 			-- move here 
  5203. 			group_table.thread = thread_new("m01_fly_direct_thread", group_table.vehicle, group_table.final_nav[1], 2.0 ) 
  5204. 		end 
  5205. 		 
  5206. 		if group_table.permission_to_fire then 
  5207. 			-- shoot a bit more 
  5208. 			npc_combat_enable(group_table.members[1], true) 
  5209. 			npc_combat_enable(group_table.members[2], true) 
  5210. 			-- target the player 
  5211. 			ai_add_enemy_target(group_table.members[1], LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE, true)	 
  5212. 			ai_add_enemy_target(group_table.members[2], LOCAL_PLAYER, ATTACK_NOW_NEVER_LOSE, true)		 
  5213. 		end 
  5214. 		 
  5215. 		if group_table.permission_to_fire then 
  5216. 			-- fire for a few seconds 
  5217. 			delay(1.5) 
  5218. 		end 
  5219. 			 
  5220. 		-- stop 
  5221. 		npc_combat_enable(group_table.members[1], false) 
  5222. 		npc_combat_enable(group_table.members[2], false)	 
  5223. 		 
  5224. 		delay(2.0) 
  5225. 		 
  5226. 		 
  5227. 		if group_table.permission_to_fire then 
  5228. 			-- go back 
  5229. 			group_table.thread = thread_new("m01_fly_direct_thread", group_table.vehicle, group_table.final_nav[2], 1.0 ) 
  5230. 		end 
  5231. 		 
  5232. 		-- cooldown 
  5233. 		delay(3.0) 
  5234. 	end	 
  5235. end 
  5236.  
  5237. -- Handle Shanundi getting attacked 
  5238. -- 
  5239. function m01_shaundi_attacked_thread() 
  5240. 	-- we are not ready 
  5241. 	M01_shaundi_attack.in_place = false 
  5242. 	 
  5243. 	-- setup trigger 
  5244. 	M01_trigger.shaundi_attack.hit = false 
  5245. 	m01_set_trigger(M01_trigger.shaundi_attack.name, "m01_attack_shaundi_cb") 
  5246. 		 
  5247. 	-- wait for freerun trigger hit 
  5248. 	while not M01_trigger.freerun.hit do 
  5249. 		thread_yield() 
  5250. 	end 
  5251. 	 
  5252. 	-- tell shaundi to get to her location 
  5253. 	local should_run = true 
  5254. 	local should_fire = false 
  5255. 	ai_do_scripted_move(M01_shaundi, M01_shaundi_attack.shuandi_nav, should_run, should_fire) 
  5256. 	 
  5257. 	while not ai_scripted_action_is_complete(M01_shaundi) do 
  5258. 		thread_yield() 
  5259. 	end 
  5260. 	 
  5261. 	-- did we beat the player upstairs? 
  5262. 	if M01_trigger.shaundi_attack.hit then 
  5263. 		return	-- missed it 
  5264. 	end 
  5265. 	 
  5266. 	set_ignore_ai_flag(M01_shaundi, true) 
  5267. 	 
  5268. 	-- exactly in place (out of sight) 
  5269. 	teleport(M01_shaundi, M01_shaundi_attack.shuandi_nav, false) 
  5270. 	M01_shaundi_attack.in_place = true 
  5271. 	 
  5272. 	-- spin until trigger is hit 
  5273. 	while not M01_trigger.shaundi_attack.hit do 
  5274. 		thread_yield() 
  5275. 	end 
  5276. 	 
  5277. 	-- double make sure Shaundi is in place (grr)	 
  5278. 	teleport(M01_shaundi, M01_shaundi_attack.shuandi_attack, false) 
  5279. 	 
  5280. 	-- make dude invulnerable because we don't want Shaundi playing half an animation 
  5281. 	turn_invulnerable(M01_shaundi_attack.attacker) 
  5282. 	 
  5283. 	-- play animation at the navpoint 
  5284. 	action_play_synced(M01_shaundi, M01_shaundi_attack.attacker, "Shaundi Attacked", M01_shaundi_attack.shuandi_attack) 
  5285. 	turn_vulnerable(M01_shaundi_attack.attacker) 
  5286. 	character_kill(M01_shaundi_attack.attacker) 
  5287. 	-- free to do stuff again 
  5288. 	set_ignore_ai_flag(M01_shaundi, false) 
  5289. 	 
  5290. 	-- clear me out 
  5291. 	M01_shaundi_attack.thread = INVALID_THREAD_HANDLE 
  5292. end 
  5293.  
  5294. -- retry pathfind until you get close 
  5295. -- 
  5296. -- name:		(string) name of npc to move 
  5297. -- navpoint:	(string) name of navpoint to go to 
  5298. -- 
  5299. function m01_have_to_get_there_thread(name, navpoint) 
  5300. 	local close = false 
  5301. 	local should_run = true 
  5302. 	local should_fire = false 
  5303. 	while not close do 
  5304. 		-- call scripted move 
  5305. 		ai_do_scripted_move(name, navpoint, should_run, should_fire) 
  5306. 	 
  5307. 		thread_yield() 
  5308. 		 
  5309. 		while not ai_scripted_action_is_complete(name) do 
  5310. 			thread_yield() 
  5311. 		end 
  5312. 		 
  5313. 		-- are we close? 
  5314. 		close = (get_dist(name, navpoint) < 2.0) 
  5315. 	end 
  5316. end 
  5317.  
  5318. -- Josh runs upstairs and is out of breath 
  5319. -- 
  5320. function m01_josh_run_upstairs() 
  5321. 	follower_make_independent(M01_josh, true) 
  5322. 	ai_clear_scripted_action(M01_josh) 
  5323. 	character_prevent_flinching(M01_josh, true) 
  5324. 	set_always_cower_flag(M01_josh, false) 
  5325. 	 
  5326. 	-- Josh runs upstairs and Shaundi will go after him? 
  5327. 	override_npc_run_and_cower_run(M01_josh, "Cower Run", "Cower Run") 
  5328. 	 
  5329. 	m01_have_to_get_there_thread(M01_josh, M01_shaundi_attack.josh_nav) 
  5330. 	 
  5331. 	-- turn off AI and do out of breath thing 
  5332. 	set_ignore_ai_flag( M01_josh, true ) 
  5333. 	delay(0.5) 
  5334. 	set_animation_state(M01_josh, "Josh Winded") 
  5335. 	character_prevent_flinching(M01_josh, false) 
  5336. 	 
  5337. end 
  5338.  
  5339. -- Josh goes to a navpoint by saints fan and waits 
  5340. -- 
  5341. function m01_josh_to_autograph() 
  5342. 	follower_make_independent(M01_josh, true) 
  5343. 	ai_clear_scripted_action(M01_josh) 
  5344. 	clear_animation_state(M01_josh) 
  5345. 	set_always_cower_flag(M01_josh, false) 
  5346. 		 
  5347. 	m01_have_to_get_there_thread(M01_josh, M01_group.autograph.josh_nav) 
  5348. 	 
  5349. 	-- er...do something 
  5350. 	npc_leash_to_nav( M01_josh, M01_group.autograph.josh_nav, 2.0 ) 
  5351. 	 
  5352. end 
  5353.  
  5354. -- Josh moves up to offer his autograph 
  5355. function m01_josh_to_autograph2() 
  5356. 	-- make sure 
  5357. 	follower_make_independent(M01_josh, true) 
  5358. 	ai_clear_scripted_action(M01_josh) 
  5359. 	clear_animation_state(M01_josh) 
  5360. 	set_always_cower_flag(M01_josh, false)	 
  5361. 	 
  5362. 	-- Josh wants to sign some breasts 
  5363. 	if get_dist(M01_josh, M01_group.autograph.josh_nav) < 3.0 then 
  5364. 		delay(3.0) 
  5365. 	end 
  5366. 	ai_clear_scripted_action(M01_josh) 
  5367. 		 
  5368. 	npc_leash_remove(M01_josh) 
  5369. 	 
  5370. 	-- walk a little closer 
  5371. 	local should_run = false 
  5372. 	local should_fire = false 
  5373. 	-- if he's not close, book it! 
  5374. 	if get_dist(M01_josh, M01_group.autograph.josh_close_nav) > 3.0 then 
  5375. 		m01_have_to_get_there_thread(M01_josh, M01_group.autograph.josh_close_nav) 
  5376. 	else 
  5377. 		ai_do_scripted_move(M01_josh, M01_group.autograph.josh_close_nav, should_run, should_fire) 
  5378. 		 
  5379. 		thread_yield() 
  5380. 		--inv_item_equip(nil, M01_josh) 
  5381. 		while not ai_scripted_action_is_complete(M01_josh) do 
  5382. 			thread_yield() 
  5383. 		end 
  5384. 	end 
  5385. 	 
  5386. 	-- do talking state	 
  5387. 	--while true do 
  5388. 		if not check_animation_state(M01_josh, "talk stand") then 
  5389. 			set_animation_state(M01_josh, "talk stand") 
  5390. 		end 
  5391. 		thread_yield() 
  5392. 	--end 
  5393. 	 
  5394. 	local anim_name = "Insult M" 
  5395. 	local morph_name = "Insult M" 
  5396. 	local force_play = false	 
  5397. 	local percentage = 1.0 
  5398. 	local stand_still = true 
  5399. 	local zero_movement = true 
  5400. 	action_play(M01_josh, anim_name, morph_name, force_play, percentage, stand_still, zero_movement) 
  5401. 	-- react Avoid Person 
  5402. 	 
  5403. 	while M01_doing_autograph do 
  5404. 		thread_yield() 
  5405. 	end 
  5406. 	 
  5407. 	-- exit 
  5408. 	clear_animation_state(M01_josh) 
  5409. 	character_prevent_flinching(M01_josh, false) 
  5410. 	character_prevent_flinching(M01_shaundi, false) 
  5411. 	 
  5412. end 
  5413.  
  5414. -- Josh in an endless cower 
  5415. function m01_josh_just_cower_thread() 
  5416. 	-- cower until this thread is killed 
  5417. 	while true do 
  5418. 		if not check_animation_state(M01_josh, "Cower Stand") then 
  5419. 			set_animation_state(M01_josh, "Cower Stand") 
  5420. 		end 
  5421. 		thread_yield() 
  5422. 	end 
  5423. end 
  5424.  
  5425. -- Josh is a dumbass.  This thread says so. 
  5426. -- 
  5427. function m01_josh_is_dumbass_thread() 
  5428. 	M01_josh_grandstanded = false 
  5429. 	 
  5430. 	-- don't do anything while we don't have Josh 
  5431. 	while M01_josh == "" do 
  5432. 		thread_yield() 
  5433. 	end 
  5434. 	set_cant_cower_flag(M01_josh, false) 
  5435. 	set_cant_flee_flag(M01_josh, true) 
  5436. 	 
  5437. 	-- don't exactly follow the player 
  5438. 	follower_make_independent(M01_josh, true) 
  5439. 	 
  5440. 	-- start Josh in a cower 
  5441. 	ai_clear_scripted_action(M01_josh) 
  5442. 	--set_always_cower_flag(M01_josh, true) 
  5443. 	 
  5444. 	set_ignore_ai_flag( M01_josh, true ) 
  5445. 	 
  5446. 	-- need to make sure he's active before doing the next parts 
  5447. 	while not character_is_ready(M01_josh) do 
  5448. 		thread_yield() 
  5449. 	end 
  5450. 	 
  5451. 	set_animation_state(M01_josh, "Cower Stand") 
  5452. 	 
  5453. 	-- make sure targets are set 
  5454. 	while (Num_enemies_alive < 2) do 
  5455. 		thread_yield() 
  5456. 		if not check_animation_state(M01_josh, "Cower Stand") then 
  5457. 			set_animation_state(M01_josh, "Cower Stand") 
  5458. 		end 
  5459. 	end 
  5460. 	 
  5461. 	-- wait until Gat starts interrogation 
  5462. 	while (Num_enemies_alive > 1) do 
  5463. 		thread_yield() 
  5464. 		if not check_animation_state(M01_josh, "Cower Stand") then 
  5465. 			set_animation_state(M01_josh, "Cower Stand") 
  5466. 		end 
  5467. 	end 
  5468. 	set_ignore_ai_flag( M01_josh, false ) 
  5469. 	clear_animation_state(M01_josh) 
  5470. 	set_always_cower_flag(M01_josh, false) 
  5471. 	ai_clear_scripted_action(M01_josh) 
  5472. 	ai_set_personality(M01_josh, "gang offensive") 
  5473. 	thread_yield() 
  5474. 	 
  5475. 	-- get by the door 
  5476. 	local should_run = true 
  5477. 	local should_fire = false 
  5478. 	ai_do_scripted_move(M01_josh, "lobby_mark 001", should_run, should_fire) 
  5479. 	 
  5480. 	-- wait until Gat kills the guard 
  5481. 	while not M01_guard_killed do 
  5482. 		thread_yield() 
  5483. 	end 
  5484. 	 
  5485. 	--  "oh my god"...move along 
  5486. 		 
  5487. 	-- Get into door bashing position 
  5488. 	m01_have_to_get_there_thread(M01_josh, M01_grandstand_nav) 
  5489. 	 
  5490. 	-- wait for Gat to get into his position 
  5491. 	while not M01_gat_at_door do 
  5492. 		thread_yield() 
  5493. 	end 
  5494. 	 
  5495. 	-- show awesome	 
  5496. 	--audio_play_persona_line(M01_josh, "M01_Josh_Grandstanding_01") 
  5497. 	 
  5498. 	M01_convo.berate_josh.handle = audio_conversation_load(M01_convo.berate_josh.name)	 
  5499. 	M01_conversation_playing = true 
  5500. 	audio_conversation_play(M01_convo.berate_josh.handle) 
  5501. 	delay(2.5) 
  5502. 	 
  5503. 	-- turn AI off while we do the action 
  5504. 	set_ignore_ai_flag( M01_josh, true ) 
  5505. 	-- tell npc to play action at navpoint (sliding into place as necessary) 
  5506. 	local anim_name = "Josh Door Fail" 
  5507. 	local morph_name = "Josh Door Fail" 
  5508. 	local force_play = false	 
  5509. 	local percentage = 0.2 
  5510. 	local stand_still = true 
  5511. 	local zero_movement = true 
  5512. 	action_play(M01_josh, anim_name, morph_name, force_play, percentage, stand_still, zero_movement, M01_grandstand_nav) 
  5513. 	 
  5514. 	-- cue guards to open the door 
  5515. 	M01_josh_grandstanded = true 
  5516. 	 
  5517. 	audio_conversation_wait_for_end(M01_convo.berate_josh.handle) 
  5518. 	M01_convo.berate_josh.handle = INVALID_CONVERSATION_HANDLE 
  5519. 	M01_conversation_playing = false 
  5520. 	 
  5521. 	-- finish animation 
  5522. 	percentage = 1.0 
  5523. 	repeat 
  5524. 		thread_yield() 
  5525. 	until action_play_is_finished(M01_josh, percentage) 
  5526. 	set_ignore_ai_flag( M01_josh, false ) 
  5527. 	 
  5528. 	-- get out of the way 
  5529. 	ai_do_scripted_move(M01_josh, "josh_lobby2", should_run, should_fire) 
  5530. 	 
  5531. 	while not ai_scripted_action_is_complete(M01_josh) do 
  5532. 		thread_yield() 
  5533. 	end	 
  5534. 	 
  5535. 	m01_josh_just_cower_thread() 
  5536. 	 
  5537. end 
  5538.  
  5539. -- Start setting up the player for the vault sequence 
  5540. function m01_vault_setup_part1_thread() 
  5541. 	-- need these guys 
  5542. 	group_create_hidden(M01_group.vault_attackers2.name) 
  5543. 	 
  5544. 	-- piss some of them off (don't waste time for all of them) 
  5545. 	ai_add_enemy_target(M01_group.vault_attackers2.members[1], M01_group.vault_attackers2.gat, ATTACK_NOW_NEVER_LOSE, true) 
  5546. 	ai_add_enemy_target(M01_group.vault_attackers2.members[2], M01_group.vault_attackers2.shaundi, ATTACK_NOW_NEVER_LOSE, true)	 
  5547. 	ai_add_enemy_target(M01_group.vault_attackers2.gat, M01_group.vault_attackers2.members[1], ATTACK_NOW_NEVER_LOSE, true) 
  5548. 	ai_add_enemy_target(M01_group.vault_attackers2.shaundi, M01_group.vault_attackers2.members[2], ATTACK_NOW_NEVER_LOSE, true)	 
  5549. 	 
  5550. 	-- please don't get thrown on the vault...please don't get thrown on the vault... 
  5551. 	character_prevent_explosion_fling(M01_group.vault_attackers2.gat, true) 
  5552. 	character_prevent_explosion_fling(M01_group.vault_attackers2.shaundi, true) 
  5553. 	character_allow_ragdoll(M01_group.vault_attackers2.gat, false) 
  5554. 	character_allow_ragdoll(M01_group.vault_attackers2.shaundi, false) 
  5555. 	 
  5556. 	-- remove the old loadout (if valid) 
  5557. 	m01_clear_player_loadout() 
  5558. 	 
  5559. 	-- start with a hidden vault 
  5560. 	group_create_hidden(M01_group.vault_heli.name, true) 
  5561. 	-- disable physics (wait until it works) 
  5562. 	while not vehicle_enable_physics(M01_group.vault_heli.vehicle, false) do 
  5563. 		thread_yield() 
  5564. 	end 
  5565. 	-- add one pilot 
  5566. 	vehicle_enter_group_teleport(M01_group.vault_heli.pilot, M01_group.vault_heli.vehicle) 
  5567.  
  5568. 	-- prep conversations for the vault 
  5569. 	persona_override_persona_start(M01_group.vault_heli.pilot, "Interrogation") 
  5570. end 
  5571.  
  5572. -- Finish setup for the player on the vault 
  5573. function m01_vault_setup_part2_thread()	 
  5574. 	group_show(M01_group.vault_attackers2.name) 
  5575. 	group_show(M01_group.vault_heli.name) 
  5576. 	m01_players_start_vault_health() 
  5577. 	 
  5578. 	-- hide the static vault 
  5579. 	mesh_mover_hide(M01_vault_mover) 
  5580. 	 
  5581. 	-- restrict camera before fading back 
  5582. 		-- limit to what we want you to look at only 
  5583. 	local look_here_pitch = 20.0	-- will remove this restriction when player has control 
  5584. 	camera_restrict_set_limits( look_here_pitch, look_here_pitch, 0.0, 0.0 ) 
  5585. 	camera_restrict_target_object(CAMERA_TARGET3)	-- target we will rise to 
  5586. 	camera_restrict_set_active(ENABLE) 
  5587. 	 
  5588. 	-- put it in position 
  5589. 	teleport_vehicle(M01_group.vault_heli.vehicle, M01_group.vault_heli.nav) 
  5590. 	-- disable physics...again 
  5591. 	while not vehicle_enable_physics(M01_group.vault_heli.vehicle, false) do 
  5592. 		thread_yield() 
  5593. 	end 
  5594. 	 
  5595. 	-- put the player in 
  5596. 	local block = true 
  5597. 	local local_seat = 1 
  5598. 	local remote_seat = 2 
  5599. 	if M01_swap_vault_seats then 
  5600. 		local_seat = 2 
  5601. 		remote_seat = 1 
  5602. 	end 
  5603. 	while not vehicle_enter_teleport(LOCAL_PLAYER, M01_group.vault_heli.vehicle, local_seat, block)	do 
  5604. 		thread_yield() 
  5605. 	end 
  5606. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, false) 
  5607. 	if ( coop_is_active() ) then 
  5608. 		while not vehicle_enter_teleport(REMOTE_PLAYER, M01_group.vault_heli.vehicle, remote_seat, block) do 
  5609. 			thread_yield() 
  5610. 		end 
  5611. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, false) 
  5612. 		-- make sure the player gets in 
  5613. 		while(not character_is_in_vehicle(REMOTE_PLAYER, M01_group.vault_heli.vehicle)) do 
  5614. 			thread_yield() 
  5615. 		end 
  5616. 	end 
  5617. 	-- make sure the player gets in 
  5618. 	while(not character_is_in_vehicle(LOCAL_PLAYER, M01_group.vault_heli.vehicle)) do 
  5619. 		thread_yield() 
  5620. 	end 
  5621. 	 
  5622. 	-- make sure we know what loadout we have 
  5623. 	m01_set_player_loadout() 
  5624. 	-- only smg for this ride 
  5625. 	inv_weapon_disable_all_but_this_slot( WEAPON_SLOT_RIFLE ) 
  5626. 		 
  5627. 	action_sequence_setup(VAULT_SEQUENCE, M01_group.vault_heli.vehicle) 
  5628. 	 
  5629. 	-- hook in special sounds 
  5630. 	vault_heli_hack_for_m01(M01_group.vault_heli.vehicle) 
  5631. 		 
  5632. 	-- attackers move out 
  5633. 	local should_run = true 
  5634. 	local should_fire = false	 
  5635. 	for i,attacker in pairs(M01_group.vault_attackers2.members) do 
  5636. 		ai_do_scripted_move(attacker, M01_group.vault_attackers2.navs[i], should_run, should_fire) 
  5637. 	 
  5638. 		ai_add_enemy_target(M01_group.vault_attackers2.gat, attacker, ATTACK_NOW_NEVER_LOSE, false) 
  5639. 		ai_add_enemy_target(M01_group.vault_attackers2.shaundi, attacker, ATTACK_NOW_NEVER_LOSE, false)	 
  5640. 	end 
  5641.  
  5642. 	thread_yield() -- wait at least 1 frame 
  5643. 	M01_thread.conversation = thread_new("m01_vault_convo_thread") 
  5644. end 
  5645.  
  5646. -- Prep everything for the vault sequence that is not directly involving the player 
  5647. -- 
  5648. function m01_vault_environ_setup_thread() 
  5649. 	m01_start_respawn_pairs() 
  5650. 	 
  5651. 	-- helicopters 
  5652. 	M01_group.heli_police1.setup_thread = thread_new("m01_spawn_and_float_heli_thread", M01_group.heli_police1, POLICE_HELI_WAIT_LOCATION2)	 
  5653. 	M01_group.heli_police2.setup_thread = thread_new("m01_spawn_and_float_heli_thread", M01_group.heli_police2, POLICE_HELI2_START) 
  5654. 	 
  5655. 	-- we may have already created this 
  5656. 	if not group_is_loaded(M01_group.heli_fighter1.name) then 
  5657. 		group_create(M01_group.heli_fighter1.name, true) 
  5658. 		-- don't take explosion damage 
  5659. 		vehicle_set_explosion_damage_multiplier(M01_group.heli_fighter1.vehicle, 0.0) 
  5660. 		vehicle_prevent_explosion_fling(M01_group.heli_fighter1.vehicle, true) 
  5661. 		vehicle_enter_group_teleport(M01_group.heli_fighter1.members, M01_group.heli_fighter1.vehicle)	 
  5662. 		vehicle_suppress_npc_exit(M01_group.heli_fighter1.vehicle, true) 
  5663. 		 
  5664. 		-- should be damaged 
  5665. 		local total_hitpoints = get_max_hit_points(M01_group.heli_fighter1.vehicle) 
  5666. 		set_current_hit_points(M01_group.heli_fighter1.vehicle, total_hitpoints * M01_group.heli_fighter1.damage1) 
  5667. 		-- set hard limit on how much damage can be taken 
  5668. 		set_min_hit_points(M01_group.heli_fighter1.vehicle, total_hitpoints * M01_group.heli_fighter1.damage2) 
  5669. 	end 
  5670. 	 
  5671. 	-- set a persona for bullhorn lines 
  5672. 	persona_override_persona_start(M01_group.heli_fighter1.members[1], "Interrogation") 
  5673. 	 
  5674. 	-- just in case 
  5675. 	vehicle_show(M01_group.heli_fighter1.vehicle) 
  5676. 	 
  5677. 	-- don't fire rockets into the back of the building 
  5678. 	npc_combat_enable(M01_group.heli_fighter1.members[1], false) 
  5679. 	npc_combat_enable(M01_group.heli_fighter1.members[2], false) 
  5680. 	m01_float_heli(M01_group.heli_fighter1, M01_group.heli_fighter1.first_float) 
  5681. 	 
  5682. 	M01_group.transport1.setup_thread = thread_new("m01_setup_transport_thread", M01_group.transport1) 
  5683. 	M01_group.transport2.setup_thread = thread_new("m01_setup_transport_thread", M01_group.transport2) 
  5684. 	M01_group.transport3.setup_thread = thread_new("m01_setup_transport_thread", M01_group.transport3) 
  5685. 	 
  5686. 	-- let's not see that 
  5687. 	m01_transport_show(M01_group.transport1, false) 
  5688. end 
  5689.