./sh03.lua

  1. --[[ 
  2. 	sh03.lua 
  3. 	SR3 Mission Script 
  4. 	DATE: 8/18/2010 
  5. 	AUTHOR:	Jimmy Cross 
  6. ]]-- 
  7.  
  8.  
  9. -- Debug flags -- 
  10.  
  11. -- Tweakable Parameters -- 
  12. local SH03_NOTERIETY_LEVEL = 1 
  13. local SH03_HELI_MAX_BANK_ANGLE = 15 
  14. local SH03_HELI_ARRIVAL_SPEED = 22 
  15. local SH03_HELI_LAND_SPEED = 10 
  16. local SH03_HELI_SPEED = 17 
  17. local SH03_UPDATE_DIST = 10 
  18. local SH03_SPECIALIST_DELAY = 22.0 
  19. local SH03_SOLDIER_DELAYY = 13 
  20. local SH03_TIMER = 100 
  21.  
  22. -- Groups -- 
  23. 	sh03_group =  
  24. 	{		 
  25. 		START =  
  26. 		{ 
  27. 			name = "start_group", 
  28. 			members =  {"NPC_Kinzie"}, 
  29. 		}, 
  30. 		 
  31. 		START_CAR =  
  32. 		{ 
  33. 			name = "start_car_group", 
  34. 			members = "Courtesy car", 
  35. 		}, 
  36. 		 
  37. 		ROOM_DEFENSE =  
  38. 		{ 
  39. 			name = "Router 001", 
  40. 			members ={ "decker 01", "decker 02", "Decker 03", "Decker 04", "Decker 05", "Decker 06", "decker 07", "decker 08", "Decker 09", "decker 10", "Decker 11", "Decker 13" , "decker 14", "Decker 16" , "Decker 17"  }, 
  41. 			size = 15 
  42. 		}, 
  43. 		 
  44. 		STAIRS =  
  45. 		{ 
  46. 			name = "stairs_npcs", 
  47. 			members = { "stairs01", "stairs02" } 
  48. 		}, 
  49. 		 
  50. 		HELICOPTER =  
  51. 		{ 
  52. 			name = "helicopter_group", 
  53. 			members = {"Rail_Heli", "Heli_Pilot"} 
  54. 		}, 
  55. 		 
  56. 		ATTACK_SPEC =  
  57. 		{ --specialist group 
  58. 			name = "attack_group 001", 
  59. 			members ={ "Decker 23" } 	 
  60. 		}, 
  61. 		 
  62. 		ATTACK_SOL =   
  63. 		{ --soldier group 
  64. 			name = "attack_group 002", 
  65. 			members ={ "Decker 24", "Decker 25" }	 
  66. 		}, 
  67. 		 
  68. 		WAVE_ONE =   
  69. 		{  
  70. 			name = "wave01", 
  71. 			members = { "defender1_1", "defender1_2", "defender1_3", "defender1_4" }, 
  72. 			thread = { INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE }, 
  73. 			size = 4 
  74. 		}, 
  75. 		 
  76. 		WAVE_TWO =   
  77. 		{ 
  78. 			name = "wave02", 
  79. 			members = { "defender2_1",  "defender2_2", "defender2_3", "defender2_4" },  
  80. 			thread = { INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE }, 
  81. 			size = 4 
  82. 		}, 
  83. 		 
  84. 		WAVE_THREE =   
  85. 		{ 
  86. 			name = "wave03", 
  87. 			members = { "defender3_1",  "defender3_2" }, 
  88. 			thread = { INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE }, 
  89. 			size = 2			 
  90. 		}, 
  91. 		 
  92. 		COOP_WAVE_ONE =   
  93. 		{  
  94. 			name = "coop_wave01", 
  95. 			members = { "coop_defender1_1", "coop_defender1_2", "coop_defender1_3", "coop_defender1_4", "coop_defender1_5", "coop_defender1_6" }, 
  96. 			thread = { INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE }, 
  97. 			size = 6 
  98. 		}, 
  99. 		 
  100. 		COOP_WAVE_TWO =   
  101. 		{ 
  102. 			name = "coop_wave02", 
  103. 			members = { "coop_defender2_1",  "coop_defender2_2", "coop_defender2_3", "coop_defender2_4", "coop_defender2_5", "coop_defender2_6" },  
  104. 			thread = { INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE }, 
  105. 			size = 6 
  106. 		}, 
  107. 		 
  108. 		COOP_WAVE_THREE =   
  109. 		{ 
  110. 			name = "coop_wave03", 
  111. 			members = { "coop_defender3_1",  "coop_defender3_2", "coop_defender3_3" }, 
  112. 			thread = { INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE }, 
  113. 			size = 2			 
  114. 		}, 
  115. 		 
  116. 		COOP_DEFENDERS =  
  117. 		{ 
  118. 			name = "coop_router_defenders", 
  119. 			members = { "coop_decker", "coop_decker<001>", "coop_decker<002>", "coop_decker<003>", "coop_decker<004>" }, 
  120. 			size = 5 
  121. 		}, 
  122. 		 
  123. 		COOP_TOWER =  
  124. 		{ 
  125. 			name = "coop_tower_attackers" 
  126. 		} 
  127. 		 
  128. 	} 
  129.  
  130. 	local sh03_queue = {} 
  131. 	local sh03_queue_size = 0 
  132. 	 
  133. -- Navpoints -- 
  134. local NAV_ONE = "" 
  135. local NAV_TWO = "" 
  136. local SH03_GPS_OBJECTIVE_ONE = "GPS_NAV_01" 
  137. local SH03_TOWER_NAV_ONE = "tower_nav 001" 
  138. local SH03_TOWER_NAV_TWO = "tower_nav 002" 
  139. local SH03_HELI_ARRIVE_NAV = "heli_arrival_nav" 
  140.  
  141. 	sh03_navs = { 
  142. 		cp_start = { "player_start 001", "player_start 002" } 
  143. 	} 
  144.  
  145.  
  146. -- Triggers -- 
  147. local SH03_TRIG_OBJECTIVE_ONE = "nuke_trigger_obj_one" 
  148. local SH03_TOWER_TRIGGER1 = "Tower_Trigger 001" 
  149. local SH03_TOWER_TRIGGER2 = "Tower_Trigger2" 
  150. local SH03_TOWER_TRIGGER3 = "Tower_Trigger3" 
  151. local SH03_TOWER_NAV1 = "TowerNavPoint 001" 
  152. local SH03_TOWER_NAV2 = "TowerNavPoint 002" 
  153. local SH03_TOWER_NAV3 = "TowerNavPoint 003" 
  154. local EXT1 = "TowerNavPointExt01" 
  155. local EXT2 = "TowerNavPointExt02" 
  156. local EXT3 = "TowerNavPointExt03" 
  157. local PIT_TRIGGER1 = "LinkTrigger1" 
  158. local PIT_TRIGGER2 = "LinkTrigger2" 
  159. local PIT_TRIGGER3 = "LinkTrigger3" 
  160. local PIT_TRIGGER4 = "LinkTrigger4" 
  161. local SH03_FINAL_LINK = "FinalLinkTrigger" 
  162. local SH03_FINAL_NAV = "FinalLinkNav" 
  163. local SH03_HELICOPTER_TRIGGER = "Helicopter_trigger" 
  164. local SH03_CONTINUOUS_SPAWN = "activate_spawns" 
  165. local TOWER_TRIGGER = "inside_trigger" 
  166. local SH03_PATH_UPDATE = "update_path" 
  167. local SH03_PLAY_CAR_CONVO = "start_convo_trigger" 
  168.  
  169. -- Characters -- 
  170. local KINZIE = "NPC_Kinzie" 
  171. local SH03_PILOT = "Heli_Pilot" 
  172.  
  173. -- Vehicles -- 
  174. local SH03_COURTESY_CAR = "Courtesy car" 
  175. local SH03_HELICOPTER = "Rail_Heli" 
  176.  
  177. -- Mesh Movers -- 
  178.  
  179. --Objectives-- 
  180. sh03_objectives = {		 
  181. 		towers =  
  182. 		{ 
  183. 			members =  {SH03_TOWER_TRIGGER1, SH03_TOWER_TRIGGER2, SH03_TOWER_TRIGGER3}, 
  184. 			status = {false, false, false}, 
  185. 			active = {false, false, false}, 
  186. 			nav = {SH03_TOWER_NAV1, SH03_TOWER_NAV2, SH03_TOWER_NAV3},  
  187. 			ext = {EXT1, EXT2, EXT3} 
  188. 		}, 
  189. 		 
  190. 		HELICOPTER =  
  191. 		{ 
  192. 			name = "helicopter", 
  193. 			members = {"Rail_Heli","Heli_Pilot"} 
  194. 		}, 
  195. 		 
  196. 		routers =  
  197. 		{ 
  198. 			members =  {PIT_TRIGGER1, PIT_TRIGGER2, PIT_TRIGGER3,PIT_TRIGGER4}, 
  199. 			status = {false, false, false, false}, 
  200. 			navs = { "link_nav1", "link_nav2", "link_nav3", "link_nav4" }, 
  201. 			hack = { "hack_nav01", "hack_nav02", "hack_nav03", "hack_nav04" } 
  202. 		}, 
  203. 	} 
  204.  
  205. -- Text -- 
  206. SH03_HACK_TOWER = "SH03_DIRECTIVE_ONE" -- Escort Kinzie to the towers 
  207. SH03_DEFEND_KINZIE = "SH03_PROTECT_KINZIE" -- Defend Kinzie while she hacks the chair interfaces 
  208. SH03_CALL_FOR_CHOPPA = "SH03_CALL_CHOPPA" 
  209. DEFEND_THE_CHOPPA = "SH03_DEFEND_THE_CHOPPA" -- Defend the Chopper while Kinzie located the chair 
  210. TURN_OF_THE_ROUTERS = "SH03_TURN_OFF_ROUTERS" --Turn off the routers 
  211. SH03_TURN_OFF_THE_FINAL_LINK = "SH03_TURN_OFF_FINAL" --Turn off the final link 
  212. SH03_HACKING_TIME = "SH03_HACKING_TIME" 
  213. SH03_SURVIVE = "SH03_OBJ_SURVIVE" --survive until the chopper arrives 
  214. KILL_TARGETS = "SH03_OBJ_KILL_TARGETS" --kill the remaining decker guards 
  215. SH03_PARACHUTE = "SH03_OBJ_PARA" --Parachute inside the building 
  216. START_MESSAGE = "SH03_START_MESSAGE" --drive to the nuke plant 
  217. SH03_GET_TO_THE_CHOPPA ="SH03_OBJ_CHOPPA" -- Get to the choppa! 
  218. GO_DOWNSTAIRS = "SH03_OBJ_GO_DOWNSTAIRS" --direct the player down stairs in the plant 
  219. ENTER_HELI = "SH03_OBJ_ENTER_HELI"--get in the helicopter 
  220.  
  221. SH03_CHAIR_DESTROYED = "SH03_FAIL_CHAIR" --the deckers destroyed the chair =( 
  222. SH03_KINZIE_DIED = "SH03_KINZIE_DIED" --Kinzie Died 
  223. SH03_KINZIE_ABANDODNED = "SH03_KINZIE_ABANDONDED" --Kinzie was abandonded 
  224.  
  225. -- Threads -- 
  226. sh03_threads = { 
  227. 	CAR_RIDE = INVALID_THREAD_HANDLE, 
  228. 	HELI_RIDE = INVALID_THREAD_HANDLE, 
  229. 	HELI_ARRIVE = INVALID_THREAD_HANDLE, 
  230. 	KINZIE_WATCHER_THREAD = INVALID_THREAD_HANDLE, 
  231. 	CONVO_PLAY_THREAD = INVALID_THREAD_HANDLE, 
  232. 	UPDATE_PATH_THREAD = INVALID_THREAD_HANDLE, 
  233. 	SPAWN_THREAD = INVALID_THREAD_HANDLE, 
  234. 	attack_line_timer = INVALID_THREAD_HANDLE, 
  235. 	} 
  236.  
  237. -- GLOBAL VARIABLES -- 
  238. local COOP_IS_ACTIVE = false 
  239. local IS_RESTART = false 
  240. local TOTAL_TOWERS = 3 
  241. local TOWER_INDEX = 0 
  242. local CURRENT_TOWER = nil 
  243. local SH03_KINZIE_HACKING = false 
  244. local SH03_MUSIC_ON = false 
  245. local play_once = true 
  246. SH03_TOWERS_HACKED = 0 
  247. SH03_SHORTEST_PATH = "" 
  248. SH03_BASE_TIME = 25000 
  249. SH03_MULTIPLIER = .825 --2.15 
  250. SH03_TOWER_HACKED = false 
  251. LINKS_COMPLETED = 0 
  252. SH03_HELI_LANDED = false 
  253. SH03_GOT_TO_CHOPPA = false 
  254. SH03_GOT_INSIDE = false 
  255.  
  256. SH03_ROUTERS_TURNED_OFF = 0 
  257. SH03_TOTAL_LINKS = 4 --total # of routers, used in objective_text 
  258.  
  259. SH03_OBJECTIVE_ONE_COMPLETE = false 
  260. SH03_OBJECTIVE_TWO_COMPLETE = false 
  261. SH03_OBJECTIVE_THREE = false 
  262. SH03_OBJ_FOUR_COMPLETE = false 
  263.  
  264. SH03_SHOULD_TELE = false 
  265. SH03_ROOM_DEFENDERS_LEFT = 0 
  266.  
  267. local mission_success = false 
  268. local first_cycle = false 
  269.  
  270. SH03_HIT_TRIGGER = false 
  271.  
  272. local kinzie_id = -1 
  273. local sh03_matt_id = -1 
  274.  
  275. -- Checkpoints -- 
  276. 	CHECKPOINT_START = MISSION_START_CHECKPOINT			-- defined in ug_lib.lua 
  277. 	sh03_checkpoint = { 
  278. 		start = { 
  279. 			name = MISSION_START_CHECKPOINT, 
  280. 			nav1 = "player_start 001", 
  281. 			nav2 = "player_start 002" 
  282. 		}, 
  283. 		 
  284. 		nuke_plant = { 
  285. 			name = "sh03_checkpoint_plant", 
  286. 			nav1 = "CHECKPOINT_TWO_PLAYER_ONE", 
  287. 			nav2 = "CHECKPOINT_TWO_PLAYER_TWO", 
  288. 			nav3 = "CHECKPOINT_KINZIE", 
  289. 			car = "CHECKPOINT_TWO_VEHICLE" 
  290. 		}, 
  291. 		 
  292. 		helicopter = { 
  293. 			name = "sh03_checkpoint_helicopter",  
  294. 			nav1 = "CHECKPOINT_THREE_PLAYER_ONE", 
  295. 			nav2 = "CHECKPOINT_THREE_PLAYER_TWO", 
  296. 			nav3 = "CHECKPOINT_THREE_KINZIE", 
  297. 			car = "CHECKPOINT_THREE_VEHICLE" 
  298. 		}, 
  299. 		 
  300. 		cooling_tower = { 
  301. 			name = "sh03_checkpoint_tower", 
  302. 			nav1 = "CHECKPOINT_FOUR_PLAYER_ONE", 
  303. 			nav2 = "CHECKPOINT_FOUR_PLAYER_TWO" 
  304. 		}, 
  305. 	} 
  306. 	 
  307. -- Cutscenes -- 
  308. 	CUTSCENE_MISSION_INTRO = "DK_SH01" 
  309.  
  310. SH03_convo = { 
  311. 		intro_call = { 
  312. 			name = "SH03_Pre_Phone_Call", 
  313. 			handle = INVALID_CONVERSATION_HANDLE 
  314. 		}, 
  315. 		 
  316. 		mission_start = { 
  317. 			name = "sh03_convo_2", --"sh03_mission_start", 
  318. 			handle = INVALID_CONVERSATION_HANDLE 
  319. 		}, 
  320.  
  321. 		drive_over = { 
  322. 			name = "SH03_Drive_Over", 
  323. 			handle = INVALID_CONVERSATION_HANDLE 
  324. 		}, 
  325. 		 
  326. 		drive_over2 = { 
  327. 			name = "SH03_Drive_Over_2", 
  328. 			handle = INVALID_CONVERSATION_HANDLE 
  329. 		}, 
  330. 		 
  331. 		first_shack = { 
  332. 			name = "SH03_1st_Power_Shack", 
  333. 			handle = INVALID_CONVERSATION_HANDLE 
  334. 		}, 
  335. 		 
  336. 		uplink_convo = { 
  337. 			name = "SH03_Uplink_Convo_1", 
  338. 			handle = INVALID_CONVERSATION_HANDLE 
  339. 		}, 
  340. 		 
  341. 		uplink_convo2 = { 
  342. 			name =  "SH03_Uplink_Convo_2", 
  343. 			handle = INVALID_CONVERSATION_HANDLE 
  344. 		}, 
  345. 		 
  346. 		hacking_complication = { 
  347. 			name = "SH03 Hacking Complication", 
  348. 			handle = INVALID_CONVERSATION_HANDLE 
  349. 		}, 
  350. 			 
  351. 		triangulate_done = { 
  352. 			name = "SH03_Uplink_3_Down", 
  353. 			handle = INVALID_CONVERSATION_HANDLE 
  354. 		}, 
  355. 		 
  356. 		enter_heli = { 
  357. 			name = "SH03_Getting_In_Heli", 
  358. 			handle = INVALID_CONVERSATION_HANDLE 
  359. 		}, 
  360. 		 
  361. 		heli_ride = { 
  362. 			name = "SH03_Heli_Ride", 
  363. 			handle = INVALID_CONVERSATION_HANDLE 
  364. 		}, 
  365. 		 
  366. 		heli_ride2 = { 
  367. 			name = "SH03_New_Helicopter_Ride", 
  368. 			handle = INVALID_CONVERSATION_HANDLE 
  369. 		}, 
  370.  
  371. 		cooling_tower = { 
  372. 			name = "SH03_Cooling_Tower", 
  373. 			handle = INVALID_CONVERSATION_HANDLE 
  374. 		}, 
  375. 		 
  376. 		enter_tower = { 
  377. 			name = "SH03_Enter_Chair_Room", 
  378. 			handle = INVALID_CONVERSATION_HANDLE 
  379. 		}, 
  380. 		 
  381. 		see_chair = { 
  382. 			name = "SH03_Seeing_Chair", 
  383. 			handle = INVALID_CONVERSATION_HANDLE 
  384. 		}, 
  385. 		 
  386. 		cut_links = { 
  387. 			name = "sh03_cut_chair_link", 
  388. 			handle = INVALID_CONVERSATION_HANDLE 
  389. 		}, 
  390. 		 
  391. 		clean_house = { 
  392. 			name = "SH03_Clear_Out_Deckers", 
  393. 			handle = INVALID_CONVERSATION_HANDLE 
  394. 		}, 
  395. 	} 
  396. 	 
  397. SH03_dialog_lines = { 
  398. 		kinzie_ouch = {  
  399. 			"sh03_kinzie_getting_shot_01", 
  400. 			"sh03_kinzie_getting_shot_02", 
  401. 			"sh03_kinzie_getting_shot_03", 
  402. 		}, 
  403. 		 
  404. 		kinzie_triangulate = { 
  405. 			"sh03_uplink_one_down", 
  406. 			"sh03_uplink_two_down", 
  407. 		}, 
  408. 		 
  409. 		impatient_player = { 
  410. 			"sh03_hurry_up_01", 
  411. 			"sh03_hurry_up_02", 
  412. 			"sh03_hurry_up_03", 
  413. 			"sh03_hurry_up_04", 
  414. 			"sh03_hurry_up_05", 
  415. 			"sh03_hurry_up_06", 
  416. 			"sh03_hurry_up_07", 
  417. 			"sh03_hurry_up_08", 
  418. 		}, 
  419. 		 
  420. 		kinzie_chair = "SH03_Located_Chair_01", 
  421. 		 
  422. 		matt_taunts = { 
  423. 		"SH03_Miller_Over_Speakers_1", 
  424. 		"SH03_Miller_Over_Speakers_2", 
  425. 		"SH03_Miller_Over_Speakers_3", 
  426. 		"SH03_Miller_Over_Speakers_4" 
  427. 		}, 
  428. 		 
  429. 		player_annoyed = { 
  430. 		"SH03_Annoyed_at_Miller_1", 
  431. 		"SH03_Annoyed_at_Miller_2", 
  432. 		"SH03_Annoyed_at_Miller_3", 
  433. 		"SH03_Annoyed_at_Miller_4" 
  434. 		}, 
  435. 		 
  436. 		arrive = "sh03_plant_arrive", 
  437. 		 
  438. 		jump = "SH03_Jumping_Out" 
  439. 	} 
  440.  
  441. SH03_cont_spawn = { 
  442. 	area1 = "ContAttack 001", 
  443. 	area2 = "ContAttack 002", 
  444. 	area3 = "ContAttack 003", 
  445. 	area4 = "ContAttack 004" 
  446. } 
  447.  
  448. -- Music 
  449. 	sh03_emitters = { 
  450. 		ff = "Force_Field", 
  451. 		main = "SH03_Music" 
  452. 	} 
  453.  
  454. -- Other -- 
  455. SH03_PATH_TO_TOWER  = "AirPath" 
  456. HELICOPTER_ARRIVE = "AirPath<001>" 
  457. HELICOPTER_LAND = "heli_land" 
  458. SH03_KINZIE_WAIT = "kinzie_wait" 
  459.  
  460. -- ************************* 
  461. -- 
  462. -- Standard functions 
  463. -- 
  464. -- ************************* 
  465.  
  466. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  467. -- at the specified checkpoint. 
  468. -- CALLED FROM CODE 
  469. -- 
  470. -- sh03_checkpoint:	The checkpoint the mission should begin at 
  471. -- is_restart:					TRUE if the mission is restarting, FALSE otherwise 
  472. -- 
  473. function sh03_start(sh03_checkpoint, is_restart) 
  474. IS_RESTART = is_restart 
  475.  
  476. 	-- Check if this mission starting from the beginning 
  477. 	if (sh03_checkpoint == CHECKPOINT_START) then 
  478. 		if (is_restart == false) then 
  479. 			-- First time playing mission 
  480.  
  481. 			-- Play an intro cutscene??? 
  482. 			if (CUTSCENE_MISSION_INTRO ~= "") then 
  483. 				zscene_prep( CUTSCENE_MISSION_INTRO ) 
  484. 				 
  485. 				--while( not zscene_is_loaded( CUTSCENE_MISSION_INTRO ) ) do 
  486. 					--thread_yield() 
  487. 				--end 
  488. 				 
  489. 				cutscene_play(CUTSCENE_MISSION_INTRO, nil, sh03_navs.cp_start, false ) 
  490. 			end 
  491. 		end 
  492. 		fade_out(0) 
  493. 	end 
  494.  
  495. 	-- Handle mission initialization for the current checkpoint 
  496. 	sh03_initialize(sh03_checkpoint) 
  497.  
  498. 	-- Run the mission from the current checkpoint 
  499. 	sh03_run(sh03_checkpoint) 
  500. 	 
  501. end 
  502.  
  503. -- This is the primary function responsible for running the entire mission from start to finish. 
  504. -- 
  505. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  506. -- 
  507. function sh03_run(first_checkpoint) 
  508. 	local current_checkpoint = first_checkpoint 
  509. 	 
  510. 	-- Run the mission from the beginning 
  511. 	if current_checkpoint == CHECKPOINT_START then 
  512. 		--[[ INSERT PROCESSING FOR THE FIRST CHECKPOINT HERE ]]-- 
  513. 		notoriety_set_max("deckers", 1)		 
  514. 		notoriety_set_max("police", 0) 
  515. 		 
  516. 		sh03_setup_obj_one() 
  517. 		fade_in(0) 
  518. 		while SH03_OBJECTIVE_ONE_COMPLETE == false do 
  519. 			thread_yield() 
  520. 		end	 
  521. 		current_checkpoint = sh03_checkpoint.nuke_plant.name 
  522. 		mission_set_checkpoint(sh03_checkpoint.nuke_plant.name, true) 
  523. 	end 
  524. 	 
  525. 	 
  526. 	if current_checkpoint == sh03_checkpoint.nuke_plant.name then 
  527. 		notoriety_set_max("deckers", 0)	 
  528. 		notoriety_set("deckers", 0) 
  529. 		 
  530. 		notoriety_set_max("police", 0)	 
  531. 		notoriety_set("police", 0) 
  532. 		notoriety_set_can_decay(false) 
  533. 		 
  534. 		if group_is_loaded( sh03_group.COOP_TOWER.name ) == false then 
  535. 			group_create( sh03_group.COOP_TOWER.name, true ) 
  536. 		end 
  537. 		 
  538. 		set_ignore_ai_flag( KINZIE, false ) 
  539. 		first_cycle = true 
  540. 		sh03_setup_obj_two() 
  541. 		fade_in(0) 
  542. 		 
  543. 		while SH03_OBJECTIVE_THREE==false do 
  544. 			while CURRENT_TOWER == nil do --yield until the player hits a tower trigger. on_trigger_exit will set this to nil 
  545. 				repeat --don't let Kinzie start hacking if the player is in a car, he could just drive away and fuck everything up 
  546. 					thread_yield() 
  547. 				until character_is_in_vehicle( LOCAL_PLAYER ) == false 
  548. 				thread_yield() 
  549. 			end 
  550. 			 
  551. 			--thread_yield() 
  552. 			 
  553. 			--the player hit a trigger and got out of the car, everything should be good for Kinzie to start hacking 
  554. 			sh03_kinzie_hack_tower( CURRENT_TOWER )  
  555. 		end 
  556. 			 
  557. 	end 
  558. 	 
  559. 	if current_checkpoint == sh03_checkpoint.helicopter.name then	 
  560. 		sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.triangulate_done)	 
  561. 		 
  562. 		--notoriety_set_max("deckers", 5)	 
  563. 		--notoriety_set("deckers", 5) 
  564. 		--make the player think he has 5* notoriety 
  565. 		hud_set_fake_notoriety("deckers", true, 5) 
  566. 		 
  567. 		sh03_control_notoriety( 4 ) --pull it back a little 
  568. 		notoriety_set_can_decay(false) 
  569. 		 
  570. 		--sh03_checkpoint_spawn_kinzie()	 
  571. 		set_ignore_ai_flag( KINZIE, false )		 
  572. 		sh03_obj_three_heli() 
  573. 		 
  574. 		fade_in(0) 
  575. 		 
  576. 		current_checkpoint = sh03_checkpoint.cooling_tower.name 
  577. 		mission_set_checkpoint(sh03_checkpoint.cooling_tower.name, true) 
  578. 	end 
  579. 	 
  580. 	if current_checkpoint == sh03_checkpoint.cooling_tower.name then 
  581. 		if SH03_MUSIC_ON == false then 
  582. 			audio_ambient_emitter_start(sh03_emitters.main) 
  583. 		end 
  584. 		 
  585. 		if kinzie_id == -1 then 
  586. 			kinzie_id = audio_persona_load_2d("Kinzie") 
  587. 		end 
  588. 		 
  589. 		notoriety_set_max("deckers", 5)	 
  590. 		notoriety_set("deckers", 5) 
  591. 		notoriety_set_can_decay(false) 
  592. 		SH03_SHOULD_TELE = true 
  593. 		 
  594. 		sh03_obj_four_cooling_tower() 
  595. 		--fade_in(0) 
  596. 		while SH03_OBJ_FOUR_COMPLETE == false do 
  597. 			thread_yield() 
  598. 		end 
  599. 		audio_ambient_emitter_stop( sh03_emitters.ff ) 
  600. 		sh03_final_link()		 
  601. 	end 
  602. 	-- Call mission success?? 
  603. 	--mission_end_success("sh03", CUTSCENE_MISSION_OUTRO) 
  604. 	 
  605. end 
  606.  
  607. -- This is the primary function responsible for cleaning up the entire mission 
  608. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  609. -- 
  610. function sh03_cleanup()	--[[ INSERT ANY MISSION SPECIFIC CLEAN-UP ]]-- 
  611. 	--parachute_enable() 
  612. 	base_jumping_enable(true) 
  613. 	--helicopters_set_jitter_override(1.0, 1.0) 
  614. 	 
  615. 	hud_prompt_clear(LOCAL_PLAYER) 
  616. 	hud_prompt_clear(REMOTE_PLAYER) 
  617. 	 
  618. 	thread_kill( sh03_threads.CAR_RIDE ) 
  619. 	 
  620. 	cleanup_threads( sh03_threads ) 
  621. 	cleanup_threads( sh03_group.WAVE_ONE.thread ) 
  622. 	cleanup_threads( sh03_group.WAVE_TWO.thread ) 
  623. 	cleanup_threads( sh03_group.WAVE_THREE.thread ) 
  624. 	cleanup_threads( sh03_group.COOP_WAVE_ONE.thread ) 
  625. 	cleanup_threads( sh03_group.COOP_WAVE_TWO.thread ) 
  626. 	cleanup_threads( sh03_group.COOP_WAVE_THREE.thread ) 
  627. 	 
  628. 	sh03_cleanup_convos() 
  629. 	sh03_cleanup_enemies() 
  630. 	 
  631. 	sh03_cleanup_kinzie() 
  632. 	--sh03_clear_trigger(SH03_TRIG_OBJECTIVE_ONE) 
  633. 	sh03_obj_two_cleanup() 
  634. 	sh03_clear_trigger(SH03_FINAL_LINK) 
  635. 	sh03_clear_trigger(TOWER_TRIGGER) 
  636. 	sh03_clear_trigger(SH03_PATH_UPDATE) 
  637. 	sh03_obj_four_cleanup() 
  638. 	sh03_cleanup_groups() 
  639. 	sh03_cleanup_notoriety() 
  640. 	 
  641. 	trigger_enable( SH03_PLAY_CAR_CONVO, false ) 
  642. 	on_trigger_exit( "", SH03_PLAY_CAR_CONVO ) 
  643. 	on_trigger_exit( "", SH03_TOWER_TRIGGER1 ) 
  644. 	on_trigger_exit( "", SH03_TOWER_TRIGGER2 ) 
  645. 	on_trigger_exit( "", SH03_TOWER_TRIGGER3 ) 
  646. 	 
  647. 	inv_weapon_disable_all_slots( false ) --enable all weapon slots 
  648. 	 
  649. 	if kinzie_id ~= -1 then 
  650. 		audio_persona_remove_2d(kinzie_id) 
  651. 		kinzie_id = -1 
  652. 	end 
  653. 	 
  654. 	if sh03_matt_id ~= -1 then 
  655. 		audio_persona_remove_2d(sh03_matt_id) 
  656. 		sh03_matt_id = -1 
  657. 	end 
  658. 	 
  659. 	--sh03_cleanup_convo_thread() 
  660. 	--hud_timer_hide(1, true) 
  661. 	--hud_timer_stop(1) 
  662. 	 
  663. 	on_vehicle_enter( "", LOCAL_PLAYER ) 
  664. 	player_force_vehicle_seat( LOCAL_PLAYER, -1 ) 
  665. 	if COOP_IS_ACTIVE == true	then 
  666. 		player_force_vehicle_seat( REMOTE_PLAYER, -1 ) 
  667. 	end 
  668. 	 
  669. 	sh03_clear_trigger( SH03_HELICOPTER_TRIGGER ) 
  670. 	 
  671. 	continuous_spawn_stop( sh03_group.ATTACK_SOL.name ) --stop the soldiers 
  672. 	continuous_spawn_stop( sh03_group.ATTACK_SPEC.name ) --stop the specialists 
  673. 	spawn_region_enable( SH03_cont_spawn.area1, false ) 
  674. 	spawn_region_enable( SH03_cont_spawn.area2, false ) 
  675. 	spawn_region_enable( SH03_cont_spawn.area3, false ) 
  676. 	spawn_region_enable( SH03_cont_spawn.area4, false ) 
  677. 	 
  678.  
  679. 	set_player_can_enter_exit_vehicles( LOCAL_PLAYER, true ) 
  680. 	if COOP_IS_ACTIVE == true then 
  681. 		set_player_can_enter_exit_vehicles( REMOTE_PLAYER, true ) 
  682. 	end 
  683.  
  684. 	if character_is_in_vehicle( LOCAL_PLAYER, SH03_HELICOPTER ) == true then 
  685. 		sh03_get_out_of_vehicles() 
  686. 		if SH03_SHOULD_TELE == true then --only teleport the player(s) if they're inside the nuke plant 
  687. 			teleport( LOCAL_PLAYER, sh03_checkpoint.nuke_plant.nav1 ) 
  688. 			if COOP_IS_ACTIVE == true then 
  689. 				teleport( REMOTE_PLAYER,sh03_checkpoint.nuke_plant.nav2 ) 
  690. 			end  
  691. 			--teleport_coop( sh03_checkpoint.nuke_plant.nav1, sh03_checkpoint.nuke_plant.nav2, true ) 
  692. 		end 
  693. 	else 
  694. 		if SH03_SHOULD_TELE == true then --only teleport the player(s) if they're inside the nuke plant 
  695. 			teleport( LOCAL_PLAYER, sh03_checkpoint.nuke_plant.nav1 ) 
  696. 			if COOP_IS_ACTIVE == true then 
  697. 				teleport( REMOTE_PLAYER,sh03_checkpoint.nuke_plant.nav2 ) 
  698. 			end 
  699. 			--teleport_coop( sh03_checkpoint.nuke_plant.nav1, sh03_checkpoint.nuke_plant.nav2, false ) 
  700. 		end 
  701. 	end 
  702. 	 
  703. 	if mission_success == false then 
  704. 		mesh_mover_show( "sh03_cap" ) 
  705. 		mesh_mover_show( "sh03_force_field" ) 
  706. 		audio_ambient_emitter_stop( sh03_emitters.main ) 
  707. 	end 
  708.  
  709. 	audio_ambient_emitter_stop( sh03_emitters.ff ) 
  710.  
  711. 	--reset globals 
  712. 	SH03_MUSIC_ON = false 
  713. 	COOP_IS_ACTIVE = false 
  714. 	IS_RESTART = false 
  715. 	TOTAL_TOWERS = 3 
  716. 	TOWER_INDEX = 0 
  717. 	CURRENT_TOWER = 0 
  718. 	SH03_TOWERS_HACKED = 0 
  719. 	SH03_SHORTEST_PATH = "" 
  720. 	SH03_TOWER_HACKED = false 
  721. 	LINKS_COMPLETED = 0 
  722. 	SH03_SHOULD_TELE = false 
  723. end 
  724.  
  725. function sh03_cleanup_convo_thread() 
  726. 	if sh03_threads.CONVO_PLAY_THREAD ~= INVALID_THREAD_HANDLE then 
  727. 		thread_kill(sh03_threads.CONVO_PLAY_THREAD) 
  728. 		sh03_threads.CONVO_PLAY_THREAD = INVALID_THREAD_HANDLE 
  729. 		--message("convo thread killed", 2) 
  730. 	end 
  731. end 
  732.  
  733. -- Called when the mission has ended with success 
  734. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  735. -- 
  736. function sh03_success() 
  737. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  738. 	mission_success = true 
  739. 	 
  740. 	local skip_teleport = true 
  741. 	sh03_coop_skip(skip_teleport) 
  742. end 
  743.  
  744. function sh03_obj_two_cleanup() 
  745.  
  746. 	CURRENT_TOWER = nil 
  747. 	SH03_KINZIE_HACKING = false 
  748.  
  749. 	for i, trigger in pairs(sh03_objectives.towers.members) do					 
  750. 		sh03_objectives.towers.active[i] = false 
  751. 		sh03_clear_trigger(trigger)			 
  752. 	end	 
  753.  
  754. 	hud_timer_stop(1)	 
  755. end 
  756.  
  757. function sh03_obj_four_cleanup() 
  758. 	SH03_ROUTERS_TURNED_OFF = 0 
  759.  
  760. 	for i, trigger in pairs(sh03_objectives.routers.members) do 
  761. 		sh03_clear_trigger(trigger)	 
  762. 		sh03_objectives.routers.status[i] = true				 
  763. 	end	 
  764. 	  
  765. 	SH03_ROUTERS_TURNED_OFF = 0  
  766. 	SH03_OBJ_FOUR_COMPLETE = false	 
  767. end 
  768.  
  769. function sh03_cleanup_convos() 
  770.  
  771. 	for index, convo in pairs( SH03_convo ) do 
  772. 		if convo.handle ~= INVALID_CONVERSATION_HANDLE then 
  773. 			if audio_is_playing(convo.handle) then 
  774. 				audio_conversation_end(convo.handle)  
  775. 			end 
  776. 			convo.handle = INVALID_CONVERSATION_HANDLE 
  777. 		end 
  778. 	end 
  779. end 
  780.  
  781. function sh03_cleanup_enemies() 
  782. 	 
  783. 	if group_is_loaded( sh03_group.WAVE_ONE.name ) == true then 
  784. 		for index, member in pairs( sh03_group.WAVE_ONE.members  ) do 
  785. 			if ( character_is_dead( member ) == false ) then 
  786. 				on_death( "", member ) 
  787. 				on_attack_performed("", member) 
  788. 			end 
  789. 		end 
  790. 	end 
  791. 	 
  792. 	if group_is_loaded( sh03_group.WAVE_TWO.name ) == true then 
  793. 		for index, member in pairs( sh03_group.WAVE_TWO.members ) do 
  794. 			if ( character_is_dead( member ) == false ) then 
  795. 				on_death( "", member ) 
  796. 				on_attack_performed("", member) 
  797. 			end 
  798. 		end 
  799. 	end 
  800. 	 
  801. 	if group_is_loaded( sh03_group.WAVE_THREE.name ) == true then 
  802. 		for index, member in pairs( sh03_group.WAVE_THREE.members ) do 
  803. 			if ( character_is_dead( member ) == false ) then 
  804. 				on_death( "", member ) 
  805. 				on_attack_performed("", member) 
  806. 			end 
  807. 		end 
  808. 	end 
  809. 	 
  810. 		if group_is_loaded( sh03_group.COOP_WAVE_ONE.name ) == true then 
  811. 		for index, member in pairs( sh03_group.COOP_WAVE_ONE.members  ) do 
  812. 			if ( character_is_dead( member ) == false ) then 
  813. 				on_death( "", member ) 
  814. 				on_attack_performed("", member) 
  815. 			end 
  816. 		end 
  817. 	end 
  818. 	 
  819. 	if group_is_loaded( sh03_group.COOP_WAVE_TWO.name ) == true then 
  820. 		for index, member in pairs( sh03_group.COOP_WAVE_TWO.members ) do 
  821. 			if ( character_is_dead( member ) == false ) then 
  822. 				on_death( "", member ) 
  823. 				on_attack_performed("", member) 
  824. 			end 
  825. 		end 
  826. 	end 
  827. 	 
  828. 	if group_is_loaded( sh03_group.COOP_WAVE_THREE.name ) == true then 
  829. 		for index, member in pairs( sh03_group.COOP_WAVE_THREE.members ) do 
  830. 			if ( character_is_dead( member ) == false ) then 
  831. 				on_death( "", member ) 
  832. 				on_attack_performed("", member) 
  833. 			end 
  834. 		end 
  835. 	end 
  836. 	 
  837. 	if group_is_loaded( sh03_group.STAIRS.name ) == true then 
  838. 		for index, member in pairs( sh03_group.STAIRS.members ) do 
  839. 			if ( character_is_dead( member ) == false ) then 
  840. 				on_death( "", member ) 
  841. 				on_attack_performed("", member) 
  842. 			end 
  843. 		end 
  844. 	end 
  845. 	 
  846. 		if group_is_loaded( sh03_group.ROOM_DEFENSE.name ) == true then 
  847. 		for index, member in pairs( sh03_group.ROOM_DEFENSE.members ) do 
  848. 			if ( character_is_dead( member ) == false ) then 
  849. 				on_death( "", member ) 
  850. 				on_attack_performed("", member) 
  851. 			end 
  852. 		end 
  853. 	end 
  854. end 
  855.  
  856.  
  857. function sh03_cleanup_kinzie() 
  858. 	 
  859. 	if sh03_threads.KINZIE_WATCHER_THREAD ~= INVALID_THREAD_HANDLE then 
  860. 		thread_kill(sh03_threads.KINZIE_WATCHER_THREAD) 
  861. 		sh03_threads.KINZIE_WATCHER_THREAD = INVALID_THREAD_HANDLE 
  862. 	end 
  863. 	 
  864. 	if group_is_loaded(sh03_group.START.name) then 
  865. 		on_death("", KINZIE)  
  866. 		on_dismiss( "", KINZIE )  
  867. 		follower_set_can_abandon( KINZIE, false ) 
  868. 		group_destroy( sh03_group.START.name, true ) 
  869. 	end 
  870.  
  871. end 
  872.  
  873. function sh03_cleanup_notoriety() 
  874.  
  875. 	notoriety_set( "deckers", 0 ) 
  876. 	notoriety_set_max( "deckers", 0 ) 
  877. 	notoriety_set_max("police", 5) 
  878. 	notoriety_set_can_decay( true ) 
  879. 	hud_set_fake_notoriety("deckers", false, 0) 
  880.  
  881. 	disable_specific_notoriety_group( "deckers", 3, "G_Decker_SUV_1S", true ) 
  882. 	disable_specific_notoriety_group(  "deckers", 3, "G_Decker_Car_1S", true ) 
  883. 	disable_specific_notoriety_group(  "deckers", 4, "G_Decker_Car_1S", true ) 
  884. 	disable_specific_notoriety_group(  "deckers", 4, "G_Decker_Car_2S", true ) 
  885. 	disable_specific_notoriety_group(  "deckers", 4, "G_Decker_Brute_F", true ) 
  886. 	disable_specific_notoriety_group(  "deckers", 5, "G_Decker_Brute_M", true ) 
  887. 	disable_specific_notoriety_group(  "deckers", 5, "G_Decker_Brute_G", true ) 
  888. 	disable_specific_notoriety_group(  "deckers", 5, "G_Decker_Car_2S", true ) 
  889. 	disable_specific_notoriety_group(  "deckers", 5, "G_Decker_SUV_2S", true ) 
  890.  
  891. end 
  892.  
  893. function sh03_cleanup_groups() 
  894. 	 
  895. 	if( mission_success == true ) then 
  896. 		--release groups to the world 
  897. 		for i, grp in pairs( sh03_group ) do 
  898. 			if group_is_loaded( grp.name ) then 
  899. 				if( (grp.name == sh03_group.ROOM_DEFENSE.name) or( grp.name == sh03_group.WAVE_ONE.name ) or ( grp.name == sh03_group.WAVE_TWO.name ) or ( grp.name == sh03_group.WAVE_THREE.name ) or (grp.name == sh03_group.ROOM_DEFENSE.name) or ( grp.name == sh03_group.COOP_WAVE_ONE.name ) or ( grp.name == sh03_group.COOP_WAVE_TWO.name ) or ( grp.name == sh03_group.COOP_WAVE_THREE.name ) ) then 
  900. 					for index, char in pairs( grp.members ) do 
  901. 						if ( character_is_dead( char ) == false ) then 
  902. 							on_death( "", char ) 
  903. 						end 
  904. 					end 
  905. 				end 
  906. 				--sh03_release_enemies( grp.name ) 
  907. 				release_to_world( grp.name ) 
  908. 			end 
  909. 		end 
  910. 	else --mission was failed or quit, destroy them like the mission never happened 
  911. 		for i, grp in pairs( sh03_group ) do 
  912. 			if group_is_loaded( grp.name ) then 
  913. 				if( (grp.name == sh03_group.ROOM_DEFENSE.name) or( grp.name == sh03_group.WAVE_ONE.name ) or ( grp.name == sh03_group.WAVE_TWO.name ) or ( grp.name == sh03_group.WAVE_THREE.name ) or ( grp.name == sh03_group.COOP_WAVE_ONE.name ) or ( grp.name == sh03_group.COOP_WAVE_TWO.name ) or ( grp.name == sh03_group.COOP_WAVE_THREE.name ) ) then 
  914. 					for index, char in pairs( grp.members ) do 
  915. 						if ( character_is_dead( char ) == false ) then 
  916. 							on_death( "", char ) 
  917. 						end 
  918. 					end 
  919. 				end 
  920. 				group_destroy( grp.name ) 
  921. 				--on_death( "", grp.members ) 
  922. 			end 
  923. 		end 
  924. 	end 
  925. end 
  926. -- ************************* 
  927. -- 
  928. -- Local functions 
  929. -- 
  930. -- ************************* 
  931.  
  932. -- Initialize the mission for the specified checkpoint 
  933. -- 
  934. -- checkpoint:		Checkpoint to initialize the mission to 
  935. -- 
  936. function sh03_initialize(current_checkpoint) 
  937. 	-- Make sure the screen is completly faded out 
  938. 	mission_start_fade_out(0.0) 
  939. 	 
  940. 		-- Common initialization 
  941. 	sh03_initialize_common() 
  942.  
  943. 	-- Checkpoint specific initialization 
  944. 	sh03_initialize_checkpoint(current_checkpoint) 
  945.  
  946. 	-- Set the mission author 
  947. 	set_mission_author("Jimmy Cross") 
  948. 	 
  949. 	-- Start fading in	 
  950. 	mission_start_fade_in() 
  951.  
  952. end 
  953.  
  954.  
  955. -- *************************************************** 
  956. -- sh03_run Helper Functions 
  957. -- *************************************************** 
  958. function sh03_setup_obj_one() 
  959. 	trigger_enable( SH03_PLAY_CAR_CONVO, true ) 
  960. 	on_trigger_exit( "sh03_play_car_convo", SH03_PLAY_CAR_CONVO ) 
  961. 	 
  962. 	sh03_checkpoint_spawn_kinzie() 
  963. 	sh03_spawn_watcher_thread() 
  964.  
  965. 	--trigger_enable( SH03_TRIG_OBJECTIVE_ONE, true ) 
  966. 	--on_trigger( "sh03_obj_one", SH03_TRIG_OBJECTIVE_ONE ) 
  967. 	 
  968. 	mission_waypoint_add(SH03_GPS_OBJECTIVE_ONE, SYNC_ALL) 
  969. 	--mission_waypoint_add( OBJECTIVE_ONE, SYNC_ALL ) 
  970. 	marker_add(SH03_GPS_OBJECTIVE_ONE, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL ) 
  971. 	objective_text(0, START_MESSAGE, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  972. 	 
  973. 	repeat thread_yield() until ( get_dist_closest_player_to_object( SH03_GPS_OBJECTIVE_ONE ) < 40 ) 
  974. 	sh03_obj_one() 
  975. 	 
  976. end 
  977.  
  978. -- Spawn Kinzie, setup death callback and (optionally) teleport her to a given navpoint 
  979. -- 
  980. -- checkpoint_nav - (string, optional) navpoint to teleport Kinzie to 
  981. -- 
  982. function sh03_checkpoint_spawn_kinzie() 
  983. 	 
  984. 	if group_is_loaded( sh03_group.START.name ) == false then 
  985. 		group_create( sh03_group.START.name, true ) 
  986. 	end 
  987. 	 
  988. 	on_death("sh03_kinzie_dead", KINZIE) --callback for kinzie dying 
  989. 	on_dismiss( "sh03_kinzie_abandoned", KINZIE ) --abandoning  kinzie makes her sadface	 
  990. 	 
  991. 	follower_set_can_abandon(KINZIE, true) 
  992. 	--party_add(KINZIE)	 
  993. end 
  994.  
  995. function sh03_spawn_watcher_thread() 
  996.  
  997. 	if sh03_threads.KINZIE_WATCHER_THREAD == INVALID_THREAD_HANDLE then 
  998. 		sh03_threads.KINZIE_WATCHER_THREAD = thread_new("sh03_kinzie_in_party") 
  999. 	end	 
  1000.  
  1001. end 
  1002.  
  1003. function sh03_teleport_kinzie(checkpoint_nav) 
  1004. 	 
  1005. 	if checkpoint_nav ~= nil  then 
  1006. 		teleport( KINZIE, checkpoint_nav, true )  
  1007. 	end 
  1008.  
  1009. 	--and (checkpoint_nav == sh03_checkpoint.nuke_plant.name or checkpoint_nav == sh03_checkpoint.helicopter.name) 
  1010. end 
  1011.  
  1012. function sh03_setup_obj_two() 
  1013. 	objective_text( 0, SH03_HACK_TOWER, SH03_TOWERS_HACKED, TOTAL_TOWERS, SYNC_ALL, OI_ASSET_LOCATION ) 
  1014. 	 
  1015. 	--kill car convos and play kinzie's arrival line 
  1016. 	if first_cycle == true then 
  1017. 		if sh03_threads.CAR_RIDE ~= INVALID_THREAD_HANDLE then 
  1018. 			thread_kill( sh03_threads.CAR_RIDE ) 
  1019. 			sh03_threads.CAR_RIDE = INVALID_THREAD_HANDLE 
  1020. 		end 
  1021. 		 
  1022. 		delay(1.0) 
  1023. 		audio_play_persona_line( KINZIE, SH03_dialog_lines.arrive ) 
  1024. 	end 
  1025. 	 
  1026. 	first_cycle = false 
  1027. 	 
  1028. 	--check for objective complete 
  1029. 	if SH03_TOWERS_HACKED == 3 then 
  1030. 		SH03_OBJECTIVE_THREE = true 
  1031. 		mission_set_checkpoint(sh03_checkpoint.helicopter.name, true) 
  1032. 		sh03_run(sh03_checkpoint.helicopter.name)	 
  1033. 		return 
  1034. 	end 
  1035. 		 
  1036. 	local dist = 9999 
  1037. 	 
  1038. 	--mark the tower triggers	 
  1039. 	for i, trigger in pairs(sh03_objectives.towers.members) do 
  1040. 		if sh03_objectives.towers.status[i] == false then 
  1041. 			--marker_add_trigger(trigger, MINIMAP_ICON_LOCATION,INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1042. 			sh03_set_trigger( trigger, "sh03_obj_two" ) 
  1043. 				if get_dist( LOCAL_PLAYER, sh03_objectives.towers.nav[i] ) < dist then 
  1044. 					SH03_SHORTEST_PATH = sh03_objectives.towers.nav[i] 
  1045. 					dist = get_dist( LOCAL_PLAYER, sh03_objectives.towers.nav[i] ) 
  1046. 				end				 
  1047. 		end 
  1048. 	end	 
  1049. 	 
  1050. 	--display the shortest path 
  1051. 	mission_waypoint_add( SH03_SHORTEST_PATH, SYNC_ALL ) 
  1052. 	--marker_add( SH03_SHORTEST_PATH, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1053. 	 
  1054. 	--fire off a thread to update the shortest path 
  1055. 	if sh03_threads.UPDATE_PATH_THREAD == INVALID_THREAD_HANDLE then 
  1056. 		sh03_threads.UPDATE_PATH_THREAD = thread_new("sh03_update_path") 
  1057. 	end	 
  1058. 	 
  1059. end 
  1060.  
  1061.  
  1062. function sh03_obj_three_heli() 
  1063. 	local kinzie_id = -1 
  1064. 	 
  1065. 	--message(SH03_CALL_FOR_CHOPPA, 6)	 
  1066. 	 
  1067. 	objective_text_clear( 0 )  
  1068. 	objective_text_clear( 1 )  
  1069. 	 
  1070. 	--sh03_set_trigger( SH03_HELICOPTER_TRIGGER, "sh03_get_to_the_choppa", "LOCATION" ) 
  1071. 	--mission_waypoint_add(SH03_HELICOPTER_TRIGGER) 
  1072. 	trigger_enable(SH03_HELICOPTER_TRIGGER, true) 
  1073. 	on_trigger( "sh03_get_to_the_choppa", SH03_HELICOPTER_TRIGGER )	 
  1074. 	 
  1075. 	if sh03_threads.HELI_ARRIVE == INVALID_THREAD_HANDLE then 
  1076. 		sh03_threads.HELI_ARRIVE = thread_new("sh03_heli_arrival") 
  1077. 	end	 
  1078. 	 
  1079. 	objective_text(0, SH03_GET_TO_THE_CHOPPA, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1080. 	--marker_add_trigger(SH03_HELICOPTER_TRIGGER, MINIMAP_ICON_LOCATION, nil, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1081. 	--marker_add(SH03_HELI_ARRIVE_NAV, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1082. 	mission_waypoint_add(SH03_HELI_ARRIVE_NAV, SYNC_ALL ) 
  1083. 	 
  1084. 	while SH03_GOT_TO_CHOPPA == false do 
  1085. 		thread_yield() 
  1086. 	end 
  1087. 	 
  1088. 	sh03_cleanup_convo_thread() 
  1089. 	objective_text_clear(0) 
  1090. 	 
  1091. 	if SH03_HELI_LANDED == false then 
  1092. 		objective_text(0, SH03_SURVIVE, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1093. 		while SH03_HELI_LANDED == false do 
  1094. 			thread_yield() 
  1095. 			delay(.1) 
  1096. 		end 
  1097. 	end 
  1098. 	 
  1099. 	player_force_vehicle_seat( LOCAL_PLAYER, 5 ) 
  1100. 	if coop_is_active() then 
  1101. 		player_force_vehicle_seat( REMOTE_PLAYER, 4 ) 
  1102. 	end 
  1103. 	 
  1104. 	--marker_remove(SH03_HELI_ARRIVE_NAV, SYNC_ALL) 
  1105. 	mission_waypoint_remove(SYNC_ALL) 
  1106. 	 
  1107. 	--prevent Kinzie from dying to minimize fuck ups 
  1108. 	set_ignore_ai_flag( KINZIE, true ) 
  1109. 	turn_invulnerable(KINZIE, false) 
  1110. 	character_allow_ragdoll(KINZIE, false)  
  1111. 	ai_do_scripted_move(KINZIE, SH03_KINZIE_WAIT, true, false) --tell kinzie to go to the helicopter and get in 
  1112.  
  1113. 	--objective_text_clear(0) 
  1114. 	objective_text(0, ENTER_HELI, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) 
  1115. 	marker_add( SH03_HELICOPTER, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL ) 
  1116. 	 
  1117. 	--GET TO THE CHOPPA!!!!!!! 
  1118. 	repeat  
  1119. 		thread_yield()  
  1120. 			--don't enter the choppa if Kinzie is dead (this can only happen if she died before the helicopter landed 
  1121. 		while ( (character_is_dead(KINZIE) == true) or (follower_is_unconscious(KINZIE) == true) ) do 
  1122. 			thread_yield()  
  1123. 		end 
  1124. 		--dont' teleport in if one of the players is dead 
  1125. 		while ( (human_is_downed(LOCAL_PLAYER) == true) or (human_is_downed(REMOTE_PLAYER) == true) ) do 
  1126. 			thread_yield()  
  1127. 		end 
  1128. 		--don't enter the helicopter if the player is in a vehicle 
  1129. 		while( (character_is_in_vehicle(LOCAL_PLAYER) == true) or (character_is_in_vehicle(REMOTE_PLAYER) == true) ) do 
  1130. 			thread_yield() 
  1131. 		end 
  1132. 		--don't teleport into the heli if involved in a qte 
  1133. 		while( (qte_human_is_used(LOCAL_PLAYER) == true) or (coop_is_active() and qte_human_is_used(REMOTE_PLAYER) == true) ) do 
  1134. 			thread_yield() 
  1135. 		end 
  1136. 		--thread_yield()	 
  1137. 		delay(.1) 
  1138. 	until get_dist_closest_player_to_object( SH03_HELICOPTER ) <= 9 
  1139. 	 
  1140. 	--player within range, time to teleport into the helicopter 
  1141. 	fade_out(1) 
  1142. 	 
  1143. 	party_dismiss_all() --get rid of followers, they mess things up 
  1144. 	delay(1) 
  1145. 	 
  1146. 	if kinzie_id == -1 then --load kinzie's persona so she can still talk to us 
  1147. 		kinzie_id = audio_persona_load_2d("Kinzie") 
  1148. 	end 
  1149. 	 
  1150. 	vehicle_enter_teleport( KINZIE, SH03_HELICOPTER, 1, true )  
  1151. 	 
  1152. 	local weapon 
  1153. 	if coop_is_active() then 
  1154. 		weapon = inv_item_in_slot(REMOTE_PLAYER, "rifle") 
  1155. 		inv_item_equip(weapon, REMOTE_PLAYER) 
  1156. 		vehicle_enter_teleport( REMOTE_PLAYER, SH03_HELICOPTER, 4, true ) 
  1157. 	end 
  1158.  
  1159. 	weapon = inv_item_in_slot(LOCAL_PLAYER, "rifle") 
  1160. 	inv_item_equip(weapon, LOCAL_PLAYER) 
  1161. 	vehicle_enter_teleport( LOCAL_PLAYER, SH03_HELICOPTER, 5, true )  
  1162.  
  1163. 	vehicle_set_keyframed_physics( SH03_HELICOPTER, false ) 
  1164. 	 
  1165. 	delay(1) 
  1166. 	 
  1167. 	fade_in(1) 
  1168.  
  1169. 	--wait until the player hits the trigger inside 
  1170. 	while SH03_GOT_INSIDE == false do 
  1171. 		thread_yield() 
  1172. 	end	 
  1173.  
  1174. end 
  1175.  
  1176.  
  1177. function sh03_obj_four_cooling_tower() 
  1178. 	hud_prompt_clear() --just to make sure it's cleaned up 
  1179. 	--sh03_remove_weapon() 
  1180. 	 
  1181. 	--parachute_disable() 
  1182. 	 
  1183. 	-- Remove the player's parachute 
  1184. 	player_parachute_wear_backpack(LOCAL_PLAYER, false) 
  1185. 	character_parachute_detach(LOCAL_PLAYER) 
  1186. 	if (coop_is_active() ) then 
  1187. 		player_parachute_wear_backpack(REMOTE_PLAYER, false) 
  1188. 		character_parachute_detach(REMOTE_PLAYER) 
  1189. 	end 
  1190. 	 
  1191. 	 
  1192. 	if sh03_threads.HELI_RIDE ~= INVALID_THREAD_HANDLE then 
  1193. 		thread_kill( sh03_threads.HELI_RIDE ) 
  1194. 		sh03_threads.HELI_RIDE = INVALID_THREAD_HANDLE 
  1195. 	end 
  1196. 	 
  1197. 	if sh03_matt_id == -1 then 
  1198. 		sh03_matt_id = audio_persona_load_2d("Matt") 
  1199. 	end 
  1200. 	 
  1201. 	inv_weapon_disable_all_slots( false ) --enable all weapon slots 
  1202. 	 
  1203. 	objective_text_clear( 0 ) 
  1204. 	objective_text_clear( 1 ) 
  1205. 	 
  1206. 	--head downstairs 
  1207. 	objective_text( 0, GO_DOWNSTAIRS, nil, nil, SYNC_ALL, OI_ASSET_LOCATION ) 
  1208. 	 
  1209. 	trigger_enable(SH03_PATH_UPDATE, true)  
  1210. 	on_trigger("sh03_update_stairs", SH03_PATH_UPDATE)  
  1211.  
  1212. 	--mission_waypoint_add( SH03_TOWER_NAV_ONE, SYNC_ALL ) 
  1213. 	marker_add( SH03_TOWER_NAV_ONE, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL ) 
  1214. 	 
  1215. 	 
  1216. 	delay(2) 
  1217. 	sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.enter_tower) 
  1218. 	 
  1219. 	--mission_waypoint_add( SH03_TOWER_NAV_TWO, SYNC_ALL ) 
  1220.  
  1221. 	--repeat thread_yield() until ( get_dist_closest_player_to_object( SH03_TOWER_NAV_ONE ) <= SH03_UPDATE_DIST )	 
  1222. 	--mission_waypoint_remove( SYNC_ALL ) 
  1223. 	 
  1224. 	repeat thread_yield() until ( get_dist_closest_player_to_object( SH03_TOWER_NAV_TWO ) <= SH03_UPDATE_DIST ) 
  1225. 	 
  1226. 	audio_object_post_event("SH03_Break", nil, nil, "SH03_Music") 
  1227. 	 
  1228. 	sh03_mark_routers() 
  1229. 	sh03_spawn_enemies( SH03_ROUTERS_TURNED_OFF ) 
  1230. 	 
  1231. 	marker_remove( SH03_TOWER_NAV_TWO, SYNC_ALL ) 
  1232. 	--mission_waypoint_remove( SYNC_ALL ) 
  1233. 	 
  1234. 	trigger_enable( SH03_CONTINUOUS_SPAWN, true ) 
  1235. 	on_trigger( "sh03_spawns_cb", SH03_CONTINUOUS_SPAWN ) 
  1236. 	 
  1237. 	objective_text_clear( 0 ) 
  1238. 	objective_text_clear( 1 ) 
  1239. 	 
  1240. 	--downstairs, turn off the routers 
  1241. 	objective_text( 0, TURN_OF_THE_ROUTERS, SH03_ROUTERS_TURNED_OFF, SH03_TOTAL_LINKS, SYNC_ALL, OI_ASSET_USE ) 
  1242. 	delay(2) 
  1243. end 
  1244.  
  1245. function sh03_heli_fly(player, veh, seat) 
  1246. 	 
  1247. 	if player ~= LOCAL_PLAYER then 
  1248. 		return 
  1249. 	end 
  1250. 	 
  1251. 	on_vehicle_enter("", SH03_HELICOPTER) 
  1252. 	mesh_mover_hide( "sh03_cap" ) 
  1253.  
  1254. 	--set_player_can_enter_exit_vehicles( KINZIE, false ) 
  1255. 	set_dont_attack_me_on_sight_flag( KINZIE, true ) 
  1256. 	 
  1257. 	--kill the arrival thread 
  1258. 	if sh03_threads.HELI_ARRIVE ~= INVALID_THREAD_HANDLE then 
  1259. 		thread_kill( sh03_threads.HELI_ARRIVE ) 
  1260. 		sh03_threads.HELI_ARRIVE = INVALID_THREAD_HANDLE 
  1261. 	end 
  1262. 	 
  1263. 	--don't progress until kinzie is in the choppa 
  1264. 	--while character_is_in_vehicle(KINZIE, SH03_HELICOPTER) == false do 
  1265. 		--thread_yield() --now we play the waiting game 
  1266. 	--end 
  1267. 	 
  1268. 	--only take off if local and remote player are in the choppa 
  1269. 	while( character_is_in_vehicle(LOCAL_PLAYER, SH03_HELICOPTER ) == false ) do  
  1270. 		if COOP_IS_ACTIVE then 
  1271. 			while(character_is_in_vehicle(REMOTE_PLAYER, SH03_HELICOPTER) == false) do  
  1272. 				thread_yield() 
  1273. 			end 
  1274. 		end	 
  1275. 		thread_yield() --now we play the waiting game 
  1276. 	end 
  1277. 	set_player_can_enter_exit_vehicles( LOCAL_PLAYER, false ) 
  1278. 	 
  1279. 	if COOP_IS_ACTIVE then 
  1280. 		set_player_can_enter_exit_vehicles( REMOTE_PLAYER, false )	 
  1281. 	end 
  1282. 	objective_text_clear(0) 
  1283.  
  1284. 	--is kinzie in the heli? if not, get in the damn helicopter already 
  1285. 	if character_is_in_vehicle(KINZIE, SH03_HELICOPTER) == false then 
  1286. 		vehicle_enter_teleport( KINZIE, SH03_HELICOPTER, 1, true )  
  1287. 	end 
  1288. 	 
  1289. 	SH03_SHOULD_TELE = true 
  1290. 	 
  1291. 	inv_weapon_disable_all_but_this_slot(WEAPON_SLOT_RIFLE, true, SYNC_ALL) --do this to limit the animations used in the heli 
  1292. 	helicopter_set_max_bank_angle( SH03_HELICOPTER, SH03_HELI_MAX_BANK_ANGLE )	 
  1293. 	marker_remove(SH03_HELICOPTER, SYNC_ALL) 
  1294. 	base_jumping_enable(false)  
  1295. 	 
  1296. 	--fire off a thread to play helicopter convos 
  1297. 	if sh03_threads.HELI_RIDE == INVALID_THREAD_HANDLE then 
  1298. 		sh03_threads.HELI_RIDE = thread_new("sh03_heli_convo_thread", SH03_convo.enter_heli, SH03_convo.heli_ride, SH03_convo.cooling_tower)  --SH03_convo.heli_ride2 
  1299. 	end 
  1300. 	 
  1301. 	--fly, helicopter. fly! 
  1302. 	helicopter_fly_to( SH03_HELICOPTER, SH03_HELI_SPEED, SH03_PATH_TO_TOWER ) 
  1303. 	vehicle_speed_override(SH03_HELICOPTER, 0.0)  
  1304. 	 
  1305. 	--we're at our destination, allow the player(s) to jump out of the helicopter again 
  1306. 	set_player_can_enter_exit_vehicles( LOCAL_PLAYER, true ) 
  1307. 	if COOP_IS_ACTIVE == true then 
  1308. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, true) 
  1309. 	end	 
  1310. 	 
  1311. 	objective_text(0, SH03_PARACHUTE, nil, nil, SYNC_ALL, OI_ASSET_LOCATION) --tell the player to jump 
  1312. 	trigger_enable( TOWER_TRIGGER, true ) 
  1313. 	marker_add( TOWER_TRIGGER, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL ) 
  1314. 	 
  1315. 	on_trigger( "sh03_inside_tower", TOWER_TRIGGER ) 
  1316. 	 
  1317. 	--helicopters_set_jitter_override(0.01, 0.01) 
  1318. 	 
  1319. 	-- Prompt the players to jump 
  1320. 	hud_prompt(LOCAL_PLAYER, "SH03_MSG_JUMP", "sh03_jump_local") 
  1321. 	if (COOP_IS_ACTIVE == true) then 
  1322. 		hud_prompt(REMOTE_PLAYER, "SH03_MSG_JUMP", "sh03_jump_remote") 
  1323. 	end 
  1324. 	 
  1325. 	--wait until the player(s) jump 
  1326. 	while character_is_in_vehicle(LOCAL_PLAYER, SH03_HELICOPTER ) or character_is_in_vehicle(REMOTE_PLAYER, SH03_HELICOPTER) do 
  1327. 		thread_yield() 
  1328. 	end	 
  1329. 	 
  1330. 	delay(2) 
  1331. 	 
  1332. 	audio_play_persona_line( LOCAL_PLAYER, SH03_dialog_lines.jump) 
  1333. 	if (COOP_IS_ACTIVE == true) then 
  1334. 		audio_play_persona_line( REMOTE_PLAYER, SH03_dialog_lines.jump) 
  1335. 	end 
  1336. 	 
  1337. 	audio_ambient_emitter_start(sh03_emitters.main) 
  1338. 	SH03_MUSIC_ON = true 
  1339. 	 
  1340. 	sh03_cleanup_kinzie() 
  1341. end 
  1342.  
  1343. function sh03_final_link() 
  1344. 	objective_text_clear(0) 
  1345. 	objective_text( 0, SH03_TURN_OFF_THE_FINAL_LINK, nil, nil, SYNC_ALL, OI_ASSET_USE) 
  1346. 	sh03_set_trigger_use( SH03_FINAL_LINK, "sh03_final_trigger" ) 
  1347. 	 
  1348. 	sh03_cleanup_convo_thread() 
  1349. 	sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.cut_links) 
  1350. end 
  1351.  
  1352. function sh03_inside_tower() 
  1353. 	SH03_GOT_INSIDE = true 
  1354. 	--mission_waypoint_remove( SYNC_ALL ) 
  1355. 	marker_remove(TOWER_TRIGGER, SYNC_ALL) 
  1356. end 
  1357.  
  1358. function sh03_jump_local() 
  1359. 	hud_prompt_clear(LOCAL_PLAYER) 
  1360. 	vehicle_exit(LOCAL_PLAYER) 
  1361. end 
  1362.  
  1363. -- Catch the remote player jumping 
  1364. function sh03_jump_remote() 
  1365. 	hud_prompt_clear(REMOTE_PLAYER) 
  1366. 	vehicle_exit(REMOTE_PLAYER) 
  1367. end 
  1368.  
  1369. -- *************************************************** 
  1370. -- sh03_initialize Helper Functions 
  1371. -- *************************************************** 
  1372.  
  1373. -- Handle any common initialization 
  1374. -- 
  1375. function sh03_initialize_common() 
  1376. 	--[[ INSERT ANY COMMON INITIALIZATION CODE HERE ]]-- 
  1377. 	--sh03_spawn_watcher_thread() 
  1378. 	 
  1379. 	--set_time_of_day(00, 00) -- Set TOD to the middle of the night 
  1380. end 
  1381.  
  1382. -- Checkpoint specific initialization 
  1383. -- 
  1384. -- checkpoint:		The checkpoint to be initialized 
  1385. function sh03_initialize_checkpoint(current_checkpoint) 
  1386.  
  1387. 	if coop_is_active() then 
  1388. 		COOP_IS_ACTIVE = true	 
  1389. 	end	 
  1390. 	 
  1391. 	if current_checkpoint == CHECKPOINT_START then 
  1392. 		group_create(sh03_group.START_CAR.name, true) 
  1393. 		vehicle_car_alarm_enable( sh03_group.START_CAR.members, false ) 
  1394. 		sh03_spawn_watcher_thread() 
  1395. 		if (IS_RESTART == true) then 
  1396. 			teleport_coop(sh03_checkpoint.start.nav1, sh03_checkpoint.start.nav2, true) 
  1397. 		end 
  1398. 	end	 
  1399. 	 
  1400. 	if current_checkpoint == sh03_checkpoint.nuke_plant.name then 
  1401. 		if group_is_loaded( sh03_group.START_CAR.name ) == false then 
  1402. 			group_create(sh03_group.START_CAR.name, true) 
  1403. 		end 
  1404. 		teleport_vehicle(sh03_group.START_CAR.members, sh03_checkpoint.nuke_plant.car) 
  1405.  
  1406. 		sh03_checkpoint_spawn_kinzie() 
  1407. 		sh03_teleport_kinzie(sh03_checkpoint.nuke_plant.nav3)	 
  1408. 		teleport_coop(sh03_checkpoint.nuke_plant.nav1, sh03_checkpoint.nuke_plant.nav2, true) 
  1409. 		sh03_spawn_watcher_thread() 
  1410. 	end	 
  1411. 		 
  1412. 	if current_checkpoint == sh03_checkpoint.helicopter.name then 
  1413. 		if group_is_loaded( sh03_group.START_CAR.name ) == false then 
  1414. 			group_create(sh03_group.START_CAR.name, true) 
  1415. 		end 
  1416. 		teleport_vehicle(sh03_group.START_CAR.members, sh03_checkpoint.helicopter.car) 
  1417.  
  1418. 		sh03_checkpoint_spawn_kinzie() 
  1419. 		sh03_teleport_kinzie(sh03_checkpoint.helicopter.nav3) 
  1420. 		teleport_coop(sh03_checkpoint.helicopter.nav1, sh03_checkpoint.helicopter.nav2, true) 
  1421. 		sh03_spawn_watcher_thread()	 
  1422. 	end 
  1423. 	 
  1424. 	if current_checkpoint == sh03_checkpoint.cooling_tower.name then 
  1425. 		teleport_coop(sh03_checkpoint.cooling_tower.nav1, sh03_checkpoint.cooling_tower.nav2, true) 
  1426. 		--sh03_checkpoint_spawn_kinzie(sh03_checkpoint.cooling_tower.nav2)	 
  1427. 	end 
  1428.  
  1429. end 
  1430.  
  1431.  
  1432. -- *************************************************** 
  1433. -- Miscellaneous sh03 Helper Funcrtions 
  1434. -- *************************************************** 
  1435. function sh03_set_trigger(trigger, trigger_callback) 
  1436. 	trigger_enable(trigger, true) 
  1437. 	marker_add_trigger(trigger, MINIMAP_ICON_LOCATION, nil, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) --INGAME_EFFECT_CHECKPOINT 
  1438. 	on_trigger(trigger_callback, trigger)	 
  1439. end 
  1440.  
  1441. function sh03_set_trigger_use(trigger, trigger_callback) 
  1442. 	trigger_enable(trigger, true) 
  1443. 	marker_add_trigger(trigger, MINIMAP_ICON_USE, INGAME_EFFECT_CHECKPOINT, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL) --INGAME_EFFECT_CHECKPOINT 
  1444. 	on_trigger(trigger_callback, trigger)	 
  1445. end 
  1446.  
  1447. function sh03_spawns_cb() 
  1448.  
  1449. 	audio_ambient_emitter_start(sh03_emitters.ff) 
  1450.  
  1451. 	sh03_clear_trigger( SH03_CONTINUOUS_SPAWN ) 
  1452. 	sh03_cleanup_convo_thread() 
  1453. 	 
  1454. 	--enable the continuous spawn groups 
  1455. 	spawn_region_enable( SH03_cont_spawn.area1, true ) 
  1456. 	spawn_region_enable( SH03_cont_spawn.area2, true ) 
  1457. 	spawn_region_enable( SH03_cont_spawn.area3, true ) 
  1458. 	spawn_region_enable( SH03_cont_spawn.area4, true ) 
  1459. 	 
  1460. 	delay(1) 
  1461. 	 
  1462. 	sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.see_chair) --see chair convo 
  1463. 	 
  1464. 	delay(1) 
  1465. 	 
  1466. 	sh03_manage_defense()  
  1467. end 
  1468.  
  1469. function sh03_update_stairs( player, trigger ) 
  1470. 	on_trigger("", trigger)  
  1471. 	 
  1472. 	marker_remove( SH03_TOWER_NAV_ONE, SYNC_ALL ) 
  1473. 	marker_add( SH03_TOWER_NAV_TWO, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL ) 
  1474. 	 
  1475. 	delay(2) 
  1476. 	if group_is_loaded( sh03_group.STAIRS.name ) == false then 
  1477. 		group_create( sh03_group.STAIRS.name, true ) 
  1478. 		for i, char in pairs(sh03_group.STAIRS.members) do 
  1479. 			on_death( "sh03_release_enemies", char ) 
  1480. 		end 
  1481. 	end 
  1482. end 
  1483.  
  1484. -- Disable trigger 
  1485. -- 
  1486. -- trigger:			(string) Name of the trigger 
  1487. -- 
  1488. function sh03_clear_trigger(trigger)	 
  1489. 	--mission_waypoint_remove(SYNC_ALL) 
  1490. 	on_trigger("", trigger) 
  1491. 	trigger_enable(trigger, false) 
  1492. 	marker_remove_trigger(trigger, SYNC_ALL)	 
  1493. end 
  1494.  
  1495.  
  1496. function sh03_obj_two(player, current_trigger) 
  1497. 	 
  1498. 	on_trigger_exit( "sh03_left_tower_trigger", current_trigger ) 
  1499. 	 
  1500. 	if play_once == true then 
  1501. 		sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.first_shack)  
  1502. 		play_once = false 
  1503. 	end 
  1504. 	 
  1505. 	--marker_remove( SH03_SHORTEST_PATH, SYNC_ALL ) 
  1506. 	 
  1507. 	for i, trigger in pairs(sh03_objectives.towers.members) do 
  1508. 		if sh03_objectives.towers.status[i] == false and sh03_objectives.towers.members[i] == current_trigger then 
  1509. 			CURRENT_TOWER = sh03_objectives.towers.nav[i] 
  1510. 			TOWER_INDEX = i 
  1511. 			--sh03_objectives.towers.active[i] = true 
  1512. 		end		 
  1513. 	end	 
  1514. 	 
  1515. 	--[[ 
  1516. 	while character_is_in_vehicle( LOCAL_PLAYER ) == true do 
  1517. 		thread_yield() 
  1518. 	end 
  1519. 	 
  1520. 	sh03_kinzie_hack_tower( CURRENT_TOWER )  
  1521. 	]]-- 
  1522. 	 
  1523. end 
  1524.  
  1525.  
  1526. function sh03_left_tower_trigger( player, trigger ) 
  1527. 	if SH03_KINZIE_HACKING == true then 
  1528. 		return 
  1529. 	end 
  1530. 	 
  1531. 	on_trigger( "sh03_obj_two", trigger ) 
  1532. 	CURRENT_TOWER = nil 
  1533. end 
  1534.  
  1535.  
  1536. function sh03_get_to_the_choppa() 
  1537. 	--sh03_clear_trigger(SH03_HELICOPTER_TRIGGER) 
  1538. 	 
  1539. 	on_trigger("", SH03_HELICOPTER_TRIGGER) 
  1540. 	trigger_enable(SH03_HELICOPTER_TRIGGER, false) 
  1541. 	 
  1542. 	objective_text_clear(0) 
  1543. 	SH03_GOT_TO_CHOPPA = true 
  1544. 	 
  1545. 	--make the player think he has 5* notoriety 
  1546. 	--hud_set_fake_notoriety("deckers", true, 5) 
  1547. 	 
  1548. 	--sh03_control_notoriety( SH03_NOTERIETY_LEVEL ) --old value 4 
  1549. 	if( character_is_in_vehicle(KINZIE) == false ) then  
  1550. 		ai_do_scripted_move(KINZIE, SH03_KINZIE_WAIT, true, false) 
  1551. 	end 
  1552. end 
  1553.  
  1554. -- called when a router is turned off 
  1555. --  
  1556. function sh03_obj_four(player, current_trigger) 
  1557.  
  1558. 	local nav 
  1559. 	 
  1560. 	--get the nav point 
  1561. 	for i, trigger in pairs(sh03_objectives.routers.members) do 
  1562. 		if sh03_objectives.routers.members[i] == current_trigger  then 
  1563. 			sh03_objectives.routers.status[i] = true	 
  1564. 			nav = i 
  1565. 		end		 
  1566. 	end	 
  1567.  
  1568. 	--be a l33t hax0r 
  1569. 	character_allow_ragdoll( player, false ) 
  1570. 	player_movement_disable(player) 
  1571. 	action_play(player, "m24 computer hack", "m24 computer hack",  false, 1.0, true, true, sh03_objectives.routers.hack[nav] ) 
  1572. 	while action_play_is_finished( player, 1.0 ) == false do 
  1573. 		thread_yield() 
  1574. 	end 
  1575. 	--delay(.5) 
  1576. 	character_allow_ragdoll( player, true ) 
  1577. 	player_movement_enable(player) 
  1578. 	 
  1579. 	--update objective 
  1580. 	SH03_ROUTERS_TURNED_OFF = SH03_ROUTERS_TURNED_OFF + 1 
  1581. 	objective_text( 0, TURN_OF_THE_ROUTERS  , SH03_ROUTERS_TURNED_OFF , SH03_TOTAL_LINKS , SYNC_ALL, OI_ASSET_USE ) 
  1582. 	sh03_clear_trigger(current_trigger)	 
  1583. 	 
  1584. 	sh03_manage_defense() --spawn enemies and/or disable cont spawns 
  1585. 	 
  1586. 	audio_object_post_event("Force_Field_Powerdown") 
  1587. 	 
  1588. 	if SH03_ROUTERS_TURNED_OFF == 4 then 
  1589. 		SH03_OBJ_FOUR_COMPLETE = true 
  1590. 		mesh_mover_hide( "sh03_force_field" ) 
  1591. 	end 
  1592. 	 
  1593. 	delay(2) 
  1594. 	audio_play_persona_line_2d( sh03_matt_id, SH03_dialog_lines.matt_taunts[SH03_ROUTERS_TURNED_OFF] ) 
  1595. 	 
  1596. end 
  1597.  
  1598. function sh03_final_trigger(player, current_trigger) 
  1599. 	 
  1600. 	character_allow_ragdoll( player, false ) 
  1601. 	player_movement_disable(player) 
  1602. 	action_play(player, "m24 computer hack", "", true, false, true, "", SH03_FINAL_NAV ) 
  1603. 	while action_play_is_finished( player, 1.0 ) == false do 
  1604. 		thread_yield() 
  1605. 	end 
  1606. 	--delay(.5) 
  1607. 	player_movement_enable(player) 
  1608. 	character_allow_ragdoll( player, true ) 
  1609. 	 
  1610. 	audio_object_post_event("Force_Field_Powerdown") 
  1611. 	 
  1612. 	delay(1) 
  1613. 	 
  1614. 	audio_object_post_event("SH03_Music_Stop", nil, nil, "SH03_Music")  
  1615. 	 
  1616. 	if sh03_threads.SPAWN_THREAD ~= INVALID_THREAD_HANDLE then 
  1617. 		thread_kill(sh03_threads.SPAWN_THREAD) 
  1618. 		sh03_threads.SPAWN_THREAD = INVALID_THREAD_HANDLE 
  1619. 		--message("convo thread killed", 2) 
  1620. 	end 
  1621. 	 
  1622. 	sh03_clear_trigger( SH03_FINAL_LINK ) 
  1623. 	 
  1624. 	--[[ 
  1625. 	if( SH03_ROOM_DEFENDERS_LEFT > 0 ) then 
  1626. 		sh03_clean_house() 
  1627. 	end 
  1628. 	]]-- 
  1629. 	 
  1630. 	objective_text_clear( 0 ) 
  1631. 	 
  1632. 	delay(1) 
  1633. 	 
  1634. 	--audio_ambient_emitter_stop( sh03_emitters.main ) 
  1635. 	 
  1636. 	mission_end_success( "sh03" ) --, CUTSCENE_MISSION_OUTRO )	 
  1637. end 
  1638.  
  1639. function sh03_kinzie_hack_tower(current_tower)  
  1640. 	local hack_done = false 
  1641. 	 
  1642. 	SH03_KINZIE_HACKING = true --fail safe for the player leaving the trigger while Kinzie is in the process of hacking 
  1643.  
  1644. 	sh03_control_notoriety(SH03_NOTERIETY_LEVEL) 
  1645. 	sh03_cleanup_convo_thread()	--kill the convo thread, if it's still playing when the player gets to this point 
  1646. 	 
  1647. 	--stop updating the shortest path 
  1648. 	SH03_HIT_TRIGGER = true  
  1649. 	if sh03_threads.UPDATE_PATH_THREAD ~= INVALID_THREAD_HANDLE then 
  1650. 		thread_kill(sh03_threads.UPDATE_PATH_THREAD) 
  1651. 		sh03_threads.UPDATE_PATH_THREAD = INVALID_THREAD_HANDLE 
  1652. 	end	 
  1653. 	 
  1654. 	--mark the current tower as active 
  1655. 	for i, trigger in pairs(sh03_objectives.towers.members) do 
  1656. 		if sh03_objectives.towers.status[i] == false and sh03_objectives.towers.members[i] == current_tower then 
  1657. 			sh03_objectives.towers.active[i] = true 
  1658. 		end		 
  1659. 	end 
  1660. 	 
  1661. 	--disable the current trigger callbacks 
  1662. 	for i, trigger in pairs(sh03_objectives.towers.members) do 
  1663. 		if sh03_objectives.towers.status[i] == false then 
  1664. 			sh03_clear_trigger( trigger ) 
  1665. 			on_trigger_exit( "", trigger ) 
  1666. 		end		 
  1667. 	end 
  1668. 	 
  1669. 	mission_waypoint_remove( SYNC_ALL ) 
  1670. 	--object_indicator_add( KINZIE, OI_ASSET_DEFEND, OI_FLAGS_FULL ) 
  1671. 	marker_add(KINZIE, MINIMAP_ICON_PROTECT_ACQUIRE, OI_ASSET_DEFEND, OI_FLAGS_FULL, SYNC_ALL )  
  1672. 	 
  1673. 	--start hacking 
  1674. 	ai_do_scripted_move(KINZIE, current_tower, true, false) --tell kinzie to go to the tower and start hacking 
  1675. 	 
  1676. 	while ai_scripted_action_is_complete( KINZIE ) == false do --wait for her to get to the tower 
  1677. 		thread_yield() 
  1678. 	end	 
  1679. 	 
  1680. 	--Kinzie is kind of an idiot and will forget to go to teh tower every now and then 
  1681. 	if get_dist( KINZIE, current_tower ) > 2.0 then --safety net, if she isn't in the navpoint tell her to go there again 
  1682. 		ai_do_scripted_move(KINZIE, current_tower, true, false) 
  1683. 		repeat thread_yield() until ( get_dist( KINZIE, current_tower ) < 2.0 ) -- wait for kinzie to get in the tower before starting the timer 
  1684. 	end 
  1685. 	 
  1686. 	--message("kinzie is at the tower!!!!!", 6) 
  1687. 	action_play_non_blocking( KINZIE, "SH03 kenzie hack enter", "", true, false, true, "", current_tower) 
  1688. 	 
  1689. 	objective_text_clear(0) 
  1690. 	objective_text_clear(1) 
  1691. 	 
  1692. 	local progress = 0 
  1693. 	local r = rand_int(1, 8) 
  1694. 	local hack_time = SH03_BASE_TIME -- + ( SH03_MULTIPLIER * 10 * ( SH03_TOWERS_HACKED + 1 )  + (SH03_MULTIPLIER * 100 ) ) 
  1695. 	local t = rand_int(15000, (SH03_BASE_TIME * .8)) 
  1696. 	 
  1697. 	hud_bar_on( 0, "Default", SH03_HACKING_TIME, hack_time, SYNC_ALL ) 
  1698. 	--action_play_non_blocking( KINZIE, "SH03 kenzie hack","", true, false, true, current_tower ) 
  1699. 	set_animation_state(KINZIE, "SH03 kenzie hack") 
  1700. 	 
  1701. 	--do a bunch of shit so kinzie stays in her animation and doesn't look stupid 
  1702. 	character_prevent_flinching(KINZIE, true)  
  1703. 	set_ignore_ai_flag( KINZIE, true ) 
  1704. 	turn_invulnerable(KINZIE, false) 
  1705. 	character_allow_ragdoll(KINZIE, false)  
  1706.  
  1707. 	--kinzie is hacking the tower loop 
  1708. 	while progress < hack_time do 
  1709. 	--	if action_play_is_finished(KINZIE, 1.0) == true then 
  1710. 	--		action_play_non_blocking( KINZIE, "SH03 kenzie hack","", true, false, true, current_tower ) 
  1711. 	--	end 
  1712. 		progress = progress + SH03_TIMER -- - (SH03_MULTIPLIER * (TOTAL_TOWERS - SH03_TOWERS_HACKED) * 10) ) 
  1713. 		 
  1714. 		if progress >= t then --the player is impatient, play a random comment telling kinzie to hurry up 
  1715. 			if SH03_TOWERS_HACKED == 0 then 
  1716. 				sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.uplink_convo2)		 
  1717. 				t = 999999 
  1718. 			elseif SH03_TOWERS_HACKED == 1 then 
  1719. 				sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.uplink_convo) 	 
  1720. 				t = 999999 
  1721. 			elseif SH03_TOWERS_HACKED == 2 then 
  1722. 				audio_play_persona_line( LOCAL_PLAYER, SH03_dialog_lines.impatient_player[r] )	 
  1723. 				t = 999999 
  1724. 			end 
  1725. 		end 
  1726. 		if human_is_downed(KINZIE) == true then 
  1727. 			progress = 0 --reset the timer if kinzie gets killed 
  1728. 		end 
  1729. 		 
  1730. 		hud_bar_set_value( 0, progress )		 
  1731. 		delay(.1) 
  1732. 	end 
  1733. 	 
  1734. 	delay(.25) 
  1735. 	clear_animation_state(KINZIE) 
  1736. 	 
  1737. 	action_play( KINZIE, "SH03 kenzie hack exit" ) 
  1738. 	character_allow_ragdoll(KINZIE, true)  
  1739. 	turn_vulnerable(KINZIE)  
  1740. 	character_prevent_flinching(KINZIE, false)  
  1741.  
  1742. 	 
  1743. 	--we done! let's clean everything up 
  1744. 	sh03_tower_complete() 
  1745. end 
  1746.  
  1747. function sh03_tower_complete(cur_tower) 
  1748.  
  1749. 	for i, trigger in pairs(sh03_objectives.towers.members) do 
  1750. 		if sh03_objectives.towers.active[i] == true  then 
  1751. 			sh03_objectives.towers.active[i] = false 
  1752. 		end		 
  1753. 	end	 
  1754. 	 
  1755. 	CURRENT_TOWER = nil 
  1756. 	 
  1757. 	SH03_KINZIE_HACKING = false 
  1758. 	 
  1759. 	if SH03_TOWERS_HACKED == 0 then 
  1760. 		audio_play_persona_line( KINZIE, SH03_dialog_lines.kinzie_triangulate[1] ) 
  1761. 	end 
  1762. 	if SH03_TOWERS_HACKED == 1 then 
  1763. 		audio_play_persona_line( KINZIE, SH03_dialog_lines.kinzie_triangulate[2] ) 
  1764. 	end	 
  1765. 	 
  1766. 	--mission_debug("hacking complete") 
  1767. 	 
  1768. 	--object_indicator_remove( KINZIE ) 
  1769. 	marker_remove(KINZIE, SYNC_ALL) 
  1770. 	set_ignore_ai_flag( KINZIE, false ) 
  1771. 	 
  1772. 	--hud_timer_hide(0, true) 
  1773. 	--hud_timer_stop( 1 ) 
  1774. 	hud_bar_off( 0 ) 
  1775. 	objective_text_clear( 0 ) 
  1776. 	objective_text_clear( 1 ) 
  1777. 	 
  1778. 	sh03_objectives.towers.status[TOWER_INDEX] = true 
  1779. 	--objective_text( 0, SH03_HACK_TOWER, SH03_TOWERS_HACKED , TOTAL_TOWERS , SYNC_ALL, OI_ASSET_LOCATION ) 
  1780. 	 
  1781. 	npc_leash_remove( KINZIE ) --allow Kinzie to run away from the navpoint 
  1782. 	 
  1783. 	SH03_NOTERIETY_LEVEL = SH03_NOTERIETY_LEVEL + 1 
  1784. 	SH03_TOWERS_HACKED = SH03_TOWERS_HACKED + 1 
  1785. 	SH03_TIMER = SH03_TIMER * SH03_MULTIPLIER 
  1786. 	--mission_debug("calling setup") 
  1787. 	sh03_setup_obj_two()	 
  1788. end 
  1789.  
  1790. function sh03_mark_routers() 
  1791. 	 
  1792. 	for i, trigger in pairs(sh03_objectives.routers.members) do 
  1793. 		if sh03_objectives.routers.status[i] == false then 
  1794. 			marker_add_trigger(trigger, MINIMAP_ICON_USE, INGAME_EFFECT_LOCATION, OI_ASSET_USE, OI_FLAGS_FULL, SYNC_ALL) --INGAME_EFFECT_CHECKPOINT 
  1795. 			sh03_set_trigger_use( trigger, "sh03_obj_four" )		 
  1796. 		end 
  1797. 	end 
  1798. 	 
  1799. end 
  1800.  
  1801. function sh03_spawn_enemies( wave ) 
  1802. 	if( wave == 0 ) then 
  1803. 		sh03_add_queue(sh03_group.ROOM_DEFENSE) 
  1804. 		 
  1805. 		--spawn additional defenders if in co-op 
  1806. 		if coop_is_active() then 
  1807. 			sh03_add_queue(sh03_group.COOP_DEFENDERS) 
  1808. 		end 
  1809. 		 
  1810. 		--make sure the spawning thread is active 
  1811. 		if sh03_threads.SPAWN_THREAD == INVALID_THREAD_HANDLE then 
  1812. 			sh03_threads.SPAWN_THREAD = thread_new("sh03_spawning") 
  1813. 		end	 
  1814. 	end 
  1815. 	 
  1816. 	if( wave == 1 ) then 
  1817. 		if coop_is_active() then 
  1818. 			sh03_add_queue(sh03_group.COOP_WAVE_ONE) 
  1819. 		else 
  1820. 			sh03_add_queue(sh03_group.WAVE_ONE) 
  1821. 		end 
  1822. 	end 
  1823. 	 
  1824. 	if( wave == 2 ) then 
  1825. 		if coop_is_active() then 
  1826. 			sh03_add_queue(sh03_group.COOP_WAVE_TWO) 
  1827. 		else 
  1828. 			sh03_add_queue(sh03_group.WAVE_TWO) 
  1829. 		end 
  1830. 	end 
  1831. 	 
  1832. 	if( wave == 3 ) then 
  1833. 		if coop_is_active() then 
  1834. 			sh03_add_queue(sh03_group.COOP_WAVE_THREE) 
  1835. 		else 
  1836. 			sh03_add_queue(sh03_group.WAVE_THREE) 
  1837. 		end 
  1838. 	end 
  1839. end 
  1840.  
  1841. function sh03_manage_defense() 
  1842.  
  1843. 	if( SH03_ROUTERS_TURNED_OFF == 0 ) then 
  1844. 		continuous_spawn_start( sh03_group.ATTACK_SOL.name, 0, SH03_SOLDIER_DELAYY ) 
  1845. 		return 
  1846. 	end 
  1847. 	if( SH03_ROUTERS_TURNED_OFF == 1 ) then  
  1848. 		--cont spawn specialists 
  1849. 		continuous_spawn_start( sh03_group.ATTACK_SPEC.name, 2, SH03_SPECIALIST_DELAY ) 
  1850. 	end 
  1851. 	if( SH03_ROUTERS_TURNED_OFF == 2 ) then 
  1852. 		continuous_spawn_stop( sh03_group.ATTACK_SPEC.name ) --stop the specialists 
  1853. 		continuous_spawn_stop( sh03_group.ATTACK_SOL.name ) --stop the soldiers 
  1854. 		 
  1855. 		--disable continuous spawns 
  1856. 		spawn_region_enable( SH03_cont_spawn.area1, false ) 
  1857. 		spawn_region_enable( SH03_cont_spawn.area2, false ) 
  1858. 		spawn_region_enable( SH03_cont_spawn.area3, false ) 
  1859. 		spawn_region_enable( SH03_cont_spawn.area4, false ) 
  1860. 	end 
  1861.  
  1862. 	sh03_spawn_enemies( SH03_ROUTERS_TURNED_OFF ) 
  1863. end 
  1864.  
  1865. function sh03_add_queue(insert) 
  1866. 	sh03_queue[sh03_queue_size] = insert 
  1867. 	sh03_queue_size = sh03_queue_size + 1 
  1868. end 
  1869.  
  1870. -- mark the remaining deckers and wait for them to be killed 
  1871. --  
  1872. function sh03_clean_house() 
  1873.  
  1874. 	if group_is_loaded( sh03_group.ROOM_DEFENSE.name ) then  
  1875. 		for i, char in pairs(sh03_group.ROOM_DEFENSE.members) do 
  1876. 			if character_is_dead( char )  == false then 
  1877. 				sh03_mark_enemies(char) 
  1878. 			end 
  1879. 		end 
  1880. 	end 
  1881. 	if group_is_loaded( sh03_group.WAVE_ONE.name ) then  
  1882. 		for i, char in pairs(sh03_group.WAVE_ONE.members) do 
  1883. 			if character_is_dead( char )  == false then 
  1884. 				sh03_mark_enemies(char) 
  1885. 			end 
  1886. 		end 
  1887. 	end 
  1888. 	if group_is_loaded( sh03_group.WAVE_TWO.name ) then  
  1889. 		for i, char in pairs(sh03_group.WAVE_TWO.members) do 
  1890. 			if character_is_dead( char )  == false then 
  1891. 				sh03_mark_enemies(char) 
  1892. 			end 
  1893. 		end 
  1894. 	end 
  1895. 	if group_is_loaded( sh03_group.WAVE_THREE.name ) then  
  1896. 		for i, char in pairs(sh03_group.WAVE_THREE.members) do 
  1897. 			if character_is_dead( char )  == false then 
  1898. 				sh03_mark_enemies(char) 
  1899. 			end 
  1900. 		end 
  1901. 	end 
  1902. 	 
  1903. 	sh03_threads.CONVO_PLAY_THREAD = thread_new("sh03_play_convo_thread", SH03_convo.clean_house) 
  1904. 	 
  1905. 	objective_text( 0, KILL_TARGETS, nil, nil, SYNC_ALL, OI_ASSET_KILL ) 
  1906. 	 
  1907. 	repeat thread_yield() until ( SH03_ROOM_DEFENDERS_LEFT <= 0 )  
  1908. 	--message("cleaning house", 5) 
  1909. 	 
  1910. 	--mission_end_success( "sh03" ) --, CUTSCENE_MISSION_OUTRO ) 
  1911. end 
  1912.  
  1913. -- this function limits what enemies spawn at certain notoriety levels 
  1914. --  
  1915. function sh03_control_notoriety(level) 
  1916.  
  1917. 	notoriety_set_max( "deckers", level ) 
  1918. 	notoriety_set_can_decay( false ) 
  1919. 	notoriety_set( "deckers", level ) 
  1920.  
  1921. 	if level == 3 then 
  1922. 		disable_specific_notoriety_group( "deckers", level, "G_Decker_SUV_1S", true ) 
  1923. 		disable_specific_notoriety_group(  "deckers", level, "G_Decker_Car_1S", true ) 
  1924. 	end 
  1925. 	if level == 4 then 
  1926. 		disable_specific_notoriety_group(  "deckers", level, "G_Decker_Car_1S", true ) 
  1927. 		disable_specific_notoriety_group(  "deckers", level, "G_Decker_Car_2S", true ) 
  1928. 		disable_specific_notoriety_group(  "deckers", level, "G_Decker_Brute_F", true ) 
  1929. 	end 
  1930. 	if level == 5 then 
  1931. 		disable_specific_notoriety_group(  "deckers", level, "G_Decker_Brute_M", true ) 
  1932. 		disable_specific_notoriety_group(  "deckers", level, "G_Decker_Brute_G", true ) 
  1933. 		--disable_specific_notoriety_group(  "deckers", level, "G_Decker_Car_2S", true ) 
  1934. 		disable_specific_notoriety_group(  "deckers", level, "G_Decker_SUV_2S", true ) 
  1935. 	end 
  1936. 		 
  1937. end 
  1938.  
  1939. -- this function tells the interior enemies where to go once they're spawned 
  1940. --  
  1941. function sh03_dispense_enemies( enemy_group ) 
  1942. 	local j 
  1943. 	 
  1944. 	-- make sure they aren't the initial group, they don't need to go anywhere 
  1945. 	if enemy_group.name ~= "Router 001" and enemy_group.name ~= "coop_router_defenders" then 
  1946. 		for i, enemy in pairs(enemy_group.members) do 
  1947. 			if i > 4 then --only 4 routers. the goal is to send 2 guards to each open router 
  1948. 				j = i % 4 
  1949. 			else 
  1950. 				j = i 
  1951. 			end 
  1952. 			 
  1953. 			--Look for routers that haven't been shut off (true = off), we don't want the deckers defending an inactive router 
  1954. 			local num_tests = 0 
  1955. 			while (sh03_objectives.routers.status[j] == true) and (num_tests < 4) do 
  1956. 				if j == 4 then --overflow check 
  1957. 					j = 1 
  1958. 				else 
  1959. 					j = j + 1 
  1960. 				end 
  1961. 				num_tests = num_tests + 1 
  1962. 			end 
  1963. 			 
  1964. 			enemy_group.thread[i] = thread_new( "sh03_attack", enemy, sh03_objectives.routers.navs[j] )  
  1965. 		end 
  1966. 	end 
  1967.  
  1968. end 
  1969.  
  1970. function sh03_kinzie_dead() 
  1971. 	mission_end_failure( "sh03", SH03_KINZIE_DIED ) 
  1972. end 
  1973.  
  1974. function sh03_kinzie_abandoned() 
  1975. 	mission_end_failure( "sh03", SH03_KINZIE_ABANDODNED ) 
  1976. end 
  1977.  
  1978. function sh03_get_out_of_vehicles() 
  1979.  
  1980. 	if character_is_in_vehicle(KINZIE, nil) then 
  1981. 		character_evacuate_from_all_vehicles(KINZIE, false)  
  1982. 	end 
  1983. 	 
  1984. 	 
  1985. 	if character_is_in_vehicle(LOCAL_PLAYER, nil) then 
  1986. 		character_evacuate_from_all_vehicles(LOCAL_PLAYER, false)  
  1987. 	end 
  1988.  
  1989. 	 
  1990. 	if COOP_IS_ACTIVE == true then 
  1991. 		if character_is_in_vehicle(REMOTE_PLAYER, nil) then 
  1992. 			character_evacuate_from_all_vehicles(REMOTE_PLAYER, false)  
  1993. 		end 
  1994. 	end 
  1995. end 
  1996.  
  1997.  
  1998. function sh03_mark_enemies(char) 
  1999. 	marker_add( char, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL )	 
  2000. end 
  2001.  
  2002. function sh03_release_enemies( char ) 
  2003. 	release_to_world( char ) 
  2004. 	on_death( "", char ) 
  2005. 	on_attack_performed("", char) 
  2006. end 
  2007.  
  2008. function sh03_free_enemies( char )	 
  2009. 	marker_remove( char, SYNC_ALL ) 
  2010. 	SH03_ROOM_DEFENDERS_LEFT = SH03_ROOM_DEFENDERS_LEFT - 1 
  2011. 	sh03_release_enemies( char ) 
  2012. end 
  2013.  
  2014. -- ************************* 
  2015. -- 
  2016. -- Callback functions 
  2017. -- 
  2018. -- ************************* 
  2019. function sh03_obj_one( )--player, trigger ) 
  2020. 	--sh03_clear_trigger(trigger)	 
  2021. 	mission_waypoint_remove(SYNC_ALL) 
  2022. 	marker_remove(SH03_GPS_OBJECTIVE_ONE, SYNC_ALL) 
  2023. 	objective_text_clear(0)	 
  2024. 	 
  2025. 	SH03_OBJECTIVE_ONE_COMPLETE = true 
  2026. 	 
  2027. 	--on_vehicle_enter( "", LOCAL_PLAYER ) --unregister the call incase the player decides to run over to the nuke plant 
  2028. end 
  2029.  
  2030. function sh03_jump() 
  2031.  
  2032. end 
  2033.  
  2034. function sh03_attack_line_cb( name, weapon, attack ) 
  2035.  
  2036. 	-- SAY IT! - "it" 
  2037. 	local situation = "SH03_Attack" 
  2038. 	 
  2039. 	-- don't play this if we have done this recently 
  2040. 	if (not thread_check_done(sh03_threads.attack_line_timer)) then 
  2041. 		return 
  2042. 	end 
  2043. 	 
  2044. 	-- start timer 
  2045. 	sh03_threads.attack_line_timer = thread_new("delay", 10) 
  2046. 	-- play situation 
  2047. 	audio_play_persona_line(name, situation) 
  2048.  
  2049. end 
  2050.  
  2051. function sh03_play_car_convo() 
  2052.  
  2053. 	trigger_enable( SH03_PLAY_CAR_CONVO, false ) 
  2054. 	on_trigger_exit( "", SH03_PLAY_CAR_CONVO ) 
  2055. 	 
  2056. 	--fire off a thread to play car convos 
  2057. 	if sh03_threads.CAR_RIDE == INVALID_THREAD_HANDLE then 
  2058. 		sh03_threads.CAR_RIDE = thread_new("sh03_car_convo_thread", SH03_convo.mission_start, SH03_convo.drive_over, SH03_convo.drive_over2) 
  2059. 	end 
  2060. end 
  2061.  
  2062.  
  2063. -- ************************* 
  2064. -- 
  2065. -- Thread functions 
  2066. -- 
  2067. -- ************************* 
  2068.  
  2069. function sh03_kinzie_in_party() 
  2070. 	 
  2071. 	while group_is_loaded( sh03_group.START.name ) == false do 
  2072. 		delay(1) 
  2073. 	end 
  2074.  
  2075. 	party_add( KINZIE, LOCAL_PLAYER ) 
  2076. 	--if (coop_is_active() == true) then 
  2077. 		--party_add( KINZIE, REMOTE_PLAYER ) 
  2078. 	--end 
  2079.  
  2080. 	while npc_is_in_party(KINZIE) == true do 
  2081. 		thread_yield()  
  2082. 	 end 
  2083. 	 --mission_end_failure("sh03",SH03_KINZIE_DIED) 
  2084. end 
  2085.  
  2086. function sh03_play_convo_thread(convo) 
  2087. 	convo.handle = audio_conversation_load(convo.name) 
  2088. 	audio_conversation_play(convo.handle) 
  2089. 	audio_conversation_wait_for_end(convo.handle) 
  2090. 	audio_conversation_end(convo.handle) 
  2091. 	--convo.handle = INVALID_CONVERSATION_HANDLE 
  2092. end 
  2093.  
  2094. function sh03_car_convo_thread(convo1, convo2, convo3) 
  2095.  
  2096. 	delay(2) 
  2097.  
  2098. 	convo1.handle = audio_conversation_load(convo1.name) 
  2099. 	audio_conversation_play(convo1.handle) 
  2100. 	audio_conversation_wait_for_end(convo1.handle) 
  2101. 	audio_conversation_end(convo1.handle) 
  2102. 	convo1.handle = INVALID_THREAD_HANDLE 
  2103. 	 
  2104. 	delay(4)  
  2105. 	 
  2106. 	convo2.handle = audio_conversation_load(convo2.name) 
  2107. 	audio_conversation_play(convo2.handle) 
  2108. 	audio_conversation_wait_for_end(convo2.handle) 
  2109. 	audio_conversation_end(convo2.handle) 
  2110. 	convo2.handle = INVALID_THREAD_HANDLE 
  2111. 	 
  2112. 	delay(6.5) 
  2113. 	 
  2114. 	convo3.handle = audio_conversation_load(convo3.name) 
  2115. 	audio_conversation_play(convo3.handle) 
  2116. 	audio_conversation_wait_for_end(convo3.handle) 
  2117. 	audio_conversation_end(convo3.handle) 
  2118. 	convo3.handle = INVALID_THREAD_HANDLE 
  2119. 	 
  2120. end 
  2121.  
  2122. function sh03_heli_convo_thread(convo1, convo2, convo3) 
  2123. 	 
  2124. 	delay(2) 
  2125. 	convo1.handle = audio_conversation_load(convo1.name) 
  2126. 	audio_conversation_play(convo1.handle) 
  2127. 	audio_conversation_wait_for_end(convo1.handle) 
  2128. 	audio_conversation_end(convo1.handle) 
  2129. 	convo1.handle = INVALID_THREAD_HANDLE 
  2130. 	 
  2131. 	delay(5) --fix this to time the flight 
  2132. 	 
  2133. 	--find anything yet? ... blah blah blah, needs more time 
  2134. 	convo2.handle = audio_conversation_load(convo2.name) 
  2135. 	audio_conversation_play(convo2.handle) 
  2136. 	audio_conversation_wait_for_end(convo2.handle) 
  2137. 	audio_conversation_end(convo2.handle) 
  2138. 	convo2.handle = INVALID_THREAD_HANDLE 
  2139. 	 
  2140. 	delay(6.5) 
  2141. 	 
  2142. 	audio_play_persona_line( KINZIE, SH03_dialog_lines.kinzie_chair ) 
  2143. 	 
  2144. 	delay(3) 
  2145. 	 
  2146. 	convo3.handle = audio_conversation_load(convo3.name) 
  2147. 	audio_conversation_play(convo3.handle) 
  2148. 	audio_conversation_wait_for_end(convo3.handle) 
  2149. 	audio_conversation_end(convo3.handle) 
  2150. 	convo3.handle = INVALID_THREAD_HANDLE 
  2151. 	 
  2152. end 
  2153.  
  2154. -- this function updates the shortest path to the hack towers 
  2155. -- 
  2156. function sh03_update_path() 
  2157. 	local dist = 99999 
  2158. 	local old_path = SH03_SHORTEST_PATH 
  2159. 	 
  2160. 	while(true) do--while( SH03_HIT_TRIGGER == false ) do 
  2161. 		for i, trigger in pairs(sh03_objectives.towers.members) do 
  2162. 			if sh03_objectives.towers.status[i] == false then 
  2163. 				if get_dist( LOCAL_PLAYER, sh03_objectives.towers.nav[i] ) < dist then  --sh03_objectives.towers.nav[i] 
  2164. 					SH03_SHORTEST_PATH = sh03_objectives.towers.members[i]  --make sure to draw the waypoint on the trigger 
  2165. 					dist = get_dist( LOCAL_PLAYER, sh03_objectives.towers.nav[i] ) 
  2166. 				end				 
  2167. 			end 
  2168. 		end	 
  2169. 		 
  2170. 		if( old_path ~= SH03_SHORTEST_PATH) then  --only print if there's a new shortest path 
  2171. 			mission_waypoint_remove( SYNC_ALL ) 
  2172. 			mission_waypoint_add( SH03_SHORTEST_PATH, SYNC_ALL ) 
  2173. 			--marker_add( SH03_SHORTEST_PATH, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  2174. 			old_path = SH03_SHORTEST_PATH 
  2175. 		end 
  2176. 		 
  2177. 		dist = 99999 
  2178. 		delay(.5) 
  2179. 	end 
  2180. end 
  2181.  
  2182. -- thread function to control spawning 
  2183. -- we can't have more than 32 objective markers on screen, so this function makes sure we never have more than 32 enemies spawned 
  2184. --  
  2185. function sh03_spawning() 
  2186. 	while(true) do 
  2187. 		-- do we have anything in the queue? 
  2188. 		if( sh03_queue_size > 0 ) then 
  2189. 			if( sh03_queue[0].size + SH03_ROOM_DEFENDERS_LEFT < 32 ) then 
  2190. 				group_create( sh03_queue[0].name, true ) 
  2191. 				if group_is_loaded( sh03_queue[0].name ) then  
  2192. 					for i, char in pairs(sh03_queue[0].members) do 
  2193. 						--sh03_mark_enemies(char) 
  2194. 						SH03_ROOM_DEFENDERS_LEFT = SH03_ROOM_DEFENDERS_LEFT + 1 
  2195. 						on_death( "sh03_free_enemies", char ) 
  2196. 						on_attack_performed("sh03_attack_line_cb", char) 
  2197. 					end 
  2198. 				end 
  2199. 				 
  2200. 				--defense group created, now tell the enemies where to go 
  2201. 				sh03_dispense_enemies( sh03_queue[0] ) 
  2202. 				 
  2203. 				--update the queue 
  2204. 				for i = 1, sh03_queue_size do 
  2205. 					 sh03_queue[i - 1] =  sh03_queue[i] 
  2206. 				end 
  2207. 				sh03_queue_size = sh03_queue_size - 1 
  2208. 			end		 
  2209. 		end 
  2210. 		 
  2211. 		delay(.5) 
  2212. 	end 
  2213. end 
  2214.  
  2215. -- thread function for the helicopter to arrive at the landing spot 
  2216. --  
  2217. function sh03_heli_arrival() 
  2218.  
  2219. 	group_create( sh03_group.HELICOPTER.name, true ) 
  2220. 	while group_is_loaded( sh03_group.HELICOPTER.name ) == false do 
  2221. 		thread_yield() 
  2222. 	end 
  2223. 	 
  2224. 	vehicle_enter_teleport(SH03_PILOT, SH03_HELICOPTER, 0, true)  
  2225. 	set_dont_attack_me_on_sight_flag(SH03_PILOT, true) 
  2226. 	--object_indicator_add( SH03_HELICOPTER, OI_ASSET_DEFEND, OI_FLAGS_DEFAULT ) 
  2227. 	 
  2228. 	--fly, helicopter. fly! 
  2229. 	helicopter_fly_to( SH03_HELICOPTER, SH03_HELI_ARRIVAL_SPEED, HELICOPTER_ARRIVE ) 
  2230. 	delay(1) 
  2231. 	on_vehicle_enter("sh03_heli_fly", SH03_HELICOPTER) 
  2232. 	helicopter_fly_to_direct( SH03_HELICOPTER, SH03_HELI_LAND_SPEED, HELICOPTER_LAND ) 
  2233. 	--helicopter_land( SH03_HELICOPTER, HELICOPTER_LAND ) 
  2234. 	vehicle_speed_override(SH03_HELICOPTER, 0.0)  
  2235. 	vehicle_set_keyframed_physics( SH03_HELICOPTER, true ) 
  2236.  
  2237. 	vehicle_suppress_npc_exit(SH03_HELICOPTER) 
  2238. 	vehicle_suppress_flipping( SH03_HELICOPTER, true ) 
  2239.  
  2240. 	--delay(3) 
  2241. 	SH03_HELI_LANDED = true 
  2242. end 
  2243.  
  2244. function sh03_attack( attacker, dest ) 
  2245. 	--tell the AI to go to the router and attack the player on sight 
  2246. 	move_to_safe( attacker, dest, 3, true, false ) 
  2247. 	ai_attack_region(attacker, dest, 18.0)  
  2248. 	set_attack_player_flag( attacker, true )  
  2249. end