sr2lua/rn11.lua

  1. -- rn11.lua 
  2. -- SR2 mission script 
  3. -- 3/28/07 
  4.  
  5. -- Global constants (All caps == GLOBAL CONSTANT) 
  6. --[[	In general, shouldn't be modified in running code, except for maybe in a setup function ) 
  7.  
  8. ]] 
  9.  
  10. 	-- DEBUG FLAGS 
  11. 	DEBUG_START_AT_FESTIVAL		= false 
  12. 	DEBUG_START_AT_JUNKS			= false 
  13. 	DEBUG_START_AT_CUTSCENE_2	= false 
  14. 	DEBUG_EFFECTS					= false 
  15.  
  16. 	-- EFFECTS  
  17. 	JUNK_BOAT_FIRE_EFFECTS =  
  18. 	{ 
  19. 		["mission_ro11_flr_4x4"] = -- Large fire to be placed on floor, to be used with sticky fire 
  20. 		{ 
  21. 			"rn11_$boat1_fire_main1", "rn11_$boat1_fire_main2",  
  22. 			"rn11_$boat1_fire_main3", "rn11_$boat1_fire_main4", 
  23. 			"rn11_$boat2_fire_main1", "rn11_$boat2_fire_main2", 
  24. 			"rn11_$boat2_fire_main3", "rn11_$boat2_fire_main4", 
  25. 			"rn11_$boat2_fire_main5", 
  26. 		}, 
  27. 		["fire_sticky"] = -- Large fire effect with light; don't use too much 
  28. 		{ 
  29. 			"rn11_$n100" 
  30. 		}, 
  31. --[[ 
  32. 		["fire_sticky_sm"] = -- Smaller fire 
  33. 		{ 
  34. 			"rn11_$boat1_fire_side1-1", "rn11_$boat1_fire_side1-2",  
  35. 			"rn11_$boat1_fire_side2-1", "rn11_$boat1_fire_side2-2", 
  36. 			"rn11_$boat1_fire_side3-1", "rn11_$boat1_fire_side3-2", 
  37. 			"rn11_$boat1_fire_side4-1", "rn11_$boat1_fire_side4-2", 
  38. 			"rn11_$boat2_fire_side1-1", "rn11_$boat2_fire_side1-2",  
  39. 			"rn11_$boat2_fire_side2-1", "rn11_$boat2_fire_side2-2", 
  40. 			"rn11_$boat2_fire_side3-1", "rn11_$boat2_fire_side3-2", 
  41. 			"rn11_$boat2_fire_side4-1", "rn11_$boat2_fire_side4-2", 
  42. 			"rn11_$boat2_fire_side5-1", "rn11_$boat2_fire_side5-2", 
  43. 		}, 
  44. 		["fire_sticky_sm02"] = -- Smallest fire 
  45. 		{ 
  46. 			"rn11_$n102" 
  47. 		}, 
  48. 		["mission_ro11_clmn_fire"] = -- Fire to be placed at the base of a column 
  49. 		{ 
  50. 			"rn11_$boat1_fire_column1", "rn11_$boat1_fire_column2",  
  51. 			"rn11_$boat1_fire_column3", "rn11_$boat1_fire_column4", 
  52. 			"rn11_$boat2_fire_column1", "rn11_$boat2_fire_column2", 
  53. 			"rn11_$boat2_fire_column3", "rn11_$boat2_fire_column4" 
  54. 			--removed to reduce particle effect numbers:  
  55. 		}, 
  56. 		["mission_ro11_brdr_fire"] = --Fire on the top of junks 
  57. 		{ 
  58. 			"rn11_$boat1_fire_brdr" 
  59. 			--removed to reduce particle effect numbers:  "rn11_$boat2_fire_brdr" 
  60. 		}, 
  61. 		["fire_flame_window"] = --Fire that goes on the junk windows 
  62. 		{ 
  63. 			"rn11_$boat1_fire_win_1", "rn11_$boat1_fire_win_4",  
  64. 			"rn11_$boat2_fire_win_2", "rn11_$boat2_fire_win_3",  
  65. 			--removed to reduce particle effect numbers: "rn11_$boat1_fire_win_2", "rn11_$boat1_fire_win_3", "rn11_$boat2_fire_win_1", "rn11_$boat2_fire_win_4" 
  66. 		}, 
  67. 		["mission_ro11_mast_fire"] = -- Fire that burns on the mast and sails 
  68. 		{ 
  69. 			"rn11_$boat1_fire_mast" 
  70. 			--removed to reduce particle effect numbers:  "rn11_$boat2_fire_mast" 
  71. 		}, 
  72. 		["fire_flame_sky_debris"] = -- Fire that drops debris from sky, placed 8-10 meters above heads and boats 
  73. 		{ 
  74. 			"rn11_$boat1_fire_sky" 
  75. 			--removed to reduce particle effect numbers:  "rn11_$boat2_fire_sky" 
  76. 		}, 
  77. 		["fire_ash_md"] = -- Falling ash to be palced above the boats 
  78. 		{ 
  79. 			"rn11_$boat1_ash", "rn11_$boat2_ash" 
  80. 			--removed to reduce particle effect numbers:  
  81. 		}, 
  82. 		["mission_ro11_bm_fire"] = -- Beam explosion and falling with wood on fire 
  83. 		{ 
  84. 			"rn11_$n098" 
  85. 		}, 
  86. ]] 
  87. 	} 
  88.  
  89. 	-- Coop mission? 
  90. 	IN_COOP	= false 
  91.  
  92. 	-- GROUPS -- 
  93. 		GROUP_START_CAR			= "rn11_$Gstart_car" 
  94. 		GROUP_START_CAR_COOP		= "rn11_$Gstart_car_coop" 
  95. 		GROUP_WATERCRAFT			= "rn11_$Gwatercraft" 
  96. 		GROUP_LIEUTENANTS			= "rn11_$Glieutenants" 
  97. 		GROUP_JUNK					= "rn11_$Gjunk" 
  98. 		GROUP_JUNK_COOP			= "rn11_$Gjunk_coop" 
  99. 		GROUP_AKUJI_AND_WONG		= "rn11_$akuji_and_wong" 
  100. 		GROUP_CTE_AKUJI			= "rn11_$CTE_Gakuji" 
  101.  
  102. 	-- GROUP MEMBER TABLES --  
  103. 	 
  104. 		MEMBERS_GROUP_LIEUTENANTS	=	{	"rn11_$c000", "rn11_$c001", "rn11_$c002", "rn11_$c003", "rn11_$c004", 
  105. 													"rn11_$c005", "rn11_$c006", "rn11_$c007", "rn11_$c008", "rn11_$c009", 
  106. 													"rn11_$c010", "rn11_$c011", "rn11_$c012", "rn11_$c013", "rn11_$c014", 
  107. 													"rn11_$c015", "rn11_$c016", "rn11_$c017", "rn11_$c018", "rn11_$c019"} 
  108.  
  109. 		MEMBERS_GROUP_JUNK			=	{	"rn11_$c020", "rn11_$c021", "rn11_$c022", "rn11_$c023", "rn11_$c024", 
  110. 													"rn11_$c025", "rn11_$c027", "rn11_$c028", "rn11_$c029", "rn11_$c030", 
  111. 													"rn11_$c031", "rn11_$c032", "rn11_$c033", "rn11_$c034", "rn11_$c035", 
  112. 													"rn11_$c036", "rn11_$c037", "rn11_$c038", "rn11_$c039"} 
  113. 											 
  114. 		MEMBERS_GROUP_JUNK_COOP		=	{	"rn11_$c040", "rn11_$c041", "rn11_$c042"} 
  115.  
  116. 	-- TRIGGERS --  
  117. 		TRIGGER_DOCK					= "rn11_$Tdock" 
  118. 		TRIGGER_FESTIVAL_ARRIVAL	= "rn11_$Tfestival_arrival" 
  119. 		TRIGGER_JUNK_AREA				= "rn11_$Tjunk_area" 
  120. 		TRIGGER_AKUJI					= "rn11_$Takuji" 
  121.  
  122. 		-- List of all triggers, makes cleaning up more convenient 
  123. 		TABLE_ALL_TRIGGERS		= {	TRIGGER_DOCK, TRIGGER_FESTIVAL_ARRIVAL, TRIGGER_JUNK_AREA, TRIGGER_AKUJI}		 
  124.  
  125. 	-- VEHICLES -- 
  126. 		VEHICLE_WAVERUNNER		= "rn11_$Vwavecraft" 
  127. 		VEHICLE_SPEEDBOAT1		= "rn11_$Vspeedboat1" 
  128. 		VEHICLE_SPEEDBOAT2		= "rn11_$Vspeedboat2" 
  129.  
  130. 	-- CHARACTERS -- 
  131. 		CHARACTER_SPEEDBOAT1_DRIVER		= "rn11_$Cspeedboat1_driver" 
  132. 		CHARACTER_SPEEDBOAT2_DRIVER		= "rn11_$Cspeedboat2_driver" 
  133. 		CHARACTER_SPEEDBOAT1_RPG			= "rn11_$Cspeedboat1_rpg" 
  134. 		CHARACTER_SPEEDBOAT2_RPG			= "rn11_$Cspeedboat2_rpg" 
  135.  
  136. 		CHARACTER_AKUJI						= "rn11_$Cakuji" 
  137. 		CHARACTER_WONG							= "rn11_$Cwong" 
  138.  
  139. 	-- NAVPOINTS 
  140.  
  141. 		-- the mission start locations 
  142. 		NAVPOINT_LOCAL_PLAYER_START					= "mission_start_sr2_city_$rn11" 
  143. 		NAVPOINT_REMOTE_PLAYER_START					= "rn11_$Nremote_player_start" 
  144.  
  145. 		NAVPOINT_LOCAL_PLAYER_START_CHECKPOINT_1	= "rn11_$Nlocal_start_checkpoint_1" 
  146. 		NAVPOINT_REMOTE_PLAYER_START_CHECKPOINT_1	= "rn11_$Nremote_start_checkpoint_1" 
  147.  
  148. 		NAVPOINT_LOCAL_PLAYER_START_CHECKPOINT_2	= "rn11_$Nlocal_start_checkpoint_2" 
  149. 		NAVPOINT_REMOTE_PLAYER_START_CHECKPOINT_2	= "rn11_$Nremote_start_checkpoint_2" 
  150.  
  151. 		NAVPOINT_LOCAL_PLAYER_START_CHECKPOINT_3	= "rn11_$Nlocal_start_checkpoint_3" 
  152. 		NAVPOINT_REMOTE_PLAYER_START_CHECKPOINT_3	= "rn11_$Nremote_start_checkpoint_3" 
  153.  
  154. 		NAVPOINT_LOCAL_PLAYER_START_AKUJI			= "rn11_$Nlocal_start_akuji" 
  155. 		NAVPOINT_REMOTE_PLAYER_START_AKUJI			= "rn11_$Nremote_start_akuji" 
  156.  
  157. 		NAVPOINT_HELI_START								= "rn11_$Nheli_start" 
  158.  
  159. 		ATTACK_HELI_SPAWN_LOCATIONS =  
  160. 		{ 
  161. 			"rn11_$n103", "rn11_$n104", "rn11_$n105", "rn11_$n106", "rn11_$n107" 
  162. 		} 
  163.  
  164. 		FESTIVAL_NAVPOINTS	=	{	"rn11_$nfestival_000", "rn11_$nfestival_001", "rn11_$nfestival_002", 
  165. 											"rn11_$nfestival_003", "rn11_$nfestival_004", "rn11_$nfestival_005", 
  166. 											"rn11_$nfestival_006", "rn11_$nfestival_007", "rn11_$nfestival_008", 
  167. 											"rn11_$nfestival_009", "rn11_$nfestival_010", "rn11_$nfestival_011", 
  168. 											"rn11_$nfestival_012"} 
  169.  
  170. 		FESTIVAL_SPAWN_NAVPOINTS_PER_AREA = 5 
  171. 		FESTIVAL_SPAWN_LOCATIONS =  
  172. 			{	 
  173. 				{"rn11_$n043", "rn11_$n044", "rn11_$n045", "rn11_$n046", "rn11_$n047"}; 
  174. 				{"rn11_$n048", "rn11_$n049", "rn11_$n050", "rn11_$n051", "rn11_$n052"}; 
  175. 				{"rn11_$n053", "rn11_$n054", "rn11_$n055", "rn11_$n056", "rn11_$n057"}; 
  176. 				{"rn11_$n058", "rn11_$n059", "rn11_$n060", "rn11_$n061", "rn11_$n062"}; 
  177. 				{"rn11_$n063", "rn11_$n064", "rn11_$n065", "rn11_$n066", "rn11_$n067"};				 
  178. 				{"rn11_$n068", "rn11_$n069", "rn11_$n070", "rn11_$n071", "rn11_$n072"}; 
  179. 				{"rn11_$n073", "rn11_$n074", "rn11_$n075", "rn11_$n076", "rn11_$n077"}; 
  180. 				{"rn11_$n078", "rn11_$n079", "rn11_$n080", "rn11_$n081", "rn11_$n082"}; 
  181. 				{"rn11_$n083", "rn11_$n084", "rn11_$n085", "rn11_$n086", "rn11_$n087"};				 
  182. 			} 
  183.  
  184. 		NAVPOINT_MOLOTOV_TARGET	=	"rn11_$Nmolotov_target" 
  185.  
  186.  
  187. 		FIRE_EFFECTS			= {	"fire_sticky_sm02", "fire_sticky_sm", "fire_sticky"} 
  188. 		FIRE_EXPLOSIONS		= {	"Big Bang", "Gas Exp Medium", "Molotov Explosion", "Satchel"} 
  189.  
  190. 		HELI_FLEE_PATH =  
  191. 			{ "rn11_$n088", "rn11_$n089", "rn11_$n090", "rn11_$n091" } 
  192. 		HELI_FLEE_CIRCLE_PATH =  
  193. 			{ "rn11_$n089", "rn11_$n090", "rn11_$n091" } 
  194.  
  195. 		-- TEMP .. test effects 
  196. 		--for i, effect in pairs(effects) do 
  197. 		--	local handle_most_significant,handle_least_significant = effect_play(effect,"mission_start_sr2_city_$rn11",true) 
  198. 		--	mission_help_table("Playing " .. effect) 
  199. 		--	delay(6.0) 
  200. 		--	effect_stop(handle_most_significant, handle_least_significant) 
  201. 		--	delay(1.0) 
  202. 		--end 
  203.  
  204. 	-- MOVERS 
  205.  
  206. 	-- HELPTEXT 
  207.  
  208. 		-- localized helptext messages 
  209. 			HELPTEXT_FAILURE_DOCK				= "rn11_failure_dock"			-- ## The Ronin got away! 
  210. 			HELPTEXT_FAILURE_FOLLOW				= "rn11_failure_follow"			-- ## You let them get away! 
  211. 			HELPTEXT_FAILURE_WONG				= "rn11_failure_wong"			-- ## You let Wong die! 
  212.  
  213. 			HELPTEXT_HUD_WONG_HEALTH			= "rn11_hud_wong_health"		-- ## Wong's Health 
  214.  
  215. 			HELPTEXT_OBJECTIVE_LIEUTENANTS	= "rn08_objective_ronin"		 
  216.  
  217. 			HELPTEXT_PROMPT_FESTIVAL			= "rn11_prompt_festival"		-- ## Head to the Heritage Festival. 
  218. 			HELPTEXT_PROMPT_FOLLOW				= "rn11_prompt_follow"			-- ## Don't let the boat get to the Heritage Festival! 
  219. 			HELPTEXT_PROMPT_GET_CLOSER			= "rn11_prompt_get_closer"    -- ## Get closer, the Ronin are escpaing. 
  220. 			HELPTEXT_PROMPT_JUNK					= "rn11_prompt_junk"				-- ## Get on the junk boats and save Wong before he dies! 
  221. 			HELPTEXT_PROMPT_LIEUTENANTS		= "rn11_prompt_lieutenants"	-- ## Dock the boat and kill the Ronin lieutenants! 
  222. 			HELPTEXT_PROMPT_LOCATION_DOCK		= "rn11_prompt_location_dock" -- ## Drive to the dock before the Ronin get away! 
  223. 			HELPTEXT_PROMPT_MASSACRE			= "rn11_prompt_massacre"		-- ## The ronin are killing civilians. 
  224. 			HELPTEXT_PROMPT_WAVERUNNER			= "rn11_prompt_waverunner"		-- ## Get in the waverunner 
  225. 			HELPTEXT_PROMPT_WARN_DIST			= "rn11_prompt_warn_dist"		-- ## The boat is getting away! 
  226.  
  227. 		-- helptext messages that need to be localized 
  228.  
  229. 		-- helptext messages that need to be fixed 
  230. 			HELPTEXT_HUD_AKUJI_HEALTH			= "rn11_hud_akuji_health"		-- ## Wong's Health 
  231.  
  232. 	-- CHECKPOINTS 
  233. 		 
  234. 		CHECKPOINT_START							= MISSION_START_CHECKPOINT -- defined in ug_lib.lua 
  235. 		CHECKPOINT_FESTIVAL						= "rn11_checkpoint_festival" 
  236. 		CHECKPOINT_JUNKS							= "rn11_checkpoint_junks" 
  237. 		CHECKPOINT_AKUJI							= "rn11_checkpoint_akuji" 
  238. 	 
  239. 	-- MISC CONSTANTS 
  240. 	 
  241. 		INVALID_INDEX								= 0	-- Represents an invalid array index 
  242.  
  243. 		TIME_OF_DAY_HOUR							= 20; 
  244. 		TIME_OF_DAY_MINUTE						= 30; 
  245.  
  246. 		-- Stage 1: Go to dock 
  247. 		ALLOWED_TIME_TO_DOCK_MS					= 1 * 75 * 1000 
  248. 		ALLOWED_TIME_TO_FESTIVAL_MS			= 4 * 60 * 1000 
  249.  
  250. 		-- OLD Stage 2: Boat chase/ fight 
  251. 		SPEEDBOAT_INITIAL_SPEED_MPH			= 30 
  252. 		SPEEDBOAT_INITIAL_SPEED_TIME_S		= 6 
  253. 		SPEEDBOAT_SLOW_SPEED_MPH				= 20 
  254. 		SPEEDBOAT_FAST_SPEED_MPH				= 60 
  255. 		SPEEDBOAT_CLOSE_RANGE_M					= 75 
  256. 		SPEEDBOAT_FOLLOW_FAIL_TIME_S			= 20 
  257. 		WAVERUNNER_MAX_SPEED						= 70 
  258. 		WAVERUNNER_HIT_POINTS					= 20000 
  259.  
  260. 		-- Stage 3: Heritage Festival Battle 
  261.  
  262. 		RONIN_ATTACK_PERSONAS = 
  263. 		{ 
  264. 			["AM_Ron2"]	=	"AMRON2", 
  265.  
  266. 			["AF_Ron1"]	=	"AFRON1", 
  267. 			["AF_Ron3"]	=	"AFRON3", 
  268.  
  269. 			["WM_Ron1"]	=	"WMRON1", 
  270.  
  271. 			["WF_Ron1"]	=	"WFRON1", 
  272. 			["WF_Ron2"]	=	"WFRON2", 
  273. 		} 
  274.  
  275. 		RONIN_RESPAWN_TIME_MS					= 500  -- Time in MS before respawning 
  276. 		RONIN_RESPAWN_DISTANCE					= 0.01 
  277. 		 
  278. 		LIEUTENANTS_TO_KILL					= 20-- # LTNTS that the player(s) need to kill 
  279. 		MAX_LIEUTENANTS_ATTACKING			= 8	-- Max # of ltnts. attacking at any time. 
  280. 		WAVE_MIN_SIZE							= 2	-- Min size of Wave 
  281. 		WAVE_MAX_SIZE							= 4	-- Max size of Wave 
  282. 		WAVE_CLUMPING_FACTOR					= 0.8	-- In (0,1), higher -> increased chance for Ronin to spawn near each other. 
  283.  
  284. 		PED_SPAWNING_DISABLE_RATIO			= 0.4	-- When ltnts killed / kills needed reaches this level, ped spawning is diabled 
  285. 		ATTACK_PLAYER_ONLY_RATIO			= 0.5 -- When ltnts killed / kills needed reaches this level, ltnts always attack the player. 
  286.  
  287. 		-- Stage 4: Junk-Boat Fight 
  288. 		WONG_SURVIVAL_TICKS			=	20		-- the number of times Wong takes damage before dying 
  289. 		WONG_SURVIVAL_TIME_S			=	125		-- the amount of time Wong survives before dying 
  290. 		COOP_HP_MULTIPLIER			=  1.25  -- factor applied to Ronin in coop 
  291.  
  292. 		-- Stage 5: Akuji Boss Battle 
  293. 		AKUJI_HIT_POINTS						= 2500 
  294. 		AKUJI_HIT_POINTS_COOP				= 2000 
  295. 		AKUJI_PASSED_OUT_TIME_S				= 10	-- Time Akuji is vulnerable to finishers before he revives 
  296. 		AKUJI_REVIVE_PERCENT					= .50 -- Amount of health Akuji revives with 
  297. 		 
  298. 		--Flags for when to use GPS 
  299. 		GPS_TO_WATERCRAFT			= true 
  300. 		GPS_TO_FESTIVAL				= true 
  301. 		GPS_TO_AKUJI				= false 
  302. 	 
  303. -- Global Variables (First letter caps == Global Variable) 
  304.  
  305. 	-- THREADS 
  306. 	Thread_speedboat1					= -1 
  307. 	Thread_speedboat2					= -1 
  308. 	Thread_speedboat_throttle		= -1 
  309. 	Thread_wong_health				= -1 
  310. 	Table_all_threads					= {	Thread_speedboat1, Thread_speedboat2, Thread_speedboat_throttle, Thread_wong_health} 
  311.  
  312. 	-- Progress flags 
  313. 	Waverunner_entered				= false -- Players have entered the waverunner? 
  314. 	rn11_speedboat1_disabled		= false -- Speedboat1 or its driver destroyed/killed? 
  315. 	rn11_speedboat2_disabled		= false -- Speedboat2 or its driver destroyed/killed? 
  316. 	Festival_reached					= false 
  317. 	Junk_area_reached					= false -- Player passed near junk boats, Wong's health can drop when true 
  318. 	Wong_tick_next						= false -- Time to apply next tick of damage? 
  319. 	--Akuji_reached						= false -- Player(s) arrived at Akuji? 
  320. 	Sword_loaned						= false -- Players given temporary swords? 
  321. 	Akuji_revived						= false 
  322.  
  323. 	Rn11_location_reached = false 
  324.  
  325. 	-- Have to define this function here so it can be used to initialize a global variable 
  326. 	function rn11_table_copy(source) 
  327. 		local table_copy = {} 
  328. 		for i,entry in pairs(source) do 
  329. 			table_copy[i] = entry 
  330. 		end 
  331. 		return table_copy 
  332. 	end 
  333.  
  334. 	Spawnable_ronin = {} 
  335. 	Spawn_locations_next_navpoint_index	= {} 
  336. 	Lieutenant_completion_ratio = 0.001			-- We divide things by this so don't start it at 0. 
  337.  
  338. 	Effect_handles = {} 
  339.  
  340. -- TEMPORARY Global Variables 
  341.  
  342. 	Debug_ltnt_quick_kill			= false 
  343.  
  344. -- DEBUG FUNCTIONS ------------------------------------------ 
  345.  
  346. function rn11_debug_festival_battle() 
  347.  
  348. 	teleport(LOCAL_PLAYER, NAVPOINT_MOLOTOV_TARGET) 
  349. 	delay(8.0) 
  350.  
  351. 	-- Turn off notoriety spawns, ambient spawns at this point 
  352. 	notoriety_force_no_spawn("Ronin", true)  
  353. 	ambient_gang_spawn_enable(false) 
  354.  
  355. 	-- low ped density 
  356. 	--set_ped_density(0.0001) 
  357.  
  358. 	rn11_festival_battle() 
  359.  
  360. 	rn11_complete() 
  361.  
  362. end 
  363.  
  364. function rn11_debug_junks() 
  365.  
  366. 	teleport(LOCAL_PLAYER, NAVPOINT_MOLOTOV_TARGET) 
  367. 	delay(8.0) 
  368.  
  369. 	cutscene_play("IG_rn11_scene1", GROUP_JUNK) 
  370. 	group_show(GROUP_JUNK) 
  371.  
  372. 	Thread_wong_health = thread_new("rn11_display_wong_health")	 
  373.  
  374. 	rn11_send_to_location(TRIGGER_AKUJI, INGAME_EFFECT_LOCATION, HELPTEXT_PROMPT_JUNK, GPS_TO_AUKJI) 
  375.  
  376. 	-- Ensure that Wong's health is no longer displayed 
  377. 	thread_kill(Thread_wong_health) 
  378. 	hud_bar_off(0) 
  379.  
  380. 	-- Akuji boss battle checkpoint 
  381. 	mission_set_checkpoint(CHECKPOINT_AKUJI) 
  382. 	rn11_checkpoint = CHECKPOINT_AKUJI 
  383.  
  384. 	rn11_complete() 
  385.  
  386. end 
  387.  
  388. function rn11_debug_cutscene() 
  389.  
  390. 	cutscene_in() 
  391.  
  392. 	-- Disable player controls 
  393. 	player_controls_disable(LOCAL_PLAYER) 
  394. 	if (IN_COOP) then 
  395. 		player_controls_disable(REMOTE_PLAYER) 
  396. 	end 
  397.  
  398. 	-- Remove the players from any vehicles before starting the boss fight 
  399. 	if (character_is_in_vehicle(LOCAL_PLAYER)) then 
  400. 		vehicle_exit_teleport(LOCAL_PLAYER) 
  401. 	end		 
  402. 	if (IN_COOP and character_is_in_vehicle(REMOTE_PLAYER)) then 
  403. 		vehicle_exit_teleport(REMOTE_PLAYER) 
  404. 	end 
  405.  
  406. 	spawning_pedestrians(false) 
  407. 	spawning_vehicles(false) 
  408.  
  409. 	cutscene_play("IG_rn11_scene2", nil, {NAVPOINT_LOCAL_PLAYER_START_AKUJI, NAVPOINT_REMOTE_PLAYER_START_AKUJI}, false ) 
  410.  
  411. 	-- Set Akuji's hit points, display his health bar 
  412. 	inv_item_remove_all(CHARACTER_AKUJI) 
  413. 	set_max_hit_points(CHARACTER_AKUJI,AKUJI_HIT_POINTS) 
  414. 	on_death("rn11_complete", CHARACTER_AKUJI) 
  415. 	damage_indicator_on(0, CHARACTER_AKUJI,0.0, HELPTEXT_HUD_AKUJI_HEALTH) 
  416. 	npc_set_boss_type(CHARACTER_AKUJI, AI_BOSS_AKUJI) 
  417.  
  418. 	inv_item_add("samurai_sword", 1, CHARACTER_AKUJI) 
  419. 	inv_item_equip("samurai_sword",CHARACTER_AKUJI) 
  420.  
  421. 	marker_add_npc(CHARACTER_AKUJI, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  422.  
  423. 	-- Give the players swords 
  424. 	inv_weapon_add_temporary(LOCAL_PLAYER, "samurai_sword", 1, true) 
  425. 	inv_item_equip("samurai_sword",LOCAL_PLAYER) 
  426. 	if (IN_COOP) then 
  427. 		inv_weapon_add_temporary(REMOTE_PLAYER, "samurai_sword", 1, true) 
  428. 		inv_item_equip("samurai_sword",REMOTE_PLAYER) 
  429. 	end 
  430. 	Sword_loaned	= true 
  431. 	party_use_melee_weapons_only(true) 
  432.  
  433. 	cutscene_out() 
  434.  
  435. 	-- Reenable player controls 
  436. 	player_controls_enable(LOCAL_PLAYER) 
  437. 	if (IN_COOP) then 
  438. 		player_controls_enable(REMOTE_PLAYER) 
  439. 	end 
  440.  
  441. 	-- Have Akuji attack 
  442. 	npc_combat_enable(CHARACTER_WONG, false) 
  443. 	attack(CHARACTER_AKUJI, LOCAL_PLAYER) 
  444.  
  445. 	delay(120) 
  446.  
  447. 	rn11_complete() 
  448.  
  449. end 
  450.  
  451. Rn11_junk_fire_start_thread = INVALID_THREAD_HANDLE 
  452. function rn11_start_junk_fire() 
  453.  
  454. 	if (Rn11_junk_fire_start_thread ~= INVALID_THREAD_HANDLE) then 
  455. 		if (not thread_check_done(Rn11_junk_fire_start_thread)) then 
  456. 			return 
  457. 		end 
  458. 	end 
  459.  
  460. 	Rn11_junk_fire_start_thread = thread_new("rn11_start_junk_fire_do") 
  461.  
  462. end 
  463.  
  464. function rn11_start_junk_fire_do() 
  465.  
  466. 	-- Delay so that effects stopped by other systems have time to die 
  467. 	delay(1.0) 
  468.  
  469. 	-- Stop any currently playing fires 
  470. 	for i, effect_handle in pairs(Effect_handles) do 
  471. 		effect_stop(effect_handle) 
  472. 	end 
  473.  
  474. 	-- Wait for the effects to die 
  475. 	delay(1.0) 
  476.  
  477. 	-- Play new effects 
  478. 	for effect, navpoints in pairs(JUNK_BOAT_FIRE_EFFECTS) do 
  479.  
  480. 		for i, navpoint in pairs(navpoints) do 
  481. 			Effect_handles[navpoint] = effect_play(effect,navpoint,true) 
  482. 		end 
  483.  
  484. 	end 
  485.  
  486. end 
  487.  
  488. -- REQUIRED MISSION FUNCTIONS ------------------------------- 
  489.  
  490. -- Called when the mission starts 
  491. function rn11_start(rn11_checkpoint, is_restart) 
  492.  
  493. 	-- The player is being respawned inside of the not-yet-loaded junk boats. This looks bad, so just 
  494. 	-- fadeout immediately. 
  495. 	if (rn11_checkpoint == CHECKPOINT_AKUJI) then 
  496. 		fade_out(0) 
  497. 	end 
  498. 	mission_start_fade_out() 
  499.  
  500. 	if (rn11_checkpoint == CHECKPOINT_START) then 
  501.  
  502. 		-- Determine which groups we need to load 
  503. 		local start_groups = {GROUP_START_CAR, GROUP_WATERCRAFT} 
  504. 		if (coop_is_active()) then 
  505. 			start_groups = {GROUP_START_CAR, GROUP_WATERCRAFT, GROUP_START_CAR_COOP} 
  506. 		end 
  507.  
  508. 		-- If it is a restart then teleport players to the start location and create the starting groups 
  509. 		if (is_restart) then 
  510. 			for i,group in pairs(start_groups) do 
  511. 				group_create(group,true) 
  512. 			end 
  513. 			teleport_coop(NAVPOINT_LOCAL_PLAYER_START, NAVPOINT_REMOTE_PLAYER_START) 
  514. 		-- Else, play the cutscene then show the starting groups 
  515. 		else 
  516. 			cutscene_play("ro11-01", start_groups, {NAVPOINT_LOCAL_PLAYER_START, NAVPOINT_REMOTE_PLAYER_START}, false) 
  517. 			for i,group in pairs(start_groups) do 
  518. 				group_show(group) 
  519. 			end 
  520. 		end 
  521. 	end 
  522.  
  523. 	rn11_initialize(rn11_checkpoint) 
  524. 	 
  525. 	if (DEBUG_START_AT_FESTIVAL) then 
  526. 		rn11_debug_festival_battle() 
  527. 		delay(5.0) 
  528. 	end 
  529.  
  530. 	if (DEBUG_START_AT_JUNKS) then 
  531. 		rn11_debug_junks() 
  532. 		delay(5.0) 
  533. 	end 
  534.  
  535. 	if (DEBUG_START_AT_CUTSCENE_2) then 
  536. 		rn11_debug_cutscene() 
  537. 	end 
  538.  
  539. 	if (rn11_checkpoint == CHECKPOINT_START) then 
  540. 		rn11_send_to_festival() 
  541.  
  542. 		mission_set_checkpoint(CHECKPOINT_FESTIVAL) 
  543. 		rn11_checkpoint = CHECKPOINT_FESTIVAL 
  544.  
  545. 		-- Load junk boat ronin now, adjust health 
  546. 		rn11_group_create_hidden_maybe_coop(GROUP_JUNK, GROUP_JUNK_COOP) 
  547. 		rn11_adjust_hp_for_coop(MEMBERS_GROUP_JUNK) 
  548.  
  549. 	end  
  550. 	 
  551. 	if (rn11_checkpoint == CHECKPOINT_FESTIVAL) then 
  552. 		rn11_clear_lieutenants() 
  553.  
  554. 		mission_set_checkpoint(CHECKPOINT_JUNKS) 
  555. 		rn11_checkpoint = CHECKPOINT_JUNKS 
  556.  
  557. 	end 
  558.  
  559. 	if (rn11_checkpoint == CHECKPOINT_JUNKS) then 
  560. 		rn11_find_akuji_and_wong() 
  561.  
  562. 		mission_set_checkpoint(CHECKPOINT_AKUJI) 
  563. 		rn11_checkpoint = CHECKPOINT_AKUJI 
  564.  
  565. 		-- Initialize next checkpoint 
  566. 		rn11_initialize_checkpoint(CHECKPOINT_AKUJI) 
  567. 	end 
  568.  
  569. 	rn11_akuji_boss_fight() 
  570. end 
  571.  
  572. function rn11_initialize(checkpoint) 
  573.  
  574. 	-- Do initialization common to all checkpoints 
  575. 	rn11_initialize_common() 
  576.  
  577. 	-- Do checkpoint-specific initialization 
  578. 	rn11_initialize_checkpoint(checkpoint) 
  579.  
  580. 	-- When starting from the Akuji checkpoint, let the cutscene do the fade-in. 
  581. 	if (checkpoint == CHECKPOINT_AKUJI) then 
  582. 		player_controls_enable(LOCAL_PLAYER) 
  583. 		if(IN_COOP) then 
  584. 			player_controls_enable(REMOTE_PLAYER) 
  585. 		end 
  586. 	else 
  587. 		mission_start_fade_in() 
  588. 	end 
  589.  
  590. end 
  591.  
  592. function rn11_initialize_common() 
  593.  
  594. 	set_mission_author("Phillip Alexander") 
  595.  
  596. 	if (coop_is_active()) then 
  597. 		IN_COOP	= true 
  598. 		rn11_table_concat(MEMBERS_GROUP_JUNK, MEMBERS_GROUP_JUNK_COOP) 
  599. 	end 
  600.  
  601. 	-- Swap out the normal chunk w/ the festival chunk: 
  602. 	city_chunk_swap("sr2_chunk179", "festival", false, true, true) 
  603. 	city_chunk_swap("sr2_intmamis3junksempty", "festival", true, true, true) 
  604.  
  605. 	-- Set notoriety  min/max 
  606. 	notoriety_set_min("Ronin",4) 
  607. 	notoriety_set_max("Ronin",4) 
  608. 	notoriety_set("Ronin",4) 
  609.  
  610. 	-- Set time of day to dusk3 
  611. 	set_time_of_day(TIME_OF_DAY_HOUR,TIME_OF_DAY_MINUTE) 
  612.  
  613. end 
  614.  
  615. function rn11_initialize_checkpoint(checkpoint) 
  616.  
  617. 	if (checkpoint ~= CHECKPOINT_START) then 
  618. 	 
  619. 		-- Start the junk boat fire 
  620. 		rn11_start_junk_fire() 
  621.  
  622. 		-- Turn off notoriety spawns, ambient spawns at this point 
  623. 		notoriety_force_no_spawn("Ronin", true)  
  624. 		ambient_gang_spawn_enable(false) 
  625. 		 
  626. 	end 
  627. 	 
  628. 	if (checkpoint == CHECKPOINT_FESTIVAL) then 
  629.  
  630. 		group_create(GROUP_LIEUTENANTS, true) 
  631.  
  632. 		-- Load junk boat ronin now, adjust health 
  633. 		rn11_group_create_hidden_maybe_coop(GROUP_JUNK, GROUP_JUNK_COOP) 
  634. 		rn11_adjust_hp_for_coop(MEMBERS_GROUP_JUNK) 
  635.  
  636. 	end 
  637.  
  638. 	if (checkpoint == CHECKPOINT_JUNKS) then 
  639. 		rn11_group_create_maybe_coop(GROUP_JUNK, GROUP_JUNK_COOP) 
  640. 		rn11_adjust_hp_for_coop(MEMBERS_GROUP_JUNK) 
  641. 	end 
  642.  
  643. end 
  644.  
  645. function rn11_send_to_festival() 
  646.  
  647. 	thread_new("rn11_create_lieutenants") 
  648.  
  649. 	-- Make the waverunner invulnerable for now 
  650. 	turn_invulnerable(VEHICLE_WAVERUNNER, false) 
  651. 	set_max_hit_points(VEHICLE_WAVERUNNER, WAVERUNNER_HIT_POINTS) 
  652.  
  653. 	-- Send player(s) to the dock 
  654. 	--rn11_send_to_location(	TRIGGER_DOCK, INGAME_EFFECT_VEHICLE_LOCATION,  
  655. 	--								HELPTEXT_PROMPT_LOCATION_DOCK, ALLOWED_TIME_TO_DOCK_MS, "rn11_failure_dock") 
  656. 	hud_timer_set(0, ALLOWED_TIME_TO_FESTIVAL_MS, "rn11_failure_dock") 
  657. 	rn11_send_to_location(	TRIGGER_DOCK, INGAME_EFFECT_VEHICLE_LOCATION, HELPTEXT_PROMPT_LOCATION_DOCK, GPS_TO_WATERCRAFT) 
  658.  
  659. 	-- Release the starting vehicle 
  660. 	release_to_world(GROUP_START_CAR) 
  661. 	if IN_COOP then 
  662. 		release_to_world(GROUP_START_CAR_COOP) 
  663. 	end 
  664.  
  665. 	-- Start the attack heli thread 
  666. 	attack_heli_set_drop_accuracy(.2,.6) 
  667. 	thread_new("rn11_attack_helis") 
  668.  
  669. 	-- Prompt the player to enter the Waverunner, add minimap and in-game icon to waverunner 
  670. 	thread_new("mission_help_table",HELPTEXT_PROMPT_WAVERUNNER) 
  671. 	marker_add_vehicle(VEHICLE_WAVERUNNER, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_INTERACT, SYNC_ALL) 
  672.  
  673. 	-- wait for a player to enter the waverunner 
  674. 	on_vehicle_enter("rn11_waverunner_entered", VEHICLE_WAVERUNNER) 
  675. 	while (not Waverunner_entered) do 
  676. 		thread_yield() 
  677. 	end 
  678. 	turn_vulnerable(VEHICLE_WAVERUNNER) 
  679.  
  680. 	-- remove the Waverunner vehicle waypoint/icon and trigger 
  681. 	marker_remove_vehicle(VEHICLE_WAVERUNNER,SYNC_ALL) 
  682. 	on_vehicle_enter("",VEHICLE_WAVERUNNER) 
  683.  
  684. 	vehicle_max_speed(VEHICLE_WAVERUNNER,WAVERUNNER_MAX_SPEED) 
  685.  
  686. 	-- Send player(s) to the Heritage festival 
  687. 	rn11_send_to_location(	TRIGGER_FESTIVAL_ARRIVAL, INGAME_EFFECT_VEHICLE_LOCATION,  
  688. 									HELPTEXT_PROMPT_FESTIVAL, GPS_TO_FESTIVAL) 
  689.  
  690. 	hud_timer_stop(0) 
  691. 	Festival_reached = true 
  692.  
  693. 	rn11_start_junk_fire() 
  694.  
  695. end 
  696.  
  697. function rn11_create_lieutenants() 
  698. 	group_create(GROUP_LIEUTENANTS, false) 
  699. end 
  700.  
  701.  
  702. function rn11_attack_helis() 
  703.  
  704. 	-- Create the attack heli 
  705. 	attack_heli_create(NAVPOINT_HELI_START, 0) 
  706. 	attack_heli_go(0) 
  707. 	attack_heli_init_weave_ai(0) 
  708.  
  709. 	local heli_name = attack_heli_get_heli_name(0) 
  710.  
  711. 	local function rn11_process_attack_helis() 
  712. 		if (vehicle_exists(heli_name) and (not vehicle_is_destroyed(heli_name))) then 
  713. 			attack_heli_update(0) 
  714. 		else 
  715. 			attack_heli_destroy(0) 
  716. 			heli_name = rn11_maybe_spawn_new_attack_heli() 
  717. 		end 
  718. 	end 
  719.  
  720. 	while ( not Festival_reached) do 
  721. 		thread_yield() 
  722. 		rn11_process_attack_helis() 
  723. 	end 
  724.  
  725. 	if (vehicle_exists(heli_name) and (not vehicle_is_destroyed(heli_name))) then 
  726. 		helicopter_enter_retreat(heli_name) 
  727. 		while(vehicle_exists(heli_name) and (not vehicle_is_destroyed(heli_name)) ) do 
  728. 			local dist, player = get_dist_closest_player_to_object(heli_name) 
  729. 			if (dist > 300) then 
  730. 				attack_heli_destroy(0)	 
  731. 			end 
  732. 			thread_yield() 
  733. 		end 
  734. 	end 
  735.  
  736. end 
  737.  
  738. function rn11_maybe_spawn_new_attack_heli() 
  739.  
  740. 	local function get_attack_heli_spawn_location() 
  741.  
  742. 		for i, navpoint in pairs(ATTACK_HELI_SPAWN_LOCATIONS) do 
  743.  
  744. 			if (not rn11_navpoint_in_fov(navpoint)) then 
  745.  
  746. 				local dist = get_dist(navpoint, LOCAL_PLAYER) 
  747. 				if (dist < 500 and dist > 100) then 
  748. 					return navpoint 
  749. 				end 
  750.  
  751. 			end 
  752.  
  753. 		end 
  754.  
  755. 		return nil 
  756.  
  757. 	end 
  758.  
  759. 	local attack_heli_spawn_location = get_attack_heli_spawn_location() 
  760.  
  761. 	if (attack_heli_spawn_location ~= nil) then 
  762. 		attack_heli_create(attack_heli_spawn_location, 0) 
  763. 		attack_heli_go(0) 
  764. 		attack_heli_init_weave_ai(0) 
  765.  
  766. 		return attack_heli_get_heli_name(0) 
  767. 	else 
  768. 		return "" 
  769. 	end 
  770.  
  771. end 
  772.  
  773. function rn11_clear_lieutenants() 
  774.  
  775. 	-- Players have to kill all the lieutenants 
  776. 	rn11_festival_battle() 
  777.  
  778. 	-- Cutscene, Akuji entering the boats 
  779. 	cutscene_in() 
  780.  
  781. 	cutscene_play("IG_rn11_scene1", "", {NAVPOINT_LOCAL_PLAYER_START_CHECKPOINT_2,NAVPOINT_REMOTE_PLAYER_START_CHECKPOINT_2}, false) 
  782. 	-- Get rid of the cutscene's group 
  783. 	group_destroy(GROUP_CTE_AKUJI) 
  784.  
  785. 	-- Make the junk-boat Ronin visible 
  786. 	rn11_group_show_maybe_coop(GROUP_JUNK, GROUP_JUNK_COOP) 
  787.  
  788. 	-- Start the junk boat fires 
  789. 	rn11_start_junk_fire() 
  790. 		 
  791. 	cutscene_out() 
  792.  
  793. end 
  794.  
  795. function rn11_find_akuji_and_wong() 
  796.  
  797. 	-- Have Wong's health tick down as the players try to find him and Akuji 
  798. 	Thread_wong_health = thread_new("rn11_display_wong_health")	 
  799. 	rn11_send_to_location(TRIGGER_AKUJI, INGAME_EFFECT_LOCATION, HELPTEXT_PROMPT_JUNK, GPS_TO_AKUJI) 
  800.  
  801. 	-- Ensure that Wong's health is no longer displayed 
  802. 	thread_kill(Thread_wong_health) 
  803. 	hud_bar_off(0) 
  804.  
  805. end 
  806.  
  807. function rn11_akuji_boss_fight() 
  808.  
  809. 	-- Cutscene, Akuji and Wong talking 
  810. 	cutscene_in() 
  811.  
  812. 	character_evacuate_from_all_vehicles(LOCAL_PLAYER) 
  813. 	if (IN_COOP and character_is_in_vehicle(REMOTE_PLAYER)) then 
  814. 		character_evacuate_from_all_vehicles(REMOTE_PLAYER) 
  815. 	end 
  816.  
  817. 	spawning_pedestrians(false) 
  818. 	spawning_vehicles(false) 
  819.  
  820. 	-- Eliminate everyone in the existing party. Turn off ped. spawnin and repopulate the world 
  821. 	-- to eliminate any followers that you brought along. 
  822. 	party_dismiss_all() 
  823. 	party_set_recruitable(false) 
  824. 	spawning_pedestrians(false, true) 
  825.  
  826. 	cutscene_play("IG_rn11_scene2") 
  827. 	 
  828. 	-- Enable sword combat 
  829. 	rn11_enable_sword_combat(true) 
  830.  
  831. 	-- Override personas: 
  832. 	persona_override_character_start(CHARACTER_AKUJI, POT_SITUATIONS[POT_ATTACK],"KAZUO_RON11_ATTACK") 
  833. 	persona_override_character_start(CHARACTER_AKUJI, POT_SITUATIONS[POT_TAKE_DAMAGE],"KAZUO_RON11_TAKEDAM") 
  834.  
  835. 	-- Setup Akuji 
  836. 	inv_item_remove_all(CHARACTER_AKUJI) 
  837. 	set_max_hit_points(CHARACTER_AKUJI,AKUJI_HIT_POINTS) 
  838. 	on_death("rn11_complete", CHARACTER_AKUJI) 
  839. 	damage_indicator_on(0, CHARACTER_AKUJI,0.0, HELPTEXT_HUD_AKUJI_HEALTH) 
  840. 	npc_set_boss_type(CHARACTER_AKUJI, AI_BOSS_AKUJI) 
  841. 	inv_item_add("samurai_sword", 1, CHARACTER_AKUJI) 
  842. 	inv_item_equip("samurai_sword",CHARACTER_AKUJI) 
  843. 	marker_add_npc(CHARACTER_AKUJI, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  844. 	--character_allow_ragdoll(CHARACTER_AKUJI, false) 
  845.  
  846. 	-- Teleport remote player to fight start 
  847. 	if (IN_COOP) then 
  848. 		teleport(REMOTE_PLAYER, NAVPOINT_REMOTE_PLAYER_START_AKUJI) 
  849. 	end 
  850.  
  851. 	-- Give the players swords 
  852. 	inv_weapon_add_temporary(LOCAL_PLAYER, "samurai_sword", 1, true) 
  853. 	inv_item_equip("samurai_sword",LOCAL_PLAYER) 
  854. 	party_use_melee_weapons_only(true) 
  855. 	if (IN_COOP) then 
  856. 		inv_weapon_add_temporary(REMOTE_PLAYER, "samurai_sword", 1, true) 
  857. 		inv_item_equip("samurai_sword",REMOTE_PLAYER) 
  858. 	end 
  859. 	Sword_loaned	= true 
  860.  
  861. 	-- Start the junk boat fires 
  862. 	rn11_start_junk_fire() 
  863. 		 
  864. 	cutscene_out() 
  865.  
  866. 	-- Make sure that the players stay close by. 
  867. 	thread_new("rn11_boss_fight_monitor_distance") 
  868.  
  869. 	-- Have Akuji attack but Wong is a bit wussy. 
  870. 	npc_combat_enable(CHARACTER_WONG, false) 
  871.  
  872. 	tutorial_start("combat_swords", 1000, true) 
  873.  
  874. 	mission_help_table("rn10_prompt_kill_akuji") 
  875.  
  876. 	attack(CHARACTER_AKUJI, LOCAL_PLAYER)	 
  877.  
  878. end 
  879.  
  880.  
  881. function rn11_boss_fight_monitor_distance() 
  882.  
  883. 	local allowed_dist = 50 
  884. 	local allowed_time_ms = 15000 
  885.  
  886. 	local player_in_range = {[LOCAL_PLAYER] = true, [REMOTE_PLAYER] = true} 
  887. 	local player_timer = {[LOCAL_PLAYER] = 0, [REMOTE_PLAYER] = 1} 
  888. 	local player_sync = {[LOCAL_PLAYER] = SYNC_LOCAL, [REMOTE_PLAYER] = SYNC_REMOTE} 
  889.  
  890. 	local function update_indicators(player) 
  891.  
  892. 		local currently_in_range = true 
  893.  
  894. 		if ( character_exists(CHARACTER_AKUJI) and (not  character_is_dead(CHARACTER_AKUJI)) ) then 
  895. 			currently_in_range = ( get_dist(CHARACTER_AKUJI, player) < allowed_dist ) 
  896. 		end 
  897.  
  898. 		-- Were in range, now we're not. Display indicators and start timing failure. 
  899. 		if ( player_in_range[player] and (not currently_in_range) ) then 
  900.  
  901. 			mission_help_table_nag("rn10_prompt_kill_akuji", "", "", player_sync[player]) 
  902. 			distance_display_on(CHARACTER_AKUJI, 0, 50.0, 0, 50.0, player_sync[player]) 
  903. 			hud_timer_set(player_timer[player], allowed_time_ms,"rn11_failure_wong") 
  904.  
  905. 		end 
  906.  
  907. 		-- Were out of range, now we're not. Remove indicators, stop timing failure. 
  908. 		if ( (not player_in_range[player]) and currently_in_range ) then 
  909. 			distance_display_off(player_sync[player]) 
  910. 			hud_timer_stop(player_timer[player]) 
  911. 		end 
  912.  
  913. 		player_in_range[player] = currently_in_range 
  914.  
  915. 	end 
  916.  
  917. 	while (true) do 
  918. 		update_indicators(LOCAL_PLAYER) 
  919. 		if (IN_COOP) then 
  920. 			update_indicators(REMOTE_PLAYER) 
  921. 		end 
  922. 		thread_yield() 
  923. 	end 
  924.  
  925. end 
  926.  
  927. -- Monitor the distance between the player(s) and the escaping Ronin. Controls the 
  928. -- timer and displays hud messages for the out-of-range failure condition. 
  929. function rn05_monitor_dist_failure() 
  930.  
  931. 	local prev_escape_vehicle = "" 
  932.  
  933. 	local failure_dist = {	[VEHICLE_RONIN_CART] = rn05_get_parameter_value("RONIN_CART_FAILURE_DIST"), 
  934. 									[VEHICLE_RONIN_BIKE] = rn05_get_parameter_value("RONIN_BIKE_FAILURE_DIST"), 
  935. 								} 
  936.  
  937. 	local failure_time_ms = 1000 * rn05_get_parameter_value("RONIN_DIST_FAILURE_TIME_S") 
  938.  
  939. 	Timing_dist_failure = false 
  940.  
  941. 	while(not vehicle_is_destroyed(Escape_vehicle)) do 
  942.  
  943. 		-- Update the distance radar if we've switched vehicles 
  944. 		if (Escape_vehicle ~= prev_escape_vehicle) then 
  945. 			distance_display_off(SYNC_ALL) 
  946. 			distance_display_on(Escape_vehicle,0,failure_dist[Escape_vehicle],0.0,failure_dist[Escape_vehicle], SYNC_ALL) 
  947. 			prev_escape_vehicle = prev_escape_vehicle 
  948. 		end 
  949.  
  950. 		local dist = get_dist_closest_player_to_object(Escape_vehicle) 
  951.  
  952. 		if (dist > failure_dist[Escape_vehicle] and not Timing_dist_failure and rn05_enemies_living > 0) then 
  953.  
  954. 			-- Tell the player(s) to catch up. 
  955. 			mission_help_table(HELPTEXT_PROMPT_WARN_DIST, "", "", SYNC_LOCAL) 
  956.  
  957. 			-- Start the timer 
  958. 			hud_timer_set(0, failure_time_ms,"rn05_ronin_escaped_failure") 
  959. 			Timing_dist_failure = true 
  960.  
  961. 		elseif (dist < failure_dist[Escape_vehicle] and Timing_dist_failure) then 
  962.  
  963. 			-- Stop the timer 
  964. 			hud_timer_stop(0) 
  965. 			Timing_dist_failure = false 
  966.  
  967. 			-- Update the objective text 
  968. 			objective_text(0, rn05_enemy_set_objective_helptext, rn05_enemies_to_kill - rn05_enemies_living, rn05_enemies_to_kill) 
  969.  
  970. 		end 
  971.  
  972. 		thread_yield() 
  973. 	end 
  974.  
  975. end 
  976.  
  977. function rn11_enable_sword_combat(enable) 
  978. 	combat_enable_sword_parries(enable) 
  979. 	combat_enable_sword_strafing(enable) 
  980.  
  981. 	local take_damage_callback = "" 
  982. 	if (enable) then 
  983. 		take_damage_callback = "rn11_player_damaged" 
  984. 		thread_new("rn11_always_ready") 
  985. 	end 
  986.  
  987. 	on_take_damage(take_damage_callback, LOCAL_PLAYER) 
  988. 	if(IN_COOP) then 
  989. 		on_take_damage(take_damage_callback, REMOTE_PLAYER) 
  990. 	end 
  991.  
  992. 	character_set_cannot_wield_havok_weapon(LOCAL_PLAYER, enable) 
  993. 	if (IN_COOP) then 
  994. 		character_set_cannot_wield_havok_weapon(REMOTE_PLAYER, enable) 
  995. 	end 
  996.  
  997. 	-- Don't let the players enter vehicles 
  998. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, (not enable)) 
  999. 	if (IN_COOP) then 
  1000. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, (not enable)) 
  1001. 	end 
  1002.  
  1003. end 
  1004.  
  1005. function rn11_always_ready() 
  1006.  
  1007. 	local function combat_ready(character) 
  1008. 		if (	character_exists(character) and  
  1009. 				(not character_is_dead(character)) and  
  1010. 				(not character_is_ragdolled(character))  
  1011. 			) then 
  1012. 			character_set_combat_ready(character, true, 1.0) 
  1013. 		end 
  1014. 	end 
  1015.  
  1016. 	while(true) do 
  1017. 		thread_yield() 
  1018. 		combat_ready(LOCAL_PLAYER) 
  1019. 		combat_ready(REMOTE_PLAYER) 
  1020. 		combat_ready(CHARACTER_AKUJI) 
  1021. 	end 
  1022.  
  1023. end 
  1024.  
  1025. function rn11_player_damaged(player, attacker, damage_percent) 
  1026.  
  1027. 	if (attacker == CHARACTER_AKUJI) then 
  1028. 		character_ragdoll(player, 1000) 
  1029. 		audio_play_persona_line(CHARACTER_AKUJI, "threat - alert (solo attack)") 
  1030. 	end 
  1031.  
  1032. end 
  1033.  
  1034. -- Cleanup mission 
  1035. function rn11_cleanup() 
  1036.  
  1037. 	IN_COOP = coop_is_active() 
  1038.  
  1039. 	-- Allow follower recruiting 
  1040. 	party_set_recruitable(true) 
  1041.  
  1042. 	-- Start spawning peds again 
  1043. 	spawning_pedestrians(true) 
  1044.  
  1045. 	-- Cleanup the hud 
  1046. 	hud_timer_stop(0) 
  1047. 	hud_timer_stop(1) 
  1048. 	distance_display_off(SYNC_ALL) 
  1049.  
  1050. 	-- Disable sword combat 
  1051. 	rn11_enable_sword_combat(false) 
  1052.  
  1053. 	-- Fires burn out 
  1054. 	for i, effect_handle in pairs(Effect_handles) do 
  1055. 		effect_stop(effect_handle) 
  1056. 	end 
  1057.  
  1058. 	-- End persona overrides 
  1059. 	persona_override_group_stop(RONIN_PERSONAS,POT_SITUATIONS[POT_ATTACK]) 
  1060.  
  1061. 	-- Reset the respawn distance 
  1062. 	npc_respawn_dist_reset() 
  1063.  
  1064. 	-- Reenable ped, vehicle spawning. It may have been turned off for the boss battle. 
  1065. 	spawning_pedestrians(true) 
  1066. 	spawning_vehicles(true) 
  1067.  
  1068. 	-- Reset Ronin notoriety 
  1069. 	notoriety_set_min("Ronin",0) 
  1070. 	notoriety_set_max("Ronin",5) 
  1071. 	notoriety_set("Ronin",0) 
  1072.  
  1073. 	-- Turn on notoriety, ambient Ronin spawns 
  1074. 	notoriety_force_no_spawn("Ronin", false)  
  1075. 	ambient_gang_spawn_enable(true) 
  1076.  
  1077. 	-- Remove waverunner marker 
  1078. 	if (group_is_loaded(GROUP_WATERCRAFT)) then 
  1079. 		marker_remove_vehicle(VEHICLE_WAVERUNNER,SYNC_ALL) 
  1080. 	end 
  1081.  
  1082. 	-- Remove npc markers, triggers 
  1083. 	if (group_is_loaded(GROUP_LIEUTENANTS)) then 
  1084. 		for i,lieutenant in pairs(MEMBERS_GROUP_LIEUTENANTS) do 
  1085. 			on_death("", lieutenant) 
  1086. 			marker_remove_npc(lieutenant) 
  1087. 		end 
  1088. 	end 
  1089.  
  1090. 	-- Kill all secondary threads 
  1091. 	for i, thread in pairs(Table_all_threads) do 
  1092. 		thread_kill(thread) 
  1093. 	end 
  1094.  
  1095. 	-- disable all triggers, remove callbacks 
  1096. 	for i, trigger in pairs(TABLE_ALL_TRIGGERS) do 
  1097. 		on_trigger("",trigger) 
  1098. 		trigger_enable(trigger,false) 
  1099. 	end 
  1100.  
  1101. 	-- remove temporary weapons 
  1102. 	if (Sword_loaned) then 
  1103. 		inv_weapon_remove_temporary(LOCAL_PLAYER, "samurai_sword") 
  1104. 		party_use_melee_weapons_only(false) 
  1105. 		if (IN_COOP) then 
  1106. 			inv_weapon_remove_temporary(REMOTE_PLAYER, "samurai_sword") 
  1107. 		end 
  1108. 	end 
  1109.  
  1110. 	party_use_melee_weapons_only(false) 
  1111. 	-- teleport players onto docks if they're in that area. 
  1112. 	if(get_dist(LOCAL_PLAYER, NAVPOINT_LOCAL_PLAYER_START_CHECKPOINT_3) < 300) then 
  1113. 		teleport(LOCAL_PLAYER, NAVPOINT_LOCAL_PLAYER_START_CHECKPOINT_3, true) 
  1114. 	end 
  1115. 	if (IN_COOP) then 
  1116. 		if (get_dist(REMOTE_PLAYER, NAVPOINT_REMOTE_PLAYER_START_CHECKPOINT_3) < 300) then 
  1117. 			teleport(REMOTE_PLAYER, NAVPOINT_REMOTE_PLAYER_START_CHECKPOINT_3, true) 
  1118. 		end 
  1119. 	end 
  1120.  
  1121. 	-- Replace festival chunks w/ normal ones. 
  1122. 	city_chunk_swap("sr2_chunk179", "normal", false, true, true) 
  1123. 	city_chunk_swap("sr2_intmamis3junksempty", "normal", true, true, true) 
  1124.  
  1125. end 
  1126.  
  1127. function rn11_success() 
  1128.  
  1129. 	-- Post the news event 
  1130. 	radio_post_event("JANE_NEWS_RON11", true) 
  1131.  
  1132. end 
  1133.  
  1134.  
  1135. -- MISSION FUNCTIONS ---------------------------------------- 
  1136.  
  1137. function rn11_waverunner_entered() 
  1138. 	Waverunner_entered = true; 
  1139. end 
  1140.  
  1141.  
  1142. -- Monitor the distance between the player(s) and the escaping Ronin. Controls the 
  1143. -- timer and displays hud messages for the out-of-range failure condition. 
  1144. function rn11_monitor_dist() 
  1145.  
  1146. 	-- Have the speedboats drive slowly for an initial period before starting failure timers 
  1147. 	vehicle_speed_override(VEHICLE_SPEEDBOAT1, SPEEDBOAT_INITIAL_SPEED_MPH) 
  1148. 	--delay(SPEEDBOAT_INITIAL_SPEED_TIME_S) 
  1149.  
  1150. 	-- The speedboat drives slowly until the player gets in the waverunner. 
  1151. 	while (not Waverunner_entered) do 
  1152. 		thread_yield() 
  1153. 	end 
  1154.  
  1155. 	-- Prompt to follow boats, minimap/in-game icons on boats 
  1156. 	local failure_distance = SPEEDBOAT_CLOSE_RANGE_M 
  1157. 	distance_display_on(VEHICLE_SPEEDBOAT1,0.0,failure_distance,0.0,failure_distance, SYNC_ALL) 
  1158. 	marker_add_vehicle(VEHICLE_SPEEDBOAT1, MINIMAP_ICON_KILL, INGAME_EFFECT_VEHICLE_KILL, SYNC_ALL) 
  1159. 	mission_help_table(HELPTEXT_PROMPT_FOLLOW) 
  1160.  
  1161. 	-- Delay while the prompt is displayed 
  1162. 	delay(5.0) 
  1163.  
  1164. 	local failure_time_ms = SPEEDBOAT_FOLLOW_FAIL_TIME_S * 1000 
  1165. 	local timing_out_of_range = false 
  1166.  
  1167. 	-- Always update speed/messages for initial check 
  1168. 	local initial_distance_check = true 
  1169.  
  1170. 	while(not rn11_speedboat1_disabled) do 
  1171.  
  1172. 		local dist = get_dist_closest_player_to_object(VEHICLE_SPEEDBOAT1) 
  1173.  
  1174. 		if (dist > failure_distance and ((not timing_out_of_range) or initial_distance_check)) then 
  1175.  
  1176. 			vehicle_speed_override(VEHICLE_SPEEDBOAT1, SPEEDBOAT_SLOW_SPEED_MPH) 
  1177.  
  1178. 			-- Tell the player(s) to catch up and start the failure timer. 
  1179. 			mission_help_table(HELPTEXT_PROMPT_WARN_DIST) 
  1180. 			hud_timer_set(0, failure_time_ms,"rn11_failure_follow") 
  1181. 			timing_out_of_range = true 
  1182.  
  1183. 		elseif (dist < SPEEDBOAT_CLOSE_RANGE_M and (timing_out_of_range or initial_distance_check)) then 
  1184.  
  1185. 			vehicle_speed_override(VEHICLE_SPEEDBOAT1, SPEEDBOAT_FAST_SPEED_MPH) 
  1186.  
  1187. 			-- Stop the timer 
  1188. 			hud_timer_stop(0) 
  1189. 			timing_out_of_range = false 
  1190.  
  1191. 		end 
  1192.  
  1193. 		initial_distance_check = false 
  1194.  
  1195. 		thread_yield() 
  1196. 	end 
  1197.  
  1198. 	-- Make sure that the  distance display is off. 
  1199. 	distance_display_off(SYNC_ALL) 
  1200.  
  1201. end 
  1202.  
  1203.  
  1204. -- Monitors the distance from the players to the speedboat 
  1205. -- throttles speedboat speed if vehicles are out of range 
  1206. -- starts misison failure timer when players are too far away 
  1207. function rn11_speedboat_throttle_old() 
  1208.  
  1209. 	-- Add boat radar indicators 
  1210. 	distance_display_on(VEHICLE_SPEEDBOAT1,SPEEDBOAT_CLOSE_RANGE_M,5000.0,0.0,SPEEDBOAT_CLOSE_RANGE_M, SYNC_ALL) 
  1211. 	distance_display_on(VEHICLE_SPEEDBOAT2,SPEEDBOAT_CLOSE_RANGE_M,5000.0,0.0,SPEEDBOAT_CLOSE_RANGE_M, SYNC_ALL) 
  1212.  
  1213. 	-- Have the speedboats drive slowly for an initial period 
  1214. 	vehicle_speed_override(VEHICLE_SPEEDBOAT1, SPEEDBOAT_INITIAL_SPEED_MPH) 
  1215. 	vehicle_speed_override(VEHICLE_SPEEDBOAT2, SPEEDBOAT_INITIAL_SPEED_MPH) 
  1216.  
  1217. 	delay(SPEEDBOAT_INITIAL_SPEED_TIME_S) 
  1218.  
  1219. 	local Timing_out_of_range = false 
  1220.  
  1221. 	local speedboat1_inrange = true 
  1222. 	local speedboat2_inrange = true 
  1223.  
  1224. 	while ( not (rn11_speedboat1_disabled and rn11_speedboat2_disabled)) do 
  1225.  
  1226. 		local speedboat1_dist, speedboat2_dist = SPEEDBOAT_CLOSE_RANGE_M+1,SPEEDBOAT_CLOSE_RANGE_M+1 
  1227.  
  1228. 		-- Treat disabled boats as out of range 
  1229. 		if (not rn11_speedboat1_disabled) then 
  1230. 			speedboat1_dist = get_dist_closest_player_to_object(VEHICLE_SPEEDBOAT1) 
  1231. 		end 
  1232. 		if (not rn11_speedboat2_disabled) then 
  1233. 			speedboat2_dist = get_dist_closest_player_to_object(VEHICLE_SPEEDBOAT2) 
  1234. 		end 
  1235.  
  1236. 		-- See if boats' in-range statuses have changed 
  1237. 		if ( (speedboat1_dist < SPEEDBOAT_CLOSE_RANGE_M) ~= speedboat1_inrange) then 
  1238. 			speedboat1_inrange = (not speedboat1_inrange) 
  1239. 			if (speedboat1_inrange) then 
  1240. 				vehicle_speed_override(VEHICLE_SPEEDBOAT1, SPEEDBOAT_FAST_SPEED_MPH) 
  1241. 			else 
  1242. 				vehicle_speed_override(VEHICLE_SPEEDBOAT1, SPEEDBOAT_SLOW_SPEED_MPH) 
  1243. 			end 
  1244. 		end 
  1245.  
  1246. 		if ( (speedboat2_dist < SPEEDBOAT_CLOSE_RANGE_M) ~= speedboat2_inrange) then 
  1247. 			speedboat2_inrange = (not speedboat2_inrange) 
  1248. 			if (speedboat2_inrange) then 
  1249. 				vehicle_speed_override(VEHICLE_SPEEDBOAT2, SPEEDBOAT_FAST_SPEED_MPH) 
  1250. 			else 
  1251. 				vehicle_speed_override(VEHICLE_SPEEDBOAT2, SPEEDBOAT_SLOW_SPEED_MPH) 
  1252. 			end 
  1253. 		end 
  1254.  
  1255. 		-- Player out of range and no timer is started, start the failure timer 
  1256. 		if ( (not speedboat1_inrange and not speedboat2_inrange) and (not Timing_out_of_range)) then 
  1257. 			Timing_out_of_range = true 
  1258. 			hud_timer_set(0, SPEEDBOAT_FOLLOW_FAIL_TIME_S * 1000, "rn11_failure_follow") 
  1259. 		elseif ( (speedboat1_inrange or speedboat2_inrange) and Timing_out_of_range) then 
  1260. 			Timing_out_of_range = false 
  1261. 			hud_timer_stop(0) 
  1262. 		end 
  1263.  
  1264. 		thread_yield() 
  1265. 	end 
  1266.  
  1267. 	-- Shouldn't be timing if both boats are disabled 
  1268. 	hud_timer_stop(0) 
  1269.  
  1270. 	-- kill the radar 
  1271. 	distance_display_off(SYNC_ALL) 
  1272.  
  1273. end 
  1274.  
  1275. function rn11_complete() 
  1276. 	--bink_play_movie("ro11-2.bik") 
  1277.  
  1278. 	-- End the mission with success 
  1279. 	mission_end_success("rn11", "ro11-02") 
  1280. end 
  1281.  
  1282. function rn11_send_speedboat1() 
  1283. 	-- Send the speedboat to the Marina 
  1284. 	vehicle_pathfind_to(VEHICLE_SPEEDBOAT1, "rn11_$n000", "rn11_$n001", "rn11_$n002", "rn11_$n003", 
  1285. 								"rn11_$n004", "rn11_$n005", "rn11_$n006", "rn11_$n007", "rn11_$n008", 
  1286. 								"rn11_$n009", "rn11_$n010", "rn11_$n011", "rn11_$n012", "rn11_$n013", 
  1287. 								"rn11_$n014", "rn11_$n015", "rn11_$n016", "rn11_$n017", "rn11_$n018", 
  1288. 								"rn11_$n019", "rn11_$n020", "rn11_$n021", "rn11_$n022", "rn11_$n023", 
  1289. 								"rn11_$n024", "rn11_$n025", "rn11_$n026", "rn11_$n027", "rn11_$n028", 
  1290. 								"rn11_$n029", "rn11_$n030", "rn11_$n031", "rn11_$n032", "rn11_$n033", 
  1291. 								"rn11_$n034", "rn11_$n035", "rn11_$n036", "rn11_$n037", "rn11_$n038", 
  1292. 								"rn11_$n039", "rn11_$n040", "rn11_$n041", "rn11_$n042", 
  1293. 								true, false) 
  1294. 	vehicle_chase(VEHICLE_SPEEDBOAT1, LOCAL_PLAYER, false, true, true); 
  1295. end 
  1296.  
  1297. function rn11_send_speedboat2() 
  1298. 	-- Send the speedboat to the Marina 
  1299. 	delay(1.0) 
  1300. 	vehicle_pathfind_to(VEHICLE_SPEEDBOAT2, "rn11_$n002", "rn11_$n003", 
  1301. 								"rn11_$n004", "rn11_$n005", "rn11_$n006", "rn11_$n007", "rn11_$n008", 
  1302. 								"rn11_$n009", "rn11_$n010", "rn11_$n011", "rn11_$n012", "rn11_$n013", 
  1303. 								"rn11_$n014", "rn11_$n015", "rn11_$n016", "rn11_$n017", "rn11_$n018", 
  1304. 								"rn11_$n019", "rn11_$n020", "rn11_$n021", "rn11_$n022", "rn11_$n023", 
  1305. 								"rn11_$n024", "rn11_$n025", "rn11_$n026", "rn11_$n027", "rn11_$n028", 
  1306. 								"rn11_$n029", "rn11_$n030", "rn11_$n031", "rn11_$n032", "rn11_$n033", 
  1307. 								"rn11_$n034", "rn11_$n035", "rn11_$n036", "rn11_$n037", "rn11_$n038", 
  1308. 								"rn11_$n039", "rn11_$n040", "rn11_$n041", "rn11_$n042", 
  1309. 								true, false) 
  1310. 	if (IN_COOP) then 
  1311. 		vehicle_chase(VEHICLE_SPEEDBOAT2, REMOTE_PLAYER, false, true, true); 
  1312. 	else 
  1313. 		vehicle_chase(VEHICLE_SPEEDBOAT2, LOCAL_PLAYER, false, true, true); 
  1314. 	end 
  1315. end 
  1316.  
  1317. function rn11_festival_battle() 
  1318.  
  1319. 	-- Start persona overrides 
  1320. 	persona_override_group_start(RONIN_ATTACK_PERSONAS,POT_SITUATIONS[POT_ATTACK], "RO11_ATTACK") 
  1321.  
  1322. 	rn11_process_enemy_set(MEMBERS_GROUP_LIEUTENANTS, HELPTEXT_PROMPT_LIEUTENANTS, HELPTEXT_OBJECTIVE_LIEUTENANTS) 
  1323.  
  1324. 	--[[ Add the helptext 
  1325. 	objective_text(0, HELPTEXT_OBJECTIVE_LIEUTENANTS, 0, LIEUTENANTS_TO_KILL) 
  1326.  
  1327. 	-- Have the Ronin attack in waves 
  1328. 	rn11_ronin_attack_in_waves() 
  1329.  
  1330. 	-- block until no living lieutenants remain 
  1331. 	while (Num_living_attackers ~= 0) do	 
  1332. 		thread_yield() 
  1333. 	end 
  1334.  
  1335. 	objective_text_clear(0) 
  1336. 	]] 
  1337.  
  1338. end 
  1339.  
  1340. rn11_enemies_to_kill = 0 
  1341. rn11_enemies_living = 0 
  1342. rn11_enemy_set_objective_helptext = "" 
  1343.  
  1344. -- Wait for the player to kill a group of enemies 
  1345. --  
  1346. -- enemy_table				A table containing the names of the enemies that need to be killed 
  1347. -- mission_helptext		The helptext message that will prompt the player(s) to kill the enemies 
  1348. -- objective_helptext	The objective text displayed in the hud, needs to be in the format %s of %s killed 
  1349. function rn11_process_enemy_set(enemy_table, mission_helptext, objective_helptext) 
  1350.  
  1351. 	-- Assign enemy callbacks, add markers 
  1352. 	for i, enemy in pairs(enemy_table) do 
  1353. 		if (not character_is_dead(enemy)) then 
  1354. 			on_death("rn11_enemy_killed", enemy) 
  1355. 			marker_add_npc(enemy, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL)  
  1356. 			rn11_enemies_to_kill = rn11_enemies_to_kill + 1 
  1357. 		end 
  1358. 	end 
  1359. 	rn11_enemies_living =  rn11_enemies_to_kill 
  1360.  
  1361. 	-- Display the objective text 
  1362. 	if(objective_helptext) then 
  1363. 		rn11_enemy_set_objective_helptext = objective_helptext 
  1364. 		objective_text(0, rn11_enemy_set_objective_helptext, rn11_enemies_to_kill - rn11_enemies_living, rn11_enemies_to_kill) 
  1365. 	end 
  1366.  
  1367. 	-- Display the help text 
  1368. 	if(mission_helptext) then 
  1369. 		mission_help_table(mission_helptext) 
  1370. 	end 
  1371.  
  1372. 	 
  1373. 	while (rn11_enemies_living > 0) do 
  1374. 		thread_yield() 
  1375. 	end 
  1376.  
  1377. end 
  1378.  
  1379. function rn11_enemy_killed(enemy) 
  1380. 	marker_remove_npc(enemy) 
  1381. 	on_death("",enemy) 
  1382. 	rn11_enemies_living = rn11_enemies_living - 1 
  1383. 	if (rn11_enemies_living < 1) then 
  1384. 		objective_text_clear(0) 
  1385. 		rn11_enemy_set_objective_helptext = "" 
  1386. 	else 
  1387. 		if (rn11_enemy_set_objective_helptext ~= "") then 
  1388. 			objective_text(0, rn11_enemy_set_objective_helptext, rn11_enemies_to_kill - rn11_enemies_living, rn11_enemies_to_kill) 
  1389. 		end 
  1390.  
  1391. 		if (rn11_enemies_living == 5) then 
  1392. 			for i,guard in pairs(MEMBERS_GROUP_LIEUTENANTS) do 
  1393. 				if (not character_is_dead(guard)) then 
  1394. 					npc_leash_remove(guard) 
  1395. 					attack(guard) 
  1396. 				end 
  1397. 			end		 
  1398. 		end 
  1399. 	end 
  1400. end 
  1401.  
  1402. -- Spawn waves of ronin to attack ceiling supports that the player(s) is(are) defending 
  1403. Num_living_attackers = 0 
  1404. Num_ronin_spawned = 0 
  1405. function rn11_ronin_attack_in_waves() 
  1406.  
  1407. 	objective_text(0, HELPTEXT_OBJECTIVE_LIEUTENANTS, Num_ronin_spawned - Num_living_attackers, LIEUTENANTS_TO_KILL) 
  1408.  
  1409. 	-- Start loading the ronin 
  1410. 	group_create_hidden(GROUP_LIEUTENANTS, true) 
  1411.  
  1412. 	-- Set respawn dist threshold very low. 
  1413. 	npc_respawn_dist_override(RONIN_RESPAWN_DISTANCE) 
  1414. 	 
  1415. 	-- All ronin are initially spawnable 
  1416. 	for i, ronin in pairs(MEMBERS_GROUP_LIEUTENANTS) do 
  1417. 		Spawnable_ronin[ronin] = true 
  1418. 	end 
  1419.  
  1420. 	-- Convenience variables for wave size parameters. 
  1421. 	local min_wave_size = WAVE_MIN_SIZE 
  1422. 	local max_wave_size = WAVE_MAX_SIZE 
  1423. 	local max_attackers = MAX_LIEUTENANTS_ATTACKING 
  1424.  
  1425. 	-- Returns the next wave size 
  1426. 	local function get_next_wave_size() 
  1427. 		local size = rand_int(min_wave_size, max_wave_size) 
  1428. 		if (size + Num_ronin_spawned > LIEUTENANTS_TO_KILL) then 
  1429. 			size = LIEUTENANTS_TO_KILL - Num_ronin_spawned 
  1430. 		end 
  1431. 		return size 
  1432. 	end 
  1433.  
  1434. 	-- Size of the next wave to spawn 
  1435. 	local next_wave_size = get_next_wave_size() 
  1436.  
  1437. 	-- Continuously check the number of Ronin attacking, spawn more if needed. 
  1438. 	while(Num_ronin_spawned < LIEUTENANTS_TO_KILL) do 
  1439.  
  1440. 		if (next_wave_size + Num_ronin_spawned > LIEUTENANTS_TO_KILL) then 
  1441. 			next_wave_size = LIEUTENANTS_TO_KILL - Num_ronin_spawned 
  1442. 		end 
  1443.  
  1444. 		-- Spawn the next wave if there is room. 
  1445. 		if (next_wave_size + Num_living_attackers <= max_attackers) then 
  1446.  
  1447. 			local num_ronin_in_wave = rn11_send_wave(next_wave_size) 
  1448. 			Num_ronin_spawned = Num_ronin_spawned + num_ronin_in_wave 
  1449. 			Num_living_attackers = Num_living_attackers + num_ronin_in_wave 
  1450. 			next_wave_size =  get_next_wave_size() 
  1451.  
  1452. 		end 
  1453.  
  1454. 		thread_yield() 
  1455.  
  1456. 	end -- end while(true) 
  1457.  
  1458. end 
  1459.  
  1460. -- Send a wave of ronin to attack a structural weakness 
  1461. -- 
  1462. -- wave_size: number of attackers to send 
  1463. -- 
  1464. -- returns number of attackers successfully spawned 
  1465. function rn11_send_wave(wave_size) 
  1466.  
  1467. 	local num_ronin_spawned = 0 
  1468.  
  1469. 	-- For each Ronin to be spawned 
  1470. 	for i=1, wave_size, 1 do 
  1471.  
  1472. 		-- Get a ronin to spawn and a safe spawning location.  
  1473. 		local ronin = rn11_get_spawnable_ronin() 
  1474. 		local spawn_navpoint, spawn_location_index = rn11_get_safe_spawn() 
  1475.  
  1476. 		-- If either one not found, return # ronin already spawned. 
  1477. 		if ( (spawn_navpoint == nil) or (spawn_location_index == nil) ) then 
  1478. 			return num_ronin_spawned 
  1479. 		end 
  1480.  
  1481. 		-- We're gonna spawn this guy, do some book keeping. 
  1482. 		num_ronin_spawned = num_ronin_spawned + 1 
  1483. 		Spawnable_ronin[ronin] = false 
  1484.  
  1485. 		-- Teleport to the spawn navpoint 
  1486. 		teleport(ronin, spawn_navpoint) 
  1487.  
  1488. 		-- Tell the ronin to respawn, override default respawn time 
  1489. 		npc_respawn_after_death(ronin, true) 
  1490. 		npc_respawn_after_death_time_override(ronin, RONIN_RESPAWN_TIME_MS, true) 
  1491. 		on_respawn("rn11_respawn_ronin",ronin) 
  1492.  
  1493. 		-- Show the ronin and start its patrol 
  1494. 		character_show(ronin) 
  1495. 		marker_add_npc(ronin, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL)  
  1496. 		rn11_lieutenant_attack(ronin) 
  1497.  
  1498. 		-- Delay a little bit, gives the ronin time to leave the spawn area and keeps congestion down. 
  1499. 		delay(.2,.5) 
  1500.  
  1501. 	end 
  1502.  
  1503. 	-- Return num of ronin spawned 
  1504. 	return num_ronin_spawned 
  1505.  
  1506. end 
  1507.  
  1508. -- Returns a spawnable ronin if one is available, nil else. 
  1509. function rn11_get_spawnable_ronin() 
  1510.  
  1511. 	for i, ronin in pairs(MEMBERS_GROUP_LIEUTENANTS) do 
  1512. 		if (Spawnable_ronin[ronin] == true) then 
  1513. 			return ronin 
  1514. 		end 
  1515. 	end 
  1516.  
  1517. 	return nil 
  1518.  
  1519. end 
  1520.  
  1521. -- Handle the respawning of an attacking Ronin. 
  1522. function rn11_respawn_ronin(ronin) 
  1523.  
  1524. 	-- keep the ronin hidden for now 
  1525. 	character_hide(ronin) 
  1526.  
  1527. 	-- Make this ronin available for spawning again 
  1528. 	delay(.5) 
  1529. 	Spawnable_ronin[ronin] = true 
  1530.  
  1531. end 
  1532.  
  1533. function rn11_lieutenant_killed(lieutenant) 
  1534. 	on_death("", lieutenant) 
  1535. 	marker_remove_npc(lieutenant) 
  1536. 	Num_living_attackers = Num_living_attackers - 1 
  1537.  
  1538. 	Lieutenant_completion_ratio = (Num_ronin_spawned - Num_living_attackers)/LIEUTENANTS_TO_KILL 
  1539. 	local ped_density = 1.0 - (Lieutenant_completion_ratio/PED_SPAWNING_DISABLE_RATIO) 
  1540. 	if (ped_density < .0001) then 
  1541. 		ped_density = .0001 
  1542. 	end 
  1543. 	set_ped_density(ped_density) 
  1544.  
  1545. 	objective_text(0, HELPTEXT_OBJECTIVE_LIEUTENANTS, Num_ronin_spawned - Num_living_attackers, LIEUTENANTS_TO_KILL) 
  1546. end 
  1547.  
  1548. function rn11_lieutenant_attack(lieutenant) 
  1549.  
  1550. 	on_death("rn11_lieutenant_killed", lieutenant) 
  1551. 	patrol("rn11_patrol_festival",lieutenant) 
  1552. 	if(Debug_ltnt_quick_kill) then 
  1553. 		delay(.25) 
  1554. 		character_kill(lieutenant) 
  1555. 	end 
  1556. end 
  1557.  
  1558. -- TODO: have the following function use the preferred starting location for the initial spawns. 
  1559.  
  1560. -- Find a navpoint at which we can safely (without popping) spawn a Ronin. 
  1561. -- 
  1562. -- The search for a safe navpoint has 2 stages: 
  1563. -- 1) Try to return a navpoint from the hint location 
  1564. -- 2) Try to return a navpoint that is a certain minimum distance from the players 
  1565. -- 
  1566. -- Parameters: 
  1567. --		hint_location: location at which we'd like to spawn the npc 
  1568. -- 
  1569. --	Returns: 
  1570. --		spawn_navpoint: navpoint at which to spawn 
  1571. --		spawn_location_index: index of the spawn location that contains spawn_navpoint 
  1572. function rn11_get_safe_spawn(hint_location) 
  1573.  
  1574. 	-- 1) Try to return a navpoint from the preferred location: 
  1575. 	if (hint_location ~= nil) then 
  1576. 		if (rn11_location_is_safe(hint_location)) then 
  1577. 			return rn11_return_location(hint_location) 
  1578. 		end 
  1579. 	end 
  1580.  
  1581. 	-- 2) Try to return a navpoint that is a certain minimum distance from the players 
  1582.  
  1583. 	local safe_spawn_location_indices = {} 
  1584. 	local num_safe_spawn_locations = 0; 
  1585.  
  1586. 	-- Add safe spawn locations to the list 
  1587. 	for i=1, sizeof_table(FESTIVAL_SPAWN_LOCATIONS), 1 do 
  1588.  
  1589. 		if (rn11_location_is_safe(i)) then 
  1590.  
  1591. 			num_safe_spawn_locations = num_safe_spawn_locations + 1 
  1592. 			safe_spawn_location_indices[num_safe_spawn_locations] = i 
  1593.  
  1594. 		end 
  1595.  
  1596. 	end 
  1597.  
  1598. 	-- Can't do anything if there are no safe spawn areas. 
  1599. 	if (num_safe_spawn_locations == 0) then 
  1600. 		return nil, nil 
  1601. 	end 
  1602.  
  1603. 	-- Select a random safe spawn area 
  1604. 	return rn11_return_location(safe_spawn_location_indices[rand_int(1,num_safe_spawn_locations)])  
  1605.  
  1606. end 
  1607.  
  1608. function rn11_return_location(location_index)  
  1609.  
  1610. 	-- Get current navpoint index 
  1611. 	local current_navpoint_index = Spawn_locations_next_navpoint_index[location_index] 
  1612. 	if (current_navpoint_index == nil) then 
  1613. 		current_navpoint_index = 0 
  1614. 	end 
  1615.  
  1616. 	-- Get the navpoint that we are going to return 
  1617. 	local navpoint = FESTIVAL_SPAWN_LOCATIONS[location_index][current_navpoint_index] 
  1618.  
  1619. 	-- Do a modular ncrement the navpoint index for this location 
  1620. 	local next_navpoint_index = current_navpoint_index + 1 
  1621. 	local max_navpoint_index = sizeof_table(FESTIVAL_SPAWN_LOCATIONS[location_index]) 
  1622. 	if (next_navpoint_index > max_navpoint_index) then 
  1623. 		next_navpoint_index = 1 
  1624. 	end 
  1625. 	Spawn_locations_next_navpoint_index[location_index] = next_navpoint_index 
  1626.  
  1627. 	-- return the navpoint and location index 
  1628. 	return navpoint, next_navpoint_index 
  1629.  
  1630. end 
  1631.  
  1632. function rn11_location_is_safe(location_index) 
  1633.  
  1634. 	-- Get the next navpoint at this location 
  1635. 	local navpoint_index = Spawn_locations_next_navpoint_index[location_index] 
  1636. 	if (navpoint_index == nil) then 
  1637. 		navpoint_index = 1 
  1638. 	end 
  1639. 	local navpoint = FESTIVAL_SPAWN_LOCATIONS[location_index][navpoint_index] 
  1640.  
  1641. 	-- See if the navpoint is distance-safe 
  1642. 	local dist, closest_player = get_dist_closest_player_to_object(navpoint) 
  1643. 	if (dist < 10.0 or dist > 200.0) then 
  1644. 		return false 
  1645. 	end 
  1646.  
  1647. 	if (not rn11_navpoint_in_fov(navpoint)) then 
  1648. 		return true 
  1649. 	end 
  1650. 	return false 
  1651.  
  1652. end 
  1653.  
  1654. function rn11_navpoint_in_fov(navpoint) 
  1655.  
  1656. 	local navpoint_in_local_fov = navpoint_in_player_fov(navpoint, LOCAL_PLAYER) 
  1657. 	local navpoint_in_remote_fov = false 
  1658. 	if (IN_COOP) then 
  1659. 		navpoint_in_remote_fov = navpoint_in_player_fov(navpoint, REMOTE_PLAYER) 
  1660. 	end 
  1661.  
  1662. 	return (navpoint_in_local_fov or navpoint_in_remote_fov) 
  1663.  
  1664. end 
  1665.  
  1666. function rn11_patrol_festival(lieutenant) 
  1667.  
  1668. 	-- run to the pier area before attacking peds 
  1669. 	local last_navpoint = FESTIVAL_NAVPOINTS[rand_int(1,sizeof_table(FESTIVAL_NAVPOINTS))] 
  1670. 	move_to(lieutenant, last_navpoint, 2, true, true) 
  1671.  
  1672. 	set_attack_peds_flag(lieutenant, true) 
  1673. 	set_attack_player_flag(lieutenant, true) 
  1674.  
  1675. 	local attacking_player_only = false 
  1676.  
  1677. 	while (not attacking_player_only) do 
  1678.  
  1679. 		-- Maybe begin ignoring peds and concentrate on attacking the player(s) 
  1680. 		local attack_player_only_chance = Lieutenant_completion_ratio / ATTACK_PLAYER_ONLY_RATIO 
  1681. 		if (rand_float(0.0,1.0) < attack_player_only_chance) then 
  1682. 			set_attack_peds_flag(lieutenant, false	) 
  1683. 			attack(lieutenant) 
  1684. 			attacking_player_only = true 
  1685.  
  1686. 		-- Otherwise move to a random festival navpoint 
  1687. 		else			 
  1688. 			local rand_navpoint = FESTIVAL_NAVPOINTS[rand_int(1,sizeof_table(FESTIVAL_NAVPOINTS))] 
  1689.  
  1690. 			-- if the npc is already in the right spot, have them mull around a bit 
  1691. 			if (rand_navpoint == last_navpoint) then 
  1692. 				delay(rand_float(1,5)) 
  1693. 			else 
  1694. 				local rand_speed = rand_int(1,3) 
  1695. 				move_to(lieutenant, rand_navpoint, rand_speed, false, false) 
  1696. 				last_navpoint = rand_navpoint 
  1697. 			end 
  1698. 		end 
  1699.  
  1700. 	end 
  1701. end 
  1702.  
  1703. function rn11_display_wong_health() 
  1704. 	local wong_tick_time		=	{} 
  1705. 	local wong_tick_amount	=	{} 
  1706. 	local wong_health			= 100 
  1707.  
  1708.    hud_bar_on(0, "Health", HELPTEXT_HUD_WONG_HEALTH, 1.0 ) 
  1709.    hud_bar_set_range(0, 0, wong_health, SYNC_ALL ) 
  1710.    hud_bar_set_value(0, wong_health, SYNC_ALL ) 
  1711.  
  1712. 	-- Initialize time and damage dividers for health ticks 
  1713. 	wong_tick_time[100]	= true	-- always have the last interval end after the last segment 
  1714. 	local num_dividers	=	1 
  1715. 	while(num_dividers < WONG_SURVIVAL_TICKS) do 
  1716. 		local rand_divider = rand_int(1,99) 
  1717. 		if(wong_tick_time[rand_divider] == nil) then 
  1718. 			wong_tick_time[rand_divider] = 1 
  1719. 			num_dividers = num_dividers+1 
  1720. 		end 
  1721. 	end 
  1722. 	wong_tick_amount[100]	= true; 
  1723. 	num_dividers				= 1 
  1724. 	while(num_dividers < WONG_SURVIVAL_TICKS) do 
  1725. 		local rand_divider = rand_int(1,99) 
  1726. 		if(wong_tick_amount[rand_divider] == nil) then 
  1727. 			wong_tick_amount[rand_divider] = 1 
  1728. 			num_dividers = num_dividers+1 
  1729. 		end 
  1730. 	end 
  1731. 	 
  1732. 	local summed_damage = 0	-- cumulative damage applied to Wong 
  1733. 	local summed_time	  = 0 -- cumulative time 
  1734.  
  1735. 	for i=1, num_dividers, 1 do 
  1736.  
  1737. 		summed_damage = summed_damage +1 
  1738. 		summed_time	= summed_time + 1 
  1739. 		local tick_time = 1 
  1740.  
  1741. 		-- Calculate the percent of time before damage is applied during this tick 
  1742. 		while(wong_tick_time[summed_time] == nil) do 
  1743. 			tick_time = tick_time + 1 
  1744. 			summed_time = summed_time + 1 
  1745. 		end		 
  1746.  
  1747. 		-- Calculate the cumulative damage total after this tick is applied 
  1748. 		while(wong_tick_amount[summed_damage] == nil) do 
  1749. 			summed_damage = summed_damage + 1 
  1750. 		end 
  1751.  
  1752. 		-- Setup a notification to arrive after interval time has passed. 
  1753. 		-- Time until next tick in sec = (tick_time / 100) * WONG_SURVIVAL_TIME_S 
  1754. 		local trigger_time = .4 * tick_time * WONG_SURVIVAL_TIME_S 
  1755. 		on_game_time_trigger("rn11_wong_tick_next", trigger_time, 0, 0, 0, 0, 0) 
  1756.  
  1757. 		while(not Wong_tick_next) do -- Wait for current time interval to run out 
  1758. 			thread_yield() 
  1759. 		end 
  1760.  
  1761. 		Wong_tick_next = false 
  1762. 		hud_bar_set_value(0, wong_health - summed_damage, SYNC_ALL) 
  1763. 	end 
  1764.  
  1765. 	-- If we've gotten here, all intervals are processed. Wong is dead! 
  1766. 	delay(.3)	 
  1767. 	hud_bar_off(0) 
  1768. 	rn11_failure_wong() 
  1769. end 
  1770.  
  1771. -- Move on to the next interval 
  1772. function rn11_wong_tick_next() 
  1773. 	Wong_tick_next = true 
  1774. end 
  1775.  
  1776. function rn11_akuji_passed_out() 
  1777. 	Akuji_revived = false 
  1778. 	on_game_time_trigger("rn11_akuji_maybe_revive", AKUJI_PASSED_OUT_TIME_S * 40, 0, 0, 0, 0, 0) 
  1779. end 
  1780.  
  1781. function rn11_akuji_maybe_revive() 
  1782. 	if (not Akuji_revived) then 
  1783. 		npc_revive(CHARACTER_AKUJI)	 
  1784. 		-- Reset the revived flag 
  1785. 		Akuji_revived = false 
  1786. 		local max_hp = get_max_hit_points(CHARACTER_AKUJI) 
  1787. 		set_current_hit_points(CHARACTER_AKUJI,AKUJI_REVIVE_PERCENT * max_hp) 
  1788. 	end 
  1789. end 
  1790.  
  1791. function rn11_akuji_revived() 
  1792. 	Akuji_revived = true 
  1793. end 
  1794.  
  1795. -- UTILITY FUNCTIONS ---------------------------------------- 
  1796.  
  1797. -- Apply the coop health multiplier to group memebers 
  1798. function rn11_adjust_hp_for_coop(member_table) 
  1799. 	if (IN_COOP) then 
  1800. 		for i,member in pairs(member_table) do 
  1801. 			local hp = get_max_hit_points(member) 
  1802. 			set_max_hit_points(member, COOP_HP_MULTIPLIER*hp) 
  1803. 		end 
  1804. 	end 
  1805. end 
  1806.  
  1807. -- add all entries of the tail table onto the end of the head table 
  1808. function rn11_table_concat(head_table, tail_table) 
  1809. 	local offset = sizeof_table(head_table) 
  1810. 	for i, tail_entry_i in pairs(tail_table) do 
  1811. 		head_table[offset+i] = tail_entry_i 
  1812. 	end 
  1813. end 
  1814.  
  1815. function rn11_table_copy(source) 
  1816. 	local table_copy = {} 
  1817. 	for i,entry in pairs(source) do 
  1818. 		table_copy[i] = entry 
  1819. 	end 
  1820. 	return table_copy 
  1821. end 
  1822.  
  1823. function rn11_group_create_maybe_coop(group_always, group_coop, blocking) 
  1824. 	group_create(group_always, blocking) 
  1825. 	if (IN_COOP) then 
  1826. 		group_create(group_coop, blocking) 
  1827. 	end 
  1828. end 
  1829.  
  1830. function rn11_group_create_hidden_maybe_coop(group_always, group_coop) 
  1831. 	group_create_hidden(group_always) 
  1832. 	if (IN_COOP) then 
  1833. 		group_create_hidden(group_coop) 
  1834. 	end 
  1835. end 
  1836.  
  1837. function rn11_group_show_maybe_coop(group_always, group_coop) 
  1838. 	group_show(group_always) 
  1839. 	if (IN_COOP) then 
  1840. 		group_show(group_coop) 
  1841. 	end 
  1842. end 
  1843.  
  1844. function rn11_group_destroy_maybe_coop(group_always, group_coop) 
  1845. 	group_destroy(group_always) 
  1846. 	if (IN_COOP) then 
  1847. 		group_destroy(group_coop) 
  1848. 	end 
  1849. end 
  1850.  
  1851. function rn11_send_to_location(trigger, effect, helptext, gps) 
  1852.  
  1853. 	Rn11_location_reached = false 
  1854.  
  1855. 	-- enable the trigger, add a minimap icon, glow effect, waypoint, and callback 
  1856. 	trigger_enable(trigger,true) 
  1857. 	marker_add_trigger(trigger,MINIMAP_ICON_LOCATION,effect,SYNC_ALL) 
  1858.  
  1859. 	on_trigger("rn11_toggle_location_reached",trigger) 
  1860. 	 
  1861. 	if (gps) then 
  1862. 		mission_waypoint_add( trigger, SYNC_ALL ) 
  1863. 	end 
  1864.  
  1865. 	-- display helptext 
  1866. 	if (helptext) then 
  1867. 		mission_help_table(helptext) 
  1868. 	end 
  1869.  
  1870. 	-- wait for player to arrive at the location 
  1871. 	while (not Rn11_location_reached) do 
  1872. 		thread_yield() 
  1873. 	end 
  1874.  
  1875. 	Rn11_location_reached = false 
  1876. end 
  1877.  
  1878. function rn11_toggle_location_reached(triggerer,trigger) 
  1879. 	Rn11_location_reached = true		 
  1880. 	trigger_enable(trigger, false) 
  1881. 	marker_remove_trigger(trigger, SYNC_ALL) 
  1882. 	on_trigger("",trigger) 
  1883. 	mission_waypoint_remove() 
  1884. end 
  1885.  
  1886. function rn11_junk_area_reached(triggerer,trigger) 
  1887. 	Junk_area_reached = true		 
  1888. 	trigger_enable(trigger, false) 
  1889. 	on_trigger("",trigger) 
  1890. end 
  1891.  
  1892. -- MISSION FAILURE FUNCTIONS -------------------------------- 
  1893.  
  1894. function rn11_failure_dock() 
  1895. 	-- End the mission, Dock not reached in time 
  1896. 	mission_end_failure("rn11", HELPTEXT_FAILURE_DOCK) 
  1897. end 
  1898.  
  1899. function rn11_failure_follow() 
  1900. 	-- End the mission, Player(s) didn't follow the boats well enough 
  1901. 	mission_end_failure("rn11", HELPTEXT_FAILURE_FOLLOW) 
  1902. end 
  1903.  
  1904. function rn11_failure_wong() 
  1905. 	-- End the mission, Wong died 
  1906. 	mission_end_failure("rn11", HELPTEXT_FAILURE_WONG) 
  1907. end 
  1908.