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

main()
{
    level._effect["vfx_carrier_rearwake"] = loadfx( "vfx/moments/carrier/vfx_carrier_rearwake" );
    level._effect["vfx_ac130_25mm_tracer"] = loadfx( "vfx/moments/carrier/vfx_ac130_25mm_tracer" );
    level._effect["vfx_ac130_25mm_impact"] = loadfx( "vfx/moments/carrier/vfx_ac130_25mm_impact" );
    level._effect["vfx_ac130_40mm_impact"] = loadfx( "vfx/moments/carrier/vfx_ac130_40mm_impact" );
    level._effect["vfx_intro_antenna_lights_close"] = loadfx( "vfx/moments/carrier/vfx_intro_antenna_lights_close" );
    level._effect["vfx_intro_antenna_lights"] = loadfx( "vfx/moments/carrier/vfx_intro_antenna_lights" );
    level._effect["vfx_ac130_105mm_impact"] = loadfx( "vfx/moments/carrier/vfx_ac130_105mm_impact" );
    level._effect["fx/muzzleflashes/ak47_flash_wv"] = loadfx( "fx/muzzleflashes/ak47_flash_wv" );
    level._effect["aircraft_light_cockpit_white_300"] = loadfx( "fx/misc/aircraft_light_cockpit_white_300" );
    level._effect["vfx_sunflare_carrier"] = loadfx( "vfx/ambient/atmospheric/vfx_sunflare_carrier" );
    level._effect["vfx_jetscrape_point_runner"] = loadfx( "vfx/moments/carrier/vfx_jetscrape_point_runner" );
    level._effect["vfx_intro_chopper_cloudbank"] = loadfx( "vfx/moments/carrier/vfx_intro_chopper_cloudbank" );
    level._effect["vfx_intro_elevator_light"] = loadfx( "vfx/moments/carrier/vfx_intro_elevator_light" );
    level._effect["vfx_intro_runway_lights"] = loadfx( "vfx/moments/carrier/vfx_intro_runway_lights" );
    level._effect["vfx_antenna_deck_impact"] = loadfx( "vfx/moments/carrier/vfx_antenna_deck_impact" );
    level._effect["vfx_firerain_large"] = loadfx( "vfx/moments/carrier/vfx_firerain_large" );
    level._effect["vfx_carrier_shock_particulates"] = loadfx( "vfx/moments/carrier/vfx_carrier_shock_particulates" );
    level._effect["vfx_crackpoof"] = loadfx( "vfx/moments/carrier/vfx_crackpoof" );
    level._effect["vfx_firerain"] = loadfx( "vfx/moments/carrier/vfx_firerain" );
    level._effect["vfx_deck_damage_fire"] = loadfx( "vfx/moments/carrier/vfx_deck_damage_fire" );
    level._effect["vfx_zodiac_water_splash"] = loadfx( "vfx/moments/carrier/vfx_zodiac_water_splash" );
    level._effect["vfx_zodiac_propeller_fast"] = loadfx( "vfx/moments/carrier/vfx_zodiac_propeller_fast" );
    level._effect["vfx_missile_death_deck"] = loadfx( "vfx/moments/carrier/vfx_missile_death_deck" );
    level._effect["vfx_exp_silenthawk_deck_trail"] = loadfx( "vfx/moments/carrier/vfx_exp_silenthawk_deck_trail" );
    level._effect["vfx_exp_silenthawk_deck"] = loadfx( "vfx/moments/carrier/vfx_exp_silenthawk_deck" );
    level._effect["vfx_exp_silenthawk_end"] = loadfx( "vfx/gameplay/explosions/vfx_exp_silenthawk_end" );
    level._effect["vfx_tower_glass_shatter"] = loadfx( "vfx/moments/carrier/vfx_tower_glass_shatter" );
    level._effect["vfx_lrg_air_exp"] = loadfx( "vfx/moments/carrier/vfx_lrg_air_exp_low_tendrils" );
    level._effect["vfx_missile_death_air"] = loadfx( "vfx/moments/carrier/vfx_missile_death_air" );
    level._effect["vfx_perif_smk_war_vista_fog_dark"] = loadfx( "vfx/ambient/skybox/vfx_perif_smk_war_vista_fog_dark" );
    level._effect["vfx_vehicle_explosion_mig29"] = loadfx( "vfx/gameplay/explosions/vfx_vehicle_explosion_mig29" );
    level._effect["vfx_zodiac_splash_idle"] = loadfx( "vfx/gameplay/vehicles/zodiac/vfx_zodiac_splash_idle" );
    level._effect["vfx_zodiac_splash_sink"] = loadfx( "vfx/gameplay/vehicles/zodiac/vfx_zodiac_splash_sink" );
    level._effect["vfx_f18_engine_afterburner"] = loadfx( "vfx/gameplay/vehicles/f18/vfx_f18_engine_afterburner" );
    level._effect["vfx_f18_engine"] = loadfx( "vfx/gameplay/vehicles/f18/vfx_f18_engine" );
    level._effect["vfx_f18_idle"] = loadfx( "vfx/gameplay/vehicles/f18/vfx_f18_idle" );
    level._effect["vfx_debris_fire_tiny"] = loadfx( "vfx/moments/mp_chasm/vfx_debris_fire_tiny" );
    level._effect["vfx_plume_med_light"] = loadfx( "vfx/ambient/smoke/vfx_plume_med_light" );
    level._effect["vfx_plume_med_dense"] = loadfx( "vfx/ambient/smoke/vfx_plume_med_dense" );
    level._effect["vfx_blowing_sparks_small"] = loadfx( "vfx/moments/carrier/vfx_blowing_sparks_small" );
    level._effect["vfx_debris_fire_nosmk"] = loadfx( "vfx/moments/carrier/vfx_debris_fire_nolight_nosmk" );
    level._effect["vfx_fire_grounded_xtralarge_nxglight"] = loadfx( "vfx/ambient/fire/vfx_fire_grounded_xtralarge_nxglight" );
    level._effect["vfx_fire_grounded_large_nxglight"] = loadfx( "vfx/ambient/fire/vfx_fire_grounded_large_nxglight" );
    level._effect["vfx_fire_wall_lg"] = loadfx( "vfx/ambient/fire/wall/vfx_fire_wall_lg" );
    level._effect["vfx_fire_wall_small"] = loadfx( "vfx/ambient/fire/wall/vfx_fire_wall_small" );
    level._effect["vfx_fire_crawling"] = loadfx( "vfx/ambient/fire/wall/vfx_fire_crawling" );
    level._effect["vfx_fire_wall_medium"] = loadfx( "vfx/ambient/fire/wall/vfx_fire_wall_medium" );
    level._effect["vfx_post_impact_debris"] = loadfx( "vfx/moments/carrier/vfx_post_impact_debris" );
    level._effect["vfx_antiair_runner"] = loadfx( "vfx/ambient/atmospheric/vfx_antiair_runner" );
    level._effect["vfx_fire_lrg_plume"] = loadfx( "vfx/ambient/fire/vfx_fire_lrg_plume" );
    level._effect["vfx_jetscrape_runner"] = loadfx( "vfx/moments/carrier/vfx_jetscrape_runner" );
    level._effect["vfx_destroyer_5in_muzzleflash"] = loadfx( "vfx/moments/carrier/vfx_destroyer_5in_muzzleflash" );
    level._effect["vfx_destroyer_vert_missile_impact"] = loadfx( "vfx/moments/carrier/vfx_destroyer_vert_missile_impact" );
    level._effect["vfx_destroyer_vert_missile_trail"] = loadfx( "vfx/moments/carrier/vfx_destroyer_vert_missile_trail" );
    level._effect["electrical_sparks_runner"] = loadfx( "vfx/ambient/sparks/electrical_sparks_runner" );
    level._effect["vfx_tower_blowingpaper"] = loadfx( "vfx/moments/carrier/vfx_tower_blowingpaper" );
    level._effect["vfx_carrier_fuel_fire_nosmoke"] = loadfx( "vfx/moments/carrier/vfx_carrier_fuel_fire_nosmoke" );
    level._effect["vfx_carrier_fuel_fire"] = loadfx( "vfx/moments/carrier/vfx_carrier_fuel_fire" );
    level._effect["vfx_blowing_debris_small"] = loadfx( "vfx/moments/carrier/vfx_blowing_debris_small" );
    level._effect["vfx_debris_fire"] = loadfx( "vfx/moments/carrier/vfx_debris_fire_nolight" );
    level._effect["vfx_rog_trail"] = loadfx( "vfx/moments/carrier/vfx_rog_trail" );
    level._effect["vfx_rog_water_impact_close"] = loadfx( "vfx/moments/carrier/vfx_rog_water_impact_close" );
    level._effect["vfx_deck_impact"] = loadfx( "vfx/moments/carrier/vfx_deck_impact" );
    level._effect["vfx_deck_heatdistortion_runner"] = loadfx( "vfx/moments/carrier/vfx_deck_heatdistortion_runner" );
    level._effect["vfx_battlesmoke_large_directional"] = loadfx( "vfx/moments/carrier/vfx_battlesmoke_large_directional" );
    level._effect["vfx_rog_tower_impact"] = loadfx( "vfx/moments/carrier/vfx_rog_tower_impact" );
    level._effect["vfx_phalanx_missile_impact"] = loadfx( "vfx/moments/carrier/vfx_phalanx_missile_impact" );
    level._effect["flesh_hit"] = loadfx( "fx/impacts/flesh_hit" );
    level._effect["zodiac_wake_geotrail"] = loadfx( "vfx/moments/carrier/vfx_zodiac_wake_cheap" );
    level._effect["body_splash"] = loadfx( "fx/water/body_splash" );
    level._effect["blank"] = loadfx( "fx/misc/blank" );
    level._effect["FX_mig29_on_fire"] = loadfx( "fx/fire/jet_on_fire" );
    level._effect["aerial_explosion_hind_woodland"] = loadfx( "fx/explosions/aerial_explosion_hind_woodland" );
    level._effect["battleship_flash_large_withmissile"] = loadfx( "fx/maps/ny_harbor/battleship_flash_large_withmissile" );
    level._effect["vfx_f18_catapult_launch"] = loadfx( "vfx/moments/carrier/vfx_f18_catapult_launch" );
    level._effect["vfx_exp_heli_primary"] = loadfx( "vfx/gameplay/explosions/vehicle/heli/vfx_exp_heli_primary" );
    level._effect["vfx_x_mphnd_primary"] = loadfx( "vfx/gameplay/explosions/vehicle/hind_mp/vfx_x_mphnd_primary" );
    level._effect["ac130_25mm_impact_water"] = loadfx( "fx/impacts/ac130_25mm_impact_water" );
    level._effect["ac130_40mm_impact_water"] = loadfx( "fx/impacts/ac130_40mm_impact_water" );
    level._effect["ac130_105mm_impact"] = loadfx( "vfx/moments/carrier/vfx_ac130_105mm_impact" );
    level._effect["angel_flare_geotrail"] = loadfx( "fx/smoke/angel_flare_geotrail" );
    level._effect["angel_flare_swirl"] = loadfx( "fx/smoke/angel_flare_swirl_runner" );
    level._effect["chopper_flare_explosion"] = loadfx( "fx/_requests/apache/apache_trophy_explosion_ai" );
    level._effect["ac130_105mm_muzzle"] = loadfx( "fx/muzzleflashes/ac130_105mm" );
    level._effect["ac130_40mm_muzzle"] = loadfx( "fx/muzzleflashes/ac130_40mm" );
    level._effect["vfx_ac130_engine_fire"] = loadfx( "vfx/moments/carrier/vfx_ac130_engine_fire" );
    level._effect["rog_maintrail_01"] = loadfx( "vfx/moments/carrier/vfx_rog_carrier_bg_runner" );
    level._effect["depth_charge_impact"] = loadfx( "fx/water/body_splash" );
    level._effect["depth_charge_explosion"] = loadfx( "vfx/moments/carrier/vfx_depthcharge_explode" );
    level._effect["sw_rog_strike_big_tail"] = loadfx( "vfx/moments/skyway/sw_rog_strike_big_tail" );
    level._effect["vfx_heli_dust_default_cheap"] = loadfx( "vfx/gameplay/tread_fx/vfx_heli_dust_default_cheap" );
    level._effect["vfx_heli_dust_default_cheap_bank"] = loadfx( "vfx/gameplay/tread_fx/vfx_heli_dust_default_cheap_bank" );
    level._effect["vfx_heli_dust_default_cheap_bank_lg"] = loadfx( "vfx/gameplay/tread_fx/vfx_heli_dust_default_cheap_bank_lg" );
    level._effect["fx_splash_carrier_side_xlg"] = loadfx( "fx/maps/carrier/fx_splash_carrier_side_xlg" );
    level._effect["drone_tracer"] = loadfx( "fx/_requests/homecoming/drone_tracer" );
    common_scripts\utility::flag_init( "exterior_effects_on" );
    common_scripts\utility::flag_init( "exterior_effects_off" );
    common_scripts\utility::flag_init( "vista_effects_on" );

    if ( !getdvarint( "r_reflectionProbeGenerate" ) )
    {
        maps\createfx\carrier_fx::main();
        maps\createfx\carrier_sound::main();
    }

    thread exterior_effects();
    thread interior_effects();
    thread ally_ships();
    thread land_aa();
    thread enemy_land_missile();
    thread treadfx_override_aas();
    thread treadfx_override_nh90();
    thread treadfx_override_y_8_gunship();
    thread treadfx_override_silenthawk();
}

treadfx_override_aas()
{
    level._vehicle_effect["script_vehicle_aas72x"]["default"] = level._effect["vfx_heli_dust_default_cheap"];
    level._vehicle_effect["script_vehicle_aas72x"]["default_bank"] = level._effect["vfx_heli_dust_default_cheap_bank"];
    level._vehicle_effect["script_vehicle_aas72x"]["default_bank_lg"] = level._effect["vfx_heli_dust_default_cheap_bank_lg"];
}

treadfx_override_nh90()
{
    var_0 = "fx/misc/blank";
    maps\_treadfx::setallvehiclefx( "script_vehicle_nh90", var_0 );
}

treadfx_override_y_8_gunship()
{
    var_0 = "fx/misc/blank";
    maps\_treadfx::setallvehiclefx( "script_vehicle_y_8_gunship", var_0 );
}

treadfx_override_silenthawk()
{
    level._vehicle_effect["script_vehicle_silenthawk"]["default"] = level._effect["vfx_heli_dust_default"];
    level._vehicle_effect["script_vehicle_silenthawk"]["default_bank"] = level._effect["vfx_heli_dust_default_bank"];
    level._vehicle_effect["script_vehicle_silenthawk"]["default_bank_lg"] = level._effect["vfx_heli_dust_default_bank_lg"];
}

fx_init()
{
    setsaveddvar( "fx_alphathreshold", 9 );
    thread defend_zodiac_fx();
    thread defend_sparrow_fx();
}

exterior_effects()
{
    for (;;)
    {
        common_scripts\utility::flag_wait( "exterior_effects_on" );
        common_scripts\utility::exploder( 5501 );
        common_scripts\utility::flag_clear( "exterior_effects_on" );
        common_scripts\utility::flag_wait( "exterior_effects_off" );
        maps\_utility::stop_exploder( 5501 );
        common_scripts\utility::flag_clear( "exterior_effects_off" );
    }
}

interior_effects()
{
    for (;;)
    {
        common_scripts\utility::flag_wait( "exterior_effects_off" );
        common_scripts\utility::exploder( 5502 );
        common_scripts\utility::flag_clear( "exterior_effects_off" );
        common_scripts\utility::flag_wait( "exterior_effects_on" );
        maps\_utility::stop_exploder( 5502 );
        common_scripts\utility::flag_clear( "exterior_effects_on" );
    }
}

ally_ships()
{
    common_scripts\utility::flag_wait( "vista_effects_on" );
    level.vert_missile_wait_min = 6;
    level.vert_missile_wait_max = 10;
    maps\_utility::delaythread( 0, ::ship_shoot_loop, "fx_ship_gun_01", "defend_sparrow_platform" );
    maps\_utility::delaythread( 0, ::ship_shoot_loop, "fx_ship_gun_02", "defend_sparrow_platform" );
    maps\_utility::delaythread( 0, ::ship_shoot_loop, "fx_ship_gun_03", "defend_sparrow_platform" );
    maps\_utility::delaythread( 0, ::ship_shoot_loop, "fx_ship_gun_04", "defend_sparrow_platform" );
    maps\_utility::delaythread( 0, ::ship_shoot_loop, "fx_ship_gun_05", "defend_sparrow_platform" );
    maps\_utility::delaythread( 0, ::ship_shoot_vert_missile_loop, "fx_ship_missile_vert_01", "fx_ship_missile_vert_01_dest", "defend_sparrow_platform", 11000, 6 );
    maps\_utility::delaythread( 0, ::ship_shoot_vert_missile_loop, "fx_ship_missile_vert_02", "fx_ship_missile_vert_02_dest", "defend_sparrow_platform" );
    maps\_utility::delaythread( 0, ::ship_shoot_vert_missile_loop, "fx_ship_missile_vert_03", "fx_ship_missile_vert_03_dest", "defend_sparrow_platform" );
    maps\_utility::delaythread( 0, ::ship_shoot_vert_missile_loop, "fx_ship_missile_vert_04", "fx_ship_missile_vert_04_dest", "defend_sparrow_platform" );
    common_scripts\utility::flag_wait( "defend_zodiac" );
    level.vert_missile_wait_min = 16;
    level.vert_missile_wait_max = 24;
}

ship_shoot_loop( var_0, var_1 )
{
    level endon( var_1 );
    var_2 = common_scripts\utility::getstruct( var_0, "targetname" );

    for (;;)
    {
        var_2 thread ship_shoot();
        wait( randomfloatrange( 5, 15 ) );
    }
}

ship_shoot()
{
    var_0 = common_scripts\utility::spawn_tag_origin();
    var_0.origin = self.origin;
    var_0.angles = self.angles + ( 0, -90, 0 );
    playfxontag( common_scripts\utility::getfx( "vfx_destroyer_5in_muzzleflash" ), var_0, "tag_origin" );
    wait 3;
    maps\_utility::deleteent( var_0 );
}

cleanup_missile_fx( var_0 )
{
    self endon( "death" );
    level waittill( var_0 );

    if ( isdefined( self ) )
    {
        stopfxontag( common_scripts\utility::getfx( "vfx_destroyer_5in_muzzleflash" ), self, "tag_origin" );
        maps\_utility::deleteent( self );
    }
}

ship_shoot_vert_missile_loop( var_0, var_1, var_2, var_3, var_4, var_5 )
{
    level endon( var_2 );

    if ( isdefined( var_5 ) )
        level endon( var_5 );

    var_6 = common_scripts\utility::getstruct( var_0, "targetname" );

    for (;;)
    {
        if ( randomint( 100 ) > 75 )
        {
            var_6 thread ship_shoot_vert_missile( var_1, var_2, var_3, var_4 );
            wait 1;
            var_6 thread ship_shoot_vert_missile( var_1, var_2, var_3, var_4 );
        }
        else
            var_6 thread ship_shoot_vert_missile( var_1, var_2, var_3, var_4 );

        wait( randomfloatrange( level.vert_missile_wait_min, level.vert_missile_wait_max ) );
    }
}

ship_shoot_vert_missile( var_0, var_1, var_2, var_3 )
{
    var_4 = common_scripts\utility::spawn_tag_origin();
    var_4.origin = self.origin;
    var_4.angles = self.angles;
    var_5 = common_scripts\utility::getstructarray( var_0, "targetname" );
    var_6 = var_5[randomint( var_5.size )];
    var_7 = randomintrange( 15000, 18000 );
    var_8 = randomintrange( 13, 15 );

    if ( isdefined( var_2 ) )
        var_7 = var_2;

    if ( isdefined( var_3 ) )
        var_8 = var_3;

    if ( var_5.size == 0 )
        return;

    if ( isdefined( var_1 ) )
        var_4 thread cleanup_vert_missile_fx( var_1 );

    playfxontag( common_scripts\utility::getfx( "vfx_destroyer_vert_missile_trail" ), var_4, "tag_origin" );
    var_4 maps\carrier_code::move_arc( var_4.origin, var_6.origin, var_7, var_8, ( 180, 0, 0 ) );

    if ( isdefined( var_4 ) )
    {
        stopfxontag( common_scripts\utility::getfx( "vfx_destroyer_vert_missile_trail" ), var_4, "tag_origin" );
        var_4.angles = ( 0, 0, 0 );
        playfx( common_scripts\utility::getfx( "vfx_destroyer_vert_missile_impact" ), var_4.origin );
        maps\_utility::deleteent( var_4 );
    }
}

cleanup_vert_missile_fx( var_0 )
{
    self endon( "death" );
    level waittill( var_0 );
    stopfxontag( common_scripts\utility::getfx( "vfx_destroyer_vert_missile_trail" ), self, "tag_origin" );

    if ( isdefined( self ) )
        maps\_utility::deleteent( self );
}

land_aa()
{
    common_scripts\utility::flag_wait( "vista_effects_on" );
    thread playfx_targetname_endon( "fx_land_aa", "vfx_antiair_runner", "defend_zodiac_finished" );
}

enemy_land_missile()
{
    common_scripts\utility::flag_wait( "vista_effects_on" );
    level.land_vert_missile_wait_min = 30;
    level.land_vert_missile_wait_max = 50;

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

    maps\_utility::delaythread( 0, ::land_shoot_vert_missile_loop, "fx_shore_missile_vert_01", "fx_shore_missile_vert_01_dest", "defend_sparrow_platform", 11000 );
    maps\_utility::delaythread( 0, ::land_shoot_vert_missile_loop, "fx_shore_missile_vert_02", "fx_shore_missile_vert_02_dest", "defend_sparrow_platform", 11000 );
    maps\_utility::delaythread( 0, ::land_shoot_vert_missile_loop, "fx_shore_missile_vert_03", "fx_shore_missile_vert_03_dest", "defend_sparrow_platform", 11000 );
}

land_shoot_vert_missile_loop( var_0, var_1, var_2, var_3, var_4, var_5 )
{
    level endon( var_2 );

    if ( isdefined( var_5 ) )
        level endon( var_5 );

    var_6 = common_scripts\utility::getstruct( var_0, "targetname" );

    for (;;)
    {
        if ( isdefined( level.player.using_depth_charge ) && level.player.using_depth_charge )
            level.player waittill( "depth_charge_exit" );

        if ( randomint( 100 ) > 75 )
        {
            var_6 thread land_shoot_vert_missile( var_1, var_2, var_3, var_4 );
            wait 2;
            var_6 thread land_shoot_vert_missile( var_1, var_2, var_3, var_4 );
        }
        else
            var_6 thread land_shoot_vert_missile( var_1, var_2, var_3, var_4 );

        wait( randomfloatrange( level.land_vert_missile_wait_min, level.land_vert_missile_wait_max ) );
    }
}

land_shoot_vert_missile( var_0, var_1, var_2, var_3 )
{
    var_4 = common_scripts\utility::spawn_tag_origin();
    var_4.origin = self.origin;
    var_4.angles = self.angles;
    level.land_missiles[level.land_missiles.size] = var_4;
    var_5 = common_scripts\utility::getstructarray( var_0, "targetname" );
    var_6 = var_5[randomint( var_5.size )];
    var_7 = randomintrange( 15000, 18000 );
    var_8 = randomintrange( 13, 15 );

    if ( isdefined( var_2 ) )
        var_7 = var_2;

    if ( isdefined( var_3 ) )
        var_8 = var_3;

    if ( var_5.size == 0 )
        return;

    if ( isdefined( var_1 ) )
        var_4 thread cleanup_land_vert_missile_fx( var_1 );

    playfxontag( common_scripts\utility::getfx( "vfx_destroyer_vert_missile_trail" ), var_4, "tag_origin" );
    var_4 maps\carrier_code::move_arc( var_4.origin, var_6.origin, var_7, var_8, ( 180, 0, 0 ) );

    if ( isdefined( var_4 ) )
    {
        level.land_missiles = common_scripts\utility::array_remove( level.land_missiles, var_4 );
        stopfxontag( common_scripts\utility::getfx( "vfx_destroyer_vert_missile_trail" ), var_4, "tag_origin" );
        var_4.angles = ( 0, 0, 0 );
        playfx( common_scripts\utility::getfx( "vfx_lrg_air_exp" ), var_4.origin );
        maps\_utility::deleteent( var_4 );
    }
}

cleanup_land_vert_missile_fx( var_0 )
{
    self endon( "death" );
    level waittill( var_0 );
    level.land_missiles = common_scripts\utility::array_remove( level.land_missiles, self );
    stopfxontag( common_scripts\utility::getfx( "vfx_destroyer_vert_missile_trail" ), self, "tag_origin" );

    if ( isdefined( self ) )
        maps\_utility::deleteent( self );
}

defend_zodiac_fx()
{
    thread dz_enemy_destroyer_mortars();
    thread dz_osprey_missiles();
    thread dz_osprey_fed_destroyer();
}

dz_enemy_destroyer_mortars()
{
    common_scripts\utility::flag_wait( "defend_zodiac_wave_01" );
    var_0 = "defend_zodiac_finished";
    level endon( var_0 );
    var_1 = [ "dz_enemy_mortar_01_dest_01", "dz_enemy_mortar_01_dest_02", "dz_enemy_mortar_01_dest_03", "dz_enemy_mortar_01_dest_04" ];
    var_2 = common_scripts\utility::getstruct( "dz_enemy_mortar_01", "targetname" );
    var_3 = common_scripts\utility::getstructarray( "dz_enemy_mortar_01_dest", "targetname" );

    for (;;)
    {
        var_4 = var_1[randomint( var_1.size )];
        var_5 = common_scripts\utility::getstruct( var_4, "targetname" );
        screenshake( var_5.origin, 3.5, 2, 2.5, 2, 0, 2, 10000, 5, 2, 7, 2.6 );
        level.player playrumbleonentity( "heavy_1s" );
        thread common_scripts\utility::play_sound_in_space( "exp_armor_vehicle", var_5.origin );
        wait( randomfloatrange( 8, 14 ) );
    }
}

dz_osprey_missiles()
{

}

dz_osprey_fed_destroyer()
{
    level.player waittill( "using_depth_charge" );

    foreach ( var_1 in level.fed_destroyer_fx_guns )
        var_1 thread fed_destroyer_gun();
}

fed_destroyer_gun()
{
    level.player endon( "depth_charge_exit" );
    level endon( "stop_fed_destroyer_guns" );

    for (;;)
    {
        playfx( common_scripts\utility::getfx( "vfx_destroyer_5in_muzzleflash" ), self.origin, anglestoforward( self.angles ) );
        wait( randomfloatrange( 1, 3 ) );
    }
}

defend_sparrow_fx()
{
    thread defend_sparrow_ships();
}

defend_sparrow_ships()
{
    level endon( "defend_sparrow_finished" );
    common_scripts\utility::flag_wait( "defend_sparrow_start" );

    for (;;)
    {
        var_0 = common_scripts\utility::getstructarray( "defend_sparrow_ship_missiles", "targetname" );

        foreach ( var_2 in var_0 )
        {
            playfx( common_scripts\utility::getfx( "battleship_flash_large_withmissile" ), var_2.origin, anglestoforward( var_2.angles ) );
            wait( randomfloatrange( 2, 4 ) );
        }
    }
}

playfx_targetname_endon( var_0, var_1, var_2, var_3 )
{
    var_4 = common_scripts\utility::getstructarray( var_0, "targetname" );

    foreach ( var_6 in var_4 )
    {
        var_7 = var_6.angles;

        if ( isdefined( var_3 ) )
            var_7 = var_3;

        if ( !isdefined( var_7 ) )
            var_7 = ( 0, 0, 0 );

        thread playfx_endon( common_scripts\utility::getfx( var_1 ), var_6.origin, var_7, var_2 );
    }
}

playfx_endon( var_0, var_1, var_2, var_3 )
{
    var_4 = common_scripts\utility::spawn_tag_origin();
    var_4.origin = var_1;
    var_4.angles = var_2;
    playfxontag( var_0, var_4, "tag_origin" );
    common_scripts\utility::flag_wait( var_3 );
    stopfxontag( var_0, var_4, "tag_origin" );
    var_4 delete();
}

handle_jet1_fx( var_0 )
{
    common_scripts\utility::flag_wait( var_0 );
    self waittillmatch( "single anim", "fx_body_1_skid_start" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_1" );
    self waittillmatch( "single anim", "fx_wing_left_skid1_start" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_wing_left" );
    self waittillmatch( "single anim", "fx_wing_tip_left_skid_start" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_wing_tip_left" );
    self waittillmatch( "single anim", "fx_body_2_skid_start" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_2" );
    self waittillmatch( "single anim", "fx_body_1_skid_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_1" );
    self waittillmatch( "single anim", "fx_body_3_skid_start" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_3" );
    self waittillmatch( "single anim", "fx_wing_left_skid1_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_wing_left" );
    self waittillmatch( "single anim", "fx_wing_left_skid2_start" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_wing_left" );
    self waittillmatch( "single anim", "fx_wing_tip_left_skid_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_wing_tip_left" );
    self waittillmatch( "single anim", "fx_wing_left_skid2_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_wing_left" );
    self waittillmatch( "single anim", "fx_body_2_skid_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_2" );
    self waittillmatch( "single anim", "fx_body_3_skid_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_3" );
}

handle_jet2_fx( var_0 )
{
    common_scripts\utility::flag_wait( var_0 );
    self waittillmatch( "single anim", "fx_body_1_start" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_1" );
    self waittillmatch( "single anim", "fx_wing_left_start" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_wing_left" );
    self waittillmatch( "single anim", "fx_body_2_start" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_2" );
    self waittillmatch( "single anim", "fx_wing_tip_left_start" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_wing_tip_left" );
    self waittillmatch( "single anim", "fx_body_3_start" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_3" );
    self waittillmatch( "single anim", "slow_down" );
    self waittillmatch( "single anim", "fx_wing_tip_left_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_wing_tip_left" );
    self waittillmatch( "single anim", "fx_wing_left_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_wing_left" );
    self waittillmatch( "single anim", "fx_body_1_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_1" );
    self waittillmatch( "single anim", "fx_body_2_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_2" );
    self waittillmatch( "single anim", "fx_body_3_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_3" );
}

handle_jet3_fx( var_0 )
{
    common_scripts\utility::flag_wait( var_0 );
}

handle_jet11_fx( var_0 )
{
    common_scripts\utility::flag_wait( var_0 );
    self waittillmatch( "single anim", "fx_body_1_contact" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_1" );
    self waittillmatch( "single anim", "fx_body_2_contact" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_2" );
    self waittillmatch( "single anim", "fx_wing_tip_left_contact" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_wing_tip_left" );
    self waittillmatch( "single anim", "fx_body_2_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_2" );
    self waittillmatch( "single anim", "fx_wing_tip_left_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_wing_tip_left" );
    self waittillmatch( "single anim", "fx_wing_left_contact" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_wing_left" );
    self waittillmatch( "single anim", "fx_body_1_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_1" );
    self waittillmatch( "single anim", "fx_wing_left_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_wing_left" );
}

handle_jet12_fx( var_0 )
{
    common_scripts\utility::flag_wait( var_0 );
    self waittillmatch( "single anim", "fx_body_1_contact" );
    playfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_1" );
    self waittillmatch( "single anim", "fx_body_1_stop" );
    stopfxontag( level._effect["vfx_jetscrape_runner"], self, "tag_fx_body_1" );
}

handle_jet20_fx( var_0 )
{
    common_scripts\utility::flag_wait( var_0 );
}

handle_radar_dish_fx()
{
    self waittillmatch( "single anim", "skid_start" );
    playfxontag( level._effect["vfx_jetscrape_point_runner"], self, "tag_fx_base_3" );
    playfxontag( level._effect["vfx_jetscrape_point_runner"], self, "tag_fx_base_2" );
    self waittillmatch( "single anim", "skid_stop" );
    stopfxontag( level._effect["vfx_jetscrape_point_runner"], self, "tag_fx_base_3" );
    stopfxontag( level._effect["vfx_jetscrape_point_runner"], self, "tag_fx_base_2" );
}

handle_antenna_fx()
{
    self waittillmatch( "single anim", "impact_deck2" );
    common_scripts\utility::exploder( 8001 );
}

handle_exploding_heli_fx( var_0 )
{
    common_scripts\utility::flag_wait( var_0 );
    playfxontag( level._effect["vfx_exp_silenthawk_deck"], self, "tag_fx_body_1" );
    playfxontag( level._effect["vfx_exp_silenthawk_deck_trail"], self, "tag_fx_nose_1" );
    common_scripts\utility::exploder( 7001 );
}

handle_onplayer_debris()
{
    var_0 = spawn( "script_model", self.origin );
    var_0 setmodel( "tag_origin" );
    var_0 linkto( self );
    playfxontag( common_scripts\utility::getfx( "vfx_post_impact_debris" ), var_0, "tag_origin" );
    level.antenna waittillmatch( "single anim", "impact_deck2" );
    stopfxontag( common_scripts\utility::getfx( "vfx_post_impact_debris" ), var_0, "tag_origin" );
}

handle_jet_launch_fx()
{
    self waittillmatch( "single anim", "engine_on" );
    playfxontag( level._effect["vfx_f18_engine"], self, "tag_engine_left" );
    playfxontag( level._effect["vfx_f18_engine"], self, "tag_engine_right" );
    self waittillmatch( "single anim", "engine_launch" );
    playfxontag( level._effect["vfx_f18_engine_afterburner"], self, "tag_engine_left" );
    playfxontag( level._effect["vfx_f18_engine_afterburner"], self, "tag_engine_right" );
    playfxontag( level._effect["vfx_f18_catapult_launch"], self, "tag_origin" );
    self waittillmatch( "single anim", "engine_off" );

    if ( isdefined( self ) )
    {
        stopfxontag( level._effect["vfx_f18_engine"], self, "tag_engine_left" );
        stopfxontag( level._effect["vfx_f18_engine"], self, "tag_engine_right" );
        stopfxontag( level._effect["vfx_f18_engine_afterburner"], self, "tag_engine_left" );
        stopfxontag( level._effect["vfx_f18_engine_afterburner"], self, "tag_engine_right" );
    }
}

handle_zodiac_propeller()
{
    self endon( "death" );
    self endon( "reached_dynamic_path_end" );
    thread handle_zodiac_propeller_end();
    playfxontag( level._effect["vfx_zodiac_propeller_fast"], self, "TAG_FX_LF" );
}

handle_zodiac_splash()
{
    self endon( "death" );
    self endon( "reached_dynamic_path_end" );

    for (;;)
    {
        self waittill( "impact_front_both" );
        playfxontag( level._effect["vfx_zodiac_water_splash"], self, "TAG_WHEEL_FRONT_RIGHT" );
        playfxontag( level._effect["vfx_zodiac_water_splash"], self, "TAG_WHEEL_FRONT_LEFT" );
    }
}

handle_zodiac_propeller_end()
{
    common_scripts\utility::waittill_any( "death", "reached_dynamic_path_end" );

    if ( isdefined( self ) )
        stopfxontag( level._effect["vfx_zodiac_propeller_fast"], self, "TAG_FX_LF" );
}

handle_sliding_osprey_fx( var_0 )
{
    common_scripts\utility::flag_wait( var_0 );
    self waittillmatch( "single anim", "front_fx1_contact" );
    playfxontag( level._effect["vfx_jetscrape_point_runner"], self, "tag_front_fx1" );
    self waittillmatch( "single anim", "front_fx1_stop" );
    stopfxontag( level._effect["vfx_jetscrape_point_runner"], self, "tag_front_fx1" );
}
