./sh04.lua

  1. --[[ 
  2. 	SH04.lua 
  3. 	SR3 Mission Script 
  4. 	DATE: 11/1/2010 
  5. 	AUTHOR:	David Bowring, Jimmy Cross 
  6. ]] 
  7.  
  8.  
  9. -- Debug flags -- 
  10.  
  11. -- Tweakable Parameters -- 
  12. sh04_status = { 
  13. 	convo_is_playing = false, 
  14. 	} 
  15. 	 
  16. -- Characters -- 
  17. 	ANGEL_NO_MASK = "Angel" 
  18. 	ANGEL_WITH_MASK = "Angel_Mask" 
  19. 	MOVING_DOWN_CHARACTERS = { "Moving Down 001", "Moving Down 002", "Moving Down 003" } 
  20. 	MOVING_DOWN_LEADER = MOVING_DOWN_CHARACTERS[1] 
  21.  
  22. -- Groups -- 
  23. 	SH04_group = { 
  24. 		homies = { 
  25. 			name = "Homies Group", 
  26. 			members = { "Angel", "Angel_Mask" }, 
  27. 			thread = INVALID_THREAD_HANDLE 
  28. 		}, 
  29. 		 
  30. 		initial_luchadors = { 
  31. 			name = "Initial Luchadors", 
  32. 			members = { "First Floor 002", "First Floor 005", 
  33. 							"Second Floor 001", "Second Floor 002", "Second Floor 003",  
  34. 							 "Second Floor 006", "Second Floor 010",} 
  35. 		}, 
  36. 		 
  37. 		right_door =   
  38. 		{  
  39. 			name = "right_door_grp", 
  40. 			members = { "First Floor 003", "First Floor 011" }, 
  41. 			thread = { INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE }, 
  42. 			navs = { "rdest", "rdest01" } 
  43. 		}, 
  44. 		 
  45. 		left_door =  
  46. 		{ 
  47. 			name = "left_door_grp", 
  48. 			members = { "First Floor 001", "First Floor 006", "First Floor 009" }, 
  49. 			thread = { INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE }, 
  50. 			navs = {"ldest01", "ldest02", "ldest03" } 
  51. 		}, 
  52. 		 
  53. 		first_specialist = { 
  54. 			name = "first_specialist", 
  55. 			members = "init_specialist", 
  56. 			dest = "spec_dest" 
  57. 		}, 
  58. 		 
  59. 		coop_initial_luchadors = { 
  60. 			name = "coop_init", 
  61. 			members = { "coop_first_floor", "coop_first_floor<001>", "coop_first_floor<002>", "coop_first_floor<003>", "coop_first_floor<004>", "coop_first_floor<005>", "coop_first_floor<006>", } 
  62. 		}, 
  63. 		 
  64. 		backroom_guards = { 
  65. 			name = "Backroom Guards", 
  66. 			members = { "Backroom Back 002", "Backroom Back 003", "Backroom Back 004" } 
  67. 		}, 
  68. 		 
  69. 		back_left = { 
  70. 			name = "Back_Left", 
  71. 			members = {"Backroom Left 001", "Backroom Left 002"}, 
  72. 			navs = { "lback01", "lback02", "lback03", "lback04" } 
  73. 		}, 
  74. 		 
  75. 		back_right = { 
  76. 			name = "Back_Right", 
  77. 			members = { "Backroom Right 002", "Backroom Right 003" }, 
  78. 			navs = { "rback01","rback02","rback03","rback04", } 
  79. 		}, 
  80.  
  81. 		backroom_specialist = { 
  82. 			name = "Backroom Specialist Group", 
  83. 			members = "Backroom Specialist"  
  84. 		}, 
  85. 		 
  86. 		backroom_specialist_coop  = { 
  87. 			name = "Backroom Specialist Coop", 
  88. 			members = "Backroom_Specialist_Coop"  
  89. 		}, 
  90.  
  91. 		alpha_squad = { 
  92. 			name = "Alpha Team", 
  93. 			members = { "Alpha 003", "Alpha 006" }, 
  94. 		}, 
  95.  
  96. 		beta_squad = { 
  97. 			name = "Beta Team", 
  98. 			members = { "Beta 001", "Beta 005"}, 
  99. 		}, 
  100. 		 
  101. 		right_room = { 
  102. 			name = "right room", 
  103. 			members = {  "Right guard 001","Right guard 002" }, 
  104. 		}, 
  105. 		 
  106. 		brute_g01 = { 
  107. 			name = "brute_01",  
  108. 			members = "brute01" 
  109. 		}, 
  110. 		 
  111. 		brute_g02 = { 
  112. 			name = "brute_02", 
  113. 			members = { "brute02", "brute03" } 
  114. 		}, 
  115.  
  116. 		brute_g03 = { 
  117. 			name = "brute_03", 
  118. 			members = {"brute04"} 
  119. 		}, 
  120.  
  121. 		post_mask_attackers = { 
  122. 			name = "Post Mask Attackers", 
  123. 			members = { "Post Mask 001", "Post Mask 002", "Post Mask 003", "Post Mask 004", "Post Mask 005"  } 
  124. 		}, 
  125. 		 
  126. 		casino_manager = { 
  127. 			name = "manager", 
  128. 			members = "sh04_manager", 
  129. 			dest = "angel_dest", 
  130. 			id = -1, 
  131. 			thread = INVALID_THREAD_HANDLE 
  132. 		}, 
  133. 		 
  134. 		cont_spawn_a = { 
  135. 			name = "spawngroup_a", 
  136. 			members = "spawn_a" 
  137. 			}, 
  138. 		 
  139. 		cont_spawn_b = { 
  140. 			name = "spawngroup_b", 
  141. 			members = "spawn_b", 
  142. 			}, 
  143. 			 
  144. 		cont_spawn_c = { 
  145. 			name = "spawngroup_c", 
  146. 			members = "spawn_c", "spawn_c<001>" 
  147. 			}, 
  148. 		 
  149. 		cont_spawn_d = { 
  150. 			name = "spawngroup_d", 
  151. 			members = "spawn_d", 
  152. 			}, 
  153. 		--[[ 
  154. 		cont_spawn_spec = { 
  155. 			name = "spawngroup_c", 
  156. 			members = "spawn_c", 
  157. 			}, 
  158. 			]]-- 
  159. 		ambush = { 
  160. 				name = "post_statue", 
  161. 				members = { "Post Statue", "Post Statue 001", "Post Statue 002", "Post Statue 003" } 
  162. 			}, 
  163. 		peds = { 
  164. 				name = "sh04_peds", 
  165. 				members = { "bartender 001", "bartender 002", "dealer", "dealer<003>",   
  166. 				"gambler<001>", "gambler<003>", "gambler<004>" }, 
  167. 				bartenders = { "bartender 001", "bartender 002" }, 
  168. 				dealers = { "dealer", "dealer<003>" } 
  169. 			}, 
  170. 		CTE_cutscene = {  
  171. 			name = "CTE Cutscene", 
  172. 			members = { "CTE Angel (No Mask)" } 
  173. 		}, 
  174. 		CTE_angel_mask = { 
  175. 			name = "CTE_AngelWMask", 
  176. 			members = { "CTE Angel Mask" }, 
  177. 		},--[[, 
  178.  
  179. 		 = { 
  180. 			name = "next group name" 
  181. 		},]] 
  182. 	} 
  183. 	 
  184. sh04_objectives = { 
  185. 	statues =  
  186. 		{ 
  187. 			members =  { "statue_trigger", "statue_trigger<001>", "statue_trigger<002>", "statue_trigger<003>", "statue_trigger<004>", "statue_trigger<005>"}, 
  188. 			status = {false, false, false, false, false, false}, 
  189. 			active = {false, false, false, false, false, false}, 
  190. 			nav = { "statue_nav", "statue_nav<001>", "statue_nav<002>", "statue_nav<003>", "statue_nav<004>", "statue_nav<005>" } 
  191. 		}, 
  192. } 
  193. 	 
  194. -- Navpoints -- 
  195. 	sh04_navs = {		 
  196. 		post_cte = { "checkpoint_cte_local", "checkpoint_cte_remote" }, 
  197. 		tele = { 
  198. 			plocal = "teleport_local", 
  199. 			premote = "teleport_remote" 
  200. 			}, 
  201. 			cp_start = { "Checkpoint Warp Start", "P2 Checkpoint Warp Start"	} 
  202. 		} 
  203. 			 
  204. 	START_WARP_LOCATIONS = { [LOCAL_PLAYER] = "Checkpoint Warp Start", [REMOTE_PLAYER] = "P2 Checkpoint Warp Start" } 
  205. 	POST_MASK_CHECKPOINT_WARP_LOCATIONS = { [LOCAL_PLAYER] = "checkpoint_cte_local", [REMOTE_PLAYER] = "checkpoint_cte_remote" } 
  206. 	NAVPOINT_ANGEL_POST_MASK = "CTE Angel Location" 
  207. 	NAVPOINT_TO_VAULT_001 = "To Vault 001" 
  208. 	NAVPOINT_TO_VAULT_002 = "To Vault 002" 
  209. 	NAVPOINT_MASK_CUTSCENE = "Mask Cutscene Location" 
  210. 	NAVPOINT_PICK_UP_MASK_LOCATION = "CTE Mask Pickup Point" 
  211. 	NAVPOINT_POST_CTE_PLAYER_WARP = "CTE Player Location" 
  212. 	NAVPOINT_POST_CTE_REMOTE_PLAYER_WARP = "CTE Angel Location" 
  213. 	NAVPOINTS_DOWN_STAIRS_PATH = { "Down Stairs Path 001", "Down Stairs Path 002" } 
  214. 	SH04_BRUTE_DEST = "brute_dest" 
  215.  
  216. -- Triggers -- 
  217. 	SH04_TRIGGER_UPSTAIRS = "Spawn_upstairs" 
  218. 	SH04_TRIGGER_ALPHA = "trigger_alpha" 
  219. 	SH04_TRIGGER_BETA = "trigger_beta" 
  220. 	SH04_TRIGGER_ATTACK = "attack_trigger" 
  221. 	--SH04_TRIGGER_ALARM = "Alarm_Trigger" 
  222. 	SH04_TRIGGER_AMBUSH = "ambush_trigger" 
  223. 	SH04_TRIGGER_CONT_SPAWN = "trig_activate_cont_spawn" 
  224. 	TRIGGER_BOTTOM_FLOOR = "Bottom Floor" 
  225. 	TRIGGER_TO_VAULT_001 = "To Vault Trigger 001" 
  226. 	TRIGGER_TO_VAULT_002 = "To Vault Trigger 002" 
  227. 	TRIGGER_MASK_CUTSCENE = "Mask Cutscene" 
  228. 	TRIGGER_MISSION_AREA_001 = "Mission Area 001" 
  229.  
  230. -- Vehicles -- 
  231.  
  232. -- Mesh Movers -- 
  233. 	SH04_killbane_statues = { "SM Killbane Statue 1F SE", "SM Killbane Statue 1F NW", "SM Killbane Statue 1F SW", 
  234. 									  "SM Killbane Statue 2F NE", "SM Killbane Statue 2F NW",  "SM Killbane Statue 2F SE" } --"SM Killbane Statue 2F SW",  "SM Killbane Statue 1F NE", 
  235.  
  236. 	-- Text -- 
  237. 	HELPTEXT_FAILURE_ANGEL_DIED = "sh04_failure_angel_died" 
  238. 	HELPTEXT_FAILURE_ANGEL_ABANDONED = "sh04_failure_angel_abandoned" 
  239. 	HELPTEXT_FAILURE_LEFT_MISSION = "sh04_failure_left_casino" 
  240. 	SH04_HELPTEXT_GET_BACK_TO_THE_CASINO = "sh04_get_back_to_the_casino" 
  241.  
  242. 	HELPTEXT_HEAD_TO_CASINO = "sh04_obj_head_to_casino" 
  243. 	HELPTEXT_GO_TO_THE_STATUE = "sh04_obj_go_to_the_statue" 
  244. 	HELPTEXT_FIND_THE_VAULT = "sh04_obj_find_the_vault" 
  245. 	HELPTEXT_DESTROY_STATUES = "sh04_obj_destroy_statues" 
  246. 	HELPTEXT_DESTROY_LUCHADORES = "SH04_OBJ_DESTROY_LUCHADORES" 
  247. 	SH04_DAMAGE = "SH04_DAMAGE" 
  248. 	SH04_TOTAL_DAMAGE = 125 
  249. 	SH04_MANAGER = "SH04_OBJ_MGR" 
  250. 	SH04_BRUTES = "SH04_OBJ_BRUTES" 
  251.  
  252. -- Threads -- 
  253. sh04_threads = { 
  254. 	attack_line_timer = INVALID_THREAD_HANDLE 
  255. 	} 
  256. 	SH04_THREAD_SPAWN_SECOND_SQUAD = INVALID_THREAD_HANDLE 
  257. 	SH04_THREAD_SPAWN_SECOND_SQUAD = INVALID_THREAD_HANDLE 
  258. 	SH04_THREAD_ANGEL_WATCHER = INVALID_THREAD_HANDLE 
  259. 	SH04_THREAD_CONVO = INVALID_THREAD_HANDLE 
  260.  
  261. -- Checkpoints -- 
  262. 	CHECKPOINT_START = MISSION_START_CHECKPOINT			-- defined in ug_lib.lua 
  263. 	SH04_CHECKPOINT_MASK = "sh04_checkpoint_mask" 
  264.  
  265. -- Cutscenes -- 
  266. 	CUTSCENE_MISSION_INTRO = "" 
  267. 	CUTSCENE_MISSION_OUTRO = "" 
  268. 	CUTSCENE_ENTRANCE = "ld_sh01" 
  269. 	CUTSCENE_TAKE_MASK = "cte_s04_angel_gets_mask" 
  270.  
  271. -- Conversations -- 
  272. 	SH04_convo = { 
  273. 		start_convo = { 
  274. 			name = "SH04_Mission_Start", 
  275. 			handle = INVALID_CONVERSATION_HANDLE 
  276. 		} 
  277. 		, 
  278. 		fake_convo = { 
  279. 			name = "SH04_Fake_Mask", 
  280. 			handle = INVALID_CONVERSATION_HANDLE 
  281. 		} 
  282. 		, 
  283. 		vault_convo = { 
  284. 			name = "SH04_Vault_Mask", 
  285. 			handle = INVALID_CONVERSATION_HANDLE 
  286. 		} 
  287. 		, 
  288. 		destroy_statues_convo = { 
  289. 			name = "SH04_Destroy_Statues", 
  290. 			handle = INVALID_CONVERSATION_HANDLE 
  291. 		} 
  292. 		, 
  293. 		see_manager = { 
  294. 			name = "SH04_See_Manager", 
  295. 			handle = INVALID_CONVERSATION_HANDLE 
  296. 		} 
  297. 		, 
  298. 		threaten_manager = { 
  299. 			name = "SH04_Threaten_Manager_New", 
  300. 			handle = INVALID_CONVERSATION_HANDLE 
  301. 		} 
  302. 		, 
  303. 		interrogate_manager = { 
  304. 			name = "SH04_Manager_Interrogation", 
  305. 			handle = INVALID_CONVERSATION_HANDLE 
  306. 		} 
  307. 		, 
  308. 		fight2vault = { 
  309. 			name = "SH04_Fights_To_The_Vault", 
  310. 			handle = INVALID_CONVERSATION_HANDLE 
  311. 		} 
  312.  
  313. 	} 
  314. 	 
  315. 	SH04_dialog_lines = { 
  316. 		pre_mask = "sh04_pre_mask_combat", 
  317. 		post_mask = "sh04_post_mask_combat", 
  318. 		brute01 = "sh04_brute_comment_01", 
  319. 		brute02 = "sh04_brute_comment_02", 
  320. 		specialist01 = "sh04_luchadore_specialist_01", 
  321. 		specialist02 = "sh04_luchadore_specialist_02", 
  322. 		clean_house = "SH04_Finish_Clearing_Guys_01", 
  323. 		put_on_mask = "sh04_puts_on_mask", 
  324. 		do_damage = "SH04_Do_Damage", 
  325. 		statue_destroyed = { 
  326. 			"SH04_Statue_Destroyed_01", 
  327. 			"SH04_Statue_Destroyed_02", 
  328. 			"SH04_Statue_Destroyed_03", 
  329. 			"SH04_Statue_Destroyed_04",  
  330. 			"SH04_Statue_Destroyed_05", 
  331. 			"SH04_Statue_Destroyed_06" 
  332. 			}, 
  333. 		} 
  334. 		 
  335. -- Other -- 
  336. 	CONTINUOUS_SPAWN_POINTS = { "Spawn 2F E", "Spawn 2F W", "Spawn N", "Spawn NE", "Spawn SE" } 
  337. 	SH04_INIT_SPAWN_POINTS = { "init_spawn_1", "init_spawn_2" } 
  338. 	SH04_INT_CONT_SPAWN_TIME = 6 
  339. 	SH04_SPECIALIST_SPAWN_DELAY_SECONDS = 10.0 
  340. 	SH04_NORMAL_SQUAD_RESPAWN_DELAY_SECONDS = 15.0 
  341. 	SH04_SPECIALIST_SQUAD_SPAWN_DELAY_SECONDS = 20.0 
  342. 	SH04_COOP_SCALE = 5.0 
  343. 	--SH04_NUM_STATUES_REMAINING_BRUTE_SPAWN_TRIGGER = 2 
  344. 	SH04_OUT_OF_AREA_FAILURE_TIME_MS = 15000 
  345. 	SH04_MIN_NOTORIETY = 4 
  346. 	SH04_GO_HOSTILE = false 
  347. 	SH04_TIMER_ACTIVE = false 
  348. 	SH04_LEAVE_AREA_FAILURE_ENABLED = false 
  349. 	SH04_INTERROGATION = false 
  350. 	SH04_INTERROGATION_COMPLETE = false 
  351. 	SH04_INTERROGATE_PLAYER = LOCAL_PLAYER 
  352. 	local IS_RESTART = false 
  353. 	 
  354. 	SH04_ANGEL_RADIUSS = 10 
  355.  
  356. 	ANIMATION_EXAMINE_FAKE_MASK = "react Surprised" 
  357. 	ANIMATION_FINISH_PUTTING_ON_MASK = "react Surprised" 
  358.  
  359. 	FAIL_TIMER_INDICES = { [LOCAL_PLAYER] = 1, [REMOTE_PLAYER] = 2 } 
  360. 	 
  361. 	SH04_NUMBER_LUCHADORES = 0 
  362. 	SH04_DEAD_BRUTES = 0 
  363. 	SH04_Players = { LOCAL_PLAYER, REMOTE_PLAYER } 
  364. 	 
  365. 	sh04_queue = {} 
  366. 	sh04_queue_size = 0 
  367. 	sh04_spawn_brutes = true 
  368.  
  369. 	-- Set by default to "true" since mission is started within the trigger regions 
  370. 	Players_in_mission_area_triggers = { [TRIGGER_MISSION_AREA_001] = { [LOCAL_PLAYER] = true, [REMOTE_PLAYER] = true }} 
  371. 	Players_in_mission_area = { [LOCAL_PLAYER] = true, [REMOTE_PLAYER] = true } 
  372.  
  373. 	Entrance_cutscene_triggered = false 
  374. 	Hit_vault_one_trigger = false 
  375. 	Hit_mask_cutscene = false 
  376. 	Wait_on_Angel_timer_expired = false 
  377. 	SH04_slot_obj = false 
  378. 	sh04_hostage_taken = false 
  379. 	SH04_num_remaining_luchadors = 0 
  380. 	SH04_num_remaining_statues = 0 
  381. 	SH04_original_num_statues = 0 
  382. 	SH04_destroyed_slots = 0 
  383. 	SH04_total_slots = 380 
  384.  
  385. 	Mission_successful = false 
  386. 	 
  387. 	---AUDIO--- 
  388. SH04_START_CONVERSATION_PLAYER = "SH04_Mission_Start_02" 
  389. SH04_START_CONVERSATION_ANGEL = "SH04_Mission_Start_01" 
  390.  
  391. -- ************************* 
  392. -- 
  393. -- Standard functions 
  394. -- 
  395. -- ************************* 
  396.  
  397. -- This is the primary entry point for the mission, and is responsible for starting up the mission 
  398. -- at the specified checkpoint. 
  399. -- CALLED FROM CODE 
  400. -- 
  401. -- sh04_checkpoint:	The checkpoint the mission should begin at 
  402. -- is_restart:					TRUE if the mission is restarting, FALSE otherwise 
  403. -- 
  404. function sh04_start(sh04_checkpoint, is_restart) 
  405. 	 
  406. 	IS_RESTART = is_restart 
  407. 	-- Check if this mission starting from the beginning 
  408. 	if (sh04_checkpoint == CHECKPOINT_START) then 
  409. 		if (is_restart == false) then 
  410. 			-- First time playing mission 
  411. 			-- Play an intro cutscene??? 
  412. 			if (CUTSCENE_ENTRANCE ~= "") then 
  413. 				zscene_prep( CUTSCENE_ENTRANCE ) 
  414.  
  415. 				cutscene_play( CUTSCENE_ENTRANCE, nil, sh04_navs.cp_start, false ) 
  416. 				--sh04_play_entrance_cutscene() 
  417. 			end 
  418. 		else --is a restart, need to make sure all movers are reset 
  419. 			mesh_mover_reset_by_zone("3count_interior") 
  420. 		end 
  421. 		 
  422. 		fade_out(0) 
  423. 		sh04_setup_slots() 
  424. 	end 
  425.  
  426. 	character_ragdoll_set_last_resort_position( sh04_navs.cp_start[1] ) 
  427. 	 
  428. 	-- Handle mission initialization for the current checkpoint 
  429. 	sh04_initialize(sh04_checkpoint) 
  430.  
  431. 	-- Run the mission from the current checkpoint 
  432. 	sh04_run(sh04_checkpoint) 
  433. 	 
  434. end 
  435.  
  436. -- This is the primary function responsible for running the entire mission from start to finish. 
  437. -- 
  438. -- first_checkpoint:	The first checkpoint to begin running the mission at 
  439. -- 
  440. function sh04_run(first_checkpoint) 
  441. 	local current_checkpoint = first_checkpoint 
  442.  
  443. 	-- Run the mission from the beginning 
  444. 	if current_checkpoint == CHECKPOINT_START then 
  445. 		sh04_initial_cont_spawn() --set up continuous spawn guys during the damage portion 
  446. 		 
  447. 		sh04_convo(SH04_convo.start_convo) 
  448. 		delay(.5) 
  449. 		--delay so we don't play the dialog line on top of the convo 
  450. 		repeat  
  451. 			thread_yield()  
  452. 		until (sh04_status.convo_is_playing == false) 
  453. 			 
  454. 		--if there have been no slots killed yet, remind the player with a voice line 
  455. 		if SH04_destroyed_slots == 0 then 
  456. 			audio_play_persona_line( LOCAL_PLAYER, SH04_dialog_lines.do_damage ) 
  457. 		end 
  458. 		--delay(1) 
  459. 		 
  460. 		--tell angel to throw a grenade 
  461. 		force_throw(ANGEL_NO_MASK, "gren_throw" ) 
  462. 	 
  463. 		--sh04_attack_trigger() --spawn initial enemies and have them file in 
  464. 		sh04_wait_for_slots() 
  465. 		 
  466. 		--talk to pit boss 
  467. 		sh04_obj_manager() 
  468. 		 
  469. 		sh04_setup_vault_destination() 
  470. 		sh04_wait_on_reach_vault() 
  471. 		sh04_play_mask_cutscene()	 
  472. 		 
  473. 		mission_set_checkpoint( SH04_CHECKPOINT_MASK ) 
  474. 		current_checkpoint = SH04_CHECKPOINT_MASK 
  475. 	end 
  476.  
  477. 	if current_checkpoint == SH04_CHECKPOINT_MASK then 
  478. 		--sh04_convo(SH04_convo.vault_convo)	 
  479. 		--audio_play_persona_line( ANGEL_WITH_MASK, SH04_dialog_lines.put_on_mask )  --angel is complete!  
  480. 		--make sure the doors are open 
  481. 		door_open("left_door") 
  482. 		door_open("right_door") 
  483. 		 
  484. 		sh04_mark_statues() 
  485. 		sh04_create_backroom_guards() 
  486.  
  487. 		--sh04_create_post_cutscene_attack() 
  488. 		 
  489. 		delay(3.5) 
  490.  
  491. 		--sh04_convo(SH04_convo.destroy_convo) 
  492. 		--ai_suggest_action(ANGEL_WITH_MASK , "follow player" ) --have ANgel follow the player because he gets lost 
  493. 		 
  494. 		trigger_enable( SH04_TRIGGER_CONT_SPAWN, true ) 
  495. 		on_trigger( "sh04_cont_spawn", SH04_TRIGGER_CONT_SPAWN ) 
  496. 		 
  497. 		sh04_wait_on_statues_destroyed() 
  498. 		sh04_activate_continuous_spawns( false ) 
  499. 		 
  500. 		if( coop_is_active() == true ) then 
  501. 			--create the mini gun brute in co=op only 
  502. 			group_create( SH04_group.brute_g03.name )	 
  503. 			marker_add_script_group( SH04_group.brute_g03.name, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL ) 
  504. 			for i, enemy in pairs(SH04_group.brute_g03.members) do 
  505. 				on_death( "sh04_remaining_luchador_died", enemy ) 
  506. 				SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  507. 				move_to( enemy, SH04_BRUTE_DEST) 
  508. 			end 
  509. 		end 
  510. 		 
  511. 		sh04_mark_remaining_luchadors() 
  512. 		--sh04_setup_ambush() 
  513. 		sh04_wait_on_leftovers_killed() 
  514. 		 
  515. 		if Mission_successful == false then 
  516. 			objective_text( 0, SH04_BRUTES, nil, nil, SYNC_ALL, OI_ASSET_KILL ) 
  517. 		end 
  518. 		 
  519. 		while( Mission_successful == false ) do 
  520. 			thread_yield() 
  521. 		end 
  522. 		 
  523. 		objective_text_clear( 0 ) 
  524. 	end 
  525.  
  526. 	-- Call mission success 
  527. 	mission_end_success( "sh04" ) 
  528. end 
  529.  
  530. -- This is the primary function responsible for cleaning up the entire mission 
  531. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  532. -- 
  533. function sh04_cleanup() 
  534. 	--enable special slot if it was disabled due to having a sonic gun 
  535. 	inv_weapon_disable_slot(WEAPON_SLOT_SPECIAL, false, SYNC_ALL) 
  536. 	on_death( "", ANGEL_NO_MASK ) 
  537. 	on_dismiss( "", ANGEL_NO_MASK ) 
  538. 	on_death( "", ANGEL_WITH_MASK ) 
  539. 	on_dismiss( "", ANGEL_WITH_MASK ) 
  540. 	on_attack_performed("", ANGEL_NO_MASK) 
  541. 	on_attack_performed("", ANGEL_WITH_MASK) 
  542. 	on_character_grabbed("", SH04_group.casino_manager.members)  
  543. 	sh04_remove_markers() 
  544. 	sh04_clear_triggers() 
  545. 	--sh04_end_conversations() 
  546. 	sh04_stop_spawns() 
  547. 	sh04_kill_threads() 
  548. 	sh04_stop_failure_timers() 
  549. 	sh04_cleanup_groups( Mission_successful )	 
  550. 	cleanup_statues() 
  551. 	notoriety_set_min( "luchadores", 0 ) 
  552. 	notoriety_set_max( "police", 5 ) 
  553. 	notoriety_set_can_decay( true ) 
  554. 	on_random_mover_killed( "",  "sh04") 
  555. 	on_random_human_killed( "", "sh04") 
  556. 	 
  557. 	character_ragdoll_clear_last_resort_position() 
  558. 	 
  559. 	if SH04_group.casino_manager.id ~= -1 then 
  560. 		audio_persona_remove_2d(SH04_group.casino_manager.id)  
  561. 		SH04_group.casino_manager.id = -1 
  562. 	end 
  563. 	 
  564. 	hud_prompt_clear(LOCAL_PLAYER) 
  565. 	hud_prompt_clear(REMOTE_PLAYER) 
  566. 	 
  567. 	set_player_can_take_human_shields(LOCAL_PLAYER, true ) 
  568. 	if coop_is_active() == true then 
  569. 		set_player_can_take_human_shields(REMOTE_PLAYER, true ) 
  570. 	end 
  571. 	 
  572. end 
  573.  
  574. -- Called when the mission has ended with success 
  575. -- CALLED FROM CODE (+++MUST RETURN IMMEDIATLY+++) 
  576. -- 
  577. function sh04_success() 
  578. 	--[[ INSERT ANY MISSION SPECIFIC SUCCESS STUFF ]]-- 
  579. 	Mission_successful = true 
  580. 	 
  581. 	local skip_teleport = true 
  582. 	sh04_coop_skip(skip_teleport) 
  583. 	 
  584. 	teleport( LOCAL_PLAYER, sh04_navs.tele.plocal ) 
  585. 	if coop_is_active() == true then 
  586. 		teleport( REMOTE_PLAYER, sh04_navs.tele.premote ) 
  587. 	end 
  588. 	-- mission_successful = true 
  589. end 
  590.  
  591.  
  592. -- ************************* 
  593. -- 
  594. -- Local functions 
  595. -- 
  596. -- ************************* 
  597.  
  598. -- Initialize the mission for the specified checkpoint 
  599. -- 
  600. -- checkpoint:		Checkpoint to initialize the mission to 
  601. -- 
  602. function sh04_initialize(checkpoint) 
  603. 	-- Make sure the screen is completly faded out 
  604. 	mission_start_fade_out(0.0) 
  605.  
  606. 	-- Set the mission author 
  607. 	set_mission_author("Jimmy Cross") 
  608.  
  609. 	-- Common initialization 
  610. 	sh04_initialize_common() 
  611.  
  612. 	-- Checkpoint specific initialization 
  613. 	sh04_initialize_checkpoint(checkpoint) 
  614.  
  615. 	-- Start fading in  
  616. 	mission_start_fade_in() 
  617. end 
  618.  
  619.  
  620. -- *************************************************** 
  621. -- sh04_run Helper Functions 
  622. -- *************************************************** 
  623.  
  624. -- this function adds a conversation to the conversation queue. the conversation is played by the play convo thread 
  625. --  
  626. function sh04_convo( convo ) 
  627. 	if (convo == nil) then 
  628. 		return 
  629. 	end 
  630. 	 
  631. 	--convo is good, add it to the queue 
  632. 	sh04_queue[sh04_queue_size] = convo 
  633. 	sh04_queue_size = sh04_queue_size + 1 
  634.  
  635. end 
  636. -- This function doesn't continue until the entrance cutscene trigger is hit. 
  637. -- 
  638. function sh04_wait_until_entrance_cutscene_triggered() 
  639. 	while( Entrance_cutscene_triggered == false ) do 
  640. 		thread_yield() 
  641. 	end 
  642. end 
  643.  
  644. -- Plays the entrance cutscene and has the Luchadors attack the player after it runs. 
  645. -- 
  646. function sh04_play_entrance_cutscene() 
  647. 	zscene_prep( CUTSCENE_ENTRANCE ) 
  648. 	 
  649. 	cutscene_play( CUTSCENE_ENTRANCE ) 
  650. end 
  651.  
  652. -- Enables, adds a callback, and adds a marker to the specified trigger. 
  653. -- 
  654. -- callback: Function that the trigger should call when it's triggered. 
  655. -- trigger_name: Name of trigger to mark, enable, etc. 
  656. -- 
  657. function sh04_set_trigger_as_destination( callback, trigger_name ) 
  658. 		trigger_enable( trigger_name, true ) 
  659. 		on_trigger( callback, trigger_name ) 
  660. 		marker_add_trigger( trigger_name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  661. end 
  662.  
  663. function sh04_set_trigger(trigger, trigger_callback) 
  664. 	trigger_enable(trigger, true) 
  665. 	on_trigger(trigger_callback, trigger)	 
  666. end 
  667.  
  668. function sh04_disable_trigger(trigger)	 
  669. 	on_trigger("", trigger) 
  670. 	trigger_enable(trigger, false) 
  671. end 
  672.  
  673. function sh04_cont_spawn() 
  674. 	--activate continuois spawns 
  675. 	sh04_activate_continuous_spawns( true ) 
  676. 	 
  677. 	--spawn the various attackers that should file in from the stairs 
  678. 	sh04_create_post_cutscene_attack() 
  679. 	 
  680. 	--tell Angel to move to a point on the casino floor then make him independent 
  681. 	move_to_safe( ANGEL_WITH_MASK, SH04_group.casino_manager.dest, 3, false, false ) 
  682. 	--follower_make_independent(ANGEL_WITH_MASK, true) 
  683. 	 
  684. 	trigger_enable( SH04_TRIGGER_CONT_SPAWN, false ) 
  685. 	on_trigger( "", SH04_TRIGGER_CONT_SPAWN ) 
  686. end 
  687.  
  688. -- Activate the trigger that causes Angel to mention that he sees his mask. 
  689. -- 
  690. function sh04_activate_dialog_trigger() 
  691. 	trigger_enable( SH04_TRIGGER_UPSTAIRS, true ) 
  692. 	on_trigger( "sh04_setup_upstairs", SH04_TRIGGER_UPSTAIRS ) 
  693. end 
  694.  
  695. function sh04_create_backroom_guards() 
  696. 	group_create( SH04_group.backroom_guards.name ) 
  697. 	group_create( SH04_group.back_left.name ) 
  698. 	group_create( SH04_group.back_right.name ) 
  699. end 
  700.  
  701. function sh04_trigger_specialist_spawn() 
  702. 	if (group_is_loaded( SH04_group.backroom_specialist.name ) == false ) then 
  703. 		group_create( SH04_group.backroom_specialist.name ) 
  704. 	end 
  705. 	if coop_is_active() == true then 
  706. 		if (group_is_loaded( SH04_group.backroom_specialist_coop.name ) == false ) then 
  707. 			group_create( SH04_group.backroom_specialist_coop.name ) 
  708. 		end 
  709. 	end 
  710. end 
  711.  
  712. -- Sets up the Vault as the next destination. (Marks the entrance to the backroom and activates guidance and messages) 
  713. -- 
  714. function sh04_setup_vault_destination() 
  715.  
  716. 	objective_text_clear(0) 
  717. 	objective_text( 0, HELPTEXT_FIND_THE_VAULT, "", "", SYNC_ALL, OI_ASSET_LOCATION ) 
  718. 	 
  719. 	if SH04_group.casino_manager.thread ~= INVALID_THREAD_HANDLE then 
  720. 		thread_kill(SH04_group.casino_manager.thread) 
  721. 		SH04_group.casino_manager.thread = INVALID_THREAD_HANDLE 
  722. 	end 
  723. 	 
  724. 	if SH04_group.homies.thread ~= INVALID_THREAD_HANDLE then 
  725. 		thread_kill(SH04_group.homies.thread) 
  726. 		SH04_group.homies.thread = INVALID_THREAD_HANDLE 
  727. 	end 
  728. 	 
  729. 	character_set_can_take_human_shield( ANGEL_NO_MASK, true ) 
  730. 	--set_player_can_take_human_shields(ANGEL_NO_MASK, true)  
  731. 	set_player_can_take_human_shields(LOCAL_PLAYER, true ) 
  732. 	if coop_is_active() == true then 
  733. 		set_player_can_take_human_shields(REMOTE_PLAYER, true ) 
  734. 	end 
  735. 	 
  736. 	-- Activate the beginning of the guidance trigger chain 
  737. 	if( Hit_mask_cutscene == false ) then 
  738. 		trigger_enable( TRIGGER_TO_VAULT_001, true ) 
  739. 		on_trigger( "sh04_to_vault_001", TRIGGER_TO_VAULT_001 ) 
  740. 		marker_add( NAVPOINT_TO_VAULT_001, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  741.  
  742. 		-- Activate the end of the guidance chain in case the player skips ahead (but don't mark it) 
  743. 		trigger_enable( TRIGGER_TO_VAULT_002, true ) 
  744. 		on_trigger( "sh04_to_vault_002", TRIGGER_TO_VAULT_002 ) 
  745. 	end 
  746. end 
  747.  
  748. -- This function delays until the vault has been reached. 
  749. -- 
  750. function sh04_wait_on_reach_vault()	 
  751. 	delay(2) 
  752. 	--sh04_convo(SH04_convo.fight2vault) 
  753. 	 
  754. 	SH04_convo.fight2vault.handle = audio_conversation_load(SH04_convo.fight2vault.name) 
  755. 	-- Play the conversation 
  756. 	audio_conversation_play(SH04_convo.fight2vault.handle) 
  757.  
  758. 	-- Wait for the conversation to end 
  759. 	audio_conversation_wait_for_end(SH04_convo.fight2vault.handle) 
  760. 	SH04_convo.fight2vault.handle = INVALID_CONVERSATION_HANDLE 
  761. 	sh04_status.convo_is_playing = false 
  762. 	 
  763. 	while ( Hit_mask_cutscene == false ) do 
  764. 		thread_yield() 
  765. 	end 
  766.  
  767. 	-- We've reached the vault, so stop the objective text 
  768. 	objective_text_clear( 0 ) 
  769. end 
  770.  
  771. function sh04_wait_for_slots() 
  772. 	while( SH04_slot_obj == false ) do 
  773. 		thread_yield() 
  774. 	end 
  775. 	hud_bar_off( 0 ) 
  776.  
  777. end 
  778.  
  779. -- This function sets up the cutscene, plays it, and sets up the situation afterward. 
  780. -- 
  781. function sh04_play_mask_cutscene() 
  782. 	fade_out(0) 
  783. 	fade_out_block() 
  784. 	cutscene_in() 
  785.  
  786. 	group_create( SH04_group.CTE_cutscene.name) 
  787. 	group_create( SH04_group.CTE_angel_mask.name) 
  788. 	--inv_item_remove_all( SH04_group.CTE_cutscene.members[1] ) 
  789. 	--inv_item_remove_all( SH04_group.CTE_angel_mask.members[1] ) 
  790. 	--inv_item_remove_all( ANGEL_NO_MASK ) 
  791. 	follower_set_can_abandon( ANGEL_NO_MASK, false ) 
  792. 	on_dismiss( "", ANGEL_NO_MASK ) 
  793. 	party_dismiss( ANGEL_NO_MASK ) 
  794. 	character_hide( ANGEL_NO_MASK ) 
  795.  
  796. 	cutscene_play( CUTSCENE_TAKE_MASK, nil, sh04_navs.post_cte, false ) 
  797. 	 
  798. 	--teleport_coop( POST_MASK_CHECKPOINT_WARP_LOCATIONS[LOCAL_PLAYER], POST_MASK_CHECKPOINT_WARP_LOCATIONS[REMOTE_PLAYER], true ) 
  799. 	character_show( ANGEL_WITH_MASK ) 
  800. 	party_add( ANGEL_WITH_MASK, LOCAL_PLAYER ) 
  801. 	--teleport( ANGEL_WITH_MASK, NAVPOINT_PICK_UP_MASK_LOCATION ) 
  802. 	group_destroy( SH04_group.CTE_cutscene.name ) 
  803. 	group_destroy( SH04_group.CTE_angel_mask.name )	 
  804. 	cutscene_out() 
  805. 	fade_in(0) 
  806. 	fade_in_block() 
  807.  
  808. 	--action_play( ANGEL_WITH_MASK, ANIMATION_FINISH_PUTTING_ON_MASK ) 
  809. 	follower_set_can_abandon( ANGEL_WITH_MASK, true ) 
  810. end 
  811.  
  812. function sh04_setup_ambush() 
  813. 	if group_is_loaded( SH04_group.initial_luchadors.members ) == true then 
  814. 		for index, member in pairs( SH04_group.initial_luchadors.members ) do 
  815. 			if ( character_is_dead( member ) == false ) then 
  816. 				--npc_leash_remove( member ) 
  817. 				set_always_sees_player_flag( member, true ) 
  818. 				ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  819. 				--ai_do_scripted_move( member, LOCAL_PLAYER, true, true ) 
  820. 				set_attack_player_flag( member, true ) 
  821. 			end 
  822. 		end 
  823. 	end 
  824. 	 
  825. 	if( group_is_loaded( SH04_group.coop_initial_luchadors.name ) ) then 
  826. 		for index, member in pairs( SH04_group.coop_initial_luchadors.members ) do 
  827. 			if ( character_is_dead( member ) == false ) then 
  828. 				--npc_leash_remove( member ) 
  829. 				set_always_sees_player_flag( member, true ) 
  830. 				ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  831. 				--ai_do_scripted_move( member, LOCAL_PLAYER, true, true ) 
  832. 				set_attack_player_flag( member, true ) 
  833. 			end 
  834. 		end 
  835. 	end 
  836. 	 
  837. 	if group_is_loaded( SH04_group.right_room.name ) == true then 
  838. 		for index, member in pairs( SH04_group.right_room.name ) do 
  839. 			if ( character_is_dead( member ) == false ) then 
  840. 				--npc_leash_remove( member ) 
  841. 				set_always_sees_player_flag( member, true ) 
  842. 				ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  843. 				--ai_do_scripted_move( member, LOCAL_PLAYER, true, true ) 
  844. 				set_attack_player_flag( member, true ) 
  845. 			end 
  846. 		end 
  847. 	end 
  848. 	 
  849. 	if( group_is_loaded( SH04_group.alpha_squad.name ) ) then 
  850. 		for index, member in pairs( SH04_group.alpha_squad.members ) do 
  851. 			if ( character_is_dead( member ) == false ) then 
  852. 				--npc_leash_remove( member ) 
  853. 				set_always_sees_player_flag( member, true ) 
  854. 				ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  855. 				--ai_do_scripted_move( member, LOCAL_PLAYER, true, true ) 
  856. 				set_attack_player_flag( member, true ) 
  857. 			end 
  858. 		end 
  859. 	end 
  860. 	 
  861. 	if( group_is_loaded( SH04_group.beta_squad.name ) ) then 
  862. 		for index, member in pairs( SH04_group.beta_squad.members ) do 
  863. 			if ( character_is_dead( member ) == false ) then 
  864. 				--npc_leash_remove( member ) 
  865. 				set_always_sees_player_flag( member, true ) 
  866. 				ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  867. 				--ai_do_scripted_move( member, LOCAL_PLAYER, true, true ) 
  868. 				set_attack_player_flag( member, true ) 
  869. 			end 
  870. 		end 
  871. 	end 
  872. 	 
  873. 	if( group_is_loaded( SH04_group.post_mask_attackers.name ) ) then 
  874. 		for index, member in pairs( SH04_group.post_mask_attackers.members ) do 
  875. 			if ( character_is_dead( member ) == false ) then 
  876. 				--npc_leash_remove( member ) 
  877. 				set_always_sees_player_flag( member, true ) 
  878. 				ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  879. 				--ai_do_scripted_move( member, LOCAL_PLAYER, true, true ) 
  880. 				set_attack_player_flag( member, true ) 
  881. 			end 
  882. 		end 
  883. 	end 
  884. 	 
  885. 	if( group_is_loaded( SH04_group.back_left.name ) ) then 
  886. 		for index, member in pairs( SH04_group.back_left.members ) do 
  887. 			if ( character_is_dead( member ) == false ) then 
  888. 				--npc_leash_remove( member ) 
  889. 				set_always_sees_player_flag( member, true ) 
  890. 				ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  891. 				--ai_do_scripted_move( member, LOCAL_PLAYER, true, true ) 
  892. 				set_attack_player_flag( member, true ) 
  893. 			end 
  894. 		end 
  895. 	end 
  896. 	 
  897. 	if( group_is_loaded( SH04_group.back_right.name ) ) then 
  898. 		for index, member in pairs( SH04_group.back_right.members ) do 
  899. 			if ( character_is_dead( member ) == false ) then 
  900. 				--npc_leash_remove( member ) 
  901. 				set_always_sees_player_flag( member, true ) 
  902. 				ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  903. 				--ai_do_scripted_move( member, LOCAL_PLAYER, true, true ) 
  904. 				set_attack_player_flag( member, true ) 
  905. 			end 
  906. 		end 
  907. 	end 
  908.  
  909. end 
  910.  
  911. -- This function marks the initial luchadors as targets and adds death callbacks to them. 
  912. -- Something of a misunderstanding, but I decided to leave it in. 
  913. -- 
  914. function sh04_mark_remaining_luchadors() 
  915. --	SH04_num_remaining_luchadors = 0 
  916. 	if( group_is_loaded( SH04_group.initial_luchadors.name ) ) then 
  917. 		for index, member in pairs( SH04_group.initial_luchadors.members ) do 
  918. 			if ( character_is_dead( member ) == false ) then 
  919. 				marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  920. 				--marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  921. 				on_death( "sh04_remaining_luchador_died", member ) 
  922. 				SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  923. 				set_always_sees_player_flag( member, true ) 
  924. 				set_attack_player_flag( member, true ) 
  925. 			end 
  926. 		end 
  927. 	end 
  928. 	 
  929. 	if( group_is_loaded( SH04_group.coop_initial_luchadors.name ) ) then 
  930. 		for index, member in pairs( SH04_group.coop_initial_luchadors.members ) do 
  931. 			if ( character_is_dead( member ) == false ) then 
  932. 				marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  933. 				--marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  934. 				on_death( "sh04_remaining_luchador_died", member ) 
  935. 				SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  936. 				set_always_sees_player_flag( member, true ) 
  937. 				set_attack_player_flag( member, true ) 
  938. 			end 
  939. 		end 
  940. 	end 
  941. 	 
  942. 	if ( character_is_dead( SH04_group.brute_g01.members ) == false ) then 
  943. 		marker_add( SH04_group.brute_g01.members, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL ) 
  944. 		on_death( "sh04_remaining_luchador_died", SH04_group.brute_g01.members ) 
  945. 		SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  946. 	end 
  947. 	 
  948. 	if ( character_is_dead( SH04_group.backroom_specialist.members ) == false ) then 
  949. 		marker_add( SH04_group.backroom_specialist.members, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  950. 		on_death( "sh04_remaining_luchador_died", SH04_group.backroom_specialist.members ) 
  951. 		SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  952. 		set_always_sees_player_flag( SH04_group.backroom_specialist.members, true ) 
  953. 		set_attack_player_flag( SH04_group.backroom_specialist.members, true ) 
  954. 	end 
  955. 	 
  956. 	if( group_is_loaded( SH04_group.backroom_specialist_coop.name ) ) then 
  957. 		if ( character_is_dead( SH04_group.backroom_specialist_coop.members ) == false ) then 
  958. 			marker_add( SH04_group.backroom_specialist_coop.members, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  959. 			on_death( "sh04_remaining_luchador_died", SH04_group.backroom_specialist_coop.members ) 
  960. 			SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  961. 			set_always_sees_player_flag( SH04_group.backroom_specialist_coop.members, true ) 
  962. 			set_attack_player_flag( SH04_group.backroom_specialist_coop.members, true ) 
  963. 		end 
  964. 	end 
  965. 	 
  966. 	if( group_is_loaded( SH04_group.right_door.name ) ) then 
  967. 		for index, member in pairs( SH04_group.right_door.members ) do 
  968. 			if ( character_is_dead( member ) == false ) then 
  969. 				marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  970. 				--marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  971. 				on_death( "sh04_remaining_luchador_died", member ) 
  972. 				SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  973. 				set_always_sees_player_flag( member, true ) 
  974. 				set_attack_player_flag( member, true ) 
  975. 			end 
  976. 		end 
  977. 	end 
  978. 	 
  979. 	if( group_is_loaded( SH04_group.left_door.name ) ) then 
  980. 		for index, member in pairs( SH04_group.left_door.members ) do 
  981. 			if ( character_is_dead( member ) == false ) then 
  982. 				marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  983. 				--marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  984. 				on_death( "sh04_remaining_luchador_died", member ) 
  985. 				SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  986. 				set_always_sees_player_flag( member, true ) 
  987. 				set_attack_player_flag( member, true ) 
  988. 			end 
  989. 		end 
  990. 	end 
  991. 	 
  992. 	if( group_is_loaded( SH04_group.alpha_squad.name ) ) then 
  993. 		for index, member in pairs( SH04_group.alpha_squad.members ) do 
  994. 			if ( character_is_dead( member ) == false ) then 
  995. 				marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  996. 				--marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  997. 				on_death( "sh04_remaining_luchador_died", member ) 
  998. 				SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  999. 				set_always_sees_player_flag( member, true ) 
  1000. 				set_attack_player_flag( member, true ) 
  1001. 			end 
  1002. 		end 
  1003. 	end 
  1004. 	 
  1005. 	if( group_is_loaded( SH04_group.beta_squad.name ) ) then 
  1006. 		for index, member in pairs( SH04_group.beta_squad.members ) do 
  1007. 			if ( character_is_dead( member ) == false ) then 
  1008. 				marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  1009. 				on_death( "sh04_remaining_luchador_died", member ) 
  1010. 				SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  1011. 				set_always_sees_player_flag( member, true ) 
  1012. 				set_attack_player_flag( member, true ) 
  1013. 			end 
  1014. 		end 
  1015. 	end 
  1016. 	 
  1017. 	if( group_is_loaded( SH04_group.post_mask_attackers.name ) ) then 
  1018. 		for index, member in pairs( SH04_group.post_mask_attackers.members ) do 
  1019. 			if ( character_is_dead( member ) == false ) then 
  1020. 				marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  1021. 				on_death( "sh04_remaining_luchador_died", member ) 
  1022. 				SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  1023. 				set_always_sees_player_flag( member, true ) 
  1024. 				set_attack_player_flag( member, true ) 
  1025. 			end 
  1026. 		end 
  1027. 	end 
  1028. 	 
  1029. 	if( group_is_loaded( SH04_group.back_left.name ) ) then 
  1030. 		for index, member in pairs( SH04_group.back_left.members ) do 
  1031. 			if ( character_is_dead( member ) == false ) then 
  1032. 				marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  1033. 				on_death( "sh04_remaining_luchador_died", member ) 
  1034. 				SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  1035. 				set_always_sees_player_flag( member, true ) 
  1036. 				set_attack_player_flag( member, true ) 
  1037. 			end 
  1038. 		end 
  1039. 	end 
  1040. 	 
  1041. 	if( group_is_loaded( SH04_group.back_right.name ) ) then 
  1042. 		for index, member in pairs( SH04_group.back_right.members ) do 
  1043. 			if ( character_is_dead( member ) == false ) then 
  1044. 				marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  1045. 				on_death( "sh04_remaining_luchador_died", member ) 
  1046. 				SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  1047. 				set_always_sees_player_flag( member, true ) 
  1048. 				set_attack_player_flag( member, true ) 
  1049. 			end 
  1050. 		end 
  1051. 	end 
  1052. 	 
  1053. 	if( group_is_loaded( SH04_group.ambush.name ) ) then 
  1054. 		for index, member in pairs( SH04_group.ambush.members ) do 
  1055. 			if ( character_is_dead( member ) == false ) then 
  1056. 				marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  1057. 				on_death( "sh04_remaining_luchador_died", member ) 
  1058. 				SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  1059. 				set_always_sees_player_flag( member, true ) 
  1060. 				set_attack_player_flag( member, true ) 
  1061. 			end 
  1062. 		end 
  1063. 	end 
  1064. 	--[[ 
  1065. 	for index, member in pairs( SH04_group.cont_spawn_a.members ) do 
  1066. 		if ( character_is_dead( member ) == false ) then 
  1067. 			marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  1068. 			on_death( "sh04_remaining_luchador_died", member ) 
  1069. 			SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  1070. 		end 
  1071. 	end 
  1072. 	for index, member in pairs( SH04_group.cont_spawn_b.members ) do 
  1073. 		if ( character_is_dead( member ) == false ) then 
  1074. 			marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  1075. 			on_death( "sh04_remaining_luchador_died", member ) 
  1076. 			SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  1077. 		end 
  1078. 	end 
  1079. 	for index, member in pairs( SH04_group.cont_spawn_c.members ) do 
  1080. 		if ( character_is_dead( member ) == false ) then 
  1081. 			marker_add( member, MINIMAP_ICON_KILL, OI_ASSET_KILL, OI_FLAGS_DEFAULT, SYNC_ALL ) 
  1082. 			on_death( "sh04_remaining_luchador_died", member ) 
  1083. 			SH04_num_remaining_luchadors = SH04_num_remaining_luchadors + 1 
  1084. 		end 
  1085. 	end 
  1086. 	]]-- 
  1087. 	SH04_NUMBER_LUCHADORES = SH04_num_remaining_luchadors 
  1088. 	objective_text( 0, HELPTEXT_DESTROY_LUCHADORES, nil, nil, SYNC_ALL, OI_ASSET_KILL ) 
  1089. 	 
  1090. 	audio_play_persona_line( LOCAL_PLAYER, SH04_dialog_lines.clean_house ) 
  1091. end 
  1092.  
  1093. -- Creates the group that waits at the exit of the vault before the continuous spawn has had a 
  1094. -- chance to start. 
  1095. -- 
  1096. function sh04_create_post_cutscene_attack() 
  1097. 	group_create( SH04_group.post_mask_attackers.name ) 
  1098. 	 
  1099. 	for index, char in pairs( SH04_group.post_mask_attackers.members ) do 
  1100. 		on_attack_performed("sh04_attack_line_cb", char) 
  1101. 	end 
  1102. end 
  1103.  
  1104. -- Marks statues of Killbane as targets and adds destruction callbacks and number tracking to them. 
  1105. -- 
  1106. function sh04_mark_statues() 
  1107. 	SH04_num_remaining_statues = 0 
  1108. 	sh04_convo( SH04_convo.destroy_statues_convo ) 
  1109. 	--marker_add_script_group( SH04_killbane_statues, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL ) 
  1110. 	 
  1111. 	--[[ 
  1112. 	for i, trigger in pairs(sh04_objectives.statues.members) do 
  1113. 		if sh04_objectives.statues.status[i] == false then 
  1114. 			sh04_set_trigger( trigger, "sh04_hit_trigger" ) 
  1115. 		end 
  1116. 	end 
  1117. 	]]-- 
  1118. 	 
  1119. 	for index, statue in pairs( SH04_killbane_statues ) do 
  1120. 		marker_add( statue, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL ) --OI_FLAGS_DEFAULT + OI_FLAG_FADE  
  1121. 		mesh_mover_set_invulnerable( statue, false ) 
  1122. 		on_mover_destroyed( "sh04_statue_died", statue ) 
  1123. 		SH04_num_remaining_statues = SH04_num_remaining_statues + 1 
  1124. 	end 
  1125. 	 
  1126. 	SH04_original_num_statues = SH04_num_remaining_statues; 
  1127. 	objective_text( 0, HELPTEXT_DESTROY_STATUES, 0, SH04_original_num_statues, SYNC_ALL, OI_ASSET_KILL ) 
  1128. end 
  1129.  
  1130. function sh04_setup_slots() 
  1131. 	on_random_mover_killed( "sh04_slot_died",  "sh04") 
  1132. 	 
  1133. 	--create initial groups 
  1134. 	group_create( SH04_group.initial_luchadors.name, true ) 
  1135. 	if  coop_is_active() == true then 
  1136. 		group_create(SH04_group.coop_initial_luchadors.name, true ) 
  1137. 	end 
  1138. 	group_create( SH04_group.first_specialist.name, true ) 
  1139. 	group_create( SH04_group.right_door.name, true ) 
  1140. 	group_create( SH04_group.left_door.name, true )	 
  1141. 	 
  1142. 	--create the manager and set him up 
  1143. 	group_create( SH04_group.casino_manager.name, true ) 
  1144. 	SH04_group.casino_manager.id = audio_persona_load_2d("Interrogation") --persona for the manager's lines are in the interrogation persona 
  1145. 	turn_invulnerable( SH04_group.casino_manager.members ) 
  1146. 	character_set_counter_on_grabbed( SH04_group.casino_manager.members, true ) 
  1147. 	 
  1148. 	if( coop_is_active() ) then 
  1149. 		SH04_TOTAL_DAMAGE = 200 
  1150. 	end 
  1151. 	--objective_text( 0, HELPTEXT_DESTROY_STATUES, 0, SH04_original_num_statues, SYNC_ALL, OI_ASSET_KILL ) 
  1152. 	hud_bar_on( 0, "Default", SH04_DAMAGE, SH04_TOTAL_DAMAGE, SYNC_ALL )  
  1153. 	 
  1154. 	notoriety_set_max( "luchadores", SH04_MIN_NOTORIETY ) 
  1155. 	notoriety_set("luchadores", SH04_MIN_NOTORIETY) 
  1156. 	notoriety_set_can_decay(false) 
  1157. 	notoriety_set_max( "police", 0 ) 
  1158. 	 
  1159. end 
  1160.  
  1161. -- Activates the continuous spawns during the Killbane statue sequence. 
  1162. -- 
  1163. function sh04_activate_continuous_spawns( activate ) 
  1164. 	--shut down spawns if the statues are gone 
  1165. 	if activate == false then 
  1166. 		continuous_spawn_stop(SH04_group.cont_spawn_c.name, true) 
  1167. 		continuous_spawn_stop(SH04_group.cont_spawn_d.name, true) 
  1168. 		continuous_spawn_regions_enable( CONTINUOUS_SPAWN_POINTS, activate ) 
  1169. 		if SH04_THREAD_SPAWN_SECOND_SQUAD ~= INVALID_THREAD_HANDLE then 
  1170. 			thread_kill(SH04_THREAD_SPAWN_SECOND_SQUAD) 
  1171. 		end 
  1172. 	elseif activate == true then 
  1173. 		continuous_spawn_regions_enable( CONTINUOUS_SPAWN_POINTS, activate ) 
  1174. 		continuous_spawn_start( SH04_group.cont_spawn_c.name, 5, SH04_NORMAL_SQUAD_RESPAWN_DELAY_SECONDS ) 
  1175. 		--delay( SH04_SPECIALIST_SPAWN_DELAY_SECONDS  ) 
  1176. 		continuous_spawn_start( SH04_group.cont_spawn_d.name, 5, SH04_NORMAL_SQUAD_RESPAWN_DELAY_SECONDS+SH04_SPECIALIST_SPAWN_DELAY_SECONDS ) 
  1177. 	end 
  1178. end 
  1179.  
  1180. -- This function waits until the statues of Killbane are destroyed before continuing. 
  1181. -- 
  1182. function sh04_wait_on_statues_destroyed() 
  1183.  
  1184. 	trigger_enable( SH04_TRIGGER_UPSTAIRS, true ) 
  1185. 	on_trigger( "sh04_setup_upstairs", SH04_TRIGGER_UPSTAIRS ) 
  1186. 	 
  1187. 	trigger_enable( SH04_TRIGGER_ALPHA, true ) 
  1188. 	on_trigger( "sh04_setup_alpha", SH04_TRIGGER_ALPHA ) 
  1189. 	 
  1190. 	trigger_enable( SH04_TRIGGER_BETA, true ) 
  1191. 	on_trigger( "sh04_setup_beta", SH04_TRIGGER_BETA ) 
  1192. 	 
  1193. 	while ( SH04_num_remaining_statues > 0 ) do 
  1194. 		thread_yield() 
  1195. 	end 
  1196. 	 
  1197. 	--on_mover_destroyed( "", statue ) 
  1198. 	 
  1199. 	-- We've destroyed all statues, so stop the objective text 
  1200. 	objective_text_clear( 0 ) 
  1201. end 
  1202.  
  1203. function sh04_wait_on_leftovers_killed()	 
  1204. 	while ( SH04_num_remaining_luchadors > 0 ) do 
  1205. 		if( SH04_num_remaining_luchadors <= 2 )  and sh04_spawn_brutes then 
  1206. 			--set up brutes 
  1207. 			sh04_brute_finale() 
  1208. 		end 
  1209. 		thread_yield() 
  1210. 	end 
  1211. 	 
  1212. 	--need to make sure the brutes were spawned since it's possible to kill all the enemies before this function is called 
  1213. 	if sh04_spawn_brutes == true then 
  1214. 		--set up brutes 
  1215. 		sh04_brute_finale() 
  1216. 	end 
  1217.  
  1218. 	-- We've destroyed all dudes, so stop the objective text 
  1219. 	objective_text_clear( 0 ) 
  1220. end 
  1221.  
  1222. -- start the continuous spawns that are active during the destruction objective 
  1223. -- 
  1224. function sh04_initial_cont_spawn()	 
  1225. 	continuous_spawn_regions_enable( SH04_INIT_SPAWN_POINTS, true ) 
  1226. 	continuous_spawn_start( SH04_group.cont_spawn_a.name, 4, SH04_INT_CONT_SPAWN_TIME ) 
  1227. 	continuous_spawn_start( SH04_group.cont_spawn_b.name, 4, SH04_INT_CONT_SPAWN_TIME ) 
  1228. end 
  1229.  
  1230. function sh04_obj_manager() 
  1231. 	local display = false 
  1232. 	on_random_mover_killed( "",  "sh04") 
  1233. 	 
  1234. 	--stop continuous spawns 
  1235. 	continuous_spawn_regions_enable( SH04_INIT_SPAWN_POINTS, false ) 
  1236. 	continuous_spawn_stop(SH04_group.cont_spawn_a.name, true) 
  1237. 	continuous_spawn_stop(SH04_group.cont_spawn_b.name, true) 
  1238. 	 
  1239. 	--create manager 
  1240. 	--group_show( SH04_group.casino_manager.name ) 
  1241. 	--character_set_counter_on_grabbed( SH04_group.casino_manager.members, true ) 
  1242. 	marker_add( SH04_group.casino_manager.members, MINIMAP_ICON_USE, OI_ASSET_USE, OI_FLAG_STICKY + OI_FLAG_DISPLAY_DISTANCE, SYNC_ALL) 
  1243. 	--on_character_grabbed("sh04_manager_interrogation_cb", SH04_group.casino_manager.members)  
  1244. 	 
  1245. 	--thread for the manager to seek out the player 
  1246. 	SH04_group.casino_manager.thread = thread_new( "sh04_move_manager" ) 
  1247. 	 
  1248. 	--objective text, talk to the manager 
  1249. 	objective_text_clear( 0 ) 
  1250. 	objective_text( 0, SH04_MANAGER, nil, nil, SYNC_ALL, OI_ASSET_USE ) 
  1251.  
  1252. 	--wait until the player gets close to the manager 
  1253. 	while (get_dist_closest_player_to_object( SH04_group.casino_manager.members ) > 20 )  or ( character_is_ragdolled(SH04_group.casino_manager.members) )  do 
  1254. 		thread_yield()  
  1255. 	end 
  1256.  
  1257. 	--you're seen the manager, say something 
  1258. 	sh04_convo( SH04_convo.see_manager ) 
  1259.  
  1260. 	npc_go_idle(ANGEL_NO_MASK) 
  1261. 	ai_suggest_action(ANGEL_NO_MASK, "follow player" ) 
  1262. 	 
  1263. 	set_player_can_take_human_shields(LOCAL_PLAYER, false ) 
  1264. 	if coop_is_active() == true then 
  1265. 		set_player_can_take_human_shields(REMOTE_PLAYER, false ) 
  1266. 	end 
  1267. 	 
  1268. 	display = false 
  1269. 	local dist 
  1270. 	while SH04_INTERROGATION == false do --need to repeat until the interrogation is started 
  1271. 		--thread_yield() 
  1272. 		dist, SH04_INTERROGATE_PLAYER = get_dist_closest_player_to_object( SH04_group.casino_manager.members )  
  1273. 		 
  1274. 		--check if the player is inside the display range && the display is not on 
  1275. 		if get_dist_closest_player_to_object( SH04_group.casino_manager.members ) <= 2 and display == false and character_is_ragdolled(SH04_group.casino_manager.members) == false then 
  1276. 			dist, SH04_INTERROGATE_PLAYER = get_dist_closest_player_to_object( SH04_group.casino_manager.members ) 
  1277. 			hud_prompt(SH04_INTERROGATE_PLAYER, "SH04_MSG_GRAB", "sh04_grab_manager_local") --sh04_grab_manager_local 
  1278. 			display = true 
  1279. 			 
  1280. 			--allow grabbing now 
  1281. 			character_set_counter_on_grabbed( SH04_group.casino_manager.members , false ) 
  1282. 		end 
  1283. 		 
  1284. 		--check if the player is outside the display range or the manager is ragdolled 
  1285. 		if( (get_dist_closest_player_to_object( SH04_group.casino_manager.members ) > 2 or character_is_ragdolled(SH04_group.casino_manager.members) == true) and display == true ) then 
  1286. 			dist, SH04_INTERROGATE_PLAYER = get_dist_closest_player_to_object( SH04_group.casino_manager.members ) 
  1287. 			hud_prompt_clear(SH04_INTERROGATE_PLAYER) 
  1288. 			display = false 
  1289. 			 
  1290. 			--disallow grabbing now 
  1291. 			character_set_counter_on_grabbed( SH04_group.casino_manager.members , true ) 
  1292. 		end 
  1293. 		 
  1294. 		delay(.1) 
  1295. 		 
  1296. 	end 
  1297. 	 
  1298. 	repeat thread_yield() until SH04_INTERROGATION_COMPLETE == true 
  1299. 	 
  1300. 	marker_remove(SH04_group.casino_manager.members, SYNC_ALL) 
  1301. 	ai_suggest_action(ANGEL_NO_MASK , "follow player" )	 
  1302. 	on_character_grabbed("", SH04_group.casino_manager.members)  
  1303. 	 
  1304. end 
  1305.  
  1306. function sh04_grab_manager_local() 
  1307.  
  1308. 	--tell angel to move to the player so he's around to threaten the manager 
  1309. 	SH04_group.homies.thread = thread_new( "sh04_move_angel" ) 
  1310.  
  1311. 	clear_animation_state( SH04_group.casino_manager.members ) 
  1312. 	 
  1313. 	--clear the prompt 
  1314. 	SH04_INTERROGATION = true 	 
  1315. 	hud_prompt_clear(LOCAL_PLAYER) 
  1316. 	hud_prompt_clear(REMOTE_PLAYER) 
  1317. 	 
  1318. 	--so the player and the manager can't be separated 
  1319. 	character_set_no_explosive_panic( SH04_group.casino_manager.members, true ) 
  1320. 	character_set_no_explosive_panic( SH04_INTERROGATE_PLAYER, true ) 
  1321. 	 
  1322. 	--the interrogation animations work best with certain inventory sets, so set one of them	 
  1323. 	local weapon 
  1324. 	weapon = inv_item_in_slot(SH04_INTERROGATE_PLAYER, "rifle") 
  1325. 	inv_item_equip(weapon, SH04_INTERROGATE_PLAYER) 
  1326. 	 
  1327. 	--player_take_human_shield(SH04_INTERROGATE_PLAYER, SH04_group.casino_manager.members, false) 
  1328. 	 
  1329. 	--delay until the human shield is registered. this seems stupid but for some reason is necessary for timings... 
  1330. 	while character_has_specific_human_shield(SH04_INTERROGATE_PLAYER, SH04_group.casino_manager.members) == false do 
  1331. 		player_take_human_shield(SH04_INTERROGATE_PLAYER, SH04_group.casino_manager.members, false) 
  1332. 		thread_yield() 
  1333. 	end 
  1334. 	 
  1335. 	--disable ragdolling so things don't mess up 
  1336. 	character_allow_ragdoll(SH04_INTERROGATE_PLAYER, false) 
  1337. 	character_allow_ragdoll(SH04_group.casino_manager.members, false) 
  1338. 	 
  1339. 	-- Block controls until the interrogation is complete 
  1340. 	player_human_shield_lock(SH04_INTERROGATE_PLAYER, true) 
  1341. 	 
  1342. 	delay(1) 
  1343. 	 
  1344. 	--animations 
  1345. 	action_play_synced_state(SH04_INTERROGATE_PLAYER, SH04_group.casino_manager.members, "Gat Interrogation State") 
  1346. 	action_play_synced(SH04_INTERROGATE_PLAYER, SH04_group.casino_manager.members, "Gat Interrogation Entry") 
  1347. 	 
  1348. 	set_ignore_ai_flag(ANGEL_NO_MASK, true) --so angel doesn't act like a dumbass and shoot enemies 
  1349. 	 
  1350. 	--sh04_convo( SH04_convo.threaten_manager ) 
  1351. 	if (sh04_status.convo_is_playing) then 
  1352. 		repeat  
  1353. 			thread_yield()  
  1354. 		until (sh04_status.convo_is_playing == false) 
  1355. 	end 
  1356. 	 
  1357. 	delay(.25) 
  1358. 	 
  1359. 	SH04_convo.threaten_manager.handle = audio_conversation_load_direct(SH04_convo.threaten_manager.name) 
  1360. 	 
  1361. 	-- Play the conversation. This isn't played in the queue because I need the exact timing for the animation states 
  1362. 	audio_conversation_play(SH04_convo.threaten_manager.handle) 
  1363. 	 
  1364. 	--enable the vault trigger, safety net in case the player interrogates back there 
  1365. 	trigger_enable( TRIGGER_MASK_CUTSCENE, true ) 
  1366. 	on_trigger( "sh04_hit_mask_cutscene", TRIGGER_MASK_CUTSCENE ) 
  1367.  
  1368. 	-- Wait for the conversation to end 
  1369. 	audio_conversation_wait_for_end(SH04_convo.threaten_manager.handle) 
  1370. 	SH04_convo.threaten_manager.handle = INVALID_CONVERSATION_HANDLE 
  1371. 	sh04_status.convo_is_playing = false 
  1372. 	 
  1373. 	--re-enable stuff 
  1374. 	turn_vulnerable( SH04_group.casino_manager.members ) 
  1375.  
  1376. 	--action_play_synced_state(SH04_INTERROGATE_PLAYER, SH04_group.casino_manager.members, "Gat Interrogation Return" ) 
  1377. 	action_play_synced_state(SH04_INTERROGATE_PLAYER, SH04_group.casino_manager.members, "HS_Stand") 
  1378. 	action_play_synced(SH04_INTERROGATE_PLAYER, SH04_group.casino_manager.members, "Gat Interrogation Return") 
  1379. 	 
  1380. 	character_set_no_explosive_panic( SH04_group.casino_manager.members, false ) 
  1381. 	character_set_no_explosive_panic( SH04_INTERROGATE_PLAYER, false ) 
  1382. 	character_allow_ragdoll(SH04_INTERROGATE_PLAYER, true) 
  1383. 	character_allow_ragdoll(SH04_group.casino_manager.members, true) 
  1384. 	 
  1385. 	set_ignore_ai_flag(ANGEL_NO_MASK, false) --end dumbass lock 
  1386. 	player_human_shield_lock(SH04_INTERROGATE_PLAYER, false) 
  1387. 	 
  1388. 	while not action_play_is_finished(SH04_INTERROGATE_PLAYER) do 
  1389. 		thread_yield() 
  1390. 	end 
  1391. 	 
  1392. 	--action_stop_synced_state(SH04_INTERROGATE_PLAYER) 
  1393. 	player_release_human_shield(SH04_INTERROGATE_PLAYER, true, false) 
  1394. 	 
  1395. 	SH04_INTERROGATION_COMPLETE = true 
  1396. end 
  1397.  
  1398. function sh04_manager_interrogation_cb( victim, attacker ) 
  1399.  
  1400. 	if attacker ~= LOCAL_PLAYER and attacker ~= REMOTE_PLAYER then 
  1401. 		return 
  1402. 	end 
  1403. 	 
  1404. 	clear_animation_state( SH04_group.casino_manager.members ) 
  1405. 	 
  1406. 	--the interrogation animations work best with certain inventory sets, so set one of them	 
  1407. 	local weapon 
  1408. 	weapon = inv_item_in_slot(attacker, "rifle") 
  1409. 	inv_item_equip(weapon, attacker) 
  1410. 	 
  1411. 	SH04_INTERROGATION = true --in case weird stuff happened and the prompt didn't get triggered 
  1412. 	 
  1413. 	hud_prompt_clear(SH04_INTERROGATE_PLAYER) 
  1414. 	 
  1415. 	--disable ragdolling so things don't mess up 
  1416. 	character_allow_ragdoll(SH04_INTERROGATE_PLAYER, false) 
  1417. 	character_allow_ragdoll(SH04_group.casino_manager.members, false) 
  1418. 	 
  1419. 	-- Block controls until the interrogation is complete 
  1420. 	player_human_shield_lock(SH04_INTERROGATE_PLAYER, true) 
  1421. 	 
  1422. 	action_play_synced(SH04_INTERROGATE_PLAYER, SH04_group.casino_manager.members, "Gat Interrogation Entry") 
  1423. 	action_play_synced_state(SH04_INTERROGATE_PLAYER, SH04_group.casino_manager.members, "Gat Interrogation State") 
  1424. 	 
  1425. 	set_ignore_ai_flag(ANGEL_NO_MASK, true) --so angel doesn't act like a dumbass and shoot enemies 
  1426. 	hud_prompt_clear(SH04_INTERROGATE_PLAYER) 
  1427. --	hud_prompt_clear(REMOTE_PLAYER) 
  1428. 	 
  1429. 	--sh04_convo( SH04_convo.threaten_manager ) 
  1430. 	if (sh04_status.convo_is_playing) then 
  1431. 		repeat  
  1432. 			thread_yield()  
  1433. 		until (sh04_status.convo_is_playing == false) 
  1434. 	end 
  1435. 	 
  1436. 	delay(.5) 
  1437. 	 
  1438. 	SH04_convo.threaten_manager.handle = audio_conversation_load_direct(SH04_convo.threaten_manager.name) 
  1439. 	 
  1440. 	-- Play the conversation. This isn't played in the queue because I need the exact timing for the animation states 
  1441. 	audio_conversation_play(SH04_convo.threaten_manager.handle) 
  1442. 	 
  1443. 	--enable the vault trigger, safety net in case the player interrogates back there 
  1444. 	trigger_enable( TRIGGER_MASK_CUTSCENE, true ) 
  1445. 	on_trigger( "sh04_hit_mask_cutscene", TRIGGER_MASK_CUTSCENE ) 
  1446.  
  1447. 	-- Wait for the conversation to end 
  1448. 	audio_conversation_wait_for_end(SH04_convo.threaten_manager.handle) 
  1449. 	SH04_convo.threaten_manager.handle = INVALID_CONVERSATION_HANDLE 
  1450. 	sh04_status.convo_is_playing = false 
  1451. 	 
  1452. 	--re-enable stuff 
  1453. 	turn_vulnerable( SH04_group.casino_manager.members ) 
  1454.  
  1455. 	action_play_synced_state(SH04_INTERROGATE_PLAYER, SH04_group.casino_manager.members, "Gat Interrogation Return" ) 
  1456. 	 
  1457. 	character_allow_ragdoll(SH04_INTERROGATE_PLAYER, true) 
  1458. 	character_allow_ragdoll(SH04_group.casino_manager.members, true) 
  1459. 	 
  1460. 	set_ignore_ai_flag(ANGEL_NO_MASK, false) --end dumbass lock 
  1461. 	player_human_shield_lock(SH04_INTERROGATE_PLAYER, false) 
  1462. 	 
  1463. 	while not action_play_is_finished(SH04_INTERROGATE_PLAYER) do 
  1464. 		thread_yield() 
  1465. 	end 
  1466. 	 
  1467. 	action_stop_synced_state(SH04_INTERROGATE_PLAYER) 
  1468. 	player_release_human_shield(SH04_INTERROGATE_PLAYER, true, false) 
  1469. 	 
  1470. 	SH04_INTERROGATION_COMPLETE = true 
  1471. end 
  1472.  
  1473. function sh04_brute_finale() 
  1474. 	sh04_spawn_brutes = false 
  1475. 	if group_is_loaded(SH04_group.brute_g02.name) == false then 
  1476. 		group_create( SH04_group.brute_g02.name )	 
  1477. 		marker_add_script_group( SH04_group.brute_g02.name, MINIMAP_ICON_KILL, OI_ASSET_KILL_FULL, OI_FLAGS_FULL, SYNC_ALL ) 
  1478. 		 
  1479. 		for i, enemy in pairs(SH04_group.brute_g02.members) do 
  1480. 			--if ( character_is_dead(enemy) == false ) then 
  1481. 			on_death("sh04_brute_killed", enemy) 
  1482. 			--end 
  1483. 		end 
  1484. 	end 
  1485. 	delay(.5) 
  1486. 	--move_to( SH04_group.brute_g02.members[1], SH04_BRUTE_DEST) 
  1487. 	--move_to( SH04_group.brute_g02.members[2], SH04_BRUTE_DEST) 
  1488. 	--ai_add_enemy_target(ANGEL_WITH_MASK, SH04_group.brute_g02.members[1], ATTACK_NOW_NEVER_LOSE, true) 
  1489. 	 
  1490. 	--while( (fov_check_xz_plane(LOCAL_PLAYER, SH04_group.brute_g02.members[0]) == false ) or (fov_check_xz_plane(LOCAL_PLAYER, SH04_group.brute_g02.members[1]) == false) ) do -- 
  1491. 		--thread_yield() 
  1492. 	--end 
  1493. 	--audio_play_persona_line( LOCAL_PLAYER, SH04_dialog_lines.brute02 ) 
  1494. end 
  1495. -- *************************************************** 
  1496. -- sh04_initialize Helper Functions 
  1497. -- *************************************************** 
  1498.  
  1499. -- Handle any common initialization 
  1500. -- 
  1501. function sh04_initialize_common() 
  1502.    -- Initialization common to all checkpoints 
  1503. end 
  1504.  
  1505. -- Checkpoint specific initialization 
  1506. -- 
  1507. -- checkpoint:		The checkpoint to be initialized 
  1508. function sh04_initialize_checkpoint(checkpoint) 
  1509. 	local current_checkpoint = checkpoint 
  1510. 	 
  1511. 	if SH04_THREAD_CONVO == INVALID_THREAD_HANDLE then 
  1512. 		SH04_THREAD_CONVO = thread_new("sh04_play_convo") 
  1513. 	end 
  1514. 	 
  1515. 	--need to diable the sonic gun since it does not kill movers 
  1516. 	--local_weap = inv_item_in_slot(LOCAL_PLAYER, WEAPON_SLOT_SPECIAL) 
  1517.  
  1518. 	group_create( SH04_group.homies.name, true ) 
  1519. 	 
  1520. 	trigger_enable( TRIGGER_MISSION_AREA_001, true ) 
  1521.  
  1522. 	on_trigger( "sh04_player_entered_mission_area_trigger", TRIGGER_MISSION_AREA_001 ) 
  1523. 	 
  1524. 	--group_create( SH04_group.peds.name ) 
  1525. 	--for i, member in pairs( SH04_group.peds.members ) do 
  1526. 	--	npc_go_idle( member )  
  1527. --	end 
  1528. 	 
  1529. 	if current_checkpoint == CHECKPOINT_START then 
  1530. 		if( inv_has_item("Special-SonicGun", LOCAL_PLAYER) == true ) then 
  1531. 			inv_weapon_disable_slot( WEAPON_SLOT_SPECIAL, true, SYNC_LOCAL) 
  1532. 		end 
  1533. 	 
  1534. 		if coop_is_active() then 
  1535. 			--remote_weap = inv_item_in_slot(REMOTE_PLAYER, WEAPON_SLOT_SPECIAL) 
  1536. 			if ( inv_has_item("Special-SonicGun", REMOTE_PLAYER) == true )  then 
  1537. 				inv_weapon_disable_slot( WEAPON_SLOT_SPECIAL, true, SYNC_REMOTE) 
  1538. 			end 
  1539. 		end 
  1540. 	 
  1541. 		if IS_RESTART == true then  
  1542. 			teleport_coop( START_WARP_LOCATIONS[LOCAL_PLAYER], START_WARP_LOCATIONS[REMOTE_PLAYER], true ) 
  1543. 		end 
  1544. 		 
  1545. 		-- Add Angel as homie 
  1546. 		--group_create( SH04_group.homies.name, true ) 
  1547. 		party_add( ANGEL_NO_MASK, LOCAL_PLAYER ) 
  1548. 		-- Hide other Angel 
  1549. 		character_hide( ANGEL_WITH_MASK ) 
  1550. 		 
  1551. 		on_attack_performed("sh04_angel_attack_line_cb", ANGEL_NO_MASK) 
  1552.  
  1553. 		on_death( "sh04_failure_angel_died", ANGEL_NO_MASK ) 
  1554. 		on_dismiss( "sh04_failure_angel_abandoned", ANGEL_NO_MASK ) 
  1555. 		follower_set_can_abandon( ANGEL_NO_MASK, true ) 
  1556. 		 
  1557. 		--set_player_can_take_human_shields(ANGEL_NO_MASK, false)  
  1558. 		character_set_can_take_human_shield( ANGEL_NO_MASK, false ) 
  1559. 		 
  1560. 		--SH04_THREAD_ANGEL_WATCHER = thread_new( "sh04_angel_watcher", ANGEL_NO_MASK ) 
  1561. 		 
  1562. 		--npc_leash_to_object( ANGEL_NO_MASK, LOCAL_PLAYER, 5 ) 
  1563. 				 
  1564. 		sh04_initialize_load_groups( checkpoint ) 
  1565. 	end	 
  1566.  
  1567. 	if ( checkpoint == SH04_CHECKPOINT_MASK ) then 
  1568. 		-- This also has the side effect of placing Angel near the player 
  1569. 		character_hide( ANGEL_NO_MASK ) 
  1570. 		on_attack_performed("", ANGEL_NO_MASK) 
  1571.  
  1572. 		--SH04_THREAD_ANGEL_WATCHER = thread_new( "sh04_angel_watcher", ANGEL_WITH_MASK ) 
  1573. 		teleport_coop( POST_MASK_CHECKPOINT_WARP_LOCATIONS[LOCAL_PLAYER], POST_MASK_CHECKPOINT_WARP_LOCATIONS[REMOTE_PLAYER], true ) 
  1574. 		teleport( ANGEL_WITH_MASK, NAVPOINT_ANGEL_POST_MASK ) 
  1575. 		party_add( ANGEL_WITH_MASK, LOCAL_PLAYER ) 
  1576. 		 
  1577. 		on_death( "sh04_failure_angel_died", ANGEL_WITH_MASK ) 
  1578. 		on_dismiss( "sh04_failure_angel_abandoned", ANGEL_WITH_MASK ) 
  1579. 		on_attack_performed("sh04_angel_attack_line_cb", ANGEL_WITH_MASK) 
  1580.  
  1581. 		inv_item_equip( "Rifle-Gang", ANGEL_WITH_MASK ) 
  1582. 	end 
  1583. end 
  1584.  
  1585. -- Load groups during initialization based on the current checkpoint. 
  1586. -- These are loaded while the screen is faded out. 
  1587. -- 
  1588. function sh04_initialize_load_groups( checkpoint ) 
  1589. 	-- Currently, all checkpoints have the "no mask" Angel, so create and add him:	 
  1590. 	if ( checkpoint == CHECKPOINT_START ) then 
  1591. 		 
  1592. 	end 
  1593. end 
  1594.  
  1595. -- Loads conversations played during the mission. 
  1596. -- 
  1597. function sh04_initialize_conversations( checkpoint ) 
  1598. 	if ( checkpoint ~= CHECKPOINT_FAKE_MASK ) then 
  1599. 		--SH04_convo.angel_sees_mask.handle = audio_conversation_load(SH04_convo.angel_sees_mask.name) 
  1600. 		--SH04_convo.angel_mask_is_fake.handle = audio_conversation_load(SH04_convo.angel_mask_is_fake.name) 
  1601. 	end 
  1602. end 
  1603.  
  1604. -- *************************************************** 
  1605. -- Miscellaneous SH04 Helper Funcrtions 
  1606. -- *************************************************** 
  1607.  
  1608. -- This function can set up Angel to play the mask sequence and reset him to normal afterward. 
  1609. -- 
  1610. -- start: Set to true if the sequence is started, false if it's ending. 
  1611. -- 
  1612. function sh04_setup_angel_for_sequence( start ) 
  1613. 	set_ignore_ai_flag( ANGEL_NO_MASK, start ) 
  1614. 	turn_invulnerable( ANGEL_NO_MASK, start ) 
  1615. 	character_prevent_bumping( ANGEL_NO_MASK, start ) 
  1616. 	character_prevent_explosion_fling( ANGEL_NO_MASK, start ) 
  1617. 	character_prevent_flinching( ANGEL_NO_MASK, start ) 
  1618. 	character_prevent_kneecapping( ANGEL_NO_MASK, start ) 
  1619. end 
  1620.  
  1621. function sh04_angel_move( statue ) 
  1622.  
  1623. 	ai_do_scripted_advance(ANGEL_WITH_MASK, statue) 
  1624. 	 
  1625. 	--make sure the triggers are cleaned up 
  1626. 	for i, trigger in pairs(sh04_objectives.statues.members) do 
  1627. 		if sh04_objectives.statues.active[i] == true  then 
  1628. 			sh04_objectives.statues.active[i] = false 
  1629. 		end		 
  1630. 	end	 
  1631. 	 
  1632. end 
  1633.  
  1634. -- Removes callbacks from all triggers. 
  1635. -- 
  1636. function sh04_clear_triggers() 
  1637. 	on_trigger( "", SH04_TRIGGER_UPSTAIRS ) 
  1638. 	on_trigger( "", SH04_TRIGGER_CONT_SPAWN ) 
  1639. 	on_trigger( "", TRIGGER_TO_VAULT_001 ) 
  1640. 	on_trigger( "", TRIGGER_TO_VAULT_002 ) 
  1641. 	--on_trigger( "", SH04_TRIGGER_ALARM ) 
  1642. 	on_trigger( "", TRIGGER_MASK_CUTSCENE ) 
  1643. 	on_trigger( "", TRIGGER_MISSION_AREA_001 ) 
  1644. 	--on_trigger( "", TRIGGER_MISSION_AREA_002 ) 
  1645. 	on_trigger_exit( "", TRIGGER_MISSION_AREA_001 ) 
  1646. 	on_trigger( "", SH04_TRIGGER_BETA ) 
  1647. 	on_trigger( "", SH04_TRIGGER_ALPHA ) 
  1648.  
  1649. end 
  1650.  
  1651. -- Disables continuous spawn regions and stops all continuously spawning groups. 
  1652. -- 
  1653. function sh04_stop_spawns() 
  1654. 	continuous_spawn_regions_enable( CONTINUOUS_SPAWN_POINTS, false ) 
  1655. 	continuous_spawn_regions_enable( SH04_INIT_SPAWN_POINTS, false ) 
  1656. 	 
  1657. --	continuous_spawn_stop( SH04_group.cont_spawn_spec.name ) 
  1658. 	continuous_spawn_stop( SH04_group.cont_spawn_a.name ) 
  1659. 	continuous_spawn_stop( SH04_group.cont_spawn_b.name ) 
  1660. --	continuous_spawn_stop( SH04_group.attack_squad_omega.name ) 
  1661. 	--continuous_spawn_stop( SH04_group.backroom_specialist.name ) 
  1662. end 
  1663.  
  1664. -- Ends any conversations that happen to be playing. 
  1665. -- 
  1666. function sh04_end_conversations() 
  1667. 	if SH04_convo.angel_sees_mask.handle ~= INVALID_CONVERSATION_HANDLE then 
  1668. 		audio_conversation_end( SH04_convo.angel_sees_mask.handle ) 
  1669. 		SH04_convo.angel_sees_mask.handle = INVALID_CONVERSATION_HANDLE 
  1670. 	end 
  1671.  
  1672. 	if SH04_convo.angel_mask_is_fake.handle ~= INVALID_CONVERSATION_HANDLE then 
  1673. 		audio_conversation_end(SH04_convo.angel_mask_is_fake.handle) 
  1674. 		SH04_convo.angel_mask_is_fake.handle = INVALID_CONVERSATION_HANDLE 
  1675. 	end 
  1676. end 
  1677.  
  1678. -- Releases/destroys all groups used by this mission to the world, as appropriate. 
  1679. -- 
  1680. function sh04_cleanup_groups( mission_successful ) 
  1681. 	-- On mission success, release everyone to the world except for homies 
  1682. 	if ( mission_successful ) then 
  1683. 		for index, group in pairs( SH04_group ) do 
  1684. 			if ( group_is_loaded( group.name ) and group.name ~= SH04_group.homies.name ) then 
  1685. 				release_to_world( group.name ) 
  1686. 			end 
  1687. 		end 
  1688.  
  1689. 		group_destroy( SH04_group.homies.name ) 
  1690. 	-- On failure/cancel, destroy everyone, because it should be like the mission never happened 
  1691. 	else 
  1692. 		for index, group in pairs( SH04_group ) do 
  1693. 			if ( group_is_loaded( group.name ) and group.name ~= SH04_group.homies.name ) then 
  1694. 				group_destroy( group.name ) 
  1695. 			end 
  1696. 		end 
  1697. 	end 
  1698. end 
  1699.  
  1700. function cleanup_statues() 
  1701. 	for index, statue in pairs( SH04_killbane_statues ) do 
  1702. 		marker_remove( statue, SYNC_ALL ) 
  1703. 		mesh_mover_set_invulnerable( statue, true ) 
  1704. 		on_mover_destroyed( "", statue ) 
  1705. 	end 
  1706. end 
  1707.  
  1708. -- Kills any threads that may still be running. 
  1709. -- 
  1710. function sh04_kill_threads() 
  1711. 	if ( SH04_THREAD_SPAWN_SECOND_SQUAD ~= INVALID_THREAD_HANDLE ) then 
  1712. 		thread_kill( SH04_THREAD_SPAWN_SECOND_SQUAD ) 
  1713. 		SH04_THREAD_SPAWN_SECOND_SQUAD = INVALID_THREAD_HANDLE 
  1714. 	end 
  1715. 	if ( SH04_THREAD_SPAWN_SECOND_SQUAD ~= INVALID_THREAD_HANDLE ) then 
  1716. 		thread_kill( SH04_THREAD_SPAWN_SECOND_SQUAD ) 
  1717. 		SH04_THREAD_SPAWN_SECOND_SQUAD = INVALID_THREAD_HANDLE 
  1718. 	end 
  1719. 	 
  1720. 	if( SH04_THREAD_ANGEL_WATCHER ~= INVALID_THREAD_HANDLE ) then 
  1721. 		thread_kill( SH04_THREAD_ANGEL_WATCHER ) 
  1722. 		SH04_THREAD_ANGEL_WATCHER = INVALID_THREAD_HANDLE 
  1723. 	end 
  1724. 	 
  1725. 	if( SH04_THREAD_CONVO ~= INVALID_THREAD_HANDLE ) then 
  1726. 		thread_kill( SH04_THREAD_CONVO ) 
  1727. 		SH04_THREAD_CONVO = INVALID_THREAD_HANDLE 
  1728. 	end 
  1729. 	 
  1730. 	if SH04_group.casino_manager.thread ~= INVALID_THREAD_HANDLE then 
  1731. 		thread_kill(SH04_group.casino_manager.thread) 
  1732. 		SH04_group.casino_manager.thread = INVALID_THREAD_HANDLE 
  1733. 	end 
  1734. 	 
  1735. 	if SH04_group.homies.thread ~= INVALID_THREAD_HANDLE then 
  1736. 		thread_kill(SH04_group.homies.thread) 
  1737. 		SH04_group.homies.thread = INVALID_THREAD_HANDLE 
  1738. 	end 
  1739. 	 
  1740. 	cleanup_threads( SH04_group.right_door.thread ) 
  1741. 	cleanup_threads( SH04_group.left_door.thread ) 
  1742. end 
  1743.  
  1744. -- Stops any failure timers that may be running. 
  1745. -- 
  1746. function sh04_stop_failure_timers() 
  1747. 	hud_critical_timer_stop( 1 ) 
  1748. 	--hud_critical_timer_set( 1, 0, "" ) 
  1749. 	--hud_timer_hide( 1, true ) 
  1750. end 
  1751.  
  1752. -- ************************* 
  1753. -- 
  1754. -- Callback functions 
  1755. -- 
  1756. -- ************************* 
  1757.  
  1758. function sh04_hit_trigger(player, current_trigger) 
  1759. 	local cur_statue 
  1760. 	 
  1761. 	sh04_disable_trigger(current_trigger)	 
  1762. 	 
  1763. 	for i, trigger in pairs(sh04_objectives.statues.members) do 
  1764. 		if sh04_objectives.statues.status[i] == false and sh04_objectives.statues.members[i] == current_trigger then 
  1765. 			cur_statue = sh04_objectives.statues.nav[i] 
  1766. 			sh04_objectives.statues.active[i] = true 
  1767. 		end		 
  1768. 	end	 
  1769. 	 
  1770. 	sh04_angel_move( cur_statue )  
  1771. end 
  1772.  
  1773. function sh04_brute_killed( brute ) 
  1774. 	SH04_DEAD_BRUTES = SH04_DEAD_BRUTES + 1 
  1775. 	 
  1776. 	marker_remove( brute, SYNC_ALL ) 
  1777. 	on_death("", brute) 
  1778. 	sh04_dead_enemy( brute ) 
  1779. 	 
  1780. 	if( SH04_DEAD_BRUTES == 2 ) then 
  1781. 		Mission_successful = true 
  1782. 	end 
  1783. end 
  1784.  
  1785. function sh04_player_entered_mission_area_trigger( player_name, trigger_name ) 
  1786. 	--Players_in_mission_area_triggers[trigger_name][player_name] = false 
  1787. 	if SH04_TIMER_ACTIVE == true then 
  1788. 		hud_critical_timer_stop( 1 ) 
  1789. 	end 
  1790. 	 
  1791. 	SH04_TIMER_ACTIVE = false 
  1792. 	 
  1793. 	on_trigger_exit( "sh04_player_left_mission_area_trigger", TRIGGER_MISSION_AREA_001 ) 
  1794.  
  1795. 	Players_in_mission_area_triggers[trigger_name][player_name] = true 
  1796. 	Players_in_mission_area[player_name] = true 
  1797. end 
  1798.  
  1799. function sh04_player_left_mission_area_trigger( player_name, trigger_name ) 
  1800. 	-- Player is no longer in this trigger, so register a new on_trigger callback 
  1801. 	on_trigger( "sh04_player_entered_mission_area_trigger", TRIGGER_MISSION_AREA_001 ) 
  1802.  
  1803. 	SH04_TIMER_ACTIVE = true 
  1804. 	 
  1805. 	Players_in_mission_area_triggers[trigger_name][player_name] = false 
  1806. 	Players_in_mission_area[player_name] = false 
  1807.  
  1808. 	local sync = SYNC_LOCAL 
  1809. 	if ( player_name == REMOTE_PLAYER ) then 
  1810. 		sync = SYNC_REMOTE 
  1811. 	end 
  1812.  
  1813. 	hud_critical_timer_set( SH04_OUT_OF_AREA_FAILURE_TIME_MS, SH04_HELPTEXT_GET_BACK_TO_THE_CASINO, "sh04_out_of_area_failure", sync )  --FAIL_TIMER_INDICES[player_name] 
  1814. 	mission_help_table_nag( SH04_HELPTEXT_GET_BACK_TO_THE_CASINO, "", "", sync ) 
  1815. end 
  1816.  
  1817. function sh04_out_of_area_failure( player_name, delay_seconds ) 
  1818. 	sh04_stop_failure_timers() 
  1819. 	mission_end_failure( "sh04", HELPTEXT_FAILURE_LEFT_MISSION ) 
  1820. end 
  1821.  
  1822. -- This function is intended to act as a failsafe timeout if the Angel mask sequence takes too 
  1823. -- long, but it wasn't working so I temporarily disabled it. 
  1824. -- 
  1825. function sh04_angel_max_action_delay() 
  1826. 	Wait_on_Angel_timer_expired = true 
  1827. end 
  1828.  
  1829. -- End the mission if Angel dies 
  1830. -- 
  1831. function sh04_failure_angel_died() 
  1832. 	mission_end_failure( "sh04", HELPTEXT_FAILURE_ANGEL_DIED ) 
  1833. end 
  1834.  
  1835. -- End the mission if Angel is abandoned 
  1836. -- 
  1837. function sh04_failure_angel_abandoned() 
  1838. 	mission_end_failure( "sh04", HELPTEXT_FAILURE_ANGEL_ABANDONED ) 
  1839. end 
  1840.  
  1841. -- Trigger for reaching the fake mask 
  1842. -- 
  1843. function sh04_reached_fake_mask( character_name, trigger_name ) 
  1844. 	local distance = get_dist( ANGEL_NO_MASK, LOCAL_PLAYER ) 
  1845.  
  1846. 	if ( ( character_name == LOCAL_PLAYER and distance < ANGEL_NEAR_PLAYER_DISTANCE_METERS ) or 
  1847. 	     character_name == ANGEL_NO_MASK ) then 
  1848. 		Reached_fake_mask = true 
  1849. 	end 
  1850. end 
  1851.  
  1852. -- Sets up the enemies around the statues upstairs 
  1853. -- 
  1854. function sh04_setup_upstairs() 
  1855. 	--right room 
  1856. 	group_create( SH04_group.right_room.name ) 
  1857. 	for index, member in pairs( SH04_group.right_room.members ) do 
  1858. 		ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  1859. 		on_attack_performed("sh04_attack_line_cb", member) 
  1860. 	end 
  1861. 	 
  1862. 	trigger_enable( SH04_TRIGGER_UPSTAIRS, false ) 
  1863. end 
  1864.  
  1865. function sh04_setup_alpha() 
  1866.  
  1867. 	group_create( SH04_group.alpha_squad.name ) 
  1868. 	group_create( SH04_group.beta_squad.name ) 
  1869. 	 
  1870. 	for index, member in pairs( SH04_group.alpha_squad.members ) do 
  1871. 		ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  1872. 		on_attack_performed("sh04_attack_line_cb", member) 
  1873. 	end 
  1874. 	for index, member in pairs( SH04_group.beta_squad.members ) do 
  1875. 		--ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  1876. 		ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  1877. 		on_attack_performed("sh04_attack_line_cb", member) 
  1878. 	end 
  1879.  
  1880. 	trigger_enable( SH04_TRIGGER_ALPHA, false )	 
  1881. 	trigger_enable( SH04_TRIGGER_BETA, false ) 
  1882. 	 
  1883. 	on_trigger( "", SH04_TRIGGER_BETA ) 
  1884. 	on_trigger( "", SH04_TRIGGER_ALPHA ) 
  1885. end 
  1886.  
  1887. function sh04_setup_beta() 
  1888. 	 
  1889. 	group_create( SH04_group.beta_squad.name ) 
  1890. 	group_create( SH04_group.alpha_squad.name ) 
  1891. 	 
  1892. 	for index, member in pairs( SH04_group.alpha_squad.members ) do 
  1893. 		ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  1894. 		on_attack_performed("sh04_attack_line_cb", member) 
  1895. 	end 
  1896. 	 
  1897. 	for index, member in pairs( SH04_group.beta_squad.members ) do 
  1898. 		--ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  1899. 		ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  1900. 		on_attack_performed("sh04_attack_line_cb", member) 
  1901. 	end 
  1902. 	 
  1903. 	trigger_enable( SH04_TRIGGER_ALPHA, false )	 
  1904. 	trigger_enable( SH04_TRIGGER_BETA, false ) 
  1905. 	 
  1906. 	on_trigger( "", SH04_TRIGGER_BETA ) 
  1907. 	on_trigger( "", SH04_TRIGGER_ALPHA ) 
  1908. end 
  1909.  
  1910. -- Trigged when the player reaches the bottom floor after Angel discovers that the mask is not 
  1911. -- his mask. 
  1912. -- Causes Luchadors in the back room to attack and a specialist to be triggered for spawn after 
  1913. -- a short delay. 
  1914. -- 
  1915. function sh04_reached_bottom_floor() 
  1916. 	--trigger_enable( SH04_TRIGGER_ALARM, false ) 
  1917. 	-- door_open( SIDE_DOOR_001 ) 
  1918. 	-- door_open( SIDE_DOOR_002 ) 
  1919.  
  1920. 	for index, member in pairs( SH04_group.back_left.members ) do 
  1921. 		ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  1922. 	end 
  1923. 	for index, member in pairs( SH04_group.back_right.members ) do 
  1924. 		ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  1925. 	end 
  1926. 	for index, member in pairs( SH04_group.backroom_guards.members ) do 
  1927. 		ai_add_enemy_target( member, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  1928. 	end 
  1929. 	 
  1930. 	--sh04_trigger_specialist_spawn() 
  1931. end 
  1932.  
  1933. -- Breadcrumb trigger function. 
  1934. -- 
  1935. function sh04_to_vault_001( character_name, trigger_name ) 
  1936. 	Hit_vault_one_trigger = true 
  1937. 	trigger_enable( trigger_name, false ) 
  1938. 	marker_remove( NAVPOINT_TO_VAULT_001 ) 
  1939.  
  1940. 	marker_add( NAVPOINT_TO_VAULT_002, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1941. 	move_to_safe( ANGEL_NO_MASK, NAVPOINT_TO_VAULT_002, 2, true, false ) 
  1942. 	-- Mark the final location (it's already been enabled, so no need to set up callbacks) 
  1943. end 
  1944.  
  1945. -- Breadcrumb trigger function two. This one sets up the final trigger and works even if the 
  1946. -- first crumb has been skipped. 
  1947. -- 
  1948. function sh04_to_vault_002( character_name, trigger_name ) 
  1949. 	trigger_enable( trigger_name, false ) 
  1950. 	marker_remove( NAVPOINT_TO_VAULT_002 ) 
  1951.  
  1952. 	--marker_add( NAVPOINT_MASK_CUTSCENE, MINIMAP_ICON_LOCATION, OI_ASSET_LOCATION, OI_FLAGS_LOCATION, SYNC_ALL) 
  1953. 	 
  1954. 	--move_to_safe( ANGEL_NO_MASK, NAVPOINT_TO_VAULT_002, 2, false, false ) --make angel run to the CTE trigger 
  1955.  
  1956. end 
  1957.  
  1958. -- Triggers the cutscene. 
  1959. -- 
  1960. function sh04_hit_mask_cutscene( char, trigger ) 
  1961. 	trigger_enable( trigger, false ) 
  1962. 	Hit_vault_one_trigger = true --catch for the player running with the manager while interrogating him 
  1963. 	Hit_mask_cutscene = true 
  1964. end 
  1965.  
  1966.  
  1967. function sh04_attack_trigger() 
  1968.  
  1969. 	--open back doors to let the enemies out 
  1970. 	door_open("left_door") 
  1971. 	door_open("right_door") 
  1972. 	 
  1973. 	--have the guys file in and attack the player 
  1974.  
  1975. 	for i, enemy in pairs( SH04_group.initial_luchadors.members ) do 
  1976. 		set_attack_player_flag( enemy, true ) 
  1977. 		on_attack_performed("sh04_attack_line_cb", enemy) 
  1978. 	end 
  1979. 	 
  1980. 	for i, enemy in pairs( SH04_group.right_door.members ) do 
  1981. 		set_attack_player_flag( enemy, true ) 
  1982. 		on_attack_performed("sh04_attack_line_cb", enemy ) 
  1983. 		SH04_group.right_door.thread[i] = thread_new( "sh04_attack", enemy, SH04_group.right_door.navs[i] )  
  1984. 	end 
  1985. 	 
  1986. 	for i, enemy in pairs( SH04_group.left_door.members ) do 
  1987. 		set_attack_player_flag( enemy, true ) 
  1988. 		on_attack_performed("sh04_attack_line_cb", enemy ) 
  1989. 		SH04_group.left_door.thread[i] = thread_new( "sh04_attack", enemy, SH04_group.left_door.navs[i] )  
  1990. 	end 
  1991. 	 
  1992. 	--ai_do_scripted_move( SH04_group.first_specialist.name, SH04_group.first_specialist.dest, true, false ) 
  1993. 	move_to_safe( SH04_group.first_specialist.members, SH04_group.first_specialist.dest, 2, true, false ) 
  1994. end 
  1995.  
  1996. -- Tracking callback for "kill all the Luchadors" behavior. 
  1997. -- 
  1998. function sh04_remaining_luchador_died( dead_luchador ) 
  1999. 	marker_remove( dead_luchador, SYNC_ALL ) 
  2000. 	on_death( "", dead_luchador ) 
  2001. 	on_attack_performed("", dead_luchador) 
  2002. 	sh04_dead_enemy( dead_luchador ) 
  2003. 	SH04_num_remaining_luchadors = SH04_num_remaining_luchadors - 1 
  2004. 	objective_text( 0, HELPTEXT_DESTROY_LUCHADORES, nil, nil, SYNC_ALL, OI_ASSET_KILL ) 
  2005. end 
  2006.  
  2007. function sh04_remove_markers() 
  2008. 	SH04_num_remaining_luchadors = 0 
  2009. 	 
  2010. 	--brutes 
  2011. 	--[[----------------------------------------------------------------------]] 
  2012. 	if( group_is_loaded( SH04_group.brute_g01.name ) ) then 
  2013. 		if ( character_is_dead( SH04_group.brute_g01.members ) == false ) then 
  2014. 			marker_remove( SH04_group.brute_g01.members, SYNC_ALL ) 
  2015. 			on_death( "", SH04_group.brute_g01.members ) 
  2016. 		end 
  2017. 	end 
  2018. 	 
  2019. 	if( group_is_loaded( SH04_group.brute_g02.name ) ) then 
  2020. 		for index, member in pairs( SH04_group.brute_g02.members ) do 
  2021. 			if ( character_is_dead( member ) == false ) then 
  2022. 				marker_remove( member, SYNC_ALL ) 
  2023. 				on_death( "", member ) 
  2024. 			end 
  2025. 		end 
  2026. 	end 
  2027. 	 
  2028. 	if( group_is_loaded( SH04_group.brute_g03.name ) ) then 
  2029. 		for index, member in pairs( SH04_group.brute_g03.members ) do 
  2030. 			if ( character_is_dead( member ) == false ) then 
  2031. 				marker_remove( member, SYNC_ALL ) 
  2032. 				on_death( "", member ) 
  2033. 			end 
  2034. 		end 
  2035. 	end 
  2036. 	--[[----------------------------------------------------------------------]] 
  2037. 	 
  2038. 	--specialists 
  2039. 	--[[----------------------------------------------------------------------]] 
  2040. 	if( group_is_loaded( SH04_group.backroom_specialist.name ) ) then 
  2041. 		if ( character_is_dead( SH04_group.backroom_specialist.members ) == false ) then 
  2042. 			marker_remove( SH04_group.backroom_specialist.members, SYNC_ALL ) 
  2043. 			on_death( "", SH04_group.backroom_specialist.members ) 
  2044. 		end 
  2045. 	end 
  2046. 	if( group_is_loaded( SH04_group.backroom_specialist_coop.name ) ) then 
  2047. 		if ( character_is_dead( SH04_group.backroom_specialist_coop.members ) == false ) then 
  2048. 			marker_remove( SH04_group.backroom_specialist.members, SYNC_ALL ) 
  2049. 			on_death( "", SH04_group.backroom_specialist.members ) 
  2050. 		end 
  2051. 	end	 
  2052. 	--[[----------------------------------------------------------------------]] 
  2053.  
  2054. 	 
  2055. 	--initial guys 
  2056. 	--[[----------------------------------------------------------------------]] 
  2057. 	if( group_is_loaded( SH04_group.initial_luchadors.name ) ) then 
  2058. 		for index, member in pairs( SH04_group.initial_luchadors.members ) do 
  2059. 			on_attack_performed("", member) 
  2060. 			if ( character_is_dead( member ) == false ) then 
  2061. 				marker_remove( member, SYNC_ALL ) 
  2062. 				on_death( "", member ) 
  2063. 			end 
  2064. 		end 
  2065. 	end 
  2066. 	 
  2067. 	if( group_is_loaded( SH04_group.coop_initial_luchadors.name ) ) then 
  2068. 		for index, member in pairs( SH04_group.coop_initial_luchadors.members ) do 
  2069. 			on_attack_performed("", member) 
  2070. 			if ( character_is_dead( member ) == false ) then 
  2071. 				marker_remove( member, SYNC_ALL ) 
  2072. 				on_death( "", member ) 
  2073. 			end 
  2074. 		end 
  2075. 	end 
  2076. 	 
  2077. 	--doors 
  2078. 	if( group_is_loaded( SH04_group.left_door.name ) ) then 
  2079. 		for index, member in pairs( SH04_group.left_door.members ) do 
  2080. 			on_attack_performed("", member) 
  2081. 			if ( character_is_dead( member ) == false ) then 
  2082. 				marker_remove( member, SYNC_ALL ) 
  2083. 				on_death( "", member ) 
  2084. 			end 
  2085. 		end 
  2086. 	end 
  2087. 	if( group_is_loaded( SH04_group.right_door.name ) ) then 
  2088. 		for index, member in pairs( SH04_group.right_door.members ) do 
  2089. 			on_attack_performed("", member) 
  2090. 			if ( character_is_dead( member ) == false ) then 
  2091. 				marker_remove( member, SYNC_ALL ) 
  2092. 				on_death( "", member ) 
  2093. 			end 
  2094. 		end 
  2095. 	end 
  2096. 	--[[----------------------------------------------------------------------]] 
  2097. 	 
  2098. 	--upstairs 
  2099. 	--[[----------------------------------------------------------------------]] 
  2100. 	if( group_is_loaded( SH04_group.alpha_squad.name ) ) then 
  2101. 		for index, member in pairs( SH04_group.alpha_squad.members ) do 
  2102. 			on_attack_performed("", member) 
  2103. 			if ( character_is_dead( member ) == false ) then 
  2104. 				marker_remove( member, SYNC_ALL ) 
  2105. 				on_death( "", member ) 
  2106. 			end 
  2107. 		end 
  2108. 	end 
  2109. 	if( group_is_loaded( SH04_group.beta_squad.name ) ) then 
  2110. 		for index, member in pairs( SH04_group.beta_squad.members ) do 
  2111. 			on_attack_performed("", member) 
  2112. 			if ( character_is_dead( member ) == false ) then 
  2113. 				marker_remove( member, SYNC_ALL ) 
  2114. 				on_death( "", member ) 
  2115. 			end 
  2116. 		end 
  2117. 	end 
  2118. 	--[[----------------------------------------------------------------------]] 
  2119. 	 
  2120. 	--misc 
  2121. 	--[[----------------------------------------------------------------------]] 
  2122. 	if group_is_loaded( SH04_group.right_room.name ) == true then 
  2123. 		for index, member in pairs( SH04_group.right_room.members ) do 
  2124. 			on_attack_performed("", member) 
  2125. 			if ( character_is_dead( member ) == false ) then 
  2126. 				on_death( "", member ) 
  2127. 			end 
  2128. 		end 
  2129. 	end	 
  2130. 	if( group_is_loaded( SH04_group.post_mask_attackers.name ) ) then 
  2131. 		for index, member in pairs( SH04_group.post_mask_attackers.members ) do 
  2132. 			on_attack_performed("", member) 
  2133. 			if ( character_is_dead( member ) == false ) then 
  2134. 				marker_remove( member, SYNC_ALL ) 
  2135. 				on_death( "", member ) 
  2136. 			end 
  2137. 		end 
  2138. 	end 
  2139. 	if( group_is_loaded( SH04_group.back_left.name ) ) then 
  2140. 		for index, member in pairs( SH04_group.back_left.members ) do 
  2141. 			on_attack_performed("", member) 
  2142. 			if ( character_is_dead( member ) == false ) then 
  2143. 				marker_remove( member, SYNC_ALL ) 
  2144. 				on_death( "", member ) 
  2145. 			end 
  2146. 		end 
  2147. 	end 
  2148. 	if( group_is_loaded( SH04_group.back_right.name ) ) then 
  2149. 		for index, member in pairs( SH04_group.back_right.members ) do 
  2150. 			on_attack_performed("", member) 
  2151. 			if ( character_is_dead( member ) == false ) then 
  2152. 				marker_remove( member, SYNC_ALL ) 
  2153. 				on_death( "", member ) 
  2154. 			end 
  2155. 		end 
  2156. 	end 
  2157. 	if( group_is_loaded( SH04_group.ambush.name ) ) then 
  2158. 		for index, member in pairs( SH04_group.ambush.members ) do	 
  2159. 			on_attack_performed("", member) 
  2160. 			if ( character_is_dead( member ) == false ) then 
  2161. 				marker_remove( member, SYNC_ALL ) 
  2162. 				on_death( "", member ) 
  2163. 			end 
  2164. 		end 
  2165. 	end 
  2166. end 
  2167.  
  2168. -- Track callback for "kill all the statues" behavior. 
  2169. -- 
  2170. function sh04_statue_died( destroyed_statue_name ) 
  2171. 	 
  2172. 	on_mover_destroyed( "", destroyed_statue_name ) 
  2173. 	marker_remove( destroyed_statue_name ) 
  2174. 	SH04_num_remaining_statues = SH04_num_remaining_statues - 1 
  2175.  
  2176. 	objective_text( 0, HELPTEXT_DESTROY_STATUES, SH04_original_num_statues - SH04_num_remaining_statues, SH04_original_num_statues, SYNC_ALL, OI_ASSET_KILL ) 
  2177. 	 
  2178. 	--sh04_play_statue_line() 
  2179. 	 
  2180. 	audio_play_persona_line( LOCAL_PLAYER, SH04_dialog_lines.statue_destroyed[SH04_num_remaining_statues + 1] ) 
  2181. 	 
  2182. 	 
  2183. 	if ( SH04_num_remaining_statues == 3 ) then --spawn melee brute 
  2184. 		group_create( SH04_group.brute_g01.name ) 
  2185. 		move_to( SH04_group.brute_g01.members, SH04_BRUTE_DEST) 
  2186. 		ai_add_enemy_target( SH04_group.brute_g01.members, get_random_target_player(), ATTACK_NOW_NEVER_LOSE ) 
  2187. 	end 
  2188. 	if ( SH04_num_remaining_statues == 2 ) then --spawn specialists 
  2189. 		sh04_trigger_specialist_spawn() 
  2190. 	end 
  2191. 	--if ( SH04_num_remaining_statues == 1 ) then --spawn a couple guys as a cool down 
  2192. 		--group_create( SH04_group.ambush.name ) 
  2193. 	--end 
  2194. end 
  2195.  
  2196. function sh04_play_statue_line() 
  2197. 	local i = rand_int(1, 4)	 
  2198. 	audio_play_persona_line( LOCAL_PLAYER, SH04_dialog_lines.statue_destroyed[i] ) 
  2199. end 
  2200.  
  2201. function sh04_spawn_brute() 
  2202. 	SH04_num_remaining_statues = SH04_num_remaining_statues - 1 
  2203. end 
  2204.  
  2205.  
  2206. function sh04_slot_died() 
  2207.  
  2208. 	if SH04_GO_HOSTILE == false then 
  2209. 		SH04_GO_HOSTILE = true 
  2210. 		sh04_attack_trigger() 
  2211. 	end 
  2212. 	 
  2213. 	SH04_destroyed_slots = SH04_destroyed_slots +1 
  2214. 	hud_bar_set_value( 0, SH04_destroyed_slots, SYNC_ALL ) 
  2215. 	 
  2216. 	if( SH04_destroyed_slots >= SH04_TOTAL_DAMAGE ) then 
  2217. 		SH04_slot_obj = true 
  2218. 	end 
  2219.  
  2220. end 
  2221.  
  2222. function sh04_dead_enemy( char ) 
  2223. 	release_to_world( char ) 
  2224. 	--SH04_TOTAL_DAMAGE = SH04_TOTAL_DAMAGE + 1 
  2225. end 
  2226.  
  2227. -- ************************* 
  2228. -- 
  2229. -- Thread functions 
  2230. -- 
  2231. -- ************************* 
  2232.  
  2233. -- Activates delayed spawning for the second group. This is done to allow a group to spawn every 
  2234. -- X seconds. If we start them both at once, it doesn't work, because they spawn at the same time. 
  2235. -- If we start one with twice the time, then both will spawn at once when they go back in phase. 
  2236. -- Instead, we delay and then activate the spawn. 
  2237. -- 
  2238. function sh04_activate_second_group( delay_seconds ) 
  2239. 	--group_create( SH04_group.cont_spawn_b.name ) 
  2240. 		 
  2241. 	delay( delay_seconds ) 
  2242. 	continuous_spawn_start( SH04_group.cont_spawn_b.name, 0, SH04_NORMAL_SQUAD_RESPAWN_DELAY_SECONDS ) 
  2243. end 
  2244.  
  2245. function sh04_angel_watcher(angel) 
  2246. 	while( true ) do 
  2247. 		while ( get_dist_closest_player_to_object( angel ) < 8.5 ) do 
  2248. 			thread_yield() 
  2249. 		end 
  2250. 		ai_do_scripted_move( angel, LOCAL_PLAYER, false ) 
  2251. 	end 
  2252. end 
  2253.  
  2254. -- play convo thread. this plays conversations from the convo queue 
  2255. --  
  2256. function sh04_play_convo() 
  2257. 	while(true) do 
  2258. 		if( sh04_queue_size > 0 ) then 
  2259. 			-- If another conversation is already playing, wait for it to finish 
  2260. 			if (sh04_status.convo_is_playing) then 
  2261. 				repeat  
  2262. 					thread_yield()  
  2263. 				until (sh04_status.convo_is_playing == false) 
  2264. 			end 
  2265. 			 
  2266. 			sh04_status.convo_is_playing = true 
  2267. 			 
  2268. 			-- Load the conversation 
  2269. 			if (sh04_queue[0].load_direct) then 
  2270. 				sh04_queue[0].handle = audio_conversation_load_direct(sh04_queue[0].name) 
  2271. 			else 
  2272. 				sh04_queue[0].handle = audio_conversation_load(sh04_queue[0].name) 
  2273. 			end 
  2274. 			 
  2275. 			-- Play the conversation 
  2276. 			audio_conversation_play(sh04_queue[0].handle) 
  2277. 			delay(1) 
  2278. 			 
  2279. 			-- Wait for the conversation to end 
  2280. 			audio_conversation_wait_for_end(sh04_queue[0].handle) 
  2281. 			sh04_queue[0].handle = INVALID_CONVERSATION_HANDLE 
  2282. 			sh04_status.convo_is_playing = false 
  2283. 			 
  2284. 			for i = 1, sh04_queue_size do 
  2285. 					 sh04_queue[i - 1] =  sh04_queue[i] 
  2286. 				end 
  2287. 				sh04_queue_size = sh04_queue_size - 1 
  2288. 		end 
  2289. 		delay(.1) 
  2290. 	end 
  2291. end 
  2292.  
  2293. function sh04_attack_line_cb( name, weapon, attack ) 
  2294.  
  2295. 	-- SAY IT! - "it" 
  2296. 	local situation = "SH04_Attack" 
  2297. 	 
  2298. 	-- don't play this if we have done this recently 
  2299. 	if (not thread_check_done(sh04_threads.attack_line_timer)) then 
  2300. 		return 
  2301. 	end 
  2302. 	 
  2303. 	-- start timer 
  2304. 	sh04_threads.attack_line_timer = thread_new("delay", 10) 
  2305. 	-- play situation 
  2306. 	audio_play_persona_line(name, situation) 
  2307.  
  2308. end 
  2309.  
  2310. function sh04_angel_attack_line_cb( name, weapon, attack ) 
  2311.  
  2312. 	local persona 
  2313. 	 
  2314. 	-- don't play this if we have done this recently 
  2315. 	if (not thread_check_done(sh04_threads.attack_line_timer)) then 
  2316. 		return 
  2317. 	end 
  2318. 	 
  2319. 	if( name == "ANGEL_NO_MASK" ) then 
  2320. 		persona = SH04_dialog_lines.pre_mask 
  2321. 	else--( name == "ANGEL_WITH_MASK" )  
  2322. 		persona = SH04_dialog_lines.post_mask 
  2323. 	end 
  2324. 	 
  2325. 	-- start timer 
  2326. 	sh04_threads.attack_line_timer = thread_new("delay", 10) 
  2327. 	 
  2328. 	audio_play_persona_line( name, persona ) 
  2329. end 
  2330.  
  2331. function sh04_attack( attacker, dest ) 
  2332. 	--tell the AI to go to the navpoint and attack the player on sight 
  2333. 	--move_to_safe( attacker, dest, 3, true, false ) 
  2334. 	--ai_do_scripted_move( attacker, dest, true ) 
  2335. 	ai_do_scripted_advance( attacker, dest ) 
  2336. 	ai_attack_region(attacker, dest, 8.0)  
  2337. 	set_attack_player_flag( attacker, true )  
  2338. 	--on_attack_performed("sh04_attack_line_cb", attacker) 
  2339. end 
  2340.  
  2341. function sh04_move_manager() 
  2342. 	ai_do_scripted_move( SH04_group.casino_manager.members, LOCAL_PLAYER, true ) 
  2343. 	--npc_leash_to_object( SH04_group.casino_manager.members, LOCAL_PLAYER, 5 ) 
  2344. end 
  2345.  
  2346. function sh04_move_angel() 
  2347. 	ai_do_scripted_move( ANGEL_NO_MASK, SH04_INTERROGATE_PLAYER, true ) 
  2348. --	npc_leash_to_object( ANGEL_NO_MASK, SH04_INTERROGATE_PLAYER, 5 ) 
  2349. end