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

exploder_sound()
{
    if ( isdefined( self.script_delay ) )
        wait( self.script_delay );

    self playsound( level.scr_sound[self.script_sound] );
}

_beginlocationselection( var_0, var_1, var_2, var_3 )
{
    self beginlocationselection( var_1, var_2, var_3 );
    self.selectinglocation = 1;
    self setblurforplayer( 10.3, 0.3 );
    thread endselectiononaction( "cancel_location" );
    thread endselectiononaction( "death" );
    thread endselectiononaction( "disconnect" );
    thread endselectiononaction( "used" );
    thread endselectiononaction( "weapon_change" );
    self endon( "stop_location_selection" );
    thread endselectiononendgame();
    thread endselectiononemp();

    if ( isdefined( var_0 ) && self.team != "spectator" )
    {
        if ( isdefined( self.streakmsg ) )
            self.streakmsg destroy();

        if ( self issplitscreenplayer() )
        {
            self.streakmsg = maps\mp\gametypes\_hud_util::createfontstring( "default", 1.3 );
            self.streakmsg maps\mp\gametypes\_hud_util::setpoint( "CENTER", "CENTER", 0, -98 );
        }
        else
        {
            self.streakmsg = maps\mp\gametypes\_hud_util::createfontstring( "default", 1.6 );
            self.streakmsg maps\mp\gametypes\_hud_util::setpoint( "CENTER", "CENTER", 0, -190 );
        }

        var_4 = getkillstreakname( var_0 );
        self.streakmsg settext( var_4 );
    }
}

stoplocationselection( var_0, var_1 )
{
    if ( !isdefined( var_1 ) )
        var_1 = "generic";

    if ( !var_0 )
    {
        self setblurforplayer( 0, 0.3 );
        self endlocationselection();
        self.selectinglocation = undefined;

        if ( isdefined( self.streakmsg ) )
            self.streakmsg destroy();
    }

    self notify( "stop_location_selection", var_1 );
}

endselectiononemp()
{
    self endon( "stop_location_selection" );

    for (;;)
    {
        level waittill( "emp_update" );

        if ( !isemped() )
            continue;

        thread stoplocationselection( 0, "emp" );
        return;
    }
}

endselectiononaction( var_0 )
{
    self endon( "stop_location_selection" );
    self waittill( var_0 );
    thread stoplocationselection( var_0 == "disconnect", var_0 );
}

endselectiononendgame()
{
    self endon( "stop_location_selection" );
    level waittill( "game_ended" );
    thread stoplocationselection( 0, "end_game" );
}

isattachment( var_0 )
{
    if ( is_aliens() )
        var_1 = tablelookup( "mp/alien/alien_attachmentTable.csv", 4, var_0, 0 );
    else
        var_1 = tablelookup( "mp/attachmentTable.csv", 4, var_0, 0 );

    if ( isdefined( var_1 ) && var_1 != "" )
        return 1;
    else
        return 0;
}

getattachmenttype( var_0 )
{
    if ( is_aliens() )
        var_1 = tablelookup( "mp/alien/alien_attachmentTable.csv", 4, var_0, 2 );
    else
        var_1 = tablelookup( "mp/attachmentTable.csv", 4, var_0, 2 );

    return var_1;
}

delaythread( var_0, var_1, var_2, var_3, var_4, var_5, var_6 )
{
    thread delaythread_proc( var_1, var_0, var_2, var_3, var_4, var_5, var_6 );
}

delaythread_proc( var_0, var_1, var_2, var_3, var_4, var_5, var_6 )
{
    wait( var_1 );

    if ( !isdefined( var_2 ) )
        thread [[ var_0 ]]();
    else if ( !isdefined( var_3 ) )
        thread [[ var_0 ]]( var_2 );
    else if ( !isdefined( var_4 ) )
        thread [[ var_0 ]]( var_2, var_3 );
    else if ( !isdefined( var_5 ) )
        thread [[ var_0 ]]( var_2, var_3, var_4 );
    else if ( !isdefined( var_6 ) )
        thread [[ var_0 ]]( var_2, var_3, var_4, var_5 );
    else
        thread [[ var_0 ]]( var_2, var_3, var_4, var_5, var_6 );
}

array_contains_index( var_0, var_1 )
{
    foreach ( var_4, var_3 in var_0 )
    {
        if ( var_4 == var_1 )
            return 1;
    }

    return 0;
}

getplant()
{
    var_0 = self.origin + ( 0, 0, 10 );
    var_1 = 11;
    var_2 = anglestoforward( self.angles );
    var_2 = var_2 * var_1;
    var_3[0] = var_0 + var_2;
    var_3[1] = var_0;
    var_4 = bullettrace( var_3[0], var_3[0] + ( 0, 0, -18 ), 0, undefined );

    if ( var_4["fraction"] < 1 )
    {
        var_5 = spawnstruct();
        var_5.origin = var_4["position"];
        var_5.angles = orienttonormal( var_4["normal"] );
        return var_5;
    }

    var_4 = bullettrace( var_3[1], var_3[1] + ( 0, 0, -18 ), 0, undefined );

    if ( var_4["fraction"] < 1 )
    {
        var_5 = spawnstruct();
        var_5.origin = var_4["position"];
        var_5.angles = orienttonormal( var_4["normal"] );
        return var_5;
    }

    var_3[2] = var_0 + ( 16, 16, 0 );
    var_3[3] = var_0 + ( 16, -16, 0 );
    var_3[4] = var_0 + ( -16, -16, 0 );
    var_3[5] = var_0 + ( -16, 16, 0 );
    var_6 = undefined;
    var_7 = undefined;

    for ( var_8 = 0; var_8 < var_3.size; var_8++ )
    {
        var_4 = bullettrace( var_3[var_8], var_3[var_8] + ( 0, 0, -1000 ), 0, undefined );

        if ( !isdefined( var_6 ) || var_4["fraction"] < var_6 )
        {
            var_6 = var_4["fraction"];
            var_7 = var_4["position"];
        }
    }

    if ( var_6 == 1 )
        var_7 = self.origin;

    var_5 = spawnstruct();
    var_5.origin = var_7;
    var_5.angles = orienttonormal( var_4["normal"] );
    return var_5;
}

orienttonormal( var_0 )
{
    var_1 = ( var_0[0], var_0[1], 0 );
    var_2 = length( var_1 );

    if ( !var_2 )
        return ( 0, 0, 0 );

    var_3 = vectornormalize( var_1 );
    var_4 = var_0[2] * -1;
    var_5 = ( var_3[0] * var_4, var_3[1] * var_4, var_2 );
    var_6 = vectortoangles( var_5 );
    return var_6;
}

deleteplacedentity( var_0 )
{
    var_1 = getentarray( var_0, "classname" );

    for ( var_2 = 0; var_2 < var_1.size; var_2++ )
        var_1[var_2] delete();
}

playsoundonplayers( var_0, var_1, var_2 )
{
    if ( level.splitscreen )
    {
        if ( isdefined( level.players[0] ) )
            level.players[0] playlocalsound( var_0 );
    }
    else if ( isdefined( var_1 ) )
    {
        if ( isdefined( var_2 ) )
        {
            for ( var_3 = 0; var_3 < level.players.size; var_3++ )
            {
                var_4 = level.players[var_3];

                if ( var_4 issplitscreenplayer() && !var_4 issplitscreenplayerprimary() )
                    continue;

                if ( isdefined( var_4.pers["team"] ) && var_4.pers["team"] == var_1 && !isexcluded( var_4, var_2 ) )
                    var_4 playlocalsound( var_0 );
            }

            return;
        }

        for ( var_3 = 0; var_3 < level.players.size; var_3++ )
        {
            var_4 = level.players[var_3];

            if ( var_4 issplitscreenplayer() && !var_4 issplitscreenplayerprimary() )
                continue;

            if ( isdefined( var_4.pers["team"] ) && var_4.pers["team"] == var_1 )
                var_4 playlocalsound( var_0 );
        }

        return;
    }
    else if ( isdefined( var_2 ) )
    {
        for ( var_3 = 0; var_3 < level.players.size; var_3++ )
        {
            if ( level.players[var_3] issplitscreenplayer() && !level.players[var_3] issplitscreenplayerprimary() )
                continue;

            if ( !isexcluded( level.players[var_3], var_2 ) )
                level.players[var_3] playlocalsound( var_0 );
        }
    }
    else
    {
        for ( var_3 = 0; var_3 < level.players.size; var_3++ )
        {
            if ( level.players[var_3] issplitscreenplayer() && !level.players[var_3] issplitscreenplayerprimary() )
                continue;

            level.players[var_3] playlocalsound( var_0 );
        }
    }
}

sortlowermessages()
{
    for ( var_0 = 1; var_0 < self.lowermessages.size; var_0++ )
    {
        var_1 = self.lowermessages[var_0];
        var_2 = var_1.priority;

        for ( var_3 = var_0 - 1; var_3 >= 0 && var_2 > self.lowermessages[var_3].priority; var_3-- )
            self.lowermessages[var_3 + 1] = self.lowermessages[var_3];

        self.lowermessages[var_3 + 1] = var_1;
    }
}

addlowermessage( var_0, var_1, var_2, var_3, var_4, var_5, var_6, var_7, var_8, var_9 )
{
    var_10 = undefined;

    foreach ( var_12 in self.lowermessages )
    {
        if ( var_12.name == var_0 )
        {
            if ( var_12.text == var_1 && var_12.priority == var_3 )
                return;

            var_10 = var_12;
            break;
        }
    }

    if ( !isdefined( var_10 ) )
    {
        var_10 = spawnstruct();
        self.lowermessages[self.lowermessages.size] = var_10;
    }

    var_10.name = var_0;
    var_10.text = var_1;
    var_10.time = var_2;
    var_10.addtime = gettime();
    var_10.priority = var_3;
    var_10.showtimer = var_4;
    var_10.shouldfade = var_5;
    var_10.fadetoalpha = var_6;
    var_10.fadetoalphatime = var_7;
    var_10.hidewhenindemo = var_8;
    var_10.hidewheninmenu = var_9;
    sortlowermessages();
}

removelowermessage( var_0 )
{
    if ( isdefined( self.lowermessages ) )
    {
        for ( var_1 = self.lowermessages.size; var_1 > 0; var_1-- )
        {
            if ( self.lowermessages[var_1 - 1].name != var_0 )
                continue;

            var_2 = self.lowermessages[var_1 - 1];

            for ( var_3 = var_1; var_3 < self.lowermessages.size; var_3++ )
            {
                if ( isdefined( self.lowermessages[var_3] ) )
                    self.lowermessages[var_3 - 1] = self.lowermessages[var_3];
            }

            self.lowermessages[self.lowermessages.size - 1] = undefined;
        }

        sortlowermessages();
    }
}

getlowermessage()
{
    if ( !isdefined( self.lowermessages ) )
        return undefined;

    return self.lowermessages[0];
}

setlowermessage( var_0, var_1, var_2, var_3, var_4, var_5, var_6, var_7, var_8, var_9 )
{
    if ( !isdefined( var_3 ) )
        var_3 = 1;

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

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

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

    if ( !isdefined( var_6 ) )
        var_6 = 0.85;

    if ( !isdefined( var_7 ) )
        var_7 = 3.0;

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

    if ( !isdefined( var_9 ) )
        var_9 = 1;

    addlowermessage( var_0, var_1, var_2, var_3, var_4, var_5, var_6, var_7, var_8, var_9 );
    updatelowermessage();
}

updatelowermessage()
{
    if ( !isdefined( self ) )
        return;

    var_0 = getlowermessage();

    if ( !isdefined( var_0 ) )
    {
        if ( isdefined( self.lowermessage ) && isdefined( self.lowertimer ) )
        {
            self.lowermessage.alpha = 0;
            self.lowertimer.alpha = 0;
        }
    }
    else
    {
        self.lowermessage settext( var_0.text );
        self.lowermessage.alpha = 0.85;
        self.lowertimer.alpha = 1;
        self.lowermessage.hidewhenindemo = var_0.hidewhenindemo;
        self.lowermessage.hidewheninmenu = var_0.hidewheninmenu;

        if ( var_0.shouldfade )
        {
            self.lowermessage fadeovertime( min( var_0.fadetoalphatime, 60 ) );
            self.lowermessage.alpha = var_0.fadetoalpha;
        }

        if ( var_0.time > 0 && var_0.showtimer )
            self.lowertimer settimer( max( var_0.time - ( gettime() - var_0.addtime ) / 1000, 0.1 ) );
        else
        {
            if ( var_0.time > 0 && !var_0.showtimer )
            {
                self.lowertimer settext( "" );
                self.lowermessage fadeovertime( min( var_0.time, 60 ) );
                self.lowermessage.alpha = 0;
                thread clearondeath( var_0 );
                thread clearafterfade( var_0 );
                return;
            }

            self.lowertimer settext( "" );
        }
    }
}

clearondeath( var_0 )
{
    self notify( "message_cleared" );
    self endon( "message_cleared" );
    self endon( "disconnect" );
    level endon( "game_ended" );
    self waittill( "death" );
    clearlowermessage( var_0.name );
}

clearafterfade( var_0 )
{
    wait( var_0.time );
    clearlowermessage( var_0.name );
    self notify( "message_cleared" );
}

clearlowermessage( var_0 )
{
    removelowermessage( var_0 );
    updatelowermessage();
}

clearlowermessages()
{
    for ( var_0 = 0; var_0 < self.lowermessages.size; var_0++ )
        self.lowermessages[var_0] = undefined;

    if ( !isdefined( self.lowermessage ) )
        return;

    updatelowermessage();
}

printonteam( var_0, var_1 )
{
    foreach ( var_3 in level.players )
    {
        if ( var_3.team != var_1 )
            continue;

        var_3 iprintln( var_0 );
    }
}

printboldonteam( var_0, var_1 )
{
    for ( var_2 = 0; var_2 < level.players.size; var_2++ )
    {
        var_3 = level.players[var_2];

        if ( isdefined( var_3.pers["team"] ) && var_3.pers["team"] == var_1 )
            var_3 iprintlnbold( var_0 );
    }
}

printboldonteamarg( var_0, var_1, var_2 )
{
    for ( var_3 = 0; var_3 < level.players.size; var_3++ )
    {
        var_4 = level.players[var_3];

        if ( isdefined( var_4.pers["team"] ) && var_4.pers["team"] == var_1 )
            var_4 iprintlnbold( var_0, var_2 );
    }
}

printonteamarg( var_0, var_1, var_2 )
{
    for ( var_3 = 0; var_3 < level.players.size; var_3++ )
    {
        var_4 = level.players[var_3];

        if ( isdefined( var_4.pers["team"] ) && var_4.pers["team"] == var_1 )
            var_4 iprintln( var_0, var_2 );
    }
}

printonplayers( var_0, var_1 )
{
    var_2 = level.players;

    for ( var_3 = 0; var_3 < var_2.size; var_3++ )
    {
        if ( isdefined( var_1 ) )
        {
            if ( isdefined( var_2[var_3].pers["team"] ) && var_2[var_3].pers["team"] == var_1 )
                var_2[var_3] iprintln( var_0 );

            continue;
        }

        var_2[var_3] iprintln( var_0 );
    }
}

printandsoundoneveryone( var_0, var_1, var_2, var_3, var_4, var_5, var_6 )
{
    var_7 = isdefined( var_4 );
    var_8 = 0;

    if ( isdefined( var_5 ) )
        var_8 = 1;

    if ( level.splitscreen || !var_7 )
    {
        for ( var_9 = 0; var_9 < level.players.size; var_9++ )
        {
            var_10 = level.players[var_9];
            var_11 = var_10.team;

            if ( isdefined( var_11 ) )
            {
                if ( var_11 == var_0 && isdefined( var_2 ) )
                {
                    var_10 iprintln( var_2, var_6 );
                    continue;
                }

                if ( var_11 == var_1 && isdefined( var_3 ) )
                    var_10 iprintln( var_3, var_6 );
            }
        }

        if ( var_7 )
            level.players[0] playlocalsound( var_4 );
    }
    else if ( var_8 )
    {
        for ( var_9 = 0; var_9 < level.players.size; var_9++ )
        {
            var_10 = level.players[var_9];
            var_11 = var_10.team;

            if ( isdefined( var_11 ) )
            {
                if ( var_11 == var_0 )
                {
                    if ( isdefined( var_2 ) )
                        var_10 iprintln( var_2, var_6 );

                    var_10 playlocalsound( var_4 );
                    continue;
                }

                if ( var_11 == var_1 )
                {
                    if ( isdefined( var_3 ) )
                        var_10 iprintln( var_3, var_6 );

                    var_10 playlocalsound( var_5 );
                }
            }
        }
    }
    else
    {
        for ( var_9 = 0; var_9 < level.players.size; var_9++ )
        {
            var_10 = level.players[var_9];
            var_11 = var_10.team;

            if ( isdefined( var_11 ) )
            {
                if ( var_11 == var_0 )
                {
                    if ( isdefined( var_2 ) )
                        var_10 iprintln( var_2, var_6 );

                    var_10 playlocalsound( var_4 );
                    continue;
                }

                if ( var_11 == var_1 )
                {
                    if ( isdefined( var_3 ) )
                        var_10 iprintln( var_3, var_6 );
                }
            }
        }
    }
}

printandsoundonteam( var_0, var_1, var_2 )
{
    foreach ( var_4 in level.players )
    {
        if ( var_4.team != var_0 )
            continue;

        var_4 printandsoundonplayer( var_1, var_2 );
    }
}

printandsoundonplayer( var_0, var_1 )
{
    self iprintln( var_0 );
    self playlocalsound( var_1 );
}

_playlocalsound( var_0 )
{
    if ( level.splitscreen && self getentitynumber() != 0 )
        return;

    self playlocalsound( var_0 );
}

dvarintvalue( var_0, var_1, var_2, var_3 )
{
    var_0 = "scr_" + level.gametype + "_" + var_0;

    if ( getdvar( var_0 ) == "" )
    {
        setdvar( var_0, var_1 );
        return var_1;
    }

    var_4 = getdvarint( var_0 );

    if ( var_4 > var_3 )
        var_4 = var_3;
    else if ( var_4 < var_2 )
        var_4 = var_2;
    else
        return var_4;

    setdvar( var_0, var_4 );
    return var_4;
}

dvarfloatvalue( var_0, var_1, var_2, var_3 )
{
    var_0 = "scr_" + level.gametype + "_" + var_0;

    if ( getdvar( var_0 ) == "" )
    {
        setdvar( var_0, var_1 );
        return var_1;
    }

    var_4 = getdvarfloat( var_0 );

    if ( var_4 > var_3 )
        var_4 = var_3;
    else if ( var_4 < var_2 )
        var_4 = var_2;
    else
        return var_4;

    setdvar( var_0, var_4 );
    return var_4;
}

play_sound_on_tag( var_0, var_1 )
{
    if ( isdefined( var_1 ) )
        playsoundatpos( self gettagorigin( var_1 ), var_0 );
    else
        playsoundatpos( self.origin, var_0 );
}

getotherteam( var_0 )
{
    if ( level.multiteambased )
    {

    }

    if ( var_0 == "allies" )
        return "axis";
    else if ( var_0 == "axis" )
        return "allies";
    else
        return "none";
}

wait_endon( var_0, var_1, var_2, var_3 )
{
    self endon( var_1 );

    if ( isdefined( var_2 ) )
        self endon( var_2 );

    if ( isdefined( var_3 ) )
        self endon( var_3 );

    wait( var_0 );
}

initpersstat( var_0 )
{
    if ( !isdefined( self.pers[var_0] ) )
        self.pers[var_0] = 0;
}

getpersstat( var_0 )
{
    return self.pers[var_0];
}

incpersstat( var_0, var_1, var_2 )
{
    if ( isdefined( self ) && isdefined( self.pers ) && isdefined( self.pers[var_0] ) )
    {
        self.pers[var_0] = self.pers[var_0] + var_1;

        if ( !isdefined( var_2 ) || var_2 == 0 )
            maps\mp\gametypes\_persistence::statadd( var_0, var_1 );
    }
}

setpersstat( var_0, var_1 )
{
    self.pers[var_0] = var_1;
}

initplayerstat( var_0, var_1 )
{
    if ( !isdefined( self.stats["stats_" + var_0] ) )
    {
        if ( !isdefined( var_1 ) )
            var_1 = 0;

        self.stats["stats_" + var_0] = spawnstruct();
        self.stats["stats_" + var_0].value = var_1;
    }
}

incplayerstat( var_0, var_1 )
{
    if ( isagent( self ) || isbot( self ) )
        return;

    var_2 = self.stats["stats_" + var_0];
    var_2.value = var_2.value + var_1;
}

setplayerstat( var_0, var_1 )
{
    var_2 = self.stats["stats_" + var_0];
    var_2.value = var_1;
    var_2.time = gettime();
}

getplayerstat( var_0 )
{
    return self.stats["stats_" + var_0].value;
}

getplayerstattime( var_0 )
{
    return self.stats["stats_" + var_0].time;
}

setplayerstatifgreater( var_0, var_1 )
{
    var_2 = getplayerstat( var_0 );

    if ( var_1 > var_2 )
        setplayerstat( var_0, var_1 );
}

setplayerstatiflower( var_0, var_1 )
{
    var_2 = getplayerstat( var_0 );

    if ( var_1 < var_2 )
        setplayerstat( var_0, var_1 );
}

updatepersratio( var_0, var_1, var_2 )
{
    if ( !rankingenabled() )
        return;

    var_3 = maps\mp\gametypes\_persistence::statget( var_1 );
    var_4 = maps\mp\gametypes\_persistence::statget( var_2 );

    if ( var_4 == 0 )
        var_4 = 1;

    maps\mp\gametypes\_persistence::statset( var_0, int( var_3 * 1000 / var_4 ) );
}

updatepersratiobuffered( var_0, var_1, var_2 )
{
    if ( !rankingenabled() )
        return;

    var_3 = maps\mp\gametypes\_persistence::statgetbuffered( var_1 );
    var_4 = maps\mp\gametypes\_persistence::statgetbuffered( var_2 );

    if ( var_4 == 0 )
        var_4 = 1;

    maps\mp\gametypes\_persistence::statsetbuffered( var_0, int( var_3 * 1000 / var_4 ) );
}

waittillslowprocessallowed( var_0 )
{
    if ( level.lastslowprocessframe == gettime() )
    {
        if ( isdefined( var_0 ) && var_0 )
        {
            while ( level.lastslowprocessframe == gettime() )
                wait 0.05;
        }
        else
        {
            wait 0.05;

            if ( level.lastslowprocessframe == gettime() )
            {
                wait 0.05;

                if ( level.lastslowprocessframe == gettime() )
                {
                    wait 0.05;

                    if ( level.lastslowprocessframe == gettime() )
                        wait 0.05;
                }
            }
        }
    }

    level.lastslowprocessframe = gettime();
}

waitfortimeornotify( var_0, var_1 )
{
    self endon( var_1 );
    wait( var_0 );
}

isexcluded( var_0, var_1 )
{
    for ( var_2 = 0; var_2 < var_1.size; var_2++ )
    {
        if ( var_0 == var_1[var_2] )
            return 1;
    }

    return 0;
}

leaderdialog( var_0, var_1, var_2, var_3, var_4 )
{
    var_5 = game["dialog"][var_0];

    if ( !isdefined( var_5 ) )
        return;

    var_6 = game["voice"]["allies"] + var_5;
    var_7 = game["voice"]["axis"] + var_5;
    queuedialog( var_6, var_7, var_0, 2, var_1, var_2, var_3, var_4 );
}

leaderdialogonplayers( var_0, var_1, var_2, var_3 )
{
    foreach ( var_5 in var_1 )
        var_5 leaderdialogonplayer( var_0, var_2, undefined, var_3 );
}

leaderdialogonplayer( var_0, var_1, var_2, var_3 )
{
    if ( !isdefined( game["dialog"][var_0] ) )
        return;

    var_4 = self.pers["team"];

    if ( isdefined( var_4 ) && ( var_4 == "axis" || var_4 == "allies" ) )
    {
        var_5 = game["voice"][var_4] + game["dialog"][var_0];
        self queuedialogforplayer( var_5, var_0, 2, var_1, var_2, var_3 );
    }
}

getnextrelevantdialog()
{
    for ( var_0 = 0; var_0 < self.leaderdialogqueue.size; var_0++ )
    {
        if ( issubstr( self.leaderdialogqueue[var_0], "losing" ) )
        {
            if ( self.team == "allies" )
            {
                if ( issubstr( level.axiscapturing, self.leaderdialogqueue[var_0] ) )
                    return self.leaderdialogqueue[var_0];
                else
                    common_scripts\utility::array_remove( self.leaderdialogqueue, self.leaderdialogqueue[var_0] );
            }
            else if ( issubstr( level.alliescapturing, self.leaderdialogqueue[var_0] ) )
                return self.leaderdialogqueue[var_0];
            else
                common_scripts\utility::array_remove( self.leaderdialogqueue, self.leaderdialogqueue[var_0] );

            continue;
        }

        return level.alliescapturing[self.leaderdialogqueue];
    }
}

orderonqueueddialog()
{
    self endon( "disconnect" );
    var_0 = [];
    var_0 = self.leaderdialogqueue;

    for ( var_1 = 0; var_1 < self.leaderdialogqueue.size; var_1++ )
    {
        if ( issubstr( self.leaderdialogqueue[var_1], "losing" ) )
        {
            for ( var_2 = var_1; var_2 >= 0; var_2-- )
            {
                if ( !issubstr( self.leaderdialogqueue[var_2], "losing" ) && var_2 != 0 )
                    continue;

                if ( var_2 != var_1 )
                {
                    arrayinsertion( var_0, self.leaderdialogqueue[var_1], var_2 );
                    common_scripts\utility::array_remove( var_0, self.leaderdialogqueue[var_1] );
                    break;
                }
            }
        }
    }

    self.leaderdialogqueue = var_0;
}

updatemainmenu()
{
    if ( self.pers["team"] == "spectator" )
        self setclientdvar( "g_scriptMainMenu", game["menu_team"] );
    else
        self setclientdvar( "g_scriptMainMenu", game["menu_class_" + self.pers["team"]] );
}

updateobjectivetext()
{
    if ( self.pers["team"] == "spectator" )
        self setclientdvar( "cg_objectiveText", "" );
    else
    {
        if ( getwatcheddvar( "scorelimit" ) > 0 && !isobjectivebased() )
        {
            if ( isdefined( getobjectivescoretext( self.pers["team"] ) ) )
            {
                if ( level.splitscreen )
                {
                    self setclientdvar( "cg_objectiveText", getobjectivescoretext( self.pers["team"] ) );
                    return;
                }

                self setclientdvar( "cg_objectiveText", getobjectivescoretext( self.pers["team"] ), getwatcheddvar( "scorelimit" ) );
                return;
                return;
            }

            return;
        }

        if ( isdefined( getobjectivetext( self.pers["team"] ) ) )
            self setclientdvar( "cg_objectiveText", getobjectivetext( self.pers["team"] ) );
    }
}

setobjectivetext( var_0, var_1 )
{
    game["strings"]["objective_" + var_0] = var_1;
}

setobjectivescoretext( var_0, var_1 )
{
    game["strings"]["objective_score_" + var_0] = var_1;
}

setobjectivehinttext( var_0, var_1 )
{
    game["strings"]["objective_hint_" + var_0] = var_1;
}

getobjectivetext( var_0 )
{
    return game["strings"]["objective_" + var_0];
}

getobjectivescoretext( var_0 )
{
    return game["strings"]["objective_score_" + var_0];
}

getobjectivehinttext( var_0 )
{
    return game["strings"]["objective_hint_" + var_0];
}

gettimepassed()
{
    if ( !isdefined( level.starttime ) || !isdefined( level.discardtime ) )
        return 0;

    if ( level.timerstopped )
        return level.timerpausetime - level.starttime - level.discardtime;
    else
        return gettime() - level.starttime - level.discardtime;
}

gettimepassedpercentage()
{
    return gettimepassed() / ( gettimelimit() * 60 * 1000 ) * 100;
}

getsecondspassed()
{
    return gettimepassed() / 1000;
}

getminutespassed()
{
    return getsecondspassed() / 60;
}

clearkillcamstate()
{
    self.forcespectatorclient = -1;
    self.killcamentity = -1;
    self.archivetime = 0;
    self.psoffsettime = 0;
    self.spectatekillcam = 0;
}

isinkillcam()
{
    return self.spectatekillcam;
}

isvalidclass( var_0 )
{
    return isdefined( var_0 ) && var_0 != "";
}

getvalueinrange( var_0, var_1, var_2 )
{
    if ( var_0 > var_2 )
        return var_2;
    else if ( var_0 < var_1 )
        return var_1;
    else
        return var_0;
}

waitfortimeornotifies( var_0 )
{
    var_1 = gettime();
    var_2 = ( gettime() - var_1 ) / 1000;

    if ( var_2 < var_0 )
    {
        wait( var_0 - var_2 );
        return var_0;
    }
    else
        return var_2;
}

logxpgains()
{
    if ( !isdefined( self.xpgains ) )
        return;

    var_0 = getarraykeys( self.xpgains );

    for ( var_1 = 0; var_1 < var_0.size; var_1++ )
    {
        var_2 = self.xpgains[var_0[var_1]];

        if ( !var_2 )
            continue;

        self logstring( "xp " + var_0[var_1] + ": " + var_2 );
    }
}

registerroundswitchdvar( var_0, var_1, var_2, var_3 )
{
    registerwatchdvarint( "roundswitch", var_1 );
    var_0 = "scr_" + var_0 + "_roundswitch";
    level.roundswitchdvar = var_0;
    level.roundswitchmin = var_2;
    level.roundswitchmax = var_3;
    level.roundswitch = getdvarint( var_0, var_1 );

    if ( level.roundswitch < var_2 )
        level.roundswitch = var_2;
    else if ( level.roundswitch > var_3 )
        level.roundswitch = var_3;
}

registerroundlimitdvar( var_0, var_1 )
{
    registerwatchdvarint( "roundlimit", var_1 );
}

registernumteamsdvar( var_0, var_1 )
{
    registerwatchdvarint( "numTeams", var_1 );
}

registerwinlimitdvar( var_0, var_1 )
{
    registerwatchdvarint( "winlimit", var_1 );
}

registerscorelimitdvar( var_0, var_1 )
{
    registerwatchdvarint( "scorelimit", var_1 );
}

registertimelimitdvar( var_0, var_1 )
{
    registerwatchdvarfloat( "timelimit", var_1 );
    setdvar( "ui_timelimit", gettimelimit() );
}

registerhalftimedvar( var_0, var_1 )
{
    registerwatchdvarint( "halftime", var_1 );
    setdvar( "ui_halftime", gethalftime() );
}

registernumlivesdvar( var_0, var_1 )
{
    registerwatchdvarint( "numlives", var_1 );
}

setovertimelimitdvar( var_0 )
{
    setdvar( "overtimeTimeLimit", var_0 );
}

get_damageable_player( var_0, var_1 )
{
    var_2 = spawnstruct();
    var_2.isplayer = 1;
    var_2.isadestructable = 0;
    var_2.entity = var_0;
    var_2.damagecenter = var_1;
    return var_2;
}

get_damageable_sentry( var_0, var_1 )
{
    var_2 = spawnstruct();
    var_2.isplayer = 0;
    var_2.isadestructable = 0;
    var_2.issentry = 1;
    var_2.entity = var_0;
    var_2.damagecenter = var_1;
    return var_2;
}

get_damageable_grenade( var_0, var_1 )
{
    var_2 = spawnstruct();
    var_2.isplayer = 0;
    var_2.isadestructable = 0;
    var_2.entity = var_0;
    var_2.damagecenter = var_1;
    return var_2;
}

get_damageable_mine( var_0, var_1 )
{
    var_2 = spawnstruct();
    var_2.isplayer = 0;
    var_2.isadestructable = 0;
    var_2.entity = var_0;
    var_2.damagecenter = var_1;
    return var_2;
}

get_damageable_player_pos( var_0 )
{
    return var_0.origin + ( 0, 0, 32 );
}

getstancecenter()
{
    if ( self getstance() == "crouch" )
        var_0 = self.origin + ( 0, 0, 24 );
    else if ( self getstance() == "prone" )
        var_0 = self.origin + ( 0, 0, 10 );
    else
        var_0 = self.origin + ( 0, 0, 32 );

    return var_0;
}

get_damageable_grenade_pos( var_0 )
{
    return var_0.origin;
}

getdvarvec( var_0 )
{
    var_1 = getdvar( var_0 );

    if ( var_1 == "" )
        return ( 0, 0, 0 );

    var_2 = strtok( var_1, " " );

    if ( var_2.size < 3 )
        return ( 0, 0, 0 );

    setdvar( "tempR", var_2[0] );
    setdvar( "tempG", var_2[1] );
    setdvar( "tempB", var_2[2] );
    return ( getdvarfloat( "tempR" ), getdvarfloat( "tempG" ), getdvarfloat( "tempB" ) );
}

strip_suffix( var_0, var_1 )
{
    if ( var_0.size <= var_1.size )
        return var_0;

    if ( getsubstr( var_0, var_0.size - var_1.size, var_0.size ) == var_1 )
        return getsubstr( var_0, 0, var_0.size - var_1.size );

    return var_0;
}

_takeweaponsexcept( var_0 )
{
    var_1 = self getweaponslistall();

    foreach ( var_3 in var_1 )
    {
        if ( var_3 == var_0 )
            continue;
        else
            self takeweapon( var_3 );
    }
}

savedata()
{
    var_0 = spawnstruct();
    var_0.offhandclass = self getoffhandsecondaryclass();
    var_0.actionslots = self.saved_actionslotdata;
    var_0.currentweapon = self getcurrentweapon();
    var_1 = self getweaponslistall();
    var_0.weapons = [];

    foreach ( var_3 in var_1 )
    {
        if ( weaponinventorytype( var_3 ) == "exclusive" )
            continue;

        if ( weaponinventorytype( var_3 ) == "altmode" )
            continue;

        var_4 = spawnstruct();
        var_4.name = var_3;
        var_4.clipammor = self getweaponammoclip( var_3, "right" );
        var_4.clipammol = self getweaponammoclip( var_3, "left" );
        var_4.stockammo = self getweaponammostock( var_3 );

        if ( isdefined( self.throwinggrenade ) && self.throwinggrenade == var_3 )
            var_4.stockammo--;

        var_0.weapons[var_0.weapons.size] = var_4;
    }

    self.script_savedata = var_0;
}

restoredata()
{
    var_0 = self.script_savedata;
    self setoffhandsecondaryclass( var_0.offhandclass );

    foreach ( var_2 in var_0.weapons )
    {
        _giveweapon( var_2.name, int( tablelookup( "mp/camoTable.csv", 1, self.loadoutprimarycamo, 0 ) ) );
        self setweaponammoclip( var_2.name, var_2.clipammor, "right" );

        if ( issubstr( var_2.name, "akimbo" ) )
            self setweaponammoclip( var_2.name, var_2.clipammol, "left" );

        self setweaponammostock( var_2.name, var_2.stockammo );
    }

    foreach ( var_6, var_5 in var_0.actionslots )
        _setactionslot( var_6, var_5.type, var_5.item );

    if ( self getcurrentweapon() == "none" )
    {
        var_2 = var_0.currentweapon;

        if ( var_2 == "none" )
            var_2 = common_scripts\utility::getlastweapon();

        self setspawnweapon( var_2 );
        self switchtoweapon( var_2 );
    }
}

_setactionslot( var_0, var_1, var_2 )
{
    self.saved_actionslotdata[var_0].type = var_1;
    self.saved_actionslotdata[var_0].item = var_2;
    self setactionslot( var_0, var_1, var_2 );
}

isfloat( var_0 )
{
    if ( int( var_0 ) != var_0 )
        return 1;

    return 0;
}

registerwatchdvarint( var_0, var_1 )
{
    var_2 = "scr_" + level.gametype + "_" + var_0;
    level.watchdvars[var_2] = spawnstruct();
    level.watchdvars[var_2].value = getdvarint( var_2, var_1 );
    level.watchdvars[var_2].type = "int";
    level.watchdvars[var_2].notifystring = "update_" + var_0;
}

registerwatchdvarfloat( var_0, var_1 )
{
    var_2 = "scr_" + level.gametype + "_" + var_0;
    level.watchdvars[var_2] = spawnstruct();
    level.watchdvars[var_2].value = getdvarfloat( var_2, var_1 );
    level.watchdvars[var_2].type = "float";
    level.watchdvars[var_2].notifystring = "update_" + var_0;
}

registerwatchdvar( var_0, var_1 )
{
    var_2 = "scr_" + level.gametype + "_" + var_0;
    level.watchdvars[var_2] = spawnstruct();
    level.watchdvars[var_2].value = getdvar( var_2, var_1 );
    level.watchdvars[var_2].type = "string";
    level.watchdvars[var_2].notifystring = "update_" + var_0;
}

setoverridewatchdvar( var_0, var_1 )
{
    var_0 = "scr_" + level.gametype + "_" + var_0;
    level.overridewatchdvars[var_0] = var_1;
}

getwatcheddvar( var_0 )
{
    var_0 = "scr_" + level.gametype + "_" + var_0;

    if ( isdefined( level.overridewatchdvars ) && isdefined( level.overridewatchdvars[var_0] ) )
        return level.overridewatchdvars[var_0];

    return level.watchdvars[var_0].value;
}

updatewatcheddvars()
{
    while ( game["state"] == "playing" )
    {
        var_0 = getarraykeys( level.watchdvars );

        foreach ( var_2 in var_0 )
        {
            if ( level.watchdvars[var_2].type == "string" )
                var_3 = getproperty( var_2, level.watchdvars[var_2].value );
            else if ( level.watchdvars[var_2].type == "float" )
                var_3 = getfloatproperty( var_2, level.watchdvars[var_2].value );
            else
                var_3 = getintproperty( var_2, level.watchdvars[var_2].value );

            if ( var_3 != level.watchdvars[var_2].value )
            {
                level.watchdvars[var_2].value = var_3;
                level notify( level.watchdvars[var_2].notifystring, var_3 );
            }
        }

        wait 1.0;
    }
}

isroundbased()
{
    if ( !level.teambased )
        return 0;

    if ( getwatcheddvar( "winlimit" ) != 1 && getwatcheddvar( "roundlimit" ) != 1 )
        return 1;

    if ( level.gametype == "sr" || level.gametype == "sd" || level.gametype == "siege" )
        return 1;

    return 0;
}

isfirstround()
{
    if ( !level.teambased )
        return 1;

    if ( getwatcheddvar( "roundlimit" ) > 1 && game["roundsPlayed"] == 0 )
        return 1;

    if ( getwatcheddvar( "winlimit" ) > 1 && game["roundsWon"]["allies"] == 0 && game["roundsWon"]["axis"] == 0 )
        return 1;

    return 0;
}

islastround()
{
    if ( !level.teambased )
        return 1;

    if ( getwatcheddvar( "roundlimit" ) > 1 && game["roundsPlayed"] >= getwatcheddvar( "roundlimit" ) - 1 )
        return 1;

    if ( getwatcheddvar( "winlimit" ) > 1 && game["roundsWon"]["allies"] >= getwatcheddvar( "winlimit" ) - 1 && game["roundsWon"]["axis"] >= getwatcheddvar( "winlimit" ) - 1 )
        return 1;

    return 0;
}

wasonlyround()
{
    if ( !level.teambased )
        return 1;

    if ( isdefined( level.onlyroundoverride ) )
        return 0;

    if ( getwatcheddvar( "winlimit" ) == 1 && hitwinlimit() )
        return 1;

    if ( getwatcheddvar( "roundlimit" ) == 1 )
        return 1;

    return 0;
}

waslastround()
{
    if ( level.forcedend )
        return 1;

    if ( !level.teambased )
        return 1;

    if ( hitroundlimit() || hitwinlimit() )
        return 1;

    return 0;
}

hittimelimit()
{
    if ( getwatcheddvar( "timelimit" ) <= 0 )
        return 0;

    var_0 = maps\mp\gametypes\_gamelogic::gettimeremaining();

    if ( var_0 > 0 )
        return 0;

    return 1;
}

hitroundlimit()
{
    if ( getwatcheddvar( "roundlimit" ) <= 0 )
        return 0;

    return game["roundsPlayed"] >= getwatcheddvar( "roundlimit" );
}

hitscorelimit()
{
    if ( isobjectivebased() )
        return 0;

    if ( getwatcheddvar( "scorelimit" ) <= 0 )
        return 0;

    if ( level.teambased )
    {
        if ( game["teamScores"]["allies"] >= getwatcheddvar( "scorelimit" ) || game["teamScores"]["axis"] >= getwatcheddvar( "scorelimit" ) )
            return 1;
    }
    else
    {
        for ( var_0 = 0; var_0 < level.players.size; var_0++ )
        {
            var_1 = level.players[var_0];

            if ( isdefined( var_1.score ) && var_1.score >= getwatcheddvar( "scorelimit" ) )
                return 1;
        }
    }

    return 0;
}

hitwinlimit()
{
    if ( getwatcheddvar( "winlimit" ) <= 0 )
        return 0;

    if ( !level.teambased )
        return 1;

    if ( getroundswon( "allies" ) >= getwatcheddvar( "winlimit" ) || getroundswon( "axis" ) >= getwatcheddvar( "winlimit" ) )
        return 1;

    return 0;
}

getscorelimit()
{
    if ( isroundbased() )
    {
        if ( getwatcheddvar( "roundlimit" ) )
            return getwatcheddvar( "roundlimit" );
        else
            return getwatcheddvar( "winlimit" );
    }
    else
        return getwatcheddvar( "scorelimit" );
}

getroundswon( var_0 )
{
    return game["roundsWon"][var_0];
}

isobjectivebased()
{
    return level.objectivebased;
}

gettimelimit()
{
    if ( inovertime() && ( !isdefined( game["inNukeOvertime"] ) || !game["inNukeOvertime"] ) )
    {
        var_0 = int( getdvar( "overtimeTimeLimit" ) );

        if ( isdefined( var_0 ) )
        {
            return var_0;
            return;
        }

        return 1;
        return;
    }
    else if ( isdefined( level.dd ) && level.dd && isdefined( level.bombexploded ) && level.bombexploded > 0 )
        return getwatcheddvar( "timelimit" ) + level.bombexploded * level.ddtimetoadd;
    else
        return getwatcheddvar( "timelimit" );
}

gethalftime()
{
    if ( inovertime() )
        return 0;
    else if ( isdefined( game["inNukeOvertime"] ) && game["inNukeOvertime"] )
        return 0;
    else
        return getwatcheddvar( "halftime" );
}

inovertime()
{
    return isdefined( game["status"] ) && game["status"] == "overtime";
}

gamehasstarted()
{
    if ( isdefined( level.gamehasstarted ) )
        return level.gamehasstarted;

    if ( level.teambased )
        return level.hasspawned["axis"] && level.hasspawned["allies"];

    return level.maxplayercount > 1;
}

getaverageorigin( var_0 )
{
    var_1 = ( 0, 0, 0 );

    if ( !var_0.size )
        return undefined;

    foreach ( var_3 in var_0 )
        var_1 = var_1 + var_3.origin;

    var_5 = int( var_1[0] / var_0.size );
    var_6 = int( var_1[1] / var_0.size );
    var_7 = int( var_1[2] / var_0.size );
    var_1 = ( var_5, var_6, var_7 );
    return var_1;
}

getlivingplayers( var_0 )
{
    var_1 = [];

    foreach ( var_3 in level.players )
    {
        if ( !isalive( var_3 ) )
            continue;

        if ( level.teambased && isdefined( var_0 ) )
        {
            if ( var_0 == var_3.pers["team"] )
                var_1[var_1.size] = var_3;

            continue;
        }

        var_1[var_1.size] = var_3;
    }

    return var_1;
}

setusingremote( var_0 )
{
    if ( isdefined( self.carryicon ) )
        self.carryicon.alpha = 0;

    self.usingremote = var_0;
    common_scripts\utility::_disableoffhandweapons();
    self notify( "using_remote" );
}

getremotename()
{
    return self.usingremote;
}

freezecontrolswrapper( var_0 )
{
    if ( isdefined( level.hostmigrationtimer ) )
    {
        self.hostmigrationcontrolsfrozen = 1;
        self freezecontrols( 1 );
        return;
    }

    self freezecontrols( var_0 );
    self.controlsfrozen = var_0;
}

clearusingremote()
{
    if ( isdefined( self.carryicon ) )
        self.carryicon.alpha = 1;

    self.usingremote = undefined;
    common_scripts\utility::_enableoffhandweapons();
    var_0 = self getcurrentweapon();

    if ( var_0 == "none" || iskillstreakweapon( var_0 ) )
    {
        var_1 = common_scripts\utility::getlastweapon();

        if ( isreallyalive( self ) )
        {
            if ( !self hasweapon( var_1 ) )
                var_1 = maps\mp\killstreaks\_killstreaks::getfirstprimaryweapon();

            self switchtoweapon( var_1 );
        }
    }

    freezecontrolswrapper( 0 );
    self notify( "stopped_using_remote" );
}

isusingremote()
{
    return isdefined( self.usingremote );
}

isrocketcorpse()
{
    return isdefined( self.isrocketcorpse ) && self.isrocketcorpse;
}

queuecreate( var_0 )
{
    if ( !isdefined( level.queues ) )
        level.queues = [];

    level.queues[var_0] = [];
}

queueadd( var_0, var_1 )
{
    level.queues[var_0][level.queues[var_0].size] = var_1;
}

queueremovefirst( var_0 )
{
    var_1 = undefined;
    var_2 = [];

    foreach ( var_4 in level.queues[var_0] )
    {
        if ( !isdefined( var_4 ) )
            continue;

        if ( !isdefined( var_1 ) )
        {
            var_1 = var_4;
            continue;
        }

        var_2[var_2.size] = var_4;
    }

    level.queues[var_0] = var_2;
    return var_1;
}

_giveweapon( var_0, var_1, var_2 )
{
    if ( !isdefined( var_1 ) )
        var_1 = -1;

    if ( issubstr( var_0, "_akimbo" ) || isdefined( var_2 ) && var_2 == 1 )
        self giveweapon( var_0, var_1, 1 );
    else
        self giveweapon( var_0, var_1, 0 );
}

perksenabled()
{
    return getdvarint( "scr_game_perks" ) == 1;
}

_hasperk( var_0 )
{
    var_1 = self.perks;

    if ( !isdefined( var_1 ) )
        return 0;

    if ( isdefined( var_1[var_0] ) )
        return 1;

    return 0;
}

giveperk( var_0, var_1 )
{
    if ( issubstr( var_0, "specialty_weapon_" ) )
    {
        _setperk( var_0, var_1 );
        return;
    }

    _setperk( var_0, var_1 );
    _setextraperks( var_0 );
}

giveperkequipment( var_0, var_1 )
{
    if ( var_0 == "none" || var_0 == "specialty_null" )
        self setoffhandprimaryclass( "none" );
    else
    {
        self.primarygrenade = var_0;

        if ( issubstr( var_0, "_mp" ) )
        {
            switch ( var_0 )
            {
                case "mortar_shelljugg_mp":
                case "mortar_shell_mp":
                case "frag_grenade_mp":
                    self setoffhandprimaryclass( "frag" );
                    break;
                case "throwingknifejugg_mp":
                case "throwingknife_mp":
                    self setoffhandprimaryclass( "throwingknife" );
                    break;
                case "thermobaric_grenade_mp":
                case "motion_sensor_mp":
                case "emp_grenade_mp":
                case "flash_grenade_mp":
                case "trophy_mp":
                    self setoffhandprimaryclass( "flash" );
                    break;
                case "concussion_grenade_mp":
                case "smoke_grenadejugg_mp":
                case "smoke_grenade_mp":
                    self setoffhandprimaryclass( "smoke" );
                    break;
                default:
                    self setoffhandprimaryclass( "other" );
                    break;
            }

            _giveweapon( var_0, 0 );
            self givestartammo( var_0 );
            _setperk( var_0, var_1 );
            return;
        }

        _setperk( var_0, var_1 );
    }
}

giveperkoffhand( var_0, var_1 )
{
    if ( var_0 == "none" || var_0 == "specialty_null" )
        self setoffhandsecondaryclass( "none" );
    else
    {
        self.secondarygrenade = var_0;

        if ( issubstr( var_0, "_mp" ) )
        {
            switch ( var_0 )
            {
                case "mortar_shelljugg_mp":
                case "mortar_shell_mp":
                case "frag_grenade_mp":
                    self setoffhandsecondaryclass( "frag" );
                    break;
                case "throwingknifejugg_mp":
                case "throwingknife_mp":
                    self setoffhandsecondaryclass( "throwingknife" );
                    break;
                case "thermobaric_grenade_mp":
                case "motion_sensor_mp":
                case "emp_grenade_mp":
                case "flash_grenade_mp":
                case "trophy_mp":
                    self setoffhandsecondaryclass( "flash" );
                    break;
                case "concussion_grenade_mp":
                case "smoke_grenadejugg_mp":
                case "smoke_grenade_mp":
                    self setoffhandsecondaryclass( "smoke" );
                    break;
                default:
                    self setoffhandsecondaryclass( "other" );
                    break;
            }

            _giveweapon( var_0, 0 );

            switch ( var_0 )
            {
                case "concussion_grenade_mp":
                case "smoke_grenade_mp":
                case "thermobaric_grenade_mp":
                case "motion_sensor_mp":
                case "emp_grenade_mp":
                case "flash_grenade_mp":
                case "trophy_mp":
                    self setweaponammoclip( var_0, 1 );
                    break;
                default:
                    self givestartammo( var_0 );
                    break;
            }

            _setperk( var_0, var_1 );
            return;
        }

        _setperk( var_0, var_1 );
    }
}

_setperk( var_0, var_1 )
{
    self.perks[var_0] = 1;
    self.perksperkname[var_0] = var_0;
    self.perksuseslot[var_0] = var_1;
    var_2 = level.perksetfuncs[var_0];

    if ( isdefined( var_2 ) )
        self thread [[ var_2 ]]();

    self setperk( var_0, !isdefined( level.scriptperks[var_0] ), var_1 );
}

_setextraperks( var_0 )
{
    if ( var_0 == "specialty_stun_resistance" )
        giveperk( "specialty_empimmune", 0 );

    if ( var_0 == "specialty_hardline" )
        giveperk( "specialty_assists", 0 );

    if ( var_0 == "specialty_incog" )
    {
        giveperk( "specialty_spygame", 0 );
        giveperk( "specialty_coldblooded", 0 );
        giveperk( "specialty_noscopeoutline", 0 );
        giveperk( "specialty_heartbreaker", 0 );
    }

    if ( var_0 == "specialty_blindeye" )
        giveperk( "specialty_noplayertarget", 0 );

    if ( var_0 == "specialty_sharp_focus" )
        giveperk( "specialty_reducedsway", 0 );

    if ( var_0 == "specialty_quickswap" )
        giveperk( "specialty_fastoffhand", 0 );
}

_unsetperk( var_0 )
{
    self.perks[var_0] = undefined;
    self.perksperkname[var_0] = undefined;
    self.perksuseslot[var_0] = undefined;

    if ( isdefined( level.perkunsetfuncs[var_0] ) )
        self thread [[ level.perkunsetfuncs[var_0] ]]();

    self unsetperk( var_0, !isdefined( level.scriptperks[var_0] ) );
}

_unsetextraperks( var_0 )
{
    if ( var_0 == "specialty_bulletaccuracy" )
        _unsetperk( "specialty_steadyaimpro" );

    if ( var_0 == "specialty_coldblooded" )
        _unsetperk( "specialty_heartbreaker" );

    if ( var_0 == "specialty_fasterlockon" )
        _unsetperk( "specialty_armorpiercing" );

    if ( var_0 == "specialty_heartbreaker" )
        _unsetperk( "specialty_empimmune" );

    if ( var_0 == "specialty_rollover" )
        _unsetperk( "specialty_assists" );
}

_clearperks()
{
    foreach ( var_2, var_1 in self.perks )
    {
        if ( isdefined( level.perkunsetfuncs[var_2] ) )
            self [[ level.perkunsetfuncs[var_2] ]]();
    }

    self.perks = [];
    self.perksperkname = [];
    self.perksuseslot = [];
    self clearperks();
}

quicksort( var_0 )
{
    return quicksortmid( var_0, 0, var_0.size - 1 );
}

quicksortmid( var_0, var_1, var_2 )
{
    var_3 = var_1;
    var_4 = var_2;

    if ( var_2 - var_1 >= 1 )
    {
        var_5 = var_0[var_1];

        while ( var_4 > var_3 )
        {
            while ( var_0[var_3] <= var_5 && var_3 <= var_2 && var_4 > var_3 )
                var_3++;

            while ( var_0[var_4] > var_5 && var_4 >= var_1 && var_4 >= var_3 )
                var_4--;

            if ( var_4 > var_3 )
                var_0 = swap( var_0, var_3, var_4 );
        }

        var_0 = swap( var_0, var_1, var_4 );
        var_0 = quicksortmid( var_0, var_1, var_4 - 1 );
        var_0 = quicksortmid( var_0, var_4 + 1, var_2 );
    }
    else
        return var_0;

    return var_0;
}

swap( var_0, var_1, var_2 )
{
    var_3 = var_0[var_1];
    var_0[var_1] = var_0[var_2];
    var_0[var_2] = var_3;
    return var_0;
}

_suicide()
{
    if ( isusingremote() && !isdefined( self.fauxdead ) )
        thread maps\mp\gametypes\_damage::playerkilled_internal( self, self, self, 10000, "MOD_SUICIDE", "frag_grenade_mp", ( 0, 0, 0 ), "none", 0, 1116, 1 );
    else if ( !isusingremote() && !isdefined( self.fauxdead ) )
        self suicide();
}

isreallyalive( var_0 )
{
    if ( isalive( var_0 ) && !isdefined( var_0.fauxdead ) )
        return 1;

    return 0;
}

waittill_any_timeout_pause_on_death_and_prematch( var_0, var_1, var_2, var_3, var_4, var_5 )
{
    var_6 = spawnstruct();

    if ( isdefined( var_1 ) )
        thread common_scripts\utility::waittill_string_no_endon_death( var_1, var_6 );

    if ( isdefined( var_2 ) )
        thread common_scripts\utility::waittill_string_no_endon_death( var_2, var_6 );

    if ( isdefined( var_3 ) )
        thread common_scripts\utility::waittill_string_no_endon_death( var_3, var_6 );

    if ( isdefined( var_4 ) )
        thread common_scripts\utility::waittill_string_no_endon_death( var_4, var_6 );

    if ( isdefined( var_5 ) )
        thread common_scripts\utility::waittill_string_no_endon_death( var_5, var_6 );

    var_6 thread _timeout_pause_on_death_and_prematch( var_0, self );
    var_6 waittill( "returned", var_7 );
    var_6 notify( "die" );
    return var_7;
}

_timeout_pause_on_death_and_prematch( var_0, var_1 )
{
    self endon( "die" );

    for ( var_2 = 0.05; var_0 > 0; var_0 = var_0 - var_2 )
    {
        if ( isplayer( var_1 ) && !isreallyalive( var_1 ) )
            var_1 waittill( "spawned_player" );

        if ( getomnvar( "ui_prematch_period" ) )
            level waittill( "prematch_over" );

        wait( var_2 );
    }

    self notify( "returned", "timeout" );
}

playdeathsound()
{
    var_0 = randomintrange( 1, 8 );
    var_1 = "generic";

    if ( self hasfemalecustomizationmodel() )
        var_1 = "female";

    if ( self.team == "axis" )
        self playsound( var_1 + "_death_russian_" + var_0 );
    else
        self playsound( var_1 + "_death_american_" + var_0 );
}

rankingenabled()
{
    if ( !isplayer( self ) )
        return 0;

    return level.rankedmatch && !self.usingonlinedataoffline;
}

privatematch()
{
    return level.onlinegame && getdvarint( "xblive_privatematch" );
}

matchmakinggame()
{
    return level.onlinegame && !getdvarint( "xblive_privatematch" );
}

setaltsceneobj( var_0, var_1, var_2, var_3 )
{

}

endsceneondeath( var_0 )
{
    self endon( "altscene" );
    var_0 waittill( "death" );
    self notify( "end_altScene" );
}

getgametypenumlives()
{
    return getwatcheddvar( "numlives" );
}

givecombathigh( var_0 )
{
    self.combathigh = var_0;
}

arrayinsertion( var_0, var_1, var_2 )
{
    if ( var_0.size != 0 )
    {
        for ( var_3 = var_0.size; var_3 >= var_2; var_3-- )
            var_0[var_3 + 1] = var_0[var_3];
    }

    var_0[var_2] = var_1;
}

getproperty( var_0, var_1 )
{
    var_2 = var_1;
    var_2 = getdvar( var_0, var_1 );
    return var_2;
}

getintproperty( var_0, var_1 )
{
    var_2 = var_1;
    var_2 = getdvarint( var_0, var_1 );
    return var_2;
}

getfloatproperty( var_0, var_1 )
{
    var_2 = var_1;
    var_2 = getdvarfloat( var_0, var_1 );
    return var_2;
}

ischangingweapon()
{
    return isdefined( self.changingweapon );
}

killshouldaddtokillstreak( var_0 )
{
    if ( var_0 == "venomxgun_mp" || var_0 == "venomxproj_mp" )
        return 1;

    if ( _hasperk( "specialty_explosivebullets" ) )
        return 0;

    if ( isdefined( self.isjuggernautrecon ) && self.isjuggernautrecon == 1 )
        return 0;

    var_1 = self.pers["killstreaks"];

    if ( isdefined( level.killstreakweildweapons[var_0] ) && isdefined( self.streaktype ) && self.streaktype != "support" )
    {
        for ( var_2 = 1; var_2 < 4; var_2++ )
        {
            if ( isdefined( var_1[var_2] ) && isdefined( var_1[var_2].streakname ) && var_1[var_2].streakname == level.killstreakweildweapons[var_0] && isdefined( var_1[var_2].lifeid ) && var_1[var_2].lifeid == self.pers["deaths"] )
                return streakshouldchain( level.killstreakweildweapons[var_0] );
        }

        return 0;
    }

    return !iskillstreakweapon( var_0 );
}

streakshouldchain( var_0 )
{
    var_1 = maps\mp\killstreaks\_killstreaks::getstreakcost( var_0 );
    var_2 = maps\mp\killstreaks\_killstreaks::getnextstreakname();
    var_3 = maps\mp\killstreaks\_killstreaks::getstreakcost( var_2 );
    return var_1 < var_3;
}

isjuggernaut()
{
    if ( isdefined( self.isjuggernaut ) && self.isjuggernaut == 1 )
        return 1;

    if ( isdefined( self.isjuggernautdef ) && self.isjuggernautdef == 1 )
        return 1;

    if ( isdefined( self.isjuggernautgl ) && self.isjuggernautgl == 1 )
        return 1;

    if ( isdefined( self.isjuggernautrecon ) && self.isjuggernautrecon == 1 )
        return 1;

    if ( isdefined( self.isjuggernautmaniac ) && self.isjuggernautmaniac == 1 )
        return 1;

    if ( isdefined( self.isjuggernautlevelcustom ) && self.isjuggernautlevelcustom == 1 )
        return 1;

    return 0;
}

iskillstreakweapon( var_0 )
{
    if ( !isdefined( var_0 ) )
        return 0;

    if ( var_0 == "none" )
        return 0;

    if ( isdestructibleweapon( var_0 ) )
        return 0;

    if ( isbombsiteweapon( var_0 ) )
        return 0;

    if ( issubstr( var_0, "killstreak" ) )
        return 1;

    if ( issubstr( var_0, "cobra" ) )
        return 1;

    if ( issubstr( var_0, "remote_tank_projectile" ) )
        return 1;

    if ( issubstr( var_0, "artillery_mp" ) )
        return 1;

    if ( issubstr( var_0, "harrier" ) )
        return 1;

    var_1 = strtok( var_0, "_" );
    var_2 = 0;

    foreach ( var_4 in var_1 )
    {
        if ( var_4 == "mp" )
        {
            var_2 = 1;
            break;
        }
    }

    if ( !var_2 )
        var_0 = var_0 + "_mp";

    if ( isdefined( level.killstreakweildweapons[var_0] ) )
        return 1;

    if ( maps\mp\killstreaks\_killstreaks::isairdropmarker( var_0 ) )
        return 1;

    var_6 = weaponinventorytype( var_0 );

    if ( isdefined( var_6 ) && var_6 == "exclusive" )
        return 1;

    return 0;
}

isdestructibleweapon( var_0 )
{
    if ( !isdefined( var_0 ) )
        return 0;

    switch ( var_0 )
    {
        case "barrel_mp":
        case "destructible":
        case "destructible_car":
        case "destructible_toy":
            return 1;
    }

    return 0;
}

isbombsiteweapon( var_0 )
{
    if ( !isdefined( var_0 ) )
        return 0;

    switch ( var_0 )
    {
        case "bomb_site_mp":
        case "briefcase_bomb_mp":
            return 1;
    }

    return 0;
}

isenvironmentweapon( var_0 )
{
    if ( !isdefined( var_0 ) )
        return 0;

    if ( var_0 == "turret_minigun_mp" )
        return 1;

    if ( issubstr( var_0, "_bipod_" ) )
        return 1;

    return 0;
}

isjuggernautweapon( var_0 )
{
    if ( !isdefined( var_0 ) )
        return 0;

    switch ( var_0 )
    {
        case "iw6_mariachimagnum_mp_akimbo":
        case "iw6_predatorcannon_mp":
        case "iw6_axe_mp":
        case "iw6_riotshieldjugg_mp":
        case "iw6_knifeonlyjugg_mp":
        case "iw6_p226jugg_mp":
        case "iw6_magnumjugg_mp":
        case "iw6_minigunjugg_mp":
        case "smoke_grenadejugg_mp":
        case "throwingknifejugg_mp":
        case "mortar_shelljugg_mp":
            return 1;
    }

    return 0;
}

getweaponclass( var_0 )
{
    var_1 = getbaseweaponname( var_0 );

    if ( is_aliens() )
        var_2 = tablelookup( "mp/alien/mode_string_tables/alien_statstable.csv", 4, var_1, 2 );
    else
        var_2 = tablelookup( "mp/statstable.csv", 4, var_1, 2 );

    if ( var_2 == "" )
    {
        var_3 = strip_suffix( var_0, "_mp" );

        if ( is_aliens() )
            var_2 = tablelookup( "mp/alien/mode_string_tables/alien_statstable.csv", 4, var_3, 2 );
        else
            var_2 = tablelookup( "mp/statstable.csv", 4, var_3, 2 );
    }

    if ( isenvironmentweapon( var_0 ) )
        var_2 = "weapon_mg";
    else if ( !is_aliens() && iskillstreakweapon( var_0 ) )
        var_2 = "killstreak";
    else if ( var_0 == "none" )
        var_2 = "other";
    else if ( var_2 == "" )
        var_2 = "other";

    return var_2;
}

getweaponattachmentarrayfromstats( var_0 )
{
    var_0 = getbaseweaponname( var_0 );

    if ( !isdefined( level.weaponattachments[var_0] ) )
    {
        var_1 = [];

        for ( var_2 = 0; var_2 <= 19; var_2++ )
        {
            var_3 = tablelookup( "mp/statsTable.csv", 4, var_0, 10 + var_2 );

            if ( var_3 == "" )
                break;

            var_1[var_1.size] = var_3;
        }

        level.weaponattachments[var_0] = var_1;
    }

    return level.weaponattachments[var_0];
}

getweaponattachmentfromstats( var_0, var_1 )
{
    var_0 = getbaseweaponname( var_0 );
    return tablelookup( "mp/statsTable.csv", 4, var_0, 10 + var_1 );
}

attachmentscompatible( var_0, var_1 )
{
    var_0 = attachmentmap_tobase( var_0 );
    var_1 = attachmentmap_tobase( var_1 );
    var_2 = 1;

    if ( var_0 == var_1 )
        var_2 = 0;
    else if ( var_0 != "none" && var_1 != "none" )
    {
        var_3 = tablelookuprownum( "mp/attachmentcombos.csv", 0, var_1 );

        if ( tablelookup( "mp/attachmentcombos.csv", 0, var_0, var_3 ) == "no" )
            var_2 = 0;
    }

    return var_2;
}

getbaseweaponname( var_0 )
{
    var_1 = strtok( var_0, "_" );

    if ( var_1[0] == "iw5" || var_1[0] == "iw6" )
        var_0 = var_1[0] + "_" + var_1[1];
    else if ( var_1[0] == "alt" )
        var_0 = var_1[1] + "_" + var_1[2];

    return var_0;
}

getbaseperkname( var_0 )
{
    if ( isendstr( var_0, "_ks" ) )
        var_0 = getsubstr( var_0, 0, var_0.size - 3 );

    return var_0;
}

getvalidextraammoweapons()
{
    var_0 = [];
    var_1 = self getweaponslistprimaries();

    foreach ( var_3 in var_1 )
    {
        var_4 = weaponclass( var_3 );

        if ( !iskillstreakweapon( var_3 ) && var_4 != "grenade" && var_4 != "rocketlauncher" )
            var_0[var_0.size] = var_3;
    }

    return var_0;
}

riotshield_hasweapon()
{
    var_0 = 0;
    var_1 = self getweaponslistprimaries();

    foreach ( var_3 in var_1 )
    {
        if ( maps\mp\gametypes\_weapons::isriotshield( var_3 ) )
        {
            var_0 = 1;
            break;
        }
    }

    return var_0;
}

riotshield_hastwo()
{
    var_0 = 0;
    var_1 = self getweaponslistprimaries();

    foreach ( var_3 in var_1 )
    {
        if ( maps\mp\gametypes\_weapons::isriotshield( var_3 ) )
            var_0++;

        if ( var_0 == 2 )
            break;
    }

    return var_0 == 2;
}

riotshield_attach( var_0, var_1 )
{
    var_2 = undefined;

    if ( var_0 )
    {
        self.riotshieldmodel = var_1;
        var_2 = "tag_weapon_right";
    }
    else
    {
        self.riotshieldmodelstowed = var_1;
        var_2 = "tag_shield_back";
    }

    self attachshieldmodel( var_1, var_2 );
    self.hasriotshield = riotshield_hasweapon();
}

riotshield_detach( var_0 )
{
    var_1 = undefined;
    var_2 = undefined;

    if ( var_0 )
    {
        var_1 = self.riotshieldmodel;
        var_2 = "tag_weapon_right";
    }
    else
    {
        var_1 = self.riotshieldmodelstowed;
        var_2 = "tag_shield_back";
    }

    self detachshieldmodel( var_1, var_2 );

    if ( var_0 )
        self.riotshieldmodel = undefined;
    else
        self.riotshieldmodelstowed = undefined;

    self.hasriotshield = riotshield_hasweapon();
}

riotshield_move( var_0 )
{
    var_1 = undefined;
    var_2 = undefined;
    var_3 = undefined;

    if ( var_0 )
    {
        var_3 = self.riotshieldmodel;
        var_1 = "tag_weapon_right";
        var_2 = "tag_shield_back";
    }
    else
    {
        var_3 = self.riotshieldmodelstowed;
        var_1 = "tag_shield_back";
        var_2 = "tag_weapon_right";
    }

    self moveshieldmodel( var_3, var_1, var_2 );

    if ( var_0 )
    {
        self.riotshieldmodelstowed = var_3;
        self.riotshieldmodel = undefined;
    }
    else
    {
        self.riotshieldmodel = var_3;
        self.riotshieldmodelstowed = undefined;
    }
}

riotshield_clear()
{
    self.hasriotshieldequipped = 0;
    self.hasriotshield = 0;
    self.riotshieldmodelstowed = undefined;
    self.riotshieldmodel = undefined;
}

riotshield_getmodel()
{
    return common_scripts\utility::ter_op( isjuggernaut(), "weapon_riot_shield_jug_iw6", "weapon_riot_shield_iw6" );
}

outlineenableforall( var_0, var_1, var_2, var_3 )
{
    var_4 = level.players;
    var_5 = maps\mp\gametypes\_outline::outlinecolorindexmap( var_1 );
    var_6 = maps\mp\gametypes\_outline::outlineprioritygroupmap( var_3 );
    return maps\mp\gametypes\_outline::outlineenableinternal( var_0, var_5, var_4, var_2, var_6, "ALL" );
}

outlineenableforteam( var_0, var_1, var_2, var_3, var_4 )
{
    var_5 = getteamarray( var_2, 0 );
    var_6 = maps\mp\gametypes\_outline::outlinecolorindexmap( var_1 );
    var_7 = maps\mp\gametypes\_outline::outlineprioritygroupmap( var_4 );
    return maps\mp\gametypes\_outline::outlineenableinternal( var_0, var_6, var_5, var_3, var_7, "TEAM", var_2 );
}

outlineenableforplayer( var_0, var_1, var_2, var_3, var_4 )
{
    var_5 = maps\mp\gametypes\_outline::outlinecolorindexmap( var_1 );
    var_6 = maps\mp\gametypes\_outline::outlineprioritygroupmap( var_4 );

    if ( isagent( var_2 ) )
        return maps\mp\gametypes\_outline::outlinegenerateuniqueid();

    return maps\mp\gametypes\_outline::outlineenableinternal( var_0, var_5, [ var_2 ], var_3, var_6, "ENTITY" );
}

outlinedisable( var_0, var_1 )
{
    maps\mp\gametypes\_outline::outlinedisableinternal( var_0, var_1 );
}

playsoundinspace( var_0, var_1 )
{
    playsoundatpos( var_1, var_0 );
}

limitdecimalplaces( var_0, var_1 )
{
    var_2 = 1;

    for ( var_3 = 0; var_3 < var_1; var_3++ )
        var_2 = var_2 * 10;

    var_4 = var_0 * var_2;
    var_4 = int( var_4 );
    var_4 = var_4 / var_2;
    return var_4;
}

rounddecimalplaces( var_0, var_1, var_2 )
{
    if ( !isdefined( var_2 ) )
        var_2 = "nearest";

    var_3 = 1;

    for ( var_4 = 0; var_4 < var_1; var_4++ )
        var_3 = var_3 * 10;

    var_5 = var_0 * var_3;

    if ( var_2 == "up" )
        var_6 = ceil( var_5 );
    else if ( var_2 == "down" )
        var_6 = floor( var_5 );
    else
        var_6 = var_5 + 0.5;

    var_5 = int( var_6 );
    var_5 = var_5 / var_3;
    return var_5;
}

playerforclientid( var_0 )
{
    foreach ( var_2 in level.players )
    {
        if ( var_2.clientid == var_0 )
            return var_2;
    }

    return undefined;
}

isrested()
{
    if ( !rankingenabled() )
        return 0;

    return self getrankedplayerdata( "restXPGoal" ) > self getrankedplayerdata( "experience" );
}

stringtofloat( var_0 )
{
    var_1 = strtok( var_0, "." );
    var_2 = int( var_1[0] );

    if ( isdefined( var_1[1] ) )
    {
        var_3 = 1;

        for ( var_4 = 0; var_4 < var_1[1].size; var_4++ )
            var_3 = var_3 * 0.1;

        var_2 = var_2 + int( var_1[1] ) * var_3;
    }

    return var_2;
}

setselfusable( var_0 )
{
    self makeusable();

    foreach ( var_2 in level.players )
    {
        if ( var_2 != var_0 )
        {
            self disableplayeruse( var_2 );
            continue;
        }

        self enableplayeruse( var_2 );
    }
}

maketeamusable( var_0 )
{
    self makeusable();
    thread _updateteamusable( var_0 );
}

_updateteamusable( var_0 )
{
    self endon( "death" );

    for (;;)
    {
        foreach ( var_2 in level.players )
        {
            if ( var_2.team == var_0 )
            {
                self enableplayeruse( var_2 );
                continue;
            }

            self disableplayeruse( var_2 );
        }

        level waittill( "joined_team" );
    }
}

makeenemyusable( var_0 )
{
    self makeusable();
    thread _updateenemyusable( var_0 );
}

_updateenemyusable( var_0 )
{
    self endon( "death" );
    var_1 = var_0.team;

    for (;;)
    {
        if ( level.teambased )
        {
            foreach ( var_3 in level.players )
            {
                if ( var_3.team != var_1 )
                {
                    self enableplayeruse( var_3 );
                    continue;
                }

                self disableplayeruse( var_3 );
            }
        }
        else
        {
            foreach ( var_3 in level.players )
            {
                if ( var_3 != var_0 )
                {
                    self enableplayeruse( var_3 );
                    continue;
                }

                self disableplayeruse( var_3 );
            }
        }

        level waittill( "joined_team" );
    }
}

initgameflags()
{
    if ( !isdefined( game["flags"] ) )
        game["flags"] = [];
}

gameflaginit( var_0, var_1 )
{
    game["flags"][var_0] = var_1;
}

gameflag( var_0 )
{
    return game["flags"][var_0];
}

gameflagset( var_0 )
{
    game["flags"][var_0] = 1;
    level notify( var_0 );
}

gameflagclear( var_0 )
{
    game["flags"][var_0] = 0;
}

gameflagwait( var_0 )
{
    while ( !gameflag( var_0 ) )
        level waittill( var_0 );
}

isprimarydamage( var_0 )
{
    if ( var_0 == "MOD_RIFLE_BULLET" || var_0 == "MOD_PISTOL_BULLET" )
        return 1;

    return 0;
}

isbulletdamage( var_0 )
{
    var_1 = "MOD_RIFLE_BULLET MOD_PISTOL_BULLET MOD_HEAD_SHOT";

    if ( issubstr( var_1, var_0 ) )
        return 1;

    return 0;
}

isfmjdamage( var_0, var_1, var_2 )
{
    return isdefined( var_2 ) && var_2 _hasperk( "specialty_bulletpenetration" ) && isdefined( var_1 ) && isbulletdamage( var_1 );
}

initlevelflags()
{
    if ( !isdefined( level.levelflags ) )
        level.levelflags = [];
}

levelflaginit( var_0, var_1 )
{
    level.levelflags[var_0] = var_1;
}

levelflag( var_0 )
{
    return level.levelflags[var_0];
}

levelflagset( var_0 )
{
    level.levelflags[var_0] = 1;
    level notify( var_0 );
}

levelflagclear( var_0 )
{
    level.levelflags[var_0] = 0;
    level notify( var_0 );
}

levelflagwait( var_0 )
{
    while ( !levelflag( var_0 ) )
        level waittill( var_0 );
}

levelflagwaitopen( var_0 )
{
    while ( levelflag( var_0 ) )
        level waittill( var_0 );
}

initglobals()
{
    if ( !isdefined( level.global_tables ) )
    {
        level.global_tables["killstreakTable"] = spawnstruct();
        level.global_tables["killstreakTable"].path = "mp/killstreakTable.csv";
        level.global_tables["killstreakTable"].index_col = 0;
        level.global_tables["killstreakTable"].ref_col = 1;
        level.global_tables["killstreakTable"].name_col = 2;
        level.global_tables["killstreakTable"].desc_col = 3;
        level.global_tables["killstreakTable"].kills_col = 4;
        level.global_tables["killstreakTable"].earned_hint_col = 5;
        level.global_tables["killstreakTable"].sound_col = 6;
        level.global_tables["killstreakTable"].earned_dialog_col = 7;
        level.global_tables["killstreakTable"].allies_dialog_col = 8;
        level.global_tables["killstreakTable"].enemy_dialog_col = 9;
        level.global_tables["killstreakTable"].enemy_use_dialog_col = 10;
        level.global_tables["killstreakTable"].weapon_col = 11;
        level.global_tables["killstreakTable"].score_col = 12;
        level.global_tables["killstreakTable"].icon_col = 13;
        level.global_tables["killstreakTable"].overhead_icon_col = 14;
        level.global_tables["killstreakTable"].dpad_icon_col = 15;
        level.global_tables["killstreakTable"].unearned_icon_col = 16;
        level.global_tables["killstreakTable"].all_team_steak_col = 17;
    }
}

iskillstreakdenied()
{
    return isemped() || isairdenied();
}

isemped()
{
    if ( self.team == "spectator" )
        return 0;

    if ( level.teambased )
        return level.teamemped[self.team] || isdefined( self.empgrenaded ) && self.empgrenaded || level.teamnukeemped[self.team];
    else
        return isdefined( level.empplayer ) && level.empplayer != self || isdefined( self.empgrenaded ) && self.empgrenaded || isdefined( level.nukeinfo.player ) && self != level.nukeinfo.player && level.teamnukeemped[self.team];
}

isairdenied()
{
    if ( self.team == "spectator" )
        return 0;

    if ( level.teambased )
        return level.teamairdenied[self.team];
    else
        return isdefined( level.airdeniedplayer ) && level.airdeniedplayer != self;
}

isnuked()
{
    if ( self.team == "spectator" )
        return 0;

    return isdefined( self.nuked );
}

getplayerforguid( var_0 )
{
    foreach ( var_2 in level.players )
    {
        if ( var_2.guid == var_0 )
            return var_2;
    }

    return undefined;
}

teamplayercardsplash( var_0, var_1, var_2, var_3 )
{
    if ( level.hardcoremode && !is_aliens() )
        return;

    foreach ( var_5 in level.players )
    {
        if ( isdefined( var_2 ) && var_5.team != var_2 )
            continue;

        if ( !isplayer( var_5 ) )
            continue;

        var_5 thread maps\mp\gametypes\_hud_message::playercardsplashnotify( var_0, var_1, var_3 );
    }
}

iscacprimaryweapon( var_0 )
{
    switch ( getweaponclass( var_0 ) )
    {
        case "weapon_shotgun":
        case "weapon_lmg":
        case "weapon_dmr":
        case "weapon_sniper":
        case "weapon_riot":
        case "weapon_assault":
        case "weapon_smg":
            return 1;
        default:
            return 0;
    }
}

iscacsecondaryweapon( var_0 )
{
    switch ( getweaponclass( var_0 ) )
    {
        case "weapon_machine_pistol":
        case "weapon_pistol":
        case "weapon_projectile":
            return 1;
        default:
            return 0;
    }
}

getlastlivingplayer( var_0 )
{
    var_1 = undefined;

    foreach ( var_3 in level.players )
    {
        if ( isdefined( var_0 ) && var_3.team != var_0 )
            continue;

        if ( !isreallyalive( var_3 ) && !var_3 maps\mp\gametypes\_playerlogic::mayspawn() )
            continue;

        if ( isdefined( var_3.switching_teams ) && var_3.switching_teams )
            continue;

        var_1 = var_3;
    }

    return var_1;
}

getpotentiallivingplayers()
{
    var_0 = [];

    foreach ( var_2 in level.players )
    {
        if ( !isreallyalive( var_2 ) && !var_2 maps\mp\gametypes\_playerlogic::mayspawn() )
            continue;

        var_0[var_0.size] = var_2;
    }

    return var_0;
}

waittillrecoveredhealth( var_0, var_1 )
{
    self endon( "death" );
    self endon( "disconnect" );
    var_2 = 0;

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

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

    for (;;)
    {
        if ( self.health != self.maxhealth )
            var_2 = 0;
        else
            var_2 = var_2 + var_1;

        wait( var_1 );

        if ( self.health == self.maxhealth && var_2 >= var_0 )
            break;
    }

    return;
}

enableweaponlaser()
{
    if ( !isdefined( self.weaponlasercalls ) )
        self.weaponlasercalls = 0;

    self.weaponlasercalls++;
    self laseron();
}

disableweaponlaser()
{
    self.weaponlasercalls--;

    if ( self.weaponlasercalls == 0 )
    {
        self laseroff();
        self.weaponlasercalls = undefined;
    }
}

attachmentmap_tounique( var_0, var_1 )
{
    var_2 = var_0;
    var_1 = getbaseweaponname( var_1 );

    if ( isdefined( level.attachmentmap_basetounique[var_1] ) && isdefined( level.attachmentmap_basetounique[var_1][var_0] ) )
        var_2 = level.attachmentmap_basetounique[var_1][var_0];
    else
    {
        if ( is_aliens() )
            var_3 = tablelookup( "mp/alien/mode_string_tables/alien_statstable.csv", 4, var_1, 2 );
        else
            var_3 = tablelookup( "mp/statstable.csv", 4, var_1, 2 );

        if ( isdefined( level.attachmentmap_basetounique[var_3] ) && isdefined( level.attachmentmap_basetounique[var_3][var_0] ) )
            var_2 = level.attachmentmap_basetounique[var_3][var_0];
    }

    return var_2;
}

attachmentperkmap( var_0 )
{
    var_1 = undefined;

    if ( isdefined( level.attachmentmap_attachtoperk[var_0] ) )
        var_1 = level.attachmentmap_attachtoperk[var_0];

    return var_1;
}

weaponperkmap( var_0 )
{
    var_1 = undefined;

    if ( isdefined( level.weaponmap_toperk[var_0] ) )
        var_1 = level.weaponmap_toperk[var_0];

    return var_1;
}

isattachmentsniperscopedefault( var_0, var_1 )
{
    var_2 = strtok( var_0, "_" );
    return isattachmentsniperscopedefaulttokenized( var_2, var_1 );
}

isattachmentsniperscopedefaulttokenized( var_0, var_1 )
{
    var_2 = 0;

    if ( var_0.size && isdefined( var_1 ) )
    {
        var_3 = 0;

        if ( var_0[0] == "alt" )
            var_3 = 1;

        if ( var_0.size >= 3 + var_3 && ( var_0[var_3] == "iw5" || var_0[var_3] == "iw6" ) )
        {
            if ( weaponclass( var_0[var_3] + "_" + var_0[var_3 + 1] + "_" + var_0[var_3 + 2] ) == "sniper" )
                var_2 = var_0[var_3 + 1] + "scope" == var_1;
        }
    }

    return var_2;
}

getnumdefaultattachments( var_0 )
{
    if ( weaponclass( var_0 ) == "sniper" )
    {
        var_1 = getweaponattachments( var_0 );

        foreach ( var_3 in var_1 )
        {
            if ( isattachmentsniperscopedefault( var_0, var_3 ) )
                return 1;
        }
    }
    else if ( isstrstart( var_0, "iw6_dlcweap02" ) )
    {
        var_1 = getweaponattachments( var_0 );

        foreach ( var_3 in var_1 )
        {
            if ( var_3 == "dlcweap02scope" )
                return 1;
        }
    }

    return 0;
}

getweaponattachmentsbasenames( var_0 )
{
    var_1 = getweaponattachments( var_0 );

    foreach ( var_4, var_3 in var_1 )
        var_1[var_4] = attachmentmap_tobase( var_3 );

    return var_1;
}

getattachmentlistbasenames()
{
    var_0 = [];
    var_1 = 0;

    if ( is_aliens() )
        var_2 = tablelookup( "mp/alien/alien_attachmentTable.csv", 0, var_1, 5 );
    else
        var_2 = tablelookup( "mp/attachmentTable.csv", 0, var_1, 5 );

    while ( var_2 != "" )
    {
        if ( !common_scripts\utility::array_contains( var_0, var_2 ) )
            var_0[var_0.size] = var_2;

        var_1++;

        if ( is_aliens() )
        {
            var_2 = tablelookup( "mp/alien/alien_attachmentTable.csv", 0, var_1, 5 );
            continue;
        }

        var_2 = tablelookup( "mp/attachmentTable.csv", 0, var_1, 5 );
    }

    return var_0;
}

getattachmentlistuniqenames()
{
    var_0 = [];
    var_1 = 0;

    if ( is_aliens() )
        var_2 = tablelookup( "mp/alien/alien_attachmentTable.csv", 0, var_1, 4 );
    else
        var_2 = tablelookup( "mp/attachmentTable.csv", 0, var_1, 4 );

    while ( var_2 != "" )
    {
        var_0[var_0.size] = var_2;
        var_1++;

        if ( is_aliens() )
        {
            var_2 = tablelookup( "mp/alien/alien_attachmentTable.csv", 0, var_1, 4 );
            continue;
        }

        var_2 = tablelookup( "mp/attachmentTable.csv", 0, var_1, 4 );
    }

    return var_0;
}

buildattachmentmaps()
{
    var_0 = getattachmentlistuniqenames();
    level.attachmentmap_uniquetobase = [];

    foreach ( var_2 in var_0 )
    {
        if ( is_aliens() )
            var_3 = tablelookup( "mp/alien/alien_attachmentTable.csv", 4, var_2, 5 );
        else
            var_3 = tablelookup( "mp/attachmenttable.csv", 4, var_2, 5 );

        if ( var_2 == var_3 )
            continue;

        level.attachmentmap_uniquetobase[var_2] = var_3;
    }

    var_5 = [];
    var_6 = 1;

    if ( is_aliens() )
        var_7 = tablelookupbyrow( "mp/alien/alien_attachmentmap.csv", var_6, 0 );
    else
        var_7 = tablelookupbyrow( "mp/attachmentmap.csv", var_6, 0 );

    while ( var_7 != "" )
    {
        var_5[var_5.size] = var_7;
        var_6++;

        if ( is_aliens() )
        {
            var_7 = tablelookupbyrow( "mp/alien/alien_attachmentmap.csv", var_6, 0 );
            continue;
        }

        var_7 = tablelookupbyrow( "mp/attachmentmap.csv", var_6, 0 );
    }

    var_8 = [];
    var_9 = 1;

    if ( is_aliens() )
        var_10 = tablelookupbyrow( "mp/alien/alien_attachmentmap.csv", 0, var_9 );
    else
        var_10 = tablelookupbyrow( "mp/attachmentmap.csv", 0, var_9 );

    while ( var_10 != "" )
    {
        var_8[var_10] = var_9;
        var_9++;

        if ( is_aliens() )
        {
            var_10 = tablelookupbyrow( "mp/alien/alien_attachmentmap.csv", 0, var_9 );
            continue;
        }

        var_10 = tablelookupbyrow( "mp/attachmentmap.csv", 0, var_9 );
    }

    level.attachmentmap_basetounique = [];

    foreach ( var_7 in var_5 )
    {
        foreach ( var_15, var_13 in var_8 )
        {
            if ( is_aliens() )
                var_14 = tablelookup( "mp/alien/alien_attachmentmap.csv", 0, var_7, var_13 );
            else
                var_14 = tablelookup( "mp/attachmentmap.csv", 0, var_7, var_13 );

            if ( var_14 == "" )
                continue;

            if ( !isdefined( level.attachmentmap_basetounique[var_7] ) )
                level.attachmentmap_basetounique[var_7] = [];

            level.attachmentmap_basetounique[var_7][var_15] = var_14;
        }
    }

    level.attachmentmap_attachtoperk = [];

    foreach ( var_18 in var_0 )
    {
        if ( is_aliens() )
            var_19 = tablelookup( "mp/alien/alien_attachmenttable.csv", 4, var_18, 12 );
        else
            var_19 = tablelookup( "mp/attachmenttable.csv", 4, var_18, 12 );

        if ( var_19 == "" )
            continue;

        level.attachmentmap_attachtoperk[var_18] = var_19;
    }
}

buildweaponperkmap()
{
    level.weaponmap_toperk = [];

    if ( is_aliens() )
        return;

    for ( var_0 = 0; tablelookup( "mp/statstable.csv", 0, var_0, 0 ) != ""; var_0++ )
    {
        var_1 = tablelookup( "mp/statstable.csv", 0, var_0, 5 );

        if ( var_1 != "" )
        {
            var_2 = tablelookup( "mp/statstable.csv", 0, var_0, 4 );

            if ( var_2 != "" )
                level.weaponmap_toperk[var_2] = var_1;
        }
    }
}

attachmentmap_tobase( var_0 )
{
    if ( isdefined( level.attachmentmap_uniquetobase[var_0] ) )
        var_0 = level.attachmentmap_uniquetobase[var_0];

    return var_0;
}

weaponmap( var_0 )
{
    if ( isdefined( var_0 ) )
    {
        switch ( var_0 )
        {
            case "semtexproj_mp":
                var_0 = "iw6_mk32_mp";
                break;
            case "iw6_maawshoming_mp":
            case "iw6_maawschild_mp":
                var_0 = "iw6_maaws_mp";
                break;
            case "iw6_knifeonlyfast_mp":
                var_0 = "iw6_knifeonly_mp";
                break;
            case "iw6_pdwauto_mp":
                var_0 = "iw6_pdw_mp";
            default:
                break;
        }
    }

    return var_0;
}

weaponhasintegratedsilencer( var_0 )
{
    return var_0 == "iw6_vks" || var_0 == "iw6_k7" || var_0 == "iw6_honeybadger";
}

weaponisfiretypeburst( var_0 )
{
    if ( weaponhasintegratedfiretypeburst( var_0 ) )
        return 1;
    else
        return weaponhasattachment( var_0, "firetypeburst" );
}

weaponhasintegratedfiretypeburst( var_0 )
{
    var_1 = getbaseweaponname( var_0 );

    if ( var_1 == "iw6_pdw" )
        return 1;
    else if ( var_1 == "iw6_msbs" )
    {
        var_2 = getweaponattachmentsbasenames( var_0 );

        foreach ( var_4 in var_2 )
        {
            if ( var_4 == "firetypeauto" || var_4 == "firetypesingle" )
                return 0;
        }

        return 1;
    }
    else
        return 0;
}

weaponhasintegratedgrip( var_0 )
{
    return var_0 == "iw6_g28";
}

weaponhasintegratedfmj( var_0 )
{
    return var_0 == "iw6_cbjms";
}

weaponhasintegratedtrackerscope( var_0 )
{
    var_1 = getbaseweaponname( var_0 );

    if ( var_1 == "iw6_dlcweap03" )
    {
        var_2 = getweaponattachments( var_0 );

        foreach ( var_4 in var_2 )
        {
            if ( isstrstart( var_4, "dlcweap03" ) )
                return 1;
        }
    }

    return 0;
}

weaponhasattachment( var_0, var_1 )
{
    var_2 = getweaponattachmentsbasenames( var_0 );

    foreach ( var_4 in var_2 )
    {
        if ( var_4 == var_1 )
            return 1;
    }

    return 0;
}

weapongetnumattachments( var_0 )
{
    var_1 = getnumdefaultattachments( var_0 );
    var_2 = getweaponattachments( var_0 );
    return var_2.size - var_1;
}

isplayerads()
{
    return self playerads() > 0.5;
}

_objective_delete( var_0 )
{
    objective_delete( var_0 );

    if ( !isdefined( level.reclaimedreservedobjectives ) )
    {
        level.reclaimedreservedobjectives = [];
        level.reclaimedreservedobjectives[0] = var_0;
    }
    else
        level.reclaimedreservedobjectives[level.reclaimedreservedobjectives.size] = var_0;
}

touchingbadtrigger( var_0 )
{
    var_1 = getentarray( "trigger_hurt", "classname" );

    foreach ( var_3 in var_1 )
    {
        if ( self istouching( var_3 ) && ( level.mapname != "mp_mine" || var_3.dmg > 0 ) )
            return 1;
    }

    var_5 = getentarray( "radiation", "targetname" );

    foreach ( var_3 in var_5 )
    {
        if ( self istouching( var_3 ) )
            return 1;
    }

    if ( isdefined( var_0 ) && var_0 == "gryphon" )
    {
        var_8 = getentarray( "gryphonDeath", "targetname" );

        foreach ( var_3 in var_8 )
        {
            if ( self istouching( var_3 ) )
                return 1;
        }
    }

    return 0;
}

setthirdpersondof( var_0 )
{
    if ( var_0 )
        self setdepthoffield( 0, 110, 512, 4096, 6, 1.8 );
    else
        self setdepthoffield( 0, 0, 512, 512, 4, 0 );
}

killtrigger( var_0, var_1, var_2 )
{
    var_3 = spawn( "trigger_radius", var_0, 0, var_1, var_2 );

    for (;;)
    {
        var_3 waittill( "trigger", var_4 );

        if ( !isplayer( var_4 ) )
            continue;

        var_4 suicide();
    }
}

findisfacing( var_0, var_1, var_2 )
{
    var_3 = cos( var_2 );
    var_4 = anglestoforward( var_0.angles );
    var_5 = var_1.origin - var_0.origin;
    var_4 = var_4 * ( 1, 1, 0 );
    var_5 = var_5 * ( 1, 1, 0 );
    var_5 = vectornormalize( var_5 );
    var_4 = vectornormalize( var_4 );
    var_6 = vectordot( var_5, var_4 );

    if ( var_6 >= var_3 )
        return 1;
    else
        return 0;
}

drawline( var_0, var_1, var_2, var_3 )
{
    var_4 = int( var_2 * 20 );

    for ( var_5 = 0; var_5 < var_4; var_5++ )
        wait 0.05;
}

drawsphere( var_0, var_1, var_2, var_3 )
{
    var_4 = int( var_2 * 20 );

    for ( var_5 = 0; var_5 < var_4; var_5++ )
        wait 0.05;
}

setrecoilscale( var_0, var_1 )
{
    if ( !isdefined( var_0 ) )
        var_0 = 0;

    if ( !isdefined( self.recoilscale ) )
        self.recoilscale = var_0;
    else
        self.recoilscale = self.recoilscale + var_0;

    if ( isdefined( var_1 ) )
    {
        if ( isdefined( self.recoilscale ) && var_1 < self.recoilscale )
            var_1 = self.recoilscale;

        var_2 = 100 - var_1;
    }
    else
        var_2 = 100 - self.recoilscale;

    if ( var_2 < 0 )
        var_2 = 0;

    if ( var_2 > 100 )
        var_2 = 100;

    if ( var_2 == 100 )
    {
        self player_recoilscaleoff();
        return;
    }

    self player_recoilscaleon( var_2 );
}

cleanarray( var_0 )
{
    var_1 = [];

    foreach ( var_4, var_3 in var_0 )
    {
        if ( !isdefined( var_3 ) )
            continue;

        var_1[var_1.size] = var_0[var_4];
    }

    return var_1;
}

notusableforjoiningplayers( var_0 )
{
    self notify( "notusablejoiningplayers" );
    self endon( "death" );
    level endon( "game_ended" );
    var_0 endon( "disconnect" );
    var_0 endon( "death" );
    self endon( "notusablejoiningplayers" );

    for (;;)
    {
        level waittill( "player_spawned", var_1 );

        if ( isdefined( var_1 ) && var_1 != var_0 )
            self disableplayeruse( var_1 );
    }
}

isstrstart( var_0, var_1 )
{
    return getsubstr( var_0, 0, var_1.size ) == var_1;
}

disableallstreaks()
{
    level.killstreaksdisabled = 1;
}

enableallstreaks()
{
    level.killstreaksdisabled = undefined;
}

validateusestreak( var_0, var_1 )
{
    if ( isdefined( var_0 ) )
        var_2 = var_0;
    else
    {
        var_3 = self.pers["killstreaks"];
        var_2 = var_3[self.killstreakindexweapon].streakname;
    }

    if ( isdefined( level.killstreaksdisabled ) && level.killstreaksdisabled )
        return 0;

    if ( !self isonground() && ( isridekillstreak( var_2 ) || iscarrykillstreak( var_2 ) ) )
        return 0;

    if ( isusingremote() )
        return 0;

    if ( isdefined( self.selectinglocation ) )
        return 0;

    if ( shouldpreventearlyuse( var_2 ) && level.killstreakrounddelay )
    {
        if ( level.graceperiod - level.ingraceperiod < level.killstreakrounddelay )
        {
            if ( !( isdefined( var_1 ) && var_1 ) )
                self iprintlnbold( &"KILLSTREAKS_UNAVAILABLE_FOR_N", level.killstreakrounddelay - ( level.graceperiod - level.ingraceperiod ) );

            return 0;
        }
    }

    if ( isdefined( self.nuked ) && self.nuked && isemped() )
    {
        if ( iskillstreakaffectedbyemp( var_2 ) )
        {
            if ( !( isdefined( var_1 ) && var_1 ) )
                self iprintlnbold( &"KILLSTREAKS_UNAVAILABLE_FOR_N_WHEN_NUKE", level.nukeemptimeremaining );

            return 0;
        }
    }

    if ( isemped() )
    {
        if ( iskillstreakaffectedbyemp( var_2 ) )
        {
            if ( !( isdefined( var_1 ) && var_1 ) )
                self iprintlnbold( &"KILLSTREAKS_UNAVAILABLE_WHEN_JAMMED" );

            return 0;
        }
    }

    if ( isairdenied() )
    {
        if ( isflyingkillstreak( var_2 ) && var_2 != "air_superiority" )
        {
            if ( !( isdefined( var_1 ) && var_1 ) )
                self iprintlnbold( &"KILLSTREAKS_UNAVAILABLE_WHEN_AA" );

            return 0;
        }
    }

    if ( self isusingturret() && ( isridekillstreak( var_2 ) || iscarrykillstreak( var_2 ) ) )
    {
        if ( !( isdefined( var_1 ) && var_1 ) )
            self iprintlnbold( &"KILLSTREAKS_UNAVAILABLE_USING_TURRET" );

        return 0;
    }

    if ( isdefined( self.laststand ) && !_hasperk( "specialty_finalstand" ) )
    {
        if ( !isdefined( level.allowlaststandai ) || !level.allowlaststandai || var_2 != "agent" )
        {
            if ( !( isdefined( var_1 ) && var_1 ) )
                self iprintlnbold( &"KILLSTREAKS_UNAVAILABLE_IN_LASTSTAND" );

            return 0;
        }
    }

    if ( !common_scripts\utility::isweaponenabled() )
        return 0;

    if ( isdefined( level.civilianjetflyby ) && isflyingkillstreak( var_2 ) )
    {
        if ( !( isdefined( var_1 ) && var_1 ) )
            self iprintlnbold( &"KILLSTREAKS_CIVILIAN_AIR_TRAFFIC" );

        return 0;
    }

    return 1;
}

isridekillstreak( var_0 )
{
    switch ( var_0 )
    {
        case "ac130":
        case "ca_a10_strafe":
        case "odin_assault":
        case "odin_support":
        case "drone_hive":
        case "heli_pilot":
        case "vanguard":
            return 1;
        default:
            return 0;
    }
}

iscarrykillstreak( var_0 )
{
    switch ( var_0 )
    {
        case "ims":
        case "deployable_exp_ammo":
        case "deployable_grenades":
        case "deployable_ammo":
        case "deployable_vest":
        case "gl_turret":
        case "minigun_turret":
        case "sentry_gl":
        case "sentry":
            return 1;
        default:
            return 0;
    }
}

shouldpreventearlyuse( var_0 )
{
    switch ( var_0 )
    {
        case "uav_3dping":
        case "jammer":
        case "recon_agent":
        case "ball_drone_radar":
        case "aa_launcher":
        case "uplink_support":
        case "ball_drone_backup":
        case "guard_dog":
        case "uplink":
        case "ims":
        case "deployable_ammo":
        case "deployable_vest":
        case "air_superiority":
        case "sentry":
            return 0;
        default:
            return !isstrstart( var_0, "airdrop_" );
    }
}

iskillstreakaffectedbyemp( var_0 )
{
    switch ( var_0 )
    {
        case "zerosub_level_killstreak":
        case "dome_seekers":
        case "recon_agent":
        case "guard_dog":
        case "deployable_ammo":
        case "deployable_vest":
        case "agent":
            return 0;
        default:
            return 1;
    }
}

iskillstreakaffectedbyjammer( var_0 )
{
    return iskillstreakaffectedbyemp( var_0 ) && !isflyingkillstreak( var_0 );
}

isflyingkillstreak( var_0 )
{
    switch ( var_0 )
    {
        case "airdrop_juggernaut_maniac":
        case "airdrop_assault":
        case "heli_sniper":
        case "airdrop_juggernaut_recon":
        case "airdrop_juggernaut":
        case "airdrop_sentry_minigun":
        case "ac130":
        case "ca_a10_strafe":
        case "odin_assault":
        case "odin_support":
        case "drone_hive":
        case "heli_pilot":
        case "vanguard":
        case "air_superiority":
        case "helicopter":
            return 1;
        default:
            return 0;
    }
}

isallteamstreak( var_0 )
{
    var_1 = getkillstreakallteamstreak( var_0 );

    if ( !isdefined( var_1 ) )
        return 0;

    if ( int( var_1 ) == 1 )
        return 1;

    return 0;
}

getkillstreakrownum( var_0 )
{
    return tablelookuprownum( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0 );
}

getkillstreakindex( var_0 )
{
    var_1 = tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].index_col );

    if ( var_1 == "" )
        var_2 = -1;
    else
        var_2 = int( var_1 );

    return var_2;
}

getkillstreakreference( var_0 )
{
    return tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].ref_col );
}

getkillstreakreferencebyweapon( var_0 )
{
    return tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].weapon_col, var_0, level.global_tables["killstreakTable"].ref_col );
}

getkillstreakname( var_0 )
{
    return tablelookupistring( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].name_col );
}

getkillstreakdescription( var_0 )
{
    return tablelookupistring( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].desc_col );
}

getkillstreakkills( var_0 )
{
    return tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].kills_col );
}

getkillstreakearnedhint( var_0 )
{
    return tablelookupistring( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].earned_hint_col );
}

getkillstreaksound( var_0 )
{
    return tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].sound_col );
}

getkillstreakearneddialog( var_0 )
{
    return tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].earned_dialog_col );
}

getkillstreakalliesdialog( var_0 )
{
    return tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].allies_dialog_col );
}

getkillstreakenemydialog( var_0 )
{
    return tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].enemy_dialog_col );
}

getkillstreakenemyusedialog( var_0 )
{
    return int( tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].enemy_use_dialog_col ) );
}

getkillstreakweapon( var_0 )
{
    return tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].weapon_col );
}

getkillstreakscore( var_0 )
{
    return tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].score_col );
}

getkillstreakicon( var_0 )
{
    return tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].icon_col );
}

getkillstreakoverheadicon( var_0 )
{
    return tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].overhead_icon_col );
}

getkillstreakdpadicon( var_0 )
{
    return tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].dpad_icon_col );
}

getkillstreakunearnedicon( var_0 )
{
    return tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].unearned_icon_col );
}

getkillstreakallteamstreak( var_0 )
{
    return tablelookup( level.global_tables["killstreakTable"].path, level.global_tables["killstreakTable"].ref_col, var_0, level.global_tables["killstreakTable"].all_team_streak_col );
}

currentactivevehiclecount( var_0 )
{
    if ( !isdefined( var_0 ) )
        var_0 = 0;

    var_1 = var_0;

    if ( isdefined( level.helis ) )
        var_1 = var_1 + level.helis.size;

    if ( isdefined( level.littlebirds ) )
        var_1 = var_1 + level.littlebirds.size;

    if ( isdefined( level.ugvs ) )
        var_1 = var_1 + level.ugvs.size;

    return var_1;
}

maxvehiclesallowed()
{
    return 8;
}

incrementfauxvehiclecount()
{
    level.fauxvehiclecount++;
}

decrementfauxvehiclecount()
{
    level.fauxvehiclecount--;
    var_0 = currentactivevehiclecount();

    if ( var_0 > level.fauxvehiclecount )
        level.fauxvehiclecount = var_0;

    if ( level.fauxvehiclecount < 0 )
        level.fauxvehiclecount = 0;
}

lightweightscalar()
{
    return 1.07;
}

allowteamchoice()
{
    if ( level.gametype == "cranked" )
        return level.teambased;

    var_0 = int( tablelookup( "mp/gametypesTable.csv", 0, level.gametype, 4 ) );
    return var_0;
}

allowclasschoice()
{
    var_0 = int( tablelookup( "mp/gametypesTable.csv", 0, level.gametype, 5 ) );
    return var_0;
}

showfakeloadout()
{
    if ( level.gametype == "sotf" || level.gametype == "sotf_ffa" || level.gametype == "gun" || level.gametype == "infect" )
        return 1;

    if ( level.gametype == "horde" && !matchmakinggame() && issplitscreen() )
        return 0;

    if ( level.gametype == "horde" && level.currentroundnumber == 0 )
        return 1;

    return 0;
}

setfakeloadoutweaponslot( var_0, var_1 )
{
    var_2 = getbaseweaponname( var_0 );
    var_3 = [];

    if ( var_2 != "iw6_knifeonly" && var_2 != "iw6_knifeonlyfast" )
        var_3 = getweaponattachments( var_0 );

    var_4 = "ui_fakeloadout_weapon" + var_1;

    if ( isdefined( var_2 ) )
    {
        var_5 = tablelookuprownum( "mp/statsTable.csv", 4, var_2 );
        self setclientomnvar( var_4, var_5 );
    }
    else
        self setclientomnvar( var_4, -1 );

    for ( var_6 = 0; var_6 < 3; var_6++ )
    {
        var_7 = var_4 + "_attach" + ( var_6 + 1 );
        var_8 = -1;

        if ( isdefined( var_3[var_6] ) )
        {
            if ( !isattachmentsniperscopedefault( var_0, var_3[var_6] ) )
                var_8 = tablelookuprownum( "mp/attachmentTable.csv", 4, var_3[var_6] );
        }

        self setclientomnvar( var_7, var_8 );
    }
}

isbuffunlockedforweapon( var_0, var_1 )
{
    var_2 = 4;
    var_3 = 0;
    var_4 = 4;
    var_5 = self getrankedplayerdata( "weaponRank", var_1 );
    var_6 = int( tablelookup( "mp/weaponRankTable.csv", var_3, getweaponclass( var_1 ), var_4 ) );
    var_7 = tablelookup( "mp/weaponRankTable.csv", var_6, var_0, var_2 );

    if ( var_7 != "" )
    {
        if ( var_5 >= int( var_7 ) )
            return 1;
    }

    return 0;
}

isbuffequippedonweapon( var_0, var_1 )
{
    if ( isdefined( self.loadoutprimary ) && self.loadoutprimary == var_1 )
    {
        if ( isdefined( self.loadoutprimarybuff ) && self.loadoutprimarybuff == var_0 )
            return 1;
    }
    else if ( isdefined( self.loadoutsecondary ) && self.loadoutsecondary == var_1 )
    {
        if ( isdefined( self.loadoutsecondarybuff ) && self.loadoutsecondarybuff == var_0 )
            return 1;
    }

    return 0;
}

setcommonrulesfrommatchrulesdata( var_0 )
{
    var_1 = getmatchrulesdata( "commonOption", "timeLimit" );
    setdynamicdvar( "scr_" + level.gametype + "_timeLimit", var_1 );
    registertimelimitdvar( level.gametype, var_1 );
    var_2 = getmatchrulesdata( "commonOption", "scoreLimit" );
    setdynamicdvar( "scr_" + level.gametype + "_scoreLimit", var_2 );
    registerscorelimitdvar( level.gametype, var_2 );
    var_3 = getmatchrulesdata( "commonOption", "numLives" );
    setdynamicdvar( "scr_" + level.gametype + "_numLives", var_3 );
    registernumlivesdvar( level.gametype, var_3 );
    setdynamicdvar( "scr_player_maxhealth", getmatchrulesdata( "commonOption", "maxHealth" ) );
    setdynamicdvar( "scr_player_healthregentime", getmatchrulesdata( "commonOption", "healthRegen" ) );
    level.matchrules_damagemultiplier = 0;
    level.matchrules_vampirism = 0;
    setdynamicdvar( "scr_game_spectatetype", getmatchrulesdata( "commonOption", "spectateModeAllowed" ) );
    setdynamicdvar( "scr_game_allowkillcam", getmatchrulesdata( "commonOption", "showKillcam" ) );
    setdynamicdvar( "scr_game_forceuav", getmatchrulesdata( "commonOption", "radarAlwaysOn" ) );
    setdynamicdvar( "scr_" + level.gametype + "_playerrespawndelay", getmatchrulesdata( "commonOption", "respawnDelay" ) );
    setdynamicdvar( "scr_" + level.gametype + "_waverespawndelay", getmatchrulesdata( "commonOption", "waveRespawnDelay" ) );
    setdynamicdvar( "scr_player_forcerespawn", getmatchrulesdata( "commonOption", "forceRespawn" ) );
    level.matchrules_allowcustomclasses = getmatchrulesdata( "commonOption", "allowCustomClasses" );
    level.supportintel = getmatchrulesdata( "commonOption", "allowIntel" );
    setdynamicdvar( "scr_game_hardpoints", getmatchrulesdata( "commonOption", "allowKillstreaks" ) );
    setdynamicdvar( "scr_game_perks", getmatchrulesdata( "commonOption", "allowPerks" ) );
    setdynamicdvar( "g_hardcore", getmatchrulesdata( "commonOption", "hardcoreModeOn" ) );
    setdynamicdvar( "scr_game_onlyheadshots", getmatchrulesdata( "commonOption", "headshotsOnly" ) );

    if ( !isdefined( var_0 ) )
        setdynamicdvar( "scr_team_fftype", getmatchrulesdata( "commonOption", "friendlyFire" ) );

    if ( getmatchrulesdata( "commonOption", "hardcoreModeOn" ) )
    {
        setdynamicdvar( "scr_team_fftype", 2 );
        setdynamicdvar( "scr_player_maxhealth", 30 );
        setdynamicdvar( "scr_player_healthregentime", 0 );
        setdynamicdvar( "scr_player_respawndelay", 0 );
        setdynamicdvar( "scr_game_allowkillcam", 0 );
        setdynamicdvar( "scr_game_forceuav", 0 );
    }

    setdvar( "bg_compassShowEnemies", getdvar( "scr_game_forceuav" ) );
}

reinitializematchrulesonmigration()
{
    for (;;)
    {
        level waittill( "host_migration_begin" );
        [[ level.initializematchrules ]]();
    }
}

reinitializethermal( var_0 )
{
    self endon( "disconnect" );

    if ( isdefined( var_0 ) )
        var_0 endon( "death" );

    for (;;)
    {
        level waittill( "host_migration_begin" );

        if ( isdefined( self.lastvisionsetthermal ) )
            self visionsetthermalforplayer( self.lastvisionsetthermal, 0 );
    }
}

getmatchrulesspecialclass( var_0, var_1 )
{
    var_2 = [];
    var_2["loadoutPrimaryAttachment2"] = "none";
    var_2["loadoutSecondaryAttachment2"] = "none";
    var_3 = [];
    var_2["loadoutPrimary"] = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "weaponSetups", 0, "weapon" );
    var_2["loadoutPrimaryAttachment"] = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "weaponSetups", 0, "attachment", 0 );
    var_2["loadoutPrimaryAttachment2"] = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "weaponSetups", 0, "attachment", 1 );
    var_2["loadoutPrimaryBuff"] = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "weaponSetups", 0, "buff" );
    var_2["loadoutPrimaryCamo"] = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "weaponSetups", 0, "camo" );
    var_2["loadoutPrimaryReticle"] = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "weaponSetups", 0, "reticle" );
    var_2["loadoutSecondary"] = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "weaponSetups", 1, "weapon" );
    var_2["loadoutSecondaryAttachment"] = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "weaponSetups", 1, "attachment", 0 );
    var_2["loadoutSecondaryAttachment2"] = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "weaponSetups", 1, "attachment", 1 );
    var_2["loadoutSecondaryBuff"] = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "weaponSetups", 1, "buff" );
    var_2["loadoutSecondaryCamo"] = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "weaponSetups", 1, "camo" );
    var_2["loadoutSecondaryReticle"] = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "weaponSetups", 1, "reticle" );
    var_2["loadoutEquipment"] = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "perks", 0 );
    var_2["loadoutOffhand"] = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "perks", 1 );

    if ( var_2["loadoutOffhand"] == "specialty_null" )
    {
        var_2["loadoutOffhand"] = "none";

        if ( level.gametype == "infect" && var_0 == "axis" )
            var_2["loadoutOffhand"] = "specialty_tacticalinsertion";
    }

    for ( var_4 = 0; var_4 < maps\mp\gametypes\_class::getnumabilitycategories(); var_4++ )
    {
        for ( var_5 = 0; var_5 < maps\mp\gametypes\_class::getnumsubability(); var_5++ )
        {
            var_6 = 0;
            var_6 = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "abilitiesPicked", var_4, var_5 );

            if ( isdefined( var_6 ) && var_6 )
            {
                var_7 = tablelookup( "mp/cacAbilityTable.csv", 0, var_4 + 1, var_5 + 4 );
                var_3[var_3.size] = var_7;
            }
        }
    }

    var_2["loadoutPerks"] = var_3;
    var_8 = getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "perks", 5 );

    if ( var_8 != "specialty_null" )
    {
        var_2["loadoutStreakType"] = var_8;
        var_2["loadoutKillstreak1"] = maps\mp\gametypes\_class::recipe_getkillstreak( var_0, var_1, var_8, 0 );
        var_2["loadoutKillstreak2"] = maps\mp\gametypes\_class::recipe_getkillstreak( var_0, var_1, var_8, 1 );
        var_2["loadoutKillstreak3"] = maps\mp\gametypes\_class::recipe_getkillstreak( var_0, var_1, var_8, 2 );
    }

    var_2["loadoutJuggernaut"] = getmatchrulesdata( "defaultClasses", var_0, var_1, "juggernaut" );
    return var_2;
}

recipeclassapplyjuggernaut( var_0 )
{
    level endon( "game_ended" );
    self endon( "disconnect" );

    if ( level.ingraceperiod && !self.hasdonecombat )
        self waittill( "giveLoadout" );
    else
        self waittill( "spawned_player" );

    if ( var_0 )
    {
        self notify( "lost_juggernaut" );
        wait 0.5;
    }

    if ( !isdefined( self.isjuiced ) )
    {
        self.movespeedscaler = 0.7;
        maps\mp\gametypes\_weapons::updatemovespeedscale();
    }

    self.juggmovespeedscaler = 0.7;
    self disableweaponpickup();

    if ( !getdvarint( "camera_thirdPerson" ) )
        self setclientomnvar( "ui_juggernaut", 1 );

    thread maps\mp\killstreaks\_juggernaut::juggernautsounds();

    if ( level.gametype != "jugg" || isdefined( level.matchrules_showjuggradaricon ) && level.matchrules_showjuggradaricon )
        self setperk( "specialty_radarjuggernaut", 1, 0 );

    if ( isdefined( self.isjuggmodejuggernaut ) && self.isjuggmodejuggernaut )
        self makeportableradar( self );

    level notify( "juggernaut_equipped", self );
    thread maps\mp\killstreaks\_juggernaut::juggremover();
}

updatesessionstate( var_0, var_1 )
{
    self.sessionstate = var_0;

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

    self.statusicon = var_1;
    self setclientomnvar( "ui_session_state", var_0 );
}

getclassindex( var_0 )
{
    return level.classmap[var_0];
}

isteaminlaststand()
{
    var_0 = getlivingplayers( self.team );

    foreach ( var_2 in var_0 )
    {
        if ( var_2 != self && ( !isdefined( var_2.laststand ) || !var_2.laststand ) )
            return 0;
    }

    return 1;
}

killteaminlaststand( var_0 )
{
    var_1 = getlivingplayers( var_0 );

    foreach ( var_3 in var_1 )
    {
        if ( isdefined( var_3.laststand ) && var_3.laststand )
            var_3 thread maps\mp\gametypes\_damage::dieaftertime( randomintrange( 1, 3 ) );
    }
}

switch_to_last_weapon( var_0 )
{
    if ( !isai( self ) )
        self switchtoweapon( var_0 );
    else
        self switchtoweapon( "none" );
}

isaiteamparticipant( var_0 )
{
    if ( isagent( var_0 ) && var_0.agent_teamparticipant == 1 )
        return 1;

    if ( isbot( var_0 ) )
        return 1;

    return 0;
}

isteamparticipant( var_0 )
{
    if ( isaiteamparticipant( var_0 ) )
        return 1;

    if ( isplayer( var_0 ) )
        return 1;

    return 0;
}

isaigameparticipant( var_0 )
{
    if ( isagent( var_0 ) && isdefined( var_0.agent_gameparticipant ) && var_0.agent_gameparticipant == 1 )
        return 1;

    if ( isbot( var_0 ) )
        return 1;

    return 0;
}

isgameparticipant( var_0 )
{
    if ( isaigameparticipant( var_0 ) )
        return 1;

    if ( isplayer( var_0 ) )
        return 1;

    return 0;
}

getteamindex( var_0 )
{
    var_1 = 0;

    if ( level.teambased )
    {
        switch ( var_0 )
        {
            case "axis":
                var_1 = 1;
                break;
            case "allies":
                var_1 = 2;
                break;
        }
    }

    return var_1;
}

getteamarray( var_0, var_1 )
{
    var_2 = [];

    if ( !isdefined( var_1 ) || var_1 )
    {
        foreach ( var_4 in level.characters )
        {
            if ( var_4.team == var_0 )
                var_2[var_2.size] = var_4;
        }
    }
    else
    {
        foreach ( var_4 in level.players )
        {
            if ( var_4.team == var_0 )
                var_2[var_2.size] = var_4;
        }
    }

    return var_2;
}

isheadshot( var_0, var_1, var_2, var_3 )
{
    if ( isdefined( var_3 ) )
    {
        if ( isdefined( var_3.owner ) )
        {
            if ( var_3.code_classname == "script_vehicle" )
                return 0;

            if ( var_3.code_classname == "misc_turret" )
                return 0;

            if ( var_3.code_classname == "script_model" )
                return 0;
        }

        if ( isdefined( var_3.agent_type ) )
        {
            if ( var_3.agent_type == "dog" || var_3.agent_type == "alien" )
                return 0;
        }
    }

    return ( var_1 == "head" || var_1 == "helmet" ) && var_2 != "MOD_MELEE" && var_2 != "MOD_IMPACT" && var_2 != "MOD_SCARAB" && var_2 != "MOD_CRUSH" && !isenvironmentweapon( var_0 );
}

attackerishittingteam( var_0, var_1 )
{
    if ( !level.teambased )
        return 0;
    else if ( !isdefined( var_1 ) || !isdefined( var_0 ) )
        return 0;
    else if ( !isdefined( var_0.team ) || !isdefined( var_1.team ) )
        return 0;
    else if ( var_0 == var_1 )
        return 0;
    else if ( level.gametype == "infect" && var_0.pers["team"] == var_1.team && isdefined( var_1.teamchangedthisframe ) )
        return 0;
    else if ( level.gametype == "infect" && var_0.pers["team"] != var_1.team && isdefined( var_1.teamchangedthisframe ) )
        return 1;
    else if ( isdefined( var_1.scrambled ) && var_1.scrambled )
        return 0;
    else if ( var_0.team == var_1.team )
        return 1;
    else
        return 0;
}

set_high_priority_target_for_bot( var_0 )
{
    if ( !( isdefined( self.high_priority_for ) && common_scripts\utility::array_contains( self.high_priority_for, var_0 ) ) )
    {
        self.high_priority_for = common_scripts\utility::array_add( self.high_priority_for, var_0 );
        var_0 notify( "calculate_new_level_targets" );
    }
}

add_to_bot_use_targets( var_0, var_1 )
{
    if ( isdefined( level.bot_funcs["bots_add_to_level_targets"] ) )
    {
        var_0.use_time = var_1;
        var_0.bot_interaction_type = "use";
        [[ level.bot_funcs["bots_add_to_level_targets"] ]]( var_0 );
    }
}

remove_from_bot_use_targets( var_0 )
{
    if ( isdefined( level.bot_funcs["bots_remove_from_level_targets"] ) )
        [[ level.bot_funcs["bots_remove_from_level_targets"] ]]( var_0 );
}

add_to_bot_damage_targets( var_0 )
{
    if ( isdefined( level.bot_funcs["bots_add_to_level_targets"] ) )
    {
        var_0.bot_interaction_type = "damage";
        [[ level.bot_funcs["bots_add_to_level_targets"] ]]( var_0 );
    }
}

remove_from_bot_damage_targets( var_0 )
{
    if ( isdefined( level.bot_funcs["bots_remove_from_level_targets"] ) )
        [[ level.bot_funcs["bots_remove_from_level_targets"] ]]( var_0 );
}

notify_enemy_bots_bomb_used( var_0 )
{
    if ( isdefined( level.bot_funcs["notify_enemy_bots_bomb_used"] ) )
        self [[ level.bot_funcs["notify_enemy_bots_bomb_used"] ]]( var_0 );
}

get_rank_xp_for_bot()
{
    if ( isdefined( level.bot_funcs["bot_get_rank_xp"] ) )
        return self [[ level.bot_funcs["bot_get_rank_xp"] ]]();
}

bot_israndom()
{
    var_0 = 1;

    if ( getdvar( "squad_use_hosts_squad" ) == "1" )
    {
        var_1 = undefined;

        if ( isdefined( self.bot_team ) )
            var_1 = self.bot_team;
        else if ( isdefined( self.pers["team"] ) )
            var_1 = self.pers["team"];

        if ( isdefined( var_1 ) && level.wargame_client.team == var_1 )
            var_0 = 0;
        else
            var_0 = 1;
    }
    else
        var_0 = self botisrandomized();

    return var_0;
}

isassaultkillstreak( var_0 )
{
    switch ( var_0 )
    {
        case "airdrop_juggernaut_maniac":
        case "airdrop_assault":
        case "airdrop_juggernaut":
        case "airdrop_sentry_minigun":
        case "ball_drone_backup":
        case "guard_dog":
        case "uplink":
        case "ims":
        case "odin_assault":
        case "drone_hive":
        case "heli_pilot":
        case "vanguard":
        case "sentry":
        case "helicopter":
            return 1;
        default:
            return 0;
    }
}

issupportkillstreak( var_0 )
{
    switch ( var_0 )
    {
        case "sam_turret":
        case "heli_sniper":
        case "airdrop_juggernaut_recon":
        case "uav_3dping":
        case "jammer":
        case "recon_agent":
        case "ball_drone_radar":
        case "aa_launcher":
        case "uplink_support":
        case "deployable_ammo":
        case "deployable_vest":
        case "odin_support":
        case "air_superiority":
            return 1;
        default:
            return 0;
    }
}

isspecialistkillstreak( var_0 )
{
    switch ( var_0 )
    {
        case "specialty_deadeye_ks":
        case "specialty_boom_ks":
        case "specialty_twoprimaries_ks":
        case "specialty_hardline_ks":
        case "specialty_gambler_ks":
        case "specialty_explosivedamage_ks":
        case "specialty_extra_attachment_ks":
        case "specialty_extra_deadly_ks":
        case "specialty_extra_equipment_ks":
        case "specialty_extraammo_ks":
        case "specialty_gunsmith_ks":
        case "_specialty_blastshield_ks":
        case "specialty_stun_resistance_ks":
        case "specialty_sharp_focus_ks":
        case "specialty_regenfaster_ks":
        case "specialty_falldamage_ks":
        case "specialty_comexp_ks":
        case "specialty_selectivehearing_ks":
        case "specialty_detectexplosive_ks":
        case "specialty_scavenger_ks":
        case "specialty_paint_ks":
        case "specialty_incog_ks":
        case "specialty_quieter_ks":
        case "specialty_gpsjammer_ks":
        case "specialty_blindeye_ks":
        case "specialty_silentkill_ks":
        case "specialty_sprintreload_ks":
        case "specialty_quickdraw_ks":
        case "specialty_bulletaccuracy_ks":
        case "specialty_pitcher_ks":
        case "specialty_quickswap_ks":
        case "specialty_reducedsway_ks":
        case "specialty_stalker_ks":
        case "specialty_marathon_ks":
        case "specialty_lightweight_ks":
        case "specialty_fastreload_ks":
        case "specialty_fastsprintrecovery_ks":
            return 1;
        default:
            return 0;
    }
}

bot_is_fireteam_mode()
{
    var_0 = botautoconnectenabled() == 2;

    if ( var_0 )
    {
        if ( !level.teambased || level.gametype != "war" && level.gametype != "dom" )
            return 0;

        return 1;
    }

    return 0;
}

set_console_status()
{
    if ( !isdefined( level.console ) )
        level.console = getdvar( "consoleGame" ) == "true";
    else
    {

    }

    if ( !isdefined( level.xenon ) )
        level.xenon = getdvar( "xenonGame" ) == "true";
    else
    {

    }

    if ( !isdefined( level.ps3 ) )
        level.ps3 = getdvar( "ps3Game" ) == "true";
    else
    {

    }

    if ( !isdefined( level.xb3 ) )
        level.xb3 = getdvar( "xb3Game" ) == "true";
    else
    {

    }

    if ( !isdefined( level.ps4 ) )
        level.ps4 = getdvar( "ps4Game" ) == "true";
    else
    {

    }
}

is_gen4()
{
    if ( level.xb3 || level.ps4 || !level.console )
        return 1;
    else
        return 0;
}

setdvar_cg_ng( var_0, var_1, var_2 )
{
    if ( !isdefined( level.console ) || !isdefined( level.xb3 ) || !isdefined( level.ps4 ) )
        set_console_status();

    if ( is_gen4() )
        setdvar( var_0, var_2 );
    else
        setdvar( var_0, var_1 );
}

isvalidteamtarget( var_0, var_1, var_2 )
{
    return isdefined( var_2.team ) && var_2.team == var_1;
}

isvalidffatarget( var_0, var_1, var_2 )
{
    return isdefined( var_2.owner ) && ( !isdefined( var_0 ) || var_2.owner != var_0 );
}

gethelipilotmeshoffset()
{
    return ( 0, 0, 5000 );
}

gethelipilottraceoffset()
{
    return ( 0, 0, 2500 );
}

getlinknamenodes()
{
    var_0 = [];

    if ( isdefined( self.script_linkto ) )
    {
        var_1 = strtok( self.script_linkto, " " );

        for ( var_2 = 0; var_2 < var_1.size; var_2++ )
        {
            var_3 = getnode( var_1[var_2], "script_linkname" );

            if ( isdefined( var_3 ) )
                var_0[var_0.size] = var_3;
        }
    }

    return var_0;
}

is_aliens()
{
    return level.gametype == "aliens";
}

get_players_watching( var_0, var_1 )
{
    if ( !isdefined( var_0 ) )
        var_0 = 0;

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

    var_2 = self getentitynumber();
    var_3 = [];

    foreach ( var_5 in level.players )
    {
        if ( var_5 == self )
            continue;

        var_6 = 0;

        if ( !var_1 )
        {
            if ( var_5.team == "spectator" || var_5.sessionstate == "spectator" )
            {
                var_7 = var_5 getspectatingplayer();

                if ( isdefined( var_7 ) && var_7 == self )
                    var_6 = 1;
            }

            if ( var_5.forcespectatorclient == var_2 )
                var_6 = 1;
        }

        if ( !var_0 )
        {
            if ( var_5.killcamentity == var_2 )
                var_6 = 1;
        }

        if ( var_6 )
            var_3[var_3.size] = var_5;
    }

    return var_3;
}

set_visionset_for_watching_players( var_0, var_1, var_2, var_3, var_4, var_5 )
{
    var_6 = get_players_watching( var_4, var_5 );

    foreach ( var_8 in var_6 )
    {
        var_8 notify( "changing_watching_visionset" );

        if ( isdefined( var_3 ) && var_3 )
            var_8 visionsetmissilecamforplayer( var_0, var_1 );
        else
            var_8 visionsetnakedforplayer( var_0, var_1 );

        if ( var_0 != "" && isdefined( var_2 ) )
        {
            var_8 thread reset_visionset_on_team_change( self, var_1 + var_2 );
            var_8 thread reset_visionset_on_disconnect( self );

            if ( var_8 isinkillcam() )
                var_8 thread reset_visionset_on_spawn();
        }
    }
}

reset_visionset_on_spawn()
{
    self endon( "disconnect" );
    self waittill( "spawned" );
    self visionsetnakedforplayer( "", 0.0 );
}

reset_visionset_on_team_change( var_0, var_1 )
{
    self endon( "changing_watching_visionset" );
    var_2 = gettime();
    var_3 = self.team;

    while ( gettime() - var_2 < var_1 * 1000 )
    {
        if ( self.team != var_3 || !common_scripts\utility::array_contains( var_0 get_players_watching(), self ) )
        {
            self visionsetnakedforplayer( "", 0.0 );
            self notify( "changing_visionset" );
            break;
        }

        wait 0.05;
    }
}

reset_visionset_on_disconnect( var_0 )
{
    self endon( "changing_watching_visionset" );
    var_0 waittill( "disconnect" );
    self visionsetnakedforplayer( "", 0.0 );
}

_setplayerdata( var_0, var_1 )
{
    if ( matchmakinggame() )
        self setrankedplayerdata( var_0, var_1 );
    else
        self setprivateplayerdata( var_0, var_1 );
}

_getplayerdata( var_0 )
{
    if ( matchmakinggame() )
        return self getrankedplayerdata( var_0 );
    else
        return self getprivateplayerdata( var_0 );
}

_validateattacker( var_0 )
{
    if ( isagent( var_0 ) && ( !isdefined( var_0.isactive ) || !var_0.isactive ) )
        return undefined;

    if ( isagent( var_0 ) && !isdefined( var_0.classname ) )
        return undefined;

    return var_0;
}

waittill_grenade_fire()
{
    self waittill( "grenade_fire", var_0, var_1 );

    if ( isdefined( var_0 ) )
    {
        if ( !isdefined( var_0.weapon_name ) )
            var_0.weapon_name = var_1;

        if ( !isdefined( var_0.owner ) )
            var_0.owner = self;

        if ( !isdefined( var_0.team ) )
            var_0.team = self.team;
    }

    return var_0;
}

waittill_missile_fire()
{
    self waittill( "missile_fire", var_0, var_1 );

    if ( isdefined( var_0 ) )
    {
        if ( !isdefined( var_0.weapon_name ) )
            var_0.weapon_name = var_1;

        if ( !isdefined( var_0.owner ) )
            var_0.owner = self;

        if ( !isdefined( var_0.team ) )
            var_0.team = self.team;
    }

    return var_0;
}

_setnameplatematerial( var_0, var_1 )
{
    if ( !isdefined( self.nameplatematerial ) )
    {
        self.nameplatematerial = [];
        self.prevnameplatematerial = [];
    }
    else
    {
        self.prevnameplatematerial[0] = self.nameplatematerial[0];
        self.prevnameplatematerial[1] = self.nameplatematerial[1];
    }

    self.nameplatematerial[0] = var_0;
    self.nameplatematerial[1] = var_1;
    self setnameplatematerial( var_0, var_1 );
}

_restorepreviousnameplatematerial()
{
    if ( isdefined( self.prevnameplatematerial ) )
        self setnameplatematerial( self.prevnameplatematerial[0], self.prevnameplatematerial[1] );
    else
        self setnameplatematerial( "", "" );

    self.nameplatematerial = undefined;
    self.prevnameplatematerial = undefined;
}

isplayeroutsideofanybombsite( var_0 )
{
    if ( isdefined( level.bombzones ) )
    {
        foreach ( var_2 in level.bombzones )
        {
            if ( self istouching( var_2.trigger ) )
                return 0;
        }
    }

    return 1;
}

weaponignoresblastshield( var_0 )
{
    return var_0 == "heli_pilot_turret_mp" || var_0 == "bomb_site_mp";
}

isweaponaffectedbyblastshield( var_0 )
{
    return var_0 == "ims_projectile_mp" || var_0 == "remote_tank_projectile_mp";
}

restorebasevisionset( var_0 )
{
    self visionsetnakedforplayer( "", var_0 );
}

playplayerandnpcsounds( var_0, var_1, var_2 )
{
    var_0 playlocalsound( var_1 );
    var_0 playsoundtoteam( var_2, "allies", var_0 );
    var_0 playsoundtoteam( var_2, "axis", var_0 );
}

isenemy( var_0 )
{
    if ( level.teambased )
        return isplayeronenemyteam( var_0 );
    else
        return isplayerffaenemy( var_0 );
}

isplayeronenemyteam( var_0 )
{
    return var_0.team != self.team;
}

isplayerffaenemy( var_0 )
{
    if ( isdefined( var_0.owner ) )
        return var_0.owner != self;
    else
        return var_0 != self;
}

setextrascore0( var_0 )
{
    self.extrascore0 = var_0;
    setpersstat( "extrascore0", var_0 );
}

allowlevelkillstreaks()
{
    if ( level.gametype == "sotf" && level.gametype == "sotf_ffa" && level.gametype == "infect" && level.gametype == "horde" )
        return 0;

    return 1;
}

getuniqueid()
{
    if ( isdefined( self.pers["guid"] ) )
        return self.pers["guid"];

    var_0 = self getguid();

    if ( var_0 == "0000000000000000" )
    {
        if ( isdefined( level.guidgen ) )
            level.guidgen++;
        else
            level.guidgen = 1;

        var_0 = "script" + level.guidgen;
    }

    self.pers["guid"] = var_0;
    return self.pers["guid"];
}

getrandomplayingplayer()
{
    var_0 = common_scripts\utility::array_removeundefined( level.players );

    for (;;)
    {
        if ( !var_0.size )
            return;

        var_1 = randomintrange( 0, var_0.size );
        var_2 = var_0[var_1];

        if ( !isreallyalive( var_2 ) || var_2.sessionstate != "playing" )
        {
            var_0 = common_scripts\utility::array_remove( var_0, var_2 );
            continue;
        }

        return var_2;
    }
}

getmapname()
{
    if ( !isdefined( level.mapname ) )
        level.mapname = getdvar( "mapname" );

    return level.mapname;
}

issinglehitweapon( var_0 )
{
    switch ( var_0 )
    {
        case "iw6_panzerfaust3_mp":
        case "iw6_rgm_mp":
        case "iw6_maaws_mp":
        case "iw6_mk32_mp":
            return 1;
        default:
            return 0;
    }
}

gamehasneutralcrateowner( var_0 )
{
    switch ( var_0 )
    {
        case "sotf_ffa":
        case "sotf":
            return 1;
        default:
            return 0;
    }
}

array_remove_keep_index( var_0, var_1 )
{
    var_2 = [];

    foreach ( var_5, var_4 in var_0 )
    {
        if ( var_4 != var_1 )
            var_2[var_5] = var_4;
    }

    return var_2;
}

isanymlgmatch()
{
    if ( getdvarint( "xblive_competitionmatch" ) )
        return 1;

    return 0;
}

ismlgsystemlink()
{
    if ( getdvarint( "systemlink" ) && getdvarint( "xblive_competitionmatch" ) )
        return 1;

    return 0;
}

ismlgprivatematch()
{
    if ( privatematch() && getdvarint( "xblive_competitionmatch" ) )
        return 1;

    return 0;
}

ismlgmatch()
{
    if ( ismlgsystemlink() || ismlgprivatematch() )
        return 1;

    return 0;
}

ismoddedroundgame()
{
    if ( level.gametype == "blitz" || level.gametype == "dom" )
        return 1;

    return 0;
}

isusingdefaultclass( var_0, var_1 )
{
    var_2 = 0;

    if ( isdefined( var_1 ) )
    {
        if ( isusingmatchrulesdata() && getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "inUse" ) )
            var_2 = 1;
    }
    else
    {
        for ( var_1 = 0; var_1 < 6; var_1++ )
        {
            if ( isusingmatchrulesdata() && getmatchrulesdata( "defaultClasses", var_0, var_1, "class", "inUse" ) )
            {
                var_2 = 1;
                break;
            }
        }
    }

    return var_2;
}

cancustomjuggusekillstreak( var_0 )
{
    var_1 = 1;

    if ( isdefined( self.isjuggernautlevelcustom ) && self.isjuggernautlevelcustom && ( isdefined( self.canusekillstreakcallback ) && !self [[ self.canusekillstreakcallback ]]( var_0 ) ) )
        var_1 = 0;

    return var_1;
}

printcustomjuggkillstreakerrormsg()
{
    if ( isdefined( self.killstreakerrormsg ) )
        [[ self.killstreakerrormsg ]]();
}
