sr2lua/ss04.lua

  1. -- ss04.lua 
  2. -- SR2 mission script 
  3. -- 3/28/07 
  4. -- Mission help table text tags 
  5.    HT_GO_TO_ON_TRACK_NIGHTCLUB = "ss04_go_to_on_track_nightclub" 
  6.    HT_KILL_VETERAN_CHILD = "ss04_kill_veteran_child" 
  7.    HT_LOOK_FOR_VETERAN_CHILD = "ss04_look_for_veteran_child" 
  8.    HT_TAKE_OUT_VC_CRONIES = "ss04_take_out_vc_cronies" 
  9.    HT_SHAUNDI_DIED = "ss04_shaundi_died" 
  10.    HT_SHAUNDI_ABANDONED = "ss04_shaundi_abandoned" 
  11.    HT_SHAUNDIS_HEALTH = "ss04_shaundis_health" 
  12.    HT_VETERAN_CHILDS_HEALTH = "ss04_veteran_childs_health" 
  13.    HT_FIND_WAY_TO_SEPARATE = "ss04_find_way_to_separate_shaundi_and_vc" 
  14.  
  15. -- Mission states 
  16.    MS_START = 1 
  17.    MS_REACHED_FIRST_NIGHTCLUB = 2 
  18.    MS_FIRST_NIGHTCLUB_CHECKPOINT = 3 
  19.    MS_CLEARED_FIRST_NIGHTCLUB = 4 
  20.    MS_REACHED_SECOND_NIGHTCLUB = 5 
  21.    MS_SECOND_NIGHTCLUB_CHECKPOINT = 6 
  22.    MS_INSIDE_SECOND_NIGHTCLUB = 7 
  23.    MS_REACHED_ON_TRACK_BOTTOM_FLOOR = 8 
  24.  
  25. -- Groups, NPCs, vehicles, navpoints, and other names 
  26.    -- Mission constant names 
  27.    MISSION_NAME = "ss04" 
  28.    -- ( Mission Prefix ) 
  29.    MP = MISSION_NAME.."_$" 
  30.    ENEMY_GANG = "Samedi" 
  31.  
  32.    STOCKS_SHOP_NAME = "HER Bar" 
  33.    ON_TRACK_SHOP_NAME = "BAR Bar" 
  34.  
  35.    -- Checkpoints 
  36.    CP_REACHED_STOCKS_CLUB = "Reached $tock$ nightclub" 
  37.    CP_REACHED_ON_TRACK_CLUB = "Reached On Track nightclub" 
  38.  
  39.    -- Weapons 
  40.    FLASHBANG = "flashbang" 
  41.  
  42.    -- Groups 
  43.    STARTER_VEHICLE_GROUP = MP.."Starter_Vehicle" 
  44.    STARTER_VEHICLE_COOP_GROUP = MP.."Starter_Vehicle_Coop" 
  45.  
  46.    STOCKS_NIGHTCLUB_GROUP = MP.."Stocks_Nightclub" 
  47.  
  48.    STOCKS_NIGHTCLUB_COOP_GROUP = MP.."Stocks_Nightclub_Coop" 
  49.  
  50.    VC_BACKUP_GROUPS = { MP.."VC_Backup_01", MP.."VC_Backup_02" } 
  51.  
  52.    ON_TRACK_NIGHTCLUB_INITIAL_SAMEDI = MP.."On_Track_Initial_Samedi" 
  53.    ON_TRACK_NIGHTCLUB_SECOND_FLOOR_SAMEDI = MP.."On_Track_Second_Floor_Samedi" 
  54.  
  55.    ON_TRACK_NIGHTCLUB_COOP_ATTACK_GROUP = MP.."On_Track_Nightclub_Attackers_Coop" 
  56.  
  57.    VETERAN_CHILD_AND_SHAUNDI_GROUP = MP.."Veteran_Child_and_Shaundi" 
  58.  
  59.    AUSSIE_VETERAN_CHILD_GROUP = MP.."Aussie_Veteran_Child" 
  60.  
  61.    SHAUNDI_GROUP = MP.."Shaundi" 
  62.  
  63.    FLASHBANG_GROUP = MP.."Flashbangs" 
  64.  
  65.    CUTSCENE_GROUP = MP.."Shaundi_and_VC_Cutscene" 
  66.  
  67.    -- NPC names 
  68.    VETERAN_CHILD_LIEUTENANTS = { MP.."VC_L01", MP.."VC_L02", MP.."VC_L03", MP.."VC_L04" } 
  69.    VETERAN_CHILD_LIEUTENANTS_HOMIES = { { MP.."VC_L01_H1" }, { MP.."VC_L02_H1" }, {}, 
  70.                                         { MP.."VC_L04_H1", MP.."VC_L04_H2" } } 
  71.    STOCKS_COOP_MEMBERS = { MP.."Stocks_Coop01", MP.."Stocks_Coop02", 
  72.                            MP.."Stocks_Coop03", MP.."Stocks_Coop04" } 
  73.  
  74.    STOCKS_OFFICE_LIEUTENANT = VETERAN_CHILD_LIEUTENANTS[3] 
  75.  
  76.    VETERAN_CHILD_NAME = MP.."Veteran_Child" 
  77.    AUSSIE_VC_NAME = MP.."Aussie_Veteran_Child" 
  78.  
  79.    ON_TRACK_STAIRWAY_ATTACKERS = { MP.."Stairway_Attackers_01", MP.."Stairway_Attackers_02", 
  80.                                    MP.."Stairway_Attackers_03" } 
  81.  
  82.    SHAUNDI_NAME = MP.."Shaundi" 
  83.  
  84.    VC_BACKUP_GROUPS_MEMBERS = { { MP.."VC_BU_M01", MP.."VC_BU_M02", MP.."VC_BU_M03" }, 
  85.                                 { MP.."VC_BU2_M01", MP.."VC_BU2_M02" } } 
  86.  
  87.    -- Vehicle names 
  88.    STARTER_VEHICLE = MP.."Starter_Vehicle" 
  89.  
  90.    -- Navpoints and paths 
  91.    REMOTE_PLAYER_START_LOCATION = MP.."Remote_Player_Start" 
  92.    LOCAL_PLAYER_START_LOCATION = "mission_start_sr2_city_$ss04" 
  93.    VETERAN_CHILD_HOLD_SHAUNDI_LOCATION = MP.."Veteran_Child_Hold_Shaundi_Location" 
  94.  
  95.    SHOOT_OUT_WINDOWS_NAVPOINTS = { MP.."Blow_Out_Window01", MP.."Blow_Out_Window02" } 
  96.    FLASHBANG_CLUSTER_LOCATIONS = { MP.."FlashbangG1", MP.."FlashbangG2", MP.."FlashbangG3", 
  97.                                    MP.."FlashbangG4", MP.."FlashbangG5" } 
  98.  
  99.    STOCKS_CHECKPOINT_WARP = MP.."Stocks_Checkpoint_Warp" 
  100.    STOCKS_CHECKPOINT_WARP_REMOTE_PLAYER = MP.."Stocks_Checkpoint_Warp_Remote_Player" 
  101.  
  102.    ON_TRACK_POST_CT_WARP_LOCAL = MP.."On_Track_Post_CT_Warp_Local" 
  103.    ON_TRACK_POST_CT_WARP_REMOTE = MP.."On_Track_Post_CT_Warp_Remote" 
  104.  
  105.    -- Triggers 
  106.    SAINTS_LOT_AREA_TRIGGER = MP.."Saints_Parking_Lot_Area" 
  107.  
  108.    STOCKS_ENTRANCE = MP.."Stocks_Entrance" 
  109.    STOCKS_MAIN_CLUB_ENTRANCE = MP.."Stocks_Main_Club_Entrance" 
  110.    STOCKS_AREA = MP.."Stocks_Nightclub_Area" 
  111.    STOCKS_WINDOW_SHOOTING_TRIGGER = MP.."Window_Shooting" 
  112.    STOCKS_STAIRWAY_TRIGGER = MP.."Stairway" 
  113.  
  114.    ON_TRACK_ENTRANCES = { MP.."On_Track_Entrance01", MP.."On_Track_Entrance02" } 
  115.    ON_TRACK_AREA = MP.."On_Track_Nightclub_Area" 
  116.    ON_TRACK_SECOND_FLOOR_SPAWN_TRIGGER = MP.."On_Track_Second_Floor_Spawn_Trigger" 
  117.  
  118.    ON_TRACK_TO_VC_TRIGGERS = { MP.."To_VC_01", MP.."To_VC_02", MP.."To_VC_03" } 
  119.  
  120.    ON_TRACK_BOTTOM_FLOOR_TRIGGER = MP.."On_Track_Bottom_Floor" 
  121.  
  122.    FLOOR_LEASH_LOCATION = MP.."Floor_Leash_Location" 
  123.  
  124.    -- Movers 
  125.    STOCKS_DOOR = "shops_sr2_city_$HER_bar_door" 
  126.  
  127.    ON_TRACK_DOORS = { MP.."On_Track_Door01", MP.."On_Track_Door02" } 
  128.  
  129.    -- Items 
  130.    FLASHBANG_CLUSTERS_FLASHBANGS = { { MP.."FlashbangG1_01", MP.."FlashbangG1_02", MP.."FlashbangG1_03" }, 
  131.                                      { MP.."FlashbangG2_01", MP.."FlashbangG2_02", MP.."FlashbangG2_03" }, 
  132.                                      { MP.."FlashbangG3_01", MP.."FlashbangG3_02", MP.."FlashbangG3_03" }, 
  133.                                      { MP.."FlashbangG4_01", MP.."FlashbangG4_02", MP.."FlashbangG4_03" }, 
  134.                                      { MP.."FlashbangG5_01", MP.."FlashbangG5_02", MP.."FlashbangG5_03" } } 
  135.  
  136.    -- Effects and animation states 
  137.    SHAUNDI_COWER = "cower stand" 
  138.  
  139.    -- Cutscenes 
  140.    CUTSCENE_NAME = "ig_ss04_scene1" 
  141.    AUSSIE_CUTSCENE_NAME = "ig_ss04_scene1alt" 
  142.    CT_INTRO = "ss04-01" 
  143.    CT_OUTRO = "ss04-02" 
  144.  
  145. -- Sound 
  146.    -- Persona overrides 
  147.    VC_HOLDING_SHAUNDI_PERSONA_SITUATION = "custom line 1" 
  148.    VC_PERSONA_OVERRIDES = { { "threat - alert (solo attack)", "DJVC_SS04_ATTACK" }, 
  149.                             { "threat - alert (group attack)", "DJVC_SS04_ATTACK" }, 
  150.                             { "threat - fleeing enemy", "DJVC_SS04_FLEE_1" } } 
  151.  
  152.    -- Lines/Dialog Stream 
  153.    VC_GO_TO_STOCKS_CALL_DIALOG_STREAM = { { "SOS4_PHONECALL_L1", nil, 0 } } 
  154.  
  155.    VC_AND_PLAYER_TAUNT_DIALOG_STREAM = { { "PLAYER_SOS4_TAUNT_L1", LOCAL_PLAYER, 0 }, 
  156.                                          { "SOS4_TAUNT_L2", CELLPHONE_CHARACTER, 0 }, 
  157.                                          { "PLAYER_SOS4_TAUNT_L3", LOCAL_PLAYER, 0 }, 
  158.                                          { "SOS4_TAUNT_L4", CELLPHONE_CHARACTER, 0 }, 
  159.                                          { "PLAYER_SOS4_TAUNT_L5", LOCAL_PLAYER, 0 }, 
  160.                                          { "SOS4_TAUNT_L6", CELLPHONE_CHARACTER, 0 } } 
  161.  
  162.    VC_AND_PLAYER_ARGUE_DIALOG_STREAM = { { "PLAYER_SOS4_ARGUE_L1", LOCAL_PLAYER, 0 }, 
  163.                                          { "SOS4_ARGUE_L2", CELLPHONE_CHARACTER, 0 }, 
  164.                                          { "PLAYER_SOS4_ARGUE_L3", LOCAL_PLAYER, 0 }, 
  165.                                          { "SOS4_ARGUE_L4", CELLPHONE_CHARACTER, 0 }, 
  166.                                          { "PLAYER_SOS4_ARGUE_L5", LOCAL_PLAYER, 0 }, 
  167.                                          { "SOS4_ARGUE_L6", CELLPHONE_CHARACTER, 0 }, 
  168.                                          { "PLAYER_SOS4_ARGUE_L7", LOCAL_PLAYER, 0 } } 
  169.  
  170.    PIERCE_AND_PLAYER_FIRST_CALL_DIALOG_STREAM = { { "PLAYER_SOS4_PHONECALL_1_L1", LOCAL_PLAYER, 0 }, 
  171.                                                   { "SOS4_PHONECALL_1_L2", nil, 0 },  
  172.                                                   { "PLAYER_SOS4_PHONECALL_1_L3", LOCAL_PLAYER, 0 },  
  173.                                                   { "SOS4_PHONECALL_1_L4", nil, 0 } } 
  174.  
  175.    PIERCE_AND_PLAYER_SECOND_CALL_DIALOG_STREAM = { { "PLAYER_SOS4_PHONECALL_2_L1", LOCAL_PLAYER, 0 }, 
  176.                                                    { "SOS4_PHONECALL_2_L2", nil, 0 },  
  177.                                                    { "PLAYER_SOS4_PHONECALL_2_L3", LOCAL_PLAYER, 0 } } 
  178.  
  179.    SHAUNDI_MOAN_AUDIO_NAME = "SHAUNDI_SOS4_MOAN" 
  180.    SHAUNDI_STUNNED_AUDIO_NAME = "SHAUNDI_SOS4_STUN" 
  181.    VC_HOLDING_SHAUNDI_AUDIO_NAME = "DJVC_SS04_HOLDSHAUNDI" 
  182.  
  183. -- Distances 
  184.    FLOOR_LEASH_RADIUS_METERS = 4.5 
  185.  
  186. -- Percents and multipliers 
  187.    VETERAN_CHILD_RETREAT_HP_PERCENT = 0.6 
  188.    SHAUNDI_HEALTH_MULTIPLIER = 3.0 
  189.  
  190.    VC_PER_RELEASE_DAMAGE_PERCENT_ALLOWED = 0.34 
  191.  
  192. -- Time values 
  193.    TEMP_CONVERSATION_DELAY = 3.0 
  194.    MISSION_BEGIN_FADE_IN_TIME_SECONDS = 2.0 
  195.    AFTER_STOCKS_NOTORIETY_INCREASE_TIME_SECONDS = 15.0 
  196.    BEFORE_STOCKS_CELLPHONE_CALL_DELAY_SECONDS = 4.0 
  197.    BEFORE_FIRST_VC_CALL_DELAY_SECONDS = 2.0 
  198.    AFTER_VC_CALL_DELAY_SECONDS = 2.0 
  199.    BETWEEN_PERSONA_LINES_MIN_SECONDS = 6 
  200.    BETWEEN_PERSONA_LINES_MAX_SECONDS = 12 
  201.    BEFORE_PLAYER_FRIGHTENS_VC_SECONDS = 12 
  202.    BEFORE_PLAYER_TAUNTS_VC_SECONDS = 20 
  203.    -- Will need to be reset if this is changed editor-side 
  204.    FLASHBANG_RESPAWN_TIME_SECONDS = 15 
  205.    SECOND_NIGHTCLUB_NOTORIETY_END_SPAWNING_DELAY_SECONDS = 4.0 
  206.    STAIR_ATTACKERS_ATTACK_DELAY_SECONDS = 5.0 
  207.    VC_BACKUP_GROUPS_RESPAWN_DELAY_SECONDS = 10 
  208.  
  209. -- Speeds 
  210.  
  211. -- Constant values and counts 
  212.    VETERAN_CHILD_HIT_POINTS = 6000 
  213.    VETERAN_CHILD_HIT_POINTS_COOP = 9000 
  214.  
  215.    AUSSIE_VC_HIT_POINTS = 12000 
  216.    AUSSIE_VC_HIT_POINTS_COOP = 15000 
  217.  
  218.    AFTER_STOCKS_MIN_NOTORIETY = 3 
  219.    VC_HEALTH_BAR_INDEX = 0 
  220.    SHAUNDI_HEALTH_BAR_INDEX = 1 
  221.    VC_BACKUP_GROUPS_COUNT = sizeof_table( VC_BACKUP_GROUPS ) 
  222.    VC_BACKUP_GROUPS_MEMBER_COUNTS = { sizeof_table( VC_BACKUP_GROUPS_MEMBERS[1] ), 
  223.                                       sizeof_table( VC_BACKUP_GROUPS_MEMBERS[2] ) } 
  224.  
  225. -- Global variables 
  226.    Stocks_required_kills_remaining = 0 
  227.  
  228.    Raise_notoriety_thread_handle = INVALID_THREAD_HANDLE 
  229.    Flashbang_groups_fbs_remaining = { sizeof_table( FLASHBANG_CLUSTERS_FLASHBANGS[1] ), 
  230.                                       sizeof_table( FLASHBANG_CLUSTERS_FLASHBANGS[2] ), 
  231.                                       sizeof_table( FLASHBANG_CLUSTERS_FLASHBANGS[3] ), 
  232.                                       sizeof_table( FLASHBANG_CLUSTERS_FLASHBANGS[4] ), 
  233.                                       sizeof_table( FLASHBANG_CLUSTERS_FLASHBANGS[5] ) } 
  234.    Cur_backup_group_members_remaining = 0 
  235.    Num_panic_instances = 0 
  236.    Num_shaundi_panic_instances = 0 
  237.    VC_call_received = false 
  238.    VC_call_complete = false 
  239.    Controls_disabled = false 
  240.    VC_damage_percent_since_last_release = 0 
  241.    VC_pre_hit_damage_percent = 1.0 
  242.    Testing_Aussie_version = false 
  243.  
  244. -- Finds the cluster index a flashbang belongs to based on the flashbang's name. 
  245. -- 
  246. -- name_to_find: The name of the flashbang to find the cluster index of. 
  247. -- 
  248. function ss04_find_flashbang_cluster_index( name_to_find ) 
  249.    for cluster_index, flashbang_cluster in pairs( FLASHBANG_CLUSTERS_FLASHBANGS ) do 
  250.       for fb_index, fb_name in pairs( flashbang_cluster ) do 
  251.          if ( fb_name == name_to_find ) then 
  252.             return cluster_index 
  253.          end 
  254.       end 
  255.    end 
  256.    return -1 
  257. end 
  258.  
  259. -- This function lets the mission know when a flashbang has respawned. 
  260. -- Re-adds the marker to the flashbangs if it was removed. 
  261. -- 
  262. -- fb_cluster_index: The cluster that just had a flashbang respawn. 
  263. -- 
  264. function ss04_flashbang_respawn_timer( fb_cluster_index ) 
  265.    -- Delay for respawn 
  266.    delay( FLASHBANG_RESPAWN_TIME_SECONDS ) 
  267.    mission_debug( "flashbang in cluster "..fb_cluster_index.." respawned.", 10 ) 
  268.    -- It respawned - increment the count 
  269.    Flashbang_groups_fbs_remaining[fb_cluster_index] = Flashbang_groups_fbs_remaining[fb_cluster_index] + 1 
  270.  
  271.    -- If this is the first to respawn, then add a marker at this location 
  272.    if ( Flashbang_groups_fbs_remaining[fb_cluster_index] == 1 ) then 
  273.       marker_add_navpoint( FLASHBANG_CLUSTER_LOCATIONS[fb_cluster_index], "", INGAME_EFFECT_PROTECT_ACQUIRE, SYNC_ALL ) 
  274.    end 
  275. end 
  276.  
  277. -- Called when a flashbang is picked up. 
  278. -- Removes the marker from the flashbang cluster if none remain. 
  279. -- 
  280. -- picked_up_flashbang_name: Name of the flashbang that was picked up. 
  281. -- 
  282. function ss04_flashbang_picked_up( human_name, picked_up_flashbang_name ) 
  283.    local cluster_index = ss04_find_flashbang_cluster_index( picked_up_flashbang_name ) 
  284.    mission_debug( "flashbang in cluster "..cluster_index.." picked up. ", 10 ) 
  285.  
  286.    Flashbang_groups_fbs_remaining[cluster_index] = Flashbang_groups_fbs_remaining[cluster_index] - 1 
  287.    mission_debug( Flashbang_groups_fbs_remaining[cluster_index].." remain. ", 10 ) 
  288.  
  289.    if ( Flashbang_groups_fbs_remaining[cluster_index] == 0 ) then 
  290.       marker_remove_navpoint( FLASHBANG_CLUSTER_LOCATIONS[cluster_index], SYNC_ALL ) 
  291.    end 
  292.  
  293.    thread_new( "ss04_flashbang_respawn_timer", cluster_index ) 
  294. end 
  295.  
  296. function ss04_start( checkpoint_name, is_restart ) 
  297. 	-- Start trigger is hit...the activate button was hit 
  298. 	set_mission_author("Mark Gabby and Brad Johnson") 
  299.  
  300.    ss04_start_or_resume_from_checkpoint( checkpoint_name, is_restart ) 
  301. end 
  302.  
  303. -- Starts the mission or resumes it from a checkpoint, based on 
  304. -- the value of the passed-in checkpoint name. 
  305. -- 
  306. -- This function does any group creation or other work that causes 
  307. -- the game to "load" before the mission is ready. Therefore, it 
  308. -- fades the screen out before it starts and fades it back in when 
  309. -- it's done. 
  310. -- 
  311. function ss04_start_or_resume_from_checkpoint( checkpoint_name, is_restart ) 
  312.    mission_start_fade_out() 
  313.  
  314.    if ( checkpoint_name == MISSION_START_CHECKPOINT ) then 
  315. 		-- Setup the list of groups we want to create on mission start based on whether we're running in 
  316. 		-- coop or single-player 
  317. 	   local starter_groups = { STARTER_VEHICLE_GROUP, STOCKS_NIGHTCLUB_GROUP } 
  318. 	   if ( coop_is_active() ) then 
  319. 			starter_groups = { STARTER_VEHICLE_GROUP, STARTER_VEHICLE_COOP_GROUP, STOCKS_NIGHTCLUB_GROUP, STOCKS_NIGHTCLUB_COOP_GROUP } 
  320. 		end 
  321.  
  322. 		if ( is_restart == false ) then 
  323. 			cutscene_play( CT_INTRO, starter_groups, { LOCAL_PLAYER_START_LOCATION, REMOTE_PLAYER_START_LOCATION }, false ) 
  324. 			for index, group_name in pairs( starter_groups ) do 
  325. 				group_show( group_name ) 
  326. 			end 
  327. 		else 
  328. 			for index, group_name in pairs( starter_groups ) do 
  329. 				group_create( group_name, true ) 
  330. 			end 
  331. 			teleport_coop( LOCAL_PLAYER_START_LOCATION, REMOTE_PLAYER_START_LOCATION ) 
  332. 		end 
  333.    end 
  334.  
  335.    local state_to_setup 
  336.  
  337.    shop_enable( STOCKS_SHOP_NAME, false ) 
  338.    shop_enable( ON_TRACK_SHOP_NAME, false ) 
  339.  
  340.    ss04_lock_on_track_entrances( true ) 
  341.  
  342.    -- Default checkpoint - means mission is starting from the beginning 
  343.    if ( checkpoint_name == MISSION_START_CHECKPOINT ) then 
  344.       -- Sets the number of required kills remaining at the first nightclub 
  345.       ss04_create_first_nightclub_groups(); 
  346.  
  347.       spawning_allow_gang_team_ambient_spawns( HUMAN_TEAM_RONIN, false ) 
  348.  
  349.       state_to_setup = MS_START 
  350.    -- The player reached the $tock$ nightclub on a previous playthrough 
  351.    elseif ( checkpoint_name == CP_REACHED_STOCKS_CLUB ) then 
  352.       -- Create the groups for the first nightclub and sets the number 
  353. 		-- of required kills remaining there 
  354.       ss04_create_first_nightclub_groups(); 
  355.  
  356.       spawning_allow_gang_team_ambient_spawns( HUMAN_TEAM_RONIN, false ) 
  357.       teleport_coop( STOCKS_CHECKPOINT_WARP, STOCKS_CHECKPOINT_WARP_REMOTE_PLAYER ) 
  358.  
  359.       state_to_setup = MS_FIRST_NIGHTCLUB_CHECKPOINT 
  360.    -- The player reached the On Track nightclub on a previous playthrough 
  361.    elseif ( checkpoint_name == CP_REACHED_ON_TRACK_CLUB ) then 
  362.       -- Create the groups for the second nightclub 
  363.       state_to_setup = MS_SECOND_NIGHTCLUB_CHECKPOINT 
  364.       -- Create Veteran child's group and the attackers so they will all load quickly 
  365.       -- when required 
  366.       ss04_create_on_track_nightclub_groups() 
  367.       ss04_lock_on_track_entrances( false ) 
  368.       notoriety_set_min( ENEMY_GANG, AFTER_STOCKS_MIN_NOTORIETY ) 
  369.    end 
  370.    mission_start_fade_in() 
  371.  
  372.    ss04_setup_state( state_to_setup ) 
  373. end 
  374.  
  375. -- Sets the $tock$ entrances to be locked or unlocked. 
  376. -- 
  377. function ss04_lock_stocks_entrances( lock_state ) 
  378.    door_lock( STOCKS_DOOR, lock_state ) 
  379. end 
  380.  
  381. -- Sets the On Track Nightclubs doors to be locked or unlocked. 
  382. -- 
  383. function ss04_lock_on_track_entrances( lock_state ) 
  384.    -- Lock or unlock the doors to the On Track nightclub to 
  385.    -- control access - we don't want the players going in 
  386.    -- before it's allowed. 
  387.    for index, name in pairs( ON_TRACK_DOORS ) do 
  388.       --door_close( name ) 
  389.       door_lock( name, lock_state ) 
  390.    end 
  391. end 
  392.  
  393. function ss04_pierce_and_veteran_child_call() 
  394.    trigger_enable( SAINTS_LOT_AREA_TRIGGER, false ) 
  395.  
  396.    audio_play_conversation( PIERCE_AND_PLAYER_FIRST_CALL_DIALOG_STREAM, OUTGOING_CALL ) 
  397.  
  398.    delay( BEFORE_PLAYER_TAUNTS_VC_SECONDS ) 
  399.  
  400.    audio_play_conversation( VC_AND_PLAYER_TAUNT_DIALOG_STREAM, OUTGOING_CALL ) 
  401. end 
  402.  
  403. function ss04_vc_call_received() 
  404.    VC_call_received = true 
  405. end 
  406.  
  407. function ss04_vc_call_player() 
  408.    mid_mission_phonecall( "ss04_vc_call_received" ) 
  409.  
  410.    local incoming_call_thread = thread_new( "ss04_play_vc_call_on_answer" ) 
  411.  
  412.    delay( 10.0 ) 
  413.  
  414.    if ( VC_call_received == false ) then 
  415.       thread_kill( incoming_call_thread ) 
  416.       mid_mission_phonecall_reset() 
  417.  
  418.       audio_play( CELLPHONE_INCOMING ) 
  419.       delay( 1.0 ) 
  420.  
  421.       audio_play_conversation( VC_GO_TO_STOCKS_CALL_DIALOG_STREAM, INCOMING_CALL ) 
  422.  
  423.       VC_call_complete = true 
  424.    end 
  425. end 
  426.  
  427. function ss04_play_vc_call_on_answer() 
  428.    repeat 
  429.       thread_yield() 
  430.    until VC_call_received 
  431.  
  432.    audio_play_conversation( VC_GO_TO_STOCKS_CALL_DIALOG_STREAM, INCOMING_CALL ) 
  433.  
  434.    mid_mission_phonecall_reset() 
  435.    VC_call_complete = true 
  436. end 
  437.  
  438. -- Sets the mission to a specified state. For example, 
  439. -- when the player reaches the first nightclub, the 
  440. -- required kill lieutenants need to be highlighted and 
  441. -- their 'on death' callbacks set up, among other 
  442. -- things. 
  443. -- 
  444. function ss04_setup_state( state_to_setup ) 
  445.    -- Mission is starting from the beginning 
  446.    if ( state_to_setup == MS_START ) then 
  447.       ss04_lock_stocks_entrances( true ) 
  448.       delay( BEFORE_FIRST_VC_CALL_DELAY_SECONDS ) 
  449.  
  450.       thread_new( "ss04_vc_call_player" ) 
  451.  
  452.       repeat 
  453.          thread_yield() 
  454.       until VC_call_complete 
  455.  
  456.       delay( AFTER_VC_CALL_DELAY_SECONDS ) 
  457.       ss04_lock_stocks_entrances( false ) 
  458.  
  459.       trigger_enable( SAINTS_LOT_AREA_TRIGGER, true ) 
  460.       on_trigger_exit( "ss04_pierce_and_veteran_child_call", SAINTS_LOT_AREA_TRIGGER ) 
  461.  
  462.       -- Give the player a message concerning the objective 
  463.       mission_help_table( HT_LOOK_FOR_VETERAN_CHILD ) 
  464.       -- Guide the player to his objective 
  465.       marker_add_trigger( STOCKS_ENTRANCE, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL ) 
  466.       waypoint_add( STOCKS_ENTRANCE, SYNC_ALL ) 
  467.  
  468.       -- Setup the objective for the player's arrival 
  469.       -- Setup the guide trigger - this one just shows you where the 
  470.       -- entrance to the club is 
  471.       trigger_enable( STOCKS_ENTRANCE, true ) 
  472.       on_trigger( "ss04_reached_stocks_entrance", STOCKS_ENTRANCE ) 
  473.  
  474.       -- Setup the area trigger - this triggers when you're near enough 
  475.       -- to the club 
  476.       trigger_enable( STOCKS_AREA, true ) 
  477.       on_trigger( "ss04_reached_first_club", STOCKS_AREA ) 
  478.  
  479.       -- Set up the trigger that causes the Samedi gang member in the window office 
  480.       -- to possibly shoot out the windows and then shoot the player 
  481.       trigger_enable( STOCKS_WINDOW_SHOOTING_TRIGGER, true ) 
  482.       on_trigger( "ss04_hit_window_shooting_trigger", STOCKS_WINDOW_SHOOTING_TRIGGER ) 
  483.  
  484.       trigger_enable( STOCKS_STAIRWAY_TRIGGER, true ) 
  485.       on_trigger( "ss04_unleash_office_lieutenant", STOCKS_STAIRWAY_TRIGGER ) 
  486.  
  487.    -- The player has hit the trigger surrounding the first nightclub 
  488.    elseif ( state_to_setup == MS_REACHED_FIRST_NIGHTCLUB ) then 
  489.       -- Set the checkpoint then setup the nightclub 
  490.       mission_set_checkpoint( CP_REACHED_STOCKS_CLUB ) 
  491.       trigger_enable( STOCKS_AREA, false ) 
  492.       ss04_setup_first_nightclub() 
  493.  
  494.    -- The player's resuming from the checkpoint set after hitting the 
  495.    -- 'near first nightclub' trigger 
  496.    elseif ( state_to_setup == MS_FIRST_NIGHTCLUB_CHECKPOINT ) then 
  497.       -- Just setup the nightclub, because the checkpoint's already set 
  498.       ss04_setup_first_nightclub() 
  499.  
  500.       -- Set up the trigger that causes the Samedi gang member in the window office 
  501.       -- to possibly shoot out the windows and then shoot the player 
  502.       trigger_enable( STOCKS_WINDOW_SHOOTING_TRIGGER, true ) 
  503.       on_trigger( "ss04_hit_window_shooting_trigger", STOCKS_WINDOW_SHOOTING_TRIGGER ) 
  504.  
  505.       trigger_enable( STOCKS_ENTRANCE, true ) 
  506.       on_trigger( "ss04_reached_stocks_entrance", STOCKS_ENTRANCE ) 
  507.  
  508.    -- The player's cleared the first nightclub of lieutenants. 
  509.    elseif ( state_to_setup == MS_CLEARED_FIRST_NIGHTCLUB ) then 
  510.       spawning_allow_gang_ambient_spawns( true ) 
  511.  
  512.       delay( BEFORE_STOCKS_CELLPHONE_CALL_DELAY_SECONDS ) 
  513.       -- Inform the player of his next goal 
  514.       audio_play_conversation( PIERCE_AND_PLAYER_SECOND_CALL_DIALOG_STREAM, OUTGOING_CALL ) 
  515.  
  516.       -- Spawn a thread that'll eventually have the player call VC and scare him 
  517.       thread_new( "ss04_player_frightens_veteran_child" ) 
  518.  
  519.       mission_help_table( HT_GO_TO_ON_TRACK_NIGHTCLUB ) 
  520.       marker_add_trigger( ON_TRACK_ENTRANCES[1], MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL ) 
  521.       waypoint_add( ON_TRACK_ENTRANCES[1], SYNC_ALL ) 
  522.       trigger_enable( STOCKS_ENTRANCE, true ) 
  523.       on_trigger( "ss04_left_stocks", STOCKS_ENTRANCE ) 
  524.  
  525.       -- Setup the On Track nightclub's entrance triggers. These are used to update 
  526.       -- the minimap guidance 
  527.       for index, name in pairs( ON_TRACK_ENTRANCES ) do 
  528.          trigger_enable( name, true ) 
  529.          on_trigger( "ss04_reached_on_track_entrance", name ) 
  530.       end 
  531.  
  532.       -- It's all right to enter the club now, so unlock the doors 
  533.       ss04_lock_on_track_entrances( false ) 
  534.  
  535.       trigger_enable( ON_TRACK_AREA, true ); 
  536.       on_trigger( "ss04_reached_on_track_area", ON_TRACK_AREA ) 
  537.  
  538.       -- Create Veteran child's group and the attackers so they will all load quickly 
  539.       -- when required 
  540.       ss04_create_on_track_nightclub_groups() 
  541.  
  542.    -- The player has has hit the trigger surrounding the second nightclub 
  543.    elseif ( state_to_setup == MS_REACHED_SECOND_NIGHTCLUB ) then 
  544.       -- Set the checkpoint then setup the nightclub 
  545.       mission_set_checkpoint( CP_REACHED_ON_TRACK_CLUB ) 
  546.       trigger_enable( ON_TRACK_AREA, false ) 
  547.  
  548.       marker_remove_trigger( ON_TRACK_ENTRANCES[1], SYNC_ALL ) 
  549.       marker_add_trigger( ON_TRACK_ENTRANCES[1], "", INGAME_EFFECT_LOCATION, SYNC_ALL ) 
  550.  
  551.       ss04_setup_reached_on_track_nightclub() 
  552.  
  553.    -- The player's resuming from the checkpoint set after hitting the 
  554.    -- 'near second nightclub' trigger 
  555.    elseif ( state_to_setup == MS_SECOND_NIGHTCLUB_CHECKPOINT ) then 
  556.       -- Just setup the nightclub, because the checkpoint's already set 
  557.       ss04_setup_reached_on_track_nightclub() 
  558.  
  559.       -- Guide the player to his next objective 
  560.       mission_help_table( HT_KILL_VETERAN_CHILD ) 
  561.       ss04_enable_next_path_trigger( ON_TRACK_TO_VC_TRIGGERS[1], "ss04_to_vc_01" ) 
  562.  
  563.    -- The player has ventured into the second nightclub 
  564.    elseif ( state_to_setup == MS_INSIDE_SECOND_NIGHTCLUB ) then 
  565.       persona_override_group_start( SAMEDI_PERSONAS, POT_SITUATIONS[POT_ATTACK], "SS04_ATTACK" ) 
  566.  
  567.       thread_new( "ss04_stair_attackers_setup_and_attack_after_delay" ) 
  568.    elseif ( state_to_setup == MS_REACHED_ON_TRACK_BOTTOM_FLOOR ) then 
  569.       fade_out( 0 ) 
  570.       spawning_pedestrians( false ) 
  571.       spawning_pedestrians( true ) 
  572.  
  573.       player_controls_disable( LOCAL_PLAYER ) 
  574.       if ( coop_is_active() ) then 
  575.          player_controls_disable( REMOTE_PLAYER ) 
  576.       end 
  577.       Controls_disabled = true 
  578.  
  579.    	teleport( LOCAL_PLAYER, ON_TRACK_POST_CT_WARP_LOCAL, true ) 
  580.       if ( coop_is_active() ) then 
  581.          teleport( REMOTE_PLAYER, ON_TRACK_POST_CT_WARP_REMOTE, true ) 
  582.          while ( get_dist_char_to_nav( REMOTE_PLAYER, ON_TRACK_POST_CT_WARP_REMOTE ) > 10 ) do 
  583.             thread_yield() 
  584.          end 
  585.       end 
  586.  
  587.       player_controls_enable( LOCAL_PLAYER ) 
  588.       if ( coop_is_active() ) then 
  589.          player_controls_enable( REMOTE_PLAYER ) 
  590.       end 
  591.       Controls_disabled = false 
  592.  
  593.       if ( human_shielding_disabled() or Testing_Aussie_version ) then 
  594.          cutscene_play( AUSSIE_CUTSCENE_NAME, "", "", false ) 
  595.       else 
  596.          cutscene_play( CUTSCENE_NAME, "", "", false )       
  597.       end 
  598.       group_hide( CUTSCENE_GROUP ) 
  599.       group_destroy( CUTSCENE_GROUP ) 
  600.       fade_out( 0 ) 
  601.       chainsaw_disable() 
  602.  
  603.       if ( human_shielding_disabled() or Testing_Aussie_version ) then 
  604.          group_create( AUSSIE_VETERAN_CHILD_GROUP, true ) 
  605.          on_death( "ss04_veteran_child_killed", AUSSIE_VC_NAME ) 
  606.  
  607.          marker_add_npc( AUSSIE_VC_NAME, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL ) 
  608.          character_prevent_explosion_fling( AUSSIE_VC_NAME, true ) 
  609.          character_prevent_flinching( AUSSIE_VC_NAME, true ) 
  610.          character_allow_ragdoll( AUSSIE_VC_NAME, false ) 
  611.          character_set_no_satchel_panic( AUSSIE_VC_NAME, true ) 
  612.          set_cant_flee_flag( AUSSIE_VC_NAME, true ) 
  613.  
  614.          local hit_points_to_set = AUSSIE_VC_HIT_POINTS 
  615.          if ( coop_is_active() ) then 
  616.             hit_points_to_set = AUSSIE_VC_HIT_POINTS_COOP 
  617.          end 
  618.          set_max_hit_points( AUSSIE_VC_NAME, hit_points_to_set ) 
  619.          set_current_hit_points( AUSSIE_VC_NAME, hit_points_to_set ) 
  620.          damage_indicator_on( VC_HEALTH_BAR_INDEX, AUSSIE_VC_NAME, 0, HT_VETERAN_CHILDS_HEALTH, hit_points_to_set ) 
  621.  
  622.          fade_in( 1 ) 
  623.          mission_help_table_nag( HT_KILL_VETERAN_CHILD ) 
  624.          attack_closest_player( AUSSIE_VC_NAME ) 
  625.       else 
  626.          -- Show and mark the stun grenades 
  627.          group_show( FLASHBANG_GROUP ) 
  628.          -- Add pickup callbacks and markers. The pickup callbacks add and remove the markers when the 
  629.          -- flashbangs respawn. 
  630.          for cluster_index, flashbang_cluster in pairs( FLASHBANG_CLUSTERS_FLASHBANGS ) do 
  631.             for fb_index, fb_name in pairs( flashbang_cluster ) do 
  632.                on_pickup( "ss04_flashbang_picked_up", fb_name ) 
  633.             end 
  634.          end 
  635.          for cluster_index, cluster_location in pairs( FLASHBANG_CLUSTER_LOCATIONS ) do 
  636.             marker_add_navpoint( cluster_location, "", INGAME_EFFECT_PROTECT_ACQUIRE, SYNC_ALL ) 
  637.          end 
  638.          marker_add_npc( VETERAN_CHILD_NAME, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL ) 
  639.  
  640.          group_show( VETERAN_CHILD_AND_SHAUNDI_GROUP ) 
  641.  
  642.          character_set_no_satchel_panic( VETERAN_CHILD_NAME, true ) 
  643.          character_set_no_satchel_panic( SHAUNDI_NAME, true ) 
  644.          character_prevent_explosion_fling( VETERAN_CHILD_NAME, true ) 
  645.          character_prevent_explosion_fling( SHAUNDI_NAME, true )       
  646.          -- Add her as a follower to the closest player 
  647.          local dist, player = get_dist_closest_player_to_object( SHAUNDI_NAME ) 
  648.          on_death( "ss04_shaundi_died", SHAUNDI_NAME ) 
  649.          character_prevent_flinching( VETERAN_CHILD_NAME, true ) 
  650.          character_allow_ragdoll( VETERAN_CHILD_NAME, false ) 
  651.          character_allow_ragdoll( SHAUNDI_NAME, false ) 
  652.          character_set_only_scripted_grabs( SHAUNDI_NAME, true ) 
  653.          character_suppress_squirted_reaction( SHAUNDI_NAME, true ) 
  654.          character_suppress_squirted_reaction( VETERAN_CHILD_NAME, true ) 
  655.          set_unrecruitable_flag( SHAUNDI_NAME, true )  
  656.          set_cant_flee_flag( VETERAN_CHILD_NAME, true ) 
  657.          npc_dont_auto_equip_or_unequip_weapons( VETERAN_CHILD_NAME, true) 
  658.          on_panic( "ss04_veteran_child_panic", VETERAN_CHILD_NAME ) 
  659.          on_panic( "ss04_shaundi_panic", SHAUNDI_NAME ) 
  660.  
  661.          npc_leash_to_nav( VETERAN_CHILD_NAME, FLOOR_LEASH_LOCATION, FLOOR_LEASH_RADIUS_METERS ) 
  662.          npc_leash_to_nav( SHAUNDI_NAME, FLOOR_LEASH_LOCATION, FLOOR_LEASH_RADIUS_METERS ) 
  663.          npc_leash_set_unbreakable( VETERAN_CHILD_NAME, true ) 
  664.          npc_leash_set_unbreakable( SHAUNDI_NAME, true ) 
  665.  
  666.          -- Take Shaundi hostage 
  667.          character_take_human_shield( VETERAN_CHILD_NAME, SHAUNDI_NAME ) 
  668.          thread_new( "ss04_veteran_child_play_hold_shaundi_lines" ) 
  669.          --thread_new( "ss04_shaundi_play_drugged_moan_lines" ) 
  670.  
  671.          local distance, player = get_dist_closest_player_to_object( VETERAN_CHILD_NAME ) 
  672.  
  673.          turn_to( VETERAN_CHILD_NAME, player, false ) 
  674.          delay( 0.5 ) 
  675.  
  676.          --thread_new( "ss04_veteran_child_emergency_retake" ) 
  677.  
  678.          turn_invulnerable( VETERAN_CHILD_NAME ) 
  679.          on_death( "ss04_veteran_child_killed", VETERAN_CHILD_NAME ) 
  680.  
  681.          for index, override in pairs( VC_PERSONA_OVERRIDES ) do 
  682.             persona_override_character_start( VETERAN_CHILD_NAME, override[1], override[2] ) 
  683.          end 
  684.  
  685.          local hit_points_to_set = VETERAN_CHILD_HIT_POINTS 
  686.          if ( coop_is_active() ) then 
  687.             hit_points_to_set = VETERAN_CHILD_HIT_POINTS_COOP 
  688.          end 
  689.          set_max_hit_points( VETERAN_CHILD_NAME, hit_points_to_set ) 
  690.          set_current_hit_points( VETERAN_CHILD_NAME, hit_points_to_set ) 
  691.  
  692.          local cur_max_shaundi_hp = get_max_hit_points( SHAUNDI_NAME ) 
  693.          local new_shaundi_hp = SHAUNDI_HEALTH_MULTIPLIER * cur_max_shaundi_hp 
  694.          set_max_hit_points( SHAUNDI_NAME, new_shaundi_hp ) 
  695.          set_current_hit_points( SHAUNDI_NAME, new_shaundi_hp ) 
  696.  
  697.          damage_indicator_on( VC_HEALTH_BAR_INDEX, VETERAN_CHILD_NAME, 0, HT_VETERAN_CHILDS_HEALTH, hit_points_to_set ) 
  698.          hud_bar_on( SHAUNDI_HEALTH_BAR_INDEX, "Health", HT_SHAUNDIS_HEALTH, 1.0, SYNC_ALL ) 
  699.          hud_bar_set_value( SHAUNDI_HEALTH_BAR_INDEX, 1.0, SYNC_ALL ) 
  700.          on_take_damage( "ss04_shaundi_damaged", SHAUNDI_NAME ) 
  701.          fade_in( 1.0 ) 
  702.          attack_closest_player( VETERAN_CHILD_NAME ) 
  703.  
  704.          mission_help_table( HT_FIND_WAY_TO_SEPARATE ) 
  705.       end 
  706.  
  707.       thread_new( "ss04_spawn_backup_members" ) 
  708.    end 
  709. end 
  710.  
  711. function ss04_veteran_child_emergency_retake() 
  712.    -- Don't do processing on this until Veteran Child initially has Shaundi as a human shield. 
  713.    repeat 
  714.       thread_yield() 
  715.    until ( character_has_specific_human_shield( VETERAN_CHILD_NAME, SHAUNDI_NAME ) ) 
  716.  
  717.    -- Keep this alive until one of these characters dies 
  718.    repeat 
  719.       -- If Shaundi is not VC's human shield and the panic callback isn't processing, something has fallen 
  720.       -- through the cracks 
  721.       if ( character_has_specific_human_shield( VETERAN_CHILD_NAME, SHAUNDI_NAME ) == false and 
  722.            Num_panic_instances == 0 ) then 
  723.  
  724.          -- Make VC vulnerable since he doesn't have Shaundi 
  725.          turn_vulnerable( VETERAN_CHILD_NAME ) 
  726.  
  727.          -- Have VC try to grab Shaundi until he panics ( and therefore goes into his "grab Shaundi" state automatically ) 
  728.          -- or grabs her 
  729.          repeat 
  730.             npc_go_idle( VETERAN_CHILD_NAME ) 
  731.             character_take_human_shield( VETERAN_CHILD_NAME, SHAUNDI_NAME ) 
  732.             mission_debug( "VC attempting to HS Shaundi - emergency", 2 ) 
  733.             delay( 2.0 ) 
  734.          until ( character_has_specific_human_shield( VETERAN_CHILD_NAME, SHAUNDI_NAME ) or Num_panic_instances > 0 ) 
  735.  
  736.          -- If he grabbed her, then turn him invulnerable 
  737.          if ( character_has_specific_human_shield( VETERAN_CHILD_NAME, SHAUNDI_NAME ) ) then 
  738.             turn_invulnerable( VETERAN_CHILD_NAME ) 
  739.          end 
  740.       end 
  741.       thread_yield() 
  742.    until ( character_is_dead( VETERAN_CHILD_NAME ) or character_is_dead( SHAUNDI_NAME ) ) 
  743. end 
  744.  
  745. function ss04_enable_next_path_trigger( trigger_name, callback ) 
  746.    trigger_enable( trigger_name ) 
  747.    on_trigger( callback, trigger_name ) 
  748.    marker_add_trigger( trigger_name, MINIMAP_ICON_LOCATION, INGAME_EFFECT_LOCATION, SYNC_ALL ) 
  749. end 
  750.  
  751. function ss04_to_vc_01( triggerer_name, trigger_name ) 
  752.    trigger_enable( trigger_name, false ) 
  753.  
  754.    ss04_enable_next_path_trigger( ON_TRACK_TO_VC_TRIGGERS[2], "ss04_to_vc_02" ) 
  755. end 
  756.  
  757. function ss04_to_vc_02( triggerer_name, trigger_name ) 
  758.    trigger_enable( trigger_name, false ) 
  759.  
  760.    ss04_enable_next_path_trigger( ON_TRACK_TO_VC_TRIGGERS[3], "ss04_to_vc_03" ) 
  761. end 
  762.  
  763. function ss04_to_vc_03( triggerer_name, trigger_name ) 
  764.    trigger_enable( trigger_name, false ) 
  765. end 
  766.  
  767. function ss04_backup_group_member_died( name ) 
  768.    Cur_backup_group_members_remaining = Cur_backup_group_members_remaining - 1 
  769.  
  770.    if ( Cur_backup_group_members_remaining == 0 ) then 
  771.       thread_new( "ss04_spawn_backup_members" ) 
  772.    end 
  773. end 
  774.  
  775. function ss04_spawn_backup_members() 
  776.    delay( VC_BACKUP_GROUPS_RESPAWN_DELAY_SECONDS ) 
  777.    -- Randomly select a group index to spawn 
  778.    local group_index = rand_int( 1, VC_BACKUP_GROUPS_COUNT ) 
  779.    mission_debug( "choose index "..group_index ) 
  780.  
  781.    -- Create the group 
  782.    mission_debug( "creating group "..VC_BACKUP_GROUPS[group_index] ) 
  783.    if ( group_is_loaded( VC_BACKUP_GROUPS[group_index] ) ) then 
  784.       release_to_world( VC_BACKUP_GROUPS[group_index] ) 
  785.    end 
  786.    group_create( VC_BACKUP_GROUPS[group_index] ) 
  787.    Cur_backup_group_members_remaining = VC_BACKUP_GROUPS_MEMBER_COUNTS[group_index] 
  788.  
  789.    -- Setup the callbacks and have them all attack 
  790.    for index, member_name in pairs( VC_BACKUP_GROUPS_MEMBERS[group_index] ) do 
  791.       on_death( "ss04_backup_group_member_died", member_name ) 
  792.       local distance, player = get_dist_closest_player_to_object( member_name ) 
  793.       attack_safe( member_name, player, false ) 
  794.    end 
  795. end 
  796.  
  797. -- Player calls Veteran Child and freaks VC out because VC's trap didn't work-  
  798. -- the player is still alive. 
  799. -- Delays before the call is made so that it hopefully happens on the way to the club. 
  800. -- 
  801. function ss04_player_frightens_veteran_child() 
  802.    repeat 
  803.       thread_yield() 
  804.    until ( get_dist_char_to_nav( LOCAL_PLAYER, STOCKS_ENTRANCE ) > 100 ) 
  805.  
  806.    audio_play_conversation( VC_AND_PLAYER_ARGUE_DIALOG_STREAM, OUTGOING_CALL ) 
  807. end 
  808.  
  809. -- Causes Shaundi to play her "drugged moan" lines randomly while being held by 
  810. -- Veteran Child. 
  811. -- 
  812. function ss04_shaundi_play_drugged_moan_lines() 
  813.    while ( 1 ) do 
  814.       local between_lines_seconds = rand_float( BETWEEN_PERSONA_LINES_MIN_SECONDS, 
  815.                                                 BETWEEN_PERSONA_LINES_MAX_SECONDS ) 
  816.  
  817.       delay( between_lines_seconds ) 
  818.       if ( character_has_specific_human_shield( VETERAN_CHILD_NAME, SHAUNDI_NAME ) ) then 
  819.          audio_play_for_character( SHAUNDI_MOAN_AUDIO_NAME, SHAUNDI_NAME, "voice", false, true ) 
  820.       end 
  821.    end 
  822. end 
  823.  
  824. -- This function plays lines for Veteran Child holding Shaundi, assuming that 
  825. -- he's still got her grabbed. If he isn't grabbing her, it just skips playing 
  826. -- lines until he is. 
  827. -- 
  828. function ss04_veteran_child_play_hold_shaundi_lines() 
  829.    while ( 1 ) do 
  830.       local between_lines_seconds = rand_float( BETWEEN_PERSONA_LINES_MIN_SECONDS, 
  831.                                                 BETWEEN_PERSONA_LINES_MAX_SECONDS ) 
  832.  
  833.       delay( between_lines_seconds ) 
  834.       if ( character_has_specific_human_shield( VETERAN_CHILD_NAME, SHAUNDI_NAME ) ) then 
  835.          audio_play_for_character( VC_HOLDING_SHAUNDI_AUDIO_NAME, SHAUNDI_NAME, "voice", false, true ) 
  836.       end 
  837.    end 
  838. end 
  839.  
  840. function ss04_shaundi_panic( stunned_char_name, stun_time_seconds ) 
  841.    Num_shaundi_panic_instances = Num_shaundi_panic_instances + 1 
  842.  
  843.    on_panic( "", SHAUNDI_NAME ) 
  844.  
  845.    repeat 
  846.       thread_yield() 
  847.    until ( character_is_panicking( stunned_char_name ) == false ) 
  848.    if ( Num_shaundi_panic_instances == 1 ) then 
  849.       delay( 0.5 ) 
  850.       set_cant_flee_flag( SHAUNDI_NAME, false ) 
  851.  
  852.       -- dont_leave_cower = true 
  853. 		flee_to_navpoint( SHAUNDI_NAME, FLOOR_LEASH_LOCATION, VETERAN_CHILD_NAME, true ) 
  854.  
  855. 		repeat 
  856. 			thread_yield() 
  857. 		until ( get_dist_char_to_nav( SHAUNDI_NAME, FLOOR_LEASH_LOCATION ) < FLOOR_LEASH_RADIUS_METERS - 1 ) 
  858. 		cower( SHAUNDI_NAME, VETERAN_CHILD_NAME, true ) 
  859.  
  860.       on_panic( "ss04_shaundi_panic", SHAUNDI_NAME ) 
  861.    end 
  862.    Num_shaundi_panic_instances = Num_shaundi_panic_instances - 1 
  863. end 
  864.  
  865. function ss04_setup_vc_to_take_damage() 
  866.    VC_damage_percent_since_last_release = 0 
  867.    VC_pre_hit_damage_percent = get_current_hit_points( VETERAN_CHILD_NAME ) / get_max_hit_points( VETERAN_CHILD_NAME ) 
  868.    turn_vulnerable( VETERAN_CHILD_NAME ) 
  869.    on_take_damage( "ss04_veteran_child_damaged", VETERAN_CHILD_NAME ) 
  870. end 
  871.  
  872. function ss04_setup_vc_as_shielding() 
  873.    turn_invulnerable( VETERAN_CHILD_NAME ) 
  874.    on_take_damage( "", VETERAN_CHILD_NAME ) 
  875. end 
  876.  
  877. function ss04_veteran_child_damaged( attacked_object_name, attacker_name, percent_hp_remaining_after_attack ) 
  878.    -- He's dead. Beyond our help at this point. 
  879.    if ( percent_hp_remaining_after_attack <= 0 ) then 
  880.       return 
  881.    end 
  882.  
  883.    -- Find out how much damage was done in percent to VC by this last hit 
  884.    local vc_max_hp = get_max_hit_points( VETERAN_CHILD_NAME ) 
  885.    local percent_damage_before_hit = get_current_hit_points( VETERAN_CHILD_NAME ) / vc_max_hp 
  886.  
  887.    -- The percent damage is updated to itself plus any percentage just done 
  888.    VC_damage_percent_since_last_release = VC_damage_percent_since_last_release + ( VC_pre_hit_damage_percent - percent_hp_remaining_after_attack ) 
  889.  
  890.    --mission_debug( "VC damaged, percent since last is "..VC_damage_percent_since_last_release..", percent remaining is "..percent_hp_remaining_after_attack, 5 ) 
  891.  
  892.    -- Check if we've reached or exceeded the damage cap 
  893.    if ( VC_damage_percent_since_last_release >= VC_PER_RELEASE_DAMAGE_PERCENT_ALLOWED ) then 
  894.       -- Prevent more damage from being done after this point 
  895.       on_take_damage( "", VETERAN_CHILD_NAME ) 
  896.       turn_invulnerable( VETERAN_CHILD_NAME ) 
  897.    end 
  898.  
  899.    local hp_left = percent_hp_remaining_after_attack * vc_max_hp 
  900.    mission_debug( "hit points remaining: "..hp_left ) 
  901.  
  902.    VC_pre_hit_damage_percent = percent_hp_remaining_after_attack 
  903. end 
  904.  
  905. -- Callback when Veteran child is stunned, as by a stun grenade, for example 
  906. -- 
  907. function ss04_veteran_child_panic( stunned_char_name, stun_time_seconds ) 
  908.    -- Record how many times this function has been called 
  909.    Num_panic_instances = Num_panic_instances + 1 
  910.    mission_debug( "panic called. num instances: "..Num_panic_instances, 10 ) 
  911.    --turn_vulnerable( VETERAN_CHILD_NAME ) 
  912.    ss04_setup_vc_to_take_damage() 
  913.    audio_play_for_character( SHAUNDI_STUNNED_AUDIO_NAME, SHAUNDI_NAME, "voice", false, true ) 
  914.  
  915.    repeat 
  916.       thread_yield() 
  917.    until ( character_is_panicking( stunned_char_name ) == false ) 
  918.  
  919.    -- If this is the final instance of this function, then have VC re-grab Shaundi 
  920.    if ( Num_panic_instances == 1 ) then 
  921.       repeat 
  922.          npc_go_idle( VETERAN_CHILD_NAME ) 
  923.          npc_leash_remove( VETERAN_CHILD_NAME ) 
  924.          character_take_human_shield( VETERAN_CHILD_NAME, SHAUNDI_NAME ) 
  925.          mission_debug( "VC attempting to HS Shaundi", 2 ) 
  926.          delay( 2.0 ) 
  927.       until ( character_has_specific_human_shield( VETERAN_CHILD_NAME, SHAUNDI_NAME ) ) 
  928.       npc_leash_to_nav( VETERAN_CHILD_NAME, FLOOR_LEASH_LOCATION, FLOOR_LEASH_RADIUS_METERS ) 
  929.       npc_leash_set_unbreakable( VETERAN_CHILD_NAME, true ) 
  930.       mission_debug( "VC retook Shaundi as a shield.", 10 ) 
  931.  
  932.       set_ignore_ai_flag( SHAUNDI_NAME, false ) 
  933.       --turn_invulnerable( VETERAN_CHILD_NAME ) 
  934.       ss04_setup_vc_as_shielding() 
  935.       attack_closest_player( VETERAN_CHILD_NAME ) 
  936.    end 
  937.    -- This instance is done, decrement 
  938.    Num_panic_instances = Num_panic_instances - 1 
  939. end 
  940.  
  941. --  
  942. function ss04_create_first_nightclub_groups() 
  943. 	if ( group_is_loaded( STOCKS_NIGHTCLUB_GROUP ) == false ) then 
  944. 		group_create_hidden( STOCKS_NIGHTCLUB_GROUP ) 
  945. 	end 
  946.    Stocks_required_kills_remaining = sizeof_table( VETERAN_CHILD_LIEUTENANTS ) + 
  947.                                      sizeof_table( VETERAN_CHILD_LIEUTENANTS_HOMIES ) 
  948.  
  949.    if ( coop_is_active() ) then 
  950. 		if ( group_is_loaded( STOCKS_NIGHTCLUB_COOP_GROUP ) == false ) then 
  951. 			group_create_hidden( STOCKS_NIGHTCLUB_COOP_GROUP ) 
  952. 		end 
  953.  
  954.       Stocks_required_kills_remaining = Stocks_required_kills_remaining + 
  955.                                         sizeof_table( STOCKS_COOP_MEMBERS ) 
  956.    end 
  957. end 
  958.  
  959. function ss04_create_on_track_nightclub_groups() 
  960.    group_create_hidden( ON_TRACK_NIGHTCLUB_INITIAL_SAMEDI, true ) 
  961.    group_create_hidden( ON_TRACK_NIGHTCLUB_SECOND_FLOOR_SAMEDI, true ) 
  962.    group_create_hidden( VETERAN_CHILD_AND_SHAUNDI_GROUP, true ) 
  963.    group_create_hidden( FLASHBANG_GROUP, true ) 
  964.  
  965.    if ( coop_is_active() ) then 
  966.       group_create_hidden( ON_TRACK_NIGHTCLUB_COOP_ATTACK_GROUP, true ) 
  967.    end 
  968. end 
  969.  
  970. -- Helper function for ss04_setup_state. This will be called while 
  971. -- the player is outside the nightclub. 
  972. -- It gets the nightclub ready and updates the player's objectives. 
  973. -- 
  974. function ss04_setup_first_nightclub() 
  975.    -- Give the player an update concerning the objective 
  976.    mission_help_table( HT_TAKE_OUT_VC_CRONIES ) 
  977.  
  978.    -- Setup the enemies in the club 
  979.    -- Make them visible and add required-kill markers 
  980.    group_show( STOCKS_NIGHTCLUB_GROUP ) 
  981.    if ( coop_is_active() ) then 
  982.       group_show( STOCKS_NIGHTCLUB_COOP_GROUP ) 
  983.    end 
  984.  
  985.    for l_index, l_name in pairs( VETERAN_CHILD_LIEUTENANTS ) do 
  986.       -- Add death tracking 
  987.       on_death( "ss04_stocks_required_kill_died", l_name ) 
  988.  
  989.       -- Add markers and on-death calls for the lieutenant's homies 
  990.       for h_index, h_name in pairs ( VETERAN_CHILD_LIEUTENANTS_HOMIES[l_index] ) do 
  991.          on_death( "ss04_stocks_required_kill_died", h_name ) 
  992.       end 
  993.    end 
  994.  
  995.    if ( coop_is_active() ) then 
  996.       for index, name in pairs( STOCKS_COOP_MEMBERS ) do 
  997.          on_death( "ss04_stocks_required_kill_died", name ) 
  998.       end 
  999.    end 
  1000. end 
  1001.  
  1002. -- Raises the player's notoriety after they kill a Samedi required-kill in 
  1003. -- the $tock$ nightclub. 
  1004. -- 
  1005. function ss04_stocks_raise_notoriety() 
  1006.    local cur_notoriety = notoriety_get_decimal( ENEMY_GANG ) 
  1007.    local increase_per_second = AFTER_STOCKS_MIN_NOTORIETY / AFTER_STOCKS_NOTORIETY_INCREASE_TIME_SECONDS 
  1008.  
  1009.    while ( cur_notoriety < AFTER_STOCKS_MIN_NOTORIETY ) do 
  1010.       local time_elapsed = get_frame_time() 
  1011.  
  1012.       cur_notoriety = cur_notoriety + ( time_elapsed * increase_per_second ) 
  1013.  
  1014.       if ( cur_notoriety > AFTER_STOCKS_MIN_NOTORIETY ) then 
  1015.          cur_notoriety = AFTER_STOCKS_MIN_NOTORIETY 
  1016.       end 
  1017.  
  1018.       notoriety_set( ENEMY_GANG, cur_notoriety ) 
  1019.       delay( 0 ) 
  1020.    end 
  1021.  
  1022.    notoriety_set_min( ENEMY_GANG, AFTER_STOCKS_MIN_NOTORIETY ) 
  1023. end 
  1024.  
  1025. -- Called when one of the required-kill Samedi in the $tock$ nightclub dies. 
  1026. -- 
  1027. -- name: Name of the required-kill Samedi that died. 
  1028. -- 
  1029. function ss04_stocks_required_kill_died( name ) 
  1030.    if ( Raise_notoriety_thread_handle == INVALID_THREAD_HANDLE ) then 
  1031.       Raise_notoriety_thread_handle = thread_new( "ss04_stocks_raise_notoriety" ) 
  1032.    end 
  1033.  
  1034.    marker_remove_npc( name, SYNC_ALL ) 
  1035.    Stocks_required_kills_remaining = Stocks_required_kills_remaining - 1 
  1036.    if ( Stocks_required_kills_remaining <= 0 ) then 
  1037.       ss04_setup_state( MS_CLEARED_FIRST_NIGHTCLUB ) 
  1038.    end 
  1039. end 
  1040.  
  1041. -- Helper function for ss04_setup_state. This will be called while 
  1042. -- the player is outside the nightclub. 
  1043. -- It gets the nightclub ready and updates the player's objectives. 
  1044. -- 
  1045. function ss04_setup_reached_on_track_nightclub() 
  1046.    -- Setup the "inside the nightclub" event to occur when the player opens 
  1047.    -- one of the doors 
  1048.    for index, door_name in pairs( ON_TRACK_DOORS ) do 
  1049.       on_door_opened( "ss04_opened_on_track_door", door_name ) 
  1050.    end 
  1051.  
  1052.    trigger_enable( ON_TRACK_SECOND_FLOOR_SPAWN_TRIGGER, true ) 
  1053.    on_trigger( "ss04_hit_on_track_second_floor_spawn_trigger", ON_TRACK_SECOND_FLOOR_SPAWN_TRIGGER ) 
  1054.  
  1055.    trigger_enable( ON_TRACK_BOTTOM_FLOOR_TRIGGER, true ) 
  1056.    on_trigger( "ss04_reached_bottom_floor", ON_TRACK_BOTTOM_FLOOR_TRIGGER ) 
  1057.  
  1058.    group_show( ON_TRACK_NIGHTCLUB_INITIAL_SAMEDI ) 
  1059. end 
  1060.  
  1061. function ss04_reached_bottom_floor( triggerer_name, trigger_name ) 
  1062.    trigger_enable( trigger_name, false ) 
  1063.  
  1064.    -- Disable the guidance if you reach the floor first 
  1065.    for index, trigger_name in pairs( ON_TRACK_TO_VC_TRIGGERS ) do 
  1066.       trigger_enable( trigger_name, false ) 
  1067.    end 
  1068.  
  1069.    ss04_setup_state( MS_REACHED_ON_TRACK_BOTTOM_FLOOR ) 
  1070. end 
  1071.  
  1072. function ss04_stair_attackers_setup_and_attack_after_delay() 
  1073.    for index, member_name in pairs( ON_TRACK_STAIRWAY_ATTACKERS ) do 
  1074.       set_ignore_ai_flag( member_name, true ) 
  1075.    end 
  1076.    delay( STAIR_ATTACKERS_ATTACK_DELAY_SECONDS ) 
  1077.  
  1078.    for index, member_name in pairs( ON_TRACK_STAIRWAY_ATTACKERS ) do 
  1079.       local distance, player = get_dist_closest_player_to_object( member_name ) 
  1080.       set_ignore_ai_flag( member_name, false ) 
  1081.       attack_safe( member_name, player, false ) 
  1082.    end 
  1083. end 
  1084.  
  1085. function ss04_hit_on_track_second_floor_spawn_trigger( triggerer_name, trigger_name ) 
  1086.    group_show( ON_TRACK_NIGHTCLUB_SECOND_FLOOR_SAMEDI ) 
  1087. end 
  1088.  
  1089. -- Updates the minimap guidance ( removes it ) when the player reaches 
  1090. -- the entrance to the $tock$ club. 
  1091. -- 
  1092. function ss04_reached_stocks_entrance( triggerer_name, trigger_name ) 
  1093.    waypoint_remove( SYNC_ALL ) 
  1094.    marker_remove_trigger( trigger_name, SYNC_ALL ) 
  1095.    trigger_enable( trigger_name, false ) 
  1096.  
  1097.    for l_index, l_name in pairs( VETERAN_CHILD_LIEUTENANTS ) do 
  1098.       -- Add the required-kill markers 
  1099.       marker_add_npc( l_name, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL ) 
  1100.  
  1101.       for h_index, h_name in pairs ( VETERAN_CHILD_LIEUTENANTS_HOMIES[l_index] ) do 
  1102.          -- Add the required-kill markers 
  1103.          marker_add_npc( h_name, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL ) 
  1104.       end 
  1105.    end 
  1106.  
  1107.    if ( coop_is_active() ) then 
  1108.       for index, name in pairs( STOCKS_COOP_MEMBERS ) do 
  1109.          marker_add_npc( name, MINIMAP_ICON_KILL, INGAME_EFFECT_KILL, SYNC_ALL ) 
  1110.       end 
  1111.    end 
  1112.  
  1113.    trigger_enable( STOCKS_MAIN_CLUB_ENTRANCE, true ) 
  1114.    on_trigger( "ss04_entered_stocks_club_area", STOCKS_MAIN_CLUB_ENTRANCE ) 
  1115. end 
  1116.  
  1117. function ss04_entered_stocks_club_area( triggerer_name, trigger_name ) 
  1118.    trigger_enable( trigger_name, false ) 
  1119.  
  1120.    if ( notoriety_get( ENEMY_GANG ) < 1 ) then 
  1121.       notoriety_set( ENEMY_GANG, 1 ) 
  1122.       notoriety_set_min( ENEMY_GANG, 1 ) 
  1123.    end 
  1124.  
  1125.    attack_closest_player( VETERAN_CHILD_LIEUTENANTS[1] ) 
  1126.    attack_closest_player( VETERAN_CHILD_LIEUTENANTS_HOMIES[1][1] ) 
  1127. end 
  1128.  
  1129. function ss04_left_stocks( triggerer_name, trigger_name ) 
  1130.    waypoint_add( ON_TRACK_ENTRANCES[1], SYNC_ALL ) 
  1131.    trigger_enable( trigger_name, false ) 
  1132. end 
  1133.  
  1134. -- Updates the minimap guidance ( removes it ) when the player reaches 
  1135. -- an entrance to the On Track club. 
  1136. -- 
  1137. function ss04_reached_on_track_entrance( triggerer_name, trigger_name ) 
  1138.    trigger_enable( trigger_name, false ) 
  1139.  
  1140.    -- Tell the player to kill VC and guide him to VC 
  1141.    mission_help_table( HT_KILL_VETERAN_CHILD ) 
  1142.    ss04_enable_next_path_trigger( ON_TRACK_TO_VC_TRIGGERS[1], "ss04_to_vc_01" ) 
  1143.  
  1144.    waypoint_remove( SYNC_ALL ) 
  1145.    marker_remove_trigger( ON_TRACK_ENTRANCES[1], SYNC_ALL ) 
  1146.  
  1147.    -- The stocks entrance trigger can cause a waypoint to be set here - 
  1148.    -- it would be silly for it to be triggered again though now that 
  1149.    -- we've reached On Track. 
  1150.    trigger_enable( STOCKS_ENTRANCE, false ) 
  1151. end 
  1152.  
  1153. -- This function is called when the player is outside the first 
  1154. -- nightclub, but close enough to have triggered the trigger. 
  1155. -- 
  1156. function ss04_reached_first_club( triggerer_name, trigger_name ) 
  1157.    trigger_enable( trigger_name, false ) 
  1158.    ss04_setup_state( MS_REACHED_FIRST_NIGHTCLUB ) 
  1159. end 
  1160.  
  1161. -- Called when the player's in range and shooting view of the Samedi 
  1162. -- in the office in the $tock$ nightclub. 
  1163. -- 
  1164. function ss04_hit_window_shooting_trigger( triggerer_name, trigger_name ) 
  1165.    trigger_enable( trigger_name, false ) 
  1166.  
  1167. --[[ 
  1168.    -- Shoot out each window 
  1169.    local fire_once = true 
  1170.    for index, window_name in pairs( SHOOT_OUT_WINDOWS_NAVPOINTS ) do 
  1171.       force_fire( STOCKS_OFFICE_LIEUTENANT, window_name, fire_once ) 
  1172.    end 
  1173. ]] 
  1174.    -- Attack the player 
  1175.    attack_safe( STOCKS_OFFICE_LIEUTENANT, triggerer_name, false ) 
  1176. end 
  1177.  
  1178. -- Called when the player goes up the stairs toward the Samedi in the 
  1179. -- office in the $tock$ nightclub. 
  1180. -- 
  1181. function ss04_unleash_office_lieutenant( triggerer_name, trigger_name ) 
  1182.    trigger_enable( trigger_name, false ) 
  1183.    npc_leash_remove( STOCKS_OFFICE_LIEUTENANT ) 
  1184. end 
  1185.  
  1186. -- This function is called when the player is outside the On Track 
  1187. -- nightclub, but close enough to have triggered the trigger. 
  1188. -- 
  1189. function ss04_reached_on_track_area( triggerer_name, trigger_name ) 
  1190.    ss04_setup_state( MS_REACHED_SECOND_NIGHTCLUB ) 
  1191.  
  1192.    on_trigger( "ss04_entered_on_track_area", trigger_name ) 
  1193.    on_trigger_exit( "ss04_left_on_track_area", trigger_name ) 
  1194.  
  1195.    ss04_entered_on_track_area() 
  1196. end 
  1197.  
  1198. -- Disable notoriety spawning when you're in the second nightclub's area - 
  1199. -- design request. 
  1200. -- 
  1201. function ss04_entered_on_track_area() 
  1202.    delay( SECOND_NIGHTCLUB_NOTORIETY_END_SPAWNING_DELAY_SECONDS ) 
  1203.    notoriety_force_no_spawn( ENEMY_GANG, true ) 
  1204. end 
  1205.  
  1206. -- Re-enable notoriety spawning when you've left the second nightclub's area - 
  1207. -- companion to the design request to disable it when you're in the area. 
  1208. -- 
  1209. function ss04_left_on_track_area() 
  1210.    notoriety_force_no_spawn( ENEMY_GANG, false ) 
  1211. end 
  1212.  
  1213. function ss04_opened_on_track_door() 
  1214.    -- Clear on-door-opened callbacks - we only want them to be triggered once 
  1215.    for index, door_name in pairs( ON_TRACK_DOORS ) do 
  1216.       on_door_opened( "", door_name ) 
  1217.    end 
  1218.    ss04_setup_state( MS_INSIDE_SECOND_NIGHTCLUB ) 
  1219. end 
  1220.  
  1221. function ss04_shaundi_damaged( name, attacker, percent_hp_left ) 
  1222.    local percent_to_set = percent_hp_left 
  1223.    if ( percent_hp_left < 0 ) then 
  1224.       percent_to_set = 0 
  1225.    end 
  1226.  
  1227.    hud_bar_set_value( SHAUNDI_HEALTH_BAR_INDEX, percent_to_set, SYNC_ALL ) 
  1228. end 
  1229.  
  1230. -- Victory function for Veteran child being killed 
  1231. -- 
  1232. function ss04_veteran_child_killed() 
  1233.    character_allow_ragdoll( VETERAN_CHILD_NAME, true ) 
  1234.  
  1235.    if ( human_shielding_disabled() or Testing_Aussie_version ) then 
  1236.       marker_remove_npc( AUSSIE_VC_NAME, SYNC_ALL ) 
  1237.    end 
  1238.  
  1239.    mission_end_success( MISSION_NAME, CT_OUTRO, { LOCAL_PLAYER_START_LOCATION, REMOTE_PLAYER_START_LOCATION } ) 
  1240. end 
  1241.  
  1242. -- Failure function for Shaundi dying 
  1243. -- 
  1244. function ss04_shaundi_died() 
  1245.    hud_bar_set_value( SHAUNDI_HEALTH_BAR_INDEX, 0, SYNC_ALL ) 
  1246.  
  1247.    character_allow_ragdoll( SHAUNDI_NAME, true ) 
  1248.    mission_end_failure( MISSION_NAME, HT_SHAUNDI_DIED ) 
  1249. end 
  1250.  
  1251. -- If the player runs away from Shaundi when Veteran Child's 
  1252. -- still alive, fail the mission. 
  1253. -- 
  1254. function ss04_shaundi_abandoned() 
  1255.    mission_end_failure( MISSION_NAME, HT_SHAUNDI_ABANDONED ) 
  1256. end 
  1257.  
  1258. function ss04_cleanup() 
  1259. 	-- Cleanup mission here 
  1260.    for index, door_name in pairs( ON_TRACK_DOORS ) do 
  1261.       on_door_opened( "", door_name ) 
  1262.    end 
  1263.    shop_enable( STOCKS_SHOP_NAME, true ) 
  1264.    shop_enable( ON_TRACK_SHOP_NAME, true ) 
  1265.    -- The doors should go back to being unlocked after the 
  1266.    -- mission ends 
  1267.    ss04_lock_on_track_entrances( false ) 
  1268.    ss04_lock_stocks_entrances( false ) 
  1269.  
  1270.    spawning_allow_gang_ambient_spawns( true ) 
  1271.    persona_override_group_stop( SAMEDI_PERSONAS, POT_SITUATIONS[POT_ATTACK] ) 
  1272.    notoriety_set_min( ENEMY_GANG, 0 ) 
  1273.    mid_mission_phonecall_reset() 
  1274.    chainsaw_enable() 
  1275.    spawning_pedestrians( true ) 
  1276.  
  1277.    if ( Controls_disabled ) then 
  1278.       player_controls_enable( LOCAL_PLAYER ) 
  1279.       if ( coop_is_active() ) then 
  1280.          player_controls_enable( REMOTE_PLAYER ) 
  1281.       end 
  1282.    end 
  1283. end 
  1284.  
  1285. function ss04_success() 
  1286. 	-- Called when the mission has ended with success 
  1287. end 
  1288.