// IW6 GSC SOURCE
// Generated by https://github.com/xensik/gsc-tool

main()
{
    maps\mp\mp_boneyard_ns_precache::main();
    maps\createart\mp_boneyard_ns_art::main();
    maps\mp\mp_boneyard_ns_fx::main();
    level.mapcustomcratefunc = ::boneyardcustomcratefunc;
    level.mapcustomkillstreakfunc = ::boneyardcustomkillstreakfunc;
    level.mapcustombotkillstreakfunc = ::boneyardcustombotkillstreakfunc;
    maps\mp\_load::main();
    maps\mp\_compass::setupminimap( "compass_map_mp_boneyard_ns" );
    maps\mp\mp_boneyard_ns_anim::main();
    setdvar( "r_lightGridEnableTweaks", 1 );
    setdvar( "r_lightGridIntensity", 1.33 );
    maps\mp\_utility::setdvar_cg_ng( "r_specularColorScale", 2, 4.5 );
    setdvar( "sm_sunShadowScale", 0.6 );
    setdvar( "sm_sunSampleSizeNear", 0.35 );
    level.alarm2_a = spawn( "script_origin", ( -93, 1451, 248 ) );
    level.alarm2_vo = spawn( "script_origin", ( 317, 1449, 247 ) );
    level.alarm2_b = spawn( "script_origin", ( 805, 1443, 275 ) );
    level.fire_event_a = spawn( "script_origin", ( 517, 1463, 14 ) );
    level.fire_event_a2 = spawn( "script_origin", ( 517, 1463, 14 ) );
    level.fire_event_a3 = spawn( "script_origin", ( 517, 1463, 14 ) );
    level.fire_event_b = spawn( "script_origin", ( 381, 1463, -18 ) );
    level.fire_event_b2 = spawn( "script_origin", ( 381, 1463, -18 ) );
    level.fire_event_lp = spawn( "script_origin", ( 280, 1471, 9 ) );
    level.fire_event_lpstart = spawn( "script_origin", ( 280, 1471, 9 ) );
    level.fire_event_lpstop = spawn( "script_origin", ( 280, 1471, 9 ) );
    level.launch_vo1 = spawn( "script_origin", ( 1936, 231, 221 ) );
    level.launch_vo2 = spawn( "script_origin", ( -1028, 534, 368 ) );
    level.launch_command_vo = spawn( "script_origin", ( 2917, 396, 10 ) );
    game["attackers"] = "allies";
    game["defenders"] = "axis";

    while ( !isdefined( level.gametypestarted ) )
        wait 0.05;

    maps\mp\mp_boneyard_ns_killstreak::boneyard_killstreak_disable();
    flag_inits();

    if ( level.gametype == "sd" || level.gametype == "sr" || level.gametype == "grind" )
        setup_no_events( 1, "horizontal rocket fire" );
    else if ( level.gametype == "blitz" || level.gametype == "horde" || maps\mp\_utility::ismlgsystemlink() )
        setup_no_events( 1 );
    else
        setup_events();

    thread join_sync_exploders();

    if ( level.gametype == "horde" || level.gametype == "infect" )
        setup_safeguard();

    level thread initextracollision();
}

initextracollision()
{
    if ( level.gametype == "horde" || level.gametype == "infect" )
    {
        var_0 = getent( "clip128x128x8", "targetname" );
        var_1 = spawn( "script_model", ( -1352, 168, 150 ) );
        var_1.angles = ( 0, 0, 0 );
        var_1 clonebrushmodeltoscriptmodel( var_0 );
    }

    if ( level.xenon || level.xb3 )
    {
        var_2 = spawn( "script_model", ( -136, 1246, 136 ) );
        var_2 setmodel( "comm_desk_part_long" );
        var_2.angles = ( 360, 90, 90 );
        var_3 = spawn( "script_model", ( -136, 1346, 136 ) );
        var_3 setmodel( "comm_desk_part_long" );
        var_3.angles = ( 360, 90, 90 );
        var_4 = spawn( "script_model", ( -136, 1446, 136 ) );
        var_4 setmodel( "comm_desk_part_long" );
        var_4.angles = ( 360, 90, 90 );
        var_5 = spawn( "script_model", ( -136, 1546, 136 ) );
        var_5 setmodel( "comm_desk_part_long" );
        var_5.angles = ( 360, 90, 90 );
        var_6 = spawn( "script_model", ( -132, 1578, 157 ) );
        var_6 setmodel( "light_post_strip_mall_02" );
        var_6.angles = ( 0, 90, 180 );
    }
}

flag_inits()
{
    common_scripts\utility::flag_init( "flag_rocket_countdown" );
    common_scripts\utility::flag_init( "flag_rocket_countdown_fx" );
    common_scripts\utility::flag_init( "flag_rocket_launched" );
    common_scripts\utility::flag_init( "Horizontal_Test_Fired" );
    common_scripts\utility::flag_init( "Horizontal_Test_Firing" );
}

setup_events()
{
    thread set_up_building_facade();
    maps\mp\mp_boneyard_ns_killstreak::boneyard_killstreak_setup();
    boneyard_fire_horizontal_setup();
    getent( "remd_02_proxy", "targetname" ) delete();
    level.rocket_explo = getentarray( "rocket_explo_obj", "targetname" );

    foreach ( var_1 in level.rocket_explo )
        var_1 setup_rocket_explo_part();

    var_3 = getscriptablearray( "scriptable_toy_com_propane_tank02_cheap", "classname" );

    foreach ( var_5 in var_3 )
        var_5 thread rocket_explo_tank_clip_swap();

    level thread maps\mp\mp_boneyard_ns_killstreak::boneyard_killstreak_activate();
    level thread maps\mp\mp_boneyard_ns_killstreak::boneyard_killstreak_endgame();
    level thread boneyard_fire_horizontal_trigger();
    thread play_and_stop_spotlight_fx();
    thread maps\mp\_dlcalienegg::setupeggformap( "alienEasterEgg" );
    maps\mp\_utility::delaythread( 5, ::event_rocket_success, 10, 3 );
    maps\mp\_utility::delaythread( 60, ::event_rocket_explode, 25, 3 );
}

setup_no_events( var_0, var_1 )
{
    getent( "rocket_explo_rocket", "targetname" ) delete();
    var_2 = getentarray( "rocket_explo_obj", "targetname" );

    foreach ( var_4 in var_2 )
    {
        var_5 = getentarray( var_4.target + "_before", "targetname" );
        common_scripts\utility::array_call( var_5, ::delete );
        var_6 = getentarray( var_4.target + "_delete", "targetname" );

        foreach ( var_8 in var_6 )
        {
            var_8 connectpaths();
            var_8 delete();
        }

        if ( isdefined( level.explo_nums["rocket_explo"][var_4.script_label] ) )
            mp_exploder( level.explo_nums["rocket_explo"][var_4.script_label], -60 );
    }

    thread sound_fire_elements();
    level notify( "rocket_crash_01" );
    getent( "remd_02_proxy", "targetname" ) delete();
    getent( "tunnel_exit_A_mantles", "targetname" ) delete();
    var_11 = getentarray( "unbroken_facade", "targetname" );
    common_scripts\utility::array_call( var_11, ::delete );
    mp_exploder( 208, -60 );
    radiusdamage( ( -309, -516, -47 ), 50, 496, 500 );
    level.exploder_queue[5] = spawnstruct();
    level.exploder_queue[5].num = 5;
    level.exploder_queue[5].time = gettime();
    level.exploder_queue[5].starttime = 0;
    var_12 = getscriptablearray( "scriptable_toy_com_propane_tank02_cheap", "classname" );

    foreach ( var_14 in var_12 )
        var_14 thread rocket_explo_tank_clip_swap();

    maps\mp\_utility::delaythread( 3, ::mp_exploder, 21 );
    level thread maps\mp\mp_boneyard_ns_killstreak::boneyard_killstreak_endgame();

    if ( isdefined( var_0 ) && var_0 )
    {
        if ( isdefined( var_1 ) )
        {
            switch ( var_1 )
            {
                case "horizontal rocket fire":
                    maps\mp\mp_boneyard_ns_killstreak::boneyard_killstreak_setup();
                    level thread maps\mp\mp_boneyard_ns_killstreak::boneyard_killstreak_activate();
                    break;
                default:
                    break;
            }
        }
        else
        {
            maps\mp\mp_boneyard_ns_killstreak::boneyard_killstreak_setup();
            boneyard_fire_horizontal_setup();
            level thread maps\mp\mp_boneyard_ns_killstreak::boneyard_killstreak_activate();
            level thread boneyard_fire_horizontal_trigger();
        }
    }

    thread maps\mp\_dlcalienegg::setupeggformap( "alienEasterEgg" );
    maps\mp\_utility::delaythread( 5, ::event_rocket_success, 10, 3 );
    maps\mp\mp_boneyard_ns_killstreak::boneyard_killstreak_enable( 200 );
}

setup_safeguard()
{
    var_0 = getnode( "crawler_ladder_bottom_node", "targetname" );
    var_1 = getnode( "crawler_ladder_top_node", "targetname" );
    disconnectnodepair( var_1, var_0 );
    var_2 = getent( "crawler_ladder", "targetname" );
    var_2 delete();
}

play_and_stop_spotlight_fx()
{
    wait 3;
    mp_exploder( 21 );
    var_0 = ( 5706.71, -2875.28, 456.125 );
    var_1 = ( 270, 0, 0 );
    var_2 = anglestoup( var_1 );
    var_3 = anglestoforward( var_1 );
    var_4 = spawnfx( level._effect["vfx_mp_boneyard_rocket_spot"], var_0, var_3, var_2 );
    triggerfx( var_4 );
    var_5 = ( 6209.81, -2376.86, 446.79 );
    var_6 = ( 307.118, 274.46, 85.1872 );
    var_7 = anglestoup( var_6 );
    var_8 = anglestoforward( var_6 );
    var_9 = spawnfx( level._effect["vfx_mp_boneyard_rocket_spot"], var_5, var_8, var_7 );
    triggerfx( var_9 );
    var_10 = ( 4493.13, -2993.15, -151.985 );
    var_11 = ( 302.07, 56.4086, -61.7638 );
    var_12 = anglestoup( var_11 );
    var_13 = anglestoforward( var_11 );
    var_14 = spawnfx( level._effect["vfx_mp_boneyard_rocket_spot"], var_10, var_13, var_12 );
    triggerfx( var_14 );
    var_15 = ( 15341.6, -606.557, 2176.76 );
    var_16 = ( 315.112, 247.696, 110.105 );
    var_17 = anglestoup( var_16 );
    var_18 = anglestoforward( var_16 );
    var_19 = spawnfx( level._effect["vfx_mp_boneyard_rocket_spot"], var_15, var_18, var_17 );
    triggerfx( var_19 );
    var_20 = ( 15101, -1212.7, 2176.63 );
    var_21 = ( 270, 0, 0 );
    var_22 = anglestoup( var_21 );
    var_23 = anglestoforward( var_21 );
    var_24 = spawnfx( level._effect["vfx_mp_boneyard_rocket_spot"], var_20, var_23, var_22 );
    triggerfx( var_24 );
    var_25 = ( 15261.2, -2023.07, 2176.63 );
    var_26 = ( 308.808, 40.8442, -47.1412 );
    var_27 = anglestoup( var_26 );
    var_28 = anglestoforward( var_26 );
    var_29 = spawnfx( level._effect["vfx_mp_boneyard_rocket_spot"], var_25, var_28, var_27 );
    triggerfx( var_29 );
    level waittill( "rocket_success_blast_off" );
    var_19 delete();
    var_24 delete();
    var_29 delete();
    level waittill( "rocket_explo_blast_off" );
    var_4 delete();
    var_9 delete();
    var_14 delete();
}

setup_rocket_explo_part()
{
    self.clip = getent( self.target, "targetname" );
    self.clip linkto( self );
    self.crash_delete = getentarray( self.target + "_delete", "targetname" );
    self.crash_before = getentarray( self.target + "_before", "targetname" );
    self.crash_after = getentarray( self.target + "_after", "targetname" );
    self.crash_path = getnodearray( self.target + "_traverse", "targetname" );
    self.linked_ents = [];
    self.kill_ents = [ self.clip ];

    if ( isdefined( self.clip.target ) )
    {
        foreach ( var_1 in getentarray( self.clip.target, "targetname" ) )
        {
            var_1 linkto( self );
            self.linked_ents[self.linked_ents.size] = var_1;

            if ( isdefined( var_1.script_noteworthy ) && var_1.script_noteworthy == "push_kill" )
                self.kill_ents[self.kill_ents.size] = var_1;
        }
    }

    self.fall_anim = self.script_label;
    self.start_org = getent( "rocket_explo_explosion", "targetname" );
    self hide();
    common_scripts\utility::array_call( self.linked_ents, ::hide );
    self.origin = self.start_org.origin;
    self.angles = self.start_org.angles;
    self.clip common_scripts\utility::delaycall( 0.05, ::disconnectpaths );
    self.clip common_scripts\utility::delaycall( 0.05, ::setaisightlinevisible, 0 );

    foreach ( var_1 in self.crash_after )
    {
        var_1 hide();
        var_1.origin = var_1.origin - ( 0, 0, 1024 );
    }

    wait 0.1;

    foreach ( var_6 in self.crash_path )
        disconnectnodepair( var_6, getnode( var_6.target, "targetname" ) );
}

set_up_building_facade()
{
    var_0 = getentarray( "unbroken_facade", "targetname" );
    var_1 = getentarray( "broken_facade", "targetname" );

    foreach ( var_3 in var_1 )
        var_3 hide();

    level waittill( "break_facade" );

    foreach ( var_3 in var_1 )
    {
        mp_exploder( 205 );
        var_3 show();
    }

    foreach ( var_3 in var_0 )
        var_3 hide();

    wait 0.36;
    mp_exploder( 206 );
    wait 0.3;
    mp_exploder( 207 );
    wait 0.28;
    mp_exploder( 208 );
}

rocket_explo_tank_clip_swap()
{
    self waittill( "death" );
    iprintln( "tank dead" );
}

boneyardcustomcratefunc()
{
    level thread maps\mp\mp_boneyard_ns_killstreak::boneyardcustomcratefunc();
}

boneyardcustomkillstreakfunc()
{
    level.killstreakfuncs["f1_engine_fire"] = ::tryuseboneyardkillstreak;
}

boneyardcustombotkillstreakfunc()
{
    maps\mp\bots\_bots_ks::bot_register_killstreak_func( "f1_engine_fire", maps\mp\bots\_bots_ks::bot_killstreak_simple_use );
}

tryuseboneyardkillstreak( var_0, var_1 )
{
    if ( common_scripts\utility::flag( "boneyard_killstreak_active" ) || !isdefined( level.ks_vertical ) )
    {
        self iprintlnbold( &"MP_BONEYARD_NS_F1_IN_USE" );
        return 0;
    }

    level.ks_vertical.uses = level.ks_vertical.uses + 1;
    level notify( "boneyard_killstreak_activate", self );

    if ( level.ks_vertical.uses >= level.ks_vertical.max_uses )
    {
        level.ks_vertical.uses = 0;
        return 1;
    }

    return 0;
}

event_rocket_countdown( var_0, var_1 )
{
    common_scripts\utility::flag_set( "flag_rocket_countdown" );

    for ( var_2 = var_0; var_2 >= 0; var_2-- )
    {
        if ( var_2 == 20 )
            mp_exploder( 16 );

        if ( isdefined( var_1[var_2] ) )
        {
            level.launch_vo1 playsound( var_1[var_2] );
            level.launch_vo2 playsound( var_1[var_2] );
        }

        wait 1;
    }

    common_scripts\utility::flag_clear( "flag_rocket_countdown" );
}

event_rocket_success( var_0, var_1 )
{
    level notify( "rocket_success_start" );
    var_2 = getent( "rocket_success_rocket", "targetname" );
    var_3 = [];
    var_2 thread event_rocket_countdown( var_0, var_3 );
    wait( var_0 - var_1 );
    level notify( "rocket_success_launch_init" );
    mp_exploder( 33 );
    var_2 playsound( "scn_beginning_launch_sfx_dist" );
    wait( var_1 );
    level notify( "rocket_success_blast_off" );
    playfxontag( level._effect["vfx_rocket_shuttle_smoke_geotrail_xlarge"], var_2, "tag_origin" );
    var_2 scriptmodelplayanimdeltamotion( level.anim_names["rocket_success"]["launch"] );
    wait( getanimlength( level.animations["rocket_success"]["launch"] ) );
    level notify( "rocket_success_finished" );
    thread audio_command_vo();
    var_2 scriptmodelclearanim();
    var_4 = anglestoup( var_2.angles );
    var_2 moveto( var_4 * 62512.5, 64 );
    wait 64;
    stopfxontag( level._effect["vfx_rocket_shuttle_smoke_geotrail_xlarge"], var_2, "tag_origin" );
    var_2 delete();
}

audio_command_vo()
{
    wait 25;
    level.launch_command_vo playsound( "mp_boneyard_fd_attentionallpersonelthis" );
}

event_rocket_explode( var_0, var_1 )
{
    level notify( "rocket_explo_start" );
    getscriptablearray( "countdown_clock", "targetname" )[0] setscriptablepartstate( 0, 1 );
    var_2 = getent( "rocket_explo_explosion", "targetname" );
    var_3 = getent( "rocket_explo_rocket", "targetname" );
    var_4 = level.animations["rocket_explo"]["launch"];
    var_5 = [];
    var_5[25] = "mp_boneyard_ld_autosequencestarttminus";
    var_5[17] = "mp_boneyard_ld_tminus15";
    var_5[13] = "mp_boneyard_ld_tminus10";
    maps\mp\_utility::delaythread( 57.8, ::mp_exploder, 111 );
    mp_exploder( 20 );
    common_scripts\utility::flag_set( "flag_rocket_countdown_fx" );
    wait( 60 - var_0 );
    var_3 thread event_rocket_countdown( var_0, var_5 );
    wait( var_0 - var_1 );
    level notify( "rocket_explo_launch_init" );
    mp_exploder( 32 );
    var_3 playsound( "scn_beginning_launch_sfx" );
    wait( var_1 );
    level notify( "rocket_explo_blast_off" );
    common_scripts\utility::flag_set( "flag_rocket_launched" );
    playfxontag( level._effect["vfx_rocket_shuttle_smoke_geotrail_xlarge"], var_3, "control_root" );
    var_3 scriptmodelplayanimdeltamotion( level.anim_names["rocket_explo"]["launch"] );
    thread sound_wait_for_pre_explosion( var_3 );
    thread building_impact_timing();

    foreach ( var_7 in level.rocket_explo )
        var_7 thread rocket_explo_drop_part();

    var_9 = getanimlength( var_4 ) * getnotetracktimes( var_4, "rog_hit" )[0];
    wait( var_9 );
    level notify( "rocket_explo_explode" );
    mp_exploder( 64 );
    stopfxontag( level._effect["vfx_rocket_shuttle_smoke_geotrail_xlarge"], var_3, "control_root" );
    thread fx_fiery_debris( var_3 );
    level.rocket_explo[1] playsound( "scn_shuttle_debris_fall_01" );
    level.rocket_explo[2] playsound( "scn_shuttle_debris_fall_02" );
    thread explosion_vo();
    thread remove_mantles();
    thread rocket_explo_destroy_tank();
    thread sound_fire_elements();
    thread sfx_dist_debris();
    thread kill_survivors( "rocket_crash_01", ( -752, 96, -112 ), 192, 96 );
    thread kill_survivors( "rocket_crash_02", ( 944, 112, -112 ), 192, 96 );
    wait( getanimlength( var_4 ) - var_9 );
    var_3 delete();
    level notify( "rocket_explo_finished" );
    maps\mp\_compass::setupminimap( "compass_map_mp_boneyard_ns_after" );
    maps\mp\mp_boneyard_ns_killstreak::boneyard_killstreak_enable( 200 );
}

fx_fiery_debris( var_0 )
{
    playfxontag( level._effect["vfx_debris_trail_xlarge"], var_0, "j_rocket_004" );
    playfxontag( level._effect["vfx_debris_trail_xlarge"], var_0, "j_rocket_005" );
    common_scripts\utility::waitframe();
    playfxontag( level._effect["vfx_debris_trail_xlarge"], var_0, "j_rocket_006" );
    playfxontag( level._effect["vfx_debris_trail_xlarge"], var_0, "j_rocket_007" );
    common_scripts\utility::waitframe();
    playfxontag( level._effect["vfx_debris_trail_xlarge"], var_0, "j_rocket_008" );
}

sound_wait_for_pre_explosion( var_0 )
{
    wait 5.5;
    var_0 playsound( "scn_beggining_launch_explode" );
}

building_impact_timing()
{
    var_0 = getanimlength( level.animations["rocket_explo"]["crash_04"] );
    var_1 = getnotetracktimes( level.animations["rocket_explo"]["crash_04"], "building_hit" );
    var_2 = var_0 * var_1[0];
    wait( var_2 );
    level notify( "break_facade" );
    thread sound_logic_impacts( "building" );
}

sfx_dist_debris()
{
    level waittill( "rocket_crash_01" );
    var_0 = spawn( "script_origin", ( -1686, 2876, 89 ) );
    var_1 = spawn( "script_origin", ( -2445, 1748, 18 ) );
    var_2 = spawn( "script_origin", ( -3190, 1477, 55 ) );
    wait 0.4;
    var_0 playsound( "scn_shuttle_dist_debris_01" );
    wait 0.1;
    var_1 playsound( "scn_shuttle_dist_debris_02" );
    wait 0.3;
    var_2 playsound( "scn_shuttle_dist_debris_06" );
    wait 6;
    var_0 delete();
    var_1 delete();
    var_2 delete();
}

sound_fire_elements()
{
    level waittill( "rocket_crash_01" );
    var_0 = spawn( "script_origin", ( -808, -14, -130 ) );
    var_1 = spawn( "script_origin", ( -817, 210, -123 ) );
    var_2 = spawn( "script_origin", ( -1028, 534, 368 ) );
    var_3 = spawn( "script_origin", ( -599, 276, -117 ) );
    var_4 = spawn( "script_origin", ( -282, 184, -127 ) );
    var_5 = spawn( "script_origin", ( -384, 504, -45 ) );
    var_6 = spawn( "script_origin", ( -69, 923, -81 ) );
    var_7 = spawn( "script_origin", ( 133, 912, -68 ) );
    var_8 = spawn( "script_origin", ( 870, 1, -110 ) );
    var_9 = spawn( "script_origin", ( 880, 229, -115 ) );
    var_10 = spawn( "script_origin", ( 1224, 231, -147 ) );
    var_11 = spawn( "script_origin", ( 1377, 207, -159 ) );
    var_12 = spawn( "script_origin", ( 1340, -15, -149 ) );
    var_13 = spawn( "script_origin", ( 1154, 128, -31 ) );
    var_14 = spawn( "script_origin", ( -558, 61, 33 ) );
    var_15 = spawn( "script_origin", ( 973, 115, 7 ) );
    var_0 playloopsound( "fire_small_01" );
    var_1 playloopsound( "fire_small_01" );
    var_2 playloopsound( "fire_small_01" );
    var_3 playloopsound( "fire_small_01" );
    var_4 playloopsound( "fire_small_01" );
    var_5 playloopsound( "fire_small_01" );
    var_6 playloopsound( "fire_small_01" );
    var_7 playloopsound( "fire_small_01" );
    var_8 playloopsound( "fire_small_01" );
    var_9 playloopsound( "fire_small_01" );
    var_10 playloopsound( "fire_small_01" );
    var_11 playloopsound( "fire_small_01" );
    var_12 playloopsound( "fire_small_01" );
    var_13 playloopsound( "fire_ceiling_small_01" );
    var_14 playloopsound( "fire_ceiling_small_01" );
    var_15 playloopsound( "fire_small_01" );
}

explosion_vo()
{
    wait 0.7;
    level.launch_vo1 playsound( "mp_boneyard_ld_supplydronehasbeen" );
    level.launch_vo2 playsound( "mp_boneyard_ld_supplydronehasbeen" );
}

rocket_explo_drop_part()
{
    common_scripts\utility::array_thread( self.kill_ents, maps\mp\_movers::player_pushed_kill, 0 );

    foreach ( var_1 in self.kill_ents )
        var_1.destroyairdroponcollision = 1;

    common_scripts\utility::array_call( self.linked_ents, ::show );
    self show();
    playfxontag( level._effect["vfx_debris_trail_xlarge"], self, "tag_origin" );
    var_3 = getanimlength( level.animations["rocket_explo"][self.fall_anim] );
    thread rocket_explo_part_ground_hit( var_3 );
    self scriptmodelplayanimdeltamotion( level.anim_names["rocket_explo"][self.fall_anim] );
    wait( var_3 );

    if ( maps\mp\gametypes\_hostmigration::waittillhostmigrationdone() )
        wait 0.05;

    stopfxontag( level._effect["vfx_debris_trail_xlarge"], self, "tag_origin" );

    foreach ( var_1 in self.crash_delete )
    {
        var_1 connectpaths();
        var_1 delete();
    }

    thread rocket_explo_drop_part_safety_check();
    common_scripts\utility::array_thread( self.kill_ents, maps\mp\_movers::stop_player_pushed_kill );
    self.clip common_scripts\utility::delaycall( 0.05, ::disconnectpaths );
    self.clip common_scripts\utility::delaycall( 0.05, ::setaisightlinevisible, 1 );
    wait 0.1;

    foreach ( var_7 in self.crash_path )
        connectnodepair( var_7, getnode( var_7.target, "targetname" ) );
}

rocket_explo_drop_part_safety_check()
{
    foreach ( var_1 in level.players )
    {
        if ( var_1 istouching( self.clip ) )
            self.clip maps\mp\_movers::unresolved_collision_owner_damage( var_1 );
    }
}

rocket_explo_part_ground_hit( var_0 )
{
    var_1 = getnotetracktimes( level.animations["rocket_explo"][self.fall_anim], "ground_hit" );
    wait( var_0 * var_1[0] );
    level notify( "rocket_" + self.fall_anim );

    if ( isdefined( level.explo_nums["rocket_explo"][self.fall_anim] ) )
        mp_exploder( level.explo_nums["rocket_explo"][self.fall_anim] );

    earthquake( 0.6, 1.5, self.origin, 800 );
    thread sound_logic_impacts( self.fall_anim );
    common_scripts\utility::array_call( self.crash_before, ::hide );

    foreach ( var_3 in self.crash_after )
    {
        var_3 show();
        var_3 movez( 1024, 0.05 );
    }

    wait 0.1;
    common_scripts\utility::array_call( self.crash_before, ::delete );
}

sound_logic_impacts( var_0 )
{
    switch ( var_0 )
    {
        case "crash_01":
            self playsound( "scn_shuttle_debris_05" );
            break;
        case "crash_02":
            self playsound( "scn_shuttle_debris_04" );
            break;
        case "crash_03a":
            break;
        case "crash_03b":
            break;
        case "crash_04":
            self playsound( "scn_shuttle_debris_02" );
            break;
        case "building":
            var_1 = spawn( "script_origin", ( 670, 1101, 442 ) );
            var_1 playsound( "scn_shuttle_debris_01" );
            break;
        case "tank":
            break;
        default:
            break;
    }
}

remove_mantles()
{
    level waittill( "rocket_crash_02" );
    var_0 = getent( "tunnel_exit_A_mantles", "targetname" );
    var_0 delete();
}

rocket_explo_destroy_tank()
{
    level waittill( "rocket_crash_01" );
    thread sound_logic_impacts( "tank" );
    radiusdamage( ( -309, -516, -47 ), 50, 496, 500 );
    level.exploder_queue[5] = spawnstruct();
    level.exploder_queue[5].num = 5;
    level.exploder_queue[5].time = gettime();
    level.exploder_queue[5].starttime = 0;
}

kill_survivors( var_0, var_1, var_2, var_3 )
{
    level endon( "game_ended" );
    level waittill( var_0 );
    var_4 = spawn( "trigger_radius", var_1, 0, var_2, var_3 );
    damage_radius_check( var_4 );
}

damage_radius_check( var_0 )
{
    foreach ( var_2 in level.participants )
    {
        if ( var_2 istouching( var_0 ) )
            var_2 dodamage( 1000, var_2.origin, undefined, undefined, "MOD_CRUSH" );
    }

    var_0 delete();
}

join_sync_exploders()
{
    for (;;)
    {
        level waittill( "connected", var_0 );
        var_0 thread join_sync_exploders_proc();
    }
}

join_sync_exploders_proc()
{
    self endon( "disconnect" );
    common_scripts\utility::waittill_any( "joined_team", "luinotifyserver" );

    if ( !isdefined( level.exploder_queue ) )
        return;

    var_0 = gettime();

    foreach ( var_2 in level.exploder_queue )
    {
        if ( var_0 < var_2.time )
            continue;

        wait 0.05;
        var_3 = var_2.starttime - gettime() + var_2.time;

        if ( var_3 > -60000 )
        {
            activateclientexploder( var_2.num, self, var_3 / 1000.0 );
            continue;
        }

        activateclientexploder( var_2.num, self, -60 );
    }

    if ( common_scripts\utility::flag( "flag_rocket_launched" ) )
        getscriptablearray( "countdown_clock", "targetname" )[0] setscriptablepartstate( 0, 0 );
    else if ( common_scripts\utility::flag( "flag_rocket_countdown_fx" ) )
        thread join_sync_countdown();
}

join_sync_countdown()
{
    self endon( "disconnect" );

    while ( !common_scripts\utility::flag( "flag_rocket_launched" ) )
    {
        activateclientexploder( 7, self );
        wait 0.05;
    }
}

mp_exploder( var_0, var_1 )
{
    common_scripts\utility::exploder( var_0, undefined, var_1 );

    if ( !isdefined( var_1 ) )
        var_1 = 0;

    if ( !isdefined( level.exploder_queue ) )
        level.exploder_queue = [];

    level.exploder_queue[var_0] = spawnstruct();
    level.exploder_queue[var_0].num = var_0;
    level.exploder_queue[var_0].time = gettime();
    level.exploder_queue[var_0].starttime = var_1 * 1000;
}

boneyard_fire_horizontal_setup()
{
    level.fire_horiz = spawnstruct();
    level.fire_horiz.dam = getent( "damage_test_fire_horizontal", "targetname" );
    level.fire_horiz.player = undefined;
    level.fire_horiz.team = undefined;
    level.fire_horiz.trig = spawn( "script_model", ( 471, 1601, -17 ) );
    level.fire_horiz.trig setmodel( "tag_origin" );
    level.fire_horiz.trig sethintstring( &"MP_BONEYARD_NS_HORIZONTAL_TEST" );
    level.fire_horiz.inflictor = getent( "horiz_fire_ent", "targetname" );
    common_scripts\utility::flag_init( "boneyard_fire_horizontal_active" );
    common_scripts\utility::flag_init( "fire_horiz_alarm_on" );
    common_scripts\utility::flag_init( "fire_horiz_firing" );
}

boneyard_fire_horizontal_trigger()
{
    level endon( "game_ended" );

    for (;;)
    {
        var_0 = spawnfx( level._effect["vfx_horz_fire_red_light"], ( 452, 1596.93, -27.28 ) );
        triggerfx( var_0 );
        thread sfx_console_beeps_start();
        level.fire_horiz.trig makeusable();
        level.fire_horiz.trig waittill( "trigger", var_1 );
        level.fire_horiz.trig makeunusable();
        thread sfx_console_beeps_stop();
        common_scripts\utility::flag_set( "boneyard_fire_horizontal_active" );
        level.fire_horiz.player = var_1;
        level.fire_horiz.team = var_1.pers["team"];
        var_0 delete();
        var_2 = spawnfx( level._effect["vfx_horz_fire_amber_light"], ( 452, 1596.93, -27.28 ) );
        triggerfx( var_2 );
        common_scripts\utility::flag_set( "fire_horiz_alarm_on" );
        thread fire_horiz_alarm();
        thread fire_horiz_firing_fx();
        wait 4;
        common_scripts\utility::flag_clear( "fire_horiz_alarm_on" );
        fire_horiz_fire();
        level.fire_horiz.player = undefined;
        level.fire_horiz.team = undefined;
        common_scripts\utility::flag_clear( "boneyard_fire_horizontal_active" );
        wait 30;
        var_2 delete();
    }
}

fire_horiz_fire()
{
    level endon( "game_ended" );
    common_scripts\utility::flag_set( "fire_horiz_firing" );
    badplace_brush( "bad_horiz_fire", 10, level.fire_horiz.dam, "allies", "axis" );

    for ( var_0 = 0; var_0 < 20; var_0++ )
    {
        wait 0.5;
        maps\mp\gametypes\_hostmigration::waittillhostmigrationdone();
        var_1 = level.fire_horiz.player;

        if ( !isdefined( level.fire_horiz.player ) || !isplayer( level.fire_horiz.player ) )
            var_1 = undefined;

        thread maps\mp\mp_boneyard_ns_killstreak::damage_characters( level.fire_horiz, var_1, 25 );
        thread maps\mp\mp_boneyard_ns_killstreak::damage_targets( level.fire_horiz, var_1, level.remote_uav, 50 );
        thread maps\mp\mp_boneyard_ns_killstreak::damage_targets( level.fire_horiz, var_1, level.placedims, 50 );
        thread maps\mp\mp_boneyard_ns_killstreak::damage_targets( level.fire_horiz, var_1, level.uplinks, 50 );
        thread maps\mp\mp_boneyard_ns_killstreak::damage_targets( level.fire_horiz, var_1, level.turrets, 50 );
        thread maps\mp\mp_boneyard_ns_killstreak::damage_targets( level.fire_horiz, var_1, level.balldrones, 50 );
        thread maps\mp\mp_boneyard_ns_killstreak::damage_targets( level.fire_horiz, var_1, level.mines, 50 );
        thread maps\mp\mp_boneyard_ns_killstreak::damage_targets( level.fire_horiz, var_1, level.deployable_box["deployable_vest"], 50 );
        thread maps\mp\mp_boneyard_ns_killstreak::damage_targets( level.fire_horiz, var_1, level.deployable_box["deployable_ammo"], 50 );
    }

    common_scripts\utility::flag_clear( "fire_horiz_firing" );
}

fire_horiz_alarm()
{
    level.alarm2_vo playsound( "mp_boneyard_cc_rockettestinitiatingin" );

    while ( common_scripts\utility::flag( "fire_horiz_alarm_on" ) )
    {
        level.alarm2_a playsound( "emt_boneyard_ns_close_alarm_02" );
        level.alarm2_b playsound( "emt_boneyard_ns_close_alarm_02" );
        wait 0.871;
    }
}

fire_horiz_firing_fx()
{
    mp_exploder( 66 );
    wait 4;

    for ( var_0 = 0; var_0 < 5; var_0++ )
    {
        mp_exploder( 67 );
        wait 2;
    }

    mp_exploder( 68 );
}

sfx_console_beeps_start()
{
    if ( !isdefined( level.console_beep ) )
        level.console_beep = spawn( "script_origin", ( 450, 1590.25, -26 ) );

    level.console_beep playloopsound( "emt_boneyard_ns_console_beep_01" );
}

sfx_console_beeps_stop()
{
    level.console_beep stoploopsound( "emt_boneyard_ns_console_beep_01" );
    sfx_console_activate();
}

sfx_console_activate()
{
    level.console_beep playsound( "scn_boneyard_ns_console_press" );
    thread sound_fire_event_logic();
    wait 0.1;
    level.console_beep playsound( "emt_boneyard_ns_console_beep_02" );
}

sound_fire_event_logic()
{
    level.fire_event_a playsound( "scn_fire_event_01" );
    level.fire_event_b playsound( "scn_fire_event_01_b" );
    wait 3.8;
    level.fire_event_a2 playsound( "scn_fire_event_01p2" );
    level.fire_event_lpstart playsound( "scn_fire_event_01_lpstart" );
    wait 1.5;
    level.fire_event_lp playloopsound( "scn_fire_event_01_lp" );
    wait 8;
    level.fire_event_a3 playsound( "scn_fire_event_01p3" );
    level.fire_event_b2 playsound( "scn_fire_event_01_bp2" );
    level.fire_event_lpstop playsound( "scn_fire_event_01_lpstop" );
    level.fire_event_lp stoploopsound();
}
