sr2lua/tss01.lua

  1. -- tss01.lua 
  2. -- SR2 mission script 
  3. -- 04/25/08 
  4.  
  5. -- Global Variables -- 
  6.  
  7. 	-- This factor is applied to player damage in single player.  
  8. 	SINGLE_PLAYER_DAMAGE_MULTIPLIER = 0.50 
  9.  
  10. 	-- This factor is applied to player damage in co-op. 
  11. 	COOP_DAMAGE_MULTIPLIER = 0.75 
  12.  
  13. 	-- German builds don't have a doctor 
  14. 	DOCTOR_ALLOWED = (build_get_build_type() ~= BUILD_TYPE_GERMAN) 
  15. 	 
  16. 	--  
  17. 	LISBON_TWEAKS_ENABLED = false 
  18.  
  19. 	-- In coop, NPC hit points are increased by this factor 
  20. 	COOP_NPC_HP_MULTIPLIER	= 1.5 
  21.  
  22. 	-- When a player enters a vehicle, its max hit points are increased by this factor: 
  23. 	PLAYER_VEHICLE_HIT_POINT_FACTOR = 5.0 
  24. 	BULLHORN_DELAY_RANGE = {15,25} 
  25. 	LAND_BULLHORN_DELAY_RANGE = {20,35} 
  26. 	MAX_BULLHORN_DIST = 100 
  27.  
  28. 	COOP_SPAWNS_DISABLED = true 
  29.  
  30. 	-- A factor applied to the max hit points of the player's boat in the turret sequence. 
  31. 	HIGH_SEAS_VEHICLE_HIT_POINTS = 5000 
  32.  
  33. 	-- The min delay between Carlos's boat-takes-damage lines in the turret sequence 
  34. 	CARLOS_BOAT_DAMAGE_LINE_DELAY_MIN_S = 20 
  35. 	-- The max delay between Carlos's boat-takes-damage lines in the turret sequence 
  36. 	CARLOS_BOAT_DAMAGE_LINE_DELAY_MAX_S = 25 
  37. 	-- The min delay between Carlos's attack lines in the turret sequence 
  38. 	CARLOS_BOAT_ATTACK_LINE_DELAY_MIN_S = 10 
  39.  
  40. -- The initial doors the player(s) have to interact with 
  41. Tss01_doors								= {"tss01_PI_jail_MeshMover080", "tss01_PI_jail_MeshMover110",  
  42. 												"tss01_PI_jail_MeshMover100", "tss01_PI_vkp_jail_FDoor030"} 
  43. Num_tss01_doors						= sizeof_table(Tss01_doors) 
  44.  
  45. -- These doors are locked the entire mission 
  46. Tss01_locked_doors					= {"tss01_PI_jaildr_MeshMover030", "tss01_JailDoor530", "tss01_GateMM020",  
  47. 												"tss01_GateMM030", "tss01_GateMM040", "tss01_GateMM050", 
  48. 												"tss01__pi_jail_meshmover12000"} 
  49. Num_tss01_locked_doors				= sizeof_table(Tss01_locked_doors) 
  50.  
  51. -- This doors are reset if the mission is failed... 
  52. Tss01_reset_doors						= {"tss01_JailDoor470", "tss01_JailDoor280", "tss01_PI_vkp_jail_FDoor080",  
  53. 												"tss01_PI_vkp_jail_FDoor100", "tss01_JailDoor320", "tss01_JailDoor080",  
  54. 												"tss01_PI_vkp_jail_FDoor050"} 
  55. Num_tss01_reset_doors				= sizeof_table(Tss01_reset_doors) 
  56.  
  57. -- This will do the initial open if the player falls off so he can't see it 
  58. Tss01_door_set_1						= {"tss01_JailDoor320", "tss01_JailDoor080", "tss01_$MMcourtyard_door"} 
  59. -- Once the player falls off, these doors need to be opened 
  60. Tss01_door_set_2						= {"tss01_JailDoor470", "tss01_JailDoor280", "tss01_PI_vkp_jail_FDoor080",  
  61. 												"tss01_PI_vkp_jail_FDoor100"} 
  62. Num_tss01_door_set_1					= sizeof_table(Tss01_door_set_1) 
  63. Num_tss01_door_set_2					= sizeof_table(Tss01_door_set_2) 
  64.  
  65. --Tss01_alarm_ext_pos					= {"tss01_$alarm1", "tss01_$alarm2", "tss01_$alarm3"} 
  66. Tss01_alarm_ext_pos					= {"tss01_$alarm1", "tss01_$alarm2"} 
  67. Tss01_audio_ext_inst					= {0, 0} 
  68. Num_tss01_alarm_ext_pos				= sizeof_table(Tss01_alarm_ext_pos) 
  69.  
  70. Tss01_prisoner_audio_ext_pos		= {"tss01_$n137", "tss01_$n138"} 
  71. Tss01_audio_prisoner_ext_inst		= {0, 0} 
  72. Num_tss01_prisoner_ext_pos			= sizeof_table(Tss01_prisoner_audio_ext_pos) 
  73.  
  74. Tss01_prisoner_audio_int_pos		= {"tss01_$n139", "tss01_$n140"} 
  75. Tss01_audio_prisoner_int_inst		= {0, 0} 
  76. Num_tss01_prisoner_int_pos			= sizeof_table(Tss01_prisoner_audio_int_pos) 
  77.  
  78. Tss01_alarm_int_pos					= {"tss01_$alarm4", "tss01_$alarm5", "tss01_$alarm6", "tss01_$alarm7", "tss01_$alarm8"} 
  79. Tss01_audio_int_inst					= {0, 0, 0, 0, 0} 
  80. Num_tss01_alarm_int_pos				= sizeof_table(Tss01_alarm_int_pos) 
  81.  
  82. Tss01_loud_speaker_audio_inst					= 0 
  83. Tss01_heli_speaker_audio_inst					= 0 
  84. Tss01_boat_chase_heli_speaker_audio_inst	= 0 
  85.  
  86. Tss01_waypoints						= {"tss01_$wp01", "tss01_$wp02", "tss01_$wp03", "tss01_$wp04", "tss01_$wp05",  
  87. 												"tss01_$wp06", "tss01_$wp07", "tss01_$wp08", "tss01_$wp09", "tss01_$wp10",  
  88. 												"tss01_$wp11", "tss01_$wp12"} 
  89. Num_tss01_waypoints					= sizeof_table(Tss01_waypoints) 
  90.  
  91. Tss01_key_guards						= {"tss01_$guard1", "tss01_$guard2"} 
  92. Num_tss01_key_guards					= sizeof_table(Tss01_key_guards) 
  93.  
  94. Tss01_cafe_guards						= {"tss01_$guard3", "tss01_$guard4"} 
  95. Num_tss01_cafe_guards				= sizeof_table(Tss01_cafe_guards) 
  96.  
  97. Tss01_rooftop_guards					= {"tss01_$wp06", "tss01_$rt02", "tss01_$rt03", "tss01_$rt04"} 
  98. Num_tss01_rooftop_guards			= sizeof_table(Tss01_rooftop_guards) 
  99.  
  100. Tss01_hide_points						= {"tss01_$n126", "tss01_$n127", "tss01_$n128", "tss01_$n129", "tss01_$n130",  
  101. 												"tss01_$n131", "tss01_$n132", "tss01_$n133", "tss01_$n134", "tss01_$n135"} 
  102. Num_tss01_hide_points				= sizeof_table(Tss01_hide_points) 
  103.  
  104. Tss01_search_01						= {"tss01_$c008", "tss01_$c009"} 
  105. Num_tss01_search_01					= sizeof_table(Tss01_search_01) 
  106.  
  107. Tss01_tut_t_road						= {"tss01_$c010", "tss01_$c011"} 
  108. Num_tss01_tut_t_road					= sizeof_table(Tss01_tut_t_road) 
  109.  
  110. Tss01_fire_escape_guards			= {"tss01_$fe1", "tss01_$fe2", "tss01_$fe3"} 
  111. Num_tss01_fire_escape_guards		= sizeof_table(Tss01_fire_escape_guards) 
  112.  
  113. Tss01_courtyard_guards				= {"tss01_$cy01", "tss01_$cy02", "tss01_$cy07", "tss01_$cy08", "tss01_$cy09"} 
  114. Num_tss01_courtyard_guards			= sizeof_table(Tss01_courtyard_guards) 
  115.  
  116. Tss01_courtyard_guards_coop		= {"tss01_$cy00", "tss01_$cy04", "tss01_$cy05"} 
  117. Num_tss01_courtyard_guards_coop	= sizeof_table(Tss01_courtyard_guards_coop) 
  118.  
  119. Tss01_run_gun_part1					= {"tss01_$c041", "tss01_$c042", "tss01_$c043", "tss01_$c044"} 
  120. Num_tss01_run_gun_part1				= sizeof_table(Tss01_run_gun_part1) 
  121.  
  122. Tss01_run_gun_part2					= {"tss01_$c045", "tss01_$c046", "tss01_$c047", "tss01_$c048"} 
  123. Num_tss01_run_gun_part2				= sizeof_table(Tss01_run_gun_part2) 
  124.  
  125. Tss01_dock_guards						= {"tss01_$dg01", "tss01_$dg02", "tss01_$dg03", "tss01_$dg04", "tss01_$dg05",  
  126. 												"tss01_$dg06", "tss01_$dg07", "tss01_$dg08", "tss01_$dg09"} 
  127. Num_tss01_dock_guards				= sizeof_table(Tss01_dock_guards) 
  128.  
  129. Tss01_dock_guards_coop				= {"tss01_$dg10", "tss01_$dg11", "tss01_$dg12", "tss01_$dg13"} 
  130. Num_tss01_dock_guards_coop			= sizeof_table(Tss01_dock_guards_coop) 
  131.  
  132. Tss01_random_guards					= {"tss01_$c013", "tss01_$c014", "tss01_$c015", "tss01_$c016", "tss01_$c019",  
  133. 												"tss01_$c020", "tss01_$c021", "tss01_$c024"} 
  134. Num_tss01_random_guards				= sizeof_table(Tss01_random_guards) 
  135.  
  136. Tss01_random_guards_coop			= {"tss01_$c012", "tss01_$c017", "tss01_$c022", "tss01_$c023", "tss01_$c025"} 
  137. Num_tss01_random_guards_coop		= sizeof_table(Tss01_random_guards_coop) 
  138.  
  139. Tss01_roadblock_guards				= {"tss01_$c032", "tss01_$c033", "tss01_$c036", "tss01_$c037"} 
  140. Num_tss01_roadblock_guards			= sizeof_table(Tss01_roadblock_guards) 
  141.  
  142. Tss01_roadblock_guards_coop		= {"tss01_$c030", "tss01_$c031", "tss01_$c034", "tss01_$c035", "tss01_$c038"} 
  143. Num_tss01_roadblock_guards_coop	= sizeof_table(Tss01_roadblock_guards_coop) 
  144.  
  145. Tss01_roadblock_cars					= {"tss01_$v004", "tss01_$v005", "tss01_$v006", "tss01_$v007", 
  146. 												"tss01_$v007 (0)", "tss01_$v006 (0)", "tss01_$v014"} 
  147. Num_tss01_roadblock_cars			= sizeof_table(Tss01_roadblock_cars) 
  148.  
  149. Tss01_warden_guards					= {"tss01_$wg01", "tss01_$wg02", "tss01_$wg04", "tss01_$wg05", "tss01_$wg06",  
  150. 												"tss01_$wg07", "tss01_$wg12", "tss01_$wg13", "tss01_$wg15"} 
  151. Num_tss01_warden_guards				= sizeof_table(Tss01_warden_guards) 
  152.  
  153. Tss01_warden_rifle_guards			= {"tss01_$wg03", "tss01_$wg08", "tss01_$wg09", "tss01_$wg10",  
  154. 												"tss01_$wg11", "tss01_$wg14"} 
  155. Num_tss01_warden_rifle_guards		= sizeof_table(Tss01_warden_rifle_guards) 
  156.  
  157. Tss01_lighthouse_rifle_guards			= {"tss01_$bd03", "tss01_$bd08", "tss01_$bd09", "tss01_$bd10", "tss01_$bd11"} 
  158. Num_tss01_lighthouse_rifle_guards	= sizeof_table(Tss01_lighthouse_rifle_guards) 
  159.  
  160. Tss01_explore_triggers				= {"tss01_$ww1", "tss01_$ww2", "tss01_$ww3"} 
  161. Num_tss01_explore_triggers			= sizeof_table(Tss01_explore_triggers) 
  162.  
  163. Tss01_pursuit_guards					= {"tss01_$pg1", "tss01_$pg2", "tss01_$pg3"} 
  164. Num_tss01_pursuit_guards			= sizeof_table(Tss01_pursuit_guards) 
  165.  
  166. Tss01_boat1_table						= {"tss01_$c000", "tss01_$c000 (0)"} 
  167. Tss01_boat2_table						= {"tss01_$c000 (3)", "tss01_$c000 (4)"} 
  168. Tss01_boat3_table						= {"tss01_$c000 (7)", "tss01_$c000 (8)"} 
  169. Tss01_boat4_table						= {"tss01_$c000 (11)", "tss01_$c000 (12)"} 
  170. Tss01_boat5_table						= {"tss01_$c000 (15)", "tss01_$c000 (16)"} 
  171.  
  172. Num_tss01_boat1_table				= sizeof_table(Tss01_boat1_table) 
  173. Num_tss01_boat2_table				= sizeof_table(Tss01_boat2_table) 
  174. Num_tss01_boat3_table				= sizeof_table(Tss01_boat3_table) 
  175. Num_tss01_boat4_table				= sizeof_table(Tss01_boat4_table) 
  176. Num_tss01_boat5_table				= sizeof_table(Tss01_boat5_table) 
  177.  
  178. Tss01_heli1_table						= {"tss01_$c000 (19)", "tss01_$c000 (20)", "tss01_$c000 (21)",  
  179. 												"tss01_$c000 (22)", "tss01_$c000 (26)", "tss01_$c000 (30)"} 
  180. Tss01_heli2_table						= {"tss01_$c000 (23)", "tss01_$c000 (24)", "tss01_$c000 (25)",  
  181. 												"tss01_$c000 (31)", "tss01_$c000 (32)", "tss01_$c000 (33)"} 
  182. Tss01_heli3_table						= {"tss01_$c000 (27)", "tss01_$c000 (28)", "tss01_$c000 (29)",  
  183. 												"tss01_$c000 (34)", "tss01_$c000 (35)", "tss01_$c000 (36)"} 
  184.  
  185. Num_tss01_heli1_table				= sizeof_table(Tss01_heli1_table) 
  186. Num_tss01_heli2_table				= sizeof_table(Tss01_heli2_table) 
  187. Num_tss01_heli3_table				= sizeof_table(Tss01_heli3_table) 
  188.  
  189. Tss01_warning_issued					= {false, false} 
  190. Tss01_lights_tracking				= {false, false} 
  191. Tss01_light_track_msg				= true 
  192. Tss01_lights_tracking_carlos		= false 
  193. Tss01_boat_sequence_begun			= false 
  194.  
  195. Num_fineaim_guards_killed			= 0 
  196.  
  197. Num_in_yacht							= 0 
  198. Num_key_guards_killed				= 0 
  199.  
  200. BACK_DOOR								= 1	-- Tutorial infirmary exit 
  201. FRONT_DOOR_1							= 2	-- Skip tutorial infirmary exit 1 
  202. FRONT_DOOR_2							= 3	-- Skip tutorial infirmary exit 2 
  203. KEY_DOOR									= 4	-- Tutorial - door after first kills (requires key) 
  204.  
  205. BACK_DOOR_POS							= "tss01_$tutorial" 
  206. FRONT_DOOR_POS							= "tss01_$run_gun" 
  207.  
  208. BACK_DOOR_TRIGGER						= "tss01_$tutorial_trigger" 
  209. FRONT_DOOR_TRIGGER					= "tss01_$run_gun_trigger" 
  210.  
  211. Tss01_kill_doctor_issued			= false 
  212.  
  213. Tss01_door_msg							= {"tss01_$tutorial", "tss01_$front1", "tss01_$front2"} 
  214. Num_tss01_door_msg					= sizeof_table(Tss01_door_msg) 
  215.  
  216. IN_COOP									= false 
  217.  
  218. MISSION_CHECKPOINT_BOAT				= "boat" 
  219. MISSION_CHECKPOINT_DOCKS			= "docks" 
  220.  
  221. LOCAL_PLAYER_START					= "tss01_$local_player_start" 
  222. REMOTE_PLAYER_START					= "tss01_$remote_player_start" 
  223.  
  224. LOCAL_PLAYER_FINISH					= "tss01_$local_player_finish" 
  225. REMOTE_PLAYER_FINISH					= "tss01_$remote_player_finish" 
  226.  
  227. LOCAL_PLAYER_DEMO						= "tss01_$local_demo" 
  228. REMOTE_PLAYER_DEMO					= "tss01_$remote_demo" 
  229.  
  230. GROUP_START								= "tss01_$start" 
  231. GROUP_DOCTOR							= "tss01_$doctor" 
  232.  
  233. GROUP_ATTACK_HELI						= "tss01_$Glisbon" 
  234.  
  235. GROUP_TUT_PRISONERS					= "tss01_$Gtut_prisoners" 
  236. GROUP_NON_TUT_PRISONERS				= "tss01_$Gnon_tut_prisoners" 
  237.  
  238. GROUP_KEY_GUARDS						= "tss01_$key_guards" 
  239. GROUP_ROOFTOP							= "tss01_$rooftop" 
  240. GROUP_PURSUIT_GUARDS					= "tss01_$pursuit_guards" 
  241. GROUP_FIRE_ESCAPE						= "tss01_$fire_escape" 
  242. GROUP_TUT_SEARCH						= "tss01_$search" 
  243. GROUP_TUT_FINE_AIM					= "tss01_$fineaim" 
  244. GROUP_TUT_T_IN_ROAD					= "tss01_$tut_t" 
  245.  
  246. GROUP_CAFE_GUARDS						= "tss01_$cafe_guards" 
  247. GROUP_2ND_FLOOR						= "tss01_$2nd_floor" 
  248. GROUP_3RD_FLOOR						= "tss01_$3rd_floor" 
  249. GROUP_COURTYARD						= "tss01_$courtyard" 
  250. GROUP_COURTYARD_COOP					= "tss01_$courtyard_coop" 
  251. GROUP_SHORTBUS							= "tss01_$shortbus" 
  252. GROUP_RUN_GUN							= "tss01_$run_gun" 
  253.  
  254. GROUP_HELI								= "tss01_$heli" 
  255. GROUP_HELI_GUARDS						= "tss01_$heli_guards" 
  256. GROUP_RANDOM							= "tss01_$random" 
  257. GROUP_RANDOM_COOP						= "tss01_$random_coop" 
  258. GROUP_DOCKS								= "tss01_$docks" 
  259. GROUP_DOCKS_COOP						= "tss01_$docks_coop" 
  260. GROUP_WARDENS							= "tss01_$wardens" 
  261. GROUP_WARDENS_COOP					= "tss01_$wardens_coop" 
  262. GROUP_LIGHTHOUSE						= "tss01_$backdoor" 
  263. GROUP_LIGHTHOUSE_COOP				= "tss01_$backdoor_coop" 
  264. GROUP_ROADBLOCK						= "tss01_$roadblock" 
  265. GROUP_ROADBLOCK_COOP					= "tss01_$roadblock_coop" 
  266. GROUP_HELI_AMBUSH						= "tss01_$ambush" 
  267.  
  268. GROUP_WAVE_1							= "tss01_$wave1" 
  269. GROUP_WAVE_2							= "tss01_$wave2" 
  270. GROUP_BOAT_1							= "tss01_$boat1" 
  271. GROUP_BOAT_2							= "tss01_$boat2" 
  272. GROUP_BOAT_3							= "tss01_$boat3" 
  273. GROUP_BOAT_4							= "tss01_$boat4" 
  274. GROUP_BOAT_5							= "tss01_$boat5" 
  275. GROUP_HELI_1							= "tss01_$heli1" 
  276. GROUP_HELI_2							= "tss01_$heli2" 
  277. GROUP_HELI_3							= "tss01_$heli3" 
  278.  
  279. CHARACTER_CARLOS						= "tss01_$carlos" 
  280. CHARACTER_DOCTOR						= "tss01_$doctor" 
  281. CHARACTER_GUARD						= "tss01_$guard5" 
  282. CHARACTER_GUARD2						= "tss01_$guard10" 
  283.  
  284. GUARD_ATTACK_DOOR						= "tss01_JailDoor470" 
  285. GUARD_OPEN_DOOR						= "tss01_JailDoor280" 
  286. GURAD_KICK_DOOR_POSITION1			= "tss01_$kick" 
  287. GURAD_KICK_DOOR_POSITION2			= "tss01_$kick2" 
  288.  
  289. KEY_TRIGGER								= "tss01_$obtain_key" 
  290. JUMP_CLIMB_TRIGGER					= "tss01_$jump" 
  291. JUMP_CLIMB_TRIGGER_REPEAT			= "tss01_$climb" 
  292. CROUCH_TRIGGER							= "tss01_$crouch" 
  293. CROUCH_CARLOS_TRIGGER					= "tss01_$crouch_carlos" 
  294. MINIMAP_TRIGGER						= "tss01_$minimap" 
  295. FIRST_ROOFTOP_TRIGGER				= "tss01_$wp06b" 
  296. FINEAIM_START_TRIGGER				= "tss01_$fineaim_start" 
  297. FINEAIM_START_HELI_TRIGGER			= "tss01_$fine_aim_start_heli" 
  298. PROGRESS_HELI_TRIGGER				= "tss01_$health" 
  299. END_ROOFTOP_TRIGGER					= "tss01_$end_rooftop" 
  300. HELI_LAND_TRIGGER						= "tss01_$heli_land" 
  301. HELI_BACKUP_TRIGGER					= "tss01_$heli_backup" 
  302.  
  303. RUN_GUN_SPRINT_TRIGGER				= "tss01_$run_gun_sprint_tut" 
  304. RUN_GUN_TRIGGER_1						= "tss01_$courtyard1" 
  305. RUN_GUN_TRIGGER_2						= "tss01_$courtyard2" 
  306. RUN_GUN_TRIGGER_3						= "tss01_$courtyard3" 
  307. RUN_GUN_TRIGGER_2ND_FLOOR			= "tss01_$2nd_floor" 
  308. RUN_GUN_TRIGGER_3RD_FLOOR			= "tss01_$3rd_floor" 
  309. BRIDGE_TRIGGER							= "tss01_$bridge" 
  310. ARMORY_TRIGGER							= "tss01_$carlos_armory" 
  311. CATWALK_TRIGGER						= "tss01_$catwalk" 
  312. FALL_TRIGGER_OPEN						= "tss01_$open_doors" 
  313. FALL_TRIGGER_CLOSE					= "tss01_$no_fall" 
  314. FALLEN_TRIGGER							= "tss01_$fall_off" 
  315. COURTYARD_SHOWDOWN_TRIGGER			= "tss01_$rush" 
  316. RUN_GUN_TRIGGER_4						= "tss01_$run_gun_start" 
  317.  
  318. WARDONS_TRIGGER						= "tss01_$warden" 
  319. LIGHTHOUSE_TRIGGER					= "tss01_$lighthouse" 
  320. CANCEL_TRIGGER							= "tss01_$cancel" 
  321. HELI_AMBUSH_TRIGGER					= "tss01_$ambush_start" 
  322.  
  323. YACHT_TRIGGER_2						= "tss01_$yacht02" 
  324. YACHT_TRIGGER_3						= "tss01_$yacht03" 
  325.  
  326. PURSUIT_TRIGGER_1						= "tss01_$tgt1" 
  327. PURSUIT_TRIGGER_2						= "tss01_$tgt2" 
  328.  
  329. WAYPOINT_11_TRIGGERED				= false 
  330. TEMP_WEAPONS_GIVEN					= false 
  331.  
  332. TABLE_ALL_TRIGGERS =  
  333. {	 
  334. 	KEY_TRIGGER, JUMP_CLIMB_TRIGGER, JUMP_CLIMB_TRIGGER_REPEAT, CROUCH_TRIGGER, CROUCH_CARLOS_TRIGGER,  
  335. 	MINIMAP_TRIGGER, FIRST_ROOFTOP_TRIGGER, FINEAIM_START_TRIGGER, FINEAIM_START_HELI_TRIGGER, PROGRESS_HELI_TRIGGER,  
  336. 	END_ROOFTOP_TRIGGER, HELI_LAND_TRIGGER, HELI_BACKUP_TRIGGER, RUN_GUN_TRIGGER_1, RUN_GUN_TRIGGER_2, RUN_GUN_TRIGGER_3, 
  337. 	RUN_GUN_TRIGGER_2ND_FLOOR, RUN_GUN_TRIGGER_3RD_FLOOR, BRIDGE_TRIGGER, ARMORY_TRIGGER, CATWALK_TRIGGER, FALL_TRIGGER_OPEN, 
  338. 	FALL_TRIGGER_CLOSE, FALLEN_TRIGGER, COURTYARD_SHOWDOWN_TRIGGER, RUN_GUN_TRIGGER_4, WARDONS_TRIGGER, LIGHTHOUSE_TRIGGER, 
  339. 	CANCEL_TRIGGER, HELI_AMBUSH_TRIGGER, YACHT_TRIGGER_2, YACHT_TRIGGER_3, PURSUIT_TRIGGER_1, PURSUIT_TRIGGER_2, 
  340. 	BACK_DOOR_TRIGGER, FRONT_DOOR_TRIGGER, "tss01_$heli_crash", 
  341. } 
  342.  
  343. FINE_AIM_VEHICLE						= "tss01_$v012" 
  344. SEARCH_VEHICLE_01						= "tss01_$v002" 
  345. SEARCH_VEHICLE_02						= "tss01_$v013" 
  346. T_IN_ROAD_VEHICLE						= "tss01_$v003" 
  347.  
  348. RUN_GUN_PART1_VEHICLE				= "tss01_$v010" 
  349. RUN_GUN_PART2_VEHICLE				= "tss01_$v011" 
  350.  
  351. SPOT_LIGHT_HELI						= "tss01_$heli" 
  352. HELI_AMBUSH_VEHICLE					= "tss01_$v008" 
  353. HIGH_SEAS_VEHICLE						= "tss01_$v000" 
  354.  
  355. VEHICLE_ATTACK_HELI					= "tss01_$v015" 
  356.  
  357. DOCTOR_THREAD_HANDLE1				= INVALID_THREAD_HANDLE 
  358. DOCTOR_THREAD_HANDLE2				= INVALID_THREAD_HANDLE 
  359. ALARM_THREAD_HANDLE					= INVALID_THREAD_HANDLE 
  360. CARLOS_THREAD_HANDLE					= INVALID_THREAD_HANDLE 
  361. AMBUSH_THREAD_HANDLE					= INVALID_THREAD_HANDLE 
  362. VEHICLE_HP_THREAD_HANDLE			= INVALID_THREAD_HANDLE 
  363. CARLOS_HIDE_THREAD_HANDLE			= INVALID_THREAD_HANDLE 
  364. SWIM_DISTANCE_THREAD_HANDLE		= INVALID_THREAD_HANDLE 
  365. CARLOS_AMBUSH_THREAD_HANDLE		= INVALID_THREAD_HANDLE 
  366.  
  367. LOCAL_PLAYER_ON_2ND_ROOFTOP		= false 
  368. REMOTE_PLAYER_ON_2ND_ROOFTOP		= false 
  369.  
  370. NAVP_BOAT_STAGING_LOCAL				= "tss01_$Nboat_staging_local" 
  371. NAVP_BOAT_STAGING_CARLOS			= "tss01_$Nboat_staging_carlos" 
  372. NAVP_BOAT_STAGING_REMOTE			= "tss01_$Nboat_staging_remote" 
  373.  
  374. -- A failure condition is triggered when the players get too far from the island without 
  375. -- starting the turret sequence. 
  376. NAVP_ISLAND_CENTER					= "tss01_$Nisland_center" 
  377. MAX_SWIM_DISTANCE_M					= 325 
  378.  
  379. VEHICLE_HEALTH_MULTIPLIER			= .625 
  380.  
  381. PARKINGSPAWN01							= "parking_spots_$parking_343" 
  382. PARKINGSPAWN02							= "parking_spots_$parking_905" 
  383.  
  384. -- This needs to come after Carlos being defined... 
  385. Tss01_carlos_exchange_1 = {{"CARLOS_TSSP1_CHATTER_01",	CHARACTER_CARLOS,	0.0}, 
  386. 									{"PLAYER_TSSP1_CHATTER_01",	LOCAL_PLAYER,		rand_float(0.25, 0.75)}} 
  387. Tss01_carlos_exchange_2 = {{"CARLOS_TSSP1_CHATTER_02",	CHARACTER_CARLOS,	0.0}, 
  388. 									{"PLAYER_TSSP1_CHATTER_02",	LOCAL_PLAYER,		rand_float(0.25, 0.75)}} 
  389. Tss01_carlos_exchange_3 = {{"CARLOS_TSSP1_CHATTER_03",	CHARACTER_CARLOS,	0.0}, 
  390. 									{"PLAYER_TSSP1_CHATTER_03",	LOCAL_PLAYER,		rand_float(0.25, 0.75)}} 
  391. Tss01_carlos_exchange_4 = {{"CARLOS_TSSP1_CHATTER_04",	CHARACTER_CARLOS,	0.0}, 
  392. 									{"PLAYER_TSSP1_CHATTER_04",	LOCAL_PLAYER,		rand_float(0.25, 0.75)}} 
  393. Tss01_carlos_exchange_5 = {{"CARLOS_TSSP1_CHATTER_05",	CHARACTER_CARLOS,	0.0}, 
  394. 									{"PLAYER_TSSP1_CHATTER_05",	LOCAL_PLAYER,		rand_float(0.25, 0.75)}} 
  395.  
  396. OTHER_PLAYER = {[LOCAL_PLAYER] = REMOTE_PLAYER, [REMOTE_PLAYER] = LOCAL_PLAYER} 
  397.  
  398. function tss01_start(checkpoint, is_restart) 
  399. 	-- Start trigger is hit...the activate button was hit 
  400. 	set_mission_author("Ryan Spencer") 
  401.  
  402. 	-- Check for coop being active 
  403. 	if (coop_is_active()) then 
  404. 		IN_COOP	= true 
  405. 	end 
  406.  
  407. 	-- Reduce the amount of damage applied to the players 
  408. 	if (IN_COOP) then 
  409. 		character_set_damage_multiplier(REMOTE_PLAYER, COOP_DAMAGE_MULTIPLIER) 
  410. 		character_set_damage_multiplier(LOCAL_PLAYER, COOP_DAMAGE_MULTIPLIER) 
  411. 	else 
  412. 		character_set_damage_multiplier(LOCAL_PLAYER, SINGLE_PLAYER_DAMAGE_MULTIPLIER) 
  413. 	end 
  414.  
  415. 	-- Fade out of free roam... 
  416. 	mission_start_fade_out() 
  417.  
  418. 	if (checkpoint == MISSION_START_CHECKPOINT) then 
  419.  
  420. 		local start_groups =	{	GROUP_TUT_PRISONERS, GROUP_NON_TUT_PRISONERS, GROUP_START,  
  421. 										GROUP_KEY_GUARDS, GROUP_CAFE_GUARDS } 
  422. 		if (DOCTOR_ALLOWED) then 
  423. 			start_groups =	{	GROUP_TUT_PRISONERS, GROUP_NON_TUT_PRISONERS, GROUP_START,  
  424. 									GROUP_KEY_GUARDS, GROUP_CAFE_GUARDS, GROUP_DOCTOR }			 
  425. 		end 
  426.  
  427. 		if (is_restart) then 
  428. 			for i,group in pairs(start_groups) do 
  429. 				group_create(group, true) 
  430. 			end 
  431.  
  432. 			-- Teleport the player(s) to where they will need to be 
  433. 			teleport_coop(LOCAL_PLAYER_START, REMOTE_PLAYER_START) 
  434.  
  435. 		else 
  436. 			cutscene_play("tssp01-01", start_groups, {LOCAL_PLAYER_START,REMOTE_PLAYER_START}, false) 
  437. 			for i,group in pairs(start_groups) do 
  438. 				group_show(group) 
  439. 			end 
  440. 		end 
  441. 	end 
  442.  
  443. 	--group_create(GROUP_START, true) 
  444. 	--checkpoint = MISSION_CHECKPOINT_DOCKS 
  445.  
  446. 	if (LISBON_TWEAKS_ENABLED) then 
  447. 		group_create_hidden(GROUP_ATTACK_HELI) 
  448. 	end 
  449.  
  450. 	-- Do the initial setup for each checkpoint of data that is not common 
  451. 	if (checkpoint == MISSION_START_CHECKPOINT) then 
  452. 		tss01_jailbreak_setup() 
  453. 	elseif (checkpoint == MISSION_CHECKPOINT_DOCKS) then 
  454. 		tss01_docks_checkpoint() 
  455. 	else 
  456. 		tss01_boat_checkpoint() 
  457. 	end 
  458.  
  459. 	if (checkpoint ~= MISSION_CHECKPOINT_BOAT) then 
  460. 		-- Increase the hp of vehicles that the players enter 
  461. 		VEHICLE_HP_THREAD_HANDLE = thread_new("tss01_player_vehicle_health") 
  462. 		-- Kill the players if they swim too far from the island 
  463. 		SWIM_DISTANCE_THREAD_HANDLE = thread_new("tss01_monitor_swim_failure") 
  464. 	end 
  465.  
  466.  
  467. 	-- Don't allow the player(s) to be busted 
  468. 	set_player_can_be_busted(LOCAL_PLAYER, false) 
  469. 	if (IN_COOP) then 
  470. 		set_player_can_be_busted(REMOTE_PLAYER, false) 
  471. 	end 
  472.  
  473. 	-- Disable the parking spanws of the helicopter and boat from the mission in the off chance they choose to appear. 
  474. 	parking_spot_enable(PARKINGSPAWN01, false) 
  475. 	parking_spot_enable(PARKINGSPAWN02, false) 
  476.  
  477. 	-- When Carlos dies 
  478. 	on_death("tss01_failure_carlos", CHARACTER_CARLOS) 
  479. 	-- When Carlos is dismissed as a follower 
  480. 	on_dismiss("tss01_abandon_carlos", CHARACTER_CARLOS) 
  481.  
  482. 	-- Lets do some persona override here... 
  483. 	persona_override_character_stop_all(CHARACTER_CARLOS) 
  484. 	persona_override_character_start(CHARACTER_CARLOS, POT_SITUATIONS[POT_ATTACK],			"CARLOS_TSSP1_ATKFOOT") 
  485. 	persona_override_character_start(CHARACTER_CARLOS, POT_SITUATIONS[POT_TAKE_DAMAGE],		"CARLOS_TSSP1_DAMFOOT") 
  486. 	persona_override_character_start(CHARACTER_CARLOS, POT_SITUATIONS[POT_PRAISED_BY_PC],	"CARLOS_TSSP1_PRAISED") 
  487. 	persona_override_character_start(CHARACTER_CARLOS, POT_SITUATIONS[POT_TAUNTED_BY_PC],	"CARLOS_TSSP1_TAUNT") 
  488. 	persona_override_character_start(CHARACTER_CARLOS, POT_SITUATIONS[POT_BARTER],			"CARLOS_TSSP1_BARTER") 
  489. 	persona_override_character_start(CHARACTER_CARLOS, POT_SITUATIONS[POT_GRATS_PC],			"CARLOS_TSSP1_GRATSPLAYER") 
  490. 	persona_override_character_start(CHARACTER_CARLOS, POT_SITUATIONS[POT_GRATS_SELF],		"CARLOS_TSSP1_GRATSSELF") 
  491.  
  492. 	-- Override the Cop personas 
  493. 	persona_override_group_start(COP_PERSONAS, POT_SITUATIONS[POT_ATTACK], "TSSP1_ATTACK") 
  494.  
  495. 	-- Set the time of day to 3am 
  496. 	set_time_of_day(3, 0) 
  497. 	set_time_of_day_scale(0.0) 
  498.  
  499. 	-- Turn spawning off 
  500. 	spawning_vehicles(false) 
  501. 	spawning_pedestrians(false) 
  502. 	--action_nodes_enable(false) 
  503. 	action_nodes_restrict_spawning(true) 
  504. 	--distant_ped_vehicle_render_enable(false) 
  505.  
  506. 	-- This is not a restricted zone during this mission 
  507. 	notoriety_restricted_zones_enable(false) 
  508. 	-- Turn notoriety spawning off 
  509. 	notoriety_force_no_spawn("police", true) 
  510. 	-- Set the initial notoriety 
  511. 	notoriety_set_max("police", 0) 
  512.  
  513. 	-- All cops can shoot from vehicles... 
  514. 	set_cops_shooting_from_vehicles(true) 
  515.  
  516. 	-- Fade in from the mission setup 
  517. 	mission_start_fade_in() 
  518.  
  519. 	-- Do the final setup for each checkpoint of data that is not common 
  520. 	-- NOTE: These are allowed to block...no common data should come after this section 
  521. 	-- 
  522. 	if (checkpoint == MISSION_START_CHECKPOINT) then 
  523. 		-- This delays and will not immediately return 
  524. 		tss01_jailbreak_start() 
  525. 	elseif (checkpoint == MISSION_CHECKPOINT_DOCKS) then 
  526. 		-- Setup the docks segment 
  527. 		tss01_to_the_docks_from_checkpoint() 
  528. 	else 
  529. 		-- This blocks and does not return until the boat has finished it's path... 
  530. 		tss01_setup_boat_segment_from_checkpoint() 
  531. 	end 
  532. end 
  533.  
  534. function tss01_player_vehicle_health() 
  535.  
  536. 	local player_vehicle = {[LOCAL_PLAYER] = "", [REMOTE_PLAYER] = ""} 
  537.  
  538. 	local function update_player_vehicle_health(player) 
  539.  
  540. 		local new_vehicle = get_char_vehicle_name(player) 
  541.  
  542. 		-- Somehow I sometimes get player's names back from this function ... even though all 
  543. 		-- vehicles in this mission are scripted. WTF? 
  544. 		if ( (new_vehicle == LOCAL_PLAYER) or (new_vehicle == REMOTE_PLAYER) ) then 
  545. 			new_vehicle = "" 
  546. 		end 
  547.  
  548. 		-- Handle player exiting a vehicle 
  549. 		local was_in_vehicle = ((player_vehicle[player] ~= "")) 
  550. 		local vehicle_changed = (new_vehicle ~= player_vehicle[player]) 
  551. 		local player_vehicles_differ = (player_vehicle[player] ~= player_vehicle[OTHER_PLAYER[player]]) 
  552. 		if ( was_in_vehicle and vehicle_changed and player_vehicles_differ) then 
  553. 			if (vehicle_exists(player_vehicle[player]) and (not vehicle_is_destroyed(player_vehicle[player]))) then 
  554. 				local max_hp = get_max_hit_points(player_vehicle[player]) 
  555. 				set_max_hit_points(player_vehicle[player], max_hp / PLAYER_VEHICLE_HIT_POINT_FACTOR) 
  556. 			end 
  557. 		end 
  558.  
  559. 		-- Handle player entering a vehicle 
  560. 		local now_in_vehicle = (new_vehicle ~= "") 
  561. 		local player_already_in_vehicle = ((player_vehicle[player] == new_vehicle) or (player_vehicle[OTHER_PLAYER[player]] == new_vehicle)) 
  562. 		if (now_in_vehicle and (not player_already_in_vehicle) )then 
  563. 			local max_hp = get_max_hit_points(new_vehicle) 
  564. 			set_max_hit_points(new_vehicle, max_hp*PLAYER_VEHICLE_HIT_POINT_FACTOR ) 
  565. 		end 
  566.  
  567. 		player_vehicle[player] = new_vehicle 
  568.  
  569. 	end 
  570.  
  571. 	while(true) do 
  572. 		thread_yield() 
  573. 		update_player_vehicle_health(LOCAL_PLAYER) 
  574. 		if (IN_COOP) then 
  575. 			update_player_vehicle_health(REMOTE_PLAYER) 
  576. 		end 
  577. 	end 
  578.  
  579. end 
  580.  
  581. function tss01_spawn_tut_extras() 
  582.  
  583. 	npc_use_closest_action_node_of_type("tss01_$c053", "InmateScrubFloor") 
  584. 	npc_use_closest_action_node_of_type("tss01_$c054", "InmateScrubFloor") 
  585. 	inv_item_remove_all("tss01_$c053") 
  586. 	inv_item_remove_all("tss01_$c054") 
  587. 	delay(10) 
  588. 	release_to_world(GROUP_TUT_PRISONERS) 
  589.  
  590. end 
  591.  
  592. function tss01_spawn_non_tut_extras() 
  593.  
  594. 	npc_use_closest_action_node_of_type("tss01_$c055", "PicnicTableSit") 
  595. 	npc_use_closest_action_node_of_type("tss01_$c056", "PicnicTableSit") 
  596. 	npc_use_closest_action_node_of_type("tss01_$c057", "PicnicTableSit") 
  597. 	inv_item_remove_all("tss01_$c055") 
  598. 	inv_item_remove_all("tss01_$c056") 
  599. 	inv_item_remove_all("tss01_$c057") 
  600. 	delay(15) 
  601. 	release_to_world(GROUP_NON_TUT_PRISONERS) 
  602.  
  603. end 
  604.  
  605.  
  606. function tss01_jailbreak_setup() 
  607.  
  608. 	thread_new("tss01_spawn_tut_extras") 
  609. 	thread_new("tss01_spawn_non_tut_extras") 
  610.  
  611. 	-- The German build has no doctor 
  612. 	if (DOCTOR_ALLOWED) then 
  613.  
  614. 		-- Disarm the doctor 
  615. 		inv_item_remove_all(CHARACTER_DOCTOR) 
  616.  
  617. 		-- Place the on_death callback on the Dr. now, just in case the player manages to kill her 
  618. 		-- more quickly than expected 
  619. 		on_death("tss01_get_out_of_here", CHARACTER_DOCTOR) 
  620.  
  621. 		-- Also have her ignore ai 
  622. 		set_ignore_ai_flag(CHARACTER_DOCTOR, true) 
  623.  
  624. 		-- Doctors use clipboards. 
  625. 		npc_use_closest_action_node_of_type(CHARACTER_DOCTOR,"Doctor_Clipboard", 5) 
  626.  
  627. 	end 
  628.  
  629. 	-- Put Carlos in player's party 
  630. 	party_add(CHARACTER_CARLOS, LOCAL_PLAYER) 
  631.  
  632. 	-- Don't allow Carlos to equip or unequip what he starts out with 
  633. 	npc_dont_auto_equip_or_unequip_weapons(CHARACTER_CARLOS, true) 
  634.  
  635. 	-- Carlos is unarmed 
  636. 	inv_item_remove_all(CHARACTER_CARLOS) 
  637. 	inv_item_remove_all(LOCAL_PLAYER) 
  638. 	if (IN_COOP) then 
  639. 		inv_item_remove_all(REMOTE_PLAYER) 
  640. 	end 
  641.  
  642. 	-- Setup the callbacks 
  643. 	on_trigger("tss01_waypoint02", Tss01_waypoints[1]) 
  644. 	on_trigger("tss01_waypoint03", Tss01_waypoints[2]) 
  645. 	on_trigger("tss01_waypoint04", Tss01_waypoints[3]) 
  646. 	on_trigger("tss01_waypoint05", Tss01_waypoints[4]) 
  647. 	on_trigger("tss01_waypoint06", Tss01_waypoints[5]) 
  648. 	-- Waypoint 06 is a human and not a trigger...setup elsewhere 
  649. 	on_trigger("tss01_waypoint08", Tss01_waypoints[7]) 
  650. 	on_trigger("tss01_waypoint09", Tss01_waypoints[8]) 
  651. 	on_trigger("tss01_waypoint12a", Tss01_waypoints[9]) 
  652. 	on_trigger("tss01_waypoint11", Tss01_waypoints[10]) 
  653. 	on_trigger("tss01_waypoint12b", Tss01_waypoints[11]) 
  654. 	on_trigger("tss01_waypoint_end", Tss01_waypoints[12]) 
  655.  
  656. 	-- Disable all of the explore triggers 
  657. 	for i = 1, Num_tss01_explore_triggers, 1 do 
  658. 		on_trigger("tss01_explore_trigger", Tss01_explore_triggers[i]) 
  659. 	end 
  660.  
  661. 	-- Close all the doors used and lock them 
  662. 	-- BACK_DOOR 
  663. 	-- FRONT_DOOR_1 
  664. 	-- FRONT_DOOR_2 
  665. 	-- KEY_DOOR 
  666. 	for i = 1, Num_tss01_doors, 1 do 
  667. 		door_close(Tss01_doors[i]) 
  668. 		door_lock(Tss01_doors[i], true) 
  669. 	end 
  670.  
  671. 	-- The door on open callbacks 
  672. 	on_door_opened("tss01_backdoor", Tss01_doors[BACK_DOOR]) 
  673. --	door_message_override(Tss01_doors[BACK_DOOR], "tss01_tutorial_door") 
  674. 	on_door_opened("tss01_frontdoor", Tss01_doors[FRONT_DOOR_1]) 
  675. --	door_message_override(Tss01_doors[FRONT_DOOR_1], "tss01_run_gun_door") 
  676. 	on_door_opened("tss01_frontdoor", Tss01_doors[FRONT_DOOR_2]) 
  677. --	door_message_override(Tss01_doors[FRONT_DOOR_2], "tss01_run_gun_door") 
  678.  
  679. 	-- Lock the permanently locked doors during this mission 
  680. 	for i = 1, Num_tss01_locked_doors, 1 do 
  681. 		door_close(Tss01_locked_doors[i]) 
  682. 		door_lock(Tss01_locked_doors[i], true) 
  683. 	end 
  684.  
  685. 	for i = 1, Num_tss01_reset_doors, 1 do 
  686. 		door_close(Tss01_reset_doors[i]) 
  687. 		door_lock(Tss01_reset_doors[i], false) 
  688. 	end 
  689.  
  690. 	-- Tell the cafe guards to wander 
  691. 	for i = 1, Num_tss01_cafe_guards, 1 do 
  692. 		npc_leash_to_nav(Tss01_cafe_guards[i], Tss01_cafe_guards[i], 2.0) 
  693. 		wander_start(Tss01_cafe_guards[i], Tss01_cafe_guards[i], 2.0) 
  694. 		on_death("tss01_release_to_world", Tss01_cafe_guards[i]) 
  695. 	end 
  696.  
  697. 	-- Leash Carlos so the player has to do the beatdown 
  698. 	npc_leash_to_nav(CHARACTER_CARLOS, CHARACTER_CARLOS, 1.0) 
  699. end 
  700.  
  701. function tss01_docks_checkpoint() 
  702.  
  703. 	on_trigger("tss01_waypoint_end", Tss01_waypoints[12]) 
  704.  
  705. 	-- Create our dock group 
  706. 	group_create(GROUP_DOCKS, true) 
  707. 	group_create(GROUP_ROADBLOCK, true) 
  708. 	group_create_hidden(GROUP_RANDOM) 
  709. 	group_create_hidden(GROUP_TUT_T_IN_ROAD) 
  710.  
  711. 	if (tss01_spawn_coop_groups()) then 
  712. 		group_create_hidden(GROUP_DOCKS_COOP) 
  713. 		group_create_hidden(GROUP_RANDOM_COOP) 
  714. 		group_create_hidden(GROUP_ROADBLOCK_COOP) 
  715. 	end 
  716. 	 
  717. 	-- Setup the drop off segment 
  718. 	tss01_docks_drop_segment() 
  719. 	-- Setup the heli crash segment 
  720. 	tss01_docks_heli_segment() 
  721.  
  722. 	-- We do not want our yacht to be destroyed 
  723. 	on_vehicle_destroyed("tss01_failure_yacht", HIGH_SEAS_VEHICLE) 
  724.  
  725. 	-- Enable Carlos's boat damage lines whenever the boat is damaged 
  726. 	on_take_damage("tss01_enable_carlos_damage_line", HIGH_SEAS_VEHICLE) 
  727.  
  728. 	-- Up the health of the boat 
  729. 	set_max_hit_points(HIGH_SEAS_VEHICLE, HIGH_SEAS_VEHICLE_HIT_POINTS, true) 
  730. 	-- Make sure the vehicle is not entered...we just want to teleport everyone 
  731. 	set_unjackable_flag(HIGH_SEAS_VEHICLE, true) 
  732.  
  733. 	-- Sound the alarms 
  734. 	thread_new("tss01_sound_escape_alarms") 
  735. end 
  736.  
  737. function tss01_docks_drop_segment() 
  738. 	-- Show the heli and humans 
  739. 	group_create(GROUP_HELI, true) 
  740. 	group_create(GROUP_HELI_GUARDS, true) 
  741.  
  742. 	-- Put the humans in the heli 
  743. 	vehicle_enter_teleport("tss01_$pilot", SPOT_LIGHT_HELI, 0) 
  744. 	vehicle_enter_teleport("tss01_$spot1", SPOT_LIGHT_HELI, 4) 
  745. 	vehicle_enter_teleport("tss01_$spot2", SPOT_LIGHT_HELI, 5) 
  746.  
  747. 	-- Make the heli unjackable 
  748. 	set_unjackable_flag(SPOT_LIGHT_HELI, true) 
  749.  
  750. 	-- Make the heli's pilot invulnerable 
  751. 	turn_invulnerable("tss01_$pilot", false) 
  752. 	on_vehicle_destroyed("tss01_spot_light_heli_destroyed",SPOT_LIGHT_HELI) 
  753.  
  754. 	-- Update hit points for coop 
  755. 	tss01_update_hit_points({"tss01_$pilot", "tss01_$spot1", "tss01_$spot2"}) 
  756.  
  757. 	-- These guys need to suck at shooting... 
  758. 	npc_weapon_spread("tss01_$spot1", tss01_get_weapon_spread(2.0)) 
  759. 	npc_weapon_spread("tss01_$spot2", tss01_get_weapon_spread(2.0)) 
  760.  
  761. 	-- Turn some lights on 
  762. 	vehicle_lights_on(SPOT_LIGHT_HELI, true) 
  763. 	vehicle_set_sirens(SPOT_LIGHT_HELI, true) 
  764.  
  765. 	-- Spawn off a thread to do a small pathfind 
  766. 	thread_new("tss01_checkpoint_heli_pathfind", SPOT_LIGHT_HELI, "tss01_$n047", "tss01_$n033") 
  767. end 
  768.  
  769. function tss01_spot_light_heli_destroyed() 
  770. 	if (character_exists("tss01_$pilot") and (not character_is_dead("tss01_$pilot"))) then 
  771. 		turn_vulnerable("tss01_$pilot") 
  772. 	end 
  773. end 
  774.  
  775. function tss01_docks_heli_segment() 
  776. 	-- Show the heli and humans 
  777. 	group_create(GROUP_TUT_FINE_AIM, true) 
  778.  
  779. 	-- Put the humans in the heli 
  780. 	vehicle_enter_teleport("tss01_$c050", FINE_AIM_VEHICLE, 0) 
  781. 	vehicle_enter_teleport("tss01_$c051", FINE_AIM_VEHICLE, 4) 
  782. 	vehicle_enter_teleport("tss01_$c052", FINE_AIM_VEHICLE, 5) 
  783.  
  784. 	-- These guys need to suck at shooting... 
  785. 	npc_weapon_spread("tss01_$c051", tss01_get_weapon_spread(2.0)) 
  786. 	npc_weapon_spread("tss01_$c052", tss01_get_weapon_spread(2.0)) 
  787.  
  788. 	tss01_update_hit_points({"tss01_$c050", "tss01_$c051", "tss01_$c052"}) 
  789.  
  790. 	-- Turn some lights on 
  791. 	vehicle_lights_on(FINE_AIM_VEHICLE, true) 
  792. 	vehicle_set_sirens(FINE_AIM_VEHICLE, true) 
  793.  
  794. 	-- Turn this heli invulnerable 
  795. 	set_unjackable_flag(FINE_AIM_VEHICLE, true) 
  796.  
  797. 	-- Spawn off a thread to do a small pathfind 
  798. 	thread_new("tss01_checkpoint_heli_pathfind", FINE_AIM_VEHICLE, "tss01_$n100", "tss01_$n101") 
  799. end 
  800.  
  801. function tss01_checkpoint_heli_pathfind(heli, warp, navpoint) 
  802. 	-- Yield for a several frames 
  803. 	thread_yield() 
  804. 	thread_yield() 
  805. 	thread_yield() 
  806. 	-- Teleport the vehicle where we need it to be 
  807. 	teleport_vehicle(heli, warp) 
  808. 	-- Do the pathfind now 
  809. 	helicopter_fly_to_direct(heli, 50.0, navpoint) 
  810. end 
  811.  
  812. function tss01_boat_checkpoint() 
  813.  
  814. 	-- Create the first wave 
  815. 	group_create_hidden(GROUP_WAVE_1) 
  816. 	group_create_hidden(GROUP_BOAT_1) 
  817. 	group_create_hidden(GROUP_BOAT_2) 
  818. 	group_create_hidden(GROUP_BOAT_3) 
  819. 	group_create_hidden(GROUP_HELI_1) 
  820.  
  821. 	-- Create the player's turret boat 
  822. 	group_create(GROUP_DOCKS, true) 
  823. 	delay(1.0) 
  824.  
  825. 	-- We do not want our yacht to be destroyed 
  826. 	on_vehicle_destroyed("tss01_failure_yacht", HIGH_SEAS_VEHICLE) 
  827.  
  828. 	-- Enable Carlos's boat damage lines whenever the boat is damaged 
  829. 	on_take_damage("tss01_enable_carlos_damage_line", HIGH_SEAS_VEHICLE) 
  830.  
  831. 	-- Up the health of the boat 
  832. 	set_max_hit_points(HIGH_SEAS_VEHICLE, HIGH_SEAS_VEHICLE_HIT_POINTS, true) 
  833. 	-- Make sure the vehicle is not entered...we just want to teleport everyone 
  834. 	set_unjackable_flag(HIGH_SEAS_VEHICLE, true) 
  835. 	 
  836. 	-- Sound the alarms 
  837. 	thread_new("tss01_sound_escape_alarms") 
  838.  
  839. 	-- Make sure that everyone is in the right spot in the boat 
  840. 	tss01_place_turret_boat_occupants() 
  841.  
  842. 	teleport_vehicle(HIGH_SEAS_VEHICLE, HIGH_SEAS_VEHICLE) 
  843. end 
  844.  
  845. function tss01_jailbreak_start() 
  846.  
  847. 	if( DOCTOR_ALLOWED ) then 
  848. 		-- Setup the doctor's death callback 
  849. 		on_death("tss01_get_out_of_here", CHARACTER_DOCTOR) 
  850.  
  851. 		-- Spawn off a thread to watch how close the player(s) are to the doctor 
  852. 		DOCTOR_THREAD_HANDLE1 = thread_new("tss01_jailbreak_kill_doctor_distance") 
  853. 		DOCTOR_THREAD_HANDLE2 = thread_new("tss01_jailbreak_kill_doctor_time") 
  854. 	else 
  855. 		tss01_get_out_of_here() 
  856. 	end 
  857.  
  858.  
  859. 	-- Delay a short period of time so the fade in can complete... 
  860. --	delay(1.0) 
  861. 	-- Show the melee help text 
  862. --	mission_help_table_nag("tss01_melee") 
  863. end 
  864.  
  865. -- Trigger the doctor-killing prompts if the player gets to close to the doctor 
  866. -- NOT CALLED ON GERMAN BUILDS 
  867. function tss01_jailbreak_kill_doctor_distance() 
  868.  
  869. 	local dr_react_dist = 5 
  870.  
  871. 	-- Wait until the thread is killed or one of the player is close enough to the doctor 
  872. 	local		dist,player = get_dist_closest_player_to_object(CHARACTER_DOCTOR) 
  873. 	local		close_to_doctor = (dist < dr_react_dist) 
  874.  
  875. 	while (not close_to_doctor) do 
  876. 		thread_yield() 
  877.  
  878. 		dist,player = get_dist_closest_player_to_object(CHARACTER_DOCTOR) 
  879. 		close_to_doctor = (dist < dr_react_dist) 
  880. 	end 
  881.  
  882. 	-- Kill the time watch thread 
  883. 	thread_kill(DOCTOR_THREAD_HANDLE2) 
  884.  
  885. 	-- Prompt players to kill the Dr. 
  886. 	tss01_jailbreak_kill_doctor() 
  887.  
  888. 	audio_play_persona_line(CHARACTER_DOCTOR, "threat - alert (solo attack)") 
  889. end 
  890.  
  891. -- Trigger the doctor-killing prompts after a bit of time passes 
  892. -- NOT CALLED ON GERMAN BUILDS 
  893. function tss01_jailbreak_kill_doctor_time() 
  894. 	-- Delay just a short period of time 
  895. 	delay(5.0) 
  896.  
  897. 	-- Kill the distance watch thread 
  898. 	thread_kill(DOCTOR_THREAD_HANDLE1) 
  899.  
  900. 	-- Prompt players to kill the Dr. 
  901. 	tss01_jailbreak_kill_doctor() 
  902. end 
  903.  
  904. -- Tell the player to kill the doctor 
  905. -- NOT CALLED ON GERMAN BUILDS 
  906. Tss01_kill_doctor_sequence_started = false 
  907. function tss01_jailbreak_kill_doctor() 
  908. 	if (Tss01_kill_doctor_sequence_started == false) then 
  909. 		Tss01_kill_doctor_sequence_started = true 
  910.  
  911. 		-- Have the Dr. stop ignoring AI 
  912. 		set_ignore_ai_flag(CHARACTER_DOCTOR, false) 
  913. 		npc_use_closest_action_node_of_type(CHARACTER_DOCTOR,"Doctor_Clipboard", 5) 
  914. 		--npc_use_closest_action_node_of_type(CHARACTER_DOCTOR,"Doctor_Clipboard", 5) 
  915.  
  916. 		-- Show the tutorial 
  917. 		tutorial_start("combat") 
  918. 		-- Delay for a moment 
  919. 		delay(0.5) 
  920.  
  921. 		-- The doctor is now a required kill 
  922. 		marker_add_npc(CHARACTER_DOCTOR, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  923. 		-- Prompt the user to kill the doctor 
  924. 		mission_help_table("tss01_doctor") 
  925. 	end 
  926. end 
  927.  
  928. function tss01_cleanup() 
  929.  
  930. 	-- Reset IN_COOP, in case the remote player disconnected 
  931. 	IN_COOP = coop_is_active() 
  932.  
  933. 	-- Let players recruit again 
  934. 	party_set_recruitable(false) 
  935.  
  936. 	-- Make sure players aren't invulnerable 
  937. 	turn_vulnerable(LOCAL_PLAYER) 
  938. 	if (IN_COOP) then 
  939. 		turn_vulnerable(REMOTE_PLAYER) 
  940. 	end 
  941.  
  942. 	-- Allow player persona lines to play. 
  943. 	audio_suppress_ambient_player_lines(false) 
  944.  
  945. 	for i,trigger in pairs(TABLE_ALL_TRIGGERS) do 
  946. 		on_trigger("", trigger) 
  947. 		trigger_enable(trigger, false) 
  948. 	end 
  949. 	for i, trigger in pairs(Tss01_waypoints) do 
  950. 		if (i ~= 6) then 
  951. 			on_trigger("", trigger) 
  952. 			trigger_enable(trigger, false) 
  953. 		end 
  954. 	end 
  955. 	for i, trigger in pairs(Tss01_explore_triggers) do 
  956. 		on_trigger("", trigger) 
  957. 		trigger_enable(trigger, false) 
  958. 	end 
  959.  
  960. 	on_vehicle_destroyed("", GROUP_BOAT_1) 
  961. 	on_vehicle_destroyed("", GROUP_BOAT_2) 
  962. 	on_vehicle_destroyed("", GROUP_BOAT_3) 
  963. 	on_vehicle_destroyed("", GROUP_HELI_1) 
  964. 	on_vehicle_destroyed("", GROUP_BOAT_4) 
  965. 	on_vehicle_destroyed("", GROUP_BOAT_5) 
  966. 	on_vehicle_destroyed("", GROUP_HELI_2) 
  967. 	on_vehicle_destroyed("", GROUP_HELI_3) 
  968.  
  969. 	if (LISBON_TWEAKS_ENABLED) then 
  970. 		vehicle_show(VEHICLE_ATTACK_HELI) 
  971. 		vehicle_mark_as_players(VEHICLE_ATTACK_HELI) 
  972. 		release_to_world(VEHICLE_ATTACK_HELI) 
  973. 	end 
  974.  
  975. 	-- Re-enable the parking spanws of the helicopter and boat. 
  976. 	parking_spot_enable(PARKINGSPAWN01, true) 
  977. 	parking_spot_enable(PARKINGSPAWN02, true) 
  978.  
  979. 	-- Reset the amount of damage applied to the players 
  980. 	character_set_damage_multiplier(LOCAL_PLAYER, 1.0) 
  981. 	if (IN_COOP) then 
  982. 		character_set_damage_multiplier(REMOTE_PLAYER, 1.0) 
  983. 	end 
  984.  
  985. 	-- The player(s) can be busted again 
  986. 	set_player_can_be_busted(LOCAL_PLAYER, true) 
  987. 	if (IN_COOP) then 
  988. 		set_player_can_be_busted(REMOTE_PLAYER, true) 
  989. 	end 
  990.  
  991. 	-- Just reset all of the persona overrides... 
  992. 	if (character_exists(CHARACTER_CARLOS)) then 
  993. 		persona_override_character_stop_all(CHARACTER_CARLOS) 
  994. 	end 
  995.  
  996. 	persona_override_group_stop(COP_PERSONAS, POT_SITUATIONS[POT_ATTACK]) 
  997.  
  998. 	-- Reset the time of day scale factor 
  999. 	set_time_of_day_scale() 
  1000.  
  1001. 	-- Remove the on weapon callbacks 
  1002. 	on_weapon_pickup("", LOCAL_PLAYER) 
  1003. 	if (IN_COOP) then 
  1004. 		on_weapon_pickup("", REMOTE_PLAYER) 
  1005. 	end 
  1006.  
  1007. 	on_weapon_equip("", LOCAL_PLAYER) 
  1008. 	if (IN_COOP) then 
  1009. 		on_weapon_equip("", REMOTE_PLAYER) 
  1010. 	end 
  1011. 	 
  1012. 	on_weapon_fired("", LOCAL_PLAYER) 
  1013. 	on_weapon_fired("", CHARACTER_CARLOS) 
  1014. 	if (IN_COOP) then 
  1015. 		on_weapon_fired("", REMOTE_PLAYER) 
  1016. 	end 
  1017.  
  1018. 	-- Invalidate the vehicle destroyed 
  1019. 	on_vehicle_destroyed("", HIGH_SEAS_VEHICLE) 
  1020. 	on_take_damage("", HIGH_SEAS_VEHICLE) 
  1021.  
  1022. 	-- Invalidate Carlos on death 
  1023. 	on_death("", CHARACTER_CARLOS) 
  1024. 	-- Invalidate the doctors death 
  1025. 	if (DOCTOR_ALLOWED) then 
  1026. 		on_death("", CHARACTER_DOCTOR) 
  1027. 	end 
  1028.  
  1029. 	-- Invalidate Carlos being dismissed 
  1030. 	on_dismiss("", CHARACTER_CARLOS) 
  1031. 	party_dismiss(CHARACTER_CARLOS) 
  1032.  
  1033. 	-- Remove the equip restriction from Carlos 
  1034. 	npc_dont_auto_equip_or_unequip_weapons(CHARACTER_CARLOS, false) 
  1035.  
  1036. 	-- Remove the player(s) searchlight callbacks 
  1037. 	on_searchlight_track("", LOCAL_PLAYER) 
  1038. 	on_searchlight_track("", CHARACTER_CARLOS) 
  1039. 	if (IN_COOP) then 
  1040. 		on_searchlight_track("", REMOTE_PLAYER) 
  1041. 	end 
  1042.  
  1043. 	-- Remove the damage callbacks 
  1044. 	on_damage("", LOCAL_PLAYER, 0.0) 
  1045. 	if (IN_COOP) then 
  1046. 		on_damage("", REMOTE_PLAYER, 0.0) 
  1047. 	end 
  1048.  
  1049. 	-- In case the hud timer is valid when the alarm triggers, we need to kill it 
  1050. 	hud_timer_stop(0) 
  1051. 	hud_timer_stop(1) 
  1052. 	-- Clear the hud from possible infinite showing text 
  1053. 	mission_help_clear() 
  1054.  
  1055. 	-- Invalidate the callback for this door 
  1056. 	on_door_opened("", "tss01_PI_vkp_jail_FDoor050") 
  1057.  
  1058. 	-- Remove the player(s) an assault rifle 
  1059. 	if (TEMP_WEAPONS_GIVEN) then 
  1060. 		inv_weapon_remove_temporary(LOCAL_PLAYER, "AR200_ss03") 
  1061. 		if (IN_COOP) then 
  1062. 			inv_weapon_remove_temporary(REMOTE_PLAYER, "AR200_ss03") 
  1063. 		end 
  1064. 	end 
  1065.  
  1066. 	-- Remove any weapon that is not in the melee, pistol, and shotgun slots 
  1067. 	inv_item_remove_in_slot( "smg", LOCAL_PLAYER) 
  1068. 	inv_item_remove_in_slot( "rifle", LOCAL_PLAYER) 
  1069. 	inv_item_remove_in_slot( "launcher", LOCAL_PLAYER) 
  1070. 	inv_item_remove_in_slot( "thrown", LOCAL_PLAYER) 
  1071. 	if (IN_COOP) then 
  1072. 		inv_item_remove_in_slot( "smg", REMOTE_PLAYER) 
  1073. 		inv_item_remove_in_slot( "rifle", REMOTE_PLAYER) 
  1074. 		inv_item_remove_in_slot( "launcher", REMOTE_PLAYER) 
  1075. 		inv_item_remove_in_slot( "thrown", REMOTE_PLAYER) 
  1076. 	end 
  1077.  
  1078. 	-- Enable all weapon slots... 
  1079. 	inv_weapon_enable_or_disable_all_slots(true) 
  1080.  
  1081. 	-- Turn the damage bar off 
  1082. 	damage_indicator_off(0) 
  1083.  
  1084. 	-- Let the player(s) exit 
  1085. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, true) 
  1086. 	if (IN_COOP) then 
  1087. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, true) 
  1088. 	end 
  1089.  
  1090. 	-- Reset all the doors used 
  1091. 	for i = 1, Num_tss01_doors, 1 do 
  1092. 		mesh_mover_reset(Tss01_doors[i]) 
  1093. 		door_lock(Tss01_doors[i], false) 
  1094. 	end 
  1095.  
  1096. 	for i = 1, Num_tss01_locked_doors, 1 do 
  1097. 		mesh_mover_reset(Tss01_locked_doors[i]) 
  1098. 		door_lock(Tss01_locked_doors[i], false) 
  1099. 	end 
  1100.  
  1101. 	for i = 1, Num_tss01_reset_doors, 1 do 
  1102. 		mesh_mover_reset(Tss01_reset_doors[i]) 
  1103. 		door_lock(Tss01_reset_doors[i], false) 
  1104. 	end 
  1105.  
  1106. 	-- Remove the waypoint 
  1107. 	mission_waypoint_remove(SYNC_ALL) 
  1108.  
  1109. 	-- Turn spawning on 
  1110. 	spawning_vehicles(true) 
  1111. 	spawning_pedestrians(true) 
  1112. 	--action_nodes_enable(true) 
  1113. 	action_nodes_restrict_spawning(false) 
  1114. 	--distant_ped_vehicle_render_enable(true) 
  1115.  
  1116. 	-- Turn notoriety spawning on 
  1117. 	notoriety_force_no_spawn("police", false) 
  1118. 	notoriety_reset("police") 
  1119. 	notoriety_restricted_zones_enable(true) 
  1120.  
  1121. 	-- Cops can no longer shoot from vehicles 
  1122. 	set_cops_shooting_from_vehicles(false) 
  1123.  
  1124. 	-- Stop the alarms and prison riot sounds that might be playing 
  1125. 	for i = 1, Num_tss01_alarm_ext_pos, 1 do 
  1126. 		if (Tss01_audio_ext_inst[i] ~= 0) then 
  1127. 			audio_stop_emitting_id(Tss01_audio_ext_inst[i]) 
  1128. 		end 
  1129. 	end 
  1130.  
  1131. 	for i = 1, Num_tss01_alarm_int_pos, 1 do 
  1132. 		if (Tss01_audio_int_inst[i] ~= 0) then 
  1133. 			audio_stop_emitting_id(Tss01_audio_int_inst[i]) 
  1134. 		end 
  1135. 	end 
  1136.  
  1137. 	for i = 1, Num_tss01_prisoner_ext_pos, 1 do 
  1138. 		if (Tss01_audio_prisoner_ext_inst[i] ~= 0) then 
  1139. 			audio_stop_emitting_id(Tss01_audio_prisoner_ext_inst[i]) 
  1140. 		end 
  1141. 	end 
  1142.  
  1143. 	for i = 1, Num_tss01_prisoner_int_pos, 1 do 
  1144. 		if (Tss01_audio_prisoner_int_inst[i] ~= 0) then 
  1145. 			audio_stop_emitting_id(Tss01_audio_prisoner_int_inst[i]) 
  1146. 		end 
  1147. 	end 
  1148.  
  1149. 	audio_stop(Tss01_loud_speaker_audio_inst) 
  1150. 	audio_stop(Tss01_heli_speaker_audio_inst) 
  1151. 	audio_stop(Tss01_boat_chase_heli_speaker_audio_inst) 
  1152.  
  1153. 	--[[ 
  1154. 	-- Remove the player(s) from the vehicle first... 
  1155. 	vehicle_exit_teleport(LOCAL_PLAYER) 
  1156. 	if (IN_COOP) then 
  1157. 		vehicle_exit_teleport(REMOTE_PLAYER) 
  1158. 	end 
  1159.  
  1160. 	if ( not mission_is_complete( "tss01" ) ) then 
  1161. 		if(coop_is_active()) then 
  1162. 			teleport( REMOTE_PLAYER, REMOTE_PLAYER_START, true) 
  1163. 		end 
  1164. 		teleport( LOCAL_PLAYER, LOCAL_PLAYER_START, true )		 
  1165. 		door_close(Tss01_doors[BACK_DOOR]) 
  1166. 		door_lock(Tss01_doors[BACK_DOOR], true) 
  1167. 		door_close(Tss01_doors[FRONT_DOOR_1]) 
  1168. 		door_lock(Tss01_doors[FRONT_DOOR_1], true) 
  1169. 		door_close(Tss01_doors[FRONT_DOOR_2]) 
  1170. 		door_lock(Tss01_doors[FRONT_DOOR_2], true) 
  1171. 	end 
  1172. 	]] 
  1173.  
  1174. end 
  1175.  
  1176. function tss01_success() 
  1177. 	-- Called when the mission has ended with success 
  1178.  
  1179. 	-- Post the news events 
  1180. 	radio_post_event("JANE_NEWS_TSSP01", true) 
  1181.  
  1182. 	-- Remove the player(s) from the vehicle first... 
  1183. 	character_evacuate_from_all_vehicles(LOCAL_PLAYER) 
  1184. 	if (IN_COOP) then 
  1185. 		character_evacuate_from_all_vehicles(REMOTE_PLAYER) 
  1186. 	end 
  1187.  
  1188. 	-- Teleport the player(s) to where they will need to be 
  1189. 	if (is_demo_execution()) then 
  1190. 		teleport(LOCAL_PLAYER, LOCAL_PLAYER_DEMO) 
  1191. 		if (coop_is_active()) then 
  1192. 			teleport(REMOTE_PLAYER, REMOTE_PLAYER_DEMO) 
  1193. 		end 
  1194. 	end 
  1195.  
  1196. 	-- Show the autosave tutorial 
  1197. 	tutorial_start("autosave", 3000) 
  1198. end 
  1199.  
  1200. function tss01_monitor_swim_failure() 
  1201.  
  1202. 	-- In coop, there might be a brief period when we think that our partner is further away than they actually are. 
  1203. 	-- So don't start checking the distance immediately. It'll take awhile to get that far out anyway. 
  1204. 	delay(20) 
  1205.  
  1206. 	-- Get the furthest distance from the prison island's center to a player 
  1207. 	local function get_current_dist() 
  1208. 		local max_dist = get_dist(LOCAL_PLAYER, NAVP_ISLAND_CENTER) 
  1209. 		if(coop_is_active()) then 
  1210. 			max_dist = max(max_dist, get_dist(REMOTE_PLAYER, NAVP_ISLAND_CENTER)) 
  1211. 		end 
  1212. 		return max_dist 
  1213. 	end 
  1214.  
  1215. 	-- Wait until a player is too far from the island 
  1216. 	while(get_current_dist() < MAX_SWIM_DISTANCE_M) do 
  1217. 		delay(0.25) 
  1218. 		thread_yield() 
  1219. 	end 
  1220.  
  1221. 	-- Too far, Carlos is abandoned 
  1222. 	tss01_abandon_carlos() 
  1223. end 
  1224.  
  1225. function tss01_failure_carlos() 
  1226. 	-- End the mission since Carlos was killed 
  1227. 	mission_end_failure("tss01", "tss01_carlos_died") 
  1228. end 
  1229.  
  1230. function tss01_abandon_carlos() 
  1231. 	-- End the mission since Carlos was abandoned 
  1232. 	mission_end_failure("tss01", "tss01_carlos_abandoned") 
  1233. end 
  1234.  
  1235. function tss01_failure_yacht() 
  1236. 	-- End the mission since the yacht was destroyed 
  1237. 	mission_end_failure("tss01", "tss01_yacht_destroyed") 
  1238. end 
  1239.  
  1240. function tss01_release_to_world(human) 
  1241. 	-- Release the human to the world 
  1242. 	release_to_world(human) 
  1243. end 
  1244.  
  1245. function tss01_get_out_of_here() 
  1246. 	-- Remove the marker 
  1247. 	if ( DOCTOR_ALLOWED ) then 
  1248. 		marker_remove_npc(CHARACTER_DOCTOR, SYNC_ALL) 
  1249. 	end 
  1250.  
  1251. 	-- Make sure Carlos is no longer leashed... 
  1252. 	npc_leash_remove(CHARACTER_CARLOS) 
  1253.  
  1254. 	-- Delay for a short period of time 
  1255. 	delay(2.0) 
  1256. 	-- Play audio line for Carlos 
  1257. 	tss01_audio_play_for_character("CARLOS_TSSP1_ESCAPE", CHARACTER_CARLOS, "voice", false, true) 
  1258.  
  1259. 	-- Show the objective 
  1260. --	mission_help_table("tss01_choose") 
  1261.  
  1262. 	-- Unlock the doors 
  1263. --	door_lock(Tss01_doors[BACK_DOOR], false) 
  1264. --	door_lock(Tss01_doors[FRONT_DOOR_1], false) 
  1265. --	door_lock(Tss01_doors[FRONT_DOOR_2], false) 
  1266.  
  1267. 	-- Delay a little while 
  1268. --	delay(4.0) 
  1269.  
  1270. 	delay(0.5) 
  1271.  
  1272. 	-- In Coop, make sure that no one can die while the vint dialog box is up.  
  1273. 	if (IN_COOP) then 
  1274. 		while(not (character_is_ready(LOCAL_PLAYER) and character_is_ready(REMOTE_PLAYER)) ) do 
  1275. 			thread_yield() 
  1276. 		end 
  1277. 		turn_invulnerable(LOCAL_PLAYER, false) 
  1278. 		turn_invulnerable(REMOTE_PLAYER, false) 
  1279. 	end 
  1280.  
  1281. 	local	path_choice = open_vint_dialog("tss01_choose", "tss01_body", "tss01_tutorial", "tss01_run_gun") 
  1282.  
  1283. 	if (IN_COOP) then 
  1284. 		turn_vulnerable(LOCAL_PLAYER) 
  1285. 		turn_vulnerable(REMOTE_PLAYER) 
  1286. 	end 
  1287.  
  1288. 	if (path_choice == 0) then 
  1289. 		door_lock(Tss01_doors[BACK_DOOR], false) 
  1290.  
  1291. 		trigger_enable(BACK_DOOR_TRIGGER, true) 
  1292. 		on_trigger("tss01_disable_exit_trigger", BACK_DOOR_TRIGGER) 
  1293. 		marker_add_trigger(BACK_DOOR_TRIGGER, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  1294. 	else 
  1295. 		door_lock(Tss01_doors[FRONT_DOOR_1], false) 
  1296. 		door_lock(Tss01_doors[FRONT_DOOR_2], false) 
  1297.  
  1298. 		trigger_enable(FRONT_DOOR_TRIGGER, true) 
  1299. 		on_trigger("tss01_disable_exit_trigger", FRONT_DOOR_TRIGGER) 
  1300. 		marker_add_trigger(FRONT_DOOR_TRIGGER, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  1301. 	end 
  1302.  
  1303. 	-- Spawn a thread to show the necessary messages 
  1304. --	thread_new("tss01_what_path") 
  1305. end 
  1306.  
  1307. function tss01_disable_exit_trigger(human, trigger) 
  1308. 	-- Disable the trigger 
  1309. 	trigger_enable(trigger, false) 
  1310. 	-- Remove the marker 
  1311. 	marker_remove_trigger(trigger, SYNC_ALL) 
  1312. end 
  1313.  
  1314. function tss01_what_path() 
  1315. 	local	back_door_closed = not door_is_open(Tss01_doors[BACK_DOOR]) 
  1316. 	local front_doors_closed = not door_is_open(Tss01_doors[FRONT_DOOR_1]) and not door_is_open(Tss01_doors[FRONT_DOOR_2]) 
  1317.  
  1318. 	local local_was_near_back = false 
  1319. 	local remote_was_near_back = false 
  1320. 	local local_was_near_front = false 
  1321. 	local remote_was_near_front = false 
  1322. 	local local_was_near_door = false 
  1323. 	local remote_was_near_door = false 
  1324.  
  1325. 	-- Check player distances until a door is no longer closed 
  1326. 	while (back_door_closed and front_doors_closed) do 
  1327. 		local		local_close_to_back = (get_dist_char_to_nav(LOCAL_PLAYER, BACK_DOOR_POS) < 9.0) 
  1328. 		local		local_close_to_front = (get_dist_char_to_nav(LOCAL_PLAYER, FRONT_DOOR_POS) < 11.0) 
  1329. 		local		remote_close_to_back = false 
  1330. 		local		remote_close_to_front = false 
  1331.  
  1332. 		if (IN_COOP) then 
  1333. 			remote_close_to_back = (get_dist_char_to_nav(REMOTE_PLAYER, BACK_DOOR_POS) < 9.0) 
  1334. 			remote_close_to_front = (get_dist_char_to_nav(REMOTE_PLAYER, FRONT_DOOR_POS) < 11.0) 
  1335. 		end 
  1336.  
  1337. 		local		local_close_to_door_msg = false 
  1338. 		local		remote_close_to_door_msg = false 
  1339.  
  1340. 		-- Check to see if we need to show the door message 
  1341. 		for i = 1, Num_tss01_door_msg, 1 do 
  1342. 			if (get_dist_char_to_nav(LOCAL_PLAYER, Tss01_door_msg[i]) < 1.5) then 
  1343. 				local_close_to_door_msg = true 
  1344. 				break 
  1345. 			end 
  1346. 		end 
  1347.  
  1348. 		if (IN_COOP) then 
  1349. 			for i = 1, Num_tss01_door_msg, 1 do 
  1350. 				if (get_dist_char_to_nav(REMOTE_PLAYER, Tss01_door_msg[i]) < 1.5) then 
  1351. 					remote_close_to_door_msg = true 
  1352. 					break 
  1353. 				end 
  1354. 			end 
  1355. 		end 
  1356. 		 
  1357. 		-- Check the local player 
  1358. 		if (not local_was_near_back and local_close_to_back and not local_close_to_door_msg) then 
  1359. 			mission_help_table_nag("tss01_tutorial", nil, nil, SYNC_LOCAL) 
  1360. 		elseif (local_close_to_back and local_was_near_door and not local_close_to_door_msg) then 
  1361. 			mission_help_table_nag("tss01_tutorial", nil, nil, SYNC_LOCAL) 
  1362. 		elseif (not local_was_near_front and local_close_to_front and not local_close_to_door_msg) then 
  1363. 			mission_help_table_nag("tss01_run_gun", nil, nil, SYNC_LOCAL) 
  1364. 		elseif (local_close_to_front and local_was_near_door and not local_close_to_door_msg) then 
  1365. 			mission_help_table_nag("tss01_run_gun", nil, nil, SYNC_LOCAL) 
  1366. 		elseif (local_was_near_back and not local_close_to_back) then 
  1367. 			mission_help_clear(SYNC_LOCAL) 
  1368. 		elseif (local_was_near_front and not local_close_to_front) then 
  1369. 			mission_help_clear(SYNC_LOCAL) 
  1370. 		elseif (not local_was_near_door and local_close_to_door_msg) then 
  1371. 			mission_help_clear(SYNC_LOCAL) 
  1372. 		end 
  1373.  
  1374. 		-- Check the remote player 
  1375. 		if (not remote_was_near_back and remote_close_to_back and not remote_close_to_door_msg) then 
  1376. 			mission_help_table_nag("tss01_tutorial", nil, nil, SYNC_REMOTE) 
  1377. 		elseif (remote_close_to_back and remote_was_near_door and not remote_close_to_door_msg) then 
  1378. 			mission_help_table_nag("tss01_tutorial", nil, nil, SYNC_REMOTE) 
  1379. 		elseif (not remote_was_near_front and remote_close_to_front and not remote_close_to_door_msg) then 
  1380. 			mission_help_table_nag("tss01_run_gun", nil, nil, SYNC_REMOTE) 
  1381. 		elseif (remote_close_to_front and remote_was_near_door and not remote_close_to_door_msg) then 
  1382. 			mission_help_table_nag("tss01_run_gun", nil, nil, SYNC_REMOTE) 
  1383. 		elseif (remote_was_near_back and not remote_close_to_back) then 
  1384. 			mission_help_clear(SYNC_REMOTE) 
  1385. 		elseif (remote_was_near_front and not remote_close_to_front) then 
  1386. 			mission_help_clear(SYNC_REMOTE) 
  1387. 		elseif (not remote_was_near_door and remote_close_to_door_msg) then 
  1388. 			mission_help_clear(SYNC_REMOTE) 
  1389. 		end 
  1390.  
  1391. 		-- Update our variables 
  1392. 		local_was_near_back = local_close_to_back 
  1393. 		remote_was_near_back = remote_close_to_back 
  1394. 		local_was_near_front = local_close_to_front 
  1395. 		remote_was_near_front = remote_close_to_front 
  1396. 		local_was_near_door = local_close_to_door_msg 
  1397. 		remote_was_near_door = remote_close_to_door_msg 
  1398.  
  1399. 		-- Wait to check again 
  1400. 		thread_yield() 
  1401. 		-- Check the doors 
  1402. 		back_door_closed = not door_is_open(Tss01_doors[BACK_DOOR]) 
  1403. 		front_doors_closed = not door_is_open(Tss01_doors[FRONT_DOOR_1]) and not door_is_open(Tss01_doors[FRONT_DOOR_2]) 
  1404. 	end 
  1405. end 
  1406.  
  1407. function tss01_carlos_can_use_melee_weapons() 
  1408. 	-- Continually look at Carlos' melee slot 
  1409. 	while (1) do 
  1410. 		local		item_in_slot = inv_item_in_slot(CHARACTER_CARLOS, "melee") 
  1411.  
  1412. 		-- Check to see if the weapon in this slot is equipped 
  1413. 		if (not inv_item_is_equipped(item_in_slot, CHARACTER_CARLOS)) then 
  1414. 			-- Equip this item 
  1415. 			inv_item_equip(item_in_slot, CHARACTER_CARLOS) 
  1416. 		end 
  1417.  
  1418. 		-- Only need to check every second or so 
  1419. 		delay(1.0) 
  1420. 	end 
  1421. end 
  1422.  
  1423. function tss01_jump_climb_first_time(human, trigger) 
  1424. 	-- Changed to help text 
  1425. 	mission_help_table_nag("tss01_jump_climb") 
  1426.  
  1427. 	-- NOTE: Not changing this...there use to be a line that played here only the first time 
  1428. 	--		this type of trigger was hit...keeping in case things change 
  1429. 	 
  1430. 	-- After this has been hit the first time, the callback changes 
  1431. 	on_trigger("tss01_jump_climb", JUMP_CLIMB_TRIGGER) 
  1432. 	-- Enable the trigger exit callback 
  1433. 	on_trigger_exit("tss01_jump_climb_exit", JUMP_CLIMB_TRIGGER) 
  1434. 	on_trigger_exit("tss01_jump_climb_exit", JUMP_CLIMB_TRIGGER_REPEAT) 
  1435. end 
  1436.  
  1437. function tss01_jump_climb() 
  1438. 	-- Show the jump/climb message now 
  1439. 	mission_help_table_nag("tss01_jump_climb") 
  1440.  
  1441. 	-- Enable the trigger exit callback 
  1442. 	on_trigger_exit("tss01_jump_climb_exit", JUMP_CLIMB_TRIGGER) 
  1443. 	on_trigger_exit("tss01_jump_climb_exit", JUMP_CLIMB_TRIGGER_REPEAT) 
  1444. end 
  1445.  
  1446. function tss01_jump_climb_exit() 
  1447. 	-- Disable the trigger exit 
  1448. 	on_trigger_exit("", JUMP_CLIMB_TRIGGER) 
  1449. 	on_trigger_exit("", JUMP_CLIMB_TRIGGER_REPEAT) 
  1450. 	-- Clear the mission help message when these triggers are exited 
  1451. 	mission_help_clear() 
  1452. end 
  1453.  
  1454. function tss01_start_crouch(human, trigger) 
  1455. 	-- The human to enter the trigger needs to be the local player 
  1456. 	if (((human == LOCAL_PLAYER) or (human == REMOTE_PLAYER)) and (trigger == CROUCH_TRIGGER)) then 
  1457. 		-- Show help text about crouching... 
  1458. 		mission_help_table_nag("tss01_crouch") 
  1459.  
  1460. 		-- Enable the crouch trigger callback for the player 
  1461. 		on_trigger_exit("tss01_crouch_exit", CROUCH_TRIGGER) 
  1462. 	end 
  1463. end 
  1464.  
  1465. function tss01_crouch_exit() 
  1466. 	-- Disable the callback 
  1467. 	on_trigger_exit("", CROUCH_TRIGGER) 
  1468. 	-- Clear the mission help message when this trigger is exited 
  1469. 	mission_help_clear() 
  1470. end 
  1471.  
  1472. function tss01_start_crouch_carlos(human) 
  1473. 	-- This trigger only needs to process Carlos 
  1474. 	if (human == CHARACTER_CARLOS) then 
  1475. 		-- Force Carlos to start crouching 
  1476. 		crouch_start(CHARACTER_CARLOS, true) 
  1477. 	end 
  1478. end 
  1479.  
  1480. function tss01_stop_crouch_carlos(human) 
  1481. 	-- This trigger only needs to process Carlos 
  1482. 	if (human == CHARACTER_CARLOS) then 
  1483. 		-- Force Carlos to stop crouching 
  1484. 		crouch_stop(CHARACTER_CARLOS) 
  1485. 	end 
  1486. end 
  1487.  
  1488. function tss01_backdoor() 
  1489. 	-- Lock the front doors 
  1490. 	door_lock(Tss01_doors[FRONT_DOOR_1], true) 
  1491. 	door_lock(Tss01_doors[FRONT_DOOR_2], true) 
  1492.  
  1493. 	door_message_override(Tss01_doors[BACK_DOOR], "") 
  1494. 	door_message_override(Tss01_doors[FRONT_DOOR_1], "") 
  1495. 	door_message_override(Tss01_doors[FRONT_DOOR_2], "") 
  1496.  
  1497. 	-- Remove the callbacks 
  1498. 	on_door_opened("", Tss01_doors[BACK_DOOR]) 
  1499. 	on_door_opened("", Tss01_doors[FRONT_DOOR_1]) 
  1500. 	on_door_opened("", Tss01_doors[FRONT_DOOR_2]) 
  1501.  
  1502. 	-- Spawn off a thread to force Carlos to equip a melee weapon if he picks it up 
  1503. 	CARLOS_THREAD_HANDLE = thread_new("tss01_carlos_can_use_melee_weapons") 
  1504.  
  1505. 	trigger_enable(JUMP_CLIMB_TRIGGER, true) 
  1506. 	on_trigger("tss01_jump_climb_first_time", JUMP_CLIMB_TRIGGER) 
  1507. 	 
  1508. 	trigger_enable(JUMP_CLIMB_TRIGGER_REPEAT, true) 
  1509. 	on_trigger("tss01_jump_climb", JUMP_CLIMB_TRIGGER_REPEAT) 
  1510. 	 
  1511. 	trigger_enable(CROUCH_CARLOS_TRIGGER, true) 
  1512. 	on_trigger("tss01_start_crouch_carlos", CROUCH_CARLOS_TRIGGER) 
  1513. 	on_trigger_exit("tss01_stop_crouch_carlos", CROUCH_CARLOS_TRIGGER) 
  1514.  
  1515. 	trigger_enable(CROUCH_TRIGGER, true) 
  1516. 	on_trigger("tss01_start_crouch", CROUCH_TRIGGER) 
  1517.  
  1518. 	tss01_tutorial() 
  1519. end 
  1520.  
  1521. function tss01_frontdoor() 
  1522. 	-- Lock the back door 
  1523. 	door_lock(Tss01_doors[BACK_DOOR], true) 
  1524.  
  1525. 	door_message_override(Tss01_doors[BACK_DOOR], "") 
  1526. 	door_message_override(Tss01_doors[FRONT_DOOR_1], "") 
  1527. 	door_message_override(Tss01_doors[FRONT_DOOR_2], "") 
  1528.  
  1529. 	-- Remove the callbacks 
  1530. 	on_door_opened("", Tss01_doors[BACK_DOOR]) 
  1531. 	on_door_opened("", Tss01_doors[FRONT_DOOR_1]) 
  1532. 	on_door_opened("", Tss01_doors[FRONT_DOOR_2]) 
  1533.  
  1534. 	-- Check to see if this mission has already been completed 
  1535. 	if (not mission_is_complete("tss01")) then 
  1536. 		-- We chose the non-tutorial route (the front door) 
  1537. 		-- 
  1538. 		-- Set the mission globals variable for having not taken the tutorial path 
  1539. 		-- 
  1540. 		Tss01_tutorial_route_chosen = false 
  1541. 	end 
  1542.  
  1543. 	trigger_enable(RUN_GUN_SPRINT_TRIGGER, true) 
  1544. 	on_trigger("tss01_sprint_tut", RUN_GUN_SPRINT_TRIGGER) 
  1545.  
  1546. 	tss01_blazing_guns() 
  1547. end 
  1548.  
  1549.  
  1550. function tss01_sprint_tut() 
  1551.  
  1552. 	-- Disable the trigger 
  1553. 	on_trigger("", RUN_GUN_SPRINT_TRIGGER) 
  1554. 	trigger_enable(RUN_GUN_SPRINT_TRIGGER, false) 
  1555. 	 
  1556. 	-- Show the checkpoint tutorial 
  1557. 	tutorial_start("sprint") 
  1558.  
  1559. end 
  1560.  
  1561. function tss01_tutorial() 
  1562. 	-- Destroy the cafeteria guards 
  1563. 	group_destroy(GROUP_CAFE_GUARDS) 
  1564. 	-- Destroy the Run & Gun Prisoners 
  1565. 	group_destroy(GROUP_NON_TUT_PRISONERS) 
  1566. 	-- Setup the callback to show the next objective 
  1567. 	on_door_opened("tss01_kill_guards", "tss01_PI_vkp_jail_FDoor050") 
  1568. 	-- Play exchange between Carlos and the Player 
  1569. 	thread_new("tss01_audio_play_conversation", Tss01_carlos_exchange_1) 
  1570. end 
  1571.  
  1572. function tss01_carlos_make_dependent() 
  1573. 	if(CARLOS_HIDE_THREAD_HANDLE ~= INVALID_THREAD_HANDLE) then 
  1574. 		thread_kill(CARLOS_HIDE_THREAD_HANDLE ) 
  1575. 		CARLOS_HIDE_THREAD_HANDLE  = INVALID_THREAD_HANDLE 
  1576. 	end 
  1577. 	follower_make_independent(CHARACTER_CARLOS, false) 
  1578. end 
  1579.  
  1580. function tss01_carlos_move(point, speed) 
  1581.  
  1582. 	if (speed == nil) then 
  1583. 		speed = 3 
  1584. 	end 
  1585.  
  1586. 	-- If Carlos is knocked out, wait for revival 
  1587. 	while (follower_is_unconscious(CHARACTER_CARLOS)) do 
  1588. 		thread_yield() 
  1589. 	end 
  1590.  
  1591. 	if (character_is_in_vehicle(CHARACTER_CARLOS)) then 
  1592. 		return 
  1593. 	end 
  1594.  
  1595. 	-- Make Carlos idle first 
  1596. 	npc_go_idle(CHARACTER_CARLOS) 
  1597. 	-- Yield for one thread cycle 
  1598. 	thread_yield() 
  1599. 	-- Move Carlos to point 
  1600. 	move_to_safe(CHARACTER_CARLOS, point, speed, true) 
  1601. end 
  1602.  
  1603. Tss01_kill_guards_triggered = false 
  1604. function tss01_kill_guards() 
  1605.  
  1606. 	--[[ 
  1607. 	local debug_text = "tss01_kill_guards, Tss01_kill_guards_triggered = " 
  1608. 	if (Tss01_kill_guards_triggered == false) then 
  1609. 		debug_text = debug_text .. "false"		 
  1610. 	else 
  1611. 		debug_text = debug_text .. "true"		 
  1612. 	end 
  1613. 	mission_debug(debug_text, 10, -1) 
  1614. 	]] 
  1615.  
  1616. 	if (Tss01_kill_guards_triggered == false) then 
  1617.  
  1618. 		Tss01_kill_guards_triggered = true 
  1619.  
  1620. 		-- We do not want this callback to happen again 
  1621. 		on_door_opened("", "tss01_PI_vkp_jail_FDoor050") 
  1622.  
  1623. 		for i = 1, Num_tss01_key_guards, 1 do 
  1624. 			on_death("tss01_tutorial_guard_death", Tss01_key_guards[i]) 
  1625. 			marker_add_npc(Tss01_key_guards[i], MINIMAP_ICON_KILL, INGAME_EFFECT_KILL) 
  1626. 			attack(Tss01_key_guards[i]) 
  1627. 		end 
  1628.  
  1629. 		 
  1630. 		-- If the doctor isn't allowed in this build, display the melee combat tutorial here 
  1631. 		if (not DOCTOR_ALLOWED ) then 
  1632. 			delay(1.0) 
  1633. 			tutorial_start("combat") 
  1634. 		end 
  1635.  
  1636. 		-- Show the kill guards text 
  1637. 		delay(1.5) 
  1638. 		mission_help_table("tss01_kill_guards") 
  1639.  
  1640. 	end 
  1641. end 
  1642.  
  1643. function tss01_tutorial_guard_death(human) 
  1644. 	-- Remove the callback 
  1645. 	on_death("", human) 
  1646. 	-- Remove the marker 
  1647. 	marker_remove_npc(human) 
  1648.  
  1649. 	-- Release this bad boy to the world 
  1650. 	release_to_world(human) 
  1651.  
  1652. 	-- Increment the count 
  1653. 	Num_key_guards_killed = Num_key_guards_killed + 1 
  1654.  
  1655. 	-- If the condition is met, proceed to have Carlos take the lead 
  1656. 	if (Num_key_guards_killed == Num_tss01_key_guards) then 
  1657. 		-- Carlos needs to be alive 
  1658. 		while (follower_is_unconscious(CHARACTER_CARLOS)) do 
  1659. 			thread_yield() 
  1660. 		end 
  1661.  
  1662. 		-- Have Carlos take the lead 
  1663. 		follower_make_independent(CHARACTER_CARLOS, true) 
  1664.  
  1665. 		-- Play audio line for Carlos 
  1666. 		tss01_audio_play_for_character("CARLOS_TSSP1_TUTORIAL", CHARACTER_CARLOS, "voice", false, true) 
  1667.  
  1668. 		-- Tell the player to follow Carlos to the roof 
  1669. 		mission_help_table("tss01_follow") 
  1670.  
  1671. 		-- Enable the first waypoint 
  1672. 		tss01_waypoint01() 
  1673.  
  1674. 		-- Carlos should not flinch or ragdoll from here to the roof 
  1675. 		character_prevent_flinching(CHARACTER_CARLOS, true) 
  1676. 		character_allow_ragdoll(CHARACTER_CARLOS, false) 
  1677. 		turn_invulnerable(CHARACTER_CARLOS) 
  1678.  
  1679. 		-- Kepp the players away from the doors 
  1680. 		thread_new("tss01_keep_player_away_from_door", LOCAL_PLAYER) 
  1681. 		if (IN_COOP) then 
  1682. 			thread_new("tss01_keep_player_away_from_door", REMOTE_PLAYER) 
  1683. 		end 
  1684.  
  1685. 		-- Tell Carlos to go to the door 
  1686. 		tss01_carlos_move(KEY_TRIGGER, 3) 
  1687. 	end 
  1688. end 
  1689.  
  1690. -- Keep the players away from the door that Carlos is supposed to be kicking open. 
  1691. function tss01_keep_player_away_from_door(player) 
  1692.  
  1693. 	local controls_disabled = false 
  1694. 	local door = Tss01_doors[KEY_DOOR] 
  1695. 	local navs = {[LOCAL_PLAYER] = "tss01_$n142", [REMOTE_PLAYER] = "tss01_$n143"} 
  1696.  
  1697. 	while(not door_is_open(door)) do 
  1698. 		thread_yield() 
  1699. 		if ( (get_dist(player, door) < 2) and (not controls_disabled)) then 
  1700. 			controls_disabled = true 
  1701. 			player_controls_disable(player) 
  1702.  
  1703. 			-- Make Carlos not collide w/ other humans  
  1704. 			npc_enable_human_collision(CHARACTER_CARLOS, false) 
  1705. 			 
  1706. 			move_to_safe(player, navs[player], 2, true) 
  1707. 		end 
  1708. 	end 
  1709.  
  1710. 	delay(.5) 
  1711.  
  1712. 	-- Make Carlos collide w/ other humans 
  1713. 	npc_enable_human_collision(CHARACTER_CARLOS, true) 
  1714.  
  1715. 	if(controls_disabled) then 
  1716. 		player_controls_enable(player) 
  1717. 	end 
  1718.  
  1719. end 
  1720.  
  1721.  
  1722. function tss01_blazing_guns() 
  1723. 	-- Destroy the key guards 
  1724. 	group_destroy(GROUP_KEY_GUARDS) 
  1725.  
  1726. 	-- Destroy the tutorial path extras 
  1727. 	group_destroy(GROUP_TUT_PRISONERS) 
  1728.  
  1729. 	-- Enable the trigger used when going to the armory 
  1730. 	trigger_enable(RUN_GUN_TRIGGER_2ND_FLOOR, true) 
  1731. 	on_trigger("tss01_2nd_floor_setup", RUN_GUN_TRIGGER_2ND_FLOOR) 
  1732.  
  1733. 	-- Enable the trigger used when we enter the court yard 
  1734. 	trigger_enable(RUN_GUN_TRIGGER_1, true) 
  1735. 	on_trigger("tss01_courtyard_setup", RUN_GUN_TRIGGER_1) 
  1736.  
  1737. 	-- Enable the door open callback 
  1738. 	thread_new("tss01_guard_attack") 
  1739.  
  1740. 	-- Sound the audio if it hasn't been already 
  1741. 	if (ALARM_THREAD_HANDLE == INVALID_THREAD_HANDLE) then 
  1742. 		ALARM_THREAD_HANDLE = thread_new("tss01_escape_alarms", false, false, true) 
  1743. 	end 
  1744.  
  1745. 	-- Have this guard use his best weapon 
  1746. --	npc_unholster_best_weapon(Tss01_cafe_guards[CAFE_GUARD_WEAPON]) 
  1747. 	-- This guard can't hit shit 
  1748. --	npc_weapon_spread(Tss01_cafe_guards[CAFE_GUARD_WEAPON], 4.0) 
  1749.  
  1750. 	-- This will trigger the fine aim tutorial...since it is new we want to show it 
  1751. 	on_weapon_fired("tss01_blazing_weapon_fired", LOCAL_PLAYER) 
  1752. 	if (IN_COOP) then 
  1753. 		on_weapon_fired("tss01_blazing_weapon_fired", REMOTE_PLAYER) 
  1754. 	end 
  1755.  
  1756. 	-- Spawn off a thread to tell the guards to attack 
  1757. 	thread_new("tss01_guards_attack") 
  1758.  
  1759. 	-- If the doctor isn't allowed in this build, display the melee combat tutorial here 
  1760. 	if (not DOCTOR_ALLOWED ) then 
  1761. 		delay(1.0) 
  1762. 		tutorial_start("combat") 
  1763. 	end 
  1764.  
  1765. 	-- Play audio line for Carlos 
  1766. 	tss01_audio_play_for_character("CARLOS_TSSP1_RUNGUN_3", CHARACTER_CARLOS, "voice", false, true) 
  1767.  
  1768. 	-- Prompt the user with help text 
  1769. 	mission_help_table("tss01_docks") 
  1770.  
  1771. 	tss01_waypoint10() 
  1772.  
  1773. 	-- Delay for for a short period of time... 
  1774. 	delay(0.5) 
  1775.  
  1776. 	-- Play the exchange between Carlos and the player 
  1777. 	tss01_audio_play_conversation(Tss01_carlos_exchange_1) 
  1778. end 
  1779.  
  1780. function tss01_guards_attack() 
  1781. 	-- Delay for a short period of time 
  1782. 	delay(1.0) 
  1783. 	 
  1784. 	-- Have the cafe guards attack the player if they have not already 
  1785. 	for i = 1, Num_tss01_cafe_guards, 1 do 
  1786. 		npc_leash_remove(Tss01_cafe_guards[i]) 
  1787. 		attack(Tss01_cafe_guards[i], CLOSEST_PLAYER) 
  1788. 	end 
  1789. end 
  1790.  
  1791. function tss01_blazing_weapon_fired(human, weapon, name) 
  1792. 	-- Only do this for when a weapon is fired 
  1793. 	if (name ~= "firearm") then 
  1794. 		return 
  1795. 	end 
  1796. 	 
  1797. 	-- Do not allow this callback to happen again 
  1798. 	on_weapon_fired("", LOCAL_PLAYER) 
  1799. 	if (IN_COOP) then 
  1800. 		on_weapon_fired("", REMOTE_PLAYER) 
  1801. 	end 
  1802.  
  1803. 	-- Do the tutorial 
  1804.  
  1805. 	-- Disabled for now in the run and gun path 
  1806. --	tutorial_start("combat_fineaim", 500, true) 
  1807. end 
  1808.  
  1809. function tss01_sound_escape_alarms() 
  1810.  
  1811. 	thread_new("tss01_prisoners_riot") 
  1812. 	thread_new("tss01_bullhorn_audio") 
  1813.  
  1814. 	local	audio_ext_id = audio_get_id("SFX_ALARM_5", "foley") 
  1815. 	local	audio_int_id = audio_get_id("SFX_ALARM_3", "foley") 
  1816.  
  1817. 	-- Fire off the exterior alarms 
  1818. 	for i = 1, Num_tss01_alarm_ext_pos, 1 do 
  1819. 		if (Tss01_audio_ext_inst[i] == 0) then 
  1820. 			Tss01_audio_ext_inst[i] = audio_play_emitting_id_for_navpoint(Tss01_alarm_ext_pos[i], audio_ext_id) 
  1821. 		end 
  1822. 	end 
  1823.  
  1824. 	-- Fire off the interior alarms 
  1825. 	for i = 1, Num_tss01_alarm_int_pos, 1 do 
  1826. 		if (Tss01_audio_int_inst[i] == 0) then 
  1827. 			Tss01_audio_int_inst[i] = audio_play_emitting_id_for_navpoint(Tss01_alarm_int_pos[i], audio_int_id) 
  1828. 		end 
  1829. 	end 
  1830.  
  1831. end 
  1832.  
  1833. function tss01_prisoners_riot() 
  1834.  
  1835. 	delay(1.0) 
  1836.  
  1837. 	local	prisoner_audio_ext_id = audio_get_id("SFX_TSS01_PRISONERS_OUTDOOR", "foley") 
  1838. 	local	prisoner_audio_int_id = audio_get_id("SFX_TSS01_PRISONERS_INDOOR", "foley") 
  1839.  
  1840. 	-- Fire off the external alarms 
  1841. 	for i = 1, Num_tss01_prisoner_ext_pos, 1 do 
  1842. 		if (Tss01_audio_prisoner_ext_inst[i] == 0) then 
  1843. 			Tss01_audio_prisoner_ext_inst[i] = audio_play_emitting_id_for_navpoint(Tss01_prisoner_audio_ext_pos[i], prisoner_audio_ext_id) 
  1844. 		end 
  1845. 	end 
  1846.  
  1847. 	-- Fire off the interior alarms 
  1848. 	for i = 1, Num_tss01_prisoner_int_pos, 1 do 
  1849. 		if (Tss01_audio_prisoner_int_inst[i] == 0) then 
  1850. 			Tss01_audio_prisoner_int_inst[i] = audio_play_emitting_id_for_navpoint(Tss01_prisoner_audio_int_pos[i], prisoner_audio_int_id) 
  1851. 		end 
  1852. 	end 
  1853.  
  1854. end 
  1855.  
  1856. function tss01_bullhorn_audio() 
  1857. 	 
  1858. 	delay(0.5) 
  1859.  
  1860. 	local speaker_sfx = {"SFX_TSS01_BULLHORN_01", "SFX_TSS01_BULLHORN_02", "SFX_TSS01_BULLHORN_03", "SFX_TSS01_BULLHORN_04", "SFX_TSS01_BULLHORN_05"} 
  1861. 	local num_speaker_sfx = sizeof_table(speaker_sfx) 
  1862.  
  1863. 	local heli_list = {SPOT_LIGHT_HELI, HELI_AMBUSH_VEHICLE, FINE_AIM_VEHICLE} 
  1864.  
  1865. 	local recent_sfx = { "", "" } 
  1866. 	local function get_next_sfx() 
  1867.  
  1868. 		while(true) do 
  1869. 			local next_sfx = speaker_sfx[rand_int(1,num_speaker_sfx)] 
  1870. 			if ( (next_sfx ~= recent_sfx[1]) and (next_sfx ~= recent_sfx[2]) ) then 
  1871. 				recent_sfx[1],recent_sfx[2] = next_sfx, recent_sfx[1] 
  1872. 				return next_sfx 
  1873. 			end 
  1874. 		end 
  1875.  
  1876. 	end 
  1877.  
  1878. 	while (not Tss01_boat_sequence_begun) do 
  1879.  
  1880. 		thread_yield() 
  1881.  
  1882. 		-- Just wait a bit if audio is already playing 
  1883. 		if audio_is_playing(Tss01_loud_speaker_audio_inst) then 
  1884. 			thread_yield() 
  1885. 		else 
  1886. 			local dist, player = get_dist_closest_player_to_object("tss01_$bullhorn_1") 
  1887. 			if (dist < MAX_BULLHORN_DIST) then 
  1888. 				local	audio_id, type = audio_get_id(get_next_sfx(), "foley") 
  1889. 				Tss01_loud_speaker_audio_inst = audio_play_id_for_navpoint("tss01_$bullhorn_1", audio_id, type) 
  1890. 				delay(rand_int(LAND_BULLHORN_DELAY_RANGE[1], LAND_BULLHORN_DELAY_RANGE[2])) 
  1891. 			end 
  1892. 		end 
  1893.  
  1894. 		-- Just wait a bit if audio is already playing 
  1895. 		if audio_is_playing(Tss01_heli_speaker_audio_inst) then 
  1896. 			thread_yield() 
  1897. 		else 
  1898.  
  1899. 			-- Build a list of helis that can emit bullhorn audio 
  1900. 			local nearby_helis = {} 
  1901. 			local num_nearby_helis = 0 
  1902. 			for i, heli in pairs(heli_list) do  
  1903. 				if (	vehicle_exists(heli) and  
  1904. 						(not vehicle_hidden(heli)) and  
  1905. 						(not vehicle_is_destroyed(heli)) and  
  1906. 						((vehicle_get_driver(heli) ~= nil)) ) then 
  1907. 					local dist, player = get_dist_closest_player_to_object(heli) 
  1908. 					if (dist < MAX_BULLHORN_DIST) then 
  1909. 						num_nearby_helis = num_nearby_helis + 1 
  1910. 						nearby_helis[num_nearby_helis] = heli 
  1911. 					end 
  1912. 				end 
  1913. 			end 
  1914.  
  1915. 			-- Play the audio at a randomly selected heli from our list 
  1916. 			if (num_nearby_helis > 0) then 
  1917. 				local heli = nearby_helis[rand_int(1,num_nearby_helis)] 
  1918. 				local	audio_id, type = audio_get_id(get_next_sfx(), "foley") 
  1919. 				local driver = vehicle_get_driver(heli) 
  1920. 				if (driver ~= nil) then 
  1921. 					Tss01_heli_speaker_audio_inst = audio_play_id_for_character(vehicle_get_driver(heli), audio_id, type) 
  1922. 					delay(rand_int(BULLHORN_DELAY_RANGE[1], BULLHORN_DELAY_RANGE[2])) 
  1923. 				end 
  1924. 			end 
  1925.  
  1926.  
  1927. 		end 
  1928.  
  1929. 	end 
  1930.  
  1931. end 
  1932.  
  1933. function tss01_boat_chase_bullhorn_audio() 
  1934. 	 
  1935. 	delay(0.5) 
  1936.  
  1937. 	local heli_list = {GROUP_HELI, GROUP_HELI_1, GROUP_HELI_2, GROUP_HELI_3} 
  1938.  
  1939. 	while (1) do 
  1940.  
  1941. 		thread_yield() 
  1942.  
  1943. 		-- Just wait a bit if audio is already playing 
  1944. 		if (	audio_is_playing(Tss01_boat_chase_heli_speaker_audio_inst) 
  1945. 				or audio_is_playing(Tss01_loud_speaker_audio_inst) 
  1946. 				or audio_is_playing(Tss01_heli_speaker_audio_inst) 
  1947. 			) then 
  1948. 			thread_yield() 
  1949. 		else 
  1950. 		-- Select a random nearby heli and have them play 
  1951. 			local nearby_helis = {} 
  1952. 			local num_nearby_helis = 0 
  1953. 			for i, heli in pairs(heli_list) do  
  1954. 				if (	vehicle_exists(heli) and  
  1955. 						(not vehicle_hidden(heli)) and  
  1956. 						(not vehicle_is_destroyed(heli)) and  
  1957. 						((vehicle_get_driver(heli) ~= nil)) ) then 
  1958. 					local dist, player = get_dist_closest_player_to_object(heli) 
  1959. 					if (dist < MAX_BULLHORN_DIST) then 
  1960. 						num_nearby_helis = num_nearby_helis + 1 
  1961. 						nearby_helis[num_nearby_helis] = heli 
  1962. 					end 
  1963. 				end 
  1964. 			end 
  1965.  
  1966. 			if (num_nearby_helis > 0) then 
  1967. 				local heli = nearby_helis[rand_int(1,num_nearby_helis)] 
  1968. 				local	audio_id, type = audio_get_id("SFX_TSS01_BOATMEGA", "foley") 
  1969. 				local driver = vehicle_get_driver(heli) 
  1970. 				if (driver ~= nil) then 
  1971. 					Tss01_boat_chase_heli_speaker_audio_inst = audio_play_id_for_character(vehicle_get_driver(heli), audio_id, type) 
  1972. 					delay(rand_int(BULLHORN_DELAY_RANGE[1], BULLHORN_DELAY_RANGE[2])) 
  1973. 				end 
  1974. 			end 
  1975.  
  1976. 		end 
  1977.  
  1978. 	end 
  1979.  
  1980. end 
  1981.  
  1982. function tss01_escape_alarms(carlos_speaks, fired_shot, do_delay) 
  1983. 	-- Remove the searchlight callback 
  1984. 	on_searchlight_track("", LOCAL_PLAYER) 
  1985. 	on_searchlight_track("", CHARACTER_CARLOS) 
  1986. 	if (IN_COOP) then 
  1987. 		on_searchlight_track("", REMOTE_PLAYER) 
  1988. 	end 
  1989.  
  1990. 	-- In case the hud timer is valid when the alarm triggers, we need to kill it 
  1991. 	hud_timer_stop(0) 
  1992. 	hud_timer_stop(1) 
  1993.  
  1994. 	-- Clear the hud from possible infinite showing text 
  1995. 	mission_help_clear() 
  1996.  
  1997. 	-- Make sure Carlos is a dependent 
  1998. 	tss01_carlos_make_dependent() 
  1999.  
  2000. 	-- Delay a short period of time before sounding the alarms 
  2001. 	if (do_delay) then 
  2002. 		delay(rand_float(2.0, 4.0)) 
  2003. 	end 
  2004.  
  2005. 	-- Kill the thread that watches Carlos and what he has equiped 
  2006. 	thread_kill(CARLOS_THREAD_HANDLE) 
  2007.  
  2008. 	-- Carlos can use a firearm weapon now 
  2009. 	npc_dont_auto_equip_or_unequip_weapons(CHARACTER_CARLOS, false) 
  2010. 	npc_unholster_best_weapon(CHARACTER_CARLOS) 
  2011.  
  2012. 	-- Set the notoriety for the rest of the mission 
  2013. 	notoriety_set_max("police", 1) 
  2014. 	notoriety_set_min("police", 1) 
  2015.  
  2016. 	-- Spawn off a new thread to handle the helicopter attacking 
  2017. 	thread_new("tss01_escape_heli", carlos_speaks, fired_shot) 
  2018.  
  2019. 	-- Do we need to play an audio line? 
  2020. 	if (carlos_speaks == true) then 
  2021. 		if (fired_shot == true) then 
  2022. 			-- Play audio line for Carlos 
  2023. 			tss01_audio_play_for_character("CARLOS_TSSP1_TRIGGER_ALARM_01", CHARACTER_CARLOS, "voice") 
  2024. 		else 
  2025. 			-- Play audio line for Carlos 
  2026. 			tss01_audio_play_for_character("CARLOS_TSSP1_ALARM", CHARACTER_CARLOS, "voice") 
  2027. 		end 
  2028. 	end 
  2029.  
  2030. 	tss01_sound_escape_alarms() 
  2031. end 
  2032.  
  2033. function tss01_escape_heli(tutorial, early_alarm) 
  2034. 	-- Create the heli group...block create 
  2035. 	if (not group_is_loaded(GROUP_HELI)) then 
  2036. 		group_create(GROUP_HELI, true) 
  2037. 	end 
  2038. 	group_create_hidden(GROUP_HELI_GUARDS) 
  2039.  
  2040. 	-- Delay and then have the helicopter attack 
  2041. 	if (not tutorial or early_alarm) then 
  2042. 		delay(rand_float(12.0, 18.0)) 
  2043. 	else 
  2044. 		delay(rand_float(2.0, 8.0)) 
  2045. 	end 
  2046.  
  2047. 	-- Show the heli and humans 
  2048. 	group_show(GROUP_HELI) 
  2049. 	group_show(GROUP_HELI_GUARDS) 
  2050.  
  2051. 	-- Put the humans in the heli 
  2052. 	vehicle_enter_teleport("tss01_$pilot", SPOT_LIGHT_HELI, 0) 
  2053. 	vehicle_enter_teleport("tss01_$spot1", SPOT_LIGHT_HELI, 4) 
  2054. 	vehicle_enter_teleport("tss01_$spot2", SPOT_LIGHT_HELI, 5) 
  2055.  
  2056. 	-- These guys need to suck at shooting... 
  2057. 	npc_weapon_spread("tss01_$spot1", tss01_get_weapon_spread(2.0)) 
  2058. 	npc_weapon_spread("tss01_$spot2", tss01_get_weapon_spread(2.0)) 
  2059.  
  2060. 	tss01_update_hit_points({"tss01_$spot1", "tss01_$spot2", "tss01_$pilot"}) 
  2061.  
  2062. 	-- Turn some lights on 
  2063. 	vehicle_lights_on(SPOT_LIGHT_HELI, true) 
  2064. 	vehicle_set_sirens(SPOT_LIGHT_HELI, true) 
  2065.  
  2066. 	-- Spawn a thread to send the attack message after the heli is in the air 
  2067. 	thread_new("tss01_escape_heli_attack") 
  2068.  
  2069. 	-- If the alarm was set off early have the heli go slow...otherwise speed to where we need to go 
  2070. 	if (tutorial) then 
  2071. 		if (early_alarm) then 
  2072. 			-- Fly slowly into position to shoot at player on 2nd roof top 
  2073. 			helicopter_fly_to_direct(SPOT_LIGHT_HELI, 15.0, "tss01_$path011") 
  2074.  
  2075. 			-- Enable the progress heli trigger 
  2076. 			trigger_enable(PROGRESS_HELI_TRIGGER, true) 
  2077. 			on_trigger("tss01_progress_heli", PROGRESS_HELI_TRIGGER) 
  2078. 		else 
  2079. 			-- Fly quicly to get into position to drop off the spotters as gunmen 
  2080. 			helicopter_fly_to_direct(SPOT_LIGHT_HELI, 50.0, "tss01_$path013") 
  2081. 		end 
  2082. 	else 
  2083. 		-- Just fly above the courtyard and wait 
  2084. 		helicopter_fly_to_direct(SPOT_LIGHT_HELI, 35.0, "tss01_$path012") 
  2085. 	end 
  2086. end 
  2087.  
  2088. function tss01_escape_heli_attack() 
  2089. 	-- Delay for a short period of time 
  2090. 	delay(1.0) 
  2091. 	-- Tell the spotters to attack 
  2092. 	attack("tss01_$spot1") 
  2093. 	attack("tss01_$spot2") 
  2094. end 
  2095.  
  2096. function tss01_progress_heli() 
  2097. 	-- Disable this trigger as it is no longer needed 
  2098. 	trigger_enable(PROGRESS_HELI_TRIGGER, false) 
  2099.  
  2100. 	-- Fly slowly into position to shoot at player on 3rd roof top 
  2101. 	helicopter_fly_to_direct(SPOT_LIGHT_HELI, 15.0, "tss01_$path011a") 
  2102. end 
  2103.  
  2104. function tss01_cancel_pursuit(human) 
  2105. 	-- Set the 2nd rooftop flags... 
  2106. 	if (human == LOCAL_PLAYER) then 
  2107. 		LOCAL_PLAYER_ON_2ND_ROOFTOP = false 
  2108. 	elseif (human == REMOTE_PLAYER) then 
  2109. 		REMOTE_PLAYER_ON_2ND_ROOFTOP = false 
  2110. 	end 
  2111. end 
  2112.  
  2113. function tss01_activate_pursuit(human) 
  2114. 	-- Deactivate the searchlights, etc. 
  2115. 	tss01_deactivate_searchlights(human) 
  2116.  
  2117. 	-- Set the 2nd rooftop flags... 
  2118. 	if (human == LOCAL_PLAYER) then 
  2119. 		LOCAL_PLAYER_ON_2ND_ROOFTOP = true 
  2120. 	elseif (human == REMOTE_PLAYER) then 
  2121. 		REMOTE_PLAYER_ON_2ND_ROOFTOP = true 
  2122. 	else 
  2123. 		return 
  2124. 	end 
  2125.  
  2126. 	-- Act accordingly 
  2127. 	if (IN_COOP) then 
  2128. 		if (LOCAL_PLAYER_ON_2ND_ROOFTOP and REMOTE_PLAYER_ON_2ND_ROOFTOP) then 
  2129. 			tss01_setup_pursuit_guards() 
  2130. 		end 
  2131. 	elseif (LOCAL_PLAYER_ON_2ND_ROOFTOP) then 
  2132. 		tss01_setup_pursuit_guards() 
  2133. 	end 
  2134. end 
  2135.  
  2136. function tss01_activate_searchlights(human) 
  2137. 	-- Check to see if the alarm is already sounding... 
  2138. 	if (not (ALARM_THREAD_HANDLE == INVALID_THREAD_HANDLE)) then 
  2139. 		-- Disable the triggers 
  2140. 		trigger_enable(PURSUIT_TRIGGER_1, false) 
  2141. 		trigger_enable(PURSUIT_TRIGGER_2, false) 
  2142. 		return 
  2143. 	end 
  2144.  
  2145. 	-- Check who needs to have this activation 
  2146. 	if (human == LOCAL_PLAYER) then 
  2147. 		on_weapon_fired("tss01_tutorial_weapon_fired", LOCAL_PLAYER) 
  2148. 		on_searchlight_track("tss01_searchlight_track", LOCAL_PLAYER) 
  2149. 	elseif (human == REMOTE_PLAYER) then 
  2150. 		on_weapon_fired("tss01_tutorial_weapon_fired", REMOTE_PLAYER) 
  2151. 		on_searchlight_track("tss01_searchlight_track", REMOTE_PLAYER) 
  2152. 	elseif (human == CHARACTER_CARLOS) then 
  2153. 		on_weapon_fired("tss01_tutorial_weapon_fired_carlos", CHARACTER_CARLOS) 
  2154. 		on_searchlight_track("tss01_searchlight_track_carlos", CHARACTER_CARLOS) 
  2155. 	end 
  2156. end 
  2157.  
  2158. function tss01_deactivate_searchlights(human) 
  2159. 	-- Check who needs to have this de-activation 
  2160. 	if (human == LOCAL_PLAYER) then 
  2161. 		-- Remove the on weapon fired and searchlight callback 
  2162. 		on_weapon_fired("", LOCAL_PLAYER) 
  2163. 		on_searchlight_track("", LOCAL_PLAYER) 
  2164. 		-- In case the hud timer is valid when the alarm triggers, we need to kill it 
  2165. 		hud_timer_stop(0) 
  2166. 		-- Stop the help text 
  2167. 		mission_help_clear(SYNC_LOCAL) 
  2168.  
  2169. 		-- Remove the on weapon fired and searchlight callback 
  2170. 		on_weapon_fired("", CHARACTER_CARLOS) 
  2171. 		on_searchlight_track("", CHARACTER_CARLOS) 
  2172. 		-- Make sure Carlos is a dependent 
  2173. 		tss01_carlos_make_dependent() 
  2174. 	elseif (human == REMOTE_PLAYER) then 
  2175. 		-- Remove the on weapon fired and searchlight callback 
  2176. 		on_weapon_fired("", REMOTE_PLAYER) 
  2177. 		on_searchlight_track("", REMOTE_PLAYER) 
  2178. 		-- In case the hud timer is valid when the alarm triggers, we need to kill it 
  2179. 		hud_timer_stop(1) 
  2180. 		-- Stop the help text 
  2181. 		mission_help_clear(SYNC_REMOTE) 
  2182. 	elseif (human == CHARACTER_CARLOS) then 
  2183. 		-- Remove the on weapon fired and searchlight callback 
  2184. 		on_weapon_fired("", CHARACTER_CARLOS) 
  2185. 		on_searchlight_track("", CHARACTER_CARLOS) 
  2186. 	end 
  2187. end 
  2188.  
  2189. function tss01_setup_pursuit_guards() 
  2190. 	-- Has the alarm been set off? 
  2191. 	if (ALARM_THREAD_HANDLE == INVALID_THREAD_HANDLE) then 
  2192. 		-- Redirect these triggers... 
  2193. 		on_trigger("tss01_deactivate_searchlights", PURSUIT_TRIGGER_1) 
  2194. 		on_trigger("tss01_activate_searchlights", PURSUIT_TRIGGER_2) 
  2195. 	else 
  2196. 		-- Disable the triggers 
  2197. 		trigger_enable(PURSUIT_TRIGGER_1, false) 
  2198. 		trigger_enable(PURSUIT_TRIGGER_2, false) 
  2199. 	end 
  2200.  
  2201. 	-- Create the group 
  2202. 	group_create(GROUP_PURSUIT_GUARDS, true) 
  2203.  
  2204. 	-- Tell the guards to attack the player(s) 
  2205. 	for i = 1, Num_tss01_pursuit_guards, 1 do 
  2206. 		attack(Tss01_pursuit_guards[i]) 
  2207. 		npc_weapon_spread(Tss01_pursuit_guards[i], tss01_get_weapon_spread(4.0)) 
  2208. 		on_death("tss01_release_to_world", Tss01_pursuit_guards[i]) 
  2209. 	end 
  2210. 	tss01_update_hit_points(Tss01_pursuit_guards) 
  2211. end 
  2212.  
  2213. function tss01_guard_attack() 
  2214. 	-- Remove the leash 
  2215. 	npc_leash_remove(CHARACTER_GUARD) 
  2216.  
  2217. 	-- Open the 1st door (This is out of sight of the pcs, we're pretending a guard opened it.) 
  2218. 	door_open(GUARD_OPEN_DOOR, true) 
  2219.  
  2220. 	-- Move the guard into position to kick open the door. 
  2221. 	npc_combat_enable(CHARACTER_GUARD, false) 
  2222. 	move_to_safe(CHARACTER_GUARD, GURAD_KICK_DOOR_POSITION2, 3, true, true) 
  2223. 	turn_to_orient(CHARACTER_GUARD, GURAD_KICK_DOOR_POSITION2) 
  2224.  
  2225. 	-- Play the door kick animation and audio 
  2226. 	action_play(CHARACTER_GUARD, "kick door", nil, true, 0.5, true) 
  2227. 	npc_combat_enable(CHARACTER_GUARD, true) 
  2228. 	audio_play("DOOR_KICK", "foley", false) 
  2229.  
  2230. 	-- Start opening the door and wait for it to open 
  2231. 	door_open(GUARD_ATTACK_DOOR, true) 
  2232. 	delay(1.0) 
  2233.  
  2234. 	-- Attack the player 
  2235. 	attack(CHARACTER_GUARD) 
  2236.  
  2237. 	-- We want this guy to react half way through 
  2238. 	thread_new("tss01_second_guard_attack") 
  2239.  
  2240. end 
  2241.  
  2242. function tss01_second_guard_attack() 
  2243. 	-- Delay this guy a bit 
  2244. 	delay(0.8) 
  2245. 	-- Remove the leash for the second guard 
  2246. 	npc_leash_remove(CHARACTER_GUARD2) 
  2247. 	-- Attack the player 
  2248. 	attack(CHARACTER_GUARD2) 
  2249. end 
  2250.  
  2251. function tss01_2nd_floor_setup() 
  2252. 	-- Disable this trigger 
  2253. 	trigger_enable(RUN_GUN_TRIGGER_2ND_FLOOR, false) 
  2254.  
  2255. 	-- Enable the next trigger 
  2256. 	trigger_enable(RUN_GUN_TRIGGER_3RD_FLOOR, true) 
  2257. 	on_trigger("tss01_3rd_floor_setup", RUN_GUN_TRIGGER_3RD_FLOOR) 
  2258.  
  2259. 	-- Create the 2nd floor guards 
  2260. 	group_create(GROUP_2ND_FLOOR) 
  2261. 	group_show(GROUP_2ND_FLOOR) 
  2262. end 
  2263.  
  2264. function tss01_3rd_floor_setup() 
  2265. 	-- Disable this trigger 
  2266. 	trigger_enable(RUN_GUN_TRIGGER_3RD_FLOOR, false) 
  2267.  
  2268. 	-- Create the 2nd floor guards 
  2269. 	group_create(GROUP_3RD_FLOOR) 
  2270. 	group_show(GROUP_3RD_FLOOR) 
  2271. end 
  2272.  
  2273. function tss01_create_shortbus_and_add_cops() 
  2274. 	-- Create the shortbuss hidden 
  2275. 	group_create_hidden(GROUP_SHORTBUS) 
  2276.  
  2277. 	-- Add the passengers to the bus 
  2278. 	vehicle_enter_teleport("tss01_$c001", "tss01_$bus", 0) 
  2279. 	vehicle_enter_teleport("tss01_$c002", "tss01_$bus", 1) 
  2280. 	vehicle_enter_teleport("tss01_$c006", "tss01_$bus", 2) 
  2281. 	vehicle_enter_teleport("tss01_$c007", "tss01_$bus", 3) 
  2282.  
  2283. 	-- Add the passengers to the car 
  2284. 	vehicle_enter_teleport("tss01_$c039", "tss01_$v009", 0) 
  2285. 	vehicle_enter_teleport("tss01_$c040", "tss01_$v009", 1) 
  2286.  
  2287. 	-- These guys can't hit shit 
  2288. 	npc_weapon_spread("tss01_$c001", tss01_get_weapon_spread(4.0)) 
  2289. 	npc_weapon_spread("tss01_$c002", tss01_get_weapon_spread(4.0)) 
  2290. 	npc_weapon_spread("tss01_$c006", tss01_get_weapon_spread(4.0)) 
  2291. 	npc_weapon_spread("tss01_$c007", tss01_get_weapon_spread(4.0)) 
  2292. 	npc_weapon_spread("tss01_$c039", tss01_get_weapon_spread(4.0)) 
  2293. 	npc_weapon_spread("tss01_$c040", tss01_get_weapon_spread(4.0)) 
  2294.  
  2295. 	tss01_update_hit_points({"tss01_$c001", "tss01_$c002", "tss01_$c006", "tss01_$c007", "tss01_$c039", "tss01_$c040"}) 
  2296.  
  2297. 	-- Enable the trigger to activate the sequence 
  2298. 	trigger_enable(COURTYARD_SHOWDOWN_TRIGGER, true) 
  2299. 	on_trigger("tss01_courtyard_showdown", COURTYARD_SHOWDOWN_TRIGGER) 
  2300. end 
  2301.  
  2302. function tss01_reset_my_infinite_mass_status(human, vehicle, seat) 
  2303. 	-- Make sure the human is the driver 
  2304. 	if (not (seat == 0)) then 
  2305. 		return 
  2306. 	end 
  2307. 	-- Remove the callback 
  2308. 	on_vehicle_exit("", vehicle) 
  2309. 	-- Turn infinite mass off 
  2310. 	vehicle_infinite_mass(vehicle, false) 
  2311. end 
  2312.  
  2313. function tss01_courtyard_showdown() 
  2314. 	-- Disable the trigger 
  2315. 	trigger_enable(COURTYARD_SHOWDOWN_TRIGGER, false) 
  2316.  
  2317. 	-- Show the hidden shortbus group...also has a car now 
  2318. 	group_show(GROUP_SHORTBUS) 
  2319.  
  2320. 	-- Give both of these vehicle infinite mass 
  2321. 	vehicle_infinite_mass("tss01_$v009", true) 
  2322. 	on_vehicle_exit("tss01_reset_my_infinite_mass_status", "tss01_$v009") 
  2323. 	vehicle_infinite_mass("tss01_$bus", true) 
  2324. 	on_vehicle_exit("tss01_reset_my_infinite_mass_status", "tss01_$bus") 
  2325.  
  2326. 	-- Lower the health of these vehicles 
  2327. 	set_max_hit_points("tss01_$v009", get_max_hit_points("tss01_$v009") * VEHICLE_HEALTH_MULTIPLIER, true) 
  2328. 	set_max_hit_points("tss01_$bus", get_max_hit_points("tss01_$bus") * VEHICLE_HEALTH_MULTIPLIER, true) 
  2329.  
  2330. 	-- Turn the lights on 
  2331. 	vehicle_lights_on("tss01_$v009", true) 
  2332. 	vehicle_set_sirens("tss01_$v009", true) 
  2333.  
  2334. 	-- Have the vehicle pathfind to the the courtyard 
  2335. 	if ( not vehicle_is_destroyed("tss01_$v009") ) then 
  2336. 		vehicle_pathfind_to("tss01_$v009", "tss01_$path005", true, true) 
  2337. 		if (not character_is_dead("tss01_$c039")) then 
  2338. 			vehicle_exit_do("tss01_$c039", false, false, false) 
  2339. 		end 
  2340. 		if (not character_is_dead("tss01_$c040")) then 
  2341. 			vehicle_exit_do("tss01_$c040", false, false, false) 
  2342. 		end 
  2343. 	end 
  2344.  
  2345. 	-- Turn the lights on 
  2346. 	vehicle_lights_on("tss01_$bus", true) 
  2347. 	vehicle_set_sirens("tss01_$bus", true) 
  2348. 	 
  2349. 	-- Have the vehicle pathfind to the courtyard 
  2350. 	vehicle_pathfind_to("tss01_$bus", "tss01_$n049", true, true) 
  2351. 	-- Make sure the bus stops 
  2352. 	vehicle_stop("tss01_$bus") 
  2353. 	-- Make sure the bus occupants exit 
  2354. 	vehicle_exit_do("tss01_$c001", false, false, false) 
  2355. 	vehicle_exit_do("tss01_$c002", false, false, false) 
  2356. 	vehicle_exit_do("tss01_$c006", false, false, false) 
  2357. 	vehicle_exit_do("tss01_$c007", false, false, false) 
  2358. end 
  2359.  
  2360. function tss01_courtyard_setup() 
  2361. 	-- Disable this trigger 
  2362. 	trigger_enable(RUN_GUN_TRIGGER_1, false) 
  2363.  
  2364. 	-- Enable the next trigger 
  2365. 	trigger_enable(RUN_GUN_TRIGGER_2, true) 
  2366. 	on_trigger("tss01_courtyard_enter", RUN_GUN_TRIGGER_2) 
  2367.  
  2368. 	-- Create the court yard guards as hidden 
  2369. 	if (not group_is_loaded(GROUP_COURTYARD)) then 
  2370. 		group_create_hidden(GROUP_COURTYARD) 
  2371. 		 
  2372. 		-- Tell the courtyard guards to wander 
  2373. 		for i = 1, Num_tss01_courtyard_guards, 1 do 
  2374. 			wander_start(Tss01_courtyard_guards[i], Tss01_courtyard_guards[i], 5.0) 
  2375. 			npc_weapon_spread(Tss01_courtyard_guards[i], tss01_get_weapon_spread(4.0)) 
  2376. 			on_death("tss01_release_to_world", Tss01_courtyard_guards[i]) 
  2377. 		end 
  2378. 		tss01_update_hit_points(Tss01_courtyard_guards) 
  2379.  
  2380. 		if (tss01_spawn_coop_groups()) then 
  2381. 			group_create_hidden(GROUP_COURTYARD_COOP) 
  2382. 		 
  2383. 			for i = 1, Num_tss01_courtyard_guards_coop, 1 do 
  2384. 				wander_start(Tss01_courtyard_guards_coop[i], Tss01_courtyard_guards_coop[i], 5.0) 
  2385. 				npc_weapon_spread(Tss01_courtyard_guards_coop[i], 4.0) 
  2386. 				on_death("tss01_release_to_world", Tss01_courtyard_guards_coop[i]) 
  2387. 			end 
  2388. 		end 
  2389. 	end 
  2390.  
  2391. 	-- Create the shortbus guards as hidden 
  2392. 	if (not group_is_loaded(GROUP_SHORTBUS)) then 
  2393. 		tss01_create_shortbus_and_add_cops() 
  2394. 	end 
  2395. end 
  2396.  
  2397. function tss01_courtyard_enter() 
  2398. 	-- Show the hidden courtyard group 
  2399. 	group_show(GROUP_COURTYARD) 
  2400.  
  2401. 	if (tss01_spawn_coop_groups()) then 
  2402. 		group_show(GROUP_COURTYARD_COOP) 
  2403. 	end 
  2404.  
  2405. 	-- Disable this trigger 
  2406. 	trigger_enable(RUN_GUN_TRIGGER_2, false) 
  2407.  
  2408. 	-- Enable the next trigger 
  2409. 	trigger_enable(RUN_GUN_TRIGGER_3, true) 
  2410. 	on_trigger("tss01_docks_setup", RUN_GUN_TRIGGER_3) 
  2411.  
  2412. 	-- Create the docks guards as hidden 
  2413. 	group_create_hidden(GROUP_DOCKS) 
  2414. 	group_create_hidden(GROUP_RANDOM) 
  2415. 	group_create_hidden(GROUP_ROADBLOCK) 
  2416.  
  2417. 	if (tss01_spawn_coop_groups()) then 
  2418. 		group_create_hidden(GROUP_DOCKS_COOP) 
  2419. 		group_create_hidden(GROUP_RANDOM_COOP) 
  2420. 		group_create_hidden(GROUP_ROADBLOCK_COOP) 
  2421. 	end 
  2422. end 
  2423.  
  2424. function tss01_docks_setup() 
  2425. 	-- Disable this trigger 
  2426. 	trigger_enable(RUN_GUN_TRIGGER_3, false) 
  2427.  
  2428. 	-- Release some stuff to the world 
  2429. 	release_to_world(GROUP_CAFE_GUARDS) 
  2430. 	release_to_world(GROUP_2ND_FLOOR) 
  2431. 	release_to_world(GROUP_3RD_FLOOR) 
  2432.  
  2433. 	-- Show the hidden docks group 
  2434. 	group_show(GROUP_DOCKS) 
  2435. 	group_show(GROUP_RANDOM) 
  2436. 	group_show(GROUP_ROADBLOCK) 
  2437.  
  2438. 	-- Tell the dock guards they can't hit the broad side of a barn 
  2439. 	for i = 1, Num_tss01_dock_guards, 1 do 
  2440. 		npc_weapon_spread(Tss01_dock_guards[i], tss01_get_weapon_spread(4.0)) 
  2441. 		on_death("tss01_release_to_world", Tss01_dock_guards[i]) 
  2442. 	end 
  2443. 	tss01_update_hit_points(Tss01_dock_guards) 
  2444.  
  2445. 	-- Tell the random guards they can't hit the broad side of a barn 
  2446. 	for i = 1, Num_tss01_random_guards, 1 do 
  2447. 		-- We want these guys to have rifles 
  2448. 		inv_item_add("m16", 1, Tss01_random_guards[i], true) 
  2449. 		npc_weapon_spread(Tss01_random_guards[i], tss01_get_weapon_spread(2.0)) 
  2450. 		on_death("tss01_release_to_world", Tss01_random_guards[i]) 
  2451. 	end 
  2452. 	tss01_update_hit_points(Tss01_random_guards) 
  2453.  
  2454. 	-- Tell the roadblock guards they can't hit the broad side of a barn 
  2455. 	for i = 1, Num_tss01_roadblock_guards, 1 do 
  2456. 		npc_weapon_spread(Tss01_roadblock_guards[i], tss01_get_weapon_spread(4.0)) 
  2457. 		on_death("tss01_release_to_world", Tss01_roadblock_guards[i]) 
  2458. 	end 
  2459. 	tss01_update_hit_points(Tss01_roadblock_guards) 
  2460.  
  2461. 	if (tss01_spawn_coop_groups()) then 
  2462. 		group_show(GROUP_DOCKS_COOP) 
  2463. 		group_show(GROUP_RANDOM_COOP) 
  2464. 		group_show(GROUP_ROADBLOCK_COOP) 
  2465.  
  2466. 		-- Tell the dock guards they can't hit the broad side of a barn 
  2467. 		for i = 1, Num_tss01_dock_guards_coop, 1 do 
  2468. 			npc_weapon_spread(Tss01_dock_guards_coop[i], 4.0) 
  2469. 			on_death("tss01_release_to_world", Tss01_dock_guards_coop[i]) 
  2470. 		end 
  2471.  
  2472. 		-- Tell the random guards they can't hit the broad side of a barn 
  2473. 		for i = 1, Num_tss01_random_guards_coop, 1 do 
  2474. 			-- We want these guys to have rifles 
  2475. 			inv_item_add("m16", 1, Tss01_random_guards_coop[i], true) 
  2476. 			npc_weapon_spread(Tss01_random_guards_coop[i], 2.0) 
  2477. 			on_death("tss01_release_to_world", Tss01_random_guards_coop[i]) 
  2478. 		end 
  2479.  
  2480. 		-- Tell the roadblock guards they can't hit the broad side of a barn 
  2481. 		for i = 1, Num_tss01_roadblock_guards_coop, 1 do 
  2482. 			npc_weapon_spread(Tss01_roadblock_guards_coop[i], 4.0) 
  2483. 			on_death("tss01_release_to_world", Tss01_roadblock_guards_coop[i]) 
  2484. 		end 
  2485. 	end 
  2486.  
  2487. 	-- Play the exchange between Carlos and the player 
  2488. 	tss01_audio_play_conversation(Tss01_carlos_exchange_3) 
  2489.  
  2490. 	-- Delay a short period of time before the leashes are removed 
  2491. 	delay(4.0) 
  2492. 	-- Remove the leashes for the courtyard prison guards 
  2493. 	for i = 1, Num_tss01_courtyard_guards, 1 do 
  2494. 		npc_leash_remove(Tss01_courtyard_guards[i]) 
  2495. 	end 
  2496. end 
  2497.  
  2498. function tss01_waypoint01() 
  2499. 	-- Remove the waypoint 
  2500. 	mission_waypoint_remove(SYNC_ALL) 
  2501.  
  2502. 	-- Enable the next trigger 
  2503. --	trigger_enable(Tss01_waypoints[1], true) 
  2504. 	-- Add the objective destination 
  2505. --	marker_add_trigger(Tss01_waypoints[1], MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  2506. 	-- Add the new waypoint 
  2507. --	mission_waypoint_add(Tss01_waypoints[1], SYNC_ALL) 
  2508.  
  2509. 	-- Enable the trigger in front of the door to do the canned animation... 
  2510. 	on_trigger("tss01_carlos_take_lead", KEY_TRIGGER) 
  2511. 	trigger_enable(KEY_TRIGGER, true) 
  2512. end 
  2513.  
  2514. function tss01_waypoint02() 
  2515. 	-- Remove the marker 
  2516. --	marker_remove_trigger(Tss01_waypoints[1], SYNC_ALL) 
  2517. 	-- Disable the incomming trigger 
  2518. --	trigger_enable(Tss01_waypoints[1], false) 
  2519. 	-- Remove the waypoint 
  2520. --	mission_waypoint_remove(SYNC_ALL) 
  2521.  
  2522. 	-- Wait until Carlos has kicked the door open 
  2523. --	while (not door_is_open(Tss01_doors[KEY_DOOR])) do 
  2524. --		thread_yield() 
  2525. --	end 
  2526.  
  2527. 	-- Change the callback 
  2528. 	on_trigger("tss01_carlos_has_lead", KEY_TRIGGER) 
  2529. 	-- Enable the trigger 
  2530. 	trigger_enable(KEY_TRIGGER, true) 
  2531. 	-- Show the next trigger to hit 
  2532. 	marker_add_trigger(KEY_TRIGGER, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  2533. 	-- Add the new waypoint 
  2534. 	mission_waypoint_add(KEY_TRIGGER, SYNC_ALL) 
  2535. end 
  2536.  
  2537. function tss01_kick_open_door(human) 
  2538. 	if (not (human == CHARACTER_CARLOS)) then 
  2539. 		return 
  2540. 	end 
  2541.  
  2542. 	-- If the human is using the IV stand then force him/her to drop it 
  2543. 	if (mesh_mover_wielding(human)) then 
  2544. 		mesh_mover_wield_stop(human) 
  2545. 	end 
  2546.  
  2547. 	-- Turn to face the door 
  2548. 	turn_to(human, "tss01_$n141") 
  2549. 	delay(0.5) 
  2550.  
  2551. 	-- Play the kick animation 
  2552. 	action_play(human, "kick door", nil, true, 0.6, true) 
  2553. 	-- Play the kick audio 
  2554. 	audio_play("DOOR_KICK", "foley", false) 
  2555. 	 
  2556. 	-- Play the action of the door opening 
  2557. 	door_open(Tss01_doors[KEY_DOOR]) 
  2558.  
  2559. 	-- Don't proceed until the door is fully open 
  2560. 	while (not door_is_open(Tss01_doors[KEY_DOOR])) do 
  2561. 		thread_yield() 
  2562. 	end 
  2563.  
  2564. end 
  2565.  
  2566. function tss01_carlos_take_lead(human, trigger) 
  2567. 	if (human == CHARACTER_CARLOS) then 
  2568. 		-- Disable the trigger 
  2569. 		trigger_enable(trigger, false) 
  2570. 		-- Kick open the door 
  2571. 		tss01_kick_open_door(human) 
  2572.  
  2573. 		-- Enable the player's waypoint 
  2574. 		tss01_waypoint02() 
  2575. 		-- Tell Carlos to move to the next location 
  2576. 		tss01_carlos_move("tss01_$carlos1") 
  2577. 	end 
  2578. end 
  2579.  
  2580. function tss01_carlos_has_lead(human, trigger) 
  2581. 	if (not (human == CHARACTER_CARLOS)) then 
  2582. 		-- Disable the trigger 
  2583. 		trigger_enable(trigger, false) 
  2584. 		on_trigger("", trigger) 
  2585. 		marker_remove_trigger(KEY_TRIGGER, SYNC_ALL) 
  2586.  
  2587. 		-- Play audio line for Carlos 
  2588. 		tss01_audio_play_for_character("CARLOS_TSSP1_WAYPOINT_2", CHARACTER_CARLOS, "voice", false, true) 
  2589.  
  2590. 		-- Enable the next trigger 
  2591. 		trigger_enable(Tss01_waypoints[2], true) 
  2592. 		-- Add the objective destination 
  2593. 		marker_add_trigger(Tss01_waypoints[2], MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  2594. 		-- Add the new waypoint 
  2595. 		mission_waypoint_add(Tss01_waypoints[2], SYNC_ALL) 
  2596. 	end 
  2597. end 
  2598.  
  2599. function tss01_waypoint03() 
  2600. 	-- Remove the marker 
  2601. 	marker_remove_trigger(Tss01_waypoints[2], SYNC_ALL) 
  2602. 	-- Disable the incomming trigger 
  2603. 	trigger_enable(Tss01_waypoints[2], false) 
  2604. 	-- Remove the waypoint 
  2605. 	mission_waypoint_remove(SYNC_ALL) 
  2606.  
  2607. 	-- Enable the next trigger 
  2608. 	trigger_enable(Tss01_waypoints[3], true) 
  2609. 	-- Add the objective destination 
  2610. 	marker_add_trigger(Tss01_waypoints[3], MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  2611. 	-- Add the new waypoint 
  2612. 	mission_waypoint_add(Tss01_waypoints[3], SYNC_ALL) 
  2613.  
  2614. 	-- Tell Carlos to move to the next location 
  2615. 	tss01_carlos_move("tss01_$carlos2") 
  2616. end 
  2617.  
  2618. function tss01_waypoint04() 
  2619. 	-- Remove the marker 
  2620. 	marker_remove_trigger(Tss01_waypoints[3], SYNC_ALL) 
  2621. 	-- Disable the incomming trigger 
  2622. 	trigger_enable(Tss01_waypoints[3], false) 
  2623. 	-- Remove the waypoint 
  2624. 	mission_waypoint_remove(SYNC_ALL) 
  2625.  
  2626. 	-- Enable the next trigger 
  2627. 	trigger_enable(Tss01_waypoints[4], true) 
  2628. 	-- Add the objective destination 
  2629. 	marker_add_trigger(Tss01_waypoints[4], MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  2630. 	-- Add the new waypoint 
  2631. 	mission_waypoint_add(Tss01_waypoints[4], SYNC_ALL) 
  2632.  
  2633. 	-- Play exchange between Carlos and the Player 
  2634. 	thread_new("tss01_audio_play_conversation", Tss01_carlos_exchange_2) 
  2635.  
  2636. 	-- Tell Carlos to move to the next location 
  2637. 	tss01_carlos_move("tss01_$carlos3") 
  2638. end 
  2639.  
  2640. function tss01_waypoint05() 
  2641. 	-- Remove the marker 
  2642. 	marker_remove_trigger(Tss01_waypoints[4], SYNC_ALL) 
  2643. 	-- Disable the incomming trigger 
  2644. 	trigger_enable(Tss01_waypoints[4], false) 
  2645. 	-- Remove the waypoint 
  2646. 	mission_waypoint_remove(SYNC_ALL) 
  2647.  
  2648. 	-- Enable the next trigger 
  2649. 	trigger_enable(Tss01_waypoints[5], true) 
  2650. 	-- Add the objective destination 
  2651. 	marker_add_trigger(Tss01_waypoints[5], MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  2652. 	-- Add the new waypoint 
  2653. 	mission_waypoint_add(Tss01_waypoints[5], SYNC_ALL) 
  2654.  
  2655. 	-- Enable the trigger to show the minimap tutorial 
  2656. 	trigger_enable(MINIMAP_TRIGGER, true) 
  2657. 	on_trigger("tss01_minimap_tutorial", MINIMAP_TRIGGER) 
  2658.  
  2659. 	-- Our goal is now waypoint 5 so create our rooftop group 
  2660. 	group_create_hidden(GROUP_ROOFTOP) 
  2661.  
  2662. 	-- Play exchange between Carlos and the Player 
  2663. 	thread_new("tss01_audio_play_conversation", Tss01_carlos_exchange_3) 
  2664.  
  2665. 	-- Tell Carlos to move to the next location 
  2666. 	tss01_carlos_move("tss01_$carlos4") 
  2667.  
  2668. 	npc_go_idle(CHARACTER_CARLOS) 
  2669. 	turn_to(CHARACTER_CARLOS, "tss01_$carlos4", true) 
  2670. end 
  2671.  
  2672. function tss01_minimap_tutorial() 
  2673. 	-- Not needed anymore 
  2674. 	trigger_enable(MINIMAP_TRIGGER, false) 
  2675.  
  2676. 	-- Do the tutorial 
  2677. 	tutorial_start("minimap", 0, true) 
  2678. end 
  2679.  
  2680. function tss01_waypoint06() 
  2681. 	-- Remove the marker 
  2682. 	marker_remove_trigger(Tss01_waypoints[5], SYNC_ALL) 
  2683. 	-- Disable the incomming trigger 
  2684. 	trigger_enable(Tss01_waypoints[5], false) 
  2685. 	-- Remove the waypoint 
  2686. 	mission_waypoint_remove(SYNC_ALL) 
  2687.  
  2688. 	-- Add the objective destination 
  2689. 	marker_add_npc(Tss01_waypoints[6], MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL) 
  2690. 	-- Add the new waypoint 
  2691. 	mission_waypoint_add(Tss01_waypoints[6], SYNC_ALL) 
  2692.  
  2693. 	-- Our goal is now waypoint 6 so show our rooftop group 
  2694. 	group_show(GROUP_ROOFTOP) 
  2695. 	group_create_hidden(GROUP_FIRE_ESCAPE) 
  2696.  
  2697. 	-- Tell the rooftop guards to wander 
  2698. 	for i = 1, Num_tss01_rooftop_guards, 1 do 
  2699. 		wander_start(Tss01_rooftop_guards[i], Tss01_rooftop_guards[i], 3.0) 
  2700. 		on_death("tss01_release_to_world", Tss01_rooftop_guards[i]) 
  2701. 	end 
  2702.  
  2703. 	-- One of the rooftop guards is a waypoint...so setup that on death  
  2704. 	--		after all the guards have been iterated through 
  2705. 	on_death("tss01_waypoint07", Tss01_waypoints[6]) 
  2706.  
  2707. 	-- Create the heli group 
  2708. 	if (not group_is_loaded(GROUP_HELI)) then 
  2709. 		group_create(GROUP_HELI) 
  2710. 		group_show(GROUP_HELI) 
  2711. 	end 
  2712.  
  2713. 	-- The player(s) and Carlos should not have a weapon until this point... 
  2714. 	on_weapon_fired("tss01_tutorial_weapon_fired", LOCAL_PLAYER) 
  2715. 	on_weapon_fired("tss01_tutorial_weapon_fired_carlos", CHARACTER_CARLOS) 
  2716. 	if (IN_COOP) then 
  2717. 		on_weapon_fired("tss01_tutorial_weapon_fired", REMOTE_PLAYER) 
  2718. 	end 
  2719.  
  2720. 	-- Tell the player(s) to kill the guard 
  2721. 	mission_help_table("tss01_kill_guard") 
  2722.  
  2723. 	tss01_carlos_make_dependent() 
  2724.  
  2725. 	-- Carlos can now flinch or ragdoll from here on out 
  2726. 	character_prevent_flinching(CHARACTER_CARLOS, false) 
  2727. 	character_allow_ragdoll(CHARACTER_CARLOS, true) 
  2728. 	turn_vulnerable(CHARACTER_CARLOS) 
  2729.  
  2730. 	-- Watch for the alarms to be set off 
  2731. 	thread_new("tss01_react_to_alarms") 
  2732.  
  2733. 	-- Look to show the radial menu tutorial 
  2734. 	on_weapon_pickup("tss01_weapon_pickup", LOCAL_PLAYER) 
  2735. 	if (IN_COOP) then 
  2736. 		on_weapon_pickup("tss01_weapon_pickup", REMOTE_PLAYER) 
  2737. 	end 
  2738.  
  2739. end 
  2740.  
  2741. function tss01_tutorial_weapon_fired(human, weapon, name) 
  2742. 	-- Only do this for when a weapon is fired 
  2743. 	if (name ~= "firearm") then 
  2744. 		return 
  2745. 	end 
  2746. 	 
  2747. 	-- Do not allow this callback to happen again 
  2748. 	on_weapon_fired("", LOCAL_PLAYER) 
  2749. 	on_weapon_fired("", CHARACTER_CARLOS) 
  2750. 	if (IN_COOP) then 
  2751. 		on_weapon_fired("", REMOTE_PLAYER) 
  2752. 	end 
  2753.  
  2754. 	-- One of the prisoners fired a weapon...the alarm must sound! 
  2755. 	if (ALARM_THREAD_HANDLE == INVALID_THREAD_HANDLE) then 
  2756. 		ALARM_THREAD_HANDLE = thread_new("tss01_escape_alarms", true, true, true) 
  2757.  
  2758. 		-- Alarm is set off early, have fire escape guards attack 
  2759. 		group_show(GROUP_FIRE_ESCAPE) 
  2760. 		for i = 1, Num_tss01_fire_escape_guards, 1 do 
  2761. 			attack(Tss01_fire_escape_guards[i]) 
  2762. 			npc_weapon_spread(Tss01_fire_escape_guards[i], tss01_get_weapon_spread(4.0)) 
  2763. 			on_death("tss01_release_to_world", Tss01_fire_escape_guards[i]) 
  2764. 		end 
  2765. 		tss01_update_hit_points(Tss01_fire_escape_guards) 
  2766. 	end 
  2767. end 
  2768.  
  2769. function tss01_tutorial_weapon_fired_carlos(human, weapon, name) 
  2770. 	-- Only do this for when a weapon is fired 
  2771. 	if (name ~= "firearm") then 
  2772. 		return 
  2773. 	end 
  2774. 	 
  2775. 	-- Do not allow this callback to happen again 
  2776. 	on_weapon_fired("", CHARACTER_CARLOS) 
  2777.  
  2778. 	-- One of the prisoners fired a weapon...the alarm must sound! 
  2779. 	if (ALARM_THREAD_HANDLE == INVALID_THREAD_HANDLE) then 
  2780. 		ALARM_THREAD_HANDLE = thread_new("tss01_escape_alarms", true, true, true) 
  2781.  
  2782. 		-- Alarm is set off early, have fire escape guards attack 
  2783. 		group_show(GROUP_FIRE_ESCAPE) 
  2784. 		for i = 1, Num_tss01_fire_escape_guards, 1 do 
  2785. 			attack(Tss01_fire_escape_guards[i]) 
  2786. 			npc_weapon_spread(Tss01_fire_escape_guards[i], tss01_get_weapon_spread(4.0)) 
  2787. 			on_death("tss01_release_to_world", Tss01_fire_escape_guards[i]) 
  2788. 		end 
  2789. 		tss01_update_hit_points(Tss01_fire_escape_guards) 
  2790. 	end 
  2791. end 
  2792.  
  2793. function tss01_searchlight_track(human, light, track) 
  2794. 	local		state_idx = 1 
  2795. 	local		hud_index = 0 
  2796. 	local		hud_sync = SYNC_LOCAL 
  2797.  
  2798. 	if (human == REMOTE_PLAYER) then 
  2799. 		state_idx = 2 
  2800. 		hud_index = 1 
  2801. 		hud_sync = SYNC_REMOTE 
  2802. 	end 
  2803.  
  2804. 	-- Is the search light starting to track or did it stop tracking? 
  2805. 	if (track) then 
  2806. 		if (Tss01_warning_issued[state_idx] == false) then 
  2807. 			-- Tell the player(s) to be stealth like! 
  2808. 			mission_help_table_nag("tss01_searchlight_avoid") 
  2809. 			-- The warning has been issued 
  2810. 			Tss01_warning_issued[state_idx] = true 
  2811. 			return 
  2812. 		end 
  2813.  
  2814. 		-- Check to see if it is already tracking a player 
  2815. 		if (Tss01_lights_tracking[state_idx] == true) then 
  2816. 			return 
  2817. 		end 
  2818.  
  2819. 		Tss01_lights_tracking[state_idx] = true 
  2820.  
  2821. 		-- Started tracking 
  2822. 		hud_timer_set(hud_index, 8 * 1000, "tss01_searchlight_timer_elapsed", true, hud_sync) 
  2823. 		-- Tell the player(s) to hide! 
  2824. 		mission_help_table_nag("tss01_searchlight_spot", nil, nil, hud_sync) 
  2825.  
  2826. 		if (Tss01_light_track_msg == true) then 
  2827. 			-- Play audio line for Carlos 
  2828. 			tss01_audio_play_for_character("CARLOS_TSSP1_SPOTLIGHTS", CHARACTER_CARLOS, "voice") 
  2829.  
  2830. 			-- Don't allow the audio and message to show again until the new thread is done executing 
  2831. 			thread_new("tss01_searhlight_enable_message") 
  2832.  
  2833. 			Tss01_light_track_msg = false 
  2834. 		end 
  2835. 	else 
  2836. 		-- Stopped tracking 
  2837. 		hud_timer_stop(hud_index) 
  2838. 		-- Stop the help text 
  2839. 		mission_help_clear(hud_sync) 
  2840.  
  2841. 		Tss01_lights_tracking[state_idx] = false 
  2842. 	end 
  2843. end 
  2844.  
  2845. function tss01_searchlight_track_carlos(human, light, track) 
  2846. 	-- Is the search light starting to track or did it stop tracking? 
  2847. 	if (track) then 
  2848. 		-- Check to see if it is already tracking Carlos 
  2849. 		if (Tss01_lights_tracking_carlos == true) then 
  2850. 			return 
  2851. 		end 
  2852.  
  2853. 		Tss01_lights_tracking_carlos = true 
  2854.  
  2855. 		-- Make Carlos independent 
  2856. 		follower_make_independent(human, true) 
  2857.  
  2858. 		local		point = Tss01_hide_points[1]; 
  2859. 		local		point_dist = get_dist(Tss01_hide_points[1], CHARACTER_CARLOS) 
  2860.  
  2861. 		-- Find the closest hide point 
  2862. 		for i = 2, Num_tss01_hide_points, 1 do 
  2863. 			local		dist = get_dist(Tss01_hide_points[i], CHARACTER_CARLOS) 
  2864. 			 
  2865. 			if (dist < point_dist) then 
  2866. 				point_dist = dist 
  2867. 				point = Tss01_hide_points[i] 
  2868. 			end 
  2869. 		end 
  2870.  
  2871. 		-- Move Carlos to the hide point 
  2872. 		CARLOS_HIDE_THREAD_HANDLE = thread_new("tss01_carlos_move",point) 
  2873. 	else 
  2874.  
  2875. 		-- Carlos is no longer independent 
  2876. 		tss01_carlos_make_dependent() 
  2877.  
  2878. 		Tss01_lights_tracking_carlos = false 
  2879. 	end 
  2880. end 
  2881.  
  2882. function tss01_searchlight_timer_elapsed() 
  2883. 	-- Sound the audio if it hasn't been already 
  2884. 	if (ALARM_THREAD_HANDLE == INVALID_THREAD_HANDLE) then 
  2885. 		ALARM_THREAD_HANDLE = thread_new("tss01_escape_alarms", false, false, false) 
  2886. 	end 
  2887. end 
  2888.  
  2889. function tss01_searhlight_enable_message() 
  2890. 	-- Delay for 15 seconds 
  2891. 	delay(15.0) 
  2892. 	-- Enable the message to be shown... 
  2893. 	Tss01_light_track_msg = true 
  2894. end 
  2895.  
  2896. function tss01_react_to_alarms() 
  2897. 	-- Do nothing until the alarm has been set off 
  2898. 	while (ALARM_THREAD_HANDLE == INVALID_THREAD_HANDLE) do 
  2899. 		thread_yield() 
  2900. 	end 
  2901.  
  2902. 	-- Disable the pursuit guard triggers so they can't be triggered (if the alarm was set off early) 
  2903. 	trigger_enable(PURSUIT_TRIGGER_1, false) 
  2904. 	trigger_enable(PURSUIT_TRIGGER_2, false) 
  2905.  
  2906. 	-- Tell the rooftop guards to attack...those that are left 
  2907. 	for i = 1, Num_tss01_rooftop_guards, 1 do 
  2908. 		attack(Tss01_rooftop_guards[i]) 
  2909. 	end 
  2910. end 
  2911.  
  2912. function tss01_waypoint06b() 
  2913. 	-- Remove the marker 
  2914. 	marker_remove_trigger(FIRST_ROOFTOP_TRIGGER, SYNC_ALL) 
  2915. 	-- Disable the incomming trigger 
  2916. 	trigger_enable(FIRST_ROOFTOP_TRIGGER, false) 
  2917. 	-- Remove the waypoint 
  2918. 	mission_waypoint_remove(SYNC_ALL) 
  2919.  
  2920. 	-- Enable the next trigger 
  2921. 	trigger_enable(Tss01_waypoints[7], true) 
  2922. 	-- Add the objective destination 
  2923. 	marker_add_trigger(Tss01_waypoints[7], MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  2924. 	-- Add the new waypoint 
  2925. 	mission_waypoint_add(Tss01_waypoints[7], SYNC_ALL) 
  2926. end 
  2927.  
  2928. function tss01_waypoint07() 
  2929. 	-- Remove the marker 
  2930. 	marker_remove_npc(Tss01_waypoints[6], SYNC_ALL) 
  2931. 	-- Remove the waypoint 
  2932. 	mission_waypoint_remove(SYNC_ALL) 
  2933.  
  2934. 	-- Create our groups for the ground tutorial segment 
  2935. 	group_create_hidden(GROUP_TUT_SEARCH) 
  2936. 	group_create_hidden(GROUP_TUT_FINE_AIM) 
  2937. 	group_create_hidden(GROUP_TUT_T_IN_ROAD) 
  2938.  
  2939. 	-- Enable the next trigger 
  2940. 	trigger_enable(FIRST_ROOFTOP_TRIGGER, true) 
  2941. 	on_trigger("tss01_waypoint06b", FIRST_ROOFTOP_TRIGGER) 
  2942. 	-- Add the objective destination 
  2943. 	marker_add_trigger(FIRST_ROOFTOP_TRIGGER, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  2944. 	-- Add the new waypoint 
  2945. 	mission_waypoint_add(FIRST_ROOFTOP_TRIGGER, SYNC_ALL) 
  2946.  
  2947. 	-- Enable the triggers for guard pursuit 
  2948. 	trigger_enable(PURSUIT_TRIGGER_1, true) 
  2949. 	trigger_enable(PURSUIT_TRIGGER_2, true) 
  2950. 	-- Setup the trigger callbacks 
  2951. 	on_trigger("tss01_activate_pursuit", PURSUIT_TRIGGER_1) 
  2952. 	on_trigger("tss01_cancel_pursuit", PURSUIT_TRIGGER_2) 
  2953.  
  2954. 	-- Prompt the user with help text... 
  2955. 	mission_help_table("tss01_roof") 
  2956.  
  2957. 	-- Look to show the ranged weapon tutorial 
  2958. 	thread_new("tss01_ranged_weapons") 
  2959.  
  2960. 	-- Delay for a short period of time to allow the messages to show 
  2961. 	delay(4.0) 
  2962. 	-- Setup the searchlight callback 
  2963. 	on_searchlight_track("tss01_searchlight_track", LOCAL_PLAYER) 
  2964. 	on_searchlight_track("tss01_searchlight_track_carlos", CHARACTER_CARLOS) 
  2965. 	if (IN_COOP) then 
  2966. 		on_searchlight_track("tss01_searchlight_track", REMOTE_PLAYER) 
  2967. 	end 
  2968.  
  2969. 	-- Watch the player(s) for the opportunity to show the health/sprint tutorial 
  2970. 	on_damage("tss01_health_tutorial", LOCAL_PLAYER, 0.66) 
  2971. 	if (IN_COOP) then 
  2972. 		on_damage("tss01_health_tutorial", REMOTE_PLAYER, 0.66) 
  2973. 	end 
  2974. end 
  2975.  
  2976. function tss01_weapon_pickup(human, weapon, firearm) 
  2977. 	-- Remove the callbacks 
  2978. 	on_weapon_pickup("", LOCAL_PLAYER) 
  2979. 	if (IN_COOP) then 
  2980. 		on_weapon_pickup("", REMOTE_PLAYER) 
  2981. 	end 
  2982.  
  2983. 	tutorial_start("combat_weapons", 1000) 
  2984. end 
  2985.  
  2986. function tss01_ranged_weapons(human, weapon, firearm) 
  2987. 	-- Only show the ranged when a firearm is equiped 
  2988.  
  2989. 	local function player_has_firearm_equipped() 
  2990. 		if (inv_item_is_firearm_equipped(LOCAL_PLAYER)) then 
  2991. 			return true 
  2992. 		end 
  2993. 		if (IN_COOP and inv_item_is_firearm_equipped(REMOTE_PLAYER)) then 
  2994. 			return true 
  2995. 		end 
  2996. 		return false 
  2997. 	end 
  2998.  
  2999. 	while(not player_has_firearm_equipped()) do 
  3000. 		thread_yield() 
  3001. 	end 
  3002. 	 
  3003. 	tutorial_start("combat_ranged", 1000) 
  3004. end 
  3005.  
  3006. function tss01_health_tutorial() 
  3007. 	-- Remove the damage callbacks 
  3008. 	on_damage("", LOCAL_PLAYER, 0.0) 
  3009. 	if (IN_COOP) then 
  3010. 		on_damage("", REMOTE_PLAYER, 0.0) 
  3011. 	end 
  3012.  
  3013. 	-- Show the tutorial 
  3014. 	tutorial_start("health_sprint_meter", 500) 
  3015. end 
  3016.  
  3017. function tss01_waypoint08() 
  3018. 	-- Remove the marker 
  3019. 	marker_remove_trigger(Tss01_waypoints[7], SYNC_ALL) 
  3020. 	-- Disable the incomming trigger 
  3021. 	trigger_enable(Tss01_waypoints[7], false) 
  3022. 	-- Remove the waypoint 
  3023. 	mission_waypoint_remove(SYNC_ALL) 
  3024.  
  3025. 	-- Enable the next trigger 
  3026. 	trigger_enable(Tss01_waypoints[8], true) 
  3027. 	-- Add the objective destination 
  3028. 	marker_add_trigger(Tss01_waypoints[8], MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  3029. 	-- Add the new waypoint 
  3030. 	mission_waypoint_add(Tss01_waypoints[8], SYNC_ALL) 
  3031.  
  3032. 	-- Show the search group 
  3033. 	group_show(GROUP_TUT_SEARCH) 
  3034. 	-- Setup the fine aim tutorial scenario 
  3035. 	thread_new("tss01_setup_fine_aim") 
  3036.  
  3037. 	-- Play exchange between Carlos and the Player 
  3038. 	tss01_audio_play_conversation(Tss01_carlos_exchange_4) 
  3039. end 
  3040.  
  3041. function tss01_setup_fine_aim() 
  3042. 	-- Show the fine aim group 
  3043. 	group_show(GROUP_TUT_FINE_AIM) 
  3044.  
  3045. 	-- Put the humans in the heli 
  3046. 	vehicle_enter_teleport("tss01_$c050", FINE_AIM_VEHICLE, 0) 
  3047. 	vehicle_enter_teleport("tss01_$c051", FINE_AIM_VEHICLE, 4) 
  3048. 	vehicle_enter_teleport("tss01_$c052", FINE_AIM_VEHICLE, 5) 
  3049.  
  3050. 	-- These guys need to suck at shooting... 
  3051. 	npc_weapon_spread("tss01_$c051", tss01_get_weapon_spread(2.0)) 
  3052. 	npc_weapon_spread("tss01_$c052", tss01_get_weapon_spread(2.0)) 
  3053.  
  3054. 	tss01_update_hit_points({"tss01_$c050", "tss01_$c051", "tss01_$c052"}) 
  3055.  
  3056. 	-- Turn some lights on 
  3057. 	vehicle_lights_on(FINE_AIM_VEHICLE, true) 
  3058. 	vehicle_set_sirens(FINE_AIM_VEHICLE, true) 
  3059.  
  3060. 	-- Tell the fine aim vehicle to fly where it needs to be 
  3061. 	helicopter_fly_to_direct(FINE_AIM_VEHICLE, 50.0, "tss01_$path007") 
  3062.  
  3063. 	-- Setup some on death callbacks for the guards with rifles 
  3064. 	on_death("tss01_fine_aim_fly_to_safe_zone", "tss01_$c051") 
  3065. 	on_death("tss01_fine_aim_fly_to_safe_zone", "tss01_$c052") 
  3066. end 
  3067.  
  3068. function tss01_fine_aim_fly_to_safe_zone(human) 
  3069. 	-- Remove the on death callback 
  3070. 	on_death("", human) 
  3071.  
  3072. 	Num_fineaim_guards_killed = Num_fineaim_guards_killed + 1 
  3073.  
  3074. 	if (Num_fineaim_guards_killed == 2) then 
  3075. 		-- Tell the fine aim vehicle to fly where it needs to be 
  3076. 		--helicopter_fly_to_direct(FINE_AIM_VEHICLE, 40.0, "tss01_$path009") 
  3077. 		--turn_vulnerable("tss01_$c050") 
  3078.  
  3079. 		--set it on fire and let it die 
  3080. 		vehicle_set_smoke_and_fire_state(FINE_AIM_VEHICLE, true, true) 
  3081. 	end 
  3082. end 
  3083.  
  3084. function tss01_waypoint09() 
  3085. 	-- Remove the marker 
  3086. 	marker_remove_trigger(Tss01_waypoints[8], SYNC_ALL) 
  3087. 	-- Disable the incomming trigger 
  3088. 	trigger_enable(Tss01_waypoints[8], false) 
  3089. 	-- Remove the waypoint 
  3090. 	mission_waypoint_remove(SYNC_ALL) 
  3091.  
  3092. 	-- Enable the next trigger 
  3093. 	trigger_enable(Tss01_waypoints[9], true) 
  3094. 	-- Add the objective destination 
  3095. 	marker_add_trigger(Tss01_waypoints[9], MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  3096. 	-- Add the new waypoint 
  3097. 	mission_waypoint_add(Tss01_waypoints[9], SYNC_ALL) 
  3098.  
  3099. 	-- Enable the fine aim triggers 
  3100. 	trigger_enable(FINEAIM_START_TRIGGER, true) 
  3101. 	on_trigger("tss01_fine_aim_start", FINEAIM_START_TRIGGER) 
  3102.  
  3103. 	trigger_enable(FINEAIM_START_HELI_TRIGGER, true) 
  3104. 	on_trigger("tss01_fine_aim_start_heli", FINEAIM_START_HELI_TRIGGER) 
  3105. 	 
  3106. 	-- Setup the search scenario 
  3107. 	thread_new("tss01_setup_police_car_search_01") 
  3108. 	thread_new("tss01_setup_police_car_search_02") 
  3109.  
  3110. 	-- Play exchange between Carlos and the Player 
  3111. 	tss01_audio_play_conversation(Tss01_carlos_exchange_5) 
  3112.  
  3113. 	-- Sound the audio if it hasn't been already 
  3114. 	if (ALARM_THREAD_HANDLE == INVALID_THREAD_HANDLE) then 
  3115. 		ALARM_THREAD_HANDLE = thread_new("tss01_escape_alarms", true, false, true) 
  3116. 	end 
  3117. end 
  3118.  
  3119. function tss01_fine_aim_start() 
  3120. 	-- Disable the fine aim trigger 
  3121. 	trigger_enable(FINEAIM_START_TRIGGER, false) 
  3122.  
  3123. 	-- Do the tutorial 
  3124. 	tutorial_start("combat_fineaim") 
  3125. end 
  3126.  
  3127. function tss01_fine_aim_start_heli() 
  3128.  
  3129. 	local pilot = "tss01_$c050" 
  3130. 	if ((not vehicle_is_destroyed(FINE_AIM_VEHICLE) and character_exists(pilot) and (not character_is_dead(pilot)))) then 
  3131. 		trigger_enable(FINEAIM_START_HELI_TRIGGER, false) 
  3132. 		on_trigger("", FINEAIM_START_HELI_TRIGGER) 
  3133.  
  3134. 		-- Tell the fine aim vehicle to fly where it needs to be 
  3135. 		helicopter_fly_to_direct(FINE_AIM_VEHICLE, 50.0, "tss01_$path008") 
  3136. 		-- Nag the player to do fine aim 
  3137. 		mission_help_table_nag("tss01_fine_aim") 
  3138. 	end 
  3139.  
  3140. end 
  3141.  
  3142. function tss01_setup_police_car_search_01() 
  3143.  
  3144. 	local driver = Tss01_search_01[1] 
  3145. 	 
  3146. 	-- Teleport them into their vehicle 
  3147. 	vehicle_enter_group_teleport(Tss01_search_01, SEARCH_VEHICLE_01) 
  3148.  
  3149. 	-- Cut the hitpoints of the police cruiser to half 
  3150. 	set_max_hit_points(SEARCH_VEHICLE_01, get_max_hit_points(SEARCH_VEHICLE_01) * VEHICLE_HEALTH_MULTIPLIER, true) 
  3151.  
  3152. 	-- Spawn off a thread to turn on the lights while driving 
  3153. 	thread_new("tss01_police_turn_lights_on") 
  3154.  
  3155. 	local function should_terminate() 
  3156. 		if ( (not vehicle_exists(SEARCH_VEHICLE_01)) or vehicle_is_destroyed(SEARCH_VEHICLE_01) ) then 
  3157. 			return true 
  3158. 		end 
  3159. 		if ( (not character_exists(driver)) or character_is_dead(driver) ) then 
  3160. 			return true 
  3161. 		end 
  3162. 		return false 
  3163. 	end 
  3164.  
  3165. 	-- Start driving to the lighthouse 
  3166. 	vehicle_pathfind_to(SEARCH_VEHICLE_01, "tss01_$path001", true, false) 
  3167.  
  3168. 	-- Return early if the vehicle or driver are destroyed 
  3169. 	if ( should_terminate() ) then 
  3170. 		return 
  3171. 	end 
  3172.  
  3173. 	-- Finish driving to the lighthouse 
  3174. 	vehicle_pathfind_to(SEARCH_VEHICLE_01, "tss01_$path001a", true, true) 
  3175.  
  3176. 	-- Return early if the vehicle or driver are destroyed 
  3177. 	if ( should_terminate() ) then 
  3178. 		return 
  3179. 	end 
  3180.  
  3181. 	-- Force the guards to exit 
  3182. 	vehicle_stop(SEARCH_VEHICLE_02) 
  3183.  
  3184. 	-- Tell these guys to exit and then attack the player 
  3185. 	for i = 1, Num_tss01_search_01, 1 do 
  3186. 		local guard = Tss01_search_01[i] 
  3187. 		if (character_exists(guard) and (not character_is_dead(guard)) ) then 
  3188. 			thread_new("tss01_guard_exit_vehicle", guard) 
  3189. 			on_death("tss01_release_to_world", guard) 
  3190. 		end 
  3191. 	end 
  3192. end 
  3193.  
  3194. function tss01_guard_exit_vehicle(guard) 
  3195. 	-- Exit the vehicle 
  3196. 	vehicle_exit(guard) 
  3197. 	-- Attack the player now 
  3198. 	attack(guard) 
  3199. 	-- Decrease his accuracy 
  3200. 	npc_weapon_spread(guard, tss01_get_weapon_spread(4.0)) 
  3201. 	tss01_update_hit_points({guard}) 
  3202. end 
  3203.  
  3204. function tss01_police_turn_lights_on() 
  3205. 	-- Delay a short period of time 
  3206. 	delay(1.0) 
  3207.  
  3208. 	-- Turn on the vehicle sirens 
  3209. 	vehicle_lights_on(SEARCH_VEHICLE_01, true) 
  3210. 	vehicle_set_sirens(SEARCH_VEHICLE_01, true) 
  3211. end 
  3212.  
  3213. function tss01_setup_police_car_search_02() 
  3214. 	-- Do not let the guard exit this vehicle 
  3215. 	vehicle_suppress_npc_exit(SEARCH_VEHICLE_02) 
  3216. 	-- Teleport them into their vehicle 
  3217. 	vehicle_enter_teleport("tss01_$c049", SEARCH_VEHICLE_02) 
  3218.  
  3219. 	-- Set the driver's weapon spread and hit points 
  3220. 	npc_weapon_spread("tss01_$c049", tss01_get_weapon_spread(4.0)) 
  3221. 	tss01_update_hit_points({"tss01_$c049"}) 
  3222.  
  3223. 	-- Cut the hitpoints of the police cruiser to half 
  3224. 	set_max_hit_points(SEARCH_VEHICLE_02, get_max_hit_points(SEARCH_VEHICLE_02) * VEHICLE_HEALTH_MULTIPLIER, true) 
  3225.  
  3226. 	-- Delay for a little while before activating this sequence... 
  3227. 	delay(20.0) 
  3228.  
  3229. 	local function should_terminate() 
  3230. 		if ( (not vehicle_exists(SEARCH_VEHICLE_02)) or vehicle_is_destroyed(SEARCH_VEHICLE_02) ) then 
  3231. 			return true 
  3232. 		end 
  3233. 		if ( (not character_exists("tss01_$c049")) or character_is_dead("tss01_$c049") ) then 
  3234. 			return true 
  3235. 		end 
  3236. 		return false 
  3237. 	end 
  3238.  
  3239. 	-- Return early if the vehicle or driver are destroyed 
  3240. 	if ( should_terminate() ) then 
  3241. 		return 
  3242. 	end 
  3243.  
  3244. 	-- Turn on the vehicle sirens 
  3245. 	vehicle_lights_on(SEARCH_VEHICLE_02, true) 
  3246. 	vehicle_set_sirens(SEARCH_VEHICLE_02, true) 
  3247.  
  3248. 	-- Have the vehicle start the pathfind to the the light house 
  3249. 	vehicle_pathfind_to(SEARCH_VEHICLE_02, "tss01_$path006", true, false, false, true) 
  3250.  
  3251. 	-- Return early if the vehicle or driver are destroyed 
  3252. 	if ( should_terminate() ) then 
  3253. 		return 
  3254. 	end 
  3255.  
  3256. 	-- Have the vehicle finish the pathfind to the lighthouse 
  3257. 	vehicle_pathfind_to(SEARCH_VEHICLE_02, "tss01_$path006a", true, true, false, true) 
  3258.  
  3259. 	-- Return early if the vehicle or driver are destroyed 
  3260. 	if ( should_terminate() ) then 
  3261. 		return 
  3262. 	end 
  3263.  
  3264. 	-- The guard can exit now 
  3265. 	vehicle_suppress_npc_exit(SEARCH_VEHICLE_02, false) 
  3266.  
  3267. 	-- Force the guard to exit the vehicle and attack the player 
  3268. 	vehicle_stop(SEARCH_VEHICLE_02) 
  3269. 	if (character_exists("tss01_$c049") and (not character_is_dead("tss01_$c049"))) then 
  3270. 		vehicle_exit("tss01_$c049") 
  3271. 	end 
  3272. 	attack_safe("tss01_$c049") 
  3273. end 
  3274.  
  3275. function tss01_waypoint10() 
  3276. 	-- Remove the waypoint 
  3277. 	mission_waypoint_remove(SYNC_ALL) 
  3278.  
  3279. 	-- Enable the next trigger 
  3280. 	trigger_enable(Tss01_waypoints[10], true) 
  3281. 	-- Add the objective destination 
  3282. 	marker_add_trigger(Tss01_waypoints[10], MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  3283. 	-- Add the new waypoint 
  3284. 	--mission_waypoint_add(Tss01_waypoints[10], SYNC_ALL) 
  3285.  
  3286. 	-- Enable the bridge trigger 
  3287. 	on_trigger("tss01_bridge_trigger", BRIDGE_TRIGGER) 
  3288. 	trigger_enable(BRIDGE_TRIGGER, true) 
  3289.  
  3290. 	-- Enable the armory trigger 
  3291. 	on_trigger("tss01_armory_trigger", ARMORY_TRIGGER) 
  3292. 	trigger_enable(ARMORY_TRIGGER, true) 
  3293. end 
  3294.  
  3295. function tss01_waypoint11() 
  3296. 	-- Check to see if the waypoint has been triggered 
  3297. 	if (WAYPOINT_11_TRIGGERED) then 
  3298. 		return 
  3299. 	end 
  3300.  
  3301. 	-- Mark as triggered 
  3302. 	WAYPOINT_11_TRIGGERED = true 
  3303.  
  3304. 	-- We no longer need this door callback 
  3305. 	on_door_opened("", GUARD_ATTACK_DOOR) 
  3306.  
  3307. 	-- Remove the marker 
  3308. 	marker_remove_trigger(Tss01_waypoints[10], SYNC_ALL) 
  3309. 	-- Disable the incomming trigger 
  3310. 	trigger_enable(Tss01_waypoints[10], false) 
  3311. 	-- Remove the waypoint 
  3312. 	--mission_waypoint_remove(SYNC_ALL) 
  3313.  
  3314. 	-- Enable the next trigger 
  3315. 	trigger_enable(Tss01_waypoints[11], true) 
  3316. 	-- Add the objective destination 
  3317. 	marker_add_trigger(Tss01_waypoints[11], MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  3318. 	-- Add the new waypoint 
  3319. 	--mission_waypoint_add(Tss01_waypoints[11], SYNC_ALL) 
  3320.  
  3321. 	-- Play the exchange between Carlos and the player 
  3322. 	tss01_audio_play_conversation(Tss01_carlos_exchange_2) 
  3323. end 
  3324.  
  3325. function tss01_bridge_trigger() 
  3326. 	-- Disable this trigger 
  3327. 	trigger_enable(BRIDGE_TRIGGER, false) 
  3328.  
  3329. 	-- Create the court yard guards 
  3330. 	if (not group_is_loaded(GROUP_COURTYARD)) then 
  3331. 		-- We want the courtyard guards to be seen on the bridge 
  3332. 		group_create(GROUP_COURTYARD) 
  3333.  
  3334. 		-- Tell the courtyard guards to wander 
  3335. 		for i = 1, Num_tss01_courtyard_guards, 1 do 
  3336. 			wander_start(Tss01_courtyard_guards[i], Tss01_courtyard_guards[i], 5.0) 
  3337. 			npc_weapon_spread(Tss01_courtyard_guards[i], tss01_get_weapon_spread(4.0)) 
  3338. 			on_death("tss01_release_to_world", Tss01_courtyard_guards[i]) 
  3339. 		end 
  3340. 		tss01_update_hit_points(Tss01_courtyard_guards) 
  3341.  
  3342. 		if (tss01_spawn_coop_groups()) then 
  3343. 			group_create(GROUP_COURTYARD_COOP) 
  3344.  
  3345. 			-- Tell the courtyard guards to wander 
  3346. 			for i = 1, Num_tss01_courtyard_guards_coop, 1 do 
  3347. 				wander_start(Tss01_courtyard_guards_coop[i], Tss01_courtyard_guards_coop[i], 5.0) 
  3348. 				npc_weapon_spread(Tss01_courtyard_guards_coop[i], 4.0) 
  3349. 				on_death("tss01_release_to_world", Tss01_courtyard_guards_coop[i]) 
  3350. 			end 
  3351. 		end 
  3352. 	end 
  3353.  
  3354. 	-- Create the shortbus guards as hidden 
  3355. 	if (not group_is_loaded(GROUP_SHORTBUS)) then 
  3356. 		tss01_create_shortbus_and_add_cops() 
  3357. 	end 
  3358.  
  3359. 	-- Enable the entering bridge trigger 
  3360. 	trigger_enable(FALL_TRIGGER_OPEN, true) 
  3361. 	on_trigger("tss01_player_entering_bridge", FALL_TRIGGER_OPEN) 
  3362.  
  3363. 	trigger_enable(FALL_TRIGGER_CLOSE, false) 
  3364. 	on_trigger("tss01_player_exiting_bridge", FALL_TRIGGER_CLOSE) 
  3365.  
  3366. 	trigger_enable(FALLEN_TRIGGER, false) 
  3367. 	on_trigger("tss01_player_fell_to_courtyard", FALLEN_TRIGGER) 
  3368. end 
  3369.  
  3370. function tss01_player_entering_bridge() 
  3371. 	-- Open the first set of doors 
  3372. 	for i = 1, Num_tss01_door_set_1, 1 do 
  3373. 		door_open(Tss01_door_set_1[i], true) 
  3374. 	end 
  3375.  
  3376. 	-- Enable/Disable appropriate triggers 
  3377. 	trigger_enable(FALL_TRIGGER_OPEN, false) 
  3378. 	trigger_enable(FALL_TRIGGER_CLOSE, true) 
  3379. 	trigger_enable(FALLEN_TRIGGER, true) 
  3380. end 
  3381.  
  3382. function tss01_player_exiting_bridge() 
  3383. 	-- Close the first set of doors 
  3384. 	for i = 1, Num_tss01_door_set_1, 1 do 
  3385. 		door_close(Tss01_door_set_1[i]) 
  3386. 	end 
  3387.  
  3388. 	-- Enable/Disable appropriate triggers 
  3389. 	trigger_enable(FALL_TRIGGER_OPEN, true) 
  3390. 	trigger_enable(FALL_TRIGGER_CLOSE, false) 
  3391. 	trigger_enable(FALLEN_TRIGGER, false) 
  3392. end 
  3393.  
  3394. function tss01_player_fell_to_courtyard() 
  3395. 	-- Disable the fall triggers 
  3396. 	trigger_enable(FALL_TRIGGER_OPEN, false) 
  3397. 	trigger_enable(FALL_TRIGGER_CLOSE, false) 
  3398. 	trigger_enable(FALLEN_TRIGGER, false) 
  3399.  
  3400. 	-- Disable exit triggers...as this portion is no longer needed 
  3401. 	trigger_enable(RUN_GUN_TRIGGER_1, false) 
  3402. 	trigger_enable(RUN_GUN_TRIGGER_2, false) 
  3403. 	trigger_enable(RUN_GUN_TRIGGER_3, false) 
  3404.  
  3405. 	-- Open the remaining doors 
  3406. 	for i = 1, Num_tss01_door_set_2, 1 do 
  3407. 		door_open(Tss01_door_set_2[i], true) 
  3408. 	end 
  3409.  
  3410. 	tss01_waypoint11() 
  3411.  
  3412. 	-- Create the docks guards as hidden 
  3413. 	if (not group_is_loaded(GROUP_DOCKS)) then 
  3414. 		group_create(GROUP_DOCKS) 
  3415. 		group_create(GROUP_RANDOM) 
  3416. 		group_create(GROUP_ROADBLOCK) 
  3417.  
  3418. 		-- Tell the dock guards  they can't hit the broad side of a barn 
  3419. 		for i = 1, Num_tss01_dock_guards, 1 do 
  3420. 			npc_weapon_spread(Tss01_dock_guards[i], tss01_get_weapon_spread(3.0)) 
  3421. 			on_death("tss01_release_to_world", Tss01_dock_guards[i]) 
  3422. 		end 
  3423. 		tss01_update_hit_points(Tss01_dock_guards) 
  3424.  
  3425. 		-- Tell the random guards they can't hit the broad side of a barn 
  3426. 		for i = 1, Num_tss01_random_guards, 1 do 
  3427. 			-- We want these guys to have rifles 
  3428. 			inv_item_add("m16", 1, Tss01_random_guards[i], true) 
  3429. 			npc_weapon_spread(Tss01_random_guards[i], tss01_get_weapon_spread(2.0)) 
  3430. 			on_death("tss01_release_to_world", Tss01_random_guards[i]) 
  3431. 		end 
  3432. 		tss01_update_hit_points(Tss01_random_guards) 
  3433.  
  3434. 		-- Tell the roadblock guards they can't hit the broad side of a barn 
  3435. 		for i = 1, Num_tss01_roadblock_guards, 1 do 
  3436. 			npc_weapon_spread(Tss01_roadblock_guards[i], tss01_get_weapon_spread(3.0)) 
  3437. 			on_death("tss01_release_to_world", Tss01_roadblock_guards[i]) 
  3438. 		end 
  3439. 		tss01_update_hit_points(Tss01_roadblock_guards) 
  3440.  
  3441. 		if (tss01_spawn_coop_groups()) then 
  3442. 			group_create(GROUP_DOCKS_COOP) 
  3443. 			group_create(GROUP_RANDOM_COOP) 
  3444. 			group_create(GROUP_ROADBLOCK_COOP) 
  3445.  
  3446. 			-- Tell the dock guards  they can't hit the broad side of a barn 
  3447. 			for i = 1, Num_tss01_dock_guards_coop, 1 do 
  3448. 				npc_weapon_spread(Tss01_dock_guards_coop[i], 4.0) 
  3449. 				on_death("tss01_release_to_world", Tss01_dock_guards_coop[i]) 
  3450. 			end  
  3451.  
  3452. 			-- Tell the random guards they can't hit the broad side of a barn 
  3453. 			for i = 1, Num_tss01_random_guards_coop, 1 do 
  3454. 				-- We want these guys to have rifles 
  3455. 				inv_item_add("m16", 1, Tss01_random_guards_coop[i], true) 
  3456. 				npc_weapon_spread(Tss01_random_guards_coop[i], 2.0) 
  3457. 				on_death("tss01_release_to_world", Tss01_random_guards_coop[i]) 
  3458. 			end 
  3459.  
  3460. 			-- Tell the roadblock guards they can't hit the broad side of a barn 
  3461. 			for i = 1, Num_tss01_roadblock_guards_coop, 1 do 
  3462. 				npc_weapon_spread(Tss01_roadblock_guards_coop[i], 4.0) 
  3463. 				on_death("tss01_release_to_world", Tss01_roadblock_guards_coop[i]) 
  3464. 			end 
  3465. 		end 
  3466. 	end 
  3467.  
  3468. 	-- Show the hidden docks group 
  3469. 	group_show(GROUP_DOCKS) 
  3470. 	group_show(GROUP_RANDOM) 
  3471. 	group_show(GROUP_ROADBLOCK) 
  3472.  
  3473. 	if (tss01_spawn_coop_groups()) then 
  3474. 		group_show(GROUP_DOCKS_COOP) 
  3475. 		group_show(GROUP_RANDOM_COOP) 
  3476. 		group_show(GROUP_ROADBLOCK_COOP) 
  3477. 	end 
  3478.  
  3479. 	-- Delay a short period of time before the leashes are removed 
  3480. 	delay(4.0) 
  3481. 	-- Remove the leashes for the courtyard prison guards 
  3482. 	for i = 1, Num_tss01_courtyard_guards, 1 do 
  3483. 		npc_leash_remove(Tss01_courtyard_guards[i]) 
  3484. 	end 
  3485. end 
  3486.  
  3487. function tss01_armory_trigger() 
  3488. 	-- Disable this trigger 
  3489. 	trigger_enable(ARMORY_TRIGGER, false) 
  3490.  
  3491. 	-- Play audio line for Carlos 
  3492. 	tss01_audio_play_for_character("CARLOS_TSSP1_RUNGUN_2", CHARACTER_CARLOS, "voice") 
  3493.  
  3494. 	-- Give Carlos an assault rifle 
  3495. 	inv_item_add("m16", 1, CHARACTER_CARLOS) 
  3496.  
  3497. 	-- Enable the catwalk trigger 
  3498. 	on_trigger("tss01_catwalk_trigger", CATWALK_TRIGGER) 
  3499. 	trigger_enable(CATWALK_TRIGGER, true) 
  3500. end 
  3501.  
  3502. function tss01_catwalk_trigger() 
  3503. 	-- Disable the catwalk trigger 
  3504. 	trigger_enable(CATWALK_TRIGGER, false) 
  3505. 	-- Play Carlos's catwalk line 
  3506. 	tss01_audio_play_for_character("CARLOS_TSSP1_CATWALK", CHARACTER_CARLOS, "voice") 
  3507. end 
  3508.  
  3509. function tss01_explore_trigger(human, trigger) 
  3510. 	-- Disable this explore trigger 
  3511. 	trigger_enable(trigger, false) 
  3512. 	-- Play audio line for Carlos 
  3513. 	tss01_audio_play_for_character("CARLOS_TSSP1_DOCKS_01", CHARACTER_CARLOS, "voice") 
  3514. end 
  3515.  
  3516. function tss01_waypoint12_common() 
  3517.  
  3518. 	trigger_enable(Tss01_waypoints[12], true) 
  3519. 	-- Add the objective destination 
  3520. 	marker_add_trigger(Tss01_waypoints[12], MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  3521. 	-- Add the new waypoint 
  3522. 	mission_waypoint_add(Tss01_waypoints[12], SYNC_ALL) 
  3523.  
  3524. 	-- Tell the dock guards to attack 
  3525. 	for i = 1, Num_tss01_dock_guards, 1 do 
  3526. 		set_always_sees_player_flag(Tss01_dock_guards[i]) 
  3527. 		attack(Tss01_dock_guards[i]) 
  3528. 	end 
  3529.  
  3530. 	-- We do not want our yacht to be destroyed 
  3531. 	on_vehicle_destroyed("tss01_failure_yacht", HIGH_SEAS_VEHICLE) 
  3532.  
  3533. 	-- Enable Carlos's boat damage lines whenever the boat is damaged 
  3534. 	on_take_damage("tss01_enable_carlos_damage_line", HIGH_SEAS_VEHICLE) 
  3535.  
  3536. 	-- Up the health of the boat 
  3537. 	set_max_hit_points(HIGH_SEAS_VEHICLE, HIGH_SEAS_VEHICLE_HIT_POINTS, true) 
  3538. 	-- Make sure the vehicle is not entered...we just want to teleport everyone 
  3539. 	set_unjackable_flag(HIGH_SEAS_VEHICLE, true) 
  3540.  
  3541. 	-- Setup the heli ambush 
  3542. 	trigger_enable(HELI_AMBUSH_TRIGGER, true) 
  3543. 	on_trigger("tss01_heli_ambush", HELI_AMBUSH_TRIGGER) 
  3544. 	-- Create the group... 
  3545. 	group_create_hidden(GROUP_HELI_AMBUSH) 
  3546.  
  3547. 	-- Setup the Warden path 
  3548. 	trigger_enable(WARDONS_TRIGGER, true) 
  3549. 	on_trigger("tss01_warden_path", WARDONS_TRIGGER) 
  3550. 	 
  3551. 	-- Setup the Lighthouse path 
  3552. 	trigger_enable(LIGHTHOUSE_TRIGGER, true) 
  3553. 	on_trigger("tss01_lighthouse_path", LIGHTHOUSE_TRIGGER) 
  3554.  
  3555. 	-- Setup the cancel...this will cancel other scenarios for coop safety 
  3556. 	trigger_enable(CANCEL_TRIGGER, true) 
  3557. 	on_trigger("tss01_cancel_paths", CANCEL_TRIGGER) 
  3558. end 
  3559.  
  3560. function tss01_cancel_paths() 
  3561. 	-- Disable this trigger 
  3562. 	trigger_enable(CANCEL_TRIGGER, false) 
  3563.  
  3564. 	-- Once any player (local or remote) have reached this point, we want to disable all open scenarios. 
  3565. 	--		We need to do this so that one player cannot run around in an area where things are spawned or 
  3566. 	--		possibly going the wrong direction. One example of wrong direction is the heli ambush the if the 
  3567. 	--		wardens path is taken and then the player works his way around and then up to the light house... 
  3568. 	--		In this case, the heli would spawn and come in behind the player(s). The other case that is 
  3569. 	--		dangerous, especially in coop is, the same case but one player waits up top by the wardens house 
  3570. 	--		until the other player has gone down the warden path, past the docks, up to the light house, and 
  3571. 	--		and then the player waiting by the wardens house travels the normal path and triggers the run 
  3572. 	--		and gun section where the two cars spawn in and chase. 
  3573.  
  3574. 	-- Disable the run and gun 
  3575. 	trigger_enable(RUN_GUN_TRIGGER_4, false) 
  3576. 	-- Disable the heli ambush 
  3577. 	trigger_enable(HELI_AMBUSH_TRIGGER, false) 
  3578. 	-- Disable the wardens 
  3579. 	trigger_enable(WARDONS_TRIGGER, false) 
  3580. end 
  3581.  
  3582. -- Tutorial 
  3583. function tss01_waypoint12a() 
  3584. 	-- Remove the marker 
  3585. 	marker_remove_trigger(Tss01_waypoints[9], SYNC_ALL) 
  3586. 	-- Disable the incomming trigger 
  3587. 	trigger_enable(Tss01_waypoints[9], false) 
  3588. 	-- Remove the waypoint 
  3589. 	mission_waypoint_remove(SYNC_ALL) 
  3590.  
  3591. 	-- Release some stuff to the world 
  3592. 	release_to_world(GROUP_KEY_GUARDS) 
  3593. 	 
  3594. 	-- Enable the triggers for when the player tries to explore 
  3595. 	for i = 1, Num_tss01_explore_triggers, 1 do 
  3596. 		trigger_enable(Tss01_explore_triggers[i], true) 
  3597. 	end 
  3598.  
  3599. 	-- Enable the trigger 
  3600. 	trigger_enable(END_ROOFTOP_TRIGGER, true) 
  3601. 	-- Setup the callback 
  3602. 	on_trigger("tss01_waypoint12aa", END_ROOFTOP_TRIGGER) 
  3603. 	-- Add the objective destination 
  3604. 	marker_add_trigger(END_ROOFTOP_TRIGGER, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL) 
  3605. 	-- Add the new waypoint 
  3606. 	mission_waypoint_add(END_ROOFTOP_TRIGGER, SYNC_ALL) 
  3607.  
  3608. 	-- Create our dock group 
  3609. 	group_create_hidden(GROUP_DOCKS) 
  3610. 	group_create_hidden(GROUP_RANDOM) 
  3611. 	group_create_hidden(GROUP_ROADBLOCK) 
  3612.  
  3613. 	if (tss01_spawn_coop_groups()) then 
  3614. 		group_create_hidden(GROUP_DOCKS_COOP) 
  3615. 		group_create_hidden(GROUP_RANDOM_COOP) 
  3616. 		group_create_hidden(GROUP_ROADBLOCK_COOP) 
  3617. 	end 
  3618. 	 
  3619. 	-- We are going to have the heli land and drop guys off 
  3620. 	if (not vehicle_is_destroyed(SPOT_LIGHT_HELI)) then 
  3621. 		-- Pathfind! 
  3622. 		helicopter_fly_to_direct(SPOT_LIGHT_HELI, 60.0, "tss01_$n047") 
  3623. 		helicopter_fly_to_direct(SPOT_LIGHT_HELI, 40.0, "tss01_$n033") 
  3624. 	end 
  3625. end 
  3626.  
  3627. function tss01_waypoint12aa() 
  3628. 	-- If we are in coop, they need to be together in order to proceed 
  3629. 	if (IN_COOP) then 
  3630. 		-- Check the distance 
  3631. 		if (get_dist(LOCAL_PLAYER, REMOTE_PLAYER) > 10.0) then 
  3632. 			-- Show the players the cooperative message 
  3633. 			mission_help_table_nag("tss01_cooperative") 
  3634. 			return 
  3635. 		end 
  3636. 	end 
  3637.  
  3638. 	-- Disable the incomming trigger 
  3639. 	trigger_enable(END_ROOFTOP_TRIGGER, false) 
  3640. 	-- Remove the waypoint 
  3641. 	mission_waypoint_remove(SYNC_ALL) 
  3642.  
  3643. 	-- Release some stuff to the world 
  3644. 	release_to_world(GROUP_ROOFTOP) 
  3645. 	release_to_world(GROUP_FIRE_ESCAPE) 
  3646. 	release_to_world(GROUP_PURSUIT_GUARDS) 
  3647.  
  3648. 	-- Set the mission checkpoint 
  3649. 	mission_set_checkpoint(MISSION_CHECKPOINT_DOCKS) 
  3650.  
  3651. 	-- Get to the docks! 
  3652. 	tss01_to_the_docks() 
  3653. end 
  3654.  
  3655. function tss01_to_the_docks() 
  3656. 	-- Setup our next scenarios 
  3657. 	trigger_enable(HELI_LAND_TRIGGER, true) 
  3658. 	on_trigger("tss01_heli_land", HELI_LAND_TRIGGER) 
  3659.  
  3660. 	trigger_enable(HELI_BACKUP_TRIGGER, true) 
  3661. 	on_trigger("tss01_heli_backup", HELI_BACKUP_TRIGGER) 
  3662.  
  3663. 	-- Our goal is now the docks so show our docks group 
  3664. 	group_show(GROUP_DOCKS) 
  3665. 	group_show(GROUP_RANDOM) 
  3666. 	group_show(GROUP_ROADBLOCK) 
  3667.  
  3668. 	-- Tell the dock guards they can't hit shit 
  3669. 	for i = 1, Num_tss01_dock_guards, 1 do 
  3670. 		npc_weapon_spread(Tss01_dock_guards[i], tss01_get_weapon_spread(4.0)) 
  3671. 		on_death("tss01_release_to_world", Tss01_dock_guards[i]) 
  3672. 	end 
  3673. 	tss01_update_hit_points(Tss01_dock_guards) 
  3674.  
  3675. 	-- Tell the random guards they can't hit the broad side of a barn 
  3676. 	for i = 1, Num_tss01_random_guards, 1 do 
  3677. 		-- We want these guys to have rifles 
  3678. 		inv_item_add("m16", 1, Tss01_random_guards[i], true) 
  3679. 		npc_weapon_spread(Tss01_random_guards[i], tss01_get_weapon_spread(2.0)) 
  3680. 		on_death("tss01_release_to_world", Tss01_random_guards[i]) 
  3681. 	end 
  3682. 	tss01_update_hit_points(Tss01_random_guards) 
  3683.  
  3684. 	-- Tell the roadblock guards they can't hit the broad side of a barn 
  3685. 	for i = 1, Num_tss01_roadblock_guards, 1 do 
  3686. 		npc_weapon_spread(Tss01_roadblock_guards[i], tss01_get_weapon_spread(4.0)) 
  3687. 		on_death("tss01_release_to_world", Tss01_roadblock_guards[i]) 
  3688. 	end 
  3689. 	tss01_update_hit_points(Tss01_roadblock_guards) 
  3690.  
  3691. 	-- Turn the lights on  
  3692. 	for i = 1, Num_tss01_roadblock_cars, 1 do 
  3693. 		vehicle_lights_on(Tss01_roadblock_cars[i], true) 
  3694. 		vehicle_set_sirenlights(Tss01_roadblock_cars[i], true) 
  3695. 		-- Lower the hit points... 
  3696. 		set_max_hit_points(Tss01_roadblock_cars[i], get_max_hit_points(Tss01_roadblock_cars[i]) * VEHICLE_HEALTH_MULTIPLIER, true) 
  3697. 	end 
  3698.  
  3699. 	-- Remove the leash from these guys 
  3700. 	for i = 1, Num_tss01_search_01, 1 do 
  3701. 		if (character_exists(Tss01_search_01[i]) and (not character_is_dead(Tss01_search_01[i])) ) then 
  3702. 			npc_leash_remove(Tss01_search_01[i]) 
  3703. 		end 
  3704. 	end 
  3705.  
  3706. 	if (tss01_spawn_coop_groups()) then 
  3707. 		group_show(GROUP_DOCKS_COOP) 
  3708. 		group_show(GROUP_RANDOM_COOP) 
  3709. 		group_show(GROUP_ROADBLOCK_COOP) 
  3710.  
  3711. 		-- Tell the dock guards they can't hit shit 
  3712. 		for i = 1, Num_tss01_dock_guards_coop, 1 do 
  3713. 			npc_weapon_spread(Tss01_dock_guards_coop[i], 4.0) 
  3714. 			on_death("tss01_release_to_world", Tss01_dock_guards_coop[i]) 
  3715. 		end 
  3716.  
  3717. 		-- Tell the random guards they can't hit the broad side of a barn 
  3718. 		for i = 1, Num_tss01_random_guards_coop, 1 do 
  3719. 			-- We want these guys to have rifles 
  3720. 			inv_item_add("m16", 1, Tss01_random_guards_coop[i], true) 
  3721. 			npc_weapon_spread(Tss01_random_guards_coop[i], 2.0) 
  3722. 			on_death("tss01_release_to_world", Tss01_random_guards_coop[i]) 
  3723. 		end 
  3724.  
  3725. 		-- Tell the roadblock guards they can't hit the broad side of a barn 
  3726. 		for i = 1, Num_tss01_roadblock_guards_coop, 1 do 
  3727. 			npc_weapon_spread(Tss01_roadblock_guards_coop[i], 4.0) 
  3728. 			on_death("tss01_release_to_world", Tss01_roadblock_guards_coop[i]) 
  3729. 		end 
  3730. 	end 
  3731.  
  3732. 	-- Give Carlos an hand gun in at this point... 
  3733. 	inv_item_add("glock", 1, CHARACTER_CARLOS) 
  3734.  
  3735. 	-- Play audio line for Carlos 
  3736. 	tss01_audio_play_for_character("CARLOS_TSSP1_LEAVEROOF", CHARACTER_CARLOS, "voice", false, true) 
  3737. 	-- Prompt the user with help text... 
  3738. 	mission_help_table("tss01_docks") 
  3739.  
  3740. 	-- Show the checkpoint tutorial 
  3741. 	tutorial_start("sprint") 
  3742.  
  3743. 	tss01_waypoint12_common() 
  3744. end 
  3745.  
  3746. function tss01_to_the_docks_from_checkpoint() 
  3747. 	-- Set the notoriety for the rest of the mission...this is for the restart at checkpoint 
  3748. 	notoriety_set_max("police", 1) 
  3749. 	notoriety_set_min("police", 1) 
  3750.  
  3751. 	tss01_to_the_docks() 
  3752. end 
  3753.  
  3754. Tss01_heli_passengers_exited = 0 
  3755. function tss01_heli_land() 
  3756. 	-- Disable the trigger since it is no longer needed 
  3757. 	trigger_enable(HELI_LAND_TRIGGER, false) 
  3758.  
  3759. 	-- We are going to have the heli land and drop guys off 
  3760. 	if (not vehicle_is_destroyed(SPOT_LIGHT_HELI)) then 
  3761. 		-- Don't let the player jack this helicopter 
  3762. 		set_unjackable_flag(SPOT_LIGHT_HELI, true) 
  3763.  
  3764. 		-- Pathfind! 
  3765. 		helicopter_fly_to_direct(SPOT_LIGHT_HELI, 17.0, "tss01_$path003") 
  3766.  
  3767. 		delay(2.0) 
  3768. 		 
  3769. 		thread_new("tss01_heli_passenger_exit","tss01_$spot1") 
  3770. 		thread_new("tss01_heli_passenger_exit","tss01_$spot2") 
  3771.  
  3772. 		while(Tss01_heli_passengers_exited ~= 2) do 
  3773. 			thread_yield() 
  3774. 		end 
  3775.  
  3776. 		-- Pathfind back up! 
  3777. 		helicopter_fly_to_direct(SPOT_LIGHT_HELI, 50.0, "tss01_$n048") 
  3778.  
  3779. 		-- Put the heli back into chase mode 
  3780. 		vehicle_chase(SPOT_LIGHT_HELI, LOCAL_PLAYER) 
  3781. 	end 
  3782. end 
  3783.  
  3784. function tss01_heli_passenger_exit(npc) 
  3785. 	if (not character_is_dead(npc)) then 
  3786. 		vehicle_exit(npc, true) 
  3787. 		Tss01_heli_passengers_exited = Tss01_heli_passengers_exited + 1 
  3788. 		audio_play_persona_line(npc, "threat - alert (group attack)") 
  3789.  
  3790. 		-- Tell him to attack 
  3791. 		attack(npc) 
  3792. 	else 
  3793. 		Tss01_heli_passengers_exited = Tss01_heli_passengers_exited + 1 
  3794. 	end 
  3795. end 
  3796.  
  3797. function tss01_heli_backup() 
  3798. 	-- Disable the trigger since it is no longer needed 
  3799. 	trigger_enable(HELI_BACKUP_TRIGGER, false) 
  3800.  
  3801. 	-- Spawn off a thread to do the fine aim heli crash 
  3802. 	thread_new("tss01_heli_crash") 
  3803.  
  3804. 	--Show the fine aim group 
  3805. 	group_show(GROUP_TUT_T_IN_ROAD) 
  3806. 	-- Teleport them into their vehicle 
  3807. 	vehicle_enter_group_teleport(Tss01_tut_t_road, T_IN_ROAD_VEHICLE) 
  3808.  
  3809. 	-- Turn on the vehicle sirens 
  3810. 	vehicle_lights_on(T_IN_ROAD_VEHICLE, true) 
  3811. 	vehicle_set_sirens(T_IN_ROAD_VEHICLE, true) 
  3812.  
  3813. 	-- Lower the hit points... 
  3814. 	set_max_hit_points(T_IN_ROAD_VEHICLE, get_max_hit_points(T_IN_ROAD_VEHICLE) * VEHICLE_HEALTH_MULTIPLIER, true) 
  3815.  
  3816. 	-- Have the vehicle pathfind to the the light house 
  3817. 	vehicle_pathfind_to(T_IN_ROAD_VEHICLE, "tss01_$path002", true, true) 
  3818.  
  3819. 	-- Tell these guys to attack the player 
  3820. 	for i = 1, Num_tss01_tut_t_road, 1 do 
  3821. 		attack(Tss01_tut_t_road[i]) 
  3822. 		npc_weapon_spread(Tss01_tut_t_road[i], tss01_get_weapon_spread(4.0)) 
  3823. 		on_death("tss01_release_to_world", Tss01_tut_t_road[i]) 
  3824. 	end 
  3825. 	tss01_update_hit_points(Tss01_tut_t_road) 
  3826. end 
  3827.  
  3828. function tss01_heli_crash() 
  3829. 	-- Make sure the vehicle hasn't been destroyed...this shouldn't be possible anymore but I'll keep it here anyway 
  3830. 	if (not vehicle_is_destroyed(FINE_AIM_VEHICLE)) then 
  3831. 		-- Setup the speed reduction 
  3832. 		trigger_enable("tss01_$heli_crash", true) 
  3833. 		on_trigger("tss01_slow_crash_down", "tss01_$heli_crash") 
  3834. 		-- Turn this heli vulnerable 
  3835. 		turn_vulnerable(FINE_AIM_VEHICLE) 
  3836. 		turn_vulnerable("tss01_$c050") 
  3837. 		-- Lower the hit points... 
  3838. 		set_current_hit_points(FINE_AIM_VEHICLE, get_max_hit_points(FINE_AIM_VEHICLE) * 0.12) 
  3839. 		-- Tell the fine aim vehicle to fly where it needs to be 
  3840. 		helicopter_fly_to_direct_dont_stop(FINE_AIM_VEHICLE, 70.0, "tss01_$path010") 
  3841. 	end 
  3842. end 
  3843.  
  3844. function tss01_slow_crash_down() 
  3845. 	-- Disable this trigger 
  3846. 	trigger_enable("tss01_$heli_crash", false) 
  3847. 	-- Change the speed 
  3848. 	vehicle_speed_override(FINE_AIM_VEHICLE, 30.0) 
  3849. end 
  3850.  
  3851. -- Run and Gun 
  3852. function tss01_waypoint12b() 
  3853. 	-- Remove the marker 
  3854. 	marker_remove_trigger(Tss01_waypoints[11], SYNC_ALL) 
  3855. 	-- Disable the incomming trigger 
  3856. 	trigger_enable(Tss01_waypoints[11], false) 
  3857. 	-- Remove the waypoint 
  3858. 	mission_waypoint_remove(SYNC_ALL) 
  3859.  
  3860. 	-- Release some stuff to the world 
  3861. 	release_to_world(GROUP_COURTYARD) 
  3862. 	release_to_world(GROUP_COURTYARD_COOP) 
  3863.  
  3864. 	-- Create the run and gun group... 
  3865. 	group_create_hidden(GROUP_RUN_GUN) 
  3866.  
  3867. 	tss01_waypoint12_common() 
  3868.  
  3869. 	-- Put the spot light heli into chase mode 
  3870. 	if (not vehicle_is_destroyed(SPOT_LIGHT_HELI)) then 
  3871. 		vehicle_chase(SPOT_LIGHT_HELI, LOCAL_PLAYER) 
  3872. 	end 
  3873.  
  3874. 	-- Setup the run and gun portion as the player makes way to docks 
  3875. 	trigger_enable(RUN_GUN_TRIGGER_4, true) 
  3876. 	on_trigger("tss01_run_gun", RUN_GUN_TRIGGER_4) 
  3877.  
  3878. 	-- Play the exchange between Carlos and the player 
  3879. 	tss01_audio_play_conversation(Tss01_carlos_exchange_4) 
  3880. end 
  3881.  
  3882. function tss01_run_gun(human, trigger) 
  3883. 	-- Disable this trigger as it is no longer needed 
  3884. 	trigger_enable(RUN_GUN_TRIGGER_4, false) 
  3885.  
  3886. 	-- Play the exchange between Carlos and the player 
  3887. 	tss01_audio_play_conversation(Tss01_carlos_exchange_5) 
  3888.  
  3889. 	-- Show the group... 
  3890. 	group_show(GROUP_RUN_GUN) 
  3891.  
  3892. 	-- Teleport the humans into the heli 
  3893. 	vehicle_enter_group_teleport(Tss01_run_gun_part1, RUN_GUN_PART1_VEHICLE) 
  3894. 	vehicle_enter_group_teleport(Tss01_run_gun_part2, RUN_GUN_PART2_VEHICLE) 
  3895.  
  3896. 	-- Tell these guys they can't hit a barn 3 feet in front of them 
  3897. 	for i = 1, Num_tss01_run_gun_part1, 1 do 
  3898. 		npc_weapon_spread(Tss01_run_gun_part1[i], tss01_get_weapon_spread(4.0)) 
  3899. 		on_death("tss01_release_to_world", Tss01_run_gun_part1[i]) 
  3900. 	end 
  3901. 	tss01_update_hit_points(Tss01_run_gun_part1) 
  3902.  
  3903. 	for i = 1, Num_tss01_run_gun_part2, 1 do 
  3904. 		npc_weapon_spread(Tss01_run_gun_part2[i], tss01_get_weapon_spread(4.0)) 
  3905. 		on_death("tss01_release_to_world", Tss01_run_gun_part2[i]) 
  3906. 	end 
  3907. 	tss01_update_hit_points(Tss01_run_gun_part2) 
  3908.  
  3909. 	-- Turn the lights on 
  3910. 	vehicle_lights_on(RUN_GUN_PART1_VEHICLE, true) 
  3911. 	vehicle_set_sirens(RUN_GUN_PART1_VEHICLE, true) 
  3912.  
  3913. 	vehicle_lights_on(RUN_GUN_PART2_VEHICLE, true) 
  3914. 	vehicle_set_sirens(RUN_GUN_PART2_VEHICLE, true) 
  3915.  
  3916. 	-- Lower the hit points... 
  3917. 	set_max_hit_points(RUN_GUN_PART1_VEHICLE, get_max_hit_points(RUN_GUN_PART1_VEHICLE) * VEHICLE_HEALTH_MULTIPLIER, true) 
  3918. 	set_max_hit_points(RUN_GUN_PART2_VEHICLE, get_max_hit_points(RUN_GUN_PART2_VEHICLE) * VEHICLE_HEALTH_MULTIPLIER, true) 
  3919.  
  3920. 	-- Should the vehicles ram? 
  3921. 	local		ram_human = character_is_in_vehicle(human) 
  3922.  
  3923. 	-- Chase the player(s) 
  3924. 	vehicle_chase(RUN_GUN_PART1_VEHICLE, human, true, ram_human, false) 
  3925. 	delay(4.0) 
  3926. 	vehicle_chase(RUN_GUN_PART2_VEHICLE, human, true, ram_human, false) 
  3927.  
  3928. 	-- If we are to ram the player, give the lead vehicle infinite mass so they can plow through the roadblock 
  3929. 	if (ram_human) then 
  3930. 		vehicle_infinite_mass(RUN_GUN_PART1_VEHICLE, true) 
  3931. 		on_vehicle_exit("tss01_reset_my_infinite_mass_status", RUN_GUN_PART1_VEHICLE) 
  3932. 	end 
  3933. end 
  3934.  
  3935. function tss01_heli_ambush() 
  3936. 	 
  3937. 	AMBUSH_THREAD_HANDLE = thread_new("tss01_heli_ambush_do") 
  3938.  
  3939. end 
  3940.  
  3941. function tss01_heli_ambush_do() 
  3942. 	-- Disable this trigger... 
  3943. 	trigger_enable(HELI_AMBUSH_TRIGGER, false) 
  3944.  
  3945. 	local		local_can_see_heli = navpoint_in_player_fov(HELI_AMBUSH_VEHICLE, LOCAL_PLAYER, 5.0) 
  3946. 	local		remote_can_see_heli = false 
  3947.  
  3948. 	if (IN_COOP) then 
  3949. 		remote_can_see_heli = navpoint_in_player_fov(HELI_AMBUSH_VEHICLE, REMOTE_PLAYER, 5.0) 
  3950. 	end 
  3951.  
  3952. 	-- Wait until the heli is not being looked at... 
  3953. 	while (local_can_see_heli or remote_can_see_heli) do 
  3954. 		thread_yield() 
  3955.  
  3956. 		local_can_see_heli = navpoint_in_player_fov(HELI_AMBUSH_VEHICLE, LOCAL_PLAYER, 5.0) 
  3957. 		if (IN_COOP) then 
  3958. 			remote_can_see_heli = navpoint_in_player_fov(HELI_AMBUSH_VEHICLE, REMOTE_PLAYER, 5.0) 
  3959. 		end 
  3960. 	end 
  3961.  
  3962. 	-- The heli is not being looked at 
  3963. 	group_show(GROUP_HELI_AMBUSH) 
  3964.  
  3965. 	-- Teleport the humans into the heli 
  3966. 	vehicle_enter_teleport("tss01_$c027", HELI_AMBUSH_VEHICLE, 0) 
  3967. 	vehicle_enter_teleport("tss01_$c028", HELI_AMBUSH_VEHICLE, 4) 
  3968. 	vehicle_enter_teleport("tss01_$c029", HELI_AMBUSH_VEHICLE, 5) 
  3969.  
  3970. 	-- This guys can't hit shit 
  3971. 	npc_weapon_spread("tss01_$c027", tss01_get_weapon_spread(2.0)) 
  3972. 	npc_weapon_spread("tss01_$c028", tss01_get_weapon_spread(2.0)) 
  3973. 	npc_weapon_spread("tss01_$c029", tss01_get_weapon_spread(2.0)) 
  3974. 	tss01_update_hit_points({"tss01_$c027", "tss01_$c028", "tss01_$c029"}) 
  3975.  
  3976. 	vehicle_lights_on(HELI_AMBUSH_VEHICLE, true) 
  3977. 	vehicle_set_sirens(HELI_AMBUSH_VEHICLE, true) 
  3978.  
  3979. 	-- Setup the speed reduction 
  3980. 	trigger_enable("tss01_$heli_ambush", true) 
  3981. 	on_trigger("tss01_slow_ambush_down", "tss01_$heli_ambush") 
  3982.  
  3983. 	--	Reduce the hitpoints 
  3984. 	set_max_hit_points(HELI_AMBUSH_VEHICLE, get_max_hit_points(HELI_AMBUSH_VEHICLE) * VEHICLE_HEALTH_MULTIPLIER, true) 
  3985.  
  3986. 	-- Setup the callback 
  3987. 	on_vehicle_destroyed("tss01_ambush_destroyed", HELI_AMBUSH_VEHICLE) 
  3988.  
  3989. 	-- Teleport the heli to the location we want it to be 
  3990. 	teleport_vehicle(HELI_AMBUSH_VEHICLE, "tss01_$n035") 
  3991.  
  3992. 	-- Have the heli pathfind 
  3993. 	helicopter_fly_to_direct(HELI_AMBUSH_VEHICLE, 90.0, "tss01_$path004") 
  3994. 	-- Make this heli unjackable 
  3995. 	set_unjackable_flag(HELI_AMBUSH_VEHICLE, true) 
  3996.  
  3997. 	-- Have Carlos attack the helicopter if he can safely do so. 
  3998. 	CARLOS_AMBUSH_THREAD_HANDLE = thread_new("tss01_carlos_destroy_ambush") 
  3999.  
  4000. 	-- If Carlos needs to be revived, have him ignore the helicopter 
  4001. 	on_revived("tss01_carlos_ignore_ambush", CHARACTER_CARLOS) 
  4002.  
  4003. 	-- We've had problems with Carlos being stuck dependent trying to destroy the ambush. 
  4004. 	-- if he takes too long, kill the thread and make him dependent. 
  4005. 	delay(12) 
  4006. 	tss01_carlos_ignore_ambush() 
  4007. end 
  4008.  
  4009. function tss01_carlos_should_destroy_ambush() 
  4010.  
  4011. 	-- Have Carlos attack the heli if it is safe to do so. 
  4012. 	if (	(get_dist("tss01_$carlos_shoot", CHARACTER_CARLOS) < 50) 
  4013. 			and vehicle_exists(HELI_AMBUSH_VEHICLE) 
  4014. 			and (not vehicle_is_destroyed(HELI_AMBUSH_VEHICLE)) 
  4015. 			and (character_exists("tss01_$c027")) 
  4016. 			and (not character_is_dead("tss01_$c027")) 
  4017. 			and (not character_is_in_vehicle(CHARACTER_CARLOS)) 
  4018. 			and (not follower_is_unconscious(CHARACTER_CARLOS)) 
  4019. 			and (CARLOS_HIDE_THREAD_HANDLE == INVALID_THREAD_HANDLE) 
  4020. 		) then 
  4021. 		return true 
  4022. 	end 
  4023.  
  4024. 	return false 
  4025.  
  4026. end 
  4027.  
  4028. function tss01_slow_ambush_down() 
  4029. 	-- Disable the trigger 
  4030. 	trigger_enable("tss01_$heli_ambush", false) 
  4031. 	-- Slow the heli down 
  4032. 	vehicle_speed_override(HELI_AMBUSH_VEHICLE, 15.0) 
  4033. end 
  4034.  
  4035. -- Have Carlos attempt to shoot down the ambush helicopter 
  4036. function tss01_carlos_destroy_ambush() 
  4037.  
  4038. 	-- Move Carlos into position 
  4039. 	if(tss01_carlos_should_destroy_ambush()) then 
  4040.  
  4041. 		follower_make_independent(CHARACTER_CARLOS, true) 
  4042. 		move_to_safe(CHARACTER_CARLOS, "tss01_$carlos_shoot", 3, true, true) 
  4043.  
  4044. 		-- Tell Carlos to shoot it down (well the pilot that is) 
  4045. 		if ( tss01_carlos_should_destroy_ambush() and (get_dist("tss01_$carlos_shoot", CHARACTER_CARLOS) < 5) ) then 
  4046. 			set_perfect_aim(CHARACTER_CARLOS, true) 
  4047. 			attack(CHARACTER_CARLOS, "tss01_$c027") 
  4048. 		end 
  4049.  
  4050. 		set_perfect_aim(CHARACTER_CARLOS, false) 
  4051.  
  4052. 	end 
  4053.  
  4054. end 
  4055.  
  4056. -- Have Carlos stop trying to shoot down the ambush helicopter 
  4057. Tss01_carlos_ignoring_ambush = false 
  4058. function tss01_carlos_ignore_ambush(dont_make_dependent) 
  4059.  
  4060. 	if(Tss01_carlos_ignoring_ambush == false) then 
  4061.  
  4062. 		Tss01_carlos_ignoring_ambush = true 
  4063.  
  4064. 		-- Clear out the on-revived callback 
  4065. 		on_revived("", CHARACTER_CARLOS) 
  4066.  
  4067. 		-- Kill the thread that has Carlos attack the ambush helicopter 
  4068. 		if(CARLOS_AMBUSH_THREAD_HANDLE ~= INVALID_THREAD_HANDLE) then 
  4069.  
  4070. 			thread_kill(CARLOS_AMBUSH_THREAD_HANDLE ) 
  4071. 			CARLOS_AMBUSH_THREAD_HANDLE  = INVALID_THREAD_HANDLE 
  4072.  
  4073. 		end 
  4074.  
  4075. 		-- Make Carlos dependent again. 
  4076. 		if (not dont_make_dependent) then 
  4077. 			follower_make_independent(CHARACTER_CARLOS, false) 
  4078. 		end 
  4079.  
  4080. 		set_perfect_aim(CHARACTER_CARLOS, false) 
  4081.  
  4082. 	end 
  4083.  
  4084.  
  4085. end 
  4086.  
  4087. -- Called when the ambush helicopter has been destroyed 
  4088. function tss01_ambush_destroyed() 
  4089. 	-- Remove the callback 
  4090. 	on_vehicle_destroyed("", HELI_AMBUSH_VEHICLE) 
  4091. 	-- Remove the revived callback 
  4092. 	on_revived("", CHARACTER_CARLOS) 
  4093. 	-- Make Carlos dependent 
  4094. 	tss01_carlos_ignore_ambush() 
  4095. end 
  4096.  
  4097. function tss01_warden_path() 
  4098. 	-- Disable the trigger since it isn't needed anymore 
  4099. 	trigger_enable(WARDONS_TRIGGER, false) 
  4100.  
  4101. 	-- Create the Warden group incase the player tries to go that direction 
  4102. 	group_create(GROUP_WARDENS) 
  4103. 	if (tss01_spawn_coop_groups()) then 
  4104. 		group_create(GROUP_WARDENS_COOP) 
  4105. 	end 
  4106.  
  4107. 	-- Tell these guys they can't hit a barn 3 feet in front of them 
  4108. 	for i = 1, Num_tss01_warden_guards, 1 do 
  4109. 		npc_weapon_spread(Tss01_warden_guards[i], tss01_get_weapon_spread(1.5)) 
  4110. 		on_death("tss01_release_to_world", Tss01_warden_guards[i]) 
  4111. 	end 
  4112. 	tss01_update_hit_points(Tss01_warden_guards) 
  4113.  
  4114. 	for i = 1, Num_tss01_warden_rifle_guards, 1 do 
  4115. 		-- We want these guys to have rifles 
  4116. 		inv_item_add("m16", 1, Tss01_warden_rifle_guards[i], true) 
  4117. 		npc_weapon_spread(Tss01_warden_rifle_guards[i], tss01_get_weapon_spread(2.0)) 
  4118. 		on_death("tss01_release_to_world", Tss01_warden_rifle_guards[i]) 
  4119. 	end 
  4120. 	tss01_update_hit_points(Tss01_warden_rifle_guards) 
  4121. end 
  4122.  
  4123. function tss01_lighthouse_path() 
  4124. 	-- Disable the trigger since it isn't needed anymore 
  4125. 	trigger_enable(LIGHTHOUSE_TRIGGER, false) 
  4126.  
  4127. 	-- Create the Lighthouse group incase the player tries to go that direction 
  4128. 	group_create(GROUP_LIGHTHOUSE) 
  4129. 	if (tss01_spawn_coop_groups()) then 
  4130. 		group_create(GROUP_LIGHTHOUSE_COOP) 
  4131. 	end 
  4132.  
  4133. 	-- Tell these guys they can't hit a barn 3 feet in front of them 
  4134. 	for i = 1, Num_tss01_lighthouse_rifle_guards, 1 do 
  4135. 		-- We want these guys to have rifles 
  4136. 		inv_item_add("m16", 1, Tss01_lighthouse_rifle_guards[i], true) 
  4137. 		npc_weapon_spread(Tss01_lighthouse_rifle_guards[i], tss01_get_weapon_spread(2.0)) 
  4138. 		on_death("tss01_release_to_world", Tss01_lighthouse_rifle_guards[i]) 
  4139. 	end 
  4140. 	tss01_update_hit_points(Tss01_lighthouse_rifle_guards) 
  4141. end 
  4142.  
  4143. function tss01_waypoint_end() 
  4144.  
  4145. 	-- Carlos must be alive when this trigger is hit 
  4146. 	if (character_is_dead(CHARACTER_CARLOS)) then 
  4147. 		return 
  4148. 	end 
  4149.  
  4150. 	-- Make sure taht Carlos isn't still trying to shoot down the ambush helicopter 
  4151. 	tss01_carlos_ignore_ambush(true) 
  4152.  
  4153. 	-- Can't activate this checkpoint while in a vehicle 
  4154. 	if ( character_is_in_vehicle(LOCAL_PLAYER) or (IN_COOP and character_is_in_vehicle(REMOTE_PLAYER)) ) then 
  4155. 		return 
  4156. 	end 
  4157.  
  4158. 	-- If we are in coop, they need to be together in order to proceed 
  4159. 	if (IN_COOP) then 
  4160. 		-- Check the distance 
  4161. 		if (	(get_dist(LOCAL_PLAYER, REMOTE_PLAYER) > 10.0) 
  4162. 				or (not character_is_ready(LOCAL_PLAYER)) 
  4163. 				or (not character_is_ready(REMOTE_PLAYER)) 
  4164. 			) then 
  4165. 			-- Show the players the cooperative message 
  4166. 			mission_help_table_nag("tss01_cooperative") 
  4167. 			return 
  4168. 		end 
  4169. 	end 
  4170.  
  4171. 	-- Stop adjusting the hp of vehicles that the players enter 
  4172. 	if (VEHICLE_HP_THREAD_HANDLE ~= INVALID_THREAD_HANDLE) then 
  4173. 		thread_kill(VEHICLE_HP_THREAD_HANDLE) 
  4174. 	end 
  4175.  
  4176. 	if (SWIM_DISTANCE_THREAD_HANDLE ~= INVALID_THREAD_HANDLE) then 
  4177. 		thread_kill(SWIM_DISTANCE_THREAD_HANDLE) 
  4178. 	end 
  4179.  
  4180. 	-- The checkpoint has been hit! 
  4181. 	mission_set_checkpoint(MISSION_CHECKPOINT_BOAT) 
  4182.  
  4183. 	-- Make Carlos invulnerable 
  4184. 	turn_invulnerable(CHARACTER_CARLOS, false) 
  4185.  
  4186. 	-- Remove this callback in case this is hit before Carlos shoots it down 
  4187. 	on_vehicle_destroyed("", HELI_AMBUSH_VEHICLE) 
  4188.  
  4189. 	-- Remove the marker 
  4190. 	marker_remove_trigger(Tss01_waypoints[12], SYNC_ALL) 
  4191. 	-- Disable the incomming trigger 
  4192. 	trigger_enable(Tss01_waypoints[12], false) 
  4193. 	-- Remove the waypoint 
  4194. 	mission_waypoint_remove(SYNC_ALL) 
  4195.  
  4196. 	-- Release the groups that are no longer needed 
  4197. 	release_to_world(GROUP_TUT_SEARCH) 
  4198. 	release_to_world(GROUP_TUT_FINE_AIM) 
  4199. 	release_to_world(GROUP_TUT_T_IN_ROAD) 
  4200. 	release_to_world(GROUP_COURTYARD) 
  4201. 	release_to_world(GROUP_COURTYARD_COOP) 
  4202. 	release_to_world(GROUP_SHORTBUS) 
  4203. 	release_to_world(GROUP_RUN_GUN) 
  4204. 	release_to_world(GROUP_RANDOM) 
  4205. 	release_to_world(GROUP_RANDOM_COOP) 
  4206. 	release_to_world(GROUP_ROADBLOCK) 
  4207. 	release_to_world(GROUP_ROADBLOCK_COOP) 
  4208. 	release_to_world(GROUP_HELI_AMBUSH) 
  4209.  
  4210. 	-- Create the first wave 
  4211. 	group_create_hidden(GROUP_WAVE_1) 
  4212. 	group_create_hidden(GROUP_BOAT_1) 
  4213. 	group_create_hidden(GROUP_BOAT_2) 
  4214. 	group_create_hidden(GROUP_BOAT_3) 
  4215. 	group_create_hidden(GROUP_HELI_1) 
  4216.  
  4217. 	-- If Carlos is knocked out, wait for revival 
  4218. 	while (follower_is_unconscious(CHARACTER_CARLOS)) do 
  4219. 		thread_yield() 
  4220. 	end 
  4221.  
  4222. 	-- Play blocking audio line for Carlos 
  4223. 	if (get_dist(CHARACTER_CARLOS,Tss01_waypoints[12])  < 20) then 
  4224. 		tss01_audio_play_for_character("CARLOS_TSSP1_SEESBOAT", CHARACTER_CARLOS, "voice", false, false, true) 
  4225. 	end 
  4226.  
  4227. 	tss01_all_aboard() 
  4228. end 
  4229.  
  4230. function tss01_all_aboard() 
  4231.  
  4232. 	-- Disable player controls while we place them in the vehicles. 
  4233. 	player_controls_disable(LOCAL_PLAYER) 
  4234. 	if (IN_COOP) then 
  4235. 		player_controls_disable(REMOTE_PLAYER) 
  4236. 	end 
  4237.  
  4238. 	-- Stop any vehicles that the players are in 
  4239. 	local local_vehicle = get_char_vehicle_name(LOCAL_PLAYER) 
  4240. 	if (local_vehicle ~= "") then 
  4241. 		vehicle_stop(local_vehicle) 
  4242. 	end 
  4243. 	if (IN_COOP) then 
  4244. 		local remote_vehicle = get_char_vehicle_name(REMOTE_PLAYER) 
  4245. 		if (remote_vehicle ~= "") then 
  4246. 			vehicle_stop(remote_vehicle) 
  4247. 		end 
  4248. 	end 
  4249.  
  4250. 	-- Delay so the audio comes after the tutorial 
  4251. 	delay(1.0) 
  4252.  
  4253. 	--[[ 
  4254. 	-- If Carlos or the players are far enough away, then we'll have to teleport people 
  4255. 	-- to the dock area. 
  4256. 	local teleport_distance = 20 
  4257. 	local need_to_teleport =	(	(get_dist(CHARACTER_CARLOS,Tss01_waypoints[12])  > teleport_distance) 
  4258. 											or (get_dist_closest_player_to_object(Tss01_waypoints[12]) > teleport_distance) 
  4259. 										) 
  4260. 	]] 
  4261.  
  4262. 	-- We're experience problems when players are directly teleported into the boat after hitting the trigger 
  4263. 	-- at full speed in a cop car. I think that always doing the teleport will fix the problem. 
  4264. 	local need_to_teleport = true 
  4265.  
  4266. 	if(need_to_teleport) then 
  4267. 		fade_out(1) 
  4268. 		fade_out_block() 
  4269. 	end 
  4270.  
  4271. 	tss01_place_turret_boat_occupants(need_to_teleport) 
  4272.  
  4273. 	if(need_to_teleport) then 
  4274. 		fade_in(0.5) 
  4275. 		fade_in_block() 
  4276. 	end 
  4277.  
  4278. 	-- Reenable player controls now that they're in the boat. 
  4279. 	player_controls_enable(LOCAL_PLAYER) 
  4280. 	if (IN_COOP) then 
  4281. 		player_controls_enable(REMOTE_PLAYER) 
  4282. 	end 
  4283.  
  4284. 	tss01_goto_mainland() 
  4285. end 
  4286.  
  4287. function tss01_place_turret_boat_occupants(need_to_teleport) 
  4288.  
  4289. 	-- Okay, now that the fade is complete the vehicle can be entered 
  4290. 	set_unjackable_flag(HIGH_SEAS_VEHICLE, false) 
  4291.  
  4292. 	-- But its radio doesn't work :( 
  4293. 	radio_block(HIGH_SEAS_VEHICLE) 
  4294.  
  4295. 	-- Make extra-special sure that the client knows they can't do shit 
  4296. 	delay(0.25) 
  4297.  
  4298. 	party_dismiss_all() 
  4299.  
  4300. 	character_evacuate_from_all_vehicles(CHARACTER_CARLOS) 
  4301. 	character_evacuate_from_all_vehicles(LOCAL_PLAYER) 
  4302. 	if (IN_COOP) then 
  4303. 		character_evacuate_from_all_vehicles(REMOTE_PLAYER) 
  4304. 	end 
  4305. 		 
  4306. 	if (need_to_teleport) then 
  4307.  
  4308. 		teleport_coop(NAVP_BOAT_STAGING_LOCAL, NAVP_BOAT_STAGING_REMOTE, true) 
  4309. 		teleport(CHARACTER_CARLOS, NAVP_BOAT_STAGING_CARLOS) 
  4310. 		while(	(get_dist(LOCAL_PLAYER, NAVP_BOAT_STAGING_LOCAL) > 5) 
  4311. 					or (get_dist(CHARACTER_CARLOS, NAVP_BOAT_STAGING_CARLOS) > 5) 
  4312. 				) do 
  4313. 			thread_yield() 
  4314. 		end 
  4315. 	end 
  4316.  
  4317. 	vehicle_evacuate(HIGH_SEAS_VEHICLE) 
  4318.  
  4319. 	-- Put Carlos in the driver's seat 
  4320. 	tss01_setup_carlos_entry() 
  4321. 	-- Put the player(s) in the correct seats 
  4322. 	tss01_setup_players() 
  4323.  
  4324. 	while(not character_is_in_vehicle(LOCAL_PLAYER, HIGH_SEAS_VEHICLE) ) do 
  4325. 		thread_yield() 
  4326. 	end 
  4327. 	while(not character_is_in_vehicle(CHARACTER_CARLOS, HIGH_SEAS_VEHICLE) ) do 
  4328. 		thread_yield() 
  4329. 	end 
  4330.  
  4331. 	if (IN_COOP) then	 
  4332. 		while(not character_is_in_vehicle(REMOTE_PLAYER, HIGH_SEAS_VEHICLE) ) do 
  4333. 			vehicle_enter_teleport(REMOTE_PLAYER, HIGH_SEAS_VEHICLE, 5) 
  4334. 			delay(1.0) 
  4335. 		end 
  4336. 	end 
  4337.  
  4338. 	-- Put Carlos back in the player's party 
  4339. 	party_add(CHARACTER_CARLOS, LOCAL_PLAYER) 
  4340. 	follower_make_independent(CHARACTER_CARLOS, true) 
  4341.  
  4342. 	-- Don't let players recruit anyone else  
  4343. 	-- (Not sure if it would be possible to re-recruit followers left on the dock. Better safe than sorry.) 
  4344. 	party_set_recruitable(false) 
  4345.  
  4346. end 
  4347.  
  4348. function tss01_setup_carlos_entry() 
  4349.  
  4350. 	-- Make sure that the ambush thread is killed 
  4351. 	if(AMBUSH_THREAD_HANDLE ~= INVALID_THREAD_HANDLE) then 
  4352. 		thread_kill(AMBUSH_THREAD_HANDLE) 
  4353. 	end 
  4354. 	 
  4355. 	-- Remove the revive callback 
  4356. 	on_revived("", CHARACTER_CARLOS) 
  4357. 	-- Make Carlos go idle first so we don't switch from a state we are not suppose to 
  4358. 	npc_go_idle(CHARACTER_CARLOS) 
  4359.  
  4360. 	-- Don't let npcs exit until we say so 
  4361. 	vehicle_suppress_npc_exit(HIGH_SEAS_VEHICLE, true) 
  4362. 	-- Don't let the vehicle move until we say so 
  4363. 	vehicle_speed_override(HIGH_SEAS_VEHICLE, 0.05) 
  4364.  
  4365. 	-- Thread yield for a frame to allow the AI to change before entering a vehicle 
  4366. 	thread_yield() 
  4367.  
  4368. 	-- Teleport Carlos into the driver's seat 
  4369. 	vehicle_enter_teleport(CHARACTER_CARLOS, HIGH_SEAS_VEHICLE, 0) 
  4370. end 
  4371.  
  4372. function tss01_setup_players() 
  4373. 	 
  4374. 	-- Teleport the player(s) into the vehicle 
  4375. 	vehicle_enter_teleport(LOCAL_PLAYER, HIGH_SEAS_VEHICLE, 4)	 
  4376. 	if (IN_COOP) then 
  4377. 		vehicle_enter_teleport(REMOTE_PLAYER, HIGH_SEAS_VEHICLE, 5) 
  4378. 	end 
  4379.  
  4380. 	tss01_setup_boat_segment() 
  4381. end 
  4382.  
  4383. function tss01_setup_boat_segment() 
  4384. 	-- Do not let the player(s) exit... 
  4385. 	set_player_can_enter_exit_vehicles(LOCAL_PLAYER, false) 
  4386. 	if (IN_COOP) then 
  4387. 		set_player_can_enter_exit_vehicles(REMOTE_PLAYER, false) 
  4388. 	end 
  4389.  
  4390. 	-- Create a new thread to setup the boat ride sequence 
  4391. 	thread_new("tss01_yacht_attack_sequence") 
  4392.  
  4393. 	-- If the ambush heli was skipped it should now chase 
  4394. 	if (not vehicle_is_destroyed(HELI_AMBUSH_VEHICLE)) then 
  4395. 		vehicle_chase(HELI_AMBUSH_VEHICLE, LOCAL_PLAYER) 
  4396. 	end 
  4397.  
  4398. 	-- Give the player(s) an assault rifle 
  4399. 	inv_weapon_add_temporary(LOCAL_PLAYER, "AR200_ss03", 1, true, true) 
  4400. 	if (IN_COOP) then 
  4401. 		inv_weapon_add_temporary(REMOTE_PLAYER, "AR200_ss03", 1, true, true) 
  4402. 	end 
  4403. 	TEMP_WEAPONS_GIVEN = true 
  4404.  
  4405. 	-- Only allow the rifle slot 
  4406. 	inv_weapon_disable_all_but_this_slot(WEAPON_SLOT_RIFLE) 
  4407.  
  4408. 	-- Make sure that the weapons is equipped and the characters are combat ready 
  4409. 	thread_new("tss01_keep_ar200_equipped") 
  4410.  
  4411. 	-- Reset the time of day scale factor 
  4412. 	set_time_of_day_scale() 
  4413.  
  4414. end 
  4415.  
  4416. function tss01_keep_ar200_equipped() 
  4417.  
  4418. 	local function update_player(player) 
  4419. 		if (not inv_item_is_equipped("AR200_ss03", player)) and character_is_in_vehicle(player, HIGH_SEAS_VEHICLE) then 
  4420. 			inv_item_equip("AR200_ss03", player) 
  4421. 		end 
  4422. 		character_set_combat_ready(player, true, 1.0) 
  4423. 	end 
  4424.  
  4425. 	while(1) do 
  4426. 		update_player(LOCAL_PLAYER) 
  4427. 		if (IN_COOP) then 
  4428. 			update_player(REMOTE_PLAYER) 
  4429. 		end 
  4430. 		delay(0.25) 
  4431. 	end 
  4432. end 
  4433.  
  4434.  
  4435. Tss01_carlos_attack_line_enabled = false 
  4436. Tss01_carlos_damage_line_enabled = false 
  4437. function tss01_play_carlos_boat_lines() 
  4438.  
  4439. 	npc_suppress_persona(CHARACTER_CARLOS, true) 
  4440.  
  4441. 	local attack_line_delay = 0 
  4442. 	local damage_line_delay = 0 
  4443.  
  4444. 	-- Don't play any lines for a bit 
  4445. 	delay(10) 
  4446. 	Tss01_carlos_attack_line_enabled = false 
  4447. 	Tss01_carlos_damage_line_enabled = false 
  4448.  
  4449. 	local function can_play_attack_line() 
  4450. 		return (Tss01_carlos_attack_line_enabled and (attack_line_delay == 0)) 
  4451. 	end 
  4452.  
  4453. 	local function can_play_damage_line() 
  4454. 		return (Tss01_carlos_damage_line_enabled and (damage_line_delay == 0)) 
  4455. 	end 
  4456.  
  4457. 	while(true) do 
  4458.  
  4459. 		-- Wait until we can play a line. Favor attack lines, they're only triggered when a boat or 
  4460. 		-- heli is destroyed and are therefore more time critical 
  4461. 		while( (can_play_attack_line() == false) and (can_play_damage_line() == false) ) do 
  4462.  
  4463. 			-- Update delays 
  4464. 			if(attack_line_delay > 0) then 
  4465. 				attack_line_delay = attack_line_delay - 1 
  4466. 			end 
  4467. 			if(damage_line_delay > 0) then 
  4468. 				damage_line_delay = damage_line_delay - 1 
  4469. 			end 
  4470.  
  4471. 			-- Reset line playability. We only want to play lines that have been triggered since the 
  4472. 			-- last check 
  4473. 			Tss01_carlos_attack_line_enabled = false 
  4474. 			Tss01_carlos_damage_line_enabled = false 
  4475.  
  4476. 			-- Wait a second before checking again 
  4477. 			delay(1) 
  4478.  
  4479. 		end 
  4480. 	 
  4481. 		if (can_play_attack_line()) then 
  4482. 			tss01_audio_play_for_character("CARLOS_TSSP1_ATKBOAT", CHARACTER_CARLOS, "voice", false, true) 
  4483. 			delay(2.0) 
  4484. 			attack_line_delay = CARLOS_BOAT_ATTACK_LINE_DELAY_MIN_S 
  4485. 		elseif (Tss01_carlos_damage_line_enabled) then 
  4486. 			tss01_audio_play_for_character("CARLOS_TSSP1_DAMBOAT", CHARACTER_CARLOS, "voice", false, true) 
  4487. 			delay(2.0) 
  4488. 			damage_line_delay = rand_int(CARLOS_BOAT_DAMAGE_LINE_DELAY_MIN_S, CARLOS_BOAT_DAMAGE_LINE_DELAY_MAX_S) 
  4489. 		end 
  4490.  
  4491. 	end 
  4492.  
  4493. end 
  4494.  
  4495. function tss01_enable_carlos_attack_line() 
  4496. 	Tss01_carlos_attack_line_enabled = true 
  4497. end 
  4498.  
  4499. function tss01_enable_carlos_damage_line() 
  4500. 	Tss01_carlos_damage_line_enabled = true 
  4501. end 
  4502.  
  4503. function tss01_setup_boat_segment_from_checkpoint() 
  4504.  
  4505. 	-- Set the notoriety for the rest of the mission...this is for the restart at checkpoint 
  4506. 	notoriety_set_max("police", 1) 
  4507. 	notoriety_set_min("police", 1) 
  4508.  
  4509. 	--tss01_setup_boat_segment() 
  4510.  
  4511. 	-- Go to the mainland 
  4512. 	tss01_goto_mainland() 
  4513. end 
  4514.  
  4515. function tss01_goto_mainland() 
  4516.  
  4517. 	Tss01_boat_sequence_begun = true 
  4518.  
  4519. 	-- Make Carlos invulnerable... players can't revive him 
  4520. 	if (character_exists(CHARACTER_CARLOS) and (not character_is_dead(CHARACTER_CARLOS))) then 
  4521. 		turn_invulnerable(CHARACTER_CARLOS, false) 
  4522. 	end 
  4523. 	-- Spawn off a thread to play the line and deliver the help text (And make the boat not be invulnerable) 
  4524. 	thread_new("tss01_defend_boat") 
  4525. 	-- Start the boat sequence bullhorn audio 
  4526. 	thread_new("tss01_boat_chase_bullhorn_audio") 
  4527. 	-- Cancel the speed override and allow Carlos to drive off 
  4528. 	vehicle_speed_cancel(HIGH_SEAS_VEHICLE) 
  4529. 	-- Pathfind to the end! 
  4530. 	vehicle_pathfind_to(HIGH_SEAS_VEHICLE, "tss01_$path000", true, false) 
  4531. end 
  4532.  
  4533. function tss01_defend_boat() 
  4534. 	-- Play audio line for Carlos 
  4535. 	tss01_audio_play_for_character("CARLOS_TSSP1_ON_BOAT_01", CHARACTER_CARLOS, "voice", false, true) 
  4536. 	-- Prompt the user with help text... 
  4537. 	mission_help_table("tss01_boat") 
  4538. 	-- Show the damage bar of the vehicle... 
  4539. 	damage_indicator_on(0, HIGH_SEAS_VEHICLE, 0.0, "tss01_boat_health", get_max_hit_points(HIGH_SEAS_VEHICLE), SYNC_ALL) 
  4540. 	-- Create a thread to play Carlos's persona lines 
  4541. 	thread_new("tss01_play_carlos_boat_lines") 
  4542. 	-- Wait a little bit, then make the vehicle invulnerable. 
  4543. 	while(get_dist(Tss01_waypoints[12], HIGH_SEAS_VEHICLE) < 50) do 
  4544. 		thread_yield() 
  4545. 	end 
  4546. 	turn_vulnerable(HIGH_SEAS_VEHICLE) 
  4547. end 
  4548.  
  4549. function tss01_yacht_attack_sequence() 
  4550. 	-- Setup the triggers for the attack sequence 
  4551. 	trigger_enable(YACHT_TRIGGER_2, true) 
  4552. 	trigger_enable(YACHT_TRIGGER_3, true) 
  4553.  
  4554. 	-- Delay a short period of time 
  4555. 	delay(3) 
  4556.  
  4557. 	-- Show the first wave and execute 
  4558. 	tss01_attack_yacht_first_wave() 
  4559. 	 
  4560. 	-- Setup the second wave and mission complete triggers 
  4561. 	on_trigger("tss01_attack_yacht_second_wave", YACHT_TRIGGER_2) 
  4562. 	on_trigger("tss01_completed", YACHT_TRIGGER_3) 
  4563.  
  4564. 	-- Create the second wave 
  4565. 	group_create_hidden(GROUP_WAVE_2) 
  4566. 	group_create_hidden(GROUP_BOAT_4) 
  4567. 	group_create_hidden(GROUP_BOAT_5) 
  4568. 	group_create_hidden(GROUP_HELI_2) 
  4569. 	group_create_hidden(GROUP_HELI_3) 
  4570.  
  4571. 	-- Put the humans in the vehicles 
  4572. 	vehicle_enter_group_teleport(Tss01_boat4_table, GROUP_BOAT_4) 
  4573. 	vehicle_enter_group_teleport(Tss01_boat5_table, GROUP_BOAT_5) 
  4574. 	vehicle_enter_group_teleport(Tss01_heli2_table, GROUP_HELI_2) 
  4575. 	vehicle_enter_group_teleport(Tss01_heli3_table, GROUP_HELI_3) 
  4576.  
  4577. 	for i = 1, Num_tss01_boat4_table, 1 do 
  4578. 		inv_item_add("m16", 1, Tss01_boat4_table[i]) 
  4579. 		npc_unholster_best_weapon(Tss01_boat4_table[i]) 
  4580. 		npc_weapon_spread(Tss01_boat4_table[i], 2.0) 
  4581. 	end 
  4582.  
  4583. 	for i = 1, Num_tss01_boat5_table, 1 do 
  4584. 		inv_item_add("m16", 1, Tss01_boat5_table[i]) 
  4585. 		npc_unholster_best_weapon(Tss01_boat5_table[i]) 
  4586. 		npc_weapon_spread(Tss01_boat5_table[i], 2.0) 
  4587. 	end 
  4588.  
  4589. 	for i = 1, Num_tss01_heli2_table, 1 do 
  4590. 		inv_item_add("m16", 1, Tss01_heli2_table[i]) 
  4591. 		npc_unholster_best_weapon(Tss01_heli2_table[i]) 
  4592. 		npc_weapon_spread(Tss01_heli2_table[i], 1.5) 
  4593. 	end 
  4594.  
  4595. 	for i = 1, Num_tss01_heli3_table, 1 do 
  4596. 		inv_item_add("m16", 1, Tss01_heli3_table[i]) 
  4597. 		npc_unholster_best_weapon(Tss01_heli3_table[i]) 
  4598. 		npc_weapon_spread(Tss01_heli3_table[i], 1.5) 
  4599. 	end 
  4600. end 
  4601.  
  4602. function tss01_attack_yacht_first_wave() 
  4603. 	-- Put the humans in the vehicles 
  4604. 	vehicle_enter_group_teleport(Tss01_boat1_table, GROUP_BOAT_1) 
  4605. 	vehicle_enter_group_teleport(Tss01_boat2_table, GROUP_BOAT_2) 
  4606. 	vehicle_enter_group_teleport(Tss01_boat3_table, GROUP_BOAT_3) 
  4607. 	vehicle_enter_group_teleport(Tss01_heli1_table, GROUP_HELI_1) 
  4608.  
  4609. 	for i = 1, Num_tss01_boat1_table, 1 do 
  4610. 		inv_item_add("m16", 1, Tss01_boat1_table[i]) 
  4611. 		npc_unholster_best_weapon(Tss01_boat1_table[i]) 
  4612. 		npc_weapon_spread(Tss01_boat1_table[i], 2.0) 
  4613. 	end 
  4614.  
  4615. 	for i = 1, Num_tss01_boat2_table, 1 do 
  4616. 		inv_item_add("m16", 1, Tss01_boat2_table[i]) 
  4617. 		npc_unholster_best_weapon(Tss01_boat2_table[i]) 
  4618. 		npc_weapon_spread(Tss01_boat2_table[i], 2.0) 
  4619. 	end 
  4620.  
  4621. 	for i = 1, Num_tss01_boat3_table, 1 do 
  4622. 		inv_item_add("m16", 1, Tss01_boat3_table[i]) 
  4623. 		npc_unholster_best_weapon(Tss01_boat3_table[i]) 
  4624. 		npc_weapon_spread(Tss01_boat3_table[i], 2.0) 
  4625. 	end 
  4626.  
  4627. 	for i = 1, Num_tss01_heli1_table, 1 do 
  4628. 		inv_item_add("m16", 1, Tss01_heli1_table[i]) 
  4629. 		npc_unholster_best_weapon(Tss01_heli1_table[i]) 
  4630. 		npc_weapon_spread(Tss01_heli1_table[i], 1.5) 
  4631. 	end 
  4632.  
  4633. 	-- Show the vehicles 
  4634. 	group_show(GROUP_WAVE_1) 
  4635. 	group_show(GROUP_BOAT_1) 
  4636. 	group_show(GROUP_BOAT_2) 
  4637. 	group_show(GROUP_BOAT_3) 
  4638. 	group_show(GROUP_HELI_1) 
  4639.  
  4640. 	-- Set the helicopter to use the new ai navigation. 
  4641. 	helicopter_set_dont_use_constraints(GROUP_HELI_1, true)  
  4642.  
  4643. 	-- Turn the lights on 
  4644. 	vehicle_lights_on(GROUP_BOAT_1, true) 
  4645. 	vehicle_lights_on(GROUP_BOAT_2, true) 
  4646. 	vehicle_lights_on(GROUP_BOAT_3, true) 
  4647. 	vehicle_lights_on(GROUP_HELI_1, true) 
  4648. 	vehicle_set_sirens(GROUP_BOAT_1, true) 
  4649. 	vehicle_set_sirens(GROUP_BOAT_2, true) 
  4650. 	vehicle_set_sirens(GROUP_BOAT_3, true) 
  4651. 	vehicle_set_sirens(GROUP_HELI_1, true) 
  4652.  
  4653. 	-- Make first wave attack 
  4654. 	vehicle_chase(GROUP_BOAT_1, LOCAL_PLAYER, false, false, true) 
  4655. 	vehicle_chase(GROUP_BOAT_2, LOCAL_PLAYER, false, false, true) 
  4656. 	vehicle_chase(GROUP_BOAT_3, LOCAL_PLAYER, false, false, true) 
  4657. 	vehicle_chase(GROUP_HELI_1, LOCAL_PLAYER) 
  4658.  
  4659. 	-- Lower the hitpoints to about half 
  4660. 	set_max_hit_points(GROUP_BOAT_1, get_max_hit_points(GROUP_BOAT_1) * 0.5, true) 
  4661. 	set_max_hit_points(GROUP_BOAT_2, get_max_hit_points(GROUP_BOAT_2) * 0.5, true) 
  4662. 	set_max_hit_points(GROUP_BOAT_3, get_max_hit_points(GROUP_BOAT_3) * 0.5, true) 
  4663. 	set_max_hit_points(GROUP_HELI_1, get_max_hit_points(GROUP_HELI_1) * 0.5, true) 
  4664.  
  4665. 	-- Allow Carlos to blay an attack line when a boat or heli is destroyed 
  4666. 	on_vehicle_destroyed("tss01_enable_carlos_attack_line", GROUP_BOAT_1) 
  4667. 	on_vehicle_destroyed("tss01_enable_carlos_attack_line", GROUP_BOAT_2) 
  4668. 	on_vehicle_destroyed("tss01_enable_carlos_attack_line", GROUP_BOAT_3) 
  4669. 	on_vehicle_destroyed("tss01_enable_carlos_attack_line", GROUP_HELI_1) 
  4670. end 
  4671.  
  4672. function tss01_attack_yacht_second_wave(human, trigger) 
  4673. 	trigger_enable(trigger, false) 
  4674.  
  4675. 	-- Show the vehicles 
  4676. 	group_show(GROUP_WAVE_2) 
  4677. 	group_show(GROUP_BOAT_4) 
  4678. 	group_show(GROUP_BOAT_5) 
  4679. 	group_show(GROUP_HELI_2) 
  4680. 	group_show(GROUP_HELI_3) 
  4681. 	 
  4682. 	-- Set the helicopter to use the new ai navigation. 
  4683. 	helicopter_set_dont_use_constraints(GROUP_HELI_2, true)  
  4684. 	helicopter_set_dont_use_constraints(GROUP_HELI_3, true)  
  4685.  
  4686. 	-- Turn the lights on 
  4687. 	vehicle_lights_on(GROUP_BOAT_4, true) 
  4688. 	vehicle_lights_on(GROUP_BOAT_5, true) 
  4689. 	vehicle_lights_on(GROUP_HELI_2, true) 
  4690. 	vehicle_lights_on(GROUP_HELI_3, true) 
  4691. 	vehicle_set_sirens(GROUP_BOAT_4, true) 
  4692. 	vehicle_set_sirens(GROUP_BOAT_5, true) 
  4693. 	vehicle_set_sirens(GROUP_HELI_2, true) 
  4694. 	vehicle_set_sirens(GROUP_HELI_3, true) 
  4695.  
  4696. 	-- Make second wave attack 
  4697. 	vehicle_chase(GROUP_BOAT_4, LOCAL_PLAYER, false, false, true) 
  4698. 	vehicle_chase(GROUP_BOAT_5, LOCAL_PLAYER, false, false, true) 
  4699. 	vehicle_chase(GROUP_HELI_2, LOCAL_PLAYER) 
  4700. 	vehicle_chase(GROUP_HELI_3, LOCAL_PLAYER) 
  4701.  
  4702. 	-- Lower the hitpoints to about half 
  4703. 	set_max_hit_points(GROUP_BOAT_4, get_max_hit_points(GROUP_BOAT_4) * 0.5, true) 
  4704. 	set_max_hit_points(GROUP_BOAT_5, get_max_hit_points(GROUP_BOAT_5) * 0.5, true) 
  4705. 	set_max_hit_points(GROUP_HELI_2, get_max_hit_points(GROUP_HELI_2) * 0.5, true) 
  4706. 	set_max_hit_points(GROUP_HELI_3, get_max_hit_points(GROUP_HELI_3) * 0.5, true) 
  4707.  
  4708. 	-- Allow Carlos to blay an attack line when a boat or heli is destroyed 
  4709. 	on_vehicle_destroyed("tss01_enable_carlos_attack_line", GROUP_BOAT_4) 
  4710. 	on_vehicle_destroyed("tss01_enable_carlos_attack_line", GROUP_BOAT_5) 
  4711. 	on_vehicle_destroyed("tss01_enable_carlos_attack_line", GROUP_HELI_2) 
  4712. 	on_vehicle_destroyed("tss01_enable_carlos_attack_line", GROUP_HELI_3) 
  4713. end 
  4714.  
  4715. function tss01_completed(human, trigger) 
  4716. 	trigger_enable(trigger, false) 
  4717.  
  4718. 	-- Retreat the first and second waves... 
  4719. 	if (vehicle_exists(GROUP_BOAT_1)) then 
  4720. 		vehicle_flee(GROUP_BOAT_1) 
  4721. 	end 
  4722. 	 
  4723. 	if (vehicle_exists(GROUP_BOAT_2)) then 
  4724. 		vehicle_flee(GROUP_BOAT_2) 
  4725. 	end 
  4726. 	 
  4727. 	if (vehicle_exists(GROUP_BOAT_3)) then 
  4728. 		vehicle_flee(GROUP_BOAT_3) 
  4729. 	end 
  4730. 	 
  4731. 	if (vehicle_exists(GROUP_BOAT_4)) then 
  4732. 		vehicle_flee(GROUP_BOAT_4) 
  4733. 	end 
  4734. 	 
  4735. 	if (vehicle_exists(GROUP_BOAT_5)) then 
  4736. 		vehicle_flee(GROUP_BOAT_5) 
  4737. 	end 
  4738. 	 
  4739. --	if (vehicle_exists(GROUP_HELI_1)) then 
  4740. --		vehicle_flee(GROUP_HELI_1) 
  4741. --	end 
  4742. 	 
  4743. --	if (vehicle_exists(GROUP_HELI_2)) then 
  4744. --		vehicle_flee(GROUP_HELI_2) 
  4745. --	end 
  4746. 	 
  4747. --	if (vehicle_exists(GROUP_HELI_3)) then 
  4748. --		vehicle_flee(GROUP_HELI_3) 
  4749. --	end 
  4750.  
  4751. 	-- Wait 3 seconds in addition to the default 2 seconds 
  4752. 	delay(3.0) 
  4753. 	-- Success! 
  4754. 	mission_end_success("tss01","TSSP01-02", {LOCAL_PLAYER_FINISH, REMOTE_PLAYER_FINISH}) 
  4755. end 
  4756.  
  4757. function tss01_spawn_coop_groups() 
  4758. 	return (IN_COOP and (not COOP_SPAWNS_DISABLED)) 
  4759. end 
  4760.  
  4761. function tss01_get_weapon_spread(value) 
  4762. 	if (IN_COOP) then 
  4763. 		return (1 + 0.5*(value - 1)) 
  4764. 	else 
  4765. 		return value 
  4766. 	end 
  4767. end 
  4768.  
  4769. function tss01_update_hit_points(npc_list) 
  4770. 	if (IN_COOP) then 
  4771. 		for i,npc in pairs(npc_list) do 
  4772. 			local max_hit_points = get_max_hit_points(npc) 
  4773. 			set_max_hit_points(npc, max_hit_points * COOP_NPC_HP_MULTIPLIER) 
  4774. 		end 
  4775. 	else 
  4776. 		return 
  4777. 	end 
  4778. end 
  4779.  
  4780. Tss01_mission_dialogue_playing = false 
  4781.  
  4782. function tss01_audio_play_for_character(tag, character, audio_type, for_cutscene, blocking, ignore_pause) 
  4783.  
  4784. 	if (not Tss01_mission_dialogue_playing) then 
  4785.  
  4786. 		Tss01_mission_dialogue_playing = true 
  4787. 		audio_play_for_character(tag, character, audio_type, for_cutscene, blocking, nil, nil, nil, ignore_pause) 
  4788. 		Tss01_mission_dialogue_playing = false 
  4789.  
  4790. 	end 
  4791.  
  4792. end 
  4793.  
  4794. function tss01_audio_play_conversation(conversation) 
  4795.  
  4796. 	if (not Tss01_mission_dialogue_playing) then 
  4797. 		Tss01_mission_dialogue_playing = true 
  4798. 		audio_play_conversation(conversation) 
  4799. 		Tss01_mission_dialogue_playing = false 
  4800. 	end 
  4801.  
  4802. end