./sh01.lua

  1. --[[ 
  2. 	sh01.lua 
  3. 	SR3 Mission Script 
  4. 	DATE: 07/06/10 
  5. 	AUTHOR:	Anne Chilldon 
  6. ]]-- 
  7.  
  8.  
  9. -- Debug flags -- 
  10.  
  11. -- Tweakable Parameters -- 
  12. 	-- Timer for attack persona lines 
  13. 	SH01_Attack_Line_Time = 10.0 
  14. 	 
  15. -- Groups �- 
  16. SH01_group = { 
  17. 	alley_grunts_001 = { 
  18. 		name = "grp_Alley_Grunts", 
  19. 		members = { "Alley_Grunt 001", "Alley_Grunt 002", "Alley_Grunt 003", "Alley_Grunt 010", 
  20. 					"Alley_Grunt 011", "Alley_Grunt 012", "Alley_Grunt 013", "Alley_Grunt 014"} 
  21. 	}, 
  22. 	warehouse_snipers_001 = { 
  23. 		name = "grp_Warehouse_Snipers", 
  24. 		members = { "Warehouse_Sniper 002",	"Warehouse_Sniper 003", --"Warehouse_Sniper 004", 
  25. 					"Warehouse_Sniper 005" } 
  26. 	}, 
  27. 	warehouse_grunts_001 = { 
  28. 		name = "grp_Warehouse_Grunts", 
  29. 		members = { "Warehouse_Grunt 001", "Warehouse_Grunt 002", "Warehouse_Grunt 003", "Warehouse_Grunt 004",} 
  30. 					 --"Warehouse_Grunt 005" , "Warehouse_Grunt 008", "Warehouse_Grunt 009", "Warehouse_Grunt 010" } 
  31. 	}, 
  32. 	warehouse_brute_001 = { 
  33. 		name = "grp_Warehouse_Brute", 
  34. 		members = { "MiniGun_Brute 001" } 
  35. 	}, 
  36. 	warehouse_brute_002 = { 
  37. 		name = "grp_Warehouse_Brute2", 
  38. 		members = { "Warehouse_Grunt 006", "Warehouse_Grunt 007", "Warehouse_Grunt 011", "Warehouse_Grunt 012" } 
  39. 	}, 
  40. 	warehouse_office_001 = { 
  41. 		name = "grp_Warehouse_Office1", 
  42. 		members = { "Office_Grunt 001", "Office_Grunt 002", "Office_Grunt 003", "Office_Grunt 004" } 
  43. 	}, 
  44. 	warehouse_office_002 = { 
  45. 		name = "grp_Warehouse_Office2", 
  46. 		members = { "Office2_Grunt 004", "Office2_Grunt 005", "Office2_Grunt 006", "Office2_Grunt 007", 
  47. 					"Office2_Grunt 008", "Office2_Grunt 009", "Office2_Grunt 010", "Office2_Grunt 011" } 
  48. 	}, 
  49. 	stairwell_grunts = { 
  50. 		name = "grp_Stair_Grunts", 
  51. 		members = { "npc_StairGrunt 001", "npc_StairGrunt 002", "npc_StairGrunt 003", "npc_StairGrunt 004", 
  52. 					"npc_StairGrunt 005", "npc_StairGrunt 006", "npc_StairGrunt 007", "npc_StairGrunt 008", 
  53. 					"npc_StairGrunt 009", "npc_StairGrunt 010", "npc_StairGrunt 011", "npc_StairGrunt 012" } 
  54. 	}, 
  55. 	breakroom_grunts_001 = { 
  56. 		name = "grp_Breakroom_Grunts", 
  57. 		members = { --"Breakroom_Grunt 001", "Breakroom_Grunt 002", "Breakroom_Grunt 003", 
  58. 					"Breakroom_Grunt 004", "Breakroom_Grunt 005", "Breakroom_Grunt 006"} 
  59. 	}, 
  60. 	catwalk_grunts = { 
  61. 		name = "grp_CatwalkGrunts", 
  62. 		members = { "npc_CatwalkGrunt 001", "npc_CatwalkGrunt 002", "npc_CatwalkGrunt 003", 
  63. 					"npc_CatwalkGrunt 004", "npc_CatwalkGrunt 005" } 
  64. 	}, 
  65. 	spawn_wave1 = { 
  66. 		name = "grp_SpawnWave1", 
  67. 		members = { "npc_SpawnWave 001", "npc_SpawnWave 002" } 
  68. 	}, 
  69. 	spawn_wave2 = { 
  70. 		name = "grp_SpawnWave2", 
  71. 		members = { "npc_SpawnWave 003", "npc_SpawnWave 004" } 
  72. 	}, 
  73. 	spawn_wave3 = { 
  74. 		name = "grp_SpawnWave3", 
  75. 		members = { "npc_SpawnWave 005", "npc_SpawnWave 006" } 
  76. 	}, 
  77. 	spawn_wave4 = { 
  78. 		name = "grp_SpawnWave4", 
  79. 		members = { "npc_SpawnWave 007", "npc_SpawnWave 008" } 
  80. 	}, 
  81. 	spawn_wave5 = { 
  82. 		name = "grp_SpawnWave5", 
  83. 		members = { "npc_SpawnWave 009", "npc_SpawnWave 010" } 
  84. 	}, 
  85. 	spawn_wave6 = { 
  86. 		name = "grp_SpawnWave6", 
  87. 		members = { "npc_SpawnWave 011", "npc_SpawnWave 012" } 
  88. 	}, 
  89. 	spawn_wave7 = { 
  90. 		name = "grp_SpawnWave7", 
  91. 		members = { "npc_SpawnWave 013", "npc_SpawnWave 014" } 
  92. 	}, 
  93. 	spawn_wave8 = { 
  94. 		name = "grp_SpawnWave8", 
  95. 		members = { "npc_SpawnWave 015", "npc_SpawnWave 016" } 
  96. 	}, 
  97. 	homies = { 
  98. 		name = "grp_Homies", 
  99. 		members = { "Pierce", "Shaundi" } 
  100. 	}, 
  101. 	cte_brute = { 
  102. 		name = "grp_cte_brute", 
  103. 	}, 
  104. } 
  105.  
  106. -- Navpoints -- 
  107. 	OFFICE_MARK = { "Office_Mark 004", "Office_Mark 005", "Office_Mark 006", "Office_Mark 007", 
  108. 					"Office_Mark 008", "Office_Mark 009", "Office_Mark 010", "Office_Mark 011"} 
  109. 	STAIR_MARK = { "nav_Stairs 001", "nav_Stairs 002", "nav_Stairs 003", "nav_Stairs 004", 
  110. 				   "nav_Stairs 005", "nav_Stairs 006", "nav_Stairs 007", "nav_Stairs 008", 
  111. 				   "nav_Stairs 009", "nav_Stairs 010", "nav_Stairs 011", "nav_Stairs 012" } 
  112. 	CATWALK_MARK = { "nav_Catwalk_Mark 001", "nav_Catwalk_Mark 002", "nav_Catwalk_Mark 003", 
  113. 					 "nav_Catwalk_Mark 004" } 
  114. 	CATWALKS = { "nav_Catwalk 001", "nav_Catwalk 002", "nav_Catwalk 003", "nav_Catwalk 004", 
  115. 				 "nav_Catwalk 005" } 
  116. 	BRUTE_TELEPORT = { "local_brute_teleport", "remote_brute_teleport", "pierce_brute_teleport", "shaundi_brute_teleport" } 
  117. 	SH01_S_TELEPORT_2 = { "Shaundi_Teleport 002" } 
  118. 	SH01_S_TELEPORT_3 = { "Shaundi_Teleport 003" } 
  119. 	SH01_S_TELEPORT_4 = { "Shaundi_Teleport 004" } 
  120. 	SH01_P_TELEPORT_2 = { "Pierce_Teleport 002" } 
  121. 	SH01_P_TELEPORT_3 = { "Pierce_Teleport 003" } 
  122. 	SH01_P_TELEPORT_4 = { "Pierce_Teleport 004" } 
  123. 	SH01_PLAYER_START = { "sh01_local_player_start" } 
  124. 	SH01_COOP_START = { "sh01_remote_player_start" } 
  125. 	SH01_PLAYER_CHECKPOINT_2 = { "sh01_local_checkpoint_ 002" } 
  126. 	SH01_COOP_CHECKPOINT_2 = { "sh01_remote_checkpoint_ 002" } 
  127. 	SH01_PLAYER_CHECKPOINT_3 = { "sh01_local_checkpoint_ 003" } 
  128. 	SH01_COOP_CHECKPOINT_3 = { "sh01_remote_checkpoint_ 003" } 
  129. 	SH01_PLAYER_CHECKPOINT_4 = { "sh01_local_checkpoint_4" } 
  130. 	SH01_COOP_CHECKPOINT_4 = { "sh01_remote_checkpoint_4" } 
  131. 	HACK_POINT = "nav_HackPoint" 
  132. 	 
  133. -- Triggers -- 
  134. 	-- Vehicle Trigger -- In front of Gun Warehouse. Once entered triggers CTE cutscene 
  135. 	-- Warehouse Door Trigger -- Checkpoint trigger 
  136. 	WAREHOUSE_DOOR_TRIGGER = "Warehouse_Door_Trigger 001" 
  137. 	-- Second Floor Trigger -- Location Trigger 
  138. 	UPSTAIRS_TRIGGER = "Upstairs_Trigger 001" 
  139. 	-- Manager�s Office Trigger -- Pick up items inside manager�s office 
  140. 	OFFICE_TRIGGER = "Office_Trigger 001" 
  141. 	-- Break room Trigger -- 
  142. 	BREAKROOM_TRIGGER = "trig_BreakRoom" 
  143. 	COMPUTER_TRIGGER = "trig_Computer" 
  144. 	SHOWROOM_TRIGGER = "trig_ShowRoom" 
  145. 	TOPSTAIRWELL_TRIGGER = "trig_StairwellTop" 
  146. 	-- Dialog Triggers -- 
  147. 	ALLEY_TRIGGER = "trig_AlleyConvo" 
  148. 	CATWALK_TRIGGER = "trig_CatwalkCombat" 
  149. 	INSIDE_TRIGGER = "trig_InsideCombat" 
  150.  
  151. -- Characters -- 
  152. 	-- Player -- 
  153. 	-- Remote Player -- 
  154. 	-- Pierce -- 
  155.  
  156. -- Vehicles -- 
  157. 	-- Starting Vehicle -- 
  158.  
  159.  
  160. -- Mesh Movers -- 
  161.  
  162. -- Spawn Regions -- 
  163. sh01_Spawn = { 
  164. 	catwalk1 = "sr_Catwalk 001", 
  165. 	catwalk2 = "sr_Catwalk 002", 
  166. 	catwalk3 = "sr_Catwalk 003", 
  167. 	catwalk4 = "sr_Catwalk 004", 
  168. 	office1 = "sr_Office 001", 
  169. 	office2 = "sr_Office 002", 
  170. 	office3 = "sr_Office 003", 
  171. 	office4 = "sr_Office 004", 
  172. } 
  173.  
  174. -- Text -- 
  175. 	-- Help Text/Objective -- 
  176. 		-- Go to the Gun Warehouse -- 
  177. 		SH01_OBJ_MEET_PIERCE = "sh01_obj_head_to_gun_warehouse" 
  178. 		-- Enter the Gun Warehouse -- 
  179. 		SH01_OBJ_ENTER_WAREHOUSE = "sh01_obj_enter_warehouse" 
  180. 		-- Find a way upstairs 
  181. 		SH01_OBJ_UPSTAIRS = "sh01_obj_upstairs" 
  182. 		-- Head to the Manager�s Office -- 
  183. 		SH01_OBJ_MANAGER_OFFICE = "sh01_obj_manager_office" 
  184. 		-- Clear out the Store -- 
  185. 		SH01_OBJ_CLEAN_HOUSE = "sh01_obj_clean_house" 
  186. 		-- Use the computer -- 
  187. 		SH01_OBJ_USE_COMPUTER = "sh01_obj_use_computer" 
  188. 		-- Head to the ShowRoom 
  189. 		SH01_OBJ_SHOWROOM = "sh01_obj_showroom" 
  190. 		-- Kill the Brute -- 
  191. 		SH01_OBJ_KILL_BRUTE = "sh01_obj_kill_brute" 
  192. 	-- Failure Text -- 
  193. 		-- Player Dies -- 
  194. 		-- Pierce Dies -- 
  195. 		SH01_FAILURE_PIERCE_DIED	= "sh01_failure_pierce_died" 
  196. 		SH01_FAILURE_ABANDON_PIERCE = "sh01_failure_abandon_pierce" 
  197. 		-- Shaundi Dies -- 
  198. 		SH01_FAILURE_SHAUNDI_DIED = "sh01_failure_shaundi_died" 
  199. 		SH01_FAILURE_ABANDON_SHAUNDI = "sh01_failure_abandon_shaundi" 
  200.  
  201. -- Threads -- 
  202. SH01_thread = { 
  203. 	chatter = INVALID_THREAD_HANDLE, 
  204. 	chatter_timer = INVALID_THREAD_HANDLE, 
  205. 	shaundi_hack = INVALID_THREAD_HANDLE, 
  206. 	attack_line_timer = INVALID_THREAD_HANDLE, 
  207. } 
  208. -- Checkpoints -- 
  209. 	SH01_CHECKPOINT_START = MISSION_START_CHECKPOINT			-- defined in ug_lib.lua 
  210. 	SH01_CHECKPOINT_ENTER_WAREHOUSE = "sh01_checkpoint_enter_warehouse" 
  211. 	SH01_CHECKPOINT_MANAGER_OFFICE = "sh01_checkpoint_manager_office" 
  212. 	SH01_CHECKPOINT_BRUTE_FIGHT = "sh01_checkpoint_brute_fight" 
  213. 	SH01_CHECKPOINT_CATWALK = "sh01_checkpoint_catwalk" 
  214. 	SH01_CHECKPOINT_CLEAN_HOUSE = "sh01_checkpoint_clean_house" 
  215. 	 
  216. -- Cutscenes -- 
  217. 	SH01_CUTSCENE_MISSION_INTRO = "MS_SH01" 
  218. 	SH01_CUTSCENE_CTE			= "sh01_cte_01" 
  219. 	SH01_CUTSCENE_MISSION_OUTRO = "" 
  220.  
  221. -- Conversations -- 
  222. SH01_convo = { 
  223. 	retail_combat1 = { 
  224. 		name = "SH01_Combat_In_Front_1", 
  225. 		handle = INVALID_CONVERSATION_HANDLE, 
  226. 		load_direct = true, 
  227. 	}, 
  228. 	retail_combat2 = { 
  229. 		name = "SH01_Combat_In_Front_2", 
  230. 		handle = INVALID_CONVERSATION_HANDLE, 
  231. 		load_direct = false, 
  232. 	}, 
  233. 	manager_office_enter = { 
  234. 		name = "SH01_Combat_Upstairs", 
  235. 		handle = INVALID_CONVERSATION_HANDLE, 
  236. 		load_direct = false, 
  237. 	}, 
  238. 	alley_combat = { 
  239. 		name = "SH01_Combat_Out_Back", 
  240. 		handle = INVALID_CONVERSATION_HANDLE, 
  241. 		load_direct = false, 
  242. 	}, 
  243. 	mission_start = { 
  244. 		name = "SH01_Mission_Start", 
  245. 		handle = INVALID_CONVERSATION_HANDLE, 
  246. 		load_direct = true, 
  247. 	}, 
  248. 	retail_brute = { 
  249. 		name = "SH01_Front_Of_Store_Brute", 
  250. 		handle = INVALID_CONVERSATION_HANDLE, 
  251. 		load_direct = true, 
  252. 	}, 
  253. 	warehouse_combat = { 
  254. 		name = "SH01_Combat_Inside", 
  255. 		handle = INVALID_CONVERSATION_HANDLE, 
  256. 		load_direct = true, 
  257. 	}, 
  258. 	go_to_office = { 
  259. 		name = "SH01_Get_To_Office", 
  260. 		handle = INVALID_CONVERSATION_HANDLE, 
  261. 		load_direct = false, 
  262. 	}, 
  263. 	warehouse_brute = { 
  264. 		name = "SH01_MiniGun_Brute", 
  265. 		handle = INVALID_CONVERSATION_HANDLE, 
  266. 		load_direct = true, 
  267. 	}, 
  268. 	inside_office = { 
  269. 		name = "SH01_Office", 
  270. 		handle = INVALID_CONVERSATION_HANDLE, 
  271. 		load_direct = false, 
  272. 	}, 
  273. } 
  274. SH01_Warehouse_Combat_Chatter = { 
  275. 	{ 
  276. 		is_conversation = false, 
  277. 		speaker = SH01_group.homies.members[2], 
  278. 		line = "SH01_Sniper_Inside_Callout", 
  279. 		spoken = false, 
  280. 	}, 
  281. --	{ 
  282. --		is_conversation = true, 
  283. --		conversation = SH01_convo.warehouse_combat, 
  284. --		spoken = false, 
  285. --	}, 
  286. 	{ 
  287. 		is_conversation = true, 
  288. 		conversation = SH01_convo.go_to_office, 
  289. 		spoken = false, 
  290. 	}, 
  291. } 
  292. SH01_Retail_Combat_Chatter = { 
  293. 	{ 
  294. 		is_conversation = true, 
  295. 		conversation = SH01_convo.retail_combat1, 
  296. 		spoken = false, 
  297. 	}, 
  298. 	{ 
  299. 		is_conversation = true, 
  300. 		conversation = SH01_convo.retail_combat2, 
  301. 		spoken = false, 
  302. 	}, 
  303. } 
  304. -- Other -- 
  305. -- Global variables 
  306. 	Num_guys_to_kill 	= 0 
  307. 	In_coop = false 
  308. 	Brute_Killed = false 
  309. 	convo_is_playing = false 
  310. 	hack_done = false 
  311. 	spawn_on = false 
  312. 	spawn_office = false 
  313. -- Trigger flags 
  314. 	warehouse_door_triggered = false 
  315. 	upstairs_triggered = false 
  316. 	office_triggered = false 
  317. 	breakroom_triggered = false 
  318. 	showroom_triggered = false 
  319. 	computer_triggered = false 
  320. 	alley_triggered = false 
  321. 	catwalk_triggered = false 
  322. 	inside_triggered = false 
  323. 	topstairwell_triggered = false 
  324. -- HUD variables 
  325. 	HUD_BAR_MAX_VALUE = 1500 
  326. 	SH01_HACK_PROGRESS = 1 
  327. 	 
  328. -- ************************* 
  329. -- 
  330. -- Standard functions 
  331. -- 
  332. -- ************************* 
  333.  
  334. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  335. -- at the specified checkpoint. 
  336. -- CALLED FROM CODE 
  337. -- 
  338. -- _checkpoint:	The checkpoint the mission should begin at 
  339. -- is_restart:					TRUE if the mission is restarting, FALSE otherwise 
  340. -- 
  341. function sh01_start(sh01_checkpoint, is_restart) 
  342. 	-- See if we are in co-op 
  343. 	In_coop = coop_is_active() 
  344. 	 
  345. 	-- Check if this mission starting from the beginning 
  346. 	if (sh01_checkpoint == SH01_CHECKPOINT_START) then 
  347. 		if (is_restart == false) then 
  348. 			-- First time playing mission 
  349. 			local cutscene_navs = { "sh01_local_checkpoint_ 002", "sh01_remote_checkpoint_ 002" } 
  350. 			-- Play an intro cutscene??? 
  351. 			if (SH01_CUTSCENE_MISSION_INTRO ~= "") then 
  352. 				cutscene_play(SH01_CUTSCENE_MISSION_INTRO, nil, cutscene_navs, false) 
  353. 			end 
  354. 		else 
  355. 			-- Teleport players 
  356. 			teleport_coop(SH01_PLAYER_CHECKPOINT_2[1], SH01_COOP_CHECKPOINT_2[1], true) 
  357. 		end 
  358. 		fade_out(0) 
  359. 	end 
  360.  
  361. 	-- Handle mission initialization for the current checkpoint 
  362. 	sh01_initialize(sh01_checkpoint) 
  363.  
  364. 	-- Set the notoriety 
  365. 	notoriety_set("Morningstar", 1) 
  366. 	-- Run the mission from the current checkpoint 
  367. 	sh01_run(sh01_checkpoint) 
  368. 	 
  369. end 
  370.  
  371. -- This is the primary function responsible for running the entire mission from start to finish. 
  372. -- 
  373. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  374. -- 
  375. function sh01_run(first_checkpoint) 
  376. 	local current_checkpoint = first_checkpoint 
  377.  
  378. 	-- Run the mission from the beginning 
  379. 	if current_checkpoint == SH01_CHECKPOINT_START then 
  380. 	--[[		 
  381. 		mission_start_fade_out() 
  382. 		--Play intro cutscene 
  383. 	--	if (SH01_CUTSCENE_MISSION_INTRO ~= "") then 
  384. 	--		bink_play(SH01_CUTSCENE_MISSION_INTRO) 
  385. 	--	end 
  386.  
  387. 		-- Teleport players 
  388. 		teleport_coop(SH01_PLAYER_CHECKPOINT_2[1], SH01_COOP_CHECKPOINT_2[1], true) 
  389. 		-- Set Pierce & Shaundi as Homie (Not sure if this goes here or during checkpoint initialization) 
  390. 		sh01_setup_crew() 
  391. 		-- Teleport Pierce to checkpoint 
  392. 		teleport(SH01_group.homies.members[1], SH01_P_TELEPORT_2[1]) 
  393. 		-- Teleport Shaundi to checkpoint 
  394. 		teleport(SH01_group.homies.members[2], SH01_S_TELEPORT_2[1]) 
  395. 		mission_start_fade_in()  
  396. 		]]-- 
  397. 		-- We reached a checkpoint, update and what not 
  398. 		current_checkpoint = SH01_CHECKPOINT_ENTER_WAREHOUSE 
  399. 		mission_set_checkpoint(SH01_CHECKPOINT_ENTER_WAREHOUSE, true) 
  400. 		 
  401. 	end 
  402. 	 
  403. 	-- Check to see if we are on objective 2 
  404. 	if current_checkpoint == SH01_CHECKPOINT_ENTER_WAREHOUSE then 
  405. 		-- Set Pierce & Shaundi as Homie (Not sure if this goes here or during checkpoint initialization) 
  406. 		--sh01_setup_crew() 
  407. 		-- Teleport Pierce to checkpoint 
  408. 		--teleport(SH01_group.homies.members[1], SH01_P_TELEPORT_2[1]) 
  409. 		-- Teleport Shaundi to checkpoint 
  410. 		--teleport(SH01_group.homies.members[2], SH01_S_TELEPORT_2[1]) 
  411. 		 
  412. 		--SH01_convo.mission_start.handle = audio_conversation_load_direct(SH01_convo.mission_start.name) 
  413. 		-- TODO: Player VO 
  414. --		message("Player VO: Let's head around back", 4.0) 
  415. 	--	delay(4.0) 
  416. 		-- Set invisible trigger for alley combat dialog 
  417. 		alley_triggered = false 
  418. 		sh01_set_invisible_trigger(ALLEY_TRIGGER, "sh01_reached_alley") 
  419. 		-- Set GPS to Warehouse Door 
  420. 		warehouse_door_triggered = false 
  421. 		sh01_set_trigger(WAREHOUSE_DOOR_TRIGGER, "sh01_reached_warehouse_door") 
  422. 		 
  423. 		-- Set Objective Text to GSI 
  424. 		objective_text( 0, "sh01_obj_enter_warehouse", "", "", SYNC_ALL, OI_ASSET_LOCATION ) 
  425. 		 
  426. 		-- Spawn Enemies 
  427. 		sh01_spawn_second_checkpoint_enemies() 
  428. 		 
  429. 	--	audio_conversation_play(SH01_convo.mission_start.handle) 
  430. 	--	thread_new("sh01_convo", SH01_convo.mission_start) 
  431. 		-- Don't continue until they reach the door 
  432. 		while not warehouse_door_triggered do 
  433. 			thread_yield() 
  434. 		end 
  435. 		 
  436. 	--	audio_conversation_wait_for_end(SH01_convo.mission_start.handle) 
  437.     --  SH01_convo.mission_start.handle = INVALID_CONVERSATION_HANDLE 
  438. 		 
  439. 		 
  440. 		 
  441. 		-- Clear Objective Text 
  442. 		objective_text_clear(0) 
  443.  
  444. 		-- We reached a checkpoint, update and what not 
  445. 		current_checkpoint = SH01_CHECKPOINT_MANAGER_OFFICE 
  446. 		mission_set_checkpoint(SH01_CHECKPOINT_MANAGER_OFFICE, true) 
  447. 	end 
  448. 	 
  449. 	-- Check to see if we are on objective 3 
  450. 	if current_checkpoint == SH01_CHECKPOINT_MANAGER_OFFICE then 
  451. 		sh01_set_invisible_trigger(INSIDE_TRIGGER, "sh01_reached_inside") 
  452. 	--	SH01_convo.warehouse_brute.handle = audio_conversation_load_direct(SH01_convo.warehouse_brute.name) 
  453. 		-- TODO: Conversation with Pierce 
  454. 		--message("Player: Head to the Manager's office on the upper level", 4.0) 
  455. 		-- This is temp and needs to be replaced 
  456. 		objective_text( 0, "sh01_obj_upstairs", "", "", SYNC_ALL, OI_ASSET_LOCATION ) 
  457. 	 
  458. 		--Set up breadcrumb triggers 
  459. 		upstairs_triggered = false 
  460. 		sh01_set_trigger(UPSTAIRS_TRIGGER, "sh01_reached_upstairs") 
  461. 		sh01_spawn_third_checkpoint_enemies_v1() 
  462.  
  463. 		sh01_set_invisible_trigger(BREAKROOM_TRIGGER, "sh01_reached_breakroom")	 
  464. 		while not breakroom_triggered do 
  465. 			thread_yield() 
  466. 		end 
  467. 		-- Cleanup the enemies from the previous objective 
  468. 		sh01_cleanup_second_checkpoint() 
  469. 		Num_guys_to_kill = 0 
  470. 		while not upstairs_triggered do 
  471. 			thread_yield() 
  472. 		end 
  473. 		 
  474. 		-- We reached a checkpoint, update and what not 
  475. 		current_checkpoint = SH01_CHECKPOINT_BRUTE_FIGHT 
  476. 		mission_set_checkpoint(SH01_CHECKPOINT_BRUTE_FIGHT, true) 
  477. 	end 
  478. 	 
  479. 	--Check to see if we are on objective 4 
  480. 	if (current_checkpoint == SH01_CHECKPOINT_BRUTE_FIGHT) then 
  481. 		-- Pause audio emitters during CTE 
  482. 		audio_ambient_emitter_pause("alarm_bell_store") 
  483. 		audio_ambient_emitter_pause("sh01_alarm_a") 
  484. 		audio_ambient_emitter_pause("sh01_alarm_b") 
  485. 		audio_ambient_emitter_pause("sh01_music") 
  486. 		 
  487. 		local teleports = { BRUTE_TELEPORT[1], BRUTE_TELEPORT[2] } 
  488. 		-- CTE Start 
  489. 		fade_out(0.5) 
  490. 		fade_out_block() 
  491. 		--	message("CTE", 4.0) 
  492. 		--sh01_convo(SH01_convo.warehouse_brute) 
  493. --		cutscene_in() 
  494. 		group_create( SH01_group.cte_brute.name, true ) 
  495. 		cutscene_play( SH01_CUTSCENE_CTE, nil, teleports, false) 
  496. 		group_destroy( SH01_group.cte_brute.name ) 
  497. 		sh01_spawn_third_checkpoint_brute() 
  498. --		cutscene_out() 
  499. 	 
  500. --		fade_out(0.5) 
  501. --		fade_out_block() 
  502. 		-- make sure doors are closed 
  503. 	--	mesh_mover_reset("sm_Stairwell 001") 
  504. 	--	mesh_mover_reset("sm_Stairwell 002") 
  505. 	--	mesh_mover_reset("sm_Office_Frontdoor 001") 
  506. 	--	mesh_mover_reset("sm_Office_Backdoor_001") 
  507. 	 
  508. 		-- CTE Done 
  509. 		group_show( SH01_group.homies.name ) 
  510. 		 
  511. 		teleport_coop(BRUTE_TELEPORT[1], BRUTE_TELEPORT[2], true) 
  512. 		teleport(SH01_group.homies.members[1], BRUTE_TELEPORT[3]) 
  513. 		teleport(SH01_group.homies.members[2], BRUTE_TELEPORT[4]) 
  514. 		-- Clear Objective Text 
  515. 		objective_text_clear(0) 
  516. 		-- Set Objective Text to GSI 
  517. 		objective_text( 0, "sh01_obj_kill_brute", "", "", SYNC_ALL, OI_ASSET_KILL) 
  518. 		 
  519. 		--audio_conversation_wait_for_end(SH01_convo.warehouse_brute.handle) 
  520. 		--SH01_convo.warehouse_brute.handle = INVALID_CONVERSATION_HANDLE 
  521. 		 
  522. 		fade_in(0.5) 
  523. 		fade_in_block() 
  524. 		-- Turn emitters back on 
  525. 		audio_ambient_emitter_resume("alarm_bell_store") 
  526. 		audio_ambient_emitter_resume("sh01_alarm_a") 
  527. 		audio_ambient_emitter_resume("sh01_alarm_b") 
  528. 		audio_ambient_emitter_resume("sh01_music") 
  529.  
  530. 		-- Wait till brute is killed 
  531. 		while not Brute_Killed do 
  532. 			thread_yield() 
  533. 		end 
  534. 		 
  535. 		sh01_spawn_warehouse_wave1() 
  536. 		 
  537. 		-- We reached a checkpoint, update and what not 
  538. 		current_checkpoint = SH01_CHECKPOINT_CATWALK 
  539. 		mission_set_checkpoint(SH01_CHECKPOINT_CATWALK, true) 
  540. 	end 
  541. 	-- Check to see if we are at checkpoint 5 
  542. 	if current_checkpoint == SH01_CHECKPOINT_CATWALK then 
  543. 		-- Set invisible trigger 
  544. 		sh01_set_trigger(TOPSTAIRWELL_TRIGGER, "sh01_reached_topstairwell") 
  545. 		 
  546. 		-- Setup continuous spawns 
  547. 		sh01_start_continuous_spawns() 
  548. 		 
  549. 		objective_text_clear(0) 
  550. 		 
  551. 		-- Set GPS to Manager's office 
  552. 		-- Set invisible trigger for dialog 
  553. 		sh01_set_invisible_trigger(CATWALK_TRIGGER, "sh01_reached_catwalk") 
  554. 		Num_guys_to_kill = 0 
  555. 		-- Set Objective Text to GSI 
  556. 		objective_text( 0, "sh01_obj_manager_office", "", "", SYNC_ALL, OI_ASSET_LOCATION ) 
  557.  
  558. 		 
  559. 		-- Spawn Enemies 
  560. 		sh01_spawn_third_checkpoint_enemies_v2() 
  561. 		 
  562. 		while not office_triggered do 
  563. 			thread_yield() 
  564. 		end 
  565. 		thread_new("sh01_convo", SH01_convo.inside_office) 
  566. --		sh01_spawn_fourth_checkpoint_enemies_v1() 
  567. 	 
  568. 		SH01_thread.shaundi_hack = thread_new("sh01_shaundi_hack_thread") 
  569. 		 
  570. 	--	delay(2.0) 
  571. 		-- Add more continuous spawns 
  572. 		sh01_start_office_spawns() 
  573. 		 
  574. 		-- TODO: Set off alarm SFX 
  575. 		-- TODO: Set off loud speaker VO 
  576. 		 
  577. 		while SH01_HACK_PROGRESS < 600 do 
  578. 			thread_yield() 
  579. 		end 
  580. 		--Shut off continuous spawn 
  581. 		sh01_stop_continuous_spawns() 
  582. 		sh01_stop_office_spawns() 
  583. 		 
  584. 		while not hack_done do 
  585. 			thread_yield() 
  586. 		end 
  587. 		-- Clear Objective Text 
  588. 		objective_text_clear (0) 
  589. 		 
  590. 		 
  591. 		 
  592. 	end 
  593.  
  594. 	 
  595. 	-- Call mission success?? 
  596. 	mission_end_success("sh01", SH01_CUTSCENE_MISSION_OUTRO) 
  597. 	 
  598. end 
  599.  
  600. -- This is the primary function responsible for cleaning up the entire mission 
  601. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  602. -- 
  603. function sh01_cleanup() 
  604. 	-- Cleanup Groups 
  605. 	sh01_cleanup_first_checkpoint() 
  606. 	sh01_cleanup_second_checkpoint() 
  607. 	sh01_cleanup_third_checkpoint() 
  608. 	sh01_cleanup_fourth_checkpoint() 
  609. 	sh01_cleanup_homies() 
  610. 	 
  611. 	-- Cleanup Triggers 
  612. 	sh01_clear_trigger(WAREHOUSE_DOOR_TRIGGER) 
  613. 	sh01_clear_trigger(UPSTAIRS_TRIGGER) 
  614. 	sh01_clear_trigger(OFFICE_TRIGGER) 
  615. 	sh01_clear_trigger(BREAKROOM_TRIGGER) 
  616. 	sh01_clear_trigger(SHOWROOM_TRIGGER) 
  617. 	sh01_clear_trigger(COMPUTER_TRIGGER) 
  618. 	sh01_clear_trigger(ALLEY_TRIGGER) 
  619. 	sh01_clear_trigger(CATWALK_TRIGGER) 
  620. 	sh01_clear_trigger(INSIDE_TRIGGER) 
  621. 	sh01_clear_trigger(TOPSTAIRWELL_TRIGGER) 
  622. 	 
  623. 	-- Cleanup continuous spawns 
  624. 	if(spawn_on)then 
  625. 		sh01_stop_continuous_spawns() 
  626. 	end 
  627. 	if(spawn_office)then 
  628. 		sh01_stop_office_spawns() 
  629. 	end 
  630. 	 
  631. 	cleanup_spawn_regions(sh01_Spawn) 
  632. 	cleanup_spawn_groups(SH01_group.spawn_wave1) 
  633. 	cleanup_spawn_groups(SH01_group.spawn_wave2) 
  634. 	cleanup_spawn_groups(SH01_group.spawn_wave3) 
  635. 	cleanup_spawn_groups(SH01_group.spawn_wave4) 
  636. 	 
  637. 	-- Clear out any conversations 
  638. 	cleanup_conversations(SH01_convo) 
  639. 	 
  640. 	-- Turn on audio emitters 
  641. 	audio_ambient_emitter_stop("alarm_bell_store") 
  642. 	audio_ambient_emitter_stop("sh01_alarm_a") 
  643. 	audio_ambient_emitter_stop("sh01_alarm_b") 
  644. 	audio_ambient_emitter_stop("sh01_music") 
  645. 	 
  646. 	-- allow notoriety spawning again 
  647. 	notoriety_force_no_spawn("police", false)	 
  648. 	notoriety_force_no_spawn("morningstar", false)	 
  649. 	 
  650. 	-- Reset followers 
  651. 	party_allow_max_followers(false) 
  652. 	 
  653. 	-- Teleport players outside at the end 
  654. 	teleport(LOCAL_PLAYER, SH01_PLAYER_START[1]) 
  655. 	if(In_coop)then 
  656. 		teleport(REMOTE_PLAYER, SH01_COOP_START[1]) 
  657. 	end 
  658. 	 
  659. 	-- Lock the doors behind you 
  660. 	door_lock("Outside_Door1", true) 
  661. 	door_lock("Outside_Door2", true) 
  662. end 
  663.  
  664. -- Called when the mission has ended with success 
  665. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  666. -- 
  667. function sh01_success() 
  668. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  669. 	 
  670. end 
  671.  
  672.  
  673. -- ************************* 
  674. -- 
  675. -- Local functions 
  676. -- 
  677. -- ************************* 
  678.  
  679. -- Initialize the mission for the specified checkpoint 
  680. -- 
  681. -- checkpoint:		Checkpoint to initialize the mission to 
  682. -- 
  683. function sh01_initialize(checkpoint) 
  684. 	-- Make sure the screen is completly faded out 
  685. 	mission_start_fade_out(0.0) 
  686.  
  687. 	-- Set the mission author 
  688. 	set_mission_author("Anne Chilldon") 
  689.  
  690. 	-- Common initialization 
  691. 	sh01_initialize_common() 
  692.  
  693. 	-- Checkpoint specific initialization 
  694. 	sh01_initialize_checkpoint(checkpoint) 
  695.  
  696. 	-- any notoriety is fake for this mission 
  697. 	notoriety_force_no_spawn("police", true) 
  698. 	notoriety_force_no_spawn("morningstar", true)	 
  699. 	 
  700. 	-- Turn on audio emitters 
  701. 	audio_ambient_emitter_start("alarm_bell_store") 
  702. 	audio_ambient_emitter_start("sh01_alarm_a") 
  703. 	audio_ambient_emitter_start("sh01_alarm_b") 
  704. 	audio_ambient_emitter_start("sh01_music") 
  705. 	 
  706. 	-- Unlock the doors 
  707. 	door_lock("Outside_Door1", false) 
  708. 	door_lock("Outside_Door2", false) 
  709. 	 
  710. 	-- Start fading in  
  711. 	mission_start_fade_in() 
  712.  
  713. end 
  714.  
  715. -- Spawn Enemies for the first checkpoint 
  716. function sh01_spawn_first_checkpoint_enemies() 
  717. end 
  718.  
  719. -- Spawn Enemies for the second checkpoint 
  720. function sh01_spawn_second_checkpoint_enemies() 
  721. 	 
  722. 	-- The Grunts 
  723. 	group_create(SH01_group.alley_grunts_001.name, true) 
  724. 	-- Set up attack persona lines 
  725. 	for i, guard in pairs (SH01_group.alley_grunts_001.members)do 
  726. 		on_attack_performed("sh01_ms_attack_line_cb", guard) 
  727. 	end 
  728. end 
  729.  
  730. -- Spawn Enemies for third checkpoint 
  731. function sh01_spawn_third_checkpoint_enemies_v1() 
  732. 	-- Group 1 
  733. 	group_create(SH01_group.warehouse_grunts_001.name, true) 
  734. 	-- Set up attack persona lines 
  735. 	for i, guard in pairs (SH01_group.warehouse_grunts_001.members)do 
  736. 		on_attack_performed("sh01_ms_attack_line_cb", guard) 
  737. 	end 
  738. 	 
  739. 	-- Group 2 (brute + snipers) 
  740. 	group_create(SH01_group.warehouse_snipers_001.name, true) 
  741. 	-- Set up attack persona lines 
  742. 	for i, guard in pairs (SH01_group.warehouse_snipers_001.members)do 
  743. 		on_attack_performed("sh01_ms_attack_line_cb", guard) 
  744. 	end 
  745. 	 
  746. 	-- Breakroom guys 
  747. 	group_create(SH01_group.breakroom_grunts_001.name, true) 
  748. 	for i, guard in pairs(SH01_group.breakroom_grunts_001.members)do 
  749. 		on_attack_performed("sh01_ms_breakroom_persona_cb", guard) 
  750. 	end 
  751. end 
  752. function sh01_spawn_third_checkpoint_brute() 
  753. 	group_create(SH01_group.warehouse_brute_001.name, true) 
  754.  
  755. 	on_death("sh01_brute_killed", SH01_group.warehouse_brute_001.members[1]) 
  756. 	marker_add(SH01_group.warehouse_brute_001.members[1], MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  757. end 
  758. function sh01_spawn_third_checkpoint_enemies_v2() 
  759. 	group_create(SH01_group.warehouse_office_001.name, true) 
  760. 	-- Set up attack persona lines 
  761. 	for i, guard in pairs(SH01_group.warehouse_office_001.members)do 
  762. 		on_attack_performed("sh01_ms_attack_line_cb", guard) 
  763. 	end 
  764. 	 
  765. end 
  766. function sh01_setup_catwalk_grunts() 
  767. 	if not group_is_loaded(SH01_group.catwalk_grunts.name) then 
  768. 		group_create(SH01_group.catwalk_grunts.name, true) 
  769. 	end 
  770. 	delay(1.0) 
  771. 	for i, guard in pairs(SH01_group.catwalk_grunts.members)do 
  772. 		ai_do_scripted_move(SH01_group.catwalk_grunts.members[i], CATWALKS[i]) 
  773. 		on_attack_performed("sh01_ms_attack_line_cb", guard) 
  774. 	end 
  775. end 
  776. function sh01_spawn_warehouse_wave1() 
  777. 	door_open("sm_Stairwell 001") 
  778. 	door_open("sm_Stairwell 002") 
  779. 	door_open("sm_Stairwell 003") 
  780. 	 
  781. 	group_create(SH01_group.stairwell_grunts.name, true) 
  782. 	 
  783. 	delay(1.0) 
  784. 	for i, guard in pairs(SH01_group.stairwell_grunts.members)do 
  785. 		on_attack_performed("sh01_ms_attack_line_cb", guard) 
  786. 		ai_do_scripted_move(SH01_group.stairwell_grunts.members[i], STAIR_MARK[i], true, false) 
  787. 		delay(0.5) 
  788. 	end 
  789. end 
  790.  
  791. -- Spawn Enemies for the last checkpoint 
  792. function sh01_spawn_fourth_checkpoint_enemies_v1() 
  793. 	door_open("sm_Office_Backdoor_001") 
  794. 	door_open("sm_Office_Backdoor_002") 
  795. 	-- Group 1 (Manager's office) 
  796. 	group_create(SH01_group.warehouse_office_002.name, true) 
  797.  
  798. 	delay(1.0) 
  799. 	-- spawn threads to move guards to their mark 
  800. 	for i, guard in pairs(SH01_group.warehouse_office_002.members) do 
  801. 		on_attack_performed("sh01_ms_attack_line_cb", guard) 
  802. 		ai_do_scripted_move(guard, OFFICE_MARK[i]) 
  803. 	end 
  804. 	 
  805. end 
  806.  
  807. function sh01_spawn_fourth_checkpoint_enemies_v2() 
  808. 	-- Create all the people in the retail store 
  809. 	-- Group 2 (Retail Store) 
  810. 	group_create(SH01_group.retail_grunts_001.name, true) 
  811. 	 
  812. 	-- Create customers 
  813. 	group_create(SH01_group.retail_customers.name, true) 
  814. 	 
  815. 	-- Group 3 (People the NEED to be killed) 
  816. 	group_create(SH01_group.retail_grunts_002.name, true) 
  817.  
  818. 	 
  819. 	-- Place a NPC in the gunner's chair of the APC 
  820. 	vehicle_enter_teleport(SH01_group.retail_grunts_001.members[1], SH01_group.retail_grunts_002.vehicle, 1)	 
  821. 	set_unjackable_flag(SH01_group.retail_grunts_002.vehicle, true) 
  822. 	vehicle_suppress_npc_exit(SH01_group.retail_grunts_002.vehicle, true) 
  823. 	follower_remain_in_car(SH01_group.retail_grunts_001.members[1], true) 
  824. end 
  825. function sh01_spawn_retail_brute() 
  826. 	group_create(SH01_group.retail_brute.name, true) 
  827. 	 
  828. 	on_death("sh01_brute_killed", SH01_group.retail_brute.members[1]) 
  829. 	marker_add(SH01_group.retail_brute.members[1], MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  830.  
  831. 	--door_open("sm_Brute_Office 001") 
  832. 	--door_open("sm_Brute_Office 002") 
  833. 	door_open("sm_Brute_Office 003") 
  834. 	--door_open("sm_Brute_Office 004") 
  835.  
  836. end 
  837. function sh01_must_kill_setup() 
  838. 	for i, enemy in pairs(SH01_group.retail_grunts_002.members) do 
  839. 		if (character_is_dead(enemy) == false) then 
  840. 			on_death("sh01_enemy_killed", enemy) 
  841. 			marker_add(enemy, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  842. 			Num_guys_to_kill = Num_guys_to_kill + 1 
  843. 		end 
  844. 	end 
  845. 	on_vehicle_destroyed("sh01_vehicle_killed", SH01_group.retail_grunts_002.vehicle) 
  846. 	marker_add(SH01_group.retail_grunts_002.vehicle, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  847. 	Num_guys_to_kill = Num_guys_to_kill + 1 
  848. end 
  849. function sh01_must_kill_cleanup() 
  850. 	-- Clear enemy callbacks 
  851. 	for i, enemy in pairs(SH01_group.retail_grunts_002.members) do 
  852. 		-- cleanup the callback 
  853. 		on_death("", enemy) 
  854. 		marker_remove(enemy, SYNC_ALL) 
  855. 	end 
  856. 	on_vehicle_destroyed("", SH01_group.retail_grunts_002.vehicle) 
  857. 	marker_remove(SH01_group.retail_grunts_002.vehicle, SYNC_ALL) 
  858. end 
  859. -- Cleanup all enemies from the first checkpoint 
  860. function sh01_cleanup_first_checkpoint() 
  861. end 
  862. -- Cleanup all enemies from the second checkpoint 
  863. function sh01_cleanup_second_checkpoint() 
  864. 	if group_is_loaded(SH01_group.alley_grunts_001.name) then 
  865. 		-- Loop over each guy in the group, and make sure their markers have been removed 
  866. 		for i, enemy in pairs(SH01_group.alley_grunts_001.members) do 
  867. 			on_attack_performed("", enemy) 
  868. 			if (character_is_dead(enemy) == false) then 
  869. 				marker_remove(enemy) 
  870. 			end 
  871. 		end 
  872. 		-- Cleanup the group 
  873. 		group_destroy(SH01_group.alley_grunts_001.name) 
  874. 	end 
  875. end 
  876. -- Cleanup all enemies from the third checkpoint 
  877. function sh01_cleanup_third_checkpoint() 
  878. 	 
  879. 	if group_is_loaded(SH01_group.warehouse_grunts_001.name) then 
  880. 		-- Loop over each guy in the group, and make sure their markers have been removed 
  881. 		for i, enemy in pairs(SH01_group.warehouse_grunts_001.members) do 
  882. 			on_attack_performed("", enemy) 
  883. 			if (character_is_dead(enemy) == false) then 
  884. 				marker_remove(enemy) 
  885. 			end 
  886. 		end 
  887. 		-- Cleanup the group 
  888. 		group_destroy(SH01_group.warehouse_grunts_001.name) 
  889. 	end 
  890.  
  891. 	if group_is_loaded(SH01_group.warehouse_brute_001.name) then 
  892. 		-- Loop over each guy in the group, and make sure their markers have been removed 
  893. 		for i, enemy in pairs(SH01_group.warehouse_brute_001.members) do 
  894. 			if (character_is_dead(enemy) == false) then 
  895. 				marker_remove(enemy) 
  896. 			end 
  897. 		end 
  898. 		-- Cleanup the group 
  899. 		group_destroy(SH01_group.warehouse_brute_001.name) 
  900. 		on_death("", SH01_group.warehouse_brute_001.members[1]) 
  901. 	end 
  902. 	 
  903. 	if group_is_loaded(SH01_group.warehouse_office_001.name) then 
  904. 		-- Loop over each guy in the group, and make sure their markers have been removed 
  905. 		for i, enemy in pairs(SH01_group.warehouse_office_001.members) do 
  906. 			on_attack_performed("", enemy) 
  907. 			if (character_is_dead(enemy) == false) then 
  908. 				marker_remove(enemy) 
  909. 			end 
  910. 		end 
  911. 		-- Cleanup the group 
  912. 		group_destroy(SH01_group.warehouse_office_001.name) 
  913. 	end 
  914. 	 
  915. 	if group_is_loaded(SH01_group.breakroom_grunts_001.name) then 
  916. 		-- Loop over each guy in the group, and make sure their markers have been removed 
  917. 		for i, enemy in pairs(SH01_group.breakroom_grunts_001.members) do 
  918. 			on_attack_performed("", enemy) 
  919. 			if (character_is_dead(enemy) == false) then 
  920. 				marker_remove(enemy) 
  921. 			end 
  922. 		end 
  923. 		-- Cleanup the group 
  924. 		group_destroy(SH01_group.breakroom_grunts_001.name) 
  925. 	end 
  926. 	if group_is_loaded(SH01_group.stairwell_grunts.name) then 
  927. 		-- Loop over each guy in the group, and make sure their markers have been removed 
  928. 		for i, enemy in pairs(SH01_group.stairwell_grunts.members) do 
  929. 			on_attack_performed("", enemy) 
  930. 			if (character_is_dead(enemy) == false) then 
  931. 				marker_remove(enemy) 
  932. 			end 
  933. 		end 
  934. 		-- Cleanup the group 
  935. 		group_destroy(SH01_group.stairwell_grunts.name) 
  936. 	end 
  937. 	if group_is_loaded(SH01_group.catwalk_grunts.name) then 
  938. 		-- Loop over each guy in the group, and make sure their markers have been removed 
  939. 		for i, enemy in pairs(SH01_group.catwalk_grunts.members) do 
  940. 			on_attack_performed("", enemy) 
  941. 			if (character_is_dead(enemy) == false) then 
  942. 				marker_remove(enemy) 
  943. 			end 
  944. 		end 
  945. 		-- Cleanup the group 
  946. 		group_destroy(SH01_group.catwalk_grunts.name) 
  947. 	end 
  948. 	if group_is_loaded(SH01_group.warehouse_snipers_001.name) then 
  949. 		-- Loop over each guy in the group, and make sure their markers have been removed 
  950. 		for i, enemy in pairs(SH01_group.warehouse_snipers_001.members) do 
  951. 			on_attack_performed("", enemy) 
  952. 			if (character_is_dead(enemy) == false) then 
  953. 				marker_remove(enemy) 
  954. 			end 
  955. 		end 
  956. 		-- Cleanup the group 
  957. 		group_destroy(SH01_group.warehouse_snipers_001.name) 
  958. 	end 
  959. end 
  960. -- Cleanup all the enemies from the fourth checkpoint 
  961. function sh01_cleanup_fourth_checkpoint() 
  962. 	 
  963. 	-- Cleanup group 1 
  964. 	if group_is_loaded(SH01_group.warehouse_office_002.name) then 
  965. 		-- Loop over each guy in the group, and make sure their markers have been removed 
  966. 		for i, enemy in pairs(SH01_group.warehouse_office_002.members) do 
  967. 			on_attack_performed("", enemy) 
  968. 			if (character_is_dead(enemy) == false) then 
  969. 				marker_remove(enemy) 
  970. 			end 
  971. 		end 
  972. 		-- Cleanup the group 
  973. 		group_destroy(SH01_group.warehouse_office_002.name) 
  974. 	end 
  975. 	--[[ 
  976. 	-- Cleanup group 2 
  977. 	if group_is_loaded(SH01_group.retail_grunts_001.name) then 
  978. 		--Loop over each guy in the group, and make sure their markers have been removed 
  979. 		for i, enemy in pairs(SH01_group.retail_grunts_001.members) do 
  980. 			if (character_is_dead(enemy) == false) then 
  981. 				marker_remove(enemy) 
  982. 			end 
  983. 		end 
  984. 		-- Cleanup the group 
  985. 		group_destroy(SH01_group.retail_grunts_001.name) 
  986. 	end 
  987. 	 
  988. 	-- Cleanup customers 
  989. 	-- Cleanup group 2 
  990. 	if group_is_loaded(SH01_group.retail_customers.name) then 
  991. 		--Loop over each guy in the group, and make sure their markers have been removed 
  992. 		for i, enemy in pairs(SH01_group.retail_customers.members) do 
  993. 			if (character_is_dead(enemy) == false) then 
  994. 				marker_remove(enemy) 
  995. 			end 
  996. 		end 
  997. 		-- Cleanup the group 
  998. 		group_destroy(SH01_group.retail_customers.name) 
  999. 	end 
  1000. 	 
  1001. 	-- Cleanup group 3 
  1002. 	if group_is_loaded(SH01_group.retail_grunts_002.name) then 
  1003. 		sh01_must_kill_cleanup() 
  1004. 		-- Cleanup the group 
  1005. 		group_destroy(SH01_group.retail_grunts_002.name) 
  1006. 	end 
  1007. 	if group_is_loaded(SH01_group.retail_brute.name) then 
  1008. 		--Loop over each guy in the group, and make sure their markers have been removed 
  1009. 		for i, enemy in pairs(SH01_group.retail_brute.members) do 
  1010. 			if (character_is_dead(enemy) == false) then 
  1011. 				marker_remove(enemy) 
  1012. 			end 
  1013. 		end 
  1014. 		-- Cleanup the group 
  1015. 		group_destroy(SH01_group.retail_brute.name) 
  1016. 		on_death("", SH01_group.retail_brute.members[1]) 
  1017. 	end 
  1018.  ]]-- 
  1019. end 
  1020. -- Cleanup the homies 
  1021. function sh01_cleanup_homies() 
  1022. 	if group_is_loaded(SH01_group.homies.name) then 
  1023. 		-- Remove Pierce as a homie 
  1024. 		group_destroy(SH01_group.homies.name) 
  1025. 	end 
  1026. 	on_death("", SH01_group.homies.members[1]) 
  1027. 	on_death("", SH01_group.homies.members[2]) 
  1028. 	on_dismiss("", SH01_group.homies.members[1]) 
  1029. 	on_dismiss("", SH01_group.homies.members[2]) 
  1030. end 
  1031.  
  1032. -- TRIGGER HAPPY FUNCTIONS 
  1033. -- Set a trigger enabled with a mission marker 
  1034. -- 
  1035. -- trigger:					(string) Name of the trigger 
  1036. -- trigger_callback:		(string) Function name to call when trigger is activated 
  1037. -- 
  1038. function sh01_set_trigger(trigger, trigger_callback) 
  1039. 	trigger_enable(trigger, true) 
  1040. 	marker_add_trigger(trigger, MINIMAP_ICON_LOCATION, INGAME_EFFECT_CHECKPOINT, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1041. 	on_trigger(trigger_callback, trigger) 
  1042. end 
  1043. function sh01_set_use_trigger(trigger, trigger_callback) 
  1044. 	trigger_enable(trigger, true) 
  1045. 	marker_add(trigger, MINIMAP_ICON_USE, OI_ASSET_USE) 
  1046. 	on_trigger(trigger_callback, trigger) 
  1047. end 
  1048. function sh01_set_invisible_trigger(trigger, trigger_callback) 
  1049. 	trigger_enable(trigger, true) 
  1050. 	on_trigger(trigger_callback, trigger) 
  1051. end 
  1052. -- Disable trigger 
  1053. -- 
  1054. -- trigger:			(string) Name of the trigger 
  1055. -- 
  1056. function sh01_clear_trigger(trigger) 
  1057. 	on_trigger("", trigger) 
  1058. 	trigger_enable(trigger, false) 
  1059. 	marker_remove_trigger(trigger, SYNC_ALL) 
  1060. 	-- HACK: This function should be removed eventually since it is called in marker_remove_trigger 
  1061. 	minimap_icon_remove( trigger, SYNC_ALL ) 
  1062. 	mission_waypoint_remove() 
  1063. end 
  1064. -- *************************************************** 
  1065. -- sh01_run Helper Functions 
  1066. -- *************************************************** 
  1067.  
  1068.  
  1069. -- *************************************************** 
  1070. -- sh01_initialize Helper Functions 
  1071. -- *************************************************** 
  1072.  
  1073. -- Handle any common initialization 
  1074. -- 
  1075. function sh01_initialize_common() 
  1076. 	--[[ INSERT ANY COMMON INITIALIZATION CODE HERE ]]-- 
  1077. 	party_allow_max_followers(true) 
  1078. end 
  1079.  
  1080. -- Checkpoint specific initialization 
  1081. -- 
  1082. -- checkpoint:		The checkpoint to be initialized 
  1083. function sh01_initialize_checkpoint(checkpoint) 
  1084.  
  1085. 	if (checkpoint == SH01_CHECKPOINT_START) then 
  1086. 		--[[ INSERT ANY INITIALIZATION CODE FOR STARTING THE MISSION AT THE BEGINNING ]]-- 
  1087. 		-- Teleport the players 
  1088. 		--teleport_coop(SH01_PLAYER_START[1], SH01_COOP_START[1], true) 
  1089. 		 
  1090. 		-- Teleport players 
  1091. 		--teleport_coop(SH01_PLAYER_CHECKPOINT_2[1], SH01_COOP_CHECKPOINT_2[1], true) 
  1092. 		-- Set Pierce & Shaundi as Homie (Not sure if this goes here or during checkpoint initialization) 
  1093. 		sh01_setup_crew() 
  1094. 		-- Teleport Pierce to checkpoint 
  1095. 		teleport(SH01_group.homies.members[1], SH01_P_TELEPORT_2[1]) 
  1096. 		-- Teleport Shaundi to checkpoint 
  1097. 		teleport(SH01_group.homies.members[2], SH01_S_TELEPORT_2[1]) 
  1098.  
  1099. 	end 
  1100. 	 
  1101. 	if (checkpoint == SH01_CHECKPOINT_ENTER_WAREHOUSE) then 
  1102. 		teleport_coop(SH01_PLAYER_CHECKPOINT_2[1], SH01_COOP_CHECKPOINT_2[1], true) 
  1103. 		-- Set Pierce & Shaundi as Homie (Not sure if this goes here or during checkpoint initialization) 
  1104. 		sh01_setup_crew() 
  1105. 		-- Teleport Pierce to checkpoint 
  1106. 		teleport(SH01_group.homies.members[1], SH01_P_TELEPORT_2[1]) 
  1107. 		-- Teleport Shaundi to checkpoint 
  1108. 		teleport(SH01_group.homies.members[2], SH01_S_TELEPORT_2[1]) 
  1109. 	end 
  1110. 	 
  1111. 	if (checkpoint == SH01_CHECKPOINT_MANAGER_OFFICE) then 
  1112. 		teleport_coop(SH01_PLAYER_CHECKPOINT_3[1], SH01_COOP_CHECKPOINT_3[1], true) 
  1113. 		sh01_setup_crew() 
  1114. 		-- Teleport Pierce to checkpoint 
  1115. 		teleport(SH01_group.homies.members[1], SH01_P_TELEPORT_3[1]) 
  1116. 		-- Teleport Shaundi to checkpoint 
  1117. 		teleport(SH01_group.homies.members[2], SH01_S_TELEPORT_3[1]) 
  1118. 	end 
  1119. 	if (checkpoint == SH01_CHECKPOINT_BRUTE_FIGHT) then 
  1120. 		teleport_coop(BRUTE_TELEPORT[1], BRUTE_TELEPORT[2], true) 
  1121. 		sh01_setup_crew() 
  1122. 		-- Teleport Pierce to checkpoint 
  1123. 		teleport(SH01_group.homies.members[1], BRUTE_TELEPORT[3]) 
  1124. 		-- Teleport Shaundi to checkpoint 
  1125. 		teleport(SH01_group.homies.members[2], BRUTE_TELEPORT[4]) 
  1126. 	end 
  1127. 	if (checkpoint == SH01_CHECKPOINT_CATWALK) then 
  1128. 		teleport_coop(SH01_PLAYER_CHECKPOINT_4[1], SH01_COOP_CHECKPOINT_4[1], true) 
  1129. 		sh01_setup_crew() 
  1130. 		-- Teleport Pierce to checkpoint 
  1131. 		teleport(SH01_group.homies.members[1], SH01_P_TELEPORT_4[1]) 
  1132. 		-- Teleport Shaundi to checkpoint 
  1133. 		teleport(SH01_group.homies.members[2], SH01_S_TELEPORT_4[1]) 
  1134. 		 
  1135. 		-- Open stairwell door 
  1136. 		door_open("sm_Stairwell 001") 
  1137. 	end 
  1138. 	if (checkpoint == SH01_CHECKPOINT_CLEAN_HOUSE) then 
  1139. 		teleport_coop(SH01_PLAYER_CHECKPOINT_4[1], SH01_COOP_CHECKPOINT_4[1], true) 
  1140. 		sh01_setup_crew() 
  1141. 		-- Teleport Pierce to checkpoint 
  1142. 		teleport(SH01_group.homies.members[1], SH01_P_TELEPORT_4[1]) 
  1143. 		-- Teleport Shaundi to checkpoint 
  1144. 		teleport(SH01_group.homies.members[2], SH01_S_TELEPORT_4[1]) 
  1145. 	end 
  1146.  
  1147. end 
  1148.  
  1149. -- *************************************************** 
  1150. -- Miscellaneous  Helper Funcrtions 
  1151. -- *************************************************** 
  1152. -- Setting up my homies 
  1153. function sh01_setup_crew () 
  1154. 	-- Spawn Shaundi and add her as a homie 
  1155. 	if not group_is_loaded(SH01_group.homies)then 
  1156. 		group_create(SH01_group.homies.name, true) 
  1157. 	end 
  1158. 	party_add(SH01_group.homies.members[2], LOCAL_PLAYER) 
  1159. 	 
  1160. 	-- In coop, remote gets Pierce 
  1161. 	if In_coop then 
  1162. 		party_add(SH01_group.homies.members[1], REMOTE_PLAYER) 
  1163. 	else 
  1164. 		party_add(SH01_group.homies.members[1], LOCAL_PLAYER) 
  1165. 	end 
  1166. 	 
  1167. 	follower_set_can_abandon(SH01_group.homies.members[1], true) 
  1168. 	follower_set_can_abandon(SH01_group.homies.members[2], true) 
  1169. 	 
  1170. 	on_death("sh01_failure_pierce_died", SH01_group.homies.members[1]) 
  1171. 	on_death("sh01_failure_shaundi_died", SH01_group.homies.members[2]) 
  1172. 	 
  1173. 	on_dismiss("sh01_failure_abandon_pierce", SH01_group.homies.members[1]) 
  1174. 	on_dismiss("sh01_failure_abandon_shaundi", SH01_group.homies.members[2]) 
  1175. end 
  1176. function must_kill_setup(enemy_table) 
  1177. 	for i, enemy in pairs(enemy_table) do 
  1178. 		if (character_is_dead(enemy) == false) then 
  1179. 			on_death("sh01_enemy_killed", enemy) 
  1180. 			marker_add(enemy, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_DEFAULT, SYNC_ALL) 
  1181. 		end 
  1182. 	end 
  1183. 	Num_guys_to_kill = Num_guys_to_kill + sizeof_table(enemy_table) 
  1184. end 
  1185. function must_kill_cleanup(enemy_table) 
  1186. 	-- Clear enemy callbacks 
  1187. 	for i, enemy in pairs(enemy_table) do 
  1188. 		-- cleanup the callback 
  1189. 		on_death("", enemy) 
  1190. 		marker_remove(enemy, SYNC_ALL) 
  1191. 	end 
  1192. end 
  1193. -- Setup continuous spawns 
  1194. -- 
  1195. function sh01_start_continuous_spawns() 
  1196. 	spawn_on = true 
  1197. 	 
  1198. 	spawn_region_enable(sh01_Spawn.catwalk1, true) 
  1199. 	spawn_region_enable(sh01_Spawn.catwalk2, true) 
  1200. 	spawn_region_enable(sh01_Spawn.catwalk3, true) 
  1201. 	spawn_region_enable(sh01_Spawn.catwalk4, true) 
  1202. 	continuous_spawn_start(SH01_group.spawn_wave1.name, 0, 2) 
  1203. 	continuous_spawn_start(SH01_group.spawn_wave2.name, 0, 2) 
  1204. 	continuous_spawn_start(SH01_group.spawn_wave3.name, 0, 2) 
  1205. 	continuous_spawn_start(SH01_group.spawn_wave4.name, 0, 2) 
  1206. end 
  1207. -- Turn off continuous spawns 
  1208. -- 
  1209. function sh01_stop_continuous_spawns() 
  1210. 	continuous_spawn_stop(SH01_group.spawn_wave1.name) 
  1211. 	continuous_spawn_stop(SH01_group.spawn_wave2.name) 
  1212. 	continuous_spawn_stop(SH01_group.spawn_wave3.name) 
  1213. 	continuous_spawn_stop(SH01_group.spawn_wave4.name) 
  1214. 	spawn_region_enable(sh01_Spawn.catwalk1, false) 
  1215. 	spawn_region_enable(sh01_Spawn.catwalk2, false) 
  1216. 	spawn_region_enable(sh01_Spawn.catwalk3, false) 
  1217. 	spawn_region_enable(sh01_Spawn.catwalk4, false) 
  1218. 	 
  1219. 	spawn_on = false 
  1220. end 
  1221. function sh01_start_office_spawns() 
  1222. 	spawn_office = true 
  1223. 	 
  1224. 	spawn_region_enable(sh01_Spawn.office1, true) 
  1225. 	spawn_region_enable(sh01_Spawn.office2, true) 
  1226. 	spawn_region_enable(sh01_Spawn.office3, true) 
  1227. 	spawn_region_enable(sh01_Spawn.office4, true) 
  1228. 	continuous_spawn_start(SH01_group.spawn_wave5.name, 0, 0) 
  1229. 	continuous_spawn_start(SH01_group.spawn_wave6.name, 0, 0) 
  1230. 	continuous_spawn_start(SH01_group.spawn_wave7.name, 0, 0) 
  1231. 	continuous_spawn_start(SH01_group.spawn_wave8.name, 0, 0) 
  1232. end 
  1233. -- Turn off continuous spawns 
  1234. -- 
  1235. function sh01_stop_office_spawns() 
  1236. 	continuous_spawn_stop(SH01_group.spawn_wave5.name) 
  1237. 	continuous_spawn_stop(SH01_group.spawn_wave6.name) 
  1238. 	continuous_spawn_stop(SH01_group.spawn_wave7.name) 
  1239. 	continuous_spawn_stop(SH01_group.spawn_wave8.name) 
  1240. 	spawn_region_enable(sh01_Spawn.office1, false) 
  1241. 	spawn_region_enable(sh01_Spawn.office2, false) 
  1242. 	spawn_region_enable(sh01_Spawn.office3, false) 
  1243. 	spawn_region_enable(sh01_Spawn.office4, false) 
  1244. 	 
  1245. 	spawn_office = false 
  1246. end 
  1247. -- ************************* 
  1248. -- 
  1249. -- Callback functions 
  1250. -- 
  1251. -- ************************* 
  1252. -- Callback for when a dude dies 
  1253. -- 
  1254. function sh01_enemy_killed(enemy) 
  1255. 	on_death("",enemy) 
  1256. 	Num_guys_to_kill = Num_guys_to_kill - 1 
  1257. end 
  1258.  
  1259. function sh01_brute_killed(enemy) 
  1260. 	marker_remove(enemy) 
  1261. 	on_death("", enemy) 
  1262. 	 
  1263. 	Brute_Killed = true 
  1264. end 
  1265. -- End the mission if Pierce dies 
  1266. function sh01_failure_pierce_died() 
  1267. 	mission_end_failure("sh01", SH01_FAILURE_PIERCE_DIED) 
  1268. end 
  1269. function sh01_failure_abandon_pierce() 
  1270. 	mission_end_failure("sh01", SH01_FAILURE_ABANDON_PIERCE) 
  1271. end 
  1272. -- End the mission if Shaundi dies 
  1273. function sh01_failure_shaundi_died() 
  1274. 	mission_end_failure("sh01", SH01_FAILURE_SHAUNDI_DIED) 
  1275. end 
  1276. function sh01_failure_abandon_shaundi() 
  1277. 	mission_end_failure("sh01", SH01_FAILURE_ABANDON_SHAUNDI) 
  1278. end 
  1279. -- Trigger Callback 
  1280. function sh01_reached_warehouse_door() 
  1281. 	audio_play_persona_line(LOCAL_PLAYER, "SH01_Get_Inside") 
  1282. 	warehouse_door_triggered = true 
  1283. 	sh01_clear_trigger(WAREHOUSE_DOOR_TRIGGER) 
  1284. end 
  1285. function sh01_reached_alley() 
  1286. 	thread_new("sh01_convo", SH01_convo.alley_combat) 
  1287. 	alley_triggered = true 
  1288. 	sh01_clear_trigger(ALLEY_TRIGGER) 
  1289. end 
  1290. function sh01_reached_inside() 
  1291. 	SH01_thread.combat_chatter = thread_new("sh01_enter_warehouse_convo_thread") 
  1292. 	inside_triggered = true 
  1293. 	sh01_clear_trigger(INSIDE_TRIGGER) 
  1294. end 
  1295. function sh01_reached_catwalk() 
  1296. 	door_open("sm_Office_Frontdoor 001") 
  1297. 	door_open("sm_Office_Frontdoor 002") 
  1298. 	thread_new("sh01_convo", SH01_convo.manager_office_enter) 
  1299. 	catwalk_triggered = true 
  1300. 	sh01_clear_trigger(CATWALK_TRIGGER) 
  1301. 	delay(1.0) 
  1302. 	for i, guard in pairs(SH01_group.warehouse_office_001.members) do 
  1303. 		ai_do_scripted_move(guard, CATWALK_MARK[i]) 
  1304. 	end 
  1305. end 
  1306. function sh01_reached_upstairs() 
  1307. 	upstairs_triggered = true 
  1308. 	sh01_clear_trigger(UPSTAIRS_TRIGGER) 
  1309. end 
  1310. -- Callback for when the player reaches the top of the stairwell 
  1311. -- 
  1312. -- character:	name of character that entered the trigger 
  1313. -- trig:		name of the trigger 
  1314. function sh01_reached_topstairwell(character, trig) 
  1315. 	if not(character == LOCAL_PLAYER)then 
  1316. 		return 
  1317. 	end 
  1318. 	 
  1319. 	topstairwell_triggered = true 
  1320. 	sh01_clear_trigger(TOPSTAIRWELL_TRIGGER) 
  1321. 	-- Set trigger to object in manager's office 
  1322. 	office_triggered = false 
  1323. 	sh01_set_trigger(OFFICE_TRIGGER, "sh01_reached_office") 
  1324. 	sh01_setup_catwalk_grunts() 
  1325. end 
  1326. -- Callback for when the player reaches the office 
  1327. -- 
  1328. -- character:	name of character that entered the trigger 
  1329. -- trig:		name of the trigger 
  1330. function sh01_reached_office(character, trig) 
  1331. 	if not(character == LOCAL_PLAYER)then 
  1332. 		return 
  1333. 	end 
  1334. 	 
  1335. 	office_triggered = true 
  1336. 	sh01_clear_trigger(OFFICE_TRIGGER) 
  1337. end 
  1338.  
  1339. function sh01_reached_breakroom() 
  1340. 	breakroom_triggered = true 
  1341. 	sh01_clear_trigger(BREAKROOM_TRIGGER) 
  1342. end 
  1343.  
  1344. function sh01_reached_showroom() 
  1345. 	showroom_triggered = true 
  1346. 	sh01_clear_trigger(SHOWROOM_TRIGGER) 
  1347. end 
  1348.  
  1349. function sh01_used_computer() 
  1350. 	computer_triggered = true 
  1351. 	marker_remove(COMPUTER_TRIGGER) 
  1352. 	sh01_clear_trigger(COMPUTER_TRIGGER) 
  1353. 	audio_play_persona_line(SH01_group.homies.members[2], "SH01_Hack_Success") 
  1354. end 
  1355. -- Callback for when a dude dies 
  1356. -- 
  1357. function sh01_enemy_killed(enemy) 
  1358. 	marker_remove(enemy) 
  1359. 	on_death("",enemy) 
  1360. 	Num_guys_to_kill = Num_guys_to_kill - 1 
  1361. end 
  1362. function sh01_vehicle_killed(enemy) 
  1363. 	marker_remove(enemy) 
  1364. 	on_vehicle_destroyed("",enemy) 
  1365. 	Num_guys_to_kill = Num_guys_to_kill - 1 
  1366. 	character_kill(SH01_group.retail_grunts_001.members[1]) 
  1367. end 
  1368. -- Have Morningstar attack persona lines 
  1369. -- 
  1370. -- name:	(string) name of character 
  1371. -- weapon:	(string) name of weapon 
  1372. -- attack:	(string) type of attack performed 
  1373. -- 
  1374. function sh01_ms_attack_line_cb(name, weapon, attack) 
  1375. 	local situation = "SH01_Attack" 
  1376. 	 
  1377. 	-- don't play this if we have done this recently 
  1378. 	if(not thread_check_done(SH01_thread.attack_line_timer))then 
  1379. 		return 
  1380. 	end 
  1381. 	 
  1382. 	-- start timer 
  1383. 	SH01_thread.attack_line_timer = thread_new("delay", SH01_Attack_Line_Time) 
  1384. 	-- Play situation 
  1385. 	audio_play_persona_line(name, situation) 
  1386. end 
  1387.  
  1388. -- Have breakroom guys bitch 
  1389. -- 
  1390. -- name:	(string) name of character 
  1391. -- weapon:	(string) name of weapon 
  1392. -- attack:	(string) type of attack performed 
  1393. -- 
  1394. function sh01_ms_breakroom_persona_cb(name, weapon, attack) 
  1395. 	local situation = "SH01_Breakroom" 
  1396. 	 
  1397. 	audio_play_persona_line(name, situation) 
  1398. end 
  1399. -- ************************* 
  1400. -- 
  1401. -- Thread functions 
  1402. -- 
  1403. -- ************************* 
  1404. function sh01_convo(convo) 
  1405. 	if(convo == nil)then 
  1406. 		return 
  1407. 	end 
  1408. 	-- If another conversation is already playing, wait for it to finish 
  1409. 	if(convo_is_playing)then 
  1410. 		repeat 
  1411. 			thread_yield() 
  1412. 		until (not convo_is_playing) 
  1413. 	end 
  1414. 	convo_is_playing = true 
  1415. 	-- Load the conversation 
  1416. 	if (convo.load_direct)then 
  1417. 		convo.handle = audio_conversation_load_direct(convo.name) 
  1418. 	else 
  1419. 		convo.handle = audio_conversation_load(convo.name) 
  1420. 	end 
  1421. 	-- Play the conversation 
  1422. 	audio_conversation_play(convo.handle) 
  1423. 	delay(1) 
  1424. 	-- Wait for the conversation to end 
  1425. 	audio_conversation_wait_for_end(convo.handle) 
  1426. 	convo.handle = INVALID_CONVERSATION_HANDLE 
  1427. 	convo_is_playing = false 
  1428. end 
  1429. function sh01_enter_warehouse_convo_thread() 
  1430. 	for i, chat in pairs(SH01_Warehouse_Combat_Chatter)do 
  1431. 		if(breakroom_triggered)then 
  1432. 			return 
  1433. 		end 
  1434. 		local playing_line = false 
  1435. 		while (not playing_line)do 
  1436. 			if convo_is_playing then 
  1437. 				thread_yield() 
  1438. 			elseif(not thread_check_done(SH01_thread.chatter_timer))then 
  1439. 				thread_yield() 
  1440. 			elseif(not playing_line) and (not chat.spoken) then 
  1441. 				chat.spoken = true 
  1442. 				playing_line = true 
  1443. 				if chat.is_conversation then 
  1444. 					sh01_convo(chat.conversation) 
  1445. 				else 
  1446. 					audio_play_persona_line(chat.speaker, chat.line) 
  1447. 				end 
  1448. 			SH01_thread.chatter_timer = thread_new("delay", 5.0) 
  1449. 			end 
  1450. 		end 
  1451. 		delay(8.0) 
  1452. 	end 
  1453. end 
  1454. function sh01_retail_combat_convo_thread() 
  1455. 	for i, chat in pairs(SH01_Retail_Combat_Chatter)do 
  1456. 		local playing_line = false 
  1457. 		while (not playing_line)do 
  1458. 			if convo_is_playing then 
  1459. 				thread_yield() 
  1460. 			elseif(not thread_check_done(SH01_thread.chatter_timer))then 
  1461. 				thread_yield() 
  1462. 			elseif(not playing_line) and (not chat.spoken) then 
  1463. 				chat.spoken = true 
  1464. 				playing_line = true 
  1465. 				if chat.is_conversation then 
  1466. 					sh01_convo(chat.conversation) 
  1467. 				else 
  1468. 					audio_play_persona_line(chat.speaker, chat.line) 
  1469. 				end 
  1470. 			SH01_thread.chatter_timer = thread_new("delay", 10.0) 
  1471. 			end 
  1472. 		end 
  1473. 		delay(10.0) 
  1474. 	end	 
  1475. end 
  1476.  
  1477. function sh01_shaundi_hack_thread() 
  1478. 	delay(2.0) 
  1479. 	-- Remove Shaundi's leash to the player 
  1480. --	follower_make_independent(SH01_group.homies.members[2], true) 
  1481. 	 
  1482. 	-- Have Shaudi ignore any other AI commands 
  1483. 	set_ignore_ai_flag(SH01_group.homies.members[2], true) 
  1484. 	-- Move Shaundi to the computer 
  1485. 	ai_do_scripted_move(SH01_group.homies.members[2], HACK_POINT, true, false) 
  1486. 	 
  1487. 	-- Make sure she gets to where she is supposed to be 
  1488. 	while (get_dist(SH01_group.homies.members[2], HACK_POINT) > 2.0)do 
  1489. 		if not (ai_scripted_action_is_processing(SH01_group.homies.members[2]))then 
  1490. 			ai_do_scripted_move(SH01_group.homies.members[2], HACK_POINT, true, false) 
  1491. 		end 
  1492. 		thread_yield() 
  1493. 	end 
  1494.  
  1495. 	-- Wait for her to finish walking 
  1496. 	--while not(ai_scripted_action_is_complete(SH01_group.homies.members[2])) do 
  1497. 	--	thread_yield() 
  1498. 	--end 
  1499. 	-- Double check to make sure the AI didn't cut out early 
  1500. --	if (get_dist(SH01_group.homies.members[2]) > 2.0)then 
  1501. --		ai_do_scripted_move(SH01_group.homies.members[2]) 
  1502. --		while not(get_dist(SH01_group.homies.members[2]) < 2.0)do 
  1503. --			thread_yield() 
  1504. --		end 
  1505. --	end 
  1506. 	 
  1507. 	 
  1508. 	-- Switch objective to the hacking meter 
  1509. 	thread_new("sh01_hack_hud_bar_thread") 
  1510. 	 
  1511. 	-- Set off animation thread so we can loop the hacking animation 
  1512. 	thread_new("sh01_shaundi_hack_animation_thread") 
  1513.  
  1514.  
  1515. --	local current_pct = 0.01 
  1516. --	local pct_step = 0.01 
  1517. --	SH01_HACK_PROGRESS = 0 
  1518. --	while current_pct < 1.0 do 
  1519. 		--while not action_play_is_finished(SH01_group.homies.members[2], current_pct) do 
  1520. 		--	thread_yield() 
  1521. 		--end 
  1522. 		--SH01_HACK_PROGRESS = current_pct * 100 
  1523. 		--current_pct = current_pct + pct_step 
  1524. 		 
  1525. 		-- alt for different timing 
  1526. --		while action_play_is_finished(SH01_group.homies.members[2], current_pct) do 
  1527. --			current_pct = current_pct + pct_step 
  1528. --		end 
  1529. --		SH01_HACK_PROGRESS = current_pct * 100 
  1530. --		thread_yield() 
  1531. --	end 
  1532. 	 
  1533. --	SH01_HACK_PROGRESS = 100 
  1534. 	 
  1535. 	SH01_HACK_PROGRESS = 0 
  1536. 	local hack_time = 1500 
  1537. 	 
  1538. 	while SH01_HACK_PROGRESS < hack_time do 
  1539. 		if human_is_downed(SH01_group.homies.members[2])then 
  1540. 			SH01_HACK_PROGRESS = 0 
  1541. 		end 
  1542. 		 
  1543. 		SH01_HACK_PROGRESS = SH01_HACK_PROGRESS + 1 
  1544. 		thread_yield() 
  1545. 	end 
  1546. 	 
  1547. 	-- Turn Shaundi's AI back on 
  1548. 	set_ignore_ai_flag(SH01_group.homies.members[2], false) 
  1549. 	 
  1550. 	audio_play_persona_line(SH01_group.homies.members[2], "SH01_Hack_Success") 
  1551. 	hack_done = true 
  1552. end 
  1553.  
  1554. function sh01_hack_hud_bar_thread() 
  1555. 	objective_text_clear(0) 
  1556. 	hud_bar_on(0, "health", "sh01_obj_use_computer", HUD_BAR_MAX_VALUE) 
  1557. 	while not hack_done do 
  1558. 		hud_bar_set_value(0, SH01_HACK_PROGRESS) 
  1559. 		thread_yield() 
  1560. 	end 
  1561. 	hud_bar_off(0) 
  1562. end 
  1563.  
  1564. -- Shaundi's hacking animation thread 
  1565. function sh01_shaundi_hack_animation_thread() 
  1566. 	-- Set up Shaundi to get into hacking animation area 
  1567. 	set_script_animation_state(SH01_group.homies.members[2], "SH03 Kenzie hack") 
  1568. 	action_play(SH01_group.homies.members[2], "SH03 Kenzie hack enter", "", false, 0.8, false, false, HACK_POINT) 
  1569. 	while not hack_done do 
  1570. 		-- Play hacking animation 
  1571. --		action_play(SH01_group.homies.members[2], "SH03 Kenzie hack", "", false, 0.8) 
  1572. 		thread_yield() 
  1573. 	end 
  1574. 	-- Take Shaundi out of hacking animation 
  1575. --	action_play(SH01_group.homies.members[2], "SH03 Kenzie hack exit", "", false, 0.8) 
  1576. 	clear_animation_state(SH01_group.homies.members[2]) 
  1577. end