sr2lua/bh03.lua

  1. -- bh03.lua 
  2. -- SR2 mission script 
  3. -- 3/28/07 
  4.  
  5. -- Global constants 
  6. 	-- Mission state constants 
  7.  
  8. 	-- End mission states 
  9.  
  10.    -- Help text ( not all help text is listed here ) 
  11.       HT_GOO_NEAR_TOWERS = "bh03_goo_near_towers" 
  12.       HT_GOO_NEAR_NORTH_DOCKS = "bh03_goo_near_north_docks" 
  13.       HT_GOO_IN_EAST_BUILDING = "bh03_goo_in_east_building" 
  14.       HT_GOO_ON_SOUTH_SIDE = "bh03_goo_on_south_side" 
  15.  
  16.       HT_GOO_LOCATIONS = { HT_GOO_NEAR_TOWERS, HT_GOO_NEAR_TOWERS, HT_GOO_IN_EAST_BUILDING, 
  17.                            HT_GOO_ON_SOUTH_SIDE, HT_GOO_NEAR_NORTH_DOCKS, HT_GOO_NEAR_NORTH_DOCKS, 
  18.                            HT_GOO_NEAR_TOWERS } 
  19.  
  20.       HT_HELI_BLOW_COVER_WARNING = "bh03_heli_blow_cover_warning" 
  21.       HT_GET_TO_HELIPAD = "bh03_get_to_helipad" 
  22.       HT_DEFEND_HELIPAD = "bh03_defend_helipad" 
  23.       HT_BOARD_HELICOPTER = "bh03_board_helicopter" 
  24.       HT_CARLOS_DIED = "bh03_carlos_died" 
  25.       HT_CARLOS_ABANDONED = "bh03_carlos_abandoned" 
  26.       HT_X_OF_Y_GUARDS_KILLED = "bh03_x_of_y_guards_killed" 
  27.       HT_HELICOPTER_DESTROYED = "bh03_helicopter_destroyed" 
  28.       HT_PILOT_KILLED = "bh03_heli_pilot_killed" 
  29.       HT_ABANDONED_HELIPAD = "bh03_abandoned_helipad" 
  30.       HT_GET_CLEAR_OF_HELI = "bh03_get_clear" 
  31.       HT_CLEAR_OUT_HELIPAD_GUARDS = "bh03_clear_out_helipad_guards" 
  32.       HT_RETURN_TO_HELIPADS_DEFENSE = "bh03_return_to_helipads_defense" 
  33.  
  34. 	-- Assorted constants -- 
  35. 		CURRENT_MISSION =			"bh03" 
  36. 		ENEMY_GANG =				"Brotherhood" 
  37.       MP = CURRENT_MISSION.."_$" 
  38.  
  39. 		NAV_NUKE_TOWERS =			{MP.."n001", MP.."n002"} 
  40. 		NAV_ALARM_LOCATION =		MP.."n003" 
  41. 		NUKE_TOWER_RADIUS =		19 
  42.  
  43. 		WEAPON_STORE_MESSAGE_RADIUS =		10 
  44. 		WEAPON_STORE_EFFECT =			"mission_purchase" 
  45.  
  46. 		NUKE_ISLAND_RADIUS =			350 
  47.  
  48. 		GOO_PREFIX =				MP.."goo_" 
  49. 		GOO_TRIGGER_PREFIX =			MP.."goo_trigger_" 
  50. 		GOO_COUNT =				7 
  51.       SPAWN_NEW_WAVE_THRESHOLD = 2 
  52.  
  53. 		GOO_LOCATION_MAP =		{MP.."nuke_island02", MP.."nuke_island02", MP.."nuke_island03", MP.."nuke_island03", 
  54. 										 MP.."nuke_island01", MP.."nuke_island01", MP.."nuke_island02"} 
  55.  
  56. 		GOO_TRIGGER_EFFECT =			"mission_complete" 
  57.  
  58. 		GEIGER_MIN_DELAY =			0.1 
  59. 		GEIGER_MAX_DELAY =			2.0 
  60. 		GEIGER_MIN_DISTANCE =			3 
  61. 		GEIGER_MAX_DISTANCE =			100 
  62. 		GEIGER_MIN_FEEDBACK =			0 
  63. 		GEIGER_CUTOFF_DELAY =			0 
  64.  
  65.       LEAVE_PAD_FAILURE_TIME_SECONDS = 30 
  66.       TIME_PER_RETURN_TO_DEFEND_UPDATE_SECONDS = 5 
  67.       HELI_ARRIVAL_HOLD_OUT_TIME_MS = 90000 
  68.       MISSION_END_FAILURE_TIME_MS = 900000 
  69.       MISSION_END_WARNING_TIME_MS = 810000 
  70.  
  71.       BETWEEN_GOO_NAGS_SECONDS = 30 
  72.  
  73.       MISSION_END_FAILURE_AFTER_CHECKPOINT_MS = 660000 
  74.       MISSION_END_WARNING_AFTER_CHECKPOINT_MS = 570000 
  75.  
  76.       MISSION_END_FAILURE_AFTER_SECOND_CHECKPOINT_MS = 540000 
  77.       MISSION_END_WARNING_AFTER_SECOND_CHECKPOINT_MS = 450000 
  78.  
  79.       MISSION_END_FAILURE_AFTER_FINAL_CHECKPOINT_MS = 420000 
  80.       MISSION_END_WARNING_AFTER_FINAL_CHECKPOINT_MS = 330000 
  81.  
  82.       -- How many of the initial guards should be remaining before the player's escape 
  83.       -- helicopter does its flyby of the helipad 
  84.       INITIAL_GUARDS_DO_FLYBY_THRESHOLD =		6 
  85.  
  86.       HELIPAD_AREA_RADIUS_METERS =				25 
  87.       HELICOPTER_BUZZ_SPEED_MPS =				30 
  88.       HELICOPTER_LAND_SPEED_MPS =				30 
  89.       HELICOPTER_RAIL_SPEED_MPS =				20 
  90.  
  91.       ULTOR_HELIS_CLOSING_SPEEDS_MPS =			{ 40, 40, 40 } 
  92.       ULTOR_HELIS_FOLLOW_SPEEDS_MPS =			{ 40, 40, 40 } 
  93.  
  94. 		GEIGER_CLICK =									"SFX_BRO_GEIGER_LOOP" 
  95. 		GEIGER_ON =										"SFX_BRO_GEIGER_ON" 
  96. 		GEIGER_OFF =									"SFX_BRO_GEIGER_OFF" 
  97. 		NUKE_ALARM_INDOORS =							"SFX_BRO_PLANT_ALARM_IN" 
  98. 		NUKE_ALARM_OUTDOORS =						"SFX_BRO_PLANT_ALARM_OUT" 
  99. 		GEIGER_FEEDBACK =								"Geiger_Counter" 
  100.  
  101. 		ACTION_PICKUP_ITEM =							"pickup item" 
  102.  
  103. 		WEAPON_GEIGER_COUNTER =						"giegerCounter" 
  104.  
  105. 		HQ_WARNING_DISTANCE =						100 
  106. 		HQ_PENALTY_DISTANCE =						50 
  107. 		HQ_DELIVER_DISTANCE =						10 
  108. 		HQ_PENALTY_NOTORIETY =						3 
  109.  
  110.       MISSION_MAX_NOTORIETY =						2 
  111. 		MISSION_MAX_NOTORIETY_COOP =				3 
  112.  
  113.       ULTOR_HELI_PILOT_SEAT =						0 
  114.       ULTOR_HELI_GUNNER_SEAT =					4 
  115.  
  116. 	-- Patrol Stuff added by Bryan D. 
  117. 		NUKE_PATROL_ROUTE01			= {MP.."sec_patrol_pt01", MP.."sec_patrol_pt02", MP.."sec_patrol_pt03", MP.."sec_patrol_pt04", MP.."sec_patrol_pt01"} 
  118. 		NUM_NUKE_PATROL01			= sizeof_table(NUKE_PATROL_ROUTE01) 
  119. 		NUKE_GUARDS				= {MP.."guard00", MP.."guard04", MP.."guard06", MP.."guard08", MP.."guard09", MP.."guard10", MP.."guard11", MP.."guard13", MP.."guard15"} 
  120. 		NUM_NUKE_GUARDS				= sizeof_table(NUKE_GUARDS) 
  121. 		NUKE_SECURITY				= "Police" 
  122.  
  123. 		GOO_GUARDS =				{{MP.."c000", MP.."c001", MP.."c002"}, 
  124. 										 {MP.."c003", MP.."c004", MP.."c005"}, 
  125. 										 {MP.."c006", MP.."c007", MP.."c008"}, 
  126. 										 {MP.."c009", MP.."c010", MP.."c011"}, 
  127. 										 {MP.."c012", MP.."c013", MP.."c014"}, 
  128. 										 {MP.."c015", MP.."c016", MP.."c017"}, 
  129. 										 {MP.."c018", MP.."c019", MP.."c020"}} 
  130.  
  131.       HELIPAD_INITIAL_GUARDS = { MP.."HIG_01", MP.."HIG_02", MP.."HIG_03", MP.."HIG_04", 
  132.                                  MP.."HIG_05", MP.."HIG_06", MP.."HIG_07", MP.."HIG_08", 
  133.                                  MP.."HIG_09", MP.."HIG_10" } 
  134.       HELIPAD_SECOND_WAVE_MEMBERS = { { MP.."SWN_M1", MP.."SWN_M2", MP.."SWN_M3", MP.."SWN_M4" }, 
  135.                                       { MP.."SWE_M1", MP.."SWE_M2", MP.."SWE_M3", MP.."SWE_M4" }, 
  136.                                       { MP.."SWW_M1", MP.."SWW_M2", MP.."SWW_M3", MP.."SWW_M4" } } 
  137.  
  138.       CARLOS_NAME = MP.."Carlos" 
  139.       ESCAPE_HELI_PILOT_NAME = MP.."Escape_Heli_Pilot" 
  140.       ESCAPE_HELICOPTER_PASSENGERS = { ESCAPE_HELI_PILOT_NAME, CARLOS_NAME } 
  141.  
  142.       ULTOR_HELI_PILOTS = { MP.."UAH1_Pilot", MP.."UAH2_Pilot", MP.."UAH3_Pilot" } 
  143.       ULTOR_HELI_GUNNERS = { MP.."UAH1_Gunner", MP.."UAH2_Gunner", MP.."UAH3_Gunner" } 
  144.  
  145. 	-- Navpoints and paths -- 
  146. 		NAVPOINT_START =									MP.."player_start" 
  147.       NAVPOINT_START_COOP =							MP.."coop_player_start" 
  148. 		NAVPOINT_FINISH =									MP.."player_finish" 
  149. 		NAVPOINT_WEAPON_STORE_OUTSIDE =				MP.."n000" 
  150. 		NAVPOINT_HQ =										MP.."brotherhood_hq" 
  151. 		NAVPOINT_NUKE_ISLAND =							"" 
  152. 		NAVPOINT_NUKE_ISLAND_CENTER =					MP.."nuke_island02" 
  153.       IN_HELI_TELEPORT_LOCATIONS = { [LOCAL_PLAYER] = MP.."In_Heli_Teleport_Goal_Local", 
  154.                                      [REMOTE_PLAYER] = MP.."In_Heli_Teleport_Goal_Remote" } 
  155. 		NEAR_HELI_CHECKPOINT_WARPS = { [LOCAL_PLAYER] = MP.."Near_Heli_Checkpoint_Warp_Local", 
  156.                                      [REMOTE_PLAYER] = MP.."Near_Heli_Checkpoint_Warp_Remote" } 
  157. 		PASSENGERS_NEAR_HELI_WARPS = { MP.."Near_Heli_Checkpoint_Warp_Local", 
  158.                                      MP.."Near_Heli_Checkpoint_Warp_Remote" } 
  159.  
  160.       HELI_BUZZ_HELIPAD_START =						MP.."Heli_Buzz_Helipad_Start" 
  161.       HELI_BUZZ_HELIPAD_PATH =						MP.."Heli_Buzz_Helipad" 
  162.  
  163.       HELI_LAND_START =									MP.."Heli_Land_Start" 
  164.       HELI_LAND_PATH =									MP.."Heli_Land" 
  165.  
  166.       REAL_HELI_START =									MP.."Real_Heli_Start" 
  167.  
  168.       HELI_BACK_TO_STILWATER_AND_CRASH_PATH =	MP.."Back_To_Stilwater_and_Crash" 
  169.       HELI_CRASH_PATH = MP.."Heli_Crash" 
  170.  
  171.       ULTOR_HELI_START_POINTS = { MP.."UAH1_Start", MP.."UAH2_Start", MP.."UAH3_Start" } 
  172.       ULTOR_HELI_FOLLOW_PATHS = { MP.."UAH1_Follow", MP.."UAH2_Follow", MP.."UAH3_Follow" } 
  173.  
  174.       HELIPAD_SECOND_WAVE_PATHS = { MP.."North_Wave_Path", MP.."East_Wave_Path", 
  175.                                     MP.."West_Wave_Path" } 
  176.  
  177.       OUTSIDE_ALARMS = { MP.."Outside_Alarm_01", MP.."Outside_Alarm_02", MP.."Outside_Alarm_03", MP.."Outside_Alarm_04", 
  178.                          MP.."Outside_Alarm_05", MP.."Outside_Alarm_06", MP.."Outside_Alarm_07", MP.."Outside_Alarm_08", 
  179.                          MP.."Outside_Alarm_09", MP.."Outside_Alarm_10", MP.."Outside_Alarm_11", MP.."Outside_Alarm_12", 
  180.                          MP.."Outside_Alarm_13", MP.."Outside_Alarm_14", MP.."Outside_Alarm_15", MP.."Outside_Alarm_16", 
  181.                          MP.."Outside_Alarm_17", MP.."Outside_Alarm_18", MP.."Outside_Alarm_19", MP.."Outside_Alarm_20" } 
  182.       INSIDE_ALARMS = { MP.."Inside_Alarm_01", MP.."Inside_Alarm_02", MP.."Inside_Alarm_03" } 
  183.  
  184. 		POLICE_SHOOTER01 = MP.."c021" 
  185. 		POLICE_SHOOTER02 = MP.."c022" 
  186. 		POLICE_SHOOTER03 = MP.."c023" 
  187.  
  188.    -- Triggers -- 
  189.       HELIPAD_AREA = MP.."Helipad_Area" 
  190.  
  191.       LZ_TOO_HOT_TRIGGER = MP.."LZ_Too_Hot" 
  192.  
  193.       ULTOR_HELI_FOLLOW_TRIGGERS = { MP.."UAH1_Trigger", MP.."UAH2_Trigger", MP.."UAH3_Trigger" } 
  194. 		TRIGGER_BOAT_CHASE = MP.."trigger_chase_boats" 
  195. 		TRIGGER_SHOOTERS = MP.."trigger_shooters"		 
  196.       FORCE_SEATING_TRIGGER = MP.."Force_Helicopter_Seating" 
  197.  
  198.       HELI_IN_TROUBLE_TRIGGER = MP.."Heli_In_Trouble" 
  199.       HELI_GOING_DOWN_TRIGGER = MP.."Heli_Going_Down" 
  200.       HELI_EJECTION_TRIGGER = MP.."Heli_Eject" 
  201.  
  202. 	-- Store Trigger -- 
  203. 		WEAPON_STORE_ORIG =		"shops_sr2_city_$AP_gun_store" -- Weapon store we're replacing 
  204. 		WEAPON_STORE =				MP.."weap_store_replacement" 
  205.  
  206. 	-- Vehicle -- 
  207. 		SECURITY_VEHICLE01 =			MP.."security_vehicle01" 
  208. 		POLICE_BOAT01 =				MP.."police_boat01" 
  209. 		POLICE_BOAT02 =				MP.."police_boat02" 
  210. 		END_COURTESY_CAR =			MP.."v000" 
  211.       HELIPAD_SECOND_WAVE_VEHICLES = { MP.."SWN_V", MP.."SWE_V", MP.."SWW_V" } 
  212.  
  213.       -- Just for appearances sake - we show this one flying by and landing 
  214.       FAUX_ESCAPE_HELICOPTER = MP.."Faux_Escape_Helicopter" 
  215.       -- This is the helicopter version that the player can actually shoot from 
  216.       ESCAPE_HELICOPTER = MP.."Escape_Helicopter" 
  217.  
  218.       ULTOR_HELIS = { MP.."UAH1_Heli", MP.."UAH2_Heli", MP.."UAH3_Heli" } 
  219.  
  220. 	-- Police Boat Chase People 
  221. 		BOAT01_DRIVER =				MP.."police_boat01_driver" 
  222. 		BOAT01_PASSENGER =			MP.."police_boat01_passenger"	 
  223. 		BOAT02_DRIVER =				MP.."police_boat02_driver" 
  224. 		BOAT02_PASSENGER =			MP.."police_boat02_passenger"	 
  225. 		BOAT01_BOAT	=					MP.."police_boat01" 
  226. 		BOAT02_BOAT	=					MP.."police_boat02" 
  227. 		BOAT01_PATH =					MP.."boat01_path" 
  228. 		BOAT02_PATH =					MP.."boat02_path" 
  229. 		BOATS_SPEED =					42 
  230. 		BOAT_HEALTH_MULTIPLIER =	.45 
  231.  
  232. 	-- Groups -- 
  233. 		GROUP_GOO =				      MP.."goo_locations" 
  234. 		GROUP_END_VEHICLE	=			MP.."final_courtesy" 
  235. 		GROUP_EXTRA_BOATS =			MP.."extra_boat_spawns" 
  236. 		GROUP_START_VEHICLE =		MP.."extra_vehicle_spawn" 
  237. 		GROUP_START_VEHICLE_COOP =	MP.."extra_vehicle_spawn_coop" 
  238. 		GROUP_ISLAND_PATROL01 =		MP.."island_patrols" 
  239. 		GROUP_ISLAND_GUARDS =		MP.."island_guards" 
  240. 		GROUP_POLICE_BOATS =			MP.."police_boat_chase" 
  241. 		GROUP_POLICE_SHOOTERS =		MP.."police_shooters" 
  242. 		GROUP_GOO_GUARDS =			{ MP.."goo_guards_1", MP.."goo_guards_2", MP.."goo_guards_3", MP.."goo_guards_4", 
  243. 											  MP.."goo_guards_5", MP.."goo_guards_6", MP.."goo_guards_7" } 
  244.  
  245.       HELIPAD_SECOND_WAVE_GROUPS = { MP.."helipad_second_wave_north", MP.."helipad_second_wave_east", 
  246.                                      MP.."helipad_second_wave_west" } 
  247.       HELIPAD_INITIAL_GUARDS_GROUP = MP.."helipad_initial_guards" 
  248.       FAUX_ESCAPE_HELICOPTER_GROUP = MP.."faux_escape_helicopter" 
  249.       ESCAPE_HELI_PASSENGERS_GROUP = MP.."heli_passengers" 
  250.       ESCAPE_HELICOPTER_GROUP = MP.."escape_helicopter" 
  251.       ULTOR_ATTACKING_HELICOPTER_GROUPS = { MP.."ultor_attack_heli_1", MP.."ultor_attack_heli_2", MP.."ultor_attack_heli_3" } 
  252.  
  253.    -- Sound 
  254.       BE_READY_FOR_PICKUP_CALL = { { "PLAYER_BR03_CALL_GOO_L1", LOCAL_PLAYER, 0 }, 
  255.                                    { "BR03_CALL_GOO_L2", CELLPHONE_CHARACTER, 0 } } 
  256.  
  257.       PICK_ME_UP_NOW_CALL = { { "PLAYER_BR03_CALL_PICKUP_L1", LOCAL_PLAYER, 0 }, 
  258.                               { "BR03_CALL_PICKUP_L2", CELLPHONE_CHARACTER, 0 } } 
  259.  
  260.       AFTER_ENTER_HELI_DIALOG_STREAM = { { "PLAYER_BR03_ENTER_HELI_L1", LOCAL_PLAYER, 0 }, 
  261.                                          { "BR03_ENTER_HELI_L2", CARLOS_NAME, 0 } } 
  262.  
  263.       HELI_GOING_DOWN_LINE = "CARLOS_BR03_HELI_CRASH_01" 
  264.  
  265.       AFTER_HELI_CRASH_DIALOG_STREAM = { { "PLAYER_BR03_CRASH_L1", LOCAL_PLAYER, 0 }, 
  266.                                          { "BR03_CRASH_L2", CARLOS_NAME, 0 }, 
  267.                                          { "PLAYER_BR03_CRASH_L3", LOCAL_PLAYER, 0 } } 
  268.  
  269.       CARLOS_ALMOST_TO_NUKE_PLANT_CALL = { { "CARLOS_BR03_HELI_UPDATE_L1", CELLPHONE_CHARACTER, 0 } } 
  270.       CARLOS_TOO_HOT_LINE_CALL = { { "CARLOS_BR03_HELI_UPDATE_L2", CELLPHONE_CHARACTER, 0 } } 
  271.       CARLOS_LANDING_NOW_LINE_CALL = { { "CARLOS_BR03_HELI_UPDATE_L3", CELLPHONE_CHARACTER, 0 } } 
  272.  
  273.       CARLOS_HELI_DAMAGED_LINE = "CARLOS_BR03_HELI_DAMAGE" 
  274.  
  275.       CARLOS_LANDED_LINE = "CARLOS_BR03_LAND_HELI_01" 
  276.  
  277.       PILOT_COMPLAIN_LINES = { "HMTRCK_BR03_CARLOS_THREAT_01", "HMTRCK_BR03_CARLOS_THREAT_02", "HMTRCK_BR03_CARLOS_THREAT_03" } 
  278.       CARLOS_COMPLAIN_TO_PILOT_LINES = { "CARLOS_BR03_HELI_PILOT_01", "CARLOS_BR03_HELI_PILOT_02", "CARLOS_BR03_HELI_PILOT_03" } 
  279.       NUM_PILOT_AND_CARLOS_COMPLAIN_CONVERSATIONS = 3 
  280.  
  281.       CARLOS_PERSONA_OVERRIDES = { { "observe - passenger when driver hits cars", "CARLOS_BR03_PLAYER_DRIVE" }, 
  282.                                    { "observe - passenger when driver hits object", "CARLOS_BR03_PLAYER_DRIVE" }, 
  283.                                    { "observe - passenger when driver hits peds", "CARLOS_BR03_PLAYER_DRIVE" } } 
  284.  
  285. 	-- Checkpoints -- 
  286. 		CHECKPOINT_NUKE_ISLAND =		   "bh03_checkpoint_nuke_island" 
  287.       CHECKPOINT_COLLECTED_GOO =       "bh03_checkpoint_collected_goo" 
  288.       CHECKPOINT_HELICOPTER_ESCAPE =   "bh03_helicopter_escape" 
  289.  
  290.    -- Weapons 
  291.       SAW_NAME = "AR200" 
  292.  
  293.    -- Cutscenes -- 
  294. 		CUTSCENE_IN =						"br03-01" 
  295. 		CUTSCENE_OUT =						"br03-02" 
  296.  
  297. 	-- Other -- 
  298. 		Geiger_sound =						{-1, -1, -1, -1, -1}	 
  299.       NUM_INITIAL_HELIPAD_GUARDS = sizeof_table( HELIPAD_INITIAL_GUARDS ) 
  300.       HELIPAD_SECOND_WAVE_ATTACK_DIRECTION_COUNT = sizeof_table( HELIPAD_SECOND_WAVE_GROUPS ) 
  301.  
  302.       PERCENT_OF_HELI_DAMAGE_BEFORE_COMPLAINT = 0.1 
  303.  
  304.       HUD_COMPLETE_MISSION_IN_TIME_INDEX = 0 
  305.       HUD_HELICOPTER_ARRIVE_INDEX = 1 
  306.       HELICOPTER_PARKING_SPAWN = "parking_spots_$parking_276_heli" 
  307.  
  308. 	-- Temporary stuff -- 
  309. 		TEMP_BOAT_SPAWN_PREFIX =		MP.."boat_spawn" 
  310. 		TEMP_BOAT_NAVP_PREFIX =			MP.."boat_location" 
  311. 		TEMP_BOAT_COUNT =			1 
  312.  
  313. -- Global Variables 
  314. 	SECURITY_ESCAPED_DIST =			20 
  315.    Goo_index = -1 
  316. 	Goo_item =							false 
  317. 	Goo_trigger =						false 
  318. 	Goo_picked_up =					false 
  319. 	Goo_delivered =					false 
  320.    Goo_player =                  LOCAL_PLAYER 
  321. 	Seen_by_security =				false 
  322.    Last_player_seen =            "" 
  323. 	Alarm_triggered =					false 
  324. 	Gotten_away_from_security =	false 
  325. 	Gotten_notoriety_down =			false 
  326. 	Thread_geiger =					INVALID_THREAD_HANDLE 
  327. 	Thread_geiger_hud =				INVALID_THREAD_HANDLE 
  328. 	Thread_geiger_message =			INVALID_THREAD_HANDLE 
  329. 	Thread_security =					INVALID_THREAD_HANDLE 
  330.    Thread_time_running_out =     INVALID_THREAD_HANDLE 
  331. 	Geiger_player =					"" 
  332. 	Geiger_bar_off =					true 
  333. 	alarm_foley_local =				-1 
  334. 	alarm_foley_remote =				-1 
  335.  
  336. 	Alarm_message_shown = { [LOCAL_PLAYER] = false, [REMOTE_PLAYER] = false } 
  337.    Players_near_helipad = { [LOCAL_PLAYER] = false, [REMOTE_PLAYER] = false } 
  338.    Player_failure_timers_threads = { [LOCAL_PLAYER] = INVALID_THREAD_HANDLE, [REMOTE_PLAYER] = INVALID_THREAD_HANDLE } 
  339.  
  340.    Initial_helipad_guards_remaining = NUM_INITIAL_HELIPAD_GUARDS 
  341.    All_players_reached_pad = false 
  342.    Helipad_initial_defenders_cleared = false 
  343.    Waves_spawned = 0 
  344.    Num_tracked_helipad_wave_attackers = 0 
  345.    Wave_spawning_enabled = true 
  346.    Helicopter_has_arrived = false 
  347.    Crash_complete = false 
  348.    Heli_percent_damage_since_last_complaint = 0 
  349.    Carlos_already_talking = false 
  350.    Controls_disabled = false 
  351.    Faux_escape_helicopter_seated = false 
  352. 	Outside_alarm_emitter_ids = {} 
  353. 	Inside_alarm_emitter_ids = {} 
  354. 	Players_have_heli_weapons = false 
  355.  
  356. function bh03_start(bh03_checkpoint, is_restart) 
  357. 	bh03_initialize_alarms() 
  358.  
  359. 	-- Start trigger is hit...the activate button was hit 
  360. 	set_mission_author("Kevin J. Price") 
  361.  
  362. 	notoriety_set_max( "Brotherhood", MISSION_MAX_NOTORIETY ) 
  363.    notoriety_set_max( "Police", MISSION_MAX_NOTORIETY ) 
  364. 	if ( coop_is_active() ) then 
  365. 		notoriety_set_max( "Police", MISSION_MAX_NOTORIETY_COOP ) 
  366. 	end 
  367.  
  368.    parking_spot_enable( HELICOPTER_PARKING_SPAWN, false ) 
  369.  
  370.    -- TEMP 
  371.    --bh03_checkpoint = CHECKPOINT_HELICOPTER_ESCAPE 
  372.    -- END TEMP 
  373.  
  374.    if bh03_checkpoint == MISSION_START_CHECKPOINT then 
  375. 	   mission_start_fade_out() 
  376.  
  377. 		if (not is_restart) then 
  378. 			cutscene_play( CUTSCENE_IN, "", {NAVPOINT_START, NAVPOINT_START_COOP} ) 
  379. 		else 
  380. 			teleport_coop( NAVPOINT_START, NAVPOINT_START_COOP ) 
  381. 		end 
  382.  
  383.    	set_time_of_day(20, 0) 
  384. 		bh03_get_geiger_counter() 
  385. 	elseif bh03_checkpoint == CHECKPOINT_NUKE_ISLAND then 
  386.       mission_start_fade_out() 
  387.       hud_timer_set( HUD_COMPLETE_MISSION_IN_TIME_INDEX, MISSION_END_FAILURE_AFTER_CHECKPOINT_MS, "bh03_mission_failure_timeout" ) 
  388. 		Thread_time_running_out = thread_new( "bh03_time_out_warning", MISSION_END_WARNING_AFTER_CHECKPOINT_MS ); 
  389. 		Geiger_player = LOCAL_PLAYER 
  390. 		inv_weapon_add_temporary(Geiger_player, WEAPON_GEIGER_COUNTER, 1, true ) 
  391. 		initialize_goo() 
  392.       mission_start_fade_in() 
  393.  
  394. 		bh03_nuke_island_get_goo() 
  395.    elseif bh03_checkpoint == CHECKPOINT_COLLECTED_GOO then 
  396.  
  397.       -- Go through all the goo locations and find the one closest to either player 
  398.       local closest_dist, closest_player = get_dist_closest_player_to_object( GOO_PREFIX.."1" ) 
  399.       local closest_index = 1 
  400.       for i = 2, GOO_COUNT, 1 do 
  401.          local goo_location = GOO_PREFIX .. i 
  402.          local dist, closest_player = get_dist_closest_player_to_object( goo_location ) 
  403.          if ( dist < closest_dist ) then 
  404.             closest_dist = dist 
  405.             closest_index = i 
  406.          end 
  407.       end 
  408.  
  409.       mission_debug( "closest index found was "..closest_index ) 
  410.       -- Create the particular guards that guard this goo, since this location is probably where the player picked it up 
  411.       group_create(GROUP_GOO_GUARDS[closest_index], true) 
  412.       for i, npc in pairs(GOO_GUARDS[closest_index]) do 
  413.          wander_start(npc, npc, 15.0) 
  414.          on_detection("bh03_seen_by_guard", npc) 
  415.       end 
  416. 	   Thread_security = thread_new("bh03_security_watch") 
  417.  
  418.       fade_in( 1 ) 
  419.       hud_timer_set( HUD_COMPLETE_MISSION_IN_TIME_INDEX, MISSION_END_FAILURE_AFTER_SECOND_CHECKPOINT_MS, "bh03_mission_failure_timeout" ) 
  420. 		Thread_time_running_out = thread_new( "bh03_time_out_warning", MISSION_END_WARNING_AFTER_SECOND_CHECKPOINT_MS ); 
  421. 		Geiger_player = LOCAL_PLAYER 
  422.       bh03_helipad_defense_and_arrival() 
  423.    elseif bh03_checkpoint == CHECKPOINT_HELICOPTER_ESCAPE then 
  424.       mission_start_fade_out() 
  425.  
  426. 		script_profiler_reset() 
  427. 		 
  428. 		script_profiler_start_section( "checkpoint: give and equip weapons" ) 
  429. 		bh03_give_and_equip_player_heli_weapons() 
  430. 		script_profiler_end_section( "checkpoint: give and equip weapons" ) 
  431.  
  432. 		script_profiler_start_section( "checkpoint group creation" ) 
  433.       if ( group_is_loaded( ESCAPE_HELICOPTER_GROUP ) == false ) then 
  434.          group_create_hidden( ESCAPE_HELICOPTER_GROUP, true ) 
  435.       end 
  436.       on_death( "bh03_carlos_died", CARLOS_NAME ) 
  437.  
  438.       group_create_hidden( ESCAPE_HELI_PASSENGERS_GROUP, true ) 
  439.       for index, group_name in pairs( ULTOR_ATTACKING_HELICOPTER_GROUPS ) do 
  440.          group_create_hidden( group_name ) 
  441.       end 
  442. 		script_profiler_end_section( "checkpoint group creation" ) 
  443.  
  444.       -- No notoriety spawning - attack helicopters destroy the escape helicopter rather quickly 
  445.       notoriety_force_no_spawn( NUKE_SECURITY, true ) 
  446.       notoriety_force_no_spawn( "Ultor", true ) 
  447.  
  448. 		script_profiler_start_section( "teleport coop" ) 
  449. 		teleport_coop( NEAR_HELI_CHECKPOINT_WARPS[LOCAL_PLAYER], NEAR_HELI_CHECKPOINT_WARPS[REMOTE_PLAYER], true ) 
  450. 		script_profiler_end_section( "teleport coop" ) 
  451.  
  452.       -- resuming_from_checkpoint = true 
  453.       bh03_helicopter_escape_and_brotherhood_hq_return( true ) 
  454.    end 
  455. end 
  456.  
  457. function bh03_give_and_equip_player_heli_weapons() 
  458. 	inv_weapon_disable_all_but_this_slot( WEAPON_SLOT_RIFLE ) 
  459. 	inv_weapon_add_temporary( LOCAL_PLAYER, SAW_NAME, 1, true, true ) 
  460. 	inv_item_equip( SAW_NAME, LOCAL_PLAYER ) 
  461. 	if ( coop_is_active() ) then 
  462. 		inv_weapon_add_temporary( REMOTE_PLAYER, SAW_NAME, 1, true, true )  
  463. 		inv_item_equip( SAW_NAME, REMOTE_PLAYER ) 
  464. 	end 
  465. 	Players_have_heli_weapons = true 
  466. end 
  467.  
  468. function bh03_equip_player_heli_weapons() 
  469. 	repeat 
  470. 		inv_item_equip( SAW_NAME, LOCAL_PLAYER ) 
  471. 		if ( coop_is_active() ) then 
  472. 			inv_item_equip( SAW_NAME, REMOTE_PLAYER ) 
  473. 		end 
  474. 		delay( 1.0 ) 
  475. 	until ( inv_item_is_equipped( SAW_NAME, LOCAL_PLAYER ) and 
  476. 			  ( coop_is_active() == false or inv_item_is_equipped( SAW_NAME, REMOTE_PLAYER ) ) ) 
  477. end 
  478.  
  479. function bh03_initialize_alarms() 
  480. 	-- Setup the emitter ID arrays 
  481. 	for index, name in pairs( OUTSIDE_ALARMS ) do 
  482. 		Outside_alarm_emitter_ids[index] = 0 
  483. 	end 
  484. 	for index, name in pairs( INSIDE_ALARMS ) do 
  485. 		Inside_alarm_emitter_ids[index] = 0 
  486. 	end 
  487. end 
  488.  
  489. function bh03_get_geiger_counter() 
  490.    -- Create groups 
  491. 	if ( coop_is_active() ) then 
  492.       group_create( GROUP_START_VEHICLE_COOP, true ) 
  493.    end 
  494. 	group_create(GROUP_START_VEHICLE, true) 
  495. 	group_create(GROUP_EXTRA_BOATS, true) 
  496.    trigger_type_enable("store ownership", false) 
  497. 	trigger_type_enable("crib weapons", false) 
  498.    -- Fade in 
  499.    mission_start_fade_in() 
  500.  
  501.    hud_timer_set( HUD_COMPLETE_MISSION_IN_TIME_INDEX, MISSION_END_FAILURE_TIME_MS, "bh03_mission_failure_timeout" ) 
  502. 	Thread_time_running_out = thread_new( "bh03_time_out_warning", MISSION_END_WARNING_TIME_MS ); 
  503.  
  504.    -- Let the player know about the time limit 
  505.    mission_help_table_nag("bh03_time_limit") 
  506. 	delay(7) 
  507.  
  508.    -- Guide the player to the first objective 
  509. 	mission_help_table("bh03_get_geiger") 
  510. 	Geiger_player = "" 
  511. 	trigger_enable(WEAPON_STORE, true) 
  512. 	marker_add_navpoint(NAVPOINT_WEAPON_STORE_OUTSIDE, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  513. 	waypoint_add(WEAPON_STORE) 
  514. 	ingame_effect_add_trigger(WEAPON_STORE, WEAPON_STORE_EFFECT, SYNC_ALL) 
  515. 	on_trigger("buy_geiger_counter", WEAPON_STORE) 
  516.  
  517.    -- Wait until he's nearly to the weapon store 
  518. 	repeat 
  519. 		thread_yield() 
  520. 	until Geiger_player ~= "" or get_dist_closest_player_to_object(WEAPON_STORE) < WEAPON_STORE_MESSAGE_RADIUS  
  521. 	marker_remove_navpoint(NAVPOINT_WEAPON_STORE_OUTSIDE, SYNC_ALL) 
  522.    ingame_effect_remove_trigger( WEAPON_STORE_ORIG, SYNC_ALL ) 
  523. 	trigger_type_enable("weapon store", false) 
  524.    trigger_enable(WEAPON_STORE_ORIG, false) 
  525.  
  526. 	mission_help_table("bh03_buy_geiger") 
  527.  
  528.    -- Wait until the player's bought the geiger counter 
  529. 	repeat 
  530. 		thread_yield() 
  531. 	until Geiger_player ~= "" 
  532.  
  533. 	waypoint_remove() 
  534.  
  535. 	-- Lets mark the available transprotation 
  536. 	marker_add_vehicle(MP.."boat_spawn1", MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_INTERACT, SYNC_ALL) 
  537.    waypoint_add( MP.."boat_spawn1", SYNC_ALL ) 
  538.  
  539. 	delay(1)  
  540.  
  541. 	mission_help_table("bh03_vehicles_available") 
  542. 	-- when the player enters one, remove the markers 
  543. 	on_vehicle_enter("bh03_player_entered_vehicle", MP.."boat_spawn1")  
  544.    on_vehicle_enter( "bh03_player_entered_vehicle", LOCAL_PLAYER ) 
  545.    if ( coop_is_active() ) then 
  546.       on_vehicle_enter( "bh03_player_entered_vehicle", REMOTE_PLAYER ) 
  547.    end 
  548.  
  549.    -- If either player is ALREADY in the vehicle, just do the callback now 
  550.    if ( character_is_in_vehicle( LOCAL_PLAYER, MP.."boat_spawn1" ) ) then 
  551.       bh03_player_entered_vehicle( LOCAL_PLAYER ) 
  552.    elseif ( coop_is_active() and character_is_in_vehicle( REMOTE_PLAYER, MP.."boat_spawn1" ) ) then 
  553.       bh03_player_entered_vehicle( REMOTE_PLAYER )       
  554.    end 
  555.  
  556. 	-- Island Security Patrol added by Bryan D. 
  557. 	group_create(GROUP_ISLAND_PATROL01, true) 
  558. 	vehicle_enter_group_teleport(MP.."security01", MP.."security02", SECURITY_VEHICLE01) 
  559. 	-- vehicle_pathfind_to(SECURITY_VEHICLE01, MP.."sec_patrol_pt01", MP.."sec_patrol_pt02", MP.."sec_patrol_pt01", MP.."sec_patrol_pt02", MP.."sec_patrol_pt01", MP.."sec_patrol_pt02", true, false) 
  560.  
  561. 	-- Force the security patrol to patrol 
  562. 	thread_new("bh03_nuke_patrol_01", SECURITY_VEHICLE01, MP.."security01", MP.."security02") 
  563. 	 
  564. 	-- Tell the island guards to wander 
  565. 	group_create(GROUP_ISLAND_GUARDS, true) 
  566. 	for i = 1, NUM_NUKE_GUARDS, 1 do 
  567. 		wander_start(NUKE_GUARDS[i], NUKE_GUARDS[i], 15.0) 
  568. 	end 
  569.  
  570. 	-- Set all these dudes to react to the player when they see him or her by raising the notoriety 
  571. 	bh03_set_guards_detection_callback( "bh03_seen_by_guard" ) 
  572.  
  573. 	-- Time to disable ambient police 
  574. 	spawning_allow_cop_ambient_spawns( false )  
  575. 	roadblocks_enable( false ) 
  576.  
  577. 	initialize_goo() 
  578.  
  579. 	while ( ( not bh03_either_player_in_water_travel_vehicle() ) and 
  580. 			  ( not bh03_either_player_close_to_nav( NAVPOINT_NUKE_ISLAND, NUKE_ISLAND_RADIUS+150 ) ) ) do 
  581. 		thread_yield() 
  582. 	end 
  583.  
  584. 	bh03_remove_nuke_island_vehicles_markers() 
  585.  
  586. 	minimap_icon_add_navpoint(NAVPOINT_NUKE_ISLAND, MINIMAP_ICON_LOCATION) 
  587.    waypoint_add( NAVPOINT_NUKE_ISLAND, SYNC_ALL ) 
  588.    mission_help_table("bh03_go_to_island") 
  589.  
  590.    thread_new( "bh03_play_be_prepared_conversation" ) 
  591.  
  592. 	repeat 
  593. 		delay(0.25) 
  594. 	until bh03_either_player_close_to_nav( NAVPOINT_NUKE_ISLAND,  NUKE_ISLAND_RADIUS ) 
  595.  
  596. 	bh03_remove_nuke_island_vehicles_markers() 
  597.  
  598. 	minimap_icon_remove_navpoint(NAVPOINT_NUKE_ISLAND) 
  599.    waypoint_remove( SYNC_ALL ) 
  600.  
  601. 	mission_set_checkpoint(CHECKPOINT_NUKE_ISLAND) 
  602.  
  603. 	bh03_nuke_island_get_goo() 
  604. end 
  605.  
  606. function bh03_play_be_prepared_conversation() 
  607.    delay( 15 ) 
  608.    audio_play_conversation( BE_READY_FOR_PICKUP_CALL, OUTGOING_CALL ) 
  609. end 
  610.  
  611. function bh03_either_player_in_water_travel_vehicle() 
  612.    local function bh03_player_in_water_travel_vehicle( player_name ) 
  613.       if ( (get_char_vehicle_type(player_name) == VT_HELICOPTER) or 
  614. 	        (get_char_vehicle_type(player_name) == VT_AIRPLANE) or 
  615. 			  (get_char_vehicle_type(player_name) == VT_WATERCRAFT) ) then 
  616.          return true 
  617.       end 
  618.       return false 
  619.    end 
  620.  
  621.    if ( bh03_player_in_water_travel_vehicle( LOCAL_PLAYER ) ) then 
  622.       return true 
  623.    end 
  624.    if ( coop_is_active() and bh03_player_in_water_travel_vehicle( REMOTE_PLAYER ) ) then 
  625.       return true 
  626.    end 
  627.  
  628.    return false 
  629. end 
  630.  
  631. function bh03_either_player_close_to_nav( nav, distance ) 
  632.    if ( get_dist_char_to_nav( LOCAL_PLAYER, nav ) < distance ) then 
  633.       return true 
  634.    end 
  635.    if ( coop_is_active() and get_dist_char_to_nav( REMOTE_PLAYER, nav ) < distance ) then 
  636.       return true 
  637.    end 
  638.  
  639.    return false 
  640. end 
  641.  
  642. function bh03_set_guards_detection_callback( callback_name ) 
  643. 	on_detection(callback_name, MP.."guard00") 
  644. 	on_detection(callback_name, MP.."guard04") 
  645. 	on_detection(callback_name, MP.."guard06") 
  646. 	on_detection(callback_name, MP.."guard08") 
  647. 	on_detection(callback_name, MP.."guard09") 
  648. 	on_detection(callback_name, MP.."guard10") 
  649. 	on_detection(callback_name, MP.."guard11") 
  650. 	on_detection(callback_name, MP.."guard13") 
  651. 	on_detection(callback_name, MP.."guard15") 
  652. end 
  653.  
  654. function bh03_nuke_island_get_goo() 
  655. 	-- Temporary measure until notoriety on the Island works correctly. 
  656. 	-- Unfortunately this appears necessary as on-detection will not work without it. 
  657. 	notoriety_set_min(NUKE_SECURITY, 1) 
  658.  
  659.    local player_reached_in_helicopter = false 
  660.  
  661.    local dist, closest_player = get_dist_closest_player_to_object( NAVPOINT_NUKE_ISLAND ) 
  662.    -- If you come in the helicopter, then set notoriety to 2 
  663.    if ( get_char_vehicle_type( closest_player ) == VT_HELICOPTER ) then 
  664.       player_reached_in_helicopter = true 
  665.    end 
  666. 	Thread_security = thread_new("bh03_security_watch") 
  667.  
  668.    -- If the player reached the island in a heli, then set off the alarm at once 
  669.    if ( player_reached_in_helicopter ) then 
  670.       bh03_seen_by_guard( nil, closest_player ) 
  671.    -- Otherwise, warn the player about security 
  672.    else 
  673.       delay(2) 
  674.       mission_help_table_nag("bh03_island_security") 
  675.    	delay(7) 
  676.       -- Let the player know that he needs to get the goo and 
  677.       -- warn hit about guards and searchlights 
  678. 	   mission_help_table("bh03_get_goo") 
  679.    end 
  680.  
  681.    delay(5) 
  682.    -- Let the player know around where the goo is 
  683.    thread_new( "bh03_nag_about_goop" ) 
  684.  
  685. 	--inv_item_equip(WEAPON_GEIGER_COUNTER, Geiger_player) 
  686. 	Thread_geiger = thread_new("bh03_geiger_loop") 
  687. 	Thread_geiger_hud = thread_new("bh03_geiger_hud_loop") 
  688. 	Thread_geiger_message = thread_new("bh03_geiger_message_loop") 
  689.  
  690. 	repeat 
  691. 		delay(0.25) 
  692. 	until Goo_picked_up 
  693.  
  694.    mission_set_checkpoint( CHECKPOINT_COLLECTED_GOO ) 
  695.  
  696.    bh03_helipad_defense_and_arrival() 
  697. end 
  698.  
  699. function bh03_nag_about_goop() 
  700.    repeat 
  701.       mission_help_table_nag( HT_GOO_LOCATIONS[Goo_index] ) 
  702.       delay( BETWEEN_GOO_NAGS_SECONDS ) 
  703.    until Goo_picked_up 
  704. end 
  705.  
  706. function bh03_helipad_defense_and_arrival() 
  707.    -- Set up the helipad, including the defenders 
  708.    delay( 3.0 ) 
  709.    -- No notoriety spawning - the mission will handle that manually 
  710.    notoriety_force_no_spawn( NUKE_SECURITY, true ) 
  711.    notoriety_force_no_spawn( "Ultor", true ) 
  712.  
  713.    audio_play_conversation( PICK_ME_UP_NOW_CALL, OUTGOING_CALL ) 
  714.    bh03_setup_and_guide_to_helipad() 
  715.  
  716.    -- Wait for both players to reach the pad and clear out the defenders 
  717.    bh03_delay_until_initial_defenders_cleared_and_all_players_reached_pad() 
  718.    mission_help_table( HT_DEFEND_HELIPAD ) 
  719.    delay( 3.0 ) 
  720.    -- If the "Guards killed" is displayed, then remove it. 
  721.    if ( bh03_all_players_near_helipad() ) then 
  722.       objective_text_clear( 0 ) 
  723.    end 
  724.  
  725.    -- Have the second wave of attackers attack 
  726.    bh03_helipad_second_wave_attack() 
  727.    -- Set the timer for the helicopter arriving 
  728.    hud_timer_hide( HUD_COMPLETE_MISSION_IN_TIME_INDEX, true ) 
  729.    hud_timer_set( HUD_HELICOPTER_ARRIVE_INDEX, HELI_ARRIVAL_HOLD_OUT_TIME_MS, "bh03_helicopter_arrive", true, SYNC_ALL ) 
  730.  
  731.    -- Create groups of helicopters that will attack the player on return 
  732.    for index, group_name in pairs( ULTOR_ATTACKING_HELICOPTER_GROUPS ) do 
  733.       group_create_hidden( group_name ) 
  734.    end 
  735.  
  736.    repeat 
  737.       thread_yield() 
  738.    until ( bh03_all_players_near_helipad() and Helicopter_has_arrived ) 
  739.    bh03_helicopter_escape_and_brotherhood_hq_return() 
  740. end 
  741.  
  742. function bh03_helicopter_escape_and_brotherhood_hq_return( resuming_from_checkpoint ) 
  743.    bh03_helicopter_escape( resuming_from_checkpoint ) 
  744.  
  745.    repeat 
  746.       thread_yield() 
  747.    until ( Crash_complete ) 
  748.  
  749.    notoriety_force_no_spawn( NUKE_SECURITY, false ) 
  750.    notoriety_force_no_spawn( "Ultor", false ) 
  751.  
  752. 	group_create(GROUP_END_VEHICLE, true) 
  753.  
  754. 	delay(2) 
  755.  
  756. 	Goo_delivered = false 
  757.  
  758.    audio_play_conversation( AFTER_HELI_CRASH_DIALOG_STREAM, NOT_CALL ) 
  759.  
  760. 	marker_add_navpoint(NAVPOINT_HQ, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_LOCATION, SYNC_ALL) 
  761.    waypoint_add( NAVPOINT_HQ, SYNC_ALL ) 
  762.  
  763. 	mission_help_table_nag("bh03_deliver_goo") 
  764.  
  765. 	repeat 
  766. 	delay(.25) 
  767. 	until get_dist(Goo_player, NAVPOINT_NUKE_ISLAND_CENTER) > NUKE_ISLAND_RADIUS 
  768.  
  769.    repeat 
  770. 		if get_dist(NAVPOINT_HQ, Goo_player) < HQ_DELIVER_DISTANCE then 
  771. 			Goo_delivered = true 
  772. 		end 
  773. 		delay(0.25) 
  774. 	until Goo_delivered 
  775.  
  776.    -- Stop the players' vehicles when they reach the HQ trigger 
  777. 	if ( character_is_in_vehicle( LOCAL_PLAYER ) ) then 
  778.       player_controls_disable( LOCAL_PLAYER ) 
  779.       vehicle_stop_do( LOCAL_PLAYER ) 
  780.    end 
  781.    if ( coop_is_active() ) then 
  782.       if ( character_is_in_vehicle( REMOTE_PLAYER ) ) then 
  783.          player_controls_disable( REMOTE_PLAYER ) 
  784.          vehicle_stop_do( REMOTE_PLAYER ) 
  785.       end 
  786.    end 
  787.  
  788. 	marker_remove_navpoint(NAVPOINT_HQ) 
  789. 	waypoint_remove( SYNC_ALL ) 
  790. 	 
  791. 	delay(1) 
  792. 	mission_end_success(CURRENT_MISSION, CUTSCENE_OUT) 
  793. end 
  794.  
  795. function bh03_clean_up_alarm_and_sunrise_timer() 
  796.    bh03_set_guards_detection_callback( "" ) 
  797.  
  798.    hud_timer_stop( HUD_COMPLETE_MISSION_IN_TIME_INDEX ) 
  799.  
  800.    if ( Thread_time_running_out ~= INVALID_THREAD_HANDLE ) then 
  801.       thread_kill( Thread_time_running_out ) 
  802.       Thread_time_running_out = INVALID_THREAD_HANDLE 
  803.    end 
  804. end 
  805.  
  806. function bh03_delay_until_initial_defenders_cleared_and_all_players_reached_pad() 
  807.    repeat 
  808.       thread_yield() 
  809.    until ( Helipad_initial_defenders_cleared and All_players_reached_pad ) 
  810. end 
  811.  
  812. function bh03_set_vehicle_interaction_allowed( allowed ) 
  813.    set_player_can_enter_exit_vehicles( LOCAL_PLAYER, allowed ) 
  814.    if ( coop_is_active() ) then 
  815.       set_player_can_enter_exit_vehicles( REMOTE_PLAYER, allowed ) 
  816.    end 
  817. end 
  818.  
  819. function bh03_helicopter_arrive() 
  820.    hud_timer_stop( HUD_HELICOPTER_ARRIVE_INDEX ) 
  821.    --hud_timer_hide( HUD_COMPLETE_MISSION_IN_TIME_INDEX, false ) 
  822.    hud_timer_pause( HUD_COMPLETE_MISSION_IN_TIME_INDEX, true ) 
  823.    Wave_spawning_enabled = false 
  824.  
  825.    group_show( FAUX_ESCAPE_HELICOPTER_GROUP ) 
  826.    group_show( ESCAPE_HELI_PASSENGERS_GROUP ) 
  827.  
  828.    if ( Faux_escape_helicopter_seated == false ) then 
  829.       vehicle_enter_group_teleport( ESCAPE_HELICOPTER_PASSENGERS, FAUX_ESCAPE_HELICOPTER ) 
  830.       Faux_escape_helicopter_seated = true 
  831.    end 
  832.  
  833.    -- Place it 
  834.    teleport_vehicle( FAUX_ESCAPE_HELICOPTER, HELI_LAND_START ) 
  835.  
  836.    set_unjackable_flag( FAUX_ESCAPE_HELICOPTER, true ) 
  837.  
  838.    -- Let the player know the helicopter's flying in 
  839.    -- thread_new( "bh03_incoming_call", CARLOS_LANDING_NOW_LINE_CALL ) 
  840.  
  841.    -- Fly in for a landing 
  842.    helicopter_fly_to_direct( FAUX_ESCAPE_HELICOPTER, HELICOPTER_LAND_SPEED_MPS, HELI_LAND_PATH ) 
  843.  
  844.    -- Set jitter on helicopters to almost nothing so that this helicopter seems to be actually hovering 
  845.    helicopters_set_jitter_override( 0.1, 0.05 ) 
  846.  
  847.    audio_play( CARLOS_LANDED_LINE, "voice", true ) 
  848.  
  849.    mission_help_table( HT_BOARD_HELICOPTER ) 
  850.    delay( 3.0 ) 
  851.  
  852.    Helicopter_has_arrived = true 
  853. end 
  854.  
  855. -- Tracking function for first helipad defenders. 
  856. -- 
  857. -- Possibly: Removes markers, update HUD, and 
  858. -- advance to the next mission state. 
  859. -- 
  860. function bh03_helipad_initial_guard_killed( member_name ) 
  861.    marker_remove_npc( member_name, SYNC_ALL ) 
  862.    Initial_helipad_guards_remaining = Initial_helipad_guards_remaining - 1 
  863.  
  864.    if ( All_players_reached_pad and bh03_all_players_near_helipad() ) then 
  865.       bh03_update_objective_display() 
  866.    end 
  867.  
  868.    -- Let the player know that Carlos is almost there 
  869.    if ( Initial_helipad_guards_remaining == ( NUM_INITIAL_HELIPAD_GUARDS - 1 ) ) then 
  870.       thread_new( "bh03_incoming_call", CARLOS_ALMOST_TO_NUKE_PLANT_CALL ) 
  871.    -- If a certain number remain, then do the flyby 
  872.    elseif ( Initial_helipad_guards_remaining == INITIAL_GUARDS_DO_FLYBY_THRESHOLD and 
  873.             All_players_reached_pad ) then 
  874.       bh03_do_flyby() 
  875.    -- If all the guards are dead, then mark the initial defenders as cleared 
  876.    elseif ( Initial_helipad_guards_remaining == 0 ) then 
  877.       Helipad_initial_defenders_cleared = true 
  878.       -- Clear the objective a few seconds after we complete it 
  879.       if ( All_players_reached_pad ) then 
  880.          delay( 3.0 ) 
  881.          objective_text_clear( 0 ) 
  882.       end 
  883.    end 
  884. end 
  885.  
  886. Current_call_received = false 
  887.  
  888. function bh03_current_call_received() 
  889.    mission_debug( "current call received!" ) 
  890.    Current_call_received = true 
  891. end 
  892.  
  893. function bh03_incoming_call( which_call ) 
  894.    mission_debug( "call made" ) 
  895.    cellphone_clear_between_call_delay() 
  896.    Current_call_received = false 
  897.  
  898.    mid_mission_phonecall( "bh03_current_call_received" ) 
  899.    local incoming_call_thread = thread_new( "bh03_do_incoming_call", which_call ) 
  900.  
  901.    delay( 20.0 ) 
  902.  
  903.    if ( Current_call_received == false ) then 
  904.       thread_kill( incoming_call_thread ) 
  905.       mission_debug( "call killed!" ) 
  906.       mid_mission_phonecall_reset() 
  907.    end 
  908. end 
  909.  
  910. function bh03_do_incoming_call( which_call ) 
  911.    mission_debug( "waiting on current call!" ) 
  912.    repeat 
  913.       thread_yield() 
  914.    until Current_call_received 
  915.  
  916.    mission_debug( "playing incoming call conversation" ) 
  917.    audio_play_conversation( which_call, INCOMING_CALL ) 
  918.    mission_debug( "incoming call conversation played" ) 
  919.    mid_mission_phonecall_reset() 
  920. end 
  921.  
  922. -- Displays the "LZ too hot" message when the escape helicopter hits 
  923. -- a trigger in the midst of its path 
  924. -- 
  925. function bh03_heli_lz_too_hot_message( triggerer_name, trigger_name ) 
  926.    if ( triggerer_name == CARLOS_NAME ) then 
  927.       trigger_enable( trigger_name, false ) 
  928.  
  929.       thread_new( "bh03_incoming_call", CARLOS_TOO_HOT_LINE_CALL ) 
  930.    end 
  931. end 
  932.  
  933. function bh03_carlos_died() 
  934.    mission_end_failure( CURRENT_MISSION, HT_CARLOS_DIED ) 
  935. end 
  936.  
  937. function bh03_carlos_abandoned() 
  938.    mission_end_failure( CURRENT_MISSION, HT_CARLOS_ABANDONED ) 
  939. end 
  940.  
  941. function bh03_heli_pilot_killed() 
  942.    mission_end_failure( CURRENT_MISSION, HT_PILOT_KILLED ) 
  943. end 
  944.  
  945. -- This function has the player's escape helicopter do a flyby of the  
  946. -- helipad. The player is informed that the landing zone is too hot 
  947. -- and he's got to defend it before the helicopter can land. 
  948. -- 
  949. function bh03_do_flyby() 
  950.    -- Show the group, 
  951.    group_show( FAUX_ESCAPE_HELICOPTER_GROUP ) 
  952.    group_show( ESCAPE_HELI_PASSENGERS_GROUP )  
  953.  
  954.    -- set up the helicopter 
  955.    on_vehicle_destroyed( "bh03_helicopter_destroyed", FAUX_ESCAPE_HELICOPTER ) 
  956.    on_death( "bh03_heli_pilot_killed", ESCAPE_HELI_PILOT_NAME ) 
  957.    vehicle_enter_group_teleport( ESCAPE_HELICOPTER_PASSENGERS, FAUX_ESCAPE_HELICOPTER ) 
  958.    Faux_escape_helicopter_seated = true 
  959.  
  960.    -- set up passengers 
  961.    on_death( "bh03_carlos_died", CARLOS_NAME ) 
  962.  
  963.    -- set up the "too hot" message 
  964.    trigger_enable( LZ_TOO_HOT_TRIGGER, true ) 
  965.    on_trigger( "bh03_heli_lz_too_hot_message", LZ_TOO_HOT_TRIGGER ) 
  966.  
  967.    -- have it fly along the path 
  968.    teleport_vehicle( FAUX_ESCAPE_HELICOPTER, HELI_BUZZ_HELIPAD_START ) 
  969.    helicopter_fly_to_direct( FAUX_ESCAPE_HELICOPTER, HELICOPTER_BUZZ_SPEED_MPS, HELI_BUZZ_HELIPAD_PATH ) 
  970.  
  971.    teleport_vehicle( FAUX_ESCAPE_HELICOPTER, FAUX_ESCAPE_HELICOPTER ) 
  972.    group_hide( ESCAPE_HELI_PASSENGERS_GROUP ) 
  973.    group_hide( FAUX_ESCAPE_HELICOPTER_GROUP ) 
  974. end 
  975.  
  976. function bh03_helicopter_damaged( name, attacker, percent_hp_left ) 
  977.    local before_damage_percent = get_current_hit_points( ESCAPE_HELICOPTER ) / get_max_hit_points( ESCAPE_HELICOPTER ) 
  978.    local percent_damaged = before_damage_percent - percent_hp_left 
  979.  
  980.    Heli_percent_damage_since_last_complaint = Heli_percent_damage_since_last_complaint + percent_damaged 
  981.    if ( Heli_percent_damage_since_last_complaint >= PERCENT_OF_HELI_DAMAGE_BEFORE_COMPLAINT ) then 
  982.       repeat 
  983.          thread_yield() 
  984.       until ( Carlos_already_talking == false ) 
  985.       Carlos_already_talking = true 
  986.       audio_play_for_character( CARLOS_HELI_DAMAGED_LINE, CARLOS_NAME ) 
  987.       Heli_percent_damage_since_last_complaint = 0 
  988.       Carlos_already_talking = false 
  989.    end 
  990. end 
  991.  
  992. function bh03_helicopter_destroyed() 
  993.    mission_end_failure( CURRENT_MISSION, HT_HELICOPTER_DESTROYED ) 
  994. end 
  995.  
  996. -- Sets up the helipad that the player needs to defend and guides 
  997. -- him there. 
  998. -- 
  999. function bh03_setup_and_guide_to_helipad() 
  1000.    -- Create the defenders, add death tracking 
  1001.    group_create( HELIPAD_INITIAL_GUARDS_GROUP, true ) 
  1002.    for index, member_name in pairs( HELIPAD_INITIAL_GUARDS ) do 
  1003.       on_death( "bh03_helipad_initial_guard_killed", member_name ) 
  1004.    end 
  1005.    group_create_hidden( FAUX_ESCAPE_HELICOPTER_GROUP, true ) 
  1006.    group_create_hidden( ESCAPE_HELI_PASSENGERS_GROUP, true ) 
  1007.    group_create_hidden( ESCAPE_HELICOPTER_GROUP, true ) 
  1008.  
  1009.    -- Enable the helipad trigger and tracking for it 
  1010.    trigger_enable( HELIPAD_AREA, true ) 
  1011.    on_trigger( "bh03_reached_helipad_initial", HELIPAD_AREA ) 
  1012.    on_trigger_exit( "bh03_left_helipad", HELIPAD_AREA ) 
  1013.  
  1014.    -- Guide the players to the helipad 
  1015.    --minimap_icon_add_navpoint_radius( HELIPAD_AREA, MINIMAP_ICON_LOCATION, HELIPAD_AREA_RADIUS_METERS, "", SYNC_ALL ) 
  1016.    marker_add_navpoint( HELIPAD_AREA, MINIMAP_ICON_LOCATION, "", SYNC_ALL ) 
  1017.    waypoint_add( HELIPAD_AREA, SYNC_ALL ) 
  1018.    mission_help_table( HT_GET_TO_HELIPAD, SYNC_ALL ) 
  1019. end 
  1020.  
  1021. -- Updates the HUD objective display for the number of helipad guards remaining 
  1022. -- 
  1023. function bh03_update_objective_display() 
  1024.    objective_text( 0, HT_X_OF_Y_GUARDS_KILLED, NUM_INITIAL_HELIPAD_GUARDS - Initial_helipad_guards_remaining, 
  1025.                    NUM_INITIAL_HELIPAD_GUARDS, SYNC_ALL ) 
  1026. end 
  1027.  
  1028. function bh03_reached_helipad_initial( triggerer_name ) 
  1029.    Players_near_helipad[triggerer_name] = true 
  1030.  
  1031.    waypoint_remove( SYNC_ALL ) 
  1032.  
  1033.    local sync_type = sync_from_player( triggerer_name ) 
  1034.    marker_remove_navpoint( HELIPAD_AREA, sync_type ) 
  1035.    if ( bh03_all_players_near_helipad() ) then 
  1036.       -- If any attackers remain, then marker them and prompt the player(s) to 
  1037.       -- kill them 
  1038.       All_players_reached_pad = true 
  1039.       if ( Initial_helipad_guards_remaining > 0 ) then 
  1040.          mission_help_table( HT_CLEAR_OUT_HELIPAD_GUARDS ) 
  1041.          bh03_update_objective_display() 
  1042.          for index, member_name in pairs( HELIPAD_INITIAL_GUARDS ) do 
  1043.             if ( character_is_dead( member_name ) == false ) then 
  1044.                marker_add_npc( member_name, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL ) 
  1045.             end 
  1046.          end 
  1047.       -- Otherwise, advance to the "attack" state 
  1048.       else 
  1049.          Helipad_initial_defenders_cleared = true 
  1050.       end 
  1051.       -- In any case, rebind this function to the non-initial state 
  1052.       on_trigger( "bh03_reached_helipad", HELIPAD_AREA ) 
  1053.    end 
  1054. end 
  1055.  
  1056. function bh03_reached_helipad( triggerer_name ) 
  1057.    Players_near_helipad[triggerer_name] = true 
  1058.    local sync_type = sync_from_player( triggerer_name ) 
  1059.    minimap_icon_remove_navpoint( HELIPAD_AREA, sync_type ) 
  1060.  
  1061.    -- If there was a failure timer running for 
  1062.    -- this player, stop it 
  1063.    if ( Player_failure_timers_threads[triggerer_name] ~= INVALID_THREAD_HANDLE ) then 
  1064.       local sync_type = sync_from_player( triggerer_name ) 
  1065.       -- Stop the failure timer 
  1066.       thread_kill( Player_failure_timers_threads[triggerer_name] ) 
  1067.       Player_failure_timers_threads[triggerer_name] = INVALID_THREAD_HANDLE 
  1068.    end 
  1069. end 
  1070.  
  1071. function bh03_defend_helipad_fail_help_text_timer( sync_type ) 
  1072.    local cur_time_left_seconds = LEAVE_PAD_FAILURE_TIME_SECONDS 
  1073.  
  1074.    repeat 
  1075.       mission_help_table_nag( HT_RETURN_TO_HELIPADS_DEFENSE, cur_time_left_seconds, "", sync_type ) 
  1076.       delay( TIME_PER_RETURN_TO_DEFEND_UPDATE_SECONDS ) 
  1077.       cur_time_left_seconds = cur_time_left_seconds - TIME_PER_RETURN_TO_DEFEND_UPDATE_SECONDS 
  1078.    until cur_time_left_seconds <= 0 
  1079.  
  1080.    mission_end_failure( CURRENT_MISSION, HT_ABANDONED_HELIPAD ) 
  1081. end 
  1082.  
  1083. function bh03_left_helipad( triggerer_name ) 
  1084.    Players_near_helipad[triggerer_name] = false 
  1085.    local sync_type = sync_from_player( triggerer_name ) 
  1086.    minimap_icon_add_navpoint_radius( HELIPAD_AREA, MINIMAP_ICON_LOCATION, HELIPAD_AREA_RADIUS_METERS, "", sync_type ) 
  1087.  
  1088.    -- Possibly start out-of-range failure timer 
  1089.    -- and prompt player 
  1090.    if ( All_players_reached_pad == true ) then 
  1091.       Player_failure_timers_threads[triggerer_name] = thread_new( "bh03_defend_helipad_fail_help_text_timer", sync_type ) 
  1092.    end 
  1093. end 
  1094.  
  1095.  
  1096. function bh03_all_players_near_helipad() 
  1097.    if ( Players_near_helipad[LOCAL_PLAYER] ) then 
  1098.       if ( coop_is_active() ) then 
  1099.          if ( Players_near_helipad[REMOTE_PLAYER] ) then 
  1100.             return true 
  1101.          end 
  1102.       else 
  1103.          return true 
  1104.       end 
  1105.    end 
  1106.    return false 
  1107. end 
  1108.  
  1109. function bh03_helipad_second_wave_attack() 
  1110.    -- Choose a direction and spawn the attackers 
  1111.    local wave_direction_index = rand_int( 1, HELIPAD_SECOND_WAVE_ATTACK_DIRECTION_COUNT ) 
  1112.  
  1113.    -- Attack from this direction 
  1114.    thread_new( "bh03_wave_direction_create_and_attack", wave_direction_index ) 
  1115. end 
  1116.  
  1117. function bh03_wave_direction_create_and_attack( wave_direction_index ) 
  1118.    local cur_group = HELIPAD_SECOND_WAVE_GROUPS[wave_direction_index] 
  1119.  
  1120.    if ( cur_group == nil ) then 
  1121.       mission_debug( "wave_direction_index = "..wave_direction_index..", cur_group = nil" ) 
  1122.       return 
  1123.    end 
  1124.    mission_debug(  "wave_direction_index = "..wave_direction_index..", cur_group = "..cur_group ) 
  1125.  
  1126.    -- Release the group from this direction if it's loaded 
  1127.    if ( group_is_loaded( cur_group ) ) then 
  1128.       release_to_world( cur_group ) 
  1129.    end 
  1130.  
  1131.    -- (Re)create the group 
  1132.    group_create( cur_group, true ) 
  1133.  
  1134.    -- Seat the people 
  1135.    local cur_members = HELIPAD_SECOND_WAVE_MEMBERS[wave_direction_index] 
  1136.    local cur_vehicle = HELIPAD_SECOND_WAVE_VEHICLES[wave_direction_index] 
  1137.    vehicle_enter_group_teleport( cur_members, cur_vehicle ) 
  1138.  
  1139.    -- Add death tracking 
  1140.    for index, member_name in pairs( cur_members ) do 
  1141.       on_death( "bh03_second_wave_member_died_d"..wave_direction_index, member_name ) 
  1142.       Num_tracked_helipad_wave_attackers = Num_tracked_helipad_wave_attackers + 1 
  1143.    end 
  1144.  
  1145.    -- Have them go to the helipad 
  1146.    vehicle_pathfind_to( cur_vehicle, HELIPAD_SECOND_WAVE_PATHS[wave_direction_index], true, true ) 
  1147.  
  1148.    -- Finally, have them attack the player(s) 
  1149.    for index, member_name in pairs( cur_members ) do 
  1150.       if ( character_is_released( member_name ) == false ) then 
  1151.          thread_new( "bh03_officer_exit_car", member_name ) 
  1152.       end 
  1153.    end 
  1154.  
  1155.    release_to_world( cur_vehicle ) 
  1156. end 
  1157.  
  1158. function bh03_officer_exit_car( officer_name ) 
  1159.    vehicle_exit( officer_name ) 
  1160.    attack_closest_player( officer_name ) 
  1161. end 
  1162.  
  1163. function bh03_second_wave_member_died_d1( member_name ) 
  1164.    bh03_second_wave_member_died( member_name, 1 ) 
  1165. end 
  1166. function bh03_second_wave_member_died_d2( member_name ) 
  1167.    bh03_second_wave_member_died( member_name, 2 ) 
  1168. end 
  1169. function bh03_second_wave_member_died_d3( member_name ) 
  1170.    bh03_second_wave_member_died( member_name, 3 ) 
  1171. end 
  1172.  
  1173. function bh03_second_wave_member_died( member_name, direction_index ) 
  1174.    Num_tracked_helipad_wave_attackers = Num_tracked_helipad_wave_attackers - 1 
  1175.    release_to_world( member_name ) 
  1176.  
  1177.    -- If we should spawn a new group to attack 
  1178.    if ( Num_tracked_helipad_wave_attackers == SPAWN_NEW_WAVE_THRESHOLD and 
  1179.         Wave_spawning_enabled ) then 
  1180.       -- Spawn attackers from another direction - exclude the current one 
  1181.       for i = 0, HELIPAD_SECOND_WAVE_ATTACK_DIRECTION_COUNT do 
  1182.          if ( i ~= direction_index ) then 
  1183.             thread_new( "bh03_wave_direction_create_and_attack", i ) 
  1184.          end 
  1185.       end 
  1186.    end 
  1187. end 
  1188.  
  1189. function bh03_attacking_heli1_follow( triggerer_name, trigger_name ) 
  1190.    trigger_enable( trigger_name, false ) 
  1191.    bh03_attacking_heli_follow( 1 ) 
  1192. end 
  1193. function bh03_attacking_heli2_follow( triggerer_name, trigger_name ) 
  1194.    trigger_enable( trigger_name, false ) 
  1195.    bh03_attacking_heli_follow( 2 ) 
  1196. end 
  1197. function bh03_attacking_heli3_follow( triggerer_name, trigger_name ) 
  1198.    trigger_enable( trigger_name, false ) 
  1199.    bh03_attacking_heli_follow( 3 ) 
  1200. end 
  1201.  
  1202. -- Function that immediately destroys a helicopter that's on fire. 
  1203. -- Stops checking and ends when the player's helicopter crashes. 
  1204. -- 
  1205. function bh03_immediately_destroy_on_fire_heli( heli_name, pilot_name ) 
  1206.     
  1207.    repeat 
  1208.       local smoke, fire = vehicle_get_smoke_and_fire_state( heli_name ) 
  1209.  
  1210.       if ( fire ) then 
  1211.          turn_vulnerable( pilot_name ) 
  1212.          vehicle_detonate( heli_name ) 
  1213.          break 
  1214.       end 
  1215.  
  1216.       thread_yield() 
  1217.    until ( vehicle_is_destroyed( heli_name ) or Crash_complete ) 
  1218.    turn_vulnerable( pilot_name ) 
  1219. end 
  1220.  
  1221. function bh03_attacking_heli_follow( heli_index ) 
  1222.    local cur_heli = ULTOR_HELIS[heli_index] 
  1223.  
  1224.    turn_invulnerable( ULTOR_HELI_PILOTS[heli_index] ) 
  1225.    thread_new( "bh03_immediately_destroy_on_fire_heli", cur_heli, ULTOR_HELI_PILOTS[heli_index] ) 
  1226.  
  1227.    -- Teleport to the start location 
  1228.    teleport_vehicle( cur_heli, ULTOR_HELI_START_POINTS[heli_index] ) 
  1229.  
  1230.    thread_new( "bh03_heli_gunner_attack", ULTOR_HELI_GUNNERS[heli_index], 7 ) 
  1231.    helicopter_fly_to_direct_follow( cur_heli, ULTOR_HELIS_CLOSING_SPEEDS_MPS[heli_index], 
  1232.                                     ESCAPE_HELICOPTER, ULTOR_HELI_FOLLOW_PATHS[heli_index] ) 
  1233.  
  1234.    -- Have the helicopter attack if it's still alive at this point 
  1235.    if ( vehicle_is_destroyed( cur_heli ) == false ) then 
  1236.       local distance, player_name = get_dist_closest_player_to_object( cur_heli ) 
  1237.       vehicle_chase( cur_heli, player_name ) 
  1238.    end 
  1239. end 
  1240.  
  1241. function bh03_heli_gunner_attack( gunner_name, delay_seconds ) 
  1242.    delay( delay_seconds ) 
  1243.  
  1244.    attack_safe( gunner_name, LOCAL_PLAYER ) 
  1245. end 
  1246.  
  1247. function bh03_heli1_slow_down() 
  1248.    bh03_heli_slow_down( 1 ) 
  1249. end 
  1250.  
  1251. function bh03_heli2_slow_down() 
  1252.    bh03_heli_slow_down( 2 ) 
  1253. end 
  1254.  
  1255. function bh03_heli_slow_down( heli_index ) 
  1256.    vehicle_speed_override( ULTOR_HELIS[heli_index], ULTOR_HELIS_FOLLOW_SPEEDS_MPS[heli_index] ) 
  1257. end 
  1258.  
  1259. function bh03_helicopter_escape( resuming_from_checkpoint ) 
  1260.    if ( resuming_from_checkpoint == nil ) then 
  1261.       resuming_from_checkpoint = false 
  1262.    end 
  1263.  
  1264.    if ( resuming_from_checkpoint == false ) then 
  1265.       fade_out( 1 ) 
  1266.       player_controls_disable( LOCAL_PLAYER ) 
  1267.       if ( coop_is_active() ) then 
  1268.          player_controls_disable( REMOTE_PLAYER ) 
  1269.       end 
  1270.       Controls_disabled = true 
  1271. 		fade_out_block() 
  1272. 	end -- else 
  1273. 	-- If we're resuming from a checkpoint, the screen has already been faded out and the 
  1274.    -- player controls have been disabled. This is basically a mission start function in 
  1275.    -- this case 
  1276.  
  1277. 	spawning_vehicles( false ) 
  1278. 	spawning_pedestrians( false, true ) 
  1279. 	 
  1280. 	if ( resuming_from_checkpoint ) then 
  1281. 		script_profiler_start_section( "checkpoint: evacuating from vehicles" ) 
  1282. 	end 
  1283.  
  1284. 	if ( resuming_from_checkpoint == false ) then 
  1285. 		character_evacuate_from_all_vehicles( LOCAL_PLAYER ) 
  1286. 		if ( coop_is_active() ) then 
  1287. 			character_evacuate_from_all_vehicles( REMOTE_PLAYER ) 
  1288. 		end 
  1289. 	end 
  1290.  
  1291. 	if ( resuming_from_checkpoint ) then 
  1292. 		script_profiler_end_section( "checkpoint: evacuating from vehicles" ) 
  1293. 	end 
  1294.  
  1295. 	if ( resuming_from_checkpoint ) then 
  1296. 		script_profiler_start_section( "checkpoint: blocking on player weapons" ) 
  1297. 	end 
  1298.  
  1299. 	if ( resuming_from_checkpoint == false ) then 
  1300. 		-- Give the players the heli weapons here also 
  1301. 		bh03_give_and_equip_player_heli_weapons() 
  1302. 	end 
  1303. 	thread_new( "bh03_equip_player_heli_weapons" ) 
  1304.  
  1305. 	if ( resuming_from_checkpoint ) then 
  1306. 		script_profiler_end_section( "checkpoint: blocking on player weapons" ) 
  1307. 	end 
  1308.  
  1309.    if ( resuming_from_checkpoint == false ) then 
  1310.       -- Disable the "abandoned helipad" trigger and failure conditions 
  1311.       trigger_enable( HELIPAD_AREA, false ) 
  1312.       if ( Player_failure_timers_threads[LOCAL_PLAYER] ~= INVALID_THREAD_HANDLE ) then 
  1313.          thread_kill( Player_failure_timers_threads[LOCAL_PLAYER] ) 
  1314.          Player_failure_timers_threads[LOCAL_PLAYER] = INVALID_THREAD_HANDLE 
  1315.       end 
  1316.       if ( Player_failure_timers_threads[REMOTE_PLAYER] ~= INVALID_THREAD_HANDLE ) then 
  1317.          thread_kill( Player_failure_timers_threads[REMOTE_PLAYER] ) 
  1318.          Player_failure_timers_threads[REMOTE_PLAYER] = INVALID_THREAD_HANDLE 
  1319.       end 
  1320.       minimap_icon_remove_navpoint( HELIPAD_AREA, SYNC_ALL ) 
  1321.  
  1322.       -- Return helicopter jitter to the default. 
  1323.       helicopters_set_jitter_override() 
  1324.  
  1325.       on_vehicle_destroyed( "", FAUX_ESCAPE_HELICOPTER ) 
  1326. 		group_hide( FAUX_ESCAPE_HELICOPTER_GROUP ) 
  1327. 		group_destroy( FAUX_ESCAPE_HELICOPTER_GROUP ) 
  1328.    end 
  1329.  
  1330.  
  1331. 	if ( resuming_from_checkpoint ) then 
  1332. 		script_profiler_start_section( "checkpoint: showing groups" ) 
  1333. 	end 
  1334.  
  1335.    -- Show the real escape helicopter, the pilot, and Carlos 
  1336.    group_show( ESCAPE_HELICOPTER_GROUP ) 
  1337.    group_show( ESCAPE_HELI_PASSENGERS_GROUP ) 
  1338.  
  1339. 	if ( resuming_from_checkpoint ) then 
  1340. 		script_profiler_end_section( "checkpoint: showing groups" ) 
  1341. 	end 
  1342.  
  1343. 	if ( resuming_from_checkpoint == false ) then 
  1344. 		mission_set_checkpoint( CHECKPOINT_HELICOPTER_ESCAPE ) 
  1345. 	end 
  1346.    party_dismiss_all() 
  1347.  
  1348. 	if ( resuming_from_checkpoint ) then 
  1349. 		script_profiler_start_section( "checkpoint: teleport coop" ) 
  1350. 	end 
  1351. 	teleport_coop( NEAR_HELI_CHECKPOINT_WARPS[LOCAL_PLAYER], NEAR_HELI_CHECKPOINT_WARPS[REMOTE_PLAYER], true ) 
  1352. 	if ( resuming_from_checkpoint ) then 
  1353. 		script_profiler_end_section( "checkpoint: teleport coop" ) 
  1354. 	end 
  1355.  
  1356. 	if ( resuming_from_checkpoint ) then 
  1357. 		script_profiler_start_section( "checkpoint: block on distance" ) 
  1358. 	end 
  1359. 	delay( 2.0 ) 
  1360. 	if ( resuming_from_checkpoint ) then 
  1361. 		script_profiler_end_section( "checkpoint: block on distance" ) 
  1362. 	end 
  1363. 	if ( resuming_from_checkpoint ) then 
  1364. 		script_profiler_start_section( "checkpoint: teleporting passengers" ) 
  1365. 	end 
  1366. 	for index, name in pairs( ESCAPE_HELICOPTER_PASSENGERS ) do 
  1367. 		teleport( name, PASSENGERS_NEAR_HELI_WARPS[index], true ) 
  1368. 	end 
  1369. 	if ( resuming_from_checkpoint ) then 
  1370. 		script_profiler_end_section( "checkpoint: teleporting passengers" ) 
  1371. 	end 
  1372. 	if ( resuming_from_checkpoint ) then 
  1373. 		script_profiler_start_section( "checkpoint: enter helicopter" ) 
  1374. 	end 
  1375. 	-- players... 
  1376. 	vehicle_enter_teleport( LOCAL_PLAYER, ESCAPE_HELICOPTER, 2 ) 
  1377. 	if ( coop_is_active() ) then 
  1378. 		vehicle_enter_teleport( REMOTE_PLAYER, ESCAPE_HELICOPTER, 3 ) 
  1379. 	end 
  1380. 	if ( resuming_from_checkpoint ) then 
  1381. 		script_profiler_end_section( "checkpoint: enter helicopter" ) 
  1382. 	end 
  1383.  
  1384. 	if ( resuming_from_checkpoint ) then 
  1385. 		script_profiler_end_section( "checkpoint: seating players" ) 
  1386. 		script_profiler_start_section( "checkpoint: misc" ) 
  1387. 	end 
  1388.  
  1389.    -- Turn the driver invulnerable to prevent him from being killed and taking the helicopter down 
  1390.    turn_invulnerable( ESCAPE_HELI_PILOT_NAME ) 
  1391. 	npc_suppress_persona( ESCAPE_HELI_PILOT_NAME, true ) 
  1392.  
  1393.    -- Don't let the player recruit the pilot. 
  1394.    set_unrecruitable_flag( ESCAPE_HELI_PILOT_NAME, true ) 
  1395.  
  1396. 	if ( resuming_from_checkpoint ) then 
  1397. 		script_profiler_start_section( "checkpoint: vehicle teleport etc" ) 
  1398. 	end 
  1399.  
  1400.    -- Now, put the helicopter in the correct location 
  1401.    teleport_vehicle( ESCAPE_HELICOPTER, REAL_HELI_START ) 
  1402.    -- Failure tracking 
  1403.    on_vehicle_destroyed( "bh03_helicopter_destroyed", ESCAPE_HELICOPTER ) 
  1404.    -- Used to have Carlos possibly complain about the helicopter's state 
  1405.    on_take_damage( "bh03_helicopter_damaged", ESCAPE_HELICOPTER ) 
  1406.    -- We don't want to be knocked off our path 
  1407.    vehicle_prevent_explosion_fling( ESCAPE_HELICOPTER, true ) 
  1408.    vehicle_infinite_mass( ESCAPE_HELICOPTER, true ) 
  1409.  
  1410. 	if ( resuming_from_checkpoint ) then 
  1411. 		script_profiler_end_section( "checkpoint: vehicle teleport etc" ) 
  1412. 	end 
  1413.  
  1414.    bh03_set_vehicle_interaction_allowed( false ) 
  1415.  
  1416.    -- Enable the triggers that will spawn the attacking helicopters 
  1417.    for index, trigger_name in pairs( ULTOR_HELI_FOLLOW_TRIGGERS ) do 
  1418.       trigger_enable( trigger_name, true ) 
  1419.       on_trigger( "bh03_attacking_heli"..index.."_follow", trigger_name ) 
  1420. 		trigger_enable( TRIGGER_SHOOTERS, true ) 
  1421. 		on_trigger( "bh03_start_shooters", TRIGGER_SHOOTERS ) 
  1422. 		trigger_enable( TRIGGER_BOAT_CHASE, true ) 
  1423. 		on_trigger( "bh03_start_chase_boats", TRIGGER_BOAT_CHASE ) 
  1424.    end 
  1425.  
  1426.    trigger_enable( HELI_IN_TROUBLE_TRIGGER, true ) 
  1427.    on_trigger( "bh03_helicopter_alarm_smoke_and_shake", HELI_IN_TROUBLE_TRIGGER ) 
  1428.  
  1429.    trigger_enable( HELI_GOING_DOWN_TRIGGER, true ) 
  1430.    on_trigger( "bh03_helicopter_going_down", HELI_GOING_DOWN_TRIGGER ) 
  1431.  
  1432.    trigger_enable( HELI_EJECTION_TRIGGER, true ) 
  1433.    on_trigger( "bh03_helicopter_ejection_and_crash", HELI_EJECTION_TRIGGER ) 
  1434.  
  1435.    objective_text_clear( SYNC_ALL ) 
  1436.    mission_help_clear() 
  1437.  
  1438. 	group_create_hidden( "bh03_$explode_heli" ) 
  1439.  
  1440.    if ( resuming_from_checkpoint ) then 
  1441. 		script_profiler_end_section( "checkpoint: misc" ) 
  1442. 		script_profiler_do_printout() 
  1443.       mission_start_fade_in() 
  1444.        
  1445.       hud_timer_set( HUD_COMPLETE_MISSION_IN_TIME_INDEX, MISSION_END_FAILURE_AFTER_FINAL_CHECKPOINT_MS, "bh03_mission_failure_timeout" ) 
  1446.       hud_timer_hide( HUD_COMPLETE_MISSION_IN_TIME_INDEX, true ) 
  1447.       hud_timer_pause( HUD_COMPLETE_MISSION_IN_TIME_INDEX, true ) 
  1448. 		Thread_time_running_out = thread_new( "bh03_time_out_warning", MISSION_END_WARNING_AFTER_FINAL_CHECKPOINT_MS ); 
  1449.    else 
  1450.       player_controls_enable( LOCAL_PLAYER ) 
  1451.       if ( coop_is_active() ) then 
  1452.          player_controls_enable( REMOTE_PLAYER ) 
  1453.       end 
  1454.       Controls_disabled = false 
  1455.       fade_in( 1 ) 
  1456.       fade_in_block() 
  1457.    end 
  1458.  
  1459. 	spawning_vehicles( true ) 
  1460. 	spawning_pedestrians( true ) 
  1461.  
  1462. 	-- Spawn threads for each entry 
  1463. 	local vehicle_enter_threads = {} 
  1464.  
  1465. 	-- Put the passengers in the helicopter 
  1466. 	for index, name in pairs( ESCAPE_HELICOPTER_PASSENGERS ) do 
  1467. 		vehicle_enter_threads[name] = thread_new( "bh03_seat_character", name, ESCAPE_HELICOPTER, index - 1 ) 
  1468. 	end 
  1469.  
  1470.    -- Setup the helicopters that will attack the player on the way 
  1471.    for index, group_name in pairs( ULTOR_ATTACKING_HELICOPTER_GROUPS ) do 
  1472.       group_show( group_name ) 
  1473. 		vehicle_enter_threads[ULTOR_HELI_PILOTS[index]] = thread_new( "bh03_seat_character", ULTOR_HELI_PILOTS[index], ULTOR_HELIS[index], ULTOR_HELI_PILOT_SEAT ) 
  1474. 		vehicle_enter_threads[ULTOR_HELI_GUNNERS[index]] = thread_new( "bh03_seat_character", ULTOR_HELI_GUNNERS[index], ULTOR_HELIS[index], ULTOR_HELI_GUNNER_SEAT ) 
  1475.    end 
  1476.  
  1477. 	-- Keep looping until all the entry threads have finished 
  1478. 	local all_entry_threads_complete = false 
  1479. 	repeat 
  1480. 		all_entry_threads_complete = true 
  1481.  
  1482. 		for index, name in pairs( ESCAPE_HELICOPTER_PASSENGERS ) do 
  1483. 			if ( thread_check_done( vehicle_enter_threads[name] ) == false ) then 
  1484. 				all_entry_threads_complete = false 
  1485. 			end 
  1486. 		end 
  1487.  
  1488. 		for index, group_name in pairs( ULTOR_ATTACKING_HELICOPTER_GROUPS ) do 
  1489. 			if ( thread_check_done( vehicle_enter_threads[ULTOR_HELI_PILOTS[index]] ) == false or 
  1490. 				  thread_check_done( vehicle_enter_threads[ULTOR_HELI_GUNNERS[index]] ) == false ) then 
  1491. 				all_entry_threads_complete = false 
  1492. 			end 
  1493. 		end 
  1494. 		thread_yield() 
  1495. 	until all_entry_threads_complete 
  1496.  
  1497.    thread_new( "bh03_helicopter_conversations" ) 
  1498.  
  1499.    thread_new( "bh03_helicopter_fly_crash_path" ) 
  1500.  
  1501.    mission_help_table("bh03_deliver_goo") 
  1502. end 
  1503.  
  1504. function bh03_seat_character( character_name, vehicle_name, seat_index ) 
  1505. 	vehicle_enter_teleport( character_name, vehicle_name, seat_index) 
  1506. end 
  1507.  
  1508. function bh03_start_chase_boats() 
  1509. 	group_create(GROUP_POLICE_BOATS, true) 
  1510. 	delay(1) 
  1511. 	vehicle_enter_teleport(BOAT01_DRIVER, BOAT01_BOAT, 0) 
  1512.    vehicle_enter_teleport(BOAT01_PASSENGER, BOAT01_BOAT, 1) 
  1513. 	vehicle_enter_teleport(BOAT02_DRIVER, BOAT02_BOAT, 0) 
  1514.    vehicle_enter_teleport(BOAT02_PASSENGER, BOAT02_BOAT, 1) 
  1515. 	set_max_hit_points(BOAT01_BOAT, get_max_hit_points(BOAT01_BOAT) * BOAT_HEALTH_MULTIPLIER, true) 
  1516. 	set_max_hit_points(BOAT02_BOAT, get_max_hit_points(BOAT02_BOAT) * BOAT_HEALTH_MULTIPLIER, true) 
  1517. 	vehicle_lights_on(BOAT01_BOAT, true) 
  1518. 	-- vehicle_set_sirens(BOAT01_BOAT, true) 
  1519. 	vehicle_lights_on(BOAT02_BOAT, true) 
  1520. 	-- vehicle_set_sirens(BOAT02_BOAT, true) 
  1521. 	thread_new( "bh03_boat_pathfind02" ) 
  1522. 	thread_new( "bh03_boat_pathfind01" ) 
  1523. end 
  1524.  
  1525. function bh03_boat_pathfind01() 
  1526. 	delay(1) 
  1527. 	vehicle_speed_override(BOAT01_BOAT, BOATS_SPEED) 
  1528. 	vehicle_pathfind_to( BOAT01_BOAT, BOAT01_PATH, true, false) 
  1529. end 
  1530.  
  1531. function bh03_boat_pathfind02() 
  1532. 	delay(2) 
  1533. 	vehicle_speed_override(BOAT02_BOAT, BOATS_SPEED) 
  1534. 	vehicle_pathfind_to( BOAT02_BOAT, BOAT02_PATH, true, false) 
  1535. end 
  1536.  
  1537. function bh03_start_shooters() 
  1538. 	group_create(GROUP_POLICE_SHOOTERS, true) 
  1539. 	delay(1) 
  1540. 	attack(POLICE_SHOOTER01, LOCAL_PLAYER, false) 
  1541. 	attack(POLICE_SHOOTER02, LOCAL_PLAYER, false) 
  1542. 	attack(POLICE_SHOOTER03, LOCAL_PLAYER, false) 
  1543. end 
  1544.  
  1545. function bh03_helicopter_fly_crash_path() 
  1546.    -- Have the helicopter fly to its next goal 
  1547.    helicopter_fly_to_direct( ESCAPE_HELICOPTER, HELICOPTER_RAIL_SPEED_MPS, HELI_BACK_TO_STILWATER_AND_CRASH_PATH ) 
  1548. 	-- we're off the ground we can now reenable ambient police 
  1549. 	spawning_allow_cop_ambient_spawns( true )  
  1550. 	roadblocks_enable( true ) 
  1551. end 
  1552.  
  1553. function bh03_helicopter_conversations() 
  1554.    delay( 2.0 ) 
  1555.    audio_play_conversation( AFTER_ENTER_HELI_DIALOG_STREAM, NOT_CALL ) 
  1556.  
  1557.    bh03_carlos_and_pilot_complain() 
  1558. end 
  1559.  
  1560. function bh03_carlos_and_pilot_complain() 
  1561.    for i = 1, NUM_PILOT_AND_CARLOS_COMPLAIN_CONVERSATIONS do 
  1562.       delay( rand_float( 15.0, 17.5 ) ) 
  1563.  
  1564.       repeat 
  1565.          thread_yield() 
  1566.       until ( Carlos_already_talking == false ) 
  1567.       Carlos_already_talking = true 
  1568.       audio_play_for_character( PILOT_COMPLAIN_LINES[i], ESCAPE_HELI_PILOT_NAME, "voice", false, true ) 
  1569.       audio_play_for_character( CARLOS_COMPLAIN_TO_PILOT_LINES[i], CARLOS_NAME, "voice", false, true ) 
  1570.       Carlos_already_talking = false 
  1571.    end 
  1572. end 
  1573.  
  1574. function bh03_helicopter_alarm_smoke_and_shake( triggerer_name, trigger_name ) 
  1575.    trigger_enable( trigger_name, false ) 
  1576.  
  1577.    local max_hp = get_max_hit_points( ESCAPE_HELICOPTER ) 
  1578.  
  1579.    set_current_hit_points( ESCAPE_HELICOPTER, max_hp * 0.2 ) 
  1580.    turn_invulnerable( ESCAPE_HELICOPTER ) 
  1581.  
  1582.    -- smoke = true, fire = false 
  1583.    vehicle_set_smoke_and_fire_state( ESCAPE_HELICOPTER, true, false ) 
  1584.  
  1585.    delay( 1.0 ) 
  1586.  
  1587.    camera_shake_start( 0.00015, 14000, 14000, 0.003 ) 
  1588. end 
  1589.  
  1590. function bh03_helicopter_going_down( triggerer_name, trigger_name ) 
  1591.    trigger_enable( trigger_name, false ) 
  1592.  
  1593.    -- Let the player know of the badness 
  1594.    audio_play( HELI_GOING_DOWN_LINE, "voice", true ) 
  1595. end 
  1596.  
  1597. function bh03_helicopter_ejection_and_crash( triggerer_name, trigger_name ) 
  1598.    trigger_enable( trigger_name, false ) 
  1599.    -- No more failure on pilot death - the escape flight is ended 
  1600.    on_death( "", ESCAPE_HELI_PILOT_NAME ) 
  1601.    turn_vulnerable( ESCAPE_HELI_PILOT_NAME ) 
  1602.  
  1603.    vehicle_exit_dive( CARLOS_NAME ) 
  1604.    turn_invulnerable( CARLOS_NAME ) 
  1605.    -- Throw the players in random directions so it seems they were blown out of the helicopter 
  1606.    if ( coop_is_active() ) then 
  1607.       turn_invulnerable( REMOTE_PLAYER ) 
  1608.       vehicle_exit_dive( REMOTE_PLAYER ) 
  1609.    end 
  1610.    turn_invulnerable( LOCAL_PLAYER ) 
  1611.    vehicle_exit_dive( LOCAL_PLAYER ) 
  1612.  
  1613.    vehicle_exit_teleport( ESCAPE_HELI_PILOT_NAME ) 
  1614.  
  1615.    if ( coop_is_active() ) then 
  1616.       character_ragdoll( REMOTE_PLAYER, 5000 ) 
  1617.    end 
  1618.    character_ragdoll( LOCAL_PLAYER, 5000 ) 
  1619.    character_ragdoll( CARLOS_NAME, 4000 ) 
  1620.  
  1621.    on_vehicle_destroyed( "", ESCAPE_HELICOPTER ) 
  1622.    on_take_damage( "", ESCAPE_HELICOPTER ) 
  1623. 	thread_yield() 
  1624. 	group_hide( ESCAPE_HELICOPTER_GROUP ) 
  1625. 	group_destroy( ESCAPE_HELICOPTER_GROUP ) 
  1626. 	group_destroy( GROUP_POLICE_BOATS ) 
  1627.  
  1628. 	group_show( "bh03_$explode_heli" ) 
  1629. 	thread_yield() 
  1630.    vehicle_enter_teleport( ESCAPE_HELI_PILOT_NAME, "bh03_$explode_heli", 0 ) 
  1631. 	thread_yield() 
  1632. 	vehicle_detonate( "bh03_$explode_heli" ) 
  1633.  
  1634.    inv_weapon_enable_or_disable_all_slots( true ) 
  1635.    inv_weapon_remove_temporary( LOCAL_PLAYER, SAW_NAME ) 
  1636.    if ( coop_is_active() ) then 
  1637.       inv_weapon_remove_temporary( REMOTE_PLAYER, SAW_NAME )  
  1638.    end 
  1639. 	Players_have_heli_weapons = false 
  1640.  
  1641.    --mission_help_table_nag( HT_GET_CLEAR_OF_HELI ) 
  1642.  
  1643.    party_add( CARLOS_NAME, LOCAL_PLAYER ) 
  1644.    on_death( "bh03_carlos_died", CARLOS_NAME ) 
  1645.    for index, override in pairs( CARLOS_PERSONA_OVERRIDES ) do 
  1646.       persona_override_character_start( CARLOS_NAME, override[1], override[2] ) 
  1647.    end 
  1648.    on_dismiss( "bh03_carlos_abandoned", CARLOS_NAME ) 
  1649.    bh03_set_vehicle_interaction_allowed( true ) 
  1650.    Crash_complete = true 
  1651.  
  1652.    -- Now, make the players vulnerable again. Give them a few seconds to recover, 
  1653.    -- and make sure they're up and about 
  1654.    thread_new( "bh03_turn_human_vulnerable", LOCAL_PLAYER ) 
  1655.    if ( coop_is_active() ) then 
  1656.       thread_new( "bh03_turn_human_vulnerable", REMOTE_PLAYER ) 
  1657.    end 
  1658.  
  1659.    thread_new( "bh03_turn_human_vulnerable", CARLOS_NAME ) 
  1660.  
  1661.    hud_timer_pause( HUD_COMPLETE_MISSION_IN_TIME_INDEX, false )    
  1662.    hud_timer_hide( HUD_COMPLETE_MISSION_IN_TIME_INDEX, false ) 
  1663. end 
  1664.  
  1665. function bh03_turn_human_vulnerable( human_name ) 
  1666.    repeat 
  1667.       thread_yield() 
  1668.    until ( character_is_ready( human_name )  ) 
  1669.    turn_vulnerable( human_name ) 
  1670. end 
  1671.  
  1672. function bh03_security_watch() 
  1673. 	local time_since_alert = 0 
  1674. 	local first_alert = true 
  1675. 	while(1) do 
  1676. 		thread_yield() 
  1677. 		time_since_alert = time_since_alert + get_frame_time() 
  1678. 		if Seen_by_security and (first_alert or ((time_since_alert >= 20) and ((player_far_from_security()) or (player_removed_notoriety())))) then 
  1679.          local sync_type = sync_from_player( Last_player_seen ) 
  1680.  
  1681. 			notoriety_set(NUKE_SECURITY, MISSION_MAX_NOTORIETY) 
  1682. 				if ( coop_is_active() ) then 
  1683. 					notoriety_set(NUKE_SECURITY, MISSION_MAX_NOTORIETY_COOP) 
  1684. 				end 
  1685. 			-- Only show the message once for each player than sets off the alarm 
  1686. 			if ( Alarm_message_shown[Last_player_seen] == false ) then 
  1687. 				mission_help_table_nag( "bh03_seen_by_guard", "", "", sync_type ) 
  1688. 				Alarm_message_shown[Last_player_seen] = true 
  1689. 			end 
  1690. 			Seen_by_security = false 
  1691. 			Gotten_away_from_security = false 
  1692. 			Gotten_notoriety_down = false 
  1693. 			time_since_alert = 0 
  1694. 			if first_alert then 
  1695. 				first_alert = false 
  1696. 			end 
  1697. 		end 
  1698. 	end 
  1699. end 
  1700.  
  1701. function player_removed_notoriety() 
  1702. 	if Gotten_notoriety_down then 
  1703. 		return true 
  1704. 	end 
  1705.  
  1706. 	if notoriety_get(NUKE_SECURITY) == 0 then 
  1707. 		Gotten_notoriety_down = true 
  1708. 	end 
  1709.  
  1710. 	return Gotten_notoriety_down 
  1711. end 
  1712.  
  1713. function player_far_from_security() 
  1714. 	if Gotten_away_from_security then 
  1715. 		return true 
  1716. 	end 
  1717.  
  1718. 	if ( coop_is_active() ) then 
  1719. 		for i, npc in pairs(NUKE_GUARDS) do 
  1720. 			if (get_dist(LOCAL_PLAYER, npc) < SECURITY_ESCAPED_DIST) or (get_dist(REMOTE_PLAYER, npc) < SECURITY_ESCAPED_DIST) then 
  1721. 				return false 
  1722. 			end 
  1723. 		end 
  1724. 		Gotten_away_from_security = true 
  1725. 		return true 
  1726. 	else 
  1727. 		for i, npc in pairs(NUKE_GUARDS) do 
  1728. 			if get_dist(LOCAL_PLAYER, npc) < SECURITY_ESCAPED_DIST then 
  1729. 				return false 
  1730. 			end 
  1731. 		end 
  1732. 		Gotten_away_from_security = true 
  1733. 		return true 
  1734. 	end 
  1735. end 
  1736.  
  1737. function bh03_mission_failure_timeout() 
  1738.    mission_end_failure( CURRENT_MISSION, "bh03_failure_out_of_time" )  
  1739. end 
  1740.  
  1741. function bh03_time_out_warning( time_ms ) 
  1742.    delay( time_ms / 1000 ) 
  1743.    mission_debug( "time out warning delay over." ) 
  1744.    mission_help_table_nag("bh03_one_hour_left") 
  1745. end 
  1746.  
  1747. function buy_geiger_counter(player) 
  1748. 	on_trigger("", WEAPON_STORE) 
  1749. 	trigger_enable(WEAPON_STORE, false) 
  1750. 	trigger_type_enable("weapon store", true) 
  1751. 	trigger_enable(WEAPON_STORE_ORIG, true) 
  1752.    ingame_effect_add_trigger(WEAPON_STORE_ORIG, WEAPON_STORE_EFFECT, SYNC_ALL) 
  1753. 	Geiger_player = player 
  1754. 	inv_weapon_add_temporary(Geiger_player, WEAPON_GEIGER_COUNTER, 1, true ) 
  1755.    inv_item_equip(WEAPON_GEIGER_COUNTER, Geiger_player) 
  1756. end 
  1757.  
  1758. Officers_see_player = false 
  1759.  
  1760. function bh03_remove_nuke_island_vehicles_markers() 
  1761. 	marker_remove_vehicle(MP.."boat_spawn1", SYNC_ALL) 
  1762. end 
  1763.  
  1764. function bh03_remove_vehicle_enter_callbacks() 
  1765.    on_vehicle_enter("", MP.."boat_spawn1") 
  1766.  
  1767.    on_vehicle_enter( "", LOCAL_PLAYER ) 
  1768.    if ( coop_is_active() ) then 
  1769.       on_vehicle_enter( "", REMOTE_PLAYER ) 
  1770.    end 
  1771. end 
  1772.  
  1773. function bh03_player_entered_vehicle( player_name ) 
  1774.    local vehicle_type = get_char_vehicle_type( player_name ) 
  1775.  
  1776.    -- Let the player know that a helicopter will blow his cover 
  1777.    if ( vehicle_type == VT_HELICOPTER ) then 
  1778.       mission_help_table_nag( HT_HELI_BLOW_COVER_WARNING ) 
  1779.    end 
  1780.  
  1781.   waypoint_remove( SYNC_ALL ) 
  1782.  
  1783. 	if ( vehicle_type == VT_HELICOPTER or 
  1784. 		  vehicle_type == VT_AIRPLANE or 
  1785. 		  vehicle_type == VT_WATERCRAFT ) then 
  1786.       bh03_remove_vehicle_enter_callbacks() 
  1787.       release_to_world( GROUP_EXTRA_BOATS ) 
  1788. 	end 
  1789. end 
  1790.  
  1791. function bh03_nuke_patrol_01(vehicle, officer1, officer2) 
  1792. 	local	i = 1 
  1793. 	local	path_success = true 
  1794.  
  1795. 	on_detection("bh03_seen_player", officer1) 
  1796. 	on_detection("bh03_seen_player", officer2) 
  1797.  
  1798. 	-- Drive this path until the character attacks or is dead 
  1799. 	while (not Officers_see_player and path_success) do 
  1800. 		path_success = vehicle_pathfind_to(vehicle, NUKE_PATROL_ROUTE01[i], false, false) 
  1801. 		i = i + 1 
  1802. 		if (i > NUM_NUKE_PATROL01) then 
  1803. 			i = 1 
  1804. 		end 
  1805. 	end 
  1806.  
  1807. 	on_detection("", officer1) 
  1808. 	on_detection("", officer2) 
  1809. 	 
  1810. --	thread_new("bh03_nuke_patrol_01", vehicle, officer1, officer2) 
  1811. end 
  1812.  
  1813. function bh03_seen_player() 
  1814. 	Officers_see_player = true 
  1815. 	notoriety_set(NUKE_SECURITY, MISSION_MAX_NOTORIETY) 
  1816. 	if ( coop_is_active() ) then 
  1817. 		notoriety_set(NUKE_SECURITY, MISSION_MAX_NOTORIETY_COOP) 
  1818. 	end 
  1819. end 
  1820.  
  1821. function bh03_play_alarms() 
  1822.    local	outside_audio_id, outside_type = audio_get_id("SFX_BRO_PLANT_ALARM_OUT", "foley") 
  1823.    local	inside_audio_id, inside_type = audio_get_id("SFX_BRO_PLANT_ALARM_IN", "foley") 
  1824.  
  1825. 	for alarm_index, alarm_location in pairs( OUTSIDE_ALARMS ) do 
  1826. 		if ( Outside_alarm_emitter_ids[alarm_index] == 0 ) then 
  1827. 			Outside_alarm_emitter_ids[alarm_index] = audio_play_emitting_id_for_navpoint( alarm_location, outside_audio_id ) 
  1828. 		end 
  1829. 	end 
  1830.  
  1831. 	for alarm_index, alarm_location in pairs( INSIDE_ALARMS ) do 
  1832. 		if ( Inside_alarm_emitter_ids[alarm_index] == 0 ) then 
  1833. 			Inside_alarm_emitter_ids[alarm_index] = audio_play_emitting_id_for_navpoint( alarm_location, inside_audio_id ) 
  1834. 		end 
  1835. 	end 
  1836. end 
  1837.  
  1838. function bh03_stop_alarms() 
  1839. 	for alarm_index, alarm_location in pairs( OUTSIDE_ALARMS ) do 
  1840. 		if ( Outside_alarm_emitter_ids[alarm_index] ~= 0 ) then 
  1841. 			audio_stop_emitting_id( Outside_alarm_emitter_ids[alarm_index] ) 
  1842. 			Outside_alarm_emitter_ids[alarm_index] = 0 
  1843. 		end 
  1844. 	end 
  1845.  
  1846. 	for alarm_index, alarm_location in pairs( INSIDE_ALARMS ) do 
  1847. 		if ( Inside_alarm_emitter_ids[alarm_index] ~= 0 ) then 
  1848. 			audio_stop_emitting_id( Inside_alarm_emitter_ids[alarm_index] ) 
  1849. 			Inside_alarm_emitter_ids[alarm_index] = 0 
  1850. 		end 
  1851. 	end 
  1852. end 
  1853.  
  1854. -- Called when the player is seen. Can be called if the player 
  1855. -- comes to the island in a helicopter. 
  1856. -- 
  1857. -- guard_name: Name of the guard that saw the player. May be nil. 
  1858. -- player_name: Name of the player that was seen. 
  1859. -- 
  1860. function bh03_seen_by_guard( guard_name, player_name ) 
  1861. 	Seen_by_security = true 
  1862.    Last_player_seen = player_name 
  1863.    if ( Alarm_triggered == false ) then 
  1864. 		Alarm_triggered = true 
  1865.       bh03_play_alarms() 
  1866.    end 
  1867. end 
  1868.  
  1869. function bh03_geiger_message_loop() 
  1870. 	local sync = sync_from_player(Geiger_player) 
  1871. 	repeat 
  1872. 		if not inv_item_is_equipped(WEAPON_GEIGER_COUNTER, Geiger_player) then 
  1873. 			bh03_stop_all_geiger_sounds() 
  1874. 			delay(20) 
  1875. 			mission_help_table("bh03_use_geiger", sync) 
  1876. 		else 
  1877. 			thread_yield() 
  1878. 		end 
  1879. 	until false 
  1880. end 
  1881.  
  1882. function bh03_geiger_hud_loop() 
  1883. 	local sync = sync_from_player(Geiger_player) 
  1884. 	repeat 
  1885. 		thread_yield() 
  1886. 		if inv_item_is_equipped(WEAPON_GEIGER_COUNTER, Geiger_player) then 
  1887. 			local dist = get_dist(Geiger_player, Goo_item) 
  1888. 			local ratio = 0 
  1889. 			if dist < GEIGER_MAX_DISTANCE then 
  1890. 				if dist < GEIGER_MIN_DISTANCE then 
  1891. 					ratio = 1 
  1892. 				else 
  1893. 					ratio = 1 - (dist - GEIGER_MIN_DISTANCE) / (GEIGER_MAX_DISTANCE - GEIGER_MIN_DISTANCE) 
  1894. 				end 
  1895. 			end 
  1896.  
  1897. 			if Geiger_bar_off then 
  1898. 				hud_bar_on(0, "Radioactivity", "bh03_radioactivity", 1.0, sync) 
  1899. 				hud_bar_set_range(0, 0.0, 1.0, SYNC_ALL) 
  1900. 				Geiger_bar_off = false 
  1901. 			end 
  1902.  
  1903. 			local noise_level = (ratio * 0.04) + 0.01 
  1904. 			local noisy_ratio = ratio + rand_float(0-noise_level, noise_level) 
  1905. 			if noisy_ratio < 0 then 
  1906. 				noisy_ratio = 0 
  1907. 			elseif noisy_ratio > 1.0 then 
  1908. 				noisy_ratio = 1.0 
  1909. 			end 
  1910. 			hud_bar_set_value(0, noisy_ratio, sync) 
  1911. 		else 
  1912. 			bh03_stop_all_geiger_sounds() 
  1913. 			hud_bar_off(0) 
  1914. 			Geiger_bar_off = true 
  1915. 		end 
  1916. 	until false 
  1917. end 
  1918.  
  1919. function bh03_geiger_loop() 
  1920. 	local sync = sync_from_player(Geiger_player) 
  1921. 	local equipped = false 
  1922. 	repeat 
  1923. 		thread_yield() 
  1924. 		if inv_item_is_equipped(WEAPON_GEIGER_COUNTER, Geiger_player) then 
  1925. 			if not equipped then 
  1926. 				audio_play_for_character_weapon(GEIGER_ON, Geiger_player) 
  1927. 			end 
  1928. 			equipped = true 
  1929. 			local dist = get_dist(Geiger_player, Goo_item) 
  1930. 			local ratio = 0 
  1931. 			if dist < GEIGER_MAX_DISTANCE then 
  1932. 				if dist < GEIGER_MIN_DISTANCE then 
  1933. 					ratio = 1 
  1934. 				else 
  1935. 					ratio = 1 - (dist - GEIGER_MIN_DISTANCE) / (GEIGER_MAX_DISTANCE - GEIGER_MIN_DISTANCE) 
  1936. 				end 
  1937. 			end 
  1938.  
  1939. 			local delay_time = GEIGER_MIN_DELAY + (GEIGER_MAX_DELAY - GEIGER_MIN_DELAY) * (1 - ratio) 
  1940. 			character_set_combat_ready(Geiger_player, true, delay_time * 1000 + 200) 
  1941.  
  1942. 			bh03_geiger_audio(ratio) 
  1943.  
  1944. 			--local click = audio_play_for_character_weapon(GEIGER_CLICK, Geiger_player) 
  1945. 			feedback_start(GEIGER_FEEDBACK, GEIGER_MIN_FEEDBACK + ratio * (1 - GEIGER_MIN_FEEDBACK), false, sync) 
  1946. 			--delay(delay_time) 
  1947. 			--audio_stop(click) 
  1948. 		else 
  1949. 			thread_yield() 
  1950. 			bh03_stop_all_geiger_sounds() 
  1951. 			equipped = false 
  1952. 		end 
  1953. 	until false 
  1954. end 
  1955.  
  1956. function bh03_geiger_audio(ratio) 
  1957. 	local new_num_geiger_sounds 
  1958.  
  1959. 	if ratio < 0.2 then 
  1960. 		new_num_geiger_sounds = 1 
  1961. 	elseif ratio < 0.4 then 
  1962. 		new_num_geiger_sounds = 2 
  1963. 	elseif ratio < 0.6 then 
  1964. 		new_num_geiger_sounds = 3 
  1965. 	elseif ratio < 0.8 then 
  1966. 		new_num_geiger_sounds = 4 
  1967. 	else 
  1968. 		new_num_geiger_sounds = 5 
  1969. 	end 
  1970.  
  1971. 	for i, sound in pairs(Geiger_sound) do 
  1972. 		if i <= new_num_geiger_sounds then 
  1973. 			if sound == -1 then 
  1974. 				Geiger_sound[i] = audio_play_for_character_weapon(GEIGER_CLICK, Geiger_player) 
  1975. 				delay(rand_float(0,1)) 
  1976. 			end 
  1977. 		else 
  1978. 			if sound ~= -1 then 
  1979. 				audio_stop(sound) 
  1980. 				Geiger_sound[i] = -1 
  1981. 			end 
  1982. 		end 
  1983. 	end 
  1984. end 
  1985.  
  1986. function bh03_stop_all_geiger_sounds() 
  1987. 	local was_equipped = false 
  1988. 	for i, sound in pairs(Geiger_sound) do 
  1989. 		if sound ~= -1 then 
  1990. 			audio_stop(sound) 
  1991. 			Geiger_sound[i] = -1 
  1992. 			was_equipped = true 
  1993. 		end 
  1994. 	end 
  1995. 	if was_equipped then 
  1996. 		audio_play_for_character_weapon(GEIGER_OFF, Geiger_player) 
  1997. 	end 
  1998. end 
  1999.  
  2000. function initialize_goo() 
  2001.    -- Create the goo 
  2002. 	group_create(GROUP_GOO, true) 
  2003.  
  2004.    -- Select a particular good item randomly 
  2005. 	Goo_index = rand_int(1, GOO_COUNT) 
  2006. 	Goo_item = GOO_PREFIX .. Goo_index 
  2007. 	Goo_trigger = GOO_TRIGGER_PREFIX .. Goo_index 
  2008.  
  2009.    -- Go through and hide all other goo 
  2010. 	for i = 1, GOO_COUNT, 1 do 
  2011. 		local item = GOO_PREFIX .. i 
  2012. 		item_hide(item) 
  2013. 	end 
  2014.  
  2015.    -- Show the selected good item and mark it with an effect ( not a minimap icon though ) 
  2016. 	item_show(Goo_item)	 
  2017. 	ingame_effect_add_item(Goo_item, INGAME_EFFECT_PROTECT_ACQUIRE, SYNC_ALL) 
  2018.  
  2019.    -- Add the trigger and picked-up-good tracking 
  2020. 	Goo_picked_up = false 
  2021. 	trigger_enable(Goo_trigger, true) 
  2022. 	ingame_effect_add_trigger(Goo_trigger, GOO_TRIGGER_EFFECT, SYNC_ALL) 
  2023. 	on_trigger("pickup_goo", Goo_trigger) 
  2024.  
  2025.    -- Create the particular guards that guard this goo 
  2026. 	group_create(GROUP_GOO_GUARDS[Goo_index], true) 
  2027. 	for i, npc in pairs(GOO_GUARDS[Goo_index]) do 
  2028. 		wander_start(npc, npc, 15.0) 
  2029. 		on_detection("bh03_seen_by_guard", npc) 
  2030. 	end 
  2031.  
  2032. 	NAVPOINT_NUKE_ISLAND = GOO_LOCATION_MAP[Goo_index] 
  2033. end 
  2034.  
  2035. function pickup_goo(player) 
  2036. 	bh03_stop_all_geiger_sounds() 
  2037. 	local sync = sync_from_player(Geiger_player) 
  2038. 	hud_bar_off(0) 
  2039. 	inv_weapon_remove_temporary(Geiger_player, WEAPON_GEIGER_COUNTER) 
  2040. 	thread_kill(Thread_geiger) 
  2041. 	thread_kill(Thread_geiger_hud) 
  2042. 	thread_kill(Thread_geiger_message) 
  2043. 	 
  2044. 	marker_remove_item(Goo_item) 
  2045. 	trigger_enable(Goo_trigger, false) 
  2046. 	on_trigger("", Goo_trigger) 
  2047.  
  2048. 	crouch_start(player) 
  2049. 	delay(1) 
  2050. 	action_play(player, ACTION_PICKUP_ITEM) 
  2051. 	for i = 1, GOO_COUNT, 1 do 
  2052. 		local item = GOO_PREFIX .. i 
  2053. 		object_destroy(item) 
  2054. 	end 
  2055. 	--object_destroy(Goo_item) 
  2056. 	Goo_picked_up = true 
  2057. 	crouch_stop(player) 
  2058.  
  2059.    Goo_player = player 
  2060.  
  2061.    -- The cop lines don't necessarily make sense until you've picked up the nuclear waste 
  2062.    persona_override_group_start( COP_PERSONAS, POT_SITUATIONS[POT_ATTACK], "BR03_ATTACK" ) 
  2063. end 
  2064.  
  2065. function bh03_cleanup() 
  2066. 	trigger_type_enable("store ownership", true) 
  2067. 	trigger_type_enable("weapon store", true) 
  2068. 	trigger_type_enable("crib weapons", true) 
  2069. 	if Geiger_player ~= "" then 
  2070. 		on_trigger("", WEAPON_STORE) 
  2071. 		trigger_enable(WEAPON_STORE_ORIG, true) 
  2072. 		trigger_enable(WEAPON_STORE, false) 
  2073. 		ingame_effect_add_trigger(WEAPON_STORE_ORIG, WEAPON_STORE_EFFECT, SYNC_ALL) 
  2074. 	end 
  2075.    bh03_stop_all_geiger_sounds() 
  2076.    bh03_remove_vehicle_enter_callbacks() 
  2077.  
  2078.   	spawning_vehicles( true ) 
  2079. 	spawning_pedestrians( true ) 
  2080.  
  2081.    hud_timer_stop( HUD_HELICOPTER_ARRIVE_INDEX ) 
  2082.    hud_timer_stop( HUD_COMPLETE_MISSION_IN_TIME_INDEX ) 
  2083. 	hud_timer_hide( HUD_COMPLETE_MISSION_IN_TIME_INDEX, false ) 
  2084.  
  2085. 	marker_remove_navpoint(NAVPOINT_WEAPON_STORE_OUTSIDE, SYNC_ALL) 
  2086.    marker_remove_navpoint( NAVPOINT_HQ, SYNC_ALL ) 
  2087. 	 
  2088. 	if Goo_trigger then 
  2089. 		trigger_enable(Goo_trigger, false) 
  2090. 	end 
  2091. 	 
  2092. 	inv_weapon_remove_temporary(Geiger_player, WEAPON_GEIGER_COUNTER) 
  2093.  
  2094. 	group_destroy(GROUP_GOO) 
  2095.  
  2096. 	if alarm_foley_local ~= -1 then 
  2097. 		audio_stop(alarm_foley_local) 
  2098. 	end 
  2099. 	if alarm_foley_remote ~= -1 then 
  2100. 		audio_stop(alarm_foley_remote) 
  2101. 	end 
  2102.  
  2103. 	notoriety_reset( "Brotherhood" ) 
  2104. 	notoriety_reset( NUKE_SECURITY ) 
  2105.    notoriety_force_no_spawn( NUKE_SECURITY, false ) 
  2106.    notoriety_force_no_spawn( "Ultor", false ) 
  2107.    player_force_vehicle_seat( LOCAL_PLAYER, -1 ) 
  2108.    if ( coop_is_active() ) then 
  2109.       player_force_vehicle_seat( REMOTE_PLAYER, -1 ) 
  2110.    end 
  2111.    bh03_set_vehicle_interaction_allowed( true ) 
  2112.    -- Return helicopter jitter to the default. 
  2113.    helicopters_set_jitter_override() 
  2114.  
  2115. 	if ( Players_have_heli_weapons ) then 
  2116. 		inv_weapon_remove_temporary( LOCAL_PLAYER, SAW_NAME ) 
  2117. 		if ( coop_is_active() ) then 
  2118. 			inv_weapon_remove_temporary( REMOTE_PLAYER, SAW_NAME )  
  2119. 		end 
  2120. 	end 
  2121.    inv_weapon_enable_or_disable_all_slots( true ) 
  2122.     
  2123.    persona_override_group_stop( COP_PERSONAS, POT_SITUATIONS[POT_ATTACK] ) 
  2124.  
  2125. --	notoriety_set_max( "Police", MAX_NOTORIETY_LEVEL ) 
  2126. --	notoriety_set_max( "Brotherhood", MAX_NOTORIETY_LEVEL ) 
  2127.  
  2128. 	bh03_stop_alarms() 
  2129.  
  2130.    mid_mission_phonecall_reset() 
  2131.  
  2132.    if ( vehicle_exists( ESCAPE_HELICOPTER ) and vehicle_is_destroyed( ESCAPE_HELICOPTER ) == false ) then 
  2133.       if ( character_is_in_vehicle( LOCAL_PLAYER, ESCAPE_HELICOPTER ) or 
  2134.            character_is_in_vehicle( REMOTE_PLAYER, ESCAPE_HELICOPTER ) ) then 
  2135.          group_destroy( ESCAPE_HELICOPTER_GROUP ) 
  2136.  
  2137.          if ( coop_is_active() ) then 
  2138.             teleport( REMOTE_PLAYER, IN_HELI_TELEPORT_LOCATIONS[REMOTE_PLAYER], true ) 
  2139.          end 
  2140.          teleport( LOCAL_PLAYER, IN_HELI_TELEPORT_LOCATIONS[LOCAL_PLAYER], true ) 
  2141.       end 
  2142.    end 
  2143.  
  2144.    if ( Controls_disabled ) then 
  2145.       player_controls_enable( LOCAL_PLAYER ) 
  2146.       if ( coop_is_active() ) then 
  2147.          player_controls_enable( REMOTE_PLAYER ) 
  2148.       end 
  2149.    end 
  2150.  
  2151.    turn_vulnerable( LOCAL_PLAYER ) 
  2152.    if ( coop_is_active() ) then 
  2153.       turn_vulnerable( REMOTE_PLAYER ) 
  2154.    end 
  2155.    mission_cleanup_maybe_reenable_player_controls() 
  2156.    parking_spot_enable( HELICOPTER_PARKING_SPAWN, true ) 
  2157. 	if ( vehicle_exists( END_COURTESY_CAR ) ) then 
  2158. 		release_to_world(END_COURTESY_CAR) 
  2159. 	end 
  2160. end 
  2161.  
  2162. function bh03_success() 
  2163. end 
  2164.