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

main()
{
    maps\mp\gametypes\_globallogic::init();
    maps\mp\gametypes\_callbacksetup::setupcallbacks();
    maps\mp\gametypes\_globallogic::setupcallbacks();

    if ( isusingmatchrulesdata() )
    {
        level.initializematchrules = ::initializematchrules;
        [[ level.initializematchrules ]]();
        level thread maps\mp\_utility::reinitializematchrulesonmigration();
    }
    else
    {
        maps\mp\_utility::registertimelimitdvar( level.gametype, 10 );
        maps\mp\_utility::setoverridewatchdvar( "scorelimit", 0 );
        maps\mp\_utility::registerroundlimitdvar( level.gametype, 1 );
        maps\mp\_utility::registerwinlimitdvar( level.gametype, 1 );
        maps\mp\_utility::registernumlivesdvar( level.gametype, 0 );
        maps\mp\_utility::registerhalftimedvar( level.gametype, 0 );
        level.matchrules_numinitialinfected = 1;
        level.matchrules_damagemultiplier = 0;
    }

    setspecialloadouts();
    level.teambased = 1;
    level.supportintel = 0;
    level.disableforfeit = 1;
    level.nobuddyspawns = 1;
    level.onstartgametype = ::onstartgametype;
    level.onspawnplayer = ::onspawnplayer;
    level.getspawnpoint = ::getspawnpoint;
    level.onplayerkilled = ::onplayerkilled;
    level.ondeadevent = ::ondeadevent;
    level.ontimelimit = ::ontimelimit;
    level.bypassclasschoicefunc = ::alwaysgamemodeclass;

    if ( level.matchrules_damagemultiplier )
        level.modifyplayerdamage = maps\mp\gametypes\_damage::gamemodemodifyplayerdamage;

    game["dialog"]["gametype"] = "infected";

    if ( getdvarint( "g_hardcore" ) )
        game["dialog"]["gametype"] = "hc_" + game["dialog"]["gametype"];

    game["dialog"]["offense_obj"] = "infct_hint";
}

initializematchrules()
{
    maps\mp\_utility::setcommonrulesfrommatchrulesdata();
    level.matchrules_numinitialinfected = getmatchrulesdata( "infectData", "numInitialInfected" );
    setdynamicdvar( "scr_" + level.gametype + "_numLives", 0 );
    maps\mp\_utility::registernumlivesdvar( level.gametype, 0 );
    maps\mp\_utility::setoverridewatchdvar( "scorelimit", 0 );
    setdynamicdvar( "scr_infect_roundswitch", 0 );
    maps\mp\_utility::registerroundswitchdvar( "infect", 0, 0, 9 );
    setdynamicdvar( "scr_infect_roundlimit", 1 );
    maps\mp\_utility::registerroundlimitdvar( "infect", 1 );
    setdynamicdvar( "scr_infect_winlimit", 1 );
    maps\mp\_utility::registerwinlimitdvar( "infect", 1 );
    setdynamicdvar( "scr_infect_halftime", 0 );
    maps\mp\_utility::registerhalftimedvar( "infect", 0 );
    setdynamicdvar( "scr_infect_playerrespawndelay", 0 );
    setdynamicdvar( "scr_infect_waverespawndelay", 0 );
    setdynamicdvar( "scr_player_forcerespawn", 1 );
    setdynamicdvar( "scr_team_fftype", 0 );
    setdynamicdvar( "scr_infect_promode", 0 );
}

onstartgametype()
{
    setclientnamemode( "auto_change" );
    maps\mp\_utility::setobjectivetext( "allies", &"OBJECTIVES_INFECT" );
    maps\mp\_utility::setobjectivetext( "axis", &"OBJECTIVES_INFECT" );

    if ( level.splitscreen )
    {
        maps\mp\_utility::setobjectivescoretext( "allies", &"OBJECTIVES_INFECT" );
        maps\mp\_utility::setobjectivescoretext( "axis", &"OBJECTIVES_INFECT" );
    }
    else
    {
        maps\mp\_utility::setobjectivescoretext( "allies", &"OBJECTIVES_INFECT_SCORE" );
        maps\mp\_utility::setobjectivescoretext( "axis", &"OBJECTIVES_INFECT_SCORE" );
    }

    maps\mp\_utility::setobjectivehinttext( "allies", &"OBJECTIVES_INFECT_HINT" );
    maps\mp\_utility::setobjectivehinttext( "axis", &"OBJECTIVES_INFECT_HINT" );
    initspawns();
    var_0[0] = level.gametype;
    maps\mp\gametypes\_gameobjects::main( var_0 );
    level.quickmessagetoall = 1;
    level.blockweapondrops = 1;
    level.infect_allowsuicide = 0;
    level.infect_chosefirstinfected = 0;
    level.infect_choosingfirstinfected = 0;
    level.infect_awardedfinalsurvivor = 0;
    level.infect_countdowninprogress = 0;
    level.infect_teamscores["axis"] = 0;
    level.infect_teamscores["allies"] = 0;
    level.infect_players = [];
    level thread onplayerconnect();
    level thread gametimer();
}

gametimer()
{
    level endon( "game_ended" );
    setdynamicdvar( "scr_infect_timelimit", 0 );

    for (;;)
    {
        level waittill( "update_game_time", var_0 );

        if ( !isdefined( var_0 ) )
            var_0 = ( maps\mp\_utility::gettimepassed() + 1500 ) / 60000 + 2;

        setdynamicdvar( "scr_infect_timelimit", var_0 );
        level thread watchhostmigration( var_0 );
    }
}

watchhostmigration( var_0 )
{
    level notify( "watchHostMigration" );
    level endon( "watchHostMigration" );
    level endon( "game_ended" );
    level waittill( "host_migration_begin" );
    setdynamicdvar( "scr_infect_timelimit", 0 );
    waittillframeend;
    setdynamicdvar( "scr_infect_timelimit", 0 );
    level waittill( "host_migration_end" );
    level notify( "update_game_time", var_0 );
}

onplayerconnect()
{
    for (;;)
    {
        level waittill( "connected", var_0 );
        var_0.gamemodefirstspawn = 1;
        var_0.gamemodejoinedatstart = 1;
        var_0.infectedrejoined = 0;

        if ( maps\mp\_utility::gameflag( "prematch_done" ) )
        {
            var_0.gamemodejoinedatstart = 0;

            if ( isdefined( level.infect_chosefirstinfected ) && level.infect_chosefirstinfected )
                var_0.survivalstarttime = gettime();
        }

        if ( isdefined( level.infect_players[var_0.name] ) )
            var_0.infectedrejoined = 1;

        var_0 thread monitorsurvivaltime();
    }
}

initspawns()
{
    level.spawnmins = ( 0, 0, 0 );
    level.spawnmaxs = ( 0, 0, 0 );
    maps\mp\gametypes\_spawnlogic::addspawnpoints( "allies", "mp_tdm_spawn" );
    maps\mp\gametypes\_spawnlogic::addspawnpoints( "axis", "mp_tdm_spawn" );
    level.mapcenter = maps\mp\gametypes\_spawnlogic::findboxcenter( level.spawnmins, level.spawnmaxs );
    setmapcenter( level.mapcenter );
}

alwaysgamemodeclass()
{
    return "gamemode";
}

getspawnpoint()
{
    if ( self.gamemodefirstspawn )
    {
        self.gamemodefirstspawn = 0;
        self.pers["class"] = "gamemode";
        self.pers["lastClass"] = "";
        self.class = self.pers["class"];
        self.lastclass = self.pers["lastClass"];
        var_0 = "allies";

        if ( self.infectedrejoined )
            var_0 = "axis";

        maps\mp\gametypes\_menus::addtoteam( var_0, 1 );
        thread monitordisconnect();
    }

    if ( level.ingraceperiod )
    {
        var_1 = maps\mp\gametypes\_spawnlogic::getspawnpointarray( "mp_tdm_spawn" );
        var_2 = maps\mp\gametypes\_spawnlogic::getspawnpoint_random( var_1 );
    }
    else
    {
        var_1 = maps\mp\gametypes\_spawnlogic::getteamspawnpoints( self.pers["team"] );
        var_2 = maps\mp\gametypes\_spawnscoring::getspawnpoint_nearteam( var_1 );
    }

    return var_2;
}

onspawnplayer()
{
    self.teamchangedthisframe = undefined;
    self.infect_spawnpos = self.origin;
    updateteamscores();

    if ( !level.infect_choosingfirstinfected )
    {
        level.infect_choosingfirstinfected = 1;
        level thread choosefirstinfected();
    }

    if ( self.infectedrejoined )
    {
        if ( !level.infect_allowsuicide )
        {
            level notify( "infect_stopCountdown" );
            level.infect_chosefirstinfected = 1;
            level.infect_allowsuicide = 1;

            foreach ( var_1 in level.players )
            {
                if ( isdefined( var_1.infect_isbeingchosen ) )
                    var_1.infect_isbeingchosen = undefined;
            }
        }

        foreach ( var_1 in level.players )
        {
            if ( isdefined( var_1.isinitialinfected ) )
                var_1 thread setinitialtonormalinfected();
        }

        if ( level.infect_teamscores["axis"] == 1 )
            self.isinitialinfected = 1;

        initsurvivaltime( 1 );
    }

    if ( isdefined( self.isinitialinfected ) )
    {
        self.pers["gamemodeLoadout"] = level.infect_loadouts["axis_initial"];
        self.infected_class = "axis_initial";
    }
    else
    {
        self.pers["gamemodeLoadout"] = level.infect_loadouts[self.pers["team"]];
        self.infected_class = self.pers["team"];
    }

    thread onspawnfinished();
    level notify( "spawned_player" );
}

spawnwithplayersecondary()
{
    var_0 = self getweaponslistprimaries();
    var_1 = self getcurrentprimaryweapon();

    if ( var_0.size > 1 )
    {
        if ( var_1 == "iw6_knifeonly_mp" )
        {
            foreach ( var_3 in var_0 )
            {
                if ( var_3 != var_1 )
                    self setspawnweapon( var_3 );
            }
        }
    }
}

setdefaultammoclip( var_0 )
{
    var_1 = 1;

    if ( isdefined( self.isinitialinfected ) )
    {
        if ( maps\mp\_utility::isusingdefaultclass( var_0, 1 ) )
            var_1 = 0;
    }
    else if ( maps\mp\_utility::isusingdefaultclass( var_0, 0 ) )
        var_1 = 0;

    return var_1;
}

onspawnfinished()
{
    self endon( "death" );
    self endon( "disconnect" );
    self waittill( "giveLoadout" );
    self.last_infected_class = self.infected_class;

    if ( self.pers["team"] == "allies" )
    {
        spawnwithplayersecondary();

        if ( setdefaultammoclip( "allies" ) )
        {
            self setweaponammoclip( "proximity_explosive_mp", 1 );
            self setweaponammoclip( "concussion_grenade_mp", 1 );
        }
    }
    else if ( self.pers["team"] == "axis" )
    {
        thread setinfectedmsg();
        self setmovespeedscale( 1.2 );

        if ( setdefaultammoclip( "axis" ) )
            self setweaponammoclip( "throwingknife_mp", 1 );

        thread setinfectedmodels();
    }

    self.faux_spawn_infected = undefined;
}

setinfectedmodels()
{
    self setmodel( "mp_body_infected_a" );

    if ( isdefined( self.headmodel ) )
    {
        self detach( self.headmodel, "" );
        self.headmodel = undefined;
    }

    self attach( "head_mp_infected", "", 1 );
    self.headmodel = "head_mp_infected";
    self setviewmodel( "viewhands_gs_hostage" );
    self setclothtype( "cloth" );
}

setinfectedmsg()
{
    if ( isdefined( self.isinitialinfected ) )
    {
        if ( !isdefined( self.showninfected ) || !self.showninfected )
        {
            thread maps\mp\gametypes\_rank::xpeventpopup( "first_infected" );
            self.showninfected = 1;
        }
    }
    else if ( isdefined( self.changingtoregularinfected ) )
    {
        self.changingtoregularinfected = undefined;

        if ( isdefined( self.changingtoregularinfectedbykill ) )
        {
            self.changingtoregularinfectedbykill = undefined;
            thread maps\mp\gametypes\_rank::xpeventpopup( "firstblood" );
            maps\mp\gametypes\_gamescore::giveplayerscore( "first_infected", self );
            thread maps\mp\gametypes\_rank::giverankxp( "first_infected" );
        }
    }
    else if ( !isdefined( self.showninfected ) || !self.showninfected )
    {
        thread maps\mp\gametypes\_rank::xpeventpopup( "got_infected" );
        self.showninfected = 1;
    }
}

choosefirstinfected()
{
    level endon( "game_ended" );
    level endon( "infect_stopCountdown" );
    level.infect_allowsuicide = 0;
    maps\mp\_utility::gameflagwait( "prematch_done" );
    level.infect_countdowninprogress = 1;
    maps\mp\gametypes\_hostmigration::waitlongdurationwithhostmigrationpause( 1.0 );
    setomnvar( "ui_match_start_text", "first_infected_in" );
    var_0 = 15;

    while ( var_0 > 0 && !level.gameended )
    {
        setomnvar( "ui_match_start_countdown", var_0 );
        var_0--;
        maps\mp\gametypes\_hostmigration::waitlongdurationwithhostmigrationpause( 1.0 );
    }

    setomnvar( "ui_match_start_countdown", 0 );
    level.infect_countdowninprogress = 0;
    var_1 = [];

    foreach ( var_3 in level.players )
    {
        if ( maps\mp\_utility::matchmakinggame() && level.players.size > 1 && var_3 ishost() )
            continue;

        if ( var_3.team == "spectator" )
            continue;

        if ( !var_3.hasspawned )
            continue;

        var_1[var_1.size] = var_3;
    }

    var_5 = var_1[randomint( var_1.size )];
    var_5 setfirstinfected( 1 );

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

        var_3.survivalstarttime = gettime();
    }
}

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

    if ( var_0 )
        self.infect_isbeingchosen = 1;

    while ( !maps\mp\_utility::isreallyalive( self ) || maps\mp\_utility::isusingremote() )
        wait 0.05;

    if ( isdefined( self.iscarrying ) && self.iscarrying == 1 )
    {
        self notify( "force_cancel_placement" );
        wait 0.05;
    }

    while ( self ismantling() )
        wait 0.05;

    while ( !self isonground() && !self isonladder() )
        wait 0.05;

    if ( maps\mp\_utility::isjuggernaut() )
    {
        self notify( "lost_juggernaut" );
        wait 0.05;
    }

    while ( !isalive( self ) )
        common_scripts\utility::waitframe();

    if ( var_0 )
    {
        maps\mp\gametypes\_menus::addtoteam( "axis", undefined, 1 );
        thread monitordisconnect();
        level.infect_chosefirstinfected = 1;
        self.infect_isbeingchosen = undefined;
        level notify( "update_game_time" );
        updateteamscores();
        level.infect_allowsuicide = 1;
    }

    self.isinitialinfected = 1;
    self.pers["gamemodeLoadout"] = level.infect_loadouts["axis_initial"];

    if ( isdefined( self.setspawnpoint ) )
        maps\mp\perks\_perkfunctions::deleteti( self.setspawnpoint );

    var_1 = spawn( "script_model", self.origin );
    var_1.angles = self.angles;
    var_1.playerspawnpos = self.origin;
    var_1.notti = 1;
    self.setspawnpoint = var_1;
    self notify( "faux_spawn" );
    self.faux_spawn_stance = self getstance();
    self.faux_spawn_infected = 1;
    thread maps\mp\gametypes\_playerlogic::spawnplayer( 1 );

    if ( var_0 )
        level.infect_players[self.name] = 1;

    foreach ( var_3 in level.players )
        var_3 thread maps\mp\gametypes\_hud_message::splashnotify( "first_infected" );

    level thread maps\mp\_utility::teamplayercardsplash( "callout_first_infected", self );
    maps\mp\_utility::playsoundonplayers( "mp_enemy_obj_captured" );
    initsurvivaltime( 1 );
}

setinitialtonormalinfected( var_0, var_1 )
{
    level endon( "game_ended" );
    self.isinitialinfected = undefined;
    self.changingtoregularinfected = 1;

    if ( isdefined( var_0 ) )
        self.changingtoregularinfectedbykill = 1;

    while ( !maps\mp\_utility::isreallyalive( self ) )
        wait 0.05;

    if ( isdefined( self.iscarrying ) && self.iscarrying == 1 )
    {
        self notify( "force_cancel_placement" );
        wait 0.05;
    }

    while ( self ismantling() )
        wait 0.05;

    while ( !self isonground() )
        wait 0.05;

    if ( maps\mp\_utility::isjuggernaut() )
    {
        self notify( "lost_juggernaut" );
        wait 0.05;
    }

    if ( isdefined( var_1 ) && var_1 == "MOD_MELEE" )
        wait 1.2;

    while ( !maps\mp\_utility::isreallyalive( self ) )
        wait 0.05;

    self.pers["gamemodeLoadout"] = level.infect_loadouts["axis"];

    if ( isdefined( self.setspawnpoint ) )
        maps\mp\perks\_perkfunctions::deleteti( self.setspawnpoint );

    var_2 = spawn( "script_model", self.origin );
    var_2.angles = self.angles;
    var_2.playerspawnpos = self.origin;
    var_2.notti = 1;
    self.setspawnpoint = var_2;
    self notify( "faux_spawn" );
    self.faux_spawn_stance = self getstance();
    self.faux_spawn_infected = 1;
    thread maps\mp\gametypes\_playerlogic::spawnplayer( 1 );
}

onplayerkilled( var_0, var_1, var_2, var_3, var_4, var_5, var_6, var_7, var_8, var_9 )
{
    var_10 = 0;
    var_11 = 0;

    if ( self.team == "allies" && isdefined( var_1 ) )
    {
        if ( isplayer( var_1 ) && var_1 != self )
            var_10 = 1;
        else if ( level.infect_allowsuicide && ( var_1 == self || !isplayer( var_1 ) ) )
        {
            var_10 = 1;
            var_11 = 1;
        }
    }

    if ( isplayer( var_1 ) && var_1.team == "allies" && var_1 != self )
    {
        var_1.pers["killsAsSurvivor"]++;
        var_1 maps\mp\gametypes\_persistence::statsetchild( "round", "killsAsSurvivor", var_1.pers["killsAsSurvivor"] );
    }
    else if ( isplayer( var_1 ) && var_1.team == "axis" && var_1 != self )
    {
        var_1.pers["killsAsInfected"]++;
        var_1 maps\mp\gametypes\_persistence::statsetchild( "round", "killsAsInfected", var_1.pers["killsAsInfected"] );
    }

    if ( var_10 )
    {
        self.teamchangedthisframe = 1;
        maps\mp\gametypes\_menus::addtoteam( "axis" );
        thread monitordisconnect();
        level notify( "update_game_time" );
        updateteamscores();
        level.infect_players[self.name] = 1;

        if ( var_11 )
        {
            if ( level.infect_teamscores["axis"] > 1 )
            {
                foreach ( var_13 in level.players )
                {
                    if ( isdefined( var_13.isinitialinfected ) )
                        var_13 thread setinitialtonormalinfected();
                }
            }
        }
        else if ( isdefined( var_1.isinitialinfected ) )
            var_1 thread setinitialtonormalinfected( 1, var_3 );
        else
        {
            var_1 thread maps\mp\gametypes\_rank::xpeventpopup( "infected_survivor" );
            maps\mp\gametypes\_gamescore::giveplayerscore( "infected_survivor", var_1, self, 1 );
            var_1 thread maps\mp\gametypes\_rank::giverankxp( "infected_survivor" );
        }

        if ( level.infect_teamscores["allies"] > 1 )
        {
            maps\mp\_utility::playsoundonplayers( "mp_enemy_obj_captured", "allies" );
            maps\mp\_utility::playsoundonplayers( "mp_war_objective_taken", "axis" );
            thread maps\mp\_utility::teamplayercardsplash( "callout_got_infected", self, "allies" );

            if ( !var_11 )
            {
                thread maps\mp\_utility::teamplayercardsplash( "callout_infected", var_1, "axis" );

                foreach ( var_13 in level.players )
                {
                    if ( !maps\mp\_utility::isreallyalive( var_13 ) || self.sessionstate == "spectator" )
                        continue;

                    if ( var_13.team == "allies" && var_13 != self && distance( var_13.infect_spawnpos, var_13.origin ) > 32 )
                    {
                        var_13 thread maps\mp\gametypes\_rank::xpeventpopup( "survivor" );
                        maps\mp\gametypes\_gamescore::giveplayerscore( "survivor", var_13, undefined, 1 );
                        var_13 thread maps\mp\gametypes\_rank::giverankxp( "survivor" );
                    }
                }
            }
        }
        else if ( level.infect_teamscores["allies"] == 1 )
            onfinalsurvivor();
        else if ( level.infect_teamscores["allies"] == 0 )
            onsurvivorseliminated();

        setsurvivaltime( 1 );
    }
}

onfinalsurvivor()
{
    maps\mp\_utility::playsoundonplayers( "mp_obj_captured" );

    foreach ( var_1 in level.players )
    {
        if ( !isdefined( var_1 ) )
            continue;

        if ( var_1.team == "allies" )
        {
            var_1 thread maps\mp\gametypes\_rank::xpeventpopup( "final_survivor" );

            if ( !level.infect_awardedfinalsurvivor )
            {
                if ( var_1.gamemodejoinedatstart && isdefined( var_1.infect_spawnpos ) && distance( var_1.infect_spawnpos, var_1.origin ) > 32 )
                {
                    maps\mp\gametypes\_gamescore::giveplayerscore( "final_survivor", var_1, undefined, 1 );
                    var_1 thread maps\mp\gametypes\_rank::giverankxp( "final_survivor" );
                }

                level.infect_awardedfinalsurvivor = 1;
            }

            thread maps\mp\_utility::teamplayercardsplash( "callout_final_survivor", var_1 );

            if ( !var_1 maps\mp\_utility::isjuggernaut() )
                level thread finalsurvivoruav( var_1 );

            break;
        }
    }
}

finalsurvivoruav( var_0 )
{
    level endon( "game_ended" );
    var_0 endon( "disconnect" );
    var_0 endon( "eliminated" );
    level endon( "infect_lateJoiner" );
    level thread enduavonlatejoiner( var_0 );
    var_1 = 0;
    level.radarmode["axis"] = "normal_radar";

    foreach ( var_3 in level.players )
    {
        if ( var_3.team == "axis" )
            var_3.radarmode = "normal_radar";
    }

    setteamradarstrength( "axis", 1 );

    for (;;)
    {
        var_5 = var_0.origin;
        wait 4;

        if ( var_1 )
        {
            setteamradar( "axis", 0 );
            var_1 = 0;
        }

        wait 6;

        if ( distance( var_5, var_0.origin ) < 200 )
        {
            setteamradar( "axis", 1 );
            var_1 = 1;

            foreach ( var_3 in level.players )
                var_3 playlocalsound( "recondrone_tag" );
        }
    }
}

enduavonlatejoiner( var_0 )
{
    level endon( "game_ended" );
    var_0 endon( "disconnect" );
    var_0 endon( "eliminated" );

    for (;;)
    {
        if ( level.infect_teamscores["allies"] > 1 )
        {
            level notify( "infect_lateJoiner" );
            wait 0.05;
            setteamradar( "axis", 0 );
            break;
        }

        wait 0.05;
    }
}

monitordisconnect()
{
    level endon( "game_ended" );
    self endon( "eliminated" );
    self notify( "infect_monitor_disconnect" );
    self endon( "infect_monitor_disconnect" );
    var_0 = self.team;

    if ( !isdefined( var_0 ) && isdefined( self.bot_team ) )
        var_0 = self.bot_team;

    self waittill( "disconnect" );
    updateteamscores();

    if ( isdefined( self.infect_isbeingchosen ) || level.infect_chosefirstinfected )
    {
        if ( level.infect_teamscores["axis"] && level.infect_teamscores["allies"] )
        {
            if ( var_0 == "allies" && level.infect_teamscores["allies"] == 1 )
                onfinalsurvivor();
            else if ( var_0 == "axis" && level.infect_teamscores["axis"] == 1 )
            {
                foreach ( var_2 in level.players )
                {
                    if ( var_2 != self && var_2.team == "axis" )
                        var_2 setfirstinfected( 0 );
                }
            }
        }
        else if ( level.infect_teamscores["allies"] == 0 )
            onsurvivorseliminated();
        else if ( level.infect_teamscores["axis"] == 0 )
        {
            if ( level.infect_teamscores["allies"] == 1 )
            {
                level.finalkillcam_winner = "allies";
                level thread maps\mp\gametypes\_gamelogic::endgame( "allies", game["end_reason"]["axis_eliminated"] );
            }
            else if ( level.infect_teamscores["allies"] > 1 )
            {
                level.infect_chosefirstinfected = 0;
                level thread choosefirstinfected();
            }
        }
    }
    else if ( level.infect_countdowninprogress && level.infect_teamscores["allies"] == 0 && level.infect_teamscores["axis"] == 0 )
    {
        level notify( "infect_stopCountdown" );
        level.infect_choosingfirstinfected = 0;
        setomnvar( "ui_match_start_countdown", 0 );
    }

    self.isinitialinfected = undefined;
}

ondeadevent( var_0 )
{
    return;
}

ontimelimit()
{
    level.finalkillcam_winner = "allies";
    level thread maps\mp\gametypes\_gamelogic::endgame( "allies", game["end_reason"]["time_limit_reached"] );
}

onsurvivorseliminated()
{
    level.finalkillcam_winner = "axis";
    level thread maps\mp\gametypes\_gamelogic::endgame( "axis", game["end_reason"]["allies_eliminated"] );
}

getteamsize( var_0 )
{
    var_1 = 0;

    foreach ( var_3 in level.players )
    {
        if ( var_3.sessionstate == "spectator" && !var_3.spectatekillcam )
            continue;

        if ( var_3.team == var_0 )
            var_1++;
    }

    return var_1;
}

updateteamscores()
{
    level.infect_teamscores["allies"] = getteamsize( "allies" );
    game["teamScores"]["allies"] = level.infect_teamscores["allies"];
    setteamscore( "allies", level.infect_teamscores["allies"] );
    level.infect_teamscores["axis"] = getteamsize( "axis" );
    game["teamScores"]["axis"] = level.infect_teamscores["axis"];
    setteamscore( "axis", level.infect_teamscores["axis"] );
}

setspecialloadouts()
{
    if ( maps\mp\_utility::isusingdefaultclass( "allies", 0 ) )
        level.infect_loadouts["allies"] = maps\mp\_utility::getmatchrulesspecialclass( "allies", 0 );
    else
    {
        level.infect_loadouts["allies"]["loadoutPrimary"] = "iw6_maul";
        level.infect_loadouts["allies"]["loadoutPrimaryAttachment"] = "none";
        level.infect_loadouts["allies"]["loadoutPrimaryAttachment2"] = "none";
        level.infect_loadouts["allies"]["loadoutPrimaryBuff"] = "specialty_longerrange";
        level.infect_loadouts["allies"]["loadoutPrimaryCamo"] = "none";
        level.infect_loadouts["allies"]["loadoutPrimaryReticle"] = "none";
        level.infect_loadouts["allies"]["loadoutSecondary"] = "none";
        level.infect_loadouts["allies"]["loadoutSecondaryAttachment"] = "none";
        level.infect_loadouts["allies"]["loadoutSecondaryAttachment2"] = "none";
        level.infect_loadouts["allies"]["loadoutSecondaryBuff"] = "specialty_null";
        level.infect_loadouts["allies"]["loadoutSecondaryCamo"] = "none";
        level.infect_loadouts["allies"]["loadoutSecondaryReticle"] = "none";
        level.infect_loadouts["allies"]["loadoutEquipment"] = "proximity_explosive_mp";
        level.infect_loadouts["allies"]["loadoutOffhand"] = "concussion_grenade_mp";
        level.infect_loadouts["allies"]["loadoutStreakType"] = "assault";
        level.infect_loadouts["allies"]["loadoutKillstreak1"] = "none";
        level.infect_loadouts["allies"]["loadoutKillstreak2"] = "none";
        level.infect_loadouts["allies"]["loadoutKillstreak3"] = "none";
        level.infect_loadouts["allies"]["loadoutJuggernaut"] = 0;
        level.infect_loadouts["allies"]["loadoutPerks"] = [ "specialty_scavenger", "specialty_quickdraw", "specialty_quieter" ];
    }

    if ( maps\mp\_utility::isusingdefaultclass( "axis", 1 ) )
    {
        level.infect_loadouts["axis_initial"] = maps\mp\_utility::getmatchrulesspecialclass( "axis", 1 );
        level.infect_loadouts["axis_initial"]["loadoutStreakType"] = "assault";
        level.infect_loadouts["axis_initial"]["loadoutKillstreak1"] = "none";
        level.infect_loadouts["axis_initial"]["loadoutKillstreak2"] = "none";
        level.infect_loadouts["axis_initial"]["loadoutKillstreak3"] = "none";
    }
    else
    {
        level.infect_loadouts["axis_initial"]["loadoutPrimary"] = "iw6_m9a1";
        level.infect_loadouts["axis_initial"]["loadoutPrimaryAttachment"] = "none";
        level.infect_loadouts["axis_initial"]["loadoutPrimaryAttachment2"] = "none";
        level.infect_loadouts["axis_initial"]["loadoutPrimaryBuff"] = "specialty_bling";
        level.infect_loadouts["axis_initial"]["loadoutPrimaryCamo"] = "none";
        level.infect_loadouts["axis_initial"]["loadoutPrimaryReticle"] = "none";
        level.infect_loadouts["axis_initial"]["loadoutSecondary"] = "none";
        level.infect_loadouts["axis_initial"]["loadoutSecondaryAttachment"] = "none";
        level.infect_loadouts["axis_initial"]["loadoutSecondaryAttachment2"] = "none";
        level.infect_loadouts["axis_initial"]["loadoutSecondaryBuff"] = "specialty_null";
        level.infect_loadouts["axis_initial"]["loadoutSecondaryCamo"] = "none";
        level.infect_loadouts["axis_initial"]["loadoutSecondaryReticle"] = "none";
        level.infect_loadouts["axis_initial"]["loadoutEquipment"] = "throwingknife_mp";
        level.infect_loadouts["axis_initial"]["loadoutOffhand"] = "specialty_tacticalinsertion";
        level.infect_loadouts["axis_initial"]["loadoutStreakType"] = "assault";
        level.infect_loadouts["axis_initial"]["loadoutKillstreak1"] = "none";
        level.infect_loadouts["axis_initial"]["loadoutKillstreak2"] = "none";
        level.infect_loadouts["axis_initial"]["loadoutKillstreak3"] = "none";
        level.infect_loadouts["axis_initial"]["loadoutJuggernaut"] = 0;
        level.infect_loadouts["axis_initial"]["loadoutPerks"] = [ "specialty_longersprint", "specialty_quickdraw", "specialty_quieter", "specialty_falldamage", "specialty_bulletaccuracy" ];
    }

    if ( maps\mp\_utility::isusingdefaultclass( "axis", 0 ) )
    {
        level.infect_loadouts["axis"] = maps\mp\_utility::getmatchrulesspecialclass( "axis", 0 );
        level.infect_loadouts["axis"]["loadoutStreakType"] = "assault";
        level.infect_loadouts["axis"]["loadoutKillstreak1"] = "none";
        level.infect_loadouts["axis"]["loadoutKillstreak2"] = "none";
        level.infect_loadouts["axis"]["loadoutKillstreak3"] = "none";
    }
    else
    {
        level.infect_loadouts["axis"]["loadoutPrimary"] = "iw6_knifeonly";
        level.infect_loadouts["axis"]["loadoutPrimaryAttachment"] = "none";
        level.infect_loadouts["axis"]["loadoutPrimaryAttachment2"] = "none";
        level.infect_loadouts["axis"]["loadoutPrimaryBuff"] = "specialty_null";
        level.infect_loadouts["axis"]["loadoutPrimaryCamo"] = "none";
        level.infect_loadouts["axis"]["loadoutPrimaryReticle"] = "none";
        level.infect_loadouts["axis"]["loadoutSecondary"] = "none";
        level.infect_loadouts["axis"]["loadoutSecondaryAttachment"] = "none";
        level.infect_loadouts["axis"]["loadoutSecondaryAttachment2"] = "none";
        level.infect_loadouts["axis"]["loadoutSecondaryBuff"] = "specialty_null";
        level.infect_loadouts["axis"]["loadoutSecondaryCamo"] = "none";
        level.infect_loadouts["axis"]["loadoutSecondaryReticle"] = "none";
        level.infect_loadouts["axis"]["loadoutEquipment"] = "throwingknife_mp";
        level.infect_loadouts["axis"]["loadoutOffhand"] = "specialty_tacticalinsertion";
        level.infect_loadouts["axis"]["loadoutStreakType"] = "assault";
        level.infect_loadouts["axis"]["loadoutKillstreak1"] = "none";
        level.infect_loadouts["axis"]["loadoutKillstreak2"] = "none";
        level.infect_loadouts["axis"]["loadoutKillstreak3"] = "none";
        level.infect_loadouts["axis"]["loadoutJuggernaut"] = 0;
        level.infect_loadouts["axis"]["loadoutPerks"] = [ "specialty_longersprint", "specialty_quickdraw", "specialty_quieter", "specialty_falldamage" ];
    }
}

monitorsurvivaltime()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "infected" );
    level endon( "game_ended" );

    for (;;)
    {
        if ( !level.infect_chosefirstinfected || !isdefined( self.survivalstarttime ) || !isalive( self ) )
        {
            wait 0.05;
            continue;
        }

        setsurvivaltime( 0 );
        wait 1.0;
    }
}

initsurvivaltime( var_0 )
{
    maps\mp\_utility::setextrascore0( 0 );

    if ( isdefined( var_0 ) && var_0 )
    {
        self notify( "infected" );
        self.extrascore1 = 1;
    }
}

setsurvivaltime( var_0 )
{
    if ( !isdefined( self.survivalstarttime ) )
        self.survivalstarttime = self.spawntime;

    var_1 = int( ( gettime() - self.survivalstarttime ) / 1000 );

    if ( var_1 > 999 )
        var_1 = 999;

    maps\mp\_utility::setextrascore0( var_1 );

    if ( isdefined( var_0 ) && var_0 )
    {
        self notify( "infected" );
        self.extrascore1 = 1;
    }
}
