sr2lua/rn09.lua

  1. -- rn09.lua 
  2. -- SR2 mission script 
  3. -- 3/28/07 
  4.  
  5. -- DEBUG Variables 
  6. DEBUG_QUICK_KILLS							= false 
  7.  
  8.  
  9. -- Global constants (All caps == GLOBAL CONSTANT) 
  10. --[[	In general, shouldn't be modified in running code, except for maybe in a setup function ) 
  11.  
  12.  
  13.  
  14. ]] 
  15.  
  16. 	--[[ *** MISSION PARAMETERS *** 
  17. 	 
  18. 		Whenever a script function looks up a wave parameter, a naming convention is used to select the appropriate value. 
  19. 		Parameter values for single player missions can use any name, say "PARAMETER_1" for example. If you wish to have 
  20. 		a different value for that parameter in coop, then prepend "COOP" to the parameter name. In this case, we get 
  21. 		"COOP_PARAMETER_1". 
  22.  
  23. 		When a mission function needs to access "PARAMETER_1", it will search for the appropriate overloaded values first: 
  24.  
  25. 			*	Single player will use the value stored in "PARAMETER_1". 
  26. 		 
  27. 			*	Coop will use the value stored in "COOP_PARAMETER_1", if it exists. Otherwise it will use the 
  28. 				default single player value stored in "PARAMETER_1". 
  29. 	 ]] 
  30.  
  31. 	RN09_PARAMETERS	=  
  32. 		{	 
  33. 			-- Parameters used in both stages 
  34. 				-- Time at which the mission takes place 
  35. 				["TIME_OF_DAY_HOUR"]							= 20; 
  36. 				["TIME_OF_DAY_MINUTE"]						= 30; 
  37.  
  38. 				["RONIN_NOTORIETY"]							= 3;	-- Fixed notoriety level throughout the mission. 
  39. 				["COOP_RONIN_NOTORIETY"]					= 3;	 
  40.  
  41. 				["RONIN_DESIRED_VEHICLE_COUNT"]			= 1; 
  42. 				["COOP_RONIN_DESIRED_VEHICLE_COUNT"]	= 2; 
  43.  
  44. 				["SHOGO_HIT_POINTS"]							= 3500; 
  45. 				["COOP_SHOGO_HIT_POINTS"]					= 6000; 
  46.  
  47. 			-- Stage 1: faux boss fight w/ Shogo 
  48.  
  49. 			-- Stage 2: bike chase 
  50.  
  51. 				-- When chasing Shogo, player(s) must stay close to him. A timer starts when they are out of range, 
  52. 				-- The mission fails if the timer counts down to 0 before a player gets back in range. 
  53. 				["SHOGO_FLEE_DIST"]							= 65; -- The distance threshold 
  54. 				["SHOGO_FLEE_TIME_S"]						= 30; -- Timer duration 
  55.  
  56. 				-- There is an initial period during which Shogo drives slowly 
  57. 				["SHOGO_FLEE_INIT_MPH_TIME_S"]			= 5; -- Duration of slow driving 
  58. 				["SHOGO_FLEE_INIT_MPH"]						= 60; -- Slow driving speed 
  59. 		 
  60. 				-- After the initial period, Shogo's speed depends on player proximity. 
  61. 				["SHOGO_FLEE_FAST_MPH"]						= 75; -- Speed while players are in range 
  62. 				["SHOGO_FLEE_SLOW_MPH"]						= 55; -- Speed while players are out of range 
  63.  
  64. 				-- Vehicle density during the bike chase, 1.0 is the normal density for the area. 
  65. 				["SHOGO_FLEE_TRAFFIC_DENSITY"]			= .50; 
  66. 		} 
  67.  
  68. 	-- Coop mission? 
  69. 	IN_COOP	= false 
  70.  
  71. 	-- GROUPS -- 
  72. 		GROUP_GAT						= "rn09_$Ggat" 
  73. 		GROUP_SHOGO						= "rn09_$Gshogo" 
  74. 		GROUP_BIKER_FRIENDS			= "rn09_$Gbiker_friends" 
  75. 		GROUP_BIKER_FRIENDS_COOP	= "rn09_$Gbiker_friends_coop" 
  76. 		GROUP_CUTSCENE_1				= "rn09_$CTE_Gshogo" 
  77. 		GROUP_MOTORCYCLES_PLAYERS	= "rn09_$Gmotorcycles" 
  78. 		GROUP_MOTORCYCLES_SHOGO		= "rn09_$Gmotorcycles_shogo" 
  79. 		GROUP_CEMETARY_RONIN			= "rn09_$Gronin_cemetary" 
  80. 		GROUP_CEMETARY_RONIN_COOP	= "rn09_$Gronin_cemetary_coop" 
  81. 		GROUP_CUTSCENE_2				= "rn09_$GCTE2" 
  82. 		GROUP_CHASE_COURTESY_CAR	= "rn09_$Gchase_courtesy_car" 
  83. 	 
  84. 	-- GROUP MEMBER TABLES --  
  85.  
  86. 		TABLE_BIKER_FRIENDS			= {	"rn09_$Cbiker_friends_00", "rn09_$Cbiker_friends_01", "rn09_$Cbiker_friends_02", 
  87. 													"rn09_$Cbiker_friends_03", "rn09_$Cbiker_friends_04", "rn09_$Cbiker_friends_05"} 
  88.  
  89. 		TABLE_BIKER_FRIENDS_COOP	= {	"rn09_$Cbiker_friends_00 (0)", "rn09_$Cbiker_friends_00 (1)"} 
  90.  
  91. 		TABLE_CEMETARY_RONIN			= {	"rn09_$Cronin_cemetary_00", "rn09_$Cronin_cemetary_01", "rn09_$Cronin_cemetary_02", 
  92. 													"rn09_$Cronin_cemetary_03", "rn09_$Cronin_cemetary_04", "rn09_$Cronin_cemetary_05", 
  93. 													"rn09_$Cronin_cemetary_06", "rn09_$Cronin_cemetary_07", "rn09_$Cronin_cemetary_08", 
  94. 													"rn09_$Cronin_cemetary_09", "rn09_$Cronin_cemetary_10", "rn09_$Cronin_cemetary_11", 
  95. 													"rn09_$Cronin_cemetary_12", "rn09_$Cronin_cemetary_13", "rn09_$Cronin_cemetary_14", 
  96. 													"rn09_$Cronin_cemetary_15", "rn09_$Cronin_cemetary_16"} 
  97.  
  98. 		TABLE_CEMETARY_RONIN_COOP	= {	"rn09_$Cronin_cemetary_coop_00", "rn09_$Cronin_cemetary_coop_01",  
  99. 													"rn09_$Cronin_cemetary_coop_02", "rn09_$Cronin_cemetary_coop_03"} 
  100.  
  101. 	-- TRIGGERS --  
  102. 		TRIGGER_START_CHASE			= "rn09_$Tstart_chase" 
  103.  
  104. 		-- List of all triggers, makes cleaning up more convenient 
  105. 		TABLE_ALL_TRIGGERS			= {	TRIGGER_START_CHASE}		 
  106.  
  107. 	-- VEHICLES -- 
  108. 		VEHICLE_SHOGO_MOTORCYCLE			= "rn09_$Vshogo_motorcycle" 
  109. 		VEHICLE_LOCAL_PLAYER_MOTORCYCLE	= "rn09_$Vlocal_player" 
  110. 		VEHICLE_REMOTE_PLAYER_MOTORCYCLE	= "rn09_$Vremote_player" 
  111.  
  112.  
  113. 	-- CHARACTERS -- 
  114. 		CHARACTER_GAT				= "rn09_$Cgat" 
  115. 		CHARACTER_SHOGO			= "rn09_$Cshogo" 
  116.  
  117. 	-- NAVPOINTS 
  118.  
  119. 		-- the start location for Player 1 
  120. 		NAVPOINT_LOCAL_PLAYER_START		= "mission_start_sr2_city_$rn09" 
  121.  
  122. 		-- the start location for Player 2		 
  123. 		NAVPOINT_REMOTE_PLAYER_START		= "rn09_$Nremote_player_start" 
  124. 		 
  125. 		-- where Shogo heads after his health is halved in stage 1 
  126. 		NAVPOINT_SHOGO_FLEE_TARGET			= "rn09_$Nshogo_flee_target" 
  127.  
  128. 	-- MOVERS 
  129. 		MM_GARAGE_SIDE_DOOR						= "rn09_$MMgarage_side_door" 
  130.  
  131. 	-- CHECKPOINTS 
  132. 		CHECKPOINT_START							= MISSION_START_CHECKPOINT -- defined in ug_lib.lua 
  133. 		CHECKPOINT_GARAGE							= "rn08_checkpoint_garage" --  
  134.  
  135. 	-- localized helptext messages 
  136. 		HELPTEXT_FAILURE_SHOGO_FLED			= "rn09_failure_shogo_fled" 
  137. 		HELPTEXT_FAILURE_GAT_DIED				= "rn09_failure_gat_died" 
  138. 		HELPTEXT_FAILURE_GAT_DISMISSED		= "rn09_failure_gat_dismissed" 
  139. 		HELPTEXT_OBJECTIVE_CLEAN_CEMETARY	= "rn09_objective_clean_cemetary" 
  140. 		HELPTEXT_PROMPT_CHASE_SHOGO			= "rn09_prompt_chase_shogo" 
  141. 		HELPTEXT_PROMPT_FIND_SHOGO				= "rn09_prompt_find_shogo" 
  142. 		HELPTEXT_PROMPT_CLEAN_CEMETARY		= "rn09_prompt_clean_cemetary" 
  143. 		HELPTEXT_PROMPT_KILL_SHOGO				= "rn09_prompt_kill_shogo" 
  144. 		HELPTEXT_PROMPT_WARN_DISTANCE			= "rn09_prompt_warn_distance" 
  145. 		HELPTEXT_CHECKPOINT						= "rn09_checkpoint" 
  146.  
  147. 	-- helptext messages that need to be localized 
  148. 		HELPTEXT_HUD_SHOGO_HEALTH				=	"rn09_hud_shogo_health" 
  149. 	 
  150. -- Global Variables (First letter caps == Global Variable) 
  151.  
  152. 	Shogo_half_health					= false 
  153. 	Enemy_set_cleared					= false 
  154. 	Start_chase							= false 
  155. 	Timing_escape						= false 
  156. 	Shogo_use_init_speed				= true 
  157. 	Shogo_in_flee_mode				= false 
  158. 	Shogo_flee_speed					= 0 
  159.  
  160. 	Enemies_living						= 0 
  161. 	Enemies_to_kill					= 0 
  162. 	Enemy_set_objective_helptext	= "" 
  163. 	Player_shogo_fleeing				= "unset" -- Player Shogo is fleeing from 
  164.  
  165. 	-- THREADS 
  166. 	--Thread_dealer						= -1 
  167. 	Thread_shogo_motorcycle_throttle		= -1 
  168. 	Thread_clear_initial_speed_override	= -1 
  169. 	Table_all_threads					= {	Thread_shogo_motorcycle_throttle, Thread_clear_initial_speed_override} 
  170.  
  171.  
  172. -- REQUIRED MISSION FUNCTIONS ------------------------------- 
  173.  
  174. -- Called when the mission starts 
  175. function rn09_start(rn09_checkpoint, is_restart) 
  176.  
  177. 	mission_start_fade_out(0.0) 
  178.  
  179. 	local starting_groups = {GROUP_SHOGO, GROUP_GAT, GROUP_BIKER_FRIENDS} 
  180. 	if (coop_is_active()) then 
  181. 		starting_groups = {GROUP_SHOGO, GROUP_GAT, GROUP_BIKER_FRIENDS, GROUP_BIKER_FRIENDS_COOP} 
  182. 	end 
  183.  
  184. 	if (rn09_checkpoint == CHECKPOINT_START) then 
  185. 		if (is_restart) then 
  186.  
  187. 			-- Teleport player(s) to starting location 
  188. 			teleport_coop(NAVPOINT_LOCAL_PLAYER_START, NAVPOINT_REMOTE_PLAYER_START) 
  189.  
  190. 			-- Create groups 
  191. 			for i,group in pairs(starting_groups) do 
  192. 				group_create(group, true) 
  193. 			end 
  194. 		else 
  195. 			-- Play the cutscene, then show the groups. 
  196. 			cutscene_play("ro09-01", starting_groups, {NAVPOINT_LOCAL_PLAYER_START, NAVPOINT_REMOTE_PLAYER_START}, false) 
  197. 			for i,group in pairs(starting_groups) do 
  198. 				group_show(group) 
  199. 			end 
  200. 		end 
  201. 	end 
  202.  
  203. 	rn09_initialize(rn09_checkpoint) 
  204.  
  205. 	if (rn09_checkpoint == CHECKPOINT_START) then 
  206. 	 
  207. 		--disable Chainsaws for Boss Battle 
  208. 		chainsaw_disable() 
  209.  
  210. 		-- Player has to get Shogo down to half health. 
  211. 		rn09_faux_boss_battle() 
  212.  
  213. 		-- Then he flees, player pursues but falls in an open grave. 
  214. 		character_prevent_flinching(CHARACTER_SHOGO, true) 
  215. 		rn09_cutscene_shogo_flees() 
  216. 		character_prevent_flinching(CHARACTER_SHOGO, false) 
  217.  
  218. 		-- Cemetary is filled w/ Ronin who must be cleared out. 
  219. 		rn09_clear_cemetary() 
  220.  
  221.  
  222. 		-- Fade out and disable player controls 
  223. 		fade_out(0.0,{0,0,0}, SYNC_ALL) 
  224. 		player_controls_disable(LOCAL_PLAYER) 
  225. 		if (IN_COOP) then 
  226. 			player_controls_disable(REMOTE_PLAYER) 
  227. 		end 
  228.  
  229. 		-- Disable Ronin spawning until the players have had time to leave the garage. 
  230. 		notoriety_force_no_spawn("Ronin", true)  
  231. 		ambient_gang_spawn_enable(false) 
  232. 		notoriety_set_desired_vehicle_count("Ronin",0) 
  233.  
  234. 		-- Shogo flees the area 
  235. 		rn09_cutscene_shogo_exits_garage() 
  236.  
  237. 		-- Show the motorcycles and shogo 
  238. 		group_show(GROUP_MOTORCYCLES_PLAYERS) 
  239. 		group_show(GROUP_CHASE_COURTESY_CAR) 
  240. 		group_show(GROUP_MOTORCYCLES_SHOGO) 
  241.  
  242. 		-- Setup for the bike pursuit 
  243. 		rn09_setup_bike_pursuit() 
  244.  
  245. 		-- Give players a bit of time to enter bikes 
  246. 		delay(1.0) 
  247.  
  248. 		-- Fade into the game 
  249. 		fade_in(1.0, SYNC_ALL) 
  250. 		fade_in_block() 
  251.  
  252. 		-- Reenable player controls 
  253. 		player_controls_enable(LOCAL_PLAYER) 
  254. 		if (IN_COOP) then 
  255. 			player_controls_enable(REMOTE_PLAYER) 
  256. 		end 
  257.  
  258. 		-- CHECKPOINT! 
  259. 		mission_set_checkpoint(CHECKPOINT_GARAGE) 
  260. 		rn09_checkpoint = CHECKPOINT_GARAGE 
  261. 		 
  262. 	end -- ends CHECKPOINT_START 
  263.  
  264. 	-- Start the bike pursuit 
  265. 	rn09_start_bike_pursuit() 
  266.  
  267. 	-- Players pursue and kill shogo 
  268. 	rn09_bike_pursuit() 
  269.  
  270. end 
  271.  
  272. function rn09_initialize(checkpoint) 
  273.  
  274. 	rn09_initialize_common() 
  275. 	rn09_initialize_checkpoint(checkpoint) 
  276.  
  277. 	mission_start_fade_in() 
  278.  
  279. end 
  280.  
  281. function	rn09_initialize_common() 
  282.  
  283. 	-- Start trigger is hit...the activate button was hit 
  284. 	set_mission_author("Phillip Alexander") 
  285.  
  286. 	-- Check for coop being active 
  287. 	if (coop_is_active()) then 
  288. 		IN_COOP	= true 
  289. 	end 
  290. 	 
  291. 	-- Close and lock the garage's side door: 
  292. 	door_close(MM_GARAGE_SIDE_DOOR) 
  293. 	door_lock(MM_GARAGE_SIDE_DOOR,true) 
  294.  
  295. 	-- Set time of day to dusk3 
  296. 	set_time_of_day(rn09_get_parameter_value("TIME_OF_DAY_HOUR"),rn09_get_parameter_value("TIME_OF_DAY_MINUTE")) 
  297.  
  298. 	-- Make it rain! 
  299. 	set_weather(6,true) 
  300.  
  301. 	-- Set a permanent notoriety of 2 and reduce notoriety vehicle spawning 
  302. 	notoriety_set("Ronin", rn09_get_parameter_value("RONIN_NOTORIETY"))  
  303. 	notoriety_set_min("Ronin", rn09_get_parameter_value("RONIN_NOTORIETY")) 
  304. 	notoriety_set_max("Ronin", rn09_get_parameter_value("RONIN_NOTORIETY")) 
  305.  
  306. 	-- Force Police Notoriety to 0 
  307. 	notoriety_set("Police", 0)  
  308. 	notoriety_set_min("Police", 0) 
  309. 	notoriety_set_max("Police", 0) 
  310.  
  311. end 
  312.  
  313. function rn09_initialize_checkpoint(checkpoint) 
  314.  
  315. 	if (checkpoint == CHECKPOINT_START) then 
  316.  
  317. 		-- Create a bunch of hidden groups that we'll need later on 
  318. 		group_create_hidden(GROUP_MOTORCYCLES_SHOGO, false) 
  319. 		group_create_hidden(GROUP_MOTORCYCLES_PLAYERS, false) 
  320. 		group_create_hidden(GROUP_CHASE_COURTESY_CAR, false) 
  321.  
  322. 		-- Give the players a second of invulnerability 
  323. 		turn_invulnerable(LOCAL_PLAYER, false) 
  324. 		if ( character_exists(CHARACTER_GAT) ) then 
  325. 			turn_invulnerable(CHARACTER_GAT, false) 
  326. 		end 
  327. 		if (IN_COOP) then  
  328. 			turn_invulnerable(REMOTE_PLAYER, false) 
  329. 		end 
  330.  
  331. 		-- No extra bikers show up for now. 
  332. 		--notoriety_set_desired_vehicle_count("Ronin",0) 
  333. 		--notoriety_force_no_spawn("Ronin", true)  
  334. 		ambient_gang_spawn_enable(false) 
  335.  
  336. 		-- Make Gat a follower, add his failure callbacks 
  337. 		party_add(CHARACTER_GAT,LOCAL_PLAYER) 
  338. 		on_death("rn09_gat_death_failure", CHARACTER_GAT) 
  339. 		on_dismiss("rn09_gat_dismiss_failure", CHARACTER_GAT) 
  340.  
  341. 		-- Setup persona overrides for Gat and Pierce 
  342. 		persona_override_character_start(CHARACTER_GAT, POT_SITUATIONS[POT_ATTACK],"GAT_RON09_ATTACK") 
  343. 		persona_override_character_start(CHARACTER_GAT, POT_SITUATIONS[POT_TAKE_DAMAGE],"GAT_RON09_TAKEDAM") 
  344. 		persona_override_character_start(CHARACTER_SHOGO, POT_SITUATIONS[POT_ATTACK],"RON09_SHOGO_ATTACK") 
  345. 		persona_override_character_start(CHARACTER_SHOGO, POT_SITUATIONS[POT_TAKE_DAMAGE],"RON09_SHOGO_TAKEDAM") 
  346.  
  347. 		-- Handle Shogo taking damage in script so that he doesn't die. 
  348. 		set_max_hit_points(CHARACTER_SHOGO, rn09_get_parameter_value("SHOGO_HIT_POINTS")) 
  349. 		set_current_hit_points(CHARACTER_SHOGO, rn09_get_parameter_value("SHOGO_HIT_POINTS")) 
  350. 		damage_indicator_on(0,CHARACTER_SHOGO,0.0,HELPTEXT_HUD_SHOGO_HEALTH) 
  351. 		on_take_damage("rn09_handle_shogo_damaged",CHARACTER_SHOGO) 
  352. 		turn_invulnerable(CHARACTER_SHOGO, false) 
  353.  
  354. 	end 
  355.  
  356. 	if (checkpoint == CHECKPOINT_GARAGE) then 
  357.  
  358. 		-- Disable Ronin spawning until the players have had time to leave the garage. 
  359. 		notoriety_force_no_spawn("Ronin", true)  
  360. 		ambient_gang_spawn_enable(false) 
  361. 		notoriety_set_desired_vehicle_count("Ronin",0) 
  362.  
  363. 		-- Create groups 
  364. 		group_create(GROUP_MOTORCYCLES_SHOGO, true) 
  365. 		group_create(GROUP_CHASE_COURTESY_CAR, true) 
  366.  
  367. 		rn09_setup_bike_pursuit(true) 
  368. 	end 
  369.  
  370. end 
  371.  
  372. function rn09_faux_boss_battle() 
  373. 	 
  374. 	-- Tell Shogo to KILL!!! 
  375. 	attack(CHARACTER_SHOGO, LOCAL_PLAYER) 
  376.  
  377. 	-- Tell the player to attack Shogo 
  378. 	mission_help_table(HELPTEXT_PROMPT_KILL_SHOGO) 
  379. 	marker_add_npc(CHARACTER_SHOGO, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL)  
  380.  
  381. 	-- Give the players a second of invulnerability 
  382. 	delay(1.0) 
  383. 	turn_vulnerable(LOCAL_PLAYER) 
  384. 	if ( character_exists(CHARACTER_GAT) ) then 
  385. 		turn_vulnerable(CHARACTER_GAT) 
  386. 	end 
  387. 	if (IN_COOP) then  
  388. 		turn_vulnerable(REMOTE_PLAYER) 
  389. 	end 
  390.  
  391. 	-- wait for Shogo to reach half health 
  392. 	while (not Shogo_half_health) do 
  393. 		thread_yield() 
  394. 	end	 
  395.  
  396. 	-- Fade out and destroy the script-copy of Shogo. (The cutscene has its own copy of him.) 
  397. 	fade_out(0.5, {0,0,0}, SYNC_ALL) 
  398. 	fade_out_block() 
  399. 	group_destroy(GROUP_SHOGO) 
  400.  
  401. 	-- Shogo isn't a target in the next stage: remove health indicator and marker and hide him 
  402. 	--hud_bar_off(0,SYNC_ALL) 
  403. 	damage_indicator_off(0) 
  404.  
  405. 	marker_remove_npc(CHARACTER_SHOGO,SYNC_ALL) 
  406. 	on_take_damage("", CHARACTER_SHOGO) 
  407.  
  408. end 
  409.  
  410. function rn09_cutscene_shogo_flees() 
  411.  
  412. 	-- make sure player doesn't die during fade out 
  413. 	turn_invulnerable(LOCAL_PLAYER, false) 
  414. 	if (IN_COOP) then 
  415. 		turn_invulnerable(REMOTE_PLAYER, false) 
  416. 	end 
  417.  
  418. 	fade_out(0.0, {0,0,0}, SYNC_ALL) 
  419.  
  420. 	-- Get rid of Shogo's biker friends 
  421. 	-- do this while faded out to eliminate popping. 
  422. 	rn09_group_destroy_maybe_coop(GROUP_BIKER_FRIENDS,GROUP_BIKER_FRIENDS_COOP)	 
  423.  
  424. 	cutscene_play("IG_rn09_scene1") 
  425. 	group_destroy(GROUP_CUTSCENE_1) 
  426.  
  427. 	rn09_group_create_maybe_coop(GROUP_CEMETARY_RONIN,GROUP_CEMETARY_RONIN_COOP, true) 
  428.  
  429.  
  430. 	fade_in(1.0, SYNC_ALL) 
  431.  
  432. 	-- Make players vulnerable to damage normally again 
  433. 	turn_vulnerable(LOCAL_PLAYER) 
  434. 	if (IN_COOP) then 
  435. 		turn_vulnerable(REMOTE_PLAYER) 
  436. 	end 
  437.  
  438. end 
  439.  
  440. function rn09_clear_cemetary() 
  441.  
  442. 	-- Set notoriety spawn limit and fix notoriety level. 
  443. 	notoriety_set_desired_vehicle_count("Ronin",rn09_get_parameter_value("RONIN_DESIRED_VEHICLE_COUNT")) 
  444.  
  445. 	rn09_process_enemy_set(TABLE_CEMETARY_RONIN, HELPTEXT_PROMPT_CLEAN_CEMETARY, HELPTEXT_OBJECTIVE_CLEAN_CEMETARY) 
  446.  
  447. 	--follower_make_independent(CHARACTER_GAT,true) 
  448. 	-- Make Gat invulnerable so that he isn't killed 
  449. 	turn_invulnerable(CHARACTER_GAT, false) 
  450. 	party_dismiss_all() 
  451. 	on_death("", CHARACTER_GAT) 
  452. 	on_dismiss("", CHARACTER_GAT) 
  453.  
  454. 	-- Tell the player to find Shogo 
  455. 	mission_help_table(HELPTEXT_PROMPT_FIND_SHOGO) 
  456.  
  457. 	-- Add a minimap icon and in-game icon near the caretaker's house 
  458. 	marker_add_navpoint(NAVPOINT_SHOGO_FLEE_TARGET, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  459.  
  460. 	-- Wait for the player to hit the chase start trigger 
  461. 	trigger_enable(TRIGGER_START_CHASE,true) 
  462. 	on_trigger("rn09_start_chase", TRIGGER_START_CHASE) 
  463. 	while (not Start_chase) do 
  464. 		thread_yield() 
  465. 	end 
  466. 	 
  467. 	marker_remove_navpoint(NAVPOINT_SHOGO_FLEE_TARGET,SYNC_ALL) 
  468.  
  469. end 
  470.  
  471. function rn09_cutscene_shogo_exits_garage() 
  472.  
  473. 	cutscene_play("IG_rn09_scene2", nil, "", false) 
  474.  
  475. 	group_destroy(GROUP_CUTSCENE_2) 
  476. 	 
  477. end 
  478.  
  479. function rn09_setup_bike_pursuit(restart_from_checkpoint) 
  480.  
  481. 	-- Recreate Shogo, setup his persona 
  482. 	group_create(GROUP_SHOGO, true) 
  483. 	persona_override_character_start(CHARACTER_SHOGO, POT_SITUATIONS[POT_ATTACK],"RON09_SHOGO_ATTACK") 
  484. 	persona_override_character_start(CHARACTER_SHOGO, POT_SITUATIONS[POT_TAKE_DAMAGE],"RON09_SHOGO_TAKEDAM") 
  485.  
  486. 	-- Setup callback for Shogo's death 
  487. 	on_death("rn09_shogo_killed",CHARACTER_SHOGO) 
  488.  
  489. 	-- Put Shogo on his bike 
  490. 	vehicle_enter_teleport(CHARACTER_SHOGO, VEHICLE_SHOGO_MOTORCYCLE, 0) 
  491.  
  492. 	-- Shogo already entered his bike, set him up for the chase 
  493. 	vehicle_suppress_npc_exit(VEHICLE_SHOGO_MOTORCYCLE, true) 
  494. 	vehicle_prevent_explosion_fling(VEHICLE_SHOGO_MOTORCYCLE,true) 
  495. 	set_seatbelt_flag(CHARACTER_SHOGO,true) 
  496. 	vehicle_never_flatten_tires(VEHICLE_SHOGO_MOTORCYCLE, true) 
  497. 	vehicle_set_allow_ram_ped(VEHICLE_SHOGO_MOTORCYCLE,true) 
  498. 	vehicle_set_crazy(VEHICLE_SHOGO_MOTORCYCLE,true) 
  499. 	vehicle_disable_chase(VEHICLE_SHOGO_MOTORCYCLE,true) 
  500. 	vehicle_suppress_flipping(VEHICLE_SHOGO_MOTORCYCLE, true) 
  501.  
  502. 	-- lower the traffic density 
  503. 	set_traffic_density(rn09_get_parameter_value("SHOGO_FLEE_TRAFFIC_DENSITY")) 
  504.  
  505. 	if (not restart_from_checkpoint) then 
  506.  
  507. 		-- Make sure that the players aren't already on vehicles 
  508. 		character_evacuate_from_all_vehicles(LOCAL_PLAYER) 
  509. 		if (IN_COOP) then 
  510. 			character_evacuate_from_all_vehicles(REMOTE_PLAYER) 
  511. 		end 
  512. 		delay(1.0) 
  513.  
  514. 		-- Put players on motorcycles 
  515. 		vehicle_enter_teleport(LOCAL_PLAYER,VEHICLE_LOCAL_PLAYER_MOTORCYCLE,0) 
  516. 		if (IN_COOP) then 
  517. 			vehicle_enter_teleport(REMOTE_PLAYER,VEHICLE_REMOTE_PLAYER_MOTORCYCLE,0) 
  518. 		end 
  519.  
  520. 		local function rn09_character_in_vehicle(char, veh) 
  521. 			if (not character_is_in_vehicle(char, veh)) then 
  522. 				return false 
  523. 			end 
  524. 			if (not vehicle_enter_check_done(char)) then 
  525. 				return false 
  526. 			end 
  527. 			return true 
  528. 		end 
  529.  
  530. 		while( not rn09_character_in_vehicle(LOCAL_PLAYER,VEHICLE_LOCAL_PLAYER_MOTORCYCLE)) do 
  531. 			thread_yield() 
  532. 		end 
  533. 		if (IN_COOP) then 
  534. 			while( not rn09_character_in_vehicle(REMOTE_PLAYER,VEHICLE_REMOTE_PLAYER_MOTORCYCLE)) do 
  535. 				thread_yield() 
  536. 			end 
  537. 		end 
  538.  
  539. 	end 
  540.  
  541. 	-- Make sure that the garage doors are open 
  542. 	mesh_mover_reset_to_action_end("rn09_$MMgarage_door_1", "start1") 
  543. 	mesh_mover_reset_to_action_end("rn09_$MMgarage_door_2", "start1") 
  544.  
  545. end 
  546.  
  547. function rn09_start_bike_pursuit() 
  548.  
  549. 	Shogo_flee_speed = rn09_get_parameter_value("SHOGO_FLEE_INIT_MPH") 
  550. 	vehicle_speed_override(VEHICLE_SHOGO_MOTORCYCLE, Shogo_flee_speed) 
  551.  
  552. 	Thread_clear_initial_speed_override = thread_new("rn09_clear_initial_speed_override") 
  553. 	Thread_shogo_motorcycle_throttle	= thread_new("rn09_shogo_motorcycle_throttle") 
  554.  
  555. 	-- Start shogo pathfinding 
  556. 	thread_new("rn09_shogo_turret") 
  557.  
  558. 	-- Delay so that Shogo can get up to speed and doors can finish opening: 
  559. 	delay(2.0) 
  560.  
  561. end 
  562.  
  563. function rn09_shogo_turret() 
  564. 	--vehicle_turret_base_to(VEHICLE_SHOGO_MOTORCYCLE, "rn09_$n016", "rn09_$n017", "rn09_$n018", "rn09_$n019", "rn09_$n020", false) 
  565. 	vehicle_turret_base_to(VEHICLE_SHOGO_MOTORCYCLE, "rn09_$n017", "rn09_$n018", "rn09_$n019", "rn09_$n020", false) 
  566. 	Shogo_in_flee_mode = true 
  567. 	local dist 
  568. 	dist, Player_shogo_fleeing = get_dist_closest_player_to_object(VEHICLE_SHOGO_MOTORCYCLE) 
  569. 	vehicle_flee(VEHICLE_SHOGO_MOTORCYCLE,Player_shogo_fleeing) 
  570. end 
  571.  
  572. function rn09_bike_pursuit() 
  573.  
  574. 	-- make the Shogo and the motorcycles vulnerable again 
  575. 	turn_vulnerable(CHARACTER_SHOGO) 
  576. 	 
  577. 	-- Give the player prompts and indicators 
  578. 	local shogo_hit_points = rn09_get_parameter_value("SHOGO_HIT_POINTS") 
  579. 	local shogo_flee_dist = rn09_get_parameter_value("SHOGO_FLEE_DIST") 
  580. 	mission_help_table(HELPTEXT_PROMPT_KILL_SHOGO) 
  581. 	set_max_hit_points(CHARACTER_SHOGO, shogo_hit_points) 
  582. 	set_current_hit_points(CHARACTER_SHOGO, 0.5*shogo_hit_points) 
  583. 	damage_indicator_on(0,CHARACTER_SHOGO,0.0, HELPTEXT_HUD_SHOGO_HEALTH) 
  584. 	distance_display_on(VEHICLE_SHOGO_MOTORCYCLE,0.0,shogo_flee_dist,0.0,shogo_flee_dist, SYNC_ALL) 
  585. 	marker_add_npc(CHARACTER_SHOGO, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL)  
  586.  
  587. 	-- Reenable gang/notoriety spawns, but give the players time to leave the garage. 
  588. 	delay(2) 
  589. 	notoriety_force_no_spawn("Ronin", false)  
  590. 	ambient_gang_spawn_enable(true) 
  591. 	notoriety_set_desired_vehicle_count("Ronin",-1) 
  592.  
  593. end 
  594.  
  595. function rn09_clear_initial_speed_override() 
  596. 	delay(rn09_get_parameter_value("SHOGO_FLEE_INIT_MPH_TIME_S")) 
  597. 	if( not vehicle_is_destroyed(VEHICLE_SHOGO_MOTORCYCLE) ) then 
  598. 		vehicle_speed_cancel(VEHICLE_SHOGO_MOTORCYCLE) 
  599. 	end 
  600. 	Shogo_use_init_speed = false 
  601. end 
  602.  
  603. function rn09_shogo_motorcycle_throttle() 
  604.  
  605. 	local shogo_flee_dist = rn09_get_parameter_value("SHOGO_FLEE_DIST") 
  606.  
  607. 	while(true) do 
  608. 		 
  609. 		local dist, closest_player = get_dist_closest_player_to_object(VEHICLE_SHOGO_MOTORCYCLE) 
  610. 		if (Shogo_in_flee_mode and (closest_player ~= Player_shogo_fleeing)) then 
  611. 			Player_shogo_fleeing = closest_player 
  612. 			vehicle_flee(VEHICLE_SHOGO_MOTORCYCLE,Player_shogo_fleeing) 
  613. 		end 
  614. 		if (dist < shogo_flee_dist) then 
  615. 			if (not Shogo_use_init_speed) then 
  616. 				Shogo_flee_speed = rn09_get_parameter_value("SHOGO_FLEE_FAST_MPH") 
  617. 			end 
  618. 			if(Timing_escape) then 
  619. 				damage_indicator_on(0,CHARACTER_SHOGO,0.0, HELPTEXT_HUD_SHOGO_HEALTH) 
  620. 				hud_timer_stop(0) 
  621. 				Timing_escape = false 
  622.  
  623. 			end 
  624. 		else 
  625. 			if (not Shogo_use_init_speed) then 
  626. 				Shogo_flee_speed = rn09_get_parameter_value("SHOGO_FLEE_SLOW_MPH") 
  627. 			end 
  628. 			if(not Timing_escape) then 
  629. 				Timing_escape = true 
  630. 				mission_help_table(HELPTEXT_PROMPT_WARN_DISTANCE, "", "", SYNC_LOCAL) 
  631. 				hud_timer_set(0, 1000*rn09_get_parameter_value("SHOGO_FLEE_TIME_S"),"rn09_shogo_escaped_failure") 
  632. 			end 
  633. 		end 
  634.  
  635. 		vehicle_max_speed(VEHICLE_SHOGO_MOTORCYCLE, Shogo_flee_speed) 
  636.  
  637. 		thread_yield() 
  638. 	end 
  639. end 
  640.  
  641. function rn09_start_chase() 
  642. 	marker_remove_navpoint(NAVPOINT_SHOGO_FLEE_TARGET, SYNC_ALL) 
  643. 	trigger_enable(TRIGGER_START_CHASE,false) 
  644. 	on_trigger("", TRIGGER_START_CHASE) 
  645. 	Start_chase = true 
  646. end 
  647.  
  648. -- Called when Shogo is damaged during the faux Shogo boss battle 
  649. -- damage_percent is Shogo's health percentage after the attack 
  650. function rn09_handle_shogo_damaged(shogo, attacker, damage_percent) 
  651.  
  652. 	if (damage_percent < 0.5) then 
  653. 		Shogo_half_health = true 
  654. 		damage_percent = 0.5 
  655. 		turn_invulnerable(CHARACTER_SHOGO, false) 
  656. 		on_take_damage("", CHARACTER_SHOGO) 
  657. 	end 
  658.  
  659. 	set_current_hit_points(CHARACTER_SHOGO, damage_percent * get_max_hit_points(CHARACTER_SHOGO)) 
  660. end 
  661.  
  662. -- Shogo killed 
  663. function rn09_shogo_killed() 
  664. 	-- Turn off the damage indicator 
  665. 	damage_indicator_off(0) 
  666.  
  667. 	-- Players win 
  668. 	rn09_complete()	 
  669. end 
  670.  
  671. -- Cleanup mission 
  672. function rn09_cleanup() 
  673.  
  674. 	-- Make sure tha players aren't still invulnerable 
  675. 	turn_vulnerable(LOCAL_PLAYER) 
  676. 	if (IN_COOP) then  
  677. 		turn_vulnerable(REMOTE_PLAYER) 
  678. 	end 
  679.  
  680. 	-- Players can use chainsaws once again. 
  681. 	chainsaw_enable() 
  682.  
  683. 	-- garage side door doesn't need to be locked any more 
  684. 	door_lock(MM_GARAGE_SIDE_DOOR,false) 
  685.  
  686. 	-- Reenable gang/notoriety spawns 
  687. 	notoriety_force_no_spawn("Ronin", false)  
  688. 	ambient_gang_spawn_enable(true) 
  689. 	notoriety_set_desired_vehicle_count("Ronin",-1) 
  690.  
  691. 	-- turn off damage, distance displays 
  692. 	distance_display_off(SYNC_ALL) 
  693. 	damage_indicator_off(0) 
  694.  
  695. 	-- make the motorcycles vulnerable again 
  696. 	--rn09_set_motorcycles_invulnerable(false) 
  697.  
  698. 	-- Let the weather do as it likes 
  699. 	set_weather(-1,false) 
  700.  
  701. 	-- Reset the notoriety 
  702. 	notoriety_set_min("Ronin",0) 
  703. 	notoriety_set_max("Ronin",5) 
  704. 	notoriety_set("Ronin", 0)  
  705. 	 
  706. 	--re-enable all weapons 
  707. 	inv_weapon_enable_or_disable_all_slots(true, SYNC_ALL) 
  708.  
  709. 	-- Remove the callback for Gat's death 
  710. 	on_death("", CHARACTER_GAT) 
  711. 	on_dismiss("", CHARACTER_GAT) 
  712.  
  713. 	-- Stop the timer, this deregisters its callback. 
  714. 	hud_timer_stop(0) 
  715.  
  716. 	-- get Gat to stop following me around 
  717. 	if (npc_is_in_party(CHARACTER_GAT)) then 
  718. 		npc_stop_following(CHARACTER_GAT) 
  719. 	end 
  720.  
  721. 	-- Remove markers, callbacks from all enemies 
  722. 	for i,enemy in pairs(TABLE_CEMETARY_RONIN) do 
  723. 		marker_remove_npc(enemy) 
  724. 		on_death("",enemy) 
  725. 	end 
  726.  
  727. 	marker_remove_npc(CHARACTER_SHOGO) 
  728. 	on_death("",CHARACTER_SHOGO) 
  729.  
  730. 	-- Kill all secondary threads 
  731. 	for i, thread in pairs(Table_all_threads) do 
  732. 		thread_kill(thread) 
  733. 	end 
  734.  
  735. 	-- disable all triggers, remove callbacks 
  736. 	for i, trigger in pairs(TABLE_ALL_TRIGGERS) do 
  737. 		on_trigger("",trigger) 
  738. 		trigger_enable(trigger,false) 
  739. 	end 
  740.  
  741. end 
  742.  
  743. function rn09_success() 
  744. end 
  745.  
  746. function rn09_set_motorcycles_invulnerable(flag) 
  747.  
  748. 	local explosion_multiplier = 1.0 
  749.  
  750. 	if (flag) then 
  751. 		explosion_multiplier = 0.0 
  752. 		turn_invulnerable(VEHICLE_SHOGO_MOTORCYCLE, false) 
  753. 		turn_invulnerable(VEHICLE_LOCAL_PLAYER_MOTORCYCLE, false) 
  754. 		turn_invulnerable(VEHICLE_REMOTE_PLAYER_MOTORCYCLE, false) 
  755. 	end 
  756.  
  757. 	vehicle_prevent_explosion_fling(VEHICLE_SHOGO_MOTORCYCLE, flag)  
  758. 	vehicle_prevent_explosion_fling(VEHICLE_LOCAL_PLAYER_MOTORCYCLE, flag)  
  759. 	vehicle_prevent_explosion_fling(VEHICLE_REMOTE_PLAYER_MOTORCYCLE, flag)  
  760.  
  761. 	vehicle_set_explosion_damage_multiplier(VEHICLE_SHOGO_MOTORCYCLE, explosion_multiplier)  
  762. 	vehicle_set_explosion_damage_multiplier(VEHICLE_LOCAL_PLAYER_MOTORCYCLE, explosion_multiplier)  
  763. 	vehicle_set_explosion_damage_multiplier(VEHICLE_REMOTE_PLAYER_MOTORCYCLE, explosion_multiplier)  
  764. end 
  765.  
  766. function rn09_complete() 
  767. 	-- delay a little bit so that failure conditions have time to be checked 
  768. 	--bink_play_movie("ro09-2.bik") 
  769.  
  770. 	-- End the mission with success 
  771. 	mission_end_success("rn09", "ro09-02") 
  772. end 
  773.  
  774. function rn09_group_create_maybe_coop(group_always,group_coop, blocking) 
  775. 	group_create(group_always, blocking) 
  776. 	if (IN_COOP) then 
  777. 		group_create(group_coop, blocking) 
  778. 	end 
  779. end 
  780.  
  781. function rn09_group_destroy_maybe_coop(group_always, group_coop) 
  782. 	group_destroy(group_always) 
  783. 	if (IN_COOP) then 
  784. 		group_destroy(group_coop) 
  785. 	end 
  786. end 
  787.  
  788. -- Get the value of the mission parameter. 
  789. -- 
  790. -- parameter	Mission parameter whose value the function should return 
  791. --	i				If the parameter is a table, then i indexes the entry that should be returned 
  792. -- 
  793. -- Returns mission paramater value. 
  794. function rn09_get_parameter_value(parameter, i) 
  795.  
  796. 	local return_val = nil 
  797.  
  798. 	-- Check for a coop value: 
  799. 	if (IN_COOP) then 
  800. 		if (i) then 
  801. 			if (RN09_PARAMETERS["COOP_" .. parameter] ~= nil) then 
  802. 				return_val = RN09_PARAMETERS["COOP_" .. parameter][i] 
  803. 			end 
  804. 		else 
  805. 			return_val = RN09_PARAMETERS["COOP_" .. parameter] 
  806. 		end 
  807. 	end 
  808.  
  809. 	-- If no coop value was found, then return the standard value. 
  810. 	if (return_val == nil) then 
  811. 		if (i) then 
  812. 			if (RN09_PARAMETERS[parameter] ~= nil) then 
  813. 				return_val = RN09_PARAMETERS[parameter][i] 
  814. 			end 
  815. 		else 
  816. 			return_val = RN09_PARAMETERS[parameter] 
  817. 		end 
  818. 	end 
  819.  
  820. 	return return_val 
  821. end 
  822.  
  823. function rn09_process_enemy_set(enemy_table, mission_helptext, objective_helptext) 
  824. 	 
  825. 	Enemy_set_cleared = false 
  826.  
  827. 	-- Assign enemy callbacks 
  828. 	for i, enemy in pairs(enemy_table) do 
  829. 		on_death("rn09_enemy_killed", enemy) 
  830. 		marker_add_npc(enemy, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL)  
  831. 		attack(enemy) 
  832. 	end 
  833.  
  834. 	-- Setup kill tracking numbers 
  835. 	Enemies_to_kill = sizeof_table(enemy_table) 
  836. 	Enemies_living =  Enemies_to_kill 
  837.  
  838. 	-- Display the help text 
  839. 	if(mission_helptext) then 
  840. 		mission_help_table(mission_helptext) 
  841. 	end 
  842.  
  843. 	-- Display the objective text 
  844. 	if(objective_helptext) then 
  845. 		Enemy_set_objective_helptext = objective_helptext 
  846. 		objective_text(0, Enemy_set_objective_helptext, Enemies_to_kill - Enemies_living, Enemies_to_kill) 
  847. 	end 
  848.  
  849. 	if(DEBUG_QUICK_KILLS) then 
  850. 		delay(1.0) 
  851. 		for i, enemy in pairs(enemy_table) do 
  852. 			character_kill(enemy) 
  853. 		end 
  854. 	end 
  855. 	 
  856. 	while (not Enemy_set_cleared) do 
  857. 		thread_yield() 
  858. 	end 
  859.  
  860. end 
  861.  
  862. function rn09_enemy_killed(enemy) 
  863. 	marker_remove_npc(enemy) 
  864. 	on_death("",enemy) 
  865. 	Enemies_living = Enemies_living - 1 
  866. 	if (Enemies_living < 1) then 
  867. 		Enemy_set_cleared = true 
  868. 		objective_text_clear(0) 
  869. 		Enemy_set_objective_helptext = "" 
  870. 	else 
  871. 		if (Enemy_set_objective_helptext ~= "") then 
  872. 			objective_text(0, Enemy_set_objective_helptext, Enemies_to_kill - Enemies_living, Enemies_to_kill) 
  873. 		end 
  874. 	end 
  875. end 
  876.  
  877. -- MISSION FAILURE FUNCTIONS -------------------------------- 
  878.  
  879. function rn09_shogo_escaped_failure() 
  880. 	-- End the mission, fence died 
  881. 	mission_end_failure("rn09", HELPTEXT_FAILURE_SHOGO_FLED) 
  882. end 
  883.  
  884. function rn09_gat_death_failure() 
  885. 	-- End the mission, fence died 
  886. 	mission_end_failure("rn09", HELPTEXT_FAILURE_GAT_DIED) 
  887. end 
  888.  
  889. function rn09_gat_dismiss_failure() 
  890. 	-- End the mission, fence died 
  891. 	mission_end_failure("rn09", HELPTEXT_FAILURE_GAT_DISMISSED) 
  892. end 
  893.