sr2lua/tss02.lua

  1. -- tss02.lua 
  2. -- SR2 mission script 
  3. -- 03/19/08 
  4.  
  5. -- Global Variables -- 
  6.  
  7. -- This factor is applied to player damage in single player.  
  8. SINGLE_PLAYER_DAMAGE_MULTIPLIER = 0.50 
  9.  
  10. -- This factor is applied to player damage in co-op. 
  11. COOP_DAMAGE_MULTIPLIER = 0.75 
  12.  
  13. Tss02_bh_brawl							= {"tss02_$c000", "tss02_$c001", "tss02_$c006", "tss02_$c007"} 
  14. Num_tss02_bh_brawl					= sizeof_table(Tss02_bh_brawl) 
  15.  
  16. Tss02_bh_brawl_coop					= {"tss02_$c005", "tss02_$c005 (0)", "tss02_$c005 (1)"} 
  17. Num_tss02_bh_brawl_coop				= sizeof_table(Tss02_bh_brawl_coop) 
  18.  
  19. Tss02_police_group_01				= {"tss02_$cop00", "tss02_$cop01", "tss02_$cop03", "tss02_$cop05", "tss02_$cop06", "tss02_$cop08"} 
  20. Num_tss02_police_group_01			= sizeof_table(Tss02_police_group_01) 
  21.  
  22. Tss02_police_group_03				= {"tss02_$cop26", "tss02_$cop27", "tss02_$cop28", "tss02_$cop29", "tss02_$cop30"} 
  23. Num_tss02_police_group_03			= sizeof_table(Tss02_police_group_03) 
  24.  
  25. Tss02_police_group_03_coop			= {"tss02_$coopcop11", "tss02_$coopcop12", "tss02_$coopcop13", "tss02_$coopcop14"} 
  26. Num_tss02_police_group_03_coop	= sizeof_table(Tss02_police_group_03_coop) 
  27.  
  28. Tss02_police_need_pistols			= {"tss02_$cop17", "tss02_$cop15", "tss02_$cop16", "tss02_$cop14", "tss02_$cop31", "tss02_$cop32"} 
  29. Num_tss02_police_need_pistols		= sizeof_table(Tss02_police_need_pistols) 
  30.  
  31. Alarm_audio_inst						= {} -- Courthouse alarm audio instances 
  32.  
  33. Tss02_clothes_thread					= {[LOCAL_PLAYER] = INVALID_THREAD_HANDLE, [REMOTE_PLAYER] = INVALID_THREAD_HANDLE} 
  34. Tss02_clothes_nag_thread			= {[LOCAL_PLAYER] = INVALID_THREAD_HANDLE, [REMOTE_PLAYER] = INVALID_THREAD_HANDLE} 
  35. Tss02_clothes_purchased				= {[LOCAL_PLAYER] = false, [REMOTE_PLAYER] = false} 
  36.  
  37. IN_COOP									= false 
  38.  
  39. BROTHERHOOD_BRAWL						= false 
  40. Tss02_clothes_obtained				= false 
  41.  
  42. LOCATION_START_LOCAL					= "tss02_$local_player_start" 
  43. LOCATION_START_REMOTE				= "tss02_$remote_player_start" 
  44. LOCATION_CHECKPOINT_LOCAL			= "tss02_$checkpoint_local" 
  45. LOCATION_CHECKPOINT_REMOTE			= "tss02_$checkpoint_remote" 
  46.  
  47. GROUP_START								= "tss02_$start" 
  48. GROUP_START_VEHICLES					= "tss02_$start_vehicles" 
  49. GROUP_COURTROOM						= "tss02_$courtroom" 
  50. GROUP_POLICE_01						= "tss02_$police01" 
  51. GROUP_POLICE_02						= "tss02_$police02" 
  52. GROUP_POLICE_03						= "tss02_$police03" 
  53. GROUP_NEWSCOPTER						= "tss02_$MediaChopper" 
  54. GROUP_MEDIA								= "tss02_$Gmedia" 
  55. GROUP_AMBUSH							= "tss02_$ambush" 
  56.  
  57. GROUP_START_COOP						= "tss02_$start_coop" 
  58. GROUP_POLICE_02_COOP					= "tss02_$police02_coop" 
  59. GROUP_POLICE_03_COOP					= "tss02_$police03_coop" 
  60.  
  61. TRIGGER_COURTHOUSE_ENTER			= "tss02_$courthouse_enter" 
  62. TRIGGER_COURTROOM						= "tss02_$courtroom" 
  63. TRIGGER_COURTHOUSE_EXIT				= "tss02_$courthouse_exit" 
  64. TRIGGER_FORGIVE_FORGET				= "tss02_$forgive_forget" 
  65. TRIGGER_MISSION_COMPLETE			= "tss02_$finish" 
  66. TRIGGER_TURN01							= "tss02_$trigger_turn01" 
  67. TRIGGER_TURN02							= "tss02_$trigger_turn02" 
  68. TRIGGER_GPSFIX							= "tss02_$trigger_gpsfix" 
  69.  
  70. TURNCOP01_01							= "tss02_$cop06" 
  71. TURNCOP01_02							= "tss02_$cop08" 
  72. TURNCOP02_01							= "tss02_$cop14" 
  73. TURNCOP02_02							= "tss02_$cop15" 
  74. TURNCOP02_03							= "tss02_$cop16" 
  75. TURNCOP03_01							= "tss02_$cop00" 
  76. TURNCOP03_02							= "tss02_$cop01" 
  77. TURNCOP03_03							= "tss02_$cop03" 
  78. TURNCOP03_04							= "tss02_$cop05" 
  79.  
  80. TRIGGER_TIMER_START					= "tss02_$timer" 
  81. TRIGGER_GO_COMMANDO					= "tss02_$commando" 
  82. TRIGGER_CREATE_POLICE_03			= "tss02_$police03" 
  83. TRIGGER_SHOW_POLICE_03				= "tss02_$climax" 
  84.  
  85. PLANTED_VEHICLE_1						= "tss02_$v000" 
  86. PLANTED_VEHICLE_2						= "tss02_$v001" 
  87.  
  88. CHARACTER_GAT							= "tss02_$gat" 
  89. CHARACTER_LEGAL_LEE					= "tss02_$legal_lee" 
  90.  
  91. CHARACTER_REPORTERS					= {	"tss02_$Creporter_1", "tss02_$Creporter_2",  
  92. 													"tss02_$Creporter_3", "tss02_$Creporter_4" 
  93. 												} 
  94. CHARACTER_CAMERAMEN					= {	"tss02_$Ccameraman_1", "tss02_$Ccameraman_2", 
  95. 													"tss02_$Ccameraman_3", "tss02_$Ccameraman_4" 
  96. 												} 
  97.  
  98. BROTHERHOOD_VEHICLE					= "tss02_$v002" 
  99.  
  100. BROTHERHOOD_THREAD					= INVALID_THREAD_HANDLE 
  101.  
  102. SECURITY_DOOR							= "tss02_SecurityDoor" 
  103.  
  104. AMBUSH_NAVPOINT01						= "tss02_$n004" 
  105. AMBUSH_NAVPOINT02						= "tss02_$n005" 
  106. AMBUSH_COP01							= "tss02_$c009" 
  107. AMBUSH_COP02							= "tss02_$c008" 
  108. AMBUSH_THREAD_1						= INVALID_THREAD_HANDLE 
  109. AMBUSH_THREAD_2						= INVALID_THREAD_HANDLE 
  110.  
  111. ALARM_NAVPOINTS						= {"tss02_$Nalarm_1"} 
  112.  
  113. -- If the players restart the mission from the beginning, they're warped to these navpoints near 
  114. -- the mission trigger. 
  115. NAVPOINT_RESTART_LOCAL				= "tss02_$local_restart" 
  116. NAVPOINT_RESTART_REMOTE				= "tss02_$remote_restart" 
  117.  
  118. NAVPOINT_OUTSIDE_SLOPPY_SECONDS	= "mission_start_sr2_city_$tss02_shop_entrance" 
  119. NAVPOINT_CASHIER_SLOPPY_SECONDS	= "shops_sr2_city_$RL_Slop_store" 
  120. NAVPOINT_OUTSIDE_TEENAY				= "tss02_$n006" 
  121. NAVPOINT_TEENAY_PARKING				= "tss02_$n007" 
  122.  
  123. CHECKPOINT_TEENAY						= "CHECKPOINT_TEENAY" 
  124. CHECKPOINT_COURTROOM					= "CHECKPOINT_GOT_GAT" 
  125. -- MISSION_START_CHECKPOINT (This checkpoint is defined in ug_lib) 
  126.  
  127. -- News Helicopter Stuffage 
  128. VEH_NEWS_HELI							= "tss02_$v005" 
  129. NEWS_HELI_PILOT						= "tss02_$c004" 
  130. NEWS_HELI_NAVPOINT					= "tss02_$media_flyaway" 
  131.  
  132. TSS02_BROTHERHOOD_TAUNT_PERSONAS = { 
  133. 	["HM_Bro1"]	=	"HMBRO1", 
  134. 	["HM_Bro2"]	=	"HMBRO2", 
  135. 	["HM_Bro3"]	=	"HMBRO3", 
  136.  
  137. 	["HF_Bro2"]	=	"HFBRO2", 
  138.  
  139. 	["WM_Bro3"]	=	"WMBRO3", 
  140.  
  141. 	["WF_Bro1"]	=	"WFBRO1", 
  142. 	["WF_Bro2"]	=	"WFBRO2", 
  143. } 
  144.  
  145. OTHER_PLAYER = {[LOCAL_PLAYER] = REMOTE_PLAYER, [REMOTE_PLAYER] = LOCAL_PLAYER} 
  146. PLAYER_SYNC = {[LOCAL_PLAYER] =SYNC_LOCAL, [REMOTE_PLAYER] = SYNC_REMOTE} 
  147.  
  148. -- This needs to come after Gat being defined... 
  149. Tss02_gat_player_drive_conversation = {{"TSSP2_EXCHANGE_L1",			CHARACTER_GAT,	.25}, 
  150. 													{"PLAYER_TSSP2_EXCHANGE_L2",	LOCAL_PLAYER,	.25}, 
  151. 													{"TSSP2_EXCHANGE_L3",			CHARACTER_GAT,	.25}, 
  152. 													{"PLAYER_TSSP2_EXCHANGE_L4",	LOCAL_PLAYER,	.25}, 
  153. 													{"TSSP2_EXCHANGE_L5",			CHARACTER_GAT,	.25}, 
  154. 													{"PLAYER_TSSP2_EXCHANGE_L6",	LOCAL_PLAYER,	.1}, 
  155. 													{"TSSP2_EXCHANGE_L7",			CHARACTER_GAT,	.25}, 
  156. 													{"PLAYER_TSSP2_EXCHANGE_L8",	LOCAL_PLAYER,	.25}, 
  157. 													{"TSSP2_EXCHANGE_L9",			CHARACTER_GAT,	.25}, 
  158. 													{"PLAYER_TSSP2_EXCHANGE_L10",	LOCAL_PLAYER,	.25}} 
  159.  
  160.  
  161. function tss02_start(checkpoint, is_restart) 
  162.  
  163. 	-- Initialize the mission 
  164. 	tss02_initialize(checkpoint, is_restart) 
  165.  
  166. 	-- If we're replaying the mission through the newspaper clippings and the player selects to restart 
  167. 	-- from the beginning, then just restart from the Teenay checkpoint. 
  168. 	if ((checkpoint == MISSION_START_CHECKPOINT) and mission_is_complete("tss02") and is_restart) then 
  169. 		checkpoint = CHECKPOINT_TEENAY 
  170. 	end 
  171.  
  172. 	-- If we're starting from the very begining, make the players change their clothes 
  173. 	if (checkpoint == MISSION_START_CHECKPOINT) then 
  174.  
  175. 		-- When replaying the mission from the newspaper clippings, don't do the clothing 
  176. 		-- purchase sequence 
  177. 		local is_replay = mission_is_complete("tss02") 
  178. 		notoriety_set_max("police", 2) 
  179. 		notoriety_set_max("brotherhood", 2) 
  180. 		notoriety_set_max("samedi", 0) 
  181. 		notoriety_set_max("ronin", 0) 
  182. 		character_slots_cap_for_team("ronin", 0) 
  183. 		character_slots_cap_for_team("brotherhood", 2) 
  184. 		character_slots_cap_for_team("samedi", 0) 
  185. 		if (not is_replay) then 
  186. 			tss02_get_new_clothes() 
  187. 		end 
  188.  
  189. 		mission_start_fade_out() 
  190. 		character_evacuate_from_all_vehicles(LOCAL_PLAYER) 
  191. 		if (IN_COOP) then 
  192. 			character_evacuate_from_all_vehicles(REMOTE_PLAYER) 
  193. 		end 
  194.  
  195. 		-- Play the cutscene 
  196. 		local group_list = {GROUP_START, GROUP_START_VEHICLES} 
  197. 		if (IN_COOP) then 
  198. 			group_list = {GROUP_START, GROUP_START_VEHICLES, GROUP_START_COOP} 
  199. 		end 
  200. 		cutscene_play("TSSP02-01", group_list, {LOCATION_START_LOCAL, LOCATION_START_REMOTE}, false) 
  201. 		notoriety_set("police", 0) 
  202. 		tss02_setup_teenay() 
  203. 		mission_start_fade_in() 
  204. 		mission_set_checkpoint(CHECKPOINT_TEENAY) 
  205. 		checkpoint = CHECKPOINT_TEENAY 
  206. 	end 
  207.  
  208. 	-- Let the brawl begin if we are starting from Teenay 
  209. 	if (checkpoint == CHECKPOINT_TEENAY) then 
  210. 		BROTHERHOOD_BRAWL = true 
  211. 	end 
  212.  
  213. 	-- Starting from the courtroom	 
  214. 	if (checkpoint == CHECKPOINT_COURTROOM) then 
  215.  
  216. 		local		human = LOCAL_PLAYER 
  217.  
  218. 		if (IN_COOP) then 
  219. 			local		local_dist = get_dist_char_to_char(LOCAL_PLAYER, CHARACTER_GAT) 
  220. 			local		remote_dist = get_dist_char_to_char(REMOTE_PLAYER, CHARACTER_GAT) 
  221.  
  222. 			if (remote_dist < local_dist) then 
  223. 				human = REMOTE_PLAYER 
  224. 			end 
  225. 		end 
  226.  
  227. 		-- Get away. 
  228. 		tss02_escape_the_courthouse(human) 
  229.  
  230. 		-- Bring the news helicopter back 
  231. 		tss02_news_helicopter() 
  232.  
  233. 	end 
  234.  
  235. end 
  236.  
  237. function tss02_initialize(checkpoint, is_restart) 
  238.  
  239. 	-- We don't need to prep anything for the start of this mission so Scott 
  240. 	-- asked me to get rid of the initial fade-in/fade-out. 
  241.  
  242. 	local do_fades = ( (checkpoint ~= MISSION_START_CHECKPOINT) or ( is_restart) ) 
  243.  
  244. 	if (do_fades) then 
  245. 		mission_start_fade_out(0.0) 
  246. 	end 
  247.  
  248. 	tss02_initialize_common() 
  249.  
  250. 	tss02_initialize_checkpoint(checkpoint, is_restart) 
  251.  
  252. 	if (do_fades) then 
  253. 		mission_start_fade_in() 
  254. 	end 
  255.  
  256. end 
  257.  
  258. function	tss02_initialize_common() 
  259. 	-- Start trigger is hit...the activate button was hit 
  260. 	set_mission_author("Ryan Spencer and Phillip Alexander") 
  261.  
  262. 	-- Reduce the amount of damage applied to the players 
  263. 	if (IN_COOP) then 
  264. 		character_set_damage_multiplier(REMOTE_PLAYER, COOP_DAMAGE_MULTIPLIER) 
  265. 		character_set_damage_multiplier(LOCAL_PLAYER, COOP_DAMAGE_MULTIPLIER) 
  266. 	else 
  267. 		character_set_damage_multiplier(LOCAL_PLAYER, SINGLE_PLAYER_DAMAGE_MULTIPLIER) 
  268. 	end 
  269.  
  270. 	-- Check for coop being active 
  271. 	if (coop_is_active()) then 
  272. 		IN_COOP	= true 
  273. 	end 
  274. end 
  275.  
  276. function tss02_initialize_checkpoint(checkpoint, is_restart) 
  277.  
  278. 	if (checkpoint == MISSION_START_CHECKPOINT) then 
  279.  
  280. 		-- If we're replaying the mission through the newspaper clippings and the player selects to restart 
  281. 		-- from the beginning, then just restart from the Teenay checkpoint. 
  282. 		if (mission_is_complete("tss02") and is_restart) then 
  283. 			teleport_coop(LOCATION_START_LOCAL, LOCATION_START_REMOTE, true) 
  284. 			checkpoint = CHECKPOINT_TEENAY 
  285. 		elseif (is_restart) then 
  286. 			teleport_coop(NAVPOINT_RESTART_LOCAL, NAVPOINT_RESTART_REMOTE, true) 
  287. 		end 
  288.  
  289. 	end 
  290. 	 
  291. 	if (checkpoint == CHECKPOINT_TEENAY) then 
  292.  
  293. 		-- Create groups hidden to match cutscene_play behavior 
  294. 		group_create_hidden(GROUP_START, true) 
  295. 		if (IN_COOP) then 
  296. 			group_create_hidden(GROUP_START_COOP, true) 
  297. 		end 
  298. 		group_create_hidden(GROUP_START_VEHICLES) 
  299.  
  300. 		tss02_setup_teenay() 
  301. 	end 
  302.  
  303. 	if (checkpoint == CHECKPOINT_COURTROOM) then 
  304.  
  305. 		-- Create the courtroom group 
  306. 		group_create(GROUP_COURTROOM, true) 
  307. 		-- Create the police group 
  308. 		group_create(GROUP_POLICE_02, true) 
  309. 		group_create(GROUP_AMBUSH, true) 
  310.  
  311. 		if (IN_COOP) then 
  312. 			group_create(GROUP_POLICE_02_COOP, true) 
  313. 		end 
  314. 		 
  315. 		if not (IN_COOP) then 
  316. 			character_hide(CHARACTER_LEGAL_LEE) 
  317. 		end 
  318.  
  319.  
  320. 	end 
  321.  
  322. end 
  323.  
  324. function tss02_setup_teenay() 
  325.  
  326. 	-- Disable Police ambient spawns. This keeps extra security guards from spawning in the Courthouse 
  327. 	-- beyond those which we've scripted to do so. 
  328. 	spawning_allow_cop_ambient_spawns(false) 
  329.  
  330. 	-- Show the starting groups 
  331. 	group_show(GROUP_START) 
  332. 	group_show(GROUP_START_VEHICLES) 
  333. 	if (IN_COOP) then 
  334. 		group_show(GROUP_START_COOP) 
  335. 	end 
  336.  
  337. 	-- Hide the brotherhood chase members for now 
  338. 	character_hide("tss02_$c002") 
  339. 	character_hide("tss02_$c003") 
  340. 	vehicle_hide(BROTHERHOOD_VEHICLE) 
  341.  
  342. 	character_set_combat_ready("tss02_$c000", true, 5000) 
  343. 	character_set_combat_ready("tss02_$c001", true, 5000) 
  344.  
  345. 	-- Enable timer trigger 
  346. 	trigger_enable(TRIGGER_TIMER_START, true) 
  347. 	on_trigger("tss02_timer_start", TRIGGER_TIMER_START) 
  348.  
  349. 	-- Enable commando trigger 
  350. 	trigger_enable(TRIGGER_GO_COMMANDO, true) 
  351. 	on_trigger("tss02_go_commando", TRIGGER_GO_COMMANDO) 
  352.  
  353. 	-- Enable courthouse trigger 
  354. 	trigger_enable(TRIGGER_COURTHOUSE_ENTER, true) 
  355. 	on_trigger("tss02_go_to_the_courtroom", TRIGGER_COURTHOUSE_ENTER) 
  356.  
  357. 	-- Enable the GPSFix Trigger 
  358. 	trigger_enable(TRIGGER_GPSFIX, true) 
  359. 	on_trigger("tss02_fix_the_gps", TRIGGER_GPSFIX) 
  360.  
  361. 	-- Remove the inventory from the bar brawlers...we want a fist fight for now 
  362. 	for i = 1, Num_tss02_bh_brawl, 1 do 
  363. 		inv_item_remove_all(Tss02_bh_brawl[i]) 
  364. 	end 
  365.  
  366. 	if (IN_COOP) then 
  367. 		for i = 1, Num_tss02_bh_brawl_coop, 1 do 
  368. 			inv_item_remove_all(Tss02_bh_brawl_coop[i]) 
  369. 		end 
  370. 	end 
  371.  
  372. 	-- Override the Brotherhood personas 
  373. 	persona_override_group_start(TSS02_BROTHERHOOD_TAUNT_PERSONAS, POT_SITUATIONS[POT_ATTACK], "TSSPROLOGUE02_TAUNT") 
  374. 	 
  375. 	-- Give the brotherhood in the doorway knives... 
  376. 	inv_item_add("baseball_bat", 1, "tss02_$c006") 
  377. 	inv_item_add("tire_iron", 1, "tss02_$c007") 
  378.  
  379. 	-- Prompt player(s) to get to the Courthouse 
  380. 	mission_help_table("tss02_courthouse") 
  381.  
  382. 	-- Up the notoriety a couple seconds after the mission starts 
  383. 	thread_new("tss02_bump_notoriety") 
  384.  
  385. 	-- Spawn off a thread to create our police group when we are close to the courthouse 
  386. 	thread_new("tss02_load_police_group") 
  387.  
  388. 	-- Spawn the media group when we're close to the courthouse 
  389. 	thread_new("tss02_load_media_group") 
  390.  
  391. 	-- Display the gang notoriety tutorial as soon as Brotherhood notoriety ~= 0 
  392. 	thread_new("tss02_notoriety_tutorial") 
  393.  
  394. 	-- Spawn a group of brotherhood to chase when the players get so far away. 
  395. 	thread_new("tss02_go_to_the_courthouse") 
  396.  
  397. end 
  398.  
  399.  
  400. Tss02_message_delay_s = 0 
  401. function tss02_get_new_clothes() 
  402.  
  403. 	-- Spawn threads directing players to change clothes 
  404. 	Tss02_clothes_thread[LOCAL_PLAYER] = thread_new("tss02_change_clothes", LOCAL_PLAYER) 
  405. 	if (coop_is_active()) then 
  406. 		Tss02_clothes_thread[REMOTE_PLAYER] = thread_new("tss02_change_clothes", REMOTE_PLAYER) 
  407. 	end 
  408.  
  409. 	while (not Tss02_clothes_obtained) do 
  410. 		thread_yield() 
  411. 	end 
  412.  
  413. end 
  414.  
  415. function tss02_change_clothes(player) 
  416.  
  417. 	local sync = PLAYER_SYNC[player] 
  418.  
  419. 	-- Tell the player to head to Sloppy Seconds 
  420. 	Tss02_clothes_nag_thread[player] = thread_new("tss02_help_nag", "MSN_TSS02_INTRO_A", sync, 40) 
  421.  
  422. 	-- Add indicators leading to the shop's parking lot 
  423. 	marker_add_navpoint(NAVPOINT_OUTSIDE_SLOPPY_SECONDS, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, sync) 
  424. 	waypoint_add(NAVPOINT_OUTSIDE_SLOPPY_SECONDS, sync) 
  425.  
  426. 	-- Add an on_item_purchased callback 
  427. 	on_purchase("tss02_item_purchased") 
  428.  
  429. 	-- Wait for the player to purchase clothing or approach the indicated store, then remove indicators 
  430. 	while ( (get_dist(player, NAVPOINT_OUTSIDE_SLOPPY_SECONDS) > 10.0) and (not Tss02_clothes_purchased[player]) ) do 
  431. 		thread_yield() 
  432. 	end 
  433. 	marker_remove_navpoint(NAVPOINT_OUTSIDE_SLOPPY_SECONDS, sync) 
  434. 	waypoint_remove(sync) 
  435.  
  436. 	-- Redisplay the help message if it hasn't played recently. 
  437. 	if (not Tss02_clothes_purchased[player]) then 
  438.  
  439. 		if (Tss02_message_delay_s > 8) then  
  440. 			Tss02_message_delay_s = 0 
  441. 		end 
  442.  
  443. 	end 
  444.  
  445. 	-- wait for player to approach the indicated cashier or purchase clothing, then remove indicator 
  446. 	minimap_icon_add_navpoint(NAVPOINT_CASHIER_SLOPPY_SECONDS, MINIMAP_ICON_LOCATION, "", sync) 
  447. 	while( (get_dist(player, NAVPOINT_CASHIER_SLOPPY_SECONDS) > 1.5) and (not Tss02_clothes_purchased[player]) ) do 
  448. 		thread_yield() 
  449. 	end 
  450. 	minimap_icon_remove_navpoint(NAVPOINT_CASHIER_SLOPPY_SECONDS, sync) 
  451. 	thread_kill(Tss02_clothes_nag_thread[player]) 
  452.  
  453. 	-- Wait for the player to leave the store 
  454. 	while( get_dist(player, NAVPOINT_CASHIER_SLOPPY_SECONDS) < 4.0)  do 
  455. 		thread_yield() 
  456. 	end 
  457.  
  458. 	-- Make sure that oustanding threads and indicators are removed for this player 
  459. 	thread_kill(Tss02_clothes_nag_thread[player])	 
  460.  
  461. 	-- Send to teenay 
  462. 	tss02_send_to_teenay(player) 
  463.  
  464. end 
  465.  
  466. function tss02_send_to_teenay(player) 
  467.  
  468. 	local sync = PLAYER_SYNC[player] 
  469.  
  470. 	-- Make sure that there is a delay after old messages are cleared 
  471. 	delay(1.0) 
  472.  
  473. 	-- Send the player to the start of tss02 
  474. 	Tss02_clothes_nag_thread[player] = thread_new("tss02_help_nag", "MSN_TSS02_INTRO_B", sync, 40) 
  475.  
  476. 	-- Send the player to the Teenay parking lot 
  477. 	waypoint_add(NAVPOINT_TEENAY_PARKING, sync) 
  478. 	marker_add_navpoint(NAVPOINT_TEENAY_PARKING, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_LOCATION, sync) 
  479. 	while( get_dist(player, NAVPOINT_TEENAY_PARKING) > 15 ) do 
  480. 		thread_yield() 
  481. 	end 
  482. 	marker_remove_navpoint(NAVPOINT_TEENAY_PARKING, sync) 
  483. 	waypoint_remove(sync) 
  484.  
  485. 	-- Send the player to the Teenay front door 
  486. 	marker_add_navpoint(NAVPOINT_OUTSIDE_TEENAY, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_LOCATION, sync) 
  487. 	while( get_dist(player, NAVPOINT_OUTSIDE_TEENAY) > 5 ) do 
  488. 		thread_yield() 
  489. 	end 
  490. 	marker_remove_navpoint(NAVPOINT_OUTSIDE_TEENAY, sync)	 
  491.  
  492. 	-- Kill outstanding threads and cleanup indicators 
  493. 	thread_kill(Tss02_clothes_nag_thread[player])	 
  494. 	thread_kill(Tss02_clothes_thread[OTHER_PLAYER[player]]) 
  495. 	thread_kill(Tss02_clothes_nag_thread[OTHER_PLAYER[player]]) 
  496.  
  497. 	-- Remove the item purchased callback 
  498. 	tss02_cleanup_clothes_sequence() 
  499. 	delay(1.0) 
  500. 	Tss02_clothes_obtained = true 
  501.  
  502. end 
  503.  
  504. function tss02_item_purchased(store_type, item_purchased, player) 
  505.  
  506. 	if(store_type == "clothing") then 
  507.  
  508. 		Tss02_clothes_purchased[player] = true 
  509.  
  510. 	end 
  511.  
  512. end 
  513.  
  514. function tss02_help_nag(tag, sync, delay_s) 
  515. 	Tss02_message_delay_s = 0 
  516. 	while(true) do 
  517. 		Tss02_message_delay_s = Tss02_message_delay_s - get_frame_time() 
  518. 		if (Tss02_message_delay_s <= 0.0) then 
  519. 			mission_help_table(tag, "", "", sync) 
  520. 			Tss02_message_delay_s = delay_s 
  521. 		end 
  522. 		thread_yield() 
  523. 	end 
  524. end 
  525.  
  526. function tss02_cleanup_clothes_sequence() 
  527.  
  528. 	on_purchase("") 
  529.  
  530. 	marker_remove_navpoint(NAVPOINT_OUTSIDE_SLOPPY_SECONDS, SYNC_LOCAL) 
  531. 	marker_remove_navpoint(NAVPOINT_CASHIER_SLOPPY_SECONDS, SYNC_LOCAL) 
  532. 	marker_remove_navpoint(NAVPOINT_TEENAY_PARKING, SYNC_LOCAL)	 
  533. 	marker_remove_navpoint(NAVPOINT_OUTSIDE_TEENAY, SYNC_LOCAL)	 
  534. 	waypoint_remove(SYNC_LOCAL) 
  535. 	mission_help_clear(SYNC_LOCAL) 
  536.  
  537. 	if( coop_is_active() ) then 
  538. 		marker_remove_navpoint(NAVPOINT_OUTSIDE_SLOPPY_SECONDS, SYNC_REMOTE) 
  539. 		marker_remove_navpoint(NAVPOINT_CASHIER_SLOPPY_SECONDS, SYNC_REMOTE) 
  540. 		marker_remove_navpoint(NAVPOINT_TEENAY_PARKING, SYNC_LOCAL)	 
  541. 		marker_remove_navpoint(NAVPOINT_OUTSIDE_TEENAY, SYNC_REMOTE)	 
  542. 		waypoint_remove(SYNC_REMOTE) 
  543. 		mission_help_clear(SYNC_REMOTE)	 
  544. 	end 
  545. end 
  546.  
  547. function tss02_cleanup() 
  548. 	-- Cleanup mission here 
  549.  
  550. 	IN_COOP = coop_is_active() 
  551.  
  552. 	-- Reset the amount of damage applied to the players 
  553. 	character_set_damage_multiplier(LOCAL_PLAYER, 1.0) 
  554. 	if (IN_COOP) then 
  555. 		character_set_damage_multiplier(REMOTE_PLAYER, 1.0) 
  556. 	end 
  557.  
  558. 	-- Reenable the action nodes 
  559. 	action_nodes_restrict_spawning(false) 
  560.  
  561. 	tss02_cleanup_clothes_sequence() 
  562.  
  563. 	-- Kill the courthouse alarms 
  564. 	for i,alarm_audio_inst in pairs(Alarm_audio_inst) do 
  565. 		audio_stop_emitting_id(alarm_audio_inst) 
  566. 	end 
  567.  
  568. 	-- Make sure that the hud timer is stopped 
  569. 	hud_timer_stop(0) 
  570.  
  571. 	-- Reenable Police ambient spawns 
  572. 	spawning_allow_cop_ambient_spawns(true) 
  573.  
  574. 	-- Just reset all of the persona overrides... 
  575. 	if (character_exists(CHARACTER_GAT)) then 
  576. 		persona_override_character_stop_all(CHARACTER_GAT) 
  577. 		on_death("", CHARACTER_GAT) 
  578. 		on_dismiss("", CHARACTER_GAT) 
  579. 		party_dismiss(CHARACTER_GAT) 
  580. 	end 
  581.  
  582. 	if (character_exists(CHARACTER_LEGAL_LEE)) then 
  583. 		persona_override_character_stop_all(CHARACTER_LEGAL_LEE) 
  584. 		on_death("", CHARACTER_LEGAL_LEE) 
  585. 		on_dismiss("", CHARACTER_LEGAL_LEE) 
  586. 		party_dismiss(CHARACTER_LEGAL_LEE) 
  587. 	end 
  588.  
  589. 	persona_override_group_stop(BROTHERHOOD_PERSONAS, POT_SITUATIONS[POT_ATTACK]) 
  590.  
  591. 	-- Reset notoriety levels 
  592. 	notoriety_reset("brotherhood") 
  593. 	notoriety_reset("police") 
  594. 	notoriety_reset("samedi") 
  595. 	notoriety_reset("ronin") 
  596.  
  597. 	-- Remove the enter callbacks 
  598. 	on_vehicle_enter("", LOCAL_PLAYER) 
  599. 	if (IN_COOP) then 
  600. 		on_vehicle_enter("", REMOTE_PLAYER) 
  601. 	end 
  602. 	on_vehicle_enter("", PLANTED_VEHICLE_1) 
  603. 	on_vehicle_enter("", PLANTED_VEHICLE_2) 
  604.  
  605. 	-- Reset the door 
  606. 	mesh_mover_reset(SECURITY_DOOR) 
  607. 	mesh_mover_reset("tss02_door_1") 
  608. 	mesh_mover_reset("tss02_door_2") 
  609.  
  610. end 
  611.  
  612. function tss02_success() 
  613. 	-- Called when the mission has ended with success 
  614.  
  615. 	-- Post the news events 
  616. 	radio_post_event("JANE_NEWS_TSSP02_01", true) 
  617. 	radio_post_event("JANE_NEWS_TSSP02_02", true) 
  618.  
  619. 	-- Unlock all activities and diversions except heli. Both heli instances 
  620. 	-- have cutscenes w/ Shaundi and Pierce who are introduced in TSS04 so 
  621. 	-- heli is unlocked after sccessfully completeing that mission. 
  622.  
  623. --	mission_unlock("angel_ct") 
  624. --	mission_unlock("angel_he") 
  625. 	mission_unlock("crowd_ht") 
  626. 	mission_unlock("crowd_su") 
  627. 	mission_unlock("demoderby_un") 
  628. 	mission_unlock("drug_ai") 
  629. 	mission_unlock("drug_ht") 
  630. 	mission_unlock("escort_rl") 
  631. 	mission_unlock("escort_un") 
  632. 	mission_unlock("fight_ar") 
  633. 	mission_unlock("fight_pr") 
  634. 	mission_unlock("fraud_fc") 
  635. 	mission_unlock("fraud_mu") 
  636. 	mission_unlock("fuzz_pj") 
  637. 	mission_unlock("fuzz_sx") 
  638. 	mission_unlock("mayhem_nu") 
  639. 	mission_unlock("mayhem_st") 
  640. --	mission_unlock("piracy_dk") 
  641. --	mission_unlock("piracy_sr") 
  642. 	mission_unlock("sewage_rl") 
  643. 	mission_unlock("sewage_sx") 
  644. 	mission_unlock("snatch_ct") 
  645. 	mission_unlock("snatch_dt") 
  646. 	mission_unlock("torch_ap") 
  647. 	mission_unlock("torch_dt") 
  648. 	mission_unlock("zombie") 
  649.  
  650. 	-- Unlock the crib purchasing 
  651. 	crib_purchasing_unlock() 
  652.  
  653. 	-- Unlock Red Light Apartment Crib 
  654.  
  655. 	-- Display the tutorials 
  656. 	tutorial_start("respect_meter", 0, true) 
  657. 	tutorial_start("waypoint", 2000, true) 
  658. end 
  659.  
  660. function tss02_complete() 
  661. 	-- End the mission with success 
  662. 	mission_end_success("tss02") 
  663. end 
  664.  
  665. function tss02_time_ran_out() 
  666. 	-- End the mission since Gat was killed 
  667. 	mission_end_failure("tss02", "tss02_time_ran_out") 
  668. end 
  669.  
  670. function tss02_gat_died() 
  671. 	-- End the mission since Gat was killed 
  672. 	mission_end_failure("tss02", "tss02_gat_died") 
  673. end 
  674.  
  675. function tss02_gat_abandoned() 
  676. 	-- End the mission since Gat was abandoned 
  677. 	mission_end_failure("tss02", "tss02_gat_abandoned") 
  678. end 
  679.  
  680. function tss02_lee_died() 
  681. 	-- End the mission since Legal Lee was killed 
  682. 	mission_end_failure("tss02", "tss02_lee_died") 
  683. end 
  684.  
  685. function tss02_lee_abandoned() 
  686. 	-- End the mission since Legal Lee was abandoned 
  687. 	mission_end_failure("tss02", "tss02_lee_abandoned") 
  688. end 
  689.  
  690. function tss02_bump_notoriety() 
  691. 	-- Wait until we can brawl 
  692. 	while (not BROTHERHOOD_BRAWL) do 
  693. 		thread_yield() 
  694. 	end 
  695. 	 
  696. 	-- Delay for a second or two 
  697. 	delay(1.5) 
  698.  
  699. 	-- Set the notoriety level for the Brotherhood 
  700. 	notoriety_set_min("brotherhood", 1) 
  701.  
  702. 	-- Have the first Brotherhood character attack 
  703. 	attack("tss02_$c000") 
  704.  
  705. end 
  706.  
  707. Tss02_notoriety_tutorial_displayed = false 
  708. function tss02_notoriety_tutorial() 
  709.  
  710. 	while( notoriety_get("Brotherhood") == 0) do 
  711. 		thread_yield() 
  712. 	end 
  713. 		 
  714. 	delay(1.0) 
  715. 	tutorial_start("notoriety_gang") 
  716.  
  717. end 
  718.  
  719. function tss02_timer_start() 
  720. 	-- Disable the trigger 
  721. 	trigger_enable(TRIGGER_TIMER_START, false) 
  722.  
  723. 	-- Tell the player(s) to get to the Courthouse before the trial ends... 
  724. 	mission_help_table("tss02_trial") 
  725.  
  726. 	-- Add a timer 
  727. 	hud_timer_set(0, 4 * 60 * 1000, "tss02_time_ran_out") 
  728.  
  729. 	-- This function returns true if the players should receive the courthouse prompts 
  730. 	local function ready_for_courthouse_prompts() 
  731. 		local in_vehicle =	(	character_is_in_vehicle(LOCAL_PLAYER)  
  732. 										or (IN_COOP and (character_is_in_vehicle(REMOTE_PLAYER))) 
  733. 									) 
  734. 		local far_enough =	(	(get_dist(LOCAL_PLAYER, TRIGGER_TIMER_START) > 100) 
  735. 										or (IN_COOP and (get_dist(REMOTE_PLAYER, TRIGGER_TIMER_START) > 100)) 
  736. 									) 
  737. 		return (in_vehicle or far_enough) 
  738. 	end 
  739.  
  740. 	-- Wait for the previous helptext to go away, then prompt to grab the car 
  741. 	delay(7.0) 
  742. 	if (not ready_for_courthouse_prompts()) then 
  743. 		mission_help_table_nag("ss08_get_a_car") 
  744. 		marker_add_vehicle(PLANTED_VEHICLE_2, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_INTERACT, SYNC_ALL) 
  745. 		while(not ready_for_courthouse_prompts() ) do 
  746. 			thread_yield() 
  747. 		end 
  748. 		marker_remove_vehicle(PLANTED_VEHICLE_2) 
  749. 	end 
  750.  
  751. 	-- If the player is in a car, display the cruise contol tutorial 
  752. 	if ( character_is_in_vehicle(LOCAL_PLAYER) or (IN_COOP and (character_is_in_vehicle(REMOTE_PLAYER))) ) then 
  753. 		tutorial_start("cruise_control_completed", 0, true) 
  754. 	end 
  755.  
  756. 	-- Mark the Courthouse, remind the player to go there 
  757. 	mission_help_table_nag("tss02_courthouse") 
  758. 	waypoint_add(TRIGGER_GPSFIX, SYNC_ALL) 
  759. 	marker_add_trigger(TRIGGER_GPSFIX, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  760. end 
  761.  
  762. function tss02_fix_the_gps() 
  763. 	marker_remove_trigger(TRIGGER_GPSFIX, SYNC_ALL) 
  764. 	waypoint_remove(SYNC_ALL) 
  765. 	waypoint_add(TRIGGER_COURTHOUSE_ENTER, SYNC_ALL) 
  766. 	marker_add_trigger(TRIGGER_COURTHOUSE_ENTER, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  767. end 
  768.  
  769. function tss02_news_helicopter() 
  770. 	group_create(GROUP_NEWSCOPTER, true) 
  771. 	delay(1) 
  772. 	vehicle_enter_teleport(NEWS_HELI_PILOT, VEH_NEWS_HELI, 0) 
  773. 	vehicle_set_dont_scare_peds(VEH_NEWS_HELI, true) 
  774. 	delay(1) 
  775. 	vehicle_chase(VEH_NEWS_HELI, LOCAL_PLAYER) 
  776. end 
  777.  
  778. function tss02_go_commando() 
  779. 	-- Disable the trigger 
  780. 	trigger_enable(TRIGGER_GO_COMMANDO, false) 
  781.  
  782. 	-- Turn the human toward the player 
  783. 	turn_to("tss02_$c006", "tss02_door_1") 
  784.  
  785. 	-- Play the kick animation 
  786. 	action_play("tss02_$c006", "kick door", nil, true, 0.45, true) 
  787. 	door_open("tss02_door_1") 
  788.  
  789. 	-- Attack the player 
  790. 	npc_leash_remove("tss02_$c006") 
  791. 	attack("tss02_$c006") 
  792.  
  793. 	-- Turn the human toward the player 
  794. 	turn_to("tss02_$c007", "tss02_door_2") 
  795.  
  796. 	-- Play the kick animation 
  797. 	action_play("tss02_$c007", "kick door", nil, true, 0.45, true) 
  798. 	door_open("tss02_door_2", true) 
  799.  
  800. 	-- Attack the player 
  801. 	npc_leash_remove("tss02_$c007") 
  802. 	attack("tss02_$c007") 
  803. end 
  804.  
  805. function tss02_load_police_group() 
  806. 	local		dist = 50.0 
  807.  
  808. 	-- Wait until either the local or remote player are close enough 
  809. 	while (1) do 
  810. 		thread_yield() 
  811.  
  812. 		-- Is the local player close enough? 
  813. 		if (get_dist_char_to_nav(LOCAL_PLAYER, TRIGGER_COURTHOUSE_ENTER) < dist) then 
  814. 			break 
  815. 		end 
  816.  
  817. 		if (IN_COOP) then 
  818. 			-- Is the remote player close enough? 
  819. 			if (get_dist_char_to_nav(REMOTE_PLAYER, TRIGGER_COURTHOUSE_ENTER) < dist) then 
  820. 				break 
  821. 			end 
  822. 		end 
  823.  
  824. 	end 
  825.  
  826. 	-- Show the group 
  827. 	group_create(GROUP_POLICE_01, true) 
  828. 	group_show(GROUP_POLICE_01) 
  829.  
  830. 	-- Have the police wander 
  831. 	-- for i = 1, Num_tss02_police_group_01, 1 do 
  832. 	-- 	wander_start(Tss02_police_group_01[i], Tss02_police_group_01[i], 10.0) 
  833. 	-- end 
  834.  
  835. 	-- since we are here anyhow, spawn the news chopper. 
  836. 	tss02_news_helicopter() 
  837.  
  838. end 
  839.  
  840. function tss02_load_media_group() 
  841.  
  842. 	local		dist = 200.0 
  843.  
  844. 	-- Wait until either the local or remote player are close enough 
  845. 	while (get_dist_closest_player_to_object(TRIGGER_COURTHOUSE_ENTER) > dist) do 
  846. 		thread_yield() 
  847. 	end 
  848.  
  849. 	-- Create the group 
  850. 	group_create(GROUP_MEDIA, true) 
  851.  
  852. 	-- Wait until a player gets closer before using the action node 
  853. 	for i=1, sizeof_table(CHARACTER_REPORTERS), 1 do 
  854. 		thread_new("tss02_media_use_action_nodes", CHARACTER_REPORTERS[i], CHARACTER_CAMERAMEN[i]) 
  855. 	end 
  856.  
  857. end 
  858.  
  859. function tss02_media_use_action_nodes(reporter, cameraman) 
  860.  
  861. 	while( (get_dist_closest_player_to_object(reporter)>75) and (get_dist_closest_player_to_object(cameraman)>75) ) do 
  862. 		thread_yield() 
  863. 	end 
  864.  
  865. 	if(	character_exists(reporter) and (not character_is_dead(reporter)) and 
  866. 			character_exists(cameraman) and (not character_is_dead(cameraman)) 
  867. 		) then 
  868. 		npc_use_closest_action_node_of_type(reporter, "Reporter") 
  869. 		npc_use_closest_action_node_of_type(cameraman, "CameraMan") 
  870. 	end 
  871.  
  872. end 
  873.  
  874. function tss02_brotherhood_chase() 
  875. 	local		dist = 60.0 
  876. 	local		local_player = false 
  877. 	local		remote_player = true 
  878.  
  879. 	-- Put the Characters in the vehicle 
  880. 	vehicle_enter_teleport("tss02_$c002", BROTHERHOOD_VEHICLE, 0) 
  881. 	vehicle_enter_teleport("tss02_$c003", BROTHERHOOD_VEHICLE, 1) 
  882.  
  883. 	-- Wait until both the local and remote player are far enough away 
  884. 	while (not local_player or not remote_player) do 
  885. 		thread_yield() 
  886.  
  887. 		-- We need to make sure both of the players are far enough away 
  888. 		local_player = (get_dist_char_to_nav(LOCAL_PLAYER, BROTHERHOOD_VEHICLE) > dist) 
  889. 		if (IN_COOP) then 
  890. 			remote_player = (get_dist_char_to_nav(REMOTE_PLAYER, BROTHERHOOD_VEHICLE) > dist) 
  891. 		end 
  892. 	end 
  893.  
  894. 	-- Show the chase members 
  895. 	character_show("tss02_$c002") 
  896. 	character_show("tss02_$c003") 
  897. 	vehicle_show(BROTHERHOOD_VEHICLE) 
  898.  
  899. 	-- Perform the chase 
  900. 	vehicle_chase(BROTHERHOOD_VEHICLE, LOCAL_PLAYER, false, true, true) 
  901. end 
  902.  
  903. function tss02_go_to_the_courthouse() 
  904.  
  905. 	-- Spawn off another thread to have the Brotherhood chase the player(s) 
  906. 	BROTHERHOOD_THREAD = thread_new("tss02_brotherhood_chase") 
  907. end 
  908.  
  909. function tss02_call_off_brotherhood() 
  910. 	-- Have them go to the forgive and forget trigger...since it isn't so far away 
  911. 	vehicle_pathfind_to(BROTHERHOOD_VEHICLE, TRIGGER_FORGIVE_FORGET, true) 
  912.  
  913. 	-- Release this group to the world 
  914. 	release_to_world("tss02_$c002") 
  915. 	release_to_world("tss02_$c003") 
  916. 	release_to_world(BROTHERHOOD_VEHICLE) 
  917. end 
  918.  
  919. function tss02_go_to_the_courtroom() 
  920.  
  921. 	-- Disable this trigger 
  922. 	trigger_enable(TRIGGER_COURTHOUSE_ENTER, false) 
  923. 	trigger_enable(TRIGGER_GPSFIX, false) 
  924. 	-- Remove the marker 
  925. 	marker_remove_trigger(TRIGGER_COURTHOUSE_ENTER, SYNC_ALL) 
  926. 	marker_remove_trigger(TRIGGER_GPSFIX, SYNC_ALL) 
  927. 	-- Remove the waypoint 
  928. 	waypoint_remove(SYNC_ALL) 
  929.  
  930. 	-- Kill the hud timer 
  931. 	hud_timer_stop(0) 
  932.  
  933. 	-- Kill the Brotherhood thread if it still is active 
  934. 	thread_kill(BROTHERHOOD_THREAD) 
  935. 	-- Reset the Brotherhood notoriety so they flee the situation 
  936. 	notoriety_reset("brotherhood") 
  937. 	notoriety_set("brotherhood", 0) 
  938. 	-- Force the scripted Brotherhood to retreat 
  939. 	if (not vehicle_is_destroyed(BROTHERHOOD_VEHICLE)) then 
  940. 		thread_new("tss02_call_off_brotherhood") 
  941. 	end 
  942.  
  943. 	-- Mark the Courtroom 
  944. 	marker_add_trigger(TRIGGER_COURTROOM, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  945.  
  946. 	-- Enable the Courtroom trigger 
  947. 	trigger_enable(TRIGGER_COURTROOM, true) 
  948. 	on_trigger("tss02_checkpoint", TRIGGER_COURTROOM) 
  949.  
  950. 	-- Make sure the door is open 
  951. 	door_open(SECURITY_DOOR) 
  952.  
  953. 	-- Tell the player(s) what to do 
  954. 	mission_help_table("tss02_find_gat") 
  955. end 
  956.  
  957. function tss02_checkpoint(human) 
  958.  
  959.    -- Disable this trigger 
  960. 	trigger_enable(TRIGGER_COURTROOM, false) 
  961. 	marker_remove_trigger(TRIGGER_COURTROOM, SYNC_ALL) 
  962.  
  963. 	-- Release the media group. Otherwise we'll have too many critical ambients. 
  964. 	release_to_world(GROUP_MEDIA) 
  965.  
  966. 	-- Play the mid-mission Story cutscene...block load the 2nd police group 
  967. 	mission_start_fade_out() 
  968.  
  969. 	-- Remove players from all vehicles 
  970. 	character_evacuate_from_all_vehicles(LOCAL_PLAYER) 
  971. 	if (IN_COOP) then 
  972. 		character_evacuate_from_all_vehicles(REMOTE_PLAYER) 
  973. 	end 
  974.  
  975. 	-- Determine which groups the cutscene will need to load 
  976. 	local groups = {GROUP_COURTROOM, GROUP_POLICE_02, GROUP_AMBUSH} 
  977. 	if (IN_COOP) then 
  978. 		groups = {GROUP_COURTROOM, GROUP_POLICE_02, GROUP_AMBUSH, GROUP_POLICE_02_COOP} 
  979. 	end 
  980.  
  981. 	-- Determine the locations to which the players should be teleported by the cutscene 
  982. 	local teleport_locations = {LOCATION_CHECKPOINT_LOCAL, LOCATION_CHECKPOINT_REMOTE} 
  983. 	if (human == REMOTE_PLAYER) then 
  984. 		teleport_locations = {LOCATION_CHECKPOINT_REMOTE, LOCATION_CHECKPOINT_LOCAL} 
  985. 	end 
  986.  
  987. 	-- Playe the cutscene and show the groups 
  988. 	cutscene_play("tssp02-02", groups, teleport_locations, false) 
  989. 	for i, group in pairs(groups) do 
  990. 		group_show(group) 
  991. 	end 
  992.  
  993. 	-- Hide Legal Lee if this is a single player game. 
  994. 	if (not IN_COOP) then 
  995. 		character_hide(CHARACTER_LEGAL_LEE) 
  996. 	end 
  997.  
  998. 	-- Force police to always be combat ready 
  999. 	set_force_combat_ready_team("police") 
  1000.  
  1001. 	-- Fade back in and set a checkpoint. 
  1002. 	mission_start_fade_in() 
  1003. 	mission_set_checkpoint(CHECKPOINT_COURTROOM) 
  1004.  
  1005. 	-- Setup the escape 
  1006. 	tss02_escape_the_courthouse(human) 
  1007. end 
  1008.  
  1009. function tss02_escape_the_courthouse(human) 
  1010.  
  1011. 	-- Start the courthouse alarms 
  1012. 	thread_new("tss02_courthouse_alarms") 
  1013.  
  1014. 	-- Lets do some persona override here... 
  1015. 	persona_override_character_stop_all(CHARACTER_GAT) 
  1016. 	persona_override_character_start(CHARACTER_GAT, POT_SITUATIONS[POT_ATTACK],		"GAT_TSSP02_ATTACK") 
  1017. 	persona_override_character_start(CHARACTER_GAT, POT_SITUATIONS[POT_TAKE_DAMAGE], "GAT_TSSP02_TAKEDAM") 
  1018. 	-- most of Gat's "chatter" lines refer to Lee who isn't present in single player 
  1019. 	if (IN_COOP) then 
  1020. 		persona_override_character_start(CHARACTER_GAT, POT_SITUATIONS[POT_GRATS_SELF],	"GAT_TSSP2_CHATTER") 
  1021. 	end 
  1022.  
  1023. 	persona_override_character_stop_all(CHARACTER_LEGAL_LEE) 
  1024. 	persona_override_character_start(CHARACTER_LEGAL_LEE, POT_SITUATIONS[POT_TAKE_DAMAGE],		"LEE_TSSP2_TAKEDAM") 
  1025. 	persona_override_character_start(CHARACTER_LEGAL_LEE, POT_SITUATIONS[POT_BARTER],			"LEE_TSSP2_BARTER") 
  1026. 	persona_override_character_start(CHARACTER_LEGAL_LEE, POT_SITUATIONS[POT_TAUNTED_BY_PC],	"LEE_TSSP2_TAUNT") 
  1027. 	persona_override_character_start(CHARACTER_LEGAL_LEE, POT_SITUATIONS[POT_PRAISED_BY_PC],	"LEE_TSSP2_PRAISED") 
  1028. 	persona_override_character_start(CHARACTER_LEGAL_LEE, POT_SITUATIONS[POT_GRATS_PC],			"LEE_TSSP2_CHATTER") 
  1029.  
  1030. 	-- Mark the Courthouse exit 
  1031. 	marker_add_trigger(TRIGGER_COURTHOUSE_EXIT, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  1032.  
  1033. 	-- Enable turn to face triggers 
  1034. 	trigger_enable(TRIGGER_TURN01, true) 
  1035. 	on_trigger("tss02_trigger_turntoface_01", TRIGGER_TURN01) 
  1036. 	trigger_enable(TRIGGER_TURN02, true) 
  1037. 	on_trigger("tss02_trigger_turntoface_02", TRIGGER_TURN02) 
  1038.  
  1039. 	-- Enable the Courthouse exit 
  1040. 	trigger_enable(TRIGGER_COURTHOUSE_EXIT, true) 
  1041. 	on_trigger("tss02_visit_forgive_and_forget", TRIGGER_COURTHOUSE_EXIT) 
  1042.  
  1043. 	-- Figure out who is added to what party 
  1044. 	if (not IN_COOP) then 
  1045. 		-- In single player, Gat is added 
  1046. 		party_add(CHARACTER_GAT, LOCAL_PLAYER) 
  1047.  
  1048. 		-- Setup the callbacks 
  1049. 		on_death("tss02_gat_died", CHARACTER_GAT) 
  1050. 		on_dismiss("tss02_gat_abandoned", CHARACTER_GAT) 
  1051.  
  1052. 	else 
  1053. 		-- Local player gets Gat and the remote gets Legal Lee 
  1054. 		party_add(CHARACTER_GAT, LOCAL_PLAYER) 
  1055. 		party_add(CHARACTER_LEGAL_LEE, REMOTE_PLAYER) 
  1056.  
  1057. 		-- Legal Lee can't do anything...so we need to remove his inventory 
  1058. 		inv_item_remove_all(CHARACTER_LEGAL_LEE) 
  1059.  
  1060. 		-- Setup the callbacks 
  1061. 		on_death("tss02_gat_died", CHARACTER_GAT) 
  1062. 		on_dismiss("tss02_gat_abandoned", CHARACTER_GAT) 
  1063.  
  1064. 		on_death("tss02_lee_died", CHARACTER_LEGAL_LEE) 
  1065. 		on_dismiss("tss02_lee_abandoned", CHARACTER_LEGAL_LEE) 
  1066. 	end 
  1067.  
  1068. 	-- Adjust the difficulty based upon which route the player took in tss01 
  1069. 	if (Tss01_tutorial_route_chosen) then 
  1070. 		-- Set the minimum police notoriety 
  1071. 		notoriety_set_min("police", 2) 
  1072. 		-- Took the tutorial route 
  1073. 		notoriety_set_max("police", 2) 
  1074. 	else 
  1075. 		-- Set the minimum police notoriety 
  1076. 		notoriety_set_min("police", 2) 
  1077. 		-- Took the run and gun route 
  1078. 		notoriety_set_max("police", 2) 
  1079. 	end 
  1080.  
  1081. 	-- Give the player a gun if he doesn't have one...more ammo if he does 
  1082. 	local weapon = inv_item_in_slot(human, "pistol") 
  1083.  
  1084. 	if (weapon == "none") then 
  1085. 		inv_item_add("glock", 2, human) 
  1086. 	else 
  1087. 		inv_item_add_ammo(human, weapon, 50) 
  1088. 	end 
  1089.  
  1090. 	-- We want to ensure these police have pistols... 
  1091. 	for i = 1, Num_tss02_police_need_pistols, 1 do 
  1092. 		inv_item_remove_all(Tss02_police_need_pistols[i]) 
  1093. 		inv_item_add("glock", 1, Tss02_police_need_pistols[i]) 
  1094. 	end 
  1095.  
  1096. 	-- Tell the player(s) to get Gat out 
  1097. 	if (IN_COOP) then 
  1098. 		mission_help_table("tss02_get_out") 
  1099. 	else 
  1100. 		mission_help_table("tss02_get_out_solo") 
  1101. 	end 
  1102.  
  1103. 	-- Close and lock the security door 
  1104. 	door_close(SECURITY_DOOR) 
  1105. 	door_lock(SECURITY_DOOR, true) 
  1106.  
  1107. 	-- Setup the trigger for creating the third police group 
  1108. 	trigger_enable(TRIGGER_CREATE_POLICE_03, true) 
  1109. 	on_trigger("tss02_create_police_group", TRIGGER_CREATE_POLICE_03) 
  1110.  
  1111. 	-- Disable the action nodes 
  1112. 	action_nodes_restrict_spawning(true) 
  1113.  
  1114. 	-- Start the cortroom ambush cops 
  1115. 	AMBUSH_THREAD_1 = thread_new("tss02_ambush_path", AMBUSH_COP01, AMBUSH_NAVPOINT01) 
  1116. 	delay(1) 
  1117. 	AMBUSH_THREAD_2 = thread_new("tss02_ambush_path", AMBUSH_COP02, AMBUSH_NAVPOINT02) 
  1118. end 
  1119.  
  1120. function tss02_courthouse_alarms() 
  1121.  
  1122. 	local	audio_id = audio_get_id("SFX_TSSP02_ALARM", "foley") 
  1123.  
  1124. 	-- Fire off the interior alarms 
  1125. 	for i, navpoint in pairs(ALARM_NAVPOINTS) do 
  1126. 		Alarm_audio_inst[i] = audio_play_emitting_id_for_navpoint(navpoint, audio_id) 
  1127. 	end 
  1128.  
  1129. end 
  1130.  
  1131. function tss02_ambush_path(cop, ambush_navp) 
  1132. 	set_ignore_ai_flag(cop, true) 
  1133. 	move_to(cop, ambush_navp, 2, true, true) 
  1134. 	if ( character_exists(cop) and (not character_is_dead(cop)) )then 
  1135. 		set_ignore_ai_flag(cop, false) 
  1136. 		local dist, player = get_dist_closest_player_to_object(cop) 
  1137. 		turn_to_char(cop, player) 
  1138. 	end 
  1139. end 
  1140.  
  1141. function tss02_trigger_turntoface_01() 
  1142.  
  1143. 	if( character_exists(TURNCOP01_01) and (not character_is_dead(TURNCOP01_01)) ) then 
  1144. 		turn_to_char(TURNCOP01_01, LOCAL_PLAYER) 
  1145. 	end 
  1146. 	if(character_exists(TURNCOP01_02) and (not character_is_dead(TURNCOP01_02)) ) then		 
  1147. 		-- Ambush cop2 and turncop01_02 are the same guy, kill the other thread manipulating him 
  1148. 		thread_kill(AMBUSH_THREAD_2) 
  1149. 		set_ignore_ai_flag(TURNCOP01_02, false) 
  1150. 		turn_to_char(TURNCOP01_02, LOCAL_PLAYER) 
  1151. 	end 
  1152. 		if( character_exists(TURNCOP03_01) and (not character_is_dead(TURNCOP03_01)) ) then 
  1153. 		turn_to_char(TURNCOP03_01, LOCAL_PLAYER) 
  1154. 	end 
  1155. 		if( character_exists(TURNCOP03_02) and (not character_is_dead(TURNCOP03_02)) ) then 
  1156. 		turn_to_char(TURNCOP03_02, LOCAL_PLAYER) 
  1157. 	end 
  1158. 		if( character_exists(TURNCOP03_03) and (not character_is_dead(TURNCOP03_03)) ) then 
  1159. 		turn_to_char(TURNCOP03_03, LOCAL_PLAYER) 
  1160. 	end 
  1161. 		if( character_exists(TURNCOP03_04) and (not character_is_dead(TURNCOP03_04)) ) then 
  1162. 		turn_to_char(TURNCOP03_04, LOCAL_PLAYER) 
  1163. 	end 
  1164.  
  1165. end 
  1166.  
  1167. function tss02_trigger_turntoface_02() 
  1168. 	if not character_is_dead(TURNCOP02_01) then 
  1169. 		turn_to_char(TURNCOP02_01, LOCAL_PLAYER) 
  1170. 	end 
  1171. 	if not character_is_dead(TURNCOP02_02) then 
  1172. 		turn_to_char(TURNCOP02_02, LOCAL_PLAYER) 
  1173. 	end 
  1174. 	if not character_is_dead(TURNCOP02_03) then 
  1175. 		turn_to_char(TURNCOP02_03, LOCAL_PLAYER) 
  1176. 	end 
  1177. end 
  1178.  
  1179. function tss02_create_police_group() 
  1180. 	-- Disable the trigger since it is no longer needed 
  1181. 	trigger_enable(TRIGGER_CREATE_POLICE_03, false) 
  1182.  
  1183. 	-- Create the police group when this trigger is hit 
  1184. 	group_create_hidden(GROUP_POLICE_03) 
  1185. 	if (IN_COOP) then 
  1186. 		group_create_hidden(GROUP_POLICE_03_COOP) 
  1187. 	end 
  1188.  
  1189. 	-- Setup the show trigger for the climax 
  1190. 	trigger_enable(TRIGGER_SHOW_POLICE_03, true) 
  1191. 	on_trigger("tss02_show_police_group", TRIGGER_SHOW_POLICE_03) 
  1192. end 
  1193.  
  1194. function tss02_show_police_group() 
  1195. 	-- Disable the trigger since it is no longer needed 
  1196. 	trigger_enable(TRIGGER_SHOW_POLICE_03, false) 
  1197.  
  1198. 	-- Show the police group when this trigger is hit 
  1199. 	group_show(GROUP_POLICE_03) 
  1200. 	if (IN_COOP) then 
  1201. 		group_show(GROUP_POLICE_03_COOP) 
  1202. 	end 
  1203.  
  1204. 	-- Check to see if a human can safely throw an item. 
  1205. 	local function npc_can_throw(npc) 
  1206.  
  1207. 		if ( (not character_exists(npc)) or character_is_dead(npc) or character_is_panicking(npc) ) then 
  1208. 			return false 
  1209. 		end 
  1210.  
  1211. 	end 
  1212.  
  1213. 	-- Move a cop into position to throw a smoke grenade 
  1214. 	set_max_hit_points("tss02_$cop27", get_max_hit_points("tss02_$cop27") * 3, true) 
  1215. 	move_to_safe("tss02_$cop27", "tss02_$smoke", 3, true, false) 
  1216. 	if (npc_can_throw("tss02_$cop27")) then 
  1217. 		force_throw_char("tss02_$cop27", CHARACTER_GAT) 
  1218. 	end 
  1219. 	if (npc_can_throw("tss02_$cop27")) then 
  1220. 		local dist, player = get_dist_closest_player_to_object("tss02_$cop27") 
  1221. 		force_throw_char("tss02_$cop27", player) 
  1222. 	end 
  1223.  
  1224.  
  1225. 	-- Move a cop into position to throw a flash bang 
  1226. 	set_max_hit_points("tss02_$cop29", get_max_hit_points("tss02_$cop29") * 3, true) 
  1227. 	move_to_safe("tss02_$cop29", "tss02_$flash", 3, true, false) 
  1228. 	if (npc_can_throw("tss02_$cop29")) then 
  1229. 		force_throw_char("tss02_$cop29", LOCAL_PLAYER) 
  1230. 	end 
  1231. 	if (npc_can_throw("tss02_$cop29")) then 
  1232. 		local dist, player = get_dist_closest_player_to_object("tss02_$cop27") 
  1233. 		force_throw_char("tss02_$cop29", player) 
  1234. 	end 
  1235.  
  1236. 	-- Have the groups attack! 
  1237. 	for i = 1, Num_tss02_police_group_03, 1 do 
  1238. 		attack(Tss02_police_group_03[i]) 
  1239. 	end 
  1240.  
  1241. 	if (IN_COOP) then 
  1242. 		for i = 1, Num_tss02_police_group_03_coop, 1 do 
  1243. 			attack(Tss02_police_group_03_coop[i]) 
  1244. 		end 
  1245. 	end 
  1246. end 
  1247.  
  1248. function tss02_visit_forgive_and_forget() 
  1249.  
  1250. 	-- Reenable police ambient spawns 
  1251. 	spawning_allow_cop_ambient_spawns(true) 
  1252.  
  1253. 	-- Reenable the action nodes 
  1254. 	action_nodes_restrict_spawning(false) 
  1255.  
  1256. 	-- Enable the confessionals and allow a free one... 
  1257. 	confessionals_enable(true) 
  1258. 	confessionals_allow_free_one(true)  
  1259.  
  1260. 	-- Disable this trigger 
  1261. 	trigger_enable(TRIGGER_COURTHOUSE_EXIT, false) 
  1262. 	 
  1263. 	-- Remove the marker 
  1264. 	marker_remove_trigger(TRIGGER_COURTHOUSE_EXIT, SYNC_ALL) 
  1265.  
  1266. 	-- Mark the forgive and forget 
  1267. 	marker_add_trigger(TRIGGER_FORGIVE_FORGET, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_LOCATION, SYNC_ALL) 
  1268. 	-- Add a waypoint 
  1269. 	waypoint_add(TRIGGER_FORGIVE_FORGET, SYNC_ALL) 
  1270.  
  1271. 	-- Enable the forgive and forget 
  1272. 	trigger_enable(TRIGGER_FORGIVE_FORGET, true) 
  1273. 	on_trigger("tss02_go_to_aishas_house", TRIGGER_FORGIVE_FORGET) 
  1274.  
  1275. 	-- Tell the player(s) to get to forgive and forget to get the FUZZ off their back 
  1276. 	mission_help_table("tss02_ff") 
  1277.  
  1278. 	-- Play the conversation table 
  1279. 	audio_play_conversation_in_vehicle(Tss02_gat_player_drive_conversation) 
  1280. end 
  1281.  
  1282. function tss02_go_to_aishas_house() 
  1283. 	-- Disable this trigger 
  1284. 	trigger_enable(TRIGGER_FORGIVE_FORGET, false) 
  1285.  
  1286. 	-- Remove the marker 
  1287. 	marker_remove_trigger(TRIGGER_FORGIVE_FORGET, SYNC_ALL) 
  1288. 	-- Remove the waypoint 
  1289. 	waypoint_remove(SYNC_ALL) 
  1290.  
  1291. 	-- Mark Aisha's house 
  1292. 	marker_add_trigger(TRIGGER_MISSION_COMPLETE, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_LOCATION, SYNC_ALL) 
  1293. 	-- Add a waypoint 
  1294. 	waypoint_add(TRIGGER_MISSION_COMPLETE, SYNC_ALL) 
  1295.  
  1296. 	-- Enable the mission complete trigger 
  1297. 	trigger_enable(TRIGGER_MISSION_COMPLETE, true) 
  1298. 	on_trigger("tss02_arrived_at_aishas", TRIGGER_MISSION_COMPLETE) 
  1299.  
  1300. 	-- Tell the player(s) to get to Aishas house 
  1301. 	mission_help_table("tss02_aishas") 
  1302.  
  1303. 	-- Reset the police notoriety 
  1304. 	notoriety_reset("police") 
  1305.  
  1306. 	--Lose the media helicopter 
  1307. 	thread_new("tss02_heli_fly_away") 
  1308. end 
  1309.  
  1310. function tss02_heli_fly_away() 
  1311. 	if ( vehicle_exists(VEH_NEWS_HELI) and (not vehicle_is_destroyed(VEH_NEWS_HELI)) ) then 
  1312. 		helicopter_enter_retreat(VEH_NEWS_HELI) 
  1313. 	end 
  1314. end 
  1315.  
  1316. function tss02_arrived_at_aishas() 
  1317. 	-- Require both players to be close enough to complete 
  1318. 	local		local_player_close_enough = (get_dist(LOCAL_PLAYER, TRIGGER_MISSION_COMPLETE) < 10.0) 
  1319. 	local		remote_player_close_enough = true 
  1320.  
  1321. 	if (IN_COOP) then 
  1322. 		remote_player_close_enough = (get_dist(REMOTE_PLAYER, TRIGGER_MISSION_COMPLETE) < 10.0) 
  1323. 	end 
  1324.  
  1325. 	-- Both players must be considered close to end this mission 
  1326. 	if (local_player_close_enough and remote_player_close_enough) then 
  1327. 		-- Disable this trigger 
  1328. 		trigger_enable(TRIGGER_MISSION_COMPLETE, false) 
  1329.  
  1330. 		-- Stop the players' vehicles when they reach the HQ trigger 
  1331. 		player_controls_disable( LOCAL_PLAYER ) 
  1332. 		vehicle_stop_do( LOCAL_PLAYER ) 
  1333. 		if ( coop_is_active() ) then 
  1334. 		   player_controls_disable( REMOTE_PLAYER ) 
  1335. 		   vehicle_stop_do( REMOTE_PLAYER ) 
  1336. 		end 
  1337.  
  1338. 		-- Remove the marker 
  1339. 		marker_remove_trigger(TRIGGER_MISSION_COMPLETE, SYNC_ALL) 
  1340. 		-- Remove the waypoint 
  1341. 		waypoint_remove(SYNC_ALL) 
  1342.  
  1343. 		-- Call the mission success 
  1344. 		tss02_complete() 
  1345. 	elseif (IN_COOP) then 
  1346. 		-- Show a message 
  1347. 		mission_help_table_nag("tss02_cooperative") 
  1348. 	end 
  1349. end 
  1350.  
  1351.