sr2lua/ss10.lua

  1. -- ss10.lua 
  2. -- SR2 mission script 
  3. -- 3/28/07 
  4.  
  5. -- Mission help table text tags 
  6. 	CATCH_UP_TO_VAN = "ss10_catch_up" 
  7. 	CHECK_IN_AT_DESK = "ss10_check_in" 
  8. 	DEFEND_ROOM = "ss10_defend_room" 
  9. 	ESCORT_SHAUNDI = "ss10_escort_shaundi" 
  10. 	SHAUNDI_ABANDONED = "ss10_shaundi_abandoned" 
  11. 	ABANDONING_SHAUNDI = "ss10_abandoning_shaundi" 
  12. 	SHAUNDI_DIED = "ss10_shaundi_died" 
  13. 	FIND_REPAIRMEN = "ss10_find_repairmen" 
  14. 	GET_EQUIPMENT_BACK = "ss10_get_equipment_back" 
  15. 	GET_IN_VAN = "ss10_get_in_van" 
  16. 	GET_TO_CAMERA_ROOM = "ss10_get_to_camera_room" 
  17. 	ENTER_THE_STATION = "ss10_enter_the_station" 
  18. 	PARK_VAN_AT_STATION = "ss10_park_van_at_station" 
  19. 	HIJACK_VAN = "ss10_hijack_van" 
  20. 	DONT_SHOW_WEAPONS = "ss10_dont_show_weapons" 
  21. 	TALK_TO_CLERK = "ss10_talk_to_clerk" 
  22. 	FLOOR_INDEX = "ss10_floor_index" 
  23. 	VAN_ESCAPED = "ss10_van_escaped" 
  24. 	VAN_DESTROYED = "ss10_van_destroyed" 
  25. 	VAN_LOST = "ss10_van_lost" 
  26. 	VAN_REQUIRED = "ss10_van_required" 
  27. 	HEAD_TO_CAMERA_ROOM = "ss10_head_to_camera_room" 
  28. 	MISSION_DISPLAY_NAME = "ss10_display_name" 
  29. 	VAN_DAMAGE_BAR_LABEL = "ss10_van_damage" 
  30. 	RUSE_BLOWN = "ss10_ruse_blown" 
  31. 	GET_TO_TERMINAL = "ss10_get_to_terminal" 
  32.  
  33. -- Mission states 
  34. 	MS_INITIAL = 1 
  35. 	MS_FIND_REPAIRMEN = 2 
  36. 	MS_HIJACK_REPAIR_VAN = 3 
  37. 	MS_REPAIRMEN_ESCAPING = 4 
  38. 	MS_REACHED_REPAIRMEN_AGAIN = 5 
  39. 	MS_VAN_DISABLED = 6 
  40. 	MS_PARK_VAN_AT_STATION = 7 
  41. 	MS_PARKED_VAN_AT_STATION = 8 
  42. 	MS_ENTERED_POLICE_STATION = 9 
  43. 	MS_GO_TO_CAMERA_ROOM = 10 
  44. 	MS_RUN_TO_CAMERA_ROOM = 11 
  45. 	MS_DEFEND_CAMERA_ROOM = 12 
  46. 	MS_LEAVE_STATION = 13 
  47. 	MS_RETURN_TO_BASE = 14 
  48.  
  49. -- Groups, NPCs, vehicles, navpoints, and other names 
  50. 	MISSION_NAME = "ss10" 
  51. 	MP = MISSION_NAME.."_$" 
  52.  
  53. 	-- Checkpoints 
  54. 	CP_PARKED_VAN_AT_STATION = "Parked_at_Station_Checkpoint" 
  55.  
  56. 	CAMERA_EQUIPMENT_GROUP = MP.."Camera_Equipment" 
  57.  
  58. 	SHAUNDI_GROUP_NAME = MP.."Shaundi" 
  59. 	SHAUNDI_NAME = MP.."Shaundi" 
  60. 	SHAUNDI_REPAIR_VARIANT_GROUP_NAME = MP.."Shaundi_Repair_Outfit" 
  61. 	SHAUNDI_REPAIR_VARIANT_NAME = MP.."Shaundi_Repair_Outfit" 
  62. 	STARTER_VEHICLE_GROUP_NAME = MP.."Starter_Vehicle" 
  63. 	STARTER_VEHICLE_COOP_GROUP_NAME = MP.."Starter_Vehicle_Coop" 
  64. 	HACKING_LOCATION_NAME = MP.."Hacking_Location" 
  65. 	REPAIR_VAN_AND_REPAIRMEN_GROUP_NAME = MP.."Repair_Group" 
  66. 	REPAIR_VAN_NAME = MP.."Repair_Van" 
  67. 	REPAIR_MAN_NAME = MP.."Repairman_01" 
  68. 	REPAIR_VAN_INITIAL_NAVPOINTS = { MP.."Initial_01", MP.."Initial_02" } 
  69. 	REPAIR_VAN_PATHS  = { MP.."Repair_Van_Path_01" }--[[, MP.."Repair_Van_Path_02", MP.."Repair_Van_Path_03" }]] 
  70. 								--[[{ MP.."Path_01", MP.."Path_02", MP.."Path_03", MP.."Path_04", 
  71. 									MP.."Path_05", MP.."Path_06", MP.."Path_07", MP.."Path_08", 
  72. 									MP.."Path_09", MP.."Path_10", MP.."Path_11", MP.."Path_12", 
  73. 									MP.."Path_13", MP.."Path_14", MP.."Path_15", MP.."Path_16" }, 
  74. 								 { MP.."Path_17", MP.."Path_18", MP.."Path_19", MP.."Path_20", 
  75. 									MP.."Path_21", MP.."Path_22", MP.."Path_23", MP.."Path_24", 
  76. 									MP.."Path_25", MP.."Path_26", MP.."Path_27", MP.."Path_28", 
  77. 									MP.."Path_29" } }]] 
  78.  
  79. 	REPAIR_VAN_AREA_TRIGGER = MP.."Repair_Van_Area" 
  80. 	REPAIR_OUTFIT_NAME = "repair" 
  81.  
  82. 	CHECK_IN_VIEW_NAVPOINT_NAME = MP.."Check_In_View" 
  83.  
  84. 	POLICE_STATION_HELICOPTER = MP.."Police_Station_Heli" 
  85.  
  86. 	POLICE_STATION_POSITION_NAVPOINT_NAME = MP.."Police_Station_Position" 
  87. 	POLICE_STATION_TRIGGER_NAME = MP.."Police_Station_Trigger" 
  88. 	--RECEPTIONIST_CHAIR_NAME = MP.."Receptionist_Chair" 
  89. 	RECEPTIONIST_GROUP_NAME = MP.."Receptionist" 
  90. 	RECEPTIONIST_NAME = RECEPTIONIST_GROUP_NAME 
  91. 	RECEPTIONIST_DESK_CHECKIN_TRIGGER_NAME = MP.."Receptionist_Desk_Checkin" 
  92. 	RECEPTIONIST_DESK_CHECKIN_TRIGGER_POSITION = MP.."Checkin_Trigger_Position" 
  93. 	RECEPTIONIST_DESK_SIGN_IN_POSITION = MP.."Receptionist_Desk_Sign_In_Position" 
  94. 	PAST_DESK_TRIGGER_NAME = MP.."Past_Desk" 
  95. 	MAIN_STATION_ENTRANCE_TRIGGERS = { MP.."Main_Station_Entrance_01", MP.."Main_Station_Entrance_02", 
  96. 												  MP.."Main_Station_Entrance_03", MP.."Main_Station_Entrance_04" } 
  97.  
  98. 	PAST_LOBBY_TRIGGERS = { MAIN_STATION_ENTRANCE_TRIGGERS[1], MAIN_STATION_ENTRANCE_TRIGGERS[2] } 
  99.  
  100. 	STATION_EXIT_TRIGGER_NAMES = { MP.."Station_Exit_01", 
  101. 											 MP.."Off_The_Balcony01", MP.."Off_The_Balcony02", 
  102. 											 MP.."Off_The_Balcony03", MP.."Off_The_Balcony04" } 
  103.  
  104. 	CAMERA_ROOM_DOOR_TRIGGER = MP.."Camera_Room_Door" 
  105.  
  106.  
  107. 	SAINTS_PARKING_LOT_TRIGGER_NAME = MP.."Saints_Hideout_Lot" 
  108.  
  109. 	GROUND_HQ_TRIGGER_INDEX = 1 
  110. 	AIR_HQ_TRIGGER_INDEX = 2 
  111.  
  112. 	SAINTS_HQ_TRIGGER_NAMES = { [GROUND_HQ_TRIGGER_INDEX] = MP.."Saints_HQ_Trigger", 
  113. 										 [AIR_HQ_TRIGGER_INDEX] = MP.."Saints_HQ_Trigger_02" } 
  114.  
  115. 	START_NAVPOINT_NAME = "mission_start_sr2_city_$ss10" 
  116. 	START_NAVPOINT_NAME_COOP_PLAYER = MP.."Coop_Player_Start" 
  117. 	MISSION_NAME = "ss10" 
  118. 	POLICE_GANG = "police" 
  119. 	ULTOR_GANG = "ultor" 
  120. 	CHECK_IN_ANIMATION_NAME = "sign in" 
  121. 	ALARM_ORIGIN = MP.."Alarm_Origin" 
  122.  
  123. 	STAIRWAY_GUIDE_NAVPOINT_NAME = MP.."Stairway_Guide" 
  124. 	STAIRWAY_TRIGGER_NAMES = { MP.."Stairway_Trigger_01", MP.."Stairway_Trigger_02" } 
  125.  
  126. 	FOURTH_FLOOR_LOCATION_NAVPOINT_NAME = MP.."Fourth_Floor_Location" 
  127.  
  128. 	HELI_SQUAD_GROUP_NAME = MP.."Heli_Squad" 
  129.  
  130. 	SWAT_HELI_DROPOFF_GROUP_NAME = MP.."Swat_Dropoff" 
  131.  
  132. 	POLICE_PISTOL_NAME = "beretta" 
  133. 	POLICE_PISTOL_AMMO_COUNT = 24 
  134. 	POLICE_SHOTGUN_NAME = "pump_action_shotgun" 
  135. 	POLICE_SHOTGUN_AMMO_COUNT = 9 
  136.  
  137. 	PACKAGE_NAME = MP.."Computer_Camera" 
  138. 	STATE_HACK_CAMERA_ROOM = "Stand Hacking" 
  139.  
  140. 	END_LOCAL_WARP = MP.."End_Local_Warp" 
  141. 	END_REMOTE_WARP = MP.."End_Remote_Warp" 
  142.  
  143. -- Specifically spawned police attackers 
  144. 	-- Per-location. Number of entries is number of locations. 
  145. 	-- Number of entries must be the same for coop and normal 
  146. 	-- attackers. 
  147. 	NUM_WAVE_ATTACKERS = { 6, 7 } 
  148. 	NUM_COOP_WAVE_ATTACKERS = { 3, 3 } 
  149.  
  150. 	WAVE_SHOTGUN_DISTRIBUTIONS = { 0, .25, .75, 1.0 } 
  151. 	function WAVE_SHOTGUN_DISTRIBUTION( wave_index ) 
  152. 		local count = sizeof_table( WAVE_SHOTGUN_DISTRIBUTIONS ) 
  153. 		if ( wave_index <= count ) then 
  154. 			return WAVE_SHOTGUN_DISTRIBUTIONS[wave_index] 
  155. 		else 
  156. 			return WAVE_SHOTGUN_DISTRIBUTIONS[count] 
  157. 		end 
  158. 	end 
  159.  
  160. 	-- Attacker name is WAVE_ATTACKER_NAME_LOCATION_PREFIX..location_index..WAVE_ATTACKER_NAME_INDEX_PREFIX..attacker_index 
  161. 	-- Example: MP.."Location3_Attacker_02" would be the second member of the third wave. 
  162. 	-- For coop, use WAVE_ATTACKER_COOP_NAME_INDEX_PREFIX instead of WAVE_ATTACKER_NAME_INDEX_PREFIX. 
  163. 	WAVE_ATTACKER_NAME_LOCATION_PREFIX = MP.."Location" 
  164. 	WAVE_ATTACKER_COOP_NAME_INDEX_PREFIX = "c_Attacker_0" 
  165. 	WAVE_ATTACKER_NAME_INDEX_PREFIX = "_Attacker_0" 
  166.  
  167. 	-- WAVE_LOCATION_NAME_PREFIX..location_index..WAVE_LOCATION_NAME_SUFFIX 
  168. 	-- For coop, WAVE_LOCATION_NAME_COOP_SUFFIX comes after location_index instead of 
  169. 	-- WAVE_LOCATION_NAME_SUFFIX. 
  170. 	WAVE_LOCATION_NAME_PREFIX = MP.."Location" 
  171. 	WAVE_LOCATION_NAME_COOP_SUFFIX = "c_Attackers" 
  172. 	WAVE_LOCATION_NAME_SUFFIX = "_Attackers" 
  173.  
  174. 	FLOOR_AMBIENT_NPC_GROUP_NAME = MP.."Station_Ambient_NPCs" 
  175.  
  176. 	FLOOR_GROUP_NAMES = { MP.."Floor1_Officers", MP.."Floor2_Officers", 
  177. 								 MP.."Floor3_Officers", MP.."Floor4_Officers", 
  178. 								 MP.."Floor5_Officers" } 
  179.  
  180. 	FLOOR1_OFFICER_NAMES = { MP.."F1_Officer01", MP.."F1_Officer02", 
  181. 									 MP.."F1_Officer03", MP.."F1_Officer04", 
  182. 									 MP.."F1_Officer05" } 
  183.  
  184. 	FLOOR2_OFFICER_NAMES = { MP.."F2_Officer01", MP.."F2_Officer02", 
  185. 									 MP.."F2_Officer03", MP.."F2_Officer04" } 
  186.  
  187. 	FLOOR3_OFFICER_NAMES = { MP.."F3_Officer01", MP.."F3_Officer02", 
  188. 									 MP.."F3_Officer03", MP.."F3_Officer04", 
  189. 									 MP.."F3_Officer05" } 
  190.  
  191. 	FLOOR4_OFFICER_NAMES = { MP.."F4_Officer01", MP.."F4_Officer02", 
  192. 									 MP.."F4_Officer03", MP.."F4_Officer04" } 
  193.  
  194. 	FLOOR5_OFFICER_NAMES = { MP.."F5_Officer01", MP.."F5_Officer02" } 
  195.  
  196. 	FLOOR_OFFICER_NAMES = { FLOOR1_OFFICER_NAMES, FLOOR2_OFFICER_NAMES, 
  197. 									FLOOR3_OFFICER_NAMES, FLOOR4_OFFICER_NAMES, 
  198. 									FLOOR5_OFFICER_NAMES } 
  199.  
  200. 	SWAT_ATTACKERS_GROUP_NAMES = { MP.."Swat_Attack1", MP.."Swat_Attack2" } 
  201. 	SWAT_ATTACKER_NAMES = { { MP.."Swat1_1", MP.."Swat1_2", MP.."Swat1_3", MP.."Swat1_4", MP.."Swat1_5" }, 
  202. 									{ MP.."Swat2_1", MP.."Swat2_2", MP.."Swat2_3", MP.."Swat2_4", MP.."Swat2_5", MP.."Swat2_6" } } 
  203.  
  204. 	HELIPAD_MEMBER_NAMES = { MP.."Heli_M01", MP.."Heli_M02", MP.."Heli_M03", MP.."Heli_M04" } 
  205.  
  206. 	SWAT_HELI_DROPOFF_SQUAD_MEMBERS = { MP.."SH_M01", MP.."SH_M02", MP.."SH_M03" } 
  207. 	SWAT_HELI_DROPOFF_PILOT = MP.."SH_Pilot" 
  208.  
  209. 	SWAT_HELI_SEATING = { SWAT_HELI_DROPOFF_PILOT, 
  210. 								 SWAT_HELI_DROPOFF_SQUAD_MEMBERS[1], SWAT_HELI_DROPOFF_SQUAD_MEMBERS[2], SWAT_HELI_DROPOFF_SQUAD_MEMBERS[3] } 
  211.  
  212. 	SWAT_HELI = MP.."Swat_Heli" 
  213.  
  214. 	SWAT_HELI_DROPOFF_PATH = MP.."Swat_Heli_Dropoff_Path" 
  215. 	SWAT_HELI_RETURN_PATH = MP.."Swat_Heli_Return_Path" 
  216.  
  217. -- Floor triggers 
  218. 	FLOOR_PREFIX = MP.."Floor" 
  219. 	FLOOR_END_SINGLE_DIGIT_PREFIX = "_0" 
  220. 	FLOOR_END_DOUBLE_DIGIT_PREFIX = "_" 
  221. 	FLOOR1_TRIGGER_COUNT = 0 
  222. 	FLOOR2_TRIGGER_COUNT = 2 
  223. 	FLOOR3_TRIGGER_COUNT = 2 
  224. 	FLOOR4_TRIGGER_COUNT = 1 
  225. 	FLOOR5_TRIGGER_COUNT = 1 
  226. 	FLOOR_TRIGGER_COUNTS = { FLOOR1_TRIGGER_COUNT, FLOOR2_TRIGGER_COUNT, FLOOR3_TRIGGER_COUNT, FLOOR4_TRIGGER_COUNT, FLOOR5_TRIGGER_COUNT } 
  227. 	CAMERA_ROOM_FLOOR = 4 
  228.  
  229. 	STATION_AREA_TRIGGERS = { MP.."Station_Area_01", MP.."Station_Area_02", MP.."Station_Area_03" } 
  230. 	HIDE_WEAPONS_TRIGGER_NAME = MP.."Hide_Weapons_Trigger" 
  231.  
  232. 	PARKING_SPOT_TRIGGER = MP.."Parking_Spot" 
  233.  
  234. 	STATION_DOORS = { MP.."Station_Front_Door01", MP.."Station_Front_Door02", 
  235. 							MP.."Station_Helipad_Door01", MP.."Station_Helipad_Door02" } 
  236.  
  237. 	HELIPAD_DOORS = { STATION_DOORS[3], STATION_DOORS[4] } 
  238.  
  239. 	DOORS_TO_HIDE = { MP.."Door_To_Hide01", MP.."Door_To_Hide02", MP.."Door_To_Hide03", 
  240. 							MP.."Door_To_Hide04" } 
  241.  
  242. 	-- Cutscenes 
  243. 	CT_INTRO = "ss10-01" 
  244. 	CT_OUTRO = "ss10-02" 
  245. -- Sound 
  246. 	-- Persona overrides 
  247. 	SHAUNDI_PERSONA_OVERRIDES = 
  248. 	{ 
  249. 	{ "hostage - barters", "SOS10_SHAUNDI_BARTER" }, 
  250. 	{ "misc - respond to player taunt w/taunt", "SOS10_SHAUNDI_TAUNT" }, 
  251. 	{ "observe - praised by pc", "SOS10_SHAUNDI_PRAISED" }, 
  252. 	{ "threat - damage received (firearm)", "SOS10_SHAUNDI_TAKEDAM" }, 
  253. 	{ "threat - damage received (melee)", "SOS10_SHAUNDI_TAKEDAM" } 
  254. 	} 
  255.  
  256. 	-- Lines/Dialog Stream 
  257. 	DON_DISGUISE_DIALOG_STREAM = 
  258. 	{ 
  259. 	{ "SOS10_DISGUISE_L1", SHAUNDI_REPAIR_VARIANT_NAME, 0 }, 
  260. 	{ "PLAYER_SOS10_DISGUISE_L2", LOCAL_PLAYER, 0 }, 
  261. 	{ "SOS10_DISGUISE_L3", SHAUNDI_REPAIR_VARIANT_NAME, 0 }, 
  262. 	{ "PLAYER_SOS10_DISGUISE_L4", LOCAL_PLAYER, 0 }, 
  263. 	{ "SOS10_DISGUISE_L5", SHAUNDI_REPAIR_VARIANT_NAME, 0 } 
  264. 	} 
  265.  
  266. 	CHECKIN_DIALOG_STREAM =  
  267. 	{ 
  268. 	{ "SOS10_FIX_L1", RECEPTIONIST_NAME, 0 }, 
  269. 	{ "PLAYER_SOS10_FIX_L2", LOCAL_PLAYER, 0 }, 
  270. 	{ "SOS10_FIX_L3", SHAUNDI_REPAIR_VARIANT_NAME, 0 }, 
  271. 	{ "SOS10_FIX_L4", RECEPTIONIST_NAME, 0 }, 
  272. 	} 
  273.  
  274. 	PIERCE_STATUS_UPDATE_DIALOG_STREAM = 
  275. 	{ 
  276. 	{ "SOS10_END_L1", nil, 0 }, 
  277. 	{ "PLAYER_SOS10_END_L2", LOCAL_PLAYER, 0 } 
  278. 	} 
  279.  
  280. 	REPAIRMAN_ATTACKED_LINE = "REPAIRMAN_SOS10_DAMAGE_01" 
  281.  
  282. 	SHAUNDI_MISSION_START_LINE = "SHAUNDI_SOS10_START_01" 
  283. 	SHAUNDI_NEAR_STATION_LINE = "SHAUNDI_SOS10_NEAR_STATION_01" 
  284. 	SHAUNDI_PAST_DESK_LINE = "SOS10_SHAUNDI_ARRIVE_1" 
  285. 	SHAUNDI_START_HACKING_LINE = "SOS10_SHAUNDI_STARTHACK_1" 
  286. 	SHAUNDI_HACK20P_LINE = "SOS10_SHAUNDI_HACK20_1" 
  287. 	SHAUNDI_HACK50P_LINE = "SOS10_SHAUNDI_HACK50_1" 
  288. 	SHAUNDI_HACK75P_LINE = "SOS10_SHAUNDI_HACK75_1" 
  289. 	SHAUNDI_HACK100P_LINE = "SOS10_SHAUNDI_HACK100_1" 
  290.  
  291. 	DONE_HACKING_LINE_ONE = "SOS10_DONE_L1" 
  292. 	DONE_HACKING_LINE_TWO = "SOS10_DONE_L2" 
  293. 	 
  294. 	SHAUNDI_GO_TO_ROOF_LINE = "SOS10_SHAUNDI_GOROOF_1" 
  295.  
  296. 	-- Sound effects 
  297. 	CHANGE_CLOTHES_SOUND = "SFX_MISSION_SOS10_CLOTHESCHANGE" 
  298.  
  299. -- Distances 
  300. 	REPAIR_VAN_CHASE_DISTANCE_METERS = 50 
  301. 	RECEPTIONIST_CHECKIN_TRIGGER_TO_ENTRANCE_METERS = 20 
  302. 	RECEPTIONIST_CHAIR_TRIGGER_DISTANCE_METERS = .10 
  303. 	FOLLOWER_HQ_WIN_DISTANCE_METERS = 30 
  304.  
  305. 	REPAIR_VAN_DESIRED_SPEED_MPS = 25 
  306. 	REPAIR_VAN_FLEE_SPEED_MPS = 55 
  307. 	SHAUNDI_ABANDONED_DISTANCE_METERS = 40 
  308.  
  309. -- Percents and multipliers 
  310. 	REPAIR_VAN_DISABLED_DAMAGE_PERCENT = 0.7 
  311. 	REPAIR_VAN_PERCENT_DAMAGE_TO_DISABLE = 1.0 - REPAIR_VAN_DISABLED_DAMAGE_PERCENT 
  312. 	VAN_HP_MULTIPLIER = 4.0 
  313.  
  314. -- Time values 
  315. 	MISSION_START_FADE_TIME_SECONDS = 2.0 
  316.  
  317. 	TIME_TO_REACH_VAN_MS = 180000 
  318. 	TIME_TO_CATCH_UP_WITH_VAN_MS = 30000 
  319. 	PLAYER_RUSE_DISCOVERED_SECONDS = 30.0 
  320. 	PLAYER_RUSE_DISCOVERED_CAMERA_ROOM_FLOOR_SECONDS = 2.0 
  321.  
  322. 	SWAT_SQUAD_SPAWN_DELAY_TIME_SECONDS = 30 
  323. 	INITIAL_HACKING_TIME_VALUE_SECONDS = 45 
  324. 	FINAL_HACKING_TIMER_VALUE_SECONDS = 120 
  325. 	TOTAL_HACKING_TIME_VALUE_SECONDS = INITIAL_HACKING_TIME_VALUE_SECONDS + FINAL_HACKING_TIMER_VALUE_SECONDS 
  326. 	SWAT_HELI_GROUP_SPAWN_THREAD_DELAY_SECONDS = 45 
  327. 	SWITCH_TO_SWAT_SPAWN_TIME_DELAY_SECONDS = 60 
  328.  
  329. 	ITEM_CHECK_DELAY_SECONDS = 1.0 
  330.  
  331. 	CLOTHES_SWITCH_FADE_TIME_SECONDS = 2.0 
  332. 	PIERCE_STATUS_UPDATE_DELAY_SECONDS = 7.0 
  333. 	TIME_BEFORE_SHAUNDI_ABANDONED_SECONDS = 30 
  334.  
  335. -- Constant values and counts 
  336. 	MISSION_POST_ALARM_NOTORIETY = 4 
  337. 	FRONTAL_ASSAULT_NOTORIETY = 3 
  338. 	PER_FLOOR_OFFICERS_REMAINING_THRESHOLD = { 2, 2, 2, 1, 2 } 
  339. 	OFFICERS_REMAINING_THRESHOLD = 2 
  340. 	OFFICERS_FOR_WAVE_ATTACK_THRESHOLD = 2 
  341. 	NUM_HACKING_TIME_DIVISIONS = 40 
  342. 	REPAIR_VAN_SEAT_COUNT = 4 
  343.  
  344. -- Global variables 
  345. 	Repair_van_follow_path_thread_handle = -1 
  346. 	Initial_van_hp = 0 
  347. 	Floor1_trigger_names = {} 
  348. 	Floor2_trigger_names = {} 
  349. 	Floor3_trigger_names = {} 
  350. 	Floor4_trigger_names = {} 
  351. 	Floor5_trigger_names = {} 
  352. 	Floor_trigger_names = { Floor1_trigger_names, Floor2_trigger_names, Floor3_trigger_names, 
  353. 									Floor4_trigger_names, Floor5_trigger_names } 
  354. 	Cur_floor_index = 1 
  355. 	State = MS_INITIAL 
  356. 	Player_ruse_thread_handle = INVALID_THREAD_HANDLE 
  357. 	Track_weapon_thread_handle = INVALID_THREAD_HANDLE 
  358. 	Tracking_Shaundi_in_vehicle_thread_handle = INVALID_THREAD_HANDLE 
  359. 	Shaundi_abandoned_thread = INVALID_THREAD_HANDLE 
  360. 	Mark_destination_thread_handle = INVALID_THREAD_HANDLE 
  361.  
  362. 	Alarm_set_off = false 
  363. 	Signing_in = false 
  364.  
  365. 	Shaundi_has_started_hacking = false 
  366. 	Shaundi_hacking = false 
  367.  
  368. 	Wave_attack_started = false 
  369. 	Police_wave_spawn_enabled = true 
  370.  
  371. 	Swat_wave_spawn_enabled = false 
  372. 	Helipad_doors_locked = false 
  373.  
  374. 	Current_wave_spawn_location = -1 
  375. 	Num_wave_members_remaining = -1 
  376. 	Alarm_handle = -1 
  377. 	Num_waves_defeated = 0 
  378.  
  379. 	Follower_distance_check_threads = {} 
  380. 	Players_in_repair_van = { [LOCAL_PLAYER] = false, [REMOTE_PLAYER] = false } 
  381. 	Players_reached_stairs = { [LOCAL_PLAYER] = false, [REMOTE_PLAYER] = false } 
  382. 	Players_in_area = { { [LOCAL_PLAYER] = false, [REMOTE_PLAYER] = false }, 
  383. 							  { [LOCAL_PLAYER] = false, [REMOTE_PLAYER] = false }, 
  384. 							  { [LOCAL_PLAYER] = false, [REMOTE_PLAYER] = false } } 
  385.  
  386. 	Floor_officers_remaining = { sizeof_table( FLOOR_OFFICER_NAMES[1] ), sizeof_table( FLOOR_OFFICER_NAMES[2] ), 
  387. 										  sizeof_table( FLOOR_OFFICER_NAMES[3] ), sizeof_table( FLOOR_OFFICER_NAMES[4] ), 
  388. 										  sizeof_table( FLOOR_OFFICER_NAMES[5] ) } 
  389.  
  390. 	Threshold_triggered = { false, false, false, false, false } 
  391.  
  392. 	Total_officers_remaining = Floor_officers_remaining[1] + Floor_officers_remaining[2] + 
  393. 										Floor_officers_remaining[3] + Floor_officers_remaining[4] + 
  394. 										Floor_officers_remaining[5]; 
  395.  
  396. -- These callbacks are used for a sequence in which officers on each floor attack 
  397. -- in sequence, starting with the fourth and fifth floors and proceeding down to 
  398. -- the first floor. 
  399. -- 
  400. function ss10_floor5_officer_died() 
  401. 	ss10_floor_officer_died( 5 ) 
  402. end 
  403.  
  404. function ss10_floor4_officer_died() 
  405. 	local cascade_to_next_floor = true 
  406. 	ss10_floor_officer_died( 4, cascade_to_next_floor ) 
  407. end 
  408.  
  409. function ss10_floor3_officer_died() 
  410. 	local cascade_to_next_floor = true 
  411. 	ss10_floor_officer_died( 3, cascade_to_next_floor ) 
  412. end 
  413.  
  414. function ss10_floor2_officer_died() 
  415. 	local cascade_to_next_floor = true 
  416. 	ss10_floor_officer_died( 2, cascade_to_next_floor ) 
  417. end 
  418.  
  419. function ss10_floor1_officer_died() 
  420. 	ss10_floor_officer_died( 1 ) 
  421. end 
  422.  
  423. -- Sets up the station interior triggers to track whether the 
  424. -- players are in the station or not. 
  425. -- 
  426. function ss10_setup_station_area_tracking() 
  427. 	for index, name in pairs( STATION_AREA_TRIGGERS ) do 
  428. 		trigger_enable( name, true ) 
  429. 		on_trigger( "ss10_entered_area_0"..index, name ) 
  430. 		on_trigger_exit( "ss10_left_area_0"..index, name ) 
  431. 	end 
  432. end 
  433.  
  434. -- Returns true if the specified player is in the police station, 
  435. -- false otherwise. 
  436. -- 
  437. function ss10_player_in_station( player_name ) 
  438. 	if ( Players_in_area[1][player_name] or 
  439. 		  Players_in_area[2][player_name] or 
  440. 		  Players_in_area[3][player_name] ) then 
  441. 		return true 
  442. 	end 
  443. 	return false 
  444. end 
  445.  
  446. function ss10_no_players_in_station() 
  447. 	if ( ss10_player_in_station( LOCAL_PLAYER ) == false ) then 
  448. 		if ( coop_is_active() ) then 
  449. 			if ( ss10_player_in_station( REMOTE_PLAYER ) == false ) then 
  450. 				return true 
  451. 			end 
  452. 		else 
  453. 			return true 
  454. 		end 
  455. 	end 
  456.  
  457. 	return false 
  458. end 
  459.  
  460. function ss10_maybe_entered_station() 
  461. 	notoriety_force_no_spawn( POLICE_GANG, true ) 
  462. 	notoriety_force_no_spawn( ULTOR_GANG, true ) 
  463. end 
  464.  
  465. function ss10_maybe_left_station() 
  466. 	if ( ss10_no_players_in_station() ) then 
  467. 		notoriety_force_no_spawn( POLICE_GANG, false ) 
  468. 		notoriety_force_no_spawn( ULTOR_GANG, false ) 
  469. 	end 
  470. end 
  471.  
  472. -- Tracking the players entering the areas in the police station 
  473. function ss10_entered_area_01( triggerer_name ) 
  474. 	if ( ss10_player_in_station( triggerer_name ) == false ) then 
  475. 		mission_debug( triggerer_name.." entered station" ) 
  476. 	end 
  477. 	ss10_maybe_entered_station() 
  478.  
  479. 	Players_in_area[1][triggerer_name] = true 
  480. end 
  481.  
  482. function ss10_entered_area_02( triggerer_name ) 
  483. 	if ( ss10_player_in_station( triggerer_name ) == false ) then 
  484. 		mission_debug( triggerer_name.." entered station" ) 
  485. 	end 
  486. 	ss10_maybe_entered_station() 
  487.  
  488. 	Players_in_area[2][triggerer_name] = true 
  489. end 
  490.  
  491. function ss10_entered_area_03( triggerer_name ) 
  492. 	if ( ss10_player_in_station( triggerer_name ) == false ) then 
  493. 		mission_debug( triggerer_name.." entered station" ) 
  494. 	end 
  495. 	ss10_maybe_entered_station() 
  496.  
  497. 	Players_in_area[3][triggerer_name] = true 
  498. end 
  499.  
  500. -- Tracking the players leaving the areas in the police station 
  501. function ss10_left_area_01( triggerer_name ) 
  502. 	Players_in_area[1][triggerer_name] = false 
  503. 	ss10_maybe_left_station() 
  504.  
  505. 	if ( ss10_player_in_station( triggerer_name ) == false ) then 
  506. 		mission_debug( triggerer_name.." left station" ) 
  507. 	end 
  508. end 
  509.  
  510. function ss10_left_area_02( triggerer_name ) 
  511. 	Players_in_area[2][triggerer_name] = false 
  512. 	ss10_maybe_left_station() 
  513.  
  514. 	if ( ss10_player_in_station( triggerer_name ) == false ) then 
  515. 		mission_debug( triggerer_name.." left station" ) 
  516. 	end 
  517. end 
  518.  
  519. function ss10_left_area_03( triggerer_name ) 
  520. 	Players_in_area[3][triggerer_name] = false 
  521. 	ss10_maybe_left_station() 
  522.  
  523. 	if ( ss10_player_in_station( triggerer_name ) == false ) then 
  524. 		mission_debug( triggerer_name.." left station" ) 
  525. 	end 
  526. end 
  527.  
  528. -- Called for when an officer belonging to a particular floor dies. 
  529. -- 
  530. -- floor_index: Index of the floor that this officer belongs to. 
  531. -- trigger_next_floor: True if this officer dying could potentially trigger 
  532. --							the next floor to attack. 
  533. -- 
  534. function ss10_floor_officer_died( floor_index, trigger_next_floor ) 
  535.  
  536. 	local time_seconds = 5 
  537. 	local debug_string = "Floor "..floor_index.." attacker died." 
  538.  
  539. 	if ( Alarm_set_off == false ) then 
  540. 		ss10_police_station_alarm() 
  541. 		debug_string = debug_string.." Ruse discovered." 
  542. 		time_seconds = time_seconds + 5 
  543. 	end 
  544.  
  545. 	if ( trigger_next_floor == nil ) then 
  546. 		trigger_next_floor = false 
  547. 	end 
  548.  
  549. 	Floor_officers_remaining[floor_index] = Floor_officers_remaining[floor_index] - 1 
  550. 	Total_officers_remaining = Total_officers_remaining - 1 
  551. 	debug_string = debug_string.." "..Floor_officers_remaining[floor_index].." remain." 
  552.  
  553. 	-- If enough of this floor dies, have the next floor help ( if we're supposed to ) 
  554. 	if ( Floor_officers_remaining[floor_index] <= PER_FLOOR_OFFICERS_REMAINING_THRESHOLD[floor_index] and 
  555. 		  Threshold_triggered[floor_index] == false and 
  556. 		  trigger_next_floor == true ) then 
  557. 	  Threshold_triggered[floor_index] = true 
  558. 	  ss10_floor_attack( floor_index - 1 ) 
  559. 	  debug_string = debug_string.." Next floor attacking." 
  560. 	  time_seconds = time_seconds + 5 
  561.  
  562. 	  -- Special case for the fourth floor - remove leashes on fifth floor members 
  563. 	  if ( floor_index == 4 ) then 
  564. 		  if ( Floor_officers_remaining[floor_index] == 1 ) then 
  565. 			  for index, name in pairs( FLOOR5_OFFICER_NAMES ) do 
  566. 				  npc_leash_remove( name ) 
  567. 			  end 
  568. 		  end 
  569. 	  end 
  570. 	-- Once the first floor is killed, have the helipad people attack 
  571. 	elseif ( floor_index == 1 and 
  572. 				Floor_officers_remaining[floor_index] <= PER_FLOOR_OFFICERS_REMAINING_THRESHOLD[floor_index] and 
  573. 				Threshold_triggered[floor_index] == false ) then 
  574.  
  575. 		Threshold_triggered[floor_index] = true 
  576. 		ss10_maybe_open_helipad_doors() 
  577.  
  578. 		for index, member in pairs( HELIPAD_MEMBER_NAMES ) do 
  579. 			attack_closest_player( member ) 
  580. 		end 
  581. 	end 
  582.  
  583. 	-- If few enough officers remain, start the wave spawning for reinforcements 
  584. 	if ( Total_officers_remaining < OFFICERS_FOR_WAVE_ATTACK_THRESHOLD and Wave_attack_started == false ) then 
  585. 		ss10_spawn_first_wave() 
  586. 	  debug_string = debug_string.." Wave spawn started." 
  587. 	  time_seconds = time_seconds + 5 
  588. 	end 
  589.  
  590. 	mission_debug( debug_string, time_seconds ) 
  591. end 
  592.  
  593. -- Opens the helipad's doors if they're locked. 
  594. function ss10_maybe_open_helipad_doors() 
  595. 	if ( Helipad_doors_locked ) then 
  596. 		ss10_lock_helipad_doors( false ) 
  597. 		for index, name in pairs( HELIPAD_DOORS ) do 
  598. 			door_open( name ) 
  599. 		end 
  600. 	end 
  601. end 
  602.  
  603. -- Causes all of the officers from the specified floor to attack 
  604. -- the player. 
  605. -- 
  606. function ss10_floor_attack( floor_index ) 
  607. 	for index, name in pairs( FLOOR_OFFICER_NAMES[floor_index] ) do 
  608. 		local distance, player_name = get_dist_closest_player_to_object( name ) 
  609. 		attack_safe( name, player_name, false ) 
  610. 	end 
  611. end 
  612.  
  613. -- Starts the ambient attack chain, which has floor of attacks successively 
  614. -- come and attack until the player reaches the end of the chain and the 
  615. -- wave spawn attackers start spawning. 
  616. --  
  617. function ss10_begin_ambient_attack() 
  618. 	ss10_floor_attack(5) 
  619. 	ss10_floor_attack(4) 
  620. end 
  621.  
  622. -- Clear the death callbacks for all members belonging to the specified floor. 
  623. -- 
  624. function ss10_clear_callbacks( floor_index ) 
  625. 	for name_index, name in pairs( FLOOR_OFFICER_NAMES[floor_index] ) do 
  626. 		if ( character_is_dead( name ) == false ) then 
  627. 			on_death( "", name ) 
  628. 		end 
  629. 	end 
  630. end 
  631.  
  632. -- Sets up all the "on death" callbacks for all of the officers in the police station. 
  633. -- 
  634. function ss10_setup_ambient_officer_callbacks() 
  635. 	for floor_index, name_list in pairs( FLOOR_OFFICER_NAMES ) do 
  636. 		for name_index, name in pairs( name_list ) do 
  637. 			on_death( "ss10_floor"..floor_index.."_officer_died", name ) 
  638. 		end 
  639. 	end 
  640. end 
  641.  
  642. function ss10_start( checkpoint_name, is_restart ) 
  643. 	-- Start trigger is hit...the activate button was hit 
  644. 	set_mission_author("Mark Gabby & Brad Johnson") 
  645.  
  646. 	action_nodes_restrict_spawning( true ) 
  647.  
  648. 	-- Prevent the player from seeing or interacting with things that are being loaded 
  649. 	mission_start_fade_out() 
  650.  
  651. 	if ( checkpoint_name == MISSION_START_CHECKPOINT ) then 
  652. 		if ( is_restart == false ) then 
  653. 			cutscene_play( CT_INTRO, { SHAUNDI_GROUP_NAME, HELI_SQUAD_GROUP_NAME, STARTER_VEHICLE_GROUP_NAME, STARTER_VEHICLE_COOP_GROUP_NAME }, { START_NAVPOINT_NAME, START_NAVPOINT_NAME_COOP_PLAYER }, false ) 
  654. 		else 
  655. 			group_create_hidden( SHAUNDI_GROUP_NAME, true ) 
  656. 			group_create_hidden( HELI_SQUAD_GROUP_NAME, true ) 
  657. 			group_create_hidden( STARTER_VEHICLE_GROUP_NAME, true ) 
  658. 			group_create_hidden( STARTER_VEHICLE_COOP_GROUP_NAME, true ) 
  659. 			teleport_coop( START_NAVPOINT_NAME, START_NAVPOINT_NAME_COOP_PLAYER ) 
  660. 		end 
  661.  
  662. 		group_show( SHAUNDI_GROUP_NAME ) 
  663. 		group_show( HELI_SQUAD_GROUP_NAME ) 
  664. 		group_show( STARTER_VEHICLE_GROUP_NAME ) 
  665. 		if ( coop_is_active() ) then 
  666. 			group_show( STARTER_VEHICLE_COOP_GROUP_NAME ) 
  667. 		end 
  668. 	end 
  669.  
  670. 	local next_state = MS_FIND_REPAIRMEN 
  671.  
  672. 	if ( checkpoint_name == MISSION_START_CHECKPOINT ) then 
  673. 		group_create_hidden( SHAUNDI_REPAIR_VARIANT_GROUP_NAME ) 
  674.  
  675. 		for index, override in pairs( SHAUNDI_PERSONA_OVERRIDES ) do 
  676. 			persona_override_character_start( SHAUNDI_NAME, override[1], override[2] ) 
  677. 			persona_override_character_start( SHAUNDI_REPAIR_VARIANT_NAME, override[1], override[2] ) 
  678. 		end 
  679.  
  680. 		party_add( SHAUNDI_NAME, LOCAL_PLAYER ) 
  681. 	elseif ( checkpoint_name == CP_PARKED_VAN_AT_STATION ) then 
  682. 		customization_outfit_wear( REPAIR_OUTFIT_NAME, 0, SYNC_LOCAL ) 
  683. 		if ( coop_is_active() ) then 
  684. 			customization_outfit_wear( REPAIR_OUTFIT_NAME, 0, SYNC_REMOTE ) 
  685. 		end 
  686. 		trigger_type_enable("clothing store", false) 
  687. 		trigger_type_enable("crib clothing", false) 
  688. 		ss10_create_and_setup_police_station_groups() 
  689.  
  690. 		if ( group_is_loaded( SHAUNDI_REPAIR_VARIANT_GROUP_NAME ) == false ) then 
  691. 			group_create( SHAUNDI_REPAIR_VARIANT_GROUP_NAME, true ) 
  692. 		end 
  693. 		group_create( HELI_SQUAD_GROUP_NAME, true ) 
  694. 		ss10_setup_shaundi_repair_variant() 
  695. 		party_add( SHAUNDI_REPAIR_VARIANT_NAME, LOCAL_PLAYER ) 
  696. 		on_dismiss( "ss10_shaundi_dismissed", SHAUNDI_REPAIR_VARIANT_NAME ) 
  697. 		on_death( "ss10_shaundi_follower_died", SHAUNDI_REPAIR_VARIANT_NAME ) 
  698.  
  699. 		next_state = MS_PARKED_VAN_AT_STATION 
  700. 	end 
  701.  
  702. 	ss10_lock_station_doors() 
  703.  
  704. 	-- Loading is done - enable player control and visuals 
  705. 	mission_start_fade_in() 
  706.  
  707. 	-- Setup the mission for hijacking mode 
  708. 	ss10_switch_state( next_state ) 
  709. end 
  710.  
  711. function ss10_lock_station_doors( lock ) 
  712. 	if ( lock == nil ) then 
  713. 		lock = true 
  714. 	end 
  715.  
  716. 	for door_index, door_name in pairs( STATION_DOORS ) do 
  717. 		door_lock( door_name, lock ) 
  718. 	end 
  719. end 
  720.  
  721. function ss10_lock_helipad_doors( lock ) 
  722. 	if ( lock == nil ) then 
  723. 		lock = true 
  724. 	end 
  725. 	Helipad_doors_locked = lock 
  726.  
  727. 	for door_index, door_name in pairs( HELIPAD_DOORS ) do 
  728. 		door_lock( door_name, lock ) 
  729. 	end 
  730. end 
  731.  
  732. -- Called when the player gets near the repair van. 
  733. -- 
  734. function ss10_reached_repair_van_area( triggerer_name, trigger_name ) 
  735. 	trigger_enable( trigger_name, false ) 
  736.  
  737. 	-- Make the repair van start following a path 
  738. 	Repair_van_follow_path_thread_handle = thread_new( "ss10_repair_van_follow_path" ) 
  739. end 
  740.  
  741. function ss10_maybe_repairman_flee() 
  742. 	-- Have the repair man flee, but only if he's alive 
  743. 	if ( character_is_dead( REPAIR_MAN_NAME ) == false ) then 
  744. 		if ( character_is_in_vehicle( REPAIR_MAN_NAME ) ) then 
  745. 			vehicle_exit( REPAIR_MAN_NAME ) 
  746. 			delay( 0 ) 
  747. 		end 
  748. 		while ( not character_is_ready( REPAIR_MAN_NAME ) ) do 
  749. 			delay( 0 ) 
  750. 		end 
  751. 		local distance = 0 
  752. 		local player_name = nil 
  753. 		distance, player_name = get_dist_closest_player_to_object( REPAIR_MAN_NAME ) 
  754. 		flee( REPAIR_MAN_NAME, player_name, false ) 
  755. 	end 
  756. end 
  757.  
  758. function ss10_parked_at_station( triggerer_name, trigger_name ) 
  759. 	if ( character_is_in_vehicle( triggerer_name, REPAIR_VAN_NAME ) ) then 
  760. 		trigger_enable( trigger_name, false ) 
  761.  
  762. 		mission_set_checkpoint( CP_PARKED_VAN_AT_STATION ) 
  763. 		ss10_switch_state( MS_PARKED_VAN_AT_STATION ) 
  764. 	else 
  765. 		mission_help_table_nag( VAN_REQUIRED ) 
  766. 	end 
  767. end 
  768.  
  769. -- Switches to a new state. All the state change code should be here if possible, not spread 
  770. -- out in various trigger callbacks. 
  771. -- 
  772. -- new_state: The new state to switch to. 
  773. -- actor_name: MAY BE nil. The name of the actor that triggered the state change. 
  774. --				 Varies based on the state. 
  775. -- extra_data: MAY BE nil. Extra data, based on the state. 
  776. function ss10_switch_state( new_state, actor_name, extra_data ) 
  777. 	-- Setup the "Find the Repairmen" state where the player is given 
  778. 	-- one minute to find the repair van. 
  779. 	if ( new_state == MS_FIND_REPAIRMEN ) then 
  780. 		-- Create the repair van 
  781. 		ss10_create_repair_van_group() 
  782. 		waypoint_add( REPAIR_VAN_NAME, SYNC_ALL ) 
  783.  
  784. 		-- Set up a thread that causes the van to start pathing when the player gets close enough 
  785. 		trigger_enable( REPAIR_VAN_AREA_TRIGGER, true ) 
  786. 		vehicle_speed_override( REPAIR_VAN_NAME, 0 ) 
  787. 		on_trigger( "ss10_reached_repair_van_area", REPAIR_VAN_AREA_TRIGGER ) 
  788.  
  789. 		-- Add a timer to reach the repair van and objectives 
  790. 		audio_play_for_character( SHAUNDI_MISSION_START_LINE, SHAUNDI_NAME, "voice", false, true ) 
  791. 		mission_help_table( FIND_REPAIRMEN ) 
  792. 		--objective_text(0, FIND_REPAIRMEN ) 
  793. 		hud_timer_set(0, TIME_TO_REACH_VAN_MS, "ss10_failed_to_catch_van" ) 
  794.  
  795. 		-- Add callbacks for the distance 
  796. 		distance_display_on( REPAIR_VAN_NAME, 0, REPAIR_VAN_CHASE_DISTANCE_METERS, 0, REPAIR_VAN_CHASE_DISTANCE_METERS, SYNC_ALL ) 
  797. 		on_tailing_good( "ss10_reached_van_initial" ) 
  798. 		marker_add_vehicle( REPAIR_VAN_NAME, MINIMAP_ICON_KILL, INGAME_EFFECT_VEHICLE_KILL, SYNC_ALL ) 
  799.  
  800. 		-- Add callbacks for the correct behavior if the van is destroyed 
  801. 		-- or the driver is killed. 
  802. 		on_vehicle_destroyed( "ss10_van_destroyed", REPAIR_VAN_NAME ) 
  803. 		on_damage( "ss10_van_disabled", REPAIR_VAN_NAME, REPAIR_VAN_DISABLED_DAMAGE_PERCENT ) 
  804. 		on_death( "ss10_van_disabled", REPAIR_MAN_NAME ) 
  805. 		set_unjackable_flag( REPAIR_VAN_NAME, true ) 
  806.  
  807. 		-- Add a callback for the player claiming the van 
  808. 		on_vehicle_enter( "ss10_entered_van", REPAIR_VAN_NAME ) 
  809. 		on_vehicle_exit( "ss10_exited_van", REPAIR_VAN_NAME ) 
  810.  
  811. 		on_dismiss( "ss10_shaundi_dismissed", SHAUNDI_NAME ) 
  812. 		on_death( "ss10_shaundi_follower_died", SHAUNDI_NAME ) 
  813.  
  814. 		-- Update the damage and collision callbacks 
  815. 		vehicle_disable_chase( REPAIR_VAN_NAME, true ) 
  816. 		vehicle_disable_flee( REPAIR_VAN_NAME, true ) 
  817. 		on_take_damage( "ss10_van_damaged_initial", REPAIR_VAN_NAME ) 
  818. 		on_collision( "ss10_van_damaged_initial", REPAIR_VAN_NAME )  
  819.  
  820. 	-- Setup the "Hijack the Van" state where the player must disable the 
  821. 	-- repairmen's van 
  822. 	-- "extra_data" in this state is set to false if the van is still out-of-range 
  823. 	-- when this is called. 
  824. 	elseif ( new_state == MS_HIJACK_REPAIR_VAN ) then 
  825. 		-- Give the player a prompt and update the objective 
  826. 		local in_range = true 
  827. 		if ( extra_data == false ) then 
  828. 			in_range = extra_data 
  829. 		end 
  830. 		if ( in_range ) then 
  831. 			mission_help_table( HIJACK_VAN ) 
  832. 		end 
  833.  
  834. 		-- Update the distance callbacks 
  835. 		on_tailing_good( "ss10_good_distance" ) 
  836. 		on_tailing_too_far( "ss10_van_escaping" ) 
  837.  
  838. 		-- Stop the "find the repairmen" timer 
  839. 		hud_timer_stop(0) 
  840.  
  841. 		-- If we're in range of the van, have the HP bar show up 
  842. 		if ( in_range ) then 
  843. 			ss10_initialize_hud_bar() 
  844. 			ss10_update_van_hp_hud_bar() 
  845. 		-- Otherwise, the van is getting away! 
  846. 		else 
  847. 			ss10_van_escaping() 
  848. 		end 
  849. 	-- State for the repair van being too far away from the player 
  850. 	elseif ( new_state == MS_REPAIRMEN_ESCAPING ) then 
  851. 		-- Let the player know he has to catch up to the repairment again 
  852. 		mission_help_table( CATCH_UP_TO_VAN ) 
  853.  
  854. 		-- Add a timer - if he doesn't catch up soon enough, he fails 
  855. 		hud_timer_set(0, TIME_TO_CATCH_UP_WITH_VAN_MS, "ss10_failed_to_catch_van" ) 
  856.  
  857. 		-- Remove the damage bar temporarily. 
  858. 		hud_bar_off( 0 ) 
  859. 	-- State for the player reaching the repair van again after reaching it 
  860. 	-- and then falling back too far 
  861. 	elseif ( new_state == MS_REACHED_REPAIRMEN_AGAIN ) then 
  862.  
  863. 		-- Stop the "he's getting away" failure time  
  864. 		hud_timer_stop(0) 
  865.  
  866. 		-- Re-add the hud bar and update it 
  867. 		ss10_initialize_hud_bar() 
  868. 		ss10_update_van_hp_hud_bar() 
  869. 	-- State for the repair van being completely disabled, and ready to be 
  870. 	-- obtained by the player. 
  871. 	elseif ( new_state == MS_VAN_DISABLED ) then 
  872. 		-- Stop all the HUD stuff, which is no longer necessary. 
  873. 		mission_debug( "disabling hud bar and timers" ) 
  874. 		hud_timer_stop( 0 ) 
  875. 		hud_bar_off( 0 ) 
  876. 		distance_display_off(SYNC_ALL) 
  877.  
  878. 		-- Remove the callbacks which are also unnecessary. 
  879. 		on_take_damage("", REPAIR_VAN_NAME) 
  880. 		on_damage( "", REPAIR_VAN_NAME, REPAIR_VAN_DISABLED_DAMAGE_PERCENT ) 
  881. 		on_death( "", REPAIR_MAN_NAME ) 
  882.  
  883. 		-- Mark the van as something to aquire and 
  884. 		-- prompt the player to aquire it 
  885. 		set_unjackable_flag( REPAIR_VAN_NAME, false ) 
  886. 		marker_remove_vehicle( REPAIR_VAN_NAME, SYNC_ALL ) 
  887. 		marker_add_vehicle( REPAIR_VAN_NAME, MINIMAP_ICON_PROTECT_ACQUIRE, INGAME_EFFECT_VEHICLE_PROTECT_ACQUIRE, SYNC_ALL ) 
  888. 		-- Remove the objective text because the player's no longer time-limited 
  889. 		--objective_text_clear(0) 
  890.  
  891. 		if ( Repair_van_follow_path_thread_handle ~= INVALID_THREAD_HANDLE ) then 
  892. 			thread_kill( Repair_van_follow_path_thread_handle ) 
  893. 			Repair_van_follow_path_thread_handle = INVALID_THREAD_HANDLE 
  894. 		end 
  895.  
  896. 		thread_new( "ss10_maybe_repairman_flee" ) 
  897.  
  898. 	-- State for the player getting into the van and having to get to 
  899. 	-- the police station with it. 
  900. 	elseif ( new_state == MS_PARK_VAN_AT_STATION ) then 
  901. 		-- Prevent the players from using clothing stores and clothing customization for the 
  902. 		-- time being 
  903. 		trigger_type_enable("clothing store", false) 
  904. 		trigger_type_enable("crib clothing", false) 
  905. 		-- Change the player's clothes 
  906. 		fade_out( CLOTHES_SWITCH_FADE_TIME_SECONDS ) 
  907. 		follower_make_independent( SHAUNDI_NAME, true ) 
  908. 		player_controls_disable( LOCAL_PLAYER ) 
  909. 		if ( coop_is_active() ) then 
  910. 			player_controls_disable( REMOTE_PLAYER ) 
  911. 		end 
  912. 		vehicle_stop( REPAIR_VAN_NAME ) 
  913. 		delay( CLOTHES_SWITCH_FADE_TIME_SECONDS ) 
  914.  
  915. 		spawning_vehicles( false ) 
  916. 		spawning_vehicles( true ) 
  917. 		spawning_pedestrians( false ) 
  918. 		spawning_pedestrians( true ) 
  919.  
  920. 		on_dismiss( "", SHAUNDI_NAME ) 
  921. 		on_death( "", SHAUNDI_NAME ) 
  922. 		group_destroy( SHAUNDI_GROUP_NAME ) 
  923.  
  924. 		-- Clear notoriety - you're in disguise! 
  925. 		notoriety_set( POLICE_GANG, 0 ) 
  926. 		group_show( SHAUNDI_REPAIR_VARIANT_GROUP_NAME ) 
  927. 		party_add( SHAUNDI_REPAIR_VARIANT_NAME, LOCAL_PLAYER ) 
  928. 		ss10_setup_shaundi_repair_variant() 
  929.  
  930. 		on_dismiss( "ss10_shaundi_dismissed", SHAUNDI_REPAIR_VARIANT_NAME ) 
  931. 		on_death( "ss10_shaundi_follower_died", SHAUNDI_REPAIR_VARIANT_NAME ) 
  932.  
  933. 		vehicle_evacuate( REPAIR_VAN_NAME ) 
  934. 		repeat 
  935. 			thread_yield() 
  936. 		until ( character_is_in_vehicle( SHAUNDI_NAME ) == false and 
  937. 				  character_is_in_vehicle( LOCAL_PLAYER ) == false ) 
  938. 		if ( coop_is_active() ) then 
  939. 			repeat 
  940. 				thread_yield() 
  941. 			until ( character_is_in_vehicle( REMOTE_PLAYER ) == false ) 
  942. 		end 
  943.  
  944. 		vehicle_enter_teleport( LOCAL_PLAYER, REPAIR_VAN_NAME, 0 ) 
  945. 		if ( coop_is_active() ) then 
  946. 			vehicle_enter_teleport( REMOTE_PLAYER, REPAIR_VAN_NAME, 2 ) 
  947. 		end 
  948.  
  949. 		customization_outfit_wear( REPAIR_OUTFIT_NAME, 0, SYNC_LOCAL ) 
  950. 		if ( coop_is_active() ) then 
  951. 			customization_outfit_wear( REPAIR_OUTFIT_NAME, 0, SYNC_REMOTE ) 
  952. 		end 
  953. 		-- Play the clothes change sound blocking 
  954. 		audio_play( CHANGE_CLOTHES_SOUND, "foley", true, true) 
  955.  
  956. 		player_controls_enable( LOCAL_PLAYER ) 
  957. 		if ( coop_is_active() ) then 
  958. 			player_controls_enable( REMOTE_PLAYER ) 
  959. 		end 
  960. 		fade_in( CLOTHES_SWITCH_FADE_TIME_SECONDS ) 
  961. 		fade_in_block() 
  962.  
  963. 		thread_new("ss10_don_disguise_conversation" ) 
  964.  
  965. 		-- Change callbacks to prevent both a green and teal marker on the map at once 
  966. 		on_vehicle_enter( "ss10_entered_van_during_drive_to_station", REPAIR_VAN_NAME ) 
  967. 		on_vehicle_exit( "ss10_exited_van_during_drive_to_station", REPAIR_VAN_NAME ) 
  968.  
  969. 		ss10_create_and_setup_police_station_groups() 
  970. 		--on_mover_dislodged( "receptionist_chair_moved", RECEPTIONIST_CHAIR_NAME, RECEPTIONIST_CHAIR_TRIGGER_DISTANCE_METERS ) 
  971.  
  972. 		mission_help_table( PARK_VAN_AT_STATION ) 
  973.  
  974. 		-- We can mark the parking spot and remove the marker for the van because all players are in the van when 
  975. 		-- this is called. 
  976. 		trigger_enable( PARKING_SPOT_TRIGGER, true ) 
  977. 		marker_add_trigger( PARKING_SPOT_TRIGGER, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_LOCATION, SYNC_ALL ) 
  978. 		marker_remove_vehicle( REPAIR_VAN_NAME, SYNC_ALL ) 
  979. 		on_trigger( "ss10_parked_at_station", PARKING_SPOT_TRIGGER ) 
  980. 		waypoint_add( PARKING_SPOT_TRIGGER, SYNC_ALL ) 
  981.  
  982. 	elseif ( new_state == MS_PARKED_VAN_AT_STATION ) then 
  983. 		-- The repair van is no longer mission-critical. 
  984. 		on_vehicle_destroyed( "", REPAIR_VAN_NAME ) 
  985. 		on_vehicle_enter( "", REPAIR_VAN_NAME ) 
  986. 		on_vehicle_exit( "", REPAIR_VAN_NAME ) 
  987. 		marker_remove_vehicle( REPAIR_VAN_NAME, SYNC_ALL ) 
  988.  
  989. 		-- Unlock the station's doors 
  990. 		ss10_lock_station_doors( false ) 
  991.  
  992. 		-- Keep the helipad doors locked 
  993. 		ss10_lock_helipad_doors() 
  994.  
  995. 		-- Lock and hide doors that we don't want to be in the way 
  996. 		for door_index, door_name in pairs( DOORS_TO_HIDE ) do 
  997. 			door_lock( door_name, true ) 
  998. 			mesh_mover_hide( door_name ) 
  999. 		end 
  1000.  
  1001. 		-- Add death tracking for receptionist 
  1002. 		on_death( "ss10_receptionist_died", RECEPTIONIST_NAME ) 
  1003. 		on_notoriety_event( "ss10_notoriety_event_local", LOCAL_PLAYER ) 
  1004. 		if ( coop_is_active() ) then 
  1005. 			on_notoriety_event( "ss10_notoriety_event_remote", REMOTE_PLAYER ) 
  1006. 		end 
  1007.  
  1008. 		mission_help_table( ENTER_THE_STATION ) 
  1009.  
  1010. 		trigger_enable( HIDE_WEAPONS_TRIGGER_NAME, true ) 
  1011. 		on_trigger( "ss10_hide_weapon_prompt", HIDE_WEAPONS_TRIGGER_NAME ) 
  1012.  
  1013. 		trigger_enable( POLICE_STATION_TRIGGER_NAME, true ) 
  1014. 		on_trigger( "ss10_reached_police_station", POLICE_STATION_TRIGGER_NAME ) 
  1015. 		marker_add_trigger( POLICE_STATION_TRIGGER_NAME, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL ) 
  1016. 		waypoint_add( POLICE_STATION_TRIGGER_NAME, SYNC_ALL ) 
  1017.  
  1018. 		ss10_setup_station_area_tracking() 
  1019.  
  1020. 	-- In this state, the player must get to the receptionist and check in 
  1021. 	elseif ( new_state == MS_ENTERED_POLICE_STATION ) then 
  1022.  
  1023. 		trigger_enable( POLICE_STATION_TRIGGER_NAME, false ) 
  1024. 		marker_remove_trigger( POLICE_STATION_TRIGGER_NAME ) 
  1025.  
  1026. 		-- If the player is sane and enters the station without police notoriety, 
  1027. 		-- allow the sneaking to continue 
  1028. 		if ( notoriety_get_decimal( POLICE_GANG ) < 1 ) then 
  1029. 			notoriety_set( POLICE_GANG, 0 ) 
  1030.  
  1031. 			-- Tell the player what he should be doing 
  1032. 			mission_help_table( CHECK_IN_AT_DESK ) 
  1033.  
  1034. 			-- Add the receptionist trigger 
  1035. 			trigger_enable( RECEPTIONIST_DESK_CHECKIN_TRIGGER_NAME, true ) 
  1036. 			marker_add_trigger( RECEPTIONIST_DESK_CHECKIN_TRIGGER_NAME, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL ) 
  1037. 			on_trigger( "ss10_sign_in_with_receptionist", RECEPTIONIST_DESK_CHECKIN_TRIGGER_NAME ) 
  1038.  
  1039. 			Track_weapon_thread_handle = thread_new( "ss10_track_weapon_equipped" ) 
  1040.  
  1041. 			on_weapon_fired( "", LOCAL_PLAYER ) 
  1042. 			if ( coop_is_active() ) then 
  1043. 				on_weapon_fired( "", REMOTE_PLAYER ) 
  1044. 			end 
  1045.  
  1046. 			trigger_enable( PAST_DESK_TRIGGER_NAME, true ) 
  1047. 			on_trigger( "ss10_went_past_desk_before_checking_in", PAST_DESK_TRIGGER_NAME ) 
  1048. 			for index, trigger in pairs( MAIN_STATION_ENTRANCE_TRIGGERS ) do 
  1049. 				trigger_enable( trigger, true ) 
  1050. 				on_trigger( "ss10_entered_entrance_before_checking_in", trigger ) 
  1051. 			end 
  1052. 		-- Deal with insane players by setting off the alarm 
  1053. 		else 
  1054. 			local entered_with_notoriety = true 
  1055. 			ss10_switch_state( MS_RUN_TO_CAMERA_ROOM, nil, entered_with_notoriety ) 
  1056. 		end 
  1057. 	-- These states are enabled if the player either checks in or just runs past the desk 
  1058. 	elseif ( new_state == MS_GO_TO_CAMERA_ROOM or new_state == MS_RUN_TO_CAMERA_ROOM  ) then 
  1059. 		if ( new_state == MS_GO_TO_CAMERA_ROOM ) then 
  1060. 			Signing_in = true 
  1061. 		end 
  1062.  
  1063. 		-- Clear on-death callback for receptionist. 
  1064. 		if ( character_is_dead( RECEPTIONIST_NAME ) == false ) then 
  1065. 			on_death( "ss10_police_station_alarm", RECEPTIONIST_NAME ) 
  1066. 		end 
  1067.  
  1068. 		if ( extra_data == nil ) then 
  1069. 			extra_data = false 
  1070. 		end 
  1071. 		local entered_with_notoriety = extra_data 
  1072.  
  1073. 		-- The player has checked in, so disable the pre-checkin triggers 
  1074. 		on_weapon_fired( "", LOCAL_PLAYER ) 
  1075. 		if ( coop_is_active() ) then 
  1076. 			on_weapon_fired( "", REMOTE_PLAYER ) 
  1077. 		end 
  1078. 		trigger_enable( PAST_DESK_TRIGGER_NAME, false ) 
  1079. 		for index, trigger in pairs( MAIN_STATION_ENTRANCE_TRIGGERS ) do 
  1080. 			trigger_enable( trigger, false ) 
  1081. 		end 
  1082. 		-- No more checking in, regardless of what happens next ... 
  1083. 		marker_remove_trigger( RECEPTIONIST_DESK_CHECKIN_TRIGGER_NAME ) 
  1084. 		trigger_enable( RECEPTIONIST_DESK_CHECKIN_TRIGGER_NAME, false ) 
  1085.  
  1086. 		if ( new_state == MS_GO_TO_CAMERA_ROOM ) then 
  1087. 			delay( 1 ) 
  1088. 			fade_out( 0 ) 
  1089. 			-- If we're in coop, make sure that one of the players isn't in a vehicle 
  1090. 			-- before the cutscene plays or ugly things can happen 
  1091. 			if ( coop_is_active() ) then 
  1092. 				vehicle_exit_teleport( LOCAL_PLAYER ) 
  1093. 				vehicle_exit_teleport( REMOTE_PLAYER ) 
  1094. 			end 
  1095. 			teleport( SHAUNDI_REPAIR_VARIANT_NAME, MP.."CT_Shaundi_Goal" ) 
  1096. 			spawning_pedestrians( false ) 
  1097. 			spawning_pedestrians( true ) 
  1098.  
  1099. 			cutscene_play( "IG_ss10_scene1" ) 
  1100. 			group_hide( MP.."Cutscene" ) 
  1101. 			group_destroy( MP.."Cutscene" ) 
  1102. 			Signing_in = false 
  1103.  
  1104. 			-- Start the "ruse was discovered" timer thread 
  1105. 			Player_ruse_thread_handle = thread_new( "ss10_player_ruse_discovered_timer" ) 
  1106. 		end 
  1107. 		if ( entered_with_notoriety == false ) then 
  1108. 			-- Let the player know where he's supposed to go 
  1109. 			mission_help_table( HEAD_TO_CAMERA_ROOM ) 
  1110. 		end 
  1111.  
  1112. 		-- Add the navpoint for the first stairway to give the player some guidance 
  1113. 		marker_add_navpoint( STAIRWAY_GUIDE_NAVPOINT_NAME, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL ) 
  1114. 		-- Add triggers to turn off the guide if the player gets up the stairs 
  1115. 		for index, trigger in pairs( STAIRWAY_TRIGGER_NAMES ) do 
  1116. 			trigger_enable( trigger, true ) 
  1117. 			on_trigger( "ss10_reached_stairway", trigger ) 
  1118. 		end 
  1119.  
  1120. 		if ( new_state == MS_RUN_TO_CAMERA_ROOM ) then 
  1121. 			-- Assume that the player was doing the ruse 
  1122. 			local was_doing_ruse = true 
  1123. 			-- Unless they entered with notoriety, in which case they didn't 
  1124. 			-- even get that far in the ruse 
  1125. 			if ( entered_with_notoriety ) then 
  1126. 				was_doing_ruse = false 
  1127. 			end 
  1128. 			-- The player gave himself away. 
  1129. 			ss10_police_station_alarm( was_doing_ruse ) 
  1130. 		elseif ( new_state == MS_GO_TO_CAMERA_ROOM ) then 
  1131. 			for index, name in pairs( PAST_LOBBY_TRIGGERS ) do 
  1132. 				mission_debug( "set up trigger "..name.." for past lobby" ) 
  1133. 				trigger_enable( name, true ) 
  1134. 				on_trigger( "ss10_past_lobby_after_checkin", name ) 
  1135. 			end 
  1136. 		end 
  1137. 	elseif ( new_state == MS_DEFEND_CAMERA_ROOM ) then	 
  1138. 		distance_display_on( SHAUNDI_REPAIR_VARIANT_NAME, 0, SHAUNDI_ABANDONED_DISTANCE_METERS, 0, SHAUNDI_ABANDONED_DISTANCE_METERS, SYNC_LOCAL ) 
  1139. 		on_tailing_good( "ss10_in_range_of_shaundi" ) 
  1140. 		on_tailing_too_far( "ss10_out_of_range_of_shaundi" ) 
  1141.  
  1142. 		mission_help_table( DEFEND_ROOM ) 
  1143. 		delay( 5.0 ) 
  1144.  
  1145.  
  1146. 		audio_play_for_character( SHAUNDI_START_HACKING_LINE, SHAUNDI_REPAIR_VARIANT_NAME, "voice", false, true ) 
  1147. 		thread_new( "ss10_shaundi_hacking_timer" ) 
  1148.  
  1149. 	elseif ( new_state == MS_LEAVE_STATION ) then 
  1150. 		ss10_maybe_open_helipad_doors() 
  1151.  
  1152. 		-- Stop animation 
  1153. 		clear_animation_state( SHAUNDI_REPAIR_VARIANT_NAME ) 
  1154.  
  1155. 		-- Prompt the player about the next objective 
  1156. 		audio_play_for_character( DONE_HACKING_LINE_ONE, SHAUNDI_REPAIR_VARIANT_NAME, "voice", false, true) 
  1157.  
  1158. 		-- Have Shaundi play a "pick up the equipment" animation 
  1159. 		-- TODO 
  1160. 		-- Stop crouching 
  1161. 		if crouch_is_crouching( SHAUNDI_REPAIR_VARIANT_NAME ) then 
  1162. 			crouch_stop( SHAUNDI_REPAIR_VARIANT_NAME ) 
  1163. 		end 
  1164.  
  1165. 		-- TODO: Play a pickup animation 
  1166. 		audio_play_for_character( DONE_HACKING_LINE_TWO, SHAUNDI_REPAIR_VARIANT_NAME, "voice", false, true) 
  1167.  
  1168. 		-- Have Shaundi follow the player again and 
  1169. 		-- remove special flags 
  1170. 		follower_make_independent( SHAUNDI_REPAIR_VARIANT_NAME, false ) 
  1171. 		set_ignore_ai_flag( SHAUNDI_REPAIR_VARIANT_NAME, false ) 
  1172. 		character_prevent_flinching( SHAUNDI_REPAIR_VARIANT_NAME, false ) 
  1173. 		on_incapacitated( "", SHAUNDI_REPAIR_VARIANT_NAME ) 
  1174. 		on_revived( "", SHAUNDI_REPAIR_VARIANT_NAME ) 
  1175. 		distance_display_off( SYNC_LOCAL ) 
  1176. 		ss10_maybe_kill_shaundi_abandoned_thread() 
  1177.  
  1178. 		npc_dont_auto_equip_or_unequip_weapons( SHAUNDI_REPAIR_VARIANT_NAME, true ) 
  1179. 		npc_combat_enable( SHAUNDI_REPAIR_VARIANT_NAME, false ) 
  1180. 		set_attack_enemies_flag( SHAUNDI_REPAIR_VARIANT_NAME, false ) 
  1181.  
  1182. 		mission_help_table( ESCORT_SHAUNDI ) 
  1183. 		marker_add_trigger( STATION_EXIT_TRIGGER_NAMES[1], MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL ) 
  1184. 		audio_play_for_character( SHAUNDI_GO_TO_ROOF_LINE, SHAUNDI_REPAIR_VARIANT_NAME, "voice", false, false ) 
  1185.  
  1186. 		ss10_setup_exit_station_triggers() 
  1187.  
  1188. 	elseif ( new_state == MS_RETURN_TO_BASE ) then 
  1189. 		mission_help_table( GET_EQUIPMENT_BACK ) 
  1190.  
  1191. 		for index, trigger_name in pairs( SAINTS_HQ_TRIGGER_NAMES ) do 
  1192. 			trigger_enable( trigger_name, true ) 
  1193. 			on_trigger( "ss10_reached_hq", trigger_name ) 
  1194. 		end 
  1195.  
  1196. 		Mark_destination_thread_handle = thread_new( "ss10_update_marked_destination_location" ) 
  1197.  
  1198. 		Police_wave_spawn_enabled = false 
  1199. 		Swat_wave_spawn_enabled = false 
  1200.  
  1201. 		trigger_enable( SAINTS_PARKING_LOT_TRIGGER_NAME, true ) 
  1202. 		on_trigger( "ss10_reached_hideout_lot", SAINTS_PARKING_LOT_TRIGGER_NAME ) 
  1203.  
  1204. 		thread_new( "ss10_pierce_status_update" ) 
  1205. 	end 
  1206.  
  1207. 	State = new_state 
  1208. end 
  1209.  
  1210. function ss10_update_marked_destination_location() 
  1211.  
  1212. 	-- Returns whether or not the player with Shaundi is in a flying vehicle or not 
  1213. 	local function is_player_in_flying_vehicle() 
  1214. 		local player_vehicle_type = get_char_vehicle_type( LOCAL_PLAYER ) 
  1215. 		if ( player_vehicle_type == VT_AIRPLANE or 
  1216. 			  player_vehicle_type == VT_HELICOPTER ) then 
  1217. 			return true 
  1218. 		end 
  1219. 		return false 
  1220. 	end 
  1221.  
  1222. 	-- Find out which trigger to mark right now based on what vehicle the player's in 
  1223. 	local player_was_in_flying_vehicle = is_player_in_flying_vehicle() 
  1224. 	local trigger_to_mark = SAINTS_HQ_TRIGGER_NAMES[GROUND_HQ_TRIGGER_INDEX] 
  1225. 	if ( player_was_in_flying_vehicle ) then 
  1226. 		trigger_to_mark = SAINTS_HQ_TRIGGER_NAMES[AIR_HQ_TRIGGER_INDEX] 
  1227. 	end 
  1228. 	-- Mark it 
  1229. 	waypoint_add( trigger_to_mark, SYNC_ALL ) 
  1230. 	marker_add_trigger( trigger_to_mark, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_LOCATION, SYNC_ALL ) 
  1231.  
  1232. 	-- Keep going until the trigger is marked 
  1233. 	while ( true ) do 
  1234. 		-- Find out if the player is in a different vehicle now than they used to be 
  1235. 		local player_is_in_flying_vehicle = is_player_in_flying_vehicle() 
  1236. 		if ( player_was_in_flying_vehicle ~= player_is_in_flying_vehicle ) then 
  1237.  
  1238. 			-- If the vehicle is different, remove the old trigger marker and GPS path and add new ones to the new location 
  1239. 			if ( player_is_in_flying_vehicle ) then 
  1240. 				marker_remove_trigger( SAINTS_HQ_TRIGGER_NAMES[GROUND_HQ_TRIGGER_INDEX] ) 
  1241. 				marker_add_trigger( SAINTS_HQ_TRIGGER_NAMES[AIR_HQ_TRIGGER_INDEX], MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_LOCATION, SYNC_ALL ) 
  1242. 				waypoint_add( SAINTS_HQ_TRIGGER_NAMES[AIR_HQ_TRIGGER_INDEX] ) 
  1243. 			else 
  1244. 				marker_remove_trigger( SAINTS_HQ_TRIGGER_NAMES[AIR_HQ_TRIGGER_INDEX] ) 
  1245. 				marker_add_trigger( SAINTS_HQ_TRIGGER_NAMES[GROUND_HQ_TRIGGER_INDEX], MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_LOCATION, SYNC_ALL ) 
  1246. 				waypoint_add( SAINTS_HQ_TRIGGER_NAMES[GROUND_HQ_TRIGGER_INDEX] ) 
  1247. 			end 
  1248. 		end 
  1249.  
  1250. 		player_was_in_flying_vehicle = player_is_in_flying_vehicle 
  1251. 		delay( 1.0 ) 
  1252. 	end 
  1253. end 
  1254.  
  1255. function ss10_check_for_shaundi_vehicle_enter() 
  1256. 	repeat 
  1257. 		thread_yield() 
  1258. 	until ( character_is_in_vehicle_transation( SHAUNDI_REPAIR_VARIANT_NAME ) or 
  1259. 			  character_is_in_vehicle( SHAUNDI_REPAIR_VARIANT_NAME ) ) 
  1260.  
  1261. 	item_drop( PACKAGE_NAME, SHAUNDI_REPAIR_VARIANT_NAME ) 
  1262. 	item_hide( PACKAGE_NAME ) 
  1263.  
  1264. 	on_incapacitated( "", SHAUNDI_REPAIR_VARIANT_NAME ) 
  1265. 	on_revived( "", SHAUNDI_REPAIR_VARIANT_NAME ) 
  1266.  
  1267. 	npc_combat_enable( SHAUNDI_REPAIR_VARIANT_NAME, true ) 
  1268. 	set_attack_enemies_flag( SHAUNDI_REPAIR_VARIANT_NAME, true ) 
  1269. 	character_allow_ragdoll( SHAUNDI_REPAIR_VARIANT_NAME, true ) 
  1270. 	npc_dont_auto_equip_or_unequip_weapons( SHAUNDI_REPAIR_VARIANT_NAME, false ) 
  1271. end 
  1272.  
  1273. function ss10_shaundi_incapacitated_with_package() 
  1274. 	character_allow_ragdoll( SHAUNDI_REPAIR_VARIANT_NAME, true ) 
  1275. 	character_ragdoll( SHAUNDI_REPAIR_VARIANT_NAME, -1 ) 
  1276. end 
  1277.  
  1278. function ss10_shaundi_revived_with_package() 
  1279. 	item_wield( PACKAGE_NAME, SHAUNDI_REPAIR_VARIANT_NAME, false ) 
  1280. end 
  1281.  
  1282. function ss10_setup_shaundi_repair_variant() 
  1283. 	set_cant_flee_flag( SHAUNDI_REPAIR_VARIANT_NAME, true ) 
  1284. 	npc_weapon_pickup_override( SHAUNDI_REPAIR_VARIANT_NAME, false ) 
  1285. 	set_attack_enemies_flag( SHAUNDI_REPAIR_VARIANT_NAME, false ) 
  1286. 	npc_combat_enable( SHAUNDI_REPAIR_VARIANT_NAME, false ) 
  1287.  
  1288. 	character_set_walk_variant( SHAUNDI_REPAIR_VARIANT_NAME, "Walk Hacking" ) 
  1289. 	character_set_stand_variant( SHAUNDI_REPAIR_VARIANT_NAME, "Stand Ready Hacking" ) 
  1290. 	character_set_run_variant( SHAUNDI_REPAIR_VARIANT_NAME, "Run Hacking" ) 
  1291. end 
  1292.  
  1293. function ss10_notoriety_event_local() 
  1294. 	ss10_notoriety_event( LOCAL_PLAYER ) 
  1295. end 
  1296.  
  1297. function ss10_notoriety_event_remote() 
  1298. 	ss10_notoriety_event( REMOTE_PLAYER ) 
  1299. end 
  1300.  
  1301. function ss10_notoriety_event( player_name ) 
  1302. 	mission_debug( "notoriety event" ) 
  1303. 	if ( notoriety_get_decimal( POLICE_GANG ) > 0 ) then 
  1304. 		if ( ss10_player_in_station( player_name ) ) then 
  1305. 			ss10_police_station_alarm() 
  1306. 		end 
  1307. 	end 
  1308. end 
  1309.  
  1310.  
  1311. function ss10_don_disguise_conversation() 
  1312. 	audio_play_conversation( DON_DISGUISE_DIALOG_STREAM, NOT_CALL ) 
  1313. end 
  1314.  
  1315. function ss10_reached_hideout_lot( triggerer_name, trigger_name ) 
  1316. 	trigger_enable( trigger_name, false ) 
  1317.  
  1318. 	notoriety_force_no_spawn( POLICE_GANG, true ) 
  1319. 	notoriety_force_no_spawn( ULTOR_GANG, true ) 
  1320. end 
  1321.  
  1322. function ss10_create_and_setup_police_station_groups() 
  1323. 	group_create( RECEPTIONIST_GROUP_NAME, true ) 
  1324. 	for index, name in pairs( FLOOR_GROUP_NAMES ) do 
  1325. 		group_create( name, true ) 
  1326. 	end 
  1327.  
  1328. 	ss10_setup_ambient_officer_callbacks() 
  1329. end 
  1330.  
  1331. -- Mostly deals with the case of players acting evilly and killing the receptionist, 
  1332. -- though she might also die in other ways. 
  1333. -- 
  1334. function ss10_receptionist_died( victim, attacker ) 
  1335. 	mission_debug( "receptionist died" ) 
  1336. 	ss10_switch_state( MS_RUN_TO_CAMERA_ROOM ) 
  1337. end 
  1338.  
  1339. function ss10_pierce_status_update() 
  1340. 	delay( PIERCE_STATUS_UPDATE_DELAY_SECONDS ) 
  1341. 	audio_play_conversation( PIERCE_STATUS_UPDATE_DIALOG_STREAM, INCOMING_CALL ) 
  1342. end 
  1343.  
  1344. function ss10_past_lobby_after_checkin() 
  1345. 	mission_debug( "past lobby after checkin called" ) 
  1346. 	for index, name in pairs( PAST_LOBBY_TRIGGERS ) do 
  1347. 		trigger_enable( name, false ) 
  1348. 	end 
  1349.  
  1350. 	-- Have Shaundi warn the player there's not much time, but only if the 
  1351. 	-- cover hasn't been blown for some reason. 
  1352. 	if ( Alarm_set_off == false and notoriety_get( POLICE_GANG ) == 0 ) then 
  1353. 		audio_play_for_character( SHAUNDI_PAST_DESK_LINE, SHAUNDI_REPAIR_VARIANT_NAME, "voice", false, true ) 
  1354. 	end 
  1355. end 
  1356.  
  1357. function ss10_shaundi_dismissed() 
  1358. 	-- End the mission since Shaundi was dismissed 
  1359. 	mission_end_failure( MISSION_NAME, SHAUNDI_ABANDONED ) 
  1360. end 
  1361.  
  1362. function ss10_shaundi_follower_died() 
  1363. 	-- End the mission since Shaundi died 
  1364. 	mission_end_failure( MISSION_NAME, SHAUNDI_DIED ) 
  1365. end 
  1366.  
  1367. -- This function delays until both the local player and Shaundi are in a vehicle. 
  1368. -- At this point, it calls the "Left station" function. 
  1369. -- 
  1370. function ss10_delay_until_shaundi_and_player_enter_escape_vehicle() 
  1371. 	-- Wait until both the local player and Shaundi are in an escape vehicle 
  1372. 	-- before continuing 
  1373. 	while ( character_is_in_vehicle( SHAUNDI_REPAIR_VARIANT_NAME ) == false or 
  1374. 			  character_is_in_vehicle( LOCAL_PLAYER ) == false ) do 
  1375. 		delay( 1 ) 
  1376. 	end 
  1377.  
  1378. 	ss10_left_station() 
  1379. end 
  1380.  
  1381. function ss10_player_entered_vehicle_leaving_station() 
  1382. 	if ( Tracking_Shaundi_in_vehicle_thread_handle == INVALID_THREAD_HANDLE ) then 
  1383. 		Tracking_Shaundi_in_vehicle_thread_handle = thread_new( "ss10_delay_until_shaundi_and_player_enter_escape_vehicle" ) 
  1384. 	end 
  1385. end 
  1386.  
  1387. function ss10_setup_exit_station_triggers() 
  1388. 	on_vehicle_enter( "ss10_player_entered_vehicle_leaving_station", POLICE_STATION_HELICOPTER ) 
  1389. 	on_vehicle_enter( "ss10_player_entered_vehicle_leaving_station", REPAIR_VAN_NAME ) 
  1390. 	on_vehicle_enter( "ss10_player_entered_vehicle_leaving_station", LOCAL_PLAYER ) 
  1391.  
  1392. 	-- Add callbacks for exiting the station 
  1393. 	for index, trigger in pairs( STATION_EXIT_TRIGGER_NAMES ) do 
  1394. 		trigger_enable( trigger, true ) 
  1395. 		on_trigger( "ss10_left_station", trigger ) 
  1396. 	end 
  1397. end 
  1398.  
  1399. function ss10_disable_station_exit_triggers() 
  1400. 	on_vehicle_enter( "", POLICE_STATION_HELICOPTER ) 
  1401. 	on_vehicle_enter( "", REPAIR_VAN_NAME ) 
  1402. 	on_vehicle_enter( "", LOCAL_PLAYER ) 
  1403.  
  1404. 	for index, trigger in pairs( STATION_EXIT_TRIGGER_NAMES ) do 
  1405. 		trigger_enable( trigger, false ) 
  1406. 	end 
  1407. end 
  1408.  
  1409. function ss10_reached_hq( triggerer_name, trigger_name ) 
  1410. 	thread_kill( Mark_destination_thread_handle ) 
  1411.  
  1412. 	if ( triggerer_name == LOCAL_PLAYER ) then 
  1413. 		player_controls_disable( LOCAL_PLAYER ) 
  1414. 		vehicle_stop_do( LOCAL_PLAYER ) 
  1415. 		mission_end_success( MISSION_NAME, CT_OUTRO, { END_LOCAL_WARP, END_REMOTE_WARP } ) 
  1416. 	end 
  1417. end 
  1418.  
  1419. function ss10_left_station() 
  1420. 	if ( Tracking_Shaundi_in_vehicle_thread_handle ~= INVALID_THREAD_HANDLE ) then 
  1421. 		thread_kill( Tracking_Shaundi_in_vehicle_thread_handle ) 
  1422. 		Tracking_Shaundi_in_vehicle_thread_handle = INVALID_THREAD_HANDLE 
  1423. 	end 
  1424. 	ss10_disable_station_exit_triggers() 
  1425. 	ss10_switch_state( MS_RETURN_TO_BASE ) 
  1426. end 
  1427.  
  1428. function ss10_shaundi_incapacitated() 
  1429. 	character_allow_ragdoll( SHAUNDI_REPAIR_VARIANT_NAME, true ) 
  1430. 	character_ragdoll( SHAUNDI_REPAIR_VARIANT_NAME, -1 ) 
  1431. 	--hud_timer_pause(0, true ) 
  1432.  
  1433. 	-- She was knocked out while hacking, so she's 
  1434. 	-- stopped for now. 
  1435. 	Shaundi_hacking = false 
  1436. end 
  1437.  
  1438. function ss10_shaundi_revived() 
  1439. 	ss10_setup_shaundi_hacking_state() 
  1440. 	--hud_timer_pause(0, false ) 
  1441. end 
  1442.  
  1443. -- Returns the name of the attack wave location group at the specified index. 
  1444. -- 
  1445. function ss10_get_wave_location_group_name( location_index ) 
  1446. 	return WAVE_LOCATION_NAME_PREFIX..location_index..WAVE_LOCATION_NAME_SUFFIX 
  1447. end 
  1448.  
  1449. -- Returns the name of the coop attack wave location group at the specified index. 
  1450. -- 
  1451. function ss10_get_coop_wave_location_group_name( location_index ) 
  1452. 	return WAVE_LOCATION_NAME_PREFIX..location_index..WAVE_LOCATION_NAME_COOP_SUFFIX 
  1453. end 
  1454.  
  1455. -- Creates a list of attackers at the specified location index. 
  1456. -- Creates both coop and normal attackers, returns them as 
  1457. -- attackers, coop_attackers 
  1458. -- 
  1459. function ss10_create_attacker_names( location_index ) 
  1460. 	local cur_attacker_names = {} 
  1461. 	local cur_coop_attacker_names = {} 
  1462.  
  1463. 	for attacker_index = 1, NUM_WAVE_ATTACKERS[location_index] do 
  1464. 		cur_attacker_names[attacker_index] = WAVE_ATTACKER_NAME_LOCATION_PREFIX..location_index..WAVE_ATTACKER_NAME_INDEX_PREFIX..attacker_index 
  1465. 	end 
  1466.  
  1467. 	if ( coop_is_active() ) then 
  1468. 		for attacker_index = 1, NUM_COOP_WAVE_ATTACKERS[location_index] do 
  1469. 			cur_coop_attacker_names[attacker_index] = WAVE_ATTACKER_NAME_LOCATION_PREFIX..location_index..WAVE_ATTACKER_COOP_NAME_INDEX_PREFIX..attacker_index 
  1470. 		end 
  1471. 	end 
  1472.  
  1473. 	return cur_attacker_names, cur_coop_attacker_names 
  1474. end 
  1475.  
  1476. -- Called to spawn the first wave. 
  1477. -- Should only be called once. 
  1478. -- 
  1479. function ss10_spawn_first_wave() 
  1480. 	Current_wave_spawn_location = 1 
  1481. 	Wave_attack_started = true 
  1482. 	ss10_spawn_location_attackers_and_attack( Current_wave_spawn_location ) 
  1483. end 
  1484.  
  1485. -- Called to spawn subsequent waves after the first wave. 
  1486. -- Handles all cleanup and location incrementing. 
  1487. -- 
  1488. function ss10_spawn_next_wave() 
  1489. 	ss10_update_location_index() 
  1490. 	ss10_release_current_location_attackers() 
  1491. 	ss10_spawn_location_attackers_and_attack( Current_wave_spawn_location ) 
  1492. end 
  1493.  
  1494. -- Releases the attack group at the current location index. 
  1495. -- Completely safe to call at any time, because it checks 
  1496. -- for group existance before it releases them. 
  1497. -- 
  1498. function ss10_release_current_location_attackers() 
  1499. 	-- Release the old wave 
  1500. 	local cur_location_name = ss10_get_wave_location_group_name( Current_wave_spawn_location ) 
  1501. 	if ( group_is_loaded( cur_location_name ) ) then 
  1502. 		mission_debug( "Releasing "..cur_location_name, 15 ) 
  1503. 		release_to_world( cur_location_name ) 
  1504. 	end 
  1505. 	if ( coop_is_active() ) then 
  1506. 		local cur_coop_location_name = ss10_get_coop_wave_location_group_name( Current_wave_spawn_location ) 
  1507. 		if ( group_is_loaded( cur_coop_location_name ) ) then 
  1508. 			mission_debug( "Releasing "..cur_coop_location_name, 15 ) 
  1509. 			release_to_world( cur_coop_location_name ) 
  1510. 		end 
  1511. 	end 
  1512. end 
  1513.  
  1514. -- Spawns attackers at a location and has them attack. 
  1515. --  
  1516. -- location_index: The location to spawn. 
  1517. -- 
  1518. function ss10_spawn_location_attackers_and_attack( location_index ) 
  1519.  
  1520. 	-- Get the group names and create the groups 
  1521. 	local cur_location_group_name = ss10_get_wave_location_group_name( location_index ) 
  1522. 	group_create( cur_location_group_name, true ) 
  1523. 	Num_wave_members_remaining = 0 
  1524.  
  1525. 	-- Do this for coop as well 
  1526. 	local cur_coop_location_group_name = nil 
  1527. 	if ( coop_is_active() ) then 
  1528. 		cur_coop_location_group_name = ss10_get_coop_wave_location_group_name( location_index ) 
  1529. 		group_create( cur_coop_location_group_name, true ) 
  1530. 	end 
  1531.  
  1532. 	-- Get the attacker names 
  1533. 	local cur_attacker_names = {} 
  1534. 	local cur_coop_attacker_names = {} 
  1535.  
  1536. 	cur_attacker_names, cur_coop_attacker_names = ss10_create_attacker_names( location_index ) 
  1537.  
  1538. 	local percent_with_shotguns = WAVE_SHOTGUN_DISTRIBUTION( Num_waves_defeated + 1 ) 
  1539. 	local number_with_shotguns = percent_with_shotguns * NUM_WAVE_ATTACKERS[location_index] + 
  1540. 					  percent_with_shotguns * NUM_COOP_WAVE_ATTACKERS[location_index] 
  1541. 	local number_given_shotguns = 0 
  1542.  
  1543. 	-- Have all the attackers attack, and setup their 'on_death' functions so that we can 
  1544. 	-- keep track of how many remain. 
  1545. 	for index, member in pairs( cur_attacker_names ) do 
  1546. 		on_death( "ss10_wave_member_death", member ) 
  1547.  
  1548. 		inv_item_remove_all( member ) 
  1549.  
  1550. 		inv_item_add( POLICE_PISTOL_NAME, 1, member ) 
  1551. 		inv_item_add_ammo( member, POLICE_PISTOL_NAME, POLICE_PISTOL_AMMO_COUNT ) 
  1552.  
  1553. 		if ( number_given_shotguns < number_with_shotguns ) then 
  1554. 			inv_item_add( POLICE_SHOTGUN_NAME, 1, member ) 
  1555. 			inv_item_add_ammo( member, POLICE_SHOTGUN_NAME, POLICE_SHOTGUN_AMMO_COUNT ) 
  1556. 			number_given_shotguns = number_given_shotguns + 1 
  1557. 		end 
  1558.  
  1559. 		local distance, player_name = get_dist_closest_player_to_object(member) 
  1560. 		attack_safe( member, player_name, false ) 
  1561.  
  1562. 		Num_wave_members_remaining = Num_wave_members_remaining + 1 
  1563. 	end 
  1564.  
  1565. 	-- Do the same thing for coop 
  1566. 	if ( coop_is_active() ) then 
  1567. 		for index, member in pairs( cur_coop_attacker_names ) do 
  1568. 			on_death( "ss10_wave_member_death", member ) 
  1569.  
  1570. 			inv_item_remove_all( member ) 
  1571.  
  1572. 			inv_item_add( POLICE_PISTOL_NAME, 1, member ) 
  1573. 			inv_item_add_ammo( member, POLICE_PISTOL_NAME, POLICE_PISTOL_AMMO_COUNT ) 
  1574. 			if ( number_given_shotguns < number_with_shotguns ) then 
  1575. 				inv_item_add( POLICE_SHOTGUN_NAME, 1, member ) 
  1576. 				inv_item_add_ammo( member, POLICE_SHOTGUN_NAME, POLICE_SHOTGUN_AMMO_COUNT ) 
  1577. 				number_given_shotguns = number_given_shotguns + 1 
  1578. 			end 
  1579.  
  1580. 			local distance, player_name = get_dist_closest_player_to_object(member) 
  1581. 			attack_safe( member, player_name, false ) 
  1582.  
  1583. 			Num_wave_members_remaining = Num_wave_members_remaining + 1 
  1584. 		end 
  1585. 	end 
  1586. end 
  1587.  
  1588. -- Updates the current location index used for spawning. 
  1589. -- Rolls over correctly so that it doesn't go over the 
  1590. -- max number of locations. 
  1591. -- 
  1592. function ss10_update_location_index() 
  1593. 	-- Go through each of the locations in turn, rolling over to 1 
  1594. 	-- when running out 
  1595. 	Current_wave_spawn_location = Current_wave_spawn_location + 1 
  1596. 	local num_spawn_locations = sizeof_table( NUM_WAVE_ATTACKERS ) 
  1597. 	if ( Current_wave_spawn_location > num_spawn_locations ) then 
  1598. 		Current_wave_spawn_location = 1 
  1599. 	end 
  1600. end 
  1601.  
  1602. -- Callback for a wave member dying. Updates the number left and 
  1603. -- updates the number of waves defeated and spawns a new wave if 
  1604. -- all members are dead. 
  1605. -- 
  1606. function ss10_wave_member_death() 
  1607. 	-- Update the number of members left 
  1608. 	Num_wave_members_remaining = Num_wave_members_remaining - 1 
  1609.  
  1610. 	-- If no more wave members survive, spawn members at another location. 
  1611. 	if ( Num_wave_members_remaining == 0 ) then 
  1612. 		if ( Police_wave_spawn_enabled ) then 
  1613. 			Num_waves_defeated = Num_waves_defeated + 1 
  1614. 			ss10_spawn_next_wave() 
  1615. 		-- If swat waves are enabled, then start them instead 
  1616. 		elseif ( Swat_wave_spawn_enabled ) then 
  1617. 			ss10_spawn_next_swat_wave() 
  1618. 		end 
  1619. 	end 
  1620.  
  1621. end 
  1622.  
  1623. -- Spawns another wave of swat attackers and has them attack the player. 
  1624. -- 
  1625. function ss10_spawn_next_swat_wave() 
  1626. 	Current_wave_spawn_location = Current_wave_spawn_location + 1 
  1627. 	if ( Current_wave_spawn_location > sizeof_table( SWAT_ATTACKERS_GROUP_NAMES ) ) then 
  1628. 		Current_wave_spawn_location = 1 
  1629. 	end 
  1630.  
  1631. 	ss10_spawn_swat_wave() 
  1632. end 
  1633.  
  1634. function ss10_spawn_swat_wave() 
  1635. 	local wave_group = SWAT_ATTACKERS_GROUP_NAMES[Current_wave_spawn_location] 
  1636.  
  1637. 	if ( group_is_loaded( wave_group ) ) then 
  1638. 		release_to_world( wave_group ) 
  1639. 	end 
  1640. 	group_create( wave_group, true ) 
  1641.  
  1642. 	local wave_members = SWAT_ATTACKER_NAMES[Current_wave_spawn_location] 
  1643.  
  1644. 	for index, member in pairs( wave_members ) do 
  1645. 		on_death( "ss10_wave_member_death", member ) 
  1646.  
  1647. 		attack_closest_player( member ) 
  1648.  
  1649. 		Num_wave_members_remaining = Num_wave_members_remaining + 1 
  1650. 	end 
  1651. end 
  1652.  
  1653. -- This function is an internal timer that counts down to the player's ruse 
  1654. -- being 'discovered.' 
  1655. -- When that happens, this function calls 'ss10_police_station_alarm.' 
  1656. -- 
  1657. function ss10_player_ruse_discovered_timer( time_seconds ) 
  1658. 	-- Use PLAYER_RUSE_DISCOVERED_SECONDS unless we've been given an override. 
  1659. 	local player_ruse_discovered_countdown_seconds = PLAYER_RUSE_DISCOVERED_SECONDS 
  1660. 	if ( time_seconds ~= nil ) then 
  1661. 		player_ruse_discovered_countdown_seconds = time_seconds 
  1662. 	end 
  1663.  
  1664. 	delay( player_ruse_discovered_countdown_seconds ) 
  1665.  
  1666. 	-- The timer's elapsed, call the 'discovered' function. 
  1667. 	ss10_police_station_alarm() 
  1668. end 
  1669.  
  1670. function ss10_swat_heli_spawn() 
  1671. 	--delay( SWAT_SQUAD_SPAWN_DELAY_TIME_SECONDS ) 
  1672.  
  1673. 	mission_debug( "swat heli spawn called" ) 
  1674.  
  1675. 	group_create( SWAT_HELI_DROPOFF_GROUP_NAME, true ) 
  1676. 	vehicle_enter_group_teleport( SWAT_HELI_SEATING, SWAT_HELI ) 
  1677.  
  1678. 	mission_debug( "swat heli squad flying" ) 
  1679. 	helicopter_fly_to_direct( SWAT_HELI, SWAT_HELI_DROPOFF_PATH ) 
  1680.  
  1681. 	for index, member_name in pairs( SWAT_HELI_DROPOFF_SQUAD_MEMBERS ) do 
  1682. 		vehicle_exit( member_name ) 
  1683. 		attack_closest_player( member_name ) 
  1684. 	end 
  1685.  
  1686. 	mission_debug( "swat heli squad deployed" ) 
  1687. 	helicopter_fly_to_direct( SWAT_HELI, SWAT_HELI_RETURN_PATH ) 
  1688. 	vehicle_hide( SWAT_HELI ) 
  1689. 	release_to_world( SWAT_HELI_DROPOFF_GROUP_NAME ) 
  1690. 	mission_debug( "swat heli spawn ending" ) 
  1691. end 
  1692.  
  1693. -- This function has a delay, but only counts down the delay when Shaundi 
  1694. -- is actively hacking. 
  1695. -- 
  1696. -- time_to_delay: The amount of time to delay 
  1697. -- num_divisions: The time is divided into these divisions. When Shaundi stops 
  1698. --					 hacking ( for example, is knocked out ) the most time that will 
  1699. --					 count down is time_to_delay / num_divisions before the 
  1700. --					 countdown pauses until she's hacking again. 
  1701. -- 
  1702. function ss10_delay_while_shaundi_hacking( time_to_delay, num_divisions ) 
  1703. 	for i = 1, num_divisions do 
  1704. 		local time_chunk = time_to_delay / num_divisions 
  1705. 		delay( time_chunk ) 
  1706. 		while ( Shaundi_hacking == false ) do 
  1707. 			delay( 0 ) 
  1708. 		end 
  1709. 	end 
  1710. end 
  1711.  
  1712. function ss10_shaundi_hacking_timer() 
  1713. 	local time_delayed_seconds = 0 
  1714. 	local time_chunk = TOTAL_HACKING_TIME_VALUE_SECONDS / NUM_HACKING_TIME_DIVISIONS 
  1715. 	local lines_played = { [SHAUNDI_HACK20P_LINE] = false, [SHAUNDI_HACK50P_LINE] = false, 
  1716. 								  [SHAUNDI_HACK75P_LINE] = false } 
  1717. 	local heli_spawned = false 
  1718.  
  1719. 	for i = 1, NUM_HACKING_TIME_DIVISIONS do 
  1720. 		delay( time_chunk ) 
  1721. 		time_delayed_seconds = time_delayed_seconds + time_chunk 
  1722.  
  1723. 		if ( time_delayed_seconds / TOTAL_HACKING_TIME_VALUE_SECONDS >= 0.20 and 
  1724. 			  lines_played[SHAUNDI_HACK20P_LINE] == false ) then 
  1725. 			audio_play_for_character( SHAUNDI_HACK20P_LINE, SHAUNDI_REPAIR_VARIANT_NAME, "voice", false, false ) 
  1726. 			lines_played[SHAUNDI_HACK20P_LINE] = true 
  1727. 		end 
  1728. 		if ( time_delayed_seconds / TOTAL_HACKING_TIME_VALUE_SECONDS >= 0.50 and 
  1729. 			  lines_played[SHAUNDI_HACK50P_LINE] == false ) then 
  1730. 			audio_play_for_character( SHAUNDI_HACK50P_LINE, SHAUNDI_REPAIR_VARIANT_NAME, "voice", false, false ) 
  1731. 			lines_played[SHAUNDI_HACK50P_LINE] = true 
  1732. 		end 
  1733. 		if ( time_delayed_seconds / TOTAL_HACKING_TIME_VALUE_SECONDS >= 0.75 and 
  1734. 			  lines_played[SHAUNDI_HACK75P_LINE] == false ) then 
  1735. 			audio_play_for_character( SHAUNDI_HACK75P_LINE, SHAUNDI_REPAIR_VARIANT_NAME, "voice", false, false ) 
  1736. 			lines_played[SHAUNDI_HACK75P_LINE] = true 
  1737. 		end 
  1738.  
  1739. 		if ( time_delayed_seconds > SWAT_HELI_GROUP_SPAWN_THREAD_DELAY_SECONDS and 
  1740. 			  heli_spawned == false ) then 
  1741. 			thread_new( "ss10_swat_heli_spawn" ) 
  1742. 			heli_spawned = true 
  1743. 		end 
  1744.  
  1745. 		if ( time_delayed_seconds > SWITCH_TO_SWAT_SPAWN_TIME_DELAY_SECONDS and 
  1746. 			  Swat_wave_spawn_enabled == false ) then 
  1747. 			Police_wave_spawn_enabled = false 
  1748. 			Swat_wave_spawn_enabled = true 
  1749. 		end 
  1750.  
  1751. 		while ( Shaundi_hacking == false ) do 
  1752. 			delay( 0 ) 
  1753. 		end 
  1754. 	end 
  1755. 	ss10_hacking_complete() 
  1756. end 
  1757.  
  1758. -- Called when the HUD hacking timer, after being set to 
  1759. -- FINAL_HACKING_TIMER_VALUE_MS, expires. 
  1760. -- 
  1761. function ss10_hacking_complete() 
  1762. 	ss10_switch_state( MS_LEAVE_STATION ) 
  1763. end 
  1764.  
  1765. -- This function sets off the alarm and causes the police to 
  1766. -- attack the player. 
  1767. -- 
  1768. function ss10_police_station_alarm( was_doing_ruse ) 
  1769. 	-- Assume by default that the player was doing the ruse 
  1770. 	-- when the function was called 
  1771. 	if( was_doing_ruse == nil ) then 
  1772. 		was_doing_ruse = true 
  1773. 	end 
  1774. 	on_notoriety_event( "", LOCAL_PLAYER ) 
  1775. 	if ( coop_is_active() ) then 
  1776. 		on_notoriety_event( "", REMOTE_PLAYER ) 
  1777. 	end 
  1778.  
  1779. 	-- The disguise doesn't matter now that the alarm has gone off 
  1780. 	trigger_type_enable("clothing store", true) 
  1781. 	trigger_type_enable("crib clothing", true) 
  1782.  
  1783. 	-- Clear all the cases where the alarm could be set off again 
  1784. 	on_death( "", RECEPTIONIST_NAME ) 
  1785. 	if ( Player_ruse_thread_handle ~= INVALID_THREAD_HANDLE ) then 
  1786. 		thread_kill( Player_ruse_thread_handle ) 
  1787. 		Player_ruse_thread_handle = INVALID_THREAD_HANDLE 
  1788. 	end 
  1789. 	if ( Track_weapon_thread_handle ~= INVALID_THREAD_HANDLE ) then 
  1790. 		thread_kill( Track_weapon_thread_handle ) 
  1791. 		Track_weapon_thread_handle = INVALID_THREAD_HANDLE 
  1792. 	end 
  1793. 	trigger_enable( RECEPTIONIST_DESK_CHECKIN_TRIGGER_NAME, false ) 
  1794.  
  1795. 	-- Play the alarm! 
  1796. 	audio_play_for_navpoint( "SFX_POLICE_ALARM", ALARM_ORIGIN ) 
  1797. 	Alarm_set_off = true 
  1798.  
  1799. 	-- Don't lower the notoriety, but raise it if necessary 
  1800. 	if ( notoriety_get( POLICE_GANG ) < MISSION_POST_ALARM_NOTORIETY ) then 
  1801. 		notoriety_set( POLICE_GANG, MISSION_POST_ALARM_NOTORIETY ) 
  1802. 	end 
  1803. 	notoriety_set_min( POLICE_GANG, MISSION_POST_ALARM_NOTORIETY ) 
  1804.  
  1805. 	-- If the player was doing the ruse 
  1806. 	if ( was_doing_ruse == true ) then 
  1807. 		-- Shaundi isn't hacking yet, so let the player know that 
  1808. 		-- she needs to start 
  1809. 		if ( Shaundi_has_started_hacking == false ) then 
  1810. 			--mission_help_table_nag( RUSE_BLOWN ) 
  1811. 		-- Shaundi is hacking - she lets the player know to defend her 
  1812. 		else 
  1813. 		end 
  1814. 	-- Otherwise, the player isn't doing the ruse at all. Let him know 
  1815. 	-- to get to the terminal. 
  1816. 	else 
  1817. 		delay( 5.0 ) 
  1818. 		mission_help_table( GET_TO_TERMINAL ) 
  1819. 		--notoriety_set_min( POLICE_GANG, FRONTAL_ASSAULT_NOTORIETY ) 
  1820. 	end 
  1821.  
  1822. 	thread_new( "ss10_begin_ambient_attack" ) 
  1823. 	--thread_new( "ss10_notoriety_increase" ) 
  1824. end 
  1825.  
  1826. -- Increases the player's notoriety to max over a period of time. 
  1827. -- 
  1828. function ss10_notoriety_increase() 
  1829. 	local increments = 300 
  1830. 	local increase_segment_seconds = TOTAL_HACKING_TIME_VALUE_SECONDS / increments 
  1831. 	local notoriety_increase_per_increment = MAX_NOTORIETY_LEVEL / increments 
  1832.  
  1833. 	for i = 1, increments do 
  1834. 		delay( increase_segment_seconds ) 
  1835. 		local cur_notoriety = notoriety_get_decimal( POLICE_GANG ) 
  1836. 		local new_notoriety = cur_notoriety + notoriety_increase_per_increment 
  1837. 		if ( new_notoriety > MAX_NOTORIETY_LEVEL ) then 
  1838. 			new_notoriety = MAX_NOTORIETY_LEVEL 
  1839. 		end 
  1840. 		notoriety_set( POLICE_GANG, new_notoriety ) 
  1841. 		notoriety_set_min( POLICE_GANG, new_notoriety ) 
  1842. 	end 
  1843. end 
  1844.  
  1845. function ss10_went_past_desk_before_checking_in() 
  1846. 	-- TODO: Warn the player that he has to check in first! 
  1847. 	mission_help_table( CHECK_IN_AT_DESK ) 
  1848. end 
  1849.  
  1850. function ss10_entered_entrance_before_checking_in() 
  1851. 	ss10_switch_state( MS_RUN_TO_CAMERA_ROOM ) 
  1852. end 
  1853.  
  1854. function ss10_all_players_in_repair_van() 
  1855. 	if ( Players_in_repair_van[LOCAL_PLAYER] ) then 
  1856. 		if ( coop_is_active() ) then 
  1857. 			if ( Players_in_repair_van[REMOTE_PLAYER] ) then 
  1858. 				return true 
  1859. 			end 
  1860. 		else 
  1861. 			return true 
  1862. 		end 
  1863. 	end 
  1864.  
  1865. 	return false 
  1866. end 
  1867.  
  1868. -- Returns true if the specified player is in the police station 
  1869. -- with a weapon equipped. 
  1870. -- 
  1871. function ss10_player_has_weapon_equipped_in_station( player_name ) 
  1872. 	local player_item = inv_item_get_equipped_item( player_name ) 
  1873.  
  1874. 	if ( player_item ~= nil ) then 
  1875. 		if ( ss10_player_in_station( player_name ) ) then 
  1876. 			return true 
  1877. 		end 
  1878. 	end 
  1879.  
  1880. 	return false 
  1881. end 
  1882.  
  1883. -- Tracks if either player equips a weapon while in the station. 
  1884. -- 
  1885. function ss10_track_weapon_equipped() 
  1886. 	local cover_blown = false 
  1887.  
  1888. 	while ( cover_blown == false ) do 
  1889. 		if ( ss10_player_has_weapon_equipped_in_station( LOCAL_PLAYER ) and Signing_in == false ) then 
  1890. 			cover_blown = true 
  1891. 		end 
  1892.  
  1893. 		if ( coop_is_active() ) then 
  1894. 			if ( ss10_player_has_weapon_equipped_in_station( REMOTE_PLAYER ) and Signing_in == false ) then 
  1895. 				cover_blown = true 
  1896. 			end 
  1897. 		end 
  1898.  
  1899. 		delay( ITEM_CHECK_DELAY_SECONDS ) 
  1900. 	end 
  1901.  
  1902. 	ss10_police_station_alarm() 
  1903. end 
  1904.  
  1905. -- Creates and spawns the repair van and the repair men. 
  1906. -- Additionally, seats the repair men in the van, and does 
  1907. -- other setup of the vehicle itself. 
  1908. -- 
  1909. function ss10_create_repair_van_group() 
  1910. 	group_create( REPAIR_VAN_AND_REPAIRMEN_GROUP_NAME ) 
  1911. 	Initial_van_hp = get_current_hit_points( REPAIR_VAN_NAME ) * VAN_HP_MULTIPLIER 
  1912. 	set_max_hit_points( REPAIR_VAN_NAME, Initial_van_hp ) 
  1913. 	set_current_hit_points( REPAIR_VAN_NAME, Initial_van_hp ) 
  1914. 	 
  1915. 	vehicle_enter_teleport( REPAIR_MAN_NAME, REPAIR_VAN_NAME ) 
  1916. 	vehicle_suppress_npc_exit( REPAIR_VAN_NAME, true ) 
  1917. end 
  1918.  
  1919. function ss10_create_floor_trigger_names() 
  1920. 	local increment = 1 
  1921.  
  1922. 	for floor_index, floor_trigger_count in pairs( FLOOR_TRIGGER_COUNTS ) do 
  1923. 		for trigger_index = 1, floor_trigger_count, increment do 
  1924. 			local trigger_name = FLOOR_PREFIX..floor_index 
  1925. 			if ( trigger_index < 10 ) then 
  1926. 				trigger_name = trigger_name..FLOOR_END_SINGLE_DIGIT_PREFIX..trigger_index 
  1927. 			else 
  1928. 				trigger_name = trigger_name..FLOOR_END_DOUBLE_DIGIT_PREFIX..trigger_index 
  1929. 			end 
  1930. 			Floor_trigger_names[floor_index][trigger_index] = trigger_name 
  1931. 		end 
  1932. 	end 
  1933. end 
  1934.  
  1935. function ss10_set_activate_floor_triggers_and_set_callbacks( floor_index, enabled, callback_name ) 
  1936. 	local increment = 1 
  1937.  
  1938. 	if ( FLOOR_TRIGGER_COUNTS[floor_index] ~= nil ) then 
  1939. 		for trigger_index = 1, FLOOR_TRIGGER_COUNTS[floor_index], increment do 
  1940. 			local trigger_name = Floor_trigger_names[floor_index][trigger_index] 
  1941. 			trigger_enable( trigger_name, enabled ) 
  1942. 			on_trigger( callback_name, trigger_name ) 
  1943. 		end 
  1944. 	end 
  1945. end 
  1946.  
  1947. function ss10_floor_trigger_callback( triggerer_name, trigger_name ) 
  1948. 	if ( triggerer_name == LOCAL_PLAYER ) then 
  1949. 		Cur_floor_index = Cur_floor_index + 1 
  1950. 		local next_floor_index = Cur_floor_index + 1 
  1951.  
  1952. 		-- Let the player know the floor they're on 
  1953. 		mission_help_table_nag( FLOOR_INDEX, Cur_floor_index ) 
  1954.  
  1955. 		-- The trigger we just hit ( and the other triggers on the same floor ) 
  1956. 		-- were previously on the next floor. Now we're on their floor, the current floor, so we disable 
  1957. 		-- the current floor's triggers and add the triggers for the next floor. 
  1958. 		ss10_set_activate_floor_triggers_and_set_callbacks( Cur_floor_index, false, "" ) 
  1959. 		ss10_set_activate_floor_triggers_and_set_callbacks( next_floor_index, true, "ss10_floor_trigger_callback" ) 
  1960.  
  1961. 		if ( Cur_floor_index == CAMERA_ROOM_FLOOR ) then 
  1962. 			marker_remove_navpoint( FOURTH_FLOOR_LOCATION_NAVPOINT_NAME ) 
  1963.  
  1964. 			trigger_enable( CAMERA_ROOM_DOOR_TRIGGER, true ) 
  1965. 			on_trigger( "ss10_reached_camera_room", CAMERA_ROOM_DOOR_TRIGGER ) 
  1966. 			marker_add_trigger( CAMERA_ROOM_DOOR_TRIGGER, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL ) 
  1967. 		end 
  1968. 	end 
  1969. end 
  1970.  
  1971. function ss10_reached_camera_room( triggerer_name, trigger_name ) 
  1972. 	-- Only trigger for the player that has Shaundi as a party member 
  1973. 	if ( triggerer_name == LOCAL_PLAYER ) then 
  1974. 		trigger_enable( trigger_name, false ) 
  1975.  
  1976. 		-- Shaundi should start hacking now 
  1977. 		ss10_begin_hacking_state() 
  1978. 	end 
  1979. end 
  1980.  
  1981. function ss10_shaundi_abandoned_delay() 
  1982. 	mission_help_table_nag( ABANDONING_SHAUNDI, "", "", SYNC_LOCAL ) 
  1983. 	delay( TIME_BEFORE_SHAUNDI_ABANDONED_SECONDS ) 
  1984.  
  1985. 	mission_end_failure( MISSION_NAME, SHAUNDI_ABANDONED ) 
  1986. end 
  1987.  
  1988. function ss10_maybe_kill_shaundi_abandoned_thread() 
  1989. 	if ( Shaundi_abandoned_thread ~= INVALID_THREAD_HANDLE ) then 
  1990. 		thread_kill( Shaundi_abandoned_thread ) 
  1991. 		Shaundi_abandoned_thread = INVALID_THREAD_HANDLE 
  1992. 	end 
  1993. end 
  1994.  
  1995. function ss10_in_range_of_shaundi( player_name ) 
  1996. 	if ( player_name == LOCAL_PLAYER ) then 
  1997. 		mission_help_clear( SYNC_LOCAL ) 
  1998. 		ss10_maybe_kill_shaundi_abandoned_thread() 
  1999. 	end 
  2000. end 
  2001.  
  2002. function ss10_out_of_range_of_shaundi( player_name ) 
  2003. 	if ( player_name == LOCAL_PLAYER ) then 
  2004. 		Shaundi_abandoned_thread = thread_new( "ss10_shaundi_abandoned_delay" ) 
  2005. 	end 
  2006. end 
  2007.  
  2008. function ss10_setup_shaundi_hacking_state() 
  2009. 	Shaundi_has_started_hacking = true 
  2010. 	follower_make_independent( SHAUNDI_REPAIR_VARIANT_NAME, true ) 
  2011. 	on_incapacitated( "ss10_shaundi_incapacitated", SHAUNDI_REPAIR_VARIANT_NAME ) 
  2012. 	on_revived( "ss10_shaundi_revived", SHAUNDI_REPAIR_VARIANT_NAME ) 
  2013. 	character_prevent_flinching( SHAUNDI_REPAIR_VARIANT_NAME, true ) 
  2014. 	set_cant_flee_flag( SHAUNDI_REPAIR_VARIANT_NAME, true ) 
  2015. 	npc_weapon_pickup_override( SHAUNDI_REPAIR_VARIANT_NAME, false ) 
  2016. 	character_allow_ragdoll( SHAUNDI_REPAIR_VARIANT_NAME, false ) 
  2017. 	set_ignore_ai_flag( SHAUNDI_REPAIR_VARIANT_NAME, true ) 
  2018.  
  2019. 	move_to( SHAUNDI_REPAIR_VARIANT_NAME, HACKING_LOCATION_NAME, 2, true, false ) 
  2020. 	delay( 1.0 ) 
  2021.  
  2022. 	--name, anim_name, morph_name, force_play, percentage, stand_still) 
  2023. 	action_play( SHAUNDI_REPAIR_VARIANT_NAME, "stand to Hacking", "", true, 0.8, true ) 
  2024. 	set_animation_state( SHAUNDI_REPAIR_VARIANT_NAME, STATE_HACK_CAMERA_ROOM ) 
  2025. 	audio_play_for_character( "SFX_POLICE_CAMERA_ACTIVATE", SHAUNDI_REPAIR_VARIANT_NAME ) 
  2026. 	Shaundi_hacking = true 
  2027. end 
  2028.  
  2029. function ss10_begin_hacking_state() 
  2030. 	ss10_setup_shaundi_hacking_state() 
  2031. 	ss10_switch_state( MS_DEFEND_CAMERA_ROOM ) 
  2032. end 
  2033.  
  2034. --function receptionist_chair_moved() 
  2035. 	-- Do something logical here. 
  2036. --end 
  2037.  
  2038. function ss10_reached_stairway( triggerer_name, trigger_name ) 
  2039. 	-- The local player has Shaundi, so don't actually disable the 
  2040. 	-- stairway guidance or enable the further guidance until he 
  2041. 	-- gets to the stairway. 
  2042. 	if ( triggerer_name == LOCAL_PLAYER ) then 
  2043. 		-- Activate the path triggers 
  2044. 		ss10_create_floor_trigger_names() 
  2045. 		-- Activate the triggers on the second floor. 
  2046. 		ss10_set_activate_floor_triggers_and_set_callbacks( 2, true, "ss10_floor_trigger_callback" ) 
  2047. 		for index, trigger in pairs( STAIRWAY_TRIGGER_NAMES ) do 
  2048. 			trigger_enable( trigger, false ) 
  2049. 		end 
  2050.  
  2051. 		marker_remove_navpoint( STAIRWAY_GUIDE_NAVPOINT_NAME ) 
  2052.  
  2053. 		marker_add_navpoint( FOURTH_FLOOR_LOCATION_NAVPOINT_NAME, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_LOCAL ) 
  2054. 	end 
  2055. end 
  2056.  
  2057. -- Callback when the player first gets within hijack range of the van. 
  2058. -- Puts the mission into the "Hijack the Van" state 
  2059. -- 
  2060. function ss10_reached_van_initial() 
  2061. 	ss10_switch_state( MS_HIJACK_REPAIR_VAN ) 
  2062. end 
  2063.  
  2064. function ss10_initialize_hud_bar() 
  2065. 	hud_bar_on(0, "Damage", VAN_DAMAGE_BAR_LABEL ) 
  2066. 	local full_value = REPAIR_VAN_PERCENT_DAMAGE_TO_DISABLE 
  2067. 	local min_value = 0 
  2068. 	hud_bar_set_range(0, min_value, full_value, SYNC_ALL ) 
  2069. 	hud_bar_set_value(0, min_value, SYNC_ALL ) 
  2070. end 
  2071.  
  2072. -- Callback when the player gets back into a good distance from 
  2073. -- the van after getting there and then falling away again. 
  2074. -- Puts the mission into the "Reached repairmen again" state 
  2075. -- 
  2076. function ss10_good_distance() 
  2077. 	ss10_switch_state( MS_REACHED_REPAIRMEN_AGAIN ) 
  2078. end 
  2079.  
  2080. -- Callback when the player falls out of range of the van after 
  2081. -- getting in range at least once. 
  2082. -- Puts the mission into the "Repairmen Escaping" state 
  2083. -- 
  2084. function ss10_van_escaping() 
  2085. 	ss10_switch_state( MS_REPAIRMEN_ESCAPING ) 
  2086. end 
  2087.  
  2088. -- Callback when the failure timer for catching or reaching the van 
  2089. -- expires. 
  2090. -- Fails the mission. 
  2091. -- 
  2092. function ss10_failed_to_catch_van() 
  2093. 	mission_end_failure( MISSION_NAME, VAN_ESCAPED ) 
  2094. end 
  2095.  
  2096. -- Callback when the van is destroyed. Should only be called when 
  2097. -- the van is necessary. 
  2098. -- 
  2099. function ss10_van_destroyed() 
  2100. 	mission_end_failure( MISSION_NAME, VAN_DESTROYED ) 
  2101. end 
  2102.  
  2103. function ss10_entered_van( player_name, vehicle_name ) 
  2104. 	if ( player_name ~= LOCAL_PLAYER and player_name ~= REMOTE_PLAYER ) then 
  2105. 		return 
  2106. 	end 
  2107.  
  2108. 	if ( Repair_van_follow_path_thread_handle ~= INVALID_THREAD_HANDLE ) then 
  2109. 		thread_kill( Repair_van_follow_path_thread_handle ) 
  2110. 		Repair_van_follow_path_thread_handle = INVALID_THREAD_HANDLE 
  2111. 	end 
  2112. 	Players_in_repair_van[player_name] = true 
  2113.  
  2114. 	local sync_type = sync_from_player( player_name ) 
  2115. 	marker_remove_vehicle( REPAIR_VAN_NAME, sync_type ) 
  2116.  
  2117. 	mission_debug( player_name.." entered "..vehicle_name, 10 ) 
  2118.  
  2119. 	-- Find out if all the players have entered the vehicle 
  2120. 	local all_players_in_vehicle = ss10_all_players_in_repair_van() 
  2121.  
  2122. 	if ( all_players_in_vehicle ) then 
  2123. 		follower_make_independent( SHAUNDI_NAME, true ) 
  2124. 		mission_debug( "Everyone's in the van." ) 
  2125. 	end 
  2126.  
  2127. 	-- If we're trying to hijack the van and we just got in it, then 
  2128. 	-- we've successfully hijacked it. We call this here because we want to be sure 
  2129. 	-- that Players_in_repair_van is correct for the next state. 
  2130. 	if ( State == MS_HIJACK_REPAIR_VAN or 
  2131. 		  State == MS_REACHED_REPAIRMEN_AGAIN ) then 
  2132. 		mission_debug( "State was \"hijacked\", calling van_disabled.", 30 ) 
  2133. 		ss10_switch_state( MS_VAN_DISABLED ) 
  2134. 	end 
  2135.  
  2136. 	-- If so, we can go to the next mission state 
  2137. 	if ( all_players_in_vehicle ) then 
  2138. 		-- Advance the mission state 
  2139. 		on_vehicle_enter( "", REPAIR_VAN_NAME ) 
  2140. 		mission_debug( "Switching to \"park_van_at_station\"", 30 ) 
  2141. 		ss10_switch_state( MS_PARK_VAN_AT_STATION ) 
  2142. 	end 
  2143. end 
  2144.  
  2145. function ss10_exited_van( player_name, vehicle_name ) 
  2146. 	if ( player_name == LOCAL_PLAYER or player_name == REMOTE_PLAYER ) then 
  2147. 		Players_in_repair_van[player_name] = false 
  2148. 	end 
  2149. end 
  2150.  
  2151. function ss10_entered_van_during_drive_to_station( player_name, vehicle_name ) 
  2152. 	if ( player_name == LOCAL_PLAYER or player_name == REMOTE_PLAYER ) then 
  2153. 		local sync_type = sync_from_player( player_name ) 
  2154. 		waypoint_add( PARKING_SPOT_TRIGGER, sync_type ) 
  2155. 		marker_add_trigger( PARKING_SPOT_TRIGGER, MINIMAP_ICON_LOCATION, INGAME_EFFECT_VEHICLE_LOCATION, sync_type ) 
  2156. 		marker_remove_vehicle( REPAIR_VAN_NAME, sync_type ) 
  2157. 	end 
  2158. end 
  2159.  
  2160. function ss10_exited_van_during_drive_to_station( player_name, vehicle_name ) 
  2161. 	if ( player_name == LOCAL_PLAYER or player_name == REMOTE_PLAYER ) then 
  2162. 		Players_in_repair_van[player_name] = false 
  2163.  
  2164. 		local sync_type = sync_from_player( player_name ) 
  2165. 		waypoint_remove( sync_type ) 
  2166. 		marker_remove_trigger( PARKING_SPOT_TRIGGER, sync_type ) 
  2167. 		marker_add_vehicle( REPAIR_VAN_NAME, MINIMAP_ICON_PROTECT_ACQUIRE, INGAME_EFFECT_VEHICLE_PROTECT_ACQUIRE, sync_type ) 
  2168.  
  2169. 		mission_help_table_nag( VAN_REQUIRED ) 
  2170. 	end 
  2171. end 
  2172.  
  2173. -- Takes an attacker name and returns the player responsible. If the 
  2174. -- attacker name is a vehicle, for example, it looks at the vehicle's 
  2175. -- driver, and if the player is the driver, returns the name of the player 
  2176. function ss10_translate_attacker_name_to_player_name( attacker_name ) 
  2177.  
  2178. 	if ( attacker_name == nil ) then 
  2179. 		return nil 
  2180. 	end 
  2181.  
  2182. 	-- No translation necessary if it's already the player's name. 
  2183. 	if ( character_is_player( attacker_name ) ) then 
  2184. 		return attacker_name 
  2185. 	end 
  2186.  
  2187. 	if ( vehicle_exists( attacker_name ) ) then 
  2188. 		-- Check to see if it's a vehicle, and being driven by a player 
  2189. 		local driver = get_char_in_vehicle( attacker_name, 0 ) 
  2190. 		if ( driver == LOCAL_PLAYER or 
  2191. 			  driver == REMOTE_PLAYER ) then 
  2192. 			return driver 
  2193. 		end 
  2194. 	end 
  2195.  
  2196. 	-- This attacker is not a player... 
  2197. 	return nil 
  2198. end 
  2199.  
  2200. -- Callback when the van is first damaged or hit. Makes the van stop 
  2201. -- pathfinding in a circle and begin to flee from the player. 
  2202. -- Rebinds the take damage callback to another function. 
  2203. -- 
  2204. -- This function doesn't update the mission state... It puts the van 
  2205. -- into its own personal "fleeing" state, however. 
  2206. -- 
  2207. function ss10_van_damaged_initial( van_name, attacker_name ) 
  2208.  
  2209. 	local player_name = ss10_translate_attacker_name_to_player_name( attacker_name ) 
  2210.  
  2211. 	if ( player_name == LOCAL_PLAYER or player_name == REMOTE_PLAYER ) then 
  2212. 		audio_play_for_character( REPAIRMAN_ATTACKED_LINE, REPAIR_MAN_NAME, "voice", false, false ) 
  2213. 		--thread_kill( Repair_van_follow_path_thread_handle ) 
  2214. 		--vehicle_flee( REPAIR_VAN_NAME, player_name ) 
  2215.  
  2216. 		vehicle_speed_override( REPAIR_VAN_NAME, REPAIR_VAN_FLEE_SPEED_MPS ) 
  2217. 		vehicle_set_crazy( REPAIR_VAN_NAME, true ) 
  2218.  
  2219. 		set_unjackable_flag( REPAIR_VAN_NAME, false ) 
  2220. 		on_take_damage("ss10_van_damaged", REPAIR_VAN_NAME)  
  2221. 		on_collision("ss10_van_damaged", REPAIR_VAN_NAME)  
  2222. 		-- If we're looking for the repairmen and the van was damaged 
  2223. 		-- by a player, then we need to switch to the hijack state with 
  2224. 		-- the extra information that we're out-of-range of the van 
  2225. 		if ( State == MS_FIND_REPAIRMEN ) then 
  2226. 			local in_range = false 
  2227. 			ss10_switch_state( MS_HIJACK_REPAIR_VAN, nil, in_range ) 
  2228. 		else 
  2229. 			ss10_van_damaged() 
  2230. 		end 
  2231. 	end 
  2232. end 
  2233.  
  2234. -- Callback when the van is damaged. Updates the HUD "van HP" 
  2235. -- meter. 
  2236. --  
  2237. function ss10_van_damaged() 
  2238. 	ss10_update_van_hp_hud_bar() 
  2239. end 
  2240.  
  2241. -- Updates the Van HP display during the hijacking portion of 
  2242. -- the mission. 
  2243. -- 
  2244. function ss10_update_van_hp_hud_bar() 
  2245. 	local cur_van_hp = get_current_hit_points( REPAIR_VAN_NAME ) 
  2246. 	local cur_fraction_of_max_hp = cur_van_hp/ Initial_van_hp 
  2247.  
  2248. 	local percent_to_set = 1.0 - cur_fraction_of_max_hp 
  2249.  
  2250. 	if ( percent_to_set > REPAIR_VAN_PERCENT_DAMAGE_TO_DISABLE ) then 
  2251. 		percent_to_set = REPAIR_VAN_PERCENT_DAMAGE_TO_DISABLE 
  2252. 	end 
  2253.  
  2254. 	hud_bar_set_value(0, percent_to_set, SYNC_ALL ) 
  2255. end 
  2256.  
  2257. -- Callback when the van is damaged enough to be disabled. 
  2258. -- Puts the mission into the "Van disabled" state. 
  2259. -- 
  2260. function ss10_van_disabled() 
  2261. 	ss10_switch_state( MS_VAN_DISABLED ) 
  2262. end 
  2263.  
  2264. function ss10_hide_weapon_prompt( triggerer_name, trigger_name ) 
  2265. 	trigger_enable( trigger_name, false ) 
  2266.  
  2267. 	if ( notoriety_get_decimal( POLICE_GANG ) < 1 ) then 
  2268. 		-- Hide the players' weapons. 
  2269. 		inv_item_equip( nil, LOCAL_PLAYER )  
  2270. 		if ( coop_is_active() ) then 
  2271. 			inv_item_equip( nil, REMOTE_PLAYER )  
  2272. 		end 
  2273. 		audio_play_for_character( SHAUNDI_NEAR_STATION_LINE, SHAUNDI_REPAIR_VARIANT_NAME, "voice", false, true ) 
  2274. 		mission_help_table_nag( DONT_SHOW_WEAPONS ) 
  2275. 	end 
  2276. end 
  2277.  
  2278. function ss10_reached_police_station() 
  2279. 	waypoint_remove( SYNC_ALL ) 
  2280. 	ss10_switch_state( MS_ENTERED_POLICE_STATION ) 
  2281. end 
  2282.  
  2283. function ss10_sign_in_with_receptionist( triggerer_name, trigger_name ) 
  2284. 	ss10_switch_state( MS_GO_TO_CAMERA_ROOM, triggerer_name ) 
  2285. end 
  2286.  
  2287. function ss10_cleanup() 
  2288. 	-- Cleanup mission here 
  2289. 	--ss10_release_repair_van() 
  2290. 	thread_kill( Repair_van_follow_path_thread_handle ) 
  2291. 	distance_display_off(SYNC_ALL) 
  2292.  
  2293. 	notoriety_force_no_spawn( ULTOR_GANG, false ) 
  2294. 	notoriety_force_no_spawn( POLICE_GANG, false ) 
  2295. 	notoriety_set_min( POLICE_GANG, 0 ) 
  2296. 	notoriety_set( POLICE_GANG, 0 ) 
  2297.  
  2298. 	party_dismiss_all() 
  2299. 	group_destroy( SHAUNDI_GROUP_NAME ) 
  2300.  
  2301. 	-- Cleanup all vehicle callbacks 
  2302. 	on_tailing_good( "" ) 
  2303. 	on_tailing_too_far( "" ) 
  2304. 	on_damage( "", REPAIR_VAN_NAME, REPAIR_VAN_DISABLED_DAMAGE_PERCENT ) 
  2305. 	on_take_damage( "", REPAIR_VAN_NAME ) 
  2306. 	on_collision( "", REPAIR_VAN_NAME )  
  2307. 	on_vehicle_enter( "", REPAIR_VAN_NAME ) 
  2308. 	on_vehicle_exit( "", REPAIR_VAN_NAME ) 
  2309.  
  2310. 	ss10_lock_station_doors( false ) 
  2311.  
  2312. 	customization_item_revert( SYNC_LOCAL ) 
  2313. 	if ( coop_is_active() ) then 
  2314. 		customization_item_revert( SYNC_REMOTE ) 
  2315. 	end 
  2316. 	on_vehicle_enter( "", LOCAL_PLAYER ) 
  2317.  
  2318. 	trigger_type_enable("clothing store", true) 
  2319. 	trigger_type_enable("crib clothing", true) 
  2320. 	action_nodes_restrict_spawning( false ) 
  2321. 	set_dont_drop_havok_weapons_on_idle( false ) 
  2322.  
  2323. 	on_notoriety_event( "", LOCAL_PLAYER ) 
  2324. 	if ( coop_is_active() ) then 
  2325. 		on_notoriety_event( "", REMOTE_PLAYER ) 
  2326. 	end 
  2327. 	hud_timer_stop( 0 ) 
  2328. end 
  2329.  
  2330. function ss10_release_repair_van() 
  2331. 	distance_display_off(SYNC_ALL) 
  2332. 	marker_remove_vehicle( REPAIR_VAN_NAME, SYNC_ALL ) 
  2333. 	release_to_world( REPAIR_VAN_AND_REPAIRMEN_GROUP_NAME ) 
  2334. end 
  2335.  
  2336. function ss10_process() 
  2337. 	-- Per-update processing 
  2338. end 
  2339.  
  2340. function ss10_repair_van_follow_path() 
  2341. 	--  
  2342. 	vehicle_speed_override( REPAIR_VAN_NAME, REPAIR_VAN_DESIRED_SPEED_MPS ) 
  2343. 	vehicle_pathfind_to( REPAIR_VAN_NAME, REPAIR_VAN_INITIAL_NAVPOINTS[1], REPAIR_VAN_INITIAL_NAVPOINTS[2], false, false ) 
  2344. 	while ( 1 ) do 
  2345. 		for index, path_name in pairs( REPAIR_VAN_PATHS ) do 
  2346. 			vehicle_pathfind_to( REPAIR_VAN_NAME, path_name, false, false ) 
  2347. 			thread_yield() 
  2348. 		end 
  2349. 	end 
  2350. end 
  2351.  
  2352. function ss10_success() 
  2353. 	-- Called when the mission has ended with success 
  2354. end 
  2355.  
  2356.