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

main()
{
    maps\mp\mp_snow_precache::main();
    maps\createart\mp_snow_art::main();
    maps\mp\mp_snow_fx::main();
    thread maps\mp\_fx::func_glass_handler();
    common_scripts\utility::flag_init( "satellite_crashed" );
    common_scripts\utility::flag_init( "satellite_incoming" );
    level.snow_satellite_allowed = maps\mp\_utility::allowlevelkillstreaks();
    level thread satellite_fall();
    precache();
    level.mapcustomcratefunc = ::snowcustomcratefunc;
    level.mapcustomkillstreakfunc = ::snowcustomkillstreakfunc;
    level.mapcustombotkillstreakfunc = ::snowcustombotkillstreakfunc;
    maps\mp\_load::main();
    precacheshader( "fullscreen_dirtylense" );
    maps\mp\_compass::setupminimap( "compass_map_mp_snow" );
    maps\mp\_utility::setdvar_cg_ng( "r_specularColorScale", 2.3, 10 );
    maps\mp\_utility::setdvar_cg_ng( "r_diffuseColorScale", 1.2, 3 );
    setdvar( "r_ssaorejectdepth", 1500 );
    setdvar( "r_ssaofadedepth", 1200 );
    setdvar( "r_sky_fog_intensity", "1" );
    setdvar( "r_sky_fog_min_angle", "74.6766" );
    setdvar( "r_sky_fog_max_angle", "91.2327" );
    setdvar( "r_lightGridEnableTweaks", 1 );
    setdvar( "r_lightGridIntensity", 1.33 );

    if ( level.ps3 )
        setdvar( "sm_sunShadowScale", "0.6" );
    else if ( level.xenon )
        setdvar( "sm_sunShadowScale", "0.7" );

    game["attackers"] = "allies";
    game["defenders"] = "axis";
    common_scripts\utility::flag_init( "satellite_active" );
    common_scripts\utility::flag_init( "satellite_charged" );
    level thread lighthouse();
    level thread snowmen();
    common_scripts\utility::waitframe();
    level thread group_anim( "buoy", "mp_snow_buoy_sway", 0.2, 1.0 );
    level thread group_anim( "boat", "mp_snow_boat_sway", 0.2, 1.0 );
    level thread fishing_boat();
    level thread rotate_helicopter_rotor();
    level thread ice();
    level thread initextracollision();
}

initextracollision()
{
    var_0 = getent( "player32x32x8", "targetname" );
    var_1 = spawn( "script_model", ( -1646.94, 881.505, -2.82839 ) );
    var_1.angles = ( 270, 211.182, 123.817 );
    var_1 clonebrushmodeltoscriptmodel( var_0 );
    var_2 = getent( "clip64x64x128", "targetname" );
    var_3 = spawn( "script_model", ( 245, 2512, -64 ) );
    var_3.angles = ( 0, 0, 0 );
    var_3 clonebrushmodeltoscriptmodel( var_2 );
    var_4 = getent( "clip256x256x128", "targetname" );
    var_5 = spawn( "script_model", ( -1536, -1312, -136 ) );
    var_5.angles = ( 0, 0, 0 );
    var_5 clonebrushmodeltoscriptmodel( var_4 );
    var_6 = getent( "clip256x256x128", "targetname" );
    var_7 = spawn( "script_model", ( -1484, -1440, -136 ) );
    var_7.angles = ( 0, 45, 0 );
    var_7 clonebrushmodeltoscriptmodel( var_6 );

    if ( maps\mp\_utility::is_gen4() )
    {
        var_8 = getent( "player64x64x128", "targetname" );
        var_9 = spawn( "script_model", ( -1474, 966, -136 ) );
        var_9.angles = ( 0, 352, 0 );
        var_9 clonebrushmodeltoscriptmodel( var_8 );
        var_10 = getent( "clip128x128x8", "targetname" );
        var_11 = spawn( "script_model", ( 1700, 872, -48 ) );
        var_11.angles = ( 0, 335, 0 );
        var_11 clonebrushmodeltoscriptmodel( var_10 );
    }
}

fishing_boat()
{
    var_0 = getentarray( "fishing_boat", "targetname" );

    foreach ( var_2 in var_0 )
    {
        var_3 = spawn( "script_model", var_2.origin );
        var_3.angles = ( 0, 0, 0 );
        var_3 setmodel( "generic_prop_raven" );
        var_2 linkto( var_3, "tag_origin" );
        var_3 scriptmodelplayanimdeltamotion( "mp_snow_fishingboat_sway_prop" );
        var_4 = getent( var_2.target, "targetname" );

        if ( isdefined( var_4 ) )
        {
            var_4 linkto( var_3, "tag_origin" );
            var_4 scriptmodelplayanimdeltamotion( "mp_snow_fishingboat_sway" );
        }

        var_2.no_moving_platfrom_death = 1;
    }
}

lighthouse()
{
    var_0 = getent( "lighthouse", "targetname" );
    var_1 = spawn( "script_model", var_0.origin );
    var_1.angles = var_0.angles;
    var_1 setmodel( "generic_prop_raven" );
    var_0 linkto( var_1, "j_prop_1" );
    var_1 scriptmodelplayanimdeltamotion( "mp_snow_lighthouse_scan" );
    var_2 = spawn( "script_model", var_0.origin + ( 0, 0, 70 ) );
    var_2.angles = var_0.angles;
    var_2 setmodel( "tag_origin" );
    var_2 linkto( var_1, "j_prop_1" );
    var_0.fx_ent = var_2;
    level thread lighthouse_play_fx_onconnect( var_0 );
}

snowmen()
{
    var_0 = getscriptablearray( "snowman", "targetname" );

    foreach ( var_2 in var_0 )
        var_2 thread snowman_death_watch();
}

snowman_death_watch()
{
    self waittill( "death" );
    maps\mp\_movers::notify_moving_platform_invalid();
}

lighthouse_play_fx_onconnect( var_0 )
{
    for (;;)
    {
        level waittill( "connected", var_1 );
        playfxontagforclients( level._effect["mp_snow_lighthouse"], var_0.fx_ent, "tag_origin", var_1 );
    }
}

precache()
{
    precachempanim( "mp_snow_boat_sway" );
    precachempanim( "mp_snow_buoy_sway" );
    precachempanim( "mp_snow_fishingboat_sway" );
    precachempanim( "mp_snow_fishingboat_sway_prop" );
    precachempanim( "mp_snow_tree_fall" );
    precachempanim( "mp_snow_tree_prefall_loop" );
}

is_dynamic_path()
{
    return isdefined( self.spawnflags ) && self.spawnflags & 1;
}

is_ai_sight_line()
{
    return isdefined( self.spawnflags ) && self.spawnflags & 2;
}

satellite_fall()
{
    if ( getdvar( "r_reflectionProbeGenerate" ) == "1" )
        return;

    if ( level.snow_satellite_allowed )
        level thread play_satellite_static_on_connect();

    common_scripts\utility::waitframe();
    var_0 = getent( "tree_broken_stump", "targetname" );
    var_1 = getent( "tree_broken_top", "targetname" );
    var_2 = spawn( "script_model", var_0.origin );
    var_2.angles = ( 0, 0, 0 );
    var_2 setmodel( "generic_prop_raven" );
    var_2 scriptmodelplayanimdeltamotion( "mp_snow_tree_prefall_loop" );
    var_0 linkto( var_2, "j_prop_1", ( 0, 0, 0 ), ( 0, 0, 0 ) );
    var_1 linkto( var_2, "j_prop_2", ( 0, 0, 0 ), ( 0, 0, 0 ) );
    var_3 = satellite_group( "satellite_pre_crash" );
    var_4 = satellite_group( "satellite_post_crash" );

    if ( !isdefined( var_3 ) || !isdefined( var_4 ) )
        return;

    var_4 satellite_group_hide();

    if ( !level.snow_satellite_allowed )
    {
        satellite_set_post_crash( var_3, var_4 );
        return;
    }

    var_5 = getent( "satellite_flash_trigger", "targetname" );
    var_6 = getent( "satellite_kill_trigger", "targetname" );
    var_7 = common_scripts\utility::getstruct( "sat_start", "targetname" );
    var_8 = getent( "sat_start_kill_trigger", "targetname" );

    if ( isdefined( var_8 ) )
    {
        var_8.start_origin = var_8.origin;
        var_8.start_angles = var_8.angles;
        var_8 enablelinkto();
    }

    if ( level.createfx_enabled )
    {
        while ( !isdefined( level.player ) )
            common_scripts\utility::waitframe();

        level.players = [ level.player ];
        level.characters = [];
    }
    else
        maps\mp\_utility::gameflagwait( "prematch_done" );

    for (;;)
    {
        var_9 = spawn( "script_model", var_7.origin );
        var_9.angles = var_7.angles;
        var_9 setmodel( "tag_origin" );
        var_10 = satellite_killstreak_wait();
        var_11 = undefined;

        if ( isdefined( var_10 ) )
            var_11 = var_10.team;

        common_scripts\utility::flag_set( "satellite_incoming" );
        wait 0.5;
        var_12 = 2000;

        if ( isdefined( var_8 ) )
        {
            var_8 linkto( var_9 );
            var_8 thread monitor_touching();
        }

        level thread play_satellite_fx_on_model( var_9 );
        var_9 playsoundonmovingent( "scn_satellite_entry" );
        var_13 = var_7;

        for ( var_14 = 0; isdefined( var_13.target ); var_13 = var_15 )
        {
            var_14++;
            var_15 = common_scripts\utility::getstruct( var_13.target, "targetname" );
            var_16 = distance( var_13.origin, var_15.origin );
            var_17 = var_16 / var_12;
            var_9 moveto( var_15.origin, var_17 );
            level.satellite = var_9;

            if ( var_14 == 1 )
                var_9 rotatevelocity( ( -360, 0, 0 ), var_17 );
            else
                var_9 rotatevelocity( ( 0, 1500, 1500 ), var_17 );

            var_9 waittill( "movedone" );

            if ( var_14 == 1 )
            {
                var_2 scriptmodelclearanim();
                var_2 scriptmodelplayanim( "mp_snow_tree_fall" );
                common_scripts\utility::exploder( "2" );

                foreach ( var_19 in level.players )
                    var_19 playrumbleonentity( "artillery_rumble" );

                var_9 playsound( "scn_satellite_skip" );
                continue;
            }

            common_scripts\utility::flag_clear( "satellite_incoming" );
            satellite_flash( var_9.origin, 2000, 0, var_5 );
            earthquake( 0.5, 3, var_9.origin, 2000 );
            playfx( level._effect["satellite_fall_impact"], var_9.origin );

            while ( level.ingraceperiod )
                common_scripts\utility::waitframe();

            foreach ( var_22 in level.characters )
            {
                if ( var_22 istouching( var_6 ) )
                {
                    if ( isdefined( var_10 ) && ( !level.teambased || var_22.team != var_11 ) )
                    {
                        var_22 dodamage( var_22.health + 1000, var_22.origin, var_10, var_9, "MOD_EXPLOSIVE" );
                        continue;
                    }

                    var_22 maps\mp\_movers::mover_suicide();
                }
            }

            if ( isdefined( level.littlebirds ) )
            {
                foreach ( var_25 in level.littlebirds )
                {
                    if ( var_25 istouching( var_6 ) )
                        var_25 notify( "death" );
                }
            }

            var_9 playsound( "scn_satellite_impact" );
            common_scripts\utility::waitframe();
            satellite_set_post_crash( var_3, var_4 );
        }

        if ( isdefined( var_8 ) )
        {
            var_8 unlink();
            var_8.origin = var_8.start_origin;
            var_8.angles = var_8.start_angles;
        }

        var_9 delete();

        if ( !maps\mp\_utility::levelflag( "post_game_level_event_active" ) )
        {
            if ( !level.teambased && !isdefined( var_10 ) )
                continue;

            var_27 = common_scripts\utility::getstruct( "satellite_use_loc", "targetname" );
            var_28 = spawn( "script_origin", var_27.origin );
            var_28.angles = ( 0, 0, 0 );
            var_28.owner = var_10;
            var_28.team = var_11;
            var_28.immediatedeath = 0;

            if ( isdefined( var_10 ) )
                var_28 setotherent( var_10 );

            maps\mp\killstreaks\_uplink::adduplinktolevellist( var_28 );
            var_29 = 0;

            if ( !var_29 )
                break;
        }
    }
}

monitor_touching()
{
    level endon( "satellite_crashed" );

    for (;;)
    {
        if ( isdefined( level.littlebirds ) )
        {
            if ( level.littlebirds.size > 0 )
            {
                foreach ( var_1 in level.littlebirds )
                {
                    if ( var_1 istouching( self ) )
                        var_1 notify( "death" );
                }
            }
        }

        common_scripts\utility::waitframe();
    }
}

satellite_set_post_crash( var_0, var_1 )
{
    common_scripts\utility::flag_set( "satellite_crashed" );

    foreach ( var_3 in level.players )
        var_3 thread play_exploder_when_not_in_killcam();

    var_0 satellite_group_hide();
    var_1 satellite_group_show();
    level thread play_crater_fire_on_connect();
}

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

    while ( maps\mp\_utility::isinkillcam() )
        common_scripts\utility::waitframe();

    common_scripts\utility::exploder( "32", self );
}

satellite_flash( var_0, var_1, var_2, var_3 )
{
    foreach ( var_5 in level.players )
    {
        var_6 = var_5 geteye();
        var_7 = var_0 - var_6;
        var_8 = length( var_7 );

        if ( var_8 > var_1 )
            continue;

        var_7 = vectornormalize( var_7 );
        var_9 = anglestoforward( var_5 getplayerangles() );
        var_10 = vectordot( var_9, var_7 );

        if ( var_10 < var_2 )
            continue;

        if ( isdefined( var_3 ) )
        {
            if ( !var_5 istouching( var_3 ) )
                continue;
        }

        var_5 shellshock( "flashbang_mp", max( 2.0, 4 * ( 1 - var_8 / var_1 ) ) );
    }
}

satellite_group_hide()
{
    if ( isdefined( self.satellite_group_hide ) && self.satellite_group_hide )
        return;

    self.satellite_group_hide = 1;
    self.origin = self.origin - ( 0, 0, 1000 );

    foreach ( var_1 in self.clip )
        var_1 satellite_clip_hide();

    self dontinterpolate();
}

satellite_clip_hide()
{
    if ( is_dynamic_path() )
        self connectpaths();

    if ( is_ai_sight_line() )
        self setaisightlinevisible( 0 );

    maps\mp\_movers::notify_moving_platform_invalid();
    self.old_contents = self setcontents( 0 );
    self notsolid();
    self hide();
}

satellite_group_show()
{
    if ( isdefined( self.satellite_group_hide ) && !self.satellite_group_hide )
        return;

    self.satellite_group_hide = 0;
    self.origin = self.origin + ( 0, 0, 1000 );

    foreach ( var_1 in self.clip )
        var_1 satellite_clip_show();

    self dontinterpolate();
}

satellite_clip_show()
{
    self solid();
    self setcontents( self.old_contents );
    self show();

    if ( is_dynamic_path() )
        self disconnectpaths();

    if ( is_ai_sight_line() )
        self setaisightlinevisible( 1 );
}

satellite_group( var_0 )
{
    var_1 = common_scripts\utility::getstruct( var_0, "targetname" );

    if ( !isdefined( var_1 ) )
        return undefined;

    var_2 = spawn( "script_model", var_1.origin );
    var_2 setmodel( "tag_origin" );
    var_2.clip = [];
    var_2.linked = [];
    var_3 = getentarray( var_1.target, "targetname" );

    foreach ( var_5 in var_3 )
    {
        if ( var_5.classname == "script_brushmodel" )
        {
            var_2.clip[var_2.clip.size] = var_5;
            continue;
        }

        var_2.linked[var_2.linked.size] = var_5;
        var_5 linkto( var_2 );
    }

    return var_2;
}

satellite_killstreak_wait()
{
    level thread satellite_activate_at_end_of_match();
    level thread satellite_killstreak_notify_wait();
    level waittill( "satellite_start", var_0 );
    return var_0;
}

satellite_activate_at_end_of_match()
{
    level endon( "satellite_start" );

    if ( !level.snow_satellite_allowed )
        return;

    level waittill( "spawning_intermission" );
    level thread satellite_end_of_match();
    level notify( "satellite_start" );
}

satellite_end_of_match()
{
    maps\mp\_utility::levelflagset( "post_game_level_event_active" );
    visionsetnaked( "", 0.5 );
    wait 15;
    maps\mp\_utility::levelflagclear( "post_game_level_event_active" );
}

satellite_killstreak_notify_wait()
{
    level waittill( "snow_satellite_killstreak", var_0 );
    level notify( "satellite_start", var_0 );
}

move_satellite( var_0 )
{
    var_1 = self.origin;
    var_2 = 3.0;
    var_3 = 3.0;

    for (;;)
    {
        self moveto( var_0, var_2, var_3, 0 );
        wait( var_2 + 3.0 );
        self moveto( var_1, 0.1 );
        wait 0.1;
    }
}

play_satellite_static_on_connect()
{
    for (;;)
    {
        level waittill( "connected", var_0 );
        var_0 thread run_func_after_spawn( ::satellite_static );
    }
}

play_crater_fire_on_connect()
{
    for (;;)
    {
        level waittill( "connected", var_0 );
        var_0 thread run_func_after_spawn( ::call_fire_exploder_on_spawn );
    }
}

call_fire_exploder_on_spawn()
{
    self endon( "disconnect" );
    common_scripts\utility::exploder( "32", self );
}

run_func_after_spawn( var_0 )
{
    self endon( "disconnect" );
    self endon( "death" );
    self waittill( "spawned_player" );
    self thread [[ var_0 ]]();
}

play_satellite_fx_on_model( var_0 )
{
    playfxontag( level._effect["satellite_fall"], var_0, "tag_origin" );
    playfxontag( level._effect["satellite_fall_child0"], var_0, "tag_origin" );
    wait 0.7;
    playfxontag( level._effect["satellite_fall_child1"], var_0, "tag_origin" );
    wait 0.7;
    playfxontag( level._effect["satellite_fall_child2"], var_0, "tag_origin" );
    wait 0.7;
    playfxontag( level._effect["satellite_fall_child3"], var_0, "tag_origin" );
    wait 0.7;
    playfxontag( level._effect["satellite_fall_child4"], var_0, "tag_origin" );
    wait 0.7;
    playfxontag( level._effect["satellite_fall_child5"], var_0, "tag_origin" );
    wait 0.7;
    playfxontag( level._effect["satellite_fall_child6"], var_0, "tag_origin" );
    wait 0.7;
    playfxontag( level._effect["satellite_fall_child7"], var_0, "tag_origin" );
    wait 0.7;
    playfxontag( level._effect["satellite_fall_child8"], var_0, "tag_origin" );
}

group_anim( var_0, var_1, var_2, var_3 )
{
    var_4 = getentarray( var_0, "targetname" );

    foreach ( var_6 in var_4 )
    {
        if ( isdefined( var_2 ) && isdefined( var_3 ) )
            wait( randomfloatrange( var_2, var_3 ) );

        var_7 = spawn( "script_model", var_6.origin );
        var_7.angles = ( 0, 0, 0 );
        var_7 setmodel( "generic_prop_raven" );
        var_6 linkto( var_7, "tag_origin" );
        var_7 scriptmodelplayanimdeltamotion( var_1 );

        if ( isdefined( var_6.target ) )
        {
            var_8 = getentarray( var_6.target, "targetname" );

            foreach ( var_10 in var_8 )
                var_10 linkto( var_7, "j_prop_1" );
        }
    }
}

rotating_windows()
{
    var_0 = getentarray( "rotating_window", "targetname" );
    common_scripts\utility::array_thread( var_0, ::rotating_windows_init );
}

rotating_windows_init()
{
    if ( !isdefined( self.target ) )
        return;

    var_0 = common_scripts\utility::getstructarray( self.target, "targetname" );

    foreach ( var_2 in var_0 )
    {
        switch ( var_2.script_noteworthy )
        {
            case "open_angles":
                self.open_angles = var_2.angles;
                break;
            case "closed_angles":
                self.closed_angles = var_2.angles;
                break;
            default:
                break;
        }
    }

    var_4 = getentarray( self.target, "targetname" );
    self.hide_when_closed = [];

    foreach ( var_6 in var_4 )
    {
        switch ( var_6.script_noteworthy )
        {
            case "open_trigger":
                self.open_trigger = var_6;
                break;
            case "close_trigger":
                self.close_trigger = var_6;
                break;
            case "hide_when_closed":
                self.hide_when_closed[self.hide_when_closed.size] = var_6;
                break;
            default:
                break;
        }
    }

    self setcandamage( 0 );
    thread rotating_windows_run();
}

rotating_windows_run()
{
    var_0 = spawn( "script_model", self.origin );
    var_0.angles = self.open_angles;
    var_0 setmodel( "tag_origin" );
    self linkto( var_0, "tag_origin" );
    var_1 = 0;

    if ( isdefined( self.script_noteworthy ) && self.script_noteworthy == "start_closed" )
    {
        var_1 = 1;
        self.open_trigger common_scripts\utility::trigger_off();

        foreach ( var_3 in self.hide_when_closed )
            var_3 hide();
    }
    else
    {
        self.close_trigger common_scripts\utility::trigger_off();

        foreach ( var_3 in self.hide_when_closed )
            var_3 show();
    }

    var_7 = angleclamp( self.closed_angles[0] - self.open_angles[0] );

    for (;;)
    {
        if ( var_1 )
            var_1 = 0;
        else
        {
            self.open_trigger common_scripts\utility::trigger_off();
            self.close_trigger common_scripts\utility::trigger_on();
            self.close_trigger waittill( "trigger" );

            foreach ( var_3 in self.hide_when_closed )
                var_3 hide();

            var_0 rotatepitch( var_7, 0.3, 0, 0 );
            wait 1;
        }

        self.open_trigger common_scripts\utility::trigger_on();
        self.close_trigger common_scripts\utility::trigger_off();
        self.open_trigger waittill( "trigger" );
        var_0 rotatepitch( -1 * var_7, 0.3, 0, 0 );
        wait 0.3;

        foreach ( var_3 in self.hide_when_closed )
            var_3 show();

        wait 0.7;
    }
}

satellite_scrambler()
{
    var_0 = common_scripts\utility::getstruct( "satellite_use_loc", "targetname" );
    var_1 = spawn( "script_model", var_0.origin );
    var_1.angles = var_0.angles;
    var_1 makescrambler( self );
}

rotate_helicopter_rotor()
{
    var_0 = getent( "heli_rotor_top", "targetname" );
    var_0 rotatevelocity( ( 0, -300, 0 ), 36000, 0, 0 );
    var_1 = getent( "heli_rotor_back", "targetname" );

    if ( isdefined( var_1 ) )
        var_1 rotatevelocity( ( -300, 0, 0 ), 36000, 0, 0 );
}

satellite_static()
{
    self endon( "disconnect" );
    var_0 = common_scripts\utility::getstruct( "satellite_use_loc", "targetname" );
    maps\mp\killstreaks\_emp_common::staticfieldinit();
    var_1 = 512;
    var_2 = var_1 * var_1;

    for (;;)
    {
        var_3 = length2dsquared( self.origin - var_0.origin ) < var_2;

        if ( var_3 && common_scripts\utility::flag( "satellite_crashed" ) )
            maps\mp\killstreaks\_emp_common::staticfieldsetstrength( 1 );
        else
            maps\mp\killstreaks\_emp_common::staticfieldsetstrength( 0 );

        wait 0.5;
    }
}

satellite_static_emp_watch()
{
    level common_scripts\utility::waittill_either( "emp_update" );
}

ice()
{
    var_0 = getentarray( "ice", "targetname" );
    common_scripts\utility::array_thread( var_0, ::ice_init );
}

ice_init()
{
    self.start_origin = self.origin;
    self.anim_ref = self;
    var_0 = getentarray( self.target, "targetname" );

    foreach ( var_2 in var_0 )
    {
        switch ( var_2.script_noteworthy )
        {
            case "border":
                self.border = var_2;
                break;
            case "trigger_sink":
                self.trigger = var_2;
                self.trigger enablelinkto();
                self.trigger linkto( self );
                break;
            default:
                break;
        }
    }

    thread ice_damage_watch();
}

ice_damage_watch()
{
    self setcandamage( 1 );
    self.health = 30;

    for (;;)
    {
        self waittill( "damage" );

        if ( self.health <= 0 )
            break;
    }

    if ( isdefined( self.script_fxid ) )
        common_scripts\utility::exploder( self.script_fxid );

    self playsound( "pond_ice_crack" );
    self.border delete();
    thread ice_float();
    thread ice_player_watch();
    thread ice_sink();
}

ice_float()
{
    var_0 = 0;

    for (;;)
    {
        var_1 = randomfloatrange( 3, 5 );
        var_2 = ( randomfloatrange( -1, 1 ), randomfloatrange( -1, 1 ), randomfloatrange( -1, 1 ) );
        var_2 = vectornormalize( var_2 );
        var_2 = var_2 * 3;

        if ( var_0 <= 2 )
        {
            var_2 = var_2 * ( 3 - var_0 );
            var_1 = var_1 / ( 3 - var_0 );
        }

        self rotateto( var_2, var_1 );
        self waittill( "rotatedone" );
        var_0++;
    }
}

ice_player_watch()
{
    self.sink_time = 0;

    for (;;)
    {
        self.trigger waittill( "trigger" );
        self.sink_time = gettime() + 200;
    }
}

ice_sink()
{
    var_0 = 40;
    var_1 = 20;
    var_2 = self.start_origin;
    var_3 = var_2 - ( 0, 0, 100 );

    for (;;)
    {
        while ( self.sink_time < gettime() )
            common_scripts\utility::waitframe();

        var_4 = distance( self.origin, var_3 );
        var_5 = var_4 / var_0;
        self.anim_ref moveto( var_3, var_5 );

        while ( self.sink_time >= gettime() )
            common_scripts\utility::waitframe();

        var_4 = distance( self.origin, var_2 );
        var_5 = var_4 / var_1;
        self.anim_ref moveto( var_2, var_5, 0, var_5 );
    }
}

wait_game_percent_complete( var_0, var_1 )
{
    if ( !isdefined( var_1 ) )
        var_1 = var_0;

    maps\mp\_utility::gameflagwait( "prematch_done" );

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

    var_2 = maps\mp\_utility::getscorelimit();
    var_3 = maps\mp\_utility::gettimelimit() * 60;
    var_4 = 0;
    var_5 = 0;

    if ( var_2 <= 0 && var_3 <= 0 )
    {
        var_4 = 1;
        var_3 = 600;
    }
    else if ( var_2 <= 0 )
        var_4 = 1;
    else if ( var_3 <= 0 )
        var_5 = 1;

    var_6 = var_0 * var_3;
    var_7 = var_1 * var_2;
    var_8 = get_highest_score();
    var_9 = ( gettime() - level.starttime ) / 1000;

    if ( var_4 )
    {
        while ( var_9 < var_6 )
        {
            wait 0.5;
            var_9 = ( gettime() - level.starttime ) / 1000;
        }
    }
    else if ( var_5 )
    {
        while ( var_8 < var_7 )
        {
            wait 0.5;
            var_8 = get_highest_score();
        }
    }
    else
    {
        while ( var_9 < var_6 && var_8 < var_7 )
        {
            wait 0.5;
            var_8 = get_highest_score();
            var_9 = ( gettime() - level.starttime ) / 1000;
        }
    }
}

get_highest_score()
{
    var_0 = 0;

    if ( level.teambased )
    {
        if ( isdefined( game["teamScores"] ) )
        {
            var_0 = game["teamScores"]["allies"];

            if ( game["teamScores"]["axis"] > var_0 )
                var_0 = game["teamScores"]["axis"];
        }
    }
    else if ( isdefined( level.players ) )
    {
        foreach ( var_2 in level.players )
        {
            if ( isdefined( var_2.score ) && var_2.score > var_0 )
                var_0 = var_2.score;
        }
    }

    return var_0;
}

snowcustomcratefunc()
{
    if ( !isdefined( game["player_holding_level_killstrek"] ) )
        game["player_holding_level_killstrek"] = 0;

    if ( !level.snow_satellite_allowed || game["player_holding_level_killstrek"] )
        return;

    maps\mp\killstreaks\_airdrop::addcratetype( "airdrop_assault", "snow_satellite", 55, maps\mp\killstreaks\_airdrop::killstreakcratethink, maps\mp\killstreaks\_airdrop::get_friendly_crate_model(), maps\mp\killstreaks\_airdrop::get_enemy_crate_model(), &"KILLSTREAKS_HINTS_SNOW_SATELLITE" );
    level thread watch_for_snow_satellite_crate();
}

watch_for_snow_satellite_crate()
{
    for (;;)
    {
        level waittill( "createAirDropCrate", var_0 );

        if ( isdefined( var_0 ) && isdefined( var_0.cratetype ) && var_0.cratetype == "snow_satellite" )
        {
            disable_snow_satellite();
            var_1 = wait_for_capture( var_0 );

            if ( !var_1 )
            {
                maps\mp\killstreaks\_airdrop::changecrateweight( "airdrop_assault", "snow_satellite", 55 );
                continue;
            }

            game["player_holding_level_killstrek"] = 1;
            break;
        }
    }
}

wait_for_capture( var_0 )
{
    var_1 = watch_for_air_drop_death( var_0 );
    return !isdefined( var_1 );
}

watch_for_air_drop_death( var_0 )
{
    var_0 endon( "captured" );
    var_0 waittill( "death" );
    waittillframeend;
    return 1;
}

disable_snow_satellite()
{
    maps\mp\killstreaks\_airdrop::changecrateweight( "airdrop_assault", "snow_satellite", 0 );
}

snowcustomkillstreakfunc()
{
    level.killstreakfuncs["snow_satellite"] = ::tryusesnowsatellite;
    level.killstreakweildweapons["snow_satellite_mp"] = "snow_satellite";
}

snowcustombotkillstreakfunc()
{
    maps\mp\bots\_bots_ks::bot_register_killstreak_func( "snow_satellite", maps\mp\bots\_bots_ks::bot_killstreak_simple_use );
}

tryusesnowsatellite( var_0, var_1 )
{
    game["player_holding_level_killstrek"] = 0;
    level notify( "snow_satellite_killstreak", self );
    return 1;
}
