sr2lua/ss07.lua

  1. -- ss07.lua 
  2. -- SR2 mission script 
  3. -- 3/28/07 
  4. -- Mission help table text tags 
  5.    -- Help text prefix 
  6.    HTP = "ss07_" 
  7.    HT_HURRY_UP =     HTP.."hurry_up" 
  8.    HT_HERE_WE_GO =   HTP.."here_we_go" 
  9.    HT_PIERCE_ABANDONED = HTP.."pierce_abandoned" 
  10.    HT_PIERCE_DIED =  HTP.."pierce_died" 
  11.    HT_GET_INTO_CAR = HTP.."get_into_car" 
  12.    HT_GET_ABOARD_BOAT =     HTP.."get_aboard_boat" 
  13.    HT_PRESS_TO_ENTER_CAR =  HTP.."press_to_enter_car" 
  14.    HT_PRESS_TO_BOARD_BOAT = HTP.."press_to_board_boat" 
  15.    HT_DESTROY_HELICOPTERS = HTP.."destroy_helicopters" 
  16.    HT_HELICOPTER_MADE_DROPOFF =      HTP.."helicopter_made_dropoff" 
  17.    HT_X_OF_Y_HELICOPTERS_DESTROYED = HTP.."x_of_y_helicopters_destroyed" 
  18.    HT_PIERCES_VEHICLE_DESTROYED = HTP.."pierces_vehicle_destroyed" 
  19.    ENEMY_GANG = "Samedi" 
  20.  
  21. -- Mission states 
  22.    MS_DELAY_BEFORE_START =    1 
  23.    MS_PATHFINDING_FIRST_CAR = 2 
  24.    MS_ARRIVED_AT_DOCK =       3 
  25.    MS_PATHFINDING_BOAT =      4 
  26.    MS_LAND_HO =               5 
  27.    MS_FINAL_CHASE =           6 
  28.    MS_END_OF_MISSION =        7 
  29.  
  30. -- Groups, NPCs, vehicles, navpoints, and other names 
  31.    -- Mission constant names 
  32.    MISSION_NAME = "ss07" 
  33.    -- ( Mission Prefix ) 
  34.    MP = MISSION_NAME.."_$" 
  35.  
  36.    -- Checkpoints 
  37.    BOAT_CHASE_CHECKPOINT = "Boat_Chase_Checkpoint" 
  38.    FINAL_CHASE_CHECKPOINT = "Final_Chase_Checkpoint" 
  39.    -- Weapons 
  40.    PLAYER_HELI_KILL_WEAPON = "ar50" 
  41.  
  42.    -- Groups 
  43.    RAIL_CAR_ONE_GROUP = MP.."Rail_Car_1" 
  44.    PIERCE_GROUP = MP.."Pierce" 
  45.    RAIL_BOAT_GROUP =    MP.."Rail_Boat" 
  46.    RAIL_CAR_TWO_GROUP = MP.."Rail_Car_2" 
  47.  
  48.    HELICOPTER_ONE_GROUP =   MP.."Heli01" 
  49.    HELICOPTER_TWO_GROUP =   MP.."Heli02" 
  50.    HELICOPTER_THREE_GROUP = MP.."Heli03" 
  51.    HELICOPTER_FOUR_GROUP =  MP.."Heli04" 
  52.    HELICOPTER_FIVE_GROUP =  MP.."Heli05" 
  53.    HELICOPTER_SIX_GROUP =   MP.."Heli06" 
  54.    HELICOPTER_GROUPS = { HELICOPTER_ONE_GROUP, HELICOPTER_TWO_GROUP, HELICOPTER_THREE_GROUP, 
  55.                          HELICOPTER_FOUR_GROUP, HELICOPTER_FIVE_GROUP, HELICOPTER_SIX_GROUP } 
  56.  
  57.    -- NPC names 
  58.    PIERCE_NAME = MP.."Pierce" 
  59.    HELI_ONE_CHARACTERS =   { MP.."H1_Driver", MP.."H1_Attacker1", MP.."H1_Attacker2" } 
  60.    HELI_TWO_CHARACTERS =   { MP.."H2_Driver", MP.."H2_Attacker1", MP.."H2_Attacker2" } 
  61.    HELI_THREE_CHARACTERS = { MP.."H3_Driver", MP.."H3_Attacker1", MP.."H3_Attacker2" } 
  62.    HELI_FOUR_CHARACTERS =  { MP.."H4_Driver", MP.."H4_Attacker1", MP.."H4_Attacker2" } 
  63.    HELI_FIVE_CHARACTERS =  { MP.."H5_Driver", MP.."H5_Attacker1", MP.."H5_Attacker2" } 
  64.    HELI_SIX_CHARACTERS =   { MP.."H6_Driver", MP.."H6_Attacker1", MP.."H6_Attacker2" } 
  65.  
  66.    HELICOPTER_CHARACTERS = { HELI_ONE_CHARACTERS, HELI_TWO_CHARACTERS, HELI_THREE_CHARACTERS, 
  67.                              HELI_FOUR_CHARACTERS, HELI_FIVE_CHARACTERS, HELI_SIX_CHARACTERS } 
  68.  
  69.    RAIL_CAR_TWO_CARJACK_VICTIM_NAME = MP.."Poor_Victim" 
  70.  
  71.    -- Vehicle names 
  72.    RAIL_CAR_ONE_NAME = MP.."Rail_Car_1" 
  73.    RAIL_BOAT_NAME = MP.."Rail_Boat" 
  74.    RAIL_CAR_TWO_NAME = MP.."Rail_Car_2" 
  75.  
  76.    RAIL_CAR_NAMES = { RAIL_CAR_ONE_NAME, RAIL_CAR_TWO_NAME } 
  77.  
  78.    HELICOPTER_ONE_NAME =   MP.."Heli01" 
  79.    HELICOPTER_TWO_NAME =   MP.."Heli02" 
  80.    HELICOPTER_THREE_NAME = MP.."Heli03" 
  81.    HELICOPTER_FOUR_NAME =  MP.."Heli04" 
  82.    HELICOPTER_FIVE_NAME =  MP.."Heli05" 
  83.    HELICOPTER_SIX_NAME =   MP.."Heli06" 
  84.  
  85.    HELICOPTER_NAMES = { HELICOPTER_ONE_NAME, HELICOPTER_TWO_NAME, HELICOPTER_THREE_NAME, 
  86.                         HELICOPTER_FOUR_NAME, HELICOPTER_FIVE_NAME, HELICOPTER_SIX_NAME } 
  87.  
  88.    -- Navpoints 
  89.    NEAR_START_CAR = MP.."Near_Start_Car" 
  90.    NEAR_START_CAR_REMOTE_PLAYER = MP.."Near_Start_Car_Remote_Player" 
  91.  
  92.    RAIL_CAR_ONE_PATH_PART_ONE =   MP.."Rail_Car_1_Path1_01" 
  93.    RAIL_CAR_ONE_PATH_PART_TWO =   MP.."Rail_Car_1_Path1_02" 
  94.    RAIL_CAR_ONE_PATH_PART_THREE = MP.."Rail_Car_1_Path1_03" 
  95.    RAIL_CAR_ONE_PATH_PART_FOUR =  MP.."Rail_Car_1_Path1_04" 
  96.    RAIL_CAR_ONE_PATH_PART_FIVE =  MP.."Rail_Car_1_Path1_05" 
  97.    RAIL_CAR_ONE_PATH_PART_SIX =  MP.."Rail_Car_1_Path1_06" 
  98.    RAIL_CAR_ONE_PATH_PART_SEVEN =  MP.."Rail_Car_1_Path1_07" 
  99.    RAIL_CAR_ONE_PATH_PART_EIGHT =  MP.."Rail_Car_1_Path1_08" 
  100.  
  101.    FIRST_RAIL_CAR_PATH_SEGMENTS = { RAIL_CAR_ONE_PATH_PART_ONE, 
  102.                                     RAIL_CAR_ONE_PATH_PART_TWO, 
  103.                                     RAIL_CAR_ONE_PATH_PART_THREE, 
  104. 			                           RAIL_CAR_ONE_PATH_PART_FOUR, 
  105. 			                           RAIL_CAR_ONE_PATH_PART_FIVE, 
  106.                                     RAIL_CAR_ONE_PATH_PART_SIX, 
  107.                                     RAIL_CAR_ONE_PATH_PART_SEVEN, 
  108.                                     RAIL_CAR_ONE_PATH_PART_EIGHT } 
  109.    FIRST_RAIL_CAR_PATH_SEGMENTS_USE_ROADS = { true, false, false, true, true, false, true, false } 
  110.  
  111.    RAIL_CAR_TWO_PATH_PART_ONE   = MP.."Rail_Car_2_Path3_01" 
  112.    RAIL_CAR_TWO_PATH_PART_TWO   = MP.."Rail_Car_2_Path3_02" 
  113.    RAIL_CAR_TWO_PATH_PART_THREE = MP.."Rail_Car_2_Path3_03" 
  114.    RAIL_CAR_TWO_PATH_PART_FOUR  = MP.."Rail_Car_2_Path3_04" 
  115.    RAIL_CAR_TWO_PATH_PART_FIVE  = MP.."Rail_Car_2_Path3_05" 
  116.    RAIL_CAR_TWO_PATH_PART_SIX  = MP.."Rail_Car_2_Path3_06" 
  117.  
  118.    SECOND_RAIL_CAR_PATH_SEGMENTS = { RAIL_CAR_TWO_PATH_PART_ONE,   
  119.                                      RAIL_CAR_TWO_PATH_PART_TWO,   
  120.                                      RAIL_CAR_TWO_PATH_PART_THREE, 
  121.                                      RAIL_CAR_TWO_PATH_PART_FOUR, 
  122.                                      RAIL_CAR_TWO_PATH_PART_FIVE, 
  123.                                      RAIL_CAR_TWO_PATH_PART_SIX }  
  124.    SECOND_RAIL_CAR_PATH_SEGEMENTS_USE_ROADS = { false, false, false, false, false, false } 
  125.  
  126.    RAIL_CARS_PATH_SEGMENTS = { FIRST_RAIL_CAR_PATH_SEGMENTS, SECOND_RAIL_CAR_PATH_SEGMENTS } 
  127.    RAIL_CARS_PATH_SEGMENTS_USE_ROADS = { FIRST_RAIL_CAR_PATH_SEGMENTS_USE_ROADS, 
  128.                                          SECOND_RAIL_CAR_PATH_SEGEMENTS_USE_ROADS } 
  129.  
  130.    RAIL_BOAT_PATH =    MP.."Rail_Boat_Path" 
  131.    RAIL_CAR_TWO_PATH = MP.."Rail_Car_2_Path" 
  132.    CARJACK_VICTIM_GROUP = MP.."Carjack_Victim" 
  133.  
  134.    CARJACK_POINT_ONE = MP.."Pierce_Carjack_P1" 
  135.    CARJACK_POINT_TWO = MP.."Pierce_Carjack_P2" 
  136.    CARJACK_POINT_THREE = MP.."Pierce_Carjack_P3" 
  137.  
  138.    CARJACKED_CAR_PATH = MP.."Victim_Path" 
  139.  
  140.    CARJACKED_CAR_CHECKPOINT_SPAWN_POS = MP.."Hijacked_Car_Stop_Position" 
  141.  
  142.    SECOND_CHECKPOINT_LOCAL_PLAYER_START_LOCATION = MP.."Second_Checkpoint_Start_Local" 
  143.    SECOND_CHECKPOINT_REMOTE_PLAYER_START_LOCATION = MP.."Second_Checkpoint_Start_Remote" 
  144.  
  145.    NEAR_DOCK = MP.."Near_Dock" 
  146.    NEAR_DOCK_REMOTE_PLAYER = MP.."Near_Dock_Remote_Player" 
  147.    PIERCE_NEAR_DOCK = MP.."Pierce_Near_Dock" 
  148.  
  149.    HELICOPTER_HOLDING_POSITIONS = { [1] = MP.."Heli1_Holding_Pos" , [2] = MP.."Heli2_Holding_Pos", [4] = MP.."Heli4_Holding_Pos" } 
  150.  
  151.    HELICOPTER_ONE_PATHS = { MP.."Heli_Path_1_01", MP.."Heli_Path_1_02" } 
  152.    HELICOPTER_TWO_PATHS = { MP.."Heli_Path_2_01", MP.."Heli_Path_2_02" } 
  153.    HELICOPTER_THREE_PATH = MP.."Heli_Path_3" 
  154.    HELICOPTER_FOUR_PATH = MP.."Heli_Path_4" 
  155.    HELICOPTER_FIVE_PATHS = { MP.."Heli_Path_5_01", MP.."Heli_Path_5_02" } 
  156.    HELICOPTER_SIX_PATH = MP.."Heli_Path_6" 
  157.  
  158.    HELICOPTER_PATHS = { HELICOPTER_ONE_PATHS, HELICOPTER_TWO_PATHS, HELICOPTER_THREE_PATH, 
  159.                         HELICOPTER_FOUR_PATH, HELICOPTER_FIVE_PATHS, HELICOPTER_SIX_PATH } 
  160.    HELICOPTER_IS_PATH_PIECEWISE = { true, true, false, false, true, false } 
  161.    HELICOPTER_IS_PATH_DIRECT = { true, true, true, true, true, true } 
  162.  
  163.    HELICOPTER_ONE_DROPOFF =   MP.."H1_D" 
  164.    HELICOPTER_TWO_DROPOFF =   MP.."H2_D" 
  165.    HELICOPTER_THREE_DROPOFF = MP.."H3_D" 
  166.    HELICOPTER_FOUR_DROPOFF =  MP.."H4_D" 
  167.    HELICOPTER_FIVE_DROPOFF =  MP.."H5_D" 
  168.    HELICOPTER_SIX_DROPOFF =   MP.."H6_D" 
  169.  
  170.    HELICOPTER_DROPOFFS = { HELICOPTER_ONE_DROPOFF, HELICOPTER_TWO_DROPOFF, HELICOPTER_THREE_DROPOFF, 
  171.                            HELICOPTER_FOUR_DROPOFF, HELICOPTER_FIVE_DROPOFF, HELICOPTER_SIX_DROPOFF } 
  172.  
  173.    HELICOPTER_END_CUTSCENE_POSITION = MP.."scene1_heli_path02" 
  174.  
  175.    -- Triggers 
  176.    HELICOPTER_TRIGGERS = { [2] = MP.."H2_Trigger", [4] = MP.."H4_Trigger", [6] = MP.."H6_Trigger" } 
  177.    PARK_BOAT_DIALOG_TRIGGER = MP.."Park_Boat_Dialog_Trigger" 
  178.  
  179.    GRAB_BOAT_CONVERSATION_TRIGGER = MP.."Grab_Boat_Conversation_Trigger" 
  180.  
  181.    -- Movers 
  182.    LAMPPOST = MP.."Lamppost" 
  183.    BILLBOARD = MP.."Billboard" 
  184.    BILLBOARD_BASE = MP.."Billboard_Base" 
  185.  
  186.    -- Effects and animation states 
  187.  
  188.    -- Cutscenes 
  189.    CT_INTRO = "ss07-01" 
  190.    CT_OUTRO = "ss07-02" 
  191.  
  192.    CT_HELI_ESTABLISH = "ig_ss07_scene1" 
  193.  
  194. -- Sound 
  195.    -- Persona overrides 
  196.  
  197.    -- Lines/Dialog Stream 
  198.    INTRO_DIALOG_STREAM = { { "SOS7_INTRO_L1", PIERCE_NAME, 0 }, 
  199.                            { "PLAYER_SOS7_INTRO_L2", LOCAL_PLAYER, 0 }, 
  200.                            { "SOS7_INTRO_L3", PIERCE_NAME, 0 }, 
  201.                            { "PLAYER_SOS7_INTRO_L4", LOCAL_PLAYER, 0 }, 
  202.                            { "SOS7_INTRO_L5", PIERCE_NAME, 0 }, 
  203.                            { "PLAYER_SOS7_INTRO_L6", LOCAL_PLAYER, 0 }, 
  204.                            { "SOS7_INTRO_L7", PIERCE_NAME, 0 } } 
  205.  
  206.    BOAT_DIALOG_STREAM = { { "SOS7_WATER_L1", PIERCE_NAME, 0 }, 
  207.                           { "PLAYER_SOS7_WATER_L2", LOCAL_PLAYER, 0 } } 
  208.  
  209.    MUSIC_DIALOG_STREAM = { { "SOS7_MUSIC_L1", PIERCE_NAME, 0 }, 
  210.                            { "PLAYER_SOS7_MUSIC_L2", LOCAL_PLAYER, 0 }, 
  211.                            { "SOS7_MUSIC_L3", PIERCE_NAME, 0 }, 
  212.                            { "PLAYER_SOS7_MUSIC_L4", LOCAL_PLAYER, 0 } } 
  213.  
  214.    PIERCE_NEED_SOME_MUSIC_LINE = "SOS7_MUSIC_L1" 
  215.    PLAYER_YOU_MUST_BE_KIDDING_LINE = "PLAYER_SOS7_MUSIC_L2" 
  216.    PLAYER_YOU_ARE_BAD_AT_SINGING_LINE = "PLAYER_SOS7_MUSIC_L4" 
  217.     
  218.  
  219.    PIERCE_MAKING_JUMP_LINE = "PIERCE_SOS7_JUMP_01" 
  220.    PIERCE_CALLING_OUT_NEXT_HELICOPTER = "PIERCE_SOS7_NEXT_HELI" 
  221.    PIERCE_CARJACKING_DIALOG_LINE = "PIERCE_SOS7_CARJACK_01" 
  222.  
  223. 	PIERCE_CALLING_OUT_ALMOST_DROPOFF_LINES = { "PIERCE_SOS7_HELI_RANGE_01", "PIERCE_SOS7_HELI_RANGE_02", "PIERCE_SOS7_HELI_RANGE_03" } 
  224. 	NUM_CALLING_OUT_HELI_LINES = sizeof_table( PIERCE_CALLING_OUT_ALMOST_DROPOFF_LINES ) 
  225.  
  226.    PLAYER_GET_BACK_TO_SHORE_LINE = "PLAYER_SOS7_LAND_01" 
  227.  
  228.    -- Sound effects 
  229.  
  230. -- Distances 
  231.  
  232. -- Percents and multipliers 
  233.    RAIL_CAR_TWO_HEALTH_MULTIPLIER = 1.15 
  234.    HELICOPTER_HP_MULTIPLIERS = { 0.8, 0.55, 1.0, 1.0, 1.0, 0.8 } 
  235.  
  236. -- Time values 
  237.    VEHICLE_FOLLOW_DELAYS_SECONDS = { 11.0, 2.0, 8.0 } 
  238.    HELICOPTER_START_DELAYS_SECONDS = { 0, 0, 0, 0, 0, 0 } 
  239.    HELI_TWO_START_DELAY = 2 
  240.    HELI_FOUR_START_DELAY = 0 
  241.    HELI_SIX_START_DELAY = 0 
  242.    HELI_TWO_PIERCE_BLAB_DELAY_SECONDS = 4 
  243.    HELI_FOUR_PIERCE_BLAB_DELAY_SECONDS = 1 
  244.    HELI_SIX_PIERCE_BLAB_DELAY_SECONDS = 4 
  245.    AFTER_JUMP_RESUME_PATHING_DELAY_SECONDS = 1.5 
  246.  
  247. -- Speeds 
  248.    RAIL_CAR_ON_ROAD_RAIL_PATH_SPEEDS_MPS = { { 55, 55, 55, 55, 55, 55, 55, 55 }, 
  249.                                              { 55, 40, 45, 50, 50, 50 } } 
  250.    BOAT_PATH_SPEED_MPS = 35 
  251.    HELICOPTER_PATH_SPEEDS_MPS = { { 20, 24 }, { 26, 26 }, 25, 15, { 23, 23 }, 20 } 
  252.    HELICOPTER_DROPOFF_SPEED_MPS = 20 
  253.    HELICOPTER_TO_HOLDING_POS_SPEED_MPS = 20 
  254.  
  255. -- Constant values and counts 
  256.    HELICOPTER_COUNT = sizeof_table( HELICOPTER_GROUPS ) 
  257.  
  258.    HELI_DESTROYED_MIN_NOTORIETY_LEVELS = { 2, 3, 4, 4, 4, 4 } 
  259.    AFTER_FIRST_HELI_DAMAGED_MIN_NOTORIETY = 1 
  260.  
  261.    MISSION_MAX_NOTORIETY = 4 
  262.  
  263.    CLASSIC_RADIO_STATION_INDEX = 7 
  264.    PIERCE_RADIO_STATION_INDEX = 44 
  265.  
  266. -- Global variables 
  267.    Helicopter_path_threads = { INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, 
  268.                                INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE, INVALID_THREAD_HANDLE } 
  269.    Num_helicopters_destroyed = 0 
  270.  
  271.    Players_in_boat = { [LOCAL_PLAYER] = false, [REMOTE_PLAYER] = false } 
  272.    Players_in_hijacked_car = { [LOCAL_PLAYER] = false, [REMOTE_PLAYER] = false } 
  273.  
  274. 	Cur_calling_out_heli_line_index = 0 
  275.  
  276. function ss07_all_players_in_vehicle( in_vehicle_status ) 
  277.    if ( in_vehicle_status[LOCAL_PLAYER] == true ) then 
  278.       if ( coop_is_active() ) then 
  279.          if ( in_vehicle_status[REMOTE_PLAYER] == true ) then 
  280.             return true 
  281.          end 
  282.       else 
  283.          return true 
  284.       end 
  285.    end 
  286.  
  287.    return false 
  288. end 
  289.  
  290. function ss07_vehicle_multiply_hp( vehicle_name, multiplier ) 
  291.    local max_hp = get_max_hit_points( vehicle_name ) 
  292.     
  293.    local new_hp = max_hp * multiplier 
  294.  
  295.    set_max_hit_points( vehicle_name, new_hp ) 
  296.    set_current_hit_points( vehicle_name, new_hp ) 
  297. end 
  298.  
  299. function ss07_set_vehicle_interaction_allowed( allowed ) 
  300.    set_player_can_enter_exit_vehicles( LOCAL_PLAYER, allowed ) 
  301.    if ( coop_is_active() ) then 
  302.       set_player_can_enter_exit_vehicles( REMOTE_PLAYER, allowed ) 
  303.    end 
  304. end 
  305.  
  306. function ss07_start( checkpoint_name, is_restart ) 
  307.    -- Start trigger is hit...the activate button was hit 
  308.    set_mission_author("Brad Johnson and Mark Gabby") 
  309.  
  310.    local resuming_from_checkpoint = false 
  311.  
  312.    mission_start_fade_out() 
  313.  
  314.    if ( checkpoint_name == MISSION_START_CHECKPOINT ) then 
  315.       if (not is_restart) then 
  316. 			cutscene_play( CT_INTRO, { RAIL_CAR_ONE_GROUP, PIERCE_GROUP, RAIL_BOAT_GROUP, RAIL_CAR_TWO_GROUP }, { NEAR_START_CAR, NEAR_START_CAR_REMOTE_PLAYER }, false ) 
  317. 		else 
  318. 			group_create_hidden( RAIL_CAR_ONE_GROUP, true ) 
  319. 			group_create_hidden( PIERCE_GROUP, true ) 
  320. 			group_create_hidden( RAIL_BOAT_GROUP, true ) 
  321. 			group_create_hidden( RAIL_CAR_TWO_GROUP, true ) 
  322. 			teleport_coop( NEAR_START_CAR, NEAR_START_CAR_REMOTE_PLAYER ) 
  323. 		end 
  324.  
  325. 		-- Show groups that need to be seen immediately 
  326. 		group_show( RAIL_CAR_ONE_GROUP ) 
  327. 		group_show( PIERCE_GROUP ) 
  328.  
  329. 		-- Non-blocking group create for group used later in the mission 
  330.       group_create_hidden( CARJACK_VICTIM_GROUP ) 
  331.    else 
  332.       resuming_from_checkpoint = true 
  333.    end 
  334.  
  335. 	spawning_boats( false ) 
  336.    mesh_mover_hide( LAMPPOST ) 
  337.    mesh_mover_hide( BILLBOARD ) 
  338.    mesh_mover_hide( BILLBOARD_BASE ) 
  339.  
  340.    ss07_setup_heli_triggers() 
  341.  
  342.    local next_state 
  343.  
  344.    notoriety_set_max( ENEMY_GANG, MISSION_MAX_NOTORIETY ) 
  345.  
  346.    inv_weapon_add_temporary( LOCAL_PLAYER, PLAYER_HELI_KILL_WEAPON, 1, true )  
  347.    if ( coop_is_active() ) then 
  348.       inv_weapon_add_temporary( REMOTE_PLAYER, PLAYER_HELI_KILL_WEAPON, 1, true )  
  349.    end 
  350.  
  351.    if ( checkpoint_name == MISSION_START_CHECKPOINT ) then 
  352.       party_add( PIERCE_NAME, LOCAL_PLAYER ) 
  353.       follower_make_independent( PIERCE_NAME, true ) 
  354.  
  355.       on_vehicle_destroyed( "ss07_rail_vehicle_destroyed", RAIL_CAR_ONE_NAME ) 
  356.       thread_yield() 
  357.  
  358.       -- Teleport both players inside and lock them in 
  359.       vehicle_enter_teleport( PIERCE_NAME, RAIL_CAR_ONE_NAME, 0, true ) 
  360.       vehicle_enter_teleport( LOCAL_PLAYER, RAIL_CAR_ONE_NAME, 2, true ) 
  361.       if ( coop_is_active() ) then 
  362.          vehicle_enter_teleport( REMOTE_PLAYER, RAIL_CAR_ONE_NAME, 3, true ) 
  363.       end 
  364.       turn_invulnerable( PIERCE_NAME ) 
  365.       thread_yield() 
  366.       ss07_setup_rail_vehicle_for_chase( RAIL_CAR_ONE_NAME ) 
  367.  
  368.       -- Give everyone a frame to get in before we make the vehicle unenterable. 
  369.       thread_yield() 
  370.       --set_unjackable_flag( RAIL_CAR_ONE_NAME, true ) 
  371.  
  372.       trigger_enable( GRAB_BOAT_CONVERSATION_TRIGGER, true ) 
  373.       on_trigger( "ss07_do_boat_conversation", GRAB_BOAT_CONVERSATION_TRIGGER ) 
  374.  
  375.       -- Start the mission 
  376.       next_state = MS_DELAY_BEFORE_START 
  377.    elseif ( checkpoint_name == BOAT_CHASE_CHECKPOINT ) then 
  378.       -- You've destroyed two helicopters, so set the min notoriety to the 2nd one's 
  379.       notoriety_set_min( ENEMY_GANG, HELI_DESTROYED_MIN_NOTORIETY_LEVELS[2] ) 
  380.  
  381.       if ( group_is_loaded( PIERCE_GROUP ) == false ) then 
  382.          group_create( PIERCE_GROUP, true ) 
  383.          party_add( PIERCE_NAME, LOCAL_PLAYER ) 
  384.       end 
  385. 		if ( group_is_loaded( RAIL_BOAT_GROUP ) == false ) then 
  386. 			group_create( RAIL_BOAT_GROUP, true ) 
  387. 		end 
  388.       group_create_hidden( RAIL_CAR_TWO_GROUP, true ) 
  389.       group_create_hidden( CARJACK_VICTIM_GROUP, true ) 
  390.  
  391.       follower_make_independent( PIERCE_NAME, true ) 
  392.       turn_invulnerable( PIERCE_NAME ) 
  393.  
  394. 		teleport( PIERCE_NAME, PIERCE_NEAR_DOCK, true ) 
  395. 		teleport_coop( NEAR_DOCK, NEAR_DOCK_REMOTE_PLAYER, true ) 
  396. 		repeat 
  397. 			thread_yield() 
  398. 		until ( get_dist( LOCAL_PLAYER, NEAR_DOCK ) < 1.0 ) 
  399. 		if ( coop_is_active() ) then 
  400. 			repeat 
  401. 				thread_yield() 
  402. 			until ( get_dist( REMOTE_PLAYER, NEAR_DOCK_REMOTE_PLAYER ) < 1.0 ) 
  403. 		end 
  404.  
  405. 		vehicle_enter_teleport( LOCAL_PLAYER, RAIL_BOAT_NAME, 1 ) 
  406.       if ( coop_is_active() ) then 
  407.          vehicle_enter_teleport( REMOTE_PLAYER, RAIL_BOAT_NAME, 2 ) 
  408.       end 
  409. 		vehicle_enter_teleport( PIERCE_NAME, RAIL_BOAT_NAME, 0 ) 
  410.  
  411.       on_vehicle_destroyed( "ss07_rail_vehicle_destroyed", RAIL_BOAT_NAME ) 
  412.       vehicle_suppress_npc_exit( RAIL_BOAT_NAME, true ) 
  413. 	   vehicle_disable_chase( RAIL_BOAT_NAME, true ) 
  414. 		vehicle_disable_flee( RAIL_BOAT_NAME, true ) 
  415.       Num_helicopters_destroyed = 2 
  416.       next_state = MS_PATHFINDING_BOAT 
  417.    elseif ( checkpoint_name == FINAL_CHASE_CHECKPOINT ) then 
  418.       -- You've destroyed four helicopters, so set the min notoriety to the 4th one's 
  419.       notoriety_set_min( ENEMY_GANG, HELI_DESTROYED_MIN_NOTORIETY_LEVELS[4] ) 
  420.  
  421.       if ( group_is_loaded( PIERCE_GROUP ) == false ) then 
  422.          group_create( PIERCE_GROUP, true ) 
  423.          party_add( PIERCE_NAME, LOCAL_PLAYER ) 
  424.       end 
  425. 		if ( group_is_loaded( RAIL_CAR_TWO_GROUP ) == false ) then 
  426. 			group_create( RAIL_CAR_TWO_GROUP, true ) 
  427. 		end 
  428.       follower_make_independent( PIERCE_NAME, true ) 
  429. 		spawning_vehicles( false ) 
  430. 		spawning_pedestrians( false, true ) 
  431.  
  432.       on_vehicle_destroyed( "ss07_rail_vehicle_destroyed", RAIL_CAR_TWO_NAME ) 
  433.  
  434. 		teleport( PIERCE_NAME, MP.."Pierce_Checkpoint_Two_Warp", true ) 
  435. 		teleport_coop( SECOND_CHECKPOINT_LOCAL_PLAYER_START_LOCATION, SECOND_CHECKPOINT_REMOTE_PLAYER_START_LOCATION, true ) 
  436. 		repeat 
  437. 			thread_yield() 
  438. 		until ( get_dist( LOCAL_PLAYER, SECOND_CHECKPOINT_LOCAL_PLAYER_START_LOCATION ) < 1.0 ) 
  439. 		if ( coop_is_active() ) then 
  440. 			repeat 
  441. 				thread_yield() 
  442. 			until ( get_dist( REMOTE_PLAYER, SECOND_CHECKPOINT_REMOTE_PLAYER_START_LOCATION ) < 1.0 ) 
  443. 		end 
  444.  
  445. 		vehicle_enter_teleport( LOCAL_PLAYER, RAIL_CAR_TWO_NAME, 2 ) 
  446.       if ( coop_is_active() ) then 
  447.          vehicle_enter_teleport( REMOTE_PLAYER, RAIL_CAR_TWO_NAME, 3, false ) 
  448.       end 
  449. 		vehicle_enter_teleport( PIERCE_NAME, RAIL_CAR_TWO_NAME, 0 ) 
  450.  
  451.       teleport_vehicle( RAIL_CAR_TWO_NAME, CARJACKED_CAR_CHECKPOINT_SPAWN_POS ) 
  452. 		spawning_vehicles( true ) 
  453. 		spawning_pedestrians( true ) 
  454.  
  455.       vehicle_suppress_npc_exit( RAIL_CAR_TWO_NAME, true ) 
  456.       turn_invulnerable( PIERCE_NAME ) 
  457.       ss07_setup_rail_vehicle_for_chase( RAIL_CAR_TWO_NAME ) 
  458.       vehicle_set_radio_controls_locked( RAIL_CAR_TWO_NAME, true ) 
  459.       radio_set_station( RAIL_CAR_TWO_NAME, CLASSIC_RADIO_STATION_INDEX ) 
  460.  
  461.       Num_helicopters_destroyed = 4 
  462.       next_state = MS_FINAL_CHASE 
  463.    end 
  464.  
  465.    on_death( "ss07_pierce_died", PIERCE_NAME ) 
  466.    on_dismiss( "ss07_pierce_abandoned", PIERCE_NAME ) 
  467.    inv_item_remove_all( PIERCE_NAME ) 
  468.  
  469.    -- Prevent the players from getting out of rail vehicles - avoids all kinds of 
  470.    -- messiness 
  471.    ss07_set_vehicle_interaction_allowed( false ) 
  472.    mission_start_fade_in() 
  473.  
  474.    mission_help_table( HT_DESTROY_HELICOPTERS, SYNC_ALL ) 
  475.  
  476.    ss07_switch_state( next_state, resuming_from_checkpoint ) 
  477. end 
  478.  
  479. function ss07_reached_park_boat_dialog_trigger( triggerer_name, trigger_name ) 
  480.    trigger_enable( trigger_name, false ) 
  481.    audio_play_for_character( PLAYER_GET_BACK_TO_SHORE_LINE, LOCAL_PLAYER, "voice", false, false ) 
  482. end 
  483.  
  484. function ss07_first_helicopter_damaged( victim, attacker ) 
  485.    if ( attacker ~= nil ) then 
  486.       if ( character_is_player( attacker ) ) then 
  487.          notoriety_set_min( ENEMY_GANG, AFTER_FIRST_HELI_DAMAGED_MIN_NOTORIETY ) 
  488.          on_take_damage( "", victim ) 
  489.           
  490.          attack_safe( HELICOPTER_CHARACTERS[1][2], LOCAL_PLAYER ) 
  491.          attack_safe( HELICOPTER_CHARACTERS[1][3], LOCAL_PLAYER ) 
  492.       end 
  493.    end 
  494. end 
  495.  
  496. function ss07_start_conversation() 
  497.    audio_play_conversation( INTRO_DIALOG_STREAM, NOT_CALL ) 
  498. end 
  499.  
  500. function ss07_switch_state( new_state, from_checkpoint ) 
  501.    if ( from_checkpoint == nil ) then 
  502.       from_checkpoint = false 
  503.    end 
  504.  
  505.    if ( new_state == MS_DELAY_BEFORE_START ) then 
  506.  
  507.       -- Spawn the helicopter 
  508.       ss07_create_and_init_helicopter( 1 ) 
  509.       ss07_create_and_init_helicopter( 2 ) 
  510.       on_take_damage( "ss07_first_helicopter_damaged", HELICOPTER_NAMES[1] ) 
  511.  
  512.       -- After the helicopter is created, start the conversation 
  513.       thread_new( "ss07_start_conversation" ) 
  514.       -- Wait a few seconds before letting the helicopter start flying 
  515.       delay( 7.0 ) 
  516.  
  517.       -- Let it fly past 
  518.       Helicopter_path_threads[1] = thread_new( "ss07_heli_fly", 1 ) 
  519.       -- Wait for the conversation to reach a good point before letting the vehicle follow 
  520.       delay( VEHICLE_FOLLOW_DELAYS_SECONDS[1] ) 
  521.  
  522.       on_vehicle_destroyed( "ss07_rail_vehicle_destroyed", RAIL_CAR_ONE_NAME ) 
  523.  
  524.       ss07_switch_state( MS_PATHFINDING_FIRST_CAR ) 
  525.       --teleport_vehicle( RAIL_CAR_ONE_NAME, MP.."Temp_End_of_First_Path" ) 
  526.       --ss07_switch_state( MS_ARRIVED_AT_DOCK ) 
  527.    elseif ( new_state == MS_PATHFINDING_FIRST_CAR ) then 
  528.       -- Set the GSI to display X of Y helicopters killed 
  529.       objective_text( 0, HT_X_OF_Y_HELICOPTERS_DESTROYED, Num_helicopters_destroyed, HELICOPTER_COUNT, SYNC_ALL ) 
  530.       -- Start the car pathfinding 
  531.       ss07_setup_rail_vehicle_damage_tracking( RAIL_CAR_ONE_NAME ) 
  532.  
  533.       thread_new( "ss07_rail_car_do_path", 1, MS_ARRIVED_AT_DOCK ) 
  534.    elseif ( new_state == MS_ARRIVED_AT_DOCK ) then 
  535.  
  536.       -- Create the boat 
  537.       group_show( RAIL_BOAT_GROUP ) 
  538.       on_vehicle_destroyed( "ss07_rail_vehicle_destroyed", RAIL_BOAT_NAME ) 
  539.       -- Have Pierce get out of the car and go to the boat 
  540.       thread_new( "ss07_pierce_exit_vehicle_and_go_to_boat" ) 
  541.  
  542. 	   vehicle_disable_chase( RAIL_BOAT_NAME, true ) 
  543. 		vehicle_disable_flee( RAIL_BOAT_NAME, true ) 
  544.  
  545.       -- Delay, then allow the player(s) to get out 
  546.       delay( 2.0 ) 
  547.       ss07_set_vehicle_interaction_allowed( true ) 
  548.       -- The first rail car is no longer mission-critical at this point 
  549.       on_vehicle_destroyed( "", RAIL_CAR_ONE_NAME ) 
  550.  
  551.       -- Tell player what to do next 
  552.       mission_help_table( HT_GET_ABOARD_BOAT, "", "", SYNC_ALL ) 
  553.       marker_add_vehicle( RAIL_BOAT_NAME, MINIMAP_ICON_PROTECT_ACQUIRE, INGAME_EFFECT_VEHICLE_PROTECT_ACQUIRE, SYNC_ALL ) 
  554.  
  555.       -- Add callbacks for entering the boat, to proceed to the next stage 
  556.       on_vehicle_enter( "ss07_entered_boat", RAIL_BOAT_NAME ) 
  557.       on_vehicle_exit( "ss07_left_boat", RAIL_BOAT_NAME ) 
  558.  
  559.    elseif ( new_state == MS_PATHFINDING_BOAT ) then 
  560.       -- The boat has started - lock the players in 
  561.       ss07_set_vehicle_interaction_allowed( false ) 
  562.       -- Prevent Samedi from clogging up the area with the second car  
  563.       notoriety_force_no_spawn( ENEMY_GANG, true ) 
  564.       -- Prevent Police from bothering Pierce 
  565.       ambient_cop_spawn_enable( false ) 
  566.  
  567. 		if ( from_checkpoint == false ) then 
  568. 	      mission_set_checkpoint( BOAT_CHASE_CHECKPOINT, true ) 
  569. 		end 
  570.  
  571.       trigger_enable( PARK_BOAT_DIALOG_TRIGGER, true ) 
  572.       on_trigger( "ss07_reached_park_boat_dialog_trigger", PARK_BOAT_DIALOG_TRIGGER ) 
  573.  
  574.       ss07_create_and_init_second_rail_car() 
  575.  
  576.       ss07_setup_rail_vehicle_damage_tracking( RAIL_BOAT_NAME ) 
  577.       -- Create the helicopter 
  578.       ss07_create_and_init_helicopter( 3 ) 
  579.       ss07_create_and_init_helicopter( 4 ) 
  580.       --cutscene_play( CT_HELI_ESTABLISH ) 
  581.       --teleport_vehicle( RAIL_BOAT_NAME, RAIL_BOAT_NAME ) 
  582.  
  583.       camera_look_through( RAIL_BOAT_NAME ) 
  584.  
  585.       teleport_vehicle( HELICOPTER_NAMES[3], HELICOPTER_END_CUTSCENE_POSITION ) 
  586.       camera_end_look_through( true ) 
  587.  
  588.       -- Have it start moving on its path 
  589.       Helicopter_path_threads[3] = thread_new( "ss07_heli_fly", 3 ) 
  590.       -- Wait 
  591.       delay( VEHICLE_FOLLOW_DELAYS_SECONDS[2] ) 
  592.  
  593.       attack_safe( HELICOPTER_CHARACTERS[3][2], LOCAL_PLAYER ) 
  594.       attack_safe( HELICOPTER_CHARACTERS[3][3], LOCAL_PLAYER ) 
  595.  
  596.       -- Start the boat pathfinding 
  597.       thread_new( "ss07_boat_do_path" ) 
  598.    elseif ( new_state == MS_LAND_HO ) then 
  599.       thread_new( "ss07_run_carjacking" ) 
  600.       on_vehicle_enter( "ss07_entered_second_car", RAIL_CAR_TWO_NAME ) 
  601.       on_vehicle_exit( "ss07_left_car", RAIL_CAR_TWO_NAME ) 
  602.       on_vehicle_destroyed( "ss07_rail_vehicle_destroyed", RAIL_CAR_TWO_NAME ) 
  603.       delay( 2.0 ) 
  604.       -- Let the player get out of the car 
  605.       ss07_set_vehicle_interaction_allowed( true ) 
  606.  
  607.       on_vehicle_destroyed( "", RAIL_BOAT_NAME ) 
  608.    elseif ( new_state == MS_FINAL_CHASE ) then 
  609.       mission_set_checkpoint( FINAL_CHASE_CHECKPOINT, true ) 
  610.       -- Again, diallow getting out of the car 
  611.       ss07_set_vehicle_interaction_allowed( false ) 
  612.       ss07_setup_rail_vehicle_damage_tracking( RAIL_CAR_TWO_NAME ) 
  613.  
  614.       ss07_vehicle_multiply_hp( RAIL_CAR_TWO_NAME, RAIL_CAR_TWO_HEALTH_MULTIPLIER ) 
  615.  
  616.       thread_new( "ss07_car_dialog_and_singalong", from_checkpoint ) 
  617.  
  618.       -- Spawn the helicopter 
  619.       ss07_create_and_init_helicopter( 5 ) 
  620.       ss07_create_and_init_helicopter( 6 ) 
  621.       -- Let it fly past 
  622.       Helicopter_path_threads[5] = thread_new( "ss07_heli_fly", 5 ) 
  623.  
  624.       delay( VEHICLE_FOLLOW_DELAYS_SECONDS[3] ) 
  625.  
  626.       attack_safe( HELICOPTER_CHARACTERS[5][2], LOCAL_PLAYER ) 
  627.       attack_safe( HELICOPTER_CHARACTERS[5][3], LOCAL_PLAYER ) 
  628.  
  629.       -- Start the car pathfinding 
  630.       thread_new( "ss07_rail_car_do_path", 2, MS_END_OF_MISSION ) 
  631.  
  632.       -- Resume notoriety spawning now that the car is underway. We stopped it 
  633.       -- so that Pierce could get in the second rail car 
  634.       notoriety_force_no_spawn( ENEMY_GANG, false ) 
  635.       -- Resume police spawning for the same reason 
  636.       ambient_cop_spawn_enable( true ) 
  637.    end 
  638. end 
  639.  
  640. function ss07_car_dialog_and_singalong( from_checkpoint ) 
  641.    if ( from_checkpoint == false ) then 
  642.       audio_play_for_character( PIERCE_CARJACKING_DIALOG_LINE, PIERCE_NAME, "voice", false, true ) 
  643.    else 
  644.       delay( 3.0 ) 
  645.    end 
  646.    audio_suppress_ambient_player_lines( true ) 
  647.    -- Reset the station to the beginning 
  648.    audio_play_for_character( PIERCE_NEED_SOME_MUSIC_LINE, PIERCE_NAME, "voice", false, false ) 
  649.    radio_set_sing_along( PIERCE_NAME ) 
  650.    radio_set_station( RAIL_CAR_TWO_NAME, PIERCE_RADIO_STATION_INDEX ) 
  651.    radio_reset_station( RAIL_CAR_TWO_NAME ) 
  652.    delay( 17.725783 ) 
  653.    audio_play_for_character( PLAYER_YOU_MUST_BE_KIDDING_LINE, LOCAL_PLAYER, "voice", false, false ) 
  654.    delay( 28.551597 ) 
  655.    audio_play_for_character( PLAYER_YOU_ARE_BAD_AT_SINGING_LINE, LOCAL_PLAYER, "voice", false, true ) 
  656.    audio_suppress_ambient_player_lines( false ) 
  657. end 
  658.  
  659. function ss07_setup_rail_vehicle_damage_tracking( rail_vehicle_name ) 
  660.    -- Setup death tracking 
  661.    on_vehicle_destroyed( "ss07_rail_vehicle_destroyed", rail_vehicle_name ) 
  662. end 
  663.  
  664. function ss07_rail_vehicle_destroyed() 
  665.    mission_end_failure( MISSION_NAME, HT_PIERCES_VEHICLE_DESTROYED ) 
  666. end 
  667.  
  668. function ss07_pierce_died() 
  669.    mission_end_failure( MISSION_NAME, HT_PIERCE_DIED ) 
  670. end 
  671.  
  672. function ss07_pierce_abandoned() 
  673.    mission_end_failure( MISSION_NAME, HT_PIERCE_ABANDONED ) 
  674. end 
  675.  
  676. function ss07_entered_boat( player_name ) 
  677.    -- Check to see if all the players have entered the boat 
  678.    mission_debug( "entered boat called", 30 ) 
  679.    Players_in_boat[player_name] = true 
  680.  
  681.    -- If so, then proceed to the next state 
  682.    if ( ss07_all_players_in_vehicle( Players_in_boat ) and 
  683.         character_is_in_vehicle( PIERCE_NAME, RAIL_BOAT_NAME ) == true ) then 
  684.       on_vehicle_enter( "", RAIL_BOAT_NAME ) 
  685.       marker_remove_vehicle( RAIL_BOAT_NAME, SYNC_ALL ) 
  686.       ss07_switch_state( MS_PATHFINDING_BOAT ) 
  687.    end 
  688. end 
  689.  
  690. function ss07_left_boat( player_name ) 
  691.    -- Update the in/out status of the player 
  692.    Players_in_boat[player_name] = false 
  693. end 
  694.  
  695. function ss07_entered_second_car( player_name, vehicle_name ) 
  696.    --if ( vehicle_name == RAIL_CAR_TWO_NAME ) then 
  697.       -- Check to see if all the players have entered the car 
  698.       Players_in_hijacked_car[player_name] = true 
  699.  
  700.       -- If so, then proceed to the next state 
  701.       if ( ss07_all_players_in_vehicle( Players_in_hijacked_car ) and 
  702. 			  character_is_in_vehicle( PIERCE_NAME, RAIL_CAR_TWO_NAME ) ) then 
  703.          on_vehicle_enter( "", RAIL_CAR_TWO_NAME ) 
  704.          marker_remove_vehicle( RAIL_CAR_TWO_NAME, SYNC_ALL ) 
  705.          ss07_switch_state( MS_FINAL_CHASE ) 
  706.       end 
  707.    --end 
  708. end 
  709.  
  710. function ss07_left_car( player_name ) 
  711.    -- Update the in/out status of the player 
  712.    Players_in_hijacked_car[player_name] = false 
  713. end 
  714.  
  715. function ss07_pierce_exit_vehicle_and_go_to_boat() 
  716.    -- 
  717.    vehicle_suppress_npc_exit( RAIL_CAR_ONE_NAME, false ) 
  718.    vehicle_exit( PIERCE_NAME ) 
  719.    turn_vulnerable( PIERCE_NAME ) 
  720.    set_ignore_ai_flag( PIERCE_NAME, true ) 
  721.  
  722.    player_force_vehicle_seat( LOCAL_PLAYER, 1, RAIL_BOAT_NAME ) 
  723.    if ( coop_is_active() ) then 
  724.       player_force_vehicle_seat( REMOTE_PLAYER, 2, RAIL_BOAT_NAME ) 
  725.    end 
  726.  
  727.    move_to_safe( PIERCE_NAME, PIERCE_NEAR_DOCK, 2, false, false ) 
  728.    while( character_is_dead( PIERCE_NAME ) ) do 
  729.       thread_yield() 
  730.    end 
  731.  
  732.    vehicle_enter_teleport( PIERCE_NAME, RAIL_BOAT_NAME, 0 ) 
  733.    turn_invulnerable( PIERCE_NAME ) 
  734.    set_ignore_ai_flag( PIERCE_NAME, false ) 
  735.  
  736.    if ( ss07_all_players_in_vehicle( Players_in_boat ) and 
  737.         character_is_in_vehicle( PIERCE_NAME, RAIL_BOAT_NAME ) == true ) then 
  738.       on_vehicle_enter( "", RAIL_BOAT_NAME ) 
  739.       marker_remove_vehicle( RAIL_BOAT_NAME, SYNC_ALL ) 
  740.       ss07_switch_state( MS_PATHFINDING_BOAT ) 
  741.    end 
  742. end 
  743.  
  744. function ss07_setup_rail_vehicle_for_chase( rail_vehicle_name ) 
  745.    vehicle_set_crazy( rail_vehicle_name, true ) 
  746.    vehicle_infinite_mass( rail_vehicle_name, true ) 
  747.    vehicle_ignore_repulsors( rail_vehicle_name, true ) 
  748.    vehicle_suppress_npc_exit( rail_vehicle_name, true ) 
  749.    vehicle_disable_chase( rail_vehicle_name, true ) 
  750.    vehicle_disable_flee( rail_vehicle_name, true ) 
  751. end 
  752.  
  753. function ss07_carjack_pathfind() 
  754.    vehicle_pathfind_to( RAIL_CAR_TWO_NAME, CARJACKED_CAR_PATH, true, true ) 
  755.  
  756.    -- Prevent her from driving off and breaking the mission! 
  757.    vehicle_disable_chase( RAIL_CAR_TWO_NAME ) 
  758.    vehicle_disable_flee( RAIL_CAR_TWO_NAME ) 
  759. end 
  760.  
  761. function ss07_create_and_init_second_rail_car() 
  762.    group_show( RAIL_CAR_TWO_GROUP ) 
  763.    group_show( CARJACK_VICTIM_GROUP ) 
  764.    ss07_setup_rail_vehicle_for_chase( RAIL_CAR_TWO_NAME ) 
  765.    vehicle_enter_teleport( RAIL_CAR_TWO_CARJACK_VICTIM_NAME, RAIL_CAR_TWO_NAME, 0, true ) 
  766. end 
  767.  
  768. function ss07_run_carjacking() 
  769.    character_allow_ragdoll( PIERCE_NAME, false ) 
  770.  
  771.    -- Set up the forced vehicle seat information. This also clears the overrides for seat locations 
  772.    -- on the boat 
  773.    player_force_vehicle_seat( LOCAL_PLAYER, 2, RAIL_CAR_TWO_NAME ) 
  774.    if ( coop_is_active() ) then 
  775.       player_force_vehicle_seat( REMOTE_PLAYER, 3, RAIL_CAR_TWO_NAME ) 
  776.    end 
  777.  
  778.    vehicle_set_radio_controls_locked( RAIL_CAR_TWO_NAME, true ) 
  779.    radio_set_station( RAIL_CAR_TWO_NAME, CLASSIC_RADIO_STATION_INDEX ) 
  780.  
  781.    -- Have Pierce go to point 1 
  782.    vehicle_exit( PIERCE_NAME ) 
  783.    --teleport( PIERCE_NAME, CARJACK_POINT_ONE ) 
  784.    move_to( PIERCE_NAME, CARJACK_POINT_ONE, 2, true, false ) 
  785.  
  786.    set_ignore_ai_flag( PIERCE_NAME, true ) 
  787.  
  788.    -- Have the car drive to the location 
  789.    thread_new( "ss07_carjack_pathfind" ) 
  790.    -- Have Pierce pathfind to the second and third points 
  791.    move_to( PIERCE_NAME, CARJACK_POINT_TWO, CARJACK_POINT_THREE, 2, true, false ) 
  792.  
  793.    -- Once there, it should look like he stopped the car by standing in front of it 
  794.    -- Have him get in, so it seems that he carjacked the car. 
  795.    local force_hijack_success = true 
  796.    vehicle_enter( PIERCE_NAME, RAIL_CAR_TWO_NAME, 0, true, force_hijack_success ) 
  797.    vehicle_speed_override( RAIL_CAR_TWO_NAME, 0 ) 
  798.  
  799.    character_allow_ragdoll( PIERCE_NAME, true ) 
  800.  
  801. 	-- If everyone's already in, then lock them in 
  802. 	if ( ss07_all_players_in_vehicle( Players_in_hijacked_car ) and 
  803. 		  character_is_in_vehicle( PIERCE_NAME, RAIL_CAR_TWO_NAME ) ) then 
  804. 		ss07_set_vehicle_interaction_allowed( false ) 
  805. 	-- If someone's not in yet, then give a prompt to get in 
  806. 	else 
  807. 		mission_help_table( HT_GET_INTO_CAR ) 
  808. 		marker_add_vehicle( RAIL_CAR_TWO_NAME, MINIMAP_ICON_PROTECT_ACQUIRE, INGAME_EFFECT_VEHICLE_PROTECT_ACQUIRE, SYNC_ALL ) 
  809. 	end 
  810. end 
  811.  
  812. function ss07_boat_do_path() 
  813.    vehicle_suppress_npc_exit( RAIL_BOAT_NAME, true ) 
  814.  
  815.    vehicle_speed_override( RAIL_BOAT_NAME, BOAT_PATH_SPEED_MPS ) 
  816.    local use_navmesh = true 
  817.    local stop_at_goal = true 
  818.    vehicle_pathfind_to( RAIL_BOAT_NAME, RAIL_BOAT_PATH, use_navmesh, stop_at_goal ) 
  819.  
  820.    ss07_switch_state( MS_LAND_HO ) 
  821. end 
  822.  
  823. function ss07_create_and_init_helicopter( heli_index ) 
  824.    -- Create the heli's group 
  825.    if ( HELICOPTER_HOLDING_POSITIONS[heli_index] ~= nil or heli_index == 3 ) then 
  826.       group_create( HELICOPTER_GROUPS[heli_index], true ) 
  827.    else 
  828.       group_create_hidden( HELICOPTER_GROUPS[heli_index], true ) 
  829.    end 
  830.  
  831.    -- Have the people get on board 
  832.    vehicle_enter_teleport( HELICOPTER_CHARACTERS[heli_index][1], HELICOPTER_NAMES[heli_index], 0 ) 
  833.    vehicle_enter_teleport( HELICOPTER_CHARACTERS[heli_index][2], HELICOPTER_NAMES[heli_index], 4 ) 
  834.    vehicle_enter_teleport( HELICOPTER_CHARACTERS[heli_index][3], HELICOPTER_NAMES[heli_index], 5 ) 
  835.  
  836.    turn_invulnerable( HELICOPTER_CHARACTERS[heli_index][1] ) 
  837.  
  838.    -- Bind a callback for destruction, because we need to know when this heli is destroyed 
  839.    local on_destroyed_callback_name = "ss07_destroyed_heli_"..heli_index 
  840.  
  841.    on_vehicle_destroyed( on_destroyed_callback_name, HELICOPTER_NAMES[heli_index] ) 
  842.  
  843.  
  844.    if ( HELICOPTER_HOLDING_POSITIONS[heli_index] ~= nil ) then 
  845.       helicopter_fly_to_direct( HELICOPTER_NAMES[heli_index], HELICOPTER_TO_HOLDING_POS_SPEED_MPS, HELICOPTER_HOLDING_POSITIONS[heli_index] ) 
  846.    end 
  847.  
  848.    ss07_vehicle_multiply_hp( HELICOPTER_NAMES[heli_index], HELICOPTER_HP_MULTIPLIERS[heli_index] ) 
  849. end 
  850.  
  851. function ss07_setup_heli_triggers() 
  852.    trigger_enable( HELICOPTER_TRIGGERS[2], true ) 
  853.    on_trigger( "ss07_heli_two_start", HELICOPTER_TRIGGERS[2] ) 
  854.    trigger_enable( HELICOPTER_TRIGGERS[4], true ) 
  855.    on_trigger( "ss07_heli_four_start", HELICOPTER_TRIGGERS[4] ) 
  856.    trigger_enable( HELICOPTER_TRIGGERS[6], true ) 
  857.    on_trigger( "ss07_heli_six_start", HELICOPTER_TRIGGERS[6] ) 
  858. end 
  859.  
  860. function ss07_heli_two_start() 
  861.    delay( HELI_TWO_START_DELAY ) 
  862.    Helicopter_path_threads[2] = thread_new( "ss07_heli_fly", 2 ) 
  863.  
  864.    attack_safe( HELICOPTER_CHARACTERS[2][2], LOCAL_PLAYER ) 
  865.    attack_safe( HELICOPTER_CHARACTERS[2][3], LOCAL_PLAYER ) 
  866.  
  867.    delay( HELI_TWO_PIERCE_BLAB_DELAY_SECONDS ) 
  868.    audio_play_for_character( PIERCE_CALLING_OUT_NEXT_HELICOPTER, PIERCE_NAME, "voice", false, false ) 
  869. end 
  870.  
  871. function ss07_heli_four_start() 
  872.    delay( HELI_FOUR_START_DELAY ) 
  873.    Helicopter_path_threads[4] = thread_new( "ss07_heli_fly", 4 ) 
  874.  
  875.    attack_safe( HELICOPTER_CHARACTERS[4][2], LOCAL_PLAYER ) 
  876.    attack_safe( HELICOPTER_CHARACTERS[4][3], LOCAL_PLAYER ) 
  877.  
  878.    delay( HELI_FOUR_PIERCE_BLAB_DELAY_SECONDS ) 
  879.    audio_play_for_character( PIERCE_CALLING_OUT_NEXT_HELICOPTER, PIERCE_NAME, "voice", false, false ) 
  880. end 
  881.  
  882. function ss07_heli_six_start() 
  883.    delay( HELI_SIX_START_DELAY ) 
  884.    Helicopter_path_threads[6] = thread_new( "ss07_heli_fly", 6 ) 
  885.  
  886.    attack_safe( HELICOPTER_CHARACTERS[6][2], LOCAL_PLAYER ) 
  887.    attack_safe( HELICOPTER_CHARACTERS[6][3], LOCAL_PLAYER ) 
  888.  
  889.    --delay( HELI_SIX_PIERCE_BLAB_DELAY_SECONDS ) 
  890.    --audio_play_for_character( PIERCE_CALLING_OUT_NEXT_HELICOPTER, PIERCE_NAME, "voice", false, false ) 
  891. end 
  892.  
  893. function ss07_destroyed_heli_1() 
  894.    ss07_heli_destroyed( 1 ) 
  895. end 
  896.  
  897. function ss07_destroyed_heli_2() 
  898.    ss07_heli_destroyed( 2 ) 
  899. end 
  900.  
  901. function ss07_destroyed_heli_3() 
  902.    ss07_heli_destroyed( 3 ) 
  903. end 
  904.  
  905. function ss07_destroyed_heli_4() 
  906.    ss07_heli_destroyed( 4 ) 
  907. end 
  908.  
  909. function ss07_destroyed_heli_5() 
  910.    ss07_heli_destroyed( 5 ) 
  911. end 
  912.  
  913. function ss07_destroyed_heli_6() 
  914.    ss07_heli_destroyed( 6 ) 
  915. end 
  916.  
  917. function ss07_heli_destroyed( heli_index ) 
  918.    Num_helicopters_destroyed = Num_helicopters_destroyed + 1 
  919.    objective_text( 0, HT_X_OF_Y_HELICOPTERS_DESTROYED, Num_helicopters_destroyed, HELICOPTER_COUNT, SYNC_ALL ) 
  920.    marker_remove_vehicle( HELICOPTER_NAMES[heli_index] ) 
  921.  
  922.    -- Make the pilot vulnerable and kill him 
  923.    turn_vulnerable( HELICOPTER_CHARACTERS[heli_index][1] ) 
  924.    character_kill( HELICOPTER_CHARACTERS[heli_index][1] ) 
  925.  
  926.    notoriety_set_min( ENEMY_GANG, HELI_DESTROYED_MIN_NOTORIETY_LEVELS[heli_index] ) 
  927.  
  928.    if ( Helicopter_path_threads[heli_index] ~= INVALID_THREAD_HANDLE ) then 
  929.       thread_kill( Helicopter_path_threads[heli_index] ) 
  930.       Helicopter_path_threads[heli_index] = INVALID_THREAD_HANDLE 
  931.    end 
  932.  
  933.    if ( Num_helicopters_destroyed == HELICOPTER_COUNT ) then 
  934.       mission_end_success( MISSION_NAME, CT_OUTRO ) 
  935.    end 
  936. end 
  937.  
  938. function ss07_do_boat_conversation( triggerer_name, trigger_name ) 
  939.    trigger_enable( trigger_name, false ) 
  940.  
  941.    audio_play_conversation( BOAT_DIALOG_STREAM, NOT_CALL ) 
  942. end 
  943.  
  944. function ss07_rail_car_do_path( car_index, state_after_path_complete ) 
  945.    local segment_count = sizeof_table( RAIL_CARS_PATH_SEGMENTS[car_index] ) 
  946.    -- Go through each segment in the path 
  947.    -- and have the car pathfind in them. 
  948.    for path_index, path_name in pairs( RAIL_CARS_PATH_SEGMENTS[car_index] ) do 
  949.       local stop_at_goal = false 
  950.       local use_navmesh = false 
  951.       vehicle_speed_override( RAIL_CAR_NAMES[car_index], RAIL_CAR_ON_ROAD_RAIL_PATH_SPEEDS_MPS[car_index][path_index] ) 
  952.  
  953.       -- Check for special pathing behavior for this segment 
  954.  
  955.       -- If this is the last segment in the list, it's also the end of this car's path, so we want to 
  956.       -- stop after this segment. 
  957.       if ( path_index == segment_count ) then 
  958.          stop_at_goal = true 
  959.       end 
  960.       if ( RAIL_CARS_PATH_SEGMENTS_USE_ROADS[car_index][path_index] == false ) then 
  961.          use_navmesh = true 
  962.       end 
  963.  
  964.       -- Special cases for car behavior at certain path points 
  965.       if ( car_index == 1 ) then 
  966.          -- Transition to another area - take it more slowly 
  967.          if ( path_index == 2 ) then 
  968.  
  969.          -- The jump 
  970.          elseif ( path_index == 3 ) then 
  971.             audio_play_for_character( PIERCE_MAKING_JUMP_LINE, PIERCE_NAME, "voice", false, false ) 
  972.             delay( AFTER_JUMP_RESUME_PATHING_DELAY_SECONDS ) 
  973.          end 
  974.       elseif ( car_index == 2 ) then 
  975.          if ( path_index == 3 ) then 
  976.             vehicle_ignore_repulsors( RAIL_CAR_NAMES[car_index], true ) 
  977.          elseif ( path_index == 5 ) then 
  978.             vehicle_ignore_repulsors( RAIL_CAR_NAMES[car_index], false ) 
  979.          end 
  980.       end 
  981.  
  982.       mission_debug( RAIL_CAR_NAMES[car_index].." pathing along "..path_name, 12 ) 
  983.       if ( use_navmesh ) then 
  984.          vehicle_pathfind_to( RAIL_CAR_NAMES[car_index], path_name, use_navmesh, stop_at_goal ) 
  985.       else 
  986.          vehicle_turret_base_to( RAIL_CAR_NAMES[car_index], path_name, stop_at_goal ) 
  987.       end 
  988.    end 
  989.  
  990.    ss07_switch_state( state_after_path_complete )  
  991. end 
  992.  
  993. function ss07_get_next_calling_out_heli_line_index() 
  994. 	Cur_calling_out_heli_line_index = Cur_calling_out_heli_line_index + 1 
  995.  
  996. 	if ( Cur_calling_out_heli_line_index > NUM_CALLING_OUT_HELI_LINES ) then 
  997. 		Cur_calling_out_heli_line_index = 1 
  998. 	end 
  999.  
  1000. 	return Cur_calling_out_heli_line_index 
  1001. end 
  1002.  
  1003. function ss07_heli_fly( heli_index ) 
  1004.    -- Heli 3's a special case because of the CTE cutscene 
  1005.    if ( heli_index ~= 3 and HELICOPTER_HOLDING_POSITIONS[heli_index] == nil ) then 
  1006.       group_show( HELICOPTER_GROUPS[heli_index] ) 
  1007.    end 
  1008.    marker_add_vehicle( HELICOPTER_NAMES[heli_index], MINIMAP_ICON_KILL, INGAME_EFFECT_VEHICLE_KILL, SYNC_ALL ) 
  1009.    -- Have the heli fly along its path 
  1010.  
  1011.    -- Find out which function to use based on whether we're direct pathfinding or not 
  1012.    local helicopter_path_is_direct = HELICOPTER_IS_PATH_DIRECT[heli_index] 
  1013.    -- Based on whether the path is piecewise, either do one pathfind or multiple 
  1014.    local helicopter_path_is_piecewise = HELICOPTER_IS_PATH_PIECEWISE[heli_index] 
  1015.   
  1016.    local heli_pathfinding_function = helicopter_fly_to 
  1017.  
  1018.    if ( helicopter_path_is_piecewise == false ) then 
  1019.       if ( helicopter_path_is_direct ) then 
  1020.          heli_pathfinding_function = helicopter_fly_to_direct 
  1021.       end 
  1022.    else 
  1023.       heli_pathfinding_function = helicopter_fly_to_dont_stop 
  1024.  
  1025.       if ( helicopter_path_is_direct ) then 
  1026.          heli_pathfinding_function = helicopter_fly_to_direct_dont_stop 
  1027.       end 
  1028.    end 
  1029.  
  1030.    if ( helicopter_path_is_piecewise ) then 
  1031.       for index, path_name in pairs( HELICOPTER_PATHS[heli_index] ) do 
  1032.          heli_pathfinding_function( HELICOPTER_NAMES[heli_index], HELICOPTER_PATH_SPEEDS_MPS[heli_index][index], path_name ) 
  1033.       end 
  1034.    else 
  1035.       heli_pathfinding_function( HELICOPTER_NAMES[heli_index], HELICOPTER_PATH_SPEEDS_MPS[heli_index], HELICOPTER_PATHS[heli_index] ) 
  1036.    end 
  1037.  
  1038.    -- If the helicopter's still alive, do the last segment, the dropoff and possible failure 
  1039.    if ( ss07_helicopter_still_alive( heli_index ) ) then 
  1040.       -- It's nearby - do the warning ( unless Pierce is distracted by his singing. ) 
  1041.       if ( heli_index < 5 ) then 
  1042. 			local line_index = ss07_get_next_calling_out_heli_line_index() 
  1043.          audio_play_for_character( PIERCE_CALLING_OUT_ALMOST_DROPOFF_LINES[line_index], PIERCE_NAME, "voice", false, false ) 
  1044.       end 
  1045.       mission_help_table_nag( HT_HURRY_UP, "", "", SYNC_ALL ) 
  1046.  
  1047.       helicopter_fly_to_direct( HELICOPTER_NAMES[heli_index], HELICOPTER_DROPOFF_SPEED_MPS, HELICOPTER_DROPOFFS[heli_index] ) 
  1048.  
  1049.       if ( ss07_helicopter_still_alive( heli_index ) ) then 
  1050.  
  1051.          delay( 4.0 ) 
  1052.  
  1053.          -- Drop the package 
  1054.  
  1055.          -- Fail the mission 
  1056.          mission_end_failure( MISSION_NAME, HT_HELICOPTER_MADE_DROPOFF ) 
  1057.       end 
  1058.    end 
  1059. end 
  1060.  
  1061. -- Returns true if the helicopter is still going and false otherwise 
  1062. -- 
  1063. -- heli_index: Index of the helicopter to check. 
  1064. -- 
  1065. function ss07_helicopter_still_alive( heli_index ) 
  1066.    local vehicle_smoking 
  1067.    local vehicle_on_fire 
  1068.    vehicle_smoking, vehicle_on_fire = vehicle_get_smoke_and_fire_state( HELICOPTER_NAMES[heli_index] ) 
  1069.  
  1070.    -- If no one's driving the heli or it's destroyed, the player need not worry about it anymore 
  1071.    if ( get_char_in_vehicle( HELICOPTER_NAMES[heli_index], 0 ) == nil or 
  1072.         vehicle_is_destroyed( HELICOPTER_NAMES[heli_index] ) or 
  1073.         vehicle_on_fire == true ) then 
  1074.       return false 
  1075.    end 
  1076.  
  1077.    return true 
  1078. end 
  1079.  
  1080. function ss07_cleanup() 
  1081. 	-- Cleanup mission here 
  1082.    on_vehicle_enter( "", RAIL_CAR_TWO_NAME ) 
  1083.    on_vehicle_exit( "", RAIL_CAR_TWO_NAME ) 
  1084.    on_vehicle_enter( "", RAIL_BOAT_NAME ) 
  1085.    on_vehicle_exit( "", RAIL_BOAT_NAME ) 
  1086.  
  1087.    inv_weapon_remove_temporary( LOCAL_PLAYER, PLAYER_HELI_KILL_WEAPON )  
  1088.    if ( coop_is_active() ) then 
  1089.       inv_weapon_remove_temporary( REMOTE_PLAYER, PLAYER_HELI_KILL_WEAPON )  
  1090.    end 
  1091.  
  1092.    --party_dismiss( PIERCE_NAME ) 
  1093.  
  1094.    -- Destroy the rail vehicles - the player shouldn't be in them 
  1095. 	if ( group_is_loaded( RAIL_CAR_ONE_GROUP ) ) then 
  1096. 	   group_destroy( RAIL_CAR_ONE_GROUP ) 
  1097. 	end 
  1098. 	if ( group_is_loaded( RAIL_CAR_TWO_GROUP ) ) then 
  1099. 		group_destroy( RAIL_CAR_TWO_GROUP ) 
  1100. 	end 
  1101. 	if ( group_is_loaded( RAIL_BOAT_GROUP ) ) then 
  1102. 	   group_destroy( RAIL_BOAT_GROUP ) 
  1103. 	end 
  1104.  
  1105.    notoriety_force_no_spawn( ENEMY_GANG, false ) 
  1106.    spawning_boats( true ) 
  1107.  
  1108.    player_force_vehicle_seat( LOCAL_PLAYER, -1 ) 
  1109.    if ( coop_is_active() ) then 
  1110.       player_force_vehicle_seat( REMOTE_PLAYER, -1 ) 
  1111.    end 
  1112.  
  1113.    radio_set_sing_along() 
  1114.  
  1115.    ss07_set_vehicle_interaction_allowed( true ) 
  1116.    audio_suppress_ambient_player_lines( false ) 
  1117. 	 
  1118. 	spawning_vehicles( true ) 
  1119. 	spawning_pedestrians( true ) 
  1120. end 
  1121.  
  1122. function ss07_success() 
  1123. 	-- Called when the mission has ended with success 
  1124. end 
  1125.