sr2lua/bh08.lua

  1. -- bh08.lua 
  2. -- SR2 mission script 
  3. -- 3/28/07 
  4.  
  5. -- DEBUG FLAGS 
  6. 	DEBUG_BOAT_PATHFINDING			= false 
  7.  
  8. -- Groups -- 
  9. 	GROUP_BUSES =						"bh08_$buses" 
  10. 	GROUP_BOATS =						"bh08_$boats" 
  11. 	GROUP_PLAYER_VEHICLES =			"bh08_$player_vehicles" 
  12. 	GROUP_PLAYER_VEHICLES_COOP =	"bh08_$player_vehicles_coop" 
  13. 	GROUP_COURTESY_CAR =				"bh08_$courtesy_car" 
  14. 	GROUP_COURTESY_CAR_COOP =		"bh08_$courtesy_car_coop" 
  15. 	GROUP_ATTACK_HELIS =				"bh08_$boat_helis_attack" 
  16. 	GROUP_NORMAL_HELIS =				"bh08_$boat_helis_normal" 
  17.  
  18. -- Navpoints -- 
  19. 	NAV_LOCAL_START =					"bh08_$n000" 
  20. 	NAV_REMOTE_START =				"bh08_$n001" 
  21. 	NAV_BUS_ROUTE =					{{"bh08_$n002", "bh08_$n003", "bh08_$n004", "bh08_$n005", "bh08_$n006", "bh08_$n007", "bh08_$n008"}, 
  22. 											{{"bh08_$n002", "bh08_$n003", "bh08_$n004"}, {"bh08_$n012", "bh08_$n013", "bh08_$n014", "bh08_$n015", "bh08_$n008"}}, 
  23. 											{"bh08_$n002", "bh08_$n003", "bh08_$n004", "bh08_$n005", "bh08_$n006", "bh08_$n007", "bh08_$n008"}} 
  24. 	NAV_BUS_DEST =						"bh08_$n008" 
  25. 	NAV_BOAT_ROUTE =					{	{"bh08_$n017", "bh08_$n016", "bh08_$n020", "bh08_$n021", "bh08_$n024", "bh08_$n009"}, 
  26. 												{"bh08_$n018", "bh08_$n019", "bh08_$n011", "bh08_$n022", "bh08_$n010", "bh08_$n009"}} 
  27. 	NAV_BOAT_DEST =					"bh08_$n009" 
  28. 	NAVPOINT_FINISH_LOCAL =			"bh08_$n025" 
  29. 	NAVPOINT_FINISH_REMOTE =		"bh08_$n026" 
  30.  
  31. -- Vehicles -- 
  32. 	VEH_BUS =							{"bh08_$v000", "bh08_$v001", "bh08_$v002"} 
  33. 	VEH_BUS_ESCORT =					{"bh08_$v003", "bh08_$v004", "bh08_$v005"} 
  34. 	VEH_BOAT =							{"bh08_$v006", "bh08_$v007", "bh08_$v008", "bh08_$v009"} 
  35. 	VEH_PLAYER =						{"bh08_$v010", "bh08_$v011"} 
  36. 	VEH_PLAYER_BOAT =					"bh08_$v011" 
  37. 	VEH_PLAYER_PLANE=					"bh08_$v010" 
  38. 	VEH_PLAYER_COOP =					{"bh08_$v017"} 
  39. 	VEH_BOAT_NORMAL_HELI=			{"bh08_$v020", "bh08_$v021"} 
  40. 	VEH_BOAT_ATTACK_HELI=			{"bh08_$v012", "bh08_$v013"} 
  41. 	VEH_BOAT_ESCORT_BOAT =			{"bh08_$v014", "bh08_$v015", "bh08_$v016"} 
  42.  
  43. -- Characters -- 
  44. 	CHAR_BUSLOAD =						{{"bh08_$c000", "bh08_$c001", "bh08_$c002", "bh08_$c003", "bh08_$c004", "bh08_$c005"}, 
  45. 											{"bh08_$c006", "bh08_$c007", "bh08_$c008", "bh08_$c009", "bh08_$c010", "bh08_$c011"}, 
  46. 											{"bh08_$c012", "bh08_$c013", "bh08_$c014", "bh08_$c015", "bh08_$c016", "bh08_$c017"}} 
  47.  
  48. 	CHAR_BUS_ESCORT =					{{"bh08_$c018", "bh08_$c019"}, 
  49. 											{"bh08_$c020", "bh08_$c021"}, 
  50. 											{"bh08_$c022", "bh08_$c023"}} 
  51.  
  52. --[[ 
  53. 	CHAR_BOATLOAD =					{{"bh08_$c024", "bh08_$c026"}, 
  54. 											{"bh08_$c029", "bh08_$c031"}, 
  55. 											{"bh08_$c034", "bh08_$c036"}, 
  56. 											{"bh08_$c039", "bh08_$c041"}} 
  57. ]] 
  58.  
  59. 	CHAR_BOATLOAD =					{{"bh08_$c024"}, 
  60. 											{"bh08_$c029"}, 
  61. 											{"bh08_$c034"}, 
  62. 											{"bh08_$c039"}} 
  63.  
  64. 	CHAR_BOAT_ATTACK_HELI =			{{"bh08_$c050"}, 
  65. 											{"bh08_$c054"}} 
  66.  
  67. 	CHAR_BOAT_NORMAL_HELI =			{{"bh08_$c058"}, 
  68. 											{"bh08_$c059"}} 
  69.  
  70. 	CHAR_BOAT_ESCORT_BOAT =			{{"bh08_$c044", "bh08_$c045"}, 
  71. 											{"bh08_$c046", "bh08_$c047"}, 
  72. 											{"bh08_$c048", "bh08_$c049"}} 
  73.  
  74. -- Checkpoints -- 
  75. 	CHECKPOINT_BUSES_DESTROYED =	"bh08_checkpoint_buses_destroyed" 
  76. 	CHECKPOINT_IN_BOAT_OR_FLIER=	"bh08_checkpoint_boat_or_flier" 
  77.  
  78. -- Text -- 
  79. 	--Three Busloads of Prisoners are en route to the Brotherhood Gang hideout. Kill them before they're set free. 
  80. 	TEXT_DESTROY_THE_BUSES =		"bh08_destroy_the_buses" 
  81. 	-- Prison Buses Destroyed: %s/%s 
  82. 	TEXT_BUSES_DESTROYED =			"bh08_buses_destroyed" 
  83. 	-- More Brotherhood Prisoners are being transfered from the Prison to the Mainland. Kill them before they're set free. 
  84. 	TEXT_DESTROY_THE_BOATS =		"bh08_destroy_the_boats" 
  85. 	-- Prison Boats Destroyed: %s/%s 
  86. 	TEXT_BOATS_DESTROYED =			"bh08_boats_destroyed" 
  87. 	-- A Boat is available for use at the Apartment Dock and a Fighter is available at the Airport. 
  88. 	TEXT_FIGHTER_AVAILABLE =		"bh08_fighter_available" 
  89. 	-- A Boat is available for use at the Apartment Dock and two Fighters are available at the Airport. 
  90. 	TEXT_FIGHTER_AVAILABLE_COOP = "bh08_fighter_available_coop" 
  91. 	-- A Prison Bus reached its destination. 
  92. 	TEXT_BUS_REACHED_DEST =			"bh08_bus_reached_destination" 
  93. 	-- A Prison Boat reached its destination. 
  94. 	TEXT_BOAT_REACHED_DEST =		"bh08_boat_reached_destination" 
  95. 	-- The Prison Buses are halfway to the Brotherhood hideout. 
  96. 	TEXT_BUS_HALF_WAY =				"bh08_bus_half_way" 
  97. 	-- A Prison Bus is almost to the Brotherhood hideout. 
  98. 	TEXT_BUS_ALMOST_THERE =			"bh08_bus_almost_there" 
  99.  
  100. 	-- Find a vehicle to intercept the [format][color:red]prison boats[/format] 
  101. 	BH08_FIND_VEHICLE		= "bh08_find_vehicle" 
  102. 	-- One [format][color:red]bus[/format] remains 
  103. 	BH08_1_BUS_REMAINING = "bh08_1_bus" 
  104. 	-- Two [format][color:red]buses[/format] remain 
  105. 	BH08_2_BUS_REMAINING = "bh08_2_bus" 
  106. 	-- One [format][color:red]boat[/format] remains 
  107. 	BH08_1_BOATS_REMAINING = "bh08_1_boat" 
  108. 	-- Two [format][color:red]boats[/format] remain 
  109. 	BH08_2_BOATS_REMAINING = "bh08_2_boats" 
  110. 	-- Three [format][color:red]boats[/format] remain 
  111. 	BH08_3_BOATS_REMAINING = "bh08_3_boats"  
  112. 	-- A [format][color:red]boat[/format] is almost at the dropoff 
  113. 	BH08_BOAT_ALMOST_THERE  = "bh08_almost_there" 
  114.  
  115. -- Threads -- 
  116. 	THREAD_BOAT_ESCORT =				{-1, -1, -1} 
  117.  
  118. -- Cutscenes -- 
  119. 	CUTSCENE_IN =						"br08-1.bik" 
  120. 	CUTSCENE_OUT =						"br08-2.bik" 
  121.  
  122. -- Other -- 
  123. 	IN_COOP =							false 
  124. 	Bus_reached_dest =				false 
  125. 	Buses_destroyed =					0 
  126. 	INITIAL_NUM_BUSES =				sizeof_table(VEH_BUS) 
  127. 	Boats_destroyed =					0 
  128. 	INITIAL_NUM_BOATS =				sizeof_table(VEH_BOAT) 
  129. 	BOAT_DESTINATION_DISTANCE =	15 
  130.  
  131. 	PLAYER_SYNC		=	{	[LOCAL_PLAYER]	= SYNC_LOCAL, 
  132. 								[REMOTE_PLAYER] = SYNC_REMOTE, 
  133. 							} 
  134.  
  135. 	OTHER_PLAYER	=	{	[LOCAL_PLAYER]	= REMOTE_PLAYER, 
  136. 								[REMOTE_PLAYER] = LOCAL_PLAYER, 
  137. 							} 
  138.  
  139. 	HELI_ESCORT_TARGET_INDICES = {1, 4} 
  140. 	BOAT_DELAYS	= { 0, 0, 10, 10} 
  141. 	BOAT_ROUTES = {2, 1, 2, 1} 
  142. 	VEHICLE_INVULNERABILITY_S = 15 
  143. 	MODIFIED_BOAT_HEALTH = 9000 
  144. 	BUS_MAX_SPEED = 25 
  145. 	BOAT_MAX_SPEED = 25 
  146. 	Boat_objective_sync				= -1 
  147.  
  148. 	-- Applied to pathfinding delays to keep vehicles further apart in co-op. Otherwise, syching can 
  149. 	-- cause the vehicles to interpenetrate one another. 
  150. 	COOP_PATHFIND_DELAY_FACTOR = 2.5 
  151.  
  152. -- Start the mission 
  153. function bh08_start(bh08_checkpoint, is_restart) 
  154.  
  155. 	if (bh08_checkpoint == MISSION_START_CHECKPOINT) then 
  156.  
  157. 		local start_groups = {GROUP_COURTESY_CAR, GROUP_BUSES} 
  158. 		if (coop_is_active()) then 
  159. 			start_groups = {GROUP_COURTESY_CAR, GROUP_COURTESY_CAR_COOP, GROUP_BUSES} 
  160. 		end 
  161.  
  162. 		if (is_restart) then 
  163. 			for i,group in pairs(start_groups) do 
  164. 				group_create(group, true) 
  165. 			end 
  166. 			teleport_coop(NAV_LOCAL_START, NAV_REMOTE_START) 
  167. 		else 
  168. 			cutscene_play("br08-01", start_groups, {NAV_LOCAL_START, NAV_REMOTE_START}, false) 
  169. 			for i,group in pairs(start_groups) do 
  170. 				group_show(group) 
  171. 			end 
  172. 		end 
  173.  
  174. 	end 
  175.  
  176. 	if(DEBUG_BOAT_PATHFINDING) then 
  177. 		bh08_debug_boats() 
  178. 	end 
  179.  
  180. 	bh08_initialize(bh08_checkpoint) 
  181.  
  182. 	if bh08_checkpoint == MISSION_START_CHECKPOINT then 
  183. 		bh08_the_buses() 
  184. 	else	 
  185. 		bh08_the_boats() 
  186. 	end 
  187. end 
  188.  
  189. -- Initialize the mission 
  190. function bh08_initialize(checkpoint) 
  191.  
  192. 	mission_start_fade_out(0.0) 
  193.  
  194. 	bh08_initialize_common() 
  195. 	bh08_initialize_checkpoint(checkpoint) 
  196.  
  197. 	mission_start_fade_in() 
  198.  
  199. end 
  200.  
  201. -- Do mission initialization that is common to all checkpoints 
  202. function bh08_initialize_common() 
  203.  
  204. 	-- Start trigger is hit...the activate button was hit 
  205. 	set_mission_author("Phillip Alexander and Aaron Hanson") 
  206.  
  207. 	if coop_is_active() then 
  208. 		IN_COOP = true 
  209. 	end 
  210.  
  211. 	roadblocks_enable(false) 
  212. 	spawning_boats(false) 
  213.  
  214. end 
  215.  
  216. -- Do mission initialization that is not common to all checkpoints 
  217. function bh08_initialize_checkpoint(checkpoint) 
  218.  
  219. 	if (checkpoint == MISSION_START_CHECKPOINT) then 
  220.  
  221. 		for i, bus in pairs(VEH_BUS) do 
  222. 			for j, npc in pairs(CHAR_BUSLOAD[i]) do 
  223. 				set_ignore_ai_flag(npc, true) 
  224. 			end 
  225. 		end 
  226. 		 
  227. 		for i, bus in pairs(VEH_BUS) do 
  228. 			on_vehicle_destroyed("bh08_bus_destroyed", bus) 
  229. 			--vehicle_enter_group_teleport(CHAR_BUSLOAD[i], bus) 
  230. 			vehicle_suppress_npc_exit(bus, true) 
  231. 			vehicle_disable_flee(bus, true) 
  232. 			vehicle_disable_chase(bus, true) 
  233. 			for j, npc in pairs(CHAR_BUSLOAD[i]) do 
  234. 				if j == 1 then 
  235. 					vehicle_enter_teleport(npc, bus, 0) 
  236. 					turn_invulnerable(npc) 
  237. 				else 
  238. 					vehicle_enter_teleport(npc, bus, j) 
  239. 				end 
  240. 				set_seatbelt_flag(npc, true) 
  241. 				set_cant_flee_flag(npc, true) 
  242. 				npc_combat_enable(npc, false) 
  243. 				npc_detection_enable(npc, false) 
  244. 				inv_item_remove_all(npc) 
  245. 			end 
  246. 			marker_add_vehicle(bus, MINIMAP_ICON_KILL, INGAME_EFFECT_VEHICLE_KILL, SYNC_ALL) 
  247. 		end 
  248.  
  249. 		for i, cruiser in pairs(VEH_BUS_ESCORT) do 
  250. 			vehicle_enter_group_teleport(CHAR_BUS_ESCORT[i], cruiser) 
  251. 			vehicle_suppress_npc_exit(cruiser, true) 
  252. 			vehicle_disable_flee(cruiser, true) 
  253. 			vehicle_disable_chase(cruiser, true) 
  254. 			vehicle_set_sirenlights(cruiser, true) 
  255. 			for j, npc in pairs(CHAR_BUS_ESCORT[i]) do 
  256. 				set_ignore_ai_flag(npc, true) 
  257. 				set_cant_flee_flag(npc, true) 
  258. 				npc_combat_enable(npc, true) 
  259. 			end 
  260. 			if i==1 then 
  261. 				thread_new("bh08_bus_escort", cruiser, CHAR_BUSLOAD[1][1], VEH_BUS[1]) 
  262. 			elseif i==2 then 
  263. 				thread_new("bh08_bus_escort", cruiser, CHAR_BUSLOAD[2][1], VEH_BUS[2]) 
  264. 			elseif i==3 then 
  265. 				thread_new("bh08_bus_escort", cruiser, CHAR_BUSLOAD[3][1], VEH_BUS[3]) 
  266. 			end 
  267. 		end 
  268. 	 
  269. 	end 
  270.  
  271. end 
  272.  
  273. function bh08_heli_boat_escort(heli, char, passenger_list, delay_s) 
  274.  
  275. 	local attacking_player = false 
  276.  
  277. 	if (IN_COOP) then 
  278. 		delay(delay_s * COOP_PATHFIND_DELAY_FACTOR) 
  279. 	else 
  280. 		delay(delay_s) 
  281. 	end 
  282. 	vehicle_chase(heli, char, false, false, false, false) 
  283.  
  284. 	while (not vehicle_is_destroyed(heli)) do 
  285.  
  286. 		local dist, player = get_dist_closest_player_to_object(char) 
  287. 		local should_attack_player = ( (dist < 200) or character_is_dead(char) ) 
  288. 			 
  289. 		if (should_attack_player and (not attacking_player) ) then 
  290. 			vehicle_chase(heli, player, false, false, false, false) 
  291. 			for i, npc in pairs(passenger_list) do 
  292. 				npc_combat_enable(npc, true) 
  293. 			end 
  294. 			-- Always attack for at least 30 seconds 
  295. 			delay(30) 
  296. 		elseif ((not should_attack_player) and attacking_player) then 
  297. 			for i, npc in pairs(passenger_list) do 
  298. 				npc_combat_enable(npc, false) 
  299. 			end 
  300. 			vehicle_chase(heli, char, false, false, false, false) 
  301. 		end 
  302.  
  303. 		-- No need to test this every frame 
  304. 		delay(1) 
  305. 		thread_yield() 
  306. 	end 
  307.  
  308. end 
  309.  
  310. function bh08_the_buses() 
  311.  
  312. 	mission_help_table(TEXT_DESTROY_THE_BUSES) 
  313. 	bh08_show_bus_counter() 
  314.  
  315. 	for i, bus in pairs(VEH_BUS) do 
  316. 		local slowdown_factor 
  317. 		if i == 2 then 
  318. 			thread_new("bh08_bus_route_special", bus, NAV_BUS_ROUTE[i], i-1) 
  319. 		else 
  320. 			thread_new("bh08_bus_route", bus, NAV_BUS_ROUTE[i], i-1) 
  321. 		end 
  322. 	end 
  323.  
  324. 	thread_new("bh08_bus_gps_path") 
  325. 	thread_new("bh08_bus_route_warnings") 
  326.  
  327. 	while (Buses_destroyed < INITIAL_NUM_BUSES) do 
  328. 		thread_yield() 
  329. 		if bh08_check_bus_reached_dest() then 
  330. 			bh08_failure_bus_destination() 
  331. 			break 
  332. 		end 
  333. 	end 
  334.  
  335. 	if (not bh08_check_bus_reached_dest()) then 
  336. 		mission_set_checkpoint(CHECKPOINT_BUSES_DESTROYED) 
  337. 		release_to_world(GROUP_BUSES) 
  338. 		group_destroy(GROUP_BUSES) 
  339. 		release_to_world(GROUP_COURTESY_CAR) 
  340. 		group_destroy(GROUP_COURTESY_CAR) 
  341. 		delay(2) 
  342. 		objective_text_clear(0) 
  343.  
  344. 		bh08_the_boats() 
  345. 	end 
  346.  
  347. end 
  348.  
  349. function bh08_bus_escort(cruiser, target, targets_vehicle) 
  350.  
  351. 	vehicle_chase(cruiser, target, false, false, true, true) 
  352. 	 
  353. 	while ((not vehicle_is_destroyed(cruiser)) and (not vehicle_is_destroyed(targets_vehicle)) and (not character_is_dead(target))) do 
  354. 		thread_yield() 
  355. 	end 
  356. 	 
  357. 	for i, escort_car in pairs(VEH_BUS_ESCORT) do 
  358.  
  359. 		if(cruiser == escort_car) then 
  360.  
  361. 			for j, npc in pairs(CHAR_BUS_ESCORT[i]) do 
  362. 				if (not character_is_dead(npc)) then 
  363. 					set_ignore_ai_flag(npc, false) 
  364. 					set_cant_flee_flag(npc, true) 
  365. 					npc_combat_enable(npc, true) 
  366. 				end 
  367. 			end 
  368.  
  369. 			if(not vehicle_is_destroyed(cruiser)) then 
  370. 				vehicle_suppress_npc_exit(cruiser, false) 
  371. 				vehicle_disable_chase(cruiser, false) 
  372. 				vehicle_set_sirenlights(cruiser, true) 
  373. 				local dist,player = get_dist_closest_player_to_object(cruiser) 
  374. 				vehicle_chase(cruiser, player, true, true, true, false) 
  375. 				 
  376. 			end		 
  377. 		end 
  378. 	end 
  379. end 
  380.  
  381. function bh08_bus_route(bus, route, delay_factor) 
  382. 	if(delay_factor) then 
  383. 		if (IN_COOP) then 
  384. 			delay(2 * delay_factor * COOP_PATHFIND_DELAY_FACTOR) 
  385. 		else 
  386. 			delay(2 * delay_factor) 
  387. 		end 
  388. 	end 
  389. 	vehicle_max_speed(bus, BUS_MAX_SPEED) 
  390. 	vehicle_turret_base_to(bus, route, true) 
  391. end 
  392.  
  393. function bh08_bus_route_special(bus, route, delay_factor) 
  394. 	if (IN_COOP) then 
  395. 		delay(2 * delay_factor * COOP_PATHFIND_DELAY_FACTOR) 
  396. 	else 
  397. 		delay(2 * delay_factor) 
  398. 	end 
  399. 	vehicle_max_speed(bus, BUS_MAX_SPEED) 
  400. 	vehicle_turret_base_to(bus, route[1], false) 
  401. 	vehicle_max_speed(bus, BUS_MAX_SPEED) 
  402. 	vehicle_turret_base_to(bus, route[2], true) 
  403. end 
  404.  
  405. function bh08_check_bus_reached_dest() 
  406. 	if Bus_reached_dest then 
  407. 		return true 
  408. 	end 
  409. 	for i, bus in pairs(VEH_BUS) do 
  410. 		if (not vehicle_is_destroyed(bus)) and (get_dist_vehicle_to_nav(bus, NAV_BUS_DEST) < 5) then 
  411. 			Bus_reached_dest = true 
  412. 			return true 
  413. 		end 
  414. 	end 
  415. 	return false 
  416. end 
  417.  
  418. function bh08_bus_destroyed(bus) 
  419. 	on_vehicle_destroyed("", bus) 
  420. 	marker_remove_vehicle(bus, SYNC_ALL) 
  421. 	local num_seats = vehicle_get_num_seats(bus) 
  422. 	for j, veh in pairs(VEH_BUS) do 
  423. 		if veh == bus then 
  424. 			for k, npc in pairs(CHAR_BUSLOAD[j]) do 
  425. 				set_ignore_ai_flag(npc, false) 
  426. 				turn_vulnerable(npc) 
  427. 				character_kill(npc) 
  428. 			end 
  429. 			break 
  430. 		end 
  431. 	end 
  432. 	Buses_destroyed = Buses_destroyed + 1 
  433.  
  434. 	local buses_remaining = INITIAL_NUM_BUSES - Buses_destroyed 
  435. 	if (buses_remaining == 1) then 
  436. 		mission_help_table_nag(BH08_1_BUS_REMAINING) 
  437. 	elseif (buses_remaining == 2) then 
  438. 		mission_help_table_nag(BH08_2_BUS_REMAINING) 
  439. 	end 
  440.  
  441.  
  442. 	bh08_show_bus_counter() 
  443. end 
  444.  
  445. -- Keep a GPS path to the closest bus. 
  446. function bh08_bus_gps_path() 
  447.  
  448. 	local min_gps_dist = 100 
  449. 	local gps_bus = {[LOCAL_PLAYER] = "", [REMOTE_PLAYER] = ""} 
  450.  
  451. 	-- Get the bus that the GPS should point the player to 
  452. 	local function get_new_gps_bus(player) 
  453.  
  454. 		local closest_bus = "" 
  455. 		local closest_dist = 0 
  456.  
  457. 		for i, bus in pairs(VEH_BUS) do 
  458. 			if ( not vehicle_is_destroyed(bus) ) then 
  459. 				local dist = get_dist(player, bus) 
  460. 				if( (closest_bus == "") or (dist < closest_dist) ) then 
  461. 					closest_bus = bus 
  462. 					closest_dist = dist 
  463. 				end 
  464. 			end 
  465. 		end 
  466.  
  467. 		 
  468. 		if (closest_dist >= min_gps_dist) then 
  469. 			return closest_bus 
  470. 		else 
  471. 			return "" 
  472. 		end 
  473.  
  474. 	end 
  475.  
  476. 	-- Update the gps for the input player 
  477. 	local function update_bus_gps(player) 
  478. 		local new_gps_bus = get_new_gps_bus(player) 
  479. 		if (new_gps_bus ~= gps_bus[player]) then 
  480. 			if(gps_bus[player] ~= "") then 
  481. 				mission_waypoint_remove(PLAYER_SYNC[player]) 
  482. 			end 
  483. 			gps_bus[player] = new_gps_bus 
  484. 			if(new_gps_bus ~= "") then 
  485. 				mission_waypoint_add(new_gps_bus, PLAYER_SYNC[player]) 
  486. 			end 
  487. 		end 
  488. 	end 
  489.  
  490. 	-- Update the gps for both players 
  491. 	while(Buses_destroyed < INITIAL_NUM_BUSES) do 
  492. 		update_bus_gps(LOCAL_PLAYER) 
  493. 		if(IN_COOP) then 
  494. 			update_bus_gps(REMOTE_PLAYER) 
  495. 		end 
  496. 		thread_yield() 
  497. 	end 
  498.  
  499. 	-- Clear up any existing waypoints 
  500. 	mission_waypoint_remove(SYNC_ALL) 
  501.  
  502. end 
  503.  
  504. function bh08_bus_route_warnings() 
  505. 	 
  506. 	local warning_messages =  
  507. 		{	[1] = {["dist_ratio"] = .50, ["message"] = TEXT_BUS_HALF_WAY},  
  508. 			[2] = {["dist_ratio"] = .20, ["message"] = TEXT_BUS_ALMOST_THERE}, 
  509. 		} 
  510.  
  511. 	-- Get the shortest distance between a bus and its destination 
  512. 	local function get_dist_to_destination() 
  513. 		local min_dist = -1 
  514. 		for i, bus in pairs(VEH_BUS) do 
  515. 			if (not vehicle_is_destroyed(bus)) then 
  516. 				local dist = get_dist_vehicle_to_nav(bus, NAV_BUS_DEST) 
  517. 				if( (min_dist == -1) or (dist < min_dist) ) then 
  518. 					min_dist = dist 
  519. 				end 
  520. 			end 
  521. 		end 
  522. 		return min_dist 
  523. 	end 
  524.  
  525. 	-- The initial distance to the destination 
  526. 	local initial_dist = get_dist_to_destination() 
  527.  
  528. 	-- Play each message when a bus gets close enough to the destination. 
  529. 	for i, message_info in pairs(warning_messages) do 
  530. 		local message_dist = message_info["dist_ratio"] * initial_dist 
  531. 		local current_dist = initial_dist 
  532. 		while(current_dist > message_dist) do 
  533. 			delay(1.0) 
  534. 			current_dist = get_dist_to_destination() 
  535. 		end 
  536. 		if(current_dist ~= -1) then 
  537. 			mission_help_table_nag(message_info["message"]) 
  538. 		end 
  539. 		delay(5.0) 
  540. 	end 
  541.  
  542. end 
  543.  
  544. function bh08_boat_route_warnings() 
  545. 	 
  546. 	local warning_messages =  
  547. 		{	[1] = {["dist_ratio"] = .30, ["message"] = BH08_BOAT_ALMOST_THERE},  
  548. 		} 
  549.  
  550. 	-- Get the shortest distance between a bus and its destination 
  551. 	local function get_dist_to_destination() 
  552. 		local min_dist = -1 
  553. 		for i, boat in pairs(VEH_BOAT) do 
  554. 			if (not vehicle_is_destroyed(boat)) then 
  555. 				local dist = get_dist_vehicle_to_nav(boat, NAV_BOAT_DEST) 
  556. 				if( (min_dist == -1) or (dist < min_dist) ) then 
  557. 					min_dist = dist 
  558. 				end 
  559. 			end 
  560. 		end 
  561. 		return min_dist 
  562. 	end 
  563.  
  564. 	-- The initial distance to the destination 
  565. 	local initial_dist = get_dist_to_destination() 
  566.  
  567. 	-- Play each message when a bus gets close enough to the destination. 
  568. 	for i, message_info in pairs(warning_messages) do 
  569. 		local message_dist = message_info["dist_ratio"] * initial_dist 
  570. 		local current_dist = initial_dist 
  571. 		while(current_dist > message_dist) do 
  572. 			delay(1.0) 
  573. 			current_dist = get_dist_to_destination() 
  574. 		end 
  575. 		if(current_dist ~= -1) then 
  576. 			mission_help_table_nag(message_info["message"]) 
  577. 		end 
  578. 		delay(5.0) 
  579. 	end 
  580.  
  581. end 
  582.  
  583. -- Players must destroy several boats before they can transport prisoners to  
  584. -- the mainland. 
  585. function bh08_the_boats() 
  586.  
  587. 	-- Prepare the boats 
  588. 	bh08_prepare_the_boats() 
  589.  
  590. 	-- Play the appropriate dialogue 
  591. 	local conversation_thread = thread_new("bh08_play_boat_conversation") 
  592.  
  593. 	-- Yield until at least one player has received markers for the boats 
  594. 	while( Boat_objective_sync == -1) do 
  595. 		thread_yield() 
  596. 	end 
  597.  
  598. 	-- If the conversation hasn't been received yet, eliminate the message 
  599. 	if (not Bh08_call_received) then 
  600. 		thread_kill(conversation_thread) 
  601. 		mid_mission_phonecall_reset() 
  602. 	else 
  603. 		-- Wait for the conversation thread to finish whatever its doing 
  604. 		while(not thread_check_done(conversation_thread)) do 
  605. 			thread_yield() 
  606. 		end 
  607. 	end 
  608.  
  609. 	-- Start the boat paths 
  610. 	bh08_send_the_boats() 
  611.  
  612. end 
  613.  
  614. Bh08_call_received = false 
  615. function bh08_call_received() 
  616. 	Bh08_call_received = true 
  617. end 
  618.  
  619. function bh08_play_boat_conversation() 
  620.  
  621. 	mid_mission_phonecall("bh08_call_received") 
  622. 	while( not Bh08_call_received ) do 
  623. 		thread_yield() 
  624. 	end 
  625.  
  626. 	local conversation =  
  627. 	{ 
  628. 		{"BR08_PHONECALL_L1", nil, 1}, 
  629. 		{"PLAYER_BR08_PHONECALL_L2", LOCAL_PLAYER, 1}, 
  630. 	} 
  631.  
  632. 	audio_play_conversation( conversation, INCOMING_CALL) 
  633.  
  634. 	delay(1.0) 
  635.  
  636. 	if (Boat_objective_sync ~= -1) then 
  637. 		return 
  638. 	end 
  639.  
  640. 	-- Tell the players about the courtesy vehicles, wait for them to enter 
  641. 	-- a boat, heli, or plane or to get close to the prisoner boats. 
  642. 	thread_new("bh08_ready_for_boats", LOCAL_PLAYER) 
  643. 	if(IN_COOP) then 
  644. 		thread_new("bh08_ready_for_boats", REMOTE_PLAYER) 
  645. 	end 
  646.  
  647. 	if (Boat_objective_sync ~= -1) then 
  648. 		return 
  649. 	end 
  650. 	mission_help_table_nag(BH08_FIND_VEHICLE) 
  651.  
  652. 	if (Boat_objective_sync ~= -1) then 
  653. 		return 
  654. 	end 
  655. 	delay(5) 
  656.  
  657. 	-- Display courtesy-vehicles-available message 
  658. 	-- Always use the Coop version because there is a typo in the single-player version and it is 
  659. 	-- too late to fix it. 
  660. 	if (Boat_objective_sync ~= -1) then 
  661. 		return 
  662. 	end 
  663. 	mission_help_table_nag(TEXT_FIGHTER_AVAILABLE_COOP) 
  664.  
  665.  
  666. end 
  667.  
  668. function bh08_prepare_the_boats() 
  669.  
  670. 	group_create(GROUP_BOATS, true) 
  671. 	group_create(GROUP_PLAYER_VEHICLES, true) 
  672. 	-- We're always spawning the coop vehicles in single-player as well now. 
  673. 	group_create(GROUP_PLAYER_VEHICLES_COOP, true) 
  674.  
  675. 	for i, boat in pairs(VEH_BOAT) do 
  676. 		on_vehicle_destroyed("bh08_boat_destroyed", boat) 
  677. 		vehicle_stop(boat) 
  678. 		vehicle_enter_group_teleport(CHAR_BOATLOAD[i], boat) 
  679. 		vehicle_set_sirenlights(boat, true) 
  680. 		vehicle_suppress_npc_exit(boat, true) 
  681. 		vehicle_disable_flee(boat, true) 
  682. 		vehicle_disable_chase(boat, true) 
  683. 		set_current_hit_points(boat, MODIFIED_BOAT_HEALTH) 
  684. 		vehicle_max_speed(boat, BOAT_MAX_SPEED) 
  685. 		for j, npc in pairs(CHAR_BOATLOAD[i]) do 
  686. 			set_ignore_ai_flag(npc, true) 
  687. 			set_cant_flee_flag(npc, true) 
  688. 			npc_combat_enable(npc, false) 
  689. 			npc_detection_enable(npc, false) 
  690. 			inv_item_remove_all(npc) 
  691. 		end 
  692. 	end 
  693.  
  694. 	for i, boat in pairs(VEH_BOAT_ESCORT_BOAT) do 
  695. 		vehicle_stop(boat) 
  696. 		vehicle_enter_group_teleport(CHAR_BOAT_ESCORT_BOAT[i], boat) 
  697. 		vehicle_suppress_npc_exit(boat, true) 
  698. 		vehicle_disable_flee(boat, true) 
  699. 		vehicle_set_sirenlights(boat, true) 
  700. 		for j, npc in pairs(CHAR_BOAT_ESCORT_BOAT[i]) do 
  701. 			set_cant_flee_flag(npc, true) 
  702. 			npc_combat_enable(npc, true) 
  703. 		end 
  704. 	end 
  705.  
  706. end 
  707.  
  708. function bh08_send_the_helis() 
  709.  
  710. 	-- Decide if we're sending attack helis or normal helis. 
  711. 	local send_attack_helis = false 
  712. 	if (	(get_char_vehicle_type(LOCAL_PLAYER) == VT_HELICOPTER) or 
  713. 			(get_char_vehicle_type(LOCAL_PLAYER) == VT_AIRPLANE) ) then 
  714. 		send_attack_helis = true 
  715. 	elseif (	IN_COOP and (	(get_char_vehicle_type(LOCAL_PLAYER) == VT_HELICOPTER) or 
  716. 									(get_char_vehicle_type(LOCAL_PLAYER) == VT_AIRPLANE)	)	) then 
  717. 		 
  718. 		send_attack_helis = true 
  719. 	end 
  720.  
  721. 	-- Make a group of helicopters escort the boats 
  722. 	local function heli_group_escort(group, heli_list, char_list) 
  723.  
  724. 		group_create(group, true) 
  725.  
  726. 		for i, heli in pairs(heli_list) do 
  727.  
  728. 			-- Set the helicopter to use the new ai navigation. 
  729. 			helicopter_set_dont_use_constraints(heli, true)  
  730.  
  731. 			vehicle_enter_group_teleport(char_list[i], heli) 
  732. 			vehicle_set_sirenlights(heli, true) 
  733. 			for j, npc in pairs(char_list[i]) do 
  734. 				npc_combat_enable(npc, false) 
  735. 			end 
  736. 			local boat_index = HELI_ESCORT_TARGET_INDICES[i] 
  737. 			local delay_s = BOAT_DELAYS[boat_index] 
  738. 			thread_new("bh08_heli_boat_escort", heli, CHAR_BOATLOAD[boat_index][1], char_list[i], delay_s) 
  739. 			thread_new( "bh08_vehicle_invulnerability", heli, VEHICLE_INVULNERABILITY_S + delay_s) 
  740. 		end		 
  741. 	end 
  742.  
  743. 	-- Have the appropriate group of helicopters attack 
  744. 	if(send_attack_helis) then 
  745. 		heli_group_escort(GROUP_ATTACK_HELIS, VEH_BOAT_ATTACK_HELI, CHAR_BOAT_ATTACK_HELI) 
  746. 	else  
  747. 		heli_group_escort(GROUP_NORMAL_HELIS, VEH_BOAT_NORMAL_HELI, CHAR_BOAT_NORMAL_HELI) 
  748. 	end 
  749.  
  750. end 
  751.  
  752. function bh08_send_the_boats() 
  753.  
  754. 	thread_new("bh08_player_swimming_watch")	 
  755. 	thread_new("bh08_send_the_helis") 
  756. 	thread_new("bh08_bus_route_warnings") 
  757.  
  758. 	for i, boat in pairs(VEH_BOAT) do 
  759. 		thread_new(	"bh08_boat_route",  
  760. 						VEH_BOAT[i],  
  761. 						VEH_BOAT_ESCORT_BOAT[i],  
  762. 						CHAR_BOATLOAD[i][1],  
  763. 						NAV_BOAT_ROUTE[BOAT_ROUTES[i]],  
  764. 						BOAT_DELAYS[i]) 
  765. 		thread_new( "bh08_vehicle_invulnerability", VEH_BOAT[i], VEHICLE_INVULNERABILITY_S + BOAT_DELAYS[i]) 
  766. 		thread_new( "bh08_vehicle_invulnerability", VEH_BOAT_ESCORT_BOAT[i], VEHICLE_INVULNERABILITY_S + BOAT_DELAYS[i]) 
  767. 	end 
  768.  
  769.  
  770. 	while (Boats_destroyed < INITIAL_NUM_BOATS) do 
  771. 		thread_yield() 
  772. 		if bh08_check_boat_reached_dest() then 
  773. 			bh08_failure_boat_destination() 
  774. 			break 
  775. 		end 
  776. 	end 
  777.  
  778. 	bh08_success_boats_destroyed() 
  779.  
  780. end 
  781.  
  782. function bh08_vehicle_invulnerability(vehicle, delay_s) 
  783.  
  784. 	if (vehicle) then 
  785.  
  786. 		turn_invulnerable(vehicle) 
  787. 		delay(delay_s) 
  788. 		if ( vehicle_exists(vehicle) and (not vehicle_is_destroyed(vehicle)) ) then 
  789. 			turn_vulnerable(vehicle) 
  790. 		end 
  791.  
  792. 	end 
  793.  
  794. end 
  795.  
  796. function bh08_mark_the_boats(player) 
  797.  
  798. 	-- Update the boat objective sync 
  799. 	if (Boat_objective_sync == PLAYER_SYNC[OTHER_PLAYER]) then 
  800. 		Boat_objective_sync = SYNC_ALL 
  801. 	else 
  802. 		-- When the boats are marked for the first person start showing the x/y count for __both__ players 
  803. 		Boat_objective_sync = PLAYER_SYNC[player] 
  804. 		objective_text(0, TEXT_BOATS_DESTROYED, Boats_destroyed, INITIAL_NUM_BOATS, SYNC_ALL) 
  805. 		bh08_show_boat_counter() 
  806. 	end 
  807.  
  808. 	-- Tell the player to destroy the prison boats 
  809. 	mission_help_table(TEXT_DESTROY_THE_BOATS, "", "", PLAYER_SYNC[player]) 
  810.  
  811. 	for i, boat in pairs(VEH_BOAT) do 
  812. 		if (not vehicle_is_destroyed(boat)) then 
  813. 			marker_add_vehicle(boat, MINIMAP_ICON_KILL, INGAME_EFFECT_VEHICLE_KILL, PLAYER_SYNC[player]) 
  814. 		end 
  815. 	end 
  816.  
  817. end 
  818.  
  819. -- Wait for a player to enter a boat, plane or helicopter. (or to get too close to the prison boats) 
  820. function bh08_ready_for_boats(player) 
  821.  
  822. 	-- Get the sync type for this player 
  823. 	local sync = PLAYER_SYNC[player] 
  824.  
  825. 	-- Define a couple of useful functions 
  826.  
  827. 		-- Is the player in a boat or flying vehicle or close enough? 
  828. 		local function player_ready_for_boats() 
  829. 			return (	(get_char_vehicle_type(player) == VT_HELICOPTER) or 
  830. 						(get_char_vehicle_type(player) == VT_AIRPLANE) or 
  831. 						(get_char_vehicle_type(player) == VT_WATERCRAFT) or 
  832. 						(get_dist(player, VEH_BOAT[1]) < 500) )  
  833. 		end 
  834.  
  835. 		-- Update the gps path. 
  836. 		local gps_target = "" 
  837. 		local function update_waypoint() 
  838. 			local new_target = "" 
  839. 			if(get_dist (player, VEH_PLAYER_PLANE) < 500) then 
  840. 				new_target = VEH_PLAYER_PLANE 
  841. 			else 
  842. 				new_target = VEH_PLAYER_BOAT 
  843. 			end 
  844. 			if(gps_target ~= new_target) then 
  845. 				gps_target = new_target 
  846. 				mission_waypoint_remove(sync) 
  847. 				mission_waypoint_add(new_target, sync) 
  848. 			end 
  849. 		end	 
  850.  
  851. 	-- If the player isn't in an appropriate vehicle, have them enter one. 
  852. 	if( not player_ready_for_boats()) then 
  853.  
  854. 		-- Mark courtesy vehicles 
  855. 		for i, veh in pairs(VEH_PLAYER) do 
  856. 			marker_add_vehicle(veh, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_INTERACT, sync) 
  857. 		end 
  858. 		for i, veh in pairs(VEH_PLAYER_COOP) do 
  859. 			marker_add_vehicle(veh, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_INTERACT, sync) 
  860. 		end 
  861.  
  862. 		-- Update the gps path whenever it changes 
  863. 		while (not player_ready_for_boats()) do 
  864. 			update_waypoint() 
  865. 			thread_yield() 
  866. 		end 
  867.  
  868. 		-- Player has entered a vehicle of the appropriate type, remove courtesy vehicle markers. 
  869. 		mission_waypoint_remove(sync) 
  870. 		for i, veh in pairs(VEH_PLAYER) do 
  871. 			marker_remove_vehicle(veh, sync) 
  872. 		end 
  873. 		for i, veh in pairs(VEH_PLAYER_COOP) do 
  874. 			marker_remove_vehicle(veh, sync) 
  875. 		end 
  876.  
  877. 	end 
  878.  
  879. 	-- Add kill markers to the boats 
  880. 	bh08_mark_the_boats(player) 
  881.  
  882. end 
  883.  
  884. function bh08_player_swimming_watch() 
  885. 	while 1 do 
  886. 		thread_yield() 
  887. 		if character_is_swimming(LOCAL_PLAYER) then 
  888. 			local close_boat = bh08_police_boat_near_player() 
  889. 			if (close_boat ~= nil) then 
  890. 				--thread_kill(THREAD_BOAT_ESCORT[close_boat]) 
  891. 				local THREAD_CHASE = thread_new("vehicle_chase", VEH_BOAT_ESCORT_BOAT[close_boat], LOCAL_PLAYER) 
  892. 				while character_is_swimming(LOCAL_PLAYER) do 
  893. 					thread_yield() 
  894. 				end 
  895. 				thread_kill(THREAD_CHASE) 
  896. 				--THREAD_BOAT_ESCORT[close_boat] = thread_new("bh08_boat_route", VEH_BOAT_ESCORT_BOAT[close_boat], close_boat-1) 
  897. 			end 
  898. 		end 
  899. 	end 
  900. end 
  901.  
  902. function bh08_police_boat_near_player() 
  903. 	for i, boat in pairs(VEH_BOAT_ESCORT_BOAT) do 
  904. 		if (not vehicle_is_destroyed(boat)) and (get_dist_char_to_vehicle(LOCAL_PLAYER, boat) <= 100) then 
  905. 			return i 
  906. 		end 
  907. 	end 
  908. 	return nil 
  909. end 
  910.  
  911. function bh08_boat_route(boat, escort_boat, chase_target, route, delay_time) 
  912. 	if(delay_time) then 
  913. 		if (IN_COOP) then 
  914. 			delay(delay_time * COOP_PATHFIND_DELAY_FACTOR)		 
  915. 		else 
  916. 			delay(delay_time) 
  917. 		end 
  918. 	end 
  919. 	if(escort_boat) then	 
  920. 		vehicle_chase(escort_boat, chase_target, false, false, false, false) 
  921. 	end 
  922. 	vehicle_pathfind_to(boat, route, true, false) 
  923. 	if(escort_boat and (not vehicle_is_destroyed(escort_boat))) then 
  924. 		release_to_world(escort_boat) 
  925. 	end 
  926. end 
  927.  
  928. function bh08_check_boat_reached_dest() 
  929. 	for i, boat in pairs(VEH_BOAT) do 
  930. 		if (not vehicle_is_destroyed(boat)) and (get_dist_vehicle_to_nav(boat, NAV_BOAT_DEST) < BOAT_DESTINATION_DISTANCE) then 
  931. 			return true 
  932. 		end 
  933. 	end 
  934. 	return false 
  935. end 
  936.  
  937. function bh08_boat_destroyed(boat) 
  938. 	on_vehicle_destroyed("", boat) 
  939. 	marker_remove_vehicle(boat, SYNC_ALL) 
  940. 	local num_seats = vehicle_get_num_seats(boat) 
  941. 	for j, veh in pairs(VEH_BOAT) do 
  942. 		if veh == boat then 
  943. 			for k, npc in pairs(CHAR_BOATLOAD[j]) do 
  944. 				if(not character_is_dead(npc)) then 
  945. 					character_kill(npc) 
  946. 				end 
  947. 			end 
  948. 			break 
  949. 		end 
  950. 	end 
  951. 	Boats_destroyed = Boats_destroyed + 1 
  952. 	local boats_remaining = (INITIAL_NUM_BOATS - Boats_destroyed) 
  953.  
  954. 	if (boats_remaining == 1) then 
  955. 		mission_help_table_nag(BH08_1_BOATS_REMAINING) 
  956. 	elseif (boats_remaining  == 2) then 
  957. 		mission_help_table_nag(BH08_2_BOATS_REMAINING) 
  958. 	elseif (boats_remaining == 3) then 
  959. 		mission_help_table_nag(BH08_3_BOATS_REMAINING) 
  960. 	end 
  961.  
  962. 	bh08_show_boat_counter() 
  963. 	notoriety_set("Brotherhood", 4) 
  964. end 
  965.  
  966. function bh08_show_bus_counter() 
  967. 	objective_text(0, TEXT_BUSES_DESTROYED, Buses_destroyed, INITIAL_NUM_BUSES) 
  968. end 
  969.  
  970. function bh08_show_boat_counter() 
  971. 	-- We always show the boat count to both players... even the one that hasn't yet been 
  972. 	-- instructed to destroy the boats. 
  973. 	objective_text(0, TEXT_BOATS_DESTROYED, Boats_destroyed, INITIAL_NUM_BOATS, SYNC_ALL) 
  974. end 
  975.  
  976. function bh08_failure_bus_destination() 
  977. 	delay(3) 
  978. 	mission_end_failure("bh08", TEXT_BUS_REACHED_DEST) 
  979. end 
  980.  
  981. function bh08_failure_boat_destination() 
  982. 	delay(3) 
  983. 	mission_end_failure("bh08", TEXT_BOAT_REACHED_DEST) 
  984. end 
  985.  
  986. function bh08_success_boats_destroyed() 
  987. 	-- release_to_world(VEH_PLAYER_PLANE) 
  988. 	-- release_to_world(VEH_PLAYER_COOP) 
  989. 	-- release_to_world(VEH_PLAYER_BOAT) 
  990. 	delay(3) 
  991. 	mission_end_success("bh08", "br08-02", { NAVPOINT_FINISH_LOCAL, NAVPOINT_FINISH_REMOTE }) 
  992. end 
  993.  
  994. function bh08_cleanup() 
  995.  
  996. 	-- Get rid of the any mid-mission phone calls 
  997. 	mid_mission_phonecall_reset() 
  998.  
  999. 	-- Fix up spawning 
  1000. 	spawning_boats(true) 
  1001. 	roadblocks_enable(true) 
  1002.  
  1003. end 
  1004.  
  1005. function bh08_success() 
  1006. 	-- Called when the mission has ended with success 
  1007.  
  1008. 	-- Post the news event 
  1009. 	radio_post_event("JANE_NEWS_BR08", true) 
  1010.  
  1011. 	--bink_play_movie(CUTSCENE_OUT) 
  1012. end 
  1013.  
  1014. -- DEBUG 
  1015.  
  1016. function bh08_debug_boats() 
  1017.  
  1018. 	group_create(GROUP_BOATS, true) 
  1019.  
  1020. 	for i, boat in pairs(VEH_BOAT) do 
  1021. 		if (i ~= 1) then 
  1022. 			vehicle_detonate(boat) 
  1023. 		end 
  1024. 	end 
  1025.  
  1026. 	local boat = VEH_BOAT[1] 
  1027.  
  1028. 	--for i, boat in pairs(VEH_BOAT) do 
  1029. 		on_vehicle_destroyed("bh08_boat_destroyed", boat) 
  1030. 		vehicle_enter_group_teleport(CHAR_BOATLOAD[1], boat) 
  1031. 		vehicle_set_sirenlights(boat, true) 
  1032. 		vehicle_suppress_npc_exit(boat, true) 
  1033. 		vehicle_disable_flee(boat, true) 
  1034. 		vehicle_disable_chase(boat, true) 
  1035. 		set_current_hit_points(boat, 7500) 
  1036. 		for j, npc in pairs(CHAR_BOATLOAD[1]) do 
  1037. 			set_ignore_ai_flag(npc, true) 
  1038. 			set_cant_flee_flag(npc, true) 
  1039. 			npc_combat_enable(npc, false) 
  1040. 			npc_detection_enable(npc, false) 
  1041. 			inv_item_remove_all(npc) 
  1042. 		end 
  1043. 		marker_add_vehicle(boat, MINIMAP_ICON_KILL, INGAME_EFFECT_VEHICLE_KILL, SYNC_ALL) 
  1044.  
  1045. 		thread_new(	"bh08_boat_route",  
  1046. 						boat,  
  1047. 						nil,  
  1048. 						nil,  
  1049. 						NAV_BOAT_ROUTE[2], 
  1050. 						0) 
  1051.  
  1052. 	while(true) do 
  1053. 		thread_yield() 
  1054. 	end 
  1055.  
  1056. end 
  1057.