sr2lua/rn05.lua

  1. -- rn05.lua 
  2. -- SR2 mission script 
  3. -- 3/28/07 
  4.  
  5. -- Note: the baggage cart's default speed (as of 10-5-07) is 65 
  6.  
  7. -- Global constants ( ALL_CAPS means that they shouldn't be modified in running code, except for maybe	group_create_hidden(group) in a setup function ) 
  8.  
  9.  
  10. 	-- KNOBS_TO_TURN -- 
  11.  
  12.  
  13. 			--[[ *** READ ME *** 
  14. 			 
  15. 				Whenever a script function looks up a wave parameter, a naming convention is used to select the appropriate value. 
  16. 				Parameter values for single player missions can use any name, say "PARAMETER_1" for example. If you wish to have 
  17. 				a different value for that parameter in coop, then prepend "COOP" to the parameter name. In this case, we get 
  18. 				"COOP_PARAMETER_1". 
  19.  
  20. 				When a mission function needs to access "PARAMETER_1", it will search for the appropriate overloaded values first: 
  21.  
  22. 					*	Single player will use the value stored in "PARAMETER_1". 
  23. 				 
  24. 					*	Coop will use the value stored in "COOP_PARAMETER_1", if it exists. Otherwise it will use the 
  25. 						default single player value stored in "PARAMETER_1". 
  26. 			 ]] 
  27.  
  28. 			-- Mission parameters 
  29. 			RN05_PARAMETERS	=  
  30. 				{	 
  31.  
  32. 					-- Stage 1, drive to airport 
  33. 						 
  34. 						-- single-player values 
  35. 						["AIRPORT_DRIVE_TIME_MS"]	=	2*60*1000; -- Time constraint on the initial drive to the airport. 
  36.  
  37. 						-- coop values 
  38.  
  39. 					-- Stage 2, gate fight 
  40. 					 
  41. 						-- single-player values 
  42. 						["ARRIVAL_GATE_SKULK_TIME_MS"]	=	5*1000;	-- Amount of time players should avoid notice before the  
  43. 																					-- flight arrives. 
  44.  
  45. 						-- coop values 
  46.  
  47. 					-- Stage 3, airport chase 
  48. 					 
  49. 						-- single-player values 
  50. 						["PIERCE_BLATHER_CHANCE"]			= .33;	-- During chase, chance that random Pierce line is played 
  51. 																				-- checked every 5 seconds. 
  52.  
  53. 						["RONIN_CART_HP"]						=	4000;	-- Hit points of the Ronin's cart. 
  54. 						["RONIN_CART_DRIVER_HP"]			=	1000; -- Hit points of the cart's driver. 
  55. 						["RONIN_CART_PASSENGER_HP"]		=	600; -- Hit points of the cart's passenger. 
  56.  
  57. 						["RONIN_CART_SPEED_JUMP_MPH"]		=	75;	-- Ronin drive the carts off the ledge at this speed 
  58.  
  59. 						["RONIN_CART_NORMAL_MAX_SPEED"]	=	65;	-- Max speed of the Ronin's cart under normal conditions. 
  60. 						["RONIN_CART_THROTTLE_DIST"]		=	20;	-- If Ronin cart > this dist from the players, then we slow it down. 
  61. 						["RONIN_CART_THROTTLE_SPEED"]		=	35;	-- Max speed for Ronin when far from player and not preparing to jump. 
  62.  
  63. 						["RONIN_BIKE_NORMAL_MAX_SPEED"]	=	75;	-- Max speed of the Ronin's cart under normal conditions. 
  64. 						["RONIN_BIKE_THROTTLE_DIST"]		=	30;	-- If Ronin cart > this dist from the players, then we slow it down. 
  65. 						["RONIN_BIKE_THROTTLE_SPEED"]		=	50;	-- Max speed for Ronin when far from player and not preparing to jump. 
  66.  
  67. 						["RONIN_CART_FAILURE_DIST"]		=	60;	-- Player(s) need to stay w/in this dist from the fleeing Ronin. 
  68. 						["RONIN_BIKE_FAILURE_DIST"]		=	50;	-- Player(s) need to stay w/in this dist from the fleeing Ronin. 
  69. 						["RONIN_DIST_FAILURE_TIME_S"]		=	20;	-- Time player(s) can exceed the above limits before mission fails. 
  70.  
  71. 						["CART_TORQUE_MODIFIER"]			= 1.9;	-- Modifier applied to all carts, helps get up stairs 
  72.  
  73. 						-- coop values 
  74.  
  75. 				} 
  76.  
  77. 	-- COOP MISSION? --  
  78. 		IN_COOP	= false 
  79.  
  80. 	-- CHARACTERS -- 
  81.  
  82. 		CHARACTER_PIERCE				= "rn05_$Cpierce" 
  83. 		CHARACTER_CART_DRIVER		= "rn05_$c023" 
  84. 		CHARACTER_CART_PASSENGER	= "rn05_$c024" 
  85.  
  86. 	-- CONVERSATIONS -- 
  87.  
  88. 	   INTRO_CONVERSATION = 
  89. 		{ 
  90. 			{ "RON5_INTRO_L1", CHARACTER_PIERCE, 1 }, 
  91. 			{ "PLAYER_RON5_INTRO_L2", LOCAL_PLAYER, 1 }, 
  92. 			{ "RON5_INTRO_L3", CHARACTER_PIERCE, 1 }, 
  93. 			{ "PLAYER_RON5_INTRO_L4", LOCAL_PLAYER, 1 }, 
  94. 			{ "RON5_INTRO_L5", CHARACTER_PIERCE, 1 }, 
  95. 		} 
  96.  
  97. 	   OUTRO_CONVERSATION = 
  98. 		{ 
  99. 			{ "PLAYER_RON5_OUTRO_L1", LOCAL_PLAYER, 1 }, 
  100. 			{ "RON5_OUTRO_L2", CHARACTER_PIERCE, 1 }, 
  101. 			{ "PLAYER_RON5_OUTRO_L3", LOCAL_PLAYER, 1 }, 
  102. 		} 
  103. 		 
  104. 		--Radio station defines for radio changing conversation 
  105. 		DEFAULT_RADIO_STATION =			3 --95.4 KRhyme FM 
  106. 		PIERCE_PREFERRED_STATION_1 =	7 -- 102.4 Klassic FM 
  107. 		PIERCE_PERFERRED_STATION_2 =	10 -- 105.0 The World 
  108. 		 
  109. 		RADIO_CONVERSATION1 =  
  110. 		{ 
  111. 			{ "RON5_BICKER_L1", CHARACTER_PIERCE, 1 }, 
  112. 		} 
  113. 	 
  114. 		RADIO_CONVERSATION2 = 
  115. 		{ 
  116. 			{ "PLAYER_RON5_BICKER_L2", LOCAL_PLAYER, 0 }, 
  117. 			{ "RON5_BICKER_L3", CHARACTER_PIERCE, 0 } 
  118. 		} 
  119. 	 
  120. 		RADIO_CONVERSATION3 = 
  121. 		{ 
  122. 			{ "PLAYER_RON5_BICKER_L4", LOCAL_PLAYER, 0 }, 
  123. 			{ "RON5_BICKER_L5", CHARACTER_PIERCE, 0 } 
  124. 		} 
  125.  
  126. 	-- CHECKPOINTS 
  127. 		 
  128. 		CHECKPOINT_START			= MISSION_START_CHECKPOINT			-- defined in ug_lib.lua 
  129. 		CHECKPOINT_AIRPORT		= "rn05_arrived_at_airport"		-- players made it to the airport 
  130. 		CHECKPOINT_CHASE			= "rn05_airport_chase"				-- players started the chase from the 2nd gate 
  131. 		 
  132. 	-- GROUPS -- 
  133.  
  134. 		GROUP_PIERCE							= "rn05_$Gpierce" 
  135. 		GROUP_COURTESY							= "rn05_$Gcourtesy" 
  136. 		GROUP_COURTESY_COOP					= "rn05_$Gcourtesy_coop" 
  137. 		GROUP_RONIN_GATE_C1					= "rn05_$Gronin_gate_c1"			-- Ronin waiting for Akuji @ the first gate (c1). 
  138. 		GROUP_RONIN_REINFORCEMENTS			= "rn05_$Gronin_reinforcements"	-- Ronin spawned if the player approaches the 
  139. 																								-- Ronin @ gate c1 too soon. 
  140. 		GROUP_PASSENGERS_GATE_C1			= "rn05_$Gpassengers_gate_c1"		-- Passengers on the plane at gate C1. 
  141. 		GROUP_RONIN_LTNTS_GATE_C1			= "rn05_$Gronin_ltnts_gate_c1"	-- Ronin Lieutenants on the plane at gate C1. 
  142.  
  143. 		GROUP_RONIN_CHASE						= "rn05_$Gronin_chase"				-- Ronin driving the cart in stage 3. 
  144. --		GROUP_CARTS								= "rn05_$Gcarts"						-- Carts used in stage 3 
  145.  
  146. 		GROUP_BIKES								= "rn05_$Gbikes"						-- Bikes sitting outside the airport in stage 3. 
  147.  
  148. 		-- Groups to destroy in cleanup 
  149.  
  150. 		-- Groups to release in cleanup 
  151. 		TABLE_RELEASE_GROUPS		= {	GROUP_PASSENGERS_GATE_C1} 
  152. 		 
  153. 		TABLE_DESTROY_GROUPS		= {	GROUP_PIERCE, GROUP_COURTESY, GROUP_RONIN_GATE_C1, GROUP_RONIN_REINFORCEMENTS, 
  154. 												GROUP_RONIN_LTNTS_GATE_C1, GROUP_RONIN_CHASE, GROUP_BIKES,  
  155. 												GROUP_PASSENGERS_GATE_C1} 
  156.  
  157.  
  158. 		-- Coop groups to destroy in cleanup 
  159. 		TABLE_COOP_DESTROY_GROUPS		= {	} 
  160.  
  161. 		-- Coop groups to release in cleanup 
  162. 		TABLE_COOP_RELEASE_GROUPS		= {	} 
  163.  
  164. 	-- GROUP MEMBER TABLES --  
  165.  
  166. 		MEMBERS_GROUP_RONIN_GATE_C1			=	{	"rn05_$c000", "rn05_$c001", "rn05_$c002", "rn05_$c003", "rn05_$c004", 
  167. 																"rn05_$c005", "rn05_$c006", "rn05_$c007"} 
  168.  
  169. 		MEMBERS_GROUP_RONIN_REINFORCEMENTS	=	{	"rn05_$c008", "rn05_$c009", "rn05_$c010", "rn05_$c011", "rn05_$c012"} 
  170.  
  171. 		MEMBERS_GROUP_PASSENGERS_GATE_C1		=	{	"rn05_$c017", "rn05_$c018", "rn05_$c019", "rn05_$c020", "rn05_$c021",  
  172. 																"rn05_$c022"} 
  173.  
  174. 		MEMBERS_GROUP_RONIN_LTNTS_GATE_C1	=	{	"rn05_$c013", "rn05_$c014", "rn05_$c015", "rn05_$c016"} 
  175. 	 
  176. 	-- HELPTEXT 
  177.  
  178. 		-- localized helptext messages 
  179.  
  180. 			-- Failure conditions 
  181.  
  182. 			HELPTEXT_FAILURE_AIRPORT_DRIVE			= "rn05_failure_airport_drive"		-- ## You didn't get to the airport in time. 
  183. 			HELPTEXT_FAILURE_PIERCE_ABANDONED		= "rn05_failure_pierce_abandoned"	-- "Pierce was abandoned" 
  184. 			HELPTEXT_FAILURE_PIERCE_DIED				= "rn05_failure_pierce_died"			-- "Pierce died" 
  185. 			HELPTEXT_FAILURE_VEHICLE_DIST				= "rn05_failure_vehicle_dist"			-- ## You let the Ronin get away. 
  186.  
  187. 			-- Prompts 
  188. 			HELPTEXT_PROMPT_LOCATION_ARRIVAL_GATE	= "rn05_prompt_location_arrival_gate"	-- ## Head to the arrival gate. 
  189. 			HELPTEXT_PROMPT_KILL_LTNTS					= "rn05_prompt_kill_ltnts"					-- ## Kill the Ronin lieutenants. 
  190. 			HELPTEXT_PROMPT_WARN_DIST					= "rn05_prompt_warn_dist"					-- ## The Ronin are getting away! 
  191. 			HELPTEXT_PROMPT_LOCATION_SECOND_GATE	= "rn05_prompt_location_second_gate"	-- Akuji isn't here, check the rest of the terminal! 
  192. 			HELPTEXT_PROMPT_HANG_BACK					= "rn05_prompt_hang_back"		--"## Lay low until Akuj's flight arrives." 
  193. 			HELPTEXT_PROMPT_PLANE_LANDED				= "rn05_prompt_plane_landed"		-- ## Akuji's plane arrived, head to the gate. 
  194. 			HELPTEXT_PROMPT_BACK_ENTRANCE				= "rn05_prompt_back_entrance"		-- ## Use the back entrance to bypass security. 
  195. 			HELPTEXT_PROMPT_CHASE_CART					= "rn05_prompt_chase_cart"			-- ## Chase down and kill the fleeing Ronin! 
  196. 			HELPTEXT_PROMPT_LOCATION_AIRPORT			= "rn05_prompt_location_airport"	-- ## Drive to the airport before the Ronin arrive! 
  197.  
  198. 			-- Objectives 
  199. 			HELPTEXT_OBJECTIVE_LTNTS					= "rn05_objective_ltnts"			-- Ronin LT's killed: %s/%s		 
  200. 			HELPTEXT_OBJECTIVE_VEHICLE_DIST			= "rn05_objective_vehicle_dist"	-- Time: 
  201.  
  202. 			-- Dialogue 
  203. 			HELPTEXT_DIALOGUE_PIERCE_WARN				= "rn05_dialogue_pierce_warn"	-- "## Pierce: Damn, lots of Ronin here. Hang back until we spot Akuji." 
  204.  
  205. 	-- MOVERS 
  206.  
  207. 		-- Doors at gate C1 
  208. 		MOVER_DOOR_GATE_C1_1		= "rn05_APHeli_Door050" 
  209. 		MOVER_DOOR_GATE_C1_2		= "rn05_APHeli_Door080" 
  210.  
  211. 		MM_DOOR_AIRPORT_2 = "rn05_$MM_airport_door_1" 
  212. 		MM_DOOR_AIRPORT_1	= "rn05_$MM_airport_door_2" 
  213.  
  214. 		-- Rails obstructing the chase path 
  215. 		MM_RAIL_1 = "rn05_$MMrail_1" 
  216. 		MM_RAIL_2 = "rn05_$MMrail_2" 
  217. 		MM_RAIL_3 = "rn05_$MMrail_3" 
  218.  
  219. 	-- NAVPOINTS 
  220.  
  221. 		-- Player locations at the mission's start 
  222. 		NAVPOINT_LOCAL_PLAYER_START		= "mission_start_sr2_city_$rn05" 
  223. 		NAVPOINT_REMOTE_PLAYER_START		= "rn05_$remote_player_start" 
  224.  
  225. 		-- Navpoints to which player(s) and Pierce are teleported after arriving at the airport 
  226. 		NAVPOINT_LOCAL_PLAYER_AIRPORT_START			= "rn05_$Nlocal_player_airport_start" 
  227. 		NAVPOINT_REMOTE_PLAYER_AIRPORT_START		= "rn05_$Nremote_player_airport_start" 
  228. 		NAVPOINT_PIERCE_AIRPORT_START					= "rn05_$Npierce_airport_start" 
  229.  
  230. 		NAVPOINT_ARRIVAL_GATE							= "rn05_$n000" -- Minimap location for 1st gate. 
  231.  
  232. 		-- When the passengers disembark at gate C1, civilians walk to these navpoints and are released to the world. 
  233. 		NAVPOINT_CIVILIAN_ARRIVAL_DESTINATIONS		= {	"rn05_$n004", "rn05_$n005"} 
  234.  
  235. 		-- When the Lieutenants disembark at gate C1, they walk to these navpoints. 
  236. 		NAVPOINT_LIEUTENANT_ARRIVAL_DESTINATIONS	= {	"rn05_$n001", "rn05_$n002", "rn05_$n003"} 
  237.  
  238. 		-- The location that the players are warped to after the outro cutscene finishes 
  239. 		NAVPOINT_END_SUCCESS = "rn05_$Nplayer_end_success" 
  240.  
  241. 	-- TRIGGERS --  
  242. 	 
  243. 		TRIGGER_AIRPORT_ARRIVAL				= "rn05_$t000" -- Destination in drive-to-airport stage. 
  244. 		TRIGGER_NEAR_GATE_C1					= "rn05_$t001" -- When hit, indicates that the player is near the first gate. 
  245. 		TRIGGER_NEARER_GATE_C1				= "rn05_$t002" -- When hit, indicates that the player has been spotted by the 
  246. 																		-- Ronin at the first gate. 
  247. 		TRIGGER_NEAR_GATE_C3					= "rn05_$t003" -- Start end of stage 2 cutscene when a player enters this area. 
  248.  
  249. 		TRIGGER_BREADCRUMB_1					= "rn05_$t004"	-- Starts the breadcrumbed path to the back entrance of the airport. 
  250. 		TRIGGER_BREADCRUMB_2					= "rn05_$t005"	-- Starts the breadcrumbed path to the back entrance of the airport. 
  251. 		TRIGGER_BREADCRUMB_3					= "rn05_$t006"	-- Starts the breadcrumbed path to the back entrance of the airport. 
  252. 		TRIGGER_BREADCRUMB_4					= "rn05_$t007"	-- Starts the breadcrumbed path to the back entrance of the airport. 
  253. 		TRIGGER_BREADCRUMB_5					= "rn05_$t008"	-- Starts the breadcrumbed path to the back entrance of the airport. 
  254.  
  255. 		-- List of all triggers, makes cleaning up more convenient 
  256. 		TABLE_ALL_TRIGGERS		= {	TRIGGER_AIRPORT_ARRIVAL, TRIGGER_NEAR_GATE_C1, TRIGGER_NEARER_GATE_C1, 
  257. 												TRIGGER_NEAR_GATE_C3, TRIGGER_BREADCRUMB_1, TRIGGER_BREADCRUMB_2, 
  258. 												TRIGGER_BREADCRUMB_3, TRIGGER_BREADCRUMB_4, TRIGGER_BREADCRUMB_5}		 
  259.  
  260. 	-- VEHICLES -- 
  261.  
  262. 		VEHICLE_RONIN_CART					= "rn05_$v001" 
  263. 		VEHICLE_PLAYER_CART					= "rn05_$v002" 
  264.  
  265. 		VEHICLE_RONIN_BIKE					= "rn05_$v003" 
  266. 		VEHICLE_PLAYER_BIKE					= "rn05_$v004" 
  267.  
  268. 	-- MISC CONSTANTS 
  269.  
  270. 		ESCAPE_PATH2 = {	"rn05_$n006", 
  271. 								"rn05_$n007", 
  272. 								"rn05_$n008", 
  273. 								"rn05_$n009", 
  274. 								"rn05_$n010", 
  275. 								"rn05_$n011", 
  276. 								"rn05_$n012", 
  277. 								"rn05_$n013"} 
  278.  
  279. 		ESCAPE_PATH	=	{	{"rn05_$n006", "normal"},  
  280. 								{"rn05_$n007", "stairs"}, 
  281. 								{"rn05_$n008", "normal"}, 
  282. 								{"rn05_$n009", "normal"}, 
  283. 								{"rn05_$n010", "normal"}, 
  284. 								{"rn05_$n011", "stairs"}, 
  285. 								{"rn05_$n012", "normal"}, 
  286. 								{"rn05_$n013", "normal"}, 
  287. 								{"rn05_$n014", "jump"}, 
  288. 								{"rn05_$n015", "fast"}, 
  289. 								{"rn05_$n016", "fast"}, 
  290. 							} 
  291.  
  292. 		JUMP_DELAY	=	{	["rn05_$n014"]	=	3.0 
  293. 							} 
  294.  
  295. -- Progress flags 
  296. 	Gate_c1_ltnts_killed						= false -- Have the ltnts that disembark at C1 been killed? 
  297.  
  298. -- Misc 
  299. 	Players_near_gate_c3						= 0 -- # players in TRIGGER_NEAR_GATE_C3 
  300. 	Timing_dist_failure						= false -- Is the player out of range in stage 3? 
  301. 	Escape_vehicle								= VEHICLE_RONIN_CART 
  302. 	Thread_ronin_escape						= -1 
  303.  
  304. function rn05_start(rn05_checkpoint, is_restart) 
  305.  
  306. 	mission_start_fade_out() 
  307.  
  308. 	if (rn05_checkpoint == CHECKPOINT_START) then 
  309.  
  310. 		local start_groups = {GROUP_PIERCE, GROUP_COURTESY} 
  311. 		if (coop_is_active()) then 
  312. 			start_groups = {GROUP_PIERCE, GROUP_COURTESY, GROUP_COURTESY_COOP} 
  313. 		end 
  314.  
  315. 		if (is_restart) then 
  316.  
  317. 			-- Teleport players to the start location 
  318. 			teleport_coop(NAVPOINT_LOCAL_PLAYER_START,NAVPOINT_REMOTE_PLAYER_START) 
  319.  
  320. 			-- Load starting groups 
  321. 			for i,group in pairs(start_groups) do 
  322. 				group_create(group, true) 
  323. 			end 
  324.  
  325. 		else 
  326.  
  327. 			-- Play the intro cutscene 
  328. 			cutscene_play("ro05-01", start_groups, {NAVPOINT_LOCAL_PLAYER_START,NAVPOINT_REMOTE_PLAYER_START}, false) 
  329. 			for i,group in pairs(start_groups) do 
  330. 				group_show(group) 
  331. 			end 
  332.  
  333. 		end 
  334.  
  335. 	end 
  336. 	 
  337. 	rn05_initialize(rn05_checkpoint) 
  338.  
  339. 	local start_from_chase = (rn05_checkpoint == CHECKPOINT_CHASE) 
  340.  
  341. 	-- Stage 1: Drive to the airport 
  342. 	if(rn05_checkpoint == CHECKPOINT_START) then 
  343.  
  344. 		rn05_drive_to_airport() 
  345.  
  346. 		mission_start_fade_out() 
  347. 		rn05_initialize_checkpoint(CHECKPOINT_AIRPORT) 
  348. 		mission_start_fade_in() 
  349.  
  350. 		-- CHECKPOINT! 
  351. 		mission_set_checkpoint(CHECKPOINT_AIRPORT) 
  352. 		rn05_checkpoint = CHECKPOINT_AIRPORT 
  353.  
  354.  
  355. 	end -- ends CHECKPOINT_START 
  356.  
  357. 	-- Players have a gunfight w/ some Ronin at the gate where they think that Akuji will arrive 
  358. 	if (rn05_checkpoint == CHECKPOINT_AIRPORT) then 
  359.  
  360. 		rn05_terminal_gun_fight() 
  361.  
  362. 		-- CHECKPOINT! 
  363. 		mission_set_checkpoint(CHECKPOINT_CHASE) 
  364. 		rn05_checkpoint = CHECKPOINT_CHASE 
  365.  
  366. 	end -- ends CHECKPOINT_AIRPORT 
  367.  
  368. 	-- Players chase 2 Ronin through the airport on baggage carts. If the Ronin manage to  
  369. 	-- escape the airport then they hop on some motorcycles and enter flee mode. 
  370. 	if (rn05_checkpoint == CHECKPOINT_CHASE) then 
  371.  
  372. 		rn05_the_chase(start_from_chase) 
  373.  
  374. 		-- Both Ltnts have been killed, trigger success. 
  375. 		rn05_complete() 
  376.  
  377. 	end 
  378. end 
  379.  
  380. function rn05_initialize(checkpoint) 
  381.  
  382. 	rn05_initialize_common() 
  383.  
  384. 	rn05_initialize_checkpoint(checkpoint) 
  385.  
  386. 	-- No need to fade in before the cutscene 
  387. 	if (checkpoint ~= CHECKPOINT_CHASE) then 
  388. 		mission_start_fade_in() 
  389. 	end 
  390.  
  391. end 
  392.  
  393. -- Initialization code shared by all checkpoints. 
  394. function rn05_initialize_common() 
  395.  
  396. 	-- Start trigger is hit...the activate button was hit 
  397. 	set_mission_author("Phillip Alexander") 
  398.  
  399. 	if coop_is_active() then 
  400. 		IN_COOP = true 
  401. 	end 
  402.  
  403. end 
  404.  
  405. -- Initialization code specific to the checkpoint. 
  406. function rn05_initialize_checkpoint(checkpoint) 
  407.  
  408. 	if(checkpoint == CHECKPOINT_START) then 
  409. 			 
  410. 		-- Put Pierce in the player's party 
  411. 		party_add(CHARACTER_PIERCE) 
  412.  
  413. 		if ( coop_is_active() == false ) then 
  414. 			-- Find his current index 
  415. 			local pierce_follower_index = party_get_follower_index(CHARACTER_PIERCE) 
  416.  
  417. 			-- If he's not the first follower, swap him and the first one 
  418. 			if ( pierce_follower_index > 0 ) then 
  419. 				party_swap_follower_indices( 0, pierce_follower_index ) 
  420. 				delay( 1.0 ) 
  421. 			end 
  422. 		end 
  423.  
  424. 		on_death("rn05_failure_pierce_died", CHARACTER_PIERCE) 
  425. 		on_dismiss("rn05_failure_pierce_abandoned", CHARACTER_PIERCE) 
  426.  
  427. 	end -- ends CHECKPOINT_START 
  428.  
  429. 	if (checkpoint == CHECKPOINT_AIRPORT) then 
  430.  
  431. 		on_death("rn05_failure_pierce_died", CHARACTER_PIERCE) 
  432. 		on_dismiss("rn05_failure_pierce_abandoned", CHARACTER_PIERCE) 
  433.  
  434. 		group_create(GROUP_RONIN_GATE_C1,false) 
  435. 		group_create(GROUP_PASSENGERS_GATE_C1, false) 
  436. 		group_create(GROUP_RONIN_LTNTS_GATE_C1, false) 
  437.  
  438. 		character_evacuate_from_all_vehicles(LOCAL_PLAYER) 
  439. 		character_evacuate_from_all_vehicles(CHARACTER_PIERCE) 
  440. 		if (IN_COOP) then 
  441. 			character_evacuate_from_all_vehicles(REMOTE_PLAYER) 
  442. 		end 
  443.  
  444. 		-- Teleport players to the airport start location 
  445. 		teleport_coop(NAVPOINT_LOCAL_PLAYER_AIRPORT_START, NAVPOINT_REMOTE_PLAYER_AIRPORT_START, true) 
  446. 		teleport(CHARACTER_PIERCE, NAVPOINT_PIERCE_AIRPORT_START) 
  447.  
  448. 		-- Lock the doors at gate C1 
  449. 		door_lock(MOVER_DOOR_GATE_C1_1, true) 
  450. 		door_lock(MOVER_DOOR_GATE_C1_2, true) 
  451.  
  452. 		-- Setup a trigger to track when players are near gate C3 (used to start the cutscene) 
  453. 		trigger_enable(TRIGGER_NEAR_GATE_C3,true) 
  454. 		on_trigger("rn05_player_enter_gate_c3_area", TRIGGER_NEAR_GATE_C3) 
  455. 		on_trigger_exit("rn05_player_exit_gate_c3_area", TRIGGER_NEAR_GATE_C3) 
  456. 		trigger_set_delay_between_activations(TRIGGER_NEAR_GATE_C3,0) 
  457.  
  458.  
  459. 	end -- ends CHECKPOINT_AIRPORT 
  460.  
  461. 	if (checkpoint == CHECKPOINT_CHASE) then 
  462.  
  463. 		if (not IN_COOP) then		 
  464. 			on_death("rn05_failure_pierce_died", CHARACTER_PIERCE) 
  465. 			on_dismiss("rn05_failure_pierce_abandoned", CHARACTER_PIERCE) 
  466. 		end 
  467.  
  468. 		-- Setup stage 3... 
  469. 			--thread_new("rn05_keep_doors_open") 
  470. 			mesh_mover_hide(MM_DOOR_AIRPORT_1) 
  471. 			mesh_mover_hide(MM_DOOR_AIRPORT_2) 
  472.  
  473. 			-- Hide the rails that obstruct the chase path 
  474. 			mesh_mover_hide(MM_RAIL_1) 
  475. 			mesh_mover_hide(MM_RAIL_2) 
  476. 			mesh_mover_hide(MM_RAIL_3) 
  477.  
  478. 	end 
  479.  
  480. end 
  481.  
  482. function rn05_drive_to_airport() 
  483.  
  484. 	local dialog_thread = thread_new("rn05_play_drive_dialogue") 
  485.  
  486. 	-- Send the player(s) to a spot near the airport entrance 
  487. 	rn05_send_to_location(	{	TRIGGER_BREADCRUMB_1}, 
  488. 									INGAME_EFFECT_VEHICLE_LOCATION,  
  489. 									{	HELPTEXT_PROMPT_LOCATION_AIRPORT},  
  490. 									rn05_get_parameter_value("AIRPORT_DRIVE_TIME_MS"), 
  491. 									"rn05_failure_airport_drive" 
  492. 								) 
  493.  
  494. 	-- Send player(s) to the back door 
  495. 	rn05_send_to_location(	{	TRIGGER_BREADCRUMB_2,  
  496. 										TRIGGER_BREADCRUMB_3, TRIGGER_BREADCRUMB_4, 
  497. 										TRIGGER_BREADCRUMB_5, TRIGGER_AIRPORT_ARRIVAL 
  498. 									}, 
  499. 									INGAME_EFFECT_VEHICLE_LOCATION,  
  500. 									{	HELPTEXT_PROMPT_BACK_ENTRANCE 
  501. 									} 
  502. 								) 
  503. 	 
  504. 	thread_kill(dialog_thread) 
  505.  
  506. end 
  507.  
  508. function rn05_terminal_gun_fight() 
  509.  
  510. 	-- Send player(s) to the airport C1 terminal. 
  511. 	delay(1.0) 
  512. 	rn05_persona_line_wrapper("PIERCE_RON5_FIRST_GATE_01", CHARACTER_PIERCE, false) 
  513.  
  514. 	-- Create the minimap marker near the gate. 
  515. 	marker_add_navpoint(	NAVPOINT_ARRIVAL_GATE, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  516.  
  517. 	-- Setup a trigger for when the players get close to the Ronin. 
  518. 	rn05_send_to_location(	TRIGGER_NEAR_GATE_C1, 
  519. 									nil,  
  520. 									HELPTEXT_PROMPT_PLANE_LANDED,  
  521. 									nil, 
  522. 									nil) 
  523. 	marker_remove_navpoint( NAVPOINT_ARRIVAL_GATE) 
  524.  
  525. 	-- Pierce spots the Ronin 
  526. 	rn05_persona_line_wrapper("PIERCE_RON5_INTERCEPT_01", CHARACTER_PIERCE, false) 
  527.  
  528. 	-- Create a thread that will cause civilian passengers and Ronin ltnts to disembark from  
  529. 	-- the plane 
  530. 	thread_new("rn05_gate_c1_disembark", rn05_get_parameter_value("ARRIVAL_GATE_SKULK_TIME_MS")) 
  531.  
  532. 	-- Wait for the ltnts to be killed. 
  533. 	while (not Gate_c1_ltnts_killed) do 
  534. 		thread_yield() 
  535. 	end 
  536.  
  537. 	-- No Akuji here line 
  538. 	rn05_persona_line_wrapper("PIERCE_RON5_TIPPED_01", CHARACTER_PIERCE, false) 
  539.  
  540. 	-- If there isn't a already near the gate, then place an icon and tell the player(s) 
  541. 	-- to head that way. 
  542. 	if (Players_near_gate_c3 == 0) then 
  543.  
  544. 		mission_help_table(HELPTEXT_PROMPT_LOCATION_SECOND_GATE) 
  545.  
  546. 		marker_add_navpoint(	TRIGGER_NEAR_GATE_C3, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  547.  
  548. 		-- Wait until a player is near the gate 
  549. 		while( Players_near_gate_c3 == 0) do 
  550. 			thread_yield() 
  551. 		end 
  552.  
  553. 		marker_remove_navpoint( TRIGGER_NEAR_GATE_C3) 
  554.  
  555. 	end 
  556.  
  557. 	-- Disable callbacks on the trigger tracking how many players are near gate C3 
  558. 	trigger_enable(TRIGGER_NEAR_GATE_C3,false) 
  559. 	on_trigger("", TRIGGER_NEAR_GATE_C3) 
  560. 	on_trigger_exit("", TRIGGER_NEAR_GATE_C3) 
  561.  
  562. end 
  563.  
  564. function rn05_the_chase(start_from_chase) 
  565. 	 
  566. 	if (not start_from_chase) then 
  567. 		mission_start_fade_out() 
  568. 	end 
  569. 	group_destroy(GROUP_RONIN_GATE_C1) 
  570. 	group_destroy(GROUP_PASSENGERS_GATE_C1) 
  571. 	group_destroy(GROUP_RONIN_LTNTS_GATE_C1) 
  572.  
  573. 	character_evacuate_from_all_vehicles(LOCAL_PLAYER) 
  574. 	character_evacuate_from_all_vehicles(CHARACTER_PIERCE) 
  575. 	if (IN_COOP) then 
  576. 		character_evacuate_from_all_vehicles(REMOTE_PLAYER) 
  577. 	end 
  578.  
  579. 	cutscene_play("IG_rn05_scene1", "", "", false) 
  580.  
  581. 	-- Destroy the old group. 
  582. 	group_destroy(GROUP_RONIN_CHASE) 
  583.  
  584. 	-- Create a new group. 
  585. 	group_create(GROUP_RONIN_CHASE, true) 
  586.  
  587. 	rn05_initialize_checkpoint(CHECKPOINT_CHASE) 
  588.  
  589. 	-- start loading the bikes, place the Ronin in the carts 
  590. 	group_create(GROUP_BIKES, false) 
  591. 	vehicle_evacuate(VEHICLE_RONIN_CART) 
  592.  
  593. 	--delay(1.0) 
  594. 	 
  595. 	-- Ensure that pierce is the first homie 
  596. 	if ( coop_is_active() == false ) then 
  597. 		-- Find his current index 
  598. 		local pierce_follower_index = party_get_follower_index(CHARACTER_PIERCE) 
  599.  
  600. 		-- If he's not the first follower, swap him and the first one 
  601. 		if ( pierce_follower_index > 0 ) then 
  602. 			party_swap_follower_indices( 0, pierce_follower_index ) 
  603. 			delay( 1.0 ) 
  604. 		end 
  605. 	end 
  606.  
  607. 	vehicle_enter_teleport(CHARACTER_CART_DRIVER,VEHICLE_RONIN_CART,0) 
  608. 	vehicle_enter_teleport(CHARACTER_CART_PASSENGER,VEHICLE_RONIN_CART,1) 
  609.  
  610. 	--delay(1.0) 
  611.  
  612. 	-- Set various flags on the escape vehicles before starting the chase. This needs to be done 
  613. 	-- before the ronin are shown so that they don't start attacking the player(s)  
  614. 	-- before entering the cart. 
  615. 	rn05_setup_ronin_escape_vehicle(VEHICLE_RONIN_CART) 
  616. 	vehicle_set_torque_multiplier(VEHICLE_PLAYER_CART, rn05_get_parameter_value("CART_TORQUE_MODIFIER")) 
  617. 	vehicle_set_torque_multiplier(VEHICLE_PLAYER_CART, rn05_get_parameter_value("CART_TORQUE_MODIFIER")) 
  618. 	rn05_setup_ronin_escape_vehicle(VEHICLE_RONIN_BIKE) 
  619.  
  620. 	rn05_setup_player_cart_occupants() 
  621. 	 
  622. 	--delay(.2) 
  623.  
  624. 	-- Adjust the Ronin's health 
  625. 	set_max_hit_points(CHARACTER_CART_DRIVER, rn05_get_parameter_value("RONIN_CART_DRIVER_HP")) 
  626. 	set_max_hit_points(CHARACTER_CART_PASSENGER, rn05_get_parameter_value("RONIN_CART_PASSENGER_HP")) 
  627. 	set_max_hit_points(VEHICLE_RONIN_CART, rn05_get_parameter_value("RONIN_CART_HP")) 
  628.  
  629. 	-- The Ronin drive out of the airport then flee from the closest player. 
  630. 	Thread_ronin_escape = thread_new("rn05_ronin_escape") 
  631.  
  632. 	mission_start_fade_in(1.0) 
  633.  
  634. -- Stage 3 
  635.  
  636. 	-- Wait for the player to kill the two fleeing Ronin ltnts. 
  637. 	rn05_process_enemy_set(	{CHARACTER_CART_DRIVER, CHARACTER_CART_PASSENGER},  
  638. 									HELPTEXT_PROMPT_CHASE_CART,  
  639. 									HELPTEXT_OBJECTIVE_LTNTS) 
  640.  
  641. end 
  642.  
  643. function rn05_setup_player_cart_occupants() 
  644.  
  645. 	-- Make sure that no random ped or vehicle spawns obstruct our vehicle 
  646. 	spawning_pedestrians(false, true) 
  647. 	spawning_vehicles(false) 
  648.  
  649. 	-- In single player, Pierce rides in the cart withg the player. The carts only 
  650. 	-- hold 2 people, so we can't just place the client in the same cart. There really 
  651. 	-- isn't a lot of room in the airport, so adding a 2nd cart is a bad idea. Instead, 
  652. 	-- in Coop, Pierce just stays to "clean up" 
  653. 	local passenger = CHARACTER_PIERCE 
  654. 	if (IN_COOP) then 
  655. 		passenger = REMOTE_PLAYER 
  656. 		if (npc_is_in_party(CHARACTER_PIERCE)) then 
  657. 			npc_stop_following(CHARACTER_PIERCE) 
  658. 			on_death("", CHARACTER_PIERCE) 
  659. 			on_dismiss("", CHARACTER_PIERCE) 
  660. 		end 
  661. 	end 
  662.  
  663. 	vehicle_enter_teleport(LOCAL_PLAYER, VEHICLE_PLAYER_CART,0) 
  664. 	vehicle_enter_teleport(passenger, VEHICLE_PLAYER_CART,1) 
  665.  
  666. 	rn05_wait_for_vehicle_entry(LOCAL_PLAYER, VEHICLE_PLAYER_CART, 0) 
  667. 	rn05_wait_for_vehicle_entry(passenger, VEHICLE_PLAYER_CART, 1) 
  668.  
  669. 	if (IN_COOP) then 
  670. 		delay(1.0) 
  671. 	end 
  672.  
  673. 	-- Reenable ped and vehicle spawning 
  674. 	spawning_pedestrians(true, true) 
  675. 	spawning_vehicles(true)	 
  676.  
  677. end 
  678.  
  679.  
  680. -- Wait for a character to enter a vehicle. Blocks for a maximum of a second or two. 
  681. function rn05_wait_for_vehicle_entry(character, vehicle, seat_index) 
  682.  
  683. 	local delay_length = 0.25 
  684. 	if (character == REMOTE_PLAYER) then 
  685. 		delay_length = 0.5 
  686. 	end 
  687.  
  688. 	local teleport_attempts = 1 
  689. 	while( (not character_is_in_vehicle(character, vehicle)) and (teleport_attempts < 5) ) do 
  690. 		teleport_attempts = teleport_attempts + 1 
  691. 		vehicle_enter_teleport(character, vehicle, seat_index) 
  692. 		delay(delay_length) 
  693. 	end 
  694.  
  695. end 
  696.  
  697. -- Doors usually close on chunk load/reload... this keeps them open. 
  698. function rn05_keep_doors_open() 
  699. 	while (true) do 
  700. 		door_open(MM_DOOR_AIRPORT_1) 
  701. 		door_open(MM_DOOR_AIRPORT_2) 
  702. 		thread_yield() 
  703. 	end 
  704. end 
  705.  
  706.  
  707. -- Stage 1 functions 
  708. Radio_dialogue_vehicle = "" 
  709.  
  710. function rn05_play_drive_dialogue() 
  711.  
  712. 	local function rn05_in_same_vehicle() 
  713. 		local player_vehicle = get_char_vehicle_name(LOCAL_PLAYER) 
  714. 		if (player_vehicle ~= "") then 
  715. 			return player_vehicle == get_char_vehicle_name(CHARACTER_PIERCE) 
  716. 		else 
  717. 			return false 
  718. 		end 
  719. 	end 
  720.  
  721. 	-- Wait for the players to get in the same vehicle 
  722. 	while(not (rn05_in_same_vehicle())) do 
  723. 		thread_yield() 
  724. 	end 
  725. 	 
  726. 		 
  727. 	delay(5) 
  728. 	local player_vehicle = get_char_vehicle_name(LOCAL_PLAYER) 
  729. 		 
  730. 	if (rn05_in_same_vehicle()) then 
  731. 		radio_set_station(player_vehicle, DEFAULT_RADIO_STATION) 
  732. 	end 
  733. 	 
  734. 	delay(2) 
  735. 	audio_play_conversation( INTRO_CONVERSATION) 
  736. 	delay(10) 
  737. 	 
  738. 	--figure out what station the player is listening to and if its the one Pierce likes then redefine what he likes 
  739. 	local player_station = radio_get_station(get_char_vehicle_name(LOCAL_PLAYER)) 
  740. 	local pierce_station = PIERCE_PREFERRED_STATION_1 
  741. 		 
  742. 	if (player_station == pierce_station) then 
  743. 		pierce_station = PIERCE_PERFERRED_STATION_2 
  744. 	end 
  745. 	 
  746. 	--Have the player and Pierce change the station while they argue about it. 
  747. 	if (rn05_in_same_vehicle()) then 
  748. 		audio_play_conversation(RADIO_CONVERSATION1) 
  749. 		radio_set_station(player_vehicle, pierce_station) 
  750. 		delay(2) 
  751. 	end 
  752. 	if (rn05_in_same_vehicle()) then 
  753. 		audio_play_conversation(RADIO_CONVERSATION2) 
  754. 	end 
  755. 	if (rn05_in_same_vehicle()) then 
  756. 		radio_set_station(player_vehicle, player_station) 
  757. 		audio_play_conversation(RADIO_CONVERSATION3) 
  758. 	end 
  759.  
  760. end 
  761.  
  762. Rn05_location_reached		= false 
  763. Rn05_current_trigger			= 1 
  764. Rn05_breadcrumb_triggers	= {} 
  765. Rn05_breadcrumb_helptext	= {} 
  766. Rn05_breadcrumb_effect		= "" 
  767. function rn05_send_to_location(trigger, effect, helptext, time, time_failure_function) 
  768.  
  769. 	Rn05_location_reached = false 
  770. 	Rn05_breadcrumb_effect = false 
  771. 	if (effect) then 
  772. 		Rn05_breadcrumb_effect = effect 
  773. 	end 
  774. 	Rn05_current_trigger = 1 
  775. 	Rn05_breadcrumb_triggers = {} 
  776. 	Rn05_breadcrumb_helptext = {} 
  777.  
  778. 	-- Place triggers into a global table variable 
  779. 	if ((type(trigger) == "table")) then 
  780. 		Rn05_breadcrumb_triggers = trigger 
  781. 	else 
  782. 		Rn05_breadcrumb_triggers[1] = trigger 
  783. 	end 
  784.  
  785. 	-- Same for helptext 
  786. 	if ((type(helptext) == "table")) then 
  787. 		Rn05_breadcrumb_helptext = helptext 
  788. 	else 
  789. 		Rn05_breadcrumb_helptext[1] = helptext 
  790. 	end 
  791.  
  792. 	-- Add callbacks for all triggers, special callback for final trigger 
  793. 	local num_breadcrumbs = sizeof_table(Rn05_breadcrumb_triggers) 
  794. 	for i,breadcrumb in pairs(Rn05_breadcrumb_triggers) do 
  795. 		trigger_enable(breadcrumb,true) 
  796. 		if (i == num_breadcrumbs) then 
  797. 			on_trigger("rn05_toggle_location_reached",breadcrumb)					 
  798. 		else 
  799. 			on_trigger("rn05_breadcrumb_reached", breadcrumb) 
  800. 		end 
  801. 	end 
  802.  
  803. 	if (effect) then 
  804. 		marker_add_trigger(Rn05_breadcrumb_triggers[Rn05_current_trigger],MINIMAP_ICON_LOCATION,effect,SYNC_ALL) 
  805. 		mission_waypoint_add( Rn05_breadcrumb_triggers[Rn05_current_trigger], SYNC_ALL ) 
  806. 	end 
  807.  
  808. 	-- Setup the time restraint if there is one. 
  809. 	if (time and time_failure_function) then 
  810. 		hud_timer_set(0, time, time_failure_function) 
  811. 	end 
  812.  
  813. 	-- Display helptext 
  814. 	if (Rn05_breadcrumb_helptext[1]) then 
  815. 		mission_help_table(Rn05_breadcrumb_helptext[1]) 
  816. 	end 
  817.  
  818. 	-- Wait for player to arrive at the location 
  819. 	while (not Rn05_location_reached) do 
  820. 		thread_yield() 
  821. 	end 
  822. 	hud_timer_stop(0) 
  823.  
  824. 	Rn05_location_reached = false 
  825. end 
  826.  
  827. function rn05_breadcrumb_reached(triggerer, trigger) 
  828.  
  829. 	-- Disable all breadcrumbs up to and including the one that we just hit 
  830. 	for i = Rn05_current_trigger, sizeof_table(Rn05_breadcrumb_triggers), 1 do 
  831. 		local breadcrumb = Rn05_breadcrumb_triggers[i] 
  832. 		trigger_enable(breadcrumb,false) 
  833. 		on_trigger("",trigger) 
  834. 		marker_remove_trigger(trigger, SYNC_ALL) 
  835. 		Rn05_current_trigger = i+1 
  836. 		if(Rn05_breadcrumb_triggers[i] == trigger) then 
  837. 			break 
  838. 		end 
  839. 	end 
  840.  
  841. 	-- Display helptext for the just-hit trigger. 
  842. 	if (Rn05_breadcrumb_helptext[trigger]) then 
  843. 		mission_help_table(Rn05_breadcrumb_helptext[trigger]) 
  844. 	end 
  845.  
  846. 	mission_waypoint_remove() 
  847.  
  848. 	-- Add an effect to the next trigger 
  849. 	if (Rn05_breadcrumb_effect) then 
  850. 		marker_add_trigger(Rn05_breadcrumb_triggers[Rn05_current_trigger],MINIMAP_ICON_LOCATION,Rn05_breadcrumb_effect,SYNC_ALL) 
  851. 		mission_waypoint_add( Rn05_breadcrumb_triggers[Rn05_current_trigger], SYNC_ALL ) 
  852. 	end 
  853. end 
  854.  
  855. function rn05_toggle_location_reached(triggerer,trigger) 
  856.  
  857. 	-- disable all breadcrumb triggers 
  858. 	for i = Rn05_current_trigger, sizeof_table(Rn05_breadcrumb_triggers), 1 do 
  859. 		local breadcrumb = Rn05_breadcrumb_triggers[i] 
  860. 		trigger_enable(breadcrumb,false) 
  861. 		on_trigger("",trigger) 
  862. 		marker_remove_trigger(trigger, SYNC_ALL) 
  863. 	end 
  864.  
  865. 	Rn05_location_reached = true		 
  866. 	--trigger_enable(trigger, false) 
  867. 	--marker_remove_trigger(trigger, SYNC_ALL) 
  868. 	--on_trigger("",trigger) 
  869.  
  870. 	mission_waypoint_remove() 
  871. end 
  872.  
  873. -- Stage 2 functions 
  874.  
  875. -- Wait a bit and then cause passengers to disembark from the plane. 
  876. function rn05_gate_c1_disembark(delay_ms) 
  877.  
  878. 	-- Wait a bit 
  879. 	delay(delay_ms * .001) 
  880.  
  881. 	-- Unlock and open airport terminal doors... 
  882. 	door_lock(MOVER_DOOR_GATE_C1_1, false) 
  883. 	door_lock(MOVER_DOOR_GATE_C1_2, false) 
  884. 	door_open(MOVER_DOOR_GATE_C1_1) 
  885. 	door_open(MOVER_DOOR_GATE_C1_2) 
  886. 	-- Start disembarking 
  887. 	local num_destination_navpoints = sizeof_table(NAVPOINT_CIVILIAN_ARRIVAL_DESTINATIONS) 
  888. 	for i,passenger in pairs(MEMBERS_GROUP_PASSENGERS_GATE_C1) do 
  889. 		thread_new(	"rn05_passenger_dismbark", 
  890. 						passenger,  
  891. 						NAVPOINT_CIVILIAN_ARRIVAL_DESTINATIONS[rand_int(1,num_destination_navpoints)], 
  892. 						true) 
  893. 	end 
  894. 	num_destination_navpoints = sizeof_table(NAVPOINT_LIEUTENANT_ARRIVAL_DESTINATIONS) 
  895. 	for i,lieutenant in pairs(MEMBERS_GROUP_RONIN_LTNTS_GATE_C1) do 
  896. 		thread_new(	"rn05_passenger_dismbark", 
  897. 						lieutenant,  
  898. 						NAVPOINT_LIEUTENANT_ARRIVAL_DESTINATIONS[rand_int(1,num_destination_navpoints)], 
  899. 						false) 
  900. 	end 
  901.  
  902. 	-- Everyone is off the plane, player decides to take out the ltnts if any remain. 
  903. 	local ltnts_remain = false 
  904. 	for i, lieutenant in pairs (MEMBERS_GROUP_RONIN_LTNTS_GATE_C1) do 
  905. 		if (not character_is_dead(lieutenant)) then 
  906. 			ltnts_remain = true 
  907. 			break 
  908. 		end 
  909. 	end 
  910.  
  911. 	-- Player(s) kill lieutenants are remaining at this point. 
  912. 	rn05_process_enemy_set(MEMBERS_GROUP_RONIN_LTNTS_GATE_C1, HELPTEXT_PROMPT_KILL_LTNTS, HELPTEXT_OBJECTIVE_LTNTS) 
  913.  
  914. 	Gate_c1_ltnts_killed = true 
  915. end 
  916.  
  917. function rn05_passenger_dismbark(passenger, destination, is_ped) 
  918. 	if (is_ped == true) then 
  919. 		flee_to_navpoint(passenger, destination) 
  920. 		release_to_world(passenger) 
  921. 	else 
  922. 		set_blitz_flag(passenger,true) 
  923. 		attack(passenger) 
  924. 		npc_leash_to_nav(passenger, destination, 10) 
  925. 	end 
  926. end 
  927.  
  928. function rn05_player_enter_gate_c3_area() 
  929. 	Players_near_gate_c3 = Players_near_gate_c3 + 1	 
  930. end 
  931.  
  932. function rn05_player_exit_gate_c3_area() 
  933. 	Players_near_gate_c3 = Players_near_gate_c3 - 1	 
  934. end 
  935.  
  936. -- Stage 3 functions 
  937.  
  938. function rn05_setup_ronin_escape_vehicle(escape_vehicle) 
  939. 	vehicle_never_flatten_tires(escape_vehicle, true) 
  940. 	vehicle_suppress_npc_exit(escape_vehicle, true) 
  941. 	vehicle_prevent_explosion_fling(escape_vehicle,true) 
  942. 	vehicle_set_allow_ram_ped(escape_vehicle,true) 
  943. 	vehicle_set_crazy(escape_vehicle,true) 
  944. 	vehicle_set_use_short_cuts(escape_vehicle, true) 
  945. 	vehicle_infinite_mass(escape_vehicle, true) 
  946. 	vehicle_ignore_repulsors(escape_vehicle, true) 
  947. 	vehicle_disable_chase(escape_vehicle, true) 
  948. end 
  949.  
  950. function rn05_ronin_escape() 
  951.  
  952. 	-- Override the cart's target speed when approaching stairs, throttle max speed when  
  953. 	-- the players are too far away. 
  954. 	local cart_speed_override_thread = thread_new("rn05_ronin_cart_override_speed_near_stairs") 
  955. 	local cart_speed_throttle_thread = thread_new("rn05_escape_vehicle_dist_throttle") 
  956. 	thread_new("rn05_monitor_dist_failure") 
  957.  
  958. 	-- Pierce has a lot to say 
  959. 	local pierce_cart_blather_thread = thread_new("rn05_pierce_cart_blather") 
  960.  
  961. 	-- The Ronin drive out of the airport and then flee the nearest player. 
  962. 	vehicle_pathfind_to(VEHICLE_RONIN_CART,ESCAPE_PATH2, true, false) 
  963.  
  964. 	-- Kill cart speed monitoring threads so that we can take over during the jump 
  965. 	thread_kill(cart_speed_override_thread) 
  966. 	thread_kill(cart_speed_throttle_thread) 
  967.  
  968. 	-- Make sure that the speed override is canceled and that speed isn't throttled 
  969. 	vehicle_speed_cancel(VEHICLE_RONIN_CART) 
  970.  
  971. 	-- We need the cart to drive off a ledge. To do this, we have the vehicle pathfind to a navpoint 
  972. 	-- just before the ledge. We tell the vehicle not to stop at the end of the path, and we override 
  973. 	-- its speed so that it doesn't slow down and go another way. 
  974. 	vehicle_max_speed(VEHICLE_RONIN_CART, rn05_get_parameter_value("RONIN_CART_SPEED_JUMP_MPH")) 
  975. 	vehicle_speed_override(VEHICLE_RONIN_CART, rn05_get_parameter_value("RONIN_CART_SPEED_JUMP_MPH")) 
  976. 	vehicle_pathfind_to(VEHICLE_RONIN_CART, "rn05_$n014", true, false) 
  977.  
  978. 	-- Wait a little bit to give the cart time to get airborn. 
  979. 	delay(.5) 
  980. 	vehicle_speed_cancel(VEHICLE_RONIN_CART) 
  981. 	vehicle_max_speed(VEHICLE_RONIN_CART, rn05_get_parameter_value("RONIN_CART_NORMAL_MAX_SPEED")) 
  982.  
  983. 	-- Retart throttling the Ronin's max speed when too far from the play. 
  984. 	cart_speed_throttle_thread = thread_new("rn05_escape_vehicle_dist_throttle") 
  985.  
  986. 	--[[ TODO 11/14 replace this code, the delay is a hack to fix vehicle_in_air being broken. 
  987. 	-- Wait for the cart to land before doing any more pathfinding. 
  988. 	while (vehicle_in_air(VEHICLE_RONIN_CART)) do 
  989. 		thread_yield() 
  990. 	end 
  991. 	]] 
  992. 	-- TODO 11/14 when vehicle_in_air works, remove this delay 
  993. 	delay(4.0) 
  994.  
  995. 	-- Pathfind to the edge of the freight room. Pathfinding currently has problems crossing the 
  996. 	-- boundaries between interiors using super chunks, and regular exterior chunks. The cart is 
  997. 	-- set to not stop at the end of the path, so we can wait for its momentum to carry it into 
  998. 	-- the next chunk. 
  999. 	vehicle_pathfind_to(VEHICLE_RONIN_CART, {"rn05_$n015", "rn05_$n016", "rn05_$n017",  
  1000. 		"rn05_$n018", "rn05_$n019"}, true, false) 
  1001. 	vehicle_speed_override(VEHICLE_RONIN_CART, 30) 
  1002. 	delay(0.5) 
  1003. 	vehicle_speed_cancel(VEHICLE_RONIN_CART) 
  1004.  
  1005. 	-- Same trick 
  1006. 	vehicle_pathfind_to(VEHICLE_RONIN_CART, "rn05_$n020", true, false) 
  1007. 	vehicle_speed_override(VEHICLE_RONIN_CART, 30) 
  1008. 	delay(0.5) 
  1009. 	vehicle_speed_cancel(VEHICLE_RONIN_CART) 
  1010.  
  1011. 	-- Some of the cart lines sound better inside the aiport... so kill that thread off now 
  1012. 	-- that we're outside 
  1013. 	thread_kill(pierce_cart_blather_thread) 
  1014.  
  1015. 	-- The Cart is outside now, the ronin should get out and jump on the motorcycle 
  1016. 	vehicle_suppress_npc_exit(VEHICLE_RONIN_CART, false) 
  1017. 	vehicle_stop(VEHICLE_RONIN_CART,false) 
  1018. 	if (not character_is_dead(CHARACTER_CART_DRIVER)) then 
  1019. 		vehicle_exit(CHARACTER_CART_DRIVER) 
  1020. 	end 
  1021. 	if (not character_is_dead(CHARACTER_CART_PASSENGER)) then 
  1022. 		vehicle_exit(CHARACTER_CART_PASSENGER) 
  1023. 	end 
  1024. 	vehicle_enter_group({CHARACTER_CART_DRIVER, CHARACTER_CART_PASSENGER}, VEHICLE_RONIN_BIKE) 
  1025. 	Escape_vehicle = VEHICLE_RONIN_BIKE 
  1026.  
  1027. 	local dist, player = get_dist_closest_player_to_object(VEHICLE_RONIN_BIKE) 
  1028. 	vehicle_flee(VEHICLE_RONIN_BIKE, player) 
  1029.  
  1030. end 
  1031.  
  1032. -- Override the Cart's target speed near stairwells so that it doesn't go flying off into 
  1033. -- a wall 
  1034. function rn05_ronin_cart_override_speed_near_stairs() 
  1035.  
  1036. 	-- Navpoints at the top of the stairwells that we'll slow as we approach 
  1037. 	local slow_navpoints					= {"rn05_$n007", "rn05_$n011"} 
  1038.  
  1039. 	-- Distance from these navpoints at which speed should be throttled. 
  1040. 	local navpoint_override_dist	= {	["rn05_$n007"] = 15, 
  1041. 													["rn05_$n011"] = 15} 
  1042.  
  1043. 	-- Slow down when this close to the corresponding navpoint. 
  1044. 	local stop_override_dist		= {	["rn05_$n007"] = 5, 
  1045. 													["rn05_$n011"] = 0} 
  1046.  
  1047. 	-- Speed to slow down to. 
  1048. 	local navpoint_override_speed	= {	["rn05_$n007"] = 15, 
  1049. 													["rn05_$n011"] = 20} 
  1050.  
  1051. 	-- Closest distance that the Ronin cart has been to the navpoint. If the cart starts 
  1052. 	-- getting further away, we can go back to normal speed. 
  1053. 	local navpoint_closest_dist	= {	["rn05_$n007"] = 100, 
  1054. 													["rn05_$n011"] = 100} 
  1055.  
  1056. 	-- Is the cart's speed currently overriden? 
  1057. 	local speed_is_overriden = false 
  1058.  
  1059. 	while (not vehicle_is_destroyed(VEHICLE_RONIN_CART)) do 
  1060.  
  1061. 		-- Speed we should override to 
  1062. 		local override_speed = 100 
  1063.  
  1064. 		-- Should we be overriding speed now 
  1065. 		local should_override_speed = false 
  1066.  
  1067. 		-- See if we're nearing one of the navpoints that we should approach slowly. 
  1068. 		for i,navpoint in pairs (slow_navpoints) do 
  1069. 			 
  1070. 			-- get distance to the current navpoint 
  1071. 			local cur_dist = get_dist(VEHICLE_RONIN_CART,navpoint) 
  1072.  
  1073. 			-- If (1) within range AND (2) don't have slower speed from previous navpoint AND 
  1074. 			-- (3) not getting further from the navpoint, then override speed. 
  1075. 			if (	cur_dist < navpoint_override_dist[navpoint] and  
  1076. 					navpoint_override_speed[navpoint] < override_speed and 
  1077. 					cur_dist < navpoint_closest_dist[navpoint]) then 
  1078.  
  1079. 				-- Record new closest distance 
  1080. 				navpoint_closest_dist[navpoint] = cur_dist 
  1081.  
  1082. 				-- If we haven't gotten close so close that we should stop overriding the speed 
  1083. 				if (cur_dist > stop_override_dist[navpoint]) then 
  1084.  
  1085. 					-- Record the new speed override 
  1086. 					override_speed = navpoint_override_speed[navpoint] 
  1087. 					should_override_speed = true 
  1088. 				end 
  1089. 			end 
  1090. 		end 
  1091.  
  1092. 		-- Start overriding speed if we weren't already and we need to 
  1093. 		if (should_override_speed and (not speed_is_overriden)) then 
  1094. 			vehicle_speed_override(VEHICLE_RONIN_CART, override_speed) 
  1095. 			speed_is_overriden = true 
  1096. 		-- Otherwise, if we were throttling and shouldn't be, then stop 
  1097. 		elseif (speed_is_overriden and (not should_override_speed)) then 
  1098. 			vehicle_speed_cancel(VEHICLE_RONIN_CART) 
  1099. 			speed_is_overriden = false 
  1100. 		end 
  1101. 		thread_yield() 
  1102. 	end 
  1103. end 
  1104.  
  1105. function rn05_pierce_cart_blather() 
  1106.  
  1107. 	-- Pierce isn't in the cart in coop. 
  1108. 	if(IN_COOP) then 
  1109. 		return 
  1110. 	end 
  1111.  
  1112. 	local blather_chance = rn05_get_parameter_value("PIERCE_BLATHER_CHANCE") 
  1113.  
  1114. 	while(true) do 
  1115.  
  1116. 		if(rand_float(0,1) < blather_chance and character_is_in_vehicle(CHARACTER_PIERCE, VEHICLE_PLAYER_CART)) then 
  1117. 			rn05_persona_line_wrapper("PIERCE_RON5_CHASE", CHARACTER_PIERCE, false) 
  1118. 		end 
  1119. 		delay(5.0) 
  1120. 		thread_yield() 
  1121. 	end 
  1122. end 
  1123.  
  1124. -- Monitor the distance between the player(s) and the escaping Ronin. Controls the 
  1125. -- timer and displays hud messages for the out-of-range failure condition. 
  1126. function rn05_monitor_dist_failure() 
  1127.  
  1128. 	local prev_escape_vehicle = "" 
  1129.  
  1130. 	local failure_dist = {	[VEHICLE_RONIN_CART] = rn05_get_parameter_value("RONIN_CART_FAILURE_DIST"), 
  1131. 									[VEHICLE_RONIN_BIKE] = rn05_get_parameter_value("RONIN_BIKE_FAILURE_DIST"), 
  1132. 								} 
  1133.  
  1134. 	local failure_time_ms = 1000 * rn05_get_parameter_value("RONIN_DIST_FAILURE_TIME_S") 
  1135.  
  1136. 	Timing_dist_failure = false 
  1137.  
  1138. 	while(not vehicle_is_destroyed(Escape_vehicle)) do 
  1139.  
  1140. 		-- Update the distance radar if we've switched vehicles 
  1141. 		if (Escape_vehicle ~= prev_escape_vehicle) then 
  1142. 			distance_display_off(SYNC_ALL) 
  1143. 			distance_display_on(Escape_vehicle,0,failure_dist[Escape_vehicle],0.0,failure_dist[Escape_vehicle], SYNC_ALL) 
  1144. 			prev_escape_vehicle = prev_escape_vehicle 
  1145. 		end 
  1146.  
  1147. 		local dist = get_dist_closest_player_to_object(Escape_vehicle) 
  1148.  
  1149. 		if (dist > failure_dist[Escape_vehicle] and not Timing_dist_failure and rn05_enemies_living > 0) then 
  1150.  
  1151. 			-- Tell the player(s) to catch up. 
  1152. 			mission_help_table(HELPTEXT_PROMPT_WARN_DIST, "", "", SYNC_LOCAL) 
  1153.  
  1154. 			-- Start the timer 
  1155. 			hud_timer_set(0, failure_time_ms,"rn05_ronin_escaped_failure") 
  1156. 			Timing_dist_failure = true 
  1157.  
  1158. 		elseif (dist < failure_dist[Escape_vehicle] and Timing_dist_failure) then 
  1159.  
  1160. 			-- Stop the timer 
  1161. 			hud_timer_stop(0) 
  1162. 			Timing_dist_failure = false 
  1163.  
  1164. 			-- Update the objective text 
  1165. 			objective_text(0, rn05_enemy_set_objective_helptext, rn05_enemies_to_kill - rn05_enemies_living, rn05_enemies_to_kill) 
  1166.  
  1167. 		end 
  1168.  
  1169. 		thread_yield() 
  1170. 	end 
  1171.  
  1172. end 
  1173.  
  1174. -- Throttle the Ronin escape vehicle's speed if it is too far from the player(s) 
  1175. function rn05_escape_vehicle_dist_throttle() 
  1176.  
  1177. 	local param_prefix = "RONIN_CART_" 
  1178. 	if(Escape_vehicle == VEHICLE_RONIN_BIKE) then 
  1179. 		param_prefix = "RONIN_BIKE_" 
  1180. 	end 
  1181.  
  1182. 	-- Get the vehicle's non-throttled max speed, the distance at which we throttle, and the speed we throttle to 
  1183. 	local normal_speed	= rn05_get_parameter_value(param_prefix .. "NORMAL_MAX_SPEED") 
  1184. 	local throttle_dist	= rn05_get_parameter_value(param_prefix .. "THROTTLE_DIST") 
  1185. 	local throttle_speed = rn05_get_parameter_value(param_prefix .. "THROTTLE_SPEED") 
  1186.  
  1187. 	-- Is the vehicle's speed currently throttled? 
  1188. 	local speed_is_throttled = false 
  1189.  
  1190. 	-- Set the vehicle's initial max speed. 
  1191. 	local initial_throttled_speed = 0 
  1192. 	speed_is_throttled, initial_throttled_speed	= rn05_get_escape_vehicle_dist_throttle(throttle_dist, throttle_speed) 
  1193. 	if (speed_is_throttled) then 
  1194. 		vehicle_max_speed(Escape_vehicle, initial_throttled_speed) 
  1195. 	end 
  1196.  
  1197. 	-- Monitor distance and adjust speed accordingly. 
  1198. 	while (not vehicle_is_destroyed(Escape_vehicle)) do 
  1199.  
  1200. 		-- See if we need to throttle the speed because we're too far from the player(s): 
  1201. 		local should_throttle_speed, throttled_speed = rn05_get_escape_vehicle_dist_throttle(throttle_dist, throttle_speed) 
  1202.  
  1203. 		-- Throttle speed if we need to 
  1204. 		if (should_throttle_speed and (not speed_is_throttled)) then 
  1205. 			speed_is_throttled = true 
  1206. 			vehicle_max_speed(Escape_vehicle, throttled_speed) 
  1207. 		-- Otherwise, if we were throttling, then stop 
  1208. 		elseif (speed_is_throttled and (not should_throttle_speed)) then 
  1209. 			speed_is_throttled = false 
  1210. 			vehicle_max_speed(Escape_vehicle, normal_speed) 
  1211. 		end 
  1212. 		thread_yield() 
  1213. 	end 
  1214. end 
  1215.  
  1216. -- Returns 2 values: shouldThrottle, throttleSpeed 
  1217. -- shouldThrottle = should we throttle the bike based on the distance to the player? 
  1218. --  
  1219. function rn05_get_escape_vehicle_dist_throttle(throttle_dist, throttle_speed) 
  1220. 	local dist = get_dist_closest_player_to_object(Escape_vehicle) 
  1221. 	if (dist > throttle_dist) then 
  1222. 		return true,throttle_speed 
  1223. 	else 
  1224. 		return false, 0 
  1225. 	end 
  1226. end 
  1227.  
  1228.  
  1229. --[[ 
  1230. function rn05_gate_ronin_attack() 
  1231.  
  1232. 	for i, ronin in pairs(MEMBERS_GROUP_RONIN_GATE_C1) do 
  1233. 		attack_safe(ronin) 
  1234. 	end 
  1235.  
  1236. end 
  1237. ]] 
  1238. rn05_enemies_to_kill = 0 
  1239. rn05_enemies_living = 0 
  1240. rn05_enemy_set_objective_helptext = "" 
  1241.  
  1242. -- Wait for the player to kill a group of enemies 
  1243. --  
  1244. -- enemy_table				A table containing the names of the enemies that need to be killed 
  1245. -- mission_helptext		The helptext message that will prompt the player(s) to kill the enemies 
  1246. -- objective_helptext	The objective text displayed in the hud, needs to be in the format %s of %s killed 
  1247. function rn05_process_enemy_set(enemy_table, mission_helptext, objective_helptext) 
  1248.  
  1249. 	-- Setup kill tracking numbers 
  1250. 	rn05_enemies_to_kill = sizeof_table(enemy_table) 
  1251. 	rn05_enemies_living =  0	-- We'll count living enemies when assigning callbacks in case the player already 
  1252. 										-- killed some. 
  1253.  
  1254. 	-- Assign enemy callbacks, add markers 
  1255. 	for i, enemy in pairs(enemy_table) do 
  1256. 		if ( not character_is_dead(enemy)) then 
  1257. 			on_death("rn05_enemy_killed", enemy) 
  1258. 			marker_add_npc(enemy, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL)  
  1259. 			rn05_enemies_living = rn05_enemies_living + 1 
  1260. 		end 
  1261. 	end 
  1262.  
  1263. 	if (rn05_enemies_living > 0) then 
  1264.  
  1265. 		-- Display the objective text 
  1266. 		if(objective_helptext and not (Timing_dist_failure)) then 
  1267. 			rn05_enemy_set_objective_helptext = objective_helptext 
  1268. 			objective_text(0, rn05_enemy_set_objective_helptext, rn05_enemies_to_kill - rn05_enemies_living, rn05_enemies_to_kill) 
  1269. 		end 
  1270.  
  1271. 		-- Display the help text 
  1272. 		if(mission_helptext) then 
  1273. 			mission_help_table(mission_helptext) 
  1274. 		end 
  1275.  
  1276. 	end 
  1277.  
  1278. 	while (rn05_enemies_living > 0) do 
  1279. 		thread_yield() 
  1280. 	end 
  1281.  
  1282. 	if(objective_helptext) then 
  1283. 		objective_text_clear(0) 
  1284. 	end 
  1285.  
  1286. end 
  1287.  
  1288. function rn05_enemy_killed(enemy) 
  1289. 	marker_remove_npc(enemy) 
  1290. 	on_death("",enemy) 
  1291. 	rn05_enemies_living = rn05_enemies_living - 1 
  1292. 	if (rn05_enemies_living < 1) then 
  1293. 		objective_text_clear(0) 
  1294. 		hud_timer_stop(0) 
  1295. 		rn05_enemy_set_objective_helptext = "" 
  1296. 	else 
  1297. 		if (rn05_enemy_set_objective_helptext ~= "" and (not Timing_dist_failure)) then 
  1298. 			objective_text(0, rn05_enemy_set_objective_helptext, rn05_enemies_to_kill - rn05_enemies_living, rn05_enemies_to_kill) 
  1299. 		end 
  1300. 	end 
  1301.  
  1302. 	-- If the cart's driver is killed, make the passenger get out and flee 
  1303. 	if (enemy == CHARACTER_CART_DRIVER) then 
  1304. 		if (not character_is_dead(CHARACTER_CART_PASSENGER)) then 
  1305.  
  1306. 			thread_kill(Thread_ronin_escape) 
  1307.  
  1308. 			vehicle_suppress_npc_exit(Escape_vehicle, false) 
  1309.  
  1310. 			if (character_is_in_vehicle(CHARACTER_CART_PASSENGER)) then 
  1311. 				vehicle_exit(CHARACTER_CART_PASSENGER) 
  1312. 			end 
  1313.  
  1314. 			-- Just attack. 
  1315. 			if (not character_is_dead(CHARACTER_CART_PASSENGER)) then 
  1316. 				attack(CHARACTER_CART_PASSENGER) 
  1317. 			end 
  1318.  
  1319. 		end 
  1320. 	end 
  1321.  
  1322. end 
  1323.  
  1324. -- Other functions 
  1325.  
  1326. function rn05_cleanup() 
  1327.  
  1328. 	-- Reenable ped and vehicle spawning 
  1329. 	spawning_pedestrians(true, true) 
  1330. 	spawning_vehicles(true)	 
  1331.  
  1332. 	-- Reset the radio 
  1333. 	if ((Radio_dialogue_vehicle ~= "") and (not vehicle_is_destroyed(Radio_dialogue_vehicle))) then 
  1334. 		vehicle_set_radio_controls_locked(Radio_dialogue_vehicle, false) 
  1335. 	end 
  1336.  
  1337.  
  1338. 	-- reset global variables 
  1339.  
  1340. 	-- reset notoriety 
  1341. 		 
  1342. 	-- remove markers 
  1343. 		marker_remove_navpoint( NAVPOINT_ARRIVAL_GATE) 
  1344.  
  1345. 	-- remove callbacks 
  1346.  
  1347. 		-- remove pierce's callbacks 
  1348. 		on_death("", CHARACTER_PIERCE) 
  1349. 		on_dismiss("", CHARACTER_PIERCE) 
  1350.  
  1351. 		-- disable all triggers, remove callbacks, remove from map 
  1352. 		for i, trigger in pairs(TABLE_ALL_TRIGGERS) do 
  1353. 			on_trigger("",trigger) 
  1354. 			trigger_enable(trigger,false) 
  1355. 			marker_remove_trigger(trigger) 
  1356. 		end 
  1357. 	 
  1358. 	--turn off timers 
  1359. 	hud_timer_stop(0) 
  1360. 	 
  1361. 	 
  1362. 	-- destroy/release groups as appropriate 
  1363. 		for i,group in pairs(TABLE_RELEASE_GROUPS) do 
  1364. 			release_to_world(group) 
  1365. 		end 
  1366. 		for i,group in pairs(TABLE_DESTROY_GROUPS) do 
  1367. 			group_destroy(group) 
  1368. 		end 
  1369. 		if (IN_COOP) then 
  1370. 			for i,group in pairs(TABLE_COOP_DESTROY_GROUPS) do 
  1371. 				group_destroy(group) 
  1372. 			end 
  1373. 			for i,group in pairs(TABLE_COOP_RELEASE_GROUPS) do 
  1374. 				release_to_world(group) 
  1375. 			end 
  1376. 		end 
  1377. end 
  1378.  
  1379. function rn05_success() 
  1380. 	-- Called when the mission has ended with success 
  1381. end 
  1382.  
  1383. function rn05_complete() 
  1384.  
  1385. 	-- Outro conversation, Pierce isn't around in coop 
  1386. 	if(not IN_COOP) then 
  1387. 		audio_play_conversation(OUTRO_CONVERSATION) 
  1388. 	end 
  1389.  
  1390. 	-- Play the success movie 
  1391. 	delay(.5) 
  1392. 	--bink_play_movie("ro05-2.bik") 
  1393.  
  1394. 	-- End the mission with success 
  1395. 	mission_end_success("rn05", "ro05-02", {NAVPOINT_END_SUCCESS, NAVPOINT_END_SUCCESS}) 
  1396. end 
  1397.  
  1398. -- Get the value of the mission parameter. 
  1399. -- 
  1400. -- parameter	Mission parameter whose value the function should return 
  1401. --	i				If the parameter is a table, then i indexes the entry that should be returned 
  1402. -- 
  1403. -- Returns mission paramater value. 
  1404. function rn05_get_parameter_value(parameter, i) 
  1405.  
  1406. 	local return_val = nil 
  1407.  
  1408. 	-- Check for a coop value: 
  1409. 	if (IN_COOP) then 
  1410. 		if (i) then 
  1411. 			if (RN05_PARAMETERS["COOP_" .. parameter] ~= nil) then 
  1412. 				return_val = RN05_PARAMETERS["COOP_" .. parameter][i] 
  1413. 			end 
  1414. 		else 
  1415. 			return_val = RN05_PARAMETERS["COOP_" .. parameter] 
  1416. 		end 
  1417. 	end 
  1418.  
  1419. 	-- Get the standard value 
  1420. 	if (return_val == nil) then 
  1421. 		if (i) then 
  1422. 			if (RN05_PARAMETERS[parameter] ~= nil) then 
  1423. 				return_val = RN05_PARAMETERS[parameter][i] 
  1424. 			end 
  1425. 		else 
  1426. 			return_val = RN05_PARAMETERS[parameter] 
  1427. 		end 
  1428. 	end 
  1429.  
  1430. 	return return_val 
  1431. end 
  1432.  
  1433. function rn05_group_create_maybe_coop(group_always, group_coop, blocking) 
  1434. 	group_create(group_always, blocking) 
  1435. 	if (IN_COOP) then 
  1436. 		group_create(group_coop, blocking) 
  1437. 	end 
  1438. end 
  1439.  
  1440. function rn05_group_loaded_maybe_coop(group_always, group_coop) 
  1441. 	local group_always_is_loaded = group_is_loaded(group_always) 
  1442. 	if (IN_COOP) then 
  1443. 		return (group_always_is_loaded and group_is_loaded(group_always)) 
  1444. 	else 
  1445. 		return group_always_is_loaded 
  1446. 	end 
  1447. end 
  1448.  
  1449. function rn05_group_create_hidden_maybe_coop(group_always, group_coop) 
  1450. 	group_create_hidden(group_always) 
  1451. 	if (IN_COOP) then 
  1452. 		group_create_hidden(group_coop) 
  1453. 	end 
  1454. end 
  1455.  
  1456. function rn05_group_show_maybe_coop(group_always, group_coop) 
  1457. 	group_show(group_always) 
  1458. 	if (IN_COOP) then 
  1459. 		group_show(group_coop) 
  1460. 	end 
  1461. end 
  1462.  
  1463. function rn05_release_to_world_maybe_coop(always, coop) 
  1464. 	release_to_world(always) 
  1465. 	if (IN_COOP) then 
  1466. 		release_to_world(coop) 
  1467. 	end 
  1468. end 
  1469.  
  1470. function rn05_persona_line_wrapper(audio_name, character, blocking) 
  1471. 	audio_play_for_character(audio_name, character, "voice", false, blocking) 
  1472. end 
  1473.  
  1474. -- MISSION FAILURE FUNCTIONS -------------------------------- 
  1475.  
  1476. -- End the mission, Pierce abandoned 
  1477. function rn05_failure_pierce_abandoned() 
  1478. 	mission_end_failure("rn05", HELPTEXT_FAILURE_PIERCE_ABANDONED) 
  1479. end 
  1480.  
  1481. -- End the mission, Pierce died 
  1482. function rn05_failure_pierce_died() 
  1483. 	mission_end_failure("rn05", HELPTEXT_FAILURE_PIERCE_DIED) 
  1484. end 
  1485.  
  1486. -- End the mission, the player(s) didn't arrive at the airport in time 
  1487. function rn05_failure_airport_drive() 
  1488. 	mission_end_failure("rn05", HELPTEXT_FAILURE_AIRPORT_DRIVE) 
  1489. end 
  1490.  
  1491. -- End the mission, the player(s) were too far from the Ronin's escape 
  1492. -- cart for too long. 
  1493. function rn05_ronin_escaped_failure() 
  1494. 	mission_end_failure("rn05", HELPTEXT_FAILURE_VEHICLE_DIST) 
  1495. end 
  1496.